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