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