@univerjs/sheets-numfmt 0.6.6 → 0.6.7-nightly.202503261607
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 +251 -238
- package/lib/facade.js +42 -0
- package/lib/index.js +666 -0
- package/lib/types/controllers/config.schema.d.ts +28 -0
- package/lib/types/controllers/numfmt-cell-content.controller.d.ts +3 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/numfmt-plugin.d.ts +4 -2
- package/lib/umd/index.js +1 -1
- package/package.json +8 -8
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var M = (e, t, n) =>
|
|
4
|
-
import { numfmt as x, CommandType as
|
|
5
|
-
import { getSheetCommandTarget as
|
|
6
|
-
import { isTextFormat as
|
|
7
|
-
import { BehaviorSubject as
|
|
8
|
-
import { stripErrorMargin as
|
|
9
|
-
const
|
|
1
|
+
var ae = Object.defineProperty;
|
|
2
|
+
var le = (e, t, n) => t in e ? ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var M = (e, t, n) => le(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { numfmt as x, CommandType as P, ICommandService as E, IUniverInstanceService as F, IUndoRedoService as ue, CellValueType as I, ObjectMatrix as b, sequenceExecute as me, Range as N, Inject as T, ThemeService as fe, LocaleService as de, IConfigService as X, Disposable as Q, LocaleType as $, InterceptorEffectEnum as K, UniverInstanceType as ee, DependentOn as ge, Injector as he, Plugin as pe, merge as Se, registerDependencies as ve, touchDependencies as z } from "@univerjs/core";
|
|
5
|
+
import { getSheetCommandTarget as H, transformCellsToRange as ye, checkCellValueType as G, rangeMerge as Y, SetNumfmtMutation as te, 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 Ie } from "@univerjs/sheets";
|
|
6
|
+
import { isTextFormat as ne } from "@univerjs/engine-numfmt";
|
|
7
|
+
import { BehaviorSubject as k, merge as Ne, switchMap as Ee, of as Te, skip as xe } from "rxjs";
|
|
8
|
+
import { stripErrorMargin as Ve } from "@univerjs/engine-formula";
|
|
9
|
+
const re = [
|
|
10
10
|
"$",
|
|
11
11
|
"£",
|
|
12
12
|
"¥",
|
|
@@ -34,7 +34,7 @@ const te = [
|
|
|
34
34
|
"₽",
|
|
35
35
|
"₾",
|
|
36
36
|
"₿"
|
|
37
|
-
],
|
|
37
|
+
], Pe = {
|
|
38
38
|
US: "$",
|
|
39
39
|
// United States Dollar
|
|
40
40
|
CA: "C$",
|
|
@@ -74,7 +74,7 @@ const te = [
|
|
|
74
74
|
SI: "€",
|
|
75
75
|
ES: "€"
|
|
76
76
|
// Add more mappings as needed
|
|
77
|
-
},
|
|
77
|
+
}, Ue = [
|
|
78
78
|
{
|
|
79
79
|
label: "1930-08-05",
|
|
80
80
|
suffix: "yyyy-MM-dd"
|
|
@@ -119,7 +119,7 @@ const te = [
|
|
|
119
119
|
label: "08-05 下午 01:30",
|
|
120
120
|
suffix: "MM-dd A/P hh:mm"
|
|
121
121
|
}
|
|
122
|
-
],
|
|
122
|
+
], we = [
|
|
123
123
|
{
|
|
124
124
|
label: "(1,235)",
|
|
125
125
|
suffix: "#,##0_);(#,##0)"
|
|
@@ -147,7 +147,7 @@ const te = [
|
|
|
147
147
|
suffix: "#,##0.00_);[Red]-#,##0.00",
|
|
148
148
|
color: "red"
|
|
149
149
|
}
|
|
150
|
-
],
|
|
150
|
+
], se = [
|
|
151
151
|
{
|
|
152
152
|
label: (e) => `${e}1,235`,
|
|
153
153
|
suffix: (e) => `"${e}"#,##0.00_);"${e}"#,##0.00`
|
|
@@ -175,131 +175,131 @@ const te = [
|
|
|
175
175
|
suffix: (e) => `"${e}"#,##0.00_);[Red]-"${e}"#,##0.00`,
|
|
176
176
|
color: "red"
|
|
177
177
|
}
|
|
178
|
-
],
|
|
178
|
+
], Oe = "SHEET_NUMFMT_PLUGIN", w = (e, t = 0) => {
|
|
179
179
|
var r;
|
|
180
180
|
return e && (r = x.getInfo(e).maxDecimals) != null ? r : t;
|
|
181
|
-
},
|
|
181
|
+
}, tt = (e, t) => {
|
|
182
182
|
if (e && !t || !e && t)
|
|
183
183
|
return !1;
|
|
184
184
|
const n = (u) => u.reduce(
|
|
185
|
-
(
|
|
186
|
-
if (
|
|
187
|
-
return
|
|
188
|
-
const
|
|
189
|
-
return p.type === "point" ? (
|
|
185
|
+
(g, p) => {
|
|
186
|
+
if (g.isEnd)
|
|
187
|
+
return g;
|
|
188
|
+
const h = p.value || p.num;
|
|
189
|
+
return p.type === "point" ? (g.isEnd = !0, g) : { ...g, result: g.result + h };
|
|
190
190
|
},
|
|
191
191
|
{ isEnd: !1, result: "" }
|
|
192
|
-
).result, r = x.getInfo(e)._partitions, s = x.getInfo(t)._partitions, o = n(r[0].tokens), c = n(s[0].tokens),
|
|
193
|
-
return o === c &&
|
|
192
|
+
).result, r = x.getInfo(e)._partitions, s = x.getInfo(t)._partitions, o = n(r[0].tokens), c = n(s[0].tokens), i = n(r[1].tokens), d = n(s[1].tokens);
|
|
193
|
+
return o === c && i === d && r[1].color === s[1].color;
|
|
194
194
|
}, q = (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(
|
|
195
195
|
/\.0*/g,
|
|
196
196
|
`${t > 0 ? "." : ""}${q(Number(t || 0))}`
|
|
197
197
|
) : /0([^0]?)|0$/.test(r) ? r.replace(
|
|
198
198
|
/0([^0]+)|0$/,
|
|
199
199
|
`0${t > 0 ? "." : ""}${q(Number(t || 0))}$1`
|
|
200
|
-
) : r).join(";"),
|
|
200
|
+
) : r).join(";"), nt = (e) => /\.0?/.test(e) || /0([^0]?)|0$/.test(e), U = {
|
|
201
201
|
id: "sheet.command.numfmt.set.numfmt",
|
|
202
|
-
type:
|
|
202
|
+
type: P.COMMAND,
|
|
203
203
|
// eslint-disable-next-line max-lines-per-function
|
|
204
204
|
handler: (e, t) => {
|
|
205
205
|
if (!t)
|
|
206
206
|
return !1;
|
|
207
|
-
const n = e.get(
|
|
207
|
+
const n = e.get(E), r = e.get(F), s = e.get(ue), o = H(r, t);
|
|
208
208
|
if (!o) return !1;
|
|
209
|
-
const { unitId: c, subUnitId:
|
|
209
|
+
const { unitId: c, subUnitId: i, worksheet: d } = o, u = t.values.filter((l) => !!l.pattern), g = t.values.filter((l) => !l.pattern), p = ye(c, i, u), h = {
|
|
210
210
|
unitId: c,
|
|
211
|
-
subUnitId:
|
|
212
|
-
ranges:
|
|
213
|
-
startColumn:
|
|
214
|
-
startRow:
|
|
215
|
-
endColumn:
|
|
216
|
-
endRow:
|
|
211
|
+
subUnitId: i,
|
|
212
|
+
ranges: g.map((l) => ({
|
|
213
|
+
startColumn: l.col,
|
|
214
|
+
startRow: l.row,
|
|
215
|
+
endColumn: l.col,
|
|
216
|
+
endRow: l.row
|
|
217
217
|
}))
|
|
218
|
-
}, C = [],
|
|
218
|
+
}, C = [], v = [];
|
|
219
219
|
if (u.length) {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
const _ =
|
|
220
|
+
const l = u.reduce((f, a) => {
|
|
221
|
+
ne(a.pattern) && f.setValue(a.row, a.col, { t: I.STRING });
|
|
222
|
+
const _ = d.getCellRaw(a.row, a.col);
|
|
223
223
|
if (_) {
|
|
224
|
-
const V =
|
|
225
|
-
V !== _.t &&
|
|
224
|
+
const V = G(_.v);
|
|
225
|
+
V !== _.t && f.setValue(a.row, a.col, { t: V });
|
|
226
226
|
}
|
|
227
|
-
return
|
|
228
|
-
}, new b()).getMatrix(),
|
|
229
|
-
new b(
|
|
230
|
-
const _ =
|
|
231
|
-
_ ?
|
|
232
|
-
}), Object.keys(p.values).forEach((
|
|
233
|
-
const a = p.values[
|
|
234
|
-
a.ranges =
|
|
227
|
+
return f;
|
|
228
|
+
}, new b()).getMatrix(), S = new b();
|
|
229
|
+
new b(l).forValue((f, a) => {
|
|
230
|
+
const _ = d.getCellRaw(f, a);
|
|
231
|
+
_ ? S.setValue(f, a, { t: _.t }) : S.setValue(f, a, { t: void 0 });
|
|
232
|
+
}), Object.keys(p.values).forEach((f) => {
|
|
233
|
+
const a = p.values[f];
|
|
234
|
+
a.ranges = Y(a.ranges);
|
|
235
235
|
}), C.push({
|
|
236
|
-
id:
|
|
236
|
+
id: te.id,
|
|
237
237
|
params: p
|
|
238
238
|
});
|
|
239
|
-
const y =
|
|
240
|
-
|
|
239
|
+
const y = _e(e, p);
|
|
240
|
+
v.push(...y);
|
|
241
241
|
}
|
|
242
|
-
if (
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
const _ =
|
|
242
|
+
if (g.length) {
|
|
243
|
+
h.ranges = Y(h.ranges);
|
|
244
|
+
const l = g.reduce((f, a) => {
|
|
245
|
+
const _ = d.getCellRaw(a.row, a.col);
|
|
246
246
|
if (_) {
|
|
247
|
-
const V =
|
|
248
|
-
V !== _.t &&
|
|
247
|
+
const V = G(_.v);
|
|
248
|
+
V !== _.t && f.setValue(a.row, a.col, { t: V });
|
|
249
249
|
}
|
|
250
|
-
return
|
|
251
|
-
}, new b()).getMatrix(),
|
|
252
|
-
new b(
|
|
253
|
-
const _ =
|
|
254
|
-
_ ?
|
|
250
|
+
return f;
|
|
251
|
+
}, new b()).getMatrix(), S = new b();
|
|
252
|
+
new b(l).forValue((f, a) => {
|
|
253
|
+
const _ = d.getCellRaw(f, a);
|
|
254
|
+
_ ? S.setValue(f, a, { t: _.t }) : S.setValue(f, a, { t: void 0 });
|
|
255
255
|
}), C.push({
|
|
256
|
-
id:
|
|
257
|
-
params:
|
|
256
|
+
id: Ce.id,
|
|
257
|
+
params: h
|
|
258
258
|
}, {
|
|
259
259
|
id: B.id,
|
|
260
260
|
params: {
|
|
261
261
|
unitId: c,
|
|
262
|
-
subUnitId:
|
|
263
|
-
cellValue:
|
|
262
|
+
subUnitId: i,
|
|
263
|
+
cellValue: l
|
|
264
264
|
}
|
|
265
265
|
});
|
|
266
|
-
const y =
|
|
267
|
-
|
|
266
|
+
const y = be(e, h);
|
|
267
|
+
v.push({
|
|
268
268
|
id: B.id,
|
|
269
269
|
params: {
|
|
270
270
|
unitId: c,
|
|
271
|
-
subUnitId:
|
|
272
|
-
cellValue:
|
|
271
|
+
subUnitId: i,
|
|
272
|
+
cellValue: S.getMatrix()
|
|
273
273
|
}
|
|
274
274
|
}, ...y);
|
|
275
275
|
}
|
|
276
|
-
const
|
|
277
|
-
return
|
|
276
|
+
const m = me(C, n).result;
|
|
277
|
+
return m && s.pushUndoRedo({
|
|
278
278
|
unitID: c,
|
|
279
|
-
undoMutations:
|
|
279
|
+
undoMutations: v,
|
|
280
280
|
redoMutations: C
|
|
281
|
-
}),
|
|
281
|
+
}), m;
|
|
282
282
|
}
|
|
283
|
-
},
|
|
283
|
+
}, De = {
|
|
284
284
|
id: "sheet.command.numfmt.add.decimal.command",
|
|
285
|
-
type:
|
|
285
|
+
type: P.COMMAND,
|
|
286
286
|
handler: async (e) => {
|
|
287
|
-
const t = e.get(
|
|
287
|
+
const t = e.get(E), n = e.get(j), r = e.get(W), s = e.get(F), o = n.getCurrentSelections();
|
|
288
288
|
if (!o || !o.length)
|
|
289
289
|
return !1;
|
|
290
|
-
const c =
|
|
290
|
+
const c = H(s);
|
|
291
291
|
if (!c) return !1;
|
|
292
|
-
const { unitId:
|
|
292
|
+
const { unitId: i, subUnitId: d } = c;
|
|
293
293
|
let u = 0;
|
|
294
294
|
o.forEach((C) => {
|
|
295
|
-
|
|
296
|
-
const
|
|
297
|
-
if (!
|
|
298
|
-
const y = c.worksheet.getCellRaw(
|
|
299
|
-
if (!u && y && y.t ===
|
|
300
|
-
const
|
|
301
|
-
if (
|
|
302
|
-
const a =
|
|
295
|
+
N.foreach(C.range, (v, m) => {
|
|
296
|
+
const l = r.getValue(i, d, v, m);
|
|
297
|
+
if (!l) {
|
|
298
|
+
const y = c.worksheet.getCellRaw(v, m);
|
|
299
|
+
if (!u && y && y.t === I.NUMBER && y.v) {
|
|
300
|
+
const f = /\.(\d*)$/.exec(String(y.v));
|
|
301
|
+
if (f) {
|
|
302
|
+
const a = f[1].length;
|
|
303
303
|
if (!a)
|
|
304
304
|
return;
|
|
305
305
|
u = Math.max(u, a);
|
|
@@ -307,35 +307,35 @@ const te = [
|
|
|
307
307
|
}
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
u =
|
|
310
|
+
const S = w(l.pattern);
|
|
311
|
+
u = S > u ? S : u;
|
|
312
312
|
});
|
|
313
313
|
});
|
|
314
|
-
const
|
|
314
|
+
const g = u + 1, p = O(`0${g > 0 ? ".0" : ""}`, g), h = [];
|
|
315
315
|
return o.forEach((C) => {
|
|
316
|
-
|
|
317
|
-
const
|
|
318
|
-
if (!
|
|
319
|
-
|
|
320
|
-
row:
|
|
321
|
-
col:
|
|
316
|
+
N.foreach(C.range, (v, m) => {
|
|
317
|
+
const l = r.getValue(i, d, v, m);
|
|
318
|
+
if (!l)
|
|
319
|
+
h.push({
|
|
320
|
+
row: v,
|
|
321
|
+
col: m,
|
|
322
322
|
pattern: p
|
|
323
323
|
});
|
|
324
324
|
else {
|
|
325
|
-
const
|
|
326
|
-
y !==
|
|
327
|
-
row:
|
|
328
|
-
col:
|
|
325
|
+
const S = w(l.pattern), y = O(l.pattern, S + 1);
|
|
326
|
+
y !== l.pattern && h.push({
|
|
327
|
+
row: v,
|
|
328
|
+
col: m,
|
|
329
329
|
pattern: y
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
});
|
|
333
|
-
}),
|
|
333
|
+
}), h.length ? await t.executeCommand(U.id, { values: h }) : !1;
|
|
334
334
|
}
|
|
335
335
|
};
|
|
336
|
-
class
|
|
336
|
+
class oe {
|
|
337
337
|
constructor() {
|
|
338
|
-
M(this, "_currencySymbol$", new
|
|
338
|
+
M(this, "_currencySymbol$", new k("US"));
|
|
339
339
|
M(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
@@ -348,52 +348,52 @@ class re {
|
|
|
348
348
|
return this._currencySymbol$.getValue();
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
const
|
|
351
|
+
const Ae = {
|
|
352
352
|
id: "sheet.command.numfmt.set.currency",
|
|
353
|
-
type:
|
|
353
|
+
type: P.COMMAND,
|
|
354
354
|
handler: async (e) => {
|
|
355
|
-
const t = e.get(
|
|
355
|
+
const t = e.get(E), n = e.get(j), r = e.get(oe), s = Pe[r.getCurrencySymbol()] || "$", o = n.getCurrentSelections();
|
|
356
356
|
if (!o || !o.length)
|
|
357
357
|
return !1;
|
|
358
|
-
const c = [],
|
|
358
|
+
const c = [], i = se[4].suffix(s);
|
|
359
359
|
return o.forEach((u) => {
|
|
360
|
-
|
|
361
|
-
c.push({ row:
|
|
360
|
+
N.foreach(u.range, (g, p) => {
|
|
361
|
+
c.push({ row: g, col: p, pattern: i, type: "currency" });
|
|
362
362
|
});
|
|
363
|
-
}), await t.executeCommand(
|
|
363
|
+
}), await t.executeCommand(U.id, { values: c });
|
|
364
364
|
}
|
|
365
|
-
},
|
|
365
|
+
}, Fe = {
|
|
366
366
|
id: "sheet.command.numfmt.set.percent",
|
|
367
|
-
type:
|
|
367
|
+
type: P.COMMAND,
|
|
368
368
|
handler: async (e) => {
|
|
369
|
-
const t = e.get(
|
|
369
|
+
const t = e.get(E), r = e.get(j).getCurrentSelections();
|
|
370
370
|
if (!r || !r.length)
|
|
371
371
|
return !1;
|
|
372
372
|
const s = [], o = "0%";
|
|
373
|
-
return r.forEach((
|
|
374
|
-
|
|
375
|
-
s.push({ row:
|
|
373
|
+
return r.forEach((i) => {
|
|
374
|
+
N.foreach(i.range, (d, u) => {
|
|
375
|
+
s.push({ row: d, col: u, pattern: o, type: "percent" });
|
|
376
376
|
});
|
|
377
|
-
}), await t.executeCommand(
|
|
377
|
+
}), await t.executeCommand(U.id, { values: s });
|
|
378
378
|
}
|
|
379
|
-
},
|
|
379
|
+
}, je = {
|
|
380
380
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
381
|
-
type:
|
|
381
|
+
type: P.COMMAND,
|
|
382
382
|
handler: async (e) => {
|
|
383
|
-
const t = e.get(
|
|
383
|
+
const t = e.get(E), n = e.get(j), r = e.get(W), s = e.get(F), o = n.getCurrentSelections();
|
|
384
384
|
if (!o || !o.length)
|
|
385
385
|
return !1;
|
|
386
|
-
const c =
|
|
386
|
+
const c = H(s);
|
|
387
387
|
if (!c) return !1;
|
|
388
|
-
const { unitId:
|
|
388
|
+
const { unitId: i, subUnitId: d } = c;
|
|
389
389
|
let u = 0;
|
|
390
|
-
o.forEach((
|
|
391
|
-
|
|
392
|
-
const
|
|
393
|
-
if (!
|
|
394
|
-
const
|
|
395
|
-
if (!u &&
|
|
396
|
-
const a = /\.(\d*)$/.exec(String(
|
|
390
|
+
o.forEach((v) => {
|
|
391
|
+
N.foreach(v.range, (m, l) => {
|
|
392
|
+
const S = r.getValue(i, d, m, l);
|
|
393
|
+
if (!S) {
|
|
394
|
+
const f = c.worksheet.getCellRaw(m, l);
|
|
395
|
+
if (!u && f && f.t === I.NUMBER && f.v) {
|
|
396
|
+
const a = /\.(\d*)$/.exec(String(f.v));
|
|
397
397
|
if (a) {
|
|
398
398
|
const _ = a[1].length;
|
|
399
399
|
if (!_)
|
|
@@ -403,32 +403,32 @@ const Pe = {
|
|
|
403
403
|
}
|
|
404
404
|
return;
|
|
405
405
|
}
|
|
406
|
-
const y =
|
|
406
|
+
const y = w(S.pattern);
|
|
407
407
|
u = y > u ? y : u;
|
|
408
408
|
});
|
|
409
409
|
});
|
|
410
|
-
const
|
|
411
|
-
return o.forEach((
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
if (!
|
|
415
|
-
|
|
416
|
-
row:
|
|
417
|
-
col:
|
|
410
|
+
const g = u - 1, p = O(`0${g > 0 ? ".0" : "."}`, g), h = [];
|
|
411
|
+
return o.forEach((v) => {
|
|
412
|
+
N.foreach(v.range, (m, l) => {
|
|
413
|
+
const S = r.getValue(i, d, m, l);
|
|
414
|
+
if (!S)
|
|
415
|
+
h.push({
|
|
416
|
+
row: m,
|
|
417
|
+
col: l,
|
|
418
418
|
pattern: p
|
|
419
419
|
});
|
|
420
420
|
else {
|
|
421
|
-
const y =
|
|
422
|
-
|
|
423
|
-
row:
|
|
424
|
-
col:
|
|
425
|
-
pattern: O(
|
|
421
|
+
const y = w(S.pattern);
|
|
422
|
+
h.push({
|
|
423
|
+
row: m,
|
|
424
|
+
col: l,
|
|
425
|
+
pattern: O(S.pattern, y - 1)
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
});
|
|
429
|
-
}), await t.executeCommand(
|
|
429
|
+
}), await t.executeCommand(U.id, { values: h });
|
|
430
430
|
}
|
|
431
|
-
},
|
|
431
|
+
}, ce = "sheets-numfmt.config", Z = {}, rt = (e) => x.getInfo(e).type || "unknown", Le = (e, t, n = "en") => {
|
|
432
432
|
const s = x.getInfo(e)._partitions[1], o = x.format(e, t, { locale: n, throws: !1 });
|
|
433
433
|
return t < 0 ? {
|
|
434
434
|
result: o,
|
|
@@ -436,27 +436,27 @@ const Pe = {
|
|
|
436
436
|
} : {
|
|
437
437
|
result: o
|
|
438
438
|
};
|
|
439
|
-
},
|
|
440
|
-
result: String(
|
|
439
|
+
}, Ge = (e, t, n) => e === "General" ? {
|
|
440
|
+
result: String(Ve(t))
|
|
441
441
|
// In Excel, the default General format also needs to handle numeric precision.
|
|
442
|
-
} :
|
|
443
|
-
var
|
|
444
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
442
|
+
} : Le(e, t, n);
|
|
443
|
+
var Be = Object.getOwnPropertyDescriptor, He = (e, t, n, r) => {
|
|
444
|
+
for (var s = r > 1 ? void 0 : r ? Be(t, n) : t, o = e.length - 1, c; o >= 0; o--)
|
|
445
445
|
(c = e[o]) && (s = c(s) || s);
|
|
446
446
|
return s;
|
|
447
|
-
},
|
|
448
|
-
const
|
|
447
|
+
}, R = (e, t) => (n, r) => t(n, r, e);
|
|
448
|
+
const We = {
|
|
449
449
|
tl: {
|
|
450
450
|
size: 6,
|
|
451
451
|
color: "#409f11"
|
|
452
452
|
}
|
|
453
453
|
};
|
|
454
|
-
let D = class extends
|
|
455
|
-
constructor(t, n, r, s, o, c) {
|
|
454
|
+
let D = class extends Q {
|
|
455
|
+
constructor(t, n, r, s, o, c, i) {
|
|
456
456
|
super();
|
|
457
|
-
M(this, "_local$", new
|
|
457
|
+
M(this, "_local$", new k("en"));
|
|
458
458
|
M(this, "local$", this._local$.asObservable());
|
|
459
|
-
this._instanceService = t, this._sheetInterceptorService = n, this._themeService = r, this._commandService = s, this._numfmtService = o, this._localeService = c, this._initInterceptorCellContent();
|
|
459
|
+
this._instanceService = t, this._sheetInterceptorService = n, this._themeService = r, this._commandService = s, this._numfmtService = o, this._localeService = c, this._configService = i, this._initInterceptorCellContent();
|
|
460
460
|
}
|
|
461
461
|
get local() {
|
|
462
462
|
const t = this._local$.getValue();
|
|
@@ -482,56 +482,60 @@ let D = class extends J {
|
|
|
482
482
|
// eslint-disable-next-line max-lines-per-function
|
|
483
483
|
_initInterceptorCellContent() {
|
|
484
484
|
const t = new b();
|
|
485
|
-
this.disposeWithMe(
|
|
485
|
+
this.disposeWithMe(Ne(this._local$, this._localeService.currentLocale$).subscribe(() => {
|
|
486
486
|
t.reset();
|
|
487
|
-
})), this.disposeWithMe(this._sheetInterceptorService.intercept(
|
|
488
|
-
effect:
|
|
487
|
+
})), this.disposeWithMe(this._sheetInterceptorService.intercept($e.CELL_CONTENT, {
|
|
488
|
+
effect: K.Value | K.Style,
|
|
489
489
|
handler: (n, r, s) => {
|
|
490
|
+
var v;
|
|
490
491
|
const o = r.unitId, c = r.subUnitId;
|
|
491
|
-
let
|
|
492
|
-
const
|
|
493
|
-
if (!
|
|
492
|
+
let i;
|
|
493
|
+
const d = n;
|
|
494
|
+
if (!d)
|
|
494
495
|
return s(n);
|
|
495
496
|
if (n != null && n.s) {
|
|
496
|
-
const
|
|
497
|
-
|
|
497
|
+
const m = r.workbook.getStyles().get(n.s);
|
|
498
|
+
m != null && m.n && (i = m.n);
|
|
498
499
|
}
|
|
499
|
-
if (
|
|
500
|
+
if (i || (i = this._numfmtService.getValue(o, c, r.row, r.col)), !i || G(d.v) !== I.NUMBER)
|
|
500
501
|
return s(n);
|
|
501
|
-
if (
|
|
502
|
-
return s({
|
|
502
|
+
if (ne(i.pattern))
|
|
503
|
+
return (v = this._configService.getConfig(ce)) != null && v.disableTextFormatMark ? s({
|
|
503
504
|
...n,
|
|
504
|
-
t:
|
|
505
|
+
t: I.STRING
|
|
506
|
+
}) : s({
|
|
507
|
+
...n,
|
|
508
|
+
t: I.STRING,
|
|
505
509
|
markers: {
|
|
506
510
|
...n == null ? void 0 : n.markers,
|
|
507
|
-
...
|
|
511
|
+
...We
|
|
508
512
|
}
|
|
509
513
|
});
|
|
510
|
-
let
|
|
514
|
+
let g = "";
|
|
511
515
|
const p = t.getValue(r.row, r.col);
|
|
512
|
-
if (p && p.parameters === `${
|
|
516
|
+
if (p && p.parameters === `${d.v}_${i.pattern}`)
|
|
513
517
|
return s({ ...n, ...p.result });
|
|
514
|
-
const
|
|
515
|
-
if (
|
|
518
|
+
const h = Ge(i.pattern, Number(d.v), this.local);
|
|
519
|
+
if (g = h.result, !g)
|
|
516
520
|
return s(n);
|
|
517
|
-
const C = { v:
|
|
518
|
-
if (
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
+
const C = { v: g, t: I.NUMBER };
|
|
522
|
+
if (h.color) {
|
|
523
|
+
const m = this._themeService.getCurrentTheme()[`${h.color}500`];
|
|
524
|
+
m && (C.interceptorStyle = { cl: { rgb: m } });
|
|
521
525
|
}
|
|
522
526
|
return t.setValue(r.row, r.col, {
|
|
523
527
|
result: C,
|
|
524
|
-
parameters: `${
|
|
528
|
+
parameters: `${d.v}_${i.pattern}`
|
|
525
529
|
}), s({ ...n, ...C });
|
|
526
530
|
},
|
|
527
|
-
priority:
|
|
531
|
+
priority: Re.NUMFMT
|
|
528
532
|
})), this.disposeWithMe(this._commandService.onCommandExecuted((n) => {
|
|
529
|
-
if (n.id ===
|
|
533
|
+
if (n.id === te.id) {
|
|
530
534
|
const r = n.params;
|
|
531
535
|
Object.keys(r.values).forEach((s) => {
|
|
532
536
|
r.values[s].ranges.forEach((c) => {
|
|
533
|
-
|
|
534
|
-
t.realDeleteValue(
|
|
537
|
+
N.foreach(c, (i, d) => {
|
|
538
|
+
t.realDeleteValue(i, d);
|
|
535
539
|
});
|
|
536
540
|
});
|
|
537
541
|
});
|
|
@@ -542,12 +546,12 @@ let D = class extends J {
|
|
|
542
546
|
});
|
|
543
547
|
}
|
|
544
548
|
})), this.disposeWithMe(
|
|
545
|
-
this._instanceService.getCurrentTypeOfUnit$(
|
|
546
|
-
|
|
549
|
+
this._instanceService.getCurrentTypeOfUnit$(ee.UNIVER_SHEET).pipe(
|
|
550
|
+
Ee((n) => {
|
|
547
551
|
var r;
|
|
548
|
-
return (r = n == null ? void 0 : n.activeSheet$) != null ? r :
|
|
552
|
+
return (r = n == null ? void 0 : n.activeSheet$) != null ? r : Te(null);
|
|
549
553
|
}),
|
|
550
|
-
|
|
554
|
+
xe(1)
|
|
551
555
|
).subscribe(() => t.reset())
|
|
552
556
|
);
|
|
553
557
|
}
|
|
@@ -555,18 +559,19 @@ let D = class extends J {
|
|
|
555
559
|
this._local$.next(t);
|
|
556
560
|
}
|
|
557
561
|
};
|
|
558
|
-
D =
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
562
|
+
D = He([
|
|
563
|
+
R(0, F),
|
|
564
|
+
R(1, T(Me)),
|
|
565
|
+
R(2, T(fe)),
|
|
566
|
+
R(3, T(E)),
|
|
567
|
+
R(4, T(W)),
|
|
568
|
+
R(5, T(de)),
|
|
569
|
+
R(6, X)
|
|
565
570
|
], D);
|
|
566
|
-
class
|
|
571
|
+
class J extends Q {
|
|
567
572
|
constructor() {
|
|
568
573
|
super(...arguments);
|
|
569
|
-
M(this, "_currencySymbol$", new
|
|
574
|
+
M(this, "_currencySymbol$", new k("US"));
|
|
570
575
|
M(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
571
576
|
}
|
|
572
577
|
/**
|
|
@@ -579,75 +584,83 @@ class Y extends J {
|
|
|
579
584
|
return this._currencySymbol$.getValue();
|
|
580
585
|
}
|
|
581
586
|
}
|
|
582
|
-
var
|
|
583
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
587
|
+
var ke = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, ze = (e, t, n) => t in e ? ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Ye = (e, t, n, r) => {
|
|
588
|
+
for (var s = r > 1 ? void 0 : r ? Ke(t, n) : t, o = e.length - 1, c; o >= 0; o--)
|
|
584
589
|
(c = e[o]) && (s = c(s) || s);
|
|
585
590
|
return s;
|
|
586
|
-
},
|
|
587
|
-
let A = class extends
|
|
588
|
-
constructor(e =
|
|
589
|
-
super(), this._config = e, this._injector = t, this._commandService =
|
|
591
|
+
}, L = (e, t) => (n, r) => t(n, r, e), ie = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
|
|
592
|
+
let A = class extends pe {
|
|
593
|
+
constructor(e = Z, t, n, r) {
|
|
594
|
+
super(), this._config = e, this._injector = t, this._configService = n, this._commandService = r;
|
|
595
|
+
const { ...s } = Se(
|
|
596
|
+
{},
|
|
597
|
+
Z,
|
|
598
|
+
this._config
|
|
599
|
+
);
|
|
600
|
+
this._configService.setConfig(ce, s);
|
|
590
601
|
}
|
|
591
602
|
onStarting() {
|
|
592
|
-
|
|
603
|
+
ve(this._injector, [
|
|
593
604
|
[D],
|
|
594
|
-
[
|
|
595
|
-
[
|
|
605
|
+
[oe],
|
|
606
|
+
[J]
|
|
596
607
|
]), z(this._injector, [
|
|
597
608
|
[D]
|
|
598
609
|
]);
|
|
599
610
|
}
|
|
600
611
|
onRendered() {
|
|
601
612
|
z(this._injector, [
|
|
602
|
-
[
|
|
613
|
+
[J]
|
|
603
614
|
]), [
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
615
|
+
De,
|
|
616
|
+
je,
|
|
617
|
+
Ae,
|
|
618
|
+
Fe,
|
|
619
|
+
U
|
|
609
620
|
].forEach((e) => {
|
|
610
621
|
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
611
622
|
});
|
|
612
623
|
}
|
|
613
624
|
};
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
A =
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
625
|
+
ie(A, "pluginName", Oe);
|
|
626
|
+
ie(A, "type", ee.UNIVER_SHEET);
|
|
627
|
+
A = Ye([
|
|
628
|
+
ge(Ie),
|
|
629
|
+
L(1, T(he)),
|
|
630
|
+
L(2, X),
|
|
631
|
+
L(3, E)
|
|
620
632
|
], A);
|
|
621
|
-
const
|
|
633
|
+
const st = (e) => re.find((n) => e.includes(n)), ot = () => re.map((e) => ({ label: e, value: e })), ct = (e) => se.map((t) => ({
|
|
622
634
|
label: t.label(e),
|
|
623
635
|
value: t.suffix(e),
|
|
624
636
|
color: t.color
|
|
625
|
-
})),
|
|
637
|
+
})), it = () => Ue.map((e) => ({ label: e.label, value: e.suffix })), at = () => we.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
|
|
626
638
|
export {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
639
|
+
De as AddDecimalCommand,
|
|
640
|
+
se as CURRENCYFORMAT,
|
|
641
|
+
Ue as DATEFMTLISG,
|
|
642
|
+
oe as MenuCurrencyService,
|
|
643
|
+
we as NUMBERFORMAT,
|
|
644
|
+
ce as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
|
|
645
|
+
Ae as SetCurrencyCommand,
|
|
646
|
+
U as SetNumfmtCommand,
|
|
647
|
+
Fe as SetPercentCommand,
|
|
635
648
|
D as SheetsNumfmtCellContentController,
|
|
636
|
-
|
|
649
|
+
je as SubtractDecimalCommand,
|
|
637
650
|
A as UniverSheetsNumfmtPlugin,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
651
|
+
Pe as countryCurrencyMap,
|
|
652
|
+
re as currencySymbols,
|
|
653
|
+
ct as getCurrencyFormatOptions,
|
|
654
|
+
ot as getCurrencyOptions,
|
|
655
|
+
st as getCurrencyType,
|
|
656
|
+
it as getDateFormatOptions,
|
|
657
|
+
w as getDecimalFromPattern,
|
|
645
658
|
q as getDecimalString,
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
659
|
+
at as getNumberFormatOptions,
|
|
660
|
+
Le as getPatternPreview,
|
|
661
|
+
Ge as getPatternPreviewIgnoreGeneral,
|
|
662
|
+
rt as getPatternType,
|
|
663
|
+
tt as isPatternEqualWithoutDecimal,
|
|
664
|
+
nt as isPatternHasDecimal,
|
|
652
665
|
O as setPatternDecimal
|
|
653
666
|
};
|