@univerjs/sheets-numfmt 0.2.11 → 0.2.13
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 +2 -2
- package/lib/es/index.js +331 -298
- package/lib/types/controllers/__tests__/test.util.d.ts +6 -6
- package/lib/types/controllers/config.schema.d.ts +7 -0
- package/lib/types/controllers/menu.schema.d.ts +2 -0
- package/lib/types/controllers/numfmt.currency.controller.d.ts +13 -0
- package/lib/types/controllers/numfmt.menu.controller.d.ts +3 -10
- package/lib/types/controllers/type.d.ts +1 -1
- package/lib/types/index.d.ts +3 -3
- package/lib/types/menu/menu.d.ts +1 -9
- package/lib/types/numfmt-plugin.d.ts +5 -3
- package/lib/umd/index.js +2 -2
- package/package.json +21 -21
package/lib/es/index.js
CHANGED
|
@@ -2,107 +2,87 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value;
|
|
3
3
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
4
|
var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 != "symbol" ? key2 + "" : key2, value);
|
|
5
|
-
import { numfmt,
|
|
6
|
-
import {
|
|
5
|
+
import { numfmt, CommandType, ICommandService, IUniverInstanceService, IUndoRedoService, sequenceExecute, Range, CellValueType, createIdentifier, runOnLifecycle, LifecycleStages, LocaleType, Disposable, ObjectMatrix, UniverInstanceType, OnLifecycle, Inject, ThemeService, LocaleService, ILocalStorageService, useDependency, toDisposable, DisposableCollection, Injector, Optional, useInjector, Plugin, DependentOn, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { getSheetCommandTarget, transformCellsToRange, rangeMerge, SetNumfmtMutation, factorySetNumfmtUndoMutation, RemoveNumfmtMutation, factoryRemoveNumfmtUndoMutation, SheetsSelectionsService, INumfmtService, INTERCEPTOR_POINT, InterceptCellContentPriority, SetRangeValuesMutation, SheetInterceptorService, SetRangeValuesCommand, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint, UniverSheetsPlugin } from "@univerjs/sheets";
|
|
7
|
+
import { BehaviorSubject, switchMap, of, skip, Observable, combineLatest, merge } from "rxjs";
|
|
7
8
|
import { SheetSkeletonManagerService, IEditorBridgeService, getCurrentRangeDisable$, deriveStateFromActiveSheet$, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { ComponentManager, ISidebarService, MenuItemType, MenuGroup, MenuPosition, getMenuHiddenObservable, IMenuService } from "@univerjs/ui";
|
|
9
|
+
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
10
|
+
import { ComponentManager, ISidebarService, ILayoutService, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, IMenuManagerService } from "@univerjs/ui";
|
|
11
11
|
import { map, switchMap as switchMap$1, tap, debounceTime } from "rxjs/operators";
|
|
12
12
|
import require$$0, { createContext, useState, useEffect, useRef, useContext, useMemo, forwardRef, createElement } from "react";
|
|
13
13
|
import { InputNumber, Select, SelectList, Input, Button } from "@univerjs/design";
|
|
14
14
|
import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
var _a8;
|
|
87
|
-
return (_a8 = workbook == null ? void 0 : workbook.activeSheet$) != null ? _a8 : of(null);
|
|
88
|
-
}),
|
|
89
|
-
skip(1)
|
|
90
|
-
).subscribe(() => renderCache.reset())
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
}, __name(_a, "SheetsNumfmtCellContentController"), _a);
|
|
94
|
-
SheetsNumfmtCellContentController = __decorateClass$6([
|
|
95
|
-
OnLifecycle(LifecycleStages.Rendered, SheetsNumfmtCellContentController),
|
|
96
|
-
__decorateParam$6(0, IUniverInstanceService),
|
|
97
|
-
__decorateParam$6(1, Inject(SheetInterceptorService)),
|
|
98
|
-
__decorateParam$6(2, Inject(ThemeService)),
|
|
99
|
-
__decorateParam$6(3, Inject(ICommandService)),
|
|
100
|
-
__decorateParam$6(4, Inject(INumfmtService)),
|
|
101
|
-
__decorateParam$6(5, Inject(LocaleService))
|
|
102
|
-
], SheetsNumfmtCellContentController);
|
|
103
|
-
const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0) => {
|
|
104
|
-
var _a8;
|
|
105
|
-
return pattern && (_a8 = numfmt.getInfo(pattern).maxDecimals) != null ? _a8 : defaultValue;
|
|
15
|
+
const currencySymbols = [
|
|
16
|
+
"$",
|
|
17
|
+
"£",
|
|
18
|
+
"¥",
|
|
19
|
+
"¤",
|
|
20
|
+
"֏",
|
|
21
|
+
"؋",
|
|
22
|
+
"৳",
|
|
23
|
+
"฿",
|
|
24
|
+
// '៛',
|
|
25
|
+
"₡",
|
|
26
|
+
"₦",
|
|
27
|
+
"₩",
|
|
28
|
+
"₪",
|
|
29
|
+
"₫",
|
|
30
|
+
"€",
|
|
31
|
+
"₭",
|
|
32
|
+
"₮",
|
|
33
|
+
"₱",
|
|
34
|
+
"₲",
|
|
35
|
+
"₴",
|
|
36
|
+
"₸",
|
|
37
|
+
"₹",
|
|
38
|
+
"₺",
|
|
39
|
+
"₼",
|
|
40
|
+
"₽",
|
|
41
|
+
"₾",
|
|
42
|
+
"₿"
|
|
43
|
+
], countryCurrencyMap = {
|
|
44
|
+
US: "$",
|
|
45
|
+
// United States Dollar
|
|
46
|
+
CA: "C$",
|
|
47
|
+
// Canadian Dollar
|
|
48
|
+
GB: "£",
|
|
49
|
+
// British Pound Sterling
|
|
50
|
+
JP: "¥",
|
|
51
|
+
// Japanese Yen
|
|
52
|
+
IN: "₹",
|
|
53
|
+
// Indian Rupee
|
|
54
|
+
AU: "A$",
|
|
55
|
+
// Australian Dollar
|
|
56
|
+
CN: "¥",
|
|
57
|
+
// Chinese Yuan
|
|
58
|
+
KR: "₩",
|
|
59
|
+
// South Korean Won
|
|
60
|
+
RU: "₽",
|
|
61
|
+
// Russian Ruble
|
|
62
|
+
// Euro countries
|
|
63
|
+
AT: "€",
|
|
64
|
+
BE: "€",
|
|
65
|
+
CY: "€",
|
|
66
|
+
EE: "€",
|
|
67
|
+
FI: "€",
|
|
68
|
+
FR: "€",
|
|
69
|
+
DE: "€",
|
|
70
|
+
GR: "€",
|
|
71
|
+
IE: "€",
|
|
72
|
+
IT: "€",
|
|
73
|
+
LV: "€",
|
|
74
|
+
LT: "€",
|
|
75
|
+
LU: "€",
|
|
76
|
+
MT: "€",
|
|
77
|
+
NL: "€",
|
|
78
|
+
PT: "€",
|
|
79
|
+
SK: "€",
|
|
80
|
+
SI: "€",
|
|
81
|
+
ES: "€"
|
|
82
|
+
// Add more mappings as needed
|
|
83
|
+
}, getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0) => {
|
|
84
|
+
var _a9;
|
|
85
|
+
return pattern && (_a9 = numfmt.getInfo(pattern).maxDecimals) != null ? _a9 : defaultValue;
|
|
106
86
|
}, "getDecimalFromPattern"), isPatternEqualWithoutDecimal = /* @__PURE__ */ __name((patternA, patternB) => {
|
|
107
87
|
if (patternA && !patternB || !patternA && patternB)
|
|
108
88
|
return !1;
|
|
@@ -319,75 +299,7 @@ const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0)
|
|
|
319
299
|
suffix: /* @__PURE__ */ __name((suffix) => `"${suffix}"#,##0.00_);[Red]-"${suffix}"#,##0.00`, "suffix"),
|
|
320
300
|
color: "red"
|
|
321
301
|
}
|
|
322
|
-
],
|
|
323
|
-
"$",
|
|
324
|
-
"£",
|
|
325
|
-
"¥",
|
|
326
|
-
"¤",
|
|
327
|
-
"֏",
|
|
328
|
-
"؋",
|
|
329
|
-
"৳",
|
|
330
|
-
"฿",
|
|
331
|
-
// '៛',
|
|
332
|
-
"₡",
|
|
333
|
-
"₦",
|
|
334
|
-
"₩",
|
|
335
|
-
"₪",
|
|
336
|
-
"₫",
|
|
337
|
-
"€",
|
|
338
|
-
"₭",
|
|
339
|
-
"₮",
|
|
340
|
-
"₱",
|
|
341
|
-
"₲",
|
|
342
|
-
"₴",
|
|
343
|
-
"₸",
|
|
344
|
-
"₹",
|
|
345
|
-
"₺",
|
|
346
|
-
"₼",
|
|
347
|
-
"₽",
|
|
348
|
-
"₾",
|
|
349
|
-
"₿"
|
|
350
|
-
], countryCurrencyMap = {
|
|
351
|
-
US: "$",
|
|
352
|
-
// United States Dollar
|
|
353
|
-
CA: "C$",
|
|
354
|
-
// Canadian Dollar
|
|
355
|
-
GB: "£",
|
|
356
|
-
// British Pound Sterling
|
|
357
|
-
JP: "¥",
|
|
358
|
-
// Japanese Yen
|
|
359
|
-
IN: "₹",
|
|
360
|
-
// Indian Rupee
|
|
361
|
-
AU: "A$",
|
|
362
|
-
// Australian Dollar
|
|
363
|
-
CN: "¥",
|
|
364
|
-
// Chinese Yuan
|
|
365
|
-
KR: "₩",
|
|
366
|
-
// South Korean Won
|
|
367
|
-
RU: "₽",
|
|
368
|
-
// Russian Ruble
|
|
369
|
-
// Euro countries
|
|
370
|
-
AT: "€",
|
|
371
|
-
BE: "€",
|
|
372
|
-
CY: "€",
|
|
373
|
-
EE: "€",
|
|
374
|
-
FI: "€",
|
|
375
|
-
FR: "€",
|
|
376
|
-
DE: "€",
|
|
377
|
-
GR: "€",
|
|
378
|
-
IE: "€",
|
|
379
|
-
IT: "€",
|
|
380
|
-
LV: "€",
|
|
381
|
-
LT: "€",
|
|
382
|
-
LU: "€",
|
|
383
|
-
MT: "€",
|
|
384
|
-
NL: "€",
|
|
385
|
-
PT: "€",
|
|
386
|
-
SK: "€",
|
|
387
|
-
SI: "€",
|
|
388
|
-
ES: "€"
|
|
389
|
-
// Add more mappings as needed
|
|
390
|
-
}, _MenuCurrencyService = class _MenuCurrencyService {
|
|
302
|
+
], _MenuCurrencyService = class _MenuCurrencyService {
|
|
391
303
|
constructor() {
|
|
392
304
|
__publicField(this, "_currencySymbol$", new BehaviorSubject("US"));
|
|
393
305
|
__publicField(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
@@ -411,13 +323,27 @@ const SetCurrencyCommand = {
|
|
|
411
323
|
const commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), menuCurrencyService = accessor.get(MenuCurrencyService), symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] || "$", selections = selectionManagerService.getCurrentSelections();
|
|
412
324
|
if (!selections || !selections.length)
|
|
413
325
|
return !1;
|
|
414
|
-
const values = [], suffix = CURRENCYFORMAT[
|
|
326
|
+
const values = [], suffix = CURRENCYFORMAT[4].suffix(symbol);
|
|
415
327
|
return selections.forEach((selection) => {
|
|
416
328
|
Range.foreach(selection.range, (row, col) => {
|
|
417
329
|
values.push({ row, col, pattern: suffix, type: "currency" });
|
|
418
330
|
});
|
|
419
331
|
}), await commandService.executeCommand(SetNumfmtCommand.id, { values });
|
|
420
332
|
}, "handler")
|
|
333
|
+
}, SetPercentCommand = {
|
|
334
|
+
id: "sheet.command.numfmt.set.percent",
|
|
335
|
+
type: CommandType.COMMAND,
|
|
336
|
+
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
337
|
+
const commandService = accessor.get(ICommandService), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
338
|
+
if (!selections || !selections.length)
|
|
339
|
+
return !1;
|
|
340
|
+
const values = [], suffix = "0%";
|
|
341
|
+
return selections.forEach((selection) => {
|
|
342
|
+
Range.foreach(selection.range, (row, col) => {
|
|
343
|
+
values.push({ row, col, pattern: suffix, type: "percent" });
|
|
344
|
+
});
|
|
345
|
+
}), await commandService.executeCommand(SetNumfmtCommand.id, { values });
|
|
346
|
+
}, "handler")
|
|
421
347
|
}, SubtractDecimalCommand = {
|
|
422
348
|
id: "sheet.command.numfmt.subtract.decimal.command",
|
|
423
349
|
type: CommandType.COMMAND,
|
|
@@ -483,7 +409,94 @@ const OpenNumfmtPanelOperator = {
|
|
|
483
409
|
id: "sheet.operation.open.numfmt.panel",
|
|
484
410
|
type: CommandType.OPERATION,
|
|
485
411
|
handler: /* @__PURE__ */ __name((accessor) => (accessor.get(INumfmtController).openPanel(), !0), "handler")
|
|
486
|
-
}
|
|
412
|
+
}, SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN", getPatternType = /* @__PURE__ */ __name((pattern) => numfmt.getInfo(pattern).type || "unknown", "getPatternType"), getPatternPreview = /* @__PURE__ */ __name((pattern, value, _locale) => {
|
|
413
|
+
const info = numfmt.getInfo(pattern), locale = _locale === LocaleType.ZH_CN ? "zh-CN" : "en", negInfo = info._partitions[1], result = numfmt.format(pattern, value, { locale });
|
|
414
|
+
return value < 0 ? {
|
|
415
|
+
result,
|
|
416
|
+
color: negInfo.color
|
|
417
|
+
} : {
|
|
418
|
+
result
|
|
419
|
+
};
|
|
420
|
+
}, "getPatternPreview");
|
|
421
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
422
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
423
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
424
|
+
return kind && result && __defProp$7(target, key2, result), result;
|
|
425
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$7"), _a;
|
|
426
|
+
let SheetsNumfmtCellContentController = (_a = class extends Disposable {
|
|
427
|
+
constructor(_instanceService, _sheetInterceptorService, _themeService, _commandService, _numfmtService, _localeService) {
|
|
428
|
+
super(), this._instanceService = _instanceService, this._sheetInterceptorService = _sheetInterceptorService, this._themeService = _themeService, this._commandService = _commandService, this._numfmtService = _numfmtService, this._localeService = _localeService, this._initInterceptorCellContent();
|
|
429
|
+
}
|
|
430
|
+
// eslint-disable-next-line max-lines-per-function
|
|
431
|
+
_initInterceptorCellContent() {
|
|
432
|
+
const renderCache = new ObjectMatrix();
|
|
433
|
+
this.disposeWithMe(this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
434
|
+
handler: /* @__PURE__ */ __name((cell, location, next) => {
|
|
435
|
+
const unitId = location.unitId, sheetId = location.subUnitId;
|
|
436
|
+
let numfmtValue;
|
|
437
|
+
if (cell != null && cell.s) {
|
|
438
|
+
const style = location.workbook.getStyles().get(cell.s);
|
|
439
|
+
style != null && style.n && (numfmtValue = style.n);
|
|
440
|
+
}
|
|
441
|
+
if (numfmtValue || (numfmtValue = this._numfmtService.getValue(unitId, sheetId, location.row, location.col)), !numfmtValue)
|
|
442
|
+
return next(cell);
|
|
443
|
+
const originCellValue = cell;
|
|
444
|
+
if (!originCellValue || originCellValue.t !== CellValueType.NUMBER || originCellValue.v == null || Number.isNaN(originCellValue.v))
|
|
445
|
+
return next(cell);
|
|
446
|
+
let numfmtRes = "";
|
|
447
|
+
const cache = renderCache.getValue(location.row, location.col);
|
|
448
|
+
if (cache && cache.parameters === `${originCellValue.v}_${numfmtValue.pattern}`)
|
|
449
|
+
return next({ ...cell, ...cache.result });
|
|
450
|
+
const info = getPatternPreview(numfmtValue.pattern, Number(originCellValue.v), this._localeService.getCurrentLocale());
|
|
451
|
+
if (numfmtRes = info.result, !numfmtRes)
|
|
452
|
+
return next(cell);
|
|
453
|
+
const res = { v: numfmtRes };
|
|
454
|
+
if (info.color) {
|
|
455
|
+
const color = this._themeService.getCurrentTheme()[`${info.color}500`];
|
|
456
|
+
color && (res.interceptorStyle = { cl: { rgb: color } });
|
|
457
|
+
}
|
|
458
|
+
return renderCache.setValue(location.row, location.col, {
|
|
459
|
+
result: res,
|
|
460
|
+
parameters: `${originCellValue.v}_${numfmtValue.pattern}`
|
|
461
|
+
}), next({ ...cell, ...res });
|
|
462
|
+
}, "handler"),
|
|
463
|
+
priority: InterceptCellContentPriority.NUMFMT
|
|
464
|
+
})), this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
|
|
465
|
+
if (commandInfo.id === SetNumfmtMutation.id) {
|
|
466
|
+
const params = commandInfo.params;
|
|
467
|
+
Object.keys(params.values).forEach((key2) => {
|
|
468
|
+
params.values[key2].ranges.forEach((range) => {
|
|
469
|
+
Range.foreach(range, (row, col) => {
|
|
470
|
+
renderCache.realDeleteValue(row, col);
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
});
|
|
474
|
+
} else if (commandInfo.id === SetRangeValuesMutation.id) {
|
|
475
|
+
const params = commandInfo.params;
|
|
476
|
+
new ObjectMatrix(params.cellValue).forValue((row, col) => {
|
|
477
|
+
renderCache.realDeleteValue(row, col);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
})), this.disposeWithMe(
|
|
481
|
+
this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
482
|
+
switchMap((workbook) => {
|
|
483
|
+
var _a9;
|
|
484
|
+
return (_a9 = workbook == null ? void 0 : workbook.activeSheet$) != null ? _a9 : of(null);
|
|
485
|
+
}),
|
|
486
|
+
skip(1)
|
|
487
|
+
).subscribe(() => renderCache.reset())
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
}, __name(_a, "SheetsNumfmtCellContentController"), _a);
|
|
491
|
+
SheetsNumfmtCellContentController = __decorateClass$7([
|
|
492
|
+
OnLifecycle(LifecycleStages.Rendered, SheetsNumfmtCellContentController),
|
|
493
|
+
__decorateParam$7(0, IUniverInstanceService),
|
|
494
|
+
__decorateParam$7(1, Inject(SheetInterceptorService)),
|
|
495
|
+
__decorateParam$7(2, Inject(ThemeService)),
|
|
496
|
+
__decorateParam$7(3, Inject(ICommandService)),
|
|
497
|
+
__decorateParam$7(4, Inject(INumfmtService)),
|
|
498
|
+
__decorateParam$7(5, Inject(LocaleService))
|
|
499
|
+
], SheetsNumfmtCellContentController);
|
|
487
500
|
var jsxRuntime = { exports: {} }, reactJsxRuntime_production_min = {};
|
|
488
501
|
/**
|
|
489
502
|
* @license React
|
|
@@ -509,11 +522,11 @@ reactJsxRuntime_production_min.jsxs = q;
|
|
|
509
522
|
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
510
523
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
511
524
|
const UserHabitCurrencyContext = createContext([]);
|
|
512
|
-
var __defProp$
|
|
513
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
525
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
526
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
514
527
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
515
|
-
return kind && result && __defProp$
|
|
516
|
-
}, "__decorateClass$
|
|
528
|
+
return kind && result && __defProp$6(target, key2, result), result;
|
|
529
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$6"), _a2;
|
|
517
530
|
let UserHabitController = (_a2 = class {
|
|
518
531
|
constructor(_localStorageService) {
|
|
519
532
|
this._localStorageService = _localStorageService;
|
|
@@ -547,8 +560,8 @@ let UserHabitController = (_a2 = class {
|
|
|
547
560
|
};
|
|
548
561
|
});
|
|
549
562
|
return sortList.sort((a, b) => {
|
|
550
|
-
var
|
|
551
|
-
const ap = ((
|
|
563
|
+
var _a9, _b;
|
|
564
|
+
const ap = ((_a9 = priority.find((item) => item.value === a)) == null ? void 0 : _a9.priority) || -1;
|
|
552
565
|
return (((_b = priority.find((item) => item.value === b)) == null ? void 0 : _b.priority) || -1) - ap;
|
|
553
566
|
});
|
|
554
567
|
}
|
|
@@ -558,8 +571,8 @@ let UserHabitController = (_a2 = class {
|
|
|
558
571
|
this._localStorageService.removeItem(habit);
|
|
559
572
|
}
|
|
560
573
|
}, __name(_a2, "UserHabitController"), _a2);
|
|
561
|
-
UserHabitController = __decorateClass$
|
|
562
|
-
__decorateParam$
|
|
574
|
+
UserHabitController = __decorateClass$6([
|
|
575
|
+
__decorateParam$6(0, Inject(ILocalStorageService))
|
|
563
576
|
], UserHabitController);
|
|
564
577
|
const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onOptionChange) => {
|
|
565
578
|
const userHabitController = useDependency(UserHabitController), [options, optionsSet] = useState(currencySymbols);
|
|
@@ -609,9 +622,9 @@ const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onO
|
|
|
609
622
|
color: item.color
|
|
610
623
|
})), "getCurrencyFormatOptions"), getDateFormatOptions = /* @__PURE__ */ __name(() => DATEFMTLISG.map((item) => ({ label: item.label, value: item.suffix })), "getDateFormatOptions"), getNumberFormatOptions = /* @__PURE__ */ __name(() => NUMBERFORMAT.map((item) => ({ label: item.label, value: item.suffix, color: item.color })), "getNumberFormatOptions"), isCurrencyPanel = /* @__PURE__ */ __name((pattern) => !!getCurrencyType(pattern) && !pattern.startsWith("_("), "isCurrencyPanel"), CurrencyPanel = /* @__PURE__ */ __name((props) => {
|
|
611
624
|
const t = useDependency(LocaleService).t, userHabitCurrency = useContext(UserHabitCurrencyContext), [suffix, suffixSet] = useState(() => getCurrencyType(props.defaultPattern) || userHabitCurrency[0]), [decimal, decimalSet] = useState(() => getDecimalFromPattern(props.defaultPattern || "", 2)), [pattern, patternSet] = useState(() => {
|
|
612
|
-
var
|
|
625
|
+
var _a9;
|
|
613
626
|
const negativeOptions2 = getCurrencyFormatOptions(suffix);
|
|
614
|
-
return ((
|
|
627
|
+
return ((_a9 = negativeOptions2.find((item) => isPatternEqualWithoutDecimal(item.value, props.defaultPattern))) == null ? void 0 : _a9.value) || negativeOptions2[0].value;
|
|
615
628
|
}), negativeOptions = useMemo(() => getCurrencyFormatOptions(suffix), [suffix]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), [userHabitCurrency]);
|
|
616
629
|
props.action.current = () => setPatternDecimal(pattern, decimal);
|
|
617
630
|
const onSelect = /* @__PURE__ */ __name((value) => {
|
|
@@ -722,15 +735,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
|
722
735
|
var attrs = __assign({}, node.attrs);
|
|
723
736
|
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
724
737
|
var defIds = runtimeProps.defIds;
|
|
725
|
-
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(
|
|
726
|
-
var key2 =
|
|
738
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a9) {
|
|
739
|
+
var key2 = _a9[0], value = _a9[1];
|
|
727
740
|
typeof value == "string" && (attrs[key2] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
728
741
|
})), attrs;
|
|
729
742
|
}
|
|
730
743
|
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
731
744
|
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
732
|
-
var
|
|
733
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((
|
|
745
|
+
var _a9, defIds = runtimeProps.defIds;
|
|
746
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a9 = node.children) === null || _a9 === void 0) && _a9.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
734
747
|
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
735
748
|
}) }) : node;
|
|
736
749
|
}
|
|
@@ -805,8 +818,8 @@ const SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
|
805
818
|
].map((item) => ({ ...item, label: t(item.label) })),
|
|
806
819
|
[]
|
|
807
820
|
), [type, typeSet] = useState(findDefaultType), [key2, keySet] = useState(() => `${row}_${col}`), { mark, userHabitCurrency } = useCurrencyOptions(() => keySet(`${row}_${col}_userCurrency'`)), BusinessComponent = useMemo(() => {
|
|
808
|
-
var
|
|
809
|
-
return (
|
|
821
|
+
var _a9;
|
|
822
|
+
return (_a9 = typeOptions.find((item) => item.label === type)) == null ? void 0 : _a9.component;
|
|
810
823
|
}, [type]);
|
|
811
824
|
function findDefaultType() {
|
|
812
825
|
return [isGeneralPanel, isAccountingPanel, isCurrencyPanel, isDatePanel, isThousandthPercentilePanel].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
|
|
@@ -843,26 +856,12 @@ const SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
|
843
856
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", size: "small", onClick: handleConfirm, children: t("sheet.numfmt.confirm") })
|
|
844
857
|
] })
|
|
845
858
|
] });
|
|
846
|
-
}, "SheetNumfmtPanel")
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
handler: /* @__PURE__ */ __name(async (accessor) => {
|
|
850
|
-
const commandService = accessor.get(ICommandService), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
|
|
851
|
-
if (!selections || !selections.length)
|
|
852
|
-
return !1;
|
|
853
|
-
const values = [], suffix = "0%";
|
|
854
|
-
return selections.forEach((selection) => {
|
|
855
|
-
Range.foreach(selection.range, (row, col) => {
|
|
856
|
-
values.push({ row, col, pattern: suffix, type: "percent" });
|
|
857
|
-
});
|
|
858
|
-
}), await commandService.executeCommand(SetNumfmtCommand.id, { values });
|
|
859
|
-
}, "handler")
|
|
860
|
-
};
|
|
861
|
-
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
862
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
859
|
+
}, "SheetNumfmtPanel");
|
|
860
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
861
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
863
862
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
864
|
-
return kind && result && __defProp$
|
|
865
|
-
}, "__decorateClass$
|
|
863
|
+
return kind && result && __defProp$5(target, key2, result), result;
|
|
864
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5"), _a3;
|
|
866
865
|
let NumfmtController = (_a3 = class extends Disposable {
|
|
867
866
|
constructor(_sheetInterceptorService, _themeService, _univerInstanceService, _commandService, _selectionManagerService, _renderManagerService, _numfmtService, _componentManager, _sidebarService, _localeService) {
|
|
868
867
|
super();
|
|
@@ -877,8 +876,8 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
877
876
|
this._sheetInterceptorService = _sheetInterceptorService, this._themeService = _themeService, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._selectionManagerService = _selectionManagerService, this._renderManagerService = _renderManagerService, this._numfmtService = _numfmtService, this._componentManager = _componentManager, this._sidebarService = _sidebarService, this._localeService = _localeService, this._initRealTimeRenderingInterceptor(), this._initPanel(), this._initCommands(), this._initCloseListener(), this._commandExecutedListener();
|
|
878
877
|
}
|
|
879
878
|
openPanel() {
|
|
880
|
-
var
|
|
881
|
-
const sidebarService = this._sidebarService, selectionManagerService = this._selectionManagerService, commandService = this._commandService, univerInstanceService = this._univerInstanceService, numfmtService = this._numfmtService, localeService = this._localeService, range = (((
|
|
879
|
+
var _a9;
|
|
880
|
+
const sidebarService = this._sidebarService, selectionManagerService = this._selectionManagerService, commandService = this._commandService, univerInstanceService = this._univerInstanceService, numfmtService = this._numfmtService, localeService = this._localeService, range = (((_a9 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a9.map((s) => s.range)) || [])[0];
|
|
882
881
|
if (!range)
|
|
883
882
|
return !1;
|
|
884
883
|
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), sheet = workbook.getActiveSheet();
|
|
@@ -894,11 +893,11 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
894
893
|
numfmtValue && (pattern = numfmtValue.pattern);
|
|
895
894
|
const defaultValue = (cellValue == null ? void 0 : cellValue.t) === CellValueType.NUMBER ? cellValue.v : 12345678, props = {
|
|
896
895
|
onChange: /* @__PURE__ */ __name((config) => {
|
|
897
|
-
var
|
|
896
|
+
var _a10;
|
|
898
897
|
if (config.type === "change")
|
|
899
898
|
this._previewPattern = config.value, this._forceUpdate();
|
|
900
899
|
else if (config.type === "confirm") {
|
|
901
|
-
const selections2 = ((
|
|
900
|
+
const selections2 = ((_a10 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a10.map((s) => s.range)) || [], params = { values: [] }, patternType = getPatternType(config.value);
|
|
902
901
|
selections2.forEach((rangeInfo) => {
|
|
903
902
|
Range.foreach(rangeInfo, (row, col) => {
|
|
904
903
|
params.values.push({
|
|
@@ -926,11 +925,11 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
926
925
|
}), !0;
|
|
927
926
|
}
|
|
928
927
|
_forceUpdate(unitId) {
|
|
929
|
-
var
|
|
928
|
+
var _a9;
|
|
930
929
|
const renderUnit = this._renderManagerService.getRenderById(
|
|
931
930
|
unitId != null ? unitId : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId()
|
|
932
931
|
);
|
|
933
|
-
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (
|
|
932
|
+
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (_a9 = renderUnit == null ? void 0 : renderUnit.mainComponent) == null || _a9.makeDirty();
|
|
934
933
|
}
|
|
935
934
|
_initCommands() {
|
|
936
935
|
[
|
|
@@ -974,7 +973,7 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
974
973
|
this._previewPattern = null;
|
|
975
974
|
})
|
|
976
975
|
).subscribe(({ disposableCollection, selectionRanges }) => {
|
|
977
|
-
var
|
|
976
|
+
var _a9, _b;
|
|
978
977
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
979
978
|
this.openPanel(), disposableCollection.add(
|
|
980
979
|
this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
@@ -1006,7 +1005,7 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
1006
1005
|
return defaultValue;
|
|
1007
1006
|
}, "handler")
|
|
1008
1007
|
})
|
|
1009
|
-
), (_b = (
|
|
1008
|
+
), (_b = (_a9 = this._renderManagerService.getRenderById(workbook.getUnitId())) == null ? void 0 : _a9.mainComponent) == null || _b.makeDirty();
|
|
1010
1009
|
})
|
|
1011
1010
|
)
|
|
1012
1011
|
);
|
|
@@ -1027,29 +1026,29 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
1027
1026
|
}
|
|
1028
1027
|
_initCloseListener() {
|
|
1029
1028
|
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe((unit) => {
|
|
1030
|
-
var
|
|
1031
|
-
unit || ((
|
|
1029
|
+
var _a9;
|
|
1030
|
+
unit || ((_a9 = this._sidebarDisposable) == null || _a9.dispose(), this._sidebarDisposable = null);
|
|
1032
1031
|
});
|
|
1033
1032
|
}
|
|
1034
1033
|
}, __name(_a3, "NumfmtController"), _a3);
|
|
1035
|
-
NumfmtController = __decorateClass$
|
|
1034
|
+
NumfmtController = __decorateClass$5([
|
|
1036
1035
|
OnLifecycle(LifecycleStages.Rendered, NumfmtController),
|
|
1037
|
-
__decorateParam$
|
|
1038
|
-
__decorateParam$
|
|
1039
|
-
__decorateParam$
|
|
1040
|
-
__decorateParam$
|
|
1041
|
-
__decorateParam$
|
|
1042
|
-
__decorateParam$
|
|
1043
|
-
__decorateParam$
|
|
1044
|
-
__decorateParam$
|
|
1045
|
-
__decorateParam$
|
|
1046
|
-
__decorateParam$
|
|
1036
|
+
__decorateParam$5(0, Inject(SheetInterceptorService)),
|
|
1037
|
+
__decorateParam$5(1, Inject(ThemeService)),
|
|
1038
|
+
__decorateParam$5(2, IUniverInstanceService),
|
|
1039
|
+
__decorateParam$5(3, ICommandService),
|
|
1040
|
+
__decorateParam$5(4, Inject(SheetsSelectionsService)),
|
|
1041
|
+
__decorateParam$5(5, IRenderManagerService),
|
|
1042
|
+
__decorateParam$5(6, INumfmtService),
|
|
1043
|
+
__decorateParam$5(7, Inject(ComponentManager)),
|
|
1044
|
+
__decorateParam$5(8, ISidebarService),
|
|
1045
|
+
__decorateParam$5(9, Inject(LocaleService))
|
|
1047
1046
|
], NumfmtController);
|
|
1048
|
-
var __defProp$
|
|
1049
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1047
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1048
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1050
1049
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1051
|
-
return kind && result && __defProp$
|
|
1052
|
-
}, "__decorateClass$
|
|
1050
|
+
return kind && result && __defProp$4(target, key2, result), result;
|
|
1051
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4");
|
|
1053
1052
|
const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
|
|
1054
1053
|
let list = [];
|
|
1055
1054
|
return {
|
|
@@ -1114,14 +1113,14 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1114
1113
|
this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,
|
|
1115
1114
|
{
|
|
1116
1115
|
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
1117
|
-
var
|
|
1116
|
+
var _a9;
|
|
1118
1117
|
this._collectEffectMutation.clean();
|
|
1119
1118
|
const currentNumfmtValue = this._numfmtService.getValue(
|
|
1120
1119
|
context.unitId,
|
|
1121
1120
|
context.subUnitId,
|
|
1122
1121
|
context.row,
|
|
1123
1122
|
context.col
|
|
1124
|
-
), currentNumfmtType = (
|
|
1123
|
+
), currentNumfmtType = (_a9 = currentNumfmtValue && getPatternType(currentNumfmtValue.pattern)) != null ? _a9 : "", clean = /* @__PURE__ */ __name(() => {
|
|
1125
1124
|
currentNumfmtValue && this._collectEffectMutation.add(
|
|
1126
1125
|
context.unitId,
|
|
1127
1126
|
context.subUnitId,
|
|
@@ -1159,10 +1158,10 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1159
1158
|
this.disposeWithMe(
|
|
1160
1159
|
this._sheetInterceptorService.interceptCommand({
|
|
1161
1160
|
getMutations(command) {
|
|
1162
|
-
var
|
|
1161
|
+
var _a9;
|
|
1163
1162
|
switch (command.id) {
|
|
1164
1163
|
case SetRangeValuesCommand.id: {
|
|
1165
|
-
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (
|
|
1164
|
+
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId();
|
|
1166
1165
|
if (!subUnitId)
|
|
1167
1166
|
return {
|
|
1168
1167
|
redos: [],
|
|
@@ -1175,15 +1174,15 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1175
1174
|
undos: []
|
|
1176
1175
|
};
|
|
1177
1176
|
const cells = list.filter((item) => {
|
|
1178
|
-
var
|
|
1179
|
-
return !!((
|
|
1177
|
+
var _a10;
|
|
1178
|
+
return !!((_a10 = item.value) != null && _a10.pattern);
|
|
1180
1179
|
}).map((item) => ({
|
|
1181
1180
|
row: item.row,
|
|
1182
1181
|
col: item.col,
|
|
1183
1182
|
pattern: item.value.pattern
|
|
1184
1183
|
})), removeCells = list.filter((item) => {
|
|
1185
|
-
var
|
|
1186
|
-
return !((
|
|
1184
|
+
var _a10;
|
|
1185
|
+
return !((_a10 = item.value) != null && _a10.pattern);
|
|
1187
1186
|
}).map((item) => ({
|
|
1188
1187
|
startRow: item.row,
|
|
1189
1188
|
endColumn: item.col,
|
|
@@ -1223,31 +1222,31 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1223
1222
|
);
|
|
1224
1223
|
}
|
|
1225
1224
|
}, __name(_a4, "NumfmtEditorController"), _a4);
|
|
1226
|
-
NumfmtEditorController = __decorateClass$
|
|
1225
|
+
NumfmtEditorController = __decorateClass$4([
|
|
1227
1226
|
OnLifecycle(LifecycleStages.Rendered, NumfmtEditorController),
|
|
1228
|
-
__decorateParam$
|
|
1229
|
-
__decorateParam$
|
|
1230
|
-
__decorateParam$
|
|
1231
|
-
__decorateParam$
|
|
1232
|
-
__decorateParam$
|
|
1227
|
+
__decorateParam$4(0, Inject(SheetInterceptorService)),
|
|
1228
|
+
__decorateParam$4(1, Inject(INumfmtService)),
|
|
1229
|
+
__decorateParam$4(2, Inject(IUniverInstanceService)),
|
|
1230
|
+
__decorateParam$4(3, Inject(Injector)),
|
|
1231
|
+
__decorateParam$4(4, Optional(IEditorBridgeService))
|
|
1233
1232
|
], NumfmtEditorController);
|
|
1234
1233
|
function isNumeric(str) {
|
|
1235
1234
|
return /^-?\d+(\.\d+)?$/.test(str);
|
|
1236
1235
|
}
|
|
1237
1236
|
__name(isNumeric, "isNumeric");
|
|
1238
|
-
var __defProp$
|
|
1239
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1237
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1238
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1240
1239
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1241
|
-
return kind && result && __defProp$
|
|
1242
|
-
}, "__decorateClass$
|
|
1240
|
+
return kind && result && __defProp$3(target, key2, result), result;
|
|
1241
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3"), _a5;
|
|
1243
1242
|
let NumfmtI18nController = (_a5 = class extends Disposable {
|
|
1244
1243
|
constructor(_localeService) {
|
|
1245
1244
|
super(), this._localeService = _localeService;
|
|
1246
1245
|
}
|
|
1247
1246
|
}, __name(_a5, "NumfmtI18nController"), _a5);
|
|
1248
|
-
NumfmtI18nController = __decorateClass$
|
|
1247
|
+
NumfmtI18nController = __decorateClass$3([
|
|
1249
1248
|
OnLifecycle(LifecycleStages.Rendered, NumfmtI18nController),
|
|
1250
|
-
__decorateParam$
|
|
1249
|
+
__decorateParam$3(0, Inject(LocaleService))
|
|
1251
1250
|
], NumfmtI18nController);
|
|
1252
1251
|
const MENU_OPTIONS = [
|
|
1253
1252
|
{
|
|
@@ -1303,18 +1302,20 @@ const MENU_OPTIONS = [
|
|
|
1303
1302
|
pattern: ""
|
|
1304
1303
|
}
|
|
1305
1304
|
], MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType", OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options", MoreNumfmtType = /* @__PURE__ */ __name((props) => {
|
|
1306
|
-
var
|
|
1307
|
-
const localeService = useDependency(LocaleService), value = (
|
|
1305
|
+
var _a9;
|
|
1306
|
+
const localeService = useDependency(LocaleService), value = (_a9 = props.value) != null ? _a9 : localeService.t("sheet.numfmt.general");
|
|
1308
1307
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "more-numfmt-type", children: value });
|
|
1309
1308
|
}, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
|
|
1310
|
-
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService),
|
|
1309
|
+
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), layoutService = useDependency(ILayoutService);
|
|
1310
|
+
useInjector();
|
|
1311
|
+
const selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
|
|
1311
1312
|
const selection = selectionManagerService.getCurrentLastSelection();
|
|
1312
1313
|
if (!selection)
|
|
1313
1314
|
return;
|
|
1314
|
-
const
|
|
1315
|
+
const range = selection.range, values = [];
|
|
1315
1316
|
Range.foreach(range, (row, col) => {
|
|
1316
1317
|
pattern ? values.push({ row, col, pattern, type: getPatternType(pattern) }) : values.push({ row, col });
|
|
1317
|
-
}), commandService.executeCommand(SetNumfmtCommand.id, { values }),
|
|
1318
|
+
}), commandService.executeCommand(SetNumfmtCommand.id, { values }), layoutService.focus();
|
|
1318
1319
|
}, "setNumfmt"), handleOnclick = /* @__PURE__ */ __name((index) => {
|
|
1319
1320
|
if (index === 0)
|
|
1320
1321
|
setNumfmt(null);
|
|
@@ -1361,8 +1362,6 @@ const MENU_OPTIONS = [
|
|
|
1361
1362
|
title: "sheet.numfmt.currency",
|
|
1362
1363
|
tooltip: "sheet.numfmt.currency",
|
|
1363
1364
|
type: MenuItemType.BUTTON,
|
|
1364
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1365
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1366
1365
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1367
1366
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1368
1367
|
}), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1371,8 +1370,6 @@ const MENU_OPTIONS = [
|
|
|
1371
1370
|
title: "sheet.numfmt.addDecimal",
|
|
1372
1371
|
tooltip: "sheet.numfmt.addDecimal",
|
|
1373
1372
|
type: MenuItemType.BUTTON,
|
|
1374
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1375
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1376
1373
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1377
1374
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1378
1375
|
}), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1381,8 +1378,6 @@ const MENU_OPTIONS = [
|
|
|
1381
1378
|
title: "sheet.numfmt.subtractDecimal",
|
|
1382
1379
|
tooltip: "sheet.numfmt.subtractDecimal",
|
|
1383
1380
|
type: MenuItemType.BUTTON,
|
|
1384
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1385
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1386
1381
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1387
1382
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1388
1383
|
}), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1391,8 +1386,6 @@ const MENU_OPTIONS = [
|
|
|
1391
1386
|
title: "sheet.numfmt.percent",
|
|
1392
1387
|
tooltip: "sheet.numfmt.percent",
|
|
1393
1388
|
type: MenuItemType.BUTTON,
|
|
1394
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1395
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1396
1389
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1397
1390
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1398
1391
|
}), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
|
|
@@ -1406,10 +1399,10 @@ const MENU_OPTIONS = [
|
|
|
1406
1399
|
return () => disposable.dispose();
|
|
1407
1400
|
})
|
|
1408
1401
|
).subscribe(() => {
|
|
1409
|
-
var
|
|
1402
|
+
var _a9, _b;
|
|
1410
1403
|
const selections = selectionManagerService.getCurrentSelections();
|
|
1411
1404
|
if (selections && selections[0]) {
|
|
1412
|
-
const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((
|
|
1405
|
+
const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((_a9 = worksheet.getCell(row, col)) == null ? void 0 : _a9.s)) == null ? void 0 : _b.n, pattern = numfmtValue == null ? void 0 : numfmtValue.pattern;
|
|
1413
1406
|
let value = localeService.t("sheet.numfmt.general");
|
|
1414
1407
|
if (pattern) {
|
|
1415
1408
|
const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
|
|
@@ -1426,8 +1419,6 @@ const MENU_OPTIONS = [
|
|
|
1426
1419
|
id: OpenNumfmtPanelOperator.id,
|
|
1427
1420
|
tooltip: "sheet.numfmt.title",
|
|
1428
1421
|
type: MenuItemType.SELECTOR,
|
|
1429
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1430
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1431
1422
|
selections: [
|
|
1432
1423
|
{
|
|
1433
1424
|
label: {
|
|
@@ -1440,61 +1431,102 @@ const MENU_OPTIONS = [
|
|
|
1440
1431
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1441
1432
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1442
1433
|
};
|
|
1443
|
-
}, "FactoryOtherMenuItem")
|
|
1434
|
+
}, "FactoryOtherMenuItem"), menuSchema = {
|
|
1435
|
+
[RibbonStartGroup.FORMULAS_INSERT]: {
|
|
1436
|
+
[SetCurrencyCommand.id]: {
|
|
1437
|
+
order: 4,
|
|
1438
|
+
menuItemFactory: CurrencyMenuItem
|
|
1439
|
+
},
|
|
1440
|
+
[AddDecimalCommand.id]: {
|
|
1441
|
+
order: 5,
|
|
1442
|
+
menuItemFactory: AddDecimalMenuItem
|
|
1443
|
+
},
|
|
1444
|
+
[SubtractDecimalCommand.id]: {
|
|
1445
|
+
order: 6,
|
|
1446
|
+
menuItemFactory: SubtractDecimalMenuItem
|
|
1447
|
+
},
|
|
1448
|
+
[SetPercentCommand.id]: {
|
|
1449
|
+
order: 7,
|
|
1450
|
+
menuItemFactory: PercentMenuItem
|
|
1451
|
+
},
|
|
1452
|
+
[OpenNumfmtPanelOperator.id]: {
|
|
1453
|
+
order: 8,
|
|
1454
|
+
menuItemFactory: FactoryOtherMenuItem
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
};
|
|
1458
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1459
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1460
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1461
|
+
return kind && result && __defProp$2(target, key2, result), result;
|
|
1462
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2"), _a6;
|
|
1463
|
+
let NumfmtMenuController = (_a6 = class extends Disposable {
|
|
1464
|
+
constructor(_injector, _componentManager, _menuManagerService) {
|
|
1465
|
+
super(), this._injector = _injector, this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._initMenu();
|
|
1466
|
+
}
|
|
1467
|
+
_initMenu() {
|
|
1468
|
+
this._menuManagerService.mergeMenu(menuSchema), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
|
|
1469
|
+
}
|
|
1470
|
+
}, __name(_a6, "NumfmtMenuController"), _a6);
|
|
1471
|
+
NumfmtMenuController = __decorateClass$2([
|
|
1472
|
+
OnLifecycle(LifecycleStages.Rendered, NumfmtMenuController),
|
|
1473
|
+
__decorateParam$2(0, Inject(Injector)),
|
|
1474
|
+
__decorateParam$2(1, Inject(ComponentManager)),
|
|
1475
|
+
__decorateParam$2(2, IMenuManagerService)
|
|
1476
|
+
], NumfmtMenuController);
|
|
1444
1477
|
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1445
1478
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1446
1479
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1447
1480
|
return kind && result && __defProp$1(target, key2, result), result;
|
|
1448
|
-
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1");
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
let NumfmtMenuController = (_a6 = class extends Disposable {
|
|
1452
|
-
constructor(_config, _injector, _componentManager, _menuService) {
|
|
1481
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1"), _a7;
|
|
1482
|
+
let NumfmtCurrencyController = (_a7 = class extends Disposable {
|
|
1483
|
+
constructor(_injector) {
|
|
1453
1484
|
super();
|
|
1454
1485
|
__publicField(this, "_currencySymbol$", new BehaviorSubject("US"));
|
|
1455
1486
|
__publicField(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
1456
|
-
this.
|
|
1487
|
+
this._injector = _injector;
|
|
1457
1488
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1489
|
+
/**
|
|
1490
|
+
* Set the currency symbol by setting the country code.
|
|
1491
|
+
*/
|
|
1492
|
+
setCurrencySymbolByCountryCode(symbol) {
|
|
1493
|
+
this._currencySymbol$.next(symbol);
|
|
1463
1494
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1495
|
+
getCurrencySymbol() {
|
|
1496
|
+
return this._currencySymbol$.getValue();
|
|
1497
|
+
}
|
|
1498
|
+
}, __name(_a7, "NumfmtCurrencyController"), _a7);
|
|
1499
|
+
NumfmtCurrencyController = __decorateClass$1([
|
|
1500
|
+
OnLifecycle(LifecycleStages.Rendered, NumfmtCurrencyController),
|
|
1501
|
+
__decorateParam$1(0, Inject(Injector))
|
|
1502
|
+
], NumfmtCurrencyController);
|
|
1503
|
+
const PLUGIN_CONFIG_KEY = "sheets-numfmt.config", defaultPluginConfig = {};
|
|
1471
1504
|
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key2, value) => key2 in obj ? __defProp2(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1472
1505
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1473
1506
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1474
1507
|
return kind && result && __defProp2(target, key2, result), result;
|
|
1475
|
-
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key2, value) => __defNormalProp2(obj, typeof key2 != "symbol" ? key2 + "" : key2, value), "__publicField"),
|
|
1476
|
-
let UniverSheetsNumfmtPlugin = (
|
|
1477
|
-
constructor(_config =
|
|
1478
|
-
super(), this._config = _config, this._injector = _injector, this.
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
]
|
|
1485
|
-
);
|
|
1508
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key2, value) => __defNormalProp2(obj, typeof key2 != "symbol" ? key2 + "" : key2, value), "__publicField"), _a8;
|
|
1509
|
+
let UniverSheetsNumfmtPlugin = (_a8 = class extends Plugin {
|
|
1510
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1511
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
1512
|
+
const { menu, ...rest } = this._config;
|
|
1513
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
|
|
1514
|
+
}
|
|
1515
|
+
onStarting() {
|
|
1516
|
+
this._injector.add([INumfmtController, { useClass: NumfmtController, lazy: !1 }]), this._injector.add([NumfmtEditorController]), this._injector.add([UserHabitController]), this._injector.add([SheetsNumfmtCellContentController]), this._injector.add([NumfmtI18nController]), this._injector.add([MenuCurrencyService]), this._injector.add([NumfmtCurrencyController]), this._injector.add([NumfmtMenuController]);
|
|
1486
1517
|
}
|
|
1487
|
-
}, __name(
|
|
1518
|
+
}, __name(_a8, "UniverSheetsNumfmtPlugin"), _a8);
|
|
1488
1519
|
__publicField2(UniverSheetsNumfmtPlugin, "pluginName", SHEET_NUMFMT_PLUGIN);
|
|
1489
1520
|
__publicField2(UniverSheetsNumfmtPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1490
1521
|
UniverSheetsNumfmtPlugin = __decorateClass([
|
|
1491
1522
|
DependentOn(UniverSheetsPlugin, UniverSheetsUIPlugin),
|
|
1492
|
-
__decorateParam(1, Inject(Injector))
|
|
1523
|
+
__decorateParam(1, Inject(Injector)),
|
|
1524
|
+
__decorateParam(2, IConfigService)
|
|
1493
1525
|
], UniverSheetsNumfmtPlugin);
|
|
1494
1526
|
export {
|
|
1495
1527
|
AddDecimalCommand,
|
|
1496
1528
|
CloseNumfmtPanelOperator,
|
|
1497
|
-
|
|
1529
|
+
MenuCurrencyService,
|
|
1498
1530
|
OpenNumfmtPanelOperator,
|
|
1499
1531
|
SetCurrencyCommand,
|
|
1500
1532
|
SetNumfmtCommand,
|
|
@@ -1502,5 +1534,6 @@ export {
|
|
|
1502
1534
|
SubtractDecimalCommand,
|
|
1503
1535
|
UniverSheetsNumfmtPlugin,
|
|
1504
1536
|
countryCurrencyMap,
|
|
1505
|
-
getPatternPreview
|
|
1537
|
+
getPatternPreview,
|
|
1538
|
+
getPatternType
|
|
1506
1539
|
};
|