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
fix: correct utility classes and normalize test files (#7930)
白熱24994e4a350f
diff --git a/packages/core/src/facade/__tests__/f-base.spec.ts b/packages/core/src/facade/__tests__/f-base.spec.tsindex 06d0cc555e..520424c504 100644--- a/packages/core/src/facade/__tests__/f-base.spec.ts+++ b/packages/core/src/facade/__tests__/f-base.spec.ts@@ -14,7 +14,6 @@* limitations under the License.*/-import type { Injector as IInjector } from '@univerjs/core';import { Inject, Injector } from '@univerjs/core';import { describe, expect, it } from 'vitest';import { FBase, FBaseInitialable } from '../f-base';@@ -34,7 +33,7 @@ describe('FBase', () => {class InitSourceA {static initSource = 'a';- _initialize(injector: IInjector) {+ _initialize(injector: Injector) {const current = initLog.get(this) ?? [];current.push(`a:${Boolean(injector)}`);initLog.set(this, current);@@ -60,7 +59,7 @@ describe('FBase', () => {class AutoInitialable extends FBaseInitialable {steps: string[] = [];- constructor(@Inject(Injector) injector: IInjector) {+ constructor(@Inject(Injector) injector: Injector) {super(injector);}}@@ -68,7 +67,7 @@ describe('FBase', () => {class ManualInitialable extends FBaseInitialable {steps: string[] = [];- constructor(@Inject(Injector) injector: IInjector) {+ constructor(@Inject(Injector) injector: Injector) {super(injector);}@@ -76,7 +75,7 @@ describe('FBase', () => {this._enableManualInit();}- runManualInitializers(injector: IInjector) {+ runManualInitializers(injector: Injector) {this._runInitializers(injector);}}@@ -114,13 +113,13 @@ describe('FBase', () => {class AccessorInitialable extends FBaseInitialable {value = 'instance';- constructor(@Inject(Injector) injector: IInjector) {+ constructor(@Inject(Injector) injector: Injector) {super(injector);}}class AccessorSourceA {- _initialize(injector: IInjector) {+ _initialize(injector: Injector) {const current = initLog.get(this) ?? [];current.push(`a:${Boolean(injector)}`);initLog.set(this, current);@@ -167,7 +166,7 @@ describe('FBase', () => {class FallbackInitialable extends FBaseInitialable {value = 'fallback';- constructor(@Inject(Injector) injector: IInjector) {+ constructor(@Inject(Injector) injector: Injector) {super(injector);}}diff --git a/packages/core/src/facade/f-base.ts b/packages/core/src/facade/f-base.tsindex 2470fd3bba..71da4f3372 100644--- a/packages/core/src/facade/f-base.ts+++ b/packages/core/src/facade/f-base.ts@@ -74,13 +74,10 @@ export class FBaseInitialable extends Disposable {const manual = Boolean(Ctor[ManualInitSymbol]); // <— Enable manual control only when this class (and its subclasses) is active.if (manual) return;- // eslint-disable-next-line ts/no-this-alias- const self = this;-const initializers = Object.getPrototypeOf(this)[InitializerSymbol];if (initializers) {- initializers.forEach(function (fn: (_injector: Injector) => void) {- fn.apply(self, [_injector]);+ initializers.forEach((fn: (_injector: Injector) => void) => {+ fn.apply(this, [_injector]);});}}diff --git a/packages/core/src/shared/cache/__tests__/image-cache.spec.ts b/packages/core/src/shared/cache/__tests__/image-cache.spec.tsindex bfff1717e6..91f6b99ef3 100644--- a/packages/core/src/shared/cache/__tests__/image-cache.spec.ts+++ b/packages/core/src/shared/cache/__tests__/image-cache.spec.ts@@ -14,8 +14,6 @@* limitations under the License.*/-import type { IImageIoService as IImageIoServiceContract } from '../../../services/image-io/image-io.service';-import type { IURLImageService as IURLImageServiceContract } from '../../../services/image-io/url-image.service';import { Subject } from 'rxjs';import { afterEach, describe, expect, it, vi } from 'vitest';import { Injector } from '../../../common/di';@@ -47,7 +45,7 @@ const flushTasks = async () => {await Promise.resolve();};-function createImageIoService(getImage: IImageIoServiceContract['getImage']): IImageIoServiceContract {+function createImageIoService(getImage: IImageIoService['getImage']): IImageIoService {return {change$: new Subject<number>(),setWaitCount: () => {},@@ -58,7 +56,7 @@ function createImageIoService(getImage: IImageIoServiceContract['getImage']): II};}-function createUrlImageService(getImage: IURLImageServiceContract['getImage']): IURLImageServiceContract {+function createUrlImageService(getImage: IURLImageService['getImage']): IURLImageService {return {getImage,downloadImage: async () => new Blob(),diff --git a/packages/design/src/components/button/Button.tsx b/packages/design/src/components/button/Button.tsxindex acdb09c3a8..68920d4e50 100644--- a/packages/design/src/components/button/Button.tsx+++ b/packages/design/src/components/button/Button.tsx@@ -59,7 +59,7 @@ export const buttonVariants = cva(dark:active:!univer-bg-gray-600`,link: `- univer-underline-current univer-border-transparent univer-bg-transparent univer-text-primary-600+ univer-border-transparent univer-bg-transparent univer-text-primary-600 univer-decoration-currentuniver-underline-offset-4hover:univer-text-primary-500 hover:univer-underlineactive:univer-text-primary-700diff --git a/packages/design/src/components/button/__tests__/index.spec.tsx b/packages/design/src/components/button/__tests__/Button.spec.tsxsimilarity index 100%rename from packages/design/src/components/button/__tests__/index.spec.tsxrename to packages/design/src/components/button/__tests__/Button.spec.tsxdiff --git a/packages/design/src/components/calendar/Calendar.tsx b/packages/design/src/components/calendar/Calendar.tsxindex 604633c86a..b40ae293dc 100644--- a/packages/design/src/components/calendar/Calendar.tsx+++ b/packages/design/src/components/calendar/Calendar.tsx@@ -23,20 +23,12 @@ import { ConfigContext } from '../config-provider/ConfigProvider';import { DropdownMenu } from '../dropdown-menu/DropdownMenu';import { Dropdown } from '../dropdown/Dropdown';import { TimeInput } from '../time-input/TimeInput';-import { VirtualList } from '../virtual-list';+import { VirtualList } from '../virtual-list/VirtualList';const DEFAULT_YEAR_RANGE = 100;const YEAR_ITEM_HEIGHT = 32;const YEAR_LIST_HEIGHT = 224;-function getDaysInMonth(year: number, month: number) {- return new Date(year, month + 1, 0).getDate();-}--function getFirstDayOfWeek(year: number, month: number) {- return new Date(year, month, 1).getDay();-}-function DayButton(props: ButtonHTMLAttributes<HTMLButtonElement>) {const { className, ...restProps } = props;@@ -137,8 +129,8 @@ export function Calendar(props: ICalendarProps) {onSelect: handleChangeMonth,}], [currentMonth, months]);- const daysInMonth = getDaysInMonth(currentYear, currentMonth);- const firstDay = getFirstDayOfWeek(currentYear, currentMonth);+ const daysInMonth = new Date(currentYear, currentMonth + 1, 0).getDate();+ const firstDay = new Date(currentYear, currentMonth, 1).getDay();const days = useMemo(() => {const daysArray = [];@@ -316,7 +308,7 @@ export function Calendar(props: ICalendarProps) {'!univer-bg-primary-600 univer-text-gray-0': isToday(day) && isSelected(day),'univer-font-semibold univer-text-primary-600 dark:!univer-text-primary-500': isToday(day) && !isSelected(day),'univer-cursor-not-allowed univer-opacity-40': isDisabled(day),- 'univer-hover:bg-primary-100 univer-cursor-pointer univer-text-gray-800': !isSelected(day) && !isDisabled(day),+ 'univer-cursor-pointer univer-text-gray-800 hover:univer-bg-primary-100': !isSelected(day) && !isDisabled(day),})}onClick={() => handleChangeDate(day)}disabled={isDisabled(day)}diff --git a/packages/design/src/components/calendar/__tests__/index.spec.tsx b/packages/design/src/components/calendar/__tests__/Calendar.spec.tsxsimilarity index 100%rename from packages/design/src/components/calendar/__tests__/index.spec.tsxrename to packages/design/src/components/calendar/__tests__/Calendar.spec.tsxdiff --git a/packages/design/src/components/cascader-list/CascaderList.tsx b/packages/design/src/components/cascader-list/CascaderList.tsxindex d00f83f6e3..034b14787a 100644--- a/packages/design/src/components/cascader-list/CascaderList.tsx+++ b/packages/design/src/components/cascader-list/CascaderList.tsx@@ -109,7 +109,7 @@ export function CascaderList(props: ICascaderListProps) {<sectiondata-u-comp="cascader-list"className={clsx(`- univer-overflow-auto-y univer-grid univer-h-full univer-max-h-80 univer-grid-flow-col univer-rounded+ univer-grid univer-h-full univer-max-h-80 univer-grid-flow-col univer-overflow-y-auto univer-roundeduniver-py-2 univer-text-gray-900dark:!univer-text-gray-0[&>ul:not(:last-child)]:univer-border-0 [&>ul:not(:last-child)]:univer-border-rdiff --git a/packages/design/src/components/cascader-list/__tests__/index.spec.tsx b/packages/design/src/components/cascader-list/__tests__/CascaderList.spec.tsxsimilarity index 75%rename from packages/design/src/components/cascader-list/__tests__/index.spec.tsxrename to packages/design/src/components/cascader-list/__tests__/CascaderList.spec.tsxindex ddb7f0cffd..f01c8f67f8 100644--- a/packages/design/src/components/cascader-list/__tests__/index.spec.tsx+++ b/packages/design/src/components/cascader-list/__tests__/CascaderList.spec.tsx@@ -21,33 +21,6 @@ import { CascaderList } from '../CascaderList';afterEach(cleanup);describe('CascaderList', () => {- afterEach(cleanup);-- // const options: ICascaderListProps['options'] = [- // {- // label: 'Option 1',- // value: 'option1',- // children: [- // { label: 'Option 1-1', value: 'option1-1' },- // { label: 'Option 1-2', value: 'option1-2' },- // ],- // },- // {- // label: 'Option 2',- // value: 'option2',- // children: [- // { label: 'Option 2-1', value: 'option2-1' },- // { label: 'Option 2-2', value: 'option2-2' },- // ],- // },- // ];-- it('renders correctly with default props', () => {- const { container } = render(<CascaderList value={[]} onChange={() => {}} />);-- expect(container).toBeTruthy();- });-it('should select parent and child options', () => {const onChange = vi.fn();const options = [diff --git a/packages/design/src/components/color-picker/ColorInput.tsx b/packages/design/src/components/color-picker/ColorInput.tsxindex 98d53fb996..9063a0537a 100644--- a/packages/design/src/components/color-picker/ColorInput.tsx+++ b/packages/design/src/components/color-picker/ColorInput.tsx@@ -196,12 +196,12 @@ export function ColorInput({ hsv, alpha, format, onChange }: IColorInputProps) {return (<divclassName={`- dark:![&_input]:univer-border-gray-600 dark:![&_input]:univer-text-gray-0univer-flex univer-gap-2[&_input]:univer-box-border [&_input]:univer-flex [&_input]:univer-h-7 [&_input]:univer-items-center[&_input]:univer-rounded [&_input]:univer-border [&_input]:univer-border-solid[&_input]:univer-border-gray-200 [&_input]:univer-bg-transparent [&_input]:univer-px-1.5[&_input]:univer-text-sm [&_input]:univer-text-gray-700 [&_input]:univer-outline-none+ dark:[&_input]:!univer-border-gray-600 dark:[&_input]:!univer-text-gray-0`}><div className="univer-relative univer-flex univer-flex-1 univer-gap-2">diff --git a/packages/design/src/components/draggable-list/DraggableList.tsx b/packages/design/src/components/draggable-list/DraggableList.tsxindex 9ee6cd864b..19dc188fb0 100644--- a/packages/design/src/components/draggable-list/DraggableList.tsx+++ b/packages/design/src/components/draggable-list/DraggableList.tsx@@ -39,16 +39,6 @@ export interface IDraggableListProps<T> extends Omit<HTMLAttributes<HTMLDivElememargin?: [number, number];}-function moveItemByIndex<T>(list: T[], fromIndex: number, toIndex: number) {- if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= list.length || toIndex >= list.length) {- return list;- }- const next = [...list];- const [item] = next.splice(fromIndex, 1);- next.splice(toIndex, 0, item);- return next;-}-export function DraggableList<T = any>(props: IDraggableListProps<T>) {const {list,@@ -111,6 +101,16 @@ export function DraggableList<T = any>(props: IDraggableListProps<T>) {return;}+ function moveItemByIndex(list: T[], fromIndex: number, toIndex: number) {+ if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= list.length || toIndex >= list.length) {+ return list;+ }+ const next = [...list];+ const [item] = next.splice(fromIndex, 1);+ next.splice(toIndex, 0, item);+ return next;+ }+const handlePointerMove = (evt: PointerEvent | globalThis.PointerEvent) => {const sourceId = dragSourceIdRef.current;if (!sourceId || pointerIdRef.current !== evt.pointerId) {@@ -210,10 +210,8 @@ export function DraggableList<T = any>(props: IDraggableListProps<T>) {'univer-relative univer-transition-all univer-duration-150',isDraggingItem && 'univer-opacity-0',isDragOverItem && `- univer-bg-primary-50/60- dark:!univer-bg-primary-900/20- univer-rounded univer-border univer-border-primary-200- dark:!univer-border-primary-700+ univer-rounded univer-border univer-border-primary-200 univer-bg-primary-50+ dark:!univer-border-primary-700 dark:!univer-bg-primary-900`)}onPointerDownCapture={(e: PointerEvent<HTMLDivElement>) => {@@ -260,8 +258,8 @@ export function DraggableList<T = any>(props: IDraggableListProps<T>) {{isDraggingItem && (<divclassName="- univer-bg-primary-50/50 univer-absolute univer-inset-0 univer-rounded- univer-border univer-border-dashed univer-border-primary-300+ univer-absolute univer-inset-0 univer-rounded univer-border univer-border-dashed+ univer-border-primary-300 univer-bg-primary-50"/>)}diff --git a/packages/design/src/components/draggable-list/__tests__/index.spec.tsx b/packages/design/src/components/draggable-list/__tests__/DraggableList.spec.tsxsimilarity index 93%rename from packages/design/src/components/draggable-list/__tests__/index.spec.tsxrename to packages/design/src/components/draggable-list/__tests__/DraggableList.spec.tsxindex 0178d73e24..459760e232 100644--- a/packages/design/src/components/draggable-list/__tests__/index.spec.tsx+++ b/packages/design/src/components/draggable-list/__tests__/DraggableList.spec.tsx@@ -19,14 +19,6 @@ import { afterEach, describe, expect, it, vi } from 'vitest';import { DraggableList } from '../DraggableList';import '@testing-library/jest-dom/vitest';-vi.mock('react-dom', async () => {- const actual = await vi.importActual<typeof import('react-dom')>('react-dom');- return {- ...actual,- createPortal: (node: any) => node,- };-});-afterEach(() => {cleanup();vi.restoreAllMocks();@@ -103,8 +95,6 @@ describe('DraggableList', () => {expect(onDragStart).toHaveBeenCalledWith(undefined, { y: 0 });});- expect(container.querySelector('.univer-pointer-events-none')).toBeInTheDocument();-fireEvent.pointerMove(window, {pointerId: 1,clientX: 48,@@ -262,7 +252,7 @@ describe('DraggableList', () => {expect(onListChange).toHaveBeenCalledTimes(1);});- it('should render ghost from cloned item dom', async () => {+ it('should show a drag preview and remove it when dragging ends', async () => {const onListChange = vi.fn();const { container } = render(@@ -276,7 +266,6 @@ describe('DraggableList', () => {const itemA = container.querySelector('[data-draggable-list-item-id="a"]') as HTMLDivElement;mockRect(itemA);- const cloneNodeSpy = vi.spyOn(itemA, 'cloneNode');Object.defineProperty(itemA, 'setPointerCapture', {configurable: true,value: vi.fn(),@@ -289,8 +278,7 @@ describe('DraggableList', () => {});await waitFor(() => {- expect(cloneNodeSpy).toHaveBeenCalledWith(true);- expect(container.querySelectorAll('.drag-content')).toHaveLength(2);+ expect(screen.getAllByText('A')).toHaveLength(2);});fireEvent.pointerUp(window, {@@ -299,5 +287,6 @@ describe('DraggableList', () => {clientY: 24,});expect(onListChange).toHaveBeenCalledTimes(1);+ expect(screen.getAllByText('A')).toHaveLength(1);});});diff --git a/packages/design/src/components/dropdown-menu/DropdownMenuPrimitive.tsx b/packages/design/src/components/dropdown-menu/DropdownMenuPrimitive.tsxindex 01b69f51c5..7926b24473 100644--- a/packages/design/src/components/dropdown-menu/DropdownMenuPrimitive.tsx+++ b/packages/design/src/components/dropdown-menu/DropdownMenuPrimitive.tsx@@ -113,7 +113,7 @@ function DropdownMenuSubTrigger({{...props}>{children}- <MoreRightIcon className="ml-auto" />+ <MoreRightIcon className="univer-ms-auto" /></SubTrigger>);}diff --git a/packages/design/src/components/dropdown/PopoverPrimitive.tsx b/packages/design/src/components/dropdown/PopoverPrimitive.tsxindex 4f0413dd88..8b3019f1a6 100644--- a/packages/design/src/components/dropdown/PopoverPrimitive.tsx+++ b/packages/design/src/components/dropdown/PopoverPrimitive.tsx@@ -45,7 +45,6 @@ function PopoverContent({sideOffset={sideOffset}className={clsx(`- univer-outline-hiddendata-[state=open]:univer-animate-in data-[state=open]:univer-fade-in-0data-[state=open]:univer-zoom-in-95data-[state=closed]:univer-animate-out data-[state=closed]:univer-fade-out-0@@ -55,7 +54,7 @@ function PopoverContent({data-[side=right]:univer-slide-in-from-left-2data-[side=top]:univer-slide-in-from-bottom-2univer-z-[1080] univer-max-h-[--radix-popper-available-height] univer-overflow-y-auto- univer-rounded-md univer-bg-gray-0 univer-text-gray-900 univer-shadow-md+ univer-rounded-md univer-bg-gray-0 univer-text-gray-900 univer-shadow-md univer-outline-nonedata-[state=closed]:univer-pointer-events-nonedark:!univer-bg-gray-900 dark:!univer-text-gray-0dark:focus-visible:!univer-border-gray-600diff --git a/packages/design/src/components/dropdown/__tests__/index.spec.tsx b/packages/design/src/components/dropdown/__tests__/PopoverPrimitive.spec.tsxsimilarity index 97%rename from packages/design/src/components/dropdown/__tests__/index.spec.tsxrename to packages/design/src/components/dropdown/__tests__/PopoverPrimitive.spec.tsxindex 89ff1b7f2e..9efd372569 100644--- a/packages/design/src/components/dropdown/__tests__/index.spec.tsx+++ b/packages/design/src/components/dropdown/__tests__/PopoverPrimitive.spec.tsx@@ -58,8 +58,6 @@ describe('Dropdown', () => {</Dropdown>);- expect(screen.getByText('Overlay Content').closest('[data-slot="popover-content"]')?.classList.contains('data-[state=closed]:univer-pointer-events-none')).toBe(true);-rerender(<Dropdown overlay={<div>Overlay Content</div>} open={false}><button type="button">Trigger</button>diff --git a/packages/design/src/components/message/Message.stories.tsx b/packages/design/src/components/message/Message.stories.tsxindex b1eca95324..02b4503492 100644--- a/packages/design/src/components/message/Message.stories.tsx+++ b/packages/design/src/components/message/Message.stories.tsx@@ -15,8 +15,8 @@*/import type { Meta } from '@storybook/react';-import type { IMessageProps } from './Message';import { useEffect } from 'react';+import type { IMessageProps } from './Message';import { Button } from '../button/Button';import { message, Messager, MessageType, removeMessage } from './Message';@@ -111,9 +111,8 @@ function MessageStoryShell({ title, description, children }: { title: string; de><divclassName={`- univer-border-gray-0/70 univer-bg-gray-0/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+ univer-mx-auto univer-max-w-5xl univer-rounded-3xl univer-border univer-border-solid+ univer-border-gray-0 univer-bg-gray-0 univer-p-8 univer-shadow-[0_30px_60px_-35px_rgba(15,23,42,0.55)]`}><h2diff --git a/packages/design/src/components/message/Message.tsx b/packages/design/src/components/message/Message.tsxindex 5074bdf67e..3570eb40ab 100644--- a/packages/design/src/components/message/Message.tsx+++ b/packages/design/src/components/message/Message.tsx@@ -100,13 +100,12 @@ export const Messager = ({ className, ...props }: IMessagerProps) => (offset={{ top: 16 }}className={clsx(`- [&_[data-sonner-toast]]:univer-bg-gray-0/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-bg-gray-0[&_[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+ dark:[&_[data-sonner-toast]]:!univer-border-gray-600 dark:[&_[data-sonner-toast]]:!univer-bg-gray-800`,className)}diff --git a/packages/design/src/components/popup/Popup.tsx b/packages/design/src/components/popup/Popup.tsxindex bd7e84e285..1c49c48b6f 100644--- a/packages/design/src/components/popup/Popup.tsx+++ b/packages/design/src/components/popup/Popup.tsx@@ -129,13 +129,9 @@ export function Popup(props: IPopupProps) {`,visible? `- univer-[transition-timing-function:cubic-bezier(0.08,0.82,0.17,1)] univer-scale-y-100- univer-opacity-100- `- : `- univer-[transition-timing-function:cubic-bezier(0.6,0.04,0.98,0.34)] univer-scale-y-0- univer-opacity-0+ univer-scale-y-100 univer-opacity-100 [transition-timing-function:cubic-bezier(0.08,0.82,0.17,1)]`+ : 'univer-scale-y-0 univer-opacity-0 [transition-timing-function:cubic-bezier(0.6,0.04,0.98,0.34)]')}style={{// Fix #1089. If the popup does not have this 2px offset, the pointerup event's target woulddiff --git a/packages/design/src/components/toaster/Toaster.tsx b/packages/design/src/components/toaster/Toaster.tsxindex 0b48a2d4ab..7bb03d152f 100644--- a/packages/design/src/components/toaster/Toaster.tsx+++ b/packages/design/src/components/toaster/Toaster.tsx@@ -23,8 +23,8 @@ function Toaster({ visibleToasts, ...props }: IToasterProps) {return (<SonnerclassName={`- dark:![&_[data-description]]:univer-text-gray-200[&_[data-description]]:univer-text-sm [&_[data-description]]:univer-text-gray-600+ dark:[&_[data-description]]:!univer-text-gray-200[&_[data-icon]>svg]:univer-relative [&_[data-icon]>svg]:univer-top-1[&_[data-icon]]:univer-self-baseline[&_[data-sonner-toast]]:univer-shadow-mddiff --git a/packages/design/src/components/toaster/__tests__/index.spec.tsx b/packages/design/src/components/toaster/__tests__/Toaster.spec.tsxsimilarity index 50%rename from packages/design/src/components/toaster/__tests__/index.spec.tsxrename to packages/design/src/components/toaster/__tests__/Toaster.spec.tsxindex fdfeb0cac5..d78cc83681 100644--- a/packages/design/src/components/toaster/__tests__/index.spec.tsx+++ b/packages/design/src/components/toaster/__tests__/Toaster.spec.tsx@@ -14,23 +14,31 @@* limitations under the License.*/-import { cleanup, render } from '@testing-library/react';+import { act, cleanup, render, screen, waitFor } from '@testing-library/react';import { afterEach, describe, expect, it } from 'vitest';-import { Toaster } from '../Toaster';-import '@testing-library/jest-dom/vitest';+import { toast, Toaster } from '../Toaster';-afterEach(cleanup);--describe('Toaster', () => {- it('should render without crashing', () => {- render(<Toaster />);- const toasterRoot = document.querySelector('[data-sonner-toast]') || document.body;- expect(toasterRoot).toBeTruthy();+afterEach(() => {+ act(() => {+ toast.dismiss();});+ cleanup();+});- it('should respect visibleToasts prop', () => {+describe('Toaster', () => {+ it('shows notifications and limits the visible stack', async () => {render(<Toaster visibleToasts={2} />);- const toasterRoot = document.querySelector('[data-sonner-toast]') || document.body;- expect(toasterRoot).toBeTruthy();++ act(() => {+ toast('First notification');+ toast('Second notification');+ toast('Third notification');+ });++ await waitFor(() => {+ const visibleToasts = screen.getAllByRole('listitem').filter((item) => item.dataset.visible === 'true');+ expect(visibleToasts).toHaveLength(2);+ expect(visibleToasts.map((item) => item.textContent)).toEqual(['Third notification', 'Second notification']);+ });});});diff --git a/packages/docs/src/utils/section-columns.ts b/packages/docs/src/utils/section-columns.tsindex 0f5a6c1a73..e9c98579e3 100644--- a/packages/docs/src/utils/section-columns.ts+++ b/packages/docs/src/utils/section-columns.ts@@ -14,8 +14,8 @@* limitations under the License.*/-import type { IDocumentStyle, ISectionBreak, ISectionColumnProperties, PageOrientType } from '@univerjs/core';-import { PAGE_SIZE, PageOrientType as PageOrient, PaperType, TRADITIONAL_DOCUMENT_DEFAULT_MARGIN } from '@univerjs/core';+import type { IDocumentStyle, ISectionBreak, ISectionColumnProperties } from '@univerjs/core';+import { PAGE_SIZE, PageOrientType, PaperType, TRADITIONAL_DOCUMENT_DEFAULT_MARGIN } from '@univerjs/core';export interface IEffectiveSectionPageSetup {pageSize: {@@ -93,7 +93,7 @@ export function getEffectiveSectionPageSetup(const pageNumberStart = section?.pageNumberStart ?? documentStyle?.pageNumberStart;return {pageSize,- pageOrient: resolveSectionValue(section?.pageOrient, documentStyle?.pageOrient, PageOrient.PORTRAIT),+ pageOrient: resolveSectionValue(section?.pageOrient, documentStyle?.pageOrient, PageOrientType.PORTRAIT),margins,contentSize,...(pageNumberStart == null ? {} : { pageNumberStart }),diff --git a/packages/drawing-ui/src/views/object-list-panel/MobileObjectListPanel.tsx b/packages/drawing-ui/src/views/object-list-panel/MobileObjectListPanel.tsxindex 51984c5de9..549ae68d1c 100644--- a/packages/drawing-ui/src/views/object-list-panel/MobileObjectListPanel.tsx+++ b/packages/drawing-ui/src/views/object-list-panel/MobileObjectListPanel.tsx@@ -15,9 +15,9 @@*/import type { ComponentProps } from 'react';-import type { IObjectListPanelBaseProps, IObjectListRowProps } from './ObjectListPanelBase';import { Button, clsx, Input, StateIconButton } from '@univerjs/design';import { ArrowDownIcon, ArrowUpIcon, EyeIcon, EyelashIcon, LocateFixedIcon, LockIcon, MoreDownIcon, UnlockIcon } from '@univerjs/icons';+import type { IObjectListPanelBaseProps, IObjectListRowProps } from './ObjectListPanelBase';import { hasCapability, ObjectDetailsEditor, useObjectListPanel, useObjectListRow } from './ObjectListPanelBase';const mobileIconButtonClassName = `@@ -139,9 +139,8 @@ export function MobileObjectListPanel(props: IObjectListPanelBaseProps) {'univer-h-11 univer-text-sm',filterMode === mode? `- dark:!univer-bg-primary-900/30univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600- dark:!univer-text-primary-200+ dark:!univer-bg-primary-900 dark:!univer-text-primary-200`: clsx(`univer-border-gray-200 univer-bg-gray-0 univer-text-gray-600diff --git a/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsxindex 2a6f1c0709..792ebf016b 100644--- a/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx+++ b/packages/drawing-ui/src/views/object-list-panel/ObjectListPanelBase.tsx@@ -399,9 +399,8 @@ export function ObjectListPanelBase(props: IObjectListPanelBaseProps) {'univer-h-7',filterMode === mode? `- dark:!univer-bg-primary-900/30univer-border-primary-500 univer-bg-primary-50 univer-text-primary-600- dark:!univer-text-primary-200+ dark:!univer-bg-primary-900 dark:!univer-text-primary-200`: clsx(`univer-border-gray-200 univer-bg-gray-0 univer-text-gray-600diff --git a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsxindex 2268cc6c45..16be8d70d7 100644--- a/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx+++ b/packages/find-replace/src/views/dialog/FindReplaceDialog.tsx@@ -14,12 +14,12 @@* limitations under the License.*/-import type { LocaleKey } from '../../locale/types';import { ICommandService, IContextService, LocaleService } from '@univerjs/core';import { Button, Checkbox, FormDualColumnLayout, FormLayout, Input, MessageType, Select } from '@univerjs/design';import { ILayoutService, IMessageService, useDebounceFn, useDependency, useObservable } from '@univerjs/ui';import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef } from 'react';import { fromEvent } from 'rxjs';+import type { LocaleKey } from '../../locale/types';import { ReplaceAllMatchesCommand, ReplaceCurrentMatchCommand } from '../../commands/commands/replace.command';import { OpenReplaceDialogOperation } from '../../commands/operations/find-replace.operation';import { FIND_REPLACE_DIALOG_FOCUS, FIND_REPLACE_INPUT_FOCUS } from '../../services/context-keys';@@ -110,8 +110,8 @@ export const FindDialog = forwardRef(function FindDialogImpl(_props, ref) {<div className="univer-mt-4 univer-text-center"><aclassName={`- hover:univer-text-primary-500/80univer-cursor-pointer univer-text-sm univer-text-primary-500 univer-transition-colors+ hover:univer-text-primary-500`}onClick={revealReplace}>diff --git a/packages/sheets-crosshair-highlight/src/views/components/CrosshairHighlight.tsx b/packages/sheets-crosshair-highlight/src/views/components/CrosshairHighlight.tsxindex dfe5bc8574..5050e3f6f3 100644--- a/packages/sheets-crosshair-highlight/src/views/components/CrosshairHighlight.tsx+++ b/packages/sheets-crosshair-highlight/src/views/components/CrosshairHighlight.tsx@@ -54,10 +54,9 @@ export function CrosshairOverlay(props: ICrosshairOverlayProps) {<divkey={CROSSHAIR_HIGHLIGHT_COLOR_THEME_PATHS[index]}className={clsx(`- hover:univer-ring-primary-600/40univer-box-border univer-size-5 univer-cursor-pointer univer-rounded univer-ring-offset-1univer-transition-shadow- hover:univer-ring-[1.5px]+ hover:univer-ring-[1.5px] hover:univer-ring-primary-600`, borderClassName, {'univer-ring-[1.5px] univer-ring-primary-600 hover:univer-ring-primary-600': color === currentColor,})}diff --git a/packages/sheets-data-validation-ui/src/views/components/DataValidationItem.tsx b/packages/sheets-data-validation-ui/src/views/components/DataValidationItem.tsxindex 5a6562275a..0aa35849bb 100644--- a/packages/sheets-data-validation-ui/src/views/components/DataValidationItem.tsx+++ b/packages/sheets-data-validation-ui/src/views/components/DataValidationItem.tsx@@ -78,10 +78,11 @@ export const DataValidationItem = (props: IDataValidationDetailProps) => {<divclassName={clsx(`- univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px]- univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md+ univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer+ univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-bg-gray-0univer-p-2 univer-pr-9rtl:univer-pl-9 rtl:univer-pr-2+ dark:!univer-bg-gray-900`,{'hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700': !disable,@@ -116,7 +117,7 @@ export const DataValidationItem = (props: IDataValidationDetailProps) => {</div><divclassName={`- univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px]+ univer-truncate univer-text-xs univer-leading-[18px] univer-text-gray-500dark:!univer-text-gray-300`}>diff --git a/packages/sheets-data-validation-ui/src/views/components/__tests__/DataValidationItem.spec.tsx b/packages/sheets-data-validation-ui/src/views/components/__tests__/DataValidationItem.spec.tsxindex bbe25fd53d..c602d5d372 100644--- a/packages/sheets-data-validation-ui/src/views/components/__tests__/DataValidationItem.spec.tsx+++ b/packages/sheets-data-validation-ui/src/views/components/__tests__/DataValidationItem.spec.tsx@@ -502,7 +502,7 @@ function renderItem();});- return document.querySelector('.univer-bg-secondary') as HTMLElement;+ return Array.from(document.querySelectorAll('div')).find((element) => element.textContent === 'A1:A2,C5:D5')!;}async function enterItem(item: HTMLElement) {@@ -579,7 +579,7 @@ describe('DataValidationItem', () => {expect(currentTestBed.markSelectionService.removed).toEqual(['shape-0', 'shape-1']);});- it('positions and runs the hovered rule delete action in RTL without selecting the item', async () => {+ it('runs the hovered rule delete action in RTL without selecting the item', async () => {currentTestBed = createItemTestBed();container = document.createElement('div');container.dir = 'rtl';@@ -597,11 +597,6 @@ describe('DataValidationItem', () => {const deleteButton = container.querySelector('.univer-absolute') as HTMLElement;- expect(item.className).toContain('rtl:univer-pl-9');- expect(item.className).toContain('rtl:univer-pr-2');- expect(deleteButton.className).toContain('rtl:univer-left-2');- expect(deleteButton.className).toContain('rtl:univer-right-auto');-await act(async () => {deleteButton.dispatchEvent(new MouseEvent('click', { bubbles: true }));await Promise.resolve();@@ -706,7 +701,7 @@ describe('DataValidationList', () => {renderList();- const item = container.querySelector('.univer-bg-secondary') as HTMLElement;+ const item = Array.from(container.querySelectorAll('div')).find((element) => element.textContent === 'A1:A2,C5:D5')!;await enterItem(item);@@ -852,7 +847,7 @@ describe('DataValidationPanel', () => {await Promise.resolve();});- const item = container.querySelector('.univer-bg-secondary') as HTMLElement;+ const item = Array.from(container.querySelectorAll('div')).find((element) => element.textContent === 'A1:A2,C5:D5')!;await act(async () => {item.dispatchEvent(new MouseEvent('click', { bubbles: true }));@@ -940,7 +935,7 @@ describe('DataValidationPanel', () => {await Promise.resolve();});- const item = container.querySelector('.univer-bg-secondary') as HTMLElement;+ const item = Array.from(container.querySelectorAll('div')).find((element) => element.textContent === 'A1:A2,C5:D5')!;await act(async () => {item.dispatchEvent(new MouseEvent('click', { bubbles: true }));diff --git a/packages/sheets-data-validation-ui/src/views/components/formula-input/ListFormulaInput.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/ListFormulaInput.tsxindex 5993095c5d..fae7759c3f 100644--- a/packages/sheets-data-validation-ui/src/views/components/formula-input/ListFormulaInput.tsx+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/ListFormulaInput.tsx@@ -16,8 +16,6 @@import type { ListValidator } from '@univerjs/sheets-data-validation';import type { IFormulaEditorRef } from '@univerjs/sheets-formula-ui';-import type { LocaleKey } from '../../../locale/types';-import type { IFormulaInputProps } from './interface';import { DataValidationType, generateRandomId, isFormulaString, LocaleService, ThemeService } from '@univerjs/core';import { DataValidationModel, DataValidatorRegistryService } from '@univerjs/data-validation';import { borderClassName, clsx, DraggableList, Dropdown, FormLayout, Input, Radio, RadioGroup } from '@univerjs/design';@@ -27,7 +25,9 @@ import { DataValidationFormulaController } from '@univerjs/sheets-data-validatioimport { FormulaEditor } from '@univerjs/sheets-formula-ui';import { useDependency, useEvent, useObservable, useSidebarClick } from '@univerjs/ui';import { useEffect, useMemo, useRef, useState } from 'react';-import { debounceTime } from 'rxjs';+import { debounceTime, noop } from 'rxjs';+import type { LocaleKey } from '../../../locale/types';+import type { IFormulaInputProps } from './interface';import { DROP_DOWN_DEFAULT_COLOR } from '../../../const';import { DataValidationPanelService } from '../../../services/data-validation-panel.service';import { buildCustomListFormulaPayload } from './utils';@@ -170,10 +170,8 @@ const Template = (props: { item: IDropdownItem; commonProps: any; className?: st);};-const NOOP = () => { /* empty */ };-export function ListFormulaInput(props: IFormulaInputProps) {- const { value, onChange: _onChange = NOOP, unitId, subUnitId, validResult, showError, ruleId } = props;+ const { value, onChange: _onChange = noop, unitId, subUnitId, validResult, showError, ruleId } = props;const { formula1 = '', formula2 = '' } = value || {};const [isFormulaStr, setIsFormulaStr] = useState(() => isFormulaString(formula1) ? '1' : '0');const [formulaStr, setFormulaStr] = useState(isFormulaStr === '1' ? formula1 : '=');@@ -412,9 +410,10 @@ export function ListFormulaInput(props: IFormulaInputProps) {/><aclassName={`- univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row- univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm+ univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center+ univer-rounded univer-p-1 univer-px-2 univer-text-sm univer-text-primary-600hover:univer-bg-primary-50+ dark:!univer-text-primary-500dark:hover:!univer-bg-gray-800`}onClick={handleAdd}diff --git a/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/formula-input.spec.tsx b/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/BaseFormulaInput.spec.tsxsimilarity index 100%rename from packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/formula-input.spec.tsxrename to packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/BaseFormulaInput.spec.tsxindex 78706a3fa5..b34c940c97 100644--- a/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/formula-input.spec.tsx+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/BaseFormulaInput.spec.tsx@@ -15,12 +15,12 @@*/import type { IFormulaValue } from '@univerjs/data-validation';-import type { FormulaInputType } from '../interface';import { LocaleService, LocaleType, Univer } from '@univerjs/core';import { RediContext } from '@univerjs/ui';import { act, useState } from 'react';import { createRoot } from 'react-dom/client';import { afterEach, describe, expect, it } from 'vitest';+import type { FormulaInputType } from '../interface';import { BaseFormulaInput } from '../BaseFormulaInput';import { CheckboxFormulaInput } from '../CheckboxFormulaInput';diff --git a/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/list-formula-input.spec.ts b/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/utils.spec.tssimilarity index 97%rename from packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/list-formula-input.spec.tsrename to packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/utils.spec.tsindex 903dd23989..02af5b266a 100644--- a/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/list-formula-input.spec.ts+++ b/packages/sheets-data-validation-ui/src/views/components/formula-input/__tests__/utils.spec.ts@@ -18,7 +18,7 @@ import { deserializeListOptions } from '@univerjs/sheets';import { describe, expect, it } from 'vitest';import { buildCustomListFormulaPayload } from '../utils';-describe('ListFormulaInput', () => {+describe('buildCustomListFormulaPayload', () => {it('keeps commas inside custom list values', () => {const payload = buildCustomListFormulaPayload([{ label: 'a,b', color: '#ff0000' },diff --git a/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts b/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.tsindex 57d27b42cf..7487ff82ab 100644--- a/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts+++ b/packages/sheets-drawing-ui/src/services/__tests__/canvas-float-dom-manager.service.spec.ts@@ -16,10 +16,9 @@import type { IWorkbookData } from '@univerjs/core';import type { IDrawingJsonUndo1 } from '@univerjs/drawing';-import type { IRender, IRenderManagerService as IRenderManagerServiceType, Scene } from '@univerjs/engine-render';+import type { IRender, Scene } from '@univerjs/engine-render';import type { ISheetFloatDom } from '@univerjs/sheets-drawing';import type { IFloatDom, IFloatDomLayout } from '@univerjs/ui';-import type { ICanvasFloatDomInfo, ISheetFloatDomRenderObjectFactoryContext } from '../canvas-float-dom-manager.service';import {BooleanNumber,Disposable,@@ -38,6 +37,7 @@ import { ISheetSelectionRenderService, SheetSkeletonManagerService } from '@univimport { CanvasFloatDomService } from '@univerjs/ui';import { BehaviorSubject, of, Subject } from 'rxjs';import { afterEach, describe, expect, it, vi } from 'vitest';+import type { ICanvasFloatDomInfo, ISheetFloatDomRenderObjectFactoryContext } from '../canvas-float-dom-manager.service';import { createSheetsDrawingUiTestBed } from '../../__tests__/create-sheets-drawing-ui-test-bed';import {applyFloatDomTransformerConfig,@@ -155,7 +155,7 @@ function setup(workbookData: IWorkbookData = BASE_WORKBOOK_DATA) {};}-class TestRenderManagerService extends Disposable implements Partial<IRenderManagerServiceType> {+class TestRenderManagerService extends Disposable implements Partial<IRenderManagerService> {private _render: IRender | null = null;readonly created$ = new Subject<IRender>();readonly disposed$ = new Subject<string>();diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetImageTransparencySlider.tsx b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetImageTransparencySlider.tsxindex 4f9c4ada13..dd1a60ddec 100644--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetImageTransparencySlider.tsx+++ b/packages/sheets-drawing-ui/src/views/sheet-image-panel/SheetImageTransparencySlider.tsx@@ -227,7 +227,7 @@ export function SheetImageTransparencySlider(props: ISheetImageTransparencySlide><divclassName={clsx(`- univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full+ univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500`, isRtl ? 'univer-right-0' : 'univer-left-0')}style={{ width: `${sliderOffset}%` }}/>@@ -294,6 +294,16 @@ function SheetImageTransparencyInput(props: ISheetImageTransparencyInputProps) {}}, [value]);+ function parseTransparency(rawValue: string): number | null {+ const normalizedValue = rawValue.trim().replace(/%$/, '').trim();+ if (normalizedValue === '') {+ return null;+ }++ const parsedValue = Number(normalizedValue);+ return Number.isFinite(parsedValue) ? normalizeTransparency(parsedValue) : null;+ }+function emitValue(nextValue: number) {const normalizedValue = normalizeTransparency(nextValue);onChange?.(normalizedValue);@@ -412,16 +422,6 @@ function SheetImageTransparencyInput(props: ISheetImageTransparencyInputProps) {);}-function parseTransparency(rawValue: string): number | null {- const normalizedValue = rawValue.trim().replace(/%$/, '').trim();- if (normalizedValue === '') {- return null;- }-- const parsedValue = Number(normalizedValue);- return Number.isFinite(parsedValue) ? normalizeTransparency(parsedValue) : null;-}-function normalizeTransparency(value: number): number {return Math.min(Math.max(Math.round(value), MIN_TRANSPARENCY), MAX_TRANSPARENCY);}diff --git a/packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanelBehavior.spec.tsx b/packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanel.spec.tsxsimilarity index 99%rename from packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanelBehavior.spec.tsxrename to packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanel.spec.tsxindex 36063c001a..8ef5548809 100644--- a/packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanelBehavior.spec.tsx+++ b/packages/sheets-drawing-ui/src/views/sheet-image-panel/__tests__/SheetDrawingPanel.spec.tsx@@ -130,7 +130,7 @@ function createSheetDrawing(unitId: string, subUnitId: string, drawingId: string};}-describe('SheetDrawingPanel behavior', () => {+describe('SheetDrawingPanel', () => {let root: Root | undefined;let container: HTMLDivElement | undefined;let currentTestBed: ReturnType<typeof createSheetsDrawingUiTestBed> | undefined;diff --git a/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx b/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsxindex 78b24ab154..95e0445a8a 100644--- a/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx+++ b/packages/sheets-filter-ui/src/views/components/SheetsFilterByValuesPanel.tsx@@ -14,12 +14,12 @@* limitations under the License.*/-import type { LocaleKey } from '../../locale/types';-import type { ByValuesModel, IFilterByValueWithTreeItem } from '../../services/sheets-filter-panel.service';import { LocaleService } from '@univerjs/core';import { borderClassName, Checkbox, clsx, Input, Tree } from '@univerjs/design';import { useDependency, useObservable } from '@univerjs/ui';import { useCallback } from 'react';+import type { LocaleKey } from '../../locale/types';+import type { ByValuesModel, IFilterByValueWithTreeItem } from '../../services/sheets-filter-panel.service';import { statisticFilterByValueItems } from '../../models/utils';/**@@ -129,7 +129,7 @@ export function FilterByValue(props: { model: ByValuesModel }) {defaultCache={treeMap}itemHeight={28}treeNodeClassName={`- univer-pr-2 univer-border-box univer-rounded-md+ univer-pr-2 univer-box-border univer-rounded-md[&:hover_a]:univer-inline-blockhover:univer-bg-gray-50 univer-h-fulluniver-text-gray-900 dark:hover:!univer-bg-gray-900diff --git a/packages/sheets-filter/src/commands/commands/__tests__/sheets-filter.command.spec.ts b/packages/sheets-filter/src/commands/commands/__tests__/sheets-filter.command.spec.tsindex c40b8fb4ff..cb7bbfc882 100644--- a/packages/sheets-filter/src/commands/commands/__tests__/sheets-filter.command.spec.ts+++ b/packages/sheets-filter/src/commands/commands/__tests__/sheets-filter.command.spec.ts@@ -14,11 +14,11 @@* limitations under the License.*/-import type { Injector, IWorkbookData, Workbook } from '@univerjs/core';+import type { IWorkbookData, Workbook } from '@univerjs/core';import {ICommandService,Inject,- Injector as InjectorIdentifier,+ Injector,IUniverInstanceService,LocaleType,Plugin,@@ -82,7 +82,7 @@ class SheetsFilterCommandTestPlugin extends Plugin {static override type = UniverInstanceType.UNIVER_SHEET;static override pluginName = 'SheetsFilterCommandTestPlugin';- constructor(_config: unknown, @Inject(InjectorIdentifier) protected readonly _injector: Injector) {+ constructor(_config: unknown, @Inject(Injector) protected readonly _injector: Injector) {super();}diff --git a/packages/sheets-numfmt/src/commands/commands/__tests__/numfmt.command.spec.ts b/packages/sheets-numfmt/src/commands/commands/__tests__/set-numfmt.command.spec.tssimilarity index 98%rename from packages/sheets-numfmt/src/commands/commands/__tests__/numfmt.command.spec.tsrename to packages/sheets-numfmt/src/commands/commands/__tests__/set-numfmt.command.spec.tsindex b249032169..7df23053a0 100644--- a/packages/sheets-numfmt/src/commands/commands/__tests__/numfmt.command.spec.ts+++ b/packages/sheets-numfmt/src/commands/commands/__tests__/set-numfmt.command.spec.ts@@ -14,7 +14,7 @@* limitations under the License.*/-import type { Dependency, IWorkbookData, Injector as RediInjector, Workbook } from '@univerjs/core';+import type { Dependency, IWorkbookData, Workbook } from '@univerjs/core';import {CellValueType,DEFAULT_TEXT_FORMAT_EXCEL,@@ -104,7 +104,7 @@ function createCommandTestBed(workbookData?: IWorkbookData) {constructor(_config: undefined,- @Inject(Injector) override readonly _injector: RediInjector+ @Inject(Injector) override readonly _injector: Injector) {super();}@@ -136,7 +136,7 @@ function createCommandTestBed(workbookData?: IWorkbookData) {describe('Sheets numfmt commands', () => {let univer: Univer;- let get: RediInjector['get'];+ let get: Injector['get'];let commandService: ICommandService;let selectionService: SheetsSelectionsService;let numfmtService: INumfmtService;diff --git a/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsxindex 03533333f9..64002c1e56 100644--- a/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx+++ b/packages/sheets-table-ui/src/views/components/SheetTableFilterPanel.tsx@@ -16,9 +16,6 @@import type { ISortRangeCommandParams } from '@univerjs/sheets-sort';import type { ITableFilterItem } from '@univerjs/sheets-table';-import type { LocaleKey } from '../../locale/types';-import type { ITableFilterColorList } from '../../types';-import type { IConditionInfo } from './type';import { generateRandomId, ICommandService, IPermissionService, IUndoRedoService, LocaleService } from '@univerjs/core';import { ActionRow, Button, ButtonGroup, Segmented } from '@univerjs/design';import {@@ -42,6 +39,9 @@ import {} from '@univerjs/sheets-table';import { useDependency } from '@univerjs/ui';import { useState } from 'react';+import type { LocaleKey } from '../../locale/types';+import type { ITableFilterColorList } from '../../types';+import type { IConditionInfo } from './type';import { SheetsTableComponentController } from '../../controllers/sheet-table-component.controller';import { SheetsTableUiService } from '../../services/sheets-table-ui.service';import { FilterByEnum } from '../../types';@@ -355,7 +355,7 @@ export function SheetTableFilterPanel() {</div><ActionRowclassName={`- univer-flex-wrap-nowrap univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0+ univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrapuniver-justify-between univer-gap-6 univer-overflow-hidden`}>diff --git a/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsx b/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsxindex 45977a78b1..6272b0da22 100644--- a/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsx+++ b/packages/sheets-table-ui/src/views/components/SheetTableItemsFilterPanel.tsx@@ -16,12 +16,12 @@import type { ITableFilterItem } from '@univerjs/sheets-table';import type { Dispatch, SetStateAction } from 'react';-import type { LocaleKey } from '../../locale/types';import { LocaleService } from '@univerjs/core';import { borderClassName, Checkbox, clsx, Input, scrollbarClassName } from '@univerjs/design';import { isRecordTableFilter } from '@univerjs/sheets-table';import { useDependency } from '@univerjs/ui';import { useMemo, useState } from 'react';+import type { LocaleKey } from '../../locale/types';import { SheetsTableUiService } from '../../services/sheets-table-ui.service';interface ISheetTableItemsFilterPanelProps {@@ -36,15 +36,15 @@ interface ISheetTableItemsFilterPanelProps {onItemChange?: () => void;}-const getCheckedItemCount = (map: Map<string, number>, checkedItemSet: Set<string>) => {- let count = 0;- checkedItemSet.forEach((item) => {- count += map.get(item) ?? 0;- });- return count;-};-export function SheetTableItemsFilterPanel(props: ISheetTableItemsFilterPanelProps) {+ function getCheckedItemCount(map: Map<string, number>, checkedItemSet: Set<string>) {+ let count = 0;+ checkedItemSet.forEach((item) => {+ count += map.get(item) ?? 0;+ });+ return count;+ }+const {unitId,tableId,@@ -196,7 +196,7 @@ export function SheetTableItemsFilterPanel(props: ISheetTableItemsFilterPanelPro><div className="univer-flex univer-h-5 univer-flex-1 univer-items-center univer-text-sm"><span className="univer-flex-1 univer-truncate">{`${localeService.t<LocaleKey>('sheets-table-ui.filter.select-all')}`}</span>- <span className="univer-ml univer-text-gray-400">{`(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`}</span>+ <span className="univer-ms-1 univer-text-gray-400">{`(${checkedCount}/${searchText ? displayItems.length : allItemsCount})`}</span></div></Checkbox></div>diff --git a/packages/sheets-table-ui/src/views/components/__tests__/SheetTableComponents.spec.tsx b/packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsxsimilarity index 100%rename from packages/sheets-table-ui/src/views/components/__tests__/SheetTableComponents.spec.tsxrename to packages/sheets-table-ui/src/views/components/__tests__/SheetTableFilterPanel.spec.tsxdiff --git a/packages/sheets-ui/src/views/defined-name/DefinedNameContainer.tsx b/packages/sheets-ui/src/views/defined-name/DefinedNameContainer.tsxindex 0948096e85..4a7e39afb1 100644--- a/packages/sheets-ui/src/views/defined-name/DefinedNameContainer.tsx+++ b/packages/sheets-ui/src/views/defined-name/DefinedNameContainer.tsx@@ -16,7 +16,6 @@import type { Nullable, Workbook } from '@univerjs/core';import type { IDefinedNamesServiceParam, ISetDefinedNameMutationParam } from '@univerjs/engine-formula';-import type { LocaleKey } from '../../locale/types';import { generateRandomId, ICommandService, IPermissionService, IUniverInstanceService, LocaleService, UniverInstanceType } from '@univerjs/core';import { Button, clsx, Confirm, scrollbarClassName, Tooltip } from '@univerjs/design';import { IDefinedNamesService, serializeRangeWithSheet } from '@univerjs/engine-formula';@@ -35,6 +34,7 @@ import {import { useDependency, useObservable, useVirtualList } from '@univerjs/ui';import { useRef, useState } from 'react';import { map, startWith } from 'rxjs';+import type { LocaleKey } from '../../locale/types';import { DefinedNameInput } from './DefinedNameInput';export interface IDefinedNameContainerProps {@@ -310,7 +310,7 @@ export const DefinedNameContainer = ({`}>{definedName.name}- <span className="univer-text-xxs univer-ml-1 univer-text-gray-400">+ <span className="univer-ml-1 univer-text-xs univer-text-gray-400">{(definedName.localSheetId === SCOPE_WORKBOOK_VALUE_DEFINED_NAME || definedName.localSheetId == null) ? '' : getSheetNameBySheetId(definedName.localSheetId)}</span></div>diff --git a/packages/sheets-ui/src/views/permission/SheetPermissionPanelList.tsx b/packages/sheets-ui/src/views/permission/SheetPermissionPanelList.tsxindex db105bc9ef..4df5bf2d47 100644--- a/packages/sheets-ui/src/views/permission/SheetPermissionPanelList.tsx+++ b/packages/sheets-ui/src/views/permission/SheetPermissionPanelList.tsx@@ -17,8 +17,6 @@import type { IRange, Workbook } from '@univerjs/core';import type { IPermissionPoint } from '@univerjs/protocol';import type { IRangeProtectionRule, IWorksheetProtectionRule } from '@univerjs/sheets';-import type { LocaleKey } from '../../locale/types';-import type { IPermissionPanelRule } from '../../services/permission/sheet-permission-panel.model';import {IAuthzIoService,ICommandService,@@ -45,6 +43,8 @@ import {import { ISidebarService, useDependency, useObservable } from '@univerjs/ui';import { useCallback, useEffect, useMemo, useState } from 'react';import { distinctUntilChanged, from, merge, startWith, switchMap } from 'rxjs';+import type { LocaleKey } from '../../locale/types';+import type { IPermissionPanelRule } from '../../services/permission/sheet-permission-panel.model';import { UNIVER_SHEET_PERMISSION_PANEL } from '../../consts/permission';import { useHighlightRange } from '../../hooks/use-highlight-range';import { SheetPermissionUserManagerService } from '../../services/permission/sheet-permission-user-list.service';@@ -385,8 +385,8 @@ function SheetPermissionPanelListContent({ ActionRowComponent }: Required<ISheet<Tooltip title={rule.description}><divclassName={`- univer-text-3 univer-mt-2 univer-max-w-64 univer-truncate- univer-text-sm univer-text-gray-400+ univer-mt-2 univer-max-w-64 univer-truncate univer-text-sm+ univer-text-gray-400`}>{rule.description}diff --git a/packages/sheets/src/services/permission/worksheet-permission/__tests__/worksheet-permission.service.spec.ts b/packages/sheets/src/services/permission/worksheet-permission/__tests__/worksheet-permission.service.spec.tsindex 5480dd6e09..4d0e8cfd4d 100644--- a/packages/sheets/src/services/permission/worksheet-permission/__tests__/worksheet-permission.service.spec.ts+++ b/packages/sheets/src/services/permission/worksheet-permission/__tests__/worksheet-permission.service.spec.ts@@ -15,11 +15,6 @@*/import type { IDisposable, Workbook, Worksheet } from '@univerjs/core';-import type {- IRangeProtectionRule,- EditStateEnum as RangeEditStateEnum,-} from '../../../../models/range-protection-rule.model';-import type { IObjectModel, IObjectPointModel } from '../../type';import {DesktopLogService,ILogService,@@ -32,6 +27,8 @@ import {import { UnitObject } from '@univerjs/protocol';import { Subject } from 'rxjs';import { beforeEach, describe, expect, it, vi } from 'vitest';+import type { IRangeProtectionRule } from '../../../../models/range-protection-rule.model';+import type { IObjectModel, IObjectPointModel } from '../../type';import {EditStateEnum,RangeProtectionRuleModel,@@ -174,7 +171,7 @@ describe('WorksheetPermissionService', () => {unitId: 'book-1',subUnitId: 'sheet-1',viewState: ViewStateEnum.OthersCanView as ViewStateEnum,- editState: EditStateEnum.OnlyMe as RangeEditStateEnum,+ editState: EditStateEnum.OnlyMe as EditStateEnum,};rangeRuleModel.addRule('book-1', 'sheet-1', rangeRule);diff --git a/packages/ui/src/views/components/feature-search/FeatureSearch.tsx b/packages/ui/src/views/components/feature-search/FeatureSearch.tsxindex fca971b6e8..bf20a8787e 100644--- a/packages/ui/src/views/components/feature-search/FeatureSearch.tsx+++ b/packages/ui/src/views/components/feature-search/FeatureSearch.tsx@@ -14,14 +14,6 @@* limitations under the License.*/-import type { LocaleKey } from '../../../locale/types';-import type {- IMenuCommandParams,- IMenuItem,- IValueOption,- MenuItemDefaultValueType,-} from '../../../services/menu/menu';-import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { ICommandService, LocaleService, Tools } from '@univerjs/core';import {Command,@@ -34,6 +26,14 @@ import {import { useMemo } from 'react';import { combineLatest, isObservable, merge, of } from 'rxjs';import { map, startWith, switchMap } from 'rxjs/operators';+import type { LocaleKey } from '../../../locale/types';+import type {+ IMenuCommandParams,+ IMenuItem,+ IValueOption,+ MenuItemDefaultValueType,+} from '../../../services/menu/menu';+import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { IDialogService } from '../../../services/dialog/dialog.service';import { ILayoutService } from '../../../services/layout/layout.service';import { MenuItemType } from '../../../services/menu/menu';@@ -64,23 +64,6 @@ interface IMenuCandidate {parentTitle?: string;}-function resolveParams(item: IMenuItem, value: MenuItemDefaultValueType) {- const params = typeof item.params === 'function' ? item.params() : item.params;- return params ?? (value === undefined ? undefined : { value });-}--function resolveOptionParams(option: IValueOption) {- const params = typeof option.params === 'function' ? option.params(option.value) : option.params;- return params ?? (option.value === undefined ? undefined : { value: option.value });-}--function deduplicate(items: IFeatureSearchItem[]) {- // ponytail: Menu inventories are small; replace this scan only if profiling shows it is a hot path.- return items.filter((item, index) => items.findIndex((candidate) => (- candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)- )) === index);-}-export function FeatureSearch() {const menuManagerService = useDependency(IMenuManagerService);const localeService = useDependency(LocaleService);@@ -89,6 +72,23 @@ export function FeatureSearch() {const layoutService = useDependency(ILayoutService);const ribbonService = useDependency(IRibbonService);const items$ = useMemo(() => {+ function resolveParams(item: IMenuItem, value: MenuItemDefaultValueType) {+ const params = typeof item.params === 'function' ? item.params() : item.params;+ return params ?? (value === undefined ? undefined : { value });+ }++ function resolveOptionParams(option: IValueOption) {+ const params = typeof option.params === 'function' ? option.params(option.value) : option.params;+ return params ?? (option.value === undefined ? undefined : { value: option.value });+ }++ function deduplicate(items: IFeatureSearchItem[]) {+ // shortcut: quadratic scan for small menu inventories, optimize if profiling identifies a bottleneck.+ return items.filter((item, index) => items.findIndex((candidate) => (+ candidate.commandId === item.commandId && Tools.diffValue(candidate.params, item.params)+ )) === index);+ }+function getItemTitle(item: IMenuItem) {const titleKey = item.title ?? item.tooltip ?? item.description;return titleKey ? localeService.t(titleKey) : '';@@ -279,7 +279,7 @@ export function FeatureSearch() {<span className="univer-truncate">{item.title}</span></span>{item.path && (- <span className="univer-max-w-1/2 univer-truncate univer-text-xs univer-text-gray-400">+ <span className="univer-max-w-[50%] univer-truncate univer-text-xs univer-text-gray-400">{item.path}</span>)}diff --git a/packages/ui/src/views/components/ribbon/MobileRibbon.tsx b/packages/ui/src/views/components/ribbon/MobileRibbon.tsxindex 506d6cec93..2fc0480d63 100644--- a/packages/ui/src/views/components/ribbon/MobileRibbon.tsx+++ b/packages/ui/src/views/components/ribbon/MobileRibbon.tsx@@ -15,8 +15,6 @@*/import type { ComponentType } from 'react';-import type { LocaleKey } from '../../../locale/types';-import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { LocaleService, UniverInstanceType } from '@univerjs/core';import {borderBottomClassName,@@ -29,6 +27,8 @@ import {import { MoreHorizontalIcon, MoreLeftIcon, MoreRightIcon } from '@univerjs/icons';import { useContext, useEffect, useMemo, useRef, useState } from 'react';import { createPortal } from 'react-dom';+import type { LocaleKey } from '../../../locale/types';+import type { IMenuSchema } from '../../../services/menu/menu-manager.service';import { RibbonPosition, RibbonStartGroup } from '../../../services/menu/types';import { IRibbonService } from '../../../services/ribbon/ribbon.service';import { IWorkbenchService } from '../../../services/workbench/workbench.service';@@ -322,7 +322,6 @@ function MobileRibbonToolbar(props: IMobileRibbonProps & { ribbon: IMenuSchema[]<divkey={child.key}className={clsx(`- [&_button]:!univer-font-inherituniver-flex univer-h-8 univer-shrink-0 univer-items-centeruniver-rounded-md[&_*]:univer-box-border@@ -356,6 +355,7 @@ function MobileRibbonToolbar(props: IMobileRibbonProps & { ribbon: IMenuSchema[][&_button]:!univer-border-0 [&_button]:!univer-bg-transparent[&_button]:!univer-p-0 [&_button]:!univer-px-1.5[&_button]:!univer-leading-none [&_button]:!univer-outline-none+ [&_button]:![font-family:inherit][&_input]:!univer-m-0 [&_input]:!univer-appearance-none[&_input]:!univer-border-0 [&_input]:!univer-bg-transparent[&_input]:!univer-p-0 [&_input]:!univer-leading-nonediff --git a/packages/ui/src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx b/packages/ui/src/views/components/ribbon/ribbon-menu/ClassicMenu.tsxindex 033bc4eae3..4cd07908ec 100644--- a/packages/ui/src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx+++ b/packages/ui/src/views/components/ribbon/ribbon-menu/ClassicMenu.tsx@@ -14,9 +14,9 @@* limitations under the License.*/-import type { IMenuSchema } from '../../../../services/menu/menu-manager.service';import { LocaleService } from '@univerjs/core';import { clsx } from '@univerjs/design';+import type { IMenuSchema } from '../../../../services/menu/menu-manager.service';import { useDependency } from '../../../../utils/di';export function ClassicMenu({@@ -49,21 +49,21 @@ export function ClassicMenu({title={localeService.t(group.title || group.key)}onClick={() => onSelectTab(group)}className={clsx(`- univer-focus:outline-none univer-focus:ring-2 univer-focus:ring-primary-500- dark:!univer-focus:ring-primary-300univer-flex univer-cursor-pointer univer-appearance-none univer-items-center univer-gap-1univer-rounded-sm univer-border-none univer-px-2 univer-py-1 univer-text-smuniver-transition-colors+ focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-500+ dark:focus:!univer-ring-primary-300`, isActive? `univer-bg-primary-50 univer-font-semibold univer-text-primary-600 univer-shadow-smdark:!univer-bg-primary-900 dark:!univer-text-primary-300`: `- univer-hover:bg-gray-100- dark:!univer-hover:bg-gray-700univer-bg-transparent univer-text-gray-700+ hover:univer-bg-gray-100dark:!univer-text-gray-200+ dark:hover:!univer-bg-gray-700`)}>{localeService.t(group.title || group.key)}diff --git a/packages/ui/src/views/components/sidebar/Sidebar.tsx b/packages/ui/src/views/components/sidebar/Sidebar.tsxindex 96e510ff87..4e0770e5a8 100644--- a/packages/ui/src/views/components/sidebar/Sidebar.tsx+++ b/packages/ui/src/views/components/sidebar/Sidebar.tsx@@ -15,12 +15,12 @@*/import type { Attributes, ReactNode } from 'react';-import type { LocaleKey } from '../../../locale/types';-import type { ICustomLabelProps } from '../../custom-label/CustomLabel';import { LocaleService } from '@univerjs/core';import { borderLeftBottomClassName, clsx, scrollbarClassName } from '@univerjs/design';import { CloseIcon } from '@univerjs/icons';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';+import type { LocaleKey } from '../../../locale/types';+import type { ICustomLabelProps } from '../../custom-label/CustomLabel';import { ISidebarService } from '../../../services/sidebar/sidebar.service';import { useDependency, useObservable } from '../../../utils/di';import { CustomLabel } from '../../custom-label/CustomLabel';@@ -231,10 +231,10 @@ export function Sidebar() {{options?.visible && (<divclassName={`- hover:univer-bg-primary-500/30- active:univer-bg-primary-500/50univer-absolute univer-left-0 univer-top-0 univer-z-20 univer-h-full univer-w-1univer-cursor-col-resize univer-transition-colors+ hover:univer-bg-primary-500+ active:univer-bg-primary-500`}onMouseDown={handleResizeMouseDown}role="separator"@@ -281,11 +281,10 @@ export function Sidebar() {ref={closeButtonRef}type="button"className={`- focus:univer-ring-primary-500/50univer-flex univer-size-6 univer-cursor-pointer univer-appearance-none univer-items-centeruniver-justify-center univer-rounded-sm univer-border-none univer-bg-transparent univer-p-0univer-text-gray-500- focus:univer-outline-none focus:univer-ring-2+ focus:univer-outline-none focus:univer-ring-2 focus:univer-ring-primary-500dark:!univer-text-gray-300`}onClick={handleClose}diff --git a/packages/ui/src/views/emoji-picker/EmojiPicker.tsx b/packages/ui/src/views/emoji-picker/EmojiPicker.tsxindex 0cedb8c8bf..86f69a5b1a 100644--- a/packages/ui/src/views/emoji-picker/EmojiPicker.tsx+++ b/packages/ui/src/views/emoji-picker/EmojiPicker.tsx@@ -15,9 +15,6 @@*/import type { KeyboardEvent, ReactElement, UIEvent } from 'react';-import type { LocaleKey } from '../../locale/types';-import type { IPopup } from '../../services/popup/canvas-popup.service';-import type { EmojiCategory, EmojiSkinTone, IEmojiItem, IEmojiVariant } from './emoji-picker-utils';import { ILocalStorageService, LocaleService } from '@univerjs/core';import { borderTopClassName, Button, clsx, Dropdown, Input, scrollbarClassName } from '@univerjs/design';import {@@ -34,6 +31,9 @@ import {SymbolsIcon,} from '@univerjs/icons';import { useDeferredValue, useEffect, useMemo, useRef, useState } from 'react';+import type { LocaleKey } from '../../locale/types';+import type { IPopup } from '../../services/popup/canvas-popup.service';+import type { EmojiCategory, EmojiSkinTone, IEmojiItem, IEmojiVariant } from './emoji-picker-utils';import { useDependency, useObservable } from '../../utils/di';import { useVirtualList } from '../hooks/virtual-list';import {@@ -111,6 +111,36 @@ export function EmojiPicker(props: IEmojiPickerProps) {const recentStorageKey = extraProps?.recentStorageKey ?? RECENTS_STORAGE_KEY;const isSearching = deferredQuery.trim().length > 0;const { rows, sectionPositions } = useMemo(() => {+ function createEmojiVirtualRows(sections: IEmojiSection[], locale: string): {+ rows: EmojiVirtualRow[];+ sectionPositions: IEmojiSectionPosition[];+ } {+ const rows: EmojiVirtualRow[] = [];+ const sectionPositions: IEmojiSectionPosition[] = [];+ let top = 0;++ sections.forEach((section) => {+ if (!section.emojis.length) {+ return;+ }++ sectionPositions.push({ key: section.key, rowIndex: rows.length, top });+ rows.push({ key: `${locale}-${section.key}-header`, title: section.title, type: 'header' });+ top += EMOJI_SECTION_HEADER_HEIGHT;++ for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {+ rows.push({+ items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),+ key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,+ type: 'emojis',+ });+ top += EMOJI_ROW_HEIGHT;+ }+ });++ return { rows, sectionPositions };+ }+const normalSections: IEmojiSection[] = [{ key: 'recent', title: localeService.t<LocaleKey>('ui.emojiPicker.recents'), emojis: recents },...EMOJI_CATEGORIES.map((category) => ({@@ -131,7 +161,7 @@ export function EmojiPicker(props: IEmojiPickerProps) {}, [currentLocale, isSearching, localeService, recents, searchResults, skinTone]);const [virtualRows, { containerProps, scrollTo, wrapperStyle }] = useVirtualList(rows, {containerTarget: scrollRef,- itemHeight: getEmojiVirtualRowHeight,+ itemHeight: (_index, row) => row.type === 'header' ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT,overscan: EMOJI_VIRTUAL_OVERSCAN,});@@ -182,6 +212,24 @@ export function EmojiPicker(props: IEmojiPickerProps) {pendingSectionRef.current = null;}, [isSearching, scrollTo, sectionPositions]);+ function writeStorageItem<T>(localStorageService: ILocalStorageService, storageKey: string, value: T): void {+ localStorageService+ .setItem(storageKey, value)+ .catch(() => undefined);+ }++ function getActiveSectionByScrollTop(sectionPositions: IEmojiSectionPosition[], scrollTop: number): EmojiSectionKey {+ let active: EmojiSectionKey = 'recent';++ sectionPositions.forEach((position) => {+ if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) {+ active = position.key;+ }+ });++ return active;+ }+const handleSelect = (item: IEmojiItem, options?: { keepOpen?: boolean }) => {const nextRecents = promoteRecentEmoji(recents, item);setActiveEmoji(item.emoji);@@ -464,15 +512,13 @@ function EmojiButton(props: {aria-label={`${title}, ${props.moreTitle}`}title={`${title}, ${props.moreTitle}`}className="- univer-bg-gray-0/90- dark:!univer-bg-gray-800/90univer-absolute univer-bottom-0 univer-right-0 univer-flex univer-size-3 univer-cursor-pointer- univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-p-0- univer-text-gray-500+ univer-items-center univer-justify-center univer-rounded-sm univer-border-0 univer-bg-gray-0+ univer-p-0 univer-text-gray-500hover:univer-bg-gray-100 hover:univer-text-gray-700focus-visible:univer-outline-none focus-visible:univer-ring-1focus-visible:univer-ring-primary-600- dark:!univer-text-gray-300+ dark:!univer-bg-gray-800 dark:!univer-text-gray-300dark:hover:!univer-bg-gray-700">@@ -644,58 +690,6 @@ function CategoryButton(props: { children: ReactElement; onClick: () => void; se);}-function writeStorageItem<T>(localStorageService: ILocalStorageService, storageKey: string, value: T): void {- localStorageService- .setItem(storageKey, value)- .catch(() => undefined);-}--function createEmojiVirtualRows(sections: IEmojiSection[], locale: string): {- rows: EmojiVirtualRow[];- sectionPositions: IEmojiSectionPosition[];-} {- const rows: EmojiVirtualRow[] = [];- const sectionPositions: IEmojiSectionPosition[] = [];- let top = 0;-- sections.forEach((section) => {- if (!section.emojis.length) {- return;- }-- sectionPositions.push({ key: section.key, rowIndex: rows.length, top });- rows.push({ key: `${locale}-${section.key}-header`, title: section.title, type: 'header' });- top += EMOJI_SECTION_HEADER_HEIGHT;-- for (let start = 0; start < section.emojis.length; start += EMOJI_COLUMN_COUNT) {- rows.push({- items: section.emojis.slice(start, start + EMOJI_COLUMN_COUNT),- key: `${locale}-${section.key}-${start / EMOJI_COLUMN_COUNT}`,- type: 'emojis',- });- top += EMOJI_ROW_HEIGHT;- }- });-- return { rows, sectionPositions };-}--function getEmojiVirtualRowHeight(_index: number, row: EmojiVirtualRow): number {- return row.type === 'header' ? EMOJI_SECTION_HEADER_HEIGHT : EMOJI_ROW_HEIGHT;-}--function getActiveSectionByScrollTop(sectionPositions: IEmojiSectionPosition[], scrollTop: number): EmojiSectionKey {- let active: EmojiSectionKey = 'recent';-- sectionPositions.forEach((position) => {- if (position.top <= scrollTop + ACTIVE_SECTION_SCROLL_OFFSET) {- active = position.key;- }- });-- return active;-}-function CategoryIcon(props: { category: EmojiCategory }) {switch (props.category) {case 'activity':diff --git a/packages/ui/src/views/emoji-picker/__tests__/EmojiPicker.spec.tsx b/packages/ui/src/views/emoji-picker/__tests__/EmojiPicker.spec.tsxindex c14d5f0786..67a1d6c377 100644--- a/packages/ui/src/views/emoji-picker/__tests__/EmojiPicker.spec.tsx+++ b/packages/ui/src/views/emoji-picker/__tests__/EmojiPicker.spec.tsx@@ -14,11 +14,9 @@* limitations under the License.*/-import type { ILocalStorageService as ILocalStorageServiceType } from '@univerjs/core';import type { ComponentType, ReactElement } from 'react';import { cleanup, fireEvent, render, waitFor } from '@testing-library/react';import { ILocalStorageService, Injector, LocaleService, LocaleType } from '@univerjs/core';-import { scrollbarClassName } from '@univerjs/design';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import enUS from '../../../locale/en-US';import zhCN from '../../../locale/zh-CN';@@ -26,7 +24,7 @@ import { connectInjector } from '../../../utils/di';import { SymbolPicker } from '../../symbol-picker/SymbolPicker';import { EmojiPicker } from '../EmojiPicker';-class TestLocalStorageService implements ILocalStorageServiceType {+class TestLocalStorageService implements ILocalStorageService {async getItem<T>(): Promise<T | null> {return null;}@@ -131,15 +129,6 @@ describe('picker callbacks', () => {});});- it('uses the design scrollbar styles for emoji content', () => {- const { container } = renderWithDependencies(<EmojiPicker />);- const scrollContainer = container.querySelector('.univer-overflow-y-auto');-- for (const className of scrollbarClassName.split(' ')) {- expect(scrollContainer?.classList.contains(className)).toBe(true);- }- });-it('finds localized titles and aliases with the compact locale data', async () => {const onChange = vi.fn();const { getByRole } = renderWithDependencies(<EmojiPicker onChange={onChange} />, LocaleType.ZH_CN);@@ -172,13 +161,4 @@ describe('picker callbacks', () => {expect(onChange).toHaveBeenCalledWith('∞');});-- it('uses the design scrollbar styles for symbol content', () => {- const { container } = renderWithDependencies(<SymbolPicker />);- const scrollContainer = container.querySelector('.univer-overflow-y-auto');-- for (const className of scrollbarClassName.split(' ')) {- expect(scrollContainer?.classList.contains(className)).toBe(true);- }- });});diff --git a/packages/ui/src/views/hooks/virtual-list.ts b/packages/ui/src/views/hooks/virtual-list.tsindex ee9c448ed3..0b3979ae83 100644--- a/packages/ui/src/views/hooks/virtual-list.ts+++ b/packages/ui/src/views/hooks/virtual-list.ts@@ -35,20 +35,9 @@ function useLatest<T>(value: T) {return ref;}-// eslint-disable-next-line max-lines-per-function-const useVirtualList = <T>(list: T[], options: IVirtualListOptions<T>) => {- const { containerTarget, itemHeight, overscan = 5 } = options;-+function useVirtualListMetrics<T>(list: T[], itemHeight: number | ItemHeight<T>) {const itemHeightRef = useLatest(itemHeight);- const [size, setSize] = useState<Nullable<{ width: number; height: number }>>(null);-- const scrollTriggerByScrollToFunc = useRef(false);-- const [targetList, setTargetList] = useState<{ index: number; data: T }[]>([]);-- const [wrapperStyle, setWrapperStyle] = useState<{ height: string | undefined; marginTop: string | undefined }>({ height: undefined, marginTop: undefined });-const getVisibleCount = (containerHeight: number, fromIndex: number) => {if (typeof itemHeightRef.current === 'number') {return Math.ceil(containerHeight / itemHeightRef.current);@@ -84,7 +73,6 @@ const useVirtualList = <T>(list: T[], options: IVirtualListOptions<T>) => {return offset + 1;};- // Get top heightconst getDistanceTop = (index: number) => {if (typeof (itemHeightRef.current) === 'number') {const height = index * itemHeightRef.current;@@ -106,6 +94,47 @@ const useVirtualList = <T>(list: T[], options: IVirtualListOptions<T>) => {);}, [list]);+ return { getVisibleCount, getOffset, getDistanceTop, totalHeight };+}++function useContainerSize(containerTarget: RefObject<HTMLElement | null>) {+ const [size, setSize] = useState<Nullable<{ width: number; height: number }>>(null);++ useEffect(() => {+ if (containerTarget.current) {+ const getSize = () => {+ const width = containerTarget.current!.clientWidth;+ const height = containerTarget.current!.clientHeight;+ if (width !== size?.width || height !== size?.height) {+ setSize({ width, height });+ }+ };++ getSize();+ const ob = new ResizeObserver(getSize);+ ob.observe(containerTarget.current);+ return () => {+ ob.disconnect();+ };+ }+ }, []);++ return size;+}++const useVirtualList = <T>(list: T[], options: IVirtualListOptions<T>) => {+ const { containerTarget, itemHeight, overscan = 5 } = options;++ const { getVisibleCount, getOffset, getDistanceTop, totalHeight } = useVirtualListMetrics(list, itemHeight);++ const size = useContainerSize(containerTarget);++ const scrollTriggerByScrollToFunc = useRef(false);++ const [targetList, setTargetList] = useState<{ index: number; data: T }[]>([]);++ const [wrapperStyle, setWrapperStyle] = useState<{ height: string | undefined; marginTop: string | undefined }>({ height: undefined, marginTop: undefined });+const calculateRange = () => {const container = containerTarget.current;@@ -134,25 +163,6 @@ const useVirtualList = <T>(list: T[], options: IVirtualListOptions<T>) => {}};- useEffect(() => {- if (containerTarget.current) {- const getSize = () => {- const width = containerTarget.current!.clientWidth;- const height = containerTarget.current!.clientHeight;- if (width !== size?.width || height !== size?.height) {- setSize({ width, height });- }- };-- getSize();- const ob = new ResizeObserver(getSize);- ob.observe(containerTarget.current);- return () => {- ob.disconnect();- };- }- }, []);-useEffect(() => {if (!size?.width || !size?.height) {return;diff --git a/packages/ui/src/views/menu/desktop/TinyMenuGroup.tsx b/packages/ui/src/views/menu/desktop/TinyMenuGroup.tsxindex 990637465c..b3980a3b14 100644--- a/packages/ui/src/views/menu/desktop/TinyMenuGroup.tsx+++ b/packages/ui/src/views/menu/desktop/TinyMenuGroup.tsx@@ -14,14 +14,14 @@* limitations under the License.*/-import type { IDisplayMenuItem, IMenuItem, IValueOption, MenuItemDefaultValueType } from '../../../services/menu/menu';-import type { IMenuSchema } from '../../../services/menu/menu-manager.service';-import type { TinyMenuLayoutVariant, TinyMenuSizeVariant } from './DesignTinyMenuGroup';import { LocaleService } from '@univerjs/core';import { cva } from '@univerjs/design';import { useMemo } from 'react';import { combineLatest, map, of, startWith } from 'rxjs';-import { IconManager } from '../../../common';+import type { IDisplayMenuItem, IMenuItem, IValueOption, MenuItemDefaultValueType } from '../../../services/menu/menu';+import type { IMenuSchema } from '../../../services/menu/menu-manager.service';+import type { TinyMenuLayoutVariant, TinyMenuSizeVariant } from './DesignTinyMenuGroup';+import { IconManager } from '../../../common/icon-manager';import { useDependency, useObservable } from '../../../utils/di';import { DesignTinyMenuGroup } from './DesignTinyMenuGroup';@@ -225,7 +225,7 @@ export function UIQuickTileMenuGroup(props: IUIQuickMenuGroupProps) {}return (- <div className="univer-item-center univer-grid univer-grid-cols-3 univer-gap-1.5 univer-py-1">+ <div className="univer-grid univer-grid-cols-3 univer-items-center univer-gap-1.5 univer-py-1">{getVisibleTinyMenuChildren(item.children, hiddenItemIds).map((menuSchema) => (<QuickTileMenuItemkey={menuSchema.key}diff --git a/packages/ui/src/views/notification/Notification.stories.tsx b/packages/ui/src/views/notification/Notification.stories.tsxindex 20a36e64ed..9fa3244c13 100644--- a/packages/ui/src/views/notification/Notification.stories.tsx+++ b/packages/ui/src/views/notification/Notification.stories.tsx@@ -41,14 +41,14 @@ function NotificationStoryShell({ title, description, children }: { title: strin><divclassName={`- univer-border-gray-0/20 univer-bg-gray-0/10 univer-mx-auto univer-max-w-5xl univer-rounded-3xl- univer-border univer-border-solid univer-p-8 univer-backdrop-blur-xl+ univer-mx-auto univer-max-w-5xl univer-rounded-3xl univer-border univer-border-solid+ univer-border-gray-0 univer-bg-gray-0 univer-p-8`}><h2className="univer-m-0 univer-font-sans univer-text-2xl univer-font-semibold univer-tracking-tight- univer-text-gray-0+ univer-text-gray-900">{title}@@ -56,7 +56,7 @@ function NotificationStoryShell({ title, description, children }: { title: strin<pclassName="univer-mb-0 univer-mt-2 univer-max-w-3xl univer-font-sans univer-text-sm univer-leading-6- univer-text-slate-200+ univer-text-gray-600">{description}diff --git a/packages/ui/src/views/slider/Slider.tsx b/packages/ui/src/views/slider/Slider.tsxindex 3cd9f8d9e1..36cd8f3b23 100644--- a/packages/ui/src/views/slider/Slider.tsx+++ b/packages/ui/src/views/slider/Slider.tsx@@ -15,10 +15,10 @@*/import type { KeyboardEvent, PointerEvent } from 'react';-import type { LocaleKey } from '../../locale/types';import { LocaleService } from '@univerjs/core';import { borderClassName, Button, clsx } from '@univerjs/design';import { useEffect, useRef, useState } from 'react';+import type { LocaleKey } from '../../locale/types';import { IconManager } from '../../common/icon-manager';import { useDependency, useObservable } from '../../utils/di';import { ZoomInput } from './ZoomInput';@@ -313,7 +313,7 @@ export function Slider(props: ISliderProps) {><divclassName={clsx(`- univer-bg-primary-500/60 univer-absolute univer-top-0 univer-h-full univer-rounded-full+ univer-absolute univer-top-0 univer-h-full univer-rounded-full univer-bg-primary-500`, isRtl ? 'univer-right-0' : 'univer-left-0')}style={{width: `${sliderOffset}%`,