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