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
refactor(base-ui): refactor `NeoCustomLabel` (#365)
白熱7194b0a5f7c6
diff --git a/docs/zh/achitecture.md b/docs/zh/achitecture.mdindex d1e73e1c9c..40c83fedff 100644--- a/docs/zh/achitecture.md+++ b/docs/zh/achitecture.md@@ -259,7 +259,6 @@ interface IMenuItemBase<V> {/** On observable value that should emit the value of the corresponding selection component. */value$?: Observable<V>;- onClose?: () => void;}export interface IMenuService {diff --git a/packages/base-slides/src/Model/ToolbarModel.ts b/packages/base-slides/src/Model/ToolbarModel.tsindex 016858899e..255ab808d9 100644--- a/packages/base-slides/src/Model/ToolbarModel.ts+++ b/packages/base-slides/src/Model/ToolbarModel.ts@@ -1,4 +1,4 @@-// import { BaseSelectChildrenProps, BaseSelectProps } from '../View/UI/Common/Select/Select';+// import { BaseSelectChildrenProps, IBaseSelectProps } from '../View/UI/Common/Select/Select';// import { BaseTextButtonProps } from '../View/UI/Common/TextButton/TextButton';// export interface IShowToolbarConfig {@@ -53,7 +53,7 @@// children?: BaseToolbarSelectChildrenProps[];// }-// interface BaseToolbarSelectProps extends BaseSelectProps {+// interface BaseToolbarSelectProps extends IBaseSelectProps {// locale?: string;// suffixLocale?: string;// children?: BaseToolbarSelectChildrenProps[];diff --git a/packages/base-ui/package.json b/packages/base-ui/package.jsonindex 5a9d0a70d4..129200ce77 100644--- a/packages/base-ui/package.json+++ b/packages/base-ui/package.json@@ -52,6 +52,7 @@"@univerjs/design": "workspace:*","@univerjs/icons": "^0.1.3","@wendellhu/redi": "^0.12.10",+ "clsx": "^2.0.0","localforage": "^1.10.0","rc-menu": "^9.12.2","rc-notification": "^5.3.0",diff --git a/packages/base-ui/src/Common/AppContext.tsx b/packages/base-ui/src/Common/AppContext.tsxdeleted file mode 100644index 74d6eaaa93..0000000000--- a/packages/base-ui/src/Common/AppContext.tsx+++ /dev/null@@ -1,22 +0,0 @@-/**- * Use createContext to provide global language and skin settings- */-import { LocaleService, LocaleType, ThemeService } from '@univerjs/core';-import { Injector } from '@wendellhu/redi';-import { createContext } from 'react';--import { ComponentManager } from './ComponentManager';-import { ZIndexManager } from './ZIndexManager';--export type AppContextValues = {- injector: Injector;- locale: LocaleType;- localeService: LocaleService;- themeService: ThemeService;- componentManager: ComponentManager;- zIndexManager: ZIndexManager;-};-/**- * @deprecated- */-export const AppContext = createContext<AppContextValues>({} as unknown as AppContextValues);diff --git a/packages/base-ui/src/Common/ComponentManager.ts b/packages/base-ui/src/Common/ComponentManager.tsindex 21033a6877..8a7c8ec65f 100644--- a/packages/base-ui/src/Common/ComponentManager.ts+++ b/packages/base-ui/src/Common/ComponentManager.ts@@ -42,13 +42,13 @@ export interface ICustomComponent {props?: any;}-export type ComponentList = Map<string, Function>;+export type ComponentList = Map<string, React.ForwardRefExoticComponent<any>>;export class ComponentManager {private _componentList: ComponentList = new Map();constructor() {- const iconList: Record<string, Function> = {+ const iconList: Record<string, React.ForwardRefExoticComponent<any>> = {AlignBottomSingle,AlignTopSingle,AllBorderSingle,diff --git a/packages/base-ui/src/Common/index.ts b/packages/base-ui/src/Common/index.tsindex a4dea8518d..932bb4dee0 100644--- a/packages/base-ui/src/Common/index.ts+++ b/packages/base-ui/src/Common/index.ts@@ -1,3 +1,2 @@-export * from './AppContext';export * from './ComponentManager';export * from './ZIndexManager';diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsxdeleted file mode 100644index d91a1ead06..0000000000--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx+++ /dev/null@@ -1,77 +0,0 @@-import { LocaleService } from '@univerjs/core';-import { CheckMarkSingle } from '@univerjs/icons';-import { useDependency } from '@wendellhu/redi/react-bindings';--import { ComponentManager, ICustomComponent } from '../../Common';-import { IMenuSelectorItem } from '../../services/menu/menu';--export interface IBaseCustomLabelProps {- icon?: string;- value?: string;- label: string | ICustomComponent | React.ReactNode;- onChange?: (e: Event) => void;- selected?: boolean;- title?: string;-}--export interface INeoCustomLabelProps {- value?: string | number | undefined;- selected?: boolean;- /**- * Triggered after value change- */- onChange?(v: string | number): void;- /**- * Triggered after input Enter or Blur- */- onValueChange?(v: string | number): void;- onFocus?: (e: React.FocusEvent<HTMLInputElement, Element>) => void;-}--/**- * The component to render toolbar item label and menu item label.- * @param props- * @returns- * @deprecated- */-export function NeoCustomLabel(- props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'title'> & INeoCustomLabelProps-): JSX.Element | null {- const { title, icon, label, selected } = props;- const localeService = useDependency(LocaleService);- const componentManager = useDependency(ComponentManager);-- function getLocale(name: string) {- return localeService.t(name) ?? name;- }-- const nodes = [];- let index = 0;- if (icon) {- const LabelComponent = componentManager.get(icon) as any;- nodes.push(<LabelComponent key={index++} extend={{ colorChannel1: 'rgb(var(--primary-color))' }} />);- }- if (label) {- const labelName = typeof label === 'string' ? label : (label as ICustomComponent).name;-- const customProps = (label as ICustomComponent).props ?? {};-- const LabelComponent = componentManager.get(labelName) as any;- LabelComponent && nodes.push(<LabelComponent key={index++} {...customProps} {...props} />);- }- if (title) {- nodes.push(<span key={index++}>{getLocale(title)}</span>);- }-- // Process Font Family drop-down list font- return (- <div>- {selected && (- <span>- <CheckMarkSingle style={{ color: 'rgb(var(--success-color))' }} />- </span>- )}- {nodes}- </div>- );-}diff --git a/packages/base-ui/src/Components/Input/Input.stories.tsx b/packages/base-ui/src/Components/Input/Input.stories.tsxdeleted file mode 100644index 7d8488c73e..0000000000--- a/packages/base-ui/src/Components/Input/Input.stories.tsx+++ /dev/null@@ -1,23 +0,0 @@-import type { Meta } from '@storybook/react';--import { Input } from './Input';--const meta: Meta<typeof Input> = {- title: 'Components / Input',- component: Input,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],- args: {- placeholder: 'Your Content',- bordered: true,- type: 'text',- },-};--export default meta;--export const Playground = {- args: {},-};diff --git a/packages/base-ui/src/Components/Input/Input.tsx b/packages/base-ui/src/Components/Input/Input.tsxdeleted file mode 100644index 8473782bfe..0000000000--- a/packages/base-ui/src/Components/Input/Input.tsx+++ /dev/null@@ -1,222 +0,0 @@-import React, { useEffect, useMemo, useRef, useState } from 'react';--import { BaseComponentProps } from '../../BaseComponent';-import { joinClassNames } from '../../Utils/util';-import styles from './Style/index.module.less';--// Component Interface-export interface BaseInputProps extends BaseComponentProps {- /**- * Input's class name- */- className?: string;-- /** Semantic DOM style */- style?: React.CSSProperties;-- /**- * The type of input- * @default 'text'- */- type?:- | 'text'- | 'button'- | 'checkbox'- | 'file'- | 'hidden'- | 'image'- | 'password'- | 'radio'- | 'reset'- | 'submit'- | 'number';-- /**- * The input content value- */- value?: string;-- /**- * The input content placeholder- */- placeholder?: string;-- /**- *- * Callback when user input- */- onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;-- /**- * Whether has border style- * @default true- */- bordered?: boolean;-- /**- * Whether the input is disabled- * @default false- */- disabled?: boolean;-- /**- * The maximum number of characters in Input- */- maxLength?: number;-- /**- * Whether the input is focused- */- onFocus?: (e: React.FocusEvent<HTMLInputElement, Element>) => void;-- /**- * Whether the input is blur- */- onBlur?: (e: React.FocusEvent<HTMLInputElement, Element>) => void;-- /**- * Whether the input is clicked- */- onClick?: (e: React.MouseEvent<HTMLInputElement, MouseEvent>) => void;-- onValueChange?: (value: string) => void;-- /**- * Whether the input is read only- * @default false- */- readonly?: boolean;-- /**- * Input's id- */- id?: string;-- /**- * When Type is Number, the maximum value- */- max?: number;-- /**- * When Type is Number, the minimum value- */- min?: number;-}--/**- * Input Component- */-export function Input(props: BaseInputProps) {- const ref = useRef<HTMLInputElement>(null);- const [value, setValue] = useState(props.value);- const [focused, setFocused] = useState(false);-- const realValue = useMemo(() => value ?? props.value ?? '', [value, props.value]);-- useEffect(() => {- if (props.value && props.value !== value) {- setValue(props.value);- }- }, [props.value]);-- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const { onChange } = props;- const target = e.target;-- setValue(target.value);- if (!onChange) return;- onChange(e);- };-- const handlePressEnter = (e: React.KeyboardEvent<HTMLInputElement>) => {- if (e.key === 'Enter') {- ref.current?.blur();- }- };-- const onFocus = (e: React.FocusEvent<HTMLInputElement, Element>) => {- const { onFocus } = props;- onFocus?.(e);- setFocused(true);- };-- const onClick = (e: React.MouseEvent<HTMLInputElement, MouseEvent>) => {- e.stopPropagation();- const { onClick } = props;- onClick?.(e);- };-- const onBlur = (e: React.FocusEvent<HTMLInputElement, Element>) => {- const { onBlur, onValueChange } = props;- onBlur?.(e);- let v = getValue();-- if (v == null) return;-- // Limit the size according to MAX MIN- const { max, min } = props;- if (props.type === 'number') {- if (typeof max === 'number' && +v > max) {- setValue(max.toString());- v = max.toString();- } else if (typeof min === 'number' && +v < min) {- setValue(min.toString());- v = min.toString();- } else {- setValue(v);- }- } else {- setValue(v);- }-- v && onValueChange?.(v);- setFocused(false);- };-- const getValue = () => ref.current?.value;-- const {- id,- disabled,- type = 'text',- placeholder,- bordered = true,- className = '',- style = {},- readonly,- maxLength,- max,- min,- } = props;-- const classes = joinClassNames(- styles.input,- {- [`${styles.input}-disable`]: disabled,- [`${styles.input}-borderless`]: !bordered,- },- className- );-- return (- <input- type={type}- style={style}- onBlur={onBlur}- onFocus={onFocus}- className={classes}- maxLength={maxLength}- placeholder={placeholder}- disabled={disabled}- ref={ref}- onChange={handleChange}- value={realValue}- onClick={onClick}- readOnly={readonly}- id={id}- onKeyUp={handlePressEnter}- max={max}- min={min}- />- );-}diff --git a/packages/base-ui/src/Components/Input/Style/index.module.less b/packages/base-ui/src/Components/Input/Style/index.module.lessdeleted file mode 100644index fc75d55575..0000000000--- a/packages/base-ui/src/Components/Input/Style/index.module.less+++ /dev/null@@ -1,5 +0,0 @@-// @import './mixin.less';--// .input {-// .input();-// }diff --git a/packages/base-ui/src/Components/Input/Style/mixin.less b/packages/base-ui/src/Components/Input/Style/mixin.lessdeleted file mode 100644index 3631c3a557..0000000000--- a/packages/base-ui/src/Components/Input/Style/mixin.less+++ /dev/null@@ -1,81 +0,0 @@-// @import '../../../Basics/CSS/Skin/default.module.less';--// .active() {-// outline: 0;-// box-shadow: var(--box-shadow-base);-// }--// .hover(@color: var(--primary-color-hover)) {-// border-color: @color;-// }--// .disabled() {-// color: var(--grey-200);-// background-color: var(--bg-color-secondary);-// border-color: var(--grey-200);-// box-shadow: none;-// cursor: not-allowed;-// opacity: 1;--// &:hover {-// .hover(var(--grey-200));-// }-// }--// .input() {-// position: relative;-// display: inline-block;-// width: 100%;-// height: 100%;-// box-sizing: border-box;-// padding: 10px 20px;-// color: var(--text-color);-// font-size: var(--font-size-base);-// background-color: var(--bg-color-secondary);-// border: 1px solid var(--grey-200);-// border-radius: var(--border-radius-base);-// transition: all 0.3s;--// &:hover {-// .hover();-// }--// &:focus,-// &-focused {-// .active();-// }--// &[disabled] {-// .disabled();-// }--// &-disabled {-// .disabled();-// }--// &-borderless {-// border: 1px solid transparent;-// box-shadow: none;--// &:hover {-// border-color: transparent;-// }--// &:focus,-// &-focused {-// border-color: var(--primary-color-hover);-// .active();-// }-// }--// // Remove Arrows/Spinners-// &::-webkit-outer-spin-button,-// &::-webkit-inner-spin-button{-// -webkit-appearance: none;-// margin: 0;-// }--// &[type=number] {-// -moz-appearance: textfield;-// }-// }diff --git a/packages/base-ui/src/Components/Input/index.ts b/packages/base-ui/src/Components/Input/index.tsdeleted file mode 100644index ba9fe7ebc6..0000000000--- a/packages/base-ui/src/Components/Input/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './Input';diff --git a/packages/base-ui/src/Components/Input/test/index.test.tsx b/packages/base-ui/src/Components/Input/test/index.test.tsxdeleted file mode 100644index 1ccf5a940a..0000000000--- a/packages/base-ui/src/Components/Input/test/index.test.tsx+++ /dev/null@@ -1,49 +0,0 @@-import { fireEvent, render } from '@testing-library/react';-import { describe, expect, test } from 'vitest';--import { Input } from '..';--describe('input', () => {- test('render', () => {- const { container } = render(<Input value="test" readonly disabled placeholder="haha" bordered />);- expect(container);- });-- test('input event', () => {- const { container } = render(<Input value="test" placeholder="haha" bordered />);- const input = container.querySelector('input');- fireEvent.input(input!, { target: { value: '23' } });- expect(input!.value).toBe('23');- });-- test('click event', () => {- let a = 1;- const { container } = render(<Input value="test" readonly onClick={() => a++} placeholder="haha" />);- fireEvent.click(container.querySelector('input')!);- expect(a).toEqual(2);- });-- test('blur event', () => {- let a = 1;- const { container } = render(<Input value="test" readonly onBlur={() => a++} disabled placeholder="haha" />);- fireEvent.blur(container.querySelector('input')!);- expect(a).toEqual(2);- });-- test('focus event', () => {- let a = 1;- const { container } = render(- <Input value="test" readonly onFocus={() => a++} disabled placeholder="haha" className="test" />- );- fireEvent.focus(container.querySelector('input')!);- expect(a).toEqual(2);- });-- test('change event', () => {- let a = 1;- const { container } = render(<Input value="test" onChange={() => a++} placeholder="haha" className="test" />);- const input = container.querySelector('input');- fireEvent.change(input!, { target: { value: 'new value' } });- expect(a).toEqual(2);- });-});diff --git a/packages/base-ui/src/Components/Select/Select.stories.tsx b/packages/base-ui/src/Components/Select/Select.stories.tsxdeleted file mode 100644index 966fdb445a..0000000000--- a/packages/base-ui/src/Components/Select/Select.stories.tsx+++ /dev/null@@ -1,21 +0,0 @@-import type { Meta } from '@storybook/react';--import { Select } from './Select';--const meta: Meta<typeof Select> = {- title: 'Components / Select',- component: Select,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],- args: {- label: 'test select',- },-};--export default meta;--export const Playground = {- args: {},-};diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsxdeleted file mode 100644index e4f57611cc..0000000000--- a/packages/base-ui/src/Components/Select/Select.tsx+++ /dev/null@@ -1,110 +0,0 @@-import { Dropdown } from '@univerjs/design';-import { MoreDownSingle } from '@univerjs/icons';-import React from 'react';--import { ICustomComponent } from '../../Common';-import { IValueOption } from '../../services/menu/menu';-import { NeoCustomLabel } from '../CustomLabel';-import { Menu } from '../Menu/Menu';-import styles from './index.module.less';--// TODO: these type definitions should be moved out of components to menu service--export interface BaseMenuItem {- className?: string;- style?: React.CSSProperties;- label?: React.ReactNode;- value?: any;- children?: BaseMenuItem[];- show?: boolean;- disabled?: boolean;- onClick?: (...arg: any) => void;- border?: boolean;-}-export interface BaseItemProps extends BaseMenuItem {- selected?: boolean;- suffix?: React.ReactNode;- border?: boolean;-}--export interface BaseSelectChildrenProps extends Omit<BaseItemProps, 'suffix' | 'label' | 'children'> {- onPressEnter?: (...arg: any) => void;- children?: BaseSelectChildrenProps[];- unSelectable?: boolean; //选中后不生效事件- label?: ICustomComponent | React.ReactNode | string;- suffix?: ICustomComponent | React.ReactNode | string;- name?: string;-}--export interface BaseSelectProps {- children?: BaseSelectChildrenProps[];- label?:- | string- | {- name: string;- props?: Record<string, string | number>;- };- onClick?: (...arg: any) => void; //下拉Ul点击事件- onPressEnter?: (...arg: any) => void;- onMainClick?: () => void; // 非功能按钮事件- defaultColor?: string;- hideSelectedIcon?: boolean;- className?: string;- name?: string;- suffix?: any;- value?: string | number;- icon?: string;- id?: string;- options?: IValueOption[];- title?: string;- onClose?: () => void;- max?: number; // input maximum value- min?: number; // INPUT minimum value-- onMouseLeave?: React.MouseEventHandler;-}--export function Select(props: BaseSelectProps) {- const renderNeo = () => {- const { onClick, ...restProps } = props;- const { value, icon, title, id, label, options, onClose, max, min } = restProps;-- const onOptionSelect = (option: IValueOption) => {- onClick?.(option);- };-- const iconToDisplay = options?.find((o) => o.value === value)?.icon ?? icon;-- return (- <div className={styles.selectDouble}>- <Dropdown- {...restProps}- overlay={- <Menu- menuType={id}- options={options}- onOptionSelect={onOptionSelect}- value={value}- onClose={onClose}- />- }- >- <div className={styles.selectLabel}>- <NeoCustomLabel- icon={iconToDisplay}- title={title!}- value={value}- label={label}- onChange={(v) => onClick?.(v)}- />- <div className={styles.selectDropIcon}>- <MoreDownSingle />- </div>- </div>- </Dropdown>- </div>- );- };-- return <div className={styles.selectComponent}>{renderNeo()}</div>;-}diff --git a/packages/base-ui/src/Components/Select/index.module.less b/packages/base-ui/src/Components/Select/index.module.lessdeleted file mode 100644index 783eb70bdc..0000000000--- a/packages/base-ui/src/Components/Select/index.module.less+++ /dev/null@@ -1,45 +0,0 @@-@select-component-height: 28px;--.select-component {- position: relative;- height: @select-component-height;- padding: 0 var(--padding-xs);- border-radius: var(--border-radius-base);- display: flex;- align-items: center;- cursor: pointer;-- &:hover {- background-color: rgb(var(--grey-100));- border-radius: var(--border-radius-base);- }-- .select-button {-- }-- .select-single {- text-overflow: ellipsis;- white-space: nowrap;- }-- .select-double {- height: 100%;- }-- .select-label {- height: 100%;- display: flex;- align-items: center;- font-size: var(--font-size-lg);- gap: var(--margin-xxs);- }-}--.select-drop-icon {- height: 100%;- display: flex;- align-items: center;- color: rgb(var(--grey-400));- font-size: 10px;-}diff --git a/packages/base-ui/src/Components/Select/index.ts b/packages/base-ui/src/Components/Select/index.tsdeleted file mode 100644index 7868ecbae2..0000000000--- a/packages/base-ui/src/Components/Select/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './Select';diff --git a/packages/base-ui/src/Components/Tabs/Tabs.stories.tsx b/packages/base-ui/src/Components/Tabs/Tabs.stories.tsxdeleted file mode 100644index 78b9f5ee1a..0000000000--- a/packages/base-ui/src/Components/Tabs/Tabs.stories.tsx+++ /dev/null@@ -1,29 +0,0 @@-import type { Meta } from '@storybook/react';--import { TabPane, Tabs } from './Tabs';--const meta: Meta<typeof Tabs> = {- title: 'Components / Tabs',- component: Tabs,- parameters: {- layout: 'centered',- },- tags: ['autodocs'],- args: {- children: [- <TabPane label="test" keys="test" active>- <div>test content</div>- </TabPane>,- <TabPane label="test1" keys="test1">- <div>test1 content</div>- </TabPane>,- ],- activeKey: 'test1',- },-};--export default meta;--export const Playground = {- args: {},-};diff --git a/packages/base-ui/src/Components/Tabs/Tabs.tsx b/packages/base-ui/src/Components/Tabs/Tabs.tsxdeleted file mode 100644index 97615f4734..0000000000--- a/packages/base-ui/src/Components/Tabs/Tabs.tsx+++ /dev/null@@ -1,419 +0,0 @@-import React, { createRef, ReactNode, useEffect, useImperativeHandle, useState } from 'react';--import { joinClassNames, randomId } from '../../Utils';-import styles from './index.module.less';--// Components interface--// Props of tab pane-export interface IBaseTabPaneProps {- /**- * TabPane's head display content- */- children?: ReactNode;-- /**- * TabPane's id- */- id?: string;-- /**- * Class name of tab pane- */- className?: string;-- /**- * Style of tab pane- */- style?: React.CSSProperties;-- /**- * TabPane's head display content- */- label: ReactNode;-- /**- * Active status of tab pane- */- active?: boolean;-- /**- * TabPane's key- */- keys?: string;-}--// Props of tabs-export interface IBaseTabsProps {- /**- * Basic style of tabs- */- type?: 'card';-- /**- * Current TabPane's key- */- activeKey?: string;-- /**- * Callback executed when tab is clicked- */- onTabClick?: (activeKey: string, e: Event) => void;-- /**- * Class name of tab container- */- className?: string;-- /**- * Style of tab container- */- style?: React.CSSProperties;-- /**- * Content of tab- */- children: Array<React.ReactElement<IBaseTabPaneProps, string>>;-- /**- * Tab pane is draggable- * @default false- */- draggable?: boolean;- /**- * Re-render when it changes- */- reRenderString?: string;-}--interface ITabInfo {- min: number;- max: number;-}--export interface ITabRef {- scrollContent: (offset: number) => void;-}--/**- * Tabs Component- */-export const Tabs = React.memo(- React.forwardRef<ITabRef, IBaseTabsProps>((props: IBaseTabsProps, ref) => {- const { type = 'line', className = '', draggable = false } = props;- const [active, setActive] = useState<string>(props.activeKey ?? ''); // Initialize active with the provided activeKey- const parent = createRef<HTMLDivElement>();-- useEffect(() => {- props.activeKey && setActive(props.activeKey); // Update active state when props.activeKey changes- }, [props.activeKey]);-- const parseNavList = () =>- props.children.map((child) => {- const { label, keys, className = '' } = child.props;- const id = `${randomId('tab')}-${keys}`;- const tabClassName =- active === keys- ? `${styles.tabsTab} ${className} ${styles.tabsTabActive}`- : `${styles.tabsTab} ${className}`;-- return (- <div- key={id}- id={id}- onClick={handleClick}- className={tabClassName}- onMouseDown={draggable ? (e: any) => dragStart(e) : undefined}- >- {label}- </div>- );- });-- const handleClick = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {- const id = e.currentTarget.id;- const index = id.lastIndexOf('-');- const value = id.slice(index + 1);-- setActive(value);-- if (props.onTabClick) {- props.onTabClick(value, e.nativeEvent);- }- };-- // 拖拽逻辑- let target: HTMLDivElement | null;- let startX: number;- let left: number;- let parentOffsetLeft: number;- let parentOffsetTop: number;- let list: ITabInfo[] = [];- let nextIndex = 0;- let previousIndex = 0;- // 滚轮滚动距离- let wheelDistance = 0;- // 超出右边界再回来- let overRight = false;- // 超出左边界再回来- let overLeft = false;- let startTime: number;- // requestAnimationFrameId- let scrollToRightId: number;-- const getDistance = (element: HTMLDivElement, direction: 'Left' | 'Top' = 'Left') => {- let distance = 0;-- while (element) {- distance += element[`offset${direction}`];- element = element.offsetParent as HTMLDivElement;- }- return distance;- };-- const getList = (parent: HTMLDivElement) => {- const list: ITabInfo[] = [];- Array.from(parent.children).forEach((item) => {- const divItem = item as HTMLDivElement;- list.push({- min: divItem.offsetLeft,- max: divItem.offsetLeft + divItem.offsetWidth,- });- });- return list;- };-- const wheel = (e: React.WheelEvent) => {- if (!parent.current) return;- const children = parent.current.children;- if (e.deltaY > 0) {- const lastChild = children[children.length - 1] as HTMLDivElement;- const width = lastChild.offsetLeft + lastChild.offsetWidth - parent.current.offsetWidth;- wheelDistance = wheelDistance + 100 <= width ? wheelDistance + 100 : width;- parent.current.scrollTo(wheelDistance, 0);- } else {- wheelDistance = wheelDistance - 100 < 0 ? 0 : wheelDistance - 100;- parent.current.scrollTo(wheelDistance, 0);- }- };-- const scrollContent = (offset: number) => {- if (parent.current) {- parent.current.scrollLeft += offset;- }- };-- useImperativeHandle(ref, () => ({- scrollContent,- }));-- // 动画函数- const scrollToAnimation = (current: HTMLDivElement, direction: 'left' | 'right') => () => {- let scrollLeft;- if (direction === 'left') {- scrollLeft = current.scrollLeft - 2;- } else {- scrollLeft = current.scrollLeft + 2;- }- current.scrollTo(scrollLeft, 0);- scrollToRightId = requestAnimationFrame(scrollToAnimation(current, direction));- };-- const drag = (e: MouseEvent) => {- const time = new Date().getTime();- if (time - startTime < 300) return;- cancelAnimationFrame(scrollToRightId);-- const current = parent.current;- if (!current || !target) return;- const diff = e.pageX - startX;- const distance = left + diff;- if (e.pageX > parentOffsetLeft + current.offsetWidth) {- target.style.left = `${parentOffsetLeft + current.offsetWidth}px`;- scrollToAnimation(current, 'right')();- overRight = true;- } else if (e.pageX < parentOffsetLeft) {- target.style.left = `${parentOffsetLeft - target.offsetWidth}px`;- scrollToAnimation(current, 'left')();- overLeft = true;- } else {- target.style.left = `${distance}px`;- // 相对父元素的offsetLeft- const offsetLeft = e.pageX + current.scrollLeft - parentOffsetLeft;-- // 超出边界再回来时,把相应的tab挤掉- requestAnimationFrame(() => {- if (!target) return;- if (overRight || overLeft) {- if (nextIndex < current.children.length) {- const item = current.children[nextIndex] as HTMLDivElement;- item.style.marginRight = '0';- item.style.marginLeft = '0';- }- if (previousIndex > -1) {- const item = current.children[previousIndex] as HTMLDivElement;- item.style.marginLeft = '0';- item.style.marginRight = '0';- }-- let index = list.findIndex((item) => offsetLeft >= item.min && offsetLeft <= item.max);- if (offsetLeft > list[list.length - 1].max) index = current.children.length - 1;-- if (index < 1) {- const item = current.children[0] as HTMLDivElement;- item.style.marginLeft = `${target.offsetWidth}px`;- previousIndex = -1;- nextIndex = 0;- } else if (index === current.children.length - 1) {- const item = current.children[index] as HTMLDivElement;- item.style.marginRight = `${target.offsetWidth}px`;- previousIndex = index;- nextIndex = current.children.length;- } else {- const item = current.children[index - 1] as HTMLDivElement;- item.style.marginRight = `${target.offsetWidth}px`;- previousIndex = index - 1;- nextIndex = index;- }- }- });-- if (nextIndex < current.children.length && offsetLeft > list[nextIndex].min) {- const nextElement = current.children[nextIndex] as HTMLDivElement;- const previousElement = current.children[previousIndex] as HTMLDivElement;- nextElement.style.marginRight = `${target.offsetWidth}px`;- nextElement.style.marginLeft = '0';- if (previousIndex > -1) {- previousElement.style.marginRight = '0';- previousElement.style.marginLeft = '0';- }- previousIndex = nextIndex;- nextIndex += 1;- } else if (previousIndex > -1 && offsetLeft < list[previousIndex].max) {- const nextElement = current.children[nextIndex] as HTMLDivElement;- const previousElement = current.children[previousIndex] as HTMLDivElement;- previousElement.style.marginLeft = `${target.offsetWidth}px`;- previousElement.style.marginRight = '0';- if (nextIndex < current.children.length) {- nextElement.style.marginLeft = '0';- nextElement.style.marginRight = '0';- }- nextIndex = previousIndex;- previousIndex -= 1;- }- list = getList(current);- overLeft = false;- overRight = false;- }- };-- const dragEnd = () => {- cancelAnimationFrame(scrollToRightId);-- overLeft = false;- overRight = false;- window.removeEventListener('mousemove', drag);- window.removeEventListener('mouseup', dragEnd);-- const current = parent.current;- if (!current || !target) return;-- const previousElement = current.children[previousIndex > -1 ? previousIndex : 0] as HTMLDivElement;- previousElement.style.marginLeft = '0';- previousElement.style.marginRight = '0';- const nextElement = current.children[- nextIndex < current.children.length ? nextIndex : current.children.length - 1- ] as HTMLDivElement;- nextElement.style.marginLeft = '0';- nextElement.style.marginRight = '0';- target.style.position = 'relative';- target.style.left = '0';- target.style.top = '0';- current.insertBefore(target, current.children[nextIndex]) as HTMLDivElement;- };-- const dragStart = (e: MouseEvent) => {- requestAnimationFrame(() => {- startTime = new Date().getTime();- startX = e.pageX;- window.addEventListener('mousemove', drag);- window.addEventListener('mouseup', dragEnd);- target = (e.target as HTMLElement).closest(`.${styles.tabsTab}`);- if (!target) return;- const width = target.offsetWidth;- const nextElement = target.nextElementSibling as HTMLDivElement;- const previousElement = target.previousElementSibling as HTMLDivElement;- const targetOffsetLeft = target.offsetLeft;- const targetOffsetTop = target.offsetTop;- const current = parent.current;- if (!current) return;- parentOffsetLeft = getDistance(parent.current, 'Left');- parentOffsetTop = getDistance(parent.current, 'Top');- // 点击时距离左边的距离- left = targetOffsetLeft + parentOffsetLeft - current.scrollLeft;- target.style.left = `${targetOffsetLeft + parentOffsetLeft - current.scrollLeft}px`;- target.style.top = `${targetOffsetTop + parentOffsetTop - current.scrollTop}px`;- // current.removeChild(target);- if (previousElement) {- previousElement.style.marginRight = `${width}px`;- } else {- nextElement.style.marginLeft = `${width}px`;- }- document.body.appendChild(target);- target.style.position = 'absolute';- // TODO: CSS变量挂在container上,container外层取不到- target.style.fontSize = '14px';- list = getList(current);- nextIndex = nextElement- ? list.findIndex((item) => item.min === nextElement.offsetLeft)- : current.children.length;- previousIndex = previousElement- ? list.findIndex((item) => item.min === previousElement.offsetLeft)- : -1;- });- };-- return (- <div className={`${styles.tabs} ${type === 'card' ? `${styles.tabs}-card` : ''} ${className}`}>- <div className={styles.tabsNav}>- <div className={styles.tabsNavWrap}>- <div className={styles.tabsNavList} ref={parent} onWheel={wheel}>- {parseNavList()}- </div>- </div>- </div>- <div className={styles.tabsContent}>- {props.children.map((child, index) => (- <TabPane- label={child.props.label}- key={index}- keys={child.props.keys}- active={child.props.keys === active}- >- {child.props.children}- </TabPane>- ))}- </div>- </div>- );- }),- (prev, next) =>- prev.children.length === next.children.length &&- prev.activeKey === next.activeKey &&- prev.reRenderString === next.reRenderString-);--// tab content-export function TabPane(props: IBaseTabPaneProps) {- const { id, keys, style, children, active } = props;- return (- <div- id={id && `${id}-panel-${keys}`}- role="tabpanel"- className={joinClassNames(styles.tabsPanel, active && styles.tabsPanelActive)}- style={{ ...style }}- >- {active && children}- </div>- );-}diff --git a/packages/base-ui/src/Components/Tabs/index.module.less b/packages/base-ui/src/Components/Tabs/index.module.lessdeleted file mode 100644index f5d3c4932b..0000000000--- a/packages/base-ui/src/Components/Tabs/index.module.less+++ /dev/null@@ -1,86 +0,0 @@-.tabs {- overflow: hidden;-- ::-webkit-scrollbar {- display: none;- }-- .tabs-nav {- width: 100%;-- .tabs-nav-wrap {- width: 100%;- position: relative;- display: flex;- flex: auto;- align-self: stretch;- overflow: hidden;- white-space: nowrap;-- .tabs-nav-list {- display: inline-block;- overflow-y: hidden;- overflow-x: auto;- position: relative;- white-space: nowrap;- scroll-behavior: smooth;- transition: scroll-behavior 0.3s ease-in-out;- }- }- }-- .tabs-content {- display: flex;- width: 100%;-- .tabs-panel {- display: none;- width: 100%;- outline: none;-- &-active {- display: block;- }- }- }-}--.tabs-tab {- display: inline-block;- position: relative;- user-select: none;- padding: 0.5rem 1em;- font-size: var(--font-size);- background: transparent;- border: 0;- outline: none;- cursor: pointer;-- &:hover,- &-active {- color: var(--primary-color);- }-}--.tabs.tabs-card {- .tabs-nav {- width: 100%;- .tabs-nav-wrap {- width: 100%;- .tabs-nav-list {- .tabs-tab {- margin: 0;- // background: @bg-color;- // border: 1px solid @border-color;-- &-active {- color: var(--primary-color);- background: var(--bg);- border-bottom: 1px solid var(--bg);- }- }- }- }- }-}-diff --git a/packages/base-ui/src/Components/Tabs/index.ts b/packages/base-ui/src/Components/Tabs/index.tsdeleted file mode 100644index 856dbbb347..0000000000--- a/packages/base-ui/src/Components/Tabs/index.ts+++ /dev/null@@ -1 +0,0 @@-export * from './Tabs';diff --git a/packages/base-ui/src/Components/Tabs/test/index.test.tsx b/packages/base-ui/src/Components/Tabs/test/index.test.tsxdeleted file mode 100644index e109875bd1..0000000000--- a/packages/base-ui/src/Components/Tabs/test/index.test.tsx+++ /dev/null@@ -1,21 +0,0 @@-import { render } from '@testing-library/react';-import { describe, expect, test } from 'vitest';--import { TabPane, Tabs } from '..';--describe('tab', () => {- test('tab render', () => {- const { container } = render(- <Tabs activeKey="tab" type="card">- <TabPane label="tab1" keys="tab">- test tab- </TabPane>- <TabPane label="tab2" keys="tabs">- test tabs- </TabPane>- </Tabs>- );-- expect(container);- });-});diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.tsdeleted file mode 100644index 3be926ce51..0000000000--- a/packages/base-ui/src/Components/index.ts+++ /dev/null@@ -1,6 +0,0 @@-export * from './CustomLabel';-export * from './Input';-export * from './Menu';-export * from './Select';-export * from './Slider';-export * from './Tabs';diff --git a/packages/base-ui/src/Utils/util.ts b/packages/base-ui/src/Utils/util.tsindex 13e1f68911..5b25391365 100644--- a/packages/base-ui/src/Utils/util.ts+++ b/packages/base-ui/src/Utils/util.ts@@ -1,143 +1,3 @@-/**- * add className- * @param className- * @param selector- * @param context- */-export function addClass(className: string, selector: HTMLElement | string, context?: HTMLElement | Document) {- if (typeof selector !== 'string') {- selector.classList.add(className);- return;- }-- context = context || document;- const elements = Array.prototype.slice.call(context.querySelectorAll(selector));-- elements.forEach((ele) => {- ele.classList.add(className);- });-}-/**- * remove className- * @param className- * @param selector- * @param context- */-export function removeClass(className: string, selector: HTMLElement | string, context?: HTMLElement | Document) {- if (typeof selector !== 'string') {- selector.classList.remove(className);- return;- }-- context = context || document;- const elements = Array.prototype.slice.call(context.querySelectorAll(selector));-- elements.forEach((ele) => {- ele.classList.remove(className);- });-}-/**- * Return the first matched element by provided selector, traversing from current element up through its ancestors in the DOM tree.- * Native - IE10+- * reference: https://github.com/nefe/You-Dont-Need-jQuery#1.6- * @param {Element} el- * @param {string} selector- */-export function closest(el: any, selector: string) {- const matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;-- while (el) {- if (matchesSelector.call(el, selector)) {- return el;- }- el = el.parentElement;- }- return null;-}--/**- * generate random id- */-export function randomId(prefix: string) {- prefix = prefix ? `${prefix}-` : '';- return (- prefix +- Math.random()- .toString(36)- .replace(/[^a-z]+/g, '')- .substr(2, 10)- );-}--/**- * join className- */-export function joinClassNames(...args: any) {- if (!args.length) return;- let result = '';- args.forEach((item: any) => {- if (item instanceof Object) {- for (const k in item) {- if (item[k]) {- result += ` ${k}`;- }- }- } else {- result += item ? ` ${item}` : '';- }- });- return result;-}--export const getNodeIndex = (elm: any) => [...elm.parentNode.children].indexOf(elm);--// 防抖-export function debounce(fn: Function, time: number) {- let timer: any = null;- return (...arg: any) => {- clearTimeout(timer);- timer = setTimeout(() => {- fn(...arg);- }, time);- };-}--export function selectTextContent(ele: Node) {- if (window.getSelection) {- // all browsers, except IE before version 9- const range = document.createRange();- const content = ele.firstChild;- if (content) {- range.setStart(content, 0);- range.setEnd(content, (content as Text).length);- if (range.startContainer && isInPage(range.startContainer)) {- window.getSelection()?.removeAllRanges();- window.getSelection()?.addRange(range);- }- }- }-}--export function selectTextContentCross(sEle: Node, eEle: Node) {- if (window.getSelection) {- const range = document.createRange();- const sContent = sEle.firstChild;- const eContent = eEle.firstChild;- if (sContent && eContent) {- range.setStart(sContent, 0);- range.setEnd(eContent, (eContent as Text).length);- if (range.startContainer && isInPage(range.startContainer)) {- window.getSelection()?.removeAllRanges();- window.getSelection()?.addRange(range);- }- }- }-}--export function isInPage(node: Node) {- return node === document.body ? false : document.body.contains(node);-}-export function textTrim(x: string): string {if (x.length === 0) {// if (x == null || x.length == 0) {@@ -145,42 +5,3 @@ export function textTrim(x: string): string {}return x.replace(/^\s+|\s+$/gm, '');}--export function printableCharacter(keycode: number) {- const valid =- (keycode > 47 && keycode < 58) || // number keys- keycode === 32 ||- keycode === 13 || // spacebar & return key(s) (if you want to allow carriage returns)- (keycode > 64 && keycode < 91) || // letter keys- (keycode > 95 && keycode < 112) || // numpad keys- (keycode > 185 && keycode < 193) || // ;=,-./` (in order)- (keycode > 218 && keycode < 223); // [\]' (in order)-- return valid;-}--export function xssDeal(str: string) {- if (typeof str !== 'string') return str;- return str.replace(/<script>/g, '<script>').replace(/<\/script>/, '</script>');-}--export function setLastCaretPosition(dom: HTMLElement) {- const range = window.getSelection();- range && range.selectAllChildren(dom);- range && range.collapseToEnd();-}--export function isCtrlPressed(event: KeyboardEvent) {- let isCtrl = false;-- // Determine the corresponding key code of the Ctrl key according to the operating system- if (navigator.userAgent.indexOf('Mac') !== -1) {- // Mac- isCtrl = event.metaKey;- } else {- // Windows- isCtrl = event.ctrlKey;- }-- return isCtrl;-}diff --git a/packages/base-ui/src/Components/README.md b/packages/base-ui/src/components/README.mdsimilarity index 100%rename from packages/base-ui/src/Components/README.mdrename to packages/base-ui/src/components/README.mddiff --git a/packages/base-ui/src/components/custom-label/CustomLabel.tsx b/packages/base-ui/src/components/custom-label/CustomLabel.tsxnew file mode 100644index 0000000000..aefd12fc53--- /dev/null+++ b/packages/base-ui/src/components/custom-label/CustomLabel.tsx@@ -0,0 +1,60 @@+import { LocaleService } from '@univerjs/core';+import { CheckMarkSingle } from '@univerjs/icons';+import { useDependency } from '@wendellhu/redi/react-bindings';++import { ComponentManager } from '../../Common';+import { IMenuSelectorItem } from '../../services/menu/menu';+import styles from './index.module.less';++export interface ICustomLabelProps {+ value?: string | number | undefined;++ selected?: boolean;++ /**+ * Triggered after value change+ */+ onChange?(v: string | number): void;+}++/**+ * The component to render toolbar item label and menu item label.+ * @param props+ * @returns+ * @deprecated+ */+export function CustomLabel(+ props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'title'> & ICustomLabelProps+): JSX.Element | null {+ const { title, icon, label, selected } = props;+ const localeService = useDependency(LocaleService);+ const componentManager = useDependency(ComponentManager);++ const nodes = [];+ let index = 0;+ if (selected) {+ nodes.push(+ <span key={index++}>+ <CheckMarkSingle style={{ color: 'rgb(var(--success-color))' }} />+ </span>+ );+ }+ if (icon) {+ const Icon = componentManager.get(icon);+ Icon && nodes.push(<Icon key={index++} extend={{ colorChannel1: 'rgb(var(--primary-color))' }} />);+ }+ if (label) {+ const isStringLabel = typeof label === 'string';++ const customProps = isStringLabel ? { ...props } : { ...label?.props, ...props };+ const labelName = isStringLabel ? label : label?.name;++ const CustomComponent = componentManager.get(labelName);+ CustomComponent && nodes.push(<CustomComponent key={index++} {...customProps} />);+ }+ if (title) {+ nodes.push(<span key={index++}>{localeService.t(title)}</span>);+ }++ return <span className={styles.customLabel}>{nodes}</span>;+}diff --git a/packages/base-ui/src/components/custom-label/index.module.less b/packages/base-ui/src/components/custom-label/index.module.lessnew file mode 100644index 0000000000..a802a5c669--- /dev/null+++ b/packages/base-ui/src/components/custom-label/index.module.less@@ -0,0 +1,5 @@+.custom-label {+ display: inline-flex;+ align-items: center;+ gap: var(--margin-xs);+}diff --git a/packages/base-ui/src/Components/CustomLabel/index.ts b/packages/base-ui/src/components/custom-label/index.tssimilarity index 100%rename from packages/base-ui/src/Components/CustomLabel/index.tsrename to packages/base-ui/src/components/custom-label/index.tsdiff --git a/packages/base-ui/src/Components/hooks/observable.ts b/packages/base-ui/src/components/hooks/observable.tssimilarity index 100%rename from packages/base-ui/src/Components/hooks/observable.tsrename to packages/base-ui/src/components/hooks/observable.tsdiff --git a/packages/base-ui/src/components/index.ts b/packages/base-ui/src/components/index.tsnew file mode 100644index 0000000000..0f31342fa2--- /dev/null+++ b/packages/base-ui/src/components/index.ts@@ -0,0 +1,3 @@+export * from './custom-label';+export * from './menu';+export * from './slider';diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/components/menu/Menu.tsxsimilarity index 83%rename from packages/base-ui/src/Components/Menu/Menu.tsxrename to packages/base-ui/src/components/menu/Menu.tsxindex 7d000dd390..bb1751d1d9 100644--- a/packages/base-ui/src/Components/Menu/Menu.tsx+++ b/packages/base-ui/src/components/menu/Menu.tsx@@ -1,6 +1,7 @@import { isRealNum } from '@univerjs/core';import { MoreSingle } from '@univerjs/icons';import { useDependency } from '@wendellhu/redi/react-bindings';+import clsx from 'clsx';import RcMenu, { MenuItem as RcMenuItem, SubMenu as RcSubMenu } from 'rc-menu';import React, { useState } from 'react';import { isObservable, of } from 'rxjs';@@ -18,8 +19,7 @@ import {MenuItemType,} from '../../services/menu/menu';import { IMenuService } from '../../services/menu/menu.service';-import { joinClassNames } from '../../Utils';-import { NeoCustomLabel } from '../CustomLabel/CustomLabel';+import { CustomLabel } from '../custom-label/CustomLabel';import { useObservable } from '../hooks/observable';import styles from './index.module.less';@@ -31,7 +31,6 @@ export interface IBaseMenuProps {options?: Array<IValueOption | ICustomComponentOption>;onOptionSelect?: (option: IValueOption) => void;- onClose?: () => void;}function MenuWrapper(props: IBaseMenuProps) {@@ -87,7 +86,7 @@ function MenuOptionsWrapper(props: IBaseMenuProps) {<RcMenuItemkey={key}eventKey={key}- className={joinClassNames(+ className={clsx(styles.menuItem,option.disabled ? styles.colsMenuitemDisabled : ''// String(value) === String(option.value) ? styles.selectItemSelected : '' // Set the background color of Item@@ -98,7 +97,7 @@ function MenuOptionsWrapper(props: IBaseMenuProps) {});}}>- <NeoCustomLabel+ <CustomLabelselected={String(value) === String(option.value)} // use √ for selectvalue={String(option.value)}label={option.label}@@ -114,7 +113,7 @@ function MenuOptionsWrapper(props: IBaseMenuProps) {<RcMenuItemkey={key}eventKey={key}- className={joinClassNames(+ className={clsx(styles.menuItem,styles.menuItemCustom,option.disabled ? styles.colsMenuitemDisabled : ''@@ -140,12 +139,12 @@ export const Menu = (props: IBaseMenuProps) => (</RcMenu>);-export interface IMenuItemProps {+interface IMenuItemProps {menuItem: IDisplayMenuItem<IMenuItem>;onClick: (params: Partial<IValueOption>) => void;}-export function MenuItem({ menuItem, onClick }: IMenuItemProps) {+function MenuItem({ menuItem, onClick }: IMenuItemProps) {const menuService = useDependency(IMenuService);const menuItems = menuItem.id ? menuService.getMenuItems(menuItem.id) : [];@@ -172,23 +171,13 @@ export function MenuItem({ menuItem, onClick }: IMenuItemProps) {<RcMenuItemkey={item.id}eventKey={item.id}- className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}+ className={clsx(styles.menuItem, disabled ? styles.menuItemDisabled : '')}// disabled={disabled} // FIXME disabled is not workingonClick={() => {onClick({ value: inputValue, id: item.id }); // merge cell}}>- <NeoCustomLabel- value={inputValue}- title={title}- label={label}- icon={item.icon}- onChange={onChange}- onValueChange={() => {- // Right-click the menu for the title bar, and the Enter key triggers after entering the row height- onClick({ value: inputValue, id: item.id });- }}- />+ <CustomLabel value={inputValue} title={title} label={label} icon={item.icon} onChange={onChange} /></RcMenuItem>);};@@ -212,11 +201,11 @@ export function MenuItem({ menuItem, onClick }: IMenuItemProps) {<RcSubMenukey={item.id}eventKey={item.id}- className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}+ className={clsx(styles.menuItem, disabled ? styles.menuItemDisabled : '')}popupOffset={[18, 0]}title={<>- <NeoCustomLabel+ <CustomLabeltitle={item.title}value={inputValue}onChange={onChange}@@ -226,9 +215,7 @@ export function MenuItem({ menuItem, onClick }: IMenuItemProps) {{item.shortcut && ` (${item.shortcut})`}</>}- expandIcon={- <MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />- }+ expandIcon={<MoreSingle className={styles.menuItemMoreIcon} />}>{selections.length > 0 && (<MenuOptionsWrapper@@ -248,9 +235,9 @@ export function MenuItem({ menuItem, onClick }: IMenuItemProps) {<RcMenuItemkey={item.id}eventKey={item.id}- className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}+ className={clsx(styles.menuItem, disabled ? styles.menuItemDisabled : '')}>- <NeoCustomLabel+ <CustomLabeltitle={item.title}value={inputValue}onChange={onChange}@@ -269,14 +256,14 @@ export function MenuItem({ menuItem, onClick }: IMenuItemProps) {<RcSubMenukey={item.id}eventKey={item.id}- className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}+ className={clsx(styles.menuItem, disabled ? styles.menuItemDisabled : '')}popupOffset={[18, 0]}title={<>- <NeoCustomLabel title={item.title} value={item.title} icon={item.icon} label={item.label} />+ <CustomLabel title={item.title} value={item.title} icon={item.icon} label={item.label} /></>}- expandIcon={<MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />}+ expandIcon={<MoreSingle className={styles.menuItemMoreIcon} />}>{menuItems.length && <MenuWrapper menuType={item.id} parentKey={item.id} onOptionSelect={onClick} />}</RcSubMenu>diff --git a/packages/base-ui/src/Components/Menu/index.module.less b/packages/base-ui/src/components/menu/index.module.lesssimilarity index 93%rename from packages/base-ui/src/Components/Menu/index.module.lessrename to packages/base-ui/src/components/menu/index.module.lessindex 6694116e39..a0603b4271 100644--- a/packages/base-ui/src/Components/Menu/index.module.less+++ b/packages/base-ui/src/components/menu/index.module.less@@ -102,18 +102,15 @@.menu-submenu-title,.menu-item {- .anticon {- width: 14px;- height: 14px;- margin-right: 8px;- top: -1px;+ &-more-icon {+ color: rgb(var(--text-color));+ font-size: var(--font-size-sm);}}&-horizontal {- background-color: #f3f5f7;border: none;- border-bottom: 1px solid #d9d9d9;+ border-bottom: 1px solid rgb(var(--border-color));box-shadow: none;white-space: nowrap;overflow: hidden;@@ -128,12 +125,6 @@border-bottom: 2px solid transparent;display: inline-block;vertical-align: bottom;-- &-active {- border-bottom: 2px solid #2db7f5;- background-color: #f3f5f7;- color: #2baee9;- }}}@@ -148,12 +139,11 @@padding: var(--padding-xs) var(--padding-sm);box-sizing: border-box;display: flex;- justify-content: space-between;align-items: center;+ justify-content: space-between;}.menu-submenu-arrow {display: inline-block;- font: normal normal normal 14px/1 FontAwesome;font-size: inherit;vertical-align: baseline;text-align: center;diff --git a/packages/base-ui/src/Components/Menu/index.ts b/packages/base-ui/src/components/menu/index.tssimilarity index 100%rename from packages/base-ui/src/Components/Menu/index.tsrename to packages/base-ui/src/components/menu/index.tsdiff --git a/packages/base-ui/src/Components/Notification/Notification.stories.tsx b/packages/base-ui/src/components/notification/Notification.stories.tsxsimilarity index 100%rename from packages/base-ui/src/Components/Notification/Notification.stories.tsxrename to packages/base-ui/src/components/notification/Notification.stories.tsxdiff --git a/packages/base-ui/src/Components/Notification/Notification.tsx b/packages/base-ui/src/components/notification/Notification.tsxsimilarity index 97%rename from packages/base-ui/src/Components/Notification/Notification.tsxrename to packages/base-ui/src/components/notification/Notification.tsxindex 35e5afe2e6..2f5440bf8f 100644--- a/packages/base-ui/src/Components/Notification/Notification.tsx+++ b/packages/base-ui/src/components/notification/Notification.tsx@@ -1,11 +1,11 @@import { CloseSingle, ErrorSingle, SuccessSingle, WarningSingle } from '@univerjs/icons';+import clsx from 'clsx';import { useNotification } from 'rc-notification';import { Placement } from 'rc-notification/es/interface';import { useEffect, useRef } from 'react';import { createRoot } from 'react-dom/client';import { Subject } from 'rxjs';-import { joinClassNames } from '../../Utils/util';import styles from './index.module.less';export type NotificationType = 'success' | 'info' | 'warning' | 'error';@@ -65,7 +65,7 @@ export const notificationObserver = new Subject<INotificationMethodOptions>();export const PureContent = (props: INotificationMethodOptions) => {const { type, content, title, lines = 0 } = props;- const contentClassName = joinClassNames(styles.notificationContent, {+ const contentClassName = clsx(styles.notificationContent, {[styles.notificationContentEllipsis]: lines !== 0,});diff --git a/packages/base-ui/src/Components/Notification/index.module.less b/packages/base-ui/src/components/notification/index.module.lesssimilarity index 100%rename from packages/base-ui/src/Components/Notification/index.module.lessrename to packages/base-ui/src/components/notification/index.module.lessdiff --git a/packages/base-ui/src/Components/Slider/Slider.stories.tsx b/packages/base-ui/src/components/slider/Slider.stories.tsxsimilarity index 100%rename from packages/base-ui/src/Components/Slider/Slider.stories.tsxrename to packages/base-ui/src/components/slider/Slider.stories.tsxdiff --git a/packages/base-ui/src/Components/Slider/Slider.tsx b/packages/base-ui/src/components/slider/Slider.tsxsimilarity index 98%rename from packages/base-ui/src/Components/Slider/Slider.tsxrename to packages/base-ui/src/components/slider/Slider.tsxindex e47283522b..9451ae20e8 100644--- a/packages/base-ui/src/Components/Slider/Slider.tsx+++ b/packages/base-ui/src/components/slider/Slider.tsx@@ -1,9 +1,9 @@/* eslint-disable no-magic-numbers */import { Button, Dropdown, Tooltip } from '@univerjs/design';import { IncreaseSingle, ReduceSingle } from '@univerjs/icons';+import clsx from 'clsx';import { useMemo, useRef } from 'react';-import { joinClassNames } from '../../Utils';import styles from './index.module.less';/**@@ -151,7 +151,7 @@ export function Slider(props: ISliderProps) {{shortcuts?.map((item) => (<akey={item}- className={joinClassNames(+ className={clsx(styles.sliderShortcut,item === value ? styles.sliderShortcutActive : '')}diff --git a/packages/base-ui/src/Components/Slider/test/index.test.tsx b/packages/base-ui/src/components/slider/__test__/index.spec.tsxsimilarity index 100%rename from packages/base-ui/src/Components/Slider/test/index.test.tsxrename to packages/base-ui/src/components/slider/__test__/index.spec.tsxdiff --git a/packages/base-ui/src/Components/Slider/index.module.less b/packages/base-ui/src/components/slider/index.module.lesssimilarity index 100%rename from packages/base-ui/src/Components/Slider/index.module.lessrename to packages/base-ui/src/components/slider/index.module.lessdiff --git a/packages/base-ui/src/Components/Slider/index.ts b/packages/base-ui/src/components/slider/index.tssimilarity index 100%rename from packages/base-ui/src/Components/Slider/index.tsrename to packages/base-ui/src/components/slider/index.tsdiff --git a/packages/base-ui/src/index.ts b/packages/base-ui/src/index.tsindex 285c37899e..61dc06a02f 100644--- a/packages/base-ui/src/index.ts+++ b/packages/base-ui/src/index.ts@@ -1,8 +1,8 @@export { UIPlugin } from './base-ui-plugin';export * from './BaseComponent';export * from './Common';-export * from './Components';-export { useObservable } from './Components/hooks/observable';+export * from './components';+export { useObservable } from './components/hooks/observable';export { SharedController } from './controllers/shared-shortcut.controller';export { IUIController } from './controllers/ui/ui.controller';export { DesktopUIPart, type IDesktopUIController } from './controllers/ui/ui-desktop.controller';diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.tsindex ea6f140964..02e70e6aa6 100644--- a/packages/base-ui/src/services/menu/menu.ts+++ b/packages/base-ui/src/services/menu/menu.ts@@ -59,19 +59,6 @@ interface IMenuItemBase<V> {disabled$?: Observable<boolean>;/** On observable value that should emit the value of the corresponding selection component. */value$?: Observable<V>;- onClose?: () => void;-- // FIXME@wzhudev: this parameters should not appear here-- /**- * e.g. set cell text size, rotation angle of the text- */- max?: number;-- /**- * Set the minimum value of the digital input box- */- min?: number;}export interface IMenuButtonItem<V = undefined> extends IMenuItemBase<V> {@@ -87,14 +74,12 @@ export interface IValueOption {| {name: string;props?: Record<string, string | number>;- }; // custom component, send to NeoCustomLabel label property+ }; // custom component, send to CustomLabel label propertyicon?: string;tooltip?: string;style?: object;disabled?: boolean;id?: string; // command id- show?: boolean; // show parent menu or not- showAfterClick?: boolean; // show children when clicked or not,暂时性做法}export function isValueOptions(v: IValueOption | ICustomComponentOption): v is IValueOption {diff --git a/packages/base-ui/src/services/notification/desktop-notification.service.ts b/packages/base-ui/src/services/notification/desktop-notification.service.tsindex 794716dc58..3c98f359aa 100644--- a/packages/base-ui/src/services/notification/desktop-notification.service.ts+++ b/packages/base-ui/src/services/notification/desktop-notification.service.ts@@ -1,7 +1,7 @@import { toDisposable } from '@univerjs/core';import { IDisposable } from '@wendellhu/redi';-import { INotificationMethodOptions, notification } from '../../Components/Notification/Notification';+import { INotificationMethodOptions, notification } from '../../components/notification/Notification';import { INotificationService } from './notification.service';export class DesktopNotificationService implements INotificationService {diff --git a/packages/base-ui/src/services/notification/notification.service.ts b/packages/base-ui/src/services/notification/notification.service.tsindex 08b9931468..1757419d3b 100644--- a/packages/base-ui/src/services/notification/notification.service.ts+++ b/packages/base-ui/src/services/notification/notification.service.ts@@ -1,6 +1,6 @@import { createIdentifier, IDisposable } from '@wendellhu/redi';-import { INotificationMethodOptions } from '../../Components/Notification/Notification';+import { INotificationMethodOptions } from '../../components/notification/Notification';export const INotificationService = createIdentifier<INotificationService>('univer.notification-service');diff --git a/packages/base-ui/src/views/app.module.less b/packages/base-ui/src/views/app.module.lessindex 9c9bf3248e..34aedd05ca 100644--- a/packages/base-ui/src/views/app.module.less+++ b/packages/base-ui/src/views/app.module.less@@ -9,27 +9,15 @@display: flex;.content-inner-left-container {- // position: relative;width: 50%;padding-right: 10px;flex: none;-- .hover-cursor {- position: absolute;- right: 0;- top: 0;- height: 100%;- width: 10px;- background: gray;- cursor: e-resize;- }}.content-inner-right-container {width: 50%;background-color: rgb(var(--bg-color-secondary));flex: 1;- // position: relative;}}@@ -40,20 +28,9 @@position: relative;.content-inner-left-container {- // position: relative;height: 50%;padding-bottom: 10px;flex: none;-- .hover-cursor {- position: absolute;- left: 0;- bottom: 0;- height: 10px;- width: 100%;- background: gray;- cursor: n-resize;- }}.content-inner-right-container {@@ -63,6 +40,7 @@}.main-content {+ position: relative;}.header-menu {@@ -73,13 +51,4 @@top: 0;right: 0;}-- .outer-right-container {- // position: relative;- flex: 0 0 280px;- > div {- position: absolute;- width: 100%;- }- }}diff --git a/packages/base-ui/src/views/app.tsx b/packages/base-ui/src/views/app.tsxindex 4bf4f86a0e..35a9a1801e 100644--- a/packages/base-ui/src/views/app.tsx+++ b/packages/base-ui/src/views/app.tsx@@ -1,4 +1,4 @@-import { LocaleService, LocaleType, ThemeService } from '@univerjs/core';+import { LocaleService, ThemeService } from '@univerjs/core';import {ConfigProvider,Container,@@ -11,11 +11,9 @@ import {Sider,themeInstance,} from '@univerjs/design';-import { useDependency, useInjector } from '@wendellhu/redi/react-bindings';+import { useDependency } from '@wendellhu/redi/react-bindings';import React, { ComponentType, useEffect, useRef, useState } from 'react';-import { ComponentManager, ZIndexManager } from '../Common';-import { AppContext } from '../Common/AppContext';import { IWorkbenchOptions } from '../controllers/ui/ui.controller';import style from './app.module.less';import { ContextMenu } from './components/ContextMenu';@@ -32,11 +30,8 @@ export interface IUniverAppProps extends IWorkbenchOptions {// eslint-disable-next-line max-lines-per-functionexport function App(props: IUniverAppProps) {- const injector = useInjector();const localeService = useDependency(LocaleService);const themeService = useDependency(ThemeService);- const zIndexManager = useDependency(ZIndexManager);- const componentManager = useDependency(ComponentManager);const containerRef = useRef<HTMLDivElement>(null);@@ -61,12 +56,12 @@ export function App(props: IUniverAppProps) {}}, [onRendered]);- const [locale, setLocale] = useState<LocaleType>(localeService.getLocale().getCurrentLocale());+ const [locale, setLocale] = useState<ILocale>(localeService.getLocales() as unknown as ILocale);useEffect(() => {const subscriptions = [localeService.getLocale().locale$.subscribe((locale) => {- locale && setLocale(locale);+ locale && setLocale(localeService.getLocales() as unknown as ILocale);}),themeService.currentTheme$.subscribe((theme) => {themeInstance.setTheme(theme);@@ -80,61 +75,59 @@ export function App(props: IUniverAppProps) {}, []);return (- <AppContext.Provider value={{ injector, localeService, themeService, locale, componentManager, zIndexManager }}>- <ConfigProvider locale={localeService.getLocales() as unknown as ILocale}>- <Container className={style.layoutContainer}>- <Layout>- {/* outer sidebar */}- <Sider style={{ display: props.outerLeft ? 'block' : 'none' }}></Sider>- <Layout className={style.mainContent} style={{ position: 'relative' }}>- {/* header */}- <Header style={{ display: props.header ? 'block' : 'none' }}>- {props.toolbar && <DocBars />}- {headerComponents &&- Array.from(headerComponents.values()).map((component, index) =>+ <ConfigProvider locale={locale}>+ <Container className={style.layoutContainer}>+ <Layout>+ {/* outer sidebar */}+ <Sider style={{ display: props.outerLeft ? 'block' : 'none' }}></Sider>+ <Layout className={style.mainContent}>+ {/* header */}+ <Header style={{ display: props.header ? 'block' : 'none' }}>+ {props.toolbar && <DocBars />}+ {headerComponents &&+ Array.from(headerComponents.values()).map((component, index) =>+ React.createElement(component(), { key: `${index}` })+ )}+ <div className={style.headerMenu}>+ {headerMenuComponents &&+ Array.from(headerMenuComponents.values()).map((component, index) =>React.createElement(component(), { key: `${index}` }))}- <div className={style.headerMenu}>- {headerMenuComponents &&- Array.from(headerMenuComponents.values()).map((component, index) =>- React.createElement(component(), { key: `${index}` })- )}- </div>- </Header>- {/* content */}- <Layout>- <Sider- style={{ display: props.innerLeft ? 'block' : 'none' }}- className={style.contentInnerLeftContainer}- >- {/* inner left */}- {sidebarComponents &&- Array.from(sidebarComponents.values()).map((component, index) =>- React.createElement(component(), { key: `${index}` })- )}- </Sider>- <Content className={style.contentContainerHorizontal}>- <ContextMenu>- <Container className={style.contentInnerRightContainer} ref={containerRef}>- {contentComponents &&- Array.from(contentComponents.values()).map((component, index) =>- React.createElement(component(), { key: `${index}` })- )}- </Container>- </ContextMenu>- </Content>- </Layout>- {/* footer */}- <Footer style={{ display: props.footer ? 'block' : 'none' }}>- {footerComponents &&- Array.from(footerComponents.values()).map((component, index) =>+ </div>+ </Header>+ {/* content */}+ <Layout>+ <Sider+ style={{ display: props.innerLeft ? 'block' : 'none' }}+ className={style.contentInnerLeftContainer}+ >+ {/* inner left */}+ {sidebarComponents &&+ Array.from(sidebarComponents.values()).map((component, index) =>React.createElement(component(), { key: `${index}` }))}- </Footer>+ </Sider>+ <Content className={style.contentContainerHorizontal}>+ <ContextMenu>+ <Container className={style.contentInnerRightContainer} ref={containerRef}>+ {contentComponents &&+ Array.from(contentComponents.values()).map((component, index) =>+ React.createElement(component(), { key: `${index}` })+ )}+ </Container>+ </ContextMenu>+ </Content></Layout>+ {/* footer */}+ <Footer style={{ display: props.footer ? 'block' : 'none' }}>+ {footerComponents &&+ Array.from(footerComponents.values()).map((component, index) =>+ React.createElement(component(), { key: `${index}` })+ )}+ </Footer></Layout>- </Container>- </ConfigProvider>- </AppContext.Provider>+ </Layout>+ </Container>+ </ConfigProvider>);}diff --git a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsxindex 8b7bd98ab8..8ea447dc9a 100644--- a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx+++ b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx@@ -4,7 +4,7 @@ import { Dropdown } from '@univerjs/design';import { useDependency } from '@wendellhu/redi/react-bindings';import React, { useEffect, useState } from 'react';-import { Menu } from '../../../Components/Menu/Menu';+import { Menu } from '../../../components/menu/Menu';import { IContextMenuService } from '../../../services/contextmenu/contextmenu.service';export interface IProps {diff --git a/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx b/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsxindex af0429ae2d..73896e56d2 100644--- a/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx+++ b/packages/base-ui/src/views/components/DocBars/Button/ToolbarButton.tsx@@ -1,4 +1,5 @@-import { joinClassNames } from '../../../../Utils/util';+import clsx from 'clsx';+import styles from './index.module.less';export interface IBaseToolbarButtonProps {@@ -62,7 +63,7 @@ export function ToolbarButton(props: IBaseToolbarButtonProps) {onDoubleClick && onDoubleClick(e);};- const _className = joinClassNames(+ const _className = clsx(styles.toolbarBtn,{[`${styles.toolbarBtn}-active`]: active,diff --git a/packages/base-ui/src/views/components/DocBars/DocBars.tsx b/packages/base-ui/src/views/components/DocBars/DocBars.tsxindex 080756a99b..950a4e1830 100644--- a/packages/base-ui/src/views/components/DocBars/DocBars.tsx+++ b/packages/base-ui/src/views/components/DocBars/DocBars.tsx@@ -1,10 +1,10 @@import { LocaleService } from '@univerjs/core';import { useDependency } from '@wendellhu/redi/react-bindings';+import clsx from 'clsx';import { useEffect, useMemo, useState } from 'react';import { IDisplayMenuItem, IMenuItem, MenuGroup, MenuPosition } from '../../../services/menu/menu';import { IMenuService } from '../../../services/menu/menu.service';-import { joinClassNames } from '../../../Utils';import styles from './index.module.less';import { ToolbarItem } from './ToolbarItem';@@ -71,12 +71,12 @@ export function DocBars() {{menuGroups.map((group, index) => (<akey={index}- className={joinClassNames(styles.menubarItem, {+ className={clsx(styles.menubarItem, {[styles.menubarItemActive]: group.name === activeMenuGroup?.name,})}onClick={() => setActiveMenuGroup(group)}>- {localeService.t(group.name) ?? ''}+ {localeService.t(group.name)}</a>))}</div>diff --git a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsxindex 25a6ff4016..a86bc7c662 100644--- a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx+++ b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx@@ -1,11 +1,13 @@import { ICommandService, LocaleService } from '@univerjs/core';-import { Tooltip } from '@univerjs/design';+import { Dropdown, Tooltip } from '@univerjs/design';+import { MoreDownSingle } from '@univerjs/icons';import { useDependency } from '@wendellhu/redi/react-bindings';import { useEffect, useState } from 'react';import { Subscription } from 'rxjs';import { ComponentManager } from '../../../Common';-import { Select } from '../../../Components/Select/Select';+import { CustomLabel } from '../../../components/custom-label/CustomLabel';+import { Menu } from '../../../components/menu/Menu';import {IDisplayMenuItem,IMenuItem,@@ -61,73 +63,78 @@ export function ToolbarItem(props: IDisplayMenuItem<IMenuItem>) {};}, []);- const { tooltip, shortcut, icon, title, label, id, onClose } = props;+ const { tooltip, shortcut, icon, title, label, id } = props;const tooltipTitle = localeService?.t(tooltip) + (shortcut ? ` (${shortcut})` : '');function renderSelectorType() {const { selections } = props as IDisplayMenuItem<IMenuSelectorItem>;- return (- <Tooltip title={tooltipTitle} placement="bottom">- <Select- id={id}- title={title}- children={selections! as IValueOption[]}- options={selections as IValueOption[]}- icon={icon}- value={value}- label={label}- onClick={(value) => {- // commandService.executeCommand(id, { value })- // 子元素commandId会被现在的id覆盖,暂时这么写以区分- // TODO: @jikkai should be refactored- let commandId = id;- if (value instanceof Object && value.id) {- commandId = value.id;- }-- if (typeof value === 'string') {- value = { value };- }- commandService.executeCommand(commandId, value);- }}- onClose={onClose}- />- </Tooltip>- );- }+ const options = selections as IValueOption[];+ const iconToDisplay = options?.find((o) => o.value === value)?.icon ?? icon;- function renderButtonType() {- function renderIconOrLabel() {- if (icon) {- const IconComponent = componentManager.get(icon) as React.ComponentType;+ function handleSelect(option: IValueOption) {+ let commandId = id;+ const value = option;- if (IconComponent) return <IconComponent />;+ if (option.id) {+ commandId = option.id;}- return title;++ commandService.executeCommand(commandId, value);+ }++ function handleChange(value: string | number) {+ const commandId = id;+ commandService.executeCommand(commandId, { value });}return (- <Tooltip title={tooltipTitle} placement="bottom">- <ToolbarButton- className={styles.toolbarItemTextButton}- active={activated}- disabled={disabled}- onClick={() => commandService.executeCommand(props.id)}- onDoubleClick={() => props.subId && commandService.executeCommand(props.subId)}- >- {renderIconOrLabel()}- </ToolbarButton>- </Tooltip>+ <Dropdown overlay={<Menu menuType={id} options={options} onOptionSelect={handleSelect} value={value} />}>+ <div className={styles.toolbarItemSelectButton}>+ <CustomLabel+ icon={iconToDisplay}+ title={title!}+ value={value}+ label={label}+ onChange={handleChange}+ />+ <div className={styles.toolbarItemSelectButtonArrow}>+ <MoreDownSingle />+ </div>+ </div>+ </Dropdown>);}- switch (props.type) {- case MenuItemType.SUBITEMS:- case MenuItemType.SELECTOR:- return renderSelectorType();- default:- return renderButtonType();+ function renderButtonType() {+ return (+ <ToolbarButton+ className={styles.toolbarItemTextButton}+ active={activated}+ disabled={disabled}+ onClick={() => commandService.executeCommand(props.id)}+ onDoubleClick={() => props.subId && commandService.executeCommand(props.subId)}+ >+ <CustomLabel icon={icon} />+ </ToolbarButton>+ );}++ function renderItem() {+ switch (props.type) {+ case MenuItemType.SUBITEMS:+ case MenuItemType.SELECTOR:+ return renderSelectorType();+ case MenuItemType.BUTTON:+ default:+ return renderButtonType();+ }+ }++ return (+ <Tooltip title={tooltipTitle} placement="bottom">+ {renderItem()}+ </Tooltip>+ );}diff --git a/packages/base-ui/src/views/components/DocBars/index.module.less b/packages/base-ui/src/views/components/DocBars/index.module.lessindex 19a84a5cb0..717c041441 100644--- a/packages/base-ui/src/views/components/DocBars/index.module.less+++ b/packages/base-ui/src/views/components/DocBars/index.module.less@@ -54,6 +54,7 @@&-group {display: flex;align-items: center;+ gap: var(--margin-xs);&:not(:last-child) {&::after {@@ -66,5 +67,31 @@}}}++ &-item {+ &-select-button {+ position: relative;+ height: 28px;+ padding: 0 var(--padding-xs);+ border-radius: var(--border-radius-base);+ display: flex;+ align-items: center;+ cursor: pointer;+ gap: var(--margin-xs);++ &:hover {+ background-color: rgb(var(--grey-100));+ border-radius: var(--border-radius-base);+ }++ &-arrow {+ height: 100%;+ color: rgb(var(--grey-400));+ font-size: 10px;+ display: flex;+ align-items: center;+ }+ }+ }}}diff --git a/packages/base-ui/src/views/hooks/di.ts b/packages/base-ui/src/views/hooks/di.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/packages/base-ui/src/views/parts.tsx b/packages/base-ui/src/views/parts.tsxdeleted file mode 100644index e69de29bb2..0000000000diff --git a/packages/design/src/components/input-number/index.module.less b/packages/design/src/components/input-number/index.module.lessindex fcd09f8ffd..1f645c965e 100644--- a/packages/design/src/components/input-number/index.module.less+++ b/packages/design/src/components/input-number/index.module.less@@ -21,11 +21,11 @@}}- &-out-of-range {- .input-number-input {- color: rgb(var(--error-color));- }- }+ // &-out-of-range {+ // .input-number-input {+ // color: rgb(var(--error-color));+ // }+ // }&-handler {text-align: center;diff --git a/packages/design/src/components/input/index.module.less b/packages/design/src/components/input/index.module.lessindex 694845f06f..563aefefe3 100644--- a/packages/design/src/components/input/index.module.less+++ b/packages/design/src/components/input/index.module.less@@ -7,9 +7,9 @@background-color: rgb(var(--primary-color));}- &-out-of-range {- color: rgb(var(--error-color));- }+ // &-out-of-range {+ // color: rgb(var(--error-color));+ // }&-affix-wrapper {border: 1px solid rgb(var(--border-color));diff --git a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx b/packages/sheets-plugin-find/src/View/UI/FindModal.tsxindex 4e1f15a7e6..6fb4ea7750 100644--- a/packages/sheets-plugin-find/src/View/UI/FindModal.tsx+++ b/packages/sheets-plugin-find/src/View/UI/FindModal.tsx@@ -1,4 +1,4 @@-import { BaseComponentProps, BaseItemProps } from '@univerjs/base-ui';+import { BaseComponentProps } from '@univerjs/base-ui';import { ICheckboxGroupProps } from '@univerjs/design';import { Component } from 'react';@@ -38,7 +38,7 @@ export enum SelectSearch {export class FindModal extends Component<IProps, IState> {private _matchGroup: ICheckboxGroupProps[] = [];- private _select: BaseItemProps[] = [];+ private _select: any[] = [];constructor(props: IProps) {super(props);@@ -107,7 +107,7 @@ export class FindModal extends Component<IProps, IState> {// 国际化SelectgetSelect() {- const arr: BaseItemProps[] = JSON.parse(JSON.stringify(this._select));+ const arr: any[] = JSON.parse(JSON.stringify(this._select));// arr.forEach((element: ICheckboxGroupProps) => {// element.label = <CustomLabel label={element.label} />;// });diff --git a/packages/sheets-plugin-numfmt/package.json b/packages/sheets-plugin-numfmt/package.jsonindex f010172613..ad8151049f 100644--- a/packages/sheets-plugin-numfmt/package.json+++ b/packages/sheets-plugin-numfmt/package.json@@ -46,6 +46,7 @@"@univerjs/base-ui": "workspace:*","@univerjs/common-plugin-data": "workspace:*","@univerjs/core": "workspace:*",+ "@univerjs/design": "workspace:*","@univerjs/ui-plugin-sheets": "workspace:*","@wendellhu/redi": "^0.12.10","react": "^18.2.0",diff --git a/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsx b/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsxindex 65a7932e7a..5f5ff7fadb 100644--- a/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsx+++ b/packages/sheets-plugin-numfmt/src/View/UI/FormatContent.tsx@@ -1,4 +1,4 @@-import { Input } from '@univerjs/base-ui';+import { InputNumber } from '@univerjs/design';import { Component, createRef } from 'react';import styles from './index.module.less';@@ -34,9 +34,8 @@ export class FormatContent extends Component<IProps, IState> {this.props.onClick(value);}- handleChange(e: React.ChangeEvent<HTMLInputElement>) {- const value = (e.target as HTMLInputElement).value;- this.props.onChange?.(value);+ handleChange(value: number | null) {+ this.props.onChange?.(value?.toString() ?? '');}/**@@ -52,7 +51,7 @@ export class FormatContent extends Component<IProps, IState> {input && (<div className={styles.formatInput}><span>{input}:</span>- <Input type="number" value="2" onChange={this.handleChange.bind(this)}></Input>+ <InputNumber value={2} onChange={this.handleChange.bind(this)} /></div>)<ul>diff --git a/packages/sheets-plugin-numfmt/src/View/UI/FormatItem.tsx b/packages/sheets-plugin-numfmt/src/View/UI/FormatItem.tsxindex bf43cdc333..b3f52fbaa3 100644--- a/packages/sheets-plugin-numfmt/src/View/UI/FormatItem.tsx+++ b/packages/sheets-plugin-numfmt/src/View/UI/FormatItem.tsx@@ -1,17 +1,14 @@-import { AppContext, AppContextValues, BaseMenuItem, joinClassNames } from '@univerjs/base-ui';-import React, { useContext } from 'react';+// import { joinClassNames } from '@univerjs/base-ui';+import { LocaleService } from '@univerjs/core';+import { useDependency } from '@wendellhu/redi/react-bindings';-import styles from './FormatItem.module.less';--export interface BaseFormatItemProps extends BaseMenuItem {+export interface BaseFormatItemProps {selected?: boolean;labelText?: string;- suffix?: React.ReactNode;+ suffix?: string;border?: boolean;-}--function getLocale(context: Partial<AppContextValues>, name: string) {- return context.localeService?.t(name);+ disabled?: boolean;+ value?: string;}/**@@ -19,15 +16,14 @@ function getLocale(context: Partial<AppContextValues>, name: string) {*/export function FormatItem(props: BaseFormatItemProps): JSX.Element {const { selected, labelText, suffix, disabled, value } = props;- const context = useContext(AppContext);+ const localeService = useDependency(LocaleService);return (- <div className={joinClassNames(styles.formatItem, disabled ? styles.selectDisabledItem : '')}>- {selected && <span className={styles.formatItemSelected}>{/* <Icon.CorrectIcon /> */}</span>}- <span className={styles.formatItemContent}>{getLocale(context, labelText as string) || labelText}</span>- {suffix && (- <span className={styles.formatItemSuffix}>{getLocale(context, suffix as string) || suffix}</span>- )}- </div>+ // <div className={joinClassNames(styles.formatItem, disabled ? styles.selectDisabledItem : '')}>+ // {selected && <span className={styles.formatItemSelected}>{/* <Icon.CorrectIcon /> */}</span>}+ // <span className={styles.formatItemContent}>{localeService.t(labelText as string) || labelText}</span>+ // {suffix && <span className={styles.formatItemSuffix}>{localeService.t(suffix as string) || suffix}</span>}+ // </div>+ <></>);}diff --git a/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsxindex 28414e4746..25a4eb15c0 100644--- a/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx+++ b/packages/sheets-plugin-numfmt/src/View/UI/NumfmtModal.tsx@@ -1,4 +1,4 @@-import { AppContext, BaseComponentProps, ComponentManager } from '@univerjs/base-ui';+import { BaseComponentProps, ComponentManager } from '@univerjs/base-ui';import { Component } from 'react';import { ModalDataProps } from '../../Controller/NumfmtModalController';@@ -10,7 +10,7 @@ interface IState {}export class NumfmtModal extends Component<IProps, IState> {- static override contextType = AppContext;+ // static override contextType = AppContext;constructor(props: IProps) {super(props);diff --git a/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx b/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsxindex 4fe108658e..3c7eaf8123 100644--- a/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx+++ b/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx@@ -1,11 +1,13 @@-import { AppContext, BaseComponentProps, BaseSelectChildrenProps, debounce } from '@univerjs/base-ui';+import { ComponentManager } from '@univerjs/base-ui';import { Nullable } from '@univerjs/core';-import { Component } from 'react';+import { CheckMarkSingle, CloseSingle } from '@univerjs/icons';+import { useDependency } from '@wendellhu/redi/react-bindings';+import { useState } from 'react';import styles from './index.module.less';type FormulaState = {- namedRanges: BaseSelectChildrenProps[];+ namedRanges: any[];spanClass: string;formulaContent: string;fx: Nullable<Fx>;@@ -16,100 +18,54 @@ export type Fx = {onClick: () => void;};-export interface BaseFormulaBarProps extends BaseComponentProps {}--export class FormulaBar extends Component<BaseFormulaBarProps, FormulaState> {- static override contextType = AppContext;-- declare context: React.ContextType<typeof AppContext>;-- // formulaContent = createRef<HTMLDivElement>();-- constructor(props: BaseFormulaBarProps) {- super(props);- this.initialize(props);- }-- initialize(props?: BaseFormulaBarProps) {- this.state = {- namedRanges: [- {- value: '1',- label: '1',- },- ],- spanClass: styles.formulaGrey,- formulaContent: '',- fx: null,- };-- this.onkeyUp = debounce(this.onkeyUp, 300);- }-- onkeyUp = (value: any) => {- // console.dir(value);- };-- printChange = (e: React.KeyboardEvent) => {- this.onkeyUp(e.target);- };-- setFormulaContent(value: string) {- this.setState({- formulaContent: value,- });+export function FormulaBar() {+ const [state, setState] = useState<FormulaState>({+ namedRanges: [+ {+ value: '1',+ label: '1',+ },+ ],+ spanClass: styles.formulaGrey,+ formulaContent: '',+ fx: null,+ });++ const componentManager = useDependency(ComponentManager);+ const Icon = componentManager.get(state.fx?.icon ?? '');++ function printChange(e: React.KeyboardEvent<HTMLDivElement>) {+ e.stopPropagation();+ console.log(e);}- setFx(fx: Fx) {- this.setState({- fx,- });- }-- setNamedRanges(namedRanges: BaseSelectChildrenProps[]) {- this.setState({- namedRanges,- });- }-- override componentDidMount() {- this.props.getComponent?.(this);- }-- getIcon(name: string) {- const componentManager = this.context.componentManager;- const Icon = componentManager?.get(name) as any;- return <Icon />;- }-- override render() {- // TODO: formula bar top left menu: 1. cell edit formula ,use formula list 2. cell selection ,use named range, 3. cell edit no formula, disable select- const { namedRanges, fx } = this.state;-- return (- <div className={styles.formulaBox}>- {/* <Select children={namedRanges} type={0}></Select> */}- <div className={styles.formulaBar}>- <div className={styles.formulaIcon}>- <span className={this.state.spanClass}>{/* <Icon.Format.CloseIcon /> */}</span>- <span className={this.state.spanClass}>{/* <Icon.Format.CorrectIcon /> */}</span>- {fx ? (- <span className={styles.formulaBlack} onClick={fx.onClick}>- {this.getIcon(fx.icon)}- </span>- ) : null}- </div>- <div className={styles.formulaInput}>- <div- autoFocus- contentEditable={true}- className={styles.formulaContent}- onKeyUp={(e) => this.printChange(e)}- dangerouslySetInnerHTML={{ __html: this.state.formulaContent }}- />- </div>+ return (+ <div className={styles.formulaBox}>+ {/* <Select children={namedRanges} type={0}></Select> */}+ <div className={styles.formulaBar}>+ <div className={styles.formulaIcon}>+ <span className={state.spanClass}>+ <CloseSingle />+ </span>+ <span className={state.spanClass}>+ <CheckMarkSingle />+ </span>+ {state.fx ? (+ <span className={styles.formulaBlack} onClick={state.fx.onClick}>+ {Icon && <Icon />}+ </span>+ ) : null}+ </div>+ <div className={styles.formulaInput}>+ <div+ autoFocus+ contentEditable={true}+ className={styles.formulaContent}+ onKeyUp={(e) => printChange(e)}+ dangerouslySetInnerHTML={{ __html: state.formulaContent }}+ /></div></div>- );- }+ </div>+ );}diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsxindex 319b59219b..58ce98241b 100644--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsx+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsx@@ -8,7 +8,6 @@ import {SetWorksheetOrderMutation,SetWorksheetShowCommand,} from '@univerjs/base-sheets';-import { joinClassNames } from '@univerjs/base-ui';import {BooleanNumber,DisposableCollection,@@ -127,11 +126,7 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {overlay={<ul className={styles.sheetBarMenu} style={{ ...style }}>{menu.map((item) => (- <li- key={item.index}- onClick={() => handleClick(item)}- className={joinClassNames(styles.sheetBarMenuItem)}- >+ <li key={item.index} onClick={() => handleClick(item)} className={styles.sheetBarMenuItem}><span className={styles.sheetBarMenuItemIcon}>{item.selected ? <CheckMarkSingle /> : ''}</span>diff --git a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/border.menu.tsindex d57a3e53d1..2410f2c720 100644--- a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts+++ b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts@@ -19,61 +19,51 @@ export const BORDER_LINE_CHILDREN = [label: 'borderLine.borderTop',icon: 'UpBorderSingle',value: 'top',- showAfterClick: true,},{label: 'borderLine.borderBottom',icon: 'DownBorderSingle',value: 'bottom',- showAfterClick: true,},{label: 'borderLine.borderLeft',icon: 'LeftBorderSingle',value: 'left',- showAfterClick: true,},{label: 'borderLine.borderRight',icon: 'RightBorderSingle',value: 'right',- showAfterClick: true,},{label: 'borderLine.borderNone',icon: 'NoBorderSingle',value: 'none',- showAfterClick: true,},{label: 'borderLine.borderAll',icon: 'AllBorderSingle',value: 'all',- showAfterClick: true,},{label: 'borderLine.borderOutside',icon: 'OuterBorderSingle',value: 'outside',- showAfterClick: true,},{label: 'borderLine.borderInside',icon: 'InnerBorderSingle',value: 'inside',- showAfterClick: true,},{label: 'borderLine.borderHorizontal',icon: 'InnerBorderSingle',value: 'horizontal',- showAfterClick: true,},{label: 'borderLine.borderVertical',icon: 'InnerBorderSingle',value: 'vertical',- showAfterClick: true,},];@@ -191,9 +181,6 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSelpositions: [MenuPosition.TOOLBAR_START],type: MenuItemType.SUBITEMS,selections: [...BORDER_LINE_CHILDREN],- onClose: () => {- borderStyleManagerService.setActiveBorderType(false);- },};}diff --git a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.tsindex e0a980b7bd..614226c9ac 100644--- a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts+++ b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts@@ -1,4 +1,4 @@-import { BaseSelectChildrenProps, BaseSelectProps, ComponentManager } from '@univerjs/base-ui';+import { ComponentManager } from '@univerjs/base-ui';import {BorderType,HorizontalAlign,@@ -14,11 +14,10 @@ import { Inject } from '@wendellhu/redi';import { DefaultToolbarConfig, SLIDE_UI_PLUGIN_NAME, SlideToolbarConfig } from '../Basics';import { Toolbar } from '../View/Toolbar';-import { TEXT_ROTATE_CHILDREN } from '../View/Toolbar/Const';import styles from '../View/Toolbar/index.module.less';-export interface BaseToolbarSelectProps extends BaseSelectProps {- children?: BaseSelectChildrenProps[];+export interface BaseToolbarSelectProps {+ children?: any[];}enum ToolbarType {@@ -27,6 +26,7 @@ enum ToolbarType {}export interface IToolbarItemProps extends BaseToolbarSelectProps {+ name: string;active?: boolean;unActive?: boolean; //button不需保持状态show?: boolean; //是否显示按钮@@ -45,7 +45,7 @@ interface BorderInfo {export class ToolbarUIController {private _toolbar?: Toolbar;- private _toolList: IToolbarItemProps[];+ private _toolList: IToolbarItemProps[] = [];private _config: SlideToolbarConfig;@@ -66,19 +66,19 @@ export class ToolbarUIController {) {this._config = Tools.deepMerge({}, DefaultToolbarConfig, config);- this._toolList = [- {- className: styles.selectDoubleString,- name: 'textRotateMode',- tooltip: 'toolbar.textRotateMode.main',- show: this._config.textRotateMode,- onClick: (value: number | string) => {- this.setTextRotation(value);- this.hideTooltip();- },- children: TEXT_ROTATE_CHILDREN,- },- ];+ // this._toolList = [+ // {+ // className: styles.selectDoubleString,+ // name: 'textRotateMode',+ // tooltip: 'toolbar.textRotateMode.main',+ // show: this._config.textRotateMode,+ // onClick: (value: number | string) => {+ // this.setTextRotation(value);+ // this.hideTooltip();+ // },+ // children: TEXT_ROTATE_CHILDREN,+ // },+ // ];this._initialize();}diff --git a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsxindex 69f6a3dd44..38a3119059 100644--- a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx+++ b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx@@ -1,6 +1,6 @@-import { BaseComponentProps, Input } from '@univerjs/base-ui';+import { BaseComponentProps } from '@univerjs/base-ui';import { Nullable } from '@univerjs/core';-import { Container, Tooltip } from '@univerjs/design';+import { Container, Input, Tooltip } from '@univerjs/design';import { Component } from 'react';import { BaseInfoBarProps } from '../../Controller/InfoBarUIController';@@ -54,7 +54,7 @@ export class InfoBar extends Component<IProps, IState> {{/* <LogoIcon style={{ width: '152px', height: '32px' }} /> */}<div className={styles.sheetName}><Tooltip title={rename.label} placement={'bottom'}>- <Input bordered={false} value={slide.label} onBlur={renameSheet} />+ <Input value={slide.label} /></Tooltip></div><div className={styles.infoDetailUpdate}>{/* <CustomLabel label={update.label} /> */}</div>diff --git a/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsx b/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsxindex 1bc3613a0b..004085fab8 100644--- a/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsx+++ b/packages/ui-plugin-slides/src/View/SlideBar/SlideBar.tsx@@ -1,5 +1,5 @@-import { AppContext, BaseComponentProps } from '@univerjs/base-ui';-import { ISlidePage, IUniverInstanceService } from '@univerjs/core';+import { BaseComponentProps } from '@univerjs/base-ui';+import { ISlidePage } from '@univerjs/core';import { Component, createRef } from 'react';import styles from './index.module.less';@@ -15,10 +15,6 @@ interface IProps extends BaseComponentProps {}export class SlideBar extends Component<{}, SlideBarState> {- static override contextType = AppContext;-- declare context: React.ContextType<typeof AppContext>;-slideBarRef = createRef<HTMLDivElement>();constructor(props: {}) {@@ -66,18 +62,18 @@ export class SlideBar extends Component<{}, SlideBarState> {private _init(): void {// TODO: should subscribe to active slide change event- const univerInstanceService = this.context.injector.get(IUniverInstanceService);- const model = univerInstanceService.getCurrentUniverSlideInstance();- const pages = model.getPages();- const pageOrder = model.getPageOrder();- if (!pages || !pageOrder) {- return;- }+ // const univerInstanceService = this.context.injector.get(IUniverInstanceService);+ // const model = univerInstanceService.getCurrentUniverSlideInstance();+ // const pages = model.getPages();+ // const pageOrder = model.getPageOrder();+ // if (!pages || !pageOrder) {+ // return;+ // }const p: ISlidePage[] = [];- pageOrder.forEach((pageKey) => {- p.push(pages[pageKey]);- });+ // pageOrder.forEach((pageKey) => {+ // p.push(pages[pageKey]);+ // });this.setState({slideList: p,diff --git a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsxindex 25395ba759..5ff8d877cc 100644--- a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx+++ b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx@@ -1,4 +1,4 @@-import { AppContext, BaseComponentProps, debounce, Select } from '@univerjs/base-ui';+import { BaseComponentProps } from '@univerjs/base-ui';import { Button, Container, Tooltip } from '@univerjs/design';import { Component, createRef } from 'react';@@ -21,8 +21,6 @@ interface IState {}export class Toolbar extends Component<IProps, IState> {- static override contextType = AppContext;-toolbarRef = createRef<HTMLDivElement>();moreBtnRef = createRef<HTMLDivElement>();@@ -34,9 +32,9 @@ export class Toolbar extends Component<IProps, IState> {/*** Gets the distance of each button from the parent element*/- debounceSetToolbarListWidth = debounce(() => {+ debounceSetToolbarListWidth = () => {this.setToolbarListWidth();- }, 50);+ };constructor(props: IProps) {super(props);@@ -195,28 +193,30 @@ export class Toolbar extends Component<IProps, IState> {if (item.toolbarType) {if (item.show) {return (- <Tooltip key={index} title={item.tooltip} placement={'bottom'}>- <Button className={styles.textButton} onClick={item.onClick}>- {/* <CustomLabel label={item.label} /> */}- </Button>- </Tooltip>+ // <Tooltip key={index} title={item.tooltip} placement={'bottom'}>+ // <Button className={styles.textButton} onClick={item.onClick}>+ // <CustomLabel label={item.label} />+ // </Button>+ // </Tooltip>+ <></>);}} else {if (item.show) {return (- <Select- key={index}- children={item.children}- suffix={item.suffix}- label={item.label}- onClick={item.onClick}- onPressEnter={item.onPressEnter}- onMainClick={item.onMainClick}- defaultColor={item.defaultColor}- hideSelectedIcon={item.hideSelectedIcon}- className={item.className}- ></Select>+ // <Select+ // key={index}+ // children={item.children}+ // suffix={item.suffix}+ // label={item.label}+ // onClick={item.onClick}+ // onPressEnter={item.onPressEnter}+ // onMainClick={item.onMainClick}+ // defaultColor={item.defaultColor}+ // hideSelectedIcon={item.hideSelectedIcon}+ // className={item.className}+ // ></Select>+ <></>);}}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ef3b3b23c8..065b3e1267 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -515,6 +515,9 @@ importers:'@wendellhu/redi':specifier: ^0.12.10version: 0.12.10+ clsx:+ specifier: ^2.0.0+ version: 2.0.0localforage:specifier: ^1.10.0version: 1.10.0@@ -941,6 +944,9 @@ importers:'@univerjs/core':specifier: workspace:*version: link:../core+ '@univerjs/design':+ specifier: workspace:*+ version: link:../design'@univerjs/ui-plugin-sheets':specifier: workspace:*version: link:../ui-plugin-sheets