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