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