@univerjs/ui 0.5.4 → 0.5.5-nightly.202501201336

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/es/facade.js CHANGED
@@ -1,25 +1,25 @@
1
1
  var x = Object.defineProperty;
2
- var E = (i, e, t) => e in i ? x(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var o = (i, e, t) => E(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Inject as l, Injector as v, ICommandService as u, FBase as b, Tools as U, CommandType as B, FUniver as I, connectInjector as D, FHooks as P, FEnum as j } from "@univerjs/core";
5
- import { IMenuManagerService as M, MenuItemType as C, RibbonStartGroup as F, RibbonPosition as O, MenuManagerPosition as T, IShortcutService as w, CopyCommand as m, PasteCommand as S, ISidebarService as R, IDialogService as $, ComponentManager as G, IMessageService as V, IUIPartsService as h, SheetPasteShortKeyCommandName as N, BuiltInUIPart as H } from "@univerjs/ui";
6
- var L = Object.defineProperty, A = Object.getOwnPropertyDescriptor, y = (i, e, t, r) => {
7
- for (var n = r > 1 ? void 0 : r ? A(e, t) : e, s = i.length - 1, c; s >= 0; s--)
8
- (c = i[s]) && (n = (r ? c(e, t, n) : c(n)) || n);
9
- return r && n && L(e, t, n), n;
10
- }, d = (i, e) => (t, r) => e(t, r, i), a;
11
- let p = (a = class extends b {
12
- constructor(e, t, r, n) {
2
+ var U = (n, e, t) => e in n ? x(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var o = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import { Inject as l, Injector as v, ICommandService as u, FBase as b, Tools as B, CommandType as D, FUniver as j, connectInjector as F, FHooks as P, FEnum as M } from "@univerjs/core";
5
+ import { IMenuManagerService as C, MenuItemType as y, RibbonStartGroup as O, RibbonPosition as T, MenuManagerPosition as w, IShortcutService as R, CopyCommand as m, PasteCommand as p, ISidebarService as $, IDialogService as G, ComponentManager as f, IMessageService as V, IUIPartsService as d, SheetPasteShortKeyCommandName as N, BuiltInUIPart as H } from "@univerjs/ui";
6
+ var L = Object.defineProperty, A = Object.getOwnPropertyDescriptor, E = (n, e, t, r) => {
7
+ for (var i = r > 1 ? void 0 : r ? A(e, t) : e, s = n.length - 1, c; s >= 0; s--)
8
+ (c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i);
9
+ return r && i && L(e, t, i), i;
10
+ }, h = (n, e) => (t, r) => e(t, r, n), a;
11
+ let S = (a = class extends b {
12
+ constructor(e, t, r, i) {
13
13
  super();
14
14
  o(this, "_commandToRegister", /* @__PURE__ */ new Map());
15
15
  o(this, "_buildingSchema");
16
- this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = n;
17
- const s = typeof e.action == "string" ? e.action : U.generateRandomId(12);
16
+ this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = i;
17
+ const s = typeof e.action == "string" ? e.action : B.generateRandomId(12);
18
18
  s !== e.action && this._commandToRegister.set(s, e.action), this._buildingSchema = {
19
19
  // eslint-disable-next-line ts/explicit-function-return-type
20
20
  menuItemFactory: () => ({
21
21
  id: e.id,
22
- type: C.BUTTON,
22
+ type: y.BUTTON,
23
23
  // we only support button for now
24
24
  icon: e.icon,
25
25
  title: e.title,
@@ -33,7 +33,7 @@ let p = (a = class extends b {
33
33
  return this._commandToRegister.forEach((e, t) => {
34
34
  this._commandService.hasCommand(t) || this._commandService.registerCommand({
35
35
  id: t,
36
- type: B.COMMAND,
36
+ type: D.COMMAND,
37
37
  handler: e
38
38
  });
39
39
  }), { [this._item.id]: this._buildingSchema };
@@ -48,12 +48,12 @@ let p = (a = class extends b {
48
48
  [e]: t
49
49
  });
50
50
  }
51
- }, o(a, "RibbonStartGroup", F), o(a, "RibbonPosition", O), o(a, "MenuManagerPosition", T), a);
52
- p = y([
53
- d(1, l(v)),
54
- d(2, u),
55
- d(3, M)
56
- ], p);
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
57
  let _ = class extends b {
58
58
  constructor(e, t, r) {
59
59
  super();
@@ -64,7 +64,7 @@ let _ = class extends b {
64
64
  // eslint-disable-next-line ts/explicit-function-return-type
65
65
  menuItemFactory: () => ({
66
66
  id: e.id,
67
- type: C.SUBITEMS,
67
+ type: y.SUBITEMS,
68
68
  icon: e.icon,
69
69
  title: e.title,
70
70
  tooltip: e.tooltip
@@ -100,22 +100,22 @@ let _ = class extends b {
100
100
  __getSchema() {
101
101
  const e = {};
102
102
  return this.addSeparator(), this._menuByGroups.forEach((t, r) => {
103
- const n = {};
103
+ const i = {};
104
104
  t.forEach((s) => {
105
- Object.assign(n, s.__getSchema());
106
- }), e[`${this._item.id}-group-${r}`] = n;
105
+ Object.assign(i, s.__getSchema());
106
+ }), e[`${this._item.id}-group-${r}`] = i;
107
107
  }), { [this._item.id]: Object.assign(this._buildingSchema, e) };
108
108
  }
109
109
  };
110
- _ = y([
111
- d(1, l(v)),
112
- d(2, M)
110
+ _ = E([
111
+ h(1, l(v)),
112
+ h(2, C)
113
113
  ], _);
114
- var K = Object.defineProperty, q = Object.getOwnPropertyDescriptor, z = (i, e, t, r) => {
115
- for (var n = r > 1 ? void 0 : r ? q(e, t) : e, s = i.length - 1, c; s >= 0; s--)
116
- (c = i[s]) && (n = (r ? c(e, t, n) : c(n)) || n);
117
- return r && n && K(e, t, n), n;
118
- }, f = (i, e) => (t, r) => e(t, r, i);
114
+ var K = Object.defineProperty, W = Object.getOwnPropertyDescriptor, q = (n, e, t, r) => {
115
+ for (var i = r > 1 ? void 0 : r ? W(e, t) : e, s = n.length - 1, c; s >= 0; s--)
116
+ (c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i);
117
+ return r && i && K(e, t, i), i;
118
+ }, I = (n, e) => (t, r) => e(t, r, n);
119
119
  let g = class extends b {
120
120
  constructor(e, t) {
121
121
  super();
@@ -133,11 +133,11 @@ let g = class extends b {
133
133
  return this._shortcutService.dispatch(e);
134
134
  }
135
135
  };
136
- g = z([
137
- f(0, l(v)),
138
- f(1, w)
136
+ g = q([
137
+ I(0, l(v)),
138
+ I(1, R)
139
139
  ], g);
140
- class J extends I {
140
+ class z extends j {
141
141
  getURL() {
142
142
  return new URL(window.location.href);
143
143
  }
@@ -145,25 +145,25 @@ class J extends I {
145
145
  return this._injector.createInstance(g);
146
146
  }
147
147
  copy() {
148
- return this._commandService.executeCommand(m.id);
148
+ return this._commandService.syncExecuteCommand(m.id);
149
149
  }
150
150
  paste() {
151
- return this._commandService.executeCommand(S.id);
151
+ return this._commandService.syncExecuteCommand(p.id);
152
152
  }
153
153
  createMenu(e) {
154
- return this._injector.createInstance(p, e);
154
+ return this._injector.createInstance(S, e);
155
155
  }
156
156
  createSubmenu(e) {
157
157
  return this._injector.createInstance(_, e);
158
158
  }
159
159
  openSiderbar(e) {
160
- return this._injector.get(R).open(e);
160
+ return this._injector.get($).open(e);
161
161
  }
162
162
  openSidebar(e) {
163
163
  return this.openSiderbar(e);
164
164
  }
165
165
  openDialog(e) {
166
- const r = this._injector.get($).open({
166
+ const r = this._injector.get(G).open({
167
167
  ...e,
168
168
  onClose: () => {
169
169
  r.dispose();
@@ -172,23 +172,27 @@ class J extends I {
172
172
  return r;
173
173
  }
174
174
  getComponentManager() {
175
- return this._injector.get(G);
175
+ return this._injector.get(f);
176
176
  }
177
177
  showMessage(e) {
178
178
  return this._injector.get(V).show(e), this;
179
179
  }
180
180
  setUIVisible(e, t) {
181
- return this._injector.get(h).setUIVisible(e, t), this;
181
+ return this._injector.get(d).setUIVisible(e, t), this;
182
182
  }
183
183
  isUIVisible(e) {
184
- return this._injector.get(h).isUIVisible(e);
184
+ return this._injector.get(d).isUIVisible(e);
185
185
  }
186
186
  registerUIPart(e, t) {
187
- return this._injector.get(h).registerComponent(e, () => D(t, this._injector));
187
+ return this._injector.get(d).registerComponent(e, () => F(t, this._injector));
188
+ }
189
+ registerComponent(e, t, r) {
190
+ const i = this._injector.get(f);
191
+ return this.disposeWithMe(i.register(e, t, r));
188
192
  }
189
193
  }
190
- I.extend(J);
191
- class Q extends P {
194
+ j.extend(z);
195
+ class J extends P {
192
196
  onBeforeCopy(e) {
193
197
  return this._injector.get(u).beforeCommandExecuted((r) => {
194
198
  r.id === m.id && e();
@@ -201,19 +205,19 @@ class Q extends P {
201
205
  }
202
206
  onBeforePaste(e) {
203
207
  return this._injector.get(u).beforeCommandExecuted((r) => {
204
- r.id === S.id && e();
208
+ r.id === p.id && e();
205
209
  });
206
210
  }
207
211
  onPaste(e) {
208
212
  return this._injector.get(u).onCommandExecuted((r) => {
209
- (r.id === S.id || r.id === N) && e();
213
+ (r.id === p.id || r.id === N) && e();
210
214
  });
211
215
  }
212
216
  }
213
- P.extend(Q);
214
- class W extends j {
217
+ P.extend(J);
218
+ class Q extends M {
215
219
  get BuiltInUIPart() {
216
220
  return H;
217
221
  }
218
222
  }
219
- j.extend(W);
223
+ M.extend(Q);