@univerjs/ui 0.5.5 → 0.6.0-alpha.0
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.
- package/lib/cjs/facade.js +1 -1
- package/lib/cjs/index.js +24 -32
- package/lib/es/facade.js +122 -80
- package/lib/es/index.js +4098 -4643
- package/lib/types/components/custom-label/CustomLabel.d.ts +2 -2
- package/lib/types/components/font-family/FontFamily.d.ts +1 -2
- package/lib/types/components/font-family/FontFamilyItem.d.ts +1 -2
- package/lib/types/components/font-size/FontSize.d.ts +1 -2
- package/lib/types/components/menu/desktop/Menu.d.ts +1 -2
- package/lib/types/components/menu/mobile/MobileMenu.d.ts +1 -2
- package/lib/types/components/menu/mobile/MobileMenu.stories.d.ts +1 -2
- package/lib/types/components/notification/Notification.d.ts +2 -3
- package/lib/types/components/notification/Notification.stories.d.ts +1 -2
- package/lib/types/components/progress-bar/ProgressBar.d.ts +16 -2
- package/lib/types/facade/f-enum.d.ts +6 -0
- package/lib/types/facade/f-hooks.d.ts +6 -0
- package/lib/types/facade/f-menu-builder.d.ts +67 -18
- package/lib/types/facade/f-shortcut.d.ts +30 -2
- package/lib/types/facade/f-univer.d.ts +7 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/services/clipboard/clipboard-interface.service.d.ts +1 -0
- package/lib/types/services/parts/parts.service.d.ts +2 -1
- package/lib/types/views/MobileApp.d.ts +1 -2
- package/lib/types/views/components/ComponentContainer.d.ts +1 -1
- package/lib/types/views/components/confirm-part/ConfirmPart.d.ts +16 -2
- package/lib/types/views/components/context-menu/ContextMenu.d.ts +16 -2
- package/lib/types/views/components/context-menu/MobileContextMenu.d.ts +16 -2
- package/lib/types/views/components/dialog-part/DialogPart.d.ts +16 -2
- package/lib/types/views/components/dom/FloatDom.d.ts +16 -2
- package/lib/types/views/components/global-zone/GlobalZone.d.ts +16 -2
- package/lib/types/views/components/popup/CanvasPopup.d.ts +16 -2
- package/lib/types/views/components/popup/RectPopup.d.ts +2 -2
- package/lib/types/views/components/popup/dom-popup.d.ts +1 -1
- package/lib/types/views/components/popup/single-canvas-popup.d.ts +1 -1
- package/lib/types/views/components/ribbon/Button/ToolbarButton.d.ts +1 -1
- package/lib/types/views/components/ribbon/Ribbon.d.ts +2 -2
- package/lib/types/views/components/ribbon/TooltipButtonWrapper.d.ts +1 -1
- package/lib/types/views/components/shortcut-panel/ShortcutPanel.d.ts +16 -2
- package/lib/types/views/components/sidebar/Sidebar.d.ts +16 -2
- package/lib/types/views/components/zen-zone/ZenZone.d.ts +16 -2
- package/lib/types/views/workbench/Workbench.d.ts +1 -2
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +24 -32
- package/package.json +9 -9
- package/lib/types/components/hooks/__tests__/observable.spec.d.ts +0 -16
package/lib/es/facade.js
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var o = (n, e, t) =>
|
|
4
|
-
import { Inject as
|
|
5
|
-
import { IMenuManagerService as
|
|
6
|
-
var
|
|
7
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
1
|
+
var F = Object.defineProperty;
|
|
2
|
+
var D = (n, e, t) => e in n ? F(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var o = (n, e, t) => D(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { Inject as v, Injector as b, ICommandService as u, Tools as O, CommandType as w, FBase as j, FUniver as P, connectInjector as R, FHooks as M, FEnum as C } from "@univerjs/core";
|
|
5
|
+
import { IMenuManagerService as y, MenuItemType as E, RibbonStartGroup as T, RibbonPosition as $, MenuManagerPosition as G, IShortcutService as V, CopyCommand as p, PasteCommand as S, ISidebarService as N, IDialogService as H, ComponentManager as f, IMessageService as L, IUIPartsService as m, SheetPasteShortKeyCommandName as A, BuiltInUIPart as K } from "@univerjs/ui";
|
|
6
|
+
var W = Object.defineProperty, q = Object.getOwnPropertyDescriptor, x = (n, e, t, r) => {
|
|
7
|
+
for (var i = r > 1 ? void 0 : r ? q(e, t) : e, s = n.length - 1, c; s >= 0; s--)
|
|
8
8
|
(c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i);
|
|
9
|
-
return r && i &&
|
|
10
|
-
},
|
|
11
|
-
|
|
9
|
+
return r && i && W(e, t, i), i;
|
|
10
|
+
}, d = (n, e) => (t, r) => e(t, r, n);
|
|
11
|
+
class U extends j {
|
|
12
|
+
/**
|
|
13
|
+
* Append the menu to any menu position on Univer UI.
|
|
14
|
+
* @param {string | string[]} path - Some predefined path to append the menu. The paths can be an array,
|
|
15
|
+
* or an array joined by `|` separator. Since lots of submenus reuse the same name,
|
|
16
|
+
* you may need to specify their parent menus as well.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // This menu item will appear on every `contextMenu.others` section.
|
|
21
|
+
* univerAPI.createMenu({
|
|
22
|
+
* id: 'custom-menu-id-1',
|
|
23
|
+
* title: 'Custom Menu 1',
|
|
24
|
+
* action: () => {},
|
|
25
|
+
* }).appendTo('contextMenu.others');
|
|
26
|
+
*
|
|
27
|
+
* // This menu item will only appear on the `contextMenu.others` section on the main area.
|
|
28
|
+
* univerAPI.createMenu({
|
|
29
|
+
* id: 'custom-menu-id-2',
|
|
30
|
+
* title: 'Custom Menu 2',
|
|
31
|
+
* action: () => { console.log(123); },
|
|
32
|
+
* }).appendTo(['contextMenu.mainArea', 'contextMenu.others']);
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
appendTo(e) {
|
|
36
|
+
const t = typeof e == "string" ? e.split("|") : e, r = t.length, i = {};
|
|
37
|
+
let s = i;
|
|
38
|
+
const c = this.__getSchema();
|
|
39
|
+
t.forEach((h, B) => {
|
|
40
|
+
B === r - 1 ? s[h] = c : s[h] = {}, s = s[h];
|
|
41
|
+
}), this._menuManagerService.mergeMenu(i);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
var a;
|
|
45
|
+
let _ = (a = class extends U {
|
|
12
46
|
constructor(e, t, r, i) {
|
|
13
47
|
super();
|
|
14
48
|
o(this, "_commandToRegister", /* @__PURE__ */ new Map());
|
|
15
49
|
o(this, "_buildingSchema");
|
|
16
50
|
this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = i;
|
|
17
|
-
const s = typeof e.action == "string" ? e.action :
|
|
51
|
+
const s = typeof e.action == "string" ? e.action : O.generateRandomId(12);
|
|
18
52
|
s !== e.action && this._commandToRegister.set(s, e.action), this._buildingSchema = {
|
|
19
53
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
20
54
|
menuItemFactory: () => ({
|
|
21
55
|
id: e.id,
|
|
22
|
-
type:
|
|
56
|
+
type: E.BUTTON,
|
|
23
57
|
// we only support button for now
|
|
24
58
|
icon: e.icon,
|
|
25
59
|
title: e.title,
|
|
@@ -28,33 +62,25 @@ let S = (a = class extends b {
|
|
|
28
62
|
})
|
|
29
63
|
}, typeof e.order < "u" && (this._buildingSchema.order = e.order);
|
|
30
64
|
}
|
|
31
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* @ignore
|
|
67
|
+
*/
|
|
32
68
|
__getSchema() {
|
|
33
69
|
return this._commandToRegister.forEach((e, t) => {
|
|
34
70
|
this._commandService.hasCommand(t) || this._commandService.registerCommand({
|
|
35
71
|
id: t,
|
|
36
|
-
type:
|
|
72
|
+
type: w.COMMAND,
|
|
37
73
|
handler: e
|
|
38
74
|
});
|
|
39
75
|
}), { [this._item.id]: this._buildingSchema };
|
|
40
76
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[e]: t
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, o(a, "RibbonStartGroup", O), o(a, "RibbonPosition", T), o(a, "MenuManagerPosition", w), a);
|
|
52
|
-
S = E([
|
|
53
|
-
h(1, l(v)),
|
|
54
|
-
h(2, u),
|
|
55
|
-
h(3, C)
|
|
56
|
-
], S);
|
|
57
|
-
let _ = class extends b {
|
|
77
|
+
}, o(a, "RibbonStartGroup", T), o(a, "RibbonPosition", $), o(a, "MenuManagerPosition", G), a);
|
|
78
|
+
_ = x([
|
|
79
|
+
d(1, v(b)),
|
|
80
|
+
d(2, u),
|
|
81
|
+
d(3, y)
|
|
82
|
+
], _);
|
|
83
|
+
let g = class extends U {
|
|
58
84
|
constructor(e, t, r) {
|
|
59
85
|
super();
|
|
60
86
|
o(this, "_menuByGroups", []);
|
|
@@ -64,7 +90,7 @@ let _ = class extends b {
|
|
|
64
90
|
// eslint-disable-next-line ts/explicit-function-return-type
|
|
65
91
|
menuItemFactory: () => ({
|
|
66
92
|
id: e.id,
|
|
67
|
-
type:
|
|
93
|
+
type: E.SUBITEMS,
|
|
68
94
|
icon: e.icon,
|
|
69
95
|
title: e.title,
|
|
70
96
|
tooltip: e.tooltip
|
|
@@ -73,30 +99,22 @@ let _ = class extends b {
|
|
|
73
99
|
}
|
|
74
100
|
/**
|
|
75
101
|
* Add a menu to the submenu. It can be a {@link FMenu} or a {@link FSubmenu}.
|
|
76
|
-
* @param submenu Menu to add to the submenu.
|
|
77
|
-
* @returns The FSubmenu itself for chaining calls.
|
|
102
|
+
* @param {FMenu | FSubmenu} submenu - Menu to add to the submenu.
|
|
103
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
78
104
|
*/
|
|
79
105
|
addSubmenu(e) {
|
|
80
106
|
return this._submenus.push(e), this;
|
|
81
107
|
}
|
|
82
108
|
/**
|
|
83
109
|
* Add a separator to the submenu.
|
|
84
|
-
* @returns The FSubmenu itself for chaining calls.
|
|
110
|
+
* @returns {FSubmenu} The FSubmenu itself for chaining calls.
|
|
85
111
|
*/
|
|
86
112
|
addSeparator() {
|
|
87
113
|
return this._menuByGroups.push(this._submenus), this._submenus = [], this;
|
|
88
114
|
}
|
|
89
115
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @param path Some predefined path to append the menu.
|
|
116
|
+
* @ignore
|
|
92
117
|
*/
|
|
93
|
-
appendTo(e) {
|
|
94
|
-
const t = this.__getSchema();
|
|
95
|
-
this._menuManagerService.mergeMenu({
|
|
96
|
-
[e]: t
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/** @ignore */
|
|
100
118
|
__getSchema() {
|
|
101
119
|
const e = {};
|
|
102
120
|
return this.addSeparator(), this._menuByGroups.forEach((t, r) => {
|
|
@@ -107,63 +125,87 @@ let _ = class extends b {
|
|
|
107
125
|
}), { [this._item.id]: Object.assign(this._buildingSchema, e) };
|
|
108
126
|
}
|
|
109
127
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
],
|
|
114
|
-
var
|
|
115
|
-
for (var i = r > 1 ? void 0 : r ?
|
|
128
|
+
g = x([
|
|
129
|
+
d(1, v(b)),
|
|
130
|
+
d(2, y)
|
|
131
|
+
], g);
|
|
132
|
+
var z = Object.defineProperty, J = Object.getOwnPropertyDescriptor, Q = (n, e, t, r) => {
|
|
133
|
+
for (var i = r > 1 ? void 0 : r ? J(e, t) : e, s = n.length - 1, c; s >= 0; s--)
|
|
116
134
|
(c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i);
|
|
117
|
-
return r && i &&
|
|
135
|
+
return r && i && z(e, t, i), i;
|
|
118
136
|
}, I = (n, e) => (t, r) => e(t, r, n);
|
|
119
|
-
let
|
|
137
|
+
let l = class extends j {
|
|
120
138
|
constructor(e, t) {
|
|
121
139
|
super();
|
|
122
140
|
o(this, "_forceEscapeDisposable", null);
|
|
123
141
|
this._injector = e, this._shortcutService = t;
|
|
124
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Enable shortcuts of Univer.
|
|
145
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
146
|
+
*/
|
|
125
147
|
enableShortcut() {
|
|
126
148
|
var e;
|
|
127
|
-
(e = this._forceEscapeDisposable) == null || e.dispose(), this._forceEscapeDisposable = null;
|
|
149
|
+
return (e = this._forceEscapeDisposable) == null || e.dispose(), this._forceEscapeDisposable = null, this;
|
|
128
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Disable shortcuts of Univer.
|
|
153
|
+
* @returns {FShortcut} The Facade API instance itself for chaining.
|
|
154
|
+
*/
|
|
129
155
|
disableShortcut() {
|
|
130
|
-
this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape());
|
|
156
|
+
return this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape()), this;
|
|
131
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Dispatch a KeyboardEvent to the shortcut service and return the matched shortcut item.
|
|
160
|
+
* @param {KeyboardEvent} e - The KeyboardEvent to dispatch.
|
|
161
|
+
* @returns {IShortcutItem<object> | undefined} The matched shortcut item.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* const fShortcut = univerAPI.getShortcut();
|
|
166
|
+
* const pseudoEvent = new KeyboardEvent('keydown', { key: 's', ctrlKey: true });
|
|
167
|
+
* const ifShortcutItem = fShortcut.dispatchShortcutEvent(pseudoEvent);
|
|
168
|
+
* if (ifShortcutItem) {
|
|
169
|
+
* const commandId = ifShortcutItem.id;
|
|
170
|
+
* // Do something with the commandId.
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
132
174
|
dispatchShortcutEvent(e) {
|
|
133
175
|
return this._shortcutService.dispatch(e);
|
|
134
176
|
}
|
|
135
177
|
};
|
|
136
|
-
|
|
137
|
-
I(0,
|
|
138
|
-
I(1,
|
|
139
|
-
],
|
|
140
|
-
class
|
|
178
|
+
l = Q([
|
|
179
|
+
I(0, v(b)),
|
|
180
|
+
I(1, V)
|
|
181
|
+
], l);
|
|
182
|
+
class X extends P {
|
|
141
183
|
getURL() {
|
|
142
184
|
return new URL(window.location.href);
|
|
143
185
|
}
|
|
144
186
|
getShortcut() {
|
|
145
|
-
return this._injector.createInstance(
|
|
187
|
+
return this._injector.createInstance(l);
|
|
146
188
|
}
|
|
147
189
|
copy() {
|
|
148
|
-
return this._commandService.syncExecuteCommand(
|
|
190
|
+
return this._commandService.syncExecuteCommand(p.id);
|
|
149
191
|
}
|
|
150
192
|
paste() {
|
|
151
|
-
return this._commandService.syncExecuteCommand(
|
|
193
|
+
return this._commandService.syncExecuteCommand(S.id);
|
|
152
194
|
}
|
|
153
195
|
createMenu(e) {
|
|
154
|
-
return this._injector.createInstance(
|
|
196
|
+
return this._injector.createInstance(_, e);
|
|
155
197
|
}
|
|
156
198
|
createSubmenu(e) {
|
|
157
|
-
return this._injector.createInstance(
|
|
199
|
+
return this._injector.createInstance(g, e);
|
|
158
200
|
}
|
|
159
201
|
openSiderbar(e) {
|
|
160
|
-
return this._injector.get(
|
|
202
|
+
return this._injector.get(N).open(e);
|
|
161
203
|
}
|
|
162
204
|
openSidebar(e) {
|
|
163
205
|
return this.openSiderbar(e);
|
|
164
206
|
}
|
|
165
207
|
openDialog(e) {
|
|
166
|
-
const r = this._injector.get(
|
|
208
|
+
const r = this._injector.get(H).open({
|
|
167
209
|
...e,
|
|
168
210
|
onClose: () => {
|
|
169
211
|
r.dispose();
|
|
@@ -175,49 +217,49 @@ class z extends j {
|
|
|
175
217
|
return this._injector.get(f);
|
|
176
218
|
}
|
|
177
219
|
showMessage(e) {
|
|
178
|
-
return this._injector.get(
|
|
220
|
+
return this._injector.get(L).show(e), this;
|
|
179
221
|
}
|
|
180
222
|
setUIVisible(e, t) {
|
|
181
|
-
return this._injector.get(
|
|
223
|
+
return this._injector.get(m).setUIVisible(e, t), this;
|
|
182
224
|
}
|
|
183
225
|
isUIVisible(e) {
|
|
184
|
-
return this._injector.get(
|
|
226
|
+
return this._injector.get(m).isUIVisible(e);
|
|
185
227
|
}
|
|
186
228
|
registerUIPart(e, t) {
|
|
187
|
-
return this._injector.get(
|
|
229
|
+
return this._injector.get(m).registerComponent(e, () => R(t, this._injector));
|
|
188
230
|
}
|
|
189
231
|
registerComponent(e, t, r) {
|
|
190
232
|
const i = this._injector.get(f);
|
|
191
233
|
return this.disposeWithMe(i.register(e, t, r));
|
|
192
234
|
}
|
|
193
235
|
}
|
|
194
|
-
|
|
195
|
-
class
|
|
236
|
+
P.extend(X);
|
|
237
|
+
class Y extends M {
|
|
196
238
|
onBeforeCopy(e) {
|
|
197
239
|
return this._injector.get(u).beforeCommandExecuted((r) => {
|
|
198
|
-
r.id ===
|
|
240
|
+
r.id === p.id && e();
|
|
199
241
|
});
|
|
200
242
|
}
|
|
201
243
|
onCopy(e) {
|
|
202
244
|
return this._injector.get(u).onCommandExecuted((r) => {
|
|
203
|
-
r.id ===
|
|
245
|
+
r.id === p.id && e();
|
|
204
246
|
});
|
|
205
247
|
}
|
|
206
248
|
onBeforePaste(e) {
|
|
207
249
|
return this._injector.get(u).beforeCommandExecuted((r) => {
|
|
208
|
-
r.id ===
|
|
250
|
+
r.id === S.id && e();
|
|
209
251
|
});
|
|
210
252
|
}
|
|
211
253
|
onPaste(e) {
|
|
212
254
|
return this._injector.get(u).onCommandExecuted((r) => {
|
|
213
|
-
(r.id ===
|
|
255
|
+
(r.id === S.id || r.id === A) && e();
|
|
214
256
|
});
|
|
215
257
|
}
|
|
216
258
|
}
|
|
217
|
-
|
|
218
|
-
class
|
|
259
|
+
M.extend(Y);
|
|
260
|
+
class Z extends C {
|
|
219
261
|
get BuiltInUIPart() {
|
|
220
|
-
return
|
|
262
|
+
return K;
|
|
221
263
|
}
|
|
222
264
|
}
|
|
223
|
-
|
|
265
|
+
C.extend(Z);
|