@univerjs/ui 0.6.1 → 0.6.2

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 (53) hide show
  1. package/README.md +4 -0
  2. package/lib/cjs/facade.js +1 -1
  3. package/lib/cjs/index.js +46 -35
  4. package/lib/cjs/locale/en-US.js +1 -1
  5. package/lib/cjs/locale/fa-IR.js +1 -1
  6. package/lib/cjs/locale/fr-FR.js +1 -1
  7. package/lib/cjs/locale/ru-RU.js +1 -1
  8. package/lib/cjs/locale/vi-VN.js +1 -1
  9. package/lib/cjs/locale/zh-CN.js +1 -1
  10. package/lib/cjs/locale/zh-TW.js +1 -1
  11. package/lib/es/facade.js +176 -74
  12. package/lib/es/index.js +3902 -3618
  13. package/lib/es/locale/en-US.js +4 -1
  14. package/lib/es/locale/fa-IR.js +4 -1
  15. package/lib/es/locale/fr-FR.js +4 -1
  16. package/lib/es/locale/ru-RU.js +4 -1
  17. package/lib/es/locale/vi-VN.js +4 -1
  18. package/lib/es/locale/zh-CN.js +6 -3
  19. package/lib/es/locale/zh-TW.js +6 -3
  20. package/lib/index.css +1 -1
  21. package/lib/types/components/index.d.ts +1 -0
  22. package/lib/types/components/menu/desktop/Menu.d.ts +2 -0
  23. package/lib/types/components/slider/Slider.d.ts +47 -0
  24. package/lib/types/components/slider/Slider.stories.d.ts +7 -0
  25. package/lib/types/components/slider/index.d.ts +16 -0
  26. package/lib/types/controllers/ui/ui-desktop.controller.d.ts +5 -16
  27. package/lib/types/controllers/ui/ui-mobile.controller.d.ts +5 -13
  28. package/lib/types/controllers/ui/ui-shared.controller.d.ts +18 -0
  29. package/lib/types/facade/f-enum.d.ts +9 -1
  30. package/lib/types/facade/f-hooks.d.ts +4 -6
  31. package/lib/types/facade/f-menu-builder.d.ts +61 -2
  32. package/lib/types/facade/f-shortcut.d.ts +37 -2
  33. package/lib/types/facade/f-univer.d.ts +275 -38
  34. package/lib/types/index.d.ts +0 -1
  35. package/lib/types/locale/zh-CN.d.ts +3 -0
  36. package/lib/types/services/menu/menu.d.ts +4 -0
  37. package/lib/types/services/shortcut/shortcut.service.d.ts +4 -4
  38. package/lib/types/views/components/ribbon/Button/ToolbarButton.d.ts +15 -1
  39. package/lib/types/views/components/ribbon/ToolbarItem.d.ts +1 -5
  40. package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +16 -5
  41. package/lib/types/views/mobile-workbench/MobileWorkbench.d.ts +6 -0
  42. package/lib/umd/facade.js +1 -1
  43. package/lib/umd/index.js +46 -35
  44. package/lib/umd/locale/en-US.js +1 -1
  45. package/lib/umd/locale/fa-IR.js +1 -1
  46. package/lib/umd/locale/fr-FR.js +1 -1
  47. package/lib/umd/locale/ru-RU.js +1 -1
  48. package/lib/umd/locale/vi-VN.js +1 -1
  49. package/lib/umd/locale/zh-CN.js +1 -1
  50. package/lib/umd/locale/zh-TW.js +1 -1
  51. package/package.json +8 -9
  52. package/lib/types/views/MobileApp.d.ts +0 -6
  53. package/lib/types/views/parts.d.ts +0 -2
@@ -10,130 +10,367 @@ import { FShortcut } from './f-shortcut';
10
10
  export interface IFUniverUIMixin {
11
11
  /**
12
12
  * Return the URL of the current page.
13
- * @returns the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object
13
+ * @returns {URL} the [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object
14
+ * @example
15
+ * ```ts
16
+ * console.log(univerAPI.getURL());
17
+ * ```
14
18
  */
15
19
  getURL(): URL;
16
20
  /**
17
21
  * Get the Shortcut handler to interact with Univer's shortcut functionalities.
22
+ * @returns the {@link FShortcut} object
23
+ * @example
24
+ * ```ts
25
+ * const fShortcut = univerAPI.getShortcut();
26
+ *
27
+ * // Disable shortcuts of Univer
28
+ * fShortcut.disableShortcut();
29
+ *
30
+ * // Enable shortcuts of Univer
31
+ * fShortcut.enableShortcut();
32
+ *
33
+ * // Trigger a shortcut
34
+ * const fWorkbook = univerAPI.getActiveWorkbook();
35
+ * const fWorksheet = fWorkbook.getActiveSheet();
36
+ * const fRange = fWorksheet.getRange('A1');
37
+ * fRange.activate();
38
+ * fRange.setValue('Hello Univer');
39
+ * console.log(fRange.getCellStyle().bold); // false
40
+ * const pseudoEvent = new KeyboardEvent('keydown', {
41
+ * key: 'b',
42
+ * ctrlKey: true,
43
+ * keyCode: univerAPI.Enum.KeyCode.B
44
+ * });
45
+ * const ifShortcutItem = fShortcut.triggerShortcut(pseudoEvent);
46
+ * if (ifShortcutItem) {
47
+ * const commandId = ifShortcutItem.id;
48
+ * console.log(fRange.getCellStyle().bold); // true
49
+ * }
50
+ * ```
18
51
  */
19
52
  getShortcut(): FShortcut;
20
53
  /**
21
54
  * Copy the current selected content of the currently focused unit into your system clipboard.
55
+ * @returns {Promise<boolean>} whether the copy operation is successful
56
+ * @example
57
+ * ```ts
58
+ * // Prevent failure due to loss of focus when executing copy and paste code in the console,
59
+ * // this example listens for the cell click event and executes the copy and paste code.
60
+ * univerAPI.addEvent(univerAPI.Event.CellClicked, async (params) => {
61
+ * const fWorkbook = univerAPI.getActiveWorkbook();
62
+ * const fWorksheet = fWorkbook.getActiveSheet();
63
+ *
64
+ * // Copy the range A1:B2 to the clipboard
65
+ * const fRange = fWorksheet.getRange('A1:B2');
66
+ * fRange.activate().setValues([
67
+ * [1, 2],
68
+ * [3, 4]
69
+ * ]);
70
+ * await univerAPI.copy();
71
+ *
72
+ * // Paste the copied content to the range C1:D2
73
+ * const fRange2 = fWorksheet.getRange('C1');
74
+ * fRange2.activate();
75
+ * await univerAPI.paste();
76
+ *
77
+ * // Check the pasted content
78
+ * console.log(fWorksheet.getRange('C1:D2').getValues()); // [[1, 2], [3, 4]]
79
+ * });
80
+ * ```
22
81
  */
23
82
  copy(): Promise<boolean>;
24
83
  /**
25
84
  * Paste into the current selected position of the currently focused unit from your system clipboard.
85
+ * @returns {Promise<boolean>} whether the paste operation is successful
86
+ * @example
87
+ * ```ts
88
+ * // Prevent failure due to loss of focus when executing copy and paste code in the console,
89
+ * // this example listens for the cell click event and executes the copy and paste code.
90
+ * univerAPI.addEvent(univerAPI.Event.CellClicked, async (params) => {
91
+ * const fWorkbook = univerAPI.getActiveWorkbook();
92
+ * const fWorksheet = fWorkbook.getActiveSheet();
93
+ *
94
+ * // Copy the range A1:B2 to the clipboard
95
+ * const fRange = fWorksheet.getRange('A1:B2');
96
+ * fRange.activate().setValues([
97
+ * [1, 2],
98
+ * [3, 4]
99
+ * ]);
100
+ * await univerAPI.copy();
101
+ *
102
+ * // Paste the copied content to the range C1:D2
103
+ * const fRange2 = fWorksheet.getRange('C1');
104
+ * fRange2.activate();
105
+ * await univerAPI.paste();
106
+ *
107
+ * // Check the pasted content
108
+ * console.log(fWorksheet.getRange('C1:D2').getValues()); // [[1, 2], [3, 4]]
109
+ * });
110
+ * ```
26
111
  */
27
112
  paste(): Promise<boolean>;
28
113
  /**
29
114
  * Create a menu build object. You can insert new menus into the UI.
30
115
  * @param {IFacadeMenuItem} menuItem the menu item
116
+ * @returns the {@link FMenu} object
31
117
  * @example
32
118
  * ```ts
119
+ * // Univer Icon can be viewed at https://univer.ai/en-US/icons
120
+ * import { SmileSingle } from '@univerjs/icons'
121
+ *
122
+ * // Create a custom menu with an univer icon
123
+ * univerAPI.registerComponent('custom-menu-icon', SmileSingle);
33
124
  * univerAPI.createMenu({
34
125
  * id: 'custom-menu',
126
+ * icon: 'custom-menu-icon',
35
127
  * title: 'Custom Menu',
36
- * action: () => {},
128
+ * tooltip: 'Custom Menu Tooltip',
129
+ * action: () => {
130
+ * console.log('Custom Menu Clicked');
131
+ * },
132
+ * }).appendTo('ribbon.start.others');
133
+ *
134
+ * // Or
135
+ * // Create a custom menu with an image icon
136
+ * univerAPI.registerComponent('custom-menu-icon', () => {
137
+ * return <img src="https://avatars.githubusercontent.com/u/61444807?s=48&v=4" alt="" style={{ width: '16px', height: '16px' }} />;
138
+ * });
139
+ * univerAPI.createMenu({
140
+ * id: 'custom-menu',
141
+ * icon: 'custom-menu-icon',
142
+ * title: 'Custom Menu',
143
+ * tooltip: 'Custom Menu Tooltip',
144
+ * action: () => {
145
+ * console.log('Custom Menu Clicked');
146
+ * },
147
+ * }).appendTo('ribbon.start.others');
148
+ *
149
+ * // Or
150
+ * // Create a custom menu without an icon
151
+ * univerAPI.createMenu({
152
+ * id: 'custom-menu',
153
+ * title: 'Custom Menu',
154
+ * tooltip: 'Custom Menu Tooltip',
155
+ * action: () => {
156
+ * console.log('Custom Menu Clicked');
157
+ * },
37
158
  * }).appendTo('ribbon.start.others');
38
159
  * ```
39
- * @returns the {@link FMenu} object
40
160
  */
41
161
  createMenu(menuItem: IFacadeMenuItem): FMenu;
42
162
  /**
43
163
  * Create a menu that contains submenus, and later you can append this menu and its submenus to the UI.
44
- * @param submenuItem the submenu item
164
+ * @param {IFacadeSubmenuItem} submenuItem the submenu item
165
+ * @returns the {@link FSubmenu} object
45
166
  * @example
46
167
  * ```ts
168
+ * // Create two leaf menus.
169
+ * const menu1 = univerAPI.createMenu({
170
+ * id: 'submenu-nested-1',
171
+ * title: 'Item 1',
172
+ * action: () => {
173
+ * console.log('Item 1 clicked');
174
+ * }
175
+ * });
176
+ * const menu2 = univerAPI.createMenu({
177
+ * id: 'submenu-nested-2',
178
+ * title: 'Item 2',
179
+ * action: () => {
180
+ * console.log('Item 2 clicked');
181
+ * }
182
+ * });
183
+ *
184
+ * // Add the leaf menus to a submenu.
185
+ * const submenu = univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
186
+ * .addSubmenu(menu1)
187
+ * .addSeparator()
188
+ * .addSubmenu(menu2);
189
+ *
190
+ * // Create a root submenu append to the `contextMenu.others` section.
47
191
  * univerAPI.createSubmenu({ id: 'custom-submenu', title: 'Custom Submenu' })
48
- * .addSubmenu(univerAPI.createSubmenu({ id: 'submenu-nested', title: 'Nested Submenu' })
49
- * .addSubmenu(univerAPI.createMenu({ id: 'submenu-nested-1', title: 'Item 1', action: () => {} }))
50
- * .addSeparator()
51
- * .addSubmenu(univerAPI.createMenu({ id: 'submenu-nested-2', title: 'Item 2', action: () => {} }))
52
- * )
192
+ * .addSubmenu(submenu)
53
193
  * .appendTo('contextMenu.others');
54
194
  * ```
55
- * @returns the {@link FSubmenu} object
56
195
  */
57
196
  createSubmenu(submenuItem: IFacadeSubmenuItem): FSubmenu;
58
197
  /**
59
198
  * Open a sidebar.
60
- * @deprecated Please use `openSidebar` instead.
61
- * @param params the sidebar options
62
- * @returns the disposable object
199
+ * @deprecated Please use `univerAPI.openSidebar` instead.
200
+ * @param {ISidebarMethodOptions} params the sidebar options
201
+ * @returns {IDisposable} the disposable object
63
202
  */
64
203
  openSiderbar(params: ISidebarMethodOptions): IDisposable;
65
204
  /**
66
205
  * Open a sidebar.
67
- * @deprecated Please use `openSidebar` instead.
68
- * @param params the sidebar options
69
- * @returns the disposable object
206
+ * @param {ISidebarMethodOptions} params the sidebar options
207
+ * @returns {IDisposable} the disposable object
208
+ * @example
209
+ * ```ts
210
+ * univerAPI.openSidebar({
211
+ * id: 'mock-sidebar-id',
212
+ * width: 300,
213
+ * header: {
214
+ * label: 'Sidebar Header',
215
+ * },
216
+ * children: {
217
+ * label: 'Sidebar Content',
218
+ * },
219
+ * footer: {
220
+ * label: 'Sidebar Footer',
221
+ * },
222
+ * onClose: () => {
223
+ * console.log('Sidebar closed')
224
+ * },
225
+ * });
226
+ * ```
70
227
  */
71
228
  openSidebar(params: ISidebarMethodOptions): IDisposable;
72
229
  /**
73
230
  * Open a dialog.
74
- * @param dialog the dialog options
75
- * @returns the disposable object
231
+ * @param {IDialogPartMethodOptions} dialog the dialog options
232
+ * @returns {IDisposable} the disposable object
233
+ * @example
234
+ * ```ts
235
+ * import { Button } from '@univerjs/design';
236
+ *
237
+ * univerAPI.openDialog({
238
+ * id: 'mock-dialog-id',
239
+ * width: 500,
240
+ * title: {
241
+ * label: 'Dialog Title',
242
+ * },
243
+ * children: {
244
+ * label: 'Dialog Content',
245
+ * },
246
+ * footer: {
247
+ * title: (
248
+ * <>
249
+ * <Button onClick={() => { console.log('Cancel clicked') }}>Cancel</Button>
250
+ * <Button type="primary" onClick={() => { console.log('Confirm clicked') }} style={{marginLeft: '10px'}}>Confirm</Button>
251
+ * </>
252
+ * )
253
+ * },
254
+ * draggable: true,
255
+ * mask: true,
256
+ * maskClosable: true,
257
+ * });
258
+ * ```
76
259
  */
77
260
  openDialog(dialog: IDialogPartMethodOptions): IDisposable;
78
261
  /**
79
262
  * Get the component manager
80
- * @returns The component manager
263
+ * @returns {ComponentManager} The component manager
264
+ * @example
265
+ * ```ts
266
+ * const componentManager = univerAPI.getComponentManager();
267
+ * console.log(componentManager);
268
+ * ```
81
269
  */
82
270
  getComponentManager(): ComponentManager;
83
271
  /**
84
272
  * Show a message.
273
+ * @returns {FUniver} the {@link FUniver} instance for chaining
85
274
  * @example
86
275
  * ```ts
87
- * const message = univerAPI.showMessage({ key: 'my-message', content: 'Warning', duration: 0 });
88
- *
89
- * someAction().then(() => message.dispose());
276
+ * univerAPI.showMessage({
277
+ * content: 'Success',
278
+ * type: 'success',
279
+ * duration: 3000,
280
+ * });
90
281
  * ```
91
282
  */
92
- showMessage(options: IMessageProps): void;
283
+ showMessage(options: IMessageProps): FUniver;
93
284
  /**
94
285
  * Set the visibility of a built-in UI part.
95
- * @param key the built-in UI part
96
- * @param visible the visibility
97
- * @returns the {@link FUniver} object
286
+ * @param {BuiltInUIPart} key the built-in UI part
287
+ * @param {boolean} visible the visibility
288
+ * @returns the {@link FUniver} instance for chaining
98
289
  * example
99
290
  * ```ts
100
- * univerAPI.setUIVisible(BuiltInUIPart.HEADER, false);
291
+ * // Hide header, footer, and toolbar
292
+ * univerAPI.setUIVisible(univerAPI.Enum.BuiltInUIPart.HEADER, false)
293
+ * .setUIVisible(univerAPI.Enum.BuiltInUIPart.FOOTER, false)
294
+ * .setUIVisible(univerAPI.Enum.BuiltInUIPart.TOOLBAR, false);
295
+ *
296
+ * // Show in 3 seconds
297
+ * setTimeout(() => {
298
+ * univerAPI.setUIVisible(univerAPI.Enum.BuiltInUIPart.HEADER, true)
299
+ * .setUIVisible(univerAPI.Enum.BuiltInUIPart.FOOTER, true)
300
+ * .setUIVisible(univerAPI.Enum.BuiltInUIPart.TOOLBAR, true);
301
+ * }, 3000);
101
302
  * ```
102
303
  */
103
304
  setUIVisible(key: BuiltInUIPart, visible: boolean): FUniver;
104
305
  /**
105
306
  * Get the visibility of a built-in UI part.
106
- * @param key the built-in UI part
107
- * @returns the visibility
108
- * example
307
+ * @param {BuiltInUIPart} key the built-in UI part
308
+ * @returns {boolean} the visibility
309
+ * @example
109
310
  * ```ts
110
- * univerAPI.isUIVisible(BuiltInUIPart.HEADER);
311
+ * // Hide header
312
+ * univerAPI.setUIVisible(univerAPI.Enum.BuiltInUIPart.HEADER, false);
313
+ * console.log(univerAPI.isUIVisible(univerAPI.Enum.BuiltInUIPart.HEADER)); // false
111
314
  * ```
112
315
  */
113
316
  isUIVisible(key: BuiltInUIPart): boolean;
114
317
  /**
115
- * register an component to a built-in UI part
116
- * @param key the built-in UI part
318
+ * Register an component to a built-in UI part
319
+ * @param {BuiltInUIPart} key the built-in UI part
117
320
  * @param component the react component
118
321
  * @example
119
322
  * ```ts
120
- * univerAPI.registerUIPart(BuiltInUIPart.CUSTOM_HEADER, () => React.createElement('h1', null, 'Custom Header'));
323
+ * univerAPI.registerUIPart(univerAPI.Enum.BuiltInUIPart.CUSTOM_HEADER, () => React.createElement('h1', null, 'Custom Header'));
121
324
  * ```
122
325
  */
123
326
  registerUIPart(key: BuiltInUIPart, component: any): IDisposable;
124
327
  /**
125
- * register an component.
126
- * @param component
328
+ * Register an component.
329
+ * @param {string} name - The name of the component.
330
+ * @param {ComponentType} component - The component.
331
+ * @param {IComponentOptions} [options] - The options of the component.
332
+ * @returns {IDisposable} The disposable object.
127
333
  * @example
128
334
  * ```ts
129
- * univerAPI.registerComponent('my-comp', () => React.createElement('h1', null, 'Custom Header'));
335
+ * const fWorksheet = univerAPI.getActiveWorkbook().getActiveSheet();
336
+ *
337
+ * // Register a range loading component
338
+ * const RangeLoading = () => {
339
+ * const divStyle = {
340
+ * width: '100%',
341
+ * height: '100%',
342
+ * backgroundColor: '#fff',
343
+ * border: '1px solid #ccc',
344
+ * boxSizing: 'border-box' as const,
345
+ * display: 'flex',
346
+ * justifyContent: 'center',
347
+ * alignItems: 'center',
348
+ * textAlign: 'center' as const,
349
+ * transformOrigin: 'top left',
350
+ * };
351
+ *
352
+ * return (
353
+ * <div style={divStyle}>
354
+ * Loading...
355
+ * </div>
356
+ * );
357
+ * };
358
+ * univerAPI.registerComponent('RangeLoading', RangeLoading);
359
+ *
360
+ * // Add the range loading component covering the range A1:C3
361
+ * const range = fWorksheet.getRange('A1:C3');
362
+ * const disposeable = fWorksheet.addFloatDomToRange(range, { componentKey: 'RangeLoading' }, {}, 'myRangeLoading');
363
+ *
364
+ * setTimeout(() => {
365
+ * disposeable?.dispose();
366
+ * }, 2000);
130
367
  * ```
131
368
  */
132
369
  registerComponent(name: string, component: ComponentType, options?: IComponentOptions): IDisposable;
133
370
  /**
134
371
  * Set a unit as the current unit and render a unit in the workbench's main area. If you have multiple units in Univer,
135
372
  * you should call this method to render the unit.
136
- * @param unitId Unit to be rendered.
373
+ * @param {string} unitId Unit to be rendered.
137
374
  *
138
375
  * @example
139
376
  * Let's assume you have created two units, `unit1` and `unit2`. Univer is rendering `unit1` and you want to
@@ -73,7 +73,6 @@ export { UNIVER_UI_PLUGIN_NAME } from './ui-plugin';
73
73
  export * from './utils';
74
74
  export { ComponentContainer, type IComponentContainerProps, useComponentsOfPart } from './views/components/ComponentContainer';
75
75
  export { ZenZone } from './views/components/zen-zone/ZenZone';
76
- export { builtInGlobalComponents } from './views/parts';
77
76
  export { type IConfirmPartMethodOptions } from './views/components/confirm-part/interface';
78
77
  export { DesktopContextMenu as ContextMenu } from './views/components/context-menu/ContextMenu';
79
78
  export { MobileContextMenu } from './views/components/context-menu/MobileContextMenu';
@@ -73,5 +73,8 @@ declare const locale: {
73
73
  cancel: string;
74
74
  };
75
75
  'global-shortcut': string;
76
+ 'zoom-slider': {
77
+ resetTo: string;
78
+ };
76
79
  };
77
80
  export default locale;
@@ -24,6 +24,7 @@ interface IMenuItemBase<V> {
24
24
  description?: string;
25
25
  icon?: string | Observable<string>;
26
26
  tooltip?: string;
27
+ slot?: boolean;
27
28
  type: MenuItemType;
28
29
  /**
29
30
  * Custom label component id.
@@ -31,6 +32,7 @@ interface IMenuItemBase<V> {
31
32
  label?: string | {
32
33
  name: string;
33
34
  hoverable?: boolean;
35
+ selectable?: boolean;
34
36
  props?: Record<string, any>;
35
37
  };
36
38
  hidden$?: Observable<boolean>;
@@ -46,9 +48,11 @@ export interface IValueOption<T = undefined> {
46
48
  id?: string;
47
49
  value?: string | number;
48
50
  value$?: Observable<T>;
51
+ slot?: boolean;
49
52
  label?: string | {
50
53
  name: string;
51
54
  hoverable?: boolean;
55
+ selectable?: boolean;
52
56
  props?: Record<string, string | number | Array<{
53
57
  [x: string | number]: string;
54
58
  }>>;
@@ -25,7 +25,7 @@ export interface IShortcutItem<P extends object = object> {
25
25
  *
26
26
  * @example { binding: KeyCode.ENTER | MetaKeys.ALT }
27
27
  */
28
- binding: KeyCode | number;
28
+ binding?: KeyCode | number;
29
29
  /**
30
30
  * The binding of the shortcut for macOS. If the property is not specified, the default binding would be used.
31
31
  */
@@ -89,9 +89,9 @@ export interface IShortcutService {
89
89
  /**
90
90
  * Get the display string of the shortcut item.
91
91
  * @param shortcut - the shortcut item to get the display string.
92
- * @returns {string} the display string of the shortcut. For example `Ctrl+Enter`.
92
+ * @returns {string | null} The display string of the shortcut. For example `Ctrl+Enter`.
93
93
  */
94
- getShortcutDisplay(shortcut: IShortcutItem): string;
94
+ getShortcutDisplay(shortcut: IShortcutItem): string | null;
95
95
  /**
96
96
  * Get the display string of the shortcut of the command.
97
97
  * @param id the id of the command to get the shortcut display.
@@ -122,7 +122,7 @@ export declare class ShortcutService extends Disposable implements IShortcutServ
122
122
  getAllShortcuts(): IShortcutItem[];
123
123
  registerShortcut(shortcut: IShortcutItem): IDisposable;
124
124
  getShortcutDisplayOfCommand(id: string): string | null;
125
- getShortcutDisplay(shortcut: IShortcutItem): string;
125
+ getShortcutDisplay(shortcut: IShortcutItem): string | null;
126
126
  private _emitShortcutChanged;
127
127
  forceEscape(): IDisposable;
128
128
  forceDisable(): IDisposable;
@@ -1,4 +1,18 @@
1
- import { default as React } from 'react';
1
+ /**
2
+ * Copyright 2023-present DreamNum Co., Ltd.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
2
16
  export interface IBaseToolbarButtonProps {
3
17
  children?: React.ReactNode;
4
18
  /** Semantic DOM class */
@@ -1,7 +1,3 @@
1
- import { IDropdownLegacyProps } from '@univerjs/design';
2
1
  import { IDisplayMenuItem, IMenuItem } from '../../../services/menu/menu';
3
2
  import { ITooltipWrapperRef } from './TooltipButtonWrapper';
4
- import { default as React } from 'react';
5
- export declare const ToolbarItem: React.ForwardRefExoticComponent<(IDisplayMenuItem<IMenuItem> & {
6
- align?: IDropdownLegacyProps["align"];
7
- }) & React.RefAttributes<ITooltipWrapperRef>>;
3
+ export declare const ToolbarItem: import('react').ForwardRefExoticComponent<IDisplayMenuItem<IMenuItem> & import('react').RefAttributes<ITooltipWrapperRef>>;
@@ -1,10 +1,21 @@
1
- import { IDropdownOverlayProps, ITooltipProps } from '@univerjs/design';
2
- import { default as React } from 'react';
1
+ import { ITooltipProps } from '@univerjs/design';
2
+ import { ReactNode } from 'react';
3
+ import { IValueOption } from '../../../services/menu/menu';
3
4
  export interface ITooltipWrapperRef {
4
5
  el: HTMLSpanElement | null;
5
6
  }
6
- export declare const TooltipWrapper: React.ForwardRefExoticComponent<ITooltipProps & React.RefAttributes<ITooltipWrapperRef>>;
7
- export declare function DropdownWrapper({ children, overlay, disabled, offset }: IDropdownOverlayProps & {
8
- overlay: React.ReactNode;
7
+ export declare const TooltipWrapper: import('react').ForwardRefExoticComponent<ITooltipProps & import('react').RefAttributes<ITooltipWrapperRef>>;
8
+ export declare function DropdownWrapper({ children, overlay, disabled }: {
9
+ children: ReactNode;
10
+ overlay: ReactNode;
9
11
  disabled?: boolean;
10
12
  }): import("react/jsx-runtime").JSX.Element;
13
+ export declare function DropdownMenuWrapper({ menuId, slot, value, options, children, disabled, onOptionSelect, }: {
14
+ menuId: string;
15
+ slot?: boolean;
16
+ value?: string | number;
17
+ options: IValueOption[];
18
+ children: ReactNode;
19
+ disabled?: boolean;
20
+ onOptionSelect: (option: IValueOption) => void;
21
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { IWorkbenchOptions } from '../../controllers/ui/ui.controller';
2
+ export interface IUniverAppProps extends IWorkbenchOptions {
3
+ mountContainer: HTMLElement;
4
+ onRendered?: (container: HTMLElement) => void;
5
+ }
6
+ export declare function MobileWorkbench(props: IUniverAppProps): import("react/jsx-runtime").JSX.Element;
package/lib/umd/facade.js CHANGED
@@ -1 +1 @@
1
- (function(i,a){typeof exports=="object"&&typeof module<"u"?a(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["@univerjs/core/facade","@univerjs/engine-render","@univerjs/ui","@univerjs/core"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.UniverCoreFacade,i.UniverEngineRender,i.UniverUi,i.UniverCore))})(this,function(i,a,r,d){"use strict";var x=Object.defineProperty;var F=(i,a,r)=>a in i?x(i,a,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[a]=r;var u=(i,a,r)=>F(i,typeof a!="symbol"?a+"":a,r);var S;var f=Object.getOwnPropertyDescriptor,_=(c,e,t,n)=>{for(var s=n>1?void 0:n?f(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},h=(c,e)=>(t,n)=>e(t,n,c);class b extends i.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,s={};let o=s;const m=this.__getSchema();t.forEach((l,U)=>{U===n-1?o[l]=m:o[l]={},o=o[l]}),this._menuManagerService.mergeMenu(s)}}let v=(S=class extends b{constructor(e,t,n,s){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=s;const o=typeof e.action=="string"?e.action:d.Tools.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:d.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(S,"RibbonStartGroup",r.RibbonStartGroup),u(S,"RibbonPosition",r.RibbonPosition),u(S,"MenuManagerPosition",r.MenuManagerPosition),S);v=_([h(1,d.Inject(d.Injector)),h(2,d.ICommandService),h(3,r.IMenuManagerService)],v);let g=class extends b{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const s={};t.forEach(o=>{Object.assign(s,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=s}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};g=_([h(1,d.Inject(d.Injector)),h(2,r.IMenuManagerService)],g);var j=Object.getOwnPropertyDescriptor,C=(c,e,t,n)=>{for(var s=n>1?void 0:n?j(e,t):e,o=c.length-1,m;o>=0;o--)(m=c[o])&&(s=m(s)||s);return s},I=(c,e)=>(t,n)=>e(t,n,c);let p=class extends i.FBase{constructor(e,t){super();u(this,"_forceDisableDisposable",null);this._injector=e,this._shortcutService=t}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};p=C([I(0,d.Inject(d.Injector)),I(1,r.IShortcutService)],p);class M extends i.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(p)}copy(){return this._commandService.syncExecuteCommand(r.CopyCommand.id)}paste(){return this._commandService.syncExecuteCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(v,e)}createSubmenu(e){return this._injector.createInstance(g,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const s=this._injector.get(r.ComponentManager);return this.disposeWithMe(s.register(e,t,n))}setCurrent(e){if(!this._injector.get(a.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}i.FUniver.extend(M);class y extends i.FHooks{onBeforeCopy(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(d.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(d.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}i.FHooks.extend(y);class P extends i.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}}i.FEnum.extend(P)});
1
+ (function(s,d){typeof exports=="object"&&typeof module<"u"?d(require("@univerjs/core/facade"),require("@univerjs/engine-render"),require("@univerjs/ui"),require("@univerjs/core")):typeof define=="function"&&define.amd?define(["@univerjs/core/facade","@univerjs/engine-render","@univerjs/ui","@univerjs/core"],d):(s=typeof globalThis<"u"?globalThis:s||self,d(s.UniverCoreFacade,s.UniverEngineRender,s.UniverUi,s.UniverCore))})(this,function(s,d,r,c){"use strict";var E=Object.defineProperty;var F=(s,d,r)=>d in s?E(s,d,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[d]=r;var u=(s,d,r)=>F(s,typeof d!="symbol"?d+"":d,r);var v;var f=Object.getOwnPropertyDescriptor,I=(a,e,t,n)=>{for(var i=n>1?void 0:n?f(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},m=(a,e)=>(t,n)=>e(t,n,a);class b extends s.FBase{appendTo(e){const t=typeof e=="string"?e.split("|"):e,n=t.length,i={};let o=i;const h=this.__getSchema();t.forEach((l,P)=>{P===n-1?o[l]=h:o[l]={},o=o[l]}),this._menuManagerService.mergeMenu(i)}}let g=(v=class extends b{constructor(e,t,n,i){super();u(this,"_commandToRegister",new Map);u(this,"_buildingSchema");this._item=e,this._injector=t,this._commandService=n,this._menuManagerService=i;const o=typeof e.action=="string"?e.action:c.Tools.generateRandomId(12);o!==e.action&&this._commandToRegister.set(o,e.action),this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.BUTTON,icon:e.icon,title:e.title,tooltip:e.tooltip,commandId:o})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}__getSchema(){return this._commandToRegister.forEach((e,t)=>{this._commandService.hasCommand(t)||this._commandService.registerCommand({id:t,type:c.CommandType.COMMAND,handler:e})}),{[this._item.id]:this._buildingSchema}}},u(v,"RibbonStartGroup",r.RibbonStartGroup),u(v,"RibbonPosition",r.RibbonPosition),u(v,"MenuManagerPosition",r.MenuManagerPosition),v);g=I([m(1,c.Inject(c.Injector)),m(2,c.ICommandService),m(3,r.IMenuManagerService)],g);let p=class extends b{constructor(e,t,n){super();u(this,"_menuByGroups",[]);u(this,"_submenus",[]);u(this,"_buildingSchema");this._item=e,this._injector=t,this._menuManagerService=n,this._buildingSchema={menuItemFactory:()=>({id:e.id,type:r.MenuItemType.SUBITEMS,icon:e.icon,title:e.title,tooltip:e.tooltip})},typeof e.order<"u"&&(this._buildingSchema.order=e.order)}addSubmenu(e){return this._submenus.push(e),this}addSeparator(){return this._menuByGroups.push(this._submenus),this._submenus=[],this}__getSchema(){const e={};return this.addSeparator(),this._menuByGroups.forEach((t,n)=>{const i={};t.forEach(o=>{Object.assign(i,o.__getSchema())}),e[`${this._item.id}-group-${n}`]=i}),{[this._item.id]:Object.assign(this._buildingSchema,e)}}};p=I([m(1,c.Inject(c.Injector)),m(2,r.IMenuManagerService)],p);var C=Object.getOwnPropertyDescriptor,j=(a,e,t,n)=>{for(var i=n>1?void 0:n?C(e,t):e,o=a.length-1,h;o>=0;o--)(h=a[o])&&(i=h(i)||i);return i},S=(a,e)=>(t,n)=>e(t,n,a);let _=class extends s.FBase{constructor(e,t,n,i){super();u(this,"_forceDisableDisposable",null);this._injector=e,this._renderManagerService=t,this._univerInstanceService=n,this._shortcutService=i}enableShortcut(){var e;return(e=this._forceDisableDisposable)==null||e.dispose(),this._forceDisableDisposable=null,this}disableShortcut(){return this._forceDisableDisposable||(this._forceDisableDisposable=this._shortcutService.forceDisable()),this}triggerShortcut(e){const t=this._univerInstanceService.getCurrentUnitForType(c.UniverInstanceType.UNIVER_SHEET);if(!t)return;const n=this._renderManagerService.getRenderById(t.getUnitId());return n?(n.engine.getCanvasElement().dispatchEvent(e),this._shortcutService.dispatch(e)):void 0}dispatchShortcutEvent(e){return this._shortcutService.dispatch(e)}};_=j([S(0,c.Inject(c.Injector)),S(1,c.Inject(d.IRenderManagerService)),S(2,c.IUniverInstanceService),S(3,r.IShortcutService)],_);class M extends s.FUniver{getURL(){return new URL(window.location.href)}getShortcut(){return this._injector.createInstance(_)}copy(){return this._commandService.executeCommand(r.CopyCommand.id)}paste(){return this._commandService.executeCommand(r.PasteCommand.id)}createMenu(e){return this._injector.createInstance(g,e)}createSubmenu(e){return this._injector.createInstance(p,e)}openSiderbar(e){return this._injector.get(r.ISidebarService).open(e)}openSidebar(e){return this.openSiderbar(e)}openDialog(e){const n=this._injector.get(r.IDialogService).open({...e,onClose:()=>{n.dispose()}});return n}getComponentManager(){return this._injector.get(r.ComponentManager)}showMessage(e){return this._injector.get(r.IMessageService).show(e),this}setUIVisible(e,t){return this._injector.get(r.IUIPartsService).setUIVisible(e,t),this}isUIVisible(e){return this._injector.get(r.IUIPartsService).isUIVisible(e)}registerUIPart(e,t){return this._injector.get(r.IUIPartsService).registerComponent(e,()=>r.connectInjector(t,this._injector))}registerComponent(e,t,n){const i=this._injector.get(r.ComponentManager);return this.disposeWithMe(i.register(e,t,n))}setCurrent(e){if(!this._injector.get(d.IRenderManagerService).getRenderById(e))throw new Error("Unit not found");this._univerInstanceService.setCurrentUnitForType(e)}}s.FUniver.extend(M);class U extends s.FHooks{onBeforeCopy(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onCopy(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{n.id===r.CopyCommand.id&&e()})}onBeforePaste(e){return this._injector.get(c.ICommandService).beforeCommandExecuted(n=>{n.id===r.PasteCommand.id&&e()})}onPaste(e){return this._injector.get(c.ICommandService).onCommandExecuted(n=>{(n.id===r.PasteCommand.id||n.id===r.SheetPasteShortKeyCommandName)&&e()})}}s.FHooks.extend(U);class y extends s.FEnum{get BuiltInUIPart(){return r.BuiltInUIPart}get KeyCode(){return r.KeyCode}}s.FEnum.extend(y)});