@univerjs/sheets-numfmt 0.2.10 → 0.2.12
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 +161 -130
- 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/index.d.ts +1 -1
- 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 +18 -18
package/lib/es/index.js
CHANGED
|
@@ -2,12 +2,12 @@ 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, LocaleType, Disposable, ObjectMatrix, CellValueType, Range, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, ThemeService, ICommandService, LocaleService, IUniverInstanceService, CommandType, IUndoRedoService, sequenceExecute, createIdentifier, runOnLifecycle, ILocalStorageService, useDependency, toDisposable, DisposableCollection, Injector, Optional, useInjector, Plugin,
|
|
5
|
+
import { numfmt, LocaleType, Disposable, ObjectMatrix, CellValueType, Range, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, ThemeService, ICommandService, LocaleService, IUniverInstanceService, CommandType, IUndoRedoService, sequenceExecute, createIdentifier, runOnLifecycle, ILocalStorageService, useDependency, toDisposable, DisposableCollection, Injector, Optional, useInjector, Plugin, DependentOn, IConfigService } from "@univerjs/core";
|
|
6
6
|
import { INTERCEPTOR_POINT, InterceptCellContentPriority, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService, INumfmtService, getSheetCommandTarget, transformCellsToRange, rangeMerge, factorySetNumfmtUndoMutation, RemoveNumfmtMutation, factoryRemoveNumfmtUndoMutation, SheetsSelectionsService, SetRangeValuesCommand, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint, UniverSheetsPlugin } from "@univerjs/sheets";
|
|
7
7
|
import { SheetSkeletonManagerService, IEditorBridgeService, getCurrentRangeDisable$, deriveStateFromActiveSheet$, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
|
|
8
8
|
import { switchMap, of, skip, BehaviorSubject, Observable, combineLatest, merge } from "rxjs";
|
|
9
9
|
import { IRenderManagerService, ITextSelectionRenderManager } from "@univerjs/engine-render";
|
|
10
|
-
import { ComponentManager, ISidebarService, MenuItemType,
|
|
10
|
+
import { ComponentManager, ISidebarService, 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";
|
|
@@ -21,11 +21,11 @@ const SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN", getPatternType = /* @__PURE__
|
|
|
21
21
|
result
|
|
22
22
|
};
|
|
23
23
|
}, "getPatternPreview");
|
|
24
|
-
var __defProp$
|
|
25
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
24
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
25
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
26
26
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
27
|
-
return kind && result && __defProp$
|
|
28
|
-
}, "__decorateClass$
|
|
27
|
+
return kind && result && __defProp$7(target, key2, result), result;
|
|
28
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$7"), _a;
|
|
29
29
|
let SheetsNumfmtCellContentController = (_a = class extends Disposable {
|
|
30
30
|
constructor(_instanceService, _sheetInterceptorService, _themeService, _commandService, _numfmtService, _localeService) {
|
|
31
31
|
super(), this._instanceService = _instanceService, this._sheetInterceptorService = _sheetInterceptorService, this._themeService = _themeService, this._commandService = _commandService, this._numfmtService = _numfmtService, this._localeService = _localeService, this._initInterceptorCellContent();
|
|
@@ -83,26 +83,26 @@ let SheetsNumfmtCellContentController = (_a = class extends Disposable {
|
|
|
83
83
|
})), this.disposeWithMe(
|
|
84
84
|
this._instanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(
|
|
85
85
|
switchMap((workbook) => {
|
|
86
|
-
var
|
|
87
|
-
return (
|
|
86
|
+
var _a9;
|
|
87
|
+
return (_a9 = workbook == null ? void 0 : workbook.activeSheet$) != null ? _a9 : of(null);
|
|
88
88
|
}),
|
|
89
89
|
skip(1)
|
|
90
90
|
).subscribe(() => renderCache.reset())
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
}, __name(_a, "SheetsNumfmtCellContentController"), _a);
|
|
94
|
-
SheetsNumfmtCellContentController = __decorateClass$
|
|
94
|
+
SheetsNumfmtCellContentController = __decorateClass$7([
|
|
95
95
|
OnLifecycle(LifecycleStages.Rendered, SheetsNumfmtCellContentController),
|
|
96
|
-
__decorateParam$
|
|
97
|
-
__decorateParam$
|
|
98
|
-
__decorateParam$
|
|
99
|
-
__decorateParam$
|
|
100
|
-
__decorateParam$
|
|
101
|
-
__decorateParam$
|
|
96
|
+
__decorateParam$7(0, IUniverInstanceService),
|
|
97
|
+
__decorateParam$7(1, Inject(SheetInterceptorService)),
|
|
98
|
+
__decorateParam$7(2, Inject(ThemeService)),
|
|
99
|
+
__decorateParam$7(3, Inject(ICommandService)),
|
|
100
|
+
__decorateParam$7(4, Inject(INumfmtService)),
|
|
101
|
+
__decorateParam$7(5, Inject(LocaleService))
|
|
102
102
|
], SheetsNumfmtCellContentController);
|
|
103
103
|
const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0) => {
|
|
104
|
-
var
|
|
105
|
-
return pattern && (
|
|
104
|
+
var _a9;
|
|
105
|
+
return pattern && (_a9 = numfmt.getInfo(pattern).maxDecimals) != null ? _a9 : defaultValue;
|
|
106
106
|
}, "getDecimalFromPattern"), isPatternEqualWithoutDecimal = /* @__PURE__ */ __name((patternA, patternB) => {
|
|
107
107
|
if (patternA && !patternB || !patternA && patternB)
|
|
108
108
|
return !1;
|
|
@@ -411,7 +411,7 @@ const SetCurrencyCommand = {
|
|
|
411
411
|
const commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), menuCurrencyService = accessor.get(MenuCurrencyService), symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] || "$", selections = selectionManagerService.getCurrentSelections();
|
|
412
412
|
if (!selections || !selections.length)
|
|
413
413
|
return !1;
|
|
414
|
-
const values = [], suffix = CURRENCYFORMAT[
|
|
414
|
+
const values = [], suffix = CURRENCYFORMAT[4].suffix(symbol);
|
|
415
415
|
return selections.forEach((selection) => {
|
|
416
416
|
Range.foreach(selection.range, (row, col) => {
|
|
417
417
|
values.push({ row, col, pattern: suffix, type: "currency" });
|
|
@@ -509,11 +509,11 @@ reactJsxRuntime_production_min.jsxs = q;
|
|
|
509
509
|
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
510
510
|
var jsxRuntimeExports = jsxRuntime.exports;
|
|
511
511
|
const UserHabitCurrencyContext = createContext([]);
|
|
512
|
-
var __defProp$
|
|
513
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
512
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
513
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
514
514
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
515
|
-
return kind && result && __defProp$
|
|
516
|
-
}, "__decorateClass$
|
|
515
|
+
return kind && result && __defProp$6(target, key2, result), result;
|
|
516
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$6"), _a2;
|
|
517
517
|
let UserHabitController = (_a2 = class {
|
|
518
518
|
constructor(_localStorageService) {
|
|
519
519
|
this._localStorageService = _localStorageService;
|
|
@@ -547,8 +547,8 @@ let UserHabitController = (_a2 = class {
|
|
|
547
547
|
};
|
|
548
548
|
});
|
|
549
549
|
return sortList.sort((a, b) => {
|
|
550
|
-
var
|
|
551
|
-
const ap = ((
|
|
550
|
+
var _a9, _b;
|
|
551
|
+
const ap = ((_a9 = priority.find((item) => item.value === a)) == null ? void 0 : _a9.priority) || -1;
|
|
552
552
|
return (((_b = priority.find((item) => item.value === b)) == null ? void 0 : _b.priority) || -1) - ap;
|
|
553
553
|
});
|
|
554
554
|
}
|
|
@@ -558,8 +558,8 @@ let UserHabitController = (_a2 = class {
|
|
|
558
558
|
this._localStorageService.removeItem(habit);
|
|
559
559
|
}
|
|
560
560
|
}, __name(_a2, "UserHabitController"), _a2);
|
|
561
|
-
UserHabitController = __decorateClass$
|
|
562
|
-
__decorateParam$
|
|
561
|
+
UserHabitController = __decorateClass$6([
|
|
562
|
+
__decorateParam$6(0, Inject(ILocalStorageService))
|
|
563
563
|
], UserHabitController);
|
|
564
564
|
const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onOptionChange) => {
|
|
565
565
|
const userHabitController = useDependency(UserHabitController), [options, optionsSet] = useState(currencySymbols);
|
|
@@ -609,9 +609,9 @@ const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onO
|
|
|
609
609
|
color: item.color
|
|
610
610
|
})), "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
611
|
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
|
|
612
|
+
var _a9;
|
|
613
613
|
const negativeOptions2 = getCurrencyFormatOptions(suffix);
|
|
614
|
-
return ((
|
|
614
|
+
return ((_a9 = negativeOptions2.find((item) => isPatternEqualWithoutDecimal(item.value, props.defaultPattern))) == null ? void 0 : _a9.value) || negativeOptions2[0].value;
|
|
615
615
|
}), negativeOptions = useMemo(() => getCurrencyFormatOptions(suffix), [suffix]), options = useMemo(() => userHabitCurrency.map((key2) => ({ label: key2, value: key2 })), [userHabitCurrency]);
|
|
616
616
|
props.action.current = () => setPatternDecimal(pattern, decimal);
|
|
617
617
|
const onSelect = /* @__PURE__ */ __name((value) => {
|
|
@@ -722,15 +722,15 @@ function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
|
722
722
|
var attrs = __assign({}, node.attrs);
|
|
723
723
|
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
724
724
|
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 =
|
|
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(_a9) {
|
|
726
|
+
var key2 = _a9[0], value = _a9[1];
|
|
727
727
|
typeof value == "string" && (attrs[key2] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
728
728
|
})), attrs;
|
|
729
729
|
}
|
|
730
730
|
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
731
731
|
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
732
|
-
var
|
|
733
|
-
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((
|
|
732
|
+
var _a9, defIds = runtimeProps.defIds;
|
|
733
|
+
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
734
|
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
735
|
}) }) : node;
|
|
736
736
|
}
|
|
@@ -805,8 +805,8 @@ const SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
|
805
805
|
].map((item) => ({ ...item, label: t(item.label) })),
|
|
806
806
|
[]
|
|
807
807
|
), [type, typeSet] = useState(findDefaultType), [key2, keySet] = useState(() => `${row}_${col}`), { mark, userHabitCurrency } = useCurrencyOptions(() => keySet(`${row}_${col}_userCurrency'`)), BusinessComponent = useMemo(() => {
|
|
808
|
-
var
|
|
809
|
-
return (
|
|
808
|
+
var _a9;
|
|
809
|
+
return (_a9 = typeOptions.find((item) => item.label === type)) == null ? void 0 : _a9.component;
|
|
810
810
|
}, [type]);
|
|
811
811
|
function findDefaultType() {
|
|
812
812
|
return [isGeneralPanel, isAccountingPanel, isCurrencyPanel, isDatePanel, isThousandthPercentilePanel].reduce((pre, curFn, index) => pre || (curFn(defaultPattern) ? typeOptions[index].label : ""), "") || typeOptions[0].label;
|
|
@@ -858,11 +858,11 @@ const SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
|
|
|
858
858
|
}), await commandService.executeCommand(SetNumfmtCommand.id, { values });
|
|
859
859
|
}, "handler")
|
|
860
860
|
};
|
|
861
|
-
var __defProp$
|
|
862
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
861
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
862
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
863
863
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
864
|
-
return kind && result && __defProp$
|
|
865
|
-
}, "__decorateClass$
|
|
864
|
+
return kind && result && __defProp$5(target, key2, result), result;
|
|
865
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5"), _a3;
|
|
866
866
|
let NumfmtController = (_a3 = class extends Disposable {
|
|
867
867
|
constructor(_sheetInterceptorService, _themeService, _univerInstanceService, _commandService, _selectionManagerService, _renderManagerService, _numfmtService, _componentManager, _sidebarService, _localeService) {
|
|
868
868
|
super();
|
|
@@ -877,8 +877,8 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
877
877
|
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
878
|
}
|
|
879
879
|
openPanel() {
|
|
880
|
-
var
|
|
881
|
-
const sidebarService = this._sidebarService, selectionManagerService = this._selectionManagerService, commandService = this._commandService, univerInstanceService = this._univerInstanceService, numfmtService = this._numfmtService, localeService = this._localeService, range = (((
|
|
880
|
+
var _a9;
|
|
881
|
+
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
882
|
if (!range)
|
|
883
883
|
return !1;
|
|
884
884
|
const workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), sheet = workbook.getActiveSheet();
|
|
@@ -894,11 +894,11 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
894
894
|
numfmtValue && (pattern = numfmtValue.pattern);
|
|
895
895
|
const defaultValue = (cellValue == null ? void 0 : cellValue.t) === CellValueType.NUMBER ? cellValue.v : 12345678, props = {
|
|
896
896
|
onChange: /* @__PURE__ */ __name((config) => {
|
|
897
|
-
var
|
|
897
|
+
var _a10;
|
|
898
898
|
if (config.type === "change")
|
|
899
899
|
this._previewPattern = config.value, this._forceUpdate();
|
|
900
900
|
else if (config.type === "confirm") {
|
|
901
|
-
const selections2 = ((
|
|
901
|
+
const selections2 = ((_a10 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a10.map((s) => s.range)) || [], params = { values: [] }, patternType = getPatternType(config.value);
|
|
902
902
|
selections2.forEach((rangeInfo) => {
|
|
903
903
|
Range.foreach(rangeInfo, (row, col) => {
|
|
904
904
|
params.values.push({
|
|
@@ -926,11 +926,11 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
926
926
|
}), !0;
|
|
927
927
|
}
|
|
928
928
|
_forceUpdate(unitId) {
|
|
929
|
-
var
|
|
929
|
+
var _a9;
|
|
930
930
|
const renderUnit = this._renderManagerService.getRenderById(
|
|
931
931
|
unitId != null ? unitId : this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getUnitId()
|
|
932
932
|
);
|
|
933
|
-
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (
|
|
933
|
+
renderUnit == null || renderUnit.with(SheetSkeletonManagerService).reCalculate(), (_a9 = renderUnit == null ? void 0 : renderUnit.mainComponent) == null || _a9.makeDirty();
|
|
934
934
|
}
|
|
935
935
|
_initCommands() {
|
|
936
936
|
[
|
|
@@ -974,7 +974,7 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
974
974
|
this._previewPattern = null;
|
|
975
975
|
})
|
|
976
976
|
).subscribe(({ disposableCollection, selectionRanges }) => {
|
|
977
|
-
var
|
|
977
|
+
var _a9, _b;
|
|
978
978
|
const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
|
|
979
979
|
this.openPanel(), disposableCollection.add(
|
|
980
980
|
this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
@@ -1006,7 +1006,7 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
1006
1006
|
return defaultValue;
|
|
1007
1007
|
}, "handler")
|
|
1008
1008
|
})
|
|
1009
|
-
), (_b = (
|
|
1009
|
+
), (_b = (_a9 = this._renderManagerService.getRenderById(workbook.getUnitId())) == null ? void 0 : _a9.mainComponent) == null || _b.makeDirty();
|
|
1010
1010
|
})
|
|
1011
1011
|
)
|
|
1012
1012
|
);
|
|
@@ -1027,29 +1027,29 @@ let NumfmtController = (_a3 = class extends Disposable {
|
|
|
1027
1027
|
}
|
|
1028
1028
|
_initCloseListener() {
|
|
1029
1029
|
this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).subscribe((unit) => {
|
|
1030
|
-
var
|
|
1031
|
-
unit || ((
|
|
1030
|
+
var _a9;
|
|
1031
|
+
unit || ((_a9 = this._sidebarDisposable) == null || _a9.dispose(), this._sidebarDisposable = null);
|
|
1032
1032
|
});
|
|
1033
1033
|
}
|
|
1034
1034
|
}, __name(_a3, "NumfmtController"), _a3);
|
|
1035
|
-
NumfmtController = __decorateClass$
|
|
1035
|
+
NumfmtController = __decorateClass$5([
|
|
1036
1036
|
OnLifecycle(LifecycleStages.Rendered, NumfmtController),
|
|
1037
|
-
__decorateParam$
|
|
1038
|
-
__decorateParam$
|
|
1039
|
-
__decorateParam$
|
|
1040
|
-
__decorateParam$
|
|
1041
|
-
__decorateParam$
|
|
1042
|
-
__decorateParam$
|
|
1043
|
-
__decorateParam$
|
|
1044
|
-
__decorateParam$
|
|
1045
|
-
__decorateParam$
|
|
1046
|
-
__decorateParam$
|
|
1037
|
+
__decorateParam$5(0, Inject(SheetInterceptorService)),
|
|
1038
|
+
__decorateParam$5(1, Inject(ThemeService)),
|
|
1039
|
+
__decorateParam$5(2, IUniverInstanceService),
|
|
1040
|
+
__decorateParam$5(3, ICommandService),
|
|
1041
|
+
__decorateParam$5(4, Inject(SheetsSelectionsService)),
|
|
1042
|
+
__decorateParam$5(5, IRenderManagerService),
|
|
1043
|
+
__decorateParam$5(6, INumfmtService),
|
|
1044
|
+
__decorateParam$5(7, Inject(ComponentManager)),
|
|
1045
|
+
__decorateParam$5(8, ISidebarService),
|
|
1046
|
+
__decorateParam$5(9, Inject(LocaleService))
|
|
1047
1047
|
], NumfmtController);
|
|
1048
|
-
var __defProp$
|
|
1049
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1048
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1049
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1050
1050
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1051
|
-
return kind && result && __defProp$
|
|
1052
|
-
}, "__decorateClass$
|
|
1051
|
+
return kind && result && __defProp$4(target, key2, result), result;
|
|
1052
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4");
|
|
1053
1053
|
const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
|
|
1054
1054
|
let list = [];
|
|
1055
1055
|
return {
|
|
@@ -1114,14 +1114,14 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1114
1114
|
this._editorBridgeService.interceptor.getInterceptPoints().AFTER_CELL_EDIT,
|
|
1115
1115
|
{
|
|
1116
1116
|
handler: /* @__PURE__ */ __name((value, context, next) => {
|
|
1117
|
-
var
|
|
1117
|
+
var _a9;
|
|
1118
1118
|
this._collectEffectMutation.clean();
|
|
1119
1119
|
const currentNumfmtValue = this._numfmtService.getValue(
|
|
1120
1120
|
context.unitId,
|
|
1121
1121
|
context.subUnitId,
|
|
1122
1122
|
context.row,
|
|
1123
1123
|
context.col
|
|
1124
|
-
), currentNumfmtType = (
|
|
1124
|
+
), currentNumfmtType = (_a9 = currentNumfmtValue && getPatternType(currentNumfmtValue.pattern)) != null ? _a9 : "", clean = /* @__PURE__ */ __name(() => {
|
|
1125
1125
|
currentNumfmtValue && this._collectEffectMutation.add(
|
|
1126
1126
|
context.unitId,
|
|
1127
1127
|
context.subUnitId,
|
|
@@ -1159,10 +1159,10 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1159
1159
|
this.disposeWithMe(
|
|
1160
1160
|
this._sheetInterceptorService.interceptCommand({
|
|
1161
1161
|
getMutations(command) {
|
|
1162
|
-
var
|
|
1162
|
+
var _a9;
|
|
1163
1163
|
switch (command.id) {
|
|
1164
1164
|
case SetRangeValuesCommand.id: {
|
|
1165
|
-
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (
|
|
1165
|
+
const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), subUnitId = (_a9 = workbook.getActiveSheet()) == null ? void 0 : _a9.getSheetId();
|
|
1166
1166
|
if (!subUnitId)
|
|
1167
1167
|
return {
|
|
1168
1168
|
redos: [],
|
|
@@ -1175,15 +1175,15 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1175
1175
|
undos: []
|
|
1176
1176
|
};
|
|
1177
1177
|
const cells = list.filter((item) => {
|
|
1178
|
-
var
|
|
1179
|
-
return !!((
|
|
1178
|
+
var _a10;
|
|
1179
|
+
return !!((_a10 = item.value) != null && _a10.pattern);
|
|
1180
1180
|
}).map((item) => ({
|
|
1181
1181
|
row: item.row,
|
|
1182
1182
|
col: item.col,
|
|
1183
1183
|
pattern: item.value.pattern
|
|
1184
1184
|
})), removeCells = list.filter((item) => {
|
|
1185
|
-
var
|
|
1186
|
-
return !((
|
|
1185
|
+
var _a10;
|
|
1186
|
+
return !((_a10 = item.value) != null && _a10.pattern);
|
|
1187
1187
|
}).map((item) => ({
|
|
1188
1188
|
startRow: item.row,
|
|
1189
1189
|
endColumn: item.col,
|
|
@@ -1223,31 +1223,31 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
|
|
|
1223
1223
|
);
|
|
1224
1224
|
}
|
|
1225
1225
|
}, __name(_a4, "NumfmtEditorController"), _a4);
|
|
1226
|
-
NumfmtEditorController = __decorateClass$
|
|
1226
|
+
NumfmtEditorController = __decorateClass$4([
|
|
1227
1227
|
OnLifecycle(LifecycleStages.Rendered, NumfmtEditorController),
|
|
1228
|
-
__decorateParam$
|
|
1229
|
-
__decorateParam$
|
|
1230
|
-
__decorateParam$
|
|
1231
|
-
__decorateParam$
|
|
1232
|
-
__decorateParam$
|
|
1228
|
+
__decorateParam$4(0, Inject(SheetInterceptorService)),
|
|
1229
|
+
__decorateParam$4(1, Inject(INumfmtService)),
|
|
1230
|
+
__decorateParam$4(2, Inject(IUniverInstanceService)),
|
|
1231
|
+
__decorateParam$4(3, Inject(Injector)),
|
|
1232
|
+
__decorateParam$4(4, Optional(IEditorBridgeService))
|
|
1233
1233
|
], NumfmtEditorController);
|
|
1234
1234
|
function isNumeric(str) {
|
|
1235
1235
|
return /^-?\d+(\.\d+)?$/.test(str);
|
|
1236
1236
|
}
|
|
1237
1237
|
__name(isNumeric, "isNumeric");
|
|
1238
|
-
var __defProp$
|
|
1239
|
-
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$
|
|
1238
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1239
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1240
1240
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1241
|
-
return kind && result && __defProp$
|
|
1242
|
-
}, "__decorateClass$
|
|
1241
|
+
return kind && result && __defProp$3(target, key2, result), result;
|
|
1242
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3"), _a5;
|
|
1243
1243
|
let NumfmtI18nController = (_a5 = class extends Disposable {
|
|
1244
1244
|
constructor(_localeService) {
|
|
1245
1245
|
super(), this._localeService = _localeService;
|
|
1246
1246
|
}
|
|
1247
1247
|
}, __name(_a5, "NumfmtI18nController"), _a5);
|
|
1248
|
-
NumfmtI18nController = __decorateClass$
|
|
1248
|
+
NumfmtI18nController = __decorateClass$3([
|
|
1249
1249
|
OnLifecycle(LifecycleStages.Rendered, NumfmtI18nController),
|
|
1250
|
-
__decorateParam$
|
|
1250
|
+
__decorateParam$3(0, Inject(LocaleService))
|
|
1251
1251
|
], NumfmtI18nController);
|
|
1252
1252
|
const MENU_OPTIONS = [
|
|
1253
1253
|
{
|
|
@@ -1303,8 +1303,8 @@ const MENU_OPTIONS = [
|
|
|
1303
1303
|
pattern: ""
|
|
1304
1304
|
}
|
|
1305
1305
|
], 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 = (
|
|
1306
|
+
var _a9;
|
|
1307
|
+
const localeService = useDependency(LocaleService), value = (_a9 = props.value) != null ? _a9 : localeService.t("sheet.numfmt.general");
|
|
1308
1308
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "more-numfmt-type", children: value });
|
|
1309
1309
|
}, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
|
|
1310
1310
|
const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), injector = useInjector(), selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
|
|
@@ -1361,8 +1361,6 @@ const MENU_OPTIONS = [
|
|
|
1361
1361
|
title: "sheet.numfmt.currency",
|
|
1362
1362
|
tooltip: "sheet.numfmt.currency",
|
|
1363
1363
|
type: MenuItemType.BUTTON,
|
|
1364
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1365
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1366
1364
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1367
1365
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1368
1366
|
}), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1371,8 +1369,6 @@ const MENU_OPTIONS = [
|
|
|
1371
1369
|
title: "sheet.numfmt.addDecimal",
|
|
1372
1370
|
tooltip: "sheet.numfmt.addDecimal",
|
|
1373
1371
|
type: MenuItemType.BUTTON,
|
|
1374
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1375
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1376
1372
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1377
1373
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1378
1374
|
}), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1381,8 +1377,6 @@ const MENU_OPTIONS = [
|
|
|
1381
1377
|
title: "sheet.numfmt.subtractDecimal",
|
|
1382
1378
|
tooltip: "sheet.numfmt.subtractDecimal",
|
|
1383
1379
|
type: MenuItemType.BUTTON,
|
|
1384
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1385
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1386
1380
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1387
1381
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1388
1382
|
}), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
|
|
@@ -1391,8 +1385,6 @@ const MENU_OPTIONS = [
|
|
|
1391
1385
|
title: "sheet.numfmt.percent",
|
|
1392
1386
|
tooltip: "sheet.numfmt.percent",
|
|
1393
1387
|
type: MenuItemType.BUTTON,
|
|
1394
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1395
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1396
1388
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1397
1389
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1398
1390
|
}), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
|
|
@@ -1406,10 +1398,10 @@ const MENU_OPTIONS = [
|
|
|
1406
1398
|
return () => disposable.dispose();
|
|
1407
1399
|
})
|
|
1408
1400
|
).subscribe(() => {
|
|
1409
|
-
var
|
|
1401
|
+
var _a9, _b;
|
|
1410
1402
|
const selections = selectionManagerService.getCurrentSelections();
|
|
1411
1403
|
if (selections && selections[0]) {
|
|
1412
|
-
const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((
|
|
1404
|
+
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
1405
|
let value = localeService.t("sheet.numfmt.general");
|
|
1414
1406
|
if (pattern) {
|
|
1415
1407
|
const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
|
|
@@ -1426,8 +1418,6 @@ const MENU_OPTIONS = [
|
|
|
1426
1418
|
id: OpenNumfmtPanelOperator.id,
|
|
1427
1419
|
tooltip: "sheet.numfmt.title",
|
|
1428
1420
|
type: MenuItemType.SELECTOR,
|
|
1429
|
-
group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
|
|
1430
|
-
positions: [MenuPosition.TOOLBAR_START],
|
|
1431
1421
|
selections: [
|
|
1432
1422
|
{
|
|
1433
1423
|
label: {
|
|
@@ -1440,61 +1430,102 @@ const MENU_OPTIONS = [
|
|
|
1440
1430
|
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1441
1431
|
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
|
|
1442
1432
|
};
|
|
1443
|
-
}, "FactoryOtherMenuItem")
|
|
1433
|
+
}, "FactoryOtherMenuItem"), menuSchema = {
|
|
1434
|
+
[RibbonStartGroup.FORMULAS_INSERT]: {
|
|
1435
|
+
[SetCurrencyCommand.id]: {
|
|
1436
|
+
order: 4,
|
|
1437
|
+
menuItemFactory: CurrencyMenuItem
|
|
1438
|
+
},
|
|
1439
|
+
[AddDecimalCommand.id]: {
|
|
1440
|
+
order: 5,
|
|
1441
|
+
menuItemFactory: AddDecimalMenuItem
|
|
1442
|
+
},
|
|
1443
|
+
[SubtractDecimalCommand.id]: {
|
|
1444
|
+
order: 6,
|
|
1445
|
+
menuItemFactory: SubtractDecimalMenuItem
|
|
1446
|
+
},
|
|
1447
|
+
[SetPercentCommand.id]: {
|
|
1448
|
+
order: 7,
|
|
1449
|
+
menuItemFactory: PercentMenuItem
|
|
1450
|
+
},
|
|
1451
|
+
[OpenNumfmtPanelOperator.id]: {
|
|
1452
|
+
order: 8,
|
|
1453
|
+
menuItemFactory: FactoryOtherMenuItem
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
};
|
|
1457
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1458
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1459
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1460
|
+
return kind && result && __defProp$2(target, key2, result), result;
|
|
1461
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2"), _a6;
|
|
1462
|
+
let NumfmtMenuController = (_a6 = class extends Disposable {
|
|
1463
|
+
constructor(_injector, _componentManager, _menuManagerService) {
|
|
1464
|
+
super(), this._injector = _injector, this._componentManager = _componentManager, this._menuManagerService = _menuManagerService, this._initMenu();
|
|
1465
|
+
}
|
|
1466
|
+
_initMenu() {
|
|
1467
|
+
this._menuManagerService.mergeMenu(menuSchema), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
|
|
1468
|
+
}
|
|
1469
|
+
}, __name(_a6, "NumfmtMenuController"), _a6);
|
|
1470
|
+
NumfmtMenuController = __decorateClass$2([
|
|
1471
|
+
OnLifecycle(LifecycleStages.Rendered, NumfmtMenuController),
|
|
1472
|
+
__decorateParam$2(0, Inject(Injector)),
|
|
1473
|
+
__decorateParam$2(1, Inject(ComponentManager)),
|
|
1474
|
+
__decorateParam$2(2, IMenuManagerService)
|
|
1475
|
+
], NumfmtMenuController);
|
|
1444
1476
|
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
|
|
1445
1477
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1446
1478
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1447
1479
|
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) {
|
|
1480
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1"), _a7;
|
|
1481
|
+
let NumfmtCurrencyController = (_a7 = class extends Disposable {
|
|
1482
|
+
constructor(_injector) {
|
|
1453
1483
|
super();
|
|
1454
1484
|
__publicField(this, "_currencySymbol$", new BehaviorSubject("US"));
|
|
1455
1485
|
__publicField(this, "currencySymbol$", this._currencySymbol$.asObservable());
|
|
1456
|
-
this.
|
|
1486
|
+
this._injector = _injector;
|
|
1457
1487
|
}
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1488
|
+
/**
|
|
1489
|
+
* Set the currency symbol by setting the country code.
|
|
1490
|
+
*/
|
|
1491
|
+
setCurrencySymbolByCountryCode(symbol) {
|
|
1492
|
+
this._currencySymbol$.next(symbol);
|
|
1463
1493
|
}
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1494
|
+
getCurrencySymbol() {
|
|
1495
|
+
return this._currencySymbol$.getValue();
|
|
1496
|
+
}
|
|
1497
|
+
}, __name(_a7, "NumfmtCurrencyController"), _a7);
|
|
1498
|
+
NumfmtCurrencyController = __decorateClass$1([
|
|
1499
|
+
OnLifecycle(LifecycleStages.Rendered, NumfmtCurrencyController),
|
|
1500
|
+
__decorateParam$1(0, Inject(Injector))
|
|
1501
|
+
], NumfmtCurrencyController);
|
|
1502
|
+
const PLUGIN_CONFIG_KEY = "sheets-numfmt.config", defaultPluginConfig = {};
|
|
1471
1503
|
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
1504
|
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1473
1505
|
(decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
|
|
1474
1506
|
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
|
-
);
|
|
1507
|
+
}, "__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;
|
|
1508
|
+
let UniverSheetsNumfmtPlugin = (_a8 = class extends Plugin {
|
|
1509
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1510
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
1511
|
+
const { menu, ...rest } = this._config;
|
|
1512
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(PLUGIN_CONFIG_KEY, rest);
|
|
1513
|
+
}
|
|
1514
|
+
onStarting() {
|
|
1515
|
+
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
1516
|
}
|
|
1487
|
-
}, __name(
|
|
1517
|
+
}, __name(_a8, "UniverSheetsNumfmtPlugin"), _a8);
|
|
1488
1518
|
__publicField2(UniverSheetsNumfmtPlugin, "pluginName", SHEET_NUMFMT_PLUGIN);
|
|
1489
1519
|
__publicField2(UniverSheetsNumfmtPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1490
1520
|
UniverSheetsNumfmtPlugin = __decorateClass([
|
|
1491
1521
|
DependentOn(UniverSheetsPlugin, UniverSheetsUIPlugin),
|
|
1492
|
-
__decorateParam(1, Inject(Injector))
|
|
1522
|
+
__decorateParam(1, Inject(Injector)),
|
|
1523
|
+
__decorateParam(2, IConfigService)
|
|
1493
1524
|
], UniverSheetsNumfmtPlugin);
|
|
1494
1525
|
export {
|
|
1495
1526
|
AddDecimalCommand,
|
|
1496
1527
|
CloseNumfmtPanelOperator,
|
|
1497
|
-
|
|
1528
|
+
MenuCurrencyService,
|
|
1498
1529
|
OpenNumfmtPanelOperator,
|
|
1499
1530
|
SetCurrencyCommand,
|
|
1500
1531
|
SetNumfmtCommand,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MenuConfig } from '@univerjs/ui';
|
|
2
|
+
export declare const PLUGIN_CONFIG_KEY = "sheets-numfmt.config";
|
|
3
|
+
export declare const configSymbol: unique symbol;
|
|
4
|
+
export interface IUniverSheetsNumfmtConfig {
|
|
5
|
+
menu?: MenuConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare const defaultPluginConfig: IUniverSheetsNumfmtConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Disposable, Injector } from '@univerjs/core';
|
|
2
|
+
import { countryCurrencyMap } from '../base/const/CURRENCY-SYMBOLS';
|
|
3
|
+
export declare class NumfmtCurrencyController extends Disposable {
|
|
4
|
+
private _injector;
|
|
5
|
+
private _currencySymbol$;
|
|
6
|
+
readonly currencySymbol$: import('rxjs').Observable<"AT" | "US" | "CA" | "GB" | "JP" | "IN" | "AU" | "CN" | "KR" | "RU" | "BE" | "CY" | "EE" | "FI" | "FR" | "DE" | "GR" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PT" | "SK" | "SI" | "ES">;
|
|
7
|
+
constructor(_injector: Injector);
|
|
8
|
+
/**
|
|
9
|
+
* Set the currency symbol by setting the country code.
|
|
10
|
+
*/
|
|
11
|
+
setCurrencySymbolByCountryCode(symbol: keyof typeof countryCurrencyMap): void;
|
|
12
|
+
getCurrencySymbol(): "AT" | "US" | "CA" | "GB" | "JP" | "IN" | "AU" | "CN" | "KR" | "RU" | "BE" | "CY" | "EE" | "FI" | "FR" | "DE" | "GR" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PT" | "SK" | "SI" | "ES";
|
|
13
|
+
}
|