@univerjs/ui 0.2.8 → 0.2.10

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.
@@ -17,8 +17,10 @@ export type ComponentType = React.ForwardRefExoticComponent<any> | ReturnType<ty
17
17
  export type ComponentList = Map<string, IVue3Component | IReactComponent>;
18
18
  export declare class ComponentManager {
19
19
  private _components;
20
+ private _componentsReverse;
20
21
  constructor();
21
22
  register(name: string, component: ComponentType, options?: IComponentOptions): IDisposable;
23
+ getKey(component: ComponentType): string | undefined;
22
24
  get(name: string): React.ForwardRefExoticComponent<any> | ((props: any) => React.FunctionComponentElement<{
23
25
  component: ReturnType<typeof defineComponent>;
24
26
  props: Record<string, any>;
@@ -1,4 +1,4 @@
1
- import { Disposable, IConfigService, Injector, LifecycleService } from '@univerjs/core';
1
+ import { Disposable, IConfigService, Injector, IUniverInstanceService, LifecycleService } from '@univerjs/core';
2
2
  import { IRenderManagerService } from '@univerjs/engine-render';
3
3
  import { ILayoutService } from '../../services/layout/layout.service';
4
4
  import { IUIPartsService } from '../../services/parts/parts.service';
@@ -6,12 +6,14 @@ import { IUniverUIConfig } from './ui.controller';
6
6
  export declare class DesktopUIController extends Disposable {
7
7
  private readonly _config;
8
8
  private readonly _renderManagerService;
9
+ private readonly _instanceSrv;
9
10
  private readonly _injector;
10
11
  private readonly _lifecycleService;
11
12
  private readonly _uiPartsService;
12
13
  private readonly _configService;
13
14
  private readonly _layoutService?;
14
- constructor(_config: IUniverUIConfig, _renderManagerService: IRenderManagerService, _injector: Injector, _lifecycleService: LifecycleService, _uiPartsService: IUIPartsService, _configService: IConfigService, _layoutService?: ILayoutService | undefined);
15
+ private _steadyTimeout;
16
+ constructor(_config: IUniverUIConfig, _renderManagerService: IRenderManagerService, _instanceSrv: IUniverInstanceService, _injector: Injector, _lifecycleService: LifecycleService, _uiPartsService: IUIPartsService, _configService: IConfigService, _layoutService?: ILayoutService | undefined);
15
17
  private _bootstrapWorkbench;
16
18
  private _initBuiltinComponents;
17
19
  }
@@ -59,7 +59,7 @@ export { IEditorService, EditorService, Editor } from './services/editor/editor.
59
59
  export { TextEditor } from './components/editor/TextEditor';
60
60
  export { RangeSelector } from './components/range-selector/RangeSelector';
61
61
  export { ProgressBar } from './components/progress-bar/ProgressBar';
62
- export { type IMenuGroup, useToolbarGroups, useToolbarItemStatus, useToolbarCollapseObserver } from './views/components/doc-bars/hook';
62
+ export { type IMenuGroup, useSimpleToolbarGroups, useToolbarGroups, useToolbarItemStatus, useToolbarCollapseObserver } from './views/components/doc-bars/hook';
63
63
  export { mergeMenuConfigs } from './common/menu-merge-configs';
64
64
  export { ShortcutPanelController } from './controllers/shortcut-display/shortcut-panel.controller';
65
65
  export { ShortcutPanelService } from './services/shortcut/shortcut-panel.service';
@@ -12,6 +12,7 @@ export declare class DesktopDialogService extends Disposable implements IDialogS
12
12
  dispose(): void;
13
13
  open(option: IDialogPartMethodOptions): IDisposable;
14
14
  close(id: string): void;
15
+ closeAll(expectIds?: string[]): void;
15
16
  getDialogs$(): import('rxjs').Observable<IDialogPartMethodOptions[]>;
16
17
  protected _initUIPart(): void;
17
18
  }
@@ -5,5 +5,10 @@ export declare const IDialogService: import('@univerjs/core').IdentifierDecorato
5
5
  export interface IDialogService {
6
6
  open(params: IDialogPartMethodOptions): IDisposable;
7
7
  close(id: string): void;
8
+ /**
9
+ * @description close all dialogs except the specified ones
10
+ * @param {string[]} [expectIds] The specified dialog ids
11
+ */
12
+ closeAll(expectIds?: string[]): void;
8
13
  getDialogs$(): Observable<IDialogPartMethodOptions[]>;
9
14
  }
@@ -19,6 +19,7 @@ export interface IFloatDom {
19
19
  onWheel: (evt: WheelEvent) => void;
20
20
  props?: Record<string, any>;
21
21
  data?: Serializable;
22
+ unitId: string;
22
23
  }
23
24
  export declare class CanvasFloatDomService {
24
25
  private _domLayerMap;
@@ -9,7 +9,8 @@ export declare enum MenuPosition {
9
9
  TOOLBAR_DATA = "uiToolbar.data",
10
10
  TOOLBAR_VIEW = "uiToolbar.view",
11
11
  TOOLBAR_OTHERS = "uiToolbar.others",
12
- CONTEXT_MENU = "contextMenu"
12
+ CONTEXT_MENU = "contextMenu",
13
+ FOOTER = "footer"
13
14
  }
14
15
  export declare enum MenuGroup {
15
16
  TOOLBAR_HISTORY = 0,
@@ -48,8 +49,10 @@ interface IMenuItemBase<V> {
48
49
  icon?: string | Observable<string>;
49
50
  tooltip?: string;
50
51
  /** The group that the item belongs to. */
52
+ /** @deprecated group will be removed in the future. */
51
53
  group?: MenuGroup;
52
54
  /** In what menu should the item display. */
55
+ /** @deprecated positions will be removed in the future. */
53
56
  positions: OneOrMany<MenuPosition | string>;
54
57
  type: MenuItemType;
55
58
  /**
@@ -92,6 +95,12 @@ export interface ICustomComponentProps<T> {
92
95
  }
93
96
  export interface IMenuSelectorItem<V = MenuItemDefaultValueType, T = undefined> extends IMenuItemBase<V> {
94
97
  type: MenuItemType.SELECTOR | MenuItemType.BUTTON_SELECTOR | MenuItemType.SUBITEMS;
98
+ /**
99
+ * If this property is set, changing the value of the selection will trigger the command with this id,
100
+ * instead of {@link IMenuItemBase.id} or {@link IMenuItemBase.commandId}. At the same title,
101
+ * clicking the button will trigger IMenuItemBase.id or IMenuItemBase.commandId.
102
+ */
103
+ selectionsCommandId?: string;
95
104
  /** Options or IDs of registered components. */
96
105
  selections?: Array<IValueOption<T>> | Observable<Array<IValueOption<T>>>;
97
106
  /** If `type` is `MenuItemType.BUTTON_SELECTOR`, this determines if the button is activated. */
@@ -3,30 +3,49 @@ import { Observable } from 'rxjs';
3
3
  import { IShortcutService } from '../shortcut/shortcut.service';
4
4
  import { IDisplayMenuItem, IMenuItem, MenuConfig, MenuPosition } from './menu';
5
5
  export declare const IMenuService: import('@univerjs/core').IdentifierDecorator<IMenuService>;
6
+ /**
7
+ * Breaking changes to IMenuService are expected in the next version. Use with caution. by @jikkai
8
+ */
6
9
  export interface IMenuService {
7
10
  menuChanged$: Observable<void>;
11
+ /** @deprecated */
8
12
  addMenuItem(item: IMenuItem, config: MenuConfig): IDisposable;
13
+ /** @deprecated */
9
14
  setMenuItem(item: IMenuItem): void;
10
15
  /** Get menu items for display at a given position or a submenu. */
16
+ /** @deprecated */
11
17
  getMenuItems(position: MenuPosition | string): Array<IDisplayMenuItem<IMenuItem>>;
18
+ /** @deprecated */
12
19
  getMenuItem(id: string): IMenuItem | null;
13
20
  }
14
21
  export declare class MenuService extends Disposable implements IMenuService {
15
22
  private readonly _shortcutService;
23
+ /** @deprecated */
16
24
  private readonly _menuItemMap;
25
+ /** @deprecated */
17
26
  private readonly _menuByPositions;
27
+ /** @deprecated */
18
28
  private readonly _menuConfigs;
19
29
  private _menuChanged$;
20
30
  menuChanged$: Observable<void>;
21
31
  constructor(_shortcutService: IShortcutService);
22
32
  dispose(): void;
33
+ /** @deprecated */
23
34
  addMenuItem(item: IMenuItem, config: MenuConfig): IDisposable;
35
+ /** @deprecated */
24
36
  getMenuItems(positions: MenuPosition | string): Array<IDisplayMenuItem<IMenuItem>>;
37
+ /** @deprecated */
25
38
  setMenuItem(item: IMenuItem): void;
39
+ /** @deprecated */
26
40
  getMenuItem(id: string): IMenuItem | null;
41
+ /** @deprecated */
27
42
  setMenuConfigs(id: string, config: MenuConfig): void;
43
+ /** @deprecated */
28
44
  getMenuConfig(id: string): MenuConfig | null;
45
+ /** @deprecated */
29
46
  private _getDisplayMenuItems;
47
+ /** @deprecated */
30
48
  private _appendMenuToPosition;
49
+ /** @deprecated */
31
50
  private _updateMenuItems;
32
51
  }
@@ -10,7 +10,8 @@ export declare enum BuiltInUIPart {
10
10
  CONTENT = "content",
11
11
  FOOTER = "footer",
12
12
  LEFT_SIDEBAR = "left-sidebar",
13
- FLOATING = "floating"
13
+ FLOATING = "floating",
14
+ UNIT = "unit"
14
15
  }
15
16
  export interface IUIPartsService {
16
17
  componentRegistered$: Observable<ComponentPartKey>;
@@ -1,9 +1,9 @@
1
- import { Disposable } from '@univerjs/core';
1
+ import { Nullable, Disposable } from '@univerjs/core';
2
2
  import { IRectPopupProps } from '@univerjs/design';
3
3
  import { IBoundRectNoAngle } from '@univerjs/engine-render';
4
4
  import { Observable } from 'rxjs';
5
5
  export interface IPopup extends Pick<IRectPopupProps, 'closeOnSelfTarget' | 'direction' | 'excludeOutside' | 'onClickOutside'> {
6
- anchorRect: IBoundRectNoAngle;
6
+ anchorRect: Nullable<IBoundRectNoAngle>;
7
7
  anchorRect$: Observable<IBoundRectNoAngle>;
8
8
  excludeRects?: IBoundRectNoAngle[];
9
9
  excludeRects$?: Observable<IBoundRectNoAngle[]>;
@@ -3,38 +3,100 @@ import { Observable } from 'rxjs';
3
3
  import { ILayoutService } from '../layout/layout.service';
4
4
  import { IPlatformService } from '../platform/platform.service';
5
5
  import { KeyCode } from './keycode';
6
+ /**
7
+ * A shortcut item that could be registered to the {@link IShortcutService}.
8
+ */
6
9
  export interface IShortcutItem<P extends object = object> {
7
- /** This should reuse the corresponding command's id. */
10
+ /** Id of the shortcut item. It should reuse the corresponding {@link ICommand}'s id. */
8
11
  id: string;
9
12
  /** Description of the shortcut. */
10
13
  description?: string;
11
14
  /** If two shortcuts have the same binding, the one with higher priority would be check first. */
12
15
  priority?: number;
13
- /** A callback that will be triggered to examine if the shortcut should be invoked. */
16
+ /**
17
+ * A callback that will be triggered to examine if the shortcut should be invoked. The `{@link IContextService}`
18
+ * would be passed to the callback.
19
+ */
14
20
  preconditions?: (contextService: IContextService) => boolean;
15
- /** A command can be bound to several bindings, with different static parameters perhaps. */
21
+ /**
22
+ * The binding of the shortcut. It should be a combination of {@link KeyCode} and {@link MetaKeys}.
23
+ *
24
+ * A command can be bound to several bindings, with different static parameters perhaps.
25
+ *
26
+ * @example { binding: KeyCode.ENTER | MetaKeys.ALT }
27
+ */
16
28
  binding: KeyCode | number;
29
+ /**
30
+ * The binding of the shortcut for macOS. If the property is not specified, the default binding would be used.
31
+ */
17
32
  mac?: number;
33
+ /**
34
+ * The binding of the shortcut for Windows. If the property is not specified, the default binding would be used.
35
+ */
18
36
  win?: number;
37
+ /**
38
+ * The binding of the shortcut for Linux. If the property is not specified, the default binding would be used.
39
+ */
19
40
  linux?: number;
20
41
  /**
21
42
  * The group of the menu item should belong to. The shortcut item would be rendered in the
22
43
  * panel if this is set.
44
+ *
45
+ * @example { group: '10_global-shortcut' }
23
46
  */
24
47
  group?: string;
25
- /** Static parameters of this shortcut. Would be send to `CommandService.executeCommand`. */
48
+ /**
49
+ * Static parameters of this shortcut. Would be send to {@link ICommandService.executeCommand} as the second
50
+ * parameter when the corresponding command is executed.
51
+ *
52
+ * You can define multi shortcuts with the same command id but different static parameters.
53
+ */
26
54
  staticParameters?: P;
27
55
  }
56
+ /**
57
+ * The dependency injection identifier of the {@link IShortcutService}.
58
+ */
59
+ export declare const IShortcutService: import('@univerjs/core').IdentifierDecorator<IShortcutService>;
60
+ /**
61
+ * The interface of the shortcut service.
62
+ */
28
63
  export interface IShortcutService {
64
+ /**
65
+ * An observable that emits when the shortcuts are changed.
66
+ */
29
67
  shortcutChanged$: Observable<void>;
68
+ /**
69
+ * Make the shortcut service ignore all keyboard events.
70
+ * @returns {IDisposable} a disposable that could be used to cancel the force escaping.
71
+ */
30
72
  forceEscape(): IDisposable;
73
+ /**
74
+ * Register a shortcut item to the shortcut service.
75
+ * @param {IShortcutItem} shortcut - the shortcut item to be registered.
76
+ * @returns {IDisposable} a disposable that could be used to unregister the shortcut.
77
+ */
31
78
  registerShortcut(shortcut: IShortcutItem): IDisposable;
79
+ /**
80
+ * Get the display string of the shortcut item.
81
+ * @param shortcut - the shortcut item to get the display string.
82
+ * @returns {string} the display string of the shortcut. For example `Ctrl+Enter`.
83
+ */
32
84
  getShortcutDisplay(shortcut: IShortcutItem): string;
85
+ /**
86
+ * Get the display string of the shortcut of the command.
87
+ * @param id the id of the command to get the shortcut display.
88
+ * @returns {string | null} the display string of the shortcut. For example `Ctrl+Enter`.
89
+ */
33
90
  getShortcutDisplayOfCommand(id: string): string | null;
91
+ /**
92
+ * Get all the shortcuts registered in the shortcut service.
93
+ * @returns {IShortcutItem[]} all the shortcuts registered in the shortcut service.
94
+ */
34
95
  getAllShortcuts(): IShortcutItem[];
35
- setDisable(disable: boolean): void;
36
96
  }
37
- export declare const IShortcutService: import('@univerjs/core').IdentifierDecorator<IShortcutService>;
97
+ /**
98
+ * @ignore
99
+ */
38
100
  export declare class ShortcutService extends Disposable implements IShortcutService {
39
101
  private readonly _commandService;
40
102
  private readonly _platformService;
@@ -45,9 +107,7 @@ export declare class ShortcutService extends Disposable implements IShortcutServ
45
107
  private readonly _shortcutChanged$;
46
108
  readonly shortcutChanged$: Observable<void>;
47
109
  private _forceEscaped;
48
- private _disable;
49
110
  constructor(_commandService: ICommandService, _platformService: IPlatformService, _contextService: IContextService, _layoutService?: ILayoutService | undefined);
50
- setDisable(disable: boolean): void;
51
111
  getAllShortcuts(): IShortcutItem[];
52
112
  registerShortcut(shortcut: IShortcutItem): IDisposable;
53
113
  getShortcutDisplayOfCommand(id: string): string | null;
@@ -14,6 +14,7 @@ export interface IToolbarRenderHookHandler {
14
14
  groups: IMenuGroup[];
15
15
  groupsByKey: Record<MenuGroup, Array<IDisplayMenuItem<IMenuItem>>>;
16
16
  }
17
+ export declare function useSimpleToolbarGroups(category: MenuPositionWithCustom): IDisplayMenuItem<IMenuItem>[];
17
18
  /**
18
19
  * If your custom toolbar component need to render menu items by their category,
19
20
  * you can use this hook to get the toolbar status.
@@ -1,2 +1,4 @@
1
1
  import { default as React } from 'react';
2
- export declare const FloatDom: () => React.JSX.Element;
2
+ export declare const FloatDom: ({ unitId }: {
3
+ unitId?: string;
4
+ }) => React.JSX.Element[] | undefined;
@@ -1,8 +1,10 @@
1
+ import { CSSProperties } from 'react';
1
2
  import { ICustomLabelProps } from '../../../components/custom-label/CustomLabel';
2
3
  export interface ISidebarMethodOptions {
3
4
  id?: string;
4
5
  header?: ICustomLabelProps;
5
6
  children?: ICustomLabelProps;
7
+ bodyStyle?: CSSProperties;
6
8
  footer?: ICustomLabelProps;
7
9
  visible?: boolean;
8
10
  width?: number | string;