@univerjs/sheets-numfmt 0.10.3 → 0.10.4-nightly.202508220605
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 +333 -347
- package/lib/index.js +333 -347
- 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 +2 -4
- 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/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 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
|
"£",
|
|
@@ -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
|
+
], V = /* @__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 we(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: V.get(e) || "€",
|
|
57
|
+
locale: e
|
|
58
|
+
};
|
|
59
|
+
case m.RU_RU:
|
|
60
|
+
return {
|
|
61
|
+
icon: "RoubleIcon",
|
|
62
|
+
symbol: V.get(e) || "₽",
|
|
63
|
+
locale: e
|
|
64
|
+
};
|
|
65
|
+
case m.ZH_CN:
|
|
66
|
+
return {
|
|
67
|
+
icon: "RmbIcon",
|
|
68
|
+
symbol: V.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 V.get(e) || "$";
|
|
82
|
+
}
|
|
83
|
+
function Ue(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 Ve = [
|
|
77
90
|
{
|
|
78
91
|
label: "1930-08-05",
|
|
79
92
|
suffix: "yyyy-MM-dd"
|
|
@@ -118,7 +131,7 @@ const ne = [
|
|
|
118
131
|
label: "08-05 下午 01:30",
|
|
119
132
|
suffix: "MM-dd A/P hh:mm"
|
|
120
133
|
}
|
|
121
|
-
],
|
|
134
|
+
], xe = [
|
|
122
135
|
{
|
|
123
136
|
label: "(1,235)",
|
|
124
137
|
suffix: "#,##0_);(#,##0)"
|
|
@@ -146,7 +159,7 @@ const ne = [
|
|
|
146
159
|
suffix: "#,##0.00_);[Red]-#,##0.00",
|
|
147
160
|
color: "red"
|
|
148
161
|
}
|
|
149
|
-
],
|
|
162
|
+
], Oe = [
|
|
150
163
|
{
|
|
151
164
|
label: (e) => `${e}1,235`,
|
|
152
165
|
suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
|
|
@@ -174,214 +187,198 @@ const ne = [
|
|
|
174
187
|
suffix: (e) => `"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,
|
|
175
188
|
color: "red"
|
|
176
189
|
}
|
|
177
|
-
],
|
|
178
|
-
var
|
|
179
|
-
return e && (
|
|
180
|
-
},
|
|
190
|
+
], x = (e, t = 0) => {
|
|
191
|
+
var r;
|
|
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(
|
|
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(";"), rt = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), U = {
|
|
187
200
|
id: "sheet.command.numfmt.set.numfmt",
|
|
188
|
-
type:
|
|
201
|
+
type: w.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(I), 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), M = _e(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
|
+
}, y = [], _ = [];
|
|
205
218
|
if (u.length) {
|
|
206
|
-
const l = u.reduce((
|
|
207
|
-
X(
|
|
208
|
-
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);
|
|
209
222
|
if (v) {
|
|
210
|
-
const
|
|
211
|
-
|
|
223
|
+
const P = H(v.v);
|
|
224
|
+
P !== v.t && g.setValue(a.row, a.col, { t: P });
|
|
212
225
|
}
|
|
213
|
-
return
|
|
214
|
-
}, new
|
|
215
|
-
new
|
|
216
|
-
const v =
|
|
217
|
-
v ? h.setValue(
|
|
218
|
-
}), Object.keys(
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
}),
|
|
222
|
-
id:
|
|
223
|
-
params:
|
|
226
|
+
return g;
|
|
227
|
+
}, new b()).getMatrix(), h = new b();
|
|
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
|
+
}), y.push({
|
|
235
|
+
id: te.id,
|
|
236
|
+
params: M
|
|
224
237
|
});
|
|
225
|
-
const
|
|
226
|
-
|
|
238
|
+
const S = Se(e, M);
|
|
239
|
+
_.push(...S);
|
|
227
240
|
}
|
|
228
|
-
if (
|
|
229
|
-
|
|
230
|
-
const l =
|
|
231
|
-
const v =
|
|
241
|
+
if (C.length) {
|
|
242
|
+
p.ranges = z(p.ranges);
|
|
243
|
+
const l = C.reduce((g, a) => {
|
|
244
|
+
const v = d.getCellRaw(a.row, a.col);
|
|
232
245
|
if (v) {
|
|
233
|
-
const
|
|
234
|
-
|
|
246
|
+
const P = H(v.v);
|
|
247
|
+
P !== v.t && g.setValue(a.row, a.col, { t: P });
|
|
235
248
|
}
|
|
236
|
-
return
|
|
237
|
-
}, new
|
|
238
|
-
new
|
|
239
|
-
const v =
|
|
240
|
-
v ? h.setValue(
|
|
241
|
-
}),
|
|
242
|
-
id:
|
|
243
|
-
params:
|
|
249
|
+
return g;
|
|
250
|
+
}, new b()).getMatrix(), h = new b();
|
|
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
|
+
}), y.push({
|
|
255
|
+
id: ve.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 S = Ce(e, p);
|
|
266
|
+
_.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
|
+
}, ...S);
|
|
261
274
|
}
|
|
262
|
-
const
|
|
263
|
-
return
|
|
264
|
-
unitID:
|
|
265
|
-
undoMutations:
|
|
266
|
-
redoMutations:
|
|
267
|
-
}),
|
|
275
|
+
const f = ie(y, n).result;
|
|
276
|
+
return f && s.pushUndoRedo({
|
|
277
|
+
unitID: c,
|
|
278
|
+
undoMutations: _,
|
|
279
|
+
redoMutations: y
|
|
280
|
+
}), f;
|
|
268
281
|
}
|
|
269
|
-
},
|
|
282
|
+
}, De = {
|
|
270
283
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
271
|
-
type:
|
|
284
|
+
type: w.COMMAND,
|
|
272
285
|
handler: async (e) => {
|
|
273
|
-
const t = e.get(I),
|
|
286
|
+
const t = e.get(I), 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
|
-
E.foreach(
|
|
282
|
-
const l =
|
|
293
|
+
o.forEach((y) => {
|
|
294
|
+
E.foreach(y.range, (_, f) => {
|
|
295
|
+
const l = r.getValue(i, d, _, f);
|
|
283
296
|
if (!l) {
|
|
284
|
-
const
|
|
285
|
-
if (!u &&
|
|
286
|
-
const
|
|
287
|
-
if (
|
|
288
|
-
const
|
|
289
|
-
if (!
|
|
297
|
+
const S = c.worksheet.getCellRaw(_, f);
|
|
298
|
+
if (!u && S && S.t === R.NUMBER && S.v) {
|
|
299
|
+
const g = /\.(\d*)$/.exec(String(S.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;
|
|
295
308
|
}
|
|
296
|
-
const h =
|
|
309
|
+
const h = x(l.pattern);
|
|
297
310
|
u = h > u ? h : u;
|
|
298
311
|
});
|
|
299
312
|
});
|
|
300
|
-
const
|
|
301
|
-
return o.forEach((
|
|
302
|
-
E.foreach(
|
|
303
|
-
const l =
|
|
313
|
+
const C = u + 1, M = O(`0${C > 0 ? ".0" : ""}`, C), p = [];
|
|
314
|
+
return o.forEach((y) => {
|
|
315
|
+
E.foreach(y.range, (_, f) => {
|
|
316
|
+
const l = r.getValue(i, d, _, f);
|
|
304
317
|
if (!l)
|
|
305
|
-
|
|
306
|
-
row:
|
|
307
|
-
col:
|
|
308
|
-
pattern:
|
|
318
|
+
p.push({
|
|
319
|
+
row: _,
|
|
320
|
+
col: f,
|
|
321
|
+
pattern: M
|
|
309
322
|
});
|
|
310
323
|
else {
|
|
311
|
-
const h =
|
|
312
|
-
|
|
313
|
-
row:
|
|
314
|
-
col:
|
|
315
|
-
pattern:
|
|
324
|
+
const h = x(l.pattern), S = O(l.pattern, h + 1);
|
|
325
|
+
S !== l.pattern && p.push({
|
|
326
|
+
row: _,
|
|
327
|
+
col: f,
|
|
328
|
+
pattern: S
|
|
316
329
|
});
|
|
317
330
|
}
|
|
318
331
|
});
|
|
319
|
-
}),
|
|
332
|
+
}), p.length ? await t.executeCommand(U.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: w.COMMAND,
|
|
340
337
|
handler: async (e) => {
|
|
341
|
-
const t = e.get(I),
|
|
342
|
-
if (!
|
|
338
|
+
const t = e.get(I), 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
|
-
E.foreach(u.range, (
|
|
347
|
-
|
|
341
|
+
const o = [], c = we(r.getCurrentLocale()), i = Ue(c.locale);
|
|
342
|
+
return s.forEach((u) => {
|
|
343
|
+
E.foreach(u.range, (C, M) => {
|
|
344
|
+
o.push({ row: C, col: M, pattern: i, type: "currency" });
|
|
348
345
|
});
|
|
349
|
-
}), await t.executeCommand(U.id, { values:
|
|
346
|
+
}), await t.executeCommand(U.id, { values: o });
|
|
350
347
|
}
|
|
351
|
-
},
|
|
348
|
+
}, Ae = {
|
|
352
349
|
id: "sheet.command.numfmt.set.percent",
|
|
353
|
-
type:
|
|
350
|
+
type: w.COMMAND,
|
|
354
351
|
handler: async (e) => {
|
|
355
|
-
const t = e.get(I),
|
|
356
|
-
if (!
|
|
352
|
+
const t = e.get(I), r = e.get(j).getCurrentSelections();
|
|
353
|
+
if (!r || !r.length)
|
|
357
354
|
return !1;
|
|
358
355
|
const s = [], o = "0%";
|
|
359
|
-
return
|
|
360
|
-
E.foreach(i.range, (
|
|
361
|
-
s.push({ row:
|
|
356
|
+
return r.forEach((i) => {
|
|
357
|
+
E.foreach(i.range, (d, u) => {
|
|
358
|
+
s.push({ row: d, col: u, pattern: o, type: "percent" });
|
|
362
359
|
});
|
|
363
360
|
}), await t.executeCommand(U.id, { values: s });
|
|
364
361
|
}
|
|
365
|
-
},
|
|
362
|
+
}, je = {
|
|
366
363
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
367
|
-
type:
|
|
364
|
+
type: w.COMMAND,
|
|
368
365
|
handler: async (e) => {
|
|
369
|
-
const t = e.get(I),
|
|
366
|
+
const t = e.get(I), 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
|
-
E.foreach(
|
|
378
|
-
const h =
|
|
373
|
+
o.forEach((_) => {
|
|
374
|
+
E.foreach(_.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 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;
|
|
385
382
|
if (!v)
|
|
386
383
|
return;
|
|
387
384
|
u = Math.max(u, v);
|
|
@@ -389,151 +386,157 @@ const De = {
|
|
|
389
386
|
}
|
|
390
387
|
return;
|
|
391
388
|
}
|
|
392
|
-
const
|
|
393
|
-
u =
|
|
389
|
+
const S = x(h.pattern);
|
|
390
|
+
u = S > u ? S : u;
|
|
394
391
|
});
|
|
395
392
|
});
|
|
396
|
-
const
|
|
397
|
-
return o.forEach((
|
|
398
|
-
E.foreach(
|
|
399
|
-
const h =
|
|
393
|
+
const C = u - 1, M = O(`0${C > 0 ? ".0" : "."}`, C), p = [];
|
|
394
|
+
return o.forEach((_) => {
|
|
395
|
+
E.foreach(_.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: M
|
|
405
402
|
});
|
|
406
403
|
else {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
row:
|
|
404
|
+
const S = x(h.pattern);
|
|
405
|
+
p.push({
|
|
406
|
+
row: f,
|
|
410
407
|
col: l,
|
|
411
|
-
pattern:
|
|
408
|
+
pattern: O(h.pattern, S - 1)
|
|
412
409
|
});
|
|
413
410
|
}
|
|
414
411
|
});
|
|
415
|
-
}), await t.executeCommand(U.id, { values:
|
|
412
|
+
}), await t.executeCommand(U.id, { values: p });
|
|
416
413
|
}
|
|
417
|
-
},
|
|
418
|
-
const
|
|
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 });
|
|
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(Pe(t))
|
|
427
424
|
// In Excel, the default General format also needs to handle numeric precision.
|
|
428
|
-
} :
|
|
429
|
-
var
|
|
430
|
-
|
|
431
|
-
|
|
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
|
+
var r, s;
|
|
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
|
+
};
|
|
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);
|
|
432
435
|
return s;
|
|
433
|
-
},
|
|
434
|
-
const
|
|
436
|
+
}, $ = (e, t) => (n, r) => t(n, r, e);
|
|
437
|
+
const Ze = {
|
|
435
438
|
tl: {
|
|
436
439
|
size: 6,
|
|
437
440
|
color: "#409f11"
|
|
438
441
|
}
|
|
439
442
|
};
|
|
440
|
-
let D = class extends
|
|
441
|
-
constructor(t,
|
|
443
|
+
let D = class extends ue {
|
|
444
|
+
constructor(t, n, r, s, o, c, i) {
|
|
442
445
|
super();
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
this._instanceService = t, this._sheetInterceptorService =
|
|
446
|
+
L(this, "_locale$", new $e("en"));
|
|
447
|
+
L(this, "locale$", this._locale$.asObservable());
|
|
448
|
+
this._instanceService = t, this._sheetInterceptorService = n, this._themeService = r, this._commandService = s, this._numfmtService = o, this._localeService = c, this._configService = i, this._initInterceptorCellContent();
|
|
446
449
|
}
|
|
447
450
|
get locale() {
|
|
448
451
|
const t = this._locale$.getValue();
|
|
449
452
|
if (t)
|
|
450
453
|
return t;
|
|
451
454
|
switch (this._localeService.getCurrentLocale()) {
|
|
452
|
-
case
|
|
455
|
+
case m.FR_FR:
|
|
453
456
|
return "fr";
|
|
454
|
-
case
|
|
457
|
+
case m.RU_RU:
|
|
455
458
|
return "ru";
|
|
456
|
-
case
|
|
459
|
+
case m.VI_VN:
|
|
457
460
|
return "vi";
|
|
458
|
-
case
|
|
461
|
+
case m.ZH_CN:
|
|
459
462
|
return "zh-CN";
|
|
460
|
-
case
|
|
463
|
+
case m.KO_KR:
|
|
461
464
|
return "ko";
|
|
462
|
-
case
|
|
465
|
+
case m.ZH_TW:
|
|
463
466
|
return "zh-TW";
|
|
464
|
-
case
|
|
465
|
-
case
|
|
467
|
+
case m.ES_ES:
|
|
468
|
+
case m.CA_ES:
|
|
466
469
|
return "es";
|
|
467
|
-
case
|
|
468
|
-
case
|
|
470
|
+
case m.EN_US:
|
|
471
|
+
case m.FA_IR:
|
|
469
472
|
default:
|
|
470
473
|
return "en";
|
|
471
474
|
}
|
|
472
475
|
}
|
|
473
476
|
// eslint-disable-next-line max-lines-per-function
|
|
474
477
|
_initInterceptorCellContent() {
|
|
475
|
-
const t = new
|
|
476
|
-
this.disposeWithMe(
|
|
478
|
+
const t = new b();
|
|
479
|
+
this.disposeWithMe(Ne(this._locale$, this._localeService.currentLocale$).subscribe(() => {
|
|
477
480
|
t.reset();
|
|
478
|
-
})), this.disposeWithMe(this._sheetInterceptorService.intercept(
|
|
479
|
-
effect:
|
|
481
|
+
})), this.disposeWithMe(this._sheetInterceptorService.intercept(ye.CELL_CONTENT, {
|
|
482
|
+
effect: Z.Value | Z.Style,
|
|
480
483
|
// eslint-disable-next-line complexity
|
|
481
|
-
handler: (
|
|
482
|
-
var
|
|
483
|
-
const o =
|
|
484
|
+
handler: (n, r, s) => {
|
|
485
|
+
var y, _;
|
|
486
|
+
const o = r.unitId, c = r.subUnitId;
|
|
484
487
|
let i;
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
487
|
-
return s(
|
|
488
|
-
if (
|
|
489
|
-
const
|
|
490
|
-
|
|
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);
|
|
491
494
|
}
|
|
492
|
-
if (i || (i = this._numfmtService.getValue(o,
|
|
493
|
-
return s(
|
|
494
|
-
if ((!
|
|
495
|
-
return (
|
|
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));
|
|
496
499
|
let u = "";
|
|
497
|
-
const
|
|
498
|
-
if (
|
|
499
|
-
return s({ ...
|
|
500
|
-
const
|
|
501
|
-
if (u =
|
|
502
|
-
return s(
|
|
503
|
-
const
|
|
504
|
-
if (
|
|
505
|
-
const
|
|
506
|
-
|
|
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
|
+
if (u = M.result, !u)
|
|
505
|
+
return s(n);
|
|
506
|
+
const p = { v: u, t: R.NUMBER };
|
|
507
|
+
if (M.color) {
|
|
508
|
+
const f = (_ = this._themeService.getColorFromTheme(`${M.color}.500`)) != null ? _ : M.color;
|
|
509
|
+
f && (p.interceptorStyle = { cl: { rgb: f } });
|
|
507
510
|
}
|
|
508
|
-
return t.setValue(
|
|
509
|
-
result:
|
|
510
|
-
parameters: `${
|
|
511
|
-
}), Object.assign(
|
|
511
|
+
return t.setValue(r.row, r.col, {
|
|
512
|
+
result: p,
|
|
513
|
+
parameters: `${d.v}_${i.pattern}`
|
|
514
|
+
}), Object.assign(n, p), s(n);
|
|
512
515
|
},
|
|
513
|
-
priority:
|
|
514
|
-
})), this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
515
|
-
if (
|
|
516
|
-
const
|
|
517
|
-
Object.keys(
|
|
518
|
-
|
|
519
|
-
E.foreach(
|
|
520
|
-
t.realDeleteValue(i,
|
|
516
|
+
priority: be.NUMFMT
|
|
517
|
+
})), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
|
|
518
|
+
if (n.id === te.id) {
|
|
519
|
+
const r = n.params;
|
|
520
|
+
Object.keys(r.values).forEach((s) => {
|
|
521
|
+
r.values[s].ranges.forEach((c) => {
|
|
522
|
+
E.foreach(c, (i, d) => {
|
|
523
|
+
t.realDeleteValue(i, d);
|
|
521
524
|
});
|
|
522
525
|
});
|
|
523
526
|
});
|
|
524
|
-
} else if (
|
|
525
|
-
const
|
|
526
|
-
new
|
|
527
|
+
} else if (n.id === B.id) {
|
|
528
|
+
const r = n.params;
|
|
529
|
+
new b(r.cellValue).forValue((s, o) => {
|
|
527
530
|
t.realDeleteValue(s, o);
|
|
528
531
|
});
|
|
529
532
|
}
|
|
530
533
|
})), this.disposeWithMe(
|
|
531
|
-
this._instanceService.getCurrentTypeOfUnit$(
|
|
532
|
-
|
|
533
|
-
var
|
|
534
|
-
return (
|
|
534
|
+
this._instanceService.getCurrentTypeOfUnit$(ee.UNIVER_SHEET).pipe(
|
|
535
|
+
Ee((n) => {
|
|
536
|
+
var r;
|
|
537
|
+
return (r = n == null ? void 0 : n.activeSheet$) != null ? r : Ie(null);
|
|
535
538
|
}),
|
|
536
|
-
|
|
539
|
+
Te(1)
|
|
537
540
|
).subscribe(() => t.reset())
|
|
538
541
|
);
|
|
539
542
|
}
|
|
@@ -541,108 +544,91 @@ let D = class extends ee {
|
|
|
541
544
|
this._locale$.next(t);
|
|
542
545
|
}
|
|
543
546
|
};
|
|
544
|
-
D =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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)
|
|
552
555
|
], 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);
|
|
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);
|
|
573
560
|
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 } =
|
|
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(
|
|
579
566
|
{},
|
|
580
567
|
q,
|
|
581
568
|
this._config
|
|
582
569
|
);
|
|
583
|
-
this._configService.setConfig(
|
|
570
|
+
this._configService.setConfig(re, s);
|
|
584
571
|
}
|
|
585
572
|
onStarting() {
|
|
586
|
-
|
|
587
|
-
[D]
|
|
588
|
-
|
|
589
|
-
[J]
|
|
590
|
-
]), Y(this._injector, [
|
|
573
|
+
he(this._injector, [
|
|
574
|
+
[D]
|
|
575
|
+
]), pe(this._injector, [
|
|
591
576
|
[D]
|
|
592
577
|
]);
|
|
593
578
|
}
|
|
594
579
|
onRendered() {
|
|
595
|
-
|
|
596
|
-
[J]
|
|
597
|
-
]), [
|
|
598
|
-
Pe,
|
|
599
|
-
Ae,
|
|
580
|
+
[
|
|
600
581
|
De,
|
|
582
|
+
je,
|
|
601
583
|
Fe,
|
|
584
|
+
Ae,
|
|
602
585
|
U
|
|
603
586
|
].forEach((e) => {
|
|
604
587
|
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
605
588
|
});
|
|
606
589
|
}
|
|
607
590
|
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
F =
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
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)
|
|
615
598
|
], F);
|
|
616
|
-
const
|
|
599
|
+
const at = (e) => ne.find((n) => e.includes(n)), ct = () => ne.map((e) => ({ label: e, value: e })), it = (e) => Oe.map((t) => ({
|
|
617
600
|
label: t.label(e),
|
|
618
601
|
value: t.suffix(e),
|
|
619
602
|
color: t.color
|
|
620
|
-
})),
|
|
603
|
+
})), lt = () => Ve.map((e) => ({ label: e.label, value: e.suffix })), ut = () => xe.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
|
|
621
604
|
export {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
De as SetCurrencyCommand,
|
|
605
|
+
De as AddDecimalCommand,
|
|
606
|
+
Oe as CURRENCYFORMAT,
|
|
607
|
+
Ve as DATEFMTLISG,
|
|
608
|
+
xe as NUMBERFORMAT,
|
|
609
|
+
re as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
|
|
610
|
+
Fe as SetCurrencyCommand,
|
|
629
611
|
U as SetNumfmtCommand,
|
|
630
|
-
|
|
612
|
+
Ae as SetPercentCommand,
|
|
631
613
|
D as SheetsNumfmtCellContentController,
|
|
632
|
-
|
|
614
|
+
je as SubtractDecimalCommand,
|
|
633
615
|
F as UniverSheetsNumfmtPlugin,
|
|
634
|
-
Ue as countryCurrencyMap,
|
|
635
616
|
ne as currencySymbols,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
617
|
+
Ue as getCurrencyFormat,
|
|
618
|
+
it as getCurrencyFormatOptions,
|
|
619
|
+
ct as getCurrencyOptions,
|
|
620
|
+
k as getCurrencySymbolByLocale,
|
|
621
|
+
we as getCurrencySymbolIconByLocale,
|
|
622
|
+
at as getCurrencyType,
|
|
623
|
+
lt as getDateFormatOptions,
|
|
624
|
+
x as getDecimalFromPattern,
|
|
625
|
+
Y as getDecimalString,
|
|
626
|
+
ut as getNumberFormatOptions,
|
|
627
|
+
ot as getNumfmtParseValueFilter,
|
|
628
|
+
Le as getPatternPreview,
|
|
629
|
+
Ge as getPatternPreviewIgnoreGeneral,
|
|
630
|
+
st as getPatternType,
|
|
631
|
+
rt as isPatternHasDecimal,
|
|
632
|
+
V as localeCurrencySymbolMap,
|
|
633
|
+
O as setPatternDecimal
|
|
648
634
|
};
|