@univerjs/sheets-numfmt 0.6.0-alpha.0 → 0.6.0-experimental.20250212-dbe9830

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