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