Skip to content

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.

refactor: remove `CustomLabel` & refactor `NeoCustomLabel` (#362)

白熱b9ca2f0677c8
diff --git a/docs/zh/achitecture.md b/docs/zh/achitecture.md
index 4cb929b478..d1e73e1c9c 100644
--- a/docs/zh/achitecture.md
+++ b/docs/zh/achitecture.md
@@ -244,8 +244,6 @@ interface IMenuItemBase<V> {
/** @deprecated this type seems unnecessary */
type: MenuItemType;
- /** Determines how the label of the selector should display. */
- display?: DisplayTypes;
/**
* Custom label component id.
* */
diff --git a/packages/base-ui/package.json b/packages/base-ui/package.json
index f10378c49d..5a9d0a70d4 100644
--- a/packages/base-ui/package.json
+++ b/packages/base-ui/package.json
@@ -53,7 +53,6 @@
"@univerjs/icons": "^0.1.3",
"@wendellhu/redi": "^0.12.10",
"localforage": "^1.10.0",
- "rc-dropdown": "^4.1.0",
"rc-menu": "^9.12.2",
"rc-notification": "^5.3.0",
"react": "^18.2.0",
diff --git a/packages/base-ui/src/Basics/CSS/Skin/base.less b/packages/base-ui/src/Basics/CSS/Skin/base.less
deleted file mode 100644
index 821c41da31..0000000000
--- a/packages/base-ui/src/Basics/CSS/Skin/base.less
+++ /dev/null
@@ -1,508 +0,0 @@
-/**
- * =====================================
- * Ramu / 瑞木 / Red
- * =====================================
- */
-@red-50: #fee7e7;
-@red-100: #fdcece;
-@red-200: #fb9d9d;
-@red-300: #fa7979;
-@red-400: #fe4b4b;
-@red-500: #f30b0b;
-@red-600: #e30909;
-@red-700: #cd0f0f;
-@red-800: #b20000;
-@red-900: #9d0000;
-
-:export {
- --red-50: @red-50;
- --red-100: @red-100;
- --red-200: @red-200;
- --red-300: @red-300;
- --red-400: @red-400;
- --red-500: @red-500;
- --red-600: @red-600;
- --red-700: @red-700;
- --red-800: @red-800;
- --red-900: @red-900;
-}
-
-/**
- * =====================================
- * Hemerocallis / 萱草 / Orange
- * =====================================
- */
-@orange-50: #fef0e6;
-@orange-100: #fee1cd;
-@orange-200: #fdc49b;
-@orange-300: #fca669;
-@orange-400: #ff8c51;
-@orange-500: #fb8937;
-@orange-600: #f96800;
-@orange-700: #df5d00;
-@orange-800: #cc4f10;
-@orange-900: #b24000;
-
-:export {
- --orange-50: @orange-50;
- --orange-100: @orange-100;
- --orange-200: @orange-200;
- --orange-300: @orange-300;
- --orange-400: @orange-400;
- --orange-500: @orange-500;
- --orange-600: @orange-600;
- --orange-700: @orange-700;
- --orange-800: @orange-800;
- --orange-900: @orange-900;
-}
-
-/**
- * =====================================
- * Marigold / 万寿菊 / Gold
- * =====================================
- */
-@gold-50: #fef6e6;
-@gold-100: #feeecd;
-@gold-200: #fddc9b;
-@gold-300: #fccb69;
-@gold-400: #ffbd37;
-@gold-500: #faad14;
-@gold-600: #e59b07;
-@gold-700: #c68400;
-@gold-800: #a97100;
-@gold-900: #8f5f00;
-
-:export {
- --gold-50: @gold-50;
- --gold-100: @gold-100;
- --gold-200: @gold-200;
- --gold-300: @gold-300;
- --gold-400: @gold-400;
- --gold-500: @gold-500;
- --gold-600: @gold-600;
- --gold-700: @gold-700;
- --gold-800: @gold-800;
- --gold-900: @gold-900;
-}
-
-/**
- * =====================================
- * Forsythia Suspensa / 连翘 / Yellow
- * =====================================
- */
-@yellow-50: #fefbe6;
-@yellow-100: #fef7cd;
-@yellow-200: #fdf09b;
-@yellow-300: #fce869;
-@yellow-400: #fbe137;
-@yellow-500: #f9d700;
-@yellow-600: #ebc301;
-@yellow-700: #d8b300;
-@yellow-800: #c5a300;
-@yellow-900: #b19401;
-
-:export {
- --yellow-50: @yellow-50;
- --yellow-100: @yellow-100;
- --yellow-200: @yellow-200;
- --yellow-300: @yellow-300;
- --yellow-400: @yellow-400;
- --yellow-500: @yellow-500;
- --yellow-600: @yellow-600;
- --yellow-700: @yellow-700;
- --yellow-800: @yellow-800;
- --yellow-900: @yellow-900;
-}
-
-/**
- * =====================================
- * Eustoma Grandiflorum / 洋桔梗 / Verdancy
- * =====================================
- */
-@verdancy-50: #f7fde8;
-@verdancy-100: #effbd0;
-@verdancy-200: #def6a2;
-@verdancy-300: #cef273;
-@verdancy-400: #beee44;
-@verdancy-500: #a4dc16;
-@verdancy-600: #8bbb11;
-@verdancy-700: #7aa017;
-@verdancy-800: #688c0d;
-@verdancy-900: #58770a;
-
-:export {
- --verdancy-50: @verdancy-50;
- --verdancy-100: @verdancy-100;
- --verdancy-200: @verdancy-200;
- --verdancy-300: @verdancy-300;
- --verdancy-400: @verdancy-400;
- --verdancy-500: @verdancy-500;
- --verdancy-600: @verdancy-600;
- --verdancy-700: @verdancy-700;
- --verdancy-800: @verdancy-800;
- --verdancy-900: @verdancy-900;
-}
-
-/**
- * =====================================
- * Asparagus Fern / 文竹 / Green
- * =====================================
- */
-@green-50: #effce8;
-@green-100: #dff9d2;
-@green-200: #bff3a5;
-@green-300: #9fed78;
-@green-400: #7fe74b;
-@green-500: #59d01e;
-@green-600: #49b811;
-@green-700: #409f11;
-@green-800: #398712;
-@green-900: #317310;
-
-:export {
- --green-50: @green-50;
- --green-100: @green-100;
- --green-200: @green-200;
- --green-300: @green-300;
- --green-400: @green-400;
- --green-500: @green-500;
- --green-600: @green-600;
- --green-700: @green-700;
- --green-800: @green-800;
- --green-900: @green-900;
-}
-
-/**
- * =====================================
- * 霁 / Jiqing
- * =====================================
- */
-@jiqing-50: #e8fcfc;
-@jiqing-100: #d1fafa;
-@jiqing-200: #a3f5f5;
-@jiqing-300: #76efef;
-@jiqing-400: #2aeaea;
-@jiqing-500: #1cd8d8;
-@jiqing-600: #00bbbb;
-@jiqing-700: #009e9e;
-@jiqing-800: #008a8a;
-@jiqing-900: #007676;
-
-:export {
- --jiqing-50: @jiqing-50;
- --jiqing-100: @jiqing-100;
- --jiqing-200: @jiqing-200;
- --jiqing-300: @jiqing-300;
- --jiqing-400: @jiqing-400;
- --jiqing-500: @jiqing-500;
- --jiqing-600: @jiqing-600;
- --jiqing-700: @jiqing-700;
- --jiqing-800: @jiqing-800;
- --jiqing-900: @jiqing-900;
-}
-
-/**
- * =====================================
- * Cornflower / 矢车菊 / Blue
- * =====================================
- */
-@blue-50: #e5f3ff;
-@blue-100: #cce6ff;
-@blue-200: #99ceff;
-@blue-300: #66b5ff;
-@blue-400: #339cff;
-@blue-500: #188fff;
-@blue-600: #0081fa;
-@blue-700: #0072de;
-@blue-800: #0063c0;
-@blue-900: #0053a0;
-
-:export {
- --blue-50: @blue-50;
- --blue-100: @blue-100;
- --blue-200: @blue-200;
- --blue-300: @blue-300;
- --blue-400: @blue-400;
- --blue-500: @blue-500;
- --blue-600: @blue-600;
- --blue-700: @blue-700;
- --blue-800: @blue-800;
- --blue-900: @blue-900;
-}
-
-/**
- * =====================================
- * Hyacinth / 风信子 / Hyacinth Blue
- * =====================================
- */
-@hyacinth-50: #e8ecfd;
-@hyacinth-100: #d0d9fb;
-@hyacinth-200: #a2b3f6;
-@hyacinth-300: #738df2;
-@hyacinth-400: #4567ed;
-@hyacinth-500: #2f55eb;
-@hyacinth-600: #133de3;
-@hyacinth-700: #012bd2;
-@hyacinth-800: #0025b7;
-@hyacinth-900: #001f9c;
-
-:export {
- --hyacinth-50: @hyacinth-50;
- --hyacinth-100: @hyacinth-100;
- --hyacinth-200: @hyacinth-200;
- --hyacinth-300: @hyacinth-300;
- --hyacinth-400: @hyacinth-400;
- --hyacinth-500: @hyacinth-500;
- --hyacinth-600: @hyacinth-600;
- --hyacinth-700: @hyacinth-700;
- --hyacinth-800: @hyacinth-800;
- --hyacinth-900: @hyacinth-900;
-}
-
-/**
- * =====================================
- * Violet / 紫罗兰 / Purple
- * =====================================
- */
-@purple-50: #f1eafa;
-@purple-100: #e3d5f6;
-@purple-200: #c7abed;
-@purple-300: #aa82e3;
-@purple-400: #9e6de3;
-@purple-500: #894ede;
-@purple-600: #7735d4;
-@purple-700: #6721cb;
-@purple-800: #510eb0;
-@purple-900: #3f0198;
-
-:export {
- --purple-50: @purple-50;
- --purple-100: @purple-100;
- --purple-200: @purple-200;
- --purple-300: @purple-300;
- --purple-400: @purple-400;
- --purple-500: @purple-500;
- --purple-600: @purple-600;
- --purple-700: @purple-700;
- --purple-800: @purple-800;
- --purple-900: @purple-900;
-}
-
-/**
- * =====================================
- * Sorrel pulp / 酢浆 / Magenta
- * =====================================
- */
-@magenta-50: #fde8f3;
-@magenta-100: #fbd0e8;
-@magenta-200: #f6a2d0;
-@magenta-300: #f273b9;
-@magenta-400: #f248a6;
-@magenta-500: #e7258f;
-@magenta-600: #d4157e;
-@magenta-700: #c1026b;
-@magenta-800: #a1095c;
-@magenta-900: #8f0550;
-
-:export {
- --magenta-50: @magenta-50;
- --magenta-100: @magenta-100;
- --magenta-200: @magenta-200;
- --magenta-300: @magenta-300;
- --magenta-400: @magenta-400;
- --magenta-500: @magenta-500;
- --magenta-600: @magenta-600;
- --magenta-700: @magenta-700;
- --magenta-800: @magenta-800;
- --magenta-900: @magenta-900;
-}
-
-/**
- * =====================================
- * 灰 / Grey
- * =====================================
- */
-@grey-50: #f9f9f9;
-@grey-100: #f5f5f5;
-@grey-200: #e5e5e5;
-@grey-300: #e8e8e8;
-@grey-400: #cccccc;
-@grey-500: #b2b2b2;
-@grey-600: #999999;
-@grey-700: #8b8b8b;
-@grey-800: #7d7d7d;
-@grey-900: #6f6f6f;
-@grey-950: #606060;
-@grey-1000: #505050;
-
-:export {
- --grey-50: @grey-50;
- --grey-100: @grey-100;
- --grey-200: @grey-200;
- --grey-300: @grey-300;
- --grey-400: @grey-400;
- --grey-500: @grey-500;
- --grey-600: @grey-600;
- --grey-700: @grey-700;
- --grey-800: @grey-800;
- --grey-900: @grey-900;
- --grey-950: @grey-950;
- --grey-1000: @grey-1000;
-}
-
-// 黑 / 白 / Black / White
-@color-black: #35322b;
-@color-white: #ffffff;
-
-// Box Shadow
-@box-shadow-base: 0 4px 12px rgba(@color-black, 0.08);
-@box-shadow-lg: 0 4px 24px 0 rgba(@color-black, 0.08);
-
-// Background
-@bg-color: @grey-100;
-@bg-color-hover: @grey-200;
-@bg-color-secondary: @color-white;
-
-// Text Color
-@text-color: @color-black;
-@text-color-secondary: @grey-600;
-@text-color-tertiary: @grey-200;
-
-// Border Color
-@border-color: @grey-200;
-
-// Border Radius
-@border-radius-base: 4px;
-@border-radius-lg: 8px;
-@border-radius-xl: 12px;
-
-// Margin
-@margin-xxl: 28px;
-@margin-xl: 24px;
-@margin-lg: 20px;
-@margin-base: 16px;
-@margin-sm: 12px;
-@margin-xs: 8px;
-@margin-xxs: 4px;
-
-// Padding
-@padding-xl: 20px;
-@padding-lg: 16px;
-@padding-base: 12px;
-@padding-sm: 8px;
-@padding-xs: 4px;
-
-// Font Size
-@font-size-xxl: 20px;
-@font-size-xl: 18px;
-@font-size-lg: 16px;
-@font-size-base: 15px;
-@font-size-sm: 14px;
-@font-size-xs: 13px;
-@font-size-xxs: 12px;
-
-:export {
- // 黑 / 白 / Black / White
- --color-black: @color-black;
- --color-white: @color-white;
-
- // Box Shadow
- --box-shadow-base: @box-shadow-base;
- --box-shadow-lg: @box-shadow-lg;
-
- // Background
- --bg-color: @bg-color;
- --bg-color-hover: @bg-color-hover;
- --bg-color-secondary: @bg-color-secondary;
-
- // Text Color
- --text-color: @text-color;
- --text-color-secondary: @text-color-secondary;
- --text-color-tertiary: @text-color-tertiary;
-
- // Border Color
- --border-color: @border-color;
-
- // Border Radius
- --border-radius-base: @border-radius-base;
- --border-radius-lg: @border-radius-lg;
- --border-radius-xl: @border-radius-xl;
-
- // Margin
- --margin-xl: @margin-xl;
- --margin-lg: @margin-lg;
- --margin-base: @margin-base;
- --margin-sm: @margin-sm;
- --margin-xs: @margin-xs;
- --margin-xxs: @margin-xxs;
-
- // Padding
- --padding-xl: @padding-xl;
- --padding-lg: @padding-lg;
- --padding-base: @padding-base;
- --padding-sm: @padding-sm;
- --padding-xs: @padding-xs;
-
- // Font Size
- --font-size-xxl: @font-size-xxl;
- --font-size-xl: @font-size-xl;
- --font-size-lg: @font-size-lg;
- --font-size-base: @font-size-base;
- --font-size-sm: @font-size-sm;
- --font-size-xs: @font-size-xs;
- --font-size-xxs: @font-size-xxs;
-}
-
-// TODO: to be removed
-
-// base css variables
-@line-height-base: 1.5715;
-
-@gray-3: #f5f5f5;
-@gray-4: #f0f0f0;
-@gray-5: #d9d9d9;
-@gray-6: #bfbfbf;
-@gray-7: #8c8c8c;
-@gray-8: #595959;
-@gray-9: #434343;
-@gray-10: #262626;
-@gray-11: #1f1f1f;
-@gray-12: #141414;
-@gray-13: #000000;
-@gray-14: #efefef;
-@gray-15: #e0e0e0;
-@gray-16: #ececec;
-@gray-17: #cbcbcb;
-
-
-@heading-color: @gray-10; // 标题色
-@disabled-color: @gray-6; // 失效色
-@disabled-bg: @gray-3; //失效背景色
-
-:export {
- --line-height-base: @line-height-base;
- --font-size-base: @font-size-base;
- --font-size-lg: @font-size-lg;
- --font-size-sm: @font-size-sm;
-
- --gray-3: @gray-3;
- --gray-4: @gray-4;
- --gray-5: @gray-5;
- --gray-6: @gray-6;
- --gray-7: @gray-7;
- --gray-8: @gray-8;
- --gray-9: @gray-9;
- --gray-10: @gray-10;
- --gray-11: @gray-11;
- --gray-12: @gray-12;
- --gray-13: @gray-13;
- --gray-14: @gray-14;
- --gray-15: @gray-15;
- --gray-16: @gray-16;
- --gray-17: @gray-17;
-
- --font-size: @font-size-base;
- --heading-color: @heading-color;
- --disabled-color: @disabled-color;
- --disabled-bg: @disabled-bg;
-}
diff --git a/packages/base-ui/src/Basics/CSS/Skin/default.module.less b/packages/base-ui/src/Basics/CSS/Skin/default.module.less
deleted file mode 100644
index 5c31fa3f22..0000000000
--- a/packages/base-ui/src/Basics/CSS/Skin/default.module.less
+++ /dev/null
@@ -1,32 +0,0 @@
-@import './base.less';
-
-/**
- * new design system
- */
-// Fuctional / 功能
-@info-color: @blue-400;
-@success-color: @green-500;
-@warning-color: @gold-400;
-@error-color: @red-400;
-
-// Brand / 品牌
-@primary-color: @blue-700;
-@primary-color-hover: @blue-600;
-
-// Link
-@link-color: @blue-500;
-
-:export {
- // Fuctional / 功能
- --info-color: @info-color;
- --success-color: @success-color;
- --warning-color: @warning-color;
- --error-color: @error-color;
-
- // Brand / 品牌
- --primary-color: @primary-color;
- --primary-color-hover: @primary-color-hover;
-
- // Link
- --link-color: @link-color;
-}
diff --git a/packages/base-ui/src/Basics/CSS/triangle.less b/packages/base-ui/src/Basics/CSS/triangle.less
deleted file mode 100644
index d56156c9d7..0000000000
--- a/packages/base-ui/src/Basics/CSS/triangle.less
+++ /dev/null
@@ -1,29 +0,0 @@
-.triangle(@w) {
- // content: '';
-
- // don't need position
- position: absolute;
-
- height: 0;
- width: 0;
-
- border-color: transparent;
- border-style: solid;
- border-width: @w;
-}
-.triangleLeft(@c,@w) {
- .triangle(@w);
- border-right-color: @c;
-}
-.triangleRight(@c,@w) {
- .triangle(@w);
- border-left-color: @c;
-}
-.triangleUp(@c,@w) {
- .triangle(@w);
- border-bottom-color: @c;
-}
-.triangleDown(@c,@w) {
- .triangle(@w);
- border-top-color: @c;
-}
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less b/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less
deleted file mode 100644
index a445746e3e..0000000000
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.module.less
+++ /dev/null
@@ -1,30 +0,0 @@
-.color-select {
- position: relative;
- display: flex;
- align-items: center;
-
- .color-select-line {
- position: absolute;
- width: 15px;
- height: 5px;
- bottom: 0px;
- left: 50%;
- transform: translate(-50%, 0);
- }
-}
-
-.font-select {
- width: 120px;
- font-size: 14px;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
-}
-
-.neo-custom-label {
- &-item {
- display: flex;
- align-items: center;
- gap: var(--margin-xs);
- }
-}
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.stories.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.stories.tsx
deleted file mode 100644
index 34632c6802..0000000000
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.stories.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import type { Meta } from '@storybook/react';
-
-import { CustomLabel } from './CustomLabel';
-
-const meta: Meta<typeof CustomLabel> = {
- title: 'Components / CustomLabel',
- component: CustomLabel,
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
- args: {
- label: 'test customLabel',
- },
-};
-
-export default meta;
-
-export const Playground = {
- args: {},
-};
diff --git a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
index ab4a47e18b..d91a1ead06 100644
--- a/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
+++ b/packages/base-ui/src/Components/CustomLabel/CustomLabel.tsx
@@ -1,19 +1,14 @@
import { LocaleService } from '@univerjs/core';
import { CheckMarkSingle } from '@univerjs/icons';
import { useDependency } from '@wendellhu/redi/react-bindings';
-import React, { isValidElement, JSX } from 'react';
import { ComponentManager, ICustomComponent } from '../../Common';
import { IMenuSelectorItem } from '../../services/menu/menu';
-import { Input } from '../Input';
-import { DisplayTypes } from '../Select';
-import styles from './CustomLabel.module.less';
export interface IBaseCustomLabelProps {
icon?: string;
value?: string;
label: string | ICustomComponent | React.ReactNode;
- display?: DisplayTypes;
onChange?: (e: Event) => void;
selected?: boolean;
title?: string;
@@ -37,12 +32,12 @@ export interface INeoCustomLabelProps {
* The component to render toolbar item label and menu item label.
* @param props
* @returns
+ * @deprecated
*/
export function NeoCustomLabel(
- props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'display' | 'title' | 'max' | 'min'> &
- INeoCustomLabelProps
+ props: Pick<IMenuSelectorItem<unknown>, 'label' | 'icon' | 'title'> & INeoCustomLabelProps
): JSX.Element | null {
- const { display, value, title, icon, label, onChange, selected, onFocus, max, min } = props;
+ const { title, icon, label, selected } = props;
const localeService = useDependency(LocaleService);
const componentManager = useDependency(ComponentManager);
@@ -50,139 +45,33 @@ export function NeoCustomLabel(
return localeService.t(name) ?? name;
}
- if (display === DisplayTypes.COLOR) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return <ColorSelect value={value as any} title={getLocale(title) as string} icon={icon} />;
+ 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 (display === DisplayTypes.FONT) {
- // According to the value, translate toolbar font
- return (
- <div className={styles.fontSelect} style={{ fontFamily: value as string }}>
- {getLocale(`fontFamily.${(`${value}` || '').replace(/\s/g, '')}`)}
- </div>
- );
- }
-
- if (display === DisplayTypes.INPUT) {
- return (
- <Input
- onValueChange={(v) => onChange?.(v as unknown as string)}
- onFocus={onFocus}
- type="number"
- value={`${value}`}
- bordered={false}
- style={{
- width: '32px',
- height: '24px',
- padding: '0',
- textAlign: 'center',
- background: 'transparent',
- }}
- max={max}
- min={min}
- />
- );
- }
-
- if (display === DisplayTypes.ICON && icon) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const IconComponent = componentManager.get(icon) as any;
- if (IconComponent) {
- return <IconComponent {...props} />;
- }
- }
-
- if (display === DisplayTypes.CUSTOM && label) {
+ if (label) {
const labelName = typeof label === 'string' ? label : (label as ICustomComponent).name;
+
const customProps = (label as ICustomComponent).props ?? {};
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
+
const LabelComponent = componentManager.get(labelName) as any;
- if (LabelComponent) {
- return <LabelComponent {...customProps} {...props} />;
- }
+ LabelComponent && nodes.push(<LabelComponent key={index++} {...customProps} {...props} />);
+ }
+ if (title) {
+ nodes.push(<span key={index++}>{getLocale(title)}</span>);
}
-
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const LabelComponent = icon ? (componentManager.get(icon) as any) : null;
// Process Font Family drop-down list font
return (
- <div
- className={styles.neoCustomLabelItem}
- style={{ fontFamily: title.indexOf('fontFamily.') === 0 ? `${value}` : 'inherit' }}
- >
+ <div>
{selected && (
- <span className={styles.selectItemSelected}>
+ <span>
<CheckMarkSingle style={{ color: 'rgb(var(--success-color))' }} />
</span>
)}
- {LabelComponent && <LabelComponent extend={{ colorChannel1: 'rgb(var(--primary-color))' }} />}
- <span className={styles.selectItemContent}>{getLocale(title)}</span>
+ {nodes}
</div>
);
}
-
-/** @deprecated */
-export function CustomLabel(props: IBaseCustomLabelProps): JSX.Element | null {
- const { label, display, onChange } = props;
-
- const localeService = useDependency(LocaleService);
- const componentManager = useDependency(ComponentManager);
-
- function getLocale(name: string) {
- return localeService.t(name) ?? name;
- }
-
- // the new way to render toolbar item type to replace Label prop
- if (display === DisplayTypes.COLOR) {
- return <ColorSelect value={props.label as string} title={props.label as string} />;
- }
-
- if (typeof label === 'string') {
- return <>{getLocale(label)}</>;
- }
-
- if (isValidElement(label)) {
- return label;
- }
-
- // other types of components and icon
- if (label) {
- const Label = componentManager.get((label as ICustomComponent).name) as any;
- if (Label) {
- const props = (label as ICustomComponent).props ?? {};
- return <Label onChange={onChange} {...props} />;
- }
- }
-
- return null;
-}
-
-export interface IColorSelectProps {
- icon?: string;
- title: string;
- /** color */
- value: string;
-}
-
-export function ColorSelect({ value, icon, title }: IColorSelectProps) {
- const componentManager = useDependency(ComponentManager);
- const localeService = useDependency(LocaleService);
-
- function renderIconComponent() {
- if (icon) {
- const IconComponent = componentManager.get(icon) as any;
-
- if (IconComponent) {
- // TODO: @jikkai fix the colorChannel1
- // return <IconComponent extend={{ colorChannel1: value }} />;
- return <IconComponent />;
- }
- }
-
- return localeService.t(title) ?? title;
- }
-
- return <div className={styles.colorSelect}>{renderIconComponent()}</div>;
-}
diff --git a/packages/base-ui/src/Components/Dropdown/index.module.less b/packages/base-ui/src/Components/Dropdown/index.module.less
deleted file mode 100644
index 9634f82599..0000000000
--- a/packages/base-ui/src/Components/Dropdown/index.module.less
+++ /dev/null
@@ -1,211 +0,0 @@
-@import '../../Basics/CSS/Skin/default.module.less';
-
-@dropdown-arrow-width: 8px;
-@dropdown-distance: @dropdown-arrow-width + 4;
-@dropdown-arrow-color: #373737;
-@dropdown-overlay-shadow: 0 1px 5px #ccc;
-
-.dropdown2 {
- position: absolute;
- left: -9999px;
- top: -9999px;
- z-index: 1070;
- display: block;
-
- &-hidden {
- display: none;
- }
-
- .effect() {
- animation-duration: 0.15s;
- animation-fill-mode: both;
- transform-origin: 0 0;
- display: block !important;
- }
-
- &-slide-up-enter,
- &-slide-up-appear {
- .effect();
- opacity: 0;
- animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);
- animation-play-state: paused;
- }
-
- &-slide-up-leave {
- .effect();
- opacity: 1;
- animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);
- animation-play-state: paused;
- }
-
- &-slide-up-enter&-slide-up-enter-active&-placement-bottomLeft,
- &-slide-up-appear&-slide-up-appear-active&-placement-bottomLeft,
- &-slide-up-enter&-slide-up-enter-active&-placement-bottomCenter,
- &-slide-up-appear&-slide-up-appear-active&-placement-bottomCenter,
- &-slide-up-enter&-slide-up-enter-active&-placement-bottomRight,
- &-slide-up-appear&-slide-up-appear-active&-placement-bottomRight {
- animation-name: rcDropdownSlideUpIn;
- animation-play-state: running;
- }
-
- &-slide-up-enter&-slide-up-enter-active&-placement-topLeft,
- &-slide-up-appear&-slide-up-appear-active&-placement-topLeft,
- &-slide-up-enter&-slide-up-enter-active&-placement-topCenter,
- &-slide-up-appear&-slide-up-appear-active&-placement-topCenter,
- &-slide-up-enter&-slide-up-enter-active&-placement-topRight,
- &-slide-up-appear&-slide-up-appear-active&-placement-topRight {
- animation-name: rcDropdownSlideDownIn;
- animation-play-state: running;
- }
-
- &-slide-up-leave&-slide-up-leave-active&-placement-bottomLeft,
- &-slide-up-leave&-slide-up-leave-active&-placement-bottomCenter,
- &-slide-up-leave&-slide-up-leave-active&-placement-bottomRight {
- animation-name: rcDropdownSlideUpOut;
- animation-play-state: running;
- }
-
- &-slide-up-leave&-slide-up-leave-active&-placement-topLeft,
- &-slide-up-leave&-slide-up-leave-active&-placement-topCenter,
- &-slide-up-leave&-slide-up-leave-active&-placement-topRight {
- animation-name: rcDropdownSlideDownOut;
- animation-play-state: running;
- }
-
- @keyframes rcDropdownSlideUpIn {
- 0% {
- opacity: 0;
- transform-origin: 0% 0%;
- transform: scaleY(0);
- }
- 100% {
- opacity: 1;
- transform-origin: 0% 0%;
- transform: scaleY(1);
- }
- }
- @keyframes rcDropdownSlideUpOut {
- 0% {
- opacity: 1;
- transform-origin: 0% 0%;
- transform: scaleY(1);
- }
- 100% {
- opacity: 0;
- transform-origin: 0% 0%;
- transform: scaleY(0);
- }
- }
-
- @keyframes rcDropdownSlideDownIn {
- 0% {
- opacity: 0;
- transform-origin: 0% 100%;
- transform: scaleY(0);
- }
- 100% {
- opacity: 1;
- transform-origin: 0% 100%;
- transform: scaleY(1);
- }
- }
- @keyframes rcDropdownSlideDownOut {
- 0% {
- opacity: 1;
- transform-origin: 0% 100%;
- transform: scaleY(1);
- }
- 100% {
- opacity: 0;
- transform-origin: 0% 100%;
- transform: scaleY(0);
- }
- }
-
- // adjust padding
- // adjust padding
- &-show-arrow&-placement-top,
- &-show-arrow&-placement-topLeft,
- &-show-arrow&-placement-topRight {
- padding-bottom: 6px;
- }
-
- &-show-arrow&-placement-bottom,
- &-show-arrow&-placement-bottomLeft,
- &-show-arrow&-placement-bottomRight {
- padding-top: 6px;
- }
-
- // top-*
- &-placement-top &-arrow,
- &-placement-topLeft &-arrow,
- &-placement-topRight &-arrow {
- bottom: @dropdown-distance - @dropdown-arrow-width;
- border-top-color: white;
- }
-
- &-placement-top &-arrow {
- left: 50%;
- }
-
- &-placement-topLeft &-arrow {
- left: 15%;
- }
-
- &-placement-topRight &-arrow {
- right: 15%;
- }
-
- // bottom-*
- &-placement-bottom &-arrow,
- &-placement-bottomLeft &-arrow,
- &-placement-bottomRight &-arrow {
- top: @dropdown-distance - @dropdown-arrow-width;
- border-bottom-color: white;
- }
-
- &-placement-bottom &-arrow {
- left: 50%;
- }
-
- &-placement-bottomLeft &-arrow {
- left: 15%;
- }
-
- &-placement-bottomRight &-arrow {
- right: 15%;
- }
-}
-
-// arrows
-.dropdown2-arrow {
- position: absolute;
- border-width: @dropdown-arrow-width / 2;
- border-color: transparent;
- box-shadow: @dropdown-overlay-shadow;
- border-style: solid;
- transform: rotate(45deg);
-}
-
-.dropdown {
- // padding: 4px 8px;
- position: relative;
- display: flex;
- align-items: center;
-
- .drop-content {
- display: flex;
- justify-content: space-between;
- align-items: center;
- }
-
- .drop-icon {
- height: 100%;
- // margin-left: 5px;
- // border-left: 1px solid @gray-14;
- display: flex;
- align-items: center;
- color: var(--grey-400);
- font-size: 10px;
- }
-}
diff --git a/packages/base-ui/src/Components/Dropdown/index.ts b/packages/base-ui/src/Components/Dropdown/index.ts
deleted file mode 100644
index 4a55c78783..0000000000
--- a/packages/base-ui/src/Components/Dropdown/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Dropdown2';
diff --git a/packages/base-ui/src/Components/Input/Style/index.module.less b/packages/base-ui/src/Components/Input/Style/index.module.less
index bf1af00b3b..fc75d55575 100644
--- a/packages/base-ui/src/Components/Input/Style/index.module.less
+++ b/packages/base-ui/src/Components/Input/Style/index.module.less
@@ -1,6 +1,5 @@
-@import '../../../Basics/CSS/Skin/default.module.less';
-@import './mixin.less';
+// @import './mixin.less';
-.input {
- .input();
-}
+// .input {
+// .input();
+// }
diff --git a/packages/base-ui/src/Components/Input/Style/mixin.less b/packages/base-ui/src/Components/Input/Style/mixin.less
index ab86f268cb..3631c3a557 100644
--- a/packages/base-ui/src/Components/Input/Style/mixin.less
+++ b/packages/base-ui/src/Components/Input/Style/mixin.less
@@ -1,81 +1,81 @@
-@import '../../../Basics/CSS/Skin/default.module.less';
+// @import '../../../Basics/CSS/Skin/default.module.less';
-.active() {
- outline: 0;
- box-shadow: var(--box-shadow-base);
-}
+// .active() {
+// outline: 0;
+// box-shadow: var(--box-shadow-base);
+// }
-.hover(@color: var(--primary-color-hover)) {
- border-color: @color;
-}
+// .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;
+// .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));
- }
-}
+// &: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;
+// .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();
- }
+// &:hover {
+// .hover();
+// }
- &:focus,
- &-focused {
- .active();
- }
+// &:focus,
+// &-focused {
+// .active();
+// }
- &[disabled] {
- .disabled();
- }
+// &[disabled] {
+// .disabled();
+// }
- &-disabled {
- .disabled();
- }
+// &-disabled {
+// .disabled();
+// }
- &-borderless {
- border: 1px solid transparent;
- box-shadow: none;
+// &-borderless {
+// border: 1px solid transparent;
+// box-shadow: none;
- &:hover {
- border-color: transparent;
- }
+// &:hover {
+// border-color: transparent;
+// }
- &:focus,
- &-focused {
- border-color: var(--primary-color-hover);
- .active();
- }
- }
+// &: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;
- }
+// // Remove Arrows/Spinners
+// &::-webkit-outer-spin-button,
+// &::-webkit-inner-spin-button{
+// -webkit-appearance: none;
+// margin: 0;
+// }
- &[type=number] {
- -moz-appearance: textfield;
- }
-}
+// &[type=number] {
+// -moz-appearance: textfield;
+// }
+// }
diff --git a/packages/base-ui/src/Components/Menu/Menu.stories.tsx b/packages/base-ui/src/Components/Menu/Menu.stories.tsx
deleted file mode 100644
index af184daf45..0000000000
--- a/packages/base-ui/src/Components/Menu/Menu.stories.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import type { Meta } from '@storybook/react';
-
-import { Menu2 } from './Menu2';
-
-const meta: Meta<typeof Menu2> = {
- title: 'Components / Menu',
- component: Menu2,
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
-};
-
-export default meta;
-
-export const Playground = {
- render() {
- return <Menu2 />;
- },
-};
diff --git a/packages/base-ui/src/Components/Menu/Menu.tsx b/packages/base-ui/src/Components/Menu/Menu.tsx
index db80b8cb01..7d000dd390 100644
--- a/packages/base-ui/src/Components/Menu/Menu.tsx
+++ b/packages/base-ui/src/Components/Menu/Menu.tsx
@@ -1,8 +1,11 @@
import { isRealNum } from '@univerjs/core';
-import React, { useContext, useEffect, useRef, useState } from 'react';
+import { MoreSingle } from '@univerjs/icons';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+import RcMenu, { MenuItem as RcMenuItem, SubMenu as RcSubMenu } from 'rc-menu';
+import React, { useState } from 'react';
import { isObservable, of } from 'rxjs';
-import { AppContext } from '../../Common/AppContext';
+import { ComponentManager } from '../../Common';
import {
ICustomComponentOption,
IDisplayMenuItem,
@@ -18,336 +21,134 @@ import { IMenuService } from '../../services/menu/menu.service';
import { joinClassNames } from '../../Utils';
import { NeoCustomLabel } from '../CustomLabel/CustomLabel';
import { useObservable } from '../hooks/observable';
-import { BaseMenuItem, DisplayTypes } from '../Select/Select';
import styles from './index.module.less';
-/** @deprecated */
-export interface BaseMenuProps {
- /** @deprecated */
- onClick?: (...arg: any) => void;
- /** @deprecated */
- className?: string;
- /** @deprecated */
- style?: React.CSSProperties;
- /** @deprecated */
- parent?: boolean;
- /** @deprecated */
- deep?: number;
- /** @deprecated this is legacy menu mechanism. Do not use it. Use `menuItems` instead. */
- menu?: BaseMenuItem[]; // TODO: should be renamed to `items`
+export interface IBaseMenuProps {
+ parentKey?: string | number;
+ menuType?: string | string[];
- // NOTE: options above are legacy. They are going to be removed after we complete refactoring.
-
- display?: DisplayTypes;
- menuId?: string;
value?: string | number;
options?: Array<IValueOption | ICustomComponentOption>;
+
onOptionSelect?: (option: IValueOption) => void;
onClose?: () => void;
- show?: boolean;
- clientPosition?: {
- clientX: number;
- clientY: number;
- }; //Right-click menu adaptive position, send the location of the mouse click
}
-/** @deprecated */
-export type BaseMenuStyle = {
- left?: string;
- right?: string;
- top?: string;
- bottom?: string;
-};
-
-// export interface IBaseMenuState {
-// show: boolean;
-// posStyle: BaseMenuStyle;
-// menuItems: Array<IDisplayMenuItem<IMenuItem>>;
-// } // Replace with your utility function import
-
-// interface IValueOption {
-// value: string | number;
-// label: string;
-// icon?: string;
-// disabled?: boolean;
-// }
-
-// interface ICustomComponentOption {
-// id: string;
-// disabled?: boolean;
-// }
-
-// interface BaseMenuItem {
-// show?: boolean;
-// className?: string;
-// style?: React.CSSProperties;
-// label: string;
-// children?: BaseMenuItem[];
-// border?: boolean;
-// disabled?: boolean;
-// onClick?: (e: MouseEvent, value: string | number, index: number, deep: number) => void;
-// }
-
-// type DisplayTypes = 'block' | 'inline' | 'none';
-
-// type BaseMenuStyle = React.CSSProperties;
-
-// interface BaseMenuProps {
-// display?: DisplayTypes;
-// menuId?: string;
-// value?: string | number;
-// options?: Array<IValueOption | ICustomComponentOption>;
-// onOptionSelect?: (option: IValueOption) => void;
-// }
-
-/** @deprecated */
-export const Menu = (props: BaseMenuProps) => {
- const {
- display,
- menuId,
- value,
- options,
- onOptionSelect,
- parent,
- onClick,
- deep = 0,
- menu = [],
- className = '',
- style = {},
- show = false,
- clientPosition,
- } = props;
- const context = useContext(AppContext);
- const [isShow, setIsShow] = useState(show);
- const [posStyle, setPosStyle] = useState<BaseMenuStyle>({});
- const [menuItems, setMenuItems] = useState<Array<IDisplayMenuItem<IMenuItem>>>([]);
- const MenuRef = useRef<HTMLUListElement | null>(null);
-
- useEffect(() => {
- getSubMenus();
- }, [menuId]);
-
- useEffect(() => {
- const { show = false } = props;
-
- showMenu(show);
- }, [props.show]);
-
- useEffect(() => {
- const { clientPosition } = props;
- if (!clientPosition) return;
- const { clientX = 0, clientY = 0 } = clientPosition;
- setAutoPosition(clientX, clientY);
- }, [props.clientPosition]);
-
- const showMenu = (show: boolean) => {
- if (!show) {
- props.onClose?.();
- }
- setIsShow(show);
- getStyle();
- };
-
- const getStyle = () => {
- const current = MenuRef.current;
- if (!current) return;
- const style: BaseMenuStyle = {};
- const curPosition = current.getBoundingClientRect();
- const docPosition = {
- left: 0,
- right: document.documentElement.clientWidth,
- top: 0,
- bottom: document.documentElement.clientHeight,
- };
-
- // Nested submenus
- if (parent) {
- current.style.position = 'fixed';
- const parPosition = current.parentElement?.getBoundingClientRect();
- if (!parPosition) return;
- if (parPosition.right + curPosition.width > docPosition.right) {
- style.left = `${parPosition.left - curPosition.width}px`;
- style.top = `${parPosition.top}px`;
- } else {
- style.left = `${parPosition.right}px`;
- style.top = `${parPosition.top}px`;
- }
- if (curPosition.bottom > docPosition.bottom) {
- style.top = 'auto';
- style.bottom = `5px`;
- }
- setPosStyle(style);
- }
- };
-
- const setAutoPosition = (clientX: number, clientY: number) => {
- const current = MenuRef.current;
- if (!current) return;
- const style: BaseMenuStyle = {};
- const curPosition = current.getBoundingClientRect();
- const docPosition = {
- left: 0,
- right: document.documentElement.clientWidth,
- top: 0,
- bottom: document.documentElement.clientHeight,
- };
-
- const screenW = docPosition.right;
- const screenH = docPosition.bottom;
- const clickX = clientX;
- const clickY = clientY;
- const rootW = curPosition.width;
- const rootH = curPosition.height;
-
- // right is true, which means that the width from the mouse click position to the right border of the browser can be used to place the menu. Otherwise, the menu is moved to the left.
- // bottom is true, which means that the menu can be dropped from the height of the mouse click position to the lower border of the browser. Otherwise, the menu is placed above.
- const right = screenW - clickX > rootW;
- const left = !right;
- const bottom = screenH - clickY > rootH;
- const top = !bottom;
+function MenuWrapper(props: IBaseMenuProps) {
+ const { menuType, onOptionSelect } = props;
+ const menuService = useDependency(IMenuService);
- if (right) {
- style.left = `${clickX}px`;
- }
+ if (!menuType) return;
- if (left) {
- style.left = `${clickX - rootW}px`;
- }
+ if (Array.isArray(menuType)) {
+ const menuTypes = menuType.map((type) => menuService.getMenuItems(type));
- if (bottom) {
- style.top = `${clickY}px`;
- }
- if (top) {
- style.top = `${clickY - rootH}px`;
- }
+ return (
+ <>
+ {menuTypes.map((menuItems) =>
+ menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
+ <MenuItem
+ key={item.id}
+ menuItem={item}
+ onClick={(object: Partial<IValueOption>) => {
+ onOptionSelect?.({ value: '', label: item.id, ...object });
+ }}
+ />
+ ))
+ )}
+ </>
+ );
+ }
- setPosStyle(style);
- };
+ const menuItems = menuService.getMenuItems(menuType);
+
+ return menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
+ <MenuItem
+ key={item.id}
+ menuItem={item}
+ onClick={(object: Partial<IValueOption>) => {
+ onOptionSelect?.({ value: '', label: item.id, ...object });
+ }}
+ />
+ ));
+}
- const getSubMenus = () => {
- if (menuId) {
- const menuService = context.injector?.get(IMenuService); // Assuming context is available
- if (!menuService) {
- throw new Error('menuService is not defined');
- }
- setMenuItems(menuService.getMenuItems(menuId));
+function MenuOptionsWrapper(props: IBaseMenuProps) {
+ const { options, value, onOptionSelect, parentKey } = props;
+
+ const componentManager = useDependency(ComponentManager);
+
+ return options?.map((option: IValueOption | ICustomComponentOption, index: number) => {
+ const isValueOption = isValueOptions(option);
+ const key = `${parentKey}-${isValueOption ? option.label : option.id}-${index}`;
+
+ if (isValueOption) {
+ return (
+ <RcMenuItem
+ key={key}
+ eventKey={key}
+ className={joinClassNames(
+ styles.menuItem,
+ option.disabled ? styles.colsMenuitemDisabled : ''
+ // String(value) === String(option.value) ? styles.selectItemSelected : '' // Set the background color of Item
+ )}
+ onClick={() => {
+ onOptionSelect?.({
+ ...option,
+ });
+ }}
+ >
+ <NeoCustomLabel
+ selected={String(value) === String(option.value)} // use √ for select
+ value={String(option.value)}
+ label={option.label}
+ title={typeof option.label === 'string' ? option.label : ''}
+ icon={option.icon}
+ />
+ </RcMenuItem>
+ );
}
- };
-
- return (
- <ul
- className={joinClassNames(styles.colsMenu, className)}
- style={{ ...style, ...posStyle, display: isShow ? 'block' : 'none' }}
- ref={MenuRef}
- >
- {/* legacy: render selections */}
- {options?.map((option: IValueOption | ICustomComponentOption, index: number) => {
- const isValueOption = isValueOptions(option);
- if (isValueOption) {
- return (
- <li
- key={index}
- className={joinClassNames(
- styles.colsMenuitem,
- option.disabled ? styles.colsMenuitemDisabled : ''
- // String(value) === String(option.value) ? styles.selectItemSelected : '' // Set the background color of Item
- )}
- onClick={() => {
- // Execute the callback function
- // if (option.value) { // color picker cancel use ''
- onOptionSelect?.({
- ...option,
- show: option.showAfterClick,
- });
- // }
- }}
- >
- <NeoCustomLabel
- selected={String(value) === String(option.value)} // use √ for select
- value={String(option.value)}
- display={display}
- label={option.label}
- title={typeof option.label === 'string' ? option.label : ''}
- icon={option.icon}
- />
- </li>
- );
- }
- const CustomComponent = context.componentManager?.get(option.id) as React.ComponentType<any>;
- return (
- <li
- key={index}
- className={joinClassNames(
- styles.colsMenuitem,
- option.disabled ? styles.colsMenuitemDisabled : ''
- )}
- >
- <CustomComponent
- onValueChange={(v: string | number) => {
- onOptionSelect?.({
- value: v,
- label: option.id,
- });
- }}
- />
- </li>
- );
- })}
- {/* render submenus */}
- {menuItems?.map((item: IDisplayMenuItem<IMenuItem>, index) => (
- <MenuItem
- menuItem={item}
- key={index}
- index={index}
- onClick={(object: Partial<IValueOption>) => {
- onOptionSelect?.({ value: '', label: item.id, ...object });
+ const CustomComponent = componentManager.get(option.id) as React.ComponentType<any>;
+ return (
+ <RcMenuItem
+ key={key}
+ eventKey={key}
+ className={joinClassNames(
+ styles.menuItem,
+ styles.menuItemCustom,
+ option.disabled ? styles.colsMenuitemDisabled : ''
+ )}
+ >
+ <CustomComponent
+ onValueChange={(v: string | number) => {
+ onOptionSelect?.({
+ value: v,
+ label: option.id,
+ });
}}
/>
- ))}
- </ul>
- );
-};
+ </RcMenuItem>
+ );
+ });
+}
+
+export const Menu = (props: IBaseMenuProps) => (
+ <RcMenu prefixCls={styles.menu} selectable={false}>
+ <MenuOptionsWrapper {...props} />
+ <MenuWrapper {...props} />
+ </RcMenu>
+);
export interface IMenuItemProps {
menuItem: IDisplayMenuItem<IMenuItem>;
- index: number;
onClick: (params: Partial<IValueOption>) => void;
}
-export interface IMenuItemState {
- disabled: boolean;
- menuItems: Array<IDisplayMenuItem<IMenuItem>>;
- value: any;
-}
-
-export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
- const context = useContext(AppContext);
- const [menuItems, setMenuItems] = useState<Array<IDisplayMenuItem<IMenuItem>>>([]);
- const [itemShow, setItemShow] = useState<boolean>(false);
-
- const mouseEnter = (e: React.MouseEvent<HTMLLIElement, MouseEvent>, index: number) => {
- setItemShow(true);
- };
-
- const mouseLeave = (e: React.MouseEvent<HTMLLIElement, MouseEvent>, index: number) => {
- setItemShow(false);
- };
-
- const getSubMenus = () => {
- const { id } = menuItem;
-
- if (id) {
- const menuService = context.injector?.get(IMenuService);
- menuService && setMenuItems(menuService.getMenuItems(id));
- }
- };
-
- useEffect(() => {
- getSubMenus();
+export function MenuItem({ menuItem, onClick }: IMenuItemProps) {
+ const menuService = useDependency(IMenuService);
- return () => {};
- }, [menuItem]);
+ const menuItems = menuItem.id ? menuService.getMenuItems(menuItem.id) : [];
const disabled = useObservable<boolean>(menuItem.disabled$ || of(false), false, true);
const hidden = useObservable(menuItem.hidden$ || of(false), false, true);
@@ -356,89 +157,108 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
/**
* user input change value from CustomLabel
- * @param e
+ * @param v
*/
const onChange = (v: string | number) => {
const newValue = isRealNum(v) && typeof v === 'string' ? parseInt(v) : v;
setInputValue(newValue);
};
- let selections: Array<IValueOption | ICustomComponentOption>;
- if (menuItem.type === MenuItemType.SELECTOR) {
- if (isObservable(menuItem.selections)) {
- selections = useObservable<Array<IValueOption | ICustomComponentOption>>(
- menuItem.selections || of([]),
- [],
- true
- );
- } else {
- selections = menuItem.selections || [];
- }
- }
const renderButtonType = () => {
const item = menuItem as IDisplayMenuItem<IMenuButtonItem>;
- const { title, display, label } = item;
+ const { title, label } = item;
return (
- <li
- className={joinClassNames(styles.colsMenuitem, disabled ? styles.colsMenuitemDisabled : '')}
+ <RcMenuItem
+ key={item.id}
+ eventKey={item.id}
+ className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}
// disabled={disabled} // FIXME disabled is not working
onClick={() => {
- // commandService.executeCommand(item.id, { value });// move to business components
onClick({ value: inputValue, id: item.id }); // merge cell
}}
>
<NeoCustomLabel
- display={display}
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 });
}}
- ></NeoCustomLabel>
- </li>
+ />
+ </RcMenuItem>
);
};
const renderSelectorType = () => {
const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;
+ let selections: Array<IValueOption | ICustomComponentOption>;
+ if (isObservable(item.selections)) {
+ selections = useObservable<Array<IValueOption | ICustomComponentOption>>(
+ item.selections || of([]),
+ [],
+ true
+ );
+ } else {
+ selections = item.selections || [];
+ }
+
+ if (selections.length > 0) {
+ return (
+ <RcSubMenu
+ key={item.id}
+ eventKey={item.id}
+ className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}
+ popupOffset={[18, 0]}
+ title={
+ <>
+ <NeoCustomLabel
+ title={item.title}
+ value={inputValue}
+ onChange={onChange}
+ icon={item.icon}
+ label={item.label}
+ />
+ {item.shortcut && ` (${item.shortcut})`}
+ </>
+ }
+ expandIcon={
+ <MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />
+ }
+ >
+ {selections.length > 0 && (
+ <MenuOptionsWrapper
+ parentKey={item.id}
+ menuType={item.id}
+ options={selections}
+ onOptionSelect={(v) => {
+ onClick({ value: v.value, id: item.id }); // border style don't trigger hide menu, set show true
+ }}
+ />
+ )}
+ </RcSubMenu>
+ );
+ }
+
return (
- <li
- className={joinClassNames(styles.colsMenuitem, disabled ? styles.colsMenuitemDisabled : '')}
- onMouseEnter={(e) => mouseEnter(e, index)}
- onMouseLeave={(e) => mouseLeave(e, index)}
- // onClick={(e) => handleClick(e, item, index)} // Nested select without click events, like border style
+ <RcMenuItem
+ key={item.id}
+ eventKey={item.id}
+ className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}
>
<NeoCustomLabel
title={item.title}
value={inputValue}
onChange={onChange}
icon={item.icon}
- display={item.display}
label={item.label}
- max={item.max}
- min={item.min}
- ></NeoCustomLabel>
+ />
{item.shortcut && ` (${item.shortcut})`}
- {(menuItems.length > 0 || selections?.length > 0) && (
- <Menu
- show={itemShow}
- onOptionSelect={(v) => {
- // commandService.executeCommand(item.id, { value: v.value });
- onClick({ value: v.value, id: item.id, show: true }); // border style don't trigger hide menu, set show true
- setItemShow(false); // hide current menu
- }}
- menuId={item.id}
- options={selections}
- display={item.display}
- parent={true}
- ></Menu>
- )}
- </li>
+ </RcMenuItem>
);
};
@@ -446,29 +266,20 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;
return (
- <li
- className={joinClassNames(styles.colsMenuitem, disabled ? styles.colsMenuitemDisabled : '')}
- onMouseEnter={(e) => mouseEnter(e, index)}
- onMouseLeave={(e) => mouseLeave(e, index)}
- // onClick={(e) => handleClick(e, item, index)} // Nested menus without click events, like right menu delete cell
+ <RcSubMenu
+ key={item.id}
+ eventKey={item.id}
+ className={joinClassNames(styles.menuItem, disabled ? styles.menuItemDisabled : '')}
+ popupOffset={[18, 0]}
+ title={
+ <>
+ <NeoCustomLabel title={item.title} value={item.title} icon={item.icon} label={item.label} />
+ </>
+ }
+ expandIcon={<MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />}
>
- <NeoCustomLabel
- title={item.title}
- value={item.title}
- icon={item.icon}
- display={item.display}
- label={item.label}
- ></NeoCustomLabel>
- {(menuItems.length > 0 || selections?.length) && (
- <Menu
- show={itemShow}
- menuId={item.id}
- display={item.display}
- parent={true}
- onOptionSelect={onClick}
- ></Menu>
- )}
- </li>
+ {menuItems.length && <MenuWrapper menuType={item.id} parentKey={item.id} onOptionSelect={onClick} />}
+ </RcSubMenu>
);
};
@@ -480,7 +291,7 @@ export function MenuItem({ menuItem, index, onClick }: IMenuItemProps) {
<>
{menuItem.type === MenuItemType.SELECTOR && renderSelectorType()}
{menuItem.type === MenuItemType.SUBITEMS && renderSubItemsType()}
- {menuItem.type !== MenuItemType.SELECTOR && menuItem.type !== MenuItemType.SUBITEMS && renderButtonType()}
+ {menuItem.type === MenuItemType.BUTTON && renderButtonType()}
</>
);
}
diff --git a/packages/base-ui/src/Components/Menu/Menu2.tsx b/packages/base-ui/src/Components/Menu/Menu2.tsx
deleted file mode 100644
index cbd1a4a2a3..0000000000
--- a/packages/base-ui/src/Components/Menu/Menu2.tsx
+++ /dev/null
@@ -1,313 +0,0 @@
-import { isRealNum } from '@univerjs/core';
-import { MoreSingle } from '@univerjs/icons';
-import { useDependency } from '@wendellhu/redi/react-bindings';
-import RcMenu, { MenuItem, SubMenu } from 'rc-menu';
-import React, { useState } from 'react';
-import { isObservable, of } from 'rxjs';
-
-import { ComponentManager } from '../../Common';
-import {
- ICustomComponentOption,
- IDisplayMenuItem,
- IMenuButtonItem,
- IMenuItem,
- IMenuSelectorItem,
- isValueOptions,
- IValueOption,
- MenuItemDefaultValueType,
- MenuItemType,
-} from '../../services/menu/menu';
-import { IMenuService } from '../../services/menu/menu.service';
-import { joinClassNames } from '../../Utils';
-import { NeoCustomLabel } from '../CustomLabel/CustomLabel';
-import { useObservable } from '../hooks/observable';
-import { DisplayTypes } from '../Select/Select';
-import styles from './index.module.less';
-
-export interface IBaseMenuProps {
- menuType?: string | string[];
-
- // used for selector
- display?: DisplayTypes;
- value?: string | number;
- options?: Array<IValueOption | ICustomComponentOption>;
-
- onOptionSelect?: (option: IValueOption) => void;
- onClose?: () => void;
-}
-
-function Menu2Wrapper(props: IBaseMenuProps) {
- const { menuType, onOptionSelect } = props;
- const menuService = useDependency(IMenuService);
-
- if (!menuType) return;
-
- if (Array.isArray(menuType)) {
- const menuTypes = menuType.map((type) => menuService.getMenuItems(type));
-
- return (
- <>
- {menuTypes.map((menuItems) =>
- menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
- <Menu2Item
- key={item.id}
- menuItem={item}
- onClick={(object: Partial<IValueOption>) => {
- onOptionSelect?.({ value: '', label: item.id, ...object });
- }}
- />
- ))
- )}
- </>
- );
- }
-
- const menuItems = menuService.getMenuItems(menuType);
-
- return menuItems.map((item: IDisplayMenuItem<IMenuItem>) => (
- <Menu2Item
- key={item.id}
- menuItem={item}
- onClick={(object: Partial<IValueOption>) => {
- onOptionSelect?.({ value: '', label: item.id, ...object });
- }}
- />
- ));
-}
-
-function Menu2OptionsWrapper(props: IBaseMenuProps) {
- const { options, value, display, onOptionSelect } = props;
-
- const componentManager = useDependency(ComponentManager);
-
- return options?.map((option: IValueOption | ICustomComponentOption, index: number) => {
- const isValueOption = isValueOptions(option);
- const key = (isValueOption ? option.label : option.id).toString();
-
- if (isValueOption) {
- return (
- <MenuItem
- key={key}
- eventKey={key}
- className={joinClassNames(
- styles.menu2Item,
- option.disabled ? styles.colsMenuitemDisabled : ''
- // String(value) === String(option.value) ? styles.selectItemSelected : '' // Set the background color of Item
- )}
- onClick={() => {
- onOptionSelect?.({
- ...option,
- });
- }}
- >
- <NeoCustomLabel
- selected={String(value) === String(option.value)} // use √ for select
- value={String(option.value)}
- display={display}
- label={option.label}
- title={typeof option.label === 'string' ? option.label : ''}
- icon={option.icon}
- />
- </MenuItem>
- );
- }
-
- const CustomComponent = componentManager.get(option.id) as React.ComponentType<any>;
- return (
- <MenuItem
- key={key}
- eventKey={key}
- className={joinClassNames(
- styles.menu2Item,
- styles.menu2ItemCustom,
- option.disabled ? styles.colsMenuitemDisabled : ''
- )}
- >
- <CustomComponent
- onValueChange={(v: string | number) => {
- onOptionSelect?.({
- value: v,
- label: option.id,
- });
- }}
- />
- </MenuItem>
- );
- });
-}
-
-export const Menu2 = (props: IBaseMenuProps) => (
- <RcMenu prefixCls={styles.menu2} selectable={false}>
- <Menu2OptionsWrapper {...props} />
- <Menu2Wrapper {...props} />
- </RcMenu>
-);
-
-export interface IMenu2ItemProps {
- menuItem: IDisplayMenuItem<IMenuItem>;
- onClick: (params: Partial<IValueOption>) => void;
-}
-
-export function Menu2Item({ menuItem, onClick }: IMenu2ItemProps) {
- const menuService = useDependency(IMenuService);
-
- const menuItems = menuItem.id ? menuService.getMenuItems(menuItem.id) : [];
-
- const disabled = useObservable<boolean>(menuItem.disabled$ || of(false), false, true);
- const hidden = useObservable(menuItem.hidden$ || of(false), false, true);
- const value = useObservable<MenuItemDefaultValueType>(menuItem.value$ || of(undefined), undefined, true);
- const [inputValue, setInputValue] = useState(value);
-
- /**
- * user input change value from CustomLabel
- * @param v
- */
- const onChange = (v: string | number) => {
- const newValue = isRealNum(v) && typeof v === 'string' ? parseInt(v) : v;
- setInputValue(newValue);
- };
-
- const renderButtonType = () => {
- const item = menuItem as IDisplayMenuItem<IMenuButtonItem>;
- const { title, display, label } = item;
-
- return (
- <MenuItem
- key={item.id}
- eventKey={item.id}
- className={joinClassNames(styles.menu2Item, disabled ? styles.menu2ItemDisabled : '')}
- // disabled={disabled} // FIXME disabled is not working
- onClick={() => {
- onClick({ value: inputValue, id: item.id }); // merge cell
- }}
- >
- <NeoCustomLabel
- display={display}
- 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 });
- }}
- />
- </MenuItem>
- );
- };
-
- const renderSelectorType = () => {
- const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;
-
- let selections: Array<IValueOption | ICustomComponentOption>;
- if (isObservable(item.selections)) {
- selections = useObservable<Array<IValueOption | ICustomComponentOption>>(
- item.selections || of([]),
- [],
- true
- );
- } else {
- selections = item.selections || [];
- }
-
- if (selections.length > 0) {
- return (
- <SubMenu
- key={item.id}
- eventKey={item.id}
- className={joinClassNames(styles.menu2Item, disabled ? styles.menu2ItemDisabled : '')}
- popupOffset={[18, 0]}
- title={
- <>
- <NeoCustomLabel
- title={item.title}
- value={inputValue}
- onChange={onChange}
- icon={item.icon}
- display={item.display}
- label={item.label}
- max={item.max}
- min={item.min}
- />
- {item.shortcut && ` (${item.shortcut})`}
- </>
- }
- expandIcon={
- <MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />
- }
- >
- {selections.length > 0 && (
- <Menu2OptionsWrapper
- menuType={item.id}
- options={selections}
- display={item.display}
- onOptionSelect={(v) => {
- onClick({ value: v.value, id: item.id }); // border style don't trigger hide menu, set show true
- }}
- />
- )}
- </SubMenu>
- );
- }
-
- return (
- <MenuItem
- key={item.id}
- eventKey={item.id}
- className={joinClassNames(styles.menu2Item, disabled ? styles.menu2ItemDisabled : '')}
- >
- <NeoCustomLabel
- title={item.title}
- value={inputValue}
- onChange={onChange}
- icon={item.icon}
- display={item.display}
- label={item.label}
- max={item.max}
- min={item.min}
- />
- {item.shortcut && ` (${item.shortcut})`}
- </MenuItem>
- );
- };
-
- const renderSubItemsType = () => {
- const item = menuItem as IDisplayMenuItem<IMenuSelectorItem>;
-
- return (
- <SubMenu
- key={item.id}
- eventKey={item.id}
- className={joinClassNames(styles.menu2Item, disabled ? styles.menu2ItemDisabled : '')}
- popupOffset={[18, 0]}
- title={
- <>
- <NeoCustomLabel
- title={item.title}
- value={item.title}
- icon={item.icon}
- display={item.display}
- label={item.label}
- />
- </>
- }
- expandIcon={<MoreSingle style={{ color: styles.textColorSecondary, fontSize: styles.fontSizeXs }} />}
- >
- {menuItems.length && <Menu2Wrapper menuType={item.id} onOptionSelect={onClick} />}
- </SubMenu>
- );
- };
-
- if (hidden) {
- return null;
- }
-
- return (
- <>
- {menuItem.type === MenuItemType.SELECTOR && renderSelectorType()}
- {menuItem.type === MenuItemType.SUBITEMS && renderSubItemsType()}
- {menuItem.type === MenuItemType.BUTTON && renderButtonType()}
- </>
- );
-}
diff --git a/packages/base-ui/src/Components/Menu/index.module.less b/packages/base-ui/src/Components/Menu/index.module.less
index c7e72613e7..6694116e39 100644
--- a/packages/base-ui/src/Components/Menu/index.module.less
+++ b/packages/base-ui/src/Components/Menu/index.module.less
@@ -1,4 +1,4 @@
-.menu2 {
+.menu {
padding: var(--padding-base);
margin: 0;
font-size: var(--font-size-sm);
@@ -73,8 +73,8 @@
cursor: pointer;
// Disabled state sets text to gray and nukes hover/tab effects
- &.menu2-item-disabled,
- &.menu2-submenu-disabled {
+ &.menu-item-disabled,
+ &.menu-submenu-disabled {
color: rgb(var(--grey-200)) !important;
}
}
@@ -95,13 +95,13 @@
padding-right: 20px;
}
}
- > .menu2 {
+ > .menu {
background-color: #fff;
}
}
- .menu2-submenu-title,
- .menu2-item {
+ .menu-submenu-title,
+ .menu-item {
.anticon {
width: 14px;
height: 14px;
@@ -118,13 +118,13 @@
white-space: nowrap;
overflow: hidden;
- & > .menu2-item,
- & > .menu2-submenu > .menu2-submenu-title {
+ & > .menu-item,
+ & > .menu-submenu > .menu-submenu-title {
padding: 15px 20px;
}
- & > .menu2-submenu,
- & > .menu2-item {
+ & > .menu-submenu,
+ & > .menu-item {
border-bottom: 2px solid transparent;
display: inline-block;
vertical-align: bottom;
@@ -141,8 +141,8 @@
&-vertical-left,
&-vertical-right,
&-inline {
- & > .menu2-item,
- & > .menu2-submenu > .menu2-submenu-title {
+ & > .menu-item,
+ & > .menu-submenu > .menu-submenu-title {
width: 100%;
min-height: 28px;
padding: var(--padding-xs) var(--padding-sm);
@@ -151,7 +151,7 @@
justify-content: space-between;
align-items: center;
}
- .menu2-submenu-arrow {
+ .menu-submenu-arrow {
display: inline-block;
font: normal normal normal 14px/1 FontAwesome;
font-size: inherit;
@@ -171,8 +171,8 @@
border-radius: 0;
box-shadow: none;
- & > .menu2-item,
- & > .menu2-submenu > .menu2-submenu-title {
+ & > .menu-item,
+ & > .menu-submenu > .menu-submenu-title {
padding-top: 8px;
padding-bottom: 8px;
padding-right: 0;
diff --git a/packages/base-ui/src/Components/Menu/index.ts b/packages/base-ui/src/Components/Menu/index.ts
index 6640e23132..629d3d0aa1 100644
--- a/packages/base-ui/src/Components/Menu/index.ts
+++ b/packages/base-ui/src/Components/Menu/index.ts
@@ -1,2 +1 @@
export * from './Menu';
-export * from './Menu2';
diff --git a/packages/base-ui/src/Components/Notification/index.module.less b/packages/base-ui/src/Components/Notification/index.module.less
index 5b0be8b6af..ad22d26124 100644
--- a/packages/base-ui/src/Components/Notification/index.module.less
+++ b/packages/base-ui/src/Components/Notification/index.module.less
@@ -1,5 +1,3 @@
-@import '../../Basics/CSS/Skin/default.module.less';
-
@width: 280px;
.notification {
@@ -121,50 +119,50 @@
overflow: hidden;
transition: all 0.3s;
}
-
+
&-fade-appear-prepare {
opacity: 0;
}
-
+
&-fade-appear-start {
transform: translateX(100%);
opacity: 0;
}
-
+
&-fade-appear-active {
transform: translateX(0);
opacity: 1;
}
-
+
.fade-effect() {
animation-duration: 0.3s;
animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2);
animation-fill-mode: both;
}
-
+
&-fade-appear,
&-fade-enter {
opacity: 0;
animation-play-state: paused;
.fade-effect();
}
-
+
&-fade-leave {
.fade-effect();
animation-play-state: paused;
}
-
+
&-fade-appear&-fade-appear-active,
&-fade-enter&-fade-enter-active {
animation-name: notificationFadeIn;
animation-play-state: running;
}
-
+
&-fade-leave&-fade-leave-active {
animation-name: notificationFadeOut;
animation-play-state: running;
}
-
+
@keyframes notificationFadeIn {
0% {
opacity: 0;
@@ -173,7 +171,7 @@
opacity: 1;
}
}
-
+
@keyframes notificationFadeOut {
0% {
opacity: 1;
diff --git a/packages/base-ui/src/Components/Select/Select.tsx b/packages/base-ui/src/Components/Select/Select.tsx
index 71777daa9b..e4f57611cc 100644
--- a/packages/base-ui/src/Components/Select/Select.tsx
+++ b/packages/base-ui/src/Components/Select/Select.tsx
@@ -1,11 +1,11 @@
+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 { Dropdown2 } from '../Dropdown';
-import { Menu2 } from '../Menu/Menu2';
+import { Menu } from '../Menu/Menu';
import styles from './index.module.less';
// TODO: these type definitions should be moved out of components to menu service
@@ -27,24 +27,6 @@ export interface BaseItemProps extends BaseMenuItem {
border?: boolean;
}
-export enum DisplayTypes {
- LABEL,
-
- /** @deprecated */
- SUFFIX,
-
- ICON,
-
- /** Label as color display. */
- COLOR,
-
- INPUT,
-
- FONT,
-
- CUSTOM,
-}
-
export interface BaseSelectChildrenProps extends Omit<BaseItemProps, 'suffix' | 'label' | 'children'> {
onPressEnter?: (...arg: any) => void;
children?: BaseSelectChildrenProps[];
@@ -56,8 +38,12 @@ export interface BaseSelectChildrenProps extends Omit<BaseItemProps, 'suffix' |
export interface BaseSelectProps {
children?: BaseSelectChildrenProps[];
- display?: DisplayTypes;
- label?: React.ReactNode;
+ label?:
+ | string
+ | {
+ name: string;
+ props?: Record<string, string | number>;
+ };
onClick?: (...arg: any) => void; //下拉Ul点击事件
onPressEnter?: (...arg: any) => void;
onMainClick?: () => void; // 非功能按钮事件
@@ -66,7 +52,6 @@ export interface BaseSelectProps {
className?: string;
name?: string;
suffix?: any;
- tooltip?: string;
value?: string | number;
icon?: string;
id?: string;
@@ -82,7 +67,7 @@ export interface BaseSelectProps {
export function Select(props: BaseSelectProps) {
const renderNeo = () => {
const { onClick, ...restProps } = props;
- const { display, value, icon, title, id, options, onClose, max, min } = restProps;
+ const { value, icon, title, id, label, options, onClose, max, min } = restProps;
const onOptionSelect = (option: IValueOption) => {
onClick?.(option);
@@ -92,10 +77,10 @@ export function Select(props: BaseSelectProps) {
return (
<div className={styles.selectDouble}>
- <Dropdown2
+ <Dropdown
{...restProps}
overlay={
- <Menu2
+ <Menu
menuType={id}
options={options}
onOptionSelect={onOptionSelect}
@@ -107,23 +92,16 @@ export function Select(props: BaseSelectProps) {
<div className={styles.selectLabel}>
<NeoCustomLabel
icon={iconToDisplay}
- display={display}
title={title!}
value={value}
- max={max}
- min={min}
+ label={label}
onChange={(v) => onClick?.(v)}
- onFocus={() => {
- console.info(
- 'TODO: 需要待Dropdown与Menu分离之后,直接控制Dropdown展示文字大小下拉选项'
- );
- }}
/>
<div className={styles.selectDropIcon}>
<MoreDownSingle />
</div>
</div>
- </Dropdown2>
+ </Dropdown>
</div>
);
};
diff --git a/packages/base-ui/src/Components/Slider/Slider.tsx b/packages/base-ui/src/Components/Slider/Slider.tsx
index 7cfa378c6a..e47283522b 100644
--- a/packages/base-ui/src/Components/Slider/Slider.tsx
+++ b/packages/base-ui/src/Components/Slider/Slider.tsx
@@ -1,10 +1,9 @@
/* eslint-disable no-magic-numbers */
-import { Button, Tooltip } from '@univerjs/design';
+import { Button, Dropdown, Tooltip } from '@univerjs/design';
import { IncreaseSingle, ReduceSingle } from '@univerjs/icons';
import { useMemo, useRef } from 'react';
import { joinClassNames } from '../../Utils';
-import { Dropdown2 } from '../Dropdown/Dropdown2';
import styles from './index.module.less';
/**
@@ -145,7 +144,7 @@ export function Slider(props: ISliderProps) {
<IncreaseSingle />
</Button>
- <Dropdown2
+ <Dropdown
placement="topLeft"
overlay={
<div className={styles.sliderShortcuts}>
@@ -166,7 +165,7 @@ export function Slider(props: ISliderProps) {
}
>
<a className={styles.sliderValue}>{value}%</a>
- </Dropdown2>
+ </Dropdown>
</div>
);
}
diff --git a/packages/base-ui/src/Components/Slider/index.module.less b/packages/base-ui/src/Components/Slider/index.module.less
index 645e3f7ce1..9d48bd6e8a 100644
--- a/packages/base-ui/src/Components/Slider/index.module.less
+++ b/packages/base-ui/src/Components/Slider/index.module.less
@@ -1,5 +1,3 @@
-@import '../../Basics/CSS/Skin/default.module.less';
-
@slider-bg: rgb(var(--text-color-secondary));
@slider-width: 116px;
@slider-height: 2px;
@@ -83,7 +81,7 @@
background-color: @slider-parts-hover-color;
}
- &.dropdown2-open {
+ &.dropdown-open {
background-color: @slider-parts-hover-color;
}
}
diff --git a/packages/base-ui/src/Components/Tabs/index.module.less b/packages/base-ui/src/Components/Tabs/index.module.less
index 82ccad240a..f5d3c4932b 100644
--- a/packages/base-ui/src/Components/Tabs/index.module.less
+++ b/packages/base-ui/src/Components/Tabs/index.module.less
@@ -1,5 +1,3 @@
-@import '../../Basics/CSS/Skin/default.module.less';
-
.tabs {
overflow: hidden;
@@ -72,8 +70,8 @@
.tabs-nav-list {
.tabs-tab {
margin: 0;
- background: @bg-color;
- border: 1px solid @border-color;
+ // background: @bg-color;
+ // border: 1px solid @border-color;
&-active {
color: var(--primary-color);
diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.ts
index fc2866bccb..3be926ce51 100644
--- a/packages/base-ui/src/Components/index.ts
+++ b/packages/base-ui/src/Components/index.ts
@@ -1,5 +1,4 @@
export * from './CustomLabel';
-export * from './Dropdown';
export * from './Input';
export * from './Menu';
export * from './Select';
diff --git a/packages/base-ui/src/Utils/util.ts b/packages/base-ui/src/Utils/util.ts
index 9f26850ad5..13e1f68911 100644
--- a/packages/base-ui/src/Utils/util.ts
+++ b/packages/base-ui/src/Utils/util.ts
@@ -1,24 +1,3 @@
-/**
- * check element
- * @param element
- * @returns
- */
-export function isElement(element: any) {
- return element instanceof Element || element instanceof HTMLDocument;
-}
-
-/**
- * DOM selector
- * @param {String} selector css selector
- * @param {String} context parent DOM
- */
-export function $$(selector: string, context?: HTMLElement | Document) {
- context = context || document;
- const elements = context.querySelectorAll(selector);
-
- return elements.length === 1 ? Array.prototype.slice.call(elements)[0] : Array.prototype.slice.call(elements);
-}
-
/**
* add className
* @param className
diff --git a/packages/base-ui/src/services/menu/menu.ts b/packages/base-ui/src/services/menu/menu.ts
index 75df9e7184..ea6f140964 100644
--- a/packages/base-ui/src/services/menu/menu.ts
+++ b/packages/base-ui/src/services/menu/menu.ts
@@ -1,8 +1,6 @@
import { IAccessor } from '@wendellhu/redi';
import { Observable } from 'rxjs';
-import { DisplayTypes } from '../../Components/Select/Select';
-
export type OneOrMany<T> = T | T[];
export const enum MenuPosition {
@@ -34,7 +32,7 @@ interface IMenuItemBase<V> {
/** ID of the menu item. Normally it should be the same as the ID of the command that it would invoke. */
id: string;
subId?: string;
- title: string;
+ title?: string;
description?: string;
icon?: string;
tooltip?: string;
@@ -47,8 +45,6 @@ interface IMenuItemBase<V> {
/** @deprecated this type seems unnecessary */
type: MenuItemType;
- /** Determines how the label of the selector should display. */
- display?: DisplayTypes;
/**
* Custom label component id.
* */
diff --git a/packages/base-ui/src/views/app.module.less b/packages/base-ui/src/views/app.module.less
index becbbe7593..9c9bf3248e 100644
--- a/packages/base-ui/src/views/app.module.less
+++ b/packages/base-ui/src/views/app.module.less
@@ -82,8 +82,4 @@
width: 100%;
}
}
-
- ::selection {
- background-color: rgb(var(--primary-color));
- }
}
diff --git a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
index bae7db3a75..8b7bd98ab8 100644
--- a/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
+++ b/packages/base-ui/src/views/components/ContextMenu/ContextMenu.tsx
@@ -1,10 +1,10 @@
import { IMouseEvent } from '@univerjs/base-render';
import { DisposableCollection, ICommandService } from '@univerjs/core';
+import { Dropdown } from '@univerjs/design';
import { useDependency } from '@wendellhu/redi/react-bindings';
import React, { useEffect, useState } from 'react';
-import { Dropdown2 } from '../../../Components/Dropdown/Dropdown2';
-import { Menu2 } from '../../../Components/Menu/Menu2';
+import { Menu } from '../../../Components/Menu/Menu';
import { IContextMenuService } from '../../../services/contextmenu/contextmenu.service';
export interface IProps {
@@ -54,12 +54,12 @@ export function ContextMenu(props: IProps) {
}
return (
- <Dropdown2
+ <Dropdown
visible={visible}
trigger={['contextMenu']}
alignPoint
overlay={
- <Menu2
+ <Menu
menuType={[menuType]}
onOptionSelect={(params) => {
const { label: commandId, value } = params;
@@ -71,6 +71,6 @@ export function ContextMenu(props: IProps) {
onVisibleChange={handleVisibleChange}
>
{children}
- </Dropdown2>
+ </Dropdown>
);
}
diff --git a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
index 7cc5a634a9..25a6ff4016 100644
--- a/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
+++ b/packages/base-ui/src/views/components/DocBars/ToolbarItem.tsx
@@ -61,7 +61,7 @@ export function ToolbarItem(props: IDisplayMenuItem<IMenuItem>) {
};
}, []);
- const { tooltip, shortcut, icon, title, label, display, id, min, max, onClose } = props;
+ const { tooltip, shortcut, icon, title, label, id, onClose } = props;
const tooltipTitle = localeService?.t(tooltip) + (shortcut ? ` (${shortcut})` : '');
@@ -75,12 +75,9 @@ export function ToolbarItem(props: IDisplayMenuItem<IMenuItem>) {
title={title}
children={selections! as IValueOption[]}
options={selections as IValueOption[]}
- display={display}
icon={icon}
value={value}
- label={value ?? label} // TODO: this line is strange
- max={max}
- min={min}
+ label={label}
onClick={(value) => {
// commandService.executeCommand(id, { value })
// 子元素commandId会被现在的id覆盖,暂时这么写以区分
diff --git a/packages/design/package.json b/packages/design/package.json
index f387447df7..1a0c2b5b32 100644
--- a/packages/design/package.json
+++ b/packages/design/package.json
@@ -53,6 +53,7 @@
"clsx": "^2.0.0",
"rc-dialog": "^9.3.4",
"rc-dropdown": "^4.1.0",
+ "rc-input": "^1.3.5",
"rc-input-number": "^8.5.0",
"rc-tooltip": "^6.1.2",
"react": "^18.2.0",
diff --git a/packages/design/src/components/dialog/index.module.less b/packages/design/src/components/dialog/index.module.less
index 44eeed12c8..cd31718483 100644
--- a/packages/design/src/components/dialog/index.module.less
+++ b/packages/design/src/components/dialog/index.module.less
@@ -125,7 +125,7 @@
bottom: 0;
left: 0;
height: 100%;
- // background-color: rgba(55, 55, 55, 0.6);
+ background-color: rgba(0, 0, 0, 0.5);
z-index: 1050;
&-hidden {
diff --git a/packages/base-ui/src/Components/Dropdown/Dropdown.stories.tsx b/packages/design/src/components/dropdown/Dropdown.stories.tsx
similarity index 57%
rename from packages/base-ui/src/Components/Dropdown/Dropdown.stories.tsx
rename to packages/design/src/components/dropdown/Dropdown.stories.tsx
index aea759254d..de0a902522 100644
--- a/packages/base-ui/src/Components/Dropdown/Dropdown.stories.tsx
+++ b/packages/design/src/components/dropdown/Dropdown.stories.tsx
@@ -1,11 +1,11 @@
import type { Meta } from '@storybook/react';
-import { Button } from '@univerjs/design';
-import { Dropdown2 } from './Dropdown2';
+import { Button } from '../button/Button';
+import { Dropdown } from './Dropdown';
-const meta: Meta<typeof Dropdown2> = {
+const meta: Meta<typeof Dropdown> = {
title: 'Components / Dropdown',
- component: Dropdown2,
+ component: Dropdown,
parameters: {
layout: 'centered',
},
@@ -17,9 +17,9 @@ export default meta;
export const Playground = {
render() {
return (
- <Dropdown2 overlay={<div>overlay</div>}>
+ <Dropdown overlay={<div>overlay</div>}>
<Button>Basic</Button>
- </Dropdown2>
+ </Dropdown>
);
},
};
diff --git a/packages/base-ui/src/Components/Dropdown/Dropdown2.tsx b/packages/design/src/components/dropdown/Dropdown.tsx
similarity index 54%
rename from packages/base-ui/src/Components/Dropdown/Dropdown2.tsx
rename to packages/design/src/components/dropdown/Dropdown.tsx
index fc3c4cb610..03160df91d 100644
--- a/packages/base-ui/src/Components/Dropdown/Dropdown2.tsx
+++ b/packages/design/src/components/dropdown/Dropdown.tsx
@@ -4,26 +4,59 @@ import Placements from 'rc-dropdown/lib/placements';
import styles from './index.module.less';
-// TODO@jikkai Need to limit width
-export interface IDropdown2Props {
+// TODO: @jikkai Need to limit width
+export interface IDropdownProps {
+ /**
+ * The dropdown content
+ */
+ children: React.ReactElement;
+
+ /**
+ * Whether the dropdown is visible
+ */
visible?: boolean;
+
+ /**
+ * The trigger mode which executes the dropdown action
+ * @default ['click']
+ */
trigger?: ActionType | ActionType[];
+
+ /**
+ * The placement of the dropdown
+ */
placement?: keyof typeof Placements;
- children: React.ReactElement;
+
+ /**
+ * The dropdown overlay
+ */
overlay: React.ReactElement;
+
+ /**
+ * Whether the dropdown aligns to the point
+ * @default false
+ */
alignPoint?: boolean;
+
+ /**
+ * The align of the dropdown
+ */
align?: AlignType;
+
+ /**
+ * Triggered after the dropdown visibility changes
+ * @param visible
+ */
onVisibleChange?: (visible: boolean) => void;
}
-export function Dropdown2(props: IDropdown2Props) {
- const { trigger = ['click'], placement, children, overlay, alignPoint, align, onVisibleChange } = props;
+export function Dropdown(props: IDropdownProps) {
+ const { trigger = ['click'], placement, children, overlay, alignPoint = false, align, onVisibleChange } = props;
return (
<RcDropdown
{...props}
- prefixCls="univer-dropdown2"
- overlayClassName={styles.dropdown2}
+ prefixCls={styles.dropdown}
trigger={trigger}
animation="slide-up"
placement={placement}
diff --git a/packages/design/src/components/dropdown/index.module.less b/packages/design/src/components/dropdown/index.module.less
new file mode 100644
index 0000000000..0efae07d71
--- /dev/null
+++ b/packages/design/src/components/dropdown/index.module.less
@@ -0,0 +1,116 @@
+.dropdown {
+ position: absolute;
+ left: -9999px;
+ top: -9999px;
+ z-index: 1070;
+ display: block;
+
+ &-hidden {
+ display: none;
+ }
+
+ .effect() {
+ animation-duration: 0.15s;
+ animation-fill-mode: both;
+ transform-origin: 0 0;
+ display: block !important;
+ }
+
+ &-slide-up-enter,&-slide-up-appear {
+ .effect();
+ opacity: 0;
+ animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1);
+ animation-play-state: paused;
+ }
+
+ &-slide-up-leave {
+ .effect();
+ opacity: 1;
+ animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34);
+ animation-play-state: paused;
+ }
+
+ &-slide-up-enter&-slide-up-enter-active&-placement-bottomLeft,
+ &-slide-up-appear&-slide-up-appear-active&-placement-bottomLeft,
+ &-slide-up-enter&-slide-up-enter-active&-placement-bottomCenter,
+ &-slide-up-appear&-slide-up-appear-active&-placement-bottomCenter,
+ &-slide-up-enter&-slide-up-enter-active&-placement-bottomRight,
+ &-slide-up-appear&-slide-up-appear-active&-placement-bottomRight {
+ animation-name: rcDropdownSlideUpIn;
+ animation-play-state: running;
+ }
+
+ &-slide-up-enter&-slide-up-enter-active&-placement-topLeft,
+ &-slide-up-appear&-slide-up-appear-active&-placement-topLeft,
+ &-slide-up-enter&-slide-up-enter-active&-placement-topCenter,
+ &-slide-up-appear&-slide-up-appear-active&-placement-topCenter,
+ &-slide-up-enter&-slide-up-enter-active&-placement-topRight,
+ &-slide-up-appear&-slide-up-appear-active&-placement-topRight {
+ animation-name: rcDropdownSlideDownIn;
+ animation-play-state: running;
+ }
+
+ &-slide-up-leave&-slide-up-leave-active&-placement-bottomLeft,
+ &-slide-up-leave&-slide-up-leave-active&-placement-bottomCenter,
+ &-slide-up-leave&-slide-up-leave-active&-placement-bottomRight {
+ animation-name: rcDropdownSlideUpOut;
+ animation-play-state: running;
+ }
+
+ &-slide-up-leave&-slide-up-leave-active&-placement-topLeft,
+ &-slide-up-leave&-slide-up-leave-active&-placement-topCenter,
+ &-slide-up-leave&-slide-up-leave-active&-placement-topRight {
+ animation-name: rcDropdownSlideDownOut;
+ animation-play-state: running;
+ }
+
+ @keyframes rcDropdownSlideUpIn {
+ 0% {
+ opacity: 0;
+ transform-origin: 0% 0%;
+ transform: scaleY(0);
+ }
+ 100% {
+ opacity: 1;
+ transform-origin: 0% 0%;
+ transform: scaleY(1);
+ }
+ }
+ @keyframes rcDropdownSlideUpOut {
+ 0% {
+ opacity: 1;
+ transform-origin: 0% 0%;
+ transform: scaleY(1);
+ }
+ 100% {
+ opacity: 0;
+ transform-origin: 0% 0%;
+ transform: scaleY(0);
+ }
+ }
+
+ @keyframes rcDropdownSlideDownIn {
+ 0% {
+ opacity: 0;
+ transform-origin: 0% 100%;
+ transform: scaleY(0);
+ }
+ 100% {
+ opacity: 1;
+ transform-origin: 0% 100%;
+ transform: scaleY(1);
+ }
+ }
+ @keyframes rcDropdownSlideDownOut {
+ 0% {
+ opacity: 1;
+ transform-origin: 0% 100%;
+ transform: scaleY(1);
+ }
+ 100% {
+ opacity: 0;
+ transform-origin: 0% 100%;
+ transform: scaleY(0);
+ }
+ }
+}
diff --git a/packages/design/src/components/dropdown/index.ts b/packages/design/src/components/dropdown/index.ts
new file mode 100644
index 0000000000..cc7572d90a
--- /dev/null
+++ b/packages/design/src/components/dropdown/index.ts
@@ -0,0 +1 @@
+export { Dropdown, type IDropdownProps } from './Dropdown';
diff --git a/packages/design/src/components/input-number/InputNumber.tsx b/packages/design/src/components/input-number/InputNumber.tsx
index b3db56344a..638ec2e5e8 100644
--- a/packages/design/src/components/input-number/InputNumber.tsx
+++ b/packages/design/src/components/input-number/InputNumber.tsx
@@ -58,6 +58,12 @@ export interface IInputNumberProps {
* @param value
*/
onChange?: (value: number | null) => void;
+
+ /**
+ * Callback when user press enter
+ * @param e
+ */
+ onPressEnter?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
}
export function InputNumber(props: IInputNumberProps) {
@@ -72,6 +78,7 @@ export function InputNumber(props: IInputNumberProps) {
onClick,
onKeyDown,
onChange,
+ onPressEnter,
} = props;
function handleChange(value: number | null) {
@@ -93,6 +100,7 @@ export function InputNumber(props: IInputNumberProps) {
onClick={onClick}
onKeyDown={onKeyDown}
onChange={handleChange}
+ onPressEnter={onPressEnter}
/>
);
}
diff --git a/packages/design/src/components/input/Input.stories.tsx b/packages/design/src/components/input/Input.stories.tsx
new file mode 100644
index 0000000000..16c1606b68
--- /dev/null
+++ b/packages/design/src/components/input/Input.stories.tsx
@@ -0,0 +1,44 @@
+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'],
+};
+
+export default meta;
+
+export const InputBasic = {
+ render() {
+ return (
+ <>
+ <Input />
+ <Input allowClear />
+ </>
+ );
+ },
+};
+
+export const InputSize = {
+ render() {
+ return (
+ <>
+ <Input size="mini" />
+ <Input size="small" />
+ <Input />
+ <Input size="large" />
+ </>
+ );
+ },
+};
+
+export const InputDisabled = {
+ render() {
+ return <Input disabled />;
+ },
+};
diff --git a/packages/design/src/components/input/Input.tsx b/packages/design/src/components/input/Input.tsx
new file mode 100644
index 0000000000..9817ef06e7
--- /dev/null
+++ b/packages/design/src/components/input/Input.tsx
@@ -0,0 +1,113 @@
+import { CloseSingle } from '@univerjs/icons';
+import clsx from 'clsx';
+import RcInput from 'rc-input';
+
+import styles from './index.module.less';
+
+export interface IInputProps {
+ /**
+ * The input affix wrapper style
+ */
+ affixWrapperStyle?: React.CSSProperties;
+
+ /**
+ * The input type
+ * @default text
+ */
+ type?: 'text' | 'password';
+
+ /**
+ * The input placeholder
+ */
+ placeholder?: string;
+
+ /**
+ * The input content value
+ */
+ value?: string;
+
+ /**
+ * The input size
+ * @default middle
+ */
+ size?: 'mini' | 'small' | 'middle' | 'large';
+
+ /**
+ * Whether the input is clearable
+ * @default false
+ */
+ allowClear?: boolean;
+
+ /**
+ * Whether the input is disabled
+ * @default false
+ */
+ disabled?: boolean;
+
+ /**
+ * Callback when user click
+ * @param e
+ */
+ onClick?: (e: React.MouseEvent<HTMLInputElement>) => void;
+
+ /**
+ * Callback when user press a key
+ * @param e
+ */
+ onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
+
+ /**
+ * Callback when user input
+ * @param value
+ */
+ onChange?: (value: string) => void;
+}
+
+export function Input(props: IInputProps) {
+ const {
+ affixWrapperStyle,
+ type = 'text',
+ placeholder,
+ value,
+ size = 'middle',
+ allowClear,
+ disabled = false,
+ onClick,
+ onKeyDown,
+ onChange,
+ } = props;
+
+ function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
+ const { value } = e.target;
+ onChange?.(value);
+ }
+
+ const _className = clsx({
+ [styles.inputAffixWrapperMini]: size === 'mini',
+ [styles.inputAffixWrapperSmall]: size === 'small',
+ [styles.inputAffixWrapperMiddle]: size === 'middle',
+ [styles.inputAffixWrapperLarge]: size === 'large',
+ });
+
+ return (
+ <RcInput
+ prefixCls={styles.input}
+ classNames={{
+ affixWrapper: _className,
+ }}
+ styles={{
+ affixWrapper: affixWrapperStyle,
+ }}
+ type={type}
+ placeholder={placeholder}
+ value={value}
+ disabled={disabled}
+ onClick={onClick}
+ onKeyDown={onKeyDown}
+ onChange={handleChange}
+ allowClear={{
+ clearIcon: allowClear ? <CloseSingle /> : <></>,
+ }}
+ />
+ );
+}
diff --git a/packages/design/src/components/input/index.module.less b/packages/design/src/components/input/index.module.less
new file mode 100644
index 0000000000..694845f06f
--- /dev/null
+++ b/packages/design/src/components/input/index.module.less
@@ -0,0 +1,74 @@
+.input {
+ color: rgb(var(--text-color));
+ box-sizing: border-box;
+
+ &::selection {
+ color: rgb(var(--color-white));
+ background-color: rgb(var(--primary-color));
+ }
+
+ &-out-of-range {
+ color: rgb(var(--error-color));
+ }
+
+ &-affix-wrapper {
+ border: 1px solid rgb(var(--border-color));
+ border-radius: var(--border-radius-base);
+ box-sizing: border-box;
+ overflow: hidden;
+ transition: all 0.15s;
+
+ &-mini {
+ font-size: var(--font-size-xs);
+ padding: 2px var(--padding-lg);
+ }
+
+ &-small {
+ font-size: var(--font-size-xs);
+ padding: 6px var(--padding-lg);
+ }
+
+ &-middle {
+ font-size: var(--font-size-sm);
+ padding: 6px var(--padding-lg);
+ }
+
+ &-large {
+ font-size: var(--font-size-sm);
+ padding: 8px var(--padding-lg);
+ }
+
+ &:hover,
+ &:focus-within {
+ border-color: rgb(var(--primary-color));
+ }
+
+ &-disabled {
+ border-color: rgb(var(--border-color));
+ cursor: not-allowed;
+
+ &:hover {
+ border-color: rgb(var(--border-color));
+ }
+ }
+
+ input {
+ padding: 0;
+ border: none;
+ outline: none;
+ &[disabled] {
+ color: rgb(var(--grey-200));
+ background-color: rgb(var(--bg-color-secondary));
+ cursor: inherit;
+ }
+ }
+ }
+
+ &-clear-icon {
+ cursor: pointer;
+
+ &-hidden {
+ display: none;
+ }
+ }
+}
diff --git a/packages/design/src/components/input/index.ts b/packages/design/src/components/input/index.ts
new file mode 100644
index 0000000000..2dfe07dbd7
--- /dev/null
+++ b/packages/design/src/components/input/index.ts
@@ -0,0 +1 @@
+export { type IInputProps, Input } from './Input';
diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts
index 38850c99ec..875d71c12b 100644
--- a/packages/design/src/index.ts
+++ b/packages/design/src/index.ts
@@ -6,6 +6,8 @@ export { ColorPicker, type IColorPickerProps } from './components/color-picker';
export { ConfigContext, ConfigProvider, type IConfigProviderProps } from './components/config-provider';
export { Container, type IContainerProps } from './components/container';
export { Dialog, type IDialogProps } from './components/dialog';
+export { Dropdown, type IDropdownProps } from './components/dropdown';
+export { type IInputProps, Input } from './components/input';
export { type IInputNumberProps, InputNumber } from './components/input-number';
export { Content, Footer, Header, type ILayoutProps, Layout, Sider } from './components/layout';
export { type IMessageProps, Message, message, type MessageType } from './components/message';
diff --git a/packages/sheets-plugin-debugger/src/controllers/index.ts b/packages/sheets-plugin-debugger/src/controllers/index.ts
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/sheets-plugin-debugger/src/controllers/menu.ts b/packages/sheets-plugin-debugger/src/controllers/menu.ts
index 12a5fb2915..9d47d26e69 100644
--- a/packages/sheets-plugin-debugger/src/controllers/menu.ts
+++ b/packages/sheets-plugin-debugger/src/controllers/menu.ts
@@ -1,4 +1,4 @@
-import { DisplayTypes, IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
+import { IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
import { LocaleType } from '@univerjs/core';
import { defaultTheme, greenTheme } from '@univerjs/design';
import { IAccessor } from '@wendellhu/redi';
@@ -10,10 +10,8 @@ import { UIComponentOperation } from '../commands/operations/ui-component.operat
export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
return {
id: LocaleOperation.id,
- icon: 'KeyboardSingle',
title: 'debugger.locale.title',
tooltip: 'debugger.locale.tooltip',
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
@@ -32,10 +30,8 @@ export function LocaleMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
export function ThemeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
return {
id: ThemeOperation.id,
- icon: 'KeyboardSingle',
title: 'debugger.theme.title',
tooltip: 'debugger.theme.tooltip',
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
@@ -53,10 +49,8 @@ export function ThemeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
export function UIComponentMenuItemFactory(accessor: IAccessor): IMenuSelectorItem {
return {
id: UIComponentOperation.id,
- icon: 'KeyboardSingle',
title: 'debugger.uiComponent.title',
tooltip: 'debugger.uiComponent.tooltip',
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_OTHERS],
selections: [
diff --git a/packages/sheets-plugin-debugger/src/locale/en-US.ts b/packages/sheets-plugin-debugger/src/locale/en-US.ts
index a04f51faca..d789bde2b4 100644
--- a/packages/sheets-plugin-debugger/src/locale/en-US.ts
+++ b/packages/sheets-plugin-debugger/src/locale/en-US.ts
@@ -1,16 +1,16 @@
export default {
debugger: {
locale: {
- title: 'Language (Debugger Tools)',
- tooltip: 'Language (Debugger Tools)',
+ title: 'Language',
+ tooltip: 'Language',
},
theme: {
- title: 'Theme (Debugger Tools)',
- tooltip: 'Theme (Debugger Tools)',
+ title: 'Theme',
+ tooltip: 'Theme',
},
uiComponent: {
- title: 'UI Component (Debugger Tools)',
- tooltip: 'UI Component Tooltip (Debugger Tools)',
+ title: 'UI Component',
+ tooltip: 'UI Component',
},
},
};
diff --git a/packages/sheets-plugin-debugger/src/locale/zh-CN.ts b/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
index f883fc04f2..31ae1e25fd 100644
--- a/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
+++ b/packages/sheets-plugin-debugger/src/locale/zh-CN.ts
@@ -1,16 +1,16 @@
export default {
debugger: {
locale: {
- title: '语言 (调试工具)',
- tooltip: '语言 (调试工具)',
+ title: '语言',
+ tooltip: '语言',
},
theme: {
- title: '主题 (调试工具)',
- tooltip: '主题 (调试工具)',
+ title: '主题',
+ tooltip: '主题',
},
uiComponent: {
- title: '组件 (调试工具)',
- tooltip: '组件提示 (调试工具)',
+ title: '组件',
+ tooltip: '组件',
},
},
};
diff --git a/packages/sheets-plugin-formula/src/Controller/CellInputHandler.ts b/packages/sheets-plugin-formula/src/Controller/CellInputHandler.ts
index 875f6c93a6..7fcebf8d1b 100644
--- a/packages/sheets-plugin-formula/src/Controller/CellInputHandler.ts
+++ b/packages/sheets-plugin-formula/src/Controller/CellInputHandler.ts
@@ -1,4 +1,4 @@
-import { $$, getNodeIndex, xssDeal } from '@univerjs/base-ui';
+import { getNodeIndex, xssDeal } from '@univerjs/base-ui';
import { IKeyValue, Nullable, Tools } from '@univerjs/core';
import { FunList } from '../Basics';
@@ -145,11 +145,11 @@ export class CellInputHandler {
if (currSelection) {
// all browsers, except IE before version 9
if (currSelection?.anchorNode instanceof HTMLElement && currSelection.anchorNode?.matches('div')) {
- const editorlen = $$('span', $editer).length;
- _this.functionRangeIndex = [
- editorlen - 1,
- $$('span', $editer)[editorlen - 1].textContent.length,
- ];
+ // const editorlen = $$('span', $editer).length;
+ // _this.functionRangeIndex = [
+ // editorlen - 1,
+ // $$('span', $editer)[editorlen - 1].textContent.length,
+ // ];
} else {
_this.functionRangeIndex = [
getNodeIndex(currSelection.anchorNode?.parentNode),
@@ -426,9 +426,8 @@ export class CellInputHandler {
currSelection.selectAllChildren((obj as IKeyValue)[0]);
currSelection.collapseToEnd();
} else if (fri != null) {
- const span = $$('span', obj);
-
- _this.setCaretPosition(Array.isArray(span) ? span[fri[0]] : span, 0, fri[1]);
+ // const span = $$('span', obj);
+ // _this.setCaretPosition(Array.isArray(span) ? span[fri[0]] : span, 0, fri[1]);
}
}
diff --git a/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/HelpFunction.tsx b/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/HelpFunction.tsx
index 0dfe7f11bb..488ab11b93 100644
--- a/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/HelpFunction.tsx
+++ b/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/HelpFunction.tsx
@@ -1,5 +1,4 @@
-import { BaseComponentProps, CustomLabel } from '@univerjs/base-ui';
-import { IKeyValue } from '@univerjs/core';
+import { BaseComponentProps } from '@univerjs/base-ui';
import { Component, createRef } from 'react';
import { FormulaParamType, FormulaType } from '../../../Basics';
@@ -90,13 +89,11 @@ export class HelpFunction extends Component<IProps, IState> {
<Help title={functionInfo.n} value={functionInfo.p} type="name" active={activeIndex} />
</div>
<div className={styles.helpFunctionContent}>
- <div>
- <CustomLabel label="formula.formulaMore.helpExample" />
- </div>
+ <div>{/* <CustomLabel label="formula.formulaMore.helpExample" /> */}</div>
<Help title={functionInfo.n} value={functionInfo.p} type="example" active={activeIndex} />
<Params
- title={(<CustomLabel label="formula.formulaMore.helpAbstract" />) as unknown as string}
- value={(<CustomLabel label={functionInfo.d} />) as unknown as string}
+ // title={(<CustomLabel label="formula.formulaMore.helpAbstract" />) as unknown as string}
+ // value={(<CustomLabel label={functionInfo.d} />) as unknown as string}
/>
<>
{functionInfo &&
@@ -105,8 +102,8 @@ export class HelpFunction extends Component<IProps, IState> {
<Params
key={i}
className={activeIndex === i ? styles.helpFunctionActive : ''}
- title={(<CustomLabel label={item.name} />) as unknown as string}
- value={(<CustomLabel label={item.detail} />) as unknown as string}
+ // title={(<CustomLabel label={item.name} />) as unknown as string}
+ // value={(<CustomLabel label={item.detail} />) as unknown as string}
active={activeIndex}
/>
))}
@@ -153,7 +150,7 @@ class Help extends Component<IHelpProps, IHelpState> {
{this.props.value &&
this.props.value.map((item: FormulaParamType, i: number) => (
<span key={i} className={this.props.active === i ? styles.helpFunctionActive : ''}>
- <CustomLabel label={(item as IKeyValue)[`${this.props.type}`]} />,
+ {/* <CustomLabel label={(item as IKeyValue)[`${this.props.type}`]} />, */}
</span>
))}
<span>{')'}</span>
diff --git a/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/SearchFunction.tsx b/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/SearchFunction.tsx
index f8e4de287c..158cc19652 100644
--- a/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/SearchFunction.tsx
+++ b/packages/sheets-plugin-formula/src/View/UI/FormulaPrompt/SearchFunction.tsx
@@ -1,4 +1,4 @@
-import { BaseComponentProps, CustomLabel } from '@univerjs/base-ui';
+import { BaseComponentProps } from '@univerjs/base-ui';
import { IKeyValue } from '@univerjs/core';
import { Component, createRef } from 'react';
@@ -90,9 +90,7 @@ export class SearchFunction extends Component<IProps, IState> {
{formula.map((item: any, i: number) => (
<li key={i} className={selectIndex === i ? styles.searchFunctionActive : ''}>
<div className={styles.formulaName}>{item.n}</div>
- <div className={styles.formulaDetail}>
- <CustomLabel label={item.d} />
- </div>
+ <div className={styles.formulaDetail}>{/* <CustomLabel label={item.d} /> */}</div>
</li>
))}
</ul>
diff --git a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx
index 66efe8efec..cb3df090c5 100644
--- a/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx
+++ b/packages/sheets-plugin-formula/src/View/UI/SearchFormulaModal/SearchFormulaContent.tsx
@@ -1,4 +1,4 @@
-import { BaseComponentProps, CustomLabel, debounce, Input, Select } from '@univerjs/base-ui';
+import { BaseComponentProps, debounce, Input, Select } from '@univerjs/base-ui';
import { Component, createRef } from 'react';
import { FormulaType, FunListILabel, Label } from '../../../Basics';
@@ -100,9 +100,9 @@ export class SearchFormulaContent extends Component<IProps, IState> {
const { select } = this.props;
const arr: Array<{ label: string | JSX.Element }> = [];
for (let i = 0; i < select.length; i++) {
- arr.push({
- label: <CustomLabel label={select[i].label} />,
- });
+ // arr.push({
+ // label: <CustomLabel label={select[i].label} />,
+ // });
}
return arr;
}
@@ -114,7 +114,7 @@ export class SearchFormulaContent extends Component<IProps, IState> {
if (functionList[i][k] instanceof Array) {
functionList[i][k] = this.getFunctionList(functionList[i][k]);
} else if (typeof functionList[i][k] === 'string') {
- functionList[i][k] = <CustomLabel label={functionList[i][k]} />;
+ // functionList[i][k] = <CustomLabel label={functionList[i][k]} />;
}
}
}
@@ -128,18 +128,18 @@ export class SearchFormulaContent extends Component<IProps, IState> {
<div className={styles.functionModal}>
<div className={styles.functionSearch}>
<div className={styles.functionLabel}>
- <CustomLabel label="formula.formulaMore.findFunctionTitle" />;
+ {/* <CustomLabel label="formula.formulaMore.findFunctionTitle" />; */}
</div>
<Input
- placeholder={
- (<CustomLabel label="formula.formulaMore.tipInputFunctionName" />) as unknown as string
- }
+ // placeholder={
+ // (<CustomLabel label="formula.formulaMore.tipInputFunctionName" />) as unknown as string
+ // }
onChange={debounce(this.changeInput.bind(this), 50)}
/>
</div>
<div className={styles.functionSelect}>
<div className={styles.functionLabel}>
- <CustomLabel label="formula.formulaMore.selectCategory" />
+ {/* <CustomLabel label="formula.formulaMore.selectCategory" /> */}
</div>
<div className={styles.functionSelector}>
<Select
@@ -151,7 +151,7 @@ export class SearchFormulaContent extends Component<IProps, IState> {
</div>
<div className={styles.functionList} ref={this.functionListRef}>
<div className={styles.functionLabel}>
- <CustomLabel label="formula.formulaMore.selectFunctionTitle" />
+ {/* <CustomLabel label="formula.formulaMore.selectFunctionTitle" /> */}
</div>
<ul className={styles.functionLists}>
{functionList?.map((item, index) => (
diff --git a/packages/sheets-plugin-numfmt/src/Controller/menu.ts b/packages/sheets-plugin-numfmt/src/Controller/menu.ts
index c6239b7d01..c54f510c7a 100644
--- a/packages/sheets-plugin-numfmt/src/Controller/menu.ts
+++ b/packages/sheets-plugin-numfmt/src/Controller/menu.ts
@@ -1,4 +1,4 @@
-import { DisplayTypes, IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
+import { IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
import { ICommandService, IPermissionService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
@@ -16,8 +16,6 @@ export function NumfmtRangeDataMenuItemFactory(accessor: IAccessor): IMenuSelect
title: 'toolbar.moreFormats',
tooltip: 'toolbar.moreFormats',
type: MenuItemType.SELECTOR,
- display: DisplayTypes.CUSTOM,
- // display: DisplayTypes.FONT,
positions: [MenuPosition.TOOLBAR_START],
selections: DEFAULT_DATA,
// disabled$: new Observable((subscriber) => {
@@ -67,7 +65,6 @@ export function OpenMoreFormatsModalMenuItemFactory(accessor: IAccessor): IMenuS
id: ShowModalOperation.id,
title: 'defaultFmt.CustomFormats.text',
positions: SetNumfmtRangeDataCommand.id,
- display: DisplayTypes.LABEL,
type: MenuItemType.SELECTOR,
selections: [...MORE_FORMATS_SELECTIONS],
};
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/index.ts b/packages/ui-plugin-sheets/src/View/BorderLine/index.ts
deleted file mode 100644
index db6e9e95cd..0000000000
--- a/packages/ui-plugin-sheets/src/View/BorderLine/index.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-export { BorderDashDot } from './BorderDashDot';
-export { BorderDashDotDot } from './BorderDashDotDot';
-export { BorderDashed } from './BorderDashed';
-export { BorderDotted } from './BorderDotted';
-export { BorderHair } from './BorderHair';
-export { BorderMedium } from './BorderMedium';
-export { BorderMediumDashDot } from './BorderMediumDashDot';
-export { BorderMediumDashDotDot } from './BorderMediumDashDotDot';
-export { BorderMediumDashed } from './BorderMediumDashed';
-export { BorderThick } from './BorderThick';
diff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx
deleted file mode 100644
index 9f43066c10..0000000000
--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/ColorSelect.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { BaseComponentProps, CustomLabel, ICustomComponent } from '@univerjs/base-ui';
-import { Component } from 'react';
-
-import styles from './index.module.less';
-
-interface IProps extends BaseComponentProps {
- label?: JSX.Element | ICustomComponent;
- id: string;
- color: string;
-}
-
-interface IState {
- color: string;
-}
-
-// TODO: @wzhudev: why this component is put under ui-plugin-sheet not base-ui?
-/** @deprecated use ColorSelect in base-ui plugin instead */
-export class ColorSelect extends Component<IProps, IState> {
- override componentDidMount(): void {
- this.props.getComponent?.(this);
- }
-
- override UNSAFE_componentWillReceiveProps(props: IProps) {
- this.setState({
- color: props.color,
- });
- }
-
- setColor(color: string) {
- this.setState({
- color,
- });
- }
-
- override render() {
- const { label } = this.props;
- return (
- <div className={styles.colorSelect}>
- <div>
- <CustomLabel label={label} />
- </div>
- <div className={styles.colorSelectLine} style={{ background: this.state.color }}></div>
- </div>
- );
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/index.module.less b/packages/ui-plugin-sheets/src/View/Common/ColorSelect/index.module.less
deleted file mode 100644
index 41556b46dd..0000000000
--- a/packages/ui-plugin-sheets/src/View/Common/ColorSelect/index.module.less
+++ /dev/null
@@ -1,12 +0,0 @@
-.color-select {
- position: relative;
-
- .color-select-line {
- position: absolute;
- width: 15px;
- height: 5px;
- bottom: 0px;
- left: 50%;
- transform: translate(-50%, 0);
- }
-}
\ No newline at end of file
diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx
deleted file mode 100644
index 0184be4b5e..0000000000
--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineBold.tsx
+++ /dev/null
@@ -1,91 +0,0 @@
-import { AppContext, BaseComponentProps, CustomLabel } from '@univerjs/base-ui';
-import { BorderStyleTypes } from '@univerjs/core';
-import { Component } from 'react';
-
-import { BORDER_SIZE_CHILDREN, LINE_BOLD_LABEL } from '../../../controller/menu/border.menu';
-
-interface IState {
- img: BorderStyleTypes;
-}
-
-interface IProps extends BaseComponentProps {
- label: string;
- title: string;
- value: BorderStyleTypes;
-}
-
-export class LineBold extends Component<IProps, IState> {
- static readonly componentName = LINE_BOLD_LABEL;
-
- static override contextType = AppContext;
-
- declare context: React.ContextType<typeof AppContext>;
-
- constructor(props: IProps) {
- super(props);
- this.initialize();
- }
-
- initialize() {
- this.state = {
- img: BorderStyleTypes.NONE,
- };
- }
-
- override componentDidMount(): void {
- this.props.getComponent?.(this);
- }
-
- override UNSAFE_componentWillReceiveProps(props: IProps) {
- this.setState({
- img: props.value,
- });
- }
-
- setImg(img: BorderStyleTypes = BorderStyleTypes.NONE) {
- this.setState({
- img,
- });
- }
-
- getImg(img: BorderStyleTypes) {
- if (!img) return null;
- const span = document.querySelector('.base-sheets-line-bold') as HTMLDivElement;
- const props = { width: span.offsetWidth };
- const Img = this.context.componentManager.get(img as unknown as string) as any;
- if (Img) {
- return <Img {...(props as any)} />;
- }
- }
-
- override render() {
- const { img } = this.state;
- const { title, value } = this.props;
- const imgComponent = img && this.getImg(img);
-
- // TODO: display a style according to the value
- const label = BORDER_SIZE_CHILDREN.find((item) => item.value === value)?.label;
-
- return (
- <div
- style={{
- paddingBottom: '3px',
- width: '100%',
- display: 'flex',
- justifyContent: 'space-between',
- alignItems: 'center',
- }}
- >
- <span className={'base-sheets-line-bold'} style={{ position: 'relative' }}>
- <CustomLabel label={title} />
- <br></br>
- <CustomLabel label={label} />
- <div style={{ width: '100%', height: 0, position: 'absolute', left: 0, bottom: '14px' }}>
- {imgComponent}
- </div>
- </span>
- {/* <Icon.RightIcon /> */}
- </div>
- );
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx b/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx
deleted file mode 100644
index 108717bdfa..0000000000
--- a/packages/ui-plugin-sheets/src/View/Common/Line/LineColor.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { BaseComponentProps, CustomLabel } from '@univerjs/base-ui';
-import { Component } from 'react';
-
-interface IState {
- color: string;
-}
-
-interface IProps extends BaseComponentProps {
- color: string;
- label?: string;
-}
-
-export class LineColor extends Component<IProps, IState> {
- constructor(props: IProps) {
- super(props);
- this.initialize();
- }
-
- initialize() {
- this.state = {
- color: this.props.color,
- };
- }
-
- override componentDidMount() {
- this.props.getComponent?.(this);
- }
-
- override UNSAFE_componentWillReceiveProps(props: IProps): void {
- this.setState({
- color: props.color,
- });
- }
-
- setColor(color: string) {
- this.setState({
- color,
- });
- }
-
- override render() {
- const { color } = this.state;
- const { label } = this.props;
-
- return (
- <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
- <span style={{ display: 'inline-block', borderBottom: `3px solid ${color}` }}>
- <CustomLabel label={label} />
- </span>
- {/* <Icon.RightIcon /> */}
- </div>
- );
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/Common/index.tsx b/packages/ui-plugin-sheets/src/View/Common/index.tsx
deleted file mode 100644
index f657a01caf..0000000000
--- a/packages/ui-plugin-sheets/src/View/Common/index.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export * from './ColorSelect/ColorSelect';
-export * from './Line/LineBold';
-export * from './Line/LineColor';
diff --git a/packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuItem.tsx b/packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuItem.tsx
deleted file mode 100644
index 3c991be400..0000000000
--- a/packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuItem.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { CustomLabel } from '@univerjs/base-ui';
-import { Component } from 'react';
-
-import styles from './index.module.less';
-
-interface IProps {
- label: string;
-}
-
-export class ContextMenuItem extends Component<IProps> {
- override render() {
- const { label } = this.props;
-
- return (
- <div className={styles.rightMenuItem}>
- <CustomLabel label={label} />
- {/* <Icon.Format.RightIcon /> */}
- </div>
- );
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/ContextMenu/index.module.less b/packages/ui-plugin-sheets/src/View/ContextMenu/index.module.less
deleted file mode 100644
index 7542fc8655..0000000000
--- a/packages/ui-plugin-sheets/src/View/ContextMenu/index.module.less
+++ /dev/null
@@ -1,55 +0,0 @@
-.ui-plugin-sheets-context-menu-input {
- display: flex;
- align-items: center;
- gap: var(--margin-sm);
-}
-
-// TODO: may be conflict with other styles, should be more specific
-.context-menu {
- position: fixed;
-
- left: 0;
- top: 26px;
- z-index: 2;
-
- .cols-menu {
- .cols-menuitem {
- text-align: left;
- padding: 8px 24px 8px 4px;
-
- input {
- width: 40px;
- height: 20px;
- text-align: center;
- margin: 0 3px;
- padding: 0;
- }
-
- button {
- margin-left: 5px;
- padding: 2px 3px;
- line-height: 12px;
- font-size: 12px;
- }
-
- .btn {
- height: auto;
- }
-
- .right-menu-center {
- min-width: auto;
- }
- }
- }
-
- .right-menu-item {
- position: relative;
-
- span {
- position: absolute;
- right: -15px;
- top: 50%;
- transform: translateY(-50%);
- }
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts b/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts
deleted file mode 100644
index 7060e6360c..0000000000
--- a/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts
+++ /dev/null
@@ -1,645 +0,0 @@
-/* eslint-disable max-lines-per-function */
-import { $$, selectTextContent, selectTextContentCross, textTrim } from '@univerjs/base-ui';
-import { Color } from '@univerjs/core';
-
-import styles from './index.module.less';
-
-interface IStyleSetting {
- bl?: string; // font-weight
- it?: string; // font-style
- ff?: string; // font-family
- fs?: number; // font-size
- fc?: string; // color
- bg?: string; // background
- cl?: string; // text-decoration(Strikethrough)
- un?: string; // border-bottom(Underline)
- // attr is un
- _fontSize?: number;
- _color?: string;
-}
-
-/**
- * update rich text style
- */
-export class CellTextStyle {
- inlineStyleAffectAttribute: {
- [key: string]: number;
- };
-
- inlineStyleAffectCssName: {
- [key: string]: number;
- };
-
- univerToCssName: {
- [key: string]: string;
- };
-
- editor: HTMLDivElement;
-
- constructor(ele: HTMLDivElement) {
- this.inlineStyleAffectAttribute = { bl: 1, it: 1, ff: 1, cl: 1, un: 1, fs: 1, fc: 1, bg: 1 };
- this.inlineStyleAffectCssName = {
- 'font-weight': 1,
- 'font-style': 1,
- 'font-family': 1,
- 'text-decoration': 1,
- 'border-bottom': 1,
- 'font-size': 1,
- color: 1,
- background: 1,
- };
-
- this.univerToCssName = {
- bl: 'font-weight',
- it: 'font-style',
- ff: 'font-family',
- fs: 'font-size',
- fc: 'color',
- bg: 'background',
- cl: 'text-decoration',
- un: 'border-bottom',
- };
- this.editor = ele;
- }
-
- // TODO:指定单元格更新
- updateFormat(attr: keyof IStyleSetting, foucsStatus: number | string) {
- if (attr in this.inlineStyleAffectAttribute) {
- // TODO: 不要使用 $$
- const value = this.editor.textContent!;
- if (value.substr(0, 1) !== '=') {
- this.updateInlineStringFormat(attr, foucsStatus);
- }
- }
- }
-
- updateInlineStringFormat(attr: keyof IStyleSetting, value: number | string) {
- const w = window.getSelection();
- let range;
- if (w?.type === 'None') {
- // range = Store.inlineStringEditRange;
- } else {
- range = w?.getRangeAt(0);
- }
-
- if (!range) return;
-
- // TODO: 不要使用 $$
- const $textEditor = this.editor;
-
- const endContainer = range.endContainer;
- const startContainer = range.startContainer;
- const endOffset = range.endOffset;
- const startOffset = range.startOffset;
-
- if ($textEditor) {
- if (startContainer === endContainer) {
- const span = startContainer.parentNode as HTMLElement;
- let spanIndex;
- let inherit = false;
-
- const content = span.innerHTML;
-
- const fullContent = $textEditor.innerHTML;
- if (fullContent.substr(0, 5) !== '<span') {
- inherit = true;
- }
-
- let left = '';
- let mid = '';
- let right = '';
- const s1 = 0;
- const s2 = startOffset;
- const s3 = endOffset;
- const s4 = content.length;
- left = content.substring(s1, s2);
- mid = content.substring(s2, s3);
- right = content.substring(s3, s4);
-
- let cont = '';
- if (left !== '') {
- let cssText = span.style.cssText;
- if (inherit) {
- const box = span.closest(`.${styles.richTextEditorContainer}`) as HTMLElement;
- if (box != null) {
- cssText = this.extendCssText(box.style.cssText, cssText);
- }
- }
- cont += `<span style='${cssText}'>${left}</span>`;
- }
-
- if (mid !== '') {
- let cssText = this.getCssText(span.style.cssText, attr, value);
-
- if (inherit) {
- const box = span.closest(`.${styles.richTextEditorContainer}`) as HTMLElement;
- if (box != null) {
- cssText = this.extendCssText(box.style.cssText, cssText);
- }
- }
-
- cont += `<span style='${cssText}'>${mid}</span>`;
- }
-
- if (right !== '') {
- let cssText = span.style.cssText;
- if (inherit) {
- const box = span.closest(`.${styles.richTextEditorContainer}`) as HTMLElement;
- if (box != null) {
- cssText = this.extendCssText(box.style.cssText, cssText);
- }
- }
- cont += `<span style='${cssText}'>${right}</span>`;
- }
-
- if ((startContainer.parentNode as HTMLElement).tagName === 'SPAN') {
- spanIndex = $$('span', $textEditor).indexOf(span);
- // spanIndex = $textEditor.find('span').index(span);
- const spanP = span.parentElement?.innerHTML;
- const spanText = span.outerHTML.replace('\\', '');
- const newS = spanP?.replace(spanText, cont);
- span.parentElement!.innerHTML = newS!;
- // span.replaceWith(cont);
- } else {
- spanIndex = 0;
- span.innerHTML = cont;
- }
-
- let seletedNodeIndex = 0;
- if (s1 === s2) {
- seletedNodeIndex = spanIndex;
- } else {
- seletedNodeIndex = spanIndex + 1;
- }
-
- selectTextContent($textEditor.querySelectorAll('span')[seletedNodeIndex]);
- } else if (
- (startContainer.parentNode as HTMLElement).tagName === 'SPAN' &&
- (endContainer.parentNode as HTMLElement).tagName === 'SPAN'
- ) {
- const startSpan = startContainer.parentNode as HTMLElement;
- const endSpan = endContainer.parentNode as HTMLElement;
-
- const startSpanIndex = $$('span', $textEditor).indexOf(startSpan);
- const endSpanIndex = $$('span', $textEditor).indexOf(endSpan);
- // startSpanIndex = $textEditor.find('span').index(startSpan);
- // endSpanIndex = $textEditor.find('span').index(endSpan);
-
- const startContent = (startSpan as HTMLElement).innerHTML;
- const endContent = (endSpan as HTMLElement).innerHTML;
- let sleft = '';
- let sright = '';
- let eleft = '';
- let eright = '';
- const s1 = 0;
- const s2 = startOffset;
- const s3 = endOffset;
- const s4 = endContent.length;
-
- sleft = startContent.substring(s1, s2);
- sright = startContent.substring(s2, startContent.length);
-
- eleft = endContent.substring(0, s3);
- eright = endContent.substring(s3, s4);
- let spans = Array.prototype.slice.call($textEditor.querySelectorAll('span'));
- const replaceSpans = spans.slice(startSpanIndex, endSpanIndex + 1);
- let cont = '';
- for (let i = 0; i < startSpanIndex; i++) {
- // let span = spans.get(i),
- const span: HTMLElement = spans[`${i}`];
- const content = span.innerHTML;
- cont += `<span style='${span.style.cssText}'>${content}</span>`;
- }
- if (sleft !== '') {
- cont += `<span style='${startSpan.style.cssText}'>${sleft}</span>`;
- }
-
- if (sright !== '') {
- const cssText = this.getCssText(startSpan.style.cssText, attr, value);
- cont += `<span style='${cssText}'>${sright}</span>`;
- }
-
- if (startSpanIndex < endSpanIndex) {
- for (let i: number = startSpanIndex + 1; i < endSpanIndex; i++) {
- // let span = spans.get(i),
- const span = spans[`${i}`];
- const content = span.innerHTML;
- const cssText = this.getCssText(span.style.cssText, attr, value);
- cont += `<span style='${cssText}'>${content}</span>`;
- }
- }
-
- if (eleft !== '') {
- const cssText = this.getCssText(endSpan.style.cssText, attr, value);
- cont += `<span style='${cssText}'>${eleft}</span>`;
- }
-
- if (eright !== '') {
- cont += `<span style='${endSpan.style.cssText}'>${eright}</span>`;
- }
-
- for (let i: number = endSpanIndex + 1; i < spans.length; i++) {
- // let span = spans.get(i),
- const span = spans[`${i}`];
- const content = span.innerHTML;
- cont += `<span style='${span.style.cssText}'>${content}</span>`;
- }
-
- $textEditor.innerHTML = cont;
-
- // console.log(replaceSpans, cont);
- // replaceSpans.replaceWith(cont);
-
- let startSeletedNodeIndex: number;
- let endSeletedNodeIndex: number;
- if (s1 === s2) {
- startSeletedNodeIndex = startSpanIndex;
- endSeletedNodeIndex = endSpanIndex;
- } else {
- startSeletedNodeIndex = startSpanIndex + 1;
- endSeletedNodeIndex = endSpanIndex + 1;
- }
-
- // spans = $textEditor.find('span');
- spans = $textEditor.querySelectorAll('span') as unknown as [];
-
- // selectTextContentCross(spans.get(startSeletedNodeIndex), spans.get(endSeletedNodeIndex));
-
- selectTextContentCross(spans[`${startSeletedNodeIndex}`], spans[`${endSeletedNodeIndex}`]);
- }
- }
- }
-
- extendCssText(origin: string, cover: string, isLimit = true) {
- const originArray = origin.split(';');
- const coverArray = cover.split(';');
- let newCss = '';
-
- const addKeyList: Record<string, string | number> = {};
- for (let i = 0; i < originArray.length; i++) {
- let so = originArray[i];
- let isAdd = true;
- so = so.toLowerCase();
- const okey = textTrim(so.substr(0, so.indexOf(':')));
-
- /* 不设置文字的大小,解决设置删除线等后字体变大的问题 */
- if (okey === 'font-size') {
- continue;
- }
-
- const ovalue = textTrim(so.substr(so.indexOf(':') + 1));
-
- if (isLimit) {
- if (!(okey in this.inlineStyleAffectCssName)) {
- continue;
- }
- }
-
- for (let a = 0; a < coverArray.length; a++) {
- let sc = coverArray[a];
- sc = sc.toLowerCase();
- const ckey = textTrim(sc.substr(0, sc.indexOf(':')));
- const cvalue = textTrim(sc.substr(sc.indexOf(':') + 1));
-
- if (okey === ckey) {
- newCss += `${ckey}:${cvalue};`;
- isAdd = false;
- continue;
- }
- }
-
- if (isAdd) {
- newCss += `${okey}:${ovalue};`;
- }
-
- addKeyList[okey] = 1;
- }
-
- for (let a = 0; a < coverArray.length; a++) {
- let sc = coverArray[a];
- sc = sc.toLowerCase();
- const ckey = textTrim(sc.substr(0, sc.indexOf(':')));
- const cvalue = textTrim(sc.substr(sc.indexOf(':') + 1));
-
- if (isLimit) {
- if (!(ckey in this.inlineStyleAffectCssName)) {
- continue;
- }
- }
-
- if (!(ckey in addKeyList)) {
- newCss += `${ckey}:${cvalue};`;
- }
- }
-
- return newCss;
- }
-
- getCssText(cssText: string, attr: keyof IStyleSetting, value: string | number) {
- const styleObj: IStyleSetting = {};
- (styleObj[attr] as string | number) = value;
- if (attr === 'un') {
- let fontColor = this.getClassWithcss(cssText, 'color');
- if (fontColor === '') {
- fontColor = '#000000';
- }
- const fs = this.getClassWithcss(cssText, 'font-size');
- let fsNum = parseInt(fs);
- if (fs === '') {
- fsNum = 11;
- }
-
- styleObj._fontSize = fsNum;
- styleObj._color = fontColor;
- }
- const s: string | undefined = this.getFontStyleByCell(styleObj, undefined, undefined, false);
- const ukey = textTrim(s && s.substr(0, s.indexOf(':')));
- let uvalue = textTrim(s && s.substr(s.indexOf(':') + 1));
- uvalue = uvalue.substr(0, uvalue.length - 1);
- // let cssText = span.style.cssText;
- cssText = this.removeClassWidthCss(cssText, attr);
-
- cssText = this.upsetClassWithCss(cssText, ukey, uvalue);
-
- return cssText;
- }
-
- getClassWithcss(cssText: string, ukey: string): string {
- const cssTextArray = cssText.split(';');
- if (ukey == null || ukey.length === 0) {
- return cssText;
- }
- if (cssText.indexOf(ukey) > -1) {
- for (let i = 0; i < cssTextArray.length; i++) {
- let s = cssTextArray[i];
- s = s.toLowerCase();
- const key = textTrim(s.substr(0, s.indexOf(':')));
- const value = textTrim(s.substr(s.indexOf(':') + 1));
- if (key === ukey) {
- return value;
- }
- }
- }
-
- return '';
- }
-
- removeClassWidthCss(cssText: string, ukey: string) {
- const cssTextArray = cssText.split(';');
- let newCss = '';
- const oUkey = ukey;
- if (ukey == null || ukey.length === 0) {
- return cssText;
- }
- if (ukey in this.univerToCssName) {
- ukey = this.univerToCssName[ukey];
- }
- if (cssText.indexOf(ukey) > -1) {
- for (let i = 0; i < cssTextArray.length; i++) {
- let s = cssTextArray[i];
- s = s.toLowerCase();
- const key = textTrim(s.substr(0, s.indexOf(':')));
- const value = textTrim(s.substr(s.indexOf(':') + 1));
- if (
- key === ukey ||
- (oUkey === 'cl' && key === 'lucky-strike') ||
- (oUkey === 'un' && key === 'lucky-underline')
- ) {
- continue;
- } else if (key.length > 0) {
- newCss += `${key}:${value};`;
- }
- }
- } else {
- newCss = cssText;
- }
-
- return newCss;
- }
-
- upsetClassWithCss(cssText: string, ukey: string, uvalue: string) {
- const cssTextArray = cssText.split(';');
- let newCss = '';
- if (ukey == null || ukey.length === 0) {
- return cssText;
- }
- if (cssText.indexOf(ukey) > -1) {
- for (let i = 0; i < cssTextArray.length; i++) {
- let s = cssTextArray[i];
- s = s.toLowerCase();
- const key = textTrim(s.substr(0, s.indexOf(':')));
- const value = textTrim(s.substr(s.indexOf(':') + 1));
- if (key === ukey) {
- newCss += `${key}:${uvalue};`;
- } else if (key.length > 0) {
- newCss += `${key}:${value};`;
- }
- }
- } else if (ukey.length > 0) {
- cssText += `${ukey}:${uvalue};`;
- newCss = cssText;
- }
-
- return newCss;
- }
-
- getFontStyleByCell(cell: IStyleSetting, checksAF: any, checksCF: any, isCheck = true): string {
- if (cell == null) {
- return '';
- }
- let style = '';
- for (const key in cell) {
- let value = cell[key as keyof IStyleSetting];
- if (isCheck) {
- value = this.checkstatusByCell(cell, key);
- }
- if (key === 'bl' && value !== '0') {
- style += 'font-weight: bold;';
- }
-
- if (key === 'it' && value !== '0') {
- style += 'font-style:italic;';
- }
-
- if (key === 'ff') {
- const f = value;
- style += `font-family: ${f};`;
- }
-
- if (key === 'fs' && value !== '10') {
- style += `font-size: ${value}pt;`;
- }
-
- if (
- (key === 'fc' && value !== '#000000') ||
- checksAF != null ||
- (checksCF != null && checksCF.textColor != null)
- ) {
- if (checksCF != null && checksCF.textColor != null) {
- style += `color: ${checksCF.textColor};`;
- } else if (checksAF != null) {
- style += `color: ${checksAF[0]};`;
- } else {
- style += `color: ${value};`;
- }
- }
-
- if (key === 'bg' && value !== '#ffffff' && value !== '#fff') {
- style += `background: ${value};`;
- }
-
- if (key === 'cl' && value !== '0') {
- style += 'text-decoration: line-through;';
- }
-
- if (key === 'un' && (value === '1' || value === '3')) {
- let color = cell._color;
- if (color == null) {
- color = cell.fc;
- }
- let fs = cell._fontSize || 11;
- if (fs == null) {
- fs = cell.fs || 11;
- }
- style += `border-bottom: ${Math.floor(fs / 9)}px solid ${color};`;
- }
- }
- return style;
- }
-
- checkstatusByCell(cell: IStyleSetting, a: string) {
- // 获取当前单元格配置 默认值
- let foucsStatus: any;
- const tf = { bl: 1, it: 1, ff: 1, cl: 1, un: 1 };
-
- if (a in tf) {
- if (foucsStatus == null) {
- foucsStatus = '0';
- } else {
- foucsStatus = foucsStatus[a];
-
- if (foucsStatus == null) {
- foucsStatus = '0';
- }
- }
- } else if (a === 'fc') {
- if (foucsStatus == null) {
- foucsStatus = '#000000';
- } else {
- foucsStatus = foucsStatus[a];
-
- if (foucsStatus == null) {
- foucsStatus = '#000000';
- }
-
- if (foucsStatus.indexOf('rgba') > -1) {
- foucsStatus = Color.rgbColorToHexValue(foucsStatus);
- }
- }
- } else if (a === 'bg') {
- if (foucsStatus == null) {
- foucsStatus = null;
- } else {
- foucsStatus = foucsStatus[a];
-
- if (foucsStatus == null) {
- foucsStatus = null;
- } else if ((foucsStatus as string).toString().indexOf('rgba') > -1) {
- foucsStatus = Color.rgbColorToHexValue(foucsStatus);
- }
- }
- } else if (a.substr(0, 2) === 'bs') {
- if (foucsStatus == null) {
- foucsStatus = 'none';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = 'none';
- }
- }
- } else if (a.substr(0, 2) === 'bc') {
- if (foucsStatus == null) {
- foucsStatus = '#000000';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '#000000';
- }
- }
- } else if (a === 'ht') {
- if (foucsStatus == null) {
- foucsStatus = '1';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '1';
- }
- }
-
- if (['0', '1', '2'].indexOf(foucsStatus.toString()) === -1) {
- foucsStatus = '1';
- }
- } else if (a === 'vt') {
- // 默认垂直居中
- if (foucsStatus == null) {
- foucsStatus = '0';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '0';
- }
- }
-
- if (['0', '1', '2'].indexOf(foucsStatus.toString()) === -1) {
- foucsStatus = '0';
- }
- } else if (a === 'ct') {
- if (foucsStatus == null) {
- foucsStatus = null;
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = null;
- }
- }
- } else if (a === 'fs') {
- if (foucsStatus == null) {
- foucsStatus = '10';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '10';
- }
- }
- } else if (a === 'tb') {
- if (foucsStatus == null) {
- foucsStatus = '0';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '0';
- }
- }
- } else if (a === 'tr') {
- if (foucsStatus == null) {
- foucsStatus = '0';
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = '0';
- }
- }
- } else if (a === 'rt') {
- if (foucsStatus == null) {
- foucsStatus = null;
- } else {
- foucsStatus = foucsStatus[a];
- if (foucsStatus == null) {
- foucsStatus = null;
- }
- }
- }
-
- return foucsStatus;
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/RichText/RichText.tsx b/packages/ui-plugin-sheets/src/View/RichText/RichText.tsx
deleted file mode 100644
index b9376bdca6..0000000000
--- a/packages/ui-plugin-sheets/src/View/RichText/RichText.tsx
+++ /dev/null
@@ -1,180 +0,0 @@
-// import { CellInputHandler } from '@univerjs/sheets-plugin-formula/src/Controller/CellInputHandler';
-import { BaseComponentProps, xssDeal } from '@univerjs/base-ui';
-import { Component, createRef, KeyboardEvent, MouseEventHandler } from 'react';
-
-import { CellTextStyle } from './CellTextStyle';
-import styles from './index.module.less';
-// interface IProps {
-// style?: {};
-// className?: string;
-// onClick?: (e: MouseEvent) => void;
-// text?: string;
-// }
-
-export interface IRichTextState {}
-
-export interface BaseRichTextProps extends BaseComponentProps {
- style?: {};
- className?: string;
- onClick?: MouseEventHandler<HTMLDivElement>;
- text?: string;
-}
-
-/**
- *
- * 现在已支持 =A2+B3 公式高亮
- * 设置字体大小
- * TODO:
- * 1. rich text editor 丰富,其他样式
- * 2. 单元格编辑框编辑,实时复制到公式栏
- * 3. 公式栏编辑,实时复制到单元格编辑框
- * 4. 单元格编辑后敲击ENTER,获取刚刚输入的最新内容更新单元格数据(用到2.x updateFormatCell)
- * 5. 单元格编辑框输入公式,实时高亮单元格(下一步:支持高亮范围拖拽)
- * 6. 单元格编辑框输入公式,实时提示公式推荐框
- * 7. 单元格编辑框 其他快捷键支持 ESC、TAB、F4、UP、DOWN、LEFT、RIGHT等
- *
- * Rich Text Cell Editor Component
- */
-export class RichText extends Component<BaseRichTextProps, IRichTextState> {
- container = createRef<HTMLDivElement>();
-
- ref = createRef<HTMLDivElement>();
-
- cellTextStyle?: CellTextStyle;
-
- hooks = new Map<string, (args: any) => void>();
-
- constructor(props: BaseRichTextProps) {
- super(props);
- this.initialize(props);
- }
-
- initialize(props: BaseRichTextProps) {}
-
- setValue(value: string) {
- if (this.ref.current) {
- this.ref.current.innerHTML = xssDeal(value);
- }
- }
-
- getValue(): string {
- return this.ref.current?.innerHTML || '';
- }
-
- show() {
- this.container.current!.style.display = 'block';
- }
-
- hide() {
- this.container.current!.style.display = 'none';
- }
-
- onKeyDown(event: KeyboardEvent<HTMLDivElement>) {
- // let ctrlKey = event.ctrlKey;
- // let altKey = event.altKey;
- // let shiftKey = event.shiftKey;
- // let kcode = event.keyCode;
-
- // execute hooks
- const onKeyDown = this.hooks.get('onKeyDown');
- onKeyDown && onKeyDown(event);
-
- // stop edit
- if (event.key === 'Enter') {
- event.preventDefault();
- }
-
- // let $inputbox = $('#universheet-input-box');
- // if (kcode === keycode.ESC && parseInt($('#universheet-input-box').css('top')) > 0) {
- // formula.dontupdate();
- // universheetMoveHighlightCell('down', 0, 'rangeOfSelect');
- // event.preventDefault();
- // } else if (kcode === keycode.ENTER && parseInt($inputbox.css('top')) > 0) {
- // if ($('#universheet-formula-search-c').is(':visible') && formula.searchFunctionCell !== null) {
- // formula.searchFunctionEnter($('#universheet-formula-search-c').find('.universheet-formula-search-item-active'));
- // event.preventDefault();
- // }
- // }
- // else if(kcode === keycode.TAB && parseInt($inputbox.css("top")) > 0){
- // if ($("#universheet-formula-search-c").is(":visible") && formula.searchFunctionCell !== null) {
- // formula.searchFunctionEnter($("#universheet-formula-search-c").find(".universheet-formula-search-item-active"));
- // }
- // else{
- // formula.updatecell(Store.universheetCellUpdate[0], Store.universheetCellUpdate[1]);
- // universheetMoveHighlightCell("right", 1, "rangeOfSelect");
- // }
-
- // event.preventDefault();
- // }
- // else if (kcode === keycode.F4 && parseInt($inputbox.css("top")) > 0) {
- // formula.setfreezonFuc(event);
- // event.preventDefault();
- // }
- // else if (kcode === keycode.UP && parseInt($inputbox.css("top")) > 0) {
- // formulaMoveEvent("up", ctrlKey, shiftKey,event);
- // }
- // else if (kcode === keycode.DOWN && parseInt($inputbox.css("top")) > 0) {
- // formulaMoveEvent("down", ctrlKey, shiftKey,event);
- // }
- // else if (kcode === keycode.LEFT && parseInt($inputbox.css("top")) > 0) {
- // formulaMoveEvent("left", ctrlKey, shiftKey,event);
- // }
- // else if (kcode === keycode.RIGHT && parseInt($inputbox.css("top")) > 0) {
- // formulaMoveEvent("right", ctrlKey, shiftKey,event);
- // }
-
- // if (kcode === KeyCode.UP) {
- // let index = this.state.funIndex;
- // if (index !== 0) index--;
- // this.setState({
- // funIndex: index,
- // });
- // } else if (kcode === KeyCode.DOWN) {
- // let index = this.state.funIndex;
- // if (index !== 10) index++;
- // this.setState({
- // funIndex: index,
- // });
- // }
- }
-
- onKeyUp(event: KeyboardEvent<HTMLDivElement>) {
- const onKeyUp = this.hooks.get('onKeyUp');
- onKeyUp && onKeyUp(event);
-
- // stop edit
- if (event.key === 'Enter') {
- event.preventDefault();
- }
- // if (kcode === KeyCode.DOWN) {
- // this.cellTextStyle.convertSpanToShareString(this.ref.current);
- // }
- }
-
- /**
- * init
- */
- override UNSAFE_componentWillMount() {}
-
- override componentDidMount() {
- this.props.getComponent?.(this);
- this.cellTextStyle = new CellTextStyle(this.ref.current!);
- }
-
- override render() {
- const { style, className = '', onClick, text } = this.props;
- return (
- <div className={`${styles.richTextEditorContainer} ${className}`} style={style} ref={this.container}>
- <div
- ref={this.ref}
- className={styles.richTextEditor}
- onClick={onClick}
- onKeyDown={(event) => this.onKeyDown(event)}
- onKeyUp={(event) => this.onKeyUp(event)}
- dangerouslySetInnerHTML={{ __html: text || '' }}
- contentEditable
- ></div>
- </div>
- );
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/RichText/index.module.less b/packages/ui-plugin-sheets/src/View/RichText/index.module.less
deleted file mode 100644
index 842a66130f..0000000000
--- a/packages/ui-plugin-sheets/src/View/RichText/index.module.less
+++ /dev/null
@@ -1,37 +0,0 @@
-.rich-text-editor-container {
- position: absolute;
- z-index: 1;
- border: 2px #5292f7 solid;
-
- background-color: rgb(255, 255, 255);
- padding: 0px 2px;
- right: auto;
- overflow-y: auto;
- box-sizing: border-box;
- display: flex;
- font-family: 'Times New Roman';
- font-size: 11pt;
- color: rgb(51, 51, 51);
-
- text-align: left;
- resize: none;
- white-space: pre-wrap;
- outline: 0;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
- word-wrap: break-word;
-
- .rich-text-editor {
- width: 100%;
- // height: 100%; // Don't set the height, otherwise the rich text editor background color will not fill the height
- margin: 0;
- outline: 0;
- cursor: text;
- white-space: pre-wrap;
- .formula-text-color {
- color: black;
- }
- .formula-text-string {
- color: forestgreen;
- }
- }
-}
diff --git a/packages/ui-plugin-sheets/src/View/RichText/index.ts b/packages/ui-plugin-sheets/src/View/RichText/index.ts
deleted file mode 100644
index 735dd7d121..0000000000
--- a/packages/ui-plugin-sheets/src/View/RichText/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './RichText';
diff --git a/packages/ui-plugin-sheets/src/View/RichText/rich-text-zh.md b/packages/ui-plugin-sheets/src/View/RichText/rich-text-zh.md
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/ui-plugin-sheets/src/View/RichText/rich-text.md b/packages/ui-plugin-sheets/src/View/RichText/rich-text.md
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarMenu/SheetBarMenu.tsx
index a889940095..319b59219b 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,7 @@ import {
SetWorksheetOrderMutation,
SetWorksheetShowCommand,
} from '@univerjs/base-sheets';
-import { Dropdown2, joinClassNames } from '@univerjs/base-ui';
+import { joinClassNames } from '@univerjs/base-ui';
import {
BooleanNumber,
DisposableCollection,
@@ -16,7 +16,7 @@ import {
ICommandService,
IUniverInstanceService,
} from '@univerjs/core';
-import { Button } from '@univerjs/design';
+import { Button, Dropdown } from '@univerjs/design';
import { CheckMarkSingle, ConvertSingle } from '@univerjs/icons';
import { useDependency } from '@wendellhu/redi/react-bindings';
import React, { useEffect, useState } from 'react';
@@ -121,7 +121,7 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {
};
return (
- <Dropdown2
+ <Dropdown
placement="topLeft"
trigger={['click']}
overlay={
@@ -154,6 +154,6 @@ export function SheetBarMenu(props: ISheetBarMenuProps) {
<Button type="text" size="small">
<ConvertSingle />
</Button>
- </Dropdown2>
+ </Dropdown>
);
}
diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarTabs/SheetBarItem.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarTabs/SheetBarItem.tsx
index 7f9a3443ab..f8a91e1d37 100644
--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarTabs/SheetBarItem.tsx
+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBarTabs/SheetBarItem.tsx
@@ -1,6 +1,7 @@
import { TinyColor } from '@ctrl/tinycolor';
-import { Dropdown2, Menu2 } from '@univerjs/base-ui';
+import { Menu } from '@univerjs/base-ui';
import { BooleanNumber, ICommandService, ThemeService } from '@univerjs/core';
+import { Dropdown } from '@univerjs/design';
import { useDependency } from '@wendellhu/redi/react-bindings';
import React, { useEffect, useState } from 'react';
@@ -44,11 +45,11 @@ export function SheetBarItem(props: IBaseSheetBarProps) {
};
return (
- <Dropdown2
+ <Dropdown
visible={visible}
trigger={['contextMenu']}
overlay={
- <Menu2
+ <Menu
menuType={SheetMenuPosition.SHEET_BAR}
onOptionSelect={(params) => {
const { label: commandId, value } = params;
@@ -78,6 +79,6 @@ export function SheetBarItem(props: IBaseSheetBarProps) {
<div className={styles.slideTabActiveBar} style={color ? { background: color } : {}}></div>
</div>
</div>
- </Dropdown2>
+ </Dropdown>
);
}
diff --git a/packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsx b/packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsx
new file mode 100644
index 0000000000..facb3ac131
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/border-line/BorderLine.tsx
@@ -0,0 +1,42 @@
+import { BorderStyleTypes } from '@univerjs/core';
+
+import { BorderDashDot } from './icons/BorderDashDot';
+import { BorderDashDotDot } from './icons/BorderDashDotDot';
+import { BorderDashed } from './icons/BorderDashed';
+import { BorderHair } from './icons/BorderHair';
+import { BorderMedium } from './icons/BorderMedium';
+import { BorderMediumDashDot } from './icons/BorderMediumDashDot';
+import { BorderMediumDashDotDot } from './icons/BorderMediumDashDotDot';
+import { BorderMediumDashed } from './icons/BorderMediumDashed';
+import { BorderThick } from './icons/BorderThick';
+import { BorderThin } from './icons/BorderThin';
+import { IBorderLineProps } from './interface';
+
+export function BorderLine(props: IBorderLineProps) {
+ const { type = BorderStyleTypes.THIN } = props;
+
+ switch (type) {
+ case BorderStyleTypes.DASH_DOT:
+ return <BorderDashDot />;
+ case BorderStyleTypes.DASH_DOT_DOT:
+ return <BorderDashDotDot />;
+ case BorderStyleTypes.DASHED:
+ return <BorderDashed />;
+ case BorderStyleTypes.HAIR:
+ return <BorderHair />;
+ case BorderStyleTypes.MEDIUM:
+ return <BorderMedium />;
+ case BorderStyleTypes.MEDIUM_DASH_DOT:
+ return <BorderMediumDashDot />;
+ case BorderStyleTypes.MEDIUM_DASH_DOT_DOT:
+ return <BorderMediumDashDotDot />;
+ case BorderStyleTypes.MEDIUM_DASHED:
+ return <BorderMediumDashed />;
+ case BorderStyleTypes.THICK:
+ return <BorderThick />;
+ case BorderStyleTypes.THIN:
+ return <BorderThin />;
+ default:
+ return <BorderThin />;
+ }
+}
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderDashDot.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDot.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderDashDot.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDot.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderDashDotDot.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDotDot.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderDashDotDot.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashDotDot.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderDashed.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashed.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderDashed.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderDashed.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderDotted.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderDotted.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderDotted.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderDotted.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderHair.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderHair.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderHair.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderHair.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderMedium.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMedium.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderMedium.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderMedium.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashDot.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDot.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashDot.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDot.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashDotDot.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDotDot.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashDotDot.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashDotDot.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashed.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashed.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderMediumDashed.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderMediumDashed.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderThick.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderThick.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderThick.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderThick.tsx
diff --git a/packages/ui-plugin-sheets/src/View/BorderLine/BorderThin.tsx b/packages/ui-plugin-sheets/src/components/border-line/icons/BorderThin.tsx
similarity index 100%
rename from packages/ui-plugin-sheets/src/View/BorderLine/BorderThin.tsx
rename to packages/ui-plugin-sheets/src/components/border-line/icons/BorderThin.tsx
diff --git a/packages/ui-plugin-sheets/src/components/border-line/index.ts b/packages/ui-plugin-sheets/src/components/border-line/index.ts
new file mode 100644
index 0000000000..7334ed0eb7
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/border-line/index.ts
@@ -0,0 +1,2 @@
+export { BorderLine } from './BorderLine';
+export { BORDER_LINE_COMPONENT } from './interface';
diff --git a/packages/ui-plugin-sheets/src/components/border-line/interface.ts b/packages/ui-plugin-sheets/src/components/border-line/interface.ts
new file mode 100644
index 0000000000..302088291c
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/border-line/interface.ts
@@ -0,0 +1,10 @@
+import { ICustomComponentProps } from '@univerjs/base-ui';
+import { BorderStyleTypes } from '@univerjs/core';
+
+import { COMPONENT_PREFIX } from '../const';
+
+export const BORDER_LINE_COMPONENT = `${COMPONENT_PREFIX}_BORDER_LINE_COMPONENT`;
+
+export interface IBorderLineProps extends ICustomComponentProps<string> {
+ type: BorderStyleTypes;
+}
diff --git a/packages/ui-plugin-sheets/src/components/color-picker/index.ts b/packages/ui-plugin-sheets/src/components/color-picker/index.ts
new file mode 100644
index 0000000000..186e0a8ea0
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/color-picker/index.ts
@@ -0,0 +1,2 @@
+export { COLOR_PICKER_COMPONENT } from './interface';
+export { ColorPicker } from '@univerjs/design';
diff --git a/packages/ui-plugin-sheets/src/components/color-picker/interface.ts b/packages/ui-plugin-sheets/src/components/color-picker/interface.ts
new file mode 100644
index 0000000000..eff75ea93c
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/color-picker/interface.ts
@@ -0,0 +1,3 @@
+import { COMPONENT_PREFIX } from '../const';
+
+export const COLOR_PICKER_COMPONENT = `${COMPONENT_PREFIX}_COLOR_PICKER_COMPONENT`;
diff --git a/packages/ui-plugin-sheets/src/components/const.ts b/packages/ui-plugin-sheets/src/components/const.ts
new file mode 100644
index 0000000000..b513519789
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/const.ts
@@ -0,0 +1 @@
+export const COMPONENT_PREFIX = 'UI_PLUGIN_SHEETS';
diff --git a/packages/ui-plugin-sheets/src/components/font-family/FontFamily.tsx b/packages/ui-plugin-sheets/src/components/font-family/FontFamily.tsx
new file mode 100644
index 0000000000..96e8061d06
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-family/FontFamily.tsx
@@ -0,0 +1,17 @@
+import { LocaleService } from '@univerjs/core';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+
+import styles from './index.module.less';
+import { IFontFamilyProps } from './interface';
+
+export const FontFamily = (props: IFontFamilyProps) => {
+ const { value } = props;
+
+ const localeService = useDependency(LocaleService);
+
+ return (
+ <div className={styles.uiPluginSheetsFontFamily} style={{ fontFamily: value as string }}>
+ {localeService.t(`fontFamily.${(`${value}` ?? '').replace(/\s/g, '')}`)}
+ </div>
+ );
+};
diff --git a/packages/ui-plugin-sheets/src/components/font-family/FontFamilyItem.tsx b/packages/ui-plugin-sheets/src/components/font-family/FontFamilyItem.tsx
new file mode 100644
index 0000000000..e331dff866
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-family/FontFamilyItem.tsx
@@ -0,0 +1,17 @@
+import { LocaleService } from '@univerjs/core';
+import { useDependency } from '@wendellhu/redi/react-bindings';
+
+import styles from './index.module.less';
+import { IFontFamilyItemProps } from './interface';
+
+export const FontFamilyItem = (props: IFontFamilyItemProps) => {
+ const { value } = props;
+
+ const localeService = useDependency(LocaleService);
+
+ return (
+ <span className={styles.uiPluginSheetsFontFamilyItem} style={{ fontFamily: value }}>
+ {localeService.t(`fontFamily.${(`${value}` ?? '').replace(/\s/g, '')}`)}
+ </span>
+ );
+};
diff --git a/packages/ui-plugin-sheets/src/components/font-family/index.module.less b/packages/ui-plugin-sheets/src/components/font-family/index.module.less
new file mode 100644
index 0000000000..0e19338bcd
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-family/index.module.less
@@ -0,0 +1,11 @@
+.ui-plugin-sheets-font-family {
+ width: 120px;
+ font-size: var(--font-size-sm);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ overflow: hidden;
+}
+
+.ui-plugin-sheets-font-family-item {
+ font-size: var(--font-size-sm);
+}
diff --git a/packages/ui-plugin-sheets/src/components/font-family/index.ts b/packages/ui-plugin-sheets/src/components/font-family/index.ts
new file mode 100644
index 0000000000..ba5a1c82f3
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-family/index.ts
@@ -0,0 +1,3 @@
+export { FontFamily } from './FontFamily';
+export { FontFamilyItem } from './FontFamilyItem';
+export { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from './interface';
diff --git a/packages/ui-plugin-sheets/src/components/font-family/interface.ts b/packages/ui-plugin-sheets/src/components/font-family/interface.ts
new file mode 100644
index 0000000000..b282ddb730
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-family/interface.ts
@@ -0,0 +1,15 @@
+import { ICustomComponentProps } from '@univerjs/base-ui';
+
+import { COMPONENT_PREFIX } from '../const';
+
+export const FONT_FAMILY_COMPONENT = `${COMPONENT_PREFIX}_FONT_FAMILY_COMPONENT`;
+
+export interface IFontFamilyProps extends ICustomComponentProps<string> {
+ value: string;
+}
+
+export const FONT_FAMILY_ITEM_COMPONENT = `${COMPONENT_PREFIX}_FONT_FAMILY_ITEM_COMPONENT`;
+
+export interface IFontFamilyItemProps extends ICustomComponentProps<string> {
+ value: string;
+}
diff --git a/packages/ui-plugin-sheets/src/components/font-size/FontSize.tsx b/packages/ui-plugin-sheets/src/components/font-size/FontSize.tsx
new file mode 100644
index 0000000000..fed2ae7f6e
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-size/FontSize.tsx
@@ -0,0 +1,39 @@
+import { InputNumber } from '@univerjs/design';
+import { useMemo, useState } from 'react';
+
+import styles from './index.module.less';
+import { IFontSizeProps } from './interface';
+
+export const FontSize = (props: IFontSizeProps) => {
+ const { value, min, max, onChange } = props;
+ const [realValue, setRealValue] = useState<number>(Number(value ?? 0));
+
+ const _value = useMemo(() => Number(value ?? realValue), [value]);
+
+ function handleChange(value: number | null) {
+ if (value === null) return;
+
+ setRealValue(value);
+ }
+
+ function handleStopPropagation(e: React.KeyboardEvent<HTMLInputElement>) {
+ e.stopPropagation();
+
+ if (e.code === 'Enter') {
+ onChange(realValue.toString());
+ }
+ }
+
+ return (
+ <div className={styles.uiPluginSheetsFontSize}>
+ <InputNumber
+ value={_value}
+ controls={false}
+ min={min}
+ max={max}
+ onKeyDown={handleStopPropagation}
+ onChange={handleChange}
+ />
+ </div>
+ );
+};
diff --git a/packages/ui-plugin-sheets/src/components/font-size/index.module.less b/packages/ui-plugin-sheets/src/components/font-size/index.module.less
new file mode 100644
index 0000000000..f29a8a6f19
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-size/index.module.less
@@ -0,0 +1,4 @@
+.ui-plugin-sheets-font-size {
+ width: 48px;
+ font-size: var(--font-size-sm);
+}
diff --git a/packages/ui-plugin-sheets/src/components/font-size/index.ts b/packages/ui-plugin-sheets/src/components/font-size/index.ts
new file mode 100644
index 0000000000..961388f23c
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-size/index.ts
@@ -0,0 +1,2 @@
+export { FontSize } from './FontSize';
+export { FONT_SIZE_COMPONENT } from './interface';
diff --git a/packages/ui-plugin-sheets/src/components/font-size/interface.ts b/packages/ui-plugin-sheets/src/components/font-size/interface.ts
new file mode 100644
index 0000000000..10812d9135
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/font-size/interface.ts
@@ -0,0 +1,15 @@
+import { ICustomComponentProps } from '@univerjs/base-ui';
+
+import { COMPONENT_PREFIX } from '../const';
+
+export const FONT_SIZE_COMPONENT = `${COMPONENT_PREFIX}_FONT_SIZE_COMPONENT`;
+
+export interface IFontSizeProps extends ICustomComponentProps<string> {
+ value: string;
+
+ min: number;
+
+ max: number;
+
+ onChange: (value: string) => void;
+}
diff --git a/packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuInput.tsx b/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx
similarity index 64%
rename from packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuInput.tsx
rename to packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx
index 8ee07792cf..51b81a81d6 100644
--- a/packages/ui-plugin-sheets/src/View/ContextMenu/ContextMenuInput.tsx
+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/MenuItemInput.tsx
@@ -1,20 +1,16 @@
-import { CustomLabel, ICustomComponentProps } from '@univerjs/base-ui';
+import { LocaleService } from '@univerjs/core';
import { InputNumber } from '@univerjs/design';
+import { useDependency } from '@wendellhu/redi/react-bindings';
import React, { useEffect, useState } from 'react';
import styles from './index.module.less';
+import { IMenuItemInputProps } from './interface';
-interface IProps extends ICustomComponentProps<string> {
- prefix: string;
- suffix: string;
+export const MenuItemInput = (props: IMenuItemInputProps) => {
+ const { prefix, suffix, value, onChange, onValueChange } = props;
- /**
- * After ENTER, execute Command, close the right-click menu
- */
- onValueChange?: (value: string) => void;
-}
+ const localeService = useDependency(LocaleService);
-export const ContextMenuInput: React.FC<IProps> = ({ prefix, suffix, value, onChange, onValueChange }) => {
const [inputValue, setInputValue] = useState<string>(); // Initialized to an empty string
const handleChange = (value: number | null) => {
@@ -34,11 +30,11 @@ export const ContextMenuInput: React.FC<IProps> = ({ prefix, suffix, value, onCh
return (
<div className={styles.uiPluginSheetsContextMenuInput}>
- <CustomLabel label={prefix} />
+ {localeService.t(prefix)}
<span onClick={(e) => e.stopPropagation()}>
<InputNumber value={Number(inputValue)} onKeyDown={handleKeyDown} onChange={handleChange} />
</span>
- <CustomLabel label={suffix} />
+ {localeService.t(suffix)}
</div>
);
};
diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less b/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less
new file mode 100644
index 0000000000..bcd70d42ed
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/index.module.less
@@ -0,0 +1,5 @@
+.ui-plugin-sheets-context-menu-input {
+ display: flex;
+ align-items: center;
+ gap: var(--margin-sm);
+}
diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/index.ts b/packages/ui-plugin-sheets/src/components/menu-item-input/index.ts
new file mode 100644
index 0000000000..338e0cade0
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/index.ts
@@ -0,0 +1,2 @@
+export { MENU_ITEM_INPUT_COMPONENT } from './interface';
+export { MenuItemInput } from './MenuItemInput';
diff --git a/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts b/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts
new file mode 100644
index 0000000000..d9886b8322
--- /dev/null
+++ b/packages/ui-plugin-sheets/src/components/menu-item-input/interface.ts
@@ -0,0 +1,15 @@
+import { ICustomComponentProps } from '@univerjs/base-ui';
+
+import { COMPONENT_PREFIX } from '../const';
+
+export const MENU_ITEM_INPUT_COMPONENT = `${COMPONENT_PREFIX}_MENU_ITEM_INPUT_COMPONENT`;
+
+export interface IMenuItemInputProps extends ICustomComponentProps<string> {
+ prefix: string;
+ suffix: string;
+
+ /**
+ * After ENTER, execute Command, close the right-click menu
+ */
+ onValueChange?: (value: string) => void;
+}
diff --git a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
index 855bd2ea7b..d57a3e53d1 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/border.menu.ts
@@ -4,13 +4,13 @@ import {
SetBorderPositionCommand,
SetBorderStyleCommand,
} from '@univerjs/base-sheets';
-import { DisplayTypes, IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
+import { IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
import { BorderStyleTypes, ICommandService, IPermissionService } from '@univerjs/core';
-import { ColorPicker } from '@univerjs/design';
import { IAccessor } from '@wendellhu/redi';
import { map } from 'rxjs/operators';
-import { SHEET_UI_PLUGIN_NAME } from '../../Basics/Const/PLUGIN_NAME';
+import { BORDER_LINE_COMPONENT } from '../../components/border-line';
+import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';
export const LINE_BOLD_LABEL = 'CONTEXT_MENU_INPUT';
@@ -79,47 +79,102 @@ export const BORDER_LINE_CHILDREN = [
export const BORDER_SIZE_CHILDREN = [
{
- label: 'BorderThin',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.THIN,
+ },
+ },
value: BorderStyleTypes.THIN,
},
{
- label: 'BorderHair',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.HAIR,
+ },
+ },
value: BorderStyleTypes.HAIR,
},
{
- label: 'BorderDotted',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.DOTTED,
+ },
+ },
value: BorderStyleTypes.DOTTED,
},
{
- label: 'BorderDashed',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.DASHED,
+ },
+ },
value: BorderStyleTypes.DASHED,
},
{
- label: 'BorderDashDot',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.DOTTED,
+ },
+ },
value: BorderStyleTypes.DOTTED,
},
{
- label: 'BorderDashDotDot',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.DASH_DOT_DOT,
+ },
+ },
value: BorderStyleTypes.DASH_DOT_DOT,
},
{
- label: 'BorderMedium',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.MEDIUM,
+ },
+ },
value: BorderStyleTypes.MEDIUM,
},
{
- label: 'BorderMediumDashed',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.MEDIUM_DASHED,
+ },
+ },
value: BorderStyleTypes.MEDIUM_DASHED,
},
{
- label: 'BorderMediumDashDot',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.MEDIUM_DASH_DOT,
+ },
+ },
value: BorderStyleTypes.MEDIUM_DASH_DOT,
},
{
- label: 'BorderMediumDashDotDot',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
+ },
+ },
value: BorderStyleTypes.MEDIUM_DASH_DOT_DOT,
},
{
- label: 'BorderThick',
+ label: {
+ name: BORDER_LINE_COMPONENT,
+ props: {
+ type: BorderStyleTypes.THICK,
+ },
+ },
value: BorderStyleTypes.THICK,
},
];
@@ -131,10 +186,8 @@ export function CellBorderSelectorMenuItemFactory(accessor: IAccessor): IMenuSel
const borderStyleManagerService = accessor.get(BorderStyleManagerService);
return {
id: SetBorderPositionCommand.id,
- title: 'border',
icon: 'AllBorderSingle',
tooltip: 'toolbar.border.main',
- display: DisplayTypes.ICON,
positions: [MenuPosition.TOOLBAR_START],
type: MenuItemType.SUBITEMS,
selections: [...BORDER_LINE_CHILDREN],
@@ -150,11 +203,10 @@ export function SetBorderColorMenuItemFactory(accessor: IAccessor): IMenuSelecto
id: SetBorderColorCommand.id,
title: 'borderLine.borderColor',
positions: SetBorderPositionCommand.id,
- display: DisplayTypes.COLOR,
type: MenuItemType.SELECTOR,
selections: [
{
- id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,
+ id: COLOR_PICKER_COMPONENT,
},
],
value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.color)),
@@ -166,9 +218,7 @@ export function SetBorderStyleMenuItemFactory(accessor: IAccessor): IMenuSelecto
return {
id: SetBorderStyleCommand.id,
title: 'borderLine.borderType',
- // label: SHEET_UI_PLUGIN_NAME + LINE_BOLD_LABEL,
positions: SetBorderPositionCommand.id,
- display: DisplayTypes.CUSTOM,
type: MenuItemType.SELECTOR,
selections: [...BORDER_SIZE_CHILDREN],
value$: borderStyleManagerService.borderInfo$.pipe(map((info) => info.style)),
diff --git a/packages/ui-plugin-sheets/src/controller/menu/menu.ts b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
index 5bf02d3df0..51981ba1ea 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/menu.ts
@@ -51,7 +51,6 @@ import {
import {
CopyCommand,
CutCommand,
- DisplayTypes,
IMenuButtonItem,
IMenuSelectorItem,
MenuItemType,
@@ -69,21 +68,21 @@ import {
VerticalAlign,
WrapStrategy,
} from '@univerjs/core';
-import { ColorPicker } from '@univerjs/design';
import { IAccessor } from '@wendellhu/redi';
import { Observable } from 'rxjs';
-import { SHEET_UI_PLUGIN_NAME } from '../../Basics/Const/PLUGIN_NAME';
import { RenameSheetOperation } from '../../commands/commands/rename.command';
import {
SetInfiniteFormatPainterCommand,
SetOnceFormatPainterCommand,
} from '../../commands/commands/set-format-painter.command';
import { ShowMenuListCommand } from '../../commands/commands/unhide.command';
+import { COLOR_PICKER_COMPONENT } from '../../components/color-picker';
+import { FONT_FAMILY_COMPONENT, FONT_FAMILY_ITEM_COMPONENT } from '../../components/font-family';
+import { FONT_SIZE_COMPONENT } from '../../components/font-size';
+import { MENU_ITEM_INPUT_COMPONENT } from '../../components/menu-item-input';
import { FormatPainterStatus, IFormatPainterService } from '../../services/format-painter/format-painter.service';
-export const CONTEXT_MENU_INPUT_LABEL = 'CONTEXT_MENU_INPUT';
-
export { SetBorderColorMenuItemFactory, SetBorderStyleMenuItemFactory } from './border.menu';
export enum SheetMenuPosition {
@@ -415,68 +414,55 @@ export const FONT_SIZE_CHILDREN = [
export const FONT_FAMILY_CHILDREN = [
{
- label: 'fontFamily.TimesNewRoman',
- style: { 'font-family': 'Times New Roman' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Times New Roman',
},
{
- label: 'fontFamily.Arial',
- style: { 'font-family': 'Arial' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Arial',
},
{
- label: 'fontFamily.Tahoma',
- style: { 'font-family': 'Tahoma' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Tahoma',
},
{
- label: 'fontFamily.Verdana',
- style: { 'font-family': 'Verdana' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Verdana',
},
{
- label: 'fontFamily.MicrosoftYaHei',
- style: { 'font-family': '微软雅黑' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Microsoft YaHei',
},
{
- label: 'fontFamily.SimSun',
- style: { 'font-family': '宋体' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'SimSun',
},
{
- label: 'fontFamily.SimHei',
- style: { 'font-family': '黑体' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'SimHei',
},
{
- label: 'fontFamily.Kaiti',
- style: { 'font-family': '楷体' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'Kaiti',
},
{
- label: 'fontFamily.FangSong',
- style: { 'font-family': '仿宋' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'FangSong',
},
{
- label: 'fontFamily.NSimSun',
- style: { 'font-family': '新宋体' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'NSimSun',
},
{
- label: 'fontFamily.STXinwei',
- style: { 'font-family': '华文新魏' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'STXinwei',
},
{
- label: 'fontFamily.STXingkai',
- style: { 'font-family': '华文行楷' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'STXingkai',
},
{
- label: 'fontFamily.STLiti',
- style: { 'font-family': '华文隶书' },
+ label: { name: FONT_FAMILY_ITEM_COMPONENT },
value: 'STLiti',
},
// The following 3 fonts do not work, temporarily delete
@@ -505,10 +491,11 @@ export function FontFamilySelectorMenuItemFactory(accessor: IAccessor): IMenuSel
return {
id: SetFontFamilyCommand.id,
- title: 'toolbar.font',
tooltip: 'toolbar.font',
type: MenuItemType.SELECTOR,
- display: DisplayTypes.FONT,
+
+ label: FONT_FAMILY_COMPONENT,
+
positions: [MenuPosition.TOOLBAR_START],
selections: FONT_FAMILY_CHILDREN,
disabled$: new Observable((subscriber) => {
@@ -566,12 +553,15 @@ export function FontSizeSelectorMenuItemFactory(accessor: IAccessor): IMenuSelec
return {
id: SetFontSizeCommand.id,
- title: 'fontSize',
tooltip: 'toolbar.fontSize',
type: MenuItemType.SELECTOR,
- display: DisplayTypes.INPUT,
- min: 1,
- max: 400,
+ label: {
+ name: FONT_SIZE_COMPONENT,
+ props: {
+ min: 1,
+ max: 400,
+ },
+ },
positions: [MenuPosition.TOOLBAR_START],
selections: FONT_SIZE_CHILDREN,
disabled$: new Observable<boolean>((subscriber) => {
@@ -635,15 +625,13 @@ export function TextColorSelectorMenuItemFactory(accessor: IAccessor): IMenuSele
return {
id: SetTextColorCommand.id,
- title: 'toolbar.textColor.main',
icon: 'FontColor',
tooltip: 'toolbar.textColor.main',
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_START],
- display: DisplayTypes.COLOR,
selections: [
{
- id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,
+ id: COLOR_PICKER_COMPONENT,
},
],
value$: new Observable<string>((subscriber) => {
@@ -676,14 +664,12 @@ export function BackgroundColorSelectorMenuItemFactory(accessor: IAccessor): IMe
return {
id: SetBackgroundColorCommand.id,
tooltip: 'toolbar.fillColor.main',
- title: 'FontColor',
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_START],
- display: DisplayTypes.COLOR,
icon: 'PaintBucket',
selections: [
{
- id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,
+ id: COLOR_PICKER_COMPONENT,
},
],
value$: new Observable<string>((subscriber) => {
@@ -724,11 +710,9 @@ export function HorizontalAlignMenuItemFactory(accessor: IAccessor): IMenuSelect
const selectionManagerService = accessor.get(SelectionManagerService);
return {
id: SetHorizontalTextAlignCommand.id,
- title: 'horizontalAlignMode',
icon: HORIZONTAL_ALIGN_CHILDREN[0].icon,
positions: [MenuPosition.TOOLBAR_START],
tooltip: 'toolbar.horizontalAlignMode.main',
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
selections: HORIZONTAL_ALIGN_CHILDREN,
value$: new Observable<HorizontalAlign>((subscriber) => {
@@ -779,10 +763,8 @@ export function VerticalAlignMenuItemFactory(accessor: IAccessor): IMenuSelector
const selectionManagerService = accessor.get(SelectionManagerService);
return {
id: SetVerticalTextAlignCommand.id,
- title: 'verticalAlignMode',
icon: VERTICAL_ALIGN_CHILDREN[0].icon,
tooltip: 'toolbar.verticalAlignMode.main',
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_START],
selections: VERTICAL_ALIGN_CHILDREN,
@@ -834,13 +816,11 @@ export function WrapTextMenuItemFactory(accessor: IAccessor): IMenuSelectorItem<
const selectionManagerService = accessor.get(SelectionManagerService);
return {
id: SetTextWrapCommand.id,
- title: 'textWrapMode',
tooltip: 'toolbar.textWrapMode.main',
icon: TEXT_WRAP_CHILDREN[0].icon,
type: MenuItemType.SELECTOR,
positions: [MenuPosition.TOOLBAR_START],
selections: TEXT_WRAP_CHILDREN,
- display: DisplayTypes.ICON,
value$: new Observable((subscriber) => {
const disposable = accessor.get(ICommandService).onCommandExecuted((c) => {
const id = c.id;
@@ -904,10 +884,8 @@ export function TextRotateMenuItemFactory(accessor: IAccessor): IMenuSelectorIte
const selectionManagerService = accessor.get(SelectionManagerService);
return {
id: SetTextRotationCommand.id,
- title: 'textRotateMode',
tooltip: 'toolbar.textRotateMode.main',
icon: TEXT_ROTATE_CHILDREN[0].icon,
- display: DisplayTypes.ICON,
type: MenuItemType.SELECTOR,
selections: TEXT_ROTATE_CHILDREN,
positions: [MenuPosition.TOOLBAR_START],
@@ -1240,10 +1218,8 @@ export function SetRowHeightMenuItemFactory(accessor: IAccessor): IMenuButtonIte
id: SetWorksheetRowHeightCommand.id,
type: MenuItemType.BUTTON,
positions: [SheetMenuPosition.ROW_HEADER_CONTEXT_MENU],
- title: 'rightClick.rowHeight',
- display: DisplayTypes.CUSTOM,
label: {
- name: CONTEXT_MENU_INPUT_LABEL,
+ name: MENU_ITEM_INPUT_COMPONENT,
props: {
prefix: 'rightClick.rowHeight',
suffix: 'px',
@@ -1286,11 +1262,9 @@ export function SetColWidthMenuItemFactory(accessor: IAccessor): IMenuButtonItem
return {
id: SetWorksheetColWidthCommand.id,
type: MenuItemType.BUTTON,
- display: DisplayTypes.CUSTOM,
positions: [SheetMenuPosition.COL_HEADER_CONTEXT_MENU],
- title: 'rightClick.columnWidth',
label: {
- name: CONTEXT_MENU_INPUT_LABEL,
+ name: MENU_ITEM_INPUT_COMPONENT,
props: {
prefix: 'rightClick.columnWidth',
suffix: 'px',
@@ -1414,11 +1388,10 @@ export function ChangeColorSheetMenuItemFactory(): IMenuSelectorItem<string> {
id: SetTabColorCommand.id,
title: 'sheetConfig.changeColor',
positions: [SheetMenuPosition.SHEET_BAR],
- display: DisplayTypes.COLOR,
type: MenuItemType.SELECTOR,
selections: [
{
- id: SHEET_UI_PLUGIN_NAME + ColorPicker.name,
+ id: COLOR_PICKER_COMPONENT,
},
],
};
diff --git a/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
index 0d63f5587a..2cb8e62f5f 100644
--- a/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
+++ b/packages/ui-plugin-sheets/src/controller/menu/merge.menu.ts
@@ -5,7 +5,7 @@ import {
AddWorksheetMergeVerticalCommand,
RemoveWorksheetMergeCommand,
} from '@univerjs/base-sheets';
-import { DisplayTypes, IMenuButtonItem, IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
+import { IMenuButtonItem, IMenuSelectorItem, MenuItemType, MenuPosition } from '@univerjs/base-ui';
import { ICommandService, IPermissionService } from '@univerjs/core';
import { IAccessor } from '@wendellhu/redi';
@@ -15,10 +15,8 @@ export function CellMergeMenuItemFactory(accessor: IAccessor): IMenuSelectorItem
return {
id: AddWorksheetMergeCommand.id,
- title: 'merge',
icon: 'MergeCellSingle',
tooltip: 'toolbar.mergeCell.main',
- display: DisplayTypes.ICON,
positions: [MenuPosition.TOOLBAR_START],
type: MenuItemType.SUBITEMS,
// selections: [...MERGE_CHILDREN],
diff --git a/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts
index 13eb81e094..675284dc08 100644
--- a/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts
+++ b/packages/ui-plugin-sheets/src/controller/sheet-ui.controller.ts
@@ -15,11 +15,9 @@ import {
IUIController,
} from '@univerjs/base-ui';
import { Disposable, ICommandService, LifecycleStages, OnLifecycle } from '@univerjs/core';
-import { ColorPicker } from '@univerjs/design';
import { Inject, Injector } from '@wendellhu/redi';
import { connectInjector } from '@wendellhu/redi/react-bindings';
-import { SHEET_UI_PLUGIN_NAME } from '../Basics';
import { RenameSheetOperation } from '../commands/commands/rename.command';
import {
SetCopySelectionCommand,
@@ -39,21 +37,16 @@ import {
SetCellEditVisibleOperation,
} from '../commands/operations/cell-edit.operation';
import { SetFormatPainterOperation } from '../commands/operations/set-format-painter.operation';
+import { BORDER_LINE_COMPONENT, BorderLine } from '../components/border-line';
+import { COLOR_PICKER_COMPONENT, ColorPicker } from '../components/color-picker';
import {
- BorderDashDot,
- BorderDashDotDot,
- BorderDashed,
- BorderDotted,
- BorderHair,
- BorderMedium,
- BorderMediumDashDot,
- BorderMediumDashDotDot,
- BorderMediumDashed,
- BorderThick,
-} from '../View/BorderLine';
-import { BorderThin } from '../View/BorderLine/BorderThin';
-import { ContextMenuInput } from '../View/ContextMenu/ContextMenuInput';
-import { ContextMenuItem } from '../View/ContextMenu/ContextMenuItem';
+ FONT_FAMILY_COMPONENT,
+ FONT_FAMILY_ITEM_COMPONENT,
+ FontFamily,
+ FontFamilyItem,
+} from '../components/font-family';
+import { FONT_SIZE_COMPONENT, FontSize } from '../components/font-size';
+import { MENU_ITEM_INPUT_COMPONENT, MenuItemInput } from '../components/menu-item-input';
import { RenderSheetContent, RenderSheetFooter, RenderSheetHeader } from '../View/SheetContainer/SheetContainer';
import { CellBorderSelectorMenuItemFactory } from './menu/border.menu';
import {
@@ -63,7 +56,6 @@ import {
ClearSelectionAllMenuItemFactory,
ClearSelectionContentMenuItemFactory,
ClearSelectionFormatMenuItemFactory,
- CONTEXT_MENU_INPUT_LABEL,
CopyMenuItemFactory,
CopySheetMenuItemFactory,
DeleteRangeMenuItemFactory,
@@ -177,25 +169,12 @@ export class SheetUIController extends Disposable {
const componentManager = this._componentManager;
// FIXME: no dispose logic
- componentManager.register(CONTEXT_MENU_INPUT_LABEL, ContextMenuInput);
- componentManager.register(ContextMenuItem.name, ContextMenuItem);
- componentManager.register(SHEET_UI_PLUGIN_NAME + ColorPicker.name, ColorPicker);
-
- [
- BorderThin,
- BorderDashDot,
- BorderDashDotDot,
- BorderDashed,
- BorderDotted,
- BorderHair,
- BorderMedium,
- BorderMediumDashDot,
- BorderMediumDashDotDot,
- BorderMediumDashed,
- BorderThick,
- ].forEach((BorderLine) => {
- componentManager.register(BorderLine.name, BorderLine);
- });
+ componentManager.register(MENU_ITEM_INPUT_COMPONENT, MenuItemInput);
+ componentManager.register(BORDER_LINE_COMPONENT, BorderLine);
+ componentManager.register(COLOR_PICKER_COMPONENT, ColorPicker);
+ componentManager.register(FONT_FAMILY_COMPONENT, FontFamily);
+ componentManager.register(FONT_FAMILY_ITEM_COMPONENT, FontFamilyItem);
+ componentManager.register(FONT_SIZE_COMPONENT, FontSize);
// init commands
[
diff --git a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
index a7c979a57e..e0a980b7bd 100644
--- a/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
+++ b/packages/ui-plugin-slides/src/Controller/ToolbarUIController.ts
@@ -71,7 +71,6 @@ export class ToolbarUIController {
className: styles.selectDoubleString,
name: 'textRotateMode',
tooltip: 'toolbar.textRotateMode.main',
- display: 1,
show: this._config.textRotateMode,
onClick: (value: number | string) => {
this.setTextRotation(value);
diff --git a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
index 7e1db84cc2..69f6a3dd44 100644
--- a/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
+++ b/packages/ui-plugin-slides/src/View/InfoBar/InfoBar.tsx
@@ -1,4 +1,4 @@
-import { BaseComponentProps, CustomLabel, Input } from '@univerjs/base-ui';
+import { BaseComponentProps, Input } from '@univerjs/base-ui';
import { Nullable } from '@univerjs/core';
import { Container, Tooltip } from '@univerjs/design';
import { Component } from 'react';
@@ -57,12 +57,8 @@ export class InfoBar extends Component<IProps, IState> {
<Input bordered={false} value={slide.label} onBlur={renameSheet} />
</Tooltip>
</div>
- <div className={styles.infoDetailUpdate}>
- <CustomLabel label={update.label} />
- </div>
- <div className={styles.infoDetailSave}>
- <CustomLabel label={save.label} />
- </div>
+ <div className={styles.infoDetailUpdate}>{/* <CustomLabel label={update.label} /> */}</div>
+ <div className={styles.infoDetailSave}>{/* <CustomLabel label={save.label} /> */}</div>
</Container>
);
}
diff --git a/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx b/packages/ui-plugin-slides/src/View/Toolbar/Toolbar.tsx
index 4c1345444c..25395ba759 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, CustomLabel, debounce, Select } from '@univerjs/base-ui';
+import { AppContext, BaseComponentProps, debounce, Select } from '@univerjs/base-ui';
import { Button, Container, Tooltip } from '@univerjs/design';
import { Component, createRef } from 'react';
@@ -197,7 +197,7 @@ export class Toolbar extends Component<IProps, IState> {
return (
<Tooltip key={index} title={item.tooltip} placement={'bottom'}>
<Button className={styles.textButton} onClick={item.onClick}>
- <CustomLabel label={item.label} />
+ {/* <CustomLabel label={item.label} /> */}
</Button>
</Tooltip>
);
@@ -207,8 +207,6 @@ export class Toolbar extends Component<IProps, IState> {
return (
<Select
key={index}
- tooltip={item.tooltip}
- display={item.display}
children={item.children}
suffix={item.suffix}
label={item.label}
@@ -239,14 +237,9 @@ export class Toolbar extends Component<IProps, IState> {
className={styles.moreButton}
style={{ visibility: moreToolList.length ? 'visible' : 'hidden' }}
>
- <Tooltip
- title={(<CustomLabel label="toolbar.toolMoreTip" />) as unknown as string}
- placement={'bottom'}
- >
+ <Tooltip title="toolbar.toolMoreTip" placement={'bottom'}>
<Button onClick={this.showMore}>
- <div style={{ fontSize: '14px' }}>
- <CustomLabel label="toolbar.toolMore" />
- </div>
+ <div style={{ fontSize: '14px' }}>{/* <CustomLabel label="toolbar.toolMore" /> */}</div>
</Button>
</Tooltip>
</div>
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b562ee5712..ab8999f15e 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -524,9 +524,6 @@ importers:
localforage:
specifier: ^1.10.0
version: 1.10.0
- rc-dropdown:
- specifier: ^4.1.0
rc-menu:
specifier: ^9.12.2
@@ -695,6 +692,9 @@ importers:
rc-dropdown:
specifier: ^4.1.0
+ rc-input:
+ specifier: ^1.3.5
rc-input-number:
specifier: ^8.5.0