@univerjs/sheets-numfmt 0.6.7-experimental.20250326-6499c07 → 0.6.7-experimental.20250328-21e0bec

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/facade.js ADDED
@@ -0,0 +1,42 @@
1
+ import { SetNumfmtCommand as m, SheetsNumfmtCellContentController as h } from "@univerjs/sheets-numfmt";
2
+ import { FRange as a, FWorkbook as i } from "@univerjs/sheets/facade";
3
+ class d extends a {
4
+ setNumberFormat(s) {
5
+ const t = [];
6
+ return this.forEach((e, o) => t.push({ row: e, col: o, pattern: s })), this._commandService.syncExecuteCommand(m.id, {
7
+ unitId: this._workbook.getUnitId(),
8
+ subUnitId: this._worksheet.getSheetId(),
9
+ values: t
10
+ }), this;
11
+ }
12
+ setNumberFormats(s) {
13
+ const t = [];
14
+ return this.forEach((e, o) => {
15
+ var r;
16
+ const n = (r = s[e]) == null ? void 0 : r[o];
17
+ t.push({ row: e, col: o, pattern: n });
18
+ }), this._commandService.syncExecuteCommand(m.id, {
19
+ unitId: this._workbook.getUnitId(),
20
+ subUnitId: this._worksheet.getSheetId(),
21
+ values: t
22
+ }), this;
23
+ }
24
+ getNumberFormat() {
25
+ var t, e;
26
+ const s = this.getCellStyle();
27
+ return (e = (t = s == null ? void 0 : s.numberFormat) == null ? void 0 : t.pattern) != null ? e : "";
28
+ }
29
+ getNumberFormats() {
30
+ return this.getCellStyles().map((t) => t.map((e) => {
31
+ var o, n;
32
+ return (n = (o = e == null ? void 0 : e.numberFormat) == null ? void 0 : o.pattern) != null ? n : "";
33
+ }));
34
+ }
35
+ }
36
+ a.extend(d);
37
+ class c extends i {
38
+ setNumfmtLocal(s) {
39
+ return this._injector.get(h).setNumfmtLocal(s), this;
40
+ }
41
+ }
42
+ i.extend(c);
package/lib/index.js ADDED
@@ -0,0 +1,666 @@
1
+ var ae = Object.defineProperty;
2
+ var le = (e, t, n) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var M = (e, t, n) => le(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { numfmt as x, CommandType as P, ICommandService as E, IUniverInstanceService as F, IUndoRedoService as ue, CellValueType as I, ObjectMatrix as b, sequenceExecute as me, Range as N, Inject as T, ThemeService as fe, LocaleService as de, IConfigService as X, Disposable as Q, LocaleType as $, InterceptorEffectEnum as K, UniverInstanceType as ee, DependentOn as ge, Injector as he, Plugin as pe, merge as Se, registerDependencies as ve, touchDependencies as z } from "@univerjs/core";
5
+ import { getSheetCommandTarget as H, transformCellsToRange as ye, checkCellValueType as G, rangeMerge as Y, SetNumfmtMutation as te, factorySetNumfmtUndoMutation as _e, RemoveNumfmtMutation as Ce, SetRangeValuesMutation as B, factoryRemoveNumfmtUndoMutation as be, SheetsSelectionsService as j, INumfmtService as W, SheetInterceptorService as Me, INTERCEPTOR_POINT as $e, InterceptCellContentPriority as Re, UniverSheetsPlugin as Ie } from "@univerjs/sheets";
6
+ import { isTextFormat as ne } from "@univerjs/engine-numfmt";
7
+ import { BehaviorSubject as k, merge as Ne, switchMap as Ee, of as Te, skip as xe } from "rxjs";
8
+ import { stripErrorMargin as Ve } from "@univerjs/engine-formula";
9
+ const re = [
10
+ "$",
11
+ "£",
12
+ "¥",
13
+ "¤",
14
+ "֏",
15
+ "؋",
16
+ "৳",
17
+ "฿",
18
+ // '៛',
19
+ "₡",
20
+ "₦",
21
+ "₩",
22
+ "₪",
23
+ "₫",
24
+ "€",
25
+ "₭",
26
+ "₮",
27
+ "₱",
28
+ "₲",
29
+ "₴",
30
+ "₸",
31
+ "₹",
32
+ "₺",
33
+ "₼",
34
+ "₽",
35
+ "₾",
36
+ "₿"
37
+ ], Pe = {
38
+ US: "$",
39
+ // United States Dollar
40
+ CA: "C$",
41
+ // Canadian Dollar
42
+ GB: "£",
43
+ // British Pound Sterling
44
+ JP: "¥",
45
+ // Japanese Yen
46
+ IN: "₹",
47
+ // Indian Rupee
48
+ AU: "A$",
49
+ // Australian Dollar
50
+ CN: "¥",
51
+ // Chinese Yuan
52
+ KR: "₩",
53
+ // South Korean Won
54
+ RU: "₽",
55
+ // Russian Ruble
56
+ // Euro countries
57
+ AT: "€",
58
+ BE: "€",
59
+ CY: "€",
60
+ EE: "€",
61
+ FI: "€",
62
+ FR: "€",
63
+ DE: "€",
64
+ GR: "€",
65
+ IE: "€",
66
+ IT: "€",
67
+ LV: "€",
68
+ LT: "€",
69
+ LU: "€",
70
+ MT: "€",
71
+ NL: "€",
72
+ PT: "€",
73
+ SK: "€",
74
+ SI: "€",
75
+ ES: "€"
76
+ // Add more mappings as needed
77
+ }, Ue = [
78
+ {
79
+ label: "1930-08-05",
80
+ suffix: "yyyy-MM-dd"
81
+ },
82
+ {
83
+ label: "1930/08/05",
84
+ suffix: "yyyy/MM/dd"
85
+ },
86
+ {
87
+ label: "1930年08月05日",
88
+ suffix: 'yyyy"年"MM"月"dd"日"'
89
+ },
90
+ {
91
+ label: "08-05",
92
+ suffix: "MM-dd"
93
+ },
94
+ {
95
+ label: "8月5日",
96
+ suffix: 'M"月"d"日"'
97
+ },
98
+ {
99
+ label: "13:30:30",
100
+ suffix: "h:mm:ss"
101
+ },
102
+ {
103
+ label: "13:30",
104
+ suffix: "h:mm"
105
+ },
106
+ {
107
+ label: "下午01:30",
108
+ suffix: "A/P hh:mm"
109
+ },
110
+ {
111
+ label: "下午1:30",
112
+ suffix: "A/P h:mm"
113
+ },
114
+ {
115
+ label: "下午1:30:30",
116
+ suffix: "A/P h:mm:ss"
117
+ },
118
+ {
119
+ label: "08-05 下午 01:30",
120
+ suffix: "MM-dd A/P hh:mm"
121
+ }
122
+ ], we = [
123
+ {
124
+ label: "(1,235)",
125
+ suffix: "#,##0_);(#,##0)"
126
+ },
127
+ {
128
+ label: "(1,235) ",
129
+ suffix: "#,##0_);[Red](#,##0)",
130
+ color: "red"
131
+ },
132
+ {
133
+ label: "1,234.56",
134
+ suffix: "#,##0.00_);#,##0.00"
135
+ },
136
+ {
137
+ label: "1,234.56",
138
+ suffix: "#,##0.00_);[Red]#,##0.00",
139
+ color: "red"
140
+ },
141
+ {
142
+ label: "-1,234.56",
143
+ suffix: "#,##0.00_);-#,##0.00"
144
+ },
145
+ {
146
+ label: "-1,234.56",
147
+ suffix: "#,##0.00_);[Red]-#,##0.00",
148
+ color: "red"
149
+ }
150
+ ], se = [
151
+ {
152
+ label: (e) => `${e}1,235`,
153
+ suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
154
+ },
155
+ {
156
+ label: (e) => `${e}1,235`,
157
+ suffix: (e) => `"${e}"#,##0.00_);[Red]"${e}"#,##0.00`,
158
+ color: "red"
159
+ },
160
+ {
161
+ label: (e) => `(${e}1,235)`,
162
+ suffix: (e) => `"${e}"#,##0.00_);("${e}"#,##0.00)`
163
+ },
164
+ {
165
+ label: (e) => `(${e}1,235)`,
166
+ suffix: (e) => `"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`,
167
+ color: "red"
168
+ },
169
+ {
170
+ label: (e) => `-${e}1,235`,
171
+ suffix: (e) => `"${e}"#,##0.00_);-"${e}"#,##0.00`
172
+ },
173
+ {
174
+ label: (e) => `-${e}1,235`,
175
+ suffix: (e) => `"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,
176
+ color: "red"
177
+ }
178
+ ], Oe = "SHEET_NUMFMT_PLUGIN", w = (e, t = 0) => {
179
+ var r;
180
+ return e && (r = x.getInfo(e).maxDecimals) != null ? r : t;
181
+ }, tt = (e, t) => {
182
+ if (e && !t || !e && t)
183
+ return !1;
184
+ const n = (u) => u.reduce(
185
+ (g, p) => {
186
+ if (g.isEnd)
187
+ return g;
188
+ const h = p.value || p.num;
189
+ return p.type === "point" ? (g.isEnd = !0, g) : { ...g, result: g.result + h };
190
+ },
191
+ { isEnd: !1, result: "" }
192
+ ).result, r = x.getInfo(e)._partitions, s = x.getInfo(t)._partitions, o = n(r[0].tokens), c = n(s[0].tokens), i = n(r[1].tokens), d = n(s[1].tokens);
193
+ return o === c && i === d && r[1].color === s[1].color;
194
+ }, q = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), O = (e, t) => e.split(";").map((r) => /\.0?/.test(r) ? r.replace(
195
+ /\.0*/g,
196
+ `${t > 0 ? "." : ""}${q(Number(t || 0))}`
197
+ ) : /0([^0]?)|0$/.test(r) ? r.replace(
198
+ /0([^0]+)|0$/,
199
+ `0${t > 0 ? "." : ""}${q(Number(t || 0))}$1`
200
+ ) : r).join(";"), nt = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), U = {
201
+ id: "sheet.command.numfmt.set.numfmt",
202
+ type: P.COMMAND,
203
+ // eslint-disable-next-line max-lines-per-function
204
+ handler: (e, t) => {
205
+ if (!t)
206
+ return !1;
207
+ const n = e.get(E), r = e.get(F), s = e.get(ue), o = H(r, t);
208
+ if (!o) return !1;
209
+ const { unitId: c, subUnitId: i, worksheet: d } = o, u = t.values.filter((l) => !!l.pattern), g = t.values.filter((l) => !l.pattern), p = ye(c, i, u), h = {
210
+ unitId: c,
211
+ subUnitId: i,
212
+ ranges: g.map((l) => ({
213
+ startColumn: l.col,
214
+ startRow: l.row,
215
+ endColumn: l.col,
216
+ endRow: l.row
217
+ }))
218
+ }, C = [], v = [];
219
+ if (u.length) {
220
+ const l = u.reduce((f, a) => {
221
+ ne(a.pattern) && f.setValue(a.row, a.col, { t: I.STRING });
222
+ const _ = d.getCellRaw(a.row, a.col);
223
+ if (_) {
224
+ const V = G(_.v);
225
+ V !== _.t && f.setValue(a.row, a.col, { t: V });
226
+ }
227
+ return f;
228
+ }, new b()).getMatrix(), S = new b();
229
+ new b(l).forValue((f, a) => {
230
+ const _ = d.getCellRaw(f, a);
231
+ _ ? S.setValue(f, a, { t: _.t }) : S.setValue(f, a, { t: void 0 });
232
+ }), Object.keys(p.values).forEach((f) => {
233
+ const a = p.values[f];
234
+ a.ranges = Y(a.ranges);
235
+ }), C.push({
236
+ id: te.id,
237
+ params: p
238
+ });
239
+ const y = _e(e, p);
240
+ v.push(...y);
241
+ }
242
+ if (g.length) {
243
+ h.ranges = Y(h.ranges);
244
+ const l = g.reduce((f, a) => {
245
+ const _ = d.getCellRaw(a.row, a.col);
246
+ if (_) {
247
+ const V = G(_.v);
248
+ V !== _.t && f.setValue(a.row, a.col, { t: V });
249
+ }
250
+ return f;
251
+ }, new b()).getMatrix(), S = new b();
252
+ new b(l).forValue((f, a) => {
253
+ const _ = d.getCellRaw(f, a);
254
+ _ ? S.setValue(f, a, { t: _.t }) : S.setValue(f, a, { t: void 0 });
255
+ }), C.push({
256
+ id: Ce.id,
257
+ params: h
258
+ }, {
259
+ id: B.id,
260
+ params: {
261
+ unitId: c,
262
+ subUnitId: i,
263
+ cellValue: l
264
+ }
265
+ });
266
+ const y = be(e, h);
267
+ v.push({
268
+ id: B.id,
269
+ params: {
270
+ unitId: c,
271
+ subUnitId: i,
272
+ cellValue: S.getMatrix()
273
+ }
274
+ }, ...y);
275
+ }
276
+ const m = me(C, n).result;
277
+ return m && s.pushUndoRedo({
278
+ unitID: c,
279
+ undoMutations: v,
280
+ redoMutations: C
281
+ }), m;
282
+ }
283
+ }, De = {
284
+ id: "sheet.command.numfmt.add.decimal.command",
285
+ type: P.COMMAND,
286
+ handler: async (e) => {
287
+ const t = e.get(E), n = e.get(j), r = e.get(W), s = e.get(F), o = n.getCurrentSelections();
288
+ if (!o || !o.length)
289
+ return !1;
290
+ const c = H(s);
291
+ if (!c) return !1;
292
+ const { unitId: i, subUnitId: d } = c;
293
+ let u = 0;
294
+ o.forEach((C) => {
295
+ N.foreach(C.range, (v, m) => {
296
+ const l = r.getValue(i, d, v, m);
297
+ if (!l) {
298
+ const y = c.worksheet.getCellRaw(v, m);
299
+ if (!u && y && y.t === I.NUMBER && y.v) {
300
+ const f = /\.(\d*)$/.exec(String(y.v));
301
+ if (f) {
302
+ const a = f[1].length;
303
+ if (!a)
304
+ return;
305
+ u = Math.max(u, a);
306
+ }
307
+ }
308
+ return;
309
+ }
310
+ const S = w(l.pattern);
311
+ u = S > u ? S : u;
312
+ });
313
+ });
314
+ const g = u + 1, p = O(`0${g > 0 ? ".0" : ""}`, g), h = [];
315
+ return o.forEach((C) => {
316
+ N.foreach(C.range, (v, m) => {
317
+ const l = r.getValue(i, d, v, m);
318
+ if (!l)
319
+ h.push({
320
+ row: v,
321
+ col: m,
322
+ pattern: p
323
+ });
324
+ else {
325
+ const S = w(l.pattern), y = O(l.pattern, S + 1);
326
+ y !== l.pattern && h.push({
327
+ row: v,
328
+ col: m,
329
+ pattern: y
330
+ });
331
+ }
332
+ });
333
+ }), h.length ? await t.executeCommand(U.id, { values: h }) : !1;
334
+ }
335
+ };
336
+ class oe {
337
+ constructor() {
338
+ M(this, "_currencySymbol$", new k("US"));
339
+ M(this, "currencySymbol$", this._currencySymbol$.asObservable());
340
+ }
341
+ /**
342
+ * Set the currency symbol by setting the country code.
343
+ */
344
+ setCurrencySymbolByCountryCode(t) {
345
+ this._currencySymbol$.next(t);
346
+ }
347
+ getCurrencySymbol() {
348
+ return this._currencySymbol$.getValue();
349
+ }
350
+ }
351
+ const Ae = {
352
+ id: "sheet.command.numfmt.set.currency",
353
+ type: P.COMMAND,
354
+ handler: async (e) => {
355
+ const t = e.get(E), n = e.get(j), r = e.get(oe), s = Pe[r.getCurrencySymbol()] || "$", o = n.getCurrentSelections();
356
+ if (!o || !o.length)
357
+ return !1;
358
+ const c = [], i = se[4].suffix(s);
359
+ return o.forEach((u) => {
360
+ N.foreach(u.range, (g, p) => {
361
+ c.push({ row: g, col: p, pattern: i, type: "currency" });
362
+ });
363
+ }), await t.executeCommand(U.id, { values: c });
364
+ }
365
+ }, Fe = {
366
+ id: "sheet.command.numfmt.set.percent",
367
+ type: P.COMMAND,
368
+ handler: async (e) => {
369
+ const t = e.get(E), r = e.get(j).getCurrentSelections();
370
+ if (!r || !r.length)
371
+ return !1;
372
+ const s = [], o = "0%";
373
+ return r.forEach((i) => {
374
+ N.foreach(i.range, (d, u) => {
375
+ s.push({ row: d, col: u, pattern: o, type: "percent" });
376
+ });
377
+ }), await t.executeCommand(U.id, { values: s });
378
+ }
379
+ }, je = {
380
+ id: "sheet.command.numfmt.subtract.decimal.command",
381
+ type: P.COMMAND,
382
+ handler: async (e) => {
383
+ const t = e.get(E), n = e.get(j), r = e.get(W), s = e.get(F), o = n.getCurrentSelections();
384
+ if (!o || !o.length)
385
+ return !1;
386
+ const c = H(s);
387
+ if (!c) return !1;
388
+ const { unitId: i, subUnitId: d } = c;
389
+ let u = 0;
390
+ o.forEach((v) => {
391
+ N.foreach(v.range, (m, l) => {
392
+ const S = r.getValue(i, d, m, l);
393
+ if (!S) {
394
+ const f = c.worksheet.getCellRaw(m, l);
395
+ if (!u && f && f.t === I.NUMBER && f.v) {
396
+ const a = /\.(\d*)$/.exec(String(f.v));
397
+ if (a) {
398
+ const _ = a[1].length;
399
+ if (!_)
400
+ return;
401
+ u = Math.max(u, _);
402
+ }
403
+ }
404
+ return;
405
+ }
406
+ const y = w(S.pattern);
407
+ u = y > u ? y : u;
408
+ });
409
+ });
410
+ const g = u - 1, p = O(`0${g > 0 ? ".0" : "."}`, g), h = [];
411
+ return o.forEach((v) => {
412
+ N.foreach(v.range, (m, l) => {
413
+ const S = r.getValue(i, d, m, l);
414
+ if (!S)
415
+ h.push({
416
+ row: m,
417
+ col: l,
418
+ pattern: p
419
+ });
420
+ else {
421
+ const y = w(S.pattern);
422
+ h.push({
423
+ row: m,
424
+ col: l,
425
+ pattern: O(S.pattern, y - 1)
426
+ });
427
+ }
428
+ });
429
+ }), await t.executeCommand(U.id, { values: h });
430
+ }
431
+ }, ce = "sheets-numfmt.config", Z = {}, rt = (e) => x.getInfo(e).type || "unknown", Le = (e, t, n = "en") => {
432
+ const s = x.getInfo(e)._partitions[1], o = x.format(e, t, { locale: n, throws: !1 });
433
+ return t < 0 ? {
434
+ result: o,
435
+ color: s.color
436
+ } : {
437
+ result: o
438
+ };
439
+ }, Ge = (e, t, n) => e === "General" ? {
440
+ result: String(Ve(t))
441
+ // In Excel, the default General format also needs to handle numeric precision.
442
+ } : Le(e, t, n);
443
+ var Be = Object.getOwnPropertyDescriptor, He = (e, t, n, r) => {
444
+ for (var s = r > 1 ? void 0 : r ? Be(t, n) : t, o = e.length - 1, c; o >= 0; o--)
445
+ (c = e[o]) && (s = c(s) || s);
446
+ return s;
447
+ }, R = (e, t) => (n, r) => t(n, r, e);
448
+ const We = {
449
+ tl: {
450
+ size: 6,
451
+ color: "#409f11"
452
+ }
453
+ };
454
+ let D = class extends Q {
455
+ constructor(t, n, r, s, o, c, i) {
456
+ super();
457
+ M(this, "_local$", new k("en"));
458
+ M(this, "local$", this._local$.asObservable());
459
+ this._instanceService = t, this._sheetInterceptorService = n, this._themeService = r, this._commandService = s, this._numfmtService = o, this._localeService = c, this._configService = i, this._initInterceptorCellContent();
460
+ }
461
+ get local() {
462
+ const t = this._local$.getValue();
463
+ if (t)
464
+ return t;
465
+ switch (this._localeService.getCurrentLocale()) {
466
+ case $.FR_FR:
467
+ return "fr";
468
+ case $.RU_RU:
469
+ return "ru";
470
+ case $.VI_VN:
471
+ return "vi";
472
+ case $.ZH_CN:
473
+ return "zh-CN";
474
+ case $.ZH_TW:
475
+ return "zh-TW";
476
+ case $.EN_US:
477
+ case $.FA_IR:
478
+ default:
479
+ return "en";
480
+ }
481
+ }
482
+ // eslint-disable-next-line max-lines-per-function
483
+ _initInterceptorCellContent() {
484
+ const t = new b();
485
+ this.disposeWithMe(Ne(this._local$, this._localeService.currentLocale$).subscribe(() => {
486
+ t.reset();
487
+ })), this.disposeWithMe(this._sheetInterceptorService.intercept($e.CELL_CONTENT, {
488
+ effect: K.Value | K.Style,
489
+ handler: (n, r, s) => {
490
+ var v;
491
+ const o = r.unitId, c = r.subUnitId;
492
+ let i;
493
+ const d = n;
494
+ if (!d)
495
+ return s(n);
496
+ if (n != null && n.s) {
497
+ const m = r.workbook.getStyles().get(n.s);
498
+ m != null && m.n && (i = m.n);
499
+ }
500
+ if (i || (i = this._numfmtService.getValue(o, c, r.row, r.col)), !i || G(d.v) !== I.NUMBER)
501
+ return s(n);
502
+ if (ne(i.pattern))
503
+ return (v = this._configService.getConfig(ce)) != null && v.disableTextFormatMark ? s({
504
+ ...n,
505
+ t: I.STRING
506
+ }) : s({
507
+ ...n,
508
+ t: I.STRING,
509
+ markers: {
510
+ ...n == null ? void 0 : n.markers,
511
+ ...We
512
+ }
513
+ });
514
+ let g = "";
515
+ const p = t.getValue(r.row, r.col);
516
+ if (p && p.parameters === `${d.v}_${i.pattern}`)
517
+ return s({ ...n, ...p.result });
518
+ const h = Ge(i.pattern, Number(d.v), this.local);
519
+ if (g = h.result, !g)
520
+ return s(n);
521
+ const C = { v: g, t: I.NUMBER };
522
+ if (h.color) {
523
+ const m = this._themeService.getCurrentTheme()[`${h.color}500`];
524
+ m && (C.interceptorStyle = { cl: { rgb: m } });
525
+ }
526
+ return t.setValue(r.row, r.col, {
527
+ result: C,
528
+ parameters: `${d.v}_${i.pattern}`
529
+ }), s({ ...n, ...C });
530
+ },
531
+ priority: Re.NUMFMT
532
+ })), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
533
+ if (n.id === te.id) {
534
+ const r = n.params;
535
+ Object.keys(r.values).forEach((s) => {
536
+ r.values[s].ranges.forEach((c) => {
537
+ N.foreach(c, (i, d) => {
538
+ t.realDeleteValue(i, d);
539
+ });
540
+ });
541
+ });
542
+ } else if (n.id === B.id) {
543
+ const r = n.params;
544
+ new b(r.cellValue).forValue((s, o) => {
545
+ t.realDeleteValue(s, o);
546
+ });
547
+ }
548
+ })), this.disposeWithMe(
549
+ this._instanceService.getCurrentTypeOfUnit$(ee.UNIVER_SHEET).pipe(
550
+ Ee((n) => {
551
+ var r;
552
+ return (r = n == null ? void 0 : n.activeSheet$) != null ? r : Te(null);
553
+ }),
554
+ xe(1)
555
+ ).subscribe(() => t.reset())
556
+ );
557
+ }
558
+ setNumfmtLocal(t) {
559
+ this._local$.next(t);
560
+ }
561
+ };
562
+ D = He([
563
+ R(0, F),
564
+ R(1, T(Me)),
565
+ R(2, T(fe)),
566
+ R(3, T(E)),
567
+ R(4, T(W)),
568
+ R(5, T(de)),
569
+ R(6, X)
570
+ ], D);
571
+ class J extends Q {
572
+ constructor() {
573
+ super(...arguments);
574
+ M(this, "_currencySymbol$", new k("US"));
575
+ M(this, "currencySymbol$", this._currencySymbol$.asObservable());
576
+ }
577
+ /**
578
+ * Set the currency symbol by setting the country code.
579
+ */
580
+ setCurrencySymbolByCountryCode(n) {
581
+ this._currencySymbol$.next(n);
582
+ }
583
+ getCurrencySymbol() {
584
+ return this._currencySymbol$.getValue();
585
+ }
586
+ }
587
+ var ke = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, ze = (e, t, n) => t in e ? ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Ye = (e, t, n, r) => {
588
+ for (var s = r > 1 ? void 0 : r ? Ke(t, n) : t, o = e.length - 1, c; o >= 0; o--)
589
+ (c = e[o]) && (s = c(s) || s);
590
+ return s;
591
+ }, L = (e, t) => (n, r) => t(n, r, e), ie = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
592
+ let A = class extends pe {
593
+ constructor(e = Z, t, n, r) {
594
+ super(), this._config = e, this._injector = t, this._configService = n, this._commandService = r;
595
+ const { ...s } = Se(
596
+ {},
597
+ Z,
598
+ this._config
599
+ );
600
+ this._configService.setConfig(ce, s);
601
+ }
602
+ onStarting() {
603
+ ve(this._injector, [
604
+ [D],
605
+ [oe],
606
+ [J]
607
+ ]), z(this._injector, [
608
+ [D]
609
+ ]);
610
+ }
611
+ onRendered() {
612
+ z(this._injector, [
613
+ [J]
614
+ ]), [
615
+ De,
616
+ je,
617
+ Ae,
618
+ Fe,
619
+ U
620
+ ].forEach((e) => {
621
+ this.disposeWithMe(this._commandService.registerCommand(e));
622
+ });
623
+ }
624
+ };
625
+ ie(A, "pluginName", Oe);
626
+ ie(A, "type", ee.UNIVER_SHEET);
627
+ A = Ye([
628
+ ge(Ie),
629
+ L(1, T(he)),
630
+ L(2, X),
631
+ L(3, E)
632
+ ], A);
633
+ const st = (e) => re.find((n) => e.includes(n)), ot = () => re.map((e) => ({ label: e, value: e })), ct = (e) => se.map((t) => ({
634
+ label: t.label(e),
635
+ value: t.suffix(e),
636
+ color: t.color
637
+ })), it = () => Ue.map((e) => ({ label: e.label, value: e.suffix })), at = () => we.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
638
+ export {
639
+ De as AddDecimalCommand,
640
+ se as CURRENCYFORMAT,
641
+ Ue as DATEFMTLISG,
642
+ oe as MenuCurrencyService,
643
+ we as NUMBERFORMAT,
644
+ ce as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
645
+ Ae as SetCurrencyCommand,
646
+ U as SetNumfmtCommand,
647
+ Fe as SetPercentCommand,
648
+ D as SheetsNumfmtCellContentController,
649
+ je as SubtractDecimalCommand,
650
+ A as UniverSheetsNumfmtPlugin,
651
+ Pe as countryCurrencyMap,
652
+ re as currencySymbols,
653
+ ct as getCurrencyFormatOptions,
654
+ ot as getCurrencyOptions,
655
+ st as getCurrencyType,
656
+ it as getDateFormatOptions,
657
+ w as getDecimalFromPattern,
658
+ q as getDecimalString,
659
+ at as getNumberFormatOptions,
660
+ Le as getPatternPreview,
661
+ Ge as getPatternPreviewIgnoreGeneral,
662
+ rt as getPatternType,
663
+ tt as isPatternEqualWithoutDecimal,
664
+ nt as isPatternHasDecimal,
665
+ O as setPatternDecimal
666
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-numfmt",
3
- "version": "0.6.7-experimental.20250326-6499c07",
3
+ "version": "0.6.7-experimental.20250328-21e0bec",
4
4
  "private": false,
5
5
  "description": "UniverSheet numfmt plugin",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,10 +53,10 @@
53
53
  "rxjs": ">=7.0.0"
54
54
  },
55
55
  "dependencies": {
56
- "@univerjs/core": "0.6.7-experimental.20250326-6499c07",
57
- "@univerjs/engine-formula": "0.6.7-experimental.20250326-6499c07",
58
- "@univerjs/engine-numfmt": "0.6.7-experimental.20250326-6499c07",
59
- "@univerjs/sheets": "0.6.7-experimental.20250326-6499c07"
56
+ "@univerjs/core": "0.6.7-experimental.20250328-21e0bec",
57
+ "@univerjs/engine-formula": "0.6.7-experimental.20250328-21e0bec",
58
+ "@univerjs/engine-numfmt": "0.6.7-experimental.20250328-21e0bec",
59
+ "@univerjs/sheets": "0.6.7-experimental.20250328-21e0bec"
60
60
  },
61
61
  "devDependencies": {
62
62
  "rxjs": "^7.8.1",