@univerjs/ui 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/cjs/index.js +14 -14
  2. package/lib/es/index.js +5762 -5704
  3. package/lib/index.css +1 -1
  4. package/lib/locale/en-US.json +61 -0
  5. package/lib/locale/ru-RU.json +61 -0
  6. package/lib/locale/zh-CN.json +61 -0
  7. package/lib/types/common/menu-merge-configs.d.ts +3 -0
  8. package/lib/types/components/editor/TextEditor.d.ts +1 -0
  9. package/lib/types/components/notification/Notification.d.ts +9 -5
  10. package/lib/types/components/progress-bar/ProgressBar.d.ts +4 -1
  11. package/lib/types/components/range-selector/RangeSelector.d.ts +1 -0
  12. package/lib/types/controllers/shared-shortcut.controller.d.ts +3 -1
  13. package/lib/types/controllers/shortcut-display/shortcut-panel.controller.d.ts +3 -1
  14. package/lib/types/controllers/ui/ui-desktop.controller.d.ts +7 -23
  15. package/lib/types/controllers/ui/ui.controller.d.ts +10 -15
  16. package/lib/types/index.d.ts +17 -5
  17. package/lib/types/services/confirm/desktop-confirm.service.d.ts +8 -2
  18. package/lib/types/services/dialog/desktop-dialog.service.d.ts +6 -1
  19. package/lib/types/services/dom/canvas-dom-layer.service.d.ts +31 -0
  20. package/lib/types/services/menu/menu.d.ts +8 -2
  21. package/lib/types/services/menu/menu.service.d.ts +8 -3
  22. package/lib/types/services/message/__testing__/mock-message.service.d.ts +2 -2
  23. package/lib/types/services/message/desktop-message.service.d.ts +4 -4
  24. package/lib/types/services/message/message.service.d.ts +2 -2
  25. package/lib/types/services/notification/desktop-notification.service.d.ts +10 -4
  26. package/lib/types/services/notification/notification.service.d.ts +2 -2
  27. package/lib/types/services/parts/parts.service.d.ts +30 -0
  28. package/lib/types/services/popup/canvas-popup.service.d.ts +9 -10
  29. package/lib/types/services/progress/progress.service.d.ts +5 -0
  30. package/lib/types/services/zen-zone/desktop-zen-zone.service.d.ts +2 -0
  31. package/lib/types/services/zen-zone/zen-zone.service.d.ts +1 -0
  32. package/lib/types/ui-plugin.d.ts +4 -7
  33. package/lib/types/views/App.d.ts +1 -6
  34. package/lib/types/views/components/context-menu/ContextMenu.d.ts +0 -2
  35. package/lib/types/views/components/doc-bars/Toolbar.d.ts +3 -2
  36. package/lib/types/views/components/doc-bars/hook.d.ts +44 -0
  37. package/lib/types/views/components/dom/FloatDom.d.ts +3 -0
  38. package/lib/types/views/parts.d.ts +1 -1
  39. package/lib/umd/index.js +14 -14
  40. package/package.json +15 -14
  41. package/lib/types/locale/index.d.ts +0 -18
  42. package/lib/types/views/components/popup/index.d.ts +0 -16
@@ -1,10 +1,10 @@
1
- import { IMessageMethodOptions, IMessageProps, Message } from '@univerjs/design';
1
+ import { IMessageOptions, IMessageProps, Message } from '@univerjs/design';
2
2
  import { IDisposable } from '@wendellhu/redi';
3
3
  import { IMessageService } from './message.service';
4
4
 
5
5
  export declare class DesktopMessageService implements IMessageService {
6
- portalContainer: HTMLElement;
7
- message?: Message;
6
+ protected _portalContainer: HTMLElement;
7
+ protected _message?: Message;
8
8
  setContainer(container: HTMLElement): void;
9
- show(options: IMessageMethodOptions & Omit<IMessageProps, 'key'>): IDisposable;
9
+ show(options: IMessageOptions & Omit<IMessageProps, 'key'>): IDisposable;
10
10
  }
@@ -1,8 +1,8 @@
1
- import { IMessageMethodOptions, IMessageProps } from '@univerjs/design';
1
+ import { IMessageOptions } from '@univerjs/design';
2
2
  import { IDisposable } from '@wendellhu/redi';
3
3
 
4
4
  export declare const IMessageService: import('@wendellhu/redi').IdentifierDecorator<IMessageService>;
5
5
  export interface IMessageService {
6
- show(options: IMessageMethodOptions & Omit<IMessageProps, 'key'>): IDisposable;
6
+ show(options: IMessageOptions): IDisposable;
7
7
  setContainer(container: HTMLElement): void;
8
8
  }
@@ -1,7 +1,13 @@
1
- import { IDisposable } from '@wendellhu/redi';
2
- import { INotificationMethodOptions } from '../../components/notification/Notification';
1
+ import { Disposable } from '@univerjs/core';
2
+ import { IDisposable, Injector } from '@wendellhu/redi';
3
+ import { INotificationOptions } from '../../components/notification/Notification';
4
+ import { IUIPartsService } from '../parts/parts.service';
3
5
  import { INotificationService } from './notification.service';
4
6
 
5
- export declare class DesktopNotificationService implements INotificationService {
6
- show(params: INotificationMethodOptions): IDisposable;
7
+ export declare class DesktopNotificationService extends Disposable implements INotificationService {
8
+ private readonly _injector;
9
+ private readonly _uiPartsService;
10
+ constructor(_injector: Injector, _uiPartsService: IUIPartsService);
11
+ show(params: INotificationOptions): IDisposable;
12
+ protected _initUIPart(): void;
7
13
  }
@@ -1,7 +1,7 @@
1
1
  import { IDisposable } from '@wendellhu/redi';
2
- import { INotificationMethodOptions } from '../../components/notification/Notification';
2
+ import { INotificationOptions } from '../../components/notification/Notification';
3
3
 
4
4
  export declare const INotificationService: import('@wendellhu/redi').IdentifierDecorator<INotificationService>;
5
5
  export interface INotificationService {
6
- show(params: INotificationMethodOptions): IDisposable;
6
+ show(params: INotificationOptions): IDisposable;
7
7
  }
@@ -0,0 +1,30 @@
1
+ import { IDisposable } from '@wendellhu/redi';
2
+ import { Observable } from 'rxjs';
3
+ import { Disposable } from '@univerjs/core';
4
+ import { ComponentType } from '../../common/component-manager';
5
+
6
+ type ComponentRenderer = () => ComponentType;
7
+ type ComponentPartKey = BuiltInUIPart | string;
8
+ export declare enum BuiltInUIPart {
9
+ GLOBAL = "global",
10
+ HEADER = "header",
11
+ HEADER_MENU = "header-menu",
12
+ CONTENT = "content",
13
+ FOOTER = "footer",
14
+ LEFT_SIDEBAR = "left-sidebar"
15
+ }
16
+ export interface IUIPartsService {
17
+ componentRegistered$: Observable<ComponentPartKey>;
18
+ registerComponent(part: ComponentPartKey, component: () => ComponentType): IDisposable;
19
+ getComponents(part: ComponentPartKey): Set<ComponentRenderer>;
20
+ }
21
+ export declare const IUIPartsService: import('@wendellhu/redi').IdentifierDecorator<IUIPartsService>;
22
+ export declare class UIPartsService extends Disposable implements IUIPartsService {
23
+ private _componentsByPart;
24
+ private readonly _componentRegistered$;
25
+ readonly componentRegistered$: Observable<string>;
26
+ dispose(): void;
27
+ registerComponent(part: ComponentPartKey, component: () => React.ComponentType): IDisposable;
28
+ getComponents(part: ComponentPartKey): Set<ComponentRenderer>;
29
+ }
30
+ export {};
@@ -1,16 +1,14 @@
1
+ import { Disposable } from '@univerjs/core';
2
+ import { IRectPopupProps } from '@univerjs/design';
1
3
  import { IBoundRectNoAngle } from '@univerjs/engine-render';
2
4
  import { Observable } from 'rxjs';
3
5
 
4
- export interface IPopup {
6
+ export interface IPopup extends Pick<IRectPopupProps, 'closeOnSelfTarget' | 'direction' | 'excludeOutside' | 'onClickOutside'> {
5
7
  anchorRect: IBoundRectNoAngle;
6
8
  anchorRect$: Observable<IBoundRectNoAngle>;
7
9
  componentKey: string;
8
- onClickOutside?: (e: MouseEvent) => void;
9
- closeOnSelfTarget?: boolean;
10
- excludeOutside?: HTMLElement[];
11
10
  unitId: string;
12
11
  subUnitId: string;
13
- direction?: 'vertical' | 'horizontal';
14
12
  offset?: [number, number];
15
13
  }
16
14
  export interface ICanvasPopupService {
@@ -21,12 +19,13 @@ export interface ICanvasPopupService {
21
19
  get popups(): [string, IPopup][];
22
20
  }
23
21
  export declare const ICanvasPopupService: import('@wendellhu/redi').IdentifierDecorator<ICanvasPopupService>;
24
- export declare class CanvasPopupService implements ICanvasPopupService {
25
- private _popupMap;
26
- private _popups$;
27
- popups$: Observable<[string, IPopup][]>;
22
+ export declare class CanvasPopupService extends Disposable implements ICanvasPopupService {
23
+ private readonly _popupMap;
24
+ private readonly _popups$;
25
+ readonly popups$: Observable<[string, IPopup][]>;
28
26
  get popups(): [string, IPopup][];
29
- private _notice;
27
+ private _update;
28
+ dispose(): void;
30
29
  addPopup(item: IPopup): string;
31
30
  removePopup(id: string): void;
32
31
  removeAll(): void;
@@ -29,6 +29,10 @@ export interface IProgressService {
29
29
  * Interrupt and hide the progress bar directly
30
30
  */
31
31
  stop(): void;
32
+ /**
33
+ * Get the total number of tasks
34
+ */
35
+ getTaskCount(): number;
32
36
  }
33
37
  export declare class ProgressService extends Disposable implements IProgressService, IDisposable {
34
38
  /**
@@ -44,6 +48,7 @@ export declare class ProgressService extends Disposable implements IProgressServ
44
48
  insertTaskCount(count: number): void;
45
49
  complete(): void;
46
50
  stop(): void;
51
+ getTaskCount(): number;
47
52
  private _clear;
48
53
  }
49
54
  export declare const IProgressService: import('@wendellhu/redi').IdentifierDecorator<IProgressService>;
@@ -8,6 +8,8 @@ export declare class DesktopZenZoneService implements IZenZoneService {
8
8
  private readonly _componentManager;
9
9
  readonly visible$: Subject<boolean>;
10
10
  readonly componentKey$: Subject<string>;
11
+ private _visible;
12
+ get visible(): boolean;
11
13
  constructor(_componentManager: ComponentManager);
12
14
  set(key: string, component: ForwardRefExoticComponent<any>): IDisposable;
13
15
  open(): void;
@@ -5,6 +5,7 @@ export declare const IZenZoneService: import('@wendellhu/redi').IdentifierDecora
5
5
  export interface IZenZoneService {
6
6
  readonly visible$: Subject<boolean>;
7
7
  readonly componentKey$: Subject<string>;
8
+ readonly visible: boolean;
8
9
  set(key: string, component: any): IDisposable;
9
10
  open(): void;
10
11
  close(): void;
@@ -1,12 +1,8 @@
1
- import { DependencyOverride, IContextService, LocaleService, Plugin } from '@univerjs/core';
1
+ import { IContextService, LocaleService, Plugin } from '@univerjs/core';
2
2
  import { Injector } from '@wendellhu/redi';
3
- import { IWorkbenchOptions } from './controllers/ui/ui.controller';
3
+ import { IUniverUIConfig } from './controllers/ui/ui.controller';
4
4
 
5
- export interface IUniverUIConfig extends IWorkbenchOptions {
6
- /** Disable auto focus when Univer bootstraps. */
7
- disableAutoFocus?: true;
8
- override?: DependencyOverride;
9
- }
5
+ export declare const DefaultUiConfig: {};
10
6
  export declare const DISABLE_AUTO_FOCUS_KEY = "DISABLE_AUTO_FOCUS";
11
7
  /**
12
8
  * UI plugin provides basic interaction with users. Including workbench (menus, UI parts, notifications etc.), copy paste, shortcut.
@@ -19,6 +15,7 @@ export declare class UniverUIPlugin extends Plugin {
19
15
  static pluginName: string;
20
16
  constructor(_config: Partial<IUniverUIConfig>, _contextService: IContextService, _injector: Injector, _localeService: LocaleService);
21
17
  onStarting(_injector: Injector): void;
18
+ onReady(): void;
22
19
  private _initDependencies;
23
20
  private _initUI;
24
21
  }
@@ -1,13 +1,8 @@
1
- import { ComponentType, default as React } from 'react';
1
+ import { default as React } from 'react';
2
2
  import { IWorkbenchOptions } from '../controllers/ui/ui.controller';
3
3
 
4
4
  export interface IUniverAppProps extends IWorkbenchOptions {
5
5
  mountContainer: HTMLElement;
6
- headerComponents?: Set<() => ComponentType>;
7
- contentComponents?: Set<() => ComponentType>;
8
- footerComponents?: Set<() => ComponentType>;
9
- headerMenuComponents?: Set<() => ComponentType>;
10
- leftSidebarComponents?: Set<() => ComponentType>;
11
6
  onRendered?: (container: HTMLElement) => void;
12
7
  }
13
8
  export declare function App(props: IUniverAppProps): React.JSX.Element;
@@ -1,5 +1,3 @@
1
1
  import { default as React } from 'react';
2
2
 
3
- export interface IProps {
4
- }
5
3
  export declare function ContextMenu(): React.JSX.Element;
@@ -1,8 +1,9 @@
1
1
  import { ComponentType, default as React } from 'react';
2
- import { MenuPosition } from '../../../services/menu/menu';
3
2
 
4
- export declare const positions: MenuPosition[];
5
3
  export interface IToolbarProps {
6
4
  headerMenuComponents?: Set<() => ComponentType>;
7
5
  }
6
+ /**
7
+ * Univer's built in toolbar component.
8
+ */
8
9
  export declare function Toolbar(props: IToolbarProps): React.JSX.Element;
@@ -0,0 +1,44 @@
1
+ import { IDisplayMenuItem, IMenuItem, MenuGroup, MenuPosition } from '../../../services/menu/menu';
2
+
3
+ type MenuPositionWithCustom = MenuPosition | string;
4
+ export interface IMenuGroup {
5
+ name: MenuPositionWithCustom;
6
+ menuItems: Array<IDisplayMenuItem<IMenuItem>>;
7
+ }
8
+ export interface IToolbarRenderHookHandler {
9
+ /** The activated category. */
10
+ category: MenuPositionWithCustom;
11
+ /** Update current activate category. */
12
+ setCategory: (position: MenuPositionWithCustom) => void;
13
+ visibleItems: IDisplayMenuItem<IMenuItem>[];
14
+ /** Menu grouped in this category. */
15
+ groups: IMenuGroup[];
16
+ groupsByKey: Record<MenuGroup, Array<IDisplayMenuItem<IMenuItem>>>;
17
+ }
18
+ /**
19
+ * If your custom toolbar component need to render menu items by their category,
20
+ * you can use this hook to get the toolbar status.
21
+ * @returns toolbar status
22
+ */
23
+ export declare function useToolbarGroups(categories: MenuPositionWithCustom[]): IToolbarRenderHookHandler;
24
+ export interface IToolbarItemStatus {
25
+ disabled: boolean;
26
+ value: any;
27
+ activated: boolean;
28
+ hidden: boolean;
29
+ }
30
+ /**
31
+ * Subscribe to a menu item's status change and return the latest status.
32
+ * @param menuItem The menu item
33
+ * @returns The menu item's status
34
+ */
35
+ export declare function useToolbarItemStatus(menuItem: IDisplayMenuItem<IMenuItem>): IToolbarItemStatus;
36
+ export declare function useToolbarCollapseObserver(visibleItems: IToolbarRenderHookHandler['visibleItems']): {
37
+ toolbarRef: import('react').RefObject<HTMLDivElement>;
38
+ toolbarItemRefs: import('react').MutableRefObject<Record<string, {
39
+ el: HTMLDivElement;
40
+ key: string;
41
+ }>>;
42
+ collapsedId: string[];
43
+ };
44
+ export {};
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+
3
+ export declare const FloatDom: () => React.JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import { ComponentType } from 'react';
2
2
 
3
- export declare const globalComponents: Set<() => ComponentType>;
3
+ export declare const builtInGlobalComponents: Set<() => ComponentType>;