@univerjs/sheets-numfmt-ui 0.17.0 → 0.18.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.
Files changed (85) hide show
  1. package/lib/cjs/index.js +26 -1
  2. package/lib/cjs/locale/ca-ES.js +1 -1
  3. package/lib/cjs/locale/en-US.js +1 -1
  4. package/lib/cjs/locale/es-ES.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/ja-JP.js +1 -1
  8. package/lib/cjs/locale/ko-KR.js +1 -1
  9. package/lib/cjs/locale/ru-RU.js +1 -1
  10. package/lib/cjs/locale/sk-SK.js +1 -1
  11. package/lib/cjs/locale/vi-VN.js +1 -1
  12. package/lib/cjs/locale/zh-CN.js +1 -1
  13. package/lib/cjs/locale/zh-TW.js +1 -1
  14. package/lib/es/index.js +26 -1218
  15. package/lib/es/locale/ca-ES.js +1 -42
  16. package/lib/es/locale/en-US.js +1 -42
  17. package/lib/es/locale/es-ES.js +1 -42
  18. package/lib/es/locale/fa-IR.js +1 -42
  19. package/lib/es/locale/fr-FR.js +1 -42
  20. package/lib/es/locale/ja-JP.js +1 -42
  21. package/lib/es/locale/ko-KR.js +1 -42
  22. package/lib/es/locale/ru-RU.js +1 -42
  23. package/lib/es/locale/sk-SK.js +1 -42
  24. package/lib/es/locale/vi-VN.js +1 -42
  25. package/lib/es/locale/zh-CN.js +1 -42
  26. package/lib/es/locale/zh-TW.js +1 -42
  27. package/lib/index.css +179 -1
  28. package/lib/index.js +26 -1218
  29. package/lib/locale/ca-ES.js +1 -42
  30. package/lib/locale/en-US.js +1 -42
  31. package/lib/locale/es-ES.js +1 -42
  32. package/lib/locale/fa-IR.js +1 -42
  33. package/lib/locale/fr-FR.js +1 -42
  34. package/lib/locale/ja-JP.js +1 -42
  35. package/lib/locale/ko-KR.js +1 -42
  36. package/lib/locale/ru-RU.js +1 -42
  37. package/lib/locale/sk-SK.js +1 -42
  38. package/lib/locale/vi-VN.js +1 -42
  39. package/lib/locale/zh-CN.js +1 -42
  40. package/lib/locale/zh-TW.js +1 -42
  41. package/lib/types/commands/operations/close.numfmt.panel.operation.d.ts +16 -1
  42. package/lib/types/commands/operations/open.numfmt.panel.operation.d.ts +16 -1
  43. package/lib/types/config/config.d.ts +16 -1
  44. package/lib/types/controllers/numfmt-alert-render.controller.d.ts +18 -2
  45. package/lib/types/controllers/numfmt.controller.d.ts +15 -0
  46. package/lib/types/controllers/numfmt.editor.controller.d.ts +15 -0
  47. package/lib/types/controllers/user-habit.controller.d.ts +16 -1
  48. package/lib/types/locale/ca-ES.d.ts +16 -1
  49. package/lib/types/locale/es-ES.d.ts +16 -1
  50. package/lib/types/locale/fa-IR.d.ts +16 -1
  51. package/lib/types/locale/fr-FR.d.ts +16 -1
  52. package/lib/types/locale/ja-JP.d.ts +16 -1
  53. package/lib/types/locale/ko-KR.d.ts +16 -1
  54. package/lib/types/locale/ru-RU.d.ts +16 -1
  55. package/lib/types/locale/sk-SK.d.ts +16 -1
  56. package/lib/types/locale/vi-VN.d.ts +16 -1
  57. package/lib/types/locale/zh-CN.d.ts +16 -1
  58. package/lib/types/locale/zh-TW.d.ts +16 -1
  59. package/lib/types/menu/menu.d.ts +18 -2
  60. package/lib/types/menu/numfmt.menu.controller.d.ts +15 -0
  61. package/lib/types/menu/schema.d.ts +16 -1
  62. package/lib/types/plugin.d.ts +16 -1
  63. package/lib/types/views/components/Accounting.d.ts +17 -2
  64. package/lib/types/views/components/Currency.d.ts +17 -2
  65. package/lib/types/views/components/CustomFormat.d.ts +16 -1
  66. package/lib/types/views/components/Date.d.ts +16 -1
  67. package/lib/types/views/components/General.d.ts +17 -2
  68. package/lib/types/views/components/ThousandthPercentile.d.ts +16 -1
  69. package/lib/types/views/components/index.d.ts +16 -1
  70. package/lib/types/views/components/interface.d.ts +16 -1
  71. package/lib/types/views/components/stories/Panel.stories.d.ts +17 -2
  72. package/lib/umd/index.js +26 -1
  73. package/lib/umd/locale/ca-ES.js +1 -1
  74. package/lib/umd/locale/en-US.js +1 -1
  75. package/lib/umd/locale/es-ES.js +1 -1
  76. package/lib/umd/locale/fa-IR.js +1 -1
  77. package/lib/umd/locale/fr-FR.js +1 -1
  78. package/lib/umd/locale/ja-JP.js +1 -1
  79. package/lib/umd/locale/ko-KR.js +1 -1
  80. package/lib/umd/locale/ru-RU.js +1 -1
  81. package/lib/umd/locale/sk-SK.js +1 -1
  82. package/lib/umd/locale/vi-VN.js +1 -1
  83. package/lib/umd/locale/zh-CN.js +1 -1
  84. package/lib/umd/locale/zh-TW.js +1 -1
  85. package/package.json +14 -13
package/lib/index.js CHANGED
@@ -1,1218 +1,26 @@
1
- var dt = Object.defineProperty;
2
- var ht = (e, t, r) => t in e ? dt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var J = (e, t, r) => ht(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { Inject as C, LocaleService as E, IConfigService as Fe, Disposable as ne, isTextFormat as Le, Tools as vt, isRealNum as ve, CommandType as Ae, ILocalStorageService as He, isPatternEqualWithoutDecimal as re, numfmt as ft, ThemeService as pt, IUniverInstanceService as ge, ICommandService as _e, UniverInstanceType as T, CellValueType as w, toDisposable as fe, DisposableCollection as gt, InterceptorEffectEnum as Pe, Range as je, Injector as Be, Optional as _t, getNumfmtParseValueFilter as St, willLoseNumericPrecision as Ct, fromCallback as yt, isDefaultFormat as bt, DEFAULT_TEXT_FORMAT_EXCEL as It, DependentOn as Nt, Plugin as Et, merge as Tt, registerDependencies as Mt, touchDependencies as wt } from "@univerjs/core";
5
- import { IRenderManagerService as We } from "@univerjs/engine-render";
6
- import { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as Pt, currencySymbols as Re, getDecimalFromPattern as Q, getCurrencyType as V, setPatternDecimal as $, getCurrencyFormatOptions as ce, CURRENCYFORMAT as Rt, DATEFMTLISG as xt, NUMBERFORMAT as $t, getDateFormatOptions as Ve, getNumberFormatOptions as Ge, isPatternHasDecimal as Ot, SheetsNumfmtCellContentController as Ke, getPatternPreviewIgnoreGeneral as kt, getPatternType as A, SetNumfmtCommand as Ye, SubtractDecimalCommand as Ze, AddDecimalCommand as ze, SetCurrencyCommand as Xe, getCurrencySymbolIconByLocale as xe, SetPercentCommand as qe, getCurrencySymbolByLocale as Ut, localeCurrencySymbolMap as Dt, getPatternPreview as Ft, UniverSheetsNumfmtPlugin as Lt } from "@univerjs/sheets-numfmt";
7
- import { HoverManagerService as At, CellAlertManagerService as Ht, CellAlertType as jt, SheetSkeletonManagerService as Bt, IEditorBridgeService as Wt, getCurrentRangeDisable$ as G, deriveStateFromActiveSheet$ as Vt, UniverSheetsUIPlugin as Gt } from "@univerjs/sheets-ui";
8
- import { INumfmtService as Se, SheetInterceptorService as Je, SheetsSelectionsService as Ce, INTERCEPTOR_POINT as Kt, RemoveNumfmtMutation as ye, SetNumfmtMutation as be, BEFORE_CELL_EDIT as Yt, AFTER_CELL_EDIT as Zt, SetRangeValuesCommand as zt, transformCellsToRange as Xt, factorySetNumfmtUndoMutation as qt, factoryRemoveNumfmtUndoMutation as Jt, RangeProtectionPermissionEditPoint as K, WorksheetEditPermission as Y, WorksheetSetCellStylePermission as Z, WorkbookEditablePermission as z } from "@univerjs/sheets";
9
- import { IZenZoneService as Qt, useDependency as b, ComponentManager as Qe, ISidebarService as en, getMenuHiddenObservable as X, MenuItemType as q, ILayoutService as tn, RibbonStartGroup as nn, IMenuManagerService as rn } from "@univerjs/ui";
10
- import { debounceTime as sn, merge as et, Observable as H, combineLatest as on, filter as cn } from "rxjs";
11
- import { map as an, switchMap as ln, tap as un, debounceTime as mn } from "rxjs/operators";
12
- import { jsxs as y, jsx as h } from "react/jsx-runtime";
13
- import { createContext as dn, useState as N, useEffect as ie, useRef as Ie, useContext as tt, useMemo as R, createElement as Ne, forwardRef as hn, useCallback as vn } from "react";
14
- import { InputNumber as Ee, Select as Te, SelectList as Me, Input as fn, clsx as nt, borderClassName as pn, Button as $e, scrollbarClassName as gn, Separator as _n } from "@univerjs/design";
15
- import { stripErrorMargin as ae } from "@univerjs/engine-formula";
16
- const Sn = "@univerjs/sheets-numfmt-ui", Cn = "0.17.0", rt = {
17
- name: Sn,
18
- version: Cn
19
- }, Oe = {};
20
- var yn = Object.getOwnPropertyDescriptor, bn = (e, t, r, n) => {
21
- for (var i = n > 1 ? void 0 : n ? yn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
22
- (o = e[s]) && (i = o(i) || i);
23
- return i;
24
- }, U = (e, t) => (r, n) => t(r, n, e);
25
- const le = "SHEET_NUMFMT_ALERT";
26
- let pe = class extends ne {
27
- constructor(e, t, r, n, i, s, o) {
28
- super(), this._context = e, this._hoverManagerService = t, this._cellAlertManagerService = r, this._localeService = n, this._zenZoneService = i, this._numfmtService = s, this._configService = o, this._init();
29
- }
30
- _init() {
31
- this._initCellAlertPopup(), this._initZenService();
32
- }
33
- _initCellAlertPopup() {
34
- this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(sn(100)).subscribe((e) => {
35
- var t, r;
36
- if (e) {
37
- const n = e.location, i = this._context.unit, s = i.getActiveSheet();
38
- if (!s) return this._hideAlert();
39
- const o = n.unitId, m = n.subUnitId;
40
- let c;
41
- const a = s.getCell(n.row, n.col);
42
- if (a != null && a.s) {
43
- const u = i.getStyles().get(a.s);
44
- u != null && u.n && (c = u.n);
45
- }
46
- if (c || (c = this._numfmtService.getValue(o, m, n.row, n.col)), !c) {
47
- this._hideAlert();
48
- return;
49
- }
50
- if (Le(c.pattern) && vt.isDefine(a == null ? void 0 : a.v) && ve(a.v)) {
51
- if ((t = this._configService.getConfig(Pt)) != null && t.disableTextFormatAlert)
52
- return;
53
- const u = this._cellAlertManagerService.currentAlert.get(le), l = (r = u == null ? void 0 : u.alert) == null ? void 0 : r.location;
54
- if (l && l.row === n.row && l.col === n.col && l.subUnitId === n.subUnitId && l.unitId === n.unitId) {
55
- this._hideAlert();
56
- return;
57
- }
58
- this._cellAlertManagerService.showAlert({
59
- type: jt.ERROR,
60
- title: this._localeService.t("info.error"),
61
- message: this._localeService.t("info.forceStringInfo"),
62
- location: n,
63
- width: 200,
64
- height: 74,
65
- key: le
66
- });
67
- return;
68
- }
69
- }
70
- this._hideAlert();
71
- }));
72
- }
73
- _initZenService() {
74
- this.disposeWithMe(this._zenZoneService.visible$.subscribe((e) => {
75
- e && this._hideAlert();
76
- }));
77
- }
78
- _hideAlert() {
79
- this._cellAlertManagerService.removeAlert(le);
80
- }
81
- };
82
- pe = bn([
83
- U(1, C(At)),
84
- U(2, C(Ht)),
85
- U(3, C(E)),
86
- U(4, Qt),
87
- U(5, C(Se)),
88
- U(6, Fe)
89
- ], pe);
90
- const ue = {
91
- id: "sheet.operation.close.numfmt.panel",
92
- type: Ae.OPERATION,
93
- handler: () => (
94
- // do nothing, just notify panel is closed
95
- !0
96
- )
97
- }, j = {
98
- id: "sheet.operation.open.numfmt.panel",
99
- type: Ae.OPERATION,
100
- handler: (e) => (e.get(W).openPanel(), !0)
101
- };
102
- var In = Object.getOwnPropertyDescriptor, Nn = (e, t, r, n) => {
103
- for (var i = n > 1 ? void 0 : n ? In(t, r) : t, s = e.length - 1, o; s >= 0; s--)
104
- (o = e[s]) && (i = o(i) || i);
105
- return i;
106
- }, En = (e, t) => (r, n) => t(r, n, e);
107
- const we = dn([]);
108
- let B = class {
109
- constructor(e) {
110
- this._localStorageService = e;
111
- }
112
- _getKey(e) {
113
- return `userHabitController_${e}`;
114
- }
115
- async addHabit(e, t) {
116
- const r = this._getKey(e);
117
- return this._localStorageService.getItem(r).then((n) => {
118
- n || this._localStorageService.setItem(r, t);
119
- });
120
- }
121
- markHabit(e, t) {
122
- const r = this._getKey(e);
123
- this._localStorageService.getItem(r).then((n) => {
124
- if (n) {
125
- const i = n.findIndex((s) => s === t);
126
- i > -1 && n.splice(i, 1), n.unshift(t), this._localStorageService.setItem(r, n);
127
- }
128
- });
129
- }
130
- async getHabit(e, t) {
131
- const r = this._getKey(e), n = await this._localStorageService.getItem(r);
132
- if (t && n) {
133
- const i = n.map((s, o, m) => {
134
- const c = m.length;
135
- return {
136
- value: s,
137
- priority: c - o
138
- };
139
- });
140
- return t.sort((s, o) => {
141
- var a, u;
142
- const m = ((a = i.find((l) => l.value === s)) == null ? void 0 : a.priority) || -1;
143
- return (((u = i.find((l) => l.value === o)) == null ? void 0 : u.priority) || -1) - m;
144
- });
145
- }
146
- return n || [];
147
- }
148
- deleteHabit(e) {
149
- this._localStorageService.removeItem(e);
150
- }
151
- };
152
- B = Nn([
153
- En(0, C(He))
154
- ], B);
155
- const ke = "numfmtCurrency", Tn = (e) => {
156
- const t = b(B), [r, n] = N(Re);
157
- return ie(() => {
158
- t.addHabit("numfmtCurrency", []).then(() => {
159
- t.getHabit(ke, [...Re]).then((s) => {
160
- n(s), e && e(s);
161
- });
162
- });
163
- }, []), { userHabitCurrency: r, mark: (s) => {
164
- t.markHabit(ke, s);
165
- } };
166
- }, Mn = () => {
167
- const e = Ie([]), [t, r] = N({});
168
- return ie(() => {
169
- e.current.forEach((i) => {
170
- i();
171
- }), e.current = [];
172
- }, [t]), (i) => {
173
- e.current.push(i), r({});
174
- };
175
- }, wn = (e) => !!V(e) && e.startsWith("_("), Pn = (e) => {
176
- const { defaultPattern: t, action: r, onChange: n } = e, [i, s] = N(() => Q(t || "", 2)), o = tt(we), [m, c] = N(() => V(t) || o[0]), a = R(() => o.map((p) => ({ label: p, value: p })), []), l = b(E).t;
177
- r.current = () => $(`_("${m}"* #,##0${i > 0 ? ".0" : ""}_)`, i);
178
- const v = (p) => {
179
- c(p), n($(`_("${p}"* #,##0${i > 0 ? ".0" : ""}_)`, i));
180
- }, f = (p) => {
181
- const d = p || 0;
182
- s(d), n($(`_("${m}"* #,##0${d > 0 ? ".0" : ""}_)`, d));
183
- };
184
- return /* @__PURE__ */ y("div", { children: [
185
- /* @__PURE__ */ y("div", { className: "univer-mt-4 univer-flex univer-justify-between", children: [
186
- /* @__PURE__ */ y("div", { className: "option", children: [
187
- /* @__PURE__ */ h("div", { className: "univer-text-sm univer-text-gray-400", children: l("sheet.numfmt.decimalLength") }),
188
- /* @__PURE__ */ h("div", { className: "univer-mt-2 univer-w-32", children: /* @__PURE__ */ h(
189
- Ee,
190
- {
191
- value: i,
192
- step: 1,
193
- precision: 0,
194
- max: 20,
195
- min: 0,
196
- onChange: f
197
- }
198
- ) })
199
- ] }),
200
- /* @__PURE__ */ y("div", { className: "option", children: [
201
- /* @__PURE__ */ h("div", { className: "univer-text-sm univer-text-gray-400", children: l("sheet.numfmt.currencyType") }),
202
- /* @__PURE__ */ h("div", { className: "univer-mt-2 univer-w-36", children: /* @__PURE__ */ h(
203
- Te,
204
- {
205
- options: a,
206
- value: m,
207
- onChange: v
208
- }
209
- ) })
210
- ] })
211
- ] }),
212
- /* @__PURE__ */ h("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: l("sheet.numfmt.accountingDes") })
213
- ] });
214
- }, Rn = (e) => !!V(e) && !e.startsWith("_("), xn = (e) => {
215
- const r = b(E).t, n = tt(we), [i, s] = N(() => V(e.defaultPattern) || n[0]), [o, m] = N(() => Q(e.defaultPattern || "", 2)), [c, a] = N(() => {
216
- var g;
217
- const d = ce(i);
218
- return ((g = d.find((I) => re(I.value, e.defaultPattern))) == null ? void 0 : g.value) || d[0].value;
219
- }), u = R(() => ce(i), [i]), l = R(() => n.map((d) => ({ label: d, value: d })), [n]);
220
- e.action.current = () => $(c, o);
221
- const v = (d) => {
222
- if (d === void 0)
223
- return;
224
- s(d);
225
- const S = ce(d)[0].value;
226
- a(S), e.onChange($(S, o));
227
- }, f = (d) => {
228
- d !== void 0 && (a(d), e.onChange($(d, o)));
229
- }, p = (d) => {
230
- m(d || 0), e.onChange($(c, d || 0));
231
- };
232
- return /* @__PURE__ */ y("div", { children: [
233
- /* @__PURE__ */ y("div", { className: "univer-mt-4 univer-flex univer-justify-between", children: [
234
- /* @__PURE__ */ y("div", { className: "option", children: [
235
- /* @__PURE__ */ h("div", { className: "univer-text-sm univer-text-gray-400", children: r("sheet.numfmt.decimalLength") }),
236
- /* @__PURE__ */ h("div", { className: "univer-mt-2 univer-w-32", children: /* @__PURE__ */ h(
237
- Ee,
238
- {
239
- value: o,
240
- max: 20,
241
- min: 0,
242
- onChange: p
243
- }
244
- ) })
245
- ] }),
246
- /* @__PURE__ */ y("div", { className: "option", children: [
247
- /* @__PURE__ */ h("div", { className: "univer-text-sm univer-text-gray-400", children: r("sheet.numfmt.currencyType") }),
248
- /* @__PURE__ */ h("div", { className: "univer-mt-2 univer-w-36", children: /* @__PURE__ */ h(
249
- Te,
250
- {
251
- value: i,
252
- options: l,
253
- onChange: v
254
- }
255
- ) })
256
- ] })
257
- ] }),
258
- /* @__PURE__ */ h("div", { className: "label univer-mt-4", children: r("sheet.numfmt.negType") }),
259
- /* @__PURE__ */ h("div", { className: "univer-mt-2", children: /* @__PURE__ */ h(Me, { value: c, options: u, onChange: f }) }),
260
- /* @__PURE__ */ h("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: r("sheet.numfmt.currencyDes") })
261
- ] });
262
- };
263
- function it({ ref: e, ...t }) {
264
- const { icon: r, id: n, className: i, extend: s, ...o } = t, m = `univerjs-icon univerjs-icon-${n} ${i || ""}`.trim(), c = Ie(`_${kn()}`);
265
- return st(r, `${n}`, {
266
- defIds: r.defIds,
267
- idSuffix: c.current
268
- }, {
269
- ref: e,
270
- className: m,
271
- ...o
272
- }, s);
273
- }
274
- function st(e, t, r, n, i) {
275
- return Ne(e.tag, {
276
- key: t,
277
- ...$n(e, r, i),
278
- ...n
279
- }, (On(e, r).children || []).map((s, o) => st(s, `${t}-${e.tag}-${o}`, r, void 0, i)));
280
- }
281
- function $n(e, t, r) {
282
- const n = { ...e.attrs };
283
- r != null && r.colorChannel1 && n.fill === "colorChannel1" && (n.fill = r.colorChannel1), e.tag === "mask" && n.id && (n.id = n.id + t.idSuffix), Object.entries(n).forEach(([s, o]) => {
284
- s === "mask" && typeof o == "string" && (n[s] = o.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
285
- });
286
- const { defIds: i } = t;
287
- return !i || i.length === 0 || (e.tag === "use" && n["xlink:href"] && (n["xlink:href"] = n["xlink:href"] + t.idSuffix), Object.entries(n).forEach(([s, o]) => {
288
- typeof o == "string" && (n[s] = o.replace(/url\(#(.*)\)/, `url(#$1${t.idSuffix})`));
289
- })), n;
290
- }
291
- function On(e, t) {
292
- var n;
293
- const { defIds: r } = t;
294
- return !r || r.length === 0 ? e : e.tag === "defs" && ((n = e.children) != null && n.length) ? {
295
- ...e,
296
- children: e.children.map((i) => typeof i.attrs.id == "string" && r && r.includes(i.attrs.id) ? {
297
- ...i,
298
- attrs: {
299
- ...i.attrs,
300
- id: i.attrs.id + t.idSuffix
301
- }
302
- } : i)
303
- } : e;
304
- }
305
- function kn() {
306
- return Math.random().toString(36).substring(2, 8);
307
- }
308
- it.displayName = "UniverIcon";
309
- const Un = {
310
- tag: "svg",
311
- attrs: {
312
- xmlns: "http://www.w3.org/2000/svg",
313
- fill: "none",
314
- viewBox: "0 0 16 16",
315
- width: "1em",
316
- height: "1em"
317
- },
318
- children: [{
319
- tag: "path",
320
- attrs: {
321
- fill: "currentColor",
322
- d: "M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z",
323
- fillRule: "evenodd",
324
- clipRule: "evenodd"
325
- }
326
- }]
327
- }, ot = hn(function(t, r) {
328
- return Ne(it, Object.assign({}, t, {
329
- id: "check-mark-icon",
330
- ref: r,
331
- icon: Un
332
- }));
333
- });
334
- ot.displayName = "CheckMarkIcon";
335
- const me = "customFormat", de = "numfmt_custom_pattern";
336
- function Dn(e) {
337
- const { defaultPattern: t, action: r, onChange: n } = e, i = b(B), s = b(He), o = b(E), [m, c] = N(t);
338
- r.current = () => (i.markHabit(me, m), s.getItem(de).then((f = []) => {
339
- const p = [.../* @__PURE__ */ new Set([m, ...f || []])].splice(0, 10).filter((d) => !!d);
340
- s.setItem(de, p);
341
- }), m);
342
- const [a, u] = N([]);
343
- ie(() => {
344
- s.getItem(de).then((f) => {
345
- const p = [
346
- ...Rt.map((d) => d.suffix("$")),
347
- ...xt.map((d) => d.suffix),
348
- ...$t.map((d) => d.suffix)
349
- ];
350
- p.push(...f || []), i.addHabit(me, []).finally(() => {
351
- i.getHabit(me, p).then((d) => {
352
- u([...new Set(d)]);
353
- });
354
- });
355
- });
356
- }, []);
357
- const l = (f) => {
358
- c(f), n(f);
359
- }, v = () => {
360
- n(m);
361
- };
362
- return /* @__PURE__ */ y("div", { children: [
363
- /* @__PURE__ */ h("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: o.t("sheet.numfmt.customFormat") }),
364
- /* @__PURE__ */ h(
365
- fn,
366
- {
367
- placeholder: o.t("sheet.numfmt.customFormat"),
368
- onBlur: v,
369
- value: m,
370
- onChange: c,
371
- className: "univer-mt-2 univer-w-full"
372
- }
373
- ),
374
- /* @__PURE__ */ h(
375
- "div",
376
- {
377
- className: nt("univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2", pn),
378
- children: a.map((f) => /* @__PURE__ */ y(
379
- "div",
380
- {
381
- onClick: () => l(f),
382
- className: "univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm",
383
- children: [
384
- /* @__PURE__ */ h("div", { className: "univer-flex univer-w-4 univer-items-center univer-text-primary-600", children: m === f && /* @__PURE__ */ h(ot, {}) }),
385
- /* @__PURE__ */ h("div", { children: f })
386
- ]
387
- },
388
- f
389
- ))
390
- }
391
- ),
392
- /* @__PURE__ */ h(
393
- "div",
394
- {
395
- className: "univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",
396
- children: o.t("sheet.numfmt.customFormatDes")
397
- }
398
- )
399
- ] });
400
- }
401
- const Fn = (e) => {
402
- const t = ft.getFormatInfo(e);
403
- return Ve().map((r) => r.value).includes(e) || ["date", "datetime", "time"].includes(t.type);
404
- };
405
- function Ln(e) {
406
- const { onChange: t, defaultPattern: r } = e, n = R(Ve, []), i = b(E), [s, o] = N(() => {
407
- if (r) {
408
- const c = n.find((a) => a.value === r);
409
- if (c)
410
- return c.value;
411
- }
412
- return n[0].value;
413
- });
414
- e.action.current = () => s;
415
- const m = (c) => {
416
- c !== void 0 && (o(c), t(c));
417
- };
418
- return /* @__PURE__ */ y("div", { children: [
419
- /* @__PURE__ */ h("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: i.t("sheet.numfmt.dateType") }),
420
- /* @__PURE__ */ h("div", { className: "univer-mt-2", children: /* @__PURE__ */ h(Me, { value: s, options: n, onChange: m }) }),
421
- /* @__PURE__ */ h(
422
- "div",
423
- {
424
- className: "univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",
425
- children: i.t("sheet.numfmt.dateDes")
426
- }
427
- )
428
- ] });
429
- }
430
- const An = (e) => !e, Hn = (e) => {
431
- const r = b(E).t;
432
- return e.action.current = () => "", /* @__PURE__ */ h("div", { children: /* @__PURE__ */ h(
433
- "div",
434
- {
435
- className: "univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",
436
- children: r("sheet.numfmt.generalDes")
437
- }
438
- ) });
439
- }, jn = (e) => Ge().some((t) => re(t.value, e));
440
- function Bn(e) {
441
- const t = b(E), r = R(Ge, []), [n, i] = N(() => Q(e.defaultPattern || "", 0)), [s, o] = N(() => {
442
- const l = r.find((v) => re(v.value, e.defaultPattern || ""));
443
- return (l == null ? void 0 : l.value) || r[0].value;
444
- }), m = R(() => $(s, Number(n || 0)), [s, n]), c = R(() => !Ot(s), [s]), a = (l) => {
445
- i(l || 0), e.onChange($(s, Number(l || 0)));
446
- }, u = (l) => {
447
- l !== void 0 && (i(Q(l, 0)), o(l), e.onChange(l));
448
- };
449
- return e.action.current = () => m, /* @__PURE__ */ y("div", { children: [
450
- /* @__PURE__ */ h("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: t.t("sheet.numfmt.decimalLength") }),
451
- /* @__PURE__ */ h("div", { className: "univer-mt-2", children: /* @__PURE__ */ h(
452
- Ee,
453
- {
454
- disabled: c,
455
- value: n,
456
- max: 20,
457
- min: 0,
458
- onChange: a
459
- }
460
- ) }),
461
- /* @__PURE__ */ y("div", { className: "univer-mt-4 univer-text-sm univer-text-gray-400", children: [
462
- " ",
463
- t.t("sheet.numfmt.negType")
464
- ] }),
465
- /* @__PURE__ */ h("div", { className: "univer-mt-2", children: /* @__PURE__ */ h(Me, { onChange: u, options: r, value: s }) }),
466
- /* @__PURE__ */ h(
467
- "div",
468
- {
469
- className: "univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200",
470
- children: t.t("sheet.numfmt.thousandthPercentileDes")
471
- }
472
- )
473
- ] });
474
- }
475
- const Wn = (e) => {
476
- const { defaultValue: t, defaultPattern: r, row: n, col: i } = e.value, s = b(E), o = Ie(() => ""), m = s.t, c = Mn(), a = R(
477
- () => [
478
- { label: "sheet.numfmt.general", component: Hn },
479
- { label: "sheet.numfmt.accounting", component: Pn },
480
- { label: "sheet.numfmt.currency", component: xn },
481
- { label: "sheet.numfmt.date", component: Ln },
482
- { label: "sheet.numfmt.thousandthPercentile", component: Bn },
483
- { label: "sheet.numfmt.customFormat", component: Dn }
484
- ].map((_) => ({ ..._, label: m(_.label) })),
485
- []
486
- ), [u, l] = N(g), [v, f] = N(() => `${n}_${i}`), { mark: p, userHabitCurrency: d } = Tn(() => f(`${n}_${i}_userCurrency'`)), S = R(() => {
487
- var _;
488
- return (_ = a.find((k) => k.label === u)) == null ? void 0 : _.component;
489
- }, [u]);
490
- function g() {
491
- return [An, wn, Rn, Fn, jn].reduce((k, ut, mt) => k || (ut(r) ? a[mt].label : ""), "") || a[0].label;
492
- }
493
- const I = a.map((_) => ({
494
- label: _.label,
495
- value: _.label
496
- })), P = (_) => {
497
- l(_), c(() => e.onChange({ type: "change", value: o.current() || "" }));
498
- }, x = vn((_) => {
499
- e.onChange({ type: "change", value: _ });
500
- }, []), O = () => {
501
- const _ = o.current() || "", k = V(_);
502
- k && p(k), e.onChange({ type: "confirm", value: _ });
503
- }, F = () => {
504
- e.onChange({ type: "cancel", value: "" });
505
- }, oe = {
506
- onChange: x,
507
- defaultValue: t,
508
- defaultPattern: r,
509
- action: o
510
- };
511
- return ie(() => {
512
- l(g()), f(`${n}_${i}`);
513
- }, [n, i]), /* @__PURE__ */ y(
514
- "div",
515
- {
516
- className: nt("univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5", gn),
517
- children: [
518
- /* @__PURE__ */ y("div", { children: [
519
- /* @__PURE__ */ h("div", { className: "univer-mt-3.5 univer-text-sm univer-text-gray-400", children: m("sheet.numfmt.numfmtType") }),
520
- /* @__PURE__ */ h("div", { className: "univer-mt-2", children: /* @__PURE__ */ h(Te, { className: "univer-w-full", value: u, options: I, onChange: P }) }),
521
- /* @__PURE__ */ h("div", { children: S && /* @__PURE__ */ h(we.Provider, { value: d, children: /* @__PURE__ */ Ne(S, { ...oe, key: v }) }) })
522
- ] }),
523
- /* @__PURE__ */ y("div", { className: "univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end", children: [
524
- /* @__PURE__ */ h($e, { onClick: F, className: "univer-mr-3", children: m("sheet.numfmt.cancel") }),
525
- /* @__PURE__ */ h($e, { variant: "primary", onClick: O, children: m("sheet.numfmt.confirm") })
526
- ] })
527
- ]
528
- }
529
- );
530
- };
531
- var Vn = Object.getOwnPropertyDescriptor, Gn = (e, t, r, n) => {
532
- for (var i = n > 1 ? void 0 : n ? Vn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
533
- (o = e[s]) && (i = o(i) || i);
534
- return i;
535
- }, M = (e, t) => (r, n) => t(r, n, e);
536
- const Ue = "SHEET_NUMFMT_PANEL";
537
- let W = class extends ne {
538
- constructor(t, r, n, i, s, o, m, c, a, u, l) {
539
- super();
540
- /**
541
- * If _previewPattern is null ,the realTimeRenderingInterceptor will skip and if it is '',realTimeRenderingInterceptor will clear numfmt.
542
- * @private
543
- * @type {(string | null)}
544
- * @memberof NumfmtController
545
- */
546
- J(this, "_previewPattern", "");
547
- J(this, "_sidebarDisposable", null);
548
- this._sheetInterceptorService = t, this._themeService = r, this._univerInstanceService = n, this._commandService = i, this._selectionManagerService = s, this._renderManagerService = o, this._numfmtService = m, this._componentManager = c, this._sidebarService = a, this._localeService = u, this._sheetsNumfmtCellContentController = l, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener(), this._initNumfmtLocalChange();
549
- }
550
- _initNumfmtLocalChange() {
551
- this.disposeWithMe(et(this._sheetsNumfmtCellContentController.locale$, this._localeService.currentLocale$).subscribe(() => {
552
- this._forceUpdate();
553
- }));
554
- }
555
- openPanel() {
556
- var S;
557
- const t = this._sidebarService, r = this._selectionManagerService, n = this._commandService, i = this._univerInstanceService, s = this._numfmtService, o = this._localeService, c = (((S = r.getCurrentSelections()) == null ? void 0 : S.map((g) => g.range)) || [])[0];
558
- if (!c)
559
- return !1;
560
- const a = i.getCurrentUnitForType(T.UNIVER_SHEET), u = a.getActiveSheet();
561
- if (!u)
562
- return !1;
563
- const l = u.getCellRaw(c.startRow, c.startColumn), v = s.getValue(
564
- a.getUnitId(),
565
- u.getSheetId(),
566
- c.startRow,
567
- c.startColumn
568
- );
569
- let f = "";
570
- v && (f = v.pattern);
571
- const p = (l == null ? void 0 : l.t) === w.NUMBER ? l.v : 12345678, d = {
572
- onChange: (g) => {
573
- var I;
574
- if (g.type === "change")
575
- this._previewPattern = g.value, this._forceUpdate();
576
- else if (g.type === "confirm") {
577
- const P = ((I = r.getCurrentSelections()) == null ? void 0 : I.map((F) => F.range)) || [], x = { values: [] }, O = A(g.value);
578
- P.forEach((F) => {
579
- je.foreach(F, (oe, _) => {
580
- x.values.push({
581
- row: oe,
582
- col: _,
583
- pattern: g.value,
584
- type: O
585
- });
586
- });
587
- }), n.executeCommand(Ye.id, x), t.close();
588
- } else g.type === "cancel" && t.close();
589
- },
590
- value: { defaultPattern: f, defaultValue: p, row: c.startRow, col: c.startColumn }
591
- };
592
- return this._sidebarDisposable = t.open({
593
- header: { title: o.t("sheet.numfmt.title") },
594
- children: {
595
- label: Ue,
596
- ...d
597
- // need passthrough to react props.
598
- },
599
- onClose: () => {
600
- this._forceUpdate(), n.executeCommand(ue.id);
601
- }
602
- }), !0;
603
- }
604
- _forceUpdate(t) {
605
- var n;
606
- const r = this._renderManagerService.getRenderById(
607
- t != null ? t : this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET).getUnitId()
608
- );
609
- r == null || r.with(Bt).reCalculate(), (n = r == null ? void 0 : r.mainComponent) == null || n.makeDirty();
610
- }
611
- _initCommands() {
612
- [
613
- j,
614
- ue
615
- ].forEach((t) => {
616
- this.disposeWithMe(this._commandService.registerCommand(t));
617
- });
618
- }
619
- _initPanel() {
620
- this.disposeWithMe(
621
- this._componentManager.register(Ue, Wn)
622
- );
623
- }
624
- // eslint-disable-next-line max-lines-per-function
625
- _initRealTimeRenderingInterceptor() {
626
- const t = new H((n) => {
627
- this._commandService.onCommandExecuted((i) => {
628
- i.id === j.id && n.next(!0), i.id === ue.id && n.next(!1);
629
- });
630
- }), r = on([
631
- t,
632
- this._selectionManagerService.selectionMoveEnd$.pipe(
633
- an((n) => n ? n.map((i) => i.range) : [])
634
- )
635
- ]);
636
- this.disposeWithMe(
637
- fe(
638
- r.pipe(
639
- ln(
640
- ([n, i]) => new H((s) => {
641
- const o = new gt();
642
- return n && i.length && s.next({ selectionRanges: i, disposableCollection: o }), () => {
643
- o.dispose();
644
- };
645
- })
646
- ),
647
- un(() => {
648
- this._previewPattern = null;
649
- })
650
- ).subscribe(({ disposableCollection: n, selectionRanges: i }) => {
651
- var o, m;
652
- const s = this._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET);
653
- this.openPanel(), n.add(
654
- this._sheetInterceptorService.intercept(Kt.CELL_CONTENT, {
655
- priority: 99,
656
- effect: Pe.Value | Pe.Style,
657
- handler: (c, a, u) => {
658
- var p;
659
- const { row: l, col: v } = a, f = u(c) || {};
660
- if (i.find(
661
- (d) => d.startColumn <= v && d.endColumn >= v && d.startRow <= l && d.endRow >= l
662
- )) {
663
- const d = a.worksheet.getCellRaw(l, v), S = d == null ? void 0 : d.v, g = d == null ? void 0 : d.t;
664
- if (S == null || g !== w.NUMBER || this._previewPattern === null)
665
- return f;
666
- const I = kt(this._previewPattern, S, this._sheetsNumfmtCellContentController.locale);
667
- if (I.color) {
668
- const P = (p = this._themeService.getColorFromTheme(`${I.color}.500`)) != null ? p : I.color;
669
- return {
670
- ...f,
671
- v: I.result,
672
- t: w.STRING,
673
- s: { cl: { rgb: P } }
674
- };
675
- }
676
- return {
677
- ...f,
678
- v: I.result,
679
- t: w.STRING
680
- };
681
- }
682
- return f;
683
- }
684
- })
685
- ), (m = (o = this._renderManagerService.getRenderById(s.getUnitId())) == null ? void 0 : o.mainComponent) == null || m.makeDirty();
686
- })
687
- )
688
- );
689
- }
690
- _commandExecutedListener() {
691
- const t = [ye.id, be.id];
692
- this.disposeWithMe(
693
- new H((r) => {
694
- const n = this._commandService.onCommandExecuted((i) => {
695
- if (t.includes(i.id)) {
696
- const s = i.params;
697
- r.next(s.unitId);
698
- }
699
- });
700
- return () => n.dispose();
701
- }).pipe(mn(16)).subscribe((r) => this._forceUpdate(r))
702
- );
703
- }
704
- _initCloseListener() {
705
- this._univerInstanceService.getCurrentTypeOfUnit$(T.UNIVER_SHEET).subscribe((t) => {
706
- var r;
707
- t || ((r = this._sidebarDisposable) == null || r.dispose(), this._sidebarDisposable = null);
708
- });
709
- }
710
- };
711
- W = Gn([
712
- M(0, C(Je)),
713
- M(1, C(pt)),
714
- M(2, ge),
715
- M(3, _e),
716
- M(4, C(Ce)),
717
- M(5, We),
718
- M(6, Se),
719
- M(7, C(Qe)),
720
- M(8, en),
721
- M(9, C(E)),
722
- M(10, C(Ke))
723
- ], W);
724
- var Kn = Object.getOwnPropertyDescriptor, Yn = (e, t, r, n) => {
725
- for (var i = n > 1 ? void 0 : n ? Kn(t, r) : t, s = e.length - 1, o; s >= 0; s--)
726
- (o = e[s]) && (i = o(i) || i);
727
- return i;
728
- }, L = (e, t) => (r, n) => t(r, n, e);
729
- const Zn = () => {
730
- let e = [];
731
- return {
732
- add: (i, s, o, m, c) => e.push({ unitId: i, subUnitId: s, row: o, col: m, value: c }),
733
- getEffects: () => e,
734
- clean: () => {
735
- e = [];
736
- }
737
- };
738
- };
739
- let ee = class extends ne {
740
- constructor(t, r, n, i, s) {
741
- super();
742
- // collect effect mutations when edit end and push this to commands stack in next commands progress
743
- J(this, "_collectEffectMutation", Zn());
744
- this._sheetInterceptorService = t, this._numfmtService = r, this._univerInstanceService = n, this._injector = i, this._editorBridgeService = s, this._initInterceptorEditorStart(), this._initInterceptorEditorEnd(), this._initInterceptorCommands();
745
- }
746
- _initInterceptorEditorStart() {
747
- this._editorBridgeService && this.disposeWithMe(
748
- fe(
749
- this._sheetInterceptorService.writeCellInterceptor.intercept(Yt, {
750
- handler: (t, r, n) => {
751
- const i = r.row, s = r.col, o = this._numfmtService.getValue(
752
- r.unitId,
753
- r.subUnitId,
754
- i,
755
- s
756
- );
757
- if (o)
758
- switch (A(o.pattern)) {
759
- /**
760
- * For scientific, currency, grouped and number format, the editor should display the raw number value without format, unlike the cell render which display the formatted value.
761
- */
762
- case "scientific":
763
- case "currency":
764
- case "grouped":
765
- case "number": {
766
- const c = { ...r.worksheet.getCellRaw(i, s) };
767
- return (c == null ? void 0 : c.t) === w.NUMBER && ve(c.v) && (c.v = ae(Number(c.v))), n && n(c);
768
- }
769
- /**
770
- * For percent format, the editor should display the full percent value, unlike the cell render which display the limited decimal places.
771
- * e.g. { v: 1.001234567, t: 2, s: { n: { pattern: '0.00%' } } } should display as '100.12%' in cell render, but when edit this cell, the editor should display '100.1234567%' rather than '100.12%'.
772
- * If the editor also display '100.12%', will lose precision when before edit.
773
- */
774
- case "percent": {
775
- const c = { ...r.worksheet.getCellRaw(i, s) };
776
- return (c == null ? void 0 : c.t) === w.NUMBER && ve(c.v) && (c.v = `${ae(Number(c.v) * 100)}%`), n && n(c);
777
- }
778
- default:
779
- return n && n(t);
780
- }
781
- return n(t);
782
- }
783
- })
784
- )
785
- );
786
- }
787
- /**
788
- * Process the values after edit
789
- * @private
790
- * @memberof NumfmtService
791
- */
792
- // eslint-disable-next-line max-lines-per-function
793
- _initInterceptorEditorEnd() {
794
- this.disposeWithMe(
795
- fe(
796
- this._sheetInterceptorService.writeCellInterceptor.intercept(Zt, {
797
- // eslint-disable-next-line max-lines-per-function,complexity
798
- handler: (t, r, n) => {
799
- var a, u, l;
800
- if (!(t != null && t.v) && !(t != null && t.p))
801
- return n(t);
802
- this._collectEffectMutation.clean();
803
- const i = this._numfmtService.getValue(
804
- r.unitId,
805
- r.subUnitId,
806
- r.row,
807
- r.col
808
- ), s = r.worksheet.getCellRaw(r.row, r.col);
809
- if (Le(i == null ? void 0 : i.pattern) || t.t === w.FORCE_STRING)
810
- return n(t);
811
- const o = (a = t.p) == null ? void 0 : a.body, m = (l = (u = t == null ? void 0 : t.p) == null ? void 0 : u.body) != null && l.dataStream ? t.p.body.dataStream.replace(/\r\n$/, "") : String(t.v), c = St(m);
812
- if (o)
813
- if (zn(o)) {
814
- const { dataStream: v } = o, f = v.replace(/\r\n$/, ""), p = Number(f);
815
- if (Number.isNaN(p) && !c)
816
- return n(t);
817
- } else
818
- return n(t);
819
- if (c) {
820
- if (!c.z && !(i != null && i.pattern) && (s == null ? void 0 : s.t) !== w.STRING && (s == null ? void 0 : s.t) !== w.FORCE_STRING && Ct(m))
821
- return n({
822
- ...t,
823
- p: void 0,
824
- v: m,
825
- t: w.FORCE_STRING
826
- });
827
- c.z && (!(i != null && i.pattern) || A(c.z) !== A(i.pattern)) && this._collectEffectMutation.add(
828
- r.unitId,
829
- r.subUnitId,
830
- r.row,
831
- r.col,
832
- {
833
- pattern: c.z
834
- }
835
- );
836
- const v = ae(Number(c.v), 16);
837
- return n({ ...t, p: void 0, v, t: w.NUMBER });
838
- }
839
- return n(t);
840
- }
841
- })
842
- )
843
- );
844
- }
845
- _initInterceptorCommands() {
846
- const t = this;
847
- this.disposeWithMe(
848
- this._sheetInterceptorService.interceptCommand({
849
- getMutations(r) {
850
- var n;
851
- switch (r.id) {
852
- case zt.id: {
853
- const i = t._univerInstanceService.getCurrentUnitForType(T.UNIVER_SHEET), s = i.getUnitId(), o = (n = i.getActiveSheet()) == null ? void 0 : n.getSheetId();
854
- if (!o)
855
- return {
856
- redos: [],
857
- undos: []
858
- };
859
- const m = t._collectEffectMutation.getEffects();
860
- if (t._collectEffectMutation.clean(), !m.length)
861
- return {
862
- redos: [],
863
- undos: []
864
- };
865
- const c = m.filter((v) => {
866
- var f;
867
- return !!((f = v.value) != null && f.pattern);
868
- }).map((v) => ({
869
- row: v.row,
870
- col: v.col,
871
- pattern: v.value.pattern
872
- })), a = m.filter((v) => {
873
- var f;
874
- return !((f = v.value) != null && f.pattern);
875
- }).map((v) => ({
876
- startRow: v.row,
877
- endColumn: v.col,
878
- startColumn: v.col,
879
- endRow: v.row
880
- })), u = [], l = [];
881
- if (c.length) {
882
- const v = {
883
- id: be.id,
884
- params: Xt(s, o, c)
885
- };
886
- u.push(v), l.push(...qt(t._injector, v.params));
887
- }
888
- if (a.length) {
889
- const v = {
890
- id: ye.id,
891
- params: {
892
- unitId: s,
893
- subUnitId: o,
894
- ranges: a
895
- }
896
- };
897
- u.push(v), l.push(...Jt(t._injector, v.params));
898
- }
899
- return {
900
- redos: u,
901
- undos: l.reverse()
902
- };
903
- }
904
- }
905
- return {
906
- redos: [],
907
- undos: []
908
- };
909
- }
910
- })
911
- );
912
- }
913
- dispose() {
914
- super.dispose(), this._collectEffectMutation.clean();
915
- }
916
- };
917
- ee = Yn([
918
- L(0, C(Je)),
919
- L(1, C(Se)),
920
- L(2, C(ge)),
921
- L(3, C(Be)),
922
- L(4, _t(Wt))
923
- ], ee);
924
- function zn(e) {
925
- const { textRuns: t = [], paragraphs: r = [], customRanges: n, customBlocks: i = [] } = e, s = ["va"];
926
- return !(t.some((o) => !!(o.ts && Object.keys(o.ts).some((c) => s.includes(c)))) || r.some((o) => o.bullet) || r.length >= 2 || n != null && n.length || i.length > 0);
927
- }
928
- const ct = (e) => [
929
- {
930
- label: "sheet.numfmt.general",
931
- pattern: null
932
- },
933
- {
934
- label: "sheet.numfmt.text",
935
- pattern: It
936
- },
937
- "|",
938
- {
939
- label: "sheet.numfmt.number",
940
- pattern: "0"
941
- },
942
- {
943
- label: "sheet.numfmt.percent",
944
- pattern: "0.00%"
945
- },
946
- {
947
- label: "sheet.numfmt.scientific",
948
- pattern: "0.00E+00"
949
- },
950
- "|",
951
- {
952
- label: "sheet.numfmt.accounting",
953
- pattern: `"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`
954
- },
955
- {
956
- label: "sheet.numfmt.financialValue",
957
- pattern: "#,##0.00;[Red]#,##0.00"
958
- },
959
- {
960
- label: "sheet.numfmt.currency",
961
- pattern: `"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`
962
- },
963
- {
964
- label: "sheet.numfmt.roundingCurrency",
965
- pattern: `"${e}"#,##0;[Red]"${e}"#,##0`
966
- },
967
- "|",
968
- {
969
- label: "sheet.numfmt.date",
970
- pattern: "yyyy-mm-dd;@"
971
- },
972
- {
973
- label: "sheet.numfmt.time",
974
- pattern: 'am/pm h":"mm":"ss'
975
- },
976
- {
977
- label: "sheet.numfmt.dateTime",
978
- pattern: "yyyy-m-d am/pm h:mm"
979
- },
980
- {
981
- label: "sheet.numfmt.timeDuration",
982
- pattern: "h:mm:ss"
983
- },
984
- "|",
985
- {
986
- label: "sheet.numfmt.moreFmt",
987
- pattern: ""
988
- }
989
- ], Xn = (e) => ({
990
- icon: new H((t) => {
991
- const r = e.get(E);
992
- return t.next(xe(r.getCurrentLocale()).icon), r.localeChanged$.subscribe(() => {
993
- t.next(xe(r.getCurrentLocale()).icon);
994
- });
995
- }),
996
- id: Xe.id,
997
- title: "sheet.numfmt.currency",
998
- tooltip: "sheet.numfmt.currency",
999
- type: q.BUTTON,
1000
- hidden$: X(e, T.UNIVER_SHEET),
1001
- disabled$: G(e, { workbookTypes: [z], worksheetTypes: [Y, Z], rangeTypes: [K] })
1002
- }), qn = (e) => ({
1003
- icon: "AddDigitsIcon",
1004
- id: ze.id,
1005
- title: "sheet.numfmt.addDecimal",
1006
- tooltip: "sheet.numfmt.addDecimal",
1007
- type: q.BUTTON,
1008
- hidden$: X(e, T.UNIVER_SHEET),
1009
- disabled$: G(e, { workbookTypes: [z], worksheetTypes: [Y, Z], rangeTypes: [K] })
1010
- }), Jn = (e) => ({
1011
- icon: "ReduceDigitsIcon",
1012
- id: Ze.id,
1013
- title: "sheet.numfmt.subtractDecimal",
1014
- tooltip: "sheet.numfmt.subtractDecimal",
1015
- type: q.BUTTON,
1016
- hidden$: X(e, T.UNIVER_SHEET),
1017
- disabled$: G(e, { workbookTypes: [z], worksheetTypes: [Y, Z], rangeTypes: [K] })
1018
- }), Qn = (e) => ({
1019
- icon: "PercentIcon",
1020
- id: qe.id,
1021
- title: "sheet.numfmt.percent",
1022
- tooltip: "sheet.numfmt.percent",
1023
- type: q.BUTTON,
1024
- hidden$: X(e, T.UNIVER_SHEET),
1025
- disabled$: G(e, { workbookTypes: [z], worksheetTypes: [Y, Z], rangeTypes: [K] })
1026
- }), er = (e) => {
1027
- const t = e.get(ge), r = e.get(_e), n = e.get(E), i = e.get(Ce), s = [ye.id, be.id], o = Vt(
1028
- t,
1029
- "",
1030
- ({ workbook: m, worksheet: c }) => new H(
1031
- (a) => et(
1032
- i.selectionMoveEnd$,
1033
- yt(r.onCommandExecuted.bind(r)).pipe(
1034
- cn(([u]) => s.includes(u.id))
1035
- )
1036
- ).subscribe(() => {
1037
- var l, v;
1038
- const u = i.getCurrentSelections();
1039
- if (u && u[0]) {
1040
- const f = u[0].range, p = f.startRow, d = f.startColumn, S = (v = m.getStyles().get((l = c.getCell(p, d)) == null ? void 0 : l.s)) == null ? void 0 : v.n, g = S == null ? void 0 : S.pattern, I = Ut(n.getCurrentLocale());
1041
- let P = n.t("sheet.numfmt.general");
1042
- if (bt(g)) {
1043
- a.next(P);
1044
- return;
1045
- }
1046
- if (g) {
1047
- const x = ct(I).filter((O) => typeof O == "object" && O.pattern).find(
1048
- (O) => re(g, O.pattern)
1049
- );
1050
- x && typeof x == "object" && x.pattern ? P = n.t(x.label) : P = n.t("sheet.numfmt.moreFmt");
1051
- }
1052
- a.next(P);
1053
- }
1054
- })
1055
- )
1056
- );
1057
- return {
1058
- label: at,
1059
- id: j.id,
1060
- tooltip: "sheet.numfmt.title",
1061
- type: q.SELECTOR,
1062
- slot: !0,
1063
- selections: [{
1064
- label: {
1065
- name: lt,
1066
- hoverable: !1,
1067
- selectable: !1
1068
- }
1069
- }],
1070
- value$: o,
1071
- hidden$: X(e, T.UNIVER_SHEET),
1072
- disabled$: G(e, { workbookTypes: [z], worksheetTypes: [Z, Y], rangeTypes: [K] })
1073
- };
1074
- }, at = "sheet.numfmt.moreNumfmtType", lt = "sheet.numfmt.moreNumfmtType.options";
1075
- function tr(e) {
1076
- const { value: t } = e, r = b(E), n = t != null ? t : r.t("sheet.numfmt.general");
1077
- return /* @__PURE__ */ h("span", { className: "univer-text-sm", children: n });
1078
- }
1079
- function nr() {
1080
- const e = b(_e), t = b(E), r = b(tn), n = b(Ke), i = b(Ce), s = (a) => {
1081
- const u = i.getCurrentLastSelection();
1082
- if (!u)
1083
- return;
1084
- const l = u.range, v = [];
1085
- je.foreach(l, (f, p) => {
1086
- a ? v.push({ row: f, col: p, pattern: a, type: A(a) }) : v.push({ row: f, col: p });
1087
- }), e.executeCommand(Ye.id, { values: v }), r.focus();
1088
- }, o = R(() => {
1089
- const a = Dt.get(t.getCurrentLocale());
1090
- return ct(a);
1091
- }, [t]), m = (a) => {
1092
- if (a === 0)
1093
- s(null);
1094
- else if (a === o.length - 1)
1095
- e.executeCommand(j.id), r.focus();
1096
- else {
1097
- const u = o[a];
1098
- u.pattern && s(u.pattern);
1099
- }
1100
- }, c = 1220;
1101
- return /* @__PURE__ */ h("div", { className: "univer-grid univer-gap-1 univer-p-1.5", children: o.map((a, u) => a === "|" ? /* @__PURE__ */ h(_n, {}, u) : /* @__PURE__ */ y(
1102
- "div",
1103
- {
1104
- className: "univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
1105
- onClick: () => m(u),
1106
- children: [
1107
- /* @__PURE__ */ h("span", { children: t.t(a.label) }),
1108
- /* @__PURE__ */ h(
1109
- "span",
1110
- {
1111
- className: "univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400",
1112
- children: a.pattern ? Ft(a.pattern || "", c, n.locale).result.trim() : ""
1113
- }
1114
- )
1115
- ]
1116
- },
1117
- u
1118
- )) });
1119
- }
1120
- const rr = {
1121
- [nn.LAYOUT]: {
1122
- [j.id]: {
1123
- order: 9,
1124
- menuItemFactory: er
1125
- },
1126
- [qe.id]: {
1127
- order: 9.1,
1128
- menuItemFactory: Qn
1129
- },
1130
- [Xe.id]: {
1131
- order: 9.2,
1132
- menuItemFactory: Xn
1133
- },
1134
- [ze.id]: {
1135
- order: 9.3,
1136
- menuItemFactory: qn
1137
- },
1138
- [Ze.id]: {
1139
- order: 9.4,
1140
- menuItemFactory: Jn
1141
- }
1142
- }
1143
- };
1144
- var ir = Object.getOwnPropertyDescriptor, sr = (e, t, r, n) => {
1145
- for (var i = n > 1 ? void 0 : n ? ir(t, r) : t, s = e.length - 1, o; s >= 0; s--)
1146
- (o = e[s]) && (i = o(i) || i);
1147
- return i;
1148
- }, De = (e, t) => (r, n) => t(r, n, e);
1149
- let te = class extends ne {
1150
- constructor(e, t) {
1151
- super(), this._componentManager = e, this._menuManagerService = t, this._initMenu();
1152
- }
1153
- _initMenu() {
1154
- this._menuManagerService.mergeMenu(rr), [
1155
- [at, tr],
1156
- [lt, nr]
1157
- ].forEach(([e, t]) => {
1158
- this.disposeWithMe(
1159
- this._componentManager.register(e, t)
1160
- );
1161
- });
1162
- }
1163
- };
1164
- te = sr([
1165
- De(0, C(Qe)),
1166
- De(1, rn)
1167
- ], te);
1168
- var or = Object.defineProperty, cr = Object.getOwnPropertyDescriptor, ar = (e, t, r) => t in e ? or(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, lr = (e, t, r, n) => {
1169
- for (var i = n > 1 ? void 0 : n ? cr(t, r) : t, s = e.length - 1, o; s >= 0; s--)
1170
- (o = e[s]) && (i = o(i) || i);
1171
- return i;
1172
- }, he = (e, t) => (r, n) => t(r, n, e), se = (e, t, r) => ar(e, typeof t != "symbol" ? t + "" : t, r);
1173
- let D = class extends Et {
1174
- constructor(e = Oe, t, r, n) {
1175
- super(), this._config = e, this._injector = t, this._configService = r, this._renderManagerService = n;
1176
- const { menu: i, ...s } = Tt(
1177
- {},
1178
- Oe,
1179
- this._config
1180
- );
1181
- i && this._configService.setConfig("menu", i, { merge: !0 }), this._configService.setConfig("sheets-numfmt-ui.config", s);
1182
- }
1183
- onStarting() {
1184
- Mt(this._injector, [
1185
- [W],
1186
- [ee],
1187
- [B],
1188
- [te]
1189
- ]);
1190
- }
1191
- onRendered() {
1192
- this._registerRenderModules(), wt(this._injector, [
1193
- [W],
1194
- [ee],
1195
- [te]
1196
- ]);
1197
- }
1198
- _registerRenderModules() {
1199
- [
1200
- [pe]
1201
- ].forEach((t) => {
1202
- this.disposeWithMe(this._renderManagerService.registerRenderModule(T.UNIVER_SHEET, t));
1203
- });
1204
- }
1205
- };
1206
- se(D, "pluginName", "SHEET_NUMFMT_UI_PLUGIN");
1207
- se(D, "packageName", rt.name);
1208
- se(D, "version", rt.version);
1209
- se(D, "type", T.UNIVER_SHEET);
1210
- D = lr([
1211
- Nt(Gt, Lt),
1212
- he(1, C(Be)),
1213
- he(2, Fe),
1214
- he(3, We)
1215
- ], D);
1216
- export {
1217
- D as UniverSheetsNumfmtUIPlugin
1218
- };
1
+ import{CellValueType as e,CommandType as t,DEFAULT_TEXT_FORMAT_EXCEL as n,DependentOn as r,Disposable as i,DisposableCollection as a,ICommandService as o,IConfigService as s,ILocalStorageService as c,IUniverInstanceService as l,Inject as u,Injector as d,InterceptorEffectEnum as f,LocaleService as p,Optional as m,Plugin as h,Range as ee,ThemeService as g,Tools as _,UniverInstanceType as v,fromCallback as te,getNumfmtParseValueFilter as ne,isDefaultFormat as re,isPatternEqualWithoutDecimal as y,isRealNum as b,isTextFormat as ie,merge as ae,numfmt as oe,registerDependencies as se,toDisposable as ce,touchDependencies as le,willLoseNumericPrecision as ue}from"@univerjs/core";import{IRenderManagerService as de}from"@univerjs/engine-render";import{AddDecimalCommand as fe,CURRENCYFORMAT as pe,DATEFMTLISG as me,NUMBERFORMAT as he,SHEETS_NUMFMT_PLUGIN_CONFIG_KEY as ge,SetCurrencyCommand as _e,SetNumfmtCommand as ve,SetPercentCommand as ye,SheetsNumfmtCellContentController as be,SubtractDecimalCommand as xe,UniverSheetsNumfmtPlugin as Se,currencySymbols as Ce,getCurrencyFormatOptions as x,getCurrencySymbolByLocale as we,getCurrencySymbolIconByLocale as Te,getCurrencyType as S,getDateFormatOptions as Ee,getDecimalFromPattern as C,getNumberFormatOptions as De,getPatternPreview as Oe,getPatternPreviewIgnoreGeneral as ke,getPatternType as w,isPatternHasDecimal as Ae,localeCurrencySymbolMap as je,setPatternDecimal as T}from"@univerjs/sheets-numfmt";import{CellAlertManagerService as Me,CellAlertType as Ne,HoverManagerService as Pe,IEditorBridgeService as Fe,SheetSkeletonManagerService as Ie,UniverSheetsUIPlugin as Le,deriveStateFromActiveSheet$ as Re,getCurrentRangeDisable$ as E}from"@univerjs/sheets-ui";import{AFTER_CELL_EDIT as ze,BEFORE_CELL_EDIT as Be,INTERCEPTOR_POINT as Ve,INumfmtService as He,RangeProtectionPermissionEditPoint as D,RemoveNumfmtMutation as O,SetNumfmtMutation as Ue,SetRangeValuesCommand as We,SheetInterceptorService as Ge,SheetsSelectionsService as Ke,WorkbookEditablePermission as k,WorksheetEditPermission as A,WorksheetSetCellStylePermission as j,factoryRemoveNumfmtUndoMutation as qe,factorySetNumfmtUndoMutation as Je,transformCellsToRange as Ye}from"@univerjs/sheets";import{ComponentManager as Xe,ILayoutService as Ze,IMenuManagerService as Qe,ISidebarService as $e,IZenZoneService as et,MenuItemType as M,RibbonStartGroup as tt,getMenuHiddenObservable as N,useDependency as P}from"@univerjs/ui";import{Observable as F,combineLatest as nt,debounceTime as rt,filter as it,merge as at}from"rxjs";import{debounceTime as ot,map as st,switchMap as ct,tap as lt}from"rxjs/operators";import{Button as ut,Input as dt,InputNumber as ft,Select as I,SelectList as pt,Separator as mt,borderClassName as ht,clsx as gt,scrollbarClassName as _t}from"@univerjs/design";import{createContext as vt,createElement as yt,useCallback as bt,useContext as xt,useEffect as L,useMemo as R,useRef as St,useState as z}from"react";import{jsx as B,jsxs as V}from"react/jsx-runtime";import{CheckMarkIcon as Ct}from"@univerjs/icons";import{stripErrorMargin as H}from"@univerjs/engine-formula";var wt=`@univerjs/sheets-numfmt-ui`,Tt=`0.18.0`;const Et={};function U(e,t){return function(n,r){t(n,r,e)}}function W(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const G=`SHEET_NUMFMT_ALERT`;let Dt=class extends i{constructor(e,t,n,r,i,a,o){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._zenZoneService=i,this._numfmtService=a,this._configService=o,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(rt(100)).subscribe(e=>{if(e){let r=e.location,i=this._context.unit,a=i.getActiveSheet();if(!a)return this._hideAlert();let o=r.unitId,s=r.subUnitId,c,l=a.getCell(r.row,r.col);if(l!=null&&l.s){let e=i.getStyles().get(l.s);e!=null&&e.n&&(c=e.n)}if(c||(c=this._numfmtService.getValue(o,s,r.row,r.col)),!c){this._hideAlert();return}if(ie(c.pattern)&&_.isDefine(l==null?void 0:l.v)&&b(l.v)){var t,n;if((t=this._configService.getConfig(ge))!=null&&t.disableTextFormatAlert)return;let e=this._cellAlertManagerService.currentAlert.get(G),i=e==null||(n=e.alert)==null?void 0:n.location;if(i&&i.row===r.row&&i.col===r.col&&i.subUnitId===r.subUnitId&&i.unitId===r.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:Ne.ERROR,title:this._localeService.t(`info.error`),message:this._localeService.t(`info.forceStringInfo`),location:r,width:200,height:74,key:G});return}}this._hideAlert()}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(G)}};Dt=W([U(1,u(Pe)),U(2,u(Me)),U(3,u(p)),U(4,et),U(5,u(He)),U(6,s)],Dt);const Ot={id:`sheet.operation.close.numfmt.panel`,type:t.OPERATION,handler:()=>!0},K={id:`sheet.operation.open.numfmt.panel`,type:t.OPERATION,handler:e=>(e.get(X).openPanel(),!0)},kt=vt([]);let q=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};q=W([U(0,u(c))],q);const At=`numfmtCurrency`,jt=e=>{let t=P(q),[n,r]=z(Ce);return L(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(At,[...Ce]).then(t=>{r(t),e&&e(t)})})},[]),{userHabitCurrency:n,mark:e=>{t.markHabit(At,e)}}},Mt=()=>{let e=St([]),[t,n]=z({});return L(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}},Nt=e=>!!S(e)&&e.startsWith(`_(`),Pt=e=>{let{defaultPattern:t,action:n,onChange:r}=e,[i,a]=z(()=>C(t||``,2)),o=xt(kt),[s,c]=z(()=>S(t)||o[0]),l=R(()=>o.map(e=>({label:e,value:e})),[]),u=P(p).t;return n.current=()=>T(`_("${s}"* #,##0${i>0?`.0`:``}_)`,i),V(`div`,{children:[V(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[V(`div`,{className:`option`,children:[B(`div`,{className:`univer-text-sm univer-text-gray-400`,children:u(`sheet.numfmt.decimalLength`)}),B(`div`,{className:`univer-mt-2 univer-w-32`,children:B(ft,{value:i,step:1,precision:0,max:20,min:0,onChange:e=>{let t=e||0;a(t),r(T(`_("${s}"* #,##0${t>0?`.0`:``}_)`,t))}})})]}),V(`div`,{className:`option`,children:[B(`div`,{className:`univer-text-sm univer-text-gray-400`,children:u(`sheet.numfmt.currencyType`)}),B(`div`,{className:`univer-mt-2 univer-w-36`,children:B(I,{options:l,value:s,onChange:e=>{c(e),r(T(`_("${e}"* #,##0${i>0?`.0`:``}_)`,i))}})})]})]}),B(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:u(`sheet.numfmt.accountingDes`)})]})},Ft=e=>!!S(e)&&!e.startsWith(`_(`),It=e=>{let t=P(p).t,n=xt(kt),[r,i]=z(()=>S(e.defaultPattern)||n[0]),[a,o]=z(()=>C(e.defaultPattern||``,2)),[s,c]=z(()=>{var t;let n=x(r);return((t=n.find(t=>y(t.value,e.defaultPattern)))==null?void 0:t.value)||n[0].value}),l=R(()=>x(r),[r]),u=R(()=>n.map(e=>({label:e,value:e})),[n]);return e.action.current=()=>T(s,a),V(`div`,{children:[V(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[V(`div`,{className:`option`,children:[B(`div`,{className:`univer-text-sm univer-text-gray-400`,children:t(`sheet.numfmt.decimalLength`)}),B(`div`,{className:`univer-mt-2 univer-w-32`,children:B(ft,{value:a,max:20,min:0,onChange:t=>{o(t||0),e.onChange(T(s,t||0))}})})]}),V(`div`,{className:`option`,children:[B(`div`,{className:`univer-text-sm univer-text-gray-400`,children:t(`sheet.numfmt.currencyType`)}),B(`div`,{className:`univer-mt-2 univer-w-36`,children:B(I,{value:r,options:u,onChange:t=>{if(t===void 0)return;i(t);let n=x(t)[0].value;c(n),e.onChange(T(n,a))}})})]})]}),B(`div`,{className:`label univer-mt-4`,children:t(`sheet.numfmt.negType`)}),B(`div`,{className:`univer-mt-2`,children:B(pt,{value:s,options:l,onChange:t=>{t!==void 0&&(c(t),e.onChange(T(t,a)))}})}),B(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:t(`sheet.numfmt.currencyDes`)})]})},Lt=`customFormat`,Rt=`numfmt_custom_pattern`;function zt(e){let{defaultPattern:t,action:n,onChange:r}=e,i=P(q),a=P(c),o=P(p),[s,l]=z(t);n.current=()=>(i.markHabit(Lt,s),a.getItem(Rt).then((e=[])=>{let t=[...new Set([s,...e||[]])].splice(0,10).filter(e=>!!e);a.setItem(Rt,t)}),s);let[u,d]=z([]);L(()=>{a.getItem(Rt).then(e=>{let t=[...pe.map(e=>e.suffix(`$`)),...me.map(e=>e.suffix),...he.map(e=>e.suffix)];t.push(...e||[]),i.addHabit(Lt,[]).finally(()=>{i.getHabit(Lt,t).then(e=>{d([...new Set(e)])})})})},[]);let f=e=>{l(e),r(e)};return V(`div`,{children:[B(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheet.numfmt.customFormat`)}),B(dt,{placeholder:o.t(`sheet.numfmt.customFormat`),onBlur:()=>{r(s)},value:s,onChange:l,className:`univer-mt-2 univer-w-full`}),B(`div`,{className:gt(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,ht),children:u.map(e=>V(`div`,{onClick:()=>f(e),className:`
2
+ univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5
3
+ univer-text-sm
4
+ `,children:[B(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:s===e&&B(Ct,{})}),B(`div`,{children:e})]},e))}),B(`div`,{className:`
5
+ univer-mt-3 univer-text-sm univer-text-gray-600
6
+ dark:!univer-text-gray-200
7
+ `,children:o.t(`sheet.numfmt.customFormatDes`)})]})}const Bt=e=>{let t=oe.getFormatInfo(e);return Ee().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(t.type)};function Vt(e){let{onChange:t,defaultPattern:n}=e,r=R(Ee,[]),i=P(p),[a,o]=z(()=>{if(n){let e=r.find(e=>e.value===n);if(e)return e.value}return r[0].value});return e.action.current=()=>a,V(`div`,{children:[B(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:i.t(`sheet.numfmt.dateType`)}),B(`div`,{className:`univer-mt-2`,children:B(pt,{value:a,options:r,onChange:e=>{e!==void 0&&(o(e),t(e))}})}),B(`div`,{className:`
8
+ univer-mt-3.5 univer-text-sm/5 univer-text-gray-600
9
+ dark:!univer-text-gray-200
10
+ `,children:i.t(`sheet.numfmt.dateDes`)})]})}const Ht=e=>!e,Ut=e=>{let t=P(p).t;return e.action.current=()=>``,B(`div`,{children:B(`div`,{className:`
11
+ univer-mt-3.5 univer-text-sm/5 univer-text-gray-600
12
+ dark:!univer-text-gray-200
13
+ `,children:t(`sheet.numfmt.generalDes`)})})},Wt=e=>De().some(t=>y(t.value,e));function Gt(e){let t=P(p),n=R(De,[]),[r,i]=z(()=>C(e.defaultPattern||``,0)),[a,o]=z(()=>{let t=n.find(t=>y(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||n[0].value}),s=R(()=>T(a,Number(r||0)),[a,r]),c=R(()=>!Ae(a),[a]),l=t=>{i(t||0),e.onChange(T(a,Number(t||0)))},u=t=>{t!==void 0&&(i(C(t,0)),o(t),e.onChange(t))};return e.action.current=()=>s,V(`div`,{children:[B(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:t.t(`sheet.numfmt.decimalLength`)}),B(`div`,{className:`univer-mt-2`,children:B(ft,{disabled:c,value:r,max:20,min:0,onChange:l})}),V(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,t.t(`sheet.numfmt.negType`)]}),B(`div`,{className:`univer-mt-2`,children:B(pt,{onChange:u,options:n,value:a})}),B(`div`,{className:`
14
+ univer-mt-3.5 univer-text-sm/5 univer-text-gray-600
15
+ dark:!univer-text-gray-200
16
+ `,children:t.t(`sheet.numfmt.thousandthPercentileDes`)})]})}const Kt=e=>{let{defaultValue:t,defaultPattern:n,row:r,col:i}=e.value,a=P(p),o=St(()=>``),s=a.t,c=Mt(),l=R(()=>[{label:`sheet.numfmt.general`,component:Ut},{label:`sheet.numfmt.accounting`,component:Pt},{label:`sheet.numfmt.currency`,component:It},{label:`sheet.numfmt.date`,component:Vt},{label:`sheet.numfmt.thousandthPercentile`,component:Gt},{label:`sheet.numfmt.customFormat`,component:zt}].map(e=>({...e,label:s(e.label)})),[]),[u,d]=z(_),[f,m]=z(()=>`${r}_${i}`),{mark:h,userHabitCurrency:ee}=jt(()=>m(`${r}_${i}_userCurrency'`)),g=R(()=>{var e;return(e=l.find(e=>e.label===u))==null?void 0:e.component},[u]);function _(){return[Ht,Nt,Ft,Bt,Wt].reduce((e,t,r)=>e||(t(n)?l[r].label:``),``)||l[0].label}let v=l.map(e=>({label:e.label,value:e.label})),te=t=>{d(t),c(()=>e.onChange({type:`change`,value:o.current()||``}))},ne=bt(t=>{e.onChange({type:`change`,value:t})},[]),re=()=>{let t=o.current()||``,n=S(t);n&&h(n),e.onChange({type:`confirm`,value:t})},y=()=>{e.onChange({type:`cancel`,value:``})},b={onChange:ne,defaultValue:t,defaultPattern:n,action:o};return L(()=>{d(_()),m(`${r}_${i}`)},[r,i]),V(`div`,{className:gt(`
17
+ univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5
18
+ `,_t),children:[V(`div`,{children:[B(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:s(`sheet.numfmt.numfmtType`)}),B(`div`,{className:`univer-mt-2`,children:B(I,{className:`univer-w-full`,value:u,options:v,onChange:te})}),B(`div`,{children:g&&B(kt.Provider,{value:ee,children:yt(g,{...b,key:f})})})]}),V(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end`,children:[B(ut,{onClick:y,className:`univer-mr-3`,children:s(`sheet.numfmt.cancel`)}),B(ut,{variant:`primary`,onClick:re,children:s(`sheet.numfmt.confirm`)})]})]})};function J(e){"@babel/helpers - typeof";return J=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},J(e)}function qt(e,t){if(J(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(J(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Jt(e){var t=qt(e,`string`);return J(t)==`symbol`?t:t+``}function Y(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Yt=`SHEET_NUMFMT_PANEL`;let X=class extends i{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._componentManager=s,this._sidebarService=c,this._localeService=l,this._sheetsNumfmtCellContentController=u,Y(this,`_previewPattern`,``),Y(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initPanel(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe(at(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var t;let n=this._sidebarService,r=this._selectionManagerService,i=this._commandService,a=this._univerInstanceService,o=this._numfmtService,s=this._localeService,c=(((t=r.getCurrentSelections())==null?void 0:t.map(e=>e.range))||[])[0];if(!c)return!1;let l=a.getCurrentUnitForType(v.UNIVER_SHEET),u=l.getActiveSheet();if(!u)return!1;let d=u.getCellRaw(c.startRow,c.startColumn),f=o.getValue(l.getUnitId(),u.getSheetId(),c.startRow,c.startColumn),p=``;f&&(p=f.pattern);let m=(d==null?void 0:d.t)===e.NUMBER?d.v:12345678,h={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var t;let a=((t=r.getCurrentSelections())==null?void 0:t.map(e=>e.range))||[],o={values:[]},s=w(e.value);a.forEach(t=>{ee.foreach(t,(t,n)=>{o.values.push({row:t,col:n,pattern:e.value,type:s})})}),i.executeCommand(ve.id,o),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:p,defaultValue:m,row:c.startRow,col:c.startColumn}};return this._sidebarDisposable=n.open({header:{title:s.t(`sheet.numfmt.title`)},children:{label:Yt,...h},onClose:()=>{this._forceUpdate(),i.executeCommand(Ot.id)}}),!0}_forceUpdate(e){var t;let n=this._renderManagerService.getRenderById(e==null?this._univerInstanceService.getCurrentUnitForType(v.UNIVER_SHEET).getUnitId():e);n==null||n.with(Ie).reCalculate(),n==null||(t=n.mainComponent)==null||t.makeDirty()}_initCommands(){[K,Ot].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initPanel(){this.disposeWithMe(this._componentManager.register(Yt,Kt))}_initRealTimeRenderingInterceptor(){let t=nt([new F(e=>{this._commandService.onCommandExecuted(t=>{t.id===K.id&&e.next(!0),t.id===Ot.id&&e.next(!1)})}),this._selectionManagerService.selectionMoveEnd$.pipe(st(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe(ce(t.pipe(ct(([e,t])=>new F(n=>{let r=new a;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:r}),()=>{r.dispose()}})),lt(()=>{this._previewPattern=null})).subscribe(({disposableCollection:t,selectionRanges:n})=>{var r;let i=this._univerInstanceService.getCurrentUnitForType(v.UNIVER_SHEET);this.openPanel(),t.add(this._sheetInterceptorService.intercept(Ve.CELL_CONTENT,{priority:99,effect:f.Value|f.Style,handler:(t,r,i)=>{let{row:a,col:o}=r,s=i(t)||{};if(n.find(e=>e.startColumn<=o&&e.endColumn>=o&&e.startRow<=a&&e.endRow>=a)){let t=r.worksheet.getCellRaw(a,o),n=t==null?void 0:t.v,i=t==null?void 0:t.t;if(n==null||i!==e.NUMBER||this._previewPattern===null)return s;let l=ke(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(l.color){var c;let t=(c=this._themeService.getColorFromTheme(`${l.color}.500`))==null?l.color:c;return{...s,v:l.result,t:e.STRING,s:{cl:{rgb:t}}}}return{...s,v:l.result,t:e.STRING}}return s}})),(r=this._renderManagerService.getRenderById(i.getUnitId()))==null||(r=r.mainComponent)==null||r.makeDirty()})))}_commandExecutedListener(){let e=[O.id,Ue.id];this.disposeWithMe(new F(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe(ot(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(v.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};X=W([U(0,u(Ge)),U(1,u(g)),U(2,l),U(3,o),U(4,u(Ke)),U(5,de),U(6,He),U(7,u(Xe)),U(8,$e),U(9,u(p)),U(10,u(be))],X);const Xt=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}};let Z=class extends i{constructor(e,t,n,r,i){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._editorBridgeService=i,Y(this,`_collectEffectMutation`,Xt()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe(ce(this._sheetInterceptorService.writeCellInterceptor.intercept(Be,{handler:(t,n,r)=>{let i=n.row,a=n.col,o=this._numfmtService.getValue(n.unitId,n.subUnitId,i,a);if(o)switch(w(o.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let t={...n.worksheet.getCellRaw(i,a)};return(t==null?void 0:t.t)===e.NUMBER&&b(t.v)&&(t.v=H(Number(t.v))),r&&r(t)}case`percent`:{let t={...n.worksheet.getCellRaw(i,a)};return(t==null?void 0:t.t)===e.NUMBER&&b(t.v)&&(t.v=`${H(Number(t.v)*100)}%`),r&&r(t)}default:return r&&r(t)}return r(t)}})))}_initInterceptorEditorEnd(){this.disposeWithMe(ce(this._sheetInterceptorService.writeCellInterceptor.intercept(ze,{handler:(t,n,r)=>{var i,a;if(!(t!=null&&t.v)&&!(t!=null&&t.p))return r(t);this._collectEffectMutation.clean();let o=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),s=n.worksheet.getCellRaw(n.row,n.col);if(ie(o==null?void 0:o.pattern)||t.t===e.FORCE_STRING)return r(t);let c=(i=t.p)==null?void 0:i.body,l=!(t==null||(a=t.p)==null||(a=a.body)==null)&&a.dataStream?t.p.body.dataStream.replace(/\r\n$/,``):String(t.v),u=ne(l);if(c)if(Zt(c)){let{dataStream:e}=c,n=e.replace(/\r\n$/,``),i=Number(n);if(Number.isNaN(i)&&!u)return r(t)}else return r(t);if(u){if(!u.z&&!(o!=null&&o.pattern)&&(s==null?void 0:s.t)!==e.STRING&&(s==null?void 0:s.t)!==e.FORCE_STRING&&ue(l))return r({...t,p:void 0,v:l,t:e.FORCE_STRING});u.z&&(!(o!=null&&o.pattern)||w(u.z)!==w(o.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:u.z});let i=H(Number(u.v),16);return r({...t,p:void 0,v:i,t:e.NUMBER})}return r(t)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case We.id:{var n;let t=e._univerInstanceService.getCurrentUnitForType(v.UNIVER_SHEET),r=t.getUnitId(),i=(n=t.getActiveSheet())==null?void 0:n.getSheetId();if(!i)return{redos:[],undos:[]};let a=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!a.length)return{redos:[],undos:[]};let o=a.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),s=a.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),c=[],l=[];if(o.length){let t={id:Ue.id,params:Ye(r,i,o)};c.push(t),l.push(...Je(e._injector,t.params))}if(s.length){let t={id:O.id,params:{unitId:r,subUnitId:i,ranges:s}};c.push(t),l.push(...qe(e._injector,t.params))}return{redos:c,undos:l.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};Z=W([U(0,u(Ge)),U(1,u(He)),U(2,u(l)),U(3,u(d)),U(4,m(Fe))],Z);function Zt(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}const Qt=e=>[{label:`sheet.numfmt.general`,pattern:null},{label:`sheet.numfmt.text`,pattern:n},`|`,{label:`sheet.numfmt.number`,pattern:`0`},{label:`sheet.numfmt.percent`,pattern:`0.00%`},{label:`sheet.numfmt.scientific`,pattern:`0.00E+00`},`|`,{label:`sheet.numfmt.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheet.numfmt.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheet.numfmt.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheet.numfmt.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheet.numfmt.date`,pattern:`yyyy-mm-dd;@`},{label:`sheet.numfmt.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheet.numfmt.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheet.numfmt.timeDuration`,pattern:`h:mm:ss`},`|`,{label:`sheet.numfmt.moreFmt`,pattern:``}],$t=e=>({icon:new F(t=>{let n=e.get(p);return t.next(Te(n.getCurrentLocale()).icon),n.localeChanged$.subscribe(()=>{t.next(Te(n.getCurrentLocale()).icon)})}),id:_e.id,title:`sheet.numfmt.currency`,tooltip:`sheet.numfmt.currency`,type:M.BUTTON,hidden$:N(e,v.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[k],worksheetTypes:[A,j],rangeTypes:[D]})}),en=e=>({icon:`AddDigitsIcon`,id:fe.id,title:`sheet.numfmt.addDecimal`,tooltip:`sheet.numfmt.addDecimal`,type:M.BUTTON,hidden$:N(e,v.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[k],worksheetTypes:[A,j],rangeTypes:[D]})}),tn=e=>({icon:`ReduceDigitsIcon`,id:xe.id,title:`sheet.numfmt.subtractDecimal`,tooltip:`sheet.numfmt.subtractDecimal`,type:M.BUTTON,hidden$:N(e,v.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[k],worksheetTypes:[A,j],rangeTypes:[D]})}),nn=e=>({icon:`PercentIcon`,id:ye.id,title:`sheet.numfmt.percent`,tooltip:`sheet.numfmt.percent`,type:M.BUTTON,hidden$:N(e,v.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[k],worksheetTypes:[A,j],rangeTypes:[D]})}),rn=e=>{let t=e.get(l),n=e.get(o),r=e.get(p),i=e.get(Ke),a=[O.id,Ue.id],s=Re(t,``,({workbook:e,worksheet:t})=>new F(o=>at(i.selectionMoveEnd$,te(n.onCommandExecuted.bind(n)).pipe(it(([e])=>a.includes(e.id)))).subscribe(()=>{let n=i.getCurrentSelections();if(n&&n[0]){var a,s;let i=n[0].range,c=i.startRow,l=i.startColumn,u=(a=e.getStyles().get((s=t.getCell(c,l))==null?void 0:s.s))==null?void 0:a.n,d=u==null?void 0:u.pattern,f=we(r.getCurrentLocale()),p=r.t(`sheet.numfmt.general`);if(re(d)){o.next(p);return}if(d){let e=Qt(f).filter(e=>typeof e==`object`&&e.pattern).find(e=>y(d,e.pattern));p=e&&typeof e==`object`&&e.pattern?r.t(e.label):r.t(`sheet.numfmt.moreFmt`)}o.next(p)}})));return{label:an,id:K.id,tooltip:`sheet.numfmt.title`,type:M.SELECTOR,slot:!0,selections:[{label:{name:on,hoverable:!1,selectable:!1}}],value$:s,hidden$:N(e,v.UNIVER_SHEET),disabled$:E(e,{workbookTypes:[k],worksheetTypes:[j,A],rangeTypes:[D]})}},an=`sheet.numfmt.moreNumfmtType`,on=`sheet.numfmt.moreNumfmtType.options`;function sn(e){let{value:t}=e,n=P(p);return B(`span`,{className:`univer-text-sm`,children:t==null?n.t(`sheet.numfmt.general`):t})}function cn(){let e=P(o),t=P(p),n=P(Ze),r=P(be),i=P(Ke),a=t=>{let r=i.getCurrentLastSelection();if(!r)return;let a=r.range,o=[];ee.foreach(a,(e,n)=>{t?o.push({row:e,col:n,pattern:t,type:w(t)}):o.push({row:e,col:n})}),e.executeCommand(ve.id,{values:o}),n.focus()},s=R(()=>Qt(je.get(t.getCurrentLocale())),[t]),c=t=>{if(t===0)a(null);else if(t===s.length-1)e.executeCommand(K.id),n.focus();else{let e=s[t];e.pattern&&a(e.pattern)}};return B(`div`,{className:`univer-grid univer-gap-1 univer-p-1.5`,children:s.map((e,n)=>e===`|`?B(mt,{},n):V(`div`,{className:`
19
+ univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between
20
+ univer-gap-6 univer-rounded univer-px-2 univer-text-sm
21
+ hover:univer-bg-gray-100
22
+ dark:hover:!univer-bg-gray-700
23
+ `,onClick:()=>c(n),children:[B(`span`,{children:t.t(e.label)}),B(`span`,{className:`
24
+ univer-text-xs univer-text-gray-500
25
+ dark:!univer-text-gray-400
26
+ `,children:e.pattern?Oe(e.pattern||``,1220,r.locale).result.trim():``})]},n))})}const ln={[tt.LAYOUT]:{[K.id]:{order:9,menuItemFactory:rn},[ye.id]:{order:9.1,menuItemFactory:nn},[_e.id]:{order:9.2,menuItemFactory:$t},[fe.id]:{order:9.3,menuItemFactory:en},[xe.id]:{order:9.4,menuItemFactory:tn}}};let Q=class extends i{constructor(e,t){super(),this._componentManager=e,this._menuManagerService=t,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(ln),[[an,sn],[on,cn]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};Q=W([U(0,u(Xe)),U(1,Qe)],Q);let $=class extends h{constructor(e=Et,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=r;let{menu:i,...a}=ae({},Et,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(`sheets-numfmt-ui.config`,a)}onStarting(){se(this._injector,[[X],[Z],[q],[Q]])}onRendered(){this._registerRenderModules(),le(this._injector,[[X],[Z],[Q]])}_registerRenderModules(){[[Dt]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(v.UNIVER_SHEET,e))})}};Y($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),Y($,`packageName`,wt),Y($,`version`,Tt),Y($,`type`,v.UNIVER_SHEET),$=W([r(Le,Se),U(1,u(d)),U(2,s),U(3,de)],$);export{$ as UniverSheetsNumfmtUIPlugin};