@univerjs/sheets-numfmt 0.10.3 → 0.10.4

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 x, CommandType as U, ICommandService as E, IUniverInstanceService as A, IUndoRedoService as ce, isTextFormat as X, CellValueType as R, ObjectMatrix as M, sequenceExecute as ie, Range as N, LocaleService as J, Inject as I, 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 ve, checkCellValueType as H, rangeMerge as z, SetNumfmtMutation as te, factorySetNumfmtUndoMutation as _e, RemoveNumfmtMutation as Se, SetRangeValuesMutation as B, factoryRemoveNumfmtUndoMutation as Ce, SheetsSelectionsService as j, INumfmtService as K, SheetInterceptorService as ye, INTERCEPTOR_POINT as be, InterceptCellContentPriority as Me, 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 Ue } 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
+ ], w = /* @__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 Ve(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: w.get(e) || "€",
57
+ locale: e
58
+ };
59
+ case m.RU_RU:
60
+ return {
61
+ icon: "RoubleIcon",
62
+ symbol: w.get(e) || "",
63
+ locale: e
64
+ };
65
+ case m.ZH_CN:
66
+ return {
67
+ icon: "RmbIcon",
68
+ symbol: w.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 w.get(e) || "$";
82
+ }
83
+ function we(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 xe = [
77
90
  {
78
91
  label: "1930-08-05",
79
92
  suffix: "yyyy-MM-dd"
@@ -146,7 +159,7 @@ const ne = [
146
159
  suffix: "#,##0.00_);[Red]-#,##0.00",
147
160
  color: "red"
148
161
  }
149
- ], se = [
162
+ ], Pe = [
150
163
  {
151
164
  label: (e) => `${e}1,235`,
152
165
  suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
@@ -175,120 +188,120 @@ const ne = [
175
188
  color: "red"
176
189
  }
177
190
  ], 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(
191
+ var r;
192
+ return e && (r = x.getFormatInfo(e).maxDecimals) != null ? r : t;
193
+ }, Y = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), P = (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(";"), tt = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), V = {
187
200
  id: "sheet.command.numfmt.set.numfmt",
188
- type: V.COMMAND,
201
+ type: U.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(E), 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), y = ve(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
+ }, b = [], v = [];
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);
209
- if (v) {
210
- const x = G(v.v);
211
- x !== v.t && d.setValue(c.row, c.col, { t: x });
219
+ const l = u.reduce((g, a) => {
220
+ X(a.pattern) && g.setValue(a.row, a.col, { t: R.STRING });
221
+ const S = d.getCellRaw(a.row, a.col);
222
+ if (S) {
223
+ const T = H(S.v);
224
+ T !== S.t && g.setValue(a.row, a.col, { t: T });
212
225
  }
213
- return d;
226
+ return g;
214
227
  }, 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: _
228
+ new M(l).forValue((g, a) => {
229
+ const S = d.getCellRaw(g, a);
230
+ S ? h.setValue(g, a, { t: S.t }) : h.setValue(g, a, { t: void 0 });
231
+ }), Object.keys(y.values).forEach((g) => {
232
+ const a = y.values[g];
233
+ a.ranges = z(a.ranges);
234
+ }), b.push({
235
+ id: te.id,
236
+ params: y
224
237
  });
225
- const p = _e(e, _);
226
- S.push(...p);
238
+ const _ = _e(e, y);
239
+ v.push(..._);
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);
232
- if (v) {
233
- const x = G(v.v);
234
- x !== v.t && d.setValue(c.row, c.col, { t: x });
241
+ if (C.length) {
242
+ p.ranges = z(p.ranges);
243
+ const l = C.reduce((g, a) => {
244
+ const S = d.getCellRaw(a.row, a.col);
245
+ if (S) {
246
+ const T = H(S.v);
247
+ T !== S.t && g.setValue(a.row, a.col, { t: T });
235
248
  }
236
- return d;
249
+ return g;
237
250
  }, 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
251
+ new M(l).forValue((g, a) => {
252
+ const S = d.getCellRaw(g, a);
253
+ S ? h.setValue(g, a, { t: S.t }) : h.setValue(g, a, { t: void 0 });
254
+ }), b.push({
255
+ id: Se.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 _ = Ce(e, p);
266
+ v.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
+ }, ..._);
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(b, n).result;
276
+ return f && s.pushUndoRedo({
277
+ unitID: c,
278
+ undoMutations: v,
279
+ redoMutations: b
280
+ }), f;
268
281
  }
269
- }, Pe = {
282
+ }, De = {
270
283
  id: "sheet.command.numfmt.add.decimal.command",
271
- type: V.COMMAND,
284
+ type: U.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(E), 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((b) => {
294
+ N.foreach(b.range, (v, f) => {
295
+ const l = r.getValue(i, d, v, 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 _ = c.worksheet.getCellRaw(v, f);
298
+ if (!u && _ && _.t === R.NUMBER && _.v) {
299
+ const g = /\.(\d*)$/.exec(String(_.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;
@@ -297,175 +310,159 @@ const ne = [
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, y = P(`0${C > 0 ? ".0" : ""}`, C), p = [];
314
+ return o.forEach((b) => {
315
+ N.foreach(b.range, (v, f) => {
316
+ const l = r.getValue(i, d, v, f);
304
317
  if (!l)
305
- g.push({
306
- row: S,
307
- col: m,
308
- pattern: _
318
+ p.push({
319
+ row: v,
320
+ col: f,
321
+ pattern: y
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 = O(l.pattern), _ = P(l.pattern, h + 1);
325
+ _ !== l.pattern && p.push({
326
+ row: v,
327
+ col: f,
328
+ pattern: _
316
329
  });
317
330
  }
318
331
  });
319
- }), g.length ? await t.executeCommand(U.id, { values: g }) : !1;
332
+ }), p.length ? await t.executeCommand(V.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: U.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(E), 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 = Ve(r.getCurrentLocale()), i = we(c.locale);
342
+ return s.forEach((u) => {
343
+ N.foreach(u.range, (C, y) => {
344
+ o.push({ row: C, col: y, pattern: i, type: "currency" });
348
345
  });
349
- }), await t.executeCommand(U.id, { values: a });
346
+ }), await t.executeCommand(V.id, { values: o });
350
347
  }
351
- }, Fe = {
348
+ }, Ae = {
352
349
  id: "sheet.command.numfmt.set.percent",
353
- type: V.COMMAND,
350
+ type: U.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(E), 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
+ N.foreach(i.range, (d, u) => {
358
+ s.push({ row: d, col: u, pattern: o, type: "percent" });
362
359
  });
363
- }), await t.executeCommand(U.id, { values: s });
360
+ }), await t.executeCommand(V.id, { values: s });
364
361
  }
365
- }, Ae = {
362
+ }, je = {
366
363
  id: "sheet.command.numfmt.subtract.decimal.command",
367
- type: V.COMMAND,
364
+ type: U.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(E), 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((v) => {
374
+ N.foreach(v.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;
385
- if (!v)
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 S = a[1].length;
382
+ if (!S)
386
383
  return;
387
- u = Math.max(u, v);
384
+ u = Math.max(u, S);
388
385
  }
389
386
  }
390
387
  return;
391
388
  }
392
- const p = O(h.pattern);
393
- u = p > u ? p : u;
389
+ const _ = O(h.pattern);
390
+ u = _ > u ? _ : 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, y = P(`0${C > 0 ? ".0" : "."}`, C), p = [];
394
+ return o.forEach((v) => {
395
+ N.foreach(v.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: y
405
402
  });
406
403
  else {
407
- const p = O(h.pattern);
408
- g.push({
409
- row: m,
404
+ const _ = O(h.pattern);
405
+ p.push({
406
+ row: f,
410
407
  col: l,
411
- pattern: P(h.pattern, p - 1)
408
+ pattern: P(h.pattern, _ - 1)
412
409
  });
413
410
  }
414
411
  });
415
- }), await t.executeCommand(U.id, { values: g });
412
+ }), await t.executeCommand(V.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 = {}, nt = (e) => x.getFormatInfo(e).type || "unknown", Le = (e, t, n = "en") => {
415
+ const r = x.formatColor(e, t), s = r ? String(r) : void 0, o = x.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(Ue(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);
426
+ var He = Object.getOwnPropertyDescriptor, Be = (e, t, n, r) => {
427
+ for (var s = r > 1 ? void 0 : r ? He(t, n) : t, o = e.length - 1, c; o >= 0; o--)
428
+ (c = e[o]) && (s = c(s) || s);
432
429
  return s;
433
- }, N = (e, t) => (r, n) => t(r, n, e);
434
- const He = {
430
+ }, $ = (e, t) => (n, r) => t(n, r, e);
431
+ const We = {
435
432
  tl: {
436
433
  size: 6,
437
434
  color: "#409f11"
438
435
  }
439
436
  };
440
- let D = class extends ee {
441
- constructor(t, r, n, s, o, a, i) {
437
+ let D = class extends ue {
438
+ constructor(t, n, r, s, o, c, i) {
442
439
  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();
440
+ L(this, "_locale$", new $e("en"));
441
+ L(this, "locale$", this._locale$.asObservable());
442
+ this._instanceService = t, this._sheetInterceptorService = n, this._themeService = r, this._commandService = s, this._numfmtService = o, this._localeService = c, this._configService = i, this._initInterceptorCellContent();
446
443
  }
447
444
  get locale() {
448
445
  const t = this._locale$.getValue();
449
446
  if (t)
450
447
  return t;
451
448
  switch (this._localeService.getCurrentLocale()) {
452
- case b.FR_FR:
449
+ case m.FR_FR:
453
450
  return "fr";
454
- case b.RU_RU:
451
+ case m.RU_RU:
455
452
  return "ru";
456
- case b.VI_VN:
453
+ case m.VI_VN:
457
454
  return "vi";
458
- case b.ZH_CN:
455
+ case m.ZH_CN:
459
456
  return "zh-CN";
460
- case b.KO_KR:
457
+ case m.KO_KR:
461
458
  return "ko";
462
- case b.ZH_TW:
459
+ case m.ZH_TW:
463
460
  return "zh-TW";
464
- case b.ES_ES:
465
- case b.CA_ES:
461
+ case m.ES_ES:
462
+ case m.CA_ES:
466
463
  return "es";
467
- case b.EN_US:
468
- case b.FA_IR:
464
+ case m.EN_US:
465
+ case m.FA_IR:
469
466
  default:
470
467
  return "en";
471
468
  }
@@ -473,67 +470,67 @@ let D = class extends ee {
473
470
  // eslint-disable-next-line max-lines-per-function
474
471
  _initInterceptorCellContent() {
475
472
  const t = new M();
476
- this.disposeWithMe(Ee(this._locale$, this._localeService.currentLocale$).subscribe(() => {
473
+ this.disposeWithMe(Ne(this._locale$, this._localeService.currentLocale$).subscribe(() => {
477
474
  t.reset();
478
- })), this.disposeWithMe(this._sheetInterceptorService.intercept($e.CELL_CONTENT, {
479
- effect: z.Value | z.Style,
475
+ })), this.disposeWithMe(this._sheetInterceptorService.intercept(be.CELL_CONTENT, {
476
+ effect: Z.Value | Z.Style,
480
477
  // eslint-disable-next-line complexity
481
- handler: (r, n, s) => {
482
- var C, S;
483
- const o = n.unitId, a = n.subUnitId;
478
+ handler: (n, r, s) => {
479
+ var b, v;
480
+ const o = r.unitId, c = r.subUnitId;
484
481
  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);
482
+ const d = n;
483
+ if (!d || d.v === void 0 || d.v === null)
484
+ return s(n);
485
+ if (n != null && n.s) {
486
+ const f = r.workbook.getStyles().get(n.s);
487
+ f != null && f.n && (i = f.n);
491
488
  }
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));
489
+ 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)
490
+ return s(n);
491
+ if ((!n || n === r.rawData) && (n = { ...r.rawData }), X(i.pattern))
492
+ return (b = this._configService.getConfig(re)) != null && b.disableTextFormatMark ? (n.t = R.STRING, s(n)) : (n.t = R.STRING, n.markers = { ...n == null ? void 0 : n.markers, ...We }, s(n));
496
493
  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 } });
494
+ const C = t.getValue(r.row, r.col);
495
+ if (C && C.parameters === `${d.v}_${i.pattern}`)
496
+ return s({ ...n, ...C.result });
497
+ const y = Ge(i.pattern, Number(d.v), this.locale);
498
+ if (u = y.result, !u)
499
+ return s(n);
500
+ const p = { v: u, t: R.NUMBER };
501
+ if (y.color) {
502
+ const f = (v = this._themeService.getColorFromTheme(`${y.color}.500`)) != null ? v : y.color;
503
+ f && (p.interceptorStyle = { cl: { rgb: f } });
507
504
  }
508
- return t.setValue(n.row, n.col, {
509
- result: g,
510
- parameters: `${f.v}_${i.pattern}`
511
- }), Object.assign(r, g), s(r);
505
+ return t.setValue(r.row, r.col, {
506
+ result: p,
507
+ parameters: `${d.v}_${i.pattern}`
508
+ }), Object.assign(n, p), s(n);
512
509
  },
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);
510
+ priority: Me.NUMFMT
511
+ })), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
512
+ if (n.id === te.id) {
513
+ const r = n.params;
514
+ Object.keys(r.values).forEach((s) => {
515
+ r.values[s].ranges.forEach((c) => {
516
+ N.foreach(c, (i, d) => {
517
+ t.realDeleteValue(i, d);
521
518
  });
522
519
  });
523
520
  });
524
- } else if (r.id === B.id) {
525
- const n = r.params;
526
- new M(n.cellValue).forValue((s, o) => {
521
+ } else if (n.id === B.id) {
522
+ const r = n.params;
523
+ new M(r.cellValue).forValue((s, o) => {
527
524
  t.realDeleteValue(s, o);
528
525
  });
529
526
  }
530
527
  })), 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);
528
+ this._instanceService.getCurrentTypeOfUnit$(ee.UNIVER_SHEET).pipe(
529
+ Ee((n) => {
530
+ var r;
531
+ return (r = n == null ? void 0 : n.activeSheet$) != null ? r : Ie(null);
535
532
  }),
536
- xe(1)
533
+ Te(1)
537
534
  ).subscribe(() => t.reset())
538
535
  );
539
536
  }
@@ -542,107 +539,89 @@ let D = class extends ee {
542
539
  }
543
540
  };
544
541
  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)
542
+ $(0, A),
543
+ $(1, I(ye)),
544
+ $(2, I(le)),
545
+ $(3, I(E)),
546
+ $(4, I(K)),
547
+ $(5, I(J)),
548
+ $(6, Q)
552
549
  ], 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);
550
+ const Ke = "SHEET_NUMFMT_PLUGIN";
551
+ var Ze = Object.defineProperty, ze = Object.getOwnPropertyDescriptor, ke = (e, t, n) => t in e ? Ze(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Ye = (e, t, n, r) => {
552
+ for (var s = r > 1 ? void 0 : r ? ze(t, n) : t, o = e.length - 1, c; o >= 0; o--)
553
+ (c = e[o]) && (s = c(s) || s);
573
554
  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(
555
+ }, G = (e, t) => (n, r) => t(n, r, e), se = (e, t, n) => ke(e, typeof t != "symbol" ? t + "" : t, n);
556
+ let F = class extends de {
557
+ constructor(e = q, t, n, r) {
558
+ super(), this._config = e, this._injector = t, this._configService = n, this._commandService = r;
559
+ const { ...s } = ge(
579
560
  {},
580
561
  q,
581
562
  this._config
582
563
  );
583
- this._configService.setConfig(ae, s);
564
+ this._configService.setConfig(re, s);
584
565
  }
585
566
  onStarting() {
586
- ve(this._injector, [
587
- [D],
588
- [oe],
589
- [J]
590
- ]), Y(this._injector, [
567
+ he(this._injector, [
568
+ [D]
569
+ ]), pe(this._injector, [
591
570
  [D]
592
571
  ]);
593
572
  }
594
573
  onRendered() {
595
- Y(this._injector, [
596
- [J]
597
- ]), [
598
- Pe,
599
- Ae,
574
+ [
600
575
  De,
576
+ je,
601
577
  Fe,
602
- U
578
+ Ae,
579
+ V
603
580
  ].forEach((e) => {
604
581
  this.disposeWithMe(this._commandService.registerCommand(e));
605
582
  });
606
583
  }
607
584
  };
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)
585
+ se(F, "pluginName", Ke);
586
+ se(F, "type", ee.UNIVER_SHEET);
587
+ F = Ye([
588
+ me(Re),
589
+ G(1, I(fe)),
590
+ G(2, Q),
591
+ G(3, E)
615
592
  ], F);
616
- const rt = (e) => ne.find((r) => e.includes(r)), nt = () => ne.map((e) => ({ label: e, value: e })), st = (e) => se.map((t) => ({
593
+ const rt = (e) => ne.find((n) => e.includes(n)), st = () => ne.map((e) => ({ label: e, value: e })), ot = (e) => Pe.map((t) => ({
617
594
  label: t.label(e),
618
595
  value: t.suffix(e),
619
596
  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 }));
597
+ })), at = () => xe.map((e) => ({ label: e.label, value: e.suffix })), ct = () => Oe.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
621
598
  export {
622
- Pe as AddDecimalCommand,
623
- se as CURRENCYFORMAT,
624
- we as DATEFMTLISG,
625
- oe as MenuCurrencyService,
599
+ De as AddDecimalCommand,
600
+ Pe as CURRENCYFORMAT,
601
+ xe as DATEFMTLISG,
626
602
  Oe as NUMBERFORMAT,
627
- ae as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
628
- De as SetCurrencyCommand,
629
- U as SetNumfmtCommand,
630
- Fe as SetPercentCommand,
603
+ re as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
604
+ Fe as SetCurrencyCommand,
605
+ V as SetNumfmtCommand,
606
+ Ae as SetPercentCommand,
631
607
  D as SheetsNumfmtCellContentController,
632
- Ae as SubtractDecimalCommand,
608
+ je as SubtractDecimalCommand,
633
609
  F as UniverSheetsNumfmtPlugin,
634
- Ue as countryCurrencyMap,
635
610
  ne as currencySymbols,
636
- st as getCurrencyFormatOptions,
637
- nt as getCurrencyOptions,
611
+ we as getCurrencyFormat,
612
+ ot as getCurrencyFormatOptions,
613
+ st as getCurrencyOptions,
614
+ k as getCurrencySymbolByLocale,
615
+ Ve as getCurrencySymbolIconByLocale,
638
616
  rt as getCurrencyType,
639
- ot as getDateFormatOptions,
617
+ at as getDateFormatOptions,
640
618
  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,
619
+ Y as getDecimalString,
620
+ ct as getNumberFormatOptions,
621
+ Le as getPatternPreview,
622
+ Ge as getPatternPreviewIgnoreGeneral,
623
+ nt as getPatternType,
624
+ tt as isPatternHasDecimal,
625
+ w as localeCurrencySymbolMap,
647
626
  P as setPatternDecimal
648
627
  };