Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
feat(design & ui): enhance message handling and UI (#6606)
白熱8eda03ab3443
diff --git a/packages/design/src/components/message/Message.stories.tsx b/packages/design/src/components/message/Message.stories.tsxindex fffa1e8473..cecfcedc76 100644--- a/packages/design/src/components/message/Message.stories.tsx+++ b/packages/design/src/components/message/Message.stories.tsx@@ -15,14 +15,16 @@*/import type { Meta } from '@storybook/react';-+import type { IMessageProps } from './Message';+import { useEffect } from 'react';import { Button } from '../button/Button';-import { message, Messager, MessageType } from './Message';+import { message, Messager, MessageType, removeMessage } from './Message';-const meta: Meta = {+const meta: Meta<typeof Messager> = {title: 'Components / Message',+ component: Messager,parameters: {- layout: 'centered',+ layout: 'fullscreen',},tags: ['autodocs'],args: {},@@ -30,35 +32,224 @@ const meta: Meta = {export default meta;-export const Playground = {+const lightPreset: IMessageProps[] = [+ {+ id: 'story-message-light-success',+ type: MessageType.Success,+ content: 'Workbook synchronized and saved to cloud.',+ duration: Infinity,+ },+ {+ id: 'story-message-light-info',+ type: MessageType.Info,+ content: '12 collaborators are editing this sheet in real time.',+ duration: Infinity,+ },+ {+ id: 'story-message-light-warning',+ type: MessageType.Warning,+ content: 'Formula references contain 3 circular dependencies.',+ duration: Infinity,+ },+ {+ id: 'story-message-light-error',+ type: MessageType.Error,+ content: 'Auto-save failed. Retrying in 15 seconds.',+ duration: Infinity,+ },+];++const darkPreset: IMessageProps[] = [+ {+ id: 'story-message-dark-success',+ type: MessageType.Success,+ content: 'Chart theme switched to Night Analytics.',+ duration: Infinity,+ },+ {+ id: 'story-message-dark-info',+ type: MessageType.Info,+ content: 'Background sync is active for 8 connected data sources.',+ duration: Infinity,+ },+ {+ id: 'story-message-dark-warning',+ type: MessageType.Warning,+ content: 'Large pivot table may impact performance on older devices.',+ duration: Infinity,+ },+ {+ id: 'story-message-dark-loading',+ type: MessageType.Loading,+ content: 'Rebuilding dependency graph and recalculating formulas...',+ duration: Infinity,+ },+];++const edgePreset: IMessageProps[] = [+ {+ id: 'story-message-edge-long',+ type: MessageType.Info,+ content: 'Publishing in progress. We are validating named ranges, chart bindings, permission rules, and comment threads before exposing this workbook to external viewers.',+ duration: Infinity,+ },+ {+ id: 'story-message-edge-loading',+ type: MessageType.Loading,+ content: 'Importing 24,392 rows from data warehouse...',+ duration: Infinity,+ },+];++function MessageStoryShell({ title, description, children }: { title: string; description: string; children?: React.ReactNode }) {+ return (+ <section+ className={`+ univer-relative univer-min-h-[520px] univer-overflow-hidden univer-bg-gradient-to-br univer-from-slate-100+ univer-via-cyan-50 univer-to-blue-100 univer-p-8+ `}+ >+ <div+ className={`+ univer-border-white/70 univer-bg-white/80 univer-mx-auto univer-max-w-5xl univer-rounded-3xl+ univer-border univer-border-solid univer-p-8 univer-shadow-[0_30px_60px_-35px_rgba(15,23,42,0.55)]+ univer-backdrop-blur-xl+ `}+ >+ <h2+ className="+ univer-m-0 univer-font-sans univer-text-2xl univer-font-semibold univer-tracking-tight+ univer-text-slate-800+ "+ >+ {title}+ </h2>+ <p+ className="+ univer-mb-0 univer-mt-2 univer-max-w-2xl univer-font-sans univer-text-sm univer-leading-6+ univer-text-slate-600+ "+ >+ {description}+ </p>+ <div className="univer-mt-6">{children}</div>+ </div>+ </section>+ );+}++function PresetMessages({ theme, preset }: { theme: 'light' | 'dark'; preset: IMessageProps[] }) {+ useEffect(() => {+ preset.forEach((item) => item.id && removeMessage(item.id));+ preset.forEach((item) => message(item));++ return () => {+ preset.forEach((item) => item.id && removeMessage(item.id));+ };+ }, [preset]);++ return <Messager theme={theme} />;+}++export const InteractivePlayground = {render: () => {- function handleOpen(type: MessageType) {- message({- type,- content: 'Hello world!',- });- }+ const handleOpen = (type: MessageType, content: string, duration?: number) => {+ message({ type, content, duration });+ };return (- <section className="univer-space-x-2">- <Button variant="primary" onClick={() => handleOpen(MessageType.Success)}>- success- </Button>- <Button variant="primary" onClick={() => handleOpen(MessageType.Info)}>- info / default- </Button>- <Button variant="primary" onClick={() => handleOpen(MessageType.Warning)}>- warning- </Button>- <Button variant="primary" onClick={() => handleOpen(MessageType.Error)}>- error- </Button>- <Button variant="primary" onClick={() => handleOpen(MessageType.Loading)}>- loading- </Button>-+ <MessageStoryShell+ title="Message Interaction Lab"+ description="A modern toast playground for manual QA. Includes quick triggers, long-content coverage, and persistent loading state checks."+ >+ <div className="univer-flex univer-flex-wrap univer-gap-3">+ <Button variant="primary" onClick={() => handleOpen(MessageType.Success, 'Dataset exported as CSV.')}>+ Trigger Success+ </Button>+ <Button onClick={() => handleOpen(MessageType.Info, '3 filters applied to the current view.')}>+ Trigger Info+ </Button>+ <Button onClick={() => handleOpen(MessageType.Warning, 'Some values were rounded during import.')}>+ Trigger Warning+ </Button>+ <Button variant="danger" onClick={() => handleOpen(MessageType.Error, 'Permission denied for this operation.')}>+ Trigger Error+ </Button>+ <Button onClick={() => handleOpen(MessageType.Loading, 'Syncing workbook metadata...', Infinity)}>+ Trigger Loading+ </Button>+ <Button onClick={() => removeMessage()}>Clear All</Button>+ </div>+ <div+ className="+ univer-mt-4 univer-grid univer-gap-3+ md:univer-grid-cols-2+ "+ >+ <div className="univer-rounded-2xl univer-bg-slate-100/80 univer-p-4">+ <p+ className="+ univer-m-0 univer-text-xs univer-font-medium univer-uppercase univer-tracking-wide+ univer-text-slate-500+ "+ >+ Visual checks+ </p>+ <p className="univer-mb-0 univer-mt-2 univer-text-sm univer-text-slate-700">+ Check stacking order, icon color contrast, and long-text wrapping in both compact and dense bursts.+ </p>+ </div>+ <div className="univer-rounded-2xl univer-bg-sky-100/70 univer-p-4">+ <p+ className="+ univer-m-0 univer-text-xs univer-font-medium univer-uppercase univer-tracking-wide+ univer-text-sky-700+ "+ >+ Interaction checks+ </p>+ <p className="univer-mb-0 univer-mt-2 univer-text-sm univer-text-sky-900">+ Verify timed dismiss, persistent loading behavior, and explicit `removeMessage()` clearing.+ </p>+ </div>+ </div><Messager />- </section>+ </MessageStoryShell>);},};++export const VisualRegressionLight = {+ render: () => (+ <MessageStoryShell+ title="Message Visual Baseline - Light"+ description="Deterministic snapshot with four toast types, fixed content, and persistent duration for stable visual diffing."+ >+ <PresetMessages theme="light" preset={lightPreset} />+ </MessageStoryShell>+ ),+};++export const VisualRegressionDark = {+ render: () => (+ <MessageStoryShell+ title="Message Visual Baseline - Dark"+ description="Dark theme parity validation for icon tones, elevation, border clarity, and text readability."+ >+ <div className="univer-rounded-3xl univer-bg-slate-900/90 univer-p-6">+ <PresetMessages theme="dark" preset={darkPreset} />+ </div>+ </MessageStoryShell>+ ),+};++export const LongContentAndLoading = {+ render: () => (+ <MessageStoryShell+ title="Message Edge Cases"+ description="Regression scene for long-copy wrapping, persistent loading rhythm, and overlap spacing under mixed priority messages."+ >+ <PresetMessages theme="light" preset={edgePreset} />+ </MessageStoryShell>+ ),+};diff --git a/packages/design/src/components/message/Message.tsx b/packages/design/src/components/message/Message.tsxindex 6db00a38fe..34dd79b8a9 100644--- a/packages/design/src/components/message/Message.tsx+++ b/packages/design/src/components/message/Message.tsx@@ -14,11 +14,10 @@* limitations under the License.*/+import type { ComponentProps, ReactNode } from 'react';import { ErrorIcon, InfoIcon, LoadingMultiIcon, SuccessIcon, WarningIcon } from '@univerjs/icons';-import { useEffect, useMemo, useState } from 'react';-import { createPortal } from 'react-dom';+import { Toaster as Sonner, toast } from 'sonner';import { clsx } from '../../helper/clsx';-import { isBrowser } from '../../helper/is-browser';export enum MessageType {Success = 'success',@@ -36,133 +35,140 @@ export interface IMessageProps {onClose?: () => void;}-const iconMap = {+export type IMessagerProps = Omit<ComponentProps<typeof Sonner>, 'id' | 'position' | 'visibleToasts' | 'toastOptions'>;++const MESSAGE_TOASTER_ID = 'univer-message-toaster';+const DEFAULT_MESSAGE_DURATION = 3000;+const activeMessageIds = new Set<string>();+const loadingIcon = <LoadingMultiIcon className="univer-animate-spin univer-text-violet-500" />;++let messageCount = 0;++const iconMap: Record<MessageType, ReactNode> = {[MessageType.Success]: <SuccessIcon className="univer-text-green-500" />,[MessageType.Info]: (<InfoIconclassName={`- univer-text-indigo-600- dark:!univer-text-primary-500+ univer-text-sky-500+ dark:!univer-text-sky-400`}/>),- [MessageType.Warning]: <WarningIcon className="univer-text-yellow-400" />,+ [MessageType.Warning]: <WarningIcon className="univer-text-amber-500" />,[MessageType.Error]: <ErrorIcon className="univer-text-red-500" />,- [MessageType.Loading]: <LoadingMultiIcon className="univer-animate-spin univer-text-yellow-400" />,+ [MessageType.Loading]: loadingIcon,};-const Message = ({ content, type = MessageType.Info }: IMessageProps) => {- const icon = useMemo(() => iconMap[type], [type]);-- return (- <div- className={clsx(- `- univer-animate-in univer-fade-in univer-slide-in-from-top-4 univer-min-w-[320px] univer-max-w-[480px]- univer-rounded-xl univer-border univer-border-solid univer-border-gray-200 univer-bg-white univer-p-4- univer-font-sans univer-shadow-md univer-transition-all univer-duration-300- dark:!univer-border-gray-600 dark:!univer-bg-gray-700- `- )}- >- <div className="univer-flex univer-gap-2">- <span className="[&>svg]:univer-relative [&>svg]:univer-top-0.5 [&>svg]:univer-block">- {icon}- </span>- <p- className={`- univer-m-0 univer-text-sm univer-text-gray-500 univer-opacity-90- dark:!univer-text-gray-400- `}- >- {content}- </p>- </div>- </div>- );+const typeClassMap: Record<MessageType, string> = {+ [MessageType.Success]: '[&_[data-icon]]:univer-text-green-500',+ [MessageType.Info]: '[&_[data-icon]]:univer-text-sky-500',+ [MessageType.Warning]: '[&_[data-icon]]:univer-text-amber-500',+ [MessageType.Error]: '[&_[data-icon]]:univer-text-red-500',+ [MessageType.Loading]: '[&_[data-icon]]:univer-text-violet-500',};-interface IMessageState {- messages: IMessageProps[];-}+const resolveToastMethod = (type: MessageType) => {+ switch (type) {+ case MessageType.Success:+ return toast.success;+ case MessageType.Warning:+ return toast.warning;+ case MessageType.Error:+ return toast.error;+ case MessageType.Loading:+ return toast.loading;+ case MessageType.Info:+ default:+ return toast.info;+ }+};-let messageCount = 0;+const createMessageId = () => {+ const id = `univer-message-${messageCount}`;+ messageCount += 1;+ return id;+};-const createMessage = (() => {- let addMessage: (message: Omit<IMessageProps, 'id'>) => void = () => {};- let removeMessage: (id?: string) => void = () => {};-- const Messager = () => {- if (!isBrowser()) return null;-- const [state, setState] = useState<IMessageState>({ messages: [] });-- removeMessage = (id?: string) => {- if (!id) {- setState({- messages: [],- });- }-- setState((prev) => ({- messages: prev.messages.filter((t) => t.id !== id),- }));- };-- useEffect(() => {- const timers: number[] = [];- addMessage = (message) => {- const id = String(messageCount++);- setState((prev) => ({- messages: [...prev.messages, { ...message, id }],- }));-- if (message.duration !== Infinity) {- const timer = window.setTimeout(() => {- setState((prev) => ({- messages: prev.messages.filter((t) => t.id !== id),- }));- }, message.duration || 3000);- timers.push(timer);- }- };-- return () => {- timers.forEach((timer) => {- window.clearTimeout(timer);- });- };- }, []);-- return createPortal(- <div- className={`- univer-fixed univer-left-1/2 univer-top-4 univer-z-50 univer-flex -univer-translate-x-1/2- univer-flex-col univer-items-center univer-gap-1- `}- >- {state.messages.map((message, index) => (- <div- key={message.id}- style={{- position: 'relative',- top: `${index * 4}px`,- zIndex: 50 - index,- }}- >- <Message {...message} onClose={() => removeMessage(message.id)} />- </div>- ))}- </div>,- document.body- );+export const Messager = ({ className, ...props }: IMessagerProps) => (+ <Sonner+ id={MESSAGE_TOASTER_ID}+ position="top-center"+ visibleToasts={4}+ closeButton={false}+ expand={false}+ icons={{ loading: loadingIcon }}+ offset={{ top: 16 }}+ className={clsx(+ `+ [&_[data-sonner-toast]]:univer-bg-white/95+ dark:[&_[data-sonner-toast]]:!univer-bg-gray-800/95+ [&_[data-sonner-toast]]:univer-rounded-2xl [&_[data-sonner-toast]]:univer-border+ [&_[data-sonner-toast]]:univer-border-solid [&_[data-sonner-toast]]:univer-border-gray-200+ [&_[data-sonner-toast]]:univer-shadow-[0_16px_40px_-20px_rgba(15,23,42,0.55)]+ [&_[data-sonner-toast]]:univer-backdrop-blur-sm+ dark:[&_[data-sonner-toast]]:!univer-border-gray-600+ `,+ className+ )}+ toastOptions={{+ duration: DEFAULT_MESSAGE_DURATION,+ classNames: {+ toast: `+ univer-group univer-min-h-0 univer-min-w-[320px] univer-max-w-[520px] univer-px-3.5 univer-py-3+ univer-font-sans univer-transition-all univer-duration-300+ `,+ title: `+ univer-m-0 univer-font-sans univer-text-sm univer-font-medium univer-leading-5 univer-text-gray-700+ dark:!univer-text-gray-100+ `,+ content: 'univer-gap-2.5',+ icon: '[&>svg]:univer-block [&>svg]:univer-size-4',+ success: typeClassMap[MessageType.Success],+ info: typeClassMap[MessageType.Info],+ warning: typeClassMap[MessageType.Warning],+ error: typeClassMap[MessageType.Error],+ loading: typeClassMap[MessageType.Loading],+ },+ }}+ {...props}+ />+);++export const message = ({ content, duration, id, onClose, type = MessageType.Info }: IMessageProps) => {+ const messageId = id ?? createMessageId();+ const method = resolveToastMethod(type);+ let closed = false;++ const handleClose = () => {+ if (closed) return;++ closed = true;+ activeMessageIds.delete(messageId);+ onClose?.();};- return {- Messager,- message: (props: Omit<IMessageProps, 'id'>) => addMessage(props),- removeMessage,- };-})();+ method(content, {+ id: messageId,+ toasterId: MESSAGE_TOASTER_ID,+ duration: duration ?? DEFAULT_MESSAGE_DURATION,+ icon: type === MessageType.Loading ? undefined : iconMap[type],+ onDismiss: handleClose,+ onAutoClose: handleClose,+ });++ activeMessageIds.add(messageId);+ return messageId;+};-export const { Messager, message, removeMessage } = createMessage;+export const removeMessage = (id?: string) => {+ if (typeof id !== 'undefined') {+ toast.dismiss(id);+ activeMessageIds.delete(id);+ return;+ }++ activeMessageIds.forEach((messageId) => {+ toast.dismiss(messageId);+ });+ activeMessageIds.clear();+};diff --git a/packages/design/src/components/message/__tests__/index.spec.tsx b/packages/design/src/components/message/__tests__/index.spec.tsxindex 78984b79e0..4e78122244 100644--- a/packages/design/src/components/message/__tests__/index.spec.tsx+++ b/packages/design/src/components/message/__tests__/index.spec.tsx@@ -14,15 +14,15 @@* limitations under the License.*/-import { cleanup, fireEvent, render, screen } from '@testing-library/react';+import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';import { afterEach, describe, expect, it } from 'vitest';import { Button } from '../../button/Button';-import { message, Messager, MessageType } from '../Message';+import { message, Messager, MessageType, removeMessage } from '../Message';afterEach(cleanup);describe('Message', () => {- it('renders correctly', () => {+ it('renders correctly', async () => {const { container } = render(<><Button@@ -41,6 +41,47 @@ describe('Message', () => {fireEvent.click(container.querySelector('button')!);- expect(screen.getByText('success content')).toBeTruthy();+ await waitFor(() => {+ expect(screen.getByText('success content')).toBeTruthy();+ });+ });++ it('removes message by id', async () => {+ render(<Messager />);++ message({+ id: 'message-test-id',+ type: MessageType.Info,+ content: 'message will be removed',+ duration: Infinity,+ });++ await waitFor(() => {+ expect(screen.getByText('message will be removed')).toBeTruthy();+ });++ removeMessage('message-test-id');++ await waitFor(() => {+ expect(screen.queryByText('message will be removed')).toBeNull();+ });+ });++ it('renders loading icon for loading message', async () => {+ render(<Messager />);++ message({+ id: 'message-loading-id',+ type: MessageType.Loading,+ content: 'loading icon content',+ duration: Infinity,+ });++ await waitFor(() => {+ expect(screen.getByText('loading icon content')).toBeTruthy();+ });++ const toastNode = screen.getByText('loading icon content').closest('[data-sonner-toast]');+ expect(toastNode?.querySelector('[data-icon] svg')).toBeTruthy();});});diff --git a/packages/ui/src/components/message/MessageContainer.tsx b/packages/ui/src/components/message/MessageContainer.tsxnew file mode 100644index 0000000000..cac609befc--- /dev/null+++ b/packages/ui/src/components/message/MessageContainer.tsx@@ -0,0 +1,26 @@+/**+ * Copyright 2023-present DreamNum Co., Ltd.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++import { ThemeService } from '@univerjs/core';+import { Messager } from '@univerjs/design';+import { useDependency, useObservable } from '../../utils/di';++export function MessageContainer() {+ const themeService = useDependency(ThemeService);+ const darkMode = useObservable(themeService.darkMode$);++ return <Messager theme={darkMode ? 'dark' : 'light'} />;+}diff --git a/packages/ui/src/components/notification/Notification.stories.tsx b/packages/ui/src/components/notification/Notification.stories.tsxindex bd4ba20eeb..190223343e 100644--- a/packages/ui/src/components/notification/Notification.stories.tsx+++ b/packages/ui/src/components/notification/Notification.stories.tsx@@ -15,7 +15,8 @@*/import type { Meta } from '@storybook/react';-import { Button, Toaster } from '@univerjs/design';+import { Button, toast, Toaster } from '@univerjs/design';+import { useEffect } from 'react';import { notification, Notification } from './Notification';@@ -23,7 +24,7 @@ const meta: Meta<typeof Notification> = {title: 'Components / Notification',component: Notification,parameters: {- layout: 'centered',+ layout: 'fullscreen',},tags: ['autodocs'],args: {},@@ -31,53 +32,259 @@ const meta: Meta<typeof Notification> = {export default meta;-export const Playground = {- render: () => (- <>- <Toaster />- <Button- variant="primary"- onClick={() =>- notification.show({- title: 'Event has been created',- type: 'success',- content: 'Sunday, December 03, 2023 at 9:00 AM',- })}- >- Notification Success- </Button>- <Button- onClick={() =>- notification.show({- type: 'info',- title: 'Notification Info',- content: 'Notification content',- })}- >- Notification Info- </Button>- <Button- variant="primary"- onClick={() =>- notification.show({- type: 'warning',- title: 'Notification Warning',- content: 'Notification content',- })}- >- Notification Warning- </Button>- <Button- variant="danger"- onClick={() =>- notification.show({- type: 'error',- title: 'Notification Error',- content: 'Notification content',- })}+function NotificationStoryShell({ title, description, children }: { title: string; description: string; children?: React.ReactNode }) {+ return (+ <section+ className={`+ univer-relative univer-min-h-[560px] univer-overflow-hidden univer-bg-gradient-to-tr univer-from-slate-950+ univer-via-blue-950 univer-to-cyan-900 univer-p-8+ `}+ >+ <div+ className={`+ univer-border-white/20 univer-bg-white/10 univer-mx-auto univer-max-w-5xl univer-rounded-3xl+ univer-border univer-border-solid univer-p-8 univer-backdrop-blur-xl+ `}>- Notification Error- </Button>- </>+ <h2+ className="+ univer-m-0 univer-font-sans univer-text-2xl univer-font-semibold univer-tracking-tight+ univer-text-white+ "+ >+ {title}+ </h2>+ <p+ className="+ univer-mb-0 univer-mt-2 univer-max-w-3xl univer-font-sans univer-text-sm univer-leading-6+ univer-text-slate-200+ "+ >+ {description}+ </p>+ <div className="univer-mt-6">{children}</div>+ </div>+ </section>+ );+}++function SeedNotifications({ seed }: { seed: 'light' | 'dark' | 'positions' | 'edge' }) {+ useEffect(() => {+ toast.dismiss();++ if (seed === 'light') {+ notification.show({+ type: 'success',+ title: 'Publishing complete',+ content: 'Dashboard release v2.3 is now live for all users.',+ duration: Infinity,+ });+ notification.show({+ type: 'info',+ title: 'Background processing active',+ content: 'Processing 1,284 queued automation jobs.',+ duration: Infinity,+ });+ notification.show({+ type: 'warning',+ title: 'Quota nearly reached',+ content: 'Storage usage is at 92%. Consider archiving old files.',+ duration: Infinity,+ });+ notification.show({+ type: 'error',+ title: 'Webhook delivery failed',+ content: 'The endpoint returned HTTP 500. Automatic retry is enabled.',+ duration: Infinity,+ });+ }++ if (seed === 'dark') {+ notification.show({+ type: 'message',+ title: 'Workspace switched to Focus mode',+ content: 'Only high-priority alerts will be displayed.',+ duration: Infinity,+ });+ notification.show({+ type: 'loading',+ title: 'Syncing cross-sheet references',+ content: 'This operation can take up to 20 seconds.',+ duration: Infinity,+ });+ notification.show({+ type: 'success',+ title: 'Snapshot saved',+ content: 'A restore point was created for this workbook.',+ duration: Infinity,+ });+ }++ if (seed === 'positions') {+ notification.show({+ type: 'success',+ title: 'Top right',+ content: 'Default placement validation.',+ position: 'top-right',+ duration: Infinity,+ });+ notification.show({+ type: 'info',+ title: 'Bottom right',+ content: 'Secondary placement validation.',+ position: 'bottom-right',+ duration: Infinity,+ });+ notification.show({+ type: 'warning',+ title: 'Top left',+ content: 'Alternative placement validation.',+ position: 'top-left',+ duration: Infinity,+ });+ notification.show({+ type: 'error',+ title: 'Bottom left',+ content: 'Edge placement validation.',+ position: 'bottom-left',+ duration: Infinity,+ });+ }++ if (seed === 'edge') {+ notification.show({+ type: 'info',+ title: 'Long content wrap',+ content: 'Validation in progress for permission inheritance, named range collisions, dependency graph integrity, and localized number formats across all sheets in this workbook.',+ duration: Infinity,+ });+ notification.show({+ type: 'loading',+ title: 'Importing transaction records',+ content: 'Current stage: deduplication, schema mapping, and formula reconciliation.',+ duration: Infinity,+ });+ }++ return () => {+ toast.dismiss();+ };+ }, [seed]);++ return null;+}++export const InteractivePlayground = {+ render: () => (+ <NotificationStoryShell+ title="Notification Interaction Lab"+ description="Manual QA scene with actions for all severity levels, persistent loading, and instant cleanup for rapid regression checks."+ >+ <div className="univer-flex univer-flex-wrap univer-gap-3">+ <Button+ variant="primary"+ onClick={() =>+ notification.show({+ title: 'Event has been created',+ type: 'success',+ content: 'Sunday, December 03, 2023 at 9:00 AM',+ })}+ >+ Trigger Success+ </Button>+ <Button+ onClick={() =>+ notification.show({+ type: 'info',+ title: 'Data pipeline update',+ content: 'Ingestion completed for region APAC.',+ })}+ >+ Trigger Info+ </Button>+ <Button+ onClick={() =>+ notification.show({+ type: 'warning',+ title: 'Indexing delay detected',+ content: 'Results may be stale for up to 3 minutes.',+ })}+ >+ Trigger Warning+ </Button>+ <Button+ variant="danger"+ onClick={() =>+ notification.show({+ type: 'error',+ title: 'Notification Error',+ content: 'Unable to connect to analytics endpoint.',+ })}+ >+ Trigger Error+ </Button>+ <Button+ onClick={() =>+ notification.show({+ type: 'loading',+ title: 'Rebuilding access index',+ content: 'Please wait...',+ duration: Infinity,+ })}+ >+ Trigger Loading+ </Button>+ <Button onClick={() => toast.dismiss()}>Clear All</Button>+ </div>+ <Toaster theme="dark" />+ </NotificationStoryShell>+ ),+};++export const VisualRegressionLight = {+ render: () => (+ <NotificationStoryShell+ title="Notification Visual Baseline - Light"+ description="Deterministic scene with four notification levels, fixed copy, and persistent duration for reliable snapshot comparisons."+ >+ <Toaster theme="light" />+ <SeedNotifications seed="light" />+ </NotificationStoryShell>+ ),+};++export const VisualRegressionDark = {+ render: () => (+ <NotificationStoryShell+ title="Notification Visual Baseline - Dark"+ description="Dark surface contrast baseline covering default message, loading state, and success feedback."+ >+ <Toaster theme="dark" />+ <SeedNotifications seed="dark" />+ </NotificationStoryShell>+ ),+};++export const PlacementMatrix = {+ render: () => (+ <NotificationStoryShell+ title="Notification Placement Matrix"+ description="Regression scene that validates corner placements and overlap behavior across top and bottom viewports."+ >+ <Toaster theme="dark" />+ <SeedNotifications seed="positions" />+ </NotificationStoryShell>+ ),+};++export const LongContentAndLoading = {+ render: () => (+ <NotificationStoryShell+ title="Notification Edge Cases"+ description="Long-copy wrapping, loading cadence, and content rhythm checks under constrained viewport space."+ >+ <Toaster theme="light" />+ <SeedNotifications seed="edge" />+ </NotificationStoryShell>),};diff --git a/packages/ui/src/services/local-file/desktop-local-file.service.ts b/packages/ui/src/services/local-file/desktop-local-file.service.tsindex ae09e6782e..1f6d8227c1 100644--- a/packages/ui/src/services/local-file/desktop-local-file.service.ts+++ b/packages/ui/src/services/local-file/desktop-local-file.service.ts@@ -14,9 +14,8 @@* limitations under the License.*/-import { Disposable } from '@univerjs/core';-import type { ILocalFileService, IOpenFileOptions } from './local-file.service';+import { Disposable } from '@univerjs/core';export class DesktopLocalFileService extends Disposable implements ILocalFileService {openFile(options?: IOpenFileOptions): Promise<File[]> {diff --git a/packages/ui/src/services/message/desktop-message.service.ts b/packages/ui/src/services/message/desktop-message.service.tsindex 398f1149da..f413ecb538 100644--- a/packages/ui/src/services/message/desktop-message.service.ts+++ b/packages/ui/src/services/message/desktop-message.service.ts@@ -18,10 +18,13 @@ import type { IDisposable } from '@univerjs/core';import type { IMessageProps } from '@univerjs/design';import type { IMessageService } from './message.service';import { Disposable, Inject, Injector, toDisposable } from '@univerjs/core';-import { message, Messager, removeMessage } from '@univerjs/design';+import { message, removeMessage } from '@univerjs/design';+import { MessageContainer } from '../../components/message/MessageContainer';import { connectInjector } from '../../utils/di';import { BuiltInUIPart, IUIPartsService } from '../parts/parts.service';+let messageId = 0;+export class DesktopMessageService extends Disposable implements IMessageService {constructor(@Inject(Injector) protected readonly _injector: Injector,@@ -34,22 +37,23 @@ export class DesktopMessageService extends Disposable implements IMessageServiceprotected _initUIPart(): void {this.disposeWithMe(- this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(Messager, this._injector))+ this._uiPartsService.registerComponent(BuiltInUIPart.GLOBAL, () => connectInjector(MessageContainer, this._injector)));}override dispose(): void {+ super.dispose();removeMessage();}show(options: IMessageProps): IDisposable {- let op = options;- if (typeof options.id === 'undefined') {- op = Object.assign({}, options, { id: `message-${Date.now()}` });- }+ const id = options.id ?? `message-${Date.now()}-${messageId}`;+ messageId += 1;++ const op = Object.assign({}, options, { id });message(op);- return toDisposable(() => removeMessage(op.id));+ return toDisposable(() => removeMessage(id));}remove(id: string): void {