@univerjs/sheets-numfmt 0.9.2 → 0.9.3
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 +130 -126
- package/lib/index.js +130 -126
- package/lib/types/controllers/numfmt-cell-content.controller.d.ts +5 -5
- package/lib/types/facade/f-workbook.d.ts +4 -4
- package/lib/types/utils/pattern.d.ts +3 -3
- package/lib/umd/index.js +1 -1
- package/package.json +6 -7
package/lib/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
var ie = Object.defineProperty;
|
|
2
2
|
var le = (e, t, r) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
-
var
|
|
4
|
-
import { numfmt as w, CommandType as V, ICommandService as
|
|
5
|
-
import { getSheetCommandTarget as H, transformCellsToRange as ye, checkCellValueType as G, rangeMerge as
|
|
6
|
-
import {
|
|
7
|
-
import { BehaviorSubject as K, merge as Ie, switchMap as Te, of as Ee, skip as xe } from "rxjs";
|
|
3
|
+
var R = (e, t, r) => le(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { numfmt as w, CommandType as V, ICommandService as I, IUniverInstanceService as A, IUndoRedoService as ue, isTextFormat as X, CellValueType as $, ObjectMatrix as M, sequenceExecute as me, Range as E, Inject as T, ThemeService as fe, LocaleService as de, IConfigService as Q, Disposable as ee, LocaleType as b, InterceptorEffectEnum as z, UniverInstanceType as te, DependentOn as he, Injector as ge, Plugin as Se, merge as pe, registerDependencies as ve, touchDependencies as Y } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as H, transformCellsToRange as ye, checkCellValueType as G, rangeMerge as k, SetNumfmtMutation as re, factorySetNumfmtUndoMutation as _e, RemoveNumfmtMutation as Ce, SetRangeValuesMutation as B, factoryRemoveNumfmtUndoMutation as be, SheetsSelectionsService as j, INumfmtService as W, SheetInterceptorService as Me, INTERCEPTOR_POINT as $e, InterceptCellContentPriority as Re, UniverSheetsPlugin as Ne } from "@univerjs/sheets";
|
|
6
|
+
import { BehaviorSubject as K, merge as Ee, switchMap as Ie, of as Te, skip as xe } from "rxjs";
|
|
8
7
|
import { stripErrorMargin as Ve } from "@univerjs/engine-formula";
|
|
9
8
|
const ne = [
|
|
10
9
|
"$",
|
|
@@ -178,20 +177,20 @@ const ne = [
|
|
|
178
177
|
], O = (e, t = 0) => {
|
|
179
178
|
var n;
|
|
180
179
|
return e && (n = w.getFormatInfo(e).maxDecimals) != null ? n : t;
|
|
181
|
-
},
|
|
180
|
+
}, Z = (e) => new Array(Math.min(Math.max(0, Number(e)), 30)).fill(0).join(""), P = (e, t) => e.split(";").map((n) => /\.0?/.test(n) ? n.replace(
|
|
182
181
|
/\.0*/g,
|
|
183
|
-
`${t > 0 ? "." : ""}${
|
|
182
|
+
`${t > 0 ? "." : ""}${Z(Number(t || 0))}`
|
|
184
183
|
) : /0([^0]?)|0$/.test(n) ? n.replace(
|
|
185
184
|
/0([^0]+)|0$/,
|
|
186
|
-
`0${t > 0 ? "." : ""}${
|
|
187
|
-
) : n).join(";"),
|
|
185
|
+
`0${t > 0 ? "." : ""}${Z(Number(t || 0))}$1`
|
|
186
|
+
) : n).join(";"), et = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), U = {
|
|
188
187
|
id: "sheet.command.numfmt.set.numfmt",
|
|
189
188
|
type: V.COMMAND,
|
|
190
189
|
// eslint-disable-next-line max-lines-per-function
|
|
191
190
|
handler: (e, t) => {
|
|
192
191
|
if (!t)
|
|
193
192
|
return !1;
|
|
194
|
-
const r = e.get(
|
|
193
|
+
const r = e.get(I), n = e.get(A), s = e.get(ue), o = H(n, t);
|
|
195
194
|
if (!o) return !1;
|
|
196
195
|
const { unitId: a, subUnitId: i, worksheet: f } = o, u = t.values.filter((l) => !!l.pattern), y = t.values.filter((l) => !l.pattern), _ = ye(a, i, u), g = {
|
|
197
196
|
unitId: a,
|
|
@@ -202,43 +201,43 @@ const ne = [
|
|
|
202
201
|
endColumn: l.col,
|
|
203
202
|
endRow: l.row
|
|
204
203
|
}))
|
|
205
|
-
}, C = [],
|
|
204
|
+
}, C = [], S = [];
|
|
206
205
|
if (u.length) {
|
|
207
206
|
const l = u.reduce((d, c) => {
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
const x = G(
|
|
212
|
-
x !==
|
|
207
|
+
X(c.pattern) && d.setValue(c.row, c.col, { t: $.STRING });
|
|
208
|
+
const v = f.getCellRaw(c.row, c.col);
|
|
209
|
+
if (v) {
|
|
210
|
+
const x = G(v.v);
|
|
211
|
+
x !== v.t && d.setValue(c.row, c.col, { t: x });
|
|
213
212
|
}
|
|
214
213
|
return d;
|
|
215
|
-
}, new
|
|
216
|
-
new
|
|
217
|
-
const
|
|
218
|
-
|
|
214
|
+
}, new M()).getMatrix(), h = new M();
|
|
215
|
+
new M(l).forValue((d, c) => {
|
|
216
|
+
const v = f.getCellRaw(d, c);
|
|
217
|
+
v ? h.setValue(d, c, { t: v.t }) : h.setValue(d, c, { t: void 0 });
|
|
219
218
|
}), Object.keys(_.values).forEach((d) => {
|
|
220
219
|
const c = _.values[d];
|
|
221
|
-
c.ranges =
|
|
220
|
+
c.ranges = k(c.ranges);
|
|
222
221
|
}), C.push({
|
|
223
|
-
id:
|
|
222
|
+
id: re.id,
|
|
224
223
|
params: _
|
|
225
224
|
});
|
|
226
|
-
const
|
|
227
|
-
|
|
225
|
+
const p = _e(e, _);
|
|
226
|
+
S.push(...p);
|
|
228
227
|
}
|
|
229
228
|
if (y.length) {
|
|
230
|
-
g.ranges =
|
|
229
|
+
g.ranges = k(g.ranges);
|
|
231
230
|
const l = y.reduce((d, c) => {
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
const x = G(
|
|
235
|
-
x !==
|
|
231
|
+
const v = f.getCellRaw(c.row, c.col);
|
|
232
|
+
if (v) {
|
|
233
|
+
const x = G(v.v);
|
|
234
|
+
x !== v.t && d.setValue(c.row, c.col, { t: x });
|
|
236
235
|
}
|
|
237
236
|
return d;
|
|
238
|
-
}, new
|
|
239
|
-
new
|
|
240
|
-
const
|
|
241
|
-
|
|
237
|
+
}, new M()).getMatrix(), h = new M();
|
|
238
|
+
new M(l).forValue((d, c) => {
|
|
239
|
+
const v = f.getCellRaw(d, c);
|
|
240
|
+
v ? h.setValue(d, c, { t: v.t }) : h.setValue(d, c, { t: void 0 });
|
|
242
241
|
}), C.push({
|
|
243
242
|
id: Ce.id,
|
|
244
243
|
params: g
|
|
@@ -250,20 +249,20 @@ const ne = [
|
|
|
250
249
|
cellValue: l
|
|
251
250
|
}
|
|
252
251
|
});
|
|
253
|
-
const
|
|
254
|
-
|
|
252
|
+
const p = be(e, g);
|
|
253
|
+
S.push({
|
|
255
254
|
id: B.id,
|
|
256
255
|
params: {
|
|
257
256
|
unitId: a,
|
|
258
257
|
subUnitId: i,
|
|
259
258
|
cellValue: h.getMatrix()
|
|
260
259
|
}
|
|
261
|
-
}, ...
|
|
260
|
+
}, ...p);
|
|
262
261
|
}
|
|
263
262
|
const m = me(C, r).result;
|
|
264
263
|
return m && s.pushUndoRedo({
|
|
265
264
|
unitID: a,
|
|
266
|
-
undoMutations:
|
|
265
|
+
undoMutations: S,
|
|
267
266
|
redoMutations: C
|
|
268
267
|
}), m;
|
|
269
268
|
}
|
|
@@ -271,7 +270,7 @@ const ne = [
|
|
|
271
270
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
272
271
|
type: V.COMMAND,
|
|
273
272
|
handler: async (e) => {
|
|
274
|
-
const t = e.get(
|
|
273
|
+
const t = e.get(I), r = e.get(j), n = e.get(W), s = e.get(A), o = r.getCurrentSelections();
|
|
275
274
|
if (!o || !o.length)
|
|
276
275
|
return !1;
|
|
277
276
|
const a = H(s);
|
|
@@ -279,12 +278,12 @@ const ne = [
|
|
|
279
278
|
const { unitId: i, subUnitId: f } = a;
|
|
280
279
|
let u = 0;
|
|
281
280
|
o.forEach((C) => {
|
|
282
|
-
|
|
283
|
-
const l = n.getValue(i, f,
|
|
281
|
+
E.foreach(C.range, (S, m) => {
|
|
282
|
+
const l = n.getValue(i, f, S, m);
|
|
284
283
|
if (!l) {
|
|
285
|
-
const
|
|
286
|
-
if (!u &&
|
|
287
|
-
const d = /\.(\d*)$/.exec(String(
|
|
284
|
+
const p = a.worksheet.getCellRaw(S, m);
|
|
285
|
+
if (!u && p && p.t === $.NUMBER && p.v) {
|
|
286
|
+
const d = /\.(\d*)$/.exec(String(p.v));
|
|
288
287
|
if (d) {
|
|
289
288
|
const c = d[1].length;
|
|
290
289
|
if (!c)
|
|
@@ -300,20 +299,20 @@ const ne = [
|
|
|
300
299
|
});
|
|
301
300
|
const y = u + 1, _ = P(`0${y > 0 ? ".0" : ""}`, y), g = [];
|
|
302
301
|
return o.forEach((C) => {
|
|
303
|
-
|
|
304
|
-
const l = n.getValue(i, f,
|
|
302
|
+
E.foreach(C.range, (S, m) => {
|
|
303
|
+
const l = n.getValue(i, f, S, m);
|
|
305
304
|
if (!l)
|
|
306
305
|
g.push({
|
|
307
|
-
row:
|
|
306
|
+
row: S,
|
|
308
307
|
col: m,
|
|
309
308
|
pattern: _
|
|
310
309
|
});
|
|
311
310
|
else {
|
|
312
|
-
const h = O(l.pattern),
|
|
313
|
-
|
|
314
|
-
row:
|
|
311
|
+
const h = O(l.pattern), p = P(l.pattern, h + 1);
|
|
312
|
+
p !== l.pattern && g.push({
|
|
313
|
+
row: S,
|
|
315
314
|
col: m,
|
|
316
|
-
pattern:
|
|
315
|
+
pattern: p
|
|
317
316
|
});
|
|
318
317
|
}
|
|
319
318
|
});
|
|
@@ -322,8 +321,8 @@ const ne = [
|
|
|
322
321
|
};
|
|
323
322
|
class oe {
|
|
324
323
|
constructor() {
|
|
325
|
-
|
|
326
|
-
|
|
324
|
+
R(this, "_currencySymbol$", new K("US"));
|
|
325
|
+
R(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
327
326
|
}
|
|
328
327
|
/**
|
|
329
328
|
* Set the currency symbol by setting the country code.
|
|
@@ -339,12 +338,12 @@ const De = {
|
|
|
339
338
|
id: "sheet.command.numfmt.set.currency",
|
|
340
339
|
type: V.COMMAND,
|
|
341
340
|
handler: async (e) => {
|
|
342
|
-
const t = e.get(
|
|
341
|
+
const t = e.get(I), r = e.get(j), n = e.get(oe), s = Ue[n.getCurrencySymbol()] || "$", o = r.getCurrentSelections();
|
|
343
342
|
if (!o || !o.length)
|
|
344
343
|
return !1;
|
|
345
344
|
const a = [], i = se[4].suffix(s);
|
|
346
345
|
return o.forEach((u) => {
|
|
347
|
-
|
|
346
|
+
E.foreach(u.range, (y, _) => {
|
|
348
347
|
a.push({ row: y, col: _, pattern: i, type: "currency" });
|
|
349
348
|
});
|
|
350
349
|
}), await t.executeCommand(U.id, { values: a });
|
|
@@ -353,12 +352,12 @@ const De = {
|
|
|
353
352
|
id: "sheet.command.numfmt.set.percent",
|
|
354
353
|
type: V.COMMAND,
|
|
355
354
|
handler: async (e) => {
|
|
356
|
-
const t = e.get(
|
|
355
|
+
const t = e.get(I), n = e.get(j).getCurrentSelections();
|
|
357
356
|
if (!n || !n.length)
|
|
358
357
|
return !1;
|
|
359
358
|
const s = [], o = "0%";
|
|
360
359
|
return n.forEach((i) => {
|
|
361
|
-
|
|
360
|
+
E.foreach(i.range, (f, u) => {
|
|
362
361
|
s.push({ row: f, col: u, pattern: o, type: "percent" });
|
|
363
362
|
});
|
|
364
363
|
}), await t.executeCommand(U.id, { values: s });
|
|
@@ -367,36 +366,36 @@ const De = {
|
|
|
367
366
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
368
367
|
type: V.COMMAND,
|
|
369
368
|
handler: async (e) => {
|
|
370
|
-
const t = e.get(
|
|
369
|
+
const t = e.get(I), r = e.get(j), n = e.get(W), s = e.get(A), o = r.getCurrentSelections();
|
|
371
370
|
if (!o || !o.length)
|
|
372
371
|
return !1;
|
|
373
372
|
const a = H(s);
|
|
374
373
|
if (!a) return !1;
|
|
375
374
|
const { unitId: i, subUnitId: f } = a;
|
|
376
375
|
let u = 0;
|
|
377
|
-
o.forEach((
|
|
378
|
-
|
|
376
|
+
o.forEach((S) => {
|
|
377
|
+
E.foreach(S.range, (m, l) => {
|
|
379
378
|
const h = n.getValue(i, f, m, l);
|
|
380
379
|
if (!h) {
|
|
381
380
|
const d = a.worksheet.getCellRaw(m, l);
|
|
382
|
-
if (!u && d && d.t ===
|
|
381
|
+
if (!u && d && d.t === $.NUMBER && d.v) {
|
|
383
382
|
const c = /\.(\d*)$/.exec(String(d.v));
|
|
384
383
|
if (c) {
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
384
|
+
const v = c[1].length;
|
|
385
|
+
if (!v)
|
|
387
386
|
return;
|
|
388
|
-
u = Math.max(u,
|
|
387
|
+
u = Math.max(u, v);
|
|
389
388
|
}
|
|
390
389
|
}
|
|
391
390
|
return;
|
|
392
391
|
}
|
|
393
|
-
const
|
|
394
|
-
u =
|
|
392
|
+
const p = O(h.pattern);
|
|
393
|
+
u = p > u ? p : u;
|
|
395
394
|
});
|
|
396
395
|
});
|
|
397
396
|
const y = u - 1, _ = P(`0${y > 0 ? ".0" : "."}`, y), g = [];
|
|
398
|
-
return o.forEach((
|
|
399
|
-
|
|
397
|
+
return o.forEach((S) => {
|
|
398
|
+
E.foreach(S.range, (m, l) => {
|
|
400
399
|
const h = n.getValue(i, f, m, l);
|
|
401
400
|
if (!h)
|
|
402
401
|
g.push({
|
|
@@ -405,17 +404,17 @@ const De = {
|
|
|
405
404
|
pattern: _
|
|
406
405
|
});
|
|
407
406
|
else {
|
|
408
|
-
const
|
|
407
|
+
const p = O(h.pattern);
|
|
409
408
|
g.push({
|
|
410
409
|
row: m,
|
|
411
410
|
col: l,
|
|
412
|
-
pattern: P(h.pattern,
|
|
411
|
+
pattern: P(h.pattern, p - 1)
|
|
413
412
|
});
|
|
414
413
|
}
|
|
415
414
|
});
|
|
416
415
|
}), await t.executeCommand(U.id, { values: g });
|
|
417
416
|
}
|
|
418
|
-
}, ae = "sheets-numfmt.config", q = {},
|
|
417
|
+
}, ae = "sheets-numfmt.config", q = {}, tt = (e) => w.getFormatInfo(e).type || "unknown", je = (e, t, r = "en") => {
|
|
419
418
|
const n = w.formatColor(e, t), s = n ? String(n) : void 0, o = w.format(e, t, { locale: r, throws: !1 });
|
|
420
419
|
return t < 0 ? {
|
|
421
420
|
result: o,
|
|
@@ -438,44 +437,49 @@ const He = {
|
|
|
438
437
|
color: "#409f11"
|
|
439
438
|
}
|
|
440
439
|
};
|
|
441
|
-
let D = class extends
|
|
440
|
+
let D = class extends ee {
|
|
442
441
|
constructor(t, r, n, s, o, a, i) {
|
|
443
442
|
super();
|
|
444
|
-
|
|
445
|
-
|
|
443
|
+
R(this, "_locale$", new K("en"));
|
|
444
|
+
R(this, "locale$", this._locale$.asObservable());
|
|
446
445
|
this._instanceService = t, this._sheetInterceptorService = r, this._themeService = n, this._commandService = s, this._numfmtService = o, this._localeService = a, this._configService = i, this._initInterceptorCellContent();
|
|
447
446
|
}
|
|
448
|
-
get
|
|
449
|
-
const t = this.
|
|
447
|
+
get locale() {
|
|
448
|
+
const t = this._locale$.getValue();
|
|
450
449
|
if (t)
|
|
451
450
|
return t;
|
|
452
451
|
switch (this._localeService.getCurrentLocale()) {
|
|
453
|
-
case
|
|
452
|
+
case b.FR_FR:
|
|
454
453
|
return "fr";
|
|
455
|
-
case
|
|
454
|
+
case b.RU_RU:
|
|
456
455
|
return "ru";
|
|
457
|
-
case
|
|
456
|
+
case b.VI_VN:
|
|
458
457
|
return "vi";
|
|
459
|
-
case
|
|
458
|
+
case b.ZH_CN:
|
|
460
459
|
return "zh-CN";
|
|
461
|
-
case
|
|
460
|
+
case b.KO_KR:
|
|
461
|
+
return "ko";
|
|
462
|
+
case b.ZH_TW:
|
|
462
463
|
return "zh-TW";
|
|
463
|
-
case
|
|
464
|
-
case
|
|
464
|
+
case b.ES_ES:
|
|
465
|
+
case b.CA_ES:
|
|
466
|
+
return "es";
|
|
467
|
+
case b.EN_US:
|
|
468
|
+
case b.FA_IR:
|
|
465
469
|
default:
|
|
466
470
|
return "en";
|
|
467
471
|
}
|
|
468
472
|
}
|
|
469
473
|
// eslint-disable-next-line max-lines-per-function
|
|
470
474
|
_initInterceptorCellContent() {
|
|
471
|
-
const t = new
|
|
472
|
-
this.disposeWithMe(
|
|
475
|
+
const t = new M();
|
|
476
|
+
this.disposeWithMe(Ee(this._locale$, this._localeService.currentLocale$).subscribe(() => {
|
|
473
477
|
t.reset();
|
|
474
478
|
})), this.disposeWithMe(this._sheetInterceptorService.intercept($e.CELL_CONTENT, {
|
|
475
479
|
effect: z.Value | z.Style,
|
|
476
480
|
// eslint-disable-next-line complexity
|
|
477
481
|
handler: (r, n, s) => {
|
|
478
|
-
var C,
|
|
482
|
+
var C, S;
|
|
479
483
|
const o = n.unitId, a = n.subUnitId;
|
|
480
484
|
let i;
|
|
481
485
|
const f = r;
|
|
@@ -485,20 +489,20 @@ let D = class extends Q {
|
|
|
485
489
|
const m = n.workbook.getStyles().get(r.s);
|
|
486
490
|
m != null && m.n && (i = m.n);
|
|
487
491
|
}
|
|
488
|
-
if (i || (i = this._numfmtService.getValue(o, a, n.row, n.col)), !i || i.pattern === "General" || f.t !==
|
|
492
|
+
if (i || (i = this._numfmtService.getValue(o, a, n.row, n.col)), !i || i.pattern === "General" || f.t !== $.NUMBER && G(f.v) !== $.NUMBER)
|
|
489
493
|
return s(r);
|
|
490
|
-
if ((!r || r === n.rawData) && (r = { ...n.rawData }),
|
|
491
|
-
return (C = this._configService.getConfig(ae)) != null && C.disableTextFormatMark ? (r.t =
|
|
494
|
+
if ((!r || r === n.rawData) && (r = { ...n.rawData }), X(i.pattern))
|
|
495
|
+
return (C = this._configService.getConfig(ae)) != null && C.disableTextFormatMark ? (r.t = $.STRING, s(r)) : (r.t = $.STRING, r.markers = { ...r == null ? void 0 : r.markers, ...He }, s(r));
|
|
492
496
|
let u = "";
|
|
493
497
|
const y = t.getValue(n.row, n.col);
|
|
494
498
|
if (y && y.parameters === `${f.v}_${i.pattern}`)
|
|
495
499
|
return s({ ...r, ...y.result });
|
|
496
|
-
const _ = Le(i.pattern, Number(f.v), this.
|
|
500
|
+
const _ = Le(i.pattern, Number(f.v), this.locale);
|
|
497
501
|
if (u = _.result, !u)
|
|
498
502
|
return s(r);
|
|
499
|
-
const g = { v: u, t:
|
|
503
|
+
const g = { v: u, t: $.NUMBER };
|
|
500
504
|
if (_.color) {
|
|
501
|
-
const m = (
|
|
505
|
+
const m = (S = this._themeService.getColorFromTheme(`${_.color}.500`)) != null ? S : _.color;
|
|
502
506
|
m && (g.interceptorStyle = { cl: { rgb: m } });
|
|
503
507
|
}
|
|
504
508
|
return t.setValue(n.row, n.col, {
|
|
@@ -508,50 +512,50 @@ let D = class extends Q {
|
|
|
508
512
|
},
|
|
509
513
|
priority: Re.NUMFMT
|
|
510
514
|
})), this.disposeWithMe(this._commandService.onCommandExecuted((r) => {
|
|
511
|
-
if (r.id ===
|
|
515
|
+
if (r.id === re.id) {
|
|
512
516
|
const n = r.params;
|
|
513
517
|
Object.keys(n.values).forEach((s) => {
|
|
514
518
|
n.values[s].ranges.forEach((a) => {
|
|
515
|
-
|
|
519
|
+
E.foreach(a, (i, f) => {
|
|
516
520
|
t.realDeleteValue(i, f);
|
|
517
521
|
});
|
|
518
522
|
});
|
|
519
523
|
});
|
|
520
524
|
} else if (r.id === B.id) {
|
|
521
525
|
const n = r.params;
|
|
522
|
-
new
|
|
526
|
+
new M(n.cellValue).forValue((s, o) => {
|
|
523
527
|
t.realDeleteValue(s, o);
|
|
524
528
|
});
|
|
525
529
|
}
|
|
526
530
|
})), this.disposeWithMe(
|
|
527
|
-
this._instanceService.getCurrentTypeOfUnit$(
|
|
528
|
-
|
|
531
|
+
this._instanceService.getCurrentTypeOfUnit$(te.UNIVER_SHEET).pipe(
|
|
532
|
+
Ie((r) => {
|
|
529
533
|
var n;
|
|
530
|
-
return (n = r == null ? void 0 : r.activeSheet$) != null ? n :
|
|
534
|
+
return (n = r == null ? void 0 : r.activeSheet$) != null ? n : Te(null);
|
|
531
535
|
}),
|
|
532
536
|
xe(1)
|
|
533
537
|
).subscribe(() => t.reset())
|
|
534
538
|
);
|
|
535
539
|
}
|
|
536
540
|
setNumfmtLocal(t) {
|
|
537
|
-
this.
|
|
541
|
+
this._locale$.next(t);
|
|
538
542
|
}
|
|
539
543
|
};
|
|
540
544
|
D = Be([
|
|
541
545
|
N(0, A),
|
|
542
|
-
N(1,
|
|
543
|
-
N(2,
|
|
544
|
-
N(3,
|
|
545
|
-
N(4,
|
|
546
|
-
N(5,
|
|
547
|
-
N(6,
|
|
546
|
+
N(1, T(Me)),
|
|
547
|
+
N(2, T(fe)),
|
|
548
|
+
N(3, T(I)),
|
|
549
|
+
N(4, T(W)),
|
|
550
|
+
N(5, T(de)),
|
|
551
|
+
N(6, Q)
|
|
548
552
|
], D);
|
|
549
553
|
const We = "SHEET_NUMFMT_PLUGIN";
|
|
550
|
-
class J extends
|
|
554
|
+
class J extends ee {
|
|
551
555
|
constructor() {
|
|
552
556
|
super(...arguments);
|
|
553
|
-
|
|
554
|
-
|
|
557
|
+
R(this, "_currencySymbol$", new K("US"));
|
|
558
|
+
R(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
555
559
|
}
|
|
556
560
|
/**
|
|
557
561
|
* Set the currency symbol by setting the country code.
|
|
@@ -563,15 +567,15 @@ class J extends Q {
|
|
|
563
567
|
return this._currencySymbol$.getValue();
|
|
564
568
|
}
|
|
565
569
|
}
|
|
566
|
-
var Ke = Object.defineProperty, ze = Object.getOwnPropertyDescriptor, Ye = (e, t, r) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r,
|
|
570
|
+
var Ke = Object.defineProperty, ze = Object.getOwnPropertyDescriptor, Ye = (e, t, r) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, ke = (e, t, r, n) => {
|
|
567
571
|
for (var s = n > 1 ? void 0 : n ? ze(t, r) : t, o = e.length - 1, a; o >= 0; o--)
|
|
568
572
|
(a = e[o]) && (s = a(s) || s);
|
|
569
573
|
return s;
|
|
570
574
|
}, L = (e, t) => (r, n) => t(r, n, e), ce = (e, t, r) => Ye(e, typeof t != "symbol" ? t + "" : t, r);
|
|
571
|
-
let F = class extends
|
|
575
|
+
let F = class extends Se {
|
|
572
576
|
constructor(e = q, t, r, n) {
|
|
573
577
|
super(), this._config = e, this._injector = t, this._configService = r, this._commandService = n;
|
|
574
|
-
const { ...s } =
|
|
578
|
+
const { ...s } = pe(
|
|
575
579
|
{},
|
|
576
580
|
q,
|
|
577
581
|
this._config
|
|
@@ -579,7 +583,7 @@ let F = class extends pe {
|
|
|
579
583
|
this._configService.setConfig(ae, s);
|
|
580
584
|
}
|
|
581
585
|
onStarting() {
|
|
582
|
-
|
|
586
|
+
ve(this._injector, [
|
|
583
587
|
[D],
|
|
584
588
|
[oe],
|
|
585
589
|
[J]
|
|
@@ -602,18 +606,18 @@ let F = class extends pe {
|
|
|
602
606
|
}
|
|
603
607
|
};
|
|
604
608
|
ce(F, "pluginName", We);
|
|
605
|
-
ce(F, "type",
|
|
606
|
-
F =
|
|
609
|
+
ce(F, "type", te.UNIVER_SHEET);
|
|
610
|
+
F = ke([
|
|
607
611
|
he(Ne),
|
|
608
|
-
L(1,
|
|
609
|
-
L(2,
|
|
610
|
-
L(3,
|
|
612
|
+
L(1, T(ge)),
|
|
613
|
+
L(2, Q),
|
|
614
|
+
L(3, I)
|
|
611
615
|
], F);
|
|
612
|
-
const
|
|
616
|
+
const rt = (e) => ne.find((r) => e.includes(r)), nt = () => ne.map((e) => ({ label: e, value: e })), st = (e) => se.map((t) => ({
|
|
613
617
|
label: t.label(e),
|
|
614
618
|
value: t.suffix(e),
|
|
615
619
|
color: t.color
|
|
616
|
-
})),
|
|
620
|
+
})), ot = () => we.map((e) => ({ label: e.label, value: e.suffix })), at = () => Oe.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
|
|
617
621
|
export {
|
|
618
622
|
Pe as AddDecimalCommand,
|
|
619
623
|
se as CURRENCYFORMAT,
|
|
@@ -629,16 +633,16 @@ export {
|
|
|
629
633
|
F as UniverSheetsNumfmtPlugin,
|
|
630
634
|
Ue as countryCurrencyMap,
|
|
631
635
|
ne as currencySymbols,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
+
st as getCurrencyFormatOptions,
|
|
637
|
+
nt as getCurrencyOptions,
|
|
638
|
+
rt as getCurrencyType,
|
|
639
|
+
ot as getDateFormatOptions,
|
|
636
640
|
O as getDecimalFromPattern,
|
|
637
|
-
|
|
638
|
-
|
|
641
|
+
Z as getDecimalString,
|
|
642
|
+
at as getNumberFormatOptions,
|
|
639
643
|
je as getPatternPreview,
|
|
640
644
|
Le as getPatternPreviewIgnoreGeneral,
|
|
641
|
-
|
|
642
|
-
|
|
645
|
+
tt as getPatternType,
|
|
646
|
+
et as isPatternHasDecimal,
|
|
643
647
|
P as setPatternDecimal
|
|
644
648
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INumfmtLocaleTag, Disposable, ICommandService, IConfigService, IUniverInstanceService, LocaleService, ThemeService } from '@univerjs/core';
|
|
2
2
|
import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
|
|
3
3
|
export declare class SheetsNumfmtCellContentController extends Disposable {
|
|
4
4
|
private readonly _instanceService;
|
|
@@ -8,10 +8,10 @@ export declare class SheetsNumfmtCellContentController extends Disposable {
|
|
|
8
8
|
private _numfmtService;
|
|
9
9
|
private _localeService;
|
|
10
10
|
private readonly _configService;
|
|
11
|
-
private
|
|
12
|
-
|
|
11
|
+
private _locale$;
|
|
12
|
+
locale$: import('rxjs').Observable<INumfmtLocaleTag>;
|
|
13
13
|
constructor(_instanceService: IUniverInstanceService, _sheetInterceptorService: SheetInterceptorService, _themeService: ThemeService, _commandService: ICommandService, _numfmtService: INumfmtService, _localeService: LocaleService, _configService: IConfigService);
|
|
14
|
-
get
|
|
14
|
+
get locale(): INumfmtLocaleTag;
|
|
15
15
|
private _initInterceptorCellContent;
|
|
16
|
-
setNumfmtLocal(
|
|
16
|
+
setNumfmtLocal(locale: INumfmtLocaleTag): void;
|
|
17
17
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INumfmtLocaleTag } from '@univerjs/core';
|
|
2
2
|
import { FWorkbook } from '@univerjs/sheets/facade';
|
|
3
3
|
export interface IFWorkbookNumfmtMixin {
|
|
4
4
|
/**
|
|
5
5
|
* Set the locale for number formatting.
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {INumfmtLocaleTag} locale zh_CN,zh_TW,zh_HK,ja,ko,th,cs,da,nl,en,en_AU,en_CA,en_GB,en_IE,fi,fr,fr_CA,fr_CH,de,de_CH,el,hu,is,id,it,it_CH,nb,no,pl,pt,pt_BR,ru,sk,es,es_AR,es_BO,es_CL,es_CO,es_EC,es_MX,es_PY,es_UY,es_VE,sv,tr,cy,az,be,bg,ca,fil,gu,he,hr,hy,ka,kk,kn,lt,lv,ml,mn,mr,my,pa,ro,sl,sr,ta,te,uk,vi,ar,bn,hi
|
|
7
7
|
* @returns {FWorkbook} The FWorkbook instance for chaining.
|
|
8
8
|
* @memberof IFWorkbookNumfmtMixin
|
|
9
9
|
* @example
|
|
@@ -22,10 +22,10 @@ export interface IFWorkbookNumfmtMixin {
|
|
|
22
22
|
* console.log(fRange.getDisplayValue()); // 1.234,57
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
setNumfmtLocal(
|
|
25
|
+
setNumfmtLocal(locale: INumfmtLocaleTag): FWorkbook;
|
|
26
26
|
}
|
|
27
27
|
export declare class FWorkbookLegacy extends FWorkbook implements IFWorkbookNumfmtMixin {
|
|
28
|
-
setNumfmtLocal(
|
|
28
|
+
setNumfmtLocal(locale: INumfmtLocaleTag): FWorkbook;
|
|
29
29
|
}
|
|
30
30
|
declare module '@univerjs/sheets/facade' {
|
|
31
31
|
interface FWorkbook extends IFWorkbookNumfmtMixin {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INumfmtLocaleTag } from '@univerjs/core';
|
|
2
2
|
import { FormatType } from '@univerjs/sheets';
|
|
3
3
|
export declare const getPatternType: (pattern: string) => FormatType;
|
|
4
4
|
interface IPatternPreview {
|
|
5
5
|
result: string;
|
|
6
6
|
color?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare const getPatternPreview: (pattern: string, value: number, locale?:
|
|
9
|
-
export declare const getPatternPreviewIgnoreGeneral: (pattern: string, value: number, locale?:
|
|
8
|
+
export declare const getPatternPreview: (pattern: string, value: number, locale?: INumfmtLocaleTag) => IPatternPreview;
|
|
9
|
+
export declare const getPatternPreviewIgnoreGeneral: (pattern: string, value: number, locale?: INumfmtLocaleTag) => IPatternPreview;
|
|
10
10
|
export {};
|