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.

fix(base-ui): ts error

tonytonychopper1238f73c20ba700
diff --git a/packages/base-ui/src/Basics/Bootstrap.ts b/packages/base-ui/src/Basics/Bootstrap.ts
index 98d12d18da..2798bd6746 100644
--- a/packages/base-ui/src/Basics/Bootstrap.ts
+++ b/packages/base-ui/src/Basics/Bootstrap.ts
@@ -1,6 +1,6 @@
-import { IOCContainer } from '@univerjs/core';
-import { StyleUniver } from '@univerjs/style-univer/src/StyleUniver';
+// import { IOCContainer } from '@univerjs/core';
+// import { StyleUniver } from '@univerjs/style-univer/src/StyleUniver';
-export function Bootstrap(IOC: IOCContainer) {
- IOC.addMapping('StyleUniver', StyleUniver);
-}
+// export function Bootstrap(IOC: IOCContainer) {
+// IOC.addMapping('StyleUniver', StyleUniver);
+// }
diff --git a/packages/base-ui/src/Basics/Register/Paste/PasteExtensionManager.ts b/packages/base-ui/src/Basics/Register/Paste/PasteExtensionManager.ts
index 0891a61848..aa8aa78a47 100644
--- a/packages/base-ui/src/Basics/Register/Paste/PasteExtensionManager.ts
+++ b/packages/base-ui/src/Basics/Register/Paste/PasteExtensionManager.ts
@@ -40,19 +40,23 @@ export class PasteExtensionManager {
pasteResolver(evt?: ClipboardEvent) {
return new Promise((resolve: (value: IPasteData) => void, reject) => {
- Clipboard.read(evt).then((file: Array<PasteType | null> | null) => {
+ Clipboard.read(evt).then((file: string | Array<PasteType | null> | null) => {
if (!file) return [];
- const HtmlIndex = file.findIndex((item: PasteType | null, index: number) => item && item.type === 'text/html');
- const PlainIndex = file.findIndex((item: PasteType | null, index: number) => item && item.type === 'text/plain');
-
const data: IPasteData = {};
- if (HtmlIndex > -1) {
- const html = file[HtmlIndex]?.result as string;
- data.html = html;
- }
- if (PlainIndex > -1) {
- const plain = file[PlainIndex]?.result as string;
- data.plain = plain;
+ if (typeof file === 'string') {
+ data.html = file;
+ } else {
+ const HtmlIndex = file.findIndex((item: PasteType | null, index: number) => item && item.type === 'text/html');
+ const PlainIndex = file.findIndex((item: PasteType | null, index: number) => item && item.type === 'text/plain');
+
+ if (HtmlIndex > -1) {
+ const html = file[HtmlIndex]?.result as string;
+ data.html = html;
+ }
+ if (PlainIndex > -1) {
+ const plain = file[PlainIndex]?.result as string;
+ data.plain = plain;
+ }
}
resolve(data);
diff --git a/packages/base-ui/src/Basics/Shared/Locale.ts b/packages/base-ui/src/Basics/Shared/Locale.ts
index 56c101ef07..2727b449a1 100644
--- a/packages/base-ui/src/Basics/Shared/Locale.ts
+++ b/packages/base-ui/src/Basics/Shared/Locale.ts
@@ -31,7 +31,7 @@ export type ILocaleOptions = {
* }
* ```
*/
- locales: object;
+ locales: Record<string, any>;
};
/**
@@ -69,7 +69,7 @@ export class Locale {
*
* @private
*/
- private static getValue(locale: object, key: string): Nullable<string | object> {
+ private static getValue(locale: Record<string, any>, key: string): Nullable<string | object> {
try {
return locale[key] ? locale[key] : key.split('.').reduce((a, b) => a[b], locale);
} catch (error) {
diff --git a/packages/base-ui/src/Basics/SlideTabBar/Animate.ts b/packages/base-ui/src/Basics/SlideTabBar/Animate.ts
index 4b804c57c5..a5d0e4e8ba 100644
--- a/packages/base-ui/src/Basics/SlideTabBar/Animate.ts
+++ b/packages/base-ui/src/Basics/SlideTabBar/Animate.ts
@@ -1,4 +1,4 @@
-const Tween = {
+const Tween: Record<string, Function> = {
easeOutStrong(t: number, b: number, c: number, d: number): number {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
},
diff --git a/packages/base-ui/src/Components/ColorPickerCircleButton/ColorPickerCircleButton.tsx b/packages/base-ui/src/Components/ColorPickerCircleButton/ColorPickerCircleButton.tsx
index a7b0a765e7..d8d495ff95 100644
--- a/packages/base-ui/src/Components/ColorPickerCircleButton/ColorPickerCircleButton.tsx
+++ b/packages/base-ui/src/Components/ColorPickerCircleButton/ColorPickerCircleButton.tsx
@@ -1,6 +1,7 @@
import { JSXComponent } from '../../BaseComponent';
import { Component, createRef } from '../../Framework';
import { BaseColorPickerCircleButtonProps, ColorPickerCircleButtonComponent } from '../../Interfaces';
+import { NextIcon } from '../Icon';
import { ColorPicker } from '../index';
import Styles from './index.module.less';
@@ -24,7 +25,6 @@ export class ColorPickerCircleButton extends Component<BaseColorPickerCircleButt
render(props: BaseColorPickerCircleButtonProps) {
const { color, onClick, onCancel, style, colorPickerStyle } = props;
- const NextIcon = this.getComponentRender().renderFunction('NextIcon');
return (
<div style={style} className={Styles.colorPickerCircleButton} ref={this.ref} onClick={this.handleColorSelectButtonClick}>
diff --git a/packages/base-ui/src/Components/FilterSelect/FilterSelect.tsx b/packages/base-ui/src/Components/FilterSelect/FilterSelect.tsx
index 05711b9d13..3ca5872022 100644
--- a/packages/base-ui/src/Components/FilterSelect/FilterSelect.tsx
+++ b/packages/base-ui/src/Components/FilterSelect/FilterSelect.tsx
@@ -1,113 +1,113 @@
-import { JSXComponent } from '../../BaseComponent';
-import { Component, createRef } from '../../Framework';
-import { BaseFilterSelectProps, FilterSelectComponent } from '../../Interfaces';
-import { ColorPicker, Icon, Ul } from '../index';
-import styles from './index.module.less';
+// import { JSXComponent } from '../../BaseComponent';
+// import { Component, createRef } from '../../Framework';
+// import { BaseFilterSelectProps, FilterSelectComponent } from '../../Interfaces';
+// import { ColorPicker, Icon, Ul } from '../index';
+// import styles from './index.module.less';
-// interface IProps {}
-interface IState {
- list: List[];
- sheetUl: any;
-}
+// // interface IProps {}
+// interface IState {
+// list: List[];
+// sheetUl: any;
+// }
-class FilterSelect extends Component<BaseFilterSelectProps, IState> {
- buttonRef = createRef();
+// class FilterSelect extends Component<BaseFilterSelectProps, IState> {
+// buttonRef = createRef();
- root = createRef();
+// root = createRef();
- initialize(props: BaseFilterSelectProps) {
- this.state = {
- list: [
- { content: '以A-Z升序排列', onClick: this.printContent.bind(this, '以A-Z升序排列') },
- { content: '以Z-A降序排列', onClick: this.printContent.bind(this, '以Z-A降序排列') },
- {
- content: '按颜色筛选',
- onClick: this.printContent.bind(this, '按颜色筛选'),
- children: [{ content: <ColorPicker color="#000" onClick={() => {}} onCancel={() => {}} style={{ display: 'flex' }} />, type: 'jsx' }],
- },
- { content: '按条件过滤', onClick: this.printContent.bind(this, '按条件过滤') },
- { content: '按值过滤', onClick: this.printContent.bind(this, '按值过滤') },
- ],
- sheetUl: [
- {
- label: '删除',
- },
- {
- label: '复制',
- },
- {
- label: '重命名',
- },
- {
- label: '更改颜色',
- icon: <Icon.Format.RightIcon />,
+// initialize(props: BaseFilterSelectProps) {
+// this.state = {
+// list: [
+// { content: '以A-Z升序排列', onClick: this.printContent.bind(this, '以A-Z升序排列') },
+// { content: '以Z-A降序排列', onClick: this.printContent.bind(this, '以Z-A降序排列') },
+// {
+// content: '按颜色筛选',
+// onClick: this.printContent.bind(this, '按颜色筛选'),
+// children: [{ content: <ColorPicker color="#000" onClick={() => {}} onCancel={() => {}} style={{ display: 'flex' }} />, type: 'jsx' }],
+// },
+// { content: '按条件过滤', onClick: this.printContent.bind(this, '按条件过滤') },
+// { content: '按值过滤', onClick: this.printContent.bind(this, '按值过滤') },
+// ],
+// sheetUl: [
+// {
+// label: '删除',
+// },
+// {
+// label: '复制',
+// },
+// {
+// label: '重命名',
+// },
+// {
+// label: '更改颜色',
+// icon: <Icon.Format.RightIcon />,
- children: [
- {
- label: <ColorPicker style={{ visibility: 'visible', position: 'relative', boxShadow: 'none' }} color="#000" onClick={() => {}} onCancel={() => {}} />,
- isJsx: true,
- },
- ],
- },
- {
- label: '隐藏',
- border: true,
- },
- {
- label: '取消隐藏',
- },
- {
- label: '向左移',
- border: true,
- },
- {
- label: '向右移',
- },
- ],
- };
- }
+// children: [
+// {
+// label: <ColorPicker style={{ visibility: 'visible', position: 'relative', boxShadow: 'none' }} color="#000" onClick={() => {}} onCancel={() => {}} />,
+// isJsx: true,
+// },
+// ],
+// },
+// {
+// label: '隐藏',
+// border: true,
+// },
+// {
+// label: '取消隐藏',
+// },
+// {
+// label: '向左移',
+// border: true,
+// },
+// {
+// label: '向右移',
+// },
+// ],
+// };
+// }
- printContent(val: string) {
- console.log(val);
- }
+// printContent(val: string) {
+// console.log(val);
+// }
- onClick(e: MouseEvent) {
- e.preventDefault();
- this.root.current.showSelect();
- }
+// onClick(e: MouseEvent) {
+// e.preventDefault();
+// this.root.current.showSelect();
+// }
- handleClick = (e: Event) => {
- if (this.buttonRef.current.contains(e.target)) return;
- this.root.current.hideSelect();
- };
+// handleClick = (e: Event) => {
+// if (this.buttonRef.current.contains(e.target)) return;
+// this.root.current.hideSelect();
+// };
- // TODO:remove to show select
- componentDidMount() {
- // 添加右键点击、点击事件监听
- document.addEventListener('click', this.handleClick);
- }
+// // TODO:remove to show select
+// componentDidMount() {
+// // 添加右键点击、点击事件监听
+// document.addEventListener('click', this.handleClick);
+// }
- componentWillUnmount() {
- // 移除事件监听
- document.removeEventListener('click', this.handleClick);
- }
+// componentWillUnmount() {
+// // 移除事件监听
+// document.removeEventListener('click', this.handleClick);
+// }
- render() {
- return (
- <div className={styles.filterSelect}>
- <span ref={this.buttonRef} onClick={this.onClick.bind(this)}>
- <Icon.Format.NextIcon />
- </span>
- <Ul children={this.state.sheetUl} ref={this.root}></Ul>
- </div>
- );
- }
-}
+// render() {
+// return (
+// <div className={styles.filterSelect}>
+// <span ref={this.buttonRef} onClick={this.onClick.bind(this)}>
+// <Icon.Format.NextIcon />
+// </span>
+// <Ul children={this.state.sheetUl} ref={this.root}></Ul>
+// </div>
+// );
+// }
+// }
-export class UniverFilterSelect implements FilterSelectComponent {
- render(): JSXComponent<BaseFilterSelectProps> {
- return FilterSelect;
- }
-}
+// export class UniverFilterSelect implements FilterSelectComponent {
+// render(): JSXComponent<BaseFilterSelectProps> {
+// return FilterSelect;
+// }
+// }
-export { FilterSelect };
+// export { FilterSelect };
diff --git a/packages/base-ui/src/Components/FilterSelect/index.ts b/packages/base-ui/src/Components/FilterSelect/index.ts
index e1d08ddeda..7e680b1b98 100644
--- a/packages/base-ui/src/Components/FilterSelect/index.ts
+++ b/packages/base-ui/src/Components/FilterSelect/index.ts
@@ -1 +1 @@
-export * from './FilterSelect';
+// export * from './FilterSelect';
diff --git a/packages/base-ui/src/Components/FormatModal/FormatModal.tsx b/packages/base-ui/src/Components/FormatModal/FormatModal.tsx
index 390f0e69ea..8fe9f55f0e 100644
--- a/packages/base-ui/src/Components/FormatModal/FormatModal.tsx
+++ b/packages/base-ui/src/Components/FormatModal/FormatModal.tsx
@@ -1,162 +1,162 @@
-import { Nullable, Observer, Workbook } from '@univerjs/core';
-import { Component } from '../../Framework';
-import { BaseFormatModalProps } from '../../Interfaces';
-import { Modal, Ul } from '../index';
-import styles from './index.module.less';
+// import { Nullable, Observer, Workbook } from '@univerjs/core';
+// import { Component } from '../../Framework';
+// import { BaseFormatModalProps } from '../../Interfaces';
+// import { Modal, Ul } from '../index';
+// import styles from './index.module.less';
-// interface FormatModalProps extends UlProps, ModalProps {
-// children?: any;
-// }
+// // interface FormatModalProps extends UlProps, ModalProps {
+// // children?: any;
+// // }
-type localeProps = {
- name: string;
- value: string;
-};
+// type localeProps = {
+// name: string;
+// value: string;
+// };
-type FormatModalState = {
- data: BaseFormatModalProps[];
-};
+// type FormatModalState = {
+// data: BaseFormatModalProps[];
+// };
-export class FormatModal extends Component<BaseFormatModalProps, FormatModalState> {
- refs: Ul[] = [];
+// export class FormatModal extends Component<BaseFormatModalProps, FormatModalState> {
+// refs: Ul[] = [];
- ModalRefs: Modal[] = [];
+// ModalRefs: Modal[] = [];
- private _localeObserver: Nullable<Observer<Workbook>>;
+// private _localeObserver: Nullable<Observer<Workbook>>;
- initialize(props: BaseFormatModalProps) {
- // super(props);
+// initialize(props: BaseFormatModalProps) {
+// // super(props);
- this.state = {
- data: [
- {
- name: 'format.titleCurrency',
- show: false,
- group: [
- {
- locale: 'button.confirm',
- type: 'primary',
- },
- {
- locale: 'button.cancel',
- },
- ],
- onCancel: () => this.showModal('format.titleCurrency', false),
- },
- {
- name: 'format.titleDateTime',
- show: false,
- group: [
- {
- locale: 'button.confirm',
- type: 'primary',
- },
- {
- locale: 'button.cancel',
- },
- ],
- onCancel: () => this.showModal('format.titleDateTime', false),
- },
- {
- name: 'format.titleNumber',
- show: false,
- group: [
- {
- locale: 'button.confirm',
- type: 'primary',
- },
- {
- locale: 'button.cancel',
- },
- ],
- onCancel: () => this.showModal('format.titleNumber', false),
- },
- ],
- };
- }
+// this.state = {
+// data: [
+// {
+// name: 'format.titleCurrency',
+// show: false,
+// group: [
+// {
+// locale: 'button.confirm',
+// type: 'primary',
+// },
+// {
+// locale: 'button.cancel',
+// },
+// ],
+// onCancel: () => this.showModal('format.titleCurrency', false),
+// },
+// {
+// name: 'format.titleDateTime',
+// show: false,
+// group: [
+// {
+// locale: 'button.confirm',
+// type: 'primary',
+// },
+// {
+// locale: 'button.cancel',
+// },
+// ],
+// onCancel: () => this.showModal('format.titleDateTime', false),
+// },
+// {
+// name: 'format.titleNumber',
+// show: false,
+// group: [
+// {
+// locale: 'button.confirm',
+// type: 'primary',
+// },
+// {
+// locale: 'button.cancel',
+// },
+// ],
+// onCancel: () => this.showModal('format.titleNumber', false),
+// },
+// ],
+// };
+// }
- setLocale() {
- const locale = this.context.locale;
- let data = this.state.data;
- data.forEach((item) => {
- item.title = locale.get(item.name);
- if (item.name === 'format.titleCurrency') {
- item.children = locale.get('currencyDetail').map((ele: localeProps) => ({
- label: ele.name,
- icon: ele.value,
- }));
- } else if (item.name === 'format.titleDateTime') {
- item.children = locale.get('dateFmtList').map((ele: localeProps) => ({
- label: ele.name,
- icon: ele.value,
- }));
- } else if (item.name === 'format.titleNumber') {
- item.children = locale.get('numFmtList').map((ele: localeProps) => ({
- label: ele.name,
- icon: ele.value,
- }));
- }
- if (item.group?.length) {
- item.group.forEach((ele) => {
- ele.label = locale.get(ele.locale);
- });
- }
- });
- this.setState((prevState) => ({
- data,
- }));
- }
+// setLocale() {
+// const locale = this.context.locale;
+// let data = this.state.data;
+// data.forEach((item) => {
+// item.title = locale.get(item.name);
+// if (item.name === 'format.titleCurrency') {
+// item.children = locale.get('currencyDetail').map((ele: localeProps) => ({
+// label: ele.name,
+// icon: ele.value,
+// }));
+// } else if (item.name === 'format.titleDateTime') {
+// item.children = locale.get('dateFmtList').map((ele: localeProps) => ({
+// label: ele.name,
+// icon: ele.value,
+// }));
+// } else if (item.name === 'format.titleNumber') {
+// item.children = locale.get('numFmtList').map((ele: localeProps) => ({
+// label: ele.name,
+// icon: ele.value,
+// }));
+// }
+// if (item.group?.length) {
+// item.group.forEach((ele) => {
+// ele.label = locale.get(ele.locale);
+// });
+// }
+// });
+// this.setState((prevState) => ({
+// data,
+// }));
+// }
- setValue = (value: object, fn?: () => void) => {
- this.setState(
- (prevState) => ({
- ...value,
- }),
- fn
- );
- };
+// setValue = (value: object, fn?: () => void) => {
+// this.setState(
+// (prevState) => ({
+// ...value,
+// }),
+// fn
+// );
+// };
- // show modal
- showModal = (name: string, isShow: boolean) => {
- let data = this.state.data;
- let index = data.findIndex((item) => item.name === name);
- if (index > -1) {
- data[index].show = isShow;
- this.setValue({ data }, () => ({ data }));
- }
- };
+// // show modal
+// showModal = (name: string, isShow: boolean) => {
+// let data = this.state.data;
+// let index = data.findIndex((item) => item.name === name);
+// if (index > -1) {
+// data[index].show = isShow;
+// this.setValue({ data }, () => ({ data }));
+// }
+// };
- componentWillMount() {
- this.setLocale();
+// componentWillMount() {
+// this.setLocale();
- this._localeObserver = this._context
- .getObserverManager()
- .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')
- ?.add(() => {
- this.setLocale();
- });
- }
+// this._localeObserver = this._context
+// .getObserverManager()
+// .getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')
+// ?.add(() => {
+// this.setLocale();
+// });
+// }
- componentWillUnmount() {
- // this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);
- }
+// componentWillUnmount() {
+// // this._context.getObserverManager().getObserver<Workbook>('onAfterChangeUILocaleObservable', 'workbook')?.remove(this._localeObserver);
+// }
- render(props: BaseFormatModalProps, state: FormatModalState) {
- const { data } = state;
- return (
- <>
- {data.map((item, index) => {
- if (item.show) {
- return (
- <Modal title={item.title} className={styles.formatModal} group={item.group} visible={item.show} onCancel={item.onCancel}>
- {item.label}
- <Ul show={true} children={item.children} ref={(ele: Ul) => (this.refs[index] = ele)}></Ul>
- </Modal>
- );
- }
- return <></>;
- })}
- </>
- );
- }
-}
+// render(props: BaseFormatModalProps, state: FormatModalState) {
+// const { data } = state;
+// return (
+// <>
+// {data.map((item, index) => {
+// if (item.show) {
+// return (
+// <Modal title={item.title} className={styles.formatModal} group={item.group} visible={item.show} onCancel={item.onCancel}>
+// {item.label}
+// <Ul show={true} children={item.children} ref={(ele: Ul) => (this.refs[index] = ele)}></Ul>
+// </Modal>
+// );
+// }
+// return <></>;
+// })}
+// </>
+// );
+// }
+// }
diff --git a/packages/base-ui/src/Components/FormatModal/index.ts b/packages/base-ui/src/Components/FormatModal/index.ts
index 7c6731fedd..7ded43672d 100644
--- a/packages/base-ui/src/Components/FormatModal/index.ts
+++ b/packages/base-ui/src/Components/FormatModal/index.ts
@@ -1 +1 @@
-export * from './FormatModal';
+// export * from './FormatModal';
diff --git a/packages/base-ui/src/Components/SelectComponent/Select-zh.md b/packages/base-ui/src/Components/SelectComponent/Select-zh.md
deleted file mode 100644
index f4cf2476d3..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/Select-zh.md
+++ /dev/null
@@ -1,58 +0,0 @@
----
-category: Components
-type: 通用
-title: Select
-subtitle: 下拉框组件
-cover: ''
----
-
-## 介绍
-
-下拉框组件
-
-下拉框组件类型
-
-- 默认:点击弹出下拉框
-- 文本框:类型`input`,点击文本框弹出下拉框
-- 复合类型:左侧按钮是功能按钮,右侧按钮弹出下拉框
-- 颜色选择类型:左侧按钮是功能按钮,右侧按钮弹出颜色选择器
-- jsx 类型:插入 jsx
-
-## API
-
-属性说明如下:
-
-| 属性 | 说明 | 类型 | 默认值 |
-
-| label | 下拉按钮显示的内容 | string/JSX | - |
-| selected | 下拉框选项被选中时显示的 √ | boolean | - |
-| icon | 尾处的图标或文字或 jsx | JSX.Element/string | - |
-| tooltip | 下拉按钮移入时的提示 | string | - |
-| children | 按钮内容或者子节点 | any | - |
-| className | 点击按钮时的回调 | string | - |
-| onClick | 点击按钮时的回调 | (...arg: Array<any>) => void | - |
-| needChange | 是否改变按钮内容 | boolean | - |
-| selectType | 下拉框类型 | input/color/double/jsx | - |
-| border | 显示侧边框 | boolean | - |
-| showSelect | 显示下拉框 | (e) => void | - |
-| hideSelect | 隐藏侧边框 | (e) => void | - |
-
-## 案例
-
-```jsx
-import { Select } from '@univerjs/style-univer';
-
-<Select
- tooltip={item.tooltip}
- tooltipRight={item.tooltipRight}
- key={item.name}
- children={item.children}
- label={item.label}
- icon={item.icon}
- needChange={item.needChange}
- selectType={item.selectType}
- border={item.border}
- slot={item.slot || {}}
- onClick={item.onClick?.bind(this, { item, index }, this.context)}
-/>;
-```
diff --git a/packages/base-ui/src/Components/SelectComponent/Select.md b/packages/base-ui/src/Components/SelectComponent/Select.md
deleted file mode 100644
index b0cba2dd97..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/Select.md
+++ /dev/null
@@ -1,55 +0,0 @@
----
-category: Components
-type: General
-title: Select
-cover: ''
----
-
-## Introductionzu
-
-Select Component
-
-Select Type
-
-- default:click to popup select
-- input:click input to popup select
-- double:click left button to relize function,click right button to popup select
-- color:click left button to relize function,click right button to popup colorpicker component
-- jsx:insert jsx
-
-## API
-
-| Property | Description | Type | Default |
-
-| label | content of select button | string/JSX | - |
-| selected | when select's options is selected to show √ | boolean | - |
-| icon | label/icon/jsx in the end | JSX.Element/string | - |
-| tooltip | tooltip | string | - |
-| children | Content or child nodes | any | - |
-| className | classname | string | - |
-| onClick | Set the handler to handle `click` event | (...arg: Array<any>) => void | - |
-| needChange | change label of button | boolean | - |
-| selectType | select type | input/color/double/jsx | - |
-| border | show side border | boolean | - |
-| showSelect | show select | (e) => void | - |
-| hideSelect | hide select | (e) => void | - |
-
-## Case
-
-```jsx
-import { Select } from '@univerjs/style-univer';
-
-<Select
- tooltip={item.tooltip}
- tooltipRight={item.tooltipRight}
- key={item.name}
- children={item.children}
- label={item.label}
- icon={item.icon}
- needChange={item.needChange}
- selectType={item.selectType}
- border={item.border}
- slot={item.slot || {}}
- onClick={item.onClick?.bind(this, { item, index }, this.context)}
-/>;
-```
diff --git a/packages/base-ui/src/Components/SelectComponent/Select.tsx b/packages/base-ui/src/Components/SelectComponent/Select.tsx
deleted file mode 100644
index 008d7fcbb1..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/Select.tsx
+++ /dev/null
@@ -1,335 +0,0 @@
-import { createRef, PureComponent } from '../../Framework';
-import { JSXComponent } from '../../BaseComponent';
-import { BaseSelectProps, SelectComponent } from '../../Interfaces';
-import { Button } from '../Button';
-import { ColorPicker } from '../ColorPicker';
-import { Input } from '../Input';
-import { Tooltip } from '../Tooltip';
-import { Ul } from '../Ul';
-import { ISelectButton } from './enum';
-import styles from './index.module.less';
-
-type BaseSelectState = {
- label?: string | JSX.Element | null | undefined;
- children: BaseSelectProps[];
- color?: string[][];
- selectColor?: string;
-};
-
-/**
- * drop-down list
- * The incoming method only needs logic, no attention list
- */
-export class Select extends PureComponent<BaseSelectProps, BaseSelectState> {
- ref = createRef();
-
- inputRef = createRef();
-
- colorBtn = createRef();
-
- constructor(props: BaseSelectProps) {
- super(props);
- this.state = {
- label: '',
- children: [],
- selectColor: '#000',
- };
-
- // Mount update function, when updating the selection range, the cell formats corresponding to different ranges are different, and the toolbar status and values need to be updated in real time
- const { triggerUpdate } = props;
- triggerUpdate && triggerUpdate(this.update.bind(this));
- }
-
- // show sub components
- showSelect = (e: MouseEvent) => {
- e.stopImmediatePropagation();
- const current = this.ref.current;
- // if (current) current.showSelect();
- if (current && this.props.selectType === ISelectButton.COLOR) {
- current.showSelect(this.colorBtn.current);
- } else if (current) {
- current.showSelect();
- }
-
- // Click outside to hide child components
- window.addEventListener('click', this.hide, true);
- };
-
- hide = (e: any) => {
- if (!this.ref.current) return;
- if (!this.ref.current.ulRef && !this.ref.current.ulRef.current) return;
- if (this.ref.current.ulRef.current.contains(e.target)) return;
- this.hideSelect(e);
- };
-
- // hide child components
- hideSelect = (e: MouseEvent | KeyboardEvent) => {
- const current = this.ref.current;
- current.hideSelect(e);
-
- window.removeEventListener('click', this.hide, true);
- };
-
- changeValue = (value: BaseSelectState) => {
- this.setState((prevState) => ({
- ...value,
- }));
- };
-
- /**
- * update new label
- * @param label
- */
- update = (value: string | number) => {
- const labelType = typeof this.props.label;
-
- const children = this.state.children;
-
- let label;
-
- children?.forEach((ele: BaseSelectProps, i: number) => {
- if (ele.value === value) {
- ele.selected = true;
-
- if (this.props.needChange) {
- this.setState({
- label: labelType === 'string' ? ele.label : ele.icon,
- });
- label = ele.label;
- }
- } else {
- ele.selected = false;
- }
- });
-
- this.setState({
- children,
- });
- this.props.selectType === ISelectButton.INPUT_NUMBER && this.inputRef.current.setValue(label);
- };
-
- handleClick = (...args: any[]) => {
- const labelType = typeof this.props.label;
-
- this.hideSelect(args[0]);
-
- const { item, index } = args[1];
-
- const children = this.state.children;
- children?.forEach((ele: BaseSelectProps) => (ele.selected = false));
-
- children[index].selected = true;
-
- let label = children[index].label;
-
- this.setState({
- children,
- });
-
- // update input box info
- if (this.props.needChange) {
- this.setState({
- label: labelType === 'string' ? label : item.icon,
- });
-
- if ([ISelectButton.INPUT, ISelectButton.INPUT_NUMBER].includes(this.props.selectType as ISelectButton)) {
- this.inputRef.current.setValue(label);
- }
-
- const propsChildren = this.props.children as any[];
-
- // border line get selected color
- if (propsChildren[10] && propsChildren[10].locale === 'borderLine.borderColor') {
- const propsColorItem = propsChildren[10] as any;
- const propsColorChildren = propsColorItem.children!;
-
- let borderLineSelectedColor = propsColorChildren[0].value;
- let borderLineSelectedSize = propsChildren[11].value;
-
- this.props.onClick?.call(
- this,
- children[index].hasOwnProperty('value') ? children[index].value : children[index].label,
- borderLineSelectedColor,
- borderLineSelectedSize
- );
- return;
- }
- }
-
- // The default value is the value. Some labels have the same value as the value. You can also use the label directly.
- this.props.onClick?.call(this, children[index].hasOwnProperty('value') ? children[index].value : children[index].label);
- };
-
- /**
- * font color/background color / border / merge buttons click
- */
- handleButtonClick = () => {
- const children = this.state.children;
- const selected = children?.find((ele: BaseSelectProps) => ele.selected === true);
-
- const propsChildren = this.props.children as any[];
-
- // toolbar font color / fill color
- if (this.props.selectType === 'color') {
- this.props.onClick?.call(this, this.state.selectColor);
- }
- // border line get selected color, TODO: do not use borderLine.borderColor, use new prop instead
- else if (propsChildren && propsChildren[10] && propsChildren[10].locale === 'borderLine.borderColor') {
- const propsColorItem = propsChildren[10] as any;
- const propsColorChildren = propsColorItem.children!;
-
- let borderLineSelectedColor = propsColorChildren[0].value;
- let borderLineSelectedSize = propsChildren[11].value;
-
- selected && this.props.onClick?.call(this, selected.hasOwnProperty('value') ? selected.value : selected.label, borderLineSelectedColor, borderLineSelectedSize);
- return;
- }
- // merge cell button click, must be "merge all"
- else if (propsChildren && propsChildren[0] && propsChildren[0].locale && propsChildren[0].locale.indexOf('merge') > -1) {
- this.props.onClick?.call(this, 'all');
- return;
- }
-
- selected && this.props.onClick?.call(this, selected.hasOwnProperty('value') ? selected.value : selected.label);
- };
-
- // Press Enter on input element
- handleKeyUp = (e: KeyboardEvent) => {
- if (e.key === 'Enter') {
- this.props.selectType === ISelectButton.INPUT_NUMBER && this.inputRef.current.base.blur();
- const label = (e.currentTarget as HTMLInputElement).value;
-
- this.update(label);
-
- this.hideSelect(e);
-
- this.props.onKeyUp?.call(this, label);
- }
- };
-
- componentWillMount() {
- this.changeValue({
- label: this.props.label,
- children: this.props.children,
- });
- }
-
- // remove to showSelect
- // componentDidMount() {
- // window.addEventListener('click', this.hideSelect, true);
- // }
-
- // componentWillUnmount() {
- // window.removeEventListener('click', this.hideSelect, true);
- // }
- render(props: BaseSelectProps) {
- const { icon, tooltip, selectType, border, slot, style, onClick } = props;
- let classes = '';
- if (typeof this.state.label !== 'object') {
- classes = 'universheet-toolbar-menu-button-text';
- }
- if (selectType === ISelectButton.INPUT || selectType === ISelectButton.INPUT_NUMBER) {
- return (
- <div className={styles.selectButton}>
- <div className={styles.selectInput}>
- <Input
- type={selectType === ISelectButton.INPUT_NUMBER ? 'number' : 'text'}
- value={this.state.label as string}
- onClick={this.showSelect}
- ref={this.inputRef}
- bordered={false}
- onKeyUp={this.handleKeyUp}
- />
- <span onClick={this.showSelect}>{icon}</span>
- </div>
- {border ? <div className={styles.selectLine}></div> : ''}
- <Ul children={this.state.children} onClick={this.handleClick} ref={this.ref} style={style}></Ul>
- </div>
- );
- }
- if (selectType === ISelectButton.DOUBLE) {
- return (
- <div className={`${styles.selectButton} ${styles.selectDoubleButton}`}>
- <div style={{ display: 'flex', alignItems: 'center' }}>
- <Tooltip title={tooltip!} placement={'bottom'}>
- <Button type="text" onClick={this.handleButtonClick}>
- <div className={styles.selectButtonInner}>
- <div className={typeof this.state.label === 'string' ? styles.selectButtonInnerLabelString : styles.selectButtonInnerLabelIcon}>
- {this.state.label}
- </div>
- </div>
- </Button>
- </Tooltip>
- <Tooltip title={this.props.tooltipRight!} placement={'bottom'}>
- <Button type="text" onClick={this.showSelect} className={styles.doubleButtons}>
- <div className={styles.selectButtonInner}>{icon}</div>
- </Button>
- </Tooltip>
- </div>
- {border ? <div className={styles.selectLine}></div> : ''}
-
- <Ul children={this.state.children} onClick={this.handleClick} ref={this.ref} style={style}></Ul>
- </div>
- );
- }
- if (selectType === ISelectButton.COLOR) {
- return (
- <div className={`${styles.selectButton} ${styles.selectDoubleButton}`} ref={this.colorBtn}>
- <div style={{ display: 'flex', alignItems: 'center' }}>
- <Tooltip title={tooltip!} placement={'bottom'}>
- <Button type="text" onClick={this.handleButtonClick}>
- <div className={styles.selectButtonInner}>
- <div className={typeof this.state.label === 'string' ? styles.selectButtonInnerLabelString : styles.selectButtonInnerLabelIcon}>
- {this.state.label}
- </div>
- <div className={styles.selectColor} style={{ backgroundColor: this.state.selectColor }}></div>
- </div>
- </Button>
- </Tooltip>
- <Tooltip title={this.props.tooltipRight!} placement={'bottom'}>
- <Button type="text" onClick={this.showSelect} className={styles.doubleButtons}>
- <div className={styles.selectButtonInner}>{icon}</div>
- </Button>
- </Tooltip>
- </div>
- {border ? <div className={styles.selectLine}></div> : ''}
- <ColorPicker
- color={'#000'}
- onClick={(col: string) => {
- this.setState(
- {
- selectColor: col,
- },
- () => {
- onClick && onClick(this.state.selectColor);
- }
- );
- }}
- slot={slot!}
- ref={this.ref}
- />
- </div>
- );
- }
- return (
- <div className={styles.selectButton}>
- <Tooltip title={tooltip!} placement={'bottom'}>
- <Button type="text" onClick={this.showSelect}>
- <div className={styles.selectButtonInner}>
- <div className={typeof this.state.label === 'string' ? styles.selectButtonInnerLabelString : styles.selectButtonInnerLabelIcon}>{this.state.label}</div>
- {icon}
- </div>
- </Button>
- </Tooltip>
- {border ? <div className={styles.selectLine}></div> : ''}
- <Ul children={this.state.children} onClick={this.handleClick} ref={this.ref} style={style}></Ul>
- </div>
- );
- }
-}
-
-export class UniverSelect implements SelectComponent {
- render(): JSXComponent<BaseSelectProps> {
- return Select;
- }
-}
diff --git a/packages/base-ui/src/Components/SelectComponent/enum.ts b/packages/base-ui/src/Components/SelectComponent/enum.ts
deleted file mode 100644
index 952c8ab628..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/enum.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export enum ISelectButton {
- INPUT = 'input',
- COLOR = 'color',
- DOUBLE = 'double',
- JSX = 'jsx',
- INPUTNUMBER = 'inputNumber',
-}
-
-export type ISelectButtonType = `${ISelectButton}`;
diff --git a/packages/base-ui/src/Components/SelectComponent/index.module.less b/packages/base-ui/src/Components/SelectComponent/index.module.less
deleted file mode 100644
index e400546bc4..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/index.module.less
+++ /dev/null
@@ -1,128 +0,0 @@
-@import '../../Basics/CSS/Skin/base.module.less';
-
-.select-button {
- position: relative;
- margin: 0 3px;
-
- &:hover {
- background-color: transparent !important;
- }
-
- > div:first-of-type {
- height: 100%;
-
- &:hover {
- background-color: @gray-14;
- }
- }
-
- .select-button-inner {
- display: flex;
- justify-content: center;
- font-size: 12px;
- position: relative;
-
- .select-color {
- position: absolute;
- width: 15px;
- height: 5px;
- background-color: #000;
- bottom: 0px;
- left: 50%;
- transform: translate(-50%, 0);
- }
-
- .select-button-inner-label-icon {
- font-size: 24px;
-
- & ~ span {
- display: flex;
- align-items: center;
- }
- }
-
- .select-button-inner-label-string {
- margin-right: 7px;
- padding: 5px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- width: 70px;
-
- & ~ span {
- align-self: center;
- }
- }
- }
-
- .select-input {
- display: flex;
- align-items: center;
- height: 100%;
-
- input {
- width: 38px;
- height: 20px;
- background: transparent;
- border: 1px solid transparent;
-
- &::-webkit-outer-spin-button,
- &::-webkit-inner-spin-button {
- -webkit-appearance: none;
- }
-
- &[type='number'] {
- -moz-appearance: textfield;
- }
-
- &:hover {
- border: 1px solid transparent;
- }
-
- &:focus {
- background: #fff;
- border: 1px solid var(--primary-color-hover);
- }
- }
- }
-
- .select-line {
- position: absolute;
- right: -3px;
- top: 15%;
- height: 70%;
- width: 1px;
- background-color: @gray-15;
- vertical-align: top;
- }
-
- // TODO 应该精确className指定按钮颜色
- button {
- .button();
- // border-color: transparent;
- }
-
- .btn:not(.color-picker .btn) {
- height: auto;
- }
-}
-
-.select-button.select-double-button {
- &:hover {
- .double-buttons {
- border-left: 1px solid @gray-6;
- }
- }
-
- .double-buttons {
- padding: 0;
- border-left: 1px solid transparent;
- }
-}
-
-.button() {
- // padding: 0px 5px;
- line-height: 1;
- // box-sizing: border-box;
- // font-size: 0px;
-}
diff --git a/packages/base-ui/src/Components/SelectComponent/index.ts b/packages/base-ui/src/Components/SelectComponent/index.ts
deleted file mode 100644
index 7868ecbae2..0000000000
--- a/packages/base-ui/src/Components/SelectComponent/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Select';
diff --git a/packages/base-ui/src/Components/Ul/Ul.tsx b/packages/base-ui/src/Components/Ul/Ul.tsx
deleted file mode 100644
index beb019d193..0000000000
--- a/packages/base-ui/src/Components/Ul/Ul.tsx
+++ /dev/null
@@ -1,272 +0,0 @@
-import { Component, createRef, cloneElement, VNode } from '../../Framework';
-import { BaseUlProps } from '../../Interfaces';
-import { debounce } from '../../Utils';
-import * as Icon from '../Icon';
-import styles from './index.module.less';
-
-type UlState = {
- style?: JSX.CSSProperties;
- posStyle?: JSX.CSSProperties;
-};
-
-type styleProp = {
- left?: string;
- right?: string;
- top?: string;
- bottom?: string;
-};
-
-export class Ul extends Component<BaseUlProps, UlState> {
- refs: Ul[] = [];
-
- ulRef = createRef<HTMLUListElement>();
-
- resizeUl: any;
-
- filterChildren = (node: HTMLElement) => {
- let flag;
- Array.from(node.children).forEach((item) => {
- if (item.nodeName === 'UL') {
- flag = true;
- }
- });
- return flag;
- };
-
- mouseOver = (e: MouseEvent, index: number) => {
- this.refs.forEach((item) => {
- item.hideSelect();
- });
- const currentTarget = e.currentTarget as HTMLElement;
- if (!this.filterChildren(currentTarget)) return;
- this.refs[index].showSelect();
- };
-
- mouseLeave = (e: MouseEvent, index: number) => {
- // const currentTarget = e.currentTarget as HTMLElement;
- // if (!this.filterChildren(currentTarget)) return;
-
- const type = this.refs[index] ? this.refs[index].props.children![0].selectType : '';
- if (type === 'jsx') return;
-
- this.refs.forEach((item) => {
- item.hideSelect();
- });
- };
-
- handleClick = (e: MouseEvent, { item, index, ref }: Record<string, BaseUlProps | number>, onClick?: (...arg: any[]) => void) => {
- e.stopImmediatePropagation();
- // item.onClick ? use onClick, or use onClick from props
- onClick?.call(this, e, { item, index, ref });
- };
-
- handleKeyUp = (e: KeyboardEvent, { item, index, ref }: Record<string, BaseUlProps | number>, onKeyUp?: (...arg: any[]) => void) => {
- e.stopImmediatePropagation();
- onKeyUp?.call(this, e, { item, index, ref });
- };
-
- // 将自己传给子组件
- sendParent = () => this;
-
- hideSelect = () => {
- window.removeEventListener('resize', this.resizeUl);
- if (this.state.style?.display === 'none') return;
- this.refs.forEach((item) => {
- item.hideSelect();
- });
- this.setState((prevState) => ({ style: { display: 'none' } }));
- };
-
- showSelect = () => {
- window.addEventListener('resize', this.resizeUl);
- this.setState(
- (prevState) => ({ style: { display: 'inline-block' } }),
- () => {
- this.getStyle();
- }
- );
- };
- // componentDidMount() {
- // window.addEventListener('resize', this.resizeUl);
- // }
-
- // componentWillUnmount() {
- // window.removeEventListener('resize', this.resizeUl);
- // }
- componentWillMount() {
- const { show = false } = this.props;
- if (show) {
- this.setState((prevState) => ({
- style: {
- display: 'inline-block',
- },
- }));
- }
- }
-
- // ul 边界处理
- getStyle = () => {
- const parent = this.ulRef.current?.parentElement;
- const current = this.ulRef.current;
-
- let style: styleProp = {};
- let docPosition: any;
- if (!current || !parent) return;
- // 获取各个节点距离屏幕的距离
- const curPosition = current.getBoundingClientRect();
- let parPosition = parent?.getBoundingClientRect();
-
- // TODO 业务组件
- const spreadsheet: any = this.getContext().getPluginManager().getPluginByName('spreadsheet');
- const contentRef = spreadsheet.getSheetContainerControl().getContentRef();
- const wrapper = contentRef.current!;
- // const wrapper = $$('.univer-content-inner-right-container');
- docPosition = wrapper.getBoundingClientRect();
- if (!docPosition || !parPosition) return;
- // 处理li中包含的ul右边界
- if (parent?.nodeName === 'LI') {
- current.style.position = 'fixed';
-
- // 获取固定定位后 父元素正确的位置信息
- parPosition = parent?.getBoundingClientRect();
- 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`;
- }
- } else if (parent?.nodeName === 'DIV') {
- if (parPosition.right + curPosition.width > docPosition!.right || parPosition.right + curPosition.width > document.documentElement.clientWidth) {
- // 边界碰到univer-main-content右边界或者小于视口
- style.right = '0';
- style.left = 'auto';
- } else {
- style.left = '0';
- style.right = 'auto';
- }
- if (curPosition.top >= docPosition.bottom) {
- style.top = 'auto';
- style.bottom = '100%';
- }
- }
- this.setState((prevState) => ({
- posStyle: style,
- }));
- };
-
- showIcon = (item: any) => {
- if ('selected' in item || 'hidden' in item) {
- if (item.selected) {
- return (
- <span className={styles.ulIcon}>
- <Icon.Format.CorrectIcon style={{ fontSize: '13px' }} />
- </span>
- );
- }
- if (item.hidden) {
- return (
- <span className={styles.ulIcon}>
- <Icon.Format.HideIcon style={{ fontSize: '13px' }} />
- </span>
- );
- }
- return <span className={styles.ulIcon}></span>;
- }
- return '';
- };
-
- /**
- * 如果是包含Icon的字符串,转为Icon图标
- */
- getIcon = (item: JSX.Element | string | null | undefined) => {
- let icon = item;
- if (typeof icon === 'string' && /Icon$/.test(icon)) {
- icon = Icon[icon];
- }
- return <span className={styles.submenuArrow}>{icon}</span>;
- };
-
- // 获取父组件
- getParent = () => this.props.getParent() ?? null;
-
- render(props: BaseUlProps, state: UlState) {
- const { children, onClick, style, onKeyUp } = props;
- const { posStyle } = state;
- const ulStyle = Object.assign(this.state.style ?? {}, posStyle, style || {});
-
- if (!children?.length) return <></>;
-
- // If there is a case where selected is set to true, other items need to be set to false, so that the icon can be constructed in the showIcon method to keep the style uniform.
- // If the selected true is not set, the showIcon method will keep an empty string
- children.some((item, i) => {
- if (item.selected) {
- children.forEach((ele, j) => {
- if (i !== j) {
- ele.selected = false;
- }
- });
- return true;
- }
- return false;
- });
-
- return (
- <ul className={children[0].selectType === 'jsx' ? styles.colsMenuJsx : styles.colsMenu} style={{ ...ulStyle }} ref={this.ulRef}>
- {children?.map((item, index: number) => {
- let liClass = item.className ? `${styles.colsMenuitem} ${item.className}` : styles.colsMenuitem;
- if (item.hideLi) {
- return;
- }
- return (
- <li
- className={liClass}
- style={{ ...item.style }}
- onClick={(e) => {
- e.stopPropagation();
- this.handleClick(e, { item, index, ref: this }, item.onClick ? item.onClick : onClick);
- }}
- onMouseEnter={(e) => {
- this.mouseOver(e, index);
- }}
- onMouseLeave={(e) => {
- this.mouseLeave(e, index);
- }}
- onKeyUp={(e) => {
- this.handleKeyUp(e, { item, index, ref: this }, item.onKeyUp ? item.onKeyUp : onKeyUp);
- }}
- >
- <div className={item.selectType === 'jsx' ? '' : styles.colsMenuitemContent}>
- {/* {'selected' in item ? <span className={styles.ulIcon}>{item.selected ? <Icon.Format.CorrectIcon style={{ fontSize: '13px' }} /> : ''}</span> : ''} */}
- {this.showIcon(item)}
- <div>
- {item.selectType === 'jsx' ? <span>{cloneElement(item.label as VNode, { onChange: this.getStyle })}</span> : <span>{item.label}</span>}
- {/* {item.icon ? <span className={styles.submenuArrow}>{item.icon}</span> : ''} */}
- {item.icon ? this.getIcon(item.icon) : ''}
- </div>
- </div>
- {item.children?.length ? (
- <Ul children={item.children} onClick={item.onClick} ref={(ele: Ul) => (this.refs[index] = ele)} getParent={this.sendParent}></Ul>
- ) : (
- <></>
- )}
-
- {item.border ? <div className={styles.line}></div> : ''}
- </li>
- );
- })}
- </ul>
- );
- }
-
- protected initialize(props: BaseUlProps) {
- this.state = {
- style: {
- display: 'none',
- },
- posStyle: {},
- };
-
- this.resizeUl = debounce(this.getStyle, 200);
- }
-}
diff --git a/packages/base-ui/src/Components/Ul/index.module.less b/packages/base-ui/src/Components/Ul/index.module.less
deleted file mode 100644
index 2d8500189e..0000000000
--- a/packages/base-ui/src/Components/Ul/index.module.less
+++ /dev/null
@@ -1,103 +0,0 @@
-@import '../../Basics/CSS/Skin/base.module.less';
-
-.cols-menu {
- .cols-menu-jsx {
- border: 1px solid rgba(0, 0, 0, 0.2);
- box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
- z-index: 2;
- border-radius: 10px;
- }
-
- .menu-button();
- position: absolute;
- width: max-content;
- padding: 6px 0;
- font-size: 13px;
- border: 1px solid rgba(0, 0, 0, 0.2);
- box-shadow: 0 2px 4px rgb(0 0 0 / 20%);
- // max-height: 200px;
- overflow: hidden;
- overflow-y: auto;
- // &:hover {
- // }
-
- .cols-menuitem {
- min-width: 80px;
- position: relative;
- color: var(--text-color);
- cursor: pointer;
- list-style: none;
- margin: 0;
- white-space: nowrap;
- vertical-align: middle;
- user-select: none;
- // line-height: 1.2;
-
- .line {
- margin: 4px 0 5px 0;
- height: 1px;
- width: 100%;
- background-color: @gray-16;
- }
-
- .cols-menuitem-content {
- padding: 5px 14px 5px 10px;
- display: flex;
- align-items: center;
- line-height: 1.2;
-
- &:hover {
- background-color: @gray-14;
- }
-
- .ul-icon {
- margin-right: 3px;
- width: 15px;
- display: inline-block;
- transform: scale(1.5);
- }
-
- > div {
- flex: 1;
- display: flex;
- justify-content: space-between;
- align-items: center;
- min-height: 20px;
-
- .submenu-arrow {
- transition: all 218ms;
- font-size: 12px;
- padding-right: 0;
- opacity: 0.5;
- color: var(--text-color);
- user-select: none;
- margin-left: 2em;
-
- span[role='img'].icon-rightIcon {
- font-size: 16px;
- transform: none;
- }
-
- span[role='img'] {
- font-size: 12px;
- transform: scale(2);
- }
- }
- }
- }
- }
-}
-
-.menu-button() {
- border-radius: 0;
- transition: opacity 218ms;
- background: var(--bg);
- box-shadow: var(--box-shadow-base);
- cursor: default;
- margin: 0;
- outline: 0;
- position: absolute;
- z-index: 2;
- box-sizing: border-box;
- user-select: none;
-}
diff --git a/packages/base-ui/src/Components/Ul/index.ts b/packages/base-ui/src/Components/Ul/index.ts
deleted file mode 100644
index b83442e2a5..0000000000
--- a/packages/base-ui/src/Components/Ul/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Ul';
diff --git a/packages/base-ui/src/Components/Ul/ul-zh.md b/packages/base-ui/src/Components/Ul/ul-zh.md
deleted file mode 100644
index c2be69de9e..0000000000
--- a/packages/base-ui/src/Components/Ul/ul-zh.md
+++ /dev/null
@@ -1,41 +0,0 @@
----
-category: Components
-type: 通用
-title: UL
-subtitle: 无序列表组件
-cover: ''
----
-
-## 介绍
-
-无序列表组件
-
-配合 select 组件使用,也可单独使用
-
-## API
-
-属性说明如下:
-
-| 属性 | 说明 | 类型 | 默认值 |
-
-| label | li 显示的内容 | string/JSX | - |
-| selected | li 选项被选中时显示的 √ | boolean | - |
-| icon | 尾处的图标或文字或 jsx | JSX.Element/string | - |
-| tooltip | li 移入时的提示 | string | - |
-| children | 按钮内容或者子节点 | any | - |
-| className | 类名 | string | - |
-| onClick | 点击按钮时的回调 | (...arg: Array<any>) => void | - |
-| style | 样式 | cssStyle | - |
-| border | 显示上边框 | boolean | - |
-| show | 是否显示 | boolean | - |
-| showSelect | 显示 ul | (e) => void | - |
-| showParentSelect | 显示父级 li(如果 li 里有子元素) | () => void | - |
-| hideSelect | 隐藏 ul | (e) => void | - |
-
-## 案例
-
-```jsx
-import { Ul } from '@univerjs/style-univer';
-
-<Ul children={this.state.children} onClick={this.handleClick} ref={this.ref}></Ul>;
-```
diff --git a/packages/base-ui/src/Components/Ul/ul.md b/packages/base-ui/src/Components/Ul/ul.md
deleted file mode 100644
index 721ea196c7..0000000000
--- a/packages/base-ui/src/Components/Ul/ul.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-category: Components
-type: General
-title: UL
-cover: ''
----
-
-## Introduce
-
-Ul Component
-
-Use with select component, also use alone
-
-## API
-
-| Property | Description | Type | Default |
-
-| label | label of li | string/JSX | - |
-| selected | when li is selected to show √ | boolean | - |
-| icon | label/icon/jsx in the end | JSX.Element/string | - |
-| tooltip | tooltip | string | - |
-| children | Content or child nodes | any | - |
-| className | classname | string | - |
-| onClick | Set the handler to handle `click` event | (...arg: Array<any>) => void | - |
-| style | css style | cssStyle | - |
-| border | show top border | boolean | - |
-| show | is show | boolean | - |
-| showSelect | show ul | (e) => void | - |
-| showParentSelect | show parent li(if li has children) | () => void | - |
-| hideSelect | hide ul | (e) => void | - |
-
-## Case
-
-```jsx
-import { Ul } from '@univerjs/style-univer';
-
-<Ul children={this.state.children} onClick={this.handleClick} ref={this.ref}></Ul>;
-```
diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.ts
index a55c57197f..cd87e103dc 100644
--- a/packages/base-ui/src/Components/index.ts
+++ b/packages/base-ui/src/Components/index.ts
@@ -6,7 +6,7 @@ import { Collapse, Panel } from './Collapse';
import { ColorPicker } from './ColorPicker';
import { ColorPickerCircleButton } from './ColorPickerCircleButton';
import { Container } from './Container';
-import { FormatModal } from './FormatModal';
+// import { FormatModal } from './FormatModal';
import * as Icon from './Icon/index';
import { Input } from './Input';
import { Content, Footer, Header, Layout, Sider } from './Layout';
@@ -22,7 +22,7 @@ import { Slider } from './Slider';
// import { IfGenerate } from './IfGenerate';
import { Tab, TabPane } from './Tabs';
import { Tooltip } from './Tooltip';
-import { Ul } from './Ul';
+// import { Ul } from './Ul';
export * from './Prompt';
@@ -49,12 +49,12 @@ export {
Input,
Separator,
ColorPicker,
- Ul,
+ // Ul,
Modal,
Slider,
Radio,
RadioGroup,
- FormatModal,
+ // FormatModal,
Checkbox,
CheckboxGroup,
Tab,
diff --git a/packages/base-ui/src/Interfaces/ColorPicker.ts b/packages/base-ui/src/Interfaces/ColorPicker.ts
index adc010f984..2aa9ddd2cd 100644
--- a/packages/base-ui/src/Interfaces/ColorPicker.ts
+++ b/packages/base-ui/src/Interfaces/ColorPicker.ts
@@ -27,10 +27,6 @@ export interface BaseColorPickerProps extends BaseComponentProps {
* class name
*/
className?: string;
-
- lang: {
- [index: string]: string;
- };
}
export interface ColorPickerComponent extends BaseComponent<BaseColorPickerProps> {
diff --git a/packages/base-ui/src/Interfaces/Description.ts b/packages/base-ui/src/Interfaces/Description.ts
index 39bf086160..3dcff50b72 100644
--- a/packages/base-ui/src/Interfaces/Description.ts
+++ b/packages/base-ui/src/Interfaces/Description.ts
@@ -3,14 +3,14 @@ import { AvatarComponent } from './Avatar';
import { CheckboxComponent, CheckboxGroupComponent } from './Checkbox';
import { ColorPickerCircleButtonComponent } from './ColorPickerCircleButton';
import { SiderModalComponent } from './SiderModal';
-import { ButtonComponent, CellRangeModalComponent } from '../BaseComponent';
+import { ButtonComponent } from '../BaseComponent';
import { IconComponent } from './Icon';
import { InputComponent } from './Input';
import { TabComponent, TabPaneComponent } from './Tab';
import { RadioComponent, RadioGroupComponent } from './Radio';
import { ContainerComponent, ContentComponent, FooterComponent, HeaderComponent, LayoutComponent, SiderComponent } from './Container';
import { SingleButtonComponent } from './SingleButton';
-import { SelectComponent } from './Select';
+// import { SelectComponent } from './Select';
import { ModalComponent } from './Modal';
import { ColorPickerComponent } from './ColorPicker';
import { TooltipComponent } from './Tooltip';
@@ -23,9 +23,9 @@ import { DropdownComponent } from './Dropdown';
export interface Description {
Button: ButtonComponent;
SingleButton: SingleButtonComponent;
- Select: SelectComponent;
+ // Select: SelectComponent;
Container: ContainerComponent;
- CellRangeModal: CellRangeModalComponent;
+ // CellRangeModal: CellRangeModalComponent;
Modal: ModalComponent;
SiderModal: SiderModalComponent;
Layout: LayoutComponent;
diff --git a/packages/base-ui/src/Interfaces/SheetBar.ts b/packages/base-ui/src/Interfaces/SheetBar.ts
index 2c14aeb0f4..f106911309 100644
--- a/packages/base-ui/src/Interfaces/SheetBar.ts
+++ b/packages/base-ui/src/Interfaces/SheetBar.ts
@@ -1,6 +1,6 @@
import { BooleanNumber } from '@univerjs/core';
import { BaseComponent, BaseComponentProps, JSXComponent } from '../BaseComponent';
-import { BaseSelectProps } from './Select';
+import { BaseSelectProps } from '../Components';
export interface BaseSheetBarProps extends BaseComponentProps, Omit<BaseSelectProps, 'children'> {
children?: any[];
@@ -10,9 +10,11 @@ export interface BaseSheetBarProps extends BaseComponentProps, Omit<BaseSelectPr
style?: JSX.CSSProperties;
hidden?: BooleanNumber;
addSheet?: () => void;
+ onDown?: () => void;
selectSheet?: () => void;
changeSheetName?: (e: Event) => void;
dragEnd?: (elements: HTMLElement[]) => void;
+ selected?: boolean;
}
export interface SheetBarComponent extends BaseComponent<BaseSheetBarProps> {
diff --git a/packages/base-ui/src/Interfaces/index.ts b/packages/base-ui/src/Interfaces/index.ts
index 23ada93c20..3be059c5dc 100644
--- a/packages/base-ui/src/Interfaces/index.ts
+++ b/packages/base-ui/src/Interfaces/index.ts
@@ -8,7 +8,7 @@ export * from './Container';
export * from './CountBar';
export * from './Drag';
export * from './FilterSelect';
-export * from './FormatModal';
+// export * from './FormatModal';
export * from './Icon';
export * from './InfoBar';
export * from './Input';
@@ -18,7 +18,6 @@ export * from './Radio';
export * from './ResizeDialog';
export * from './RightMenu';
export * from './SearchTree';
-export * from './Select';
export * from './SheetBar';
export * from './SiderModal';
export * from './SingleButton';
diff --git a/packages/base-ui/src/Utils/util.ts b/packages/base-ui/src/Utils/util.ts
index 3d9365ffa6..c7019a0baa 100644
--- a/packages/base-ui/src/Utils/util.ts
+++ b/packages/base-ui/src/Utils/util.ts
@@ -259,15 +259,15 @@ export function setLastCaretPosition(dom: HTMLElement) {
// return str;
// }
-export function findLocale<T>(obj: T, fn: Function) {
- for (let k in obj) {
- if (k.endsWith('Locale') && typeof obj[k] === 'string') {
- const index = k.indexOf('Locale');
- obj[k.slice(0, index)] = fn(obj[k]);
- }
- }
- return obj;
-}
+// export function findLocale<T>(obj: T, fn: Function) {
+// for (let k in obj) {
+// if (k.endsWith('Locale') && typeof obj[k] === 'string') {
+// const index = k.indexOf('Locale');
+// obj[k.slice(0, index)] = fn(obj[k]);
+// }
+// }
+// return obj;
+// }
// function findLocale(obj: any, locale: Locale) {
// for (let k in obj) {
diff --git a/packages/ui-plugin-sheets/src/Basics/SlideTabBar/Animate.ts b/packages/ui-plugin-sheets/src/Basics/SlideTabBar/Animate.ts
index 4b804c57c5..a5d0e4e8ba 100644
--- a/packages/ui-plugin-sheets/src/Basics/SlideTabBar/Animate.ts
+++ b/packages/ui-plugin-sheets/src/Basics/SlideTabBar/Animate.ts
@@ -1,4 +1,4 @@
-const Tween = {
+const Tween: Record<string, Function> = {
easeOutStrong(t: number, b: number, c: number, d: number): number {
return -c * ((t = t / d - 1) * t * t * t - 1) + b;
},
diff --git a/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx b/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx
index 234578fed4..cc6732e0a8 100644
--- a/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx
+++ b/packages/ui-plugin-sheets/src/View/FormulaBar/FormulaBar.tsx
@@ -1,7 +1,5 @@
import { BaseComponentProps, BaseComponentRender, BaseSelectChildrenProps, Component, debounce, Icon } from '@univerjs/base-ui';
import { Nullable } from '@univerjs/core';
-import { SHEET_UI_PLUGIN_NAME } from '../../Basics';
-import { SheetUIPlugin } from '../../SheetUIPlugin';
import styles from './index.module.less';
type FormulaState = {
@@ -71,7 +69,7 @@ export class FormulaBar extends Component<BaseFormulaBarProps, FormulaState> {
}
getIcon(name: string) {
- const componentManager = this.getContext().getPluginManager().getPluginByName<SheetUIPlugin>(SHEET_UI_PLUGIN_NAME)?.getComponentManager();
+ const componentManager = this.context.componentManager;
const Icon = componentManager?.get(name);
return <Icon />;
}
diff --git a/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts b/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts
index 5cde98fcfb..251c375534 100644
--- a/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts
+++ b/packages/ui-plugin-sheets/src/View/RichText/CellTextStyle.ts
@@ -52,7 +52,7 @@ export class CellTextStyle {
}
// TODO:指定单元格更新
- updateFormat(attr: string, foucsStatus: number | string) {
+ updateFormat(attr: keyof IStyleSetting, foucsStatus: number | string) {
if (attr in this.inlineStyleAffectAttribute) {
// TODO: 不要使用 $$
let value = this.editor.textContent!;
@@ -62,7 +62,7 @@ export class CellTextStyle {
}
}
- updateInlineStringFormat(attr: string, value: number | string) {
+ updateInlineStringFormat(attr: keyof IStyleSetting, value: number | string) {
let w = window.getSelection();
let range;
if (w?.type === 'None') {
@@ -208,7 +208,7 @@ export class CellTextStyle {
}
if (startSpanIndex < endSpanIndex) {
- for (let i = startSpanIndex + 1; i < endSpanIndex; i++) {
+ for (let i: number = startSpanIndex + 1; i < endSpanIndex; i++) {
// let span = spans.get(i),
let span = spans[`${i}`];
let content = span.innerHTML;
@@ -226,7 +226,7 @@ export class CellTextStyle {
cont += `<span style='${endSpan.style.cssText}'>${eright}</span>`;
}
- for (let i = endSpanIndex + 1; i < spans.length; i++) {
+ for (let i: number = endSpanIndex + 1; i < spans.length; i++) {
// let span = spans.get(i),
let span = spans[`${i}`];
let content = span.innerHTML;
@@ -238,8 +238,8 @@ export class CellTextStyle {
// console.log(replaceSpans, cont);
// replaceSpans.replaceWith(cont);
- let startSeletedNodeIndex;
- let endSeletedNodeIndex;
+ let startSeletedNodeIndex: number;
+ let endSeletedNodeIndex: number;
if (s1 === s2) {
startSeletedNodeIndex = startSpanIndex;
endSeletedNodeIndex = endSpanIndex;
@@ -263,7 +263,7 @@ export class CellTextStyle {
let coverArray = cover.split(';');
let newCss = '';
- let addKeyList = {};
+ let addKeyList: Record<string, string | number> = {};
for (let i = 0; i < originArray.length; i++) {
let so = originArray[i];
let isAdd = true;
@@ -323,9 +323,9 @@ export class CellTextStyle {
return newCss;
}
- getCssText(cssText: string, attr: string, value: string | number) {
+ getCssText(cssText: string, attr: keyof IStyleSetting, value: string | number) {
let styleObj: IStyleSetting = {};
- styleObj[attr] = value;
+ (styleObj[attr] as string | number) = value;
if (attr === 'un') {
let fontColor = this.getClassWithcss(cssText, 'color');
if (fontColor === '') {
@@ -433,7 +433,7 @@ export class CellTextStyle {
}
let style = '';
for (let key in cell) {
- let value = cell[key];
+ let value = cell[key as keyof IStyleSetting];
if (isCheck) {
value = this.checkstatusByCell(cell, key);
}
diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuSelect.tsx b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuSelect.tsx
index 1099f95332..708a29f8da 100644
--- a/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuSelect.tsx
+++ b/packages/ui-plugin-sheets/src/View/RightMenu/RightMenuSelect.tsx
@@ -1,25 +1,25 @@
-import { Component, Input } from '@univerjs/base-ui';
-import { CustomLabelOptions } from '../../Controller';
+// import { Component, Input } from '@univerjs/base-ui';
+// import { CustomLabelOptions } from '../../Controller';
-interface IProps {
- label: string;
- options: CustomLabelOptions[];
-}
+// interface IProps {
+// label: string;
+// options: CustomLabelOptions[];
+// }
-export class RightMenuSelect extends Component<IProps> {
- render() {
- const { label, options } = this.props;
+// export class RightMenuSelect extends Component<IProps> {
+// render() {
+// const { label, options } = this.props;
- return (
- <div>
- <div>{label}</div>
- <select>
- {options.map((item) => (
- <option>{item.label}</option>
- ))}
- </select>
- <Input type="number" placeholder="2"></Input>
- </div>
- );
- }
-}
+// return (
+// <div>
+// <div>{label}</div>
+// <select>
+// {options.map((item) => (
+// <option>{item.label}</option>
+// ))}
+// </select>
+// <Input type="number" placeholder="2"></Input>
+// </div>
+// );
+// }
+// }
diff --git a/packages/ui-plugin-sheets/src/View/RightMenu/index.ts b/packages/ui-plugin-sheets/src/View/RightMenu/index.ts
index 405d194f0f..caa1ab04bc 100644
--- a/packages/ui-plugin-sheets/src/View/RightMenu/index.ts
+++ b/packages/ui-plugin-sheets/src/View/RightMenu/index.ts
@@ -2,4 +2,4 @@ export * from './RightMenu';
export * from './RightMenuButton';
export * from './RightMenuInput';
export * from './RightMenuItem';
-export * from './RightMenuSelect';
+// export * from './RightMenuSelect';
diff --git a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx
index c1912832eb..1e8fa29198 100644
--- a/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx
+++ b/packages/ui-plugin-sheets/src/View/SheetBar/SheetBar.tsx
@@ -1,5 +1,5 @@
import { BaseMenuItem, BaseSheetBarProps, Button, Component, createRef, Icon, Menu, RefObject } from '@univerjs/base-ui';
-import { SheetBarMenu } from './SheetBarMenu';
+import { SheetBarMenu, SheetBarMenuItem } from './SheetBarMenu';
import styles from './index.module.less';
import { SlideTabBar } from '../../Basics/SlideTabBar/SlideTabBar';
@@ -166,7 +166,7 @@ export class SheetBar extends Component<BaseSheetBarProps, SheetState> {
</Button>
<Button className={styles.sheetBarOptionsButton} onClick={(e: MouseEvent) => this.ref.current.showMenu(true)} type="text">
<Icon.MenuIcon style={{ fontSize: '20px' }} />
- <SheetBarMenu onClick={selectSheet} menu={menuList} ref={this.ref}></SheetBarMenu>
+ <SheetBarMenu onClick={selectSheet} menu={menuList as SheetBarMenuItem[]} ref={this.ref}></SheetBarMenu>
</Button>
</div>