@univerjs/sheets-numfmt 0.8.0-nightly.202505271607 → 0.8.0-nightly.202505291607
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 +261 -275
- package/lib/index.js +261 -275
- 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 +6 -6
package/lib/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
|
"¥",
|
|
@@ -74,7 +74,7 @@ const re = [
|
|
|
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 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,167 +175,154 @@ 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, 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
|
-
},
|
|
191
|
-
{ isEnd: !1, result: "" }
|
|
192
|
-
).result, r = x.getInfo(e)._partitions, s = x.getInfo(t)._partitions, o = n(r[0].tokens), a = n(s[0].tokens), i = n(r[1].tokens), m = n(s[1].tokens);
|
|
193
|
-
return o === a && 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:
|
|
210
|
-
unitId:
|
|
211
|
-
subUnitId:
|
|
212
|
-
ranges:
|
|
213
|
-
startColumn:
|
|
214
|
-
startRow:
|
|
215
|
-
endColumn:
|
|
216
|
-
endRow:
|
|
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 = {
|
|
197
|
+
unitId: c,
|
|
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
|
|
258
245
|
}, {
|
|
259
246
|
id: B.id,
|
|
260
247
|
params: {
|
|
261
|
-
unitId:
|
|
262
|
-
subUnitId:
|
|
263
|
-
cellValue:
|
|
248
|
+
unitId: c,
|
|
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
|
-
unitId:
|
|
271
|
-
subUnitId:
|
|
272
|
-
cellValue:
|
|
257
|
+
unitId: c,
|
|
258
|
+
subUnitId: l,
|
|
259
|
+
cellValue: g.getMatrix()
|
|
273
260
|
}
|
|
274
|
-
}, ...
|
|
261
|
+
}, ...S);
|
|
275
262
|
}
|
|
276
|
-
const
|
|
277
|
-
return
|
|
278
|
-
unitID:
|
|
279
|
-
undoMutations:
|
|
263
|
+
const d = me(C, r).result;
|
|
264
|
+
return d && s.pushUndoRedo({
|
|
265
|
+
unitID: c,
|
|
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
|
-
const
|
|
291
|
-
if (!
|
|
292
|
-
const { unitId:
|
|
277
|
+
const c = H(s);
|
|
278
|
+
if (!c) return !1;
|
|
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
|
|
359
|
-
return
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
const { unitId:
|
|
373
|
+
const c = H(s);
|
|
374
|
+
if (!c) return !1;
|
|
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
|
-
}, ae = "sheets-numfmt.config",
|
|
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
|
-
(
|
|
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,65 +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
|
-
let
|
|
506
|
-
const
|
|
507
|
-
if (
|
|
508
|
-
return s({ ...
|
|
509
|
-
const h = Ge(
|
|
510
|
-
if (
|
|
511
|
-
return s(
|
|
512
|
-
const C = { v:
|
|
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 };
|
|
513
500
|
if (h.color) {
|
|
514
|
-
const
|
|
515
|
-
|
|
501
|
+
const o = (d = this._themeService.getColorFromTheme(`${h.color}.500`)) != null ? d : h.color;
|
|
502
|
+
o && (C.interceptorStyle = { cl: { rgb: o } });
|
|
516
503
|
}
|
|
517
|
-
return t.setValue(
|
|
504
|
+
return t.setValue(n.row, n.col, {
|
|
518
505
|
result: C,
|
|
519
|
-
parameters: `${
|
|
520
|
-
}), Object.assign(
|
|
506
|
+
parameters: `${f.v}_${l.pattern}`
|
|
507
|
+
}), Object.assign(r, C), s(r);
|
|
521
508
|
},
|
|
522
509
|
priority: Re.NUMFMT
|
|
523
|
-
})), this.disposeWithMe(this._commandService.onCommandExecuted((
|
|
524
|
-
if (
|
|
525
|
-
const
|
|
526
|
-
Object.keys(
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
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);
|
|
530
517
|
});
|
|
531
518
|
});
|
|
532
519
|
});
|
|
533
|
-
} else if (
|
|
534
|
-
const
|
|
535
|
-
new b(
|
|
536
|
-
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);
|
|
537
524
|
});
|
|
538
525
|
}
|
|
539
526
|
})), this.disposeWithMe(
|
|
540
527
|
this._instanceService.getCurrentTypeOfUnit$(ee.UNIVER_SHEET).pipe(
|
|
541
|
-
|
|
542
|
-
var
|
|
543
|
-
return (
|
|
528
|
+
Te((r) => {
|
|
529
|
+
var n;
|
|
530
|
+
return (n = r == null ? void 0 : r.activeSheet$) != null ? n : Ee(null);
|
|
544
531
|
}),
|
|
545
532
|
xe(1)
|
|
546
533
|
).subscribe(() => t.reset())
|
|
@@ -551,107 +538,106 @@ let D = class extends Q {
|
|
|
551
538
|
}
|
|
552
539
|
};
|
|
553
540
|
D = He([
|
|
554
|
-
R(0,
|
|
555
|
-
R(1,
|
|
556
|
-
R(2,
|
|
557
|
-
R(3, T
|
|
558
|
-
R(4,
|
|
559
|
-
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)),
|
|
560
547
|
R(6, X)
|
|
561
548
|
], D);
|
|
562
549
|
class J extends Q {
|
|
563
550
|
constructor() {
|
|
564
551
|
super(...arguments);
|
|
565
|
-
M(this, "_currencySymbol$", new
|
|
552
|
+
M(this, "_currencySymbol$", new K("US"));
|
|
566
553
|
M(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
567
554
|
}
|
|
568
555
|
/**
|
|
569
556
|
* Set the currency symbol by setting the country code.
|
|
570
557
|
*/
|
|
571
|
-
setCurrencySymbolByCountryCode(
|
|
572
|
-
this._currencySymbol$.next(
|
|
558
|
+
setCurrencySymbolByCountryCode(r) {
|
|
559
|
+
this._currencySymbol$.next(r);
|
|
573
560
|
}
|
|
574
561
|
getCurrencySymbol() {
|
|
575
562
|
return this._currencySymbol$.getValue();
|
|
576
563
|
}
|
|
577
564
|
}
|
|
578
|
-
var
|
|
579
|
-
for (var s =
|
|
580
|
-
(
|
|
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);
|
|
581
568
|
return s;
|
|
582
|
-
}, L = (e, t) => (
|
|
583
|
-
let
|
|
584
|
-
constructor(e =
|
|
585
|
-
super(), this._config = e, this._injector = t, this._configService =
|
|
586
|
-
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(
|
|
587
574
|
{},
|
|
588
|
-
|
|
575
|
+
q,
|
|
589
576
|
this._config
|
|
590
577
|
);
|
|
591
578
|
this._configService.setConfig(ae, s);
|
|
592
579
|
}
|
|
593
580
|
onStarting() {
|
|
594
|
-
|
|
581
|
+
ve(this._injector, [
|
|
595
582
|
[D],
|
|
596
583
|
[oe],
|
|
597
584
|
[J]
|
|
598
|
-
]),
|
|
585
|
+
]), Y(this._injector, [
|
|
599
586
|
[D]
|
|
600
587
|
]);
|
|
601
588
|
}
|
|
602
589
|
onRendered() {
|
|
603
|
-
|
|
590
|
+
Y(this._injector, [
|
|
604
591
|
[J]
|
|
605
592
|
]), [
|
|
606
593
|
De,
|
|
607
594
|
je,
|
|
608
|
-
Ae,
|
|
609
595
|
Fe,
|
|
610
|
-
|
|
596
|
+
Ae,
|
|
597
|
+
w
|
|
611
598
|
].forEach((e) => {
|
|
612
599
|
this.disposeWithMe(this._commandService.registerCommand(e));
|
|
613
600
|
});
|
|
614
601
|
}
|
|
615
602
|
};
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
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)),
|
|
621
608
|
L(2, X),
|
|
622
|
-
L(3,
|
|
623
|
-
],
|
|
624
|
-
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) => ({
|
|
625
612
|
label: t.label(e),
|
|
626
613
|
value: t.suffix(e),
|
|
627
614
|
color: t.color
|
|
628
|
-
})),
|
|
615
|
+
})), at = () => Ue.map((e) => ({ label: e.label, value: e.suffix })), ct = () => Oe.map((e) => ({ label: e.label, value: e.suffix, color: e.color }));
|
|
629
616
|
export {
|
|
630
617
|
De as AddDecimalCommand,
|
|
631
618
|
se as CURRENCYFORMAT,
|
|
632
|
-
|
|
619
|
+
Ue as DATEFMTLISG,
|
|
633
620
|
oe as MenuCurrencyService,
|
|
634
|
-
|
|
621
|
+
Oe as NUMBERFORMAT,
|
|
635
622
|
ae as SHEETS_NUMFMT_PLUGIN_CONFIG_KEY,
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
623
|
+
Fe as SetCurrencyCommand,
|
|
624
|
+
w as SetNumfmtCommand,
|
|
625
|
+
Ae as SetPercentCommand,
|
|
639
626
|
D as SheetsNumfmtCellContentController,
|
|
640
627
|
je as SubtractDecimalCommand,
|
|
641
|
-
|
|
628
|
+
F as UniverSheetsNumfmtPlugin,
|
|
642
629
|
we as countryCurrencyMap,
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
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,
|
|
650
637
|
ct as getNumberFormatOptions,
|
|
651
638
|
Le as getPatternPreview,
|
|
652
639
|
Ge as getPatternPreviewIgnoreGeneral,
|
|
653
640
|
rt as getPatternType,
|
|
654
|
-
tt as
|
|
655
|
-
|
|
656
|
-
O as setPatternDecimal
|
|
641
|
+
tt as isPatternHasDecimal,
|
|
642
|
+
P as setPatternDecimal
|
|
657
643
|
};
|