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(ui): removed `Prompt` component (#141)

白熱9cd108b94f9e
diff --git a/packages/base-ui/src/Components/Prompt/Prompt.stories.tsx b/packages/base-ui/src/Components/Prompt/Prompt.stories.tsx
deleted file mode 100644
index ab737b6a37..0000000000
--- a/packages/base-ui/src/Components/Prompt/Prompt.stories.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { Prompt } from './Prompt';
-
-// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
-export default {
- title: 'Components/Prompt',
- component: Prompt,
- parameters: {
- layout: 'centered',
- },
- tags: ['autodocs'],
- args: {
- title: 'test',
- content: 'test prompt',
- },
-};
-
-// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
-export const Playground = {
- args: {},
-};
diff --git a/packages/base-ui/src/Components/Prompt/Prompt.tsx b/packages/base-ui/src/Components/Prompt/Prompt.tsx
deleted file mode 100644
index 218b66fa7d..0000000000
--- a/packages/base-ui/src/Components/Prompt/Prompt.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import React, { useEffect, useState } from 'react';
-
-import { CustomLabel } from '../CustomLabel';
-import { Modal, ModalButtonGroup } from '../Modal';
-import styles from './index.module.less';
-
-// interface BaseConfirmProps {
-// title: string;
-// content: string;
-// onClick?: () => void;
-// show?: boolean;
-// }
-
-// interface IState {
-// show: boolean;
-// }
-
-// export class Prompt extends Component<BaseConfirmProps, IState> {
-// constructor(props: BaseConfirmProps) {
-// super();
-// this.state = {
-// show: props.show ?? false,
-// };
-// }
-
-// showModal(show: boolean) {
-// this.setState({
-// show,
-// });
-// }
-
-// handleClick() {
-// const { onClick } = this.props;
-// onClick?.();
-// this.showModal(false);
-// }
-
-// getGroup() {
-// const group = [
-// {
-// label: 'button.confirm',
-// type: 'primary',
-// onClick: () => this.handleClick(),
-// },
-// {
-// label: 'button.cancel',
-// onClick: () => this.showModal(false),
-// },
-// ];
-// return group;
-// }
-
-// UNSAFE_componentWillReceiveProps(props: BaseConfirmProps): void {
-// if (props.show !== this.props.show) {
-// this.setState({
-// show: props.show,
-// });
-// }
-// }
-
-// render() {
-// const { title, content } = this.props;
-// const { show } = this.state;
-// return (
-// <div className={styles.confirmModal}>
-// <Modal visible={show} isDrag={true} title={<CustomLabel label={title} />} group={this.getGroup()}>
-// <CustomLabel label={content} />
-// </Modal>
-// </div>
-// );
-// }
-// }
-
-interface BaseConfirmProps {
- title: string;
- content: string;
- onClick?: () => void;
- show?: boolean;
-}
-
-export function Prompt(props: BaseConfirmProps) {
- const [show, setShow] = useState<boolean>(props.show ?? false);
-
- const showModal = (show: boolean) => {
- setShow(show);
- };
-
- const handleClick = () => {
- const { onClick } = props;
- onClick?.();
- setShow(false);
- };
-
- const getGroup: ModalButtonGroup[] = [
- {
- label: 'button.confirm',
- type: 'primary',
- onClick: () => handleClick(),
- },
- {
- type: 'default',
- label: 'button.cancel',
- onClick: () => showModal(false),
- },
- ];
-
- useEffect(() => {
- if (props.show !== show) {
- setShow(props.show ?? false);
- }
- }, [props.show]);
-
- const { title, content } = props;
-
- return (
- <div className={styles.confirmModal}>
- <Modal visible={show} isDrag={true} title={<CustomLabel label={title} />} group={getGroup}>
- <CustomLabel label={content} />
- </Modal>
- </div>
- );
-}
diff --git a/packages/base-ui/src/Components/Prompt/index.module.less b/packages/base-ui/src/Components/Prompt/index.module.less
deleted file mode 100644
index cf4347d7e9..0000000000
--- a/packages/base-ui/src/Components/Prompt/index.module.less
+++ /dev/null
@@ -1,27 +0,0 @@
-@import '../../Basics/CSS/Skin/base.module.less';
-
-.confirm-modal {
- .modal-mask {
- background-color: rgba(255, 255, 255, 0.6);
- }
-
- .modal-header {
- position: relative;
- }
-
- .modal-close {
- position: absolute;
- right: 1.5rem;
- top: 0
- }
-
- .drag {
- box-shadow: 0 4px 16px rgb(0 0 0 / 20%);
- background-clip: padding-box;
- border: 1px solid rgba(0, 0, 0, .333)
- }
-
- .modal-body {
- color: rgba(0, 0, 0, 0.6);
- }
-}
\ No newline at end of file
diff --git a/packages/base-ui/src/Components/Prompt/index.ts b/packages/base-ui/src/Components/Prompt/index.ts
deleted file mode 100644
index 1987f18263..0000000000
--- a/packages/base-ui/src/Components/Prompt/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from './Prompt';
diff --git a/packages/base-ui/src/Components/index.ts b/packages/base-ui/src/Components/index.ts
index bfa7befce7..a993d6b0c2 100644
--- a/packages/base-ui/src/Components/index.ts
+++ b/packages/base-ui/src/Components/index.ts
@@ -16,7 +16,6 @@ export * from './Item/Item';
export * from './Layout';
export * from './Menu';
export * from './Modal';
-export * from './Prompt';
export * from './Radio';
export * from './ResizeDialog';
export * from './Select';
diff --git a/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx b/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx
index 351eee652c..2e01d85485 100644
--- a/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx
+++ b/packages/ui-plugin-docs/src/View/DocContainer/DocContainer.tsx
@@ -215,7 +215,6 @@ export class DocContainer extends Component<BaseDocContainerProps> {
</Container>
)}
<Container onContextMenu={(e) => e.preventDefault()} ref={this.contentRef} className={style.contentInnerRightContainer}></Container>
- {/* <Prompt show={true} title="123" content="235" /> */}
{/* extend main content */}
</Content>
diff --git a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
index 82315ba8bc..b9475c5924 100644
--- a/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
+++ b/packages/ui-plugin-sheets/src/Controller/SheetContainerUIController.ts
@@ -1,4 +1,4 @@
-import { ComponentManager, DragManager, Prompt, SlotManager } from '@univerjs/base-ui';
+import { ComponentManager, DragManager, SlotManager } from '@univerjs/base-ui';
import { LocaleService, LocaleType, ObserverManager } from '@univerjs/core';
import { Inject, Injector, Self, SkipSelf } from '@wendellhu/redi';
@@ -59,16 +59,6 @@ export class SheetContainerUIController {
this._countBarController = this._injector.createInstance(CountBarUIController);
this._sheetBarController = this._injector.createInstance(SheetBarUIController);
this._injector.add([SheetBarUIController, { useFactory: () => this._sheetBarController }]);
- // this._dragManager = this._injector.createInstance(DragManager);
-
- // 插入prompt组件
- this._componentManager.register(Prompt.name, Prompt);
- this._slotManager.setSlotComponent('main', {
- name: Prompt.name,
- component: {
- name: Prompt.name,
- },
- });
}
getUIConfig() {
diff --git a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
index 256f7a1ae2..99407892bb 100644
--- a/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
+++ b/packages/ui-plugin-sheets/src/View/SheetContainer/SheetContainer.tsx
@@ -225,7 +225,6 @@ export class SheetContainer extends Component<BaseSheetContainerProps> {
{config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>}
{<RichText {...methods.cellEditor}></RichText>}
</Container>
- {/* <Prompt show={true} title="123" content="235" /> */}
{/* extend main content */}
<Slot name="main" {...methods.slot}></Slot>
</Content>
diff --git a/packages/ui-plugin-sheets/src/View/index.tsx b/packages/ui-plugin-sheets/src/View/index.tsx
index e155757ed3..77e98dc1e5 100644
--- a/packages/ui-plugin-sheets/src/View/index.tsx
+++ b/packages/ui-plugin-sheets/src/View/index.tsx
@@ -1,5 +1,6 @@
import { isElement } from '@univerjs/base-ui';
import { createRoot } from 'react-dom/client';
+
import { App, BaseUIProps } from './App';
interface BaseSheetUIConfig extends BaseUIProps {
@@ -39,9 +40,8 @@ export class UI {
}
}
+export * from './Common';
+export * from './InfoBar';
+export * from './RightMenu';
export * from './SheetContainer';
export * from './Toolbar';
-export * from './RightMenu';
-export * from './InfoBar';
-export * from './Common';
-export * from './Slot/Slot';
diff --git a/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx b/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx
index a5f70df6d6..1059aa057e 100644
--- a/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx
+++ b/packages/ui-plugin-slides/src/View/SlideContainer/SlideContainer.tsx
@@ -1,13 +1,14 @@
import { BaseComponentProps, Container, Content, Footer, Header, Layout, Sider } from '@univerjs/base-ui';
-import { Component, createRef } from 'react';
import defaultSkin from '@univerjs/base-ui/Basics/CSS/Skin/default.module.less';
import { Tools } from '@univerjs/core';
import cssVars from 'css-vars-ponyfill';
-import style from './index.module.less';
-import { InfoBar } from '../InfoBar';
+import { Component, createRef } from 'react';
+
import { ISlideUIPluginConfig } from '../../Basics';
-import { Toolbar } from '../Toolbar';
+import { InfoBar } from '../InfoBar';
import { SlideBar } from '../SlideBar/SlideBar';
+import { Toolbar } from '../Toolbar';
+import style from './index.module.less';
export interface BaseSlideContainerProps extends BaseComponentProps {
config: ISlideUIPluginConfig;
@@ -216,7 +217,6 @@ export class SlideContainer extends Component<BaseSlideContainerProps> {
<SlideBar {...methods.slideBar}></SlideBar>
</Sider>
<Content className={config.contentSplit === 'vertical' ? style.contentContainerVertical : style.contentContainerHorizontal}>
- {/* <Slot {...methods.slot}></Slot> */}
{!!config.contentSplit && (
<Container ref={this.splitLeftRef} className={style.contentInnerLeftContainer}>
<div className={style.hoverCursor} onMouseDown={this.handleSplitBarMouseDown}></div>
@@ -225,7 +225,6 @@ export class SlideContainer extends Component<BaseSlideContainerProps> {
<Container onContextMenu={(e) => e.preventDefault()} ref={this.contentRef} className={style.contentInnerRightContainer}>
{/* {config.rightMenu && <RightMenu {...methods.rightMenu}></RightMenu>} */}
</Container>
- {/* <Prompt show={true} title="123" content="235" /> */}
{/* extend main content */}
</Content>