@univerjs/sheets-numfmt 0.10.3 → 0.10.4-nightly.202508220605

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