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