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