@univerjs/sheets-numfmt-ui 1.0.0-alpha.6 → 1.0.0-alpha.7
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 +38 -14
- package/lib/es/index.js +44 -20
- package/lib/index.js +44 -20
- package/lib/umd/index.js +1 -1
- package/package.json +11 -11
package/lib/cjs/index.js
CHANGED
|
@@ -303,9 +303,11 @@ function MoreNumfmtType(props) {
|
|
|
303
303
|
function Options() {
|
|
304
304
|
const commandService = (0, _univerjs_ui.useDependency)(_univerjs_core.ICommandService);
|
|
305
305
|
const localeService = (0, _univerjs_ui.useDependency)(_univerjs_core.LocaleService);
|
|
306
|
+
const regionService = (0, _univerjs_ui.useDependency)(_univerjs_core.RegionService);
|
|
306
307
|
const layoutService = (0, _univerjs_ui.useDependency)(_univerjs_ui.ILayoutService);
|
|
307
308
|
const sheetsNumfmtCellContentController = (0, _univerjs_ui.useDependency)(_univerjs_sheets_numfmt.SheetsNumfmtCellContentController);
|
|
308
309
|
const direction = (0, _univerjs_ui.useObservable)(localeService.direction$, localeService.getDirection());
|
|
310
|
+
const region = (0, _univerjs_ui.useObservable)(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
309
311
|
const selectionManagerService = (0, _univerjs_ui.useDependency)(_univerjs_sheets.SheetsSelectionsService);
|
|
310
312
|
const setNumfmt = (pattern) => {
|
|
311
313
|
const selection = selectionManagerService.getCurrentLastSelection();
|
|
@@ -328,8 +330,8 @@ function Options() {
|
|
|
328
330
|
layoutService.focus();
|
|
329
331
|
};
|
|
330
332
|
const menuOptions = (0, react.useMemo)(() => {
|
|
331
|
-
return MENU_OPTIONS(_univerjs_sheets_numfmt.
|
|
332
|
-
}, [
|
|
333
|
+
return MENU_OPTIONS((0, _univerjs_sheets_numfmt.getCurrencySymbolByLocale)(region));
|
|
334
|
+
}, [region]);
|
|
333
335
|
const handleClick = (index) => {
|
|
334
336
|
if (index === 0) setNumfmt(null);
|
|
335
337
|
else if (index === menuOptions.length - 1) {
|
|
@@ -426,13 +428,7 @@ const MENU_OPTIONS = (currencySymbol) => {
|
|
|
426
428
|
};
|
|
427
429
|
function CurrencySymbolIconMenuItem(accessor) {
|
|
428
430
|
return {
|
|
429
|
-
icon:
|
|
430
|
-
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
431
|
-
subscribe.next((0, _univerjs_sheets_numfmt.getCurrencySymbolIconByLocale)(localeService.getCurrentLocale()).icon);
|
|
432
|
-
return localeService.localeChanged$.subscribe(() => {
|
|
433
|
-
subscribe.next((0, _univerjs_sheets_numfmt.getCurrencySymbolIconByLocale)(localeService.getCurrentLocale()).icon);
|
|
434
|
-
});
|
|
435
|
-
}),
|
|
431
|
+
icon: accessor.get(_univerjs_core.RegionService).currentRegion$.pipe((0, rxjs.map)((region) => (0, _univerjs_sheets_numfmt.getCurrencySymbolIconByLocale)(region).icon)),
|
|
436
432
|
id: _univerjs_sheets_numfmt.SetCurrencyCommand.id,
|
|
437
433
|
title: "sheets-numfmt-ui.currency",
|
|
438
434
|
tooltip: "sheets-numfmt-ui.currency",
|
|
@@ -494,9 +490,10 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
494
490
|
const univerInstanceService = accessor.get(_univerjs_core.IUniverInstanceService);
|
|
495
491
|
const commandService = accessor.get(_univerjs_core.ICommandService);
|
|
496
492
|
const localeService = accessor.get(_univerjs_core.LocaleService);
|
|
493
|
+
const regionService = accessor.get(_univerjs_core.RegionService);
|
|
497
494
|
const selectionManagerService = accessor.get(_univerjs_sheets.SheetsSelectionsService);
|
|
498
495
|
const commandList = [_univerjs_sheets.RemoveNumfmtMutation.id, _univerjs_sheets.SetNumfmtMutation.id];
|
|
499
|
-
const value$ = (0, _univerjs_sheets_ui.deriveStateFromActiveSheet$)(univerInstanceService, "", ({ workbook, worksheet }) => new rxjs.Observable((subscribe) => (0, rxjs.merge)(selectionManagerService.selectionMoveEnd$, (0, _univerjs_core.fromCallback)(commandService.onCommandExecuted.bind(commandService)).pipe((0, rxjs.filter)(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
496
|
+
const value$ = (0, _univerjs_sheets_ui.deriveStateFromActiveSheet$)(univerInstanceService, "", ({ workbook, worksheet }) => new rxjs.Observable((subscribe) => (0, rxjs.merge)(selectionManagerService.selectionMoveEnd$, regionService.currentRegion$, (0, _univerjs_core.fromCallback)(commandService.onCommandExecuted.bind(commandService)).pipe((0, rxjs.filter)(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
500
497
|
const selections = selectionManagerService.getCurrentSelections();
|
|
501
498
|
if (selections && selections[0]) {
|
|
502
499
|
var _workbook$getStyles$g, _worksheet$getCell;
|
|
@@ -505,7 +502,7 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
505
502
|
const col = range.startColumn;
|
|
506
503
|
const numfmtValue = (_workbook$getStyles$g = workbook.getStyles().get((_worksheet$getCell = worksheet.getCell(row, col)) === null || _worksheet$getCell === void 0 ? void 0 : _worksheet$getCell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n;
|
|
507
504
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
508
|
-
const currencySymbol = (0, _univerjs_sheets_numfmt.getCurrencySymbolByLocale)(
|
|
505
|
+
const currencySymbol = (0, _univerjs_sheets_numfmt.getCurrencySymbolByLocale)(regionService.getCurrentRegion());
|
|
509
506
|
let value = localeService.t("sheets-numfmt-ui.general");
|
|
510
507
|
if ((0, _univerjs_core.isDefaultFormat)(pattern)) {
|
|
511
508
|
subscribe.next(value);
|
|
@@ -542,25 +539,47 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
542
539
|
|
|
543
540
|
//#endregion
|
|
544
541
|
//#region src/menu/schema.ts
|
|
545
|
-
const menuSchema = { [_univerjs_ui.RibbonStartGroup.
|
|
542
|
+
const menuSchema = { [_univerjs_ui.RibbonStartGroup.NUMBER]: {
|
|
546
543
|
[OpenNumfmtPanelOperator.id]: {
|
|
547
544
|
order: 9,
|
|
545
|
+
gridLayout: {
|
|
546
|
+
row: 1,
|
|
547
|
+
column: 1,
|
|
548
|
+
columnSpan: 4,
|
|
549
|
+
width: 210
|
|
550
|
+
},
|
|
548
551
|
menuItemFactory: FactoryOtherMenuItem
|
|
549
552
|
},
|
|
550
553
|
[_univerjs_sheets_numfmt.SetPercentCommand.id]: {
|
|
551
554
|
order: 9.1,
|
|
555
|
+
gridLayout: {
|
|
556
|
+
row: 2,
|
|
557
|
+
column: 1
|
|
558
|
+
},
|
|
552
559
|
menuItemFactory: PercentMenuItem
|
|
553
560
|
},
|
|
554
561
|
[_univerjs_sheets_numfmt.SetCurrencyCommand.id]: {
|
|
555
562
|
order: 9.2,
|
|
563
|
+
gridLayout: {
|
|
564
|
+
row: 2,
|
|
565
|
+
column: 2
|
|
566
|
+
},
|
|
556
567
|
menuItemFactory: CurrencySymbolIconMenuItem
|
|
557
568
|
},
|
|
558
569
|
[_univerjs_sheets_numfmt.AddDecimalCommand.id]: {
|
|
559
570
|
order: 9.3,
|
|
571
|
+
gridLayout: {
|
|
572
|
+
row: 2,
|
|
573
|
+
column: 3
|
|
574
|
+
},
|
|
560
575
|
menuItemFactory: AddDecimalMenuItem
|
|
561
576
|
},
|
|
562
577
|
[_univerjs_sheets_numfmt.SubtractDecimalCommand.id]: {
|
|
563
578
|
order: 9.4,
|
|
579
|
+
gridLayout: {
|
|
580
|
+
row: 2,
|
|
581
|
+
column: 4
|
|
582
|
+
},
|
|
564
583
|
menuItemFactory: SubtractDecimalMenuItem
|
|
565
584
|
}
|
|
566
585
|
} };
|
|
@@ -568,7 +587,7 @@ const menuSchema = { [_univerjs_ui.RibbonStartGroup.LAYOUT]: {
|
|
|
568
587
|
//#endregion
|
|
569
588
|
//#region package.json
|
|
570
589
|
var name = "@univerjs/sheets-numfmt-ui";
|
|
571
|
-
var version = "1.0.0-alpha.
|
|
590
|
+
var version = "1.0.0-alpha.7";
|
|
572
591
|
|
|
573
592
|
//#endregion
|
|
574
593
|
//#region src/config/config.ts
|
|
@@ -1250,11 +1269,16 @@ let ComponentsController = class ComponentsController extends _univerjs_core.Dis
|
|
|
1250
1269
|
this.disposeWithMe(this._iconManager.register({
|
|
1251
1270
|
AddDigitsIcon: _univerjs_icons.AddDigitsIcon,
|
|
1252
1271
|
DollarIcon: _univerjs_icons.DollarIcon,
|
|
1272
|
+
DongIcon: _univerjs_icons.DongIcon,
|
|
1253
1273
|
EuroIcon: _univerjs_icons.EuroIcon,
|
|
1254
1274
|
PercentIcon: _univerjs_icons.PercentIcon,
|
|
1255
1275
|
ReduceDigitsIcon: _univerjs_icons.ReduceDigitsIcon,
|
|
1276
|
+
RialIcon: _univerjs_icons.RialIcon,
|
|
1256
1277
|
RmbIcon: _univerjs_icons.RmbIcon,
|
|
1257
|
-
RoubleIcon: _univerjs_icons.RoubleIcon
|
|
1278
|
+
RoubleIcon: _univerjs_icons.RoubleIcon,
|
|
1279
|
+
RupiahIcon: _univerjs_icons.RupiahIcon,
|
|
1280
|
+
WonIcon: _univerjs_icons.WonIcon,
|
|
1281
|
+
ZlotyIcon: _univerjs_icons.ZlotyIcon
|
|
1258
1282
|
}));
|
|
1259
1283
|
}
|
|
1260
1284
|
_registerComponents() {
|
package/lib/es/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal,
|
|
1
|
+
import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
|
|
2
2
|
import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
3
|
-
import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
3
|
+
import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
4
4
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
5
5
|
import { AFTER_CELL_EDIT, BEFORE_CELL_EDIT, INTERCEPTOR_POINT, INumfmtService, RangeProtectionPermissionEditPoint, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesCommand, SheetInterceptorService, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, transformCellsToRange } from "@univerjs/sheets";
|
|
6
6
|
import { CellAlertManagerService, CellAlertType, HoverManagerService, IEditorBridgeService, IRepeatLastActionService, RepeatLastActionPermission, SheetSkeletonManagerService, UniverSheetsUIPlugin, deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
7
|
-
import { Observable, combineLatest, debounceTime, filter, merge as merge$1 } from "rxjs";
|
|
8
|
-
import { debounceTime as debounceTime$1, map, switchMap, tap } from "rxjs/operators";
|
|
7
|
+
import { Observable, combineLatest, debounceTime, filter, map, merge as merge$1 } from "rxjs";
|
|
8
|
+
import { debounceTime as debounceTime$1, map as map$1, switchMap, tap } from "rxjs/operators";
|
|
9
9
|
import { Button, Input, InputNumber, Select, SelectList, Separator, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
10
10
|
import { createContext, createElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { AddDigitsIcon, CheckMarkIcon, DollarIcon, EuroIcon, PercentIcon, ReduceDigitsIcon, RmbIcon, RoubleIcon } from "@univerjs/icons";
|
|
12
|
+
import { AddDigitsIcon, CheckMarkIcon, DollarIcon, DongIcon, EuroIcon, PercentIcon, ReduceDigitsIcon, RialIcon, RmbIcon, RoubleIcon, RupiahIcon, WonIcon, ZlotyIcon } from "@univerjs/icons";
|
|
13
13
|
import { stripErrorMargin } from "@univerjs/engine-formula";
|
|
14
14
|
|
|
15
15
|
//#region src/commands/operations/close.numfmt.panel.operation.ts
|
|
@@ -188,7 +188,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
|
|
|
188
188
|
if (commandInfo.id === OpenNumfmtPanelOperator.id) subscriber.next(true);
|
|
189
189
|
if (commandInfo.id === CloseNumfmtPanelOperator.id) subscriber.next(false);
|
|
190
190
|
});
|
|
191
|
-
}), this._selectionManagerService.selectionMoveEnd$.pipe(map((selectionInfos) => {
|
|
191
|
+
}), this._selectionManagerService.selectionMoveEnd$.pipe(map$1((selectionInfos) => {
|
|
192
192
|
if (!selectionInfos) return [];
|
|
193
193
|
return selectionInfos.map((selectionInfo) => selectionInfo.range);
|
|
194
194
|
}))]);
|
|
@@ -302,9 +302,11 @@ function MoreNumfmtType(props) {
|
|
|
302
302
|
function Options() {
|
|
303
303
|
const commandService = useDependency(ICommandService);
|
|
304
304
|
const localeService = useDependency(LocaleService);
|
|
305
|
+
const regionService = useDependency(RegionService);
|
|
305
306
|
const layoutService = useDependency(ILayoutService);
|
|
306
307
|
const sheetsNumfmtCellContentController = useDependency(SheetsNumfmtCellContentController);
|
|
307
308
|
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
309
|
+
const region = useObservable(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
308
310
|
const selectionManagerService = useDependency(SheetsSelectionsService);
|
|
309
311
|
const setNumfmt = (pattern) => {
|
|
310
312
|
const selection = selectionManagerService.getCurrentLastSelection();
|
|
@@ -327,8 +329,8 @@ function Options() {
|
|
|
327
329
|
layoutService.focus();
|
|
328
330
|
};
|
|
329
331
|
const menuOptions = useMemo(() => {
|
|
330
|
-
return MENU_OPTIONS(
|
|
331
|
-
}, [
|
|
332
|
+
return MENU_OPTIONS(getCurrencySymbolByLocale(region));
|
|
333
|
+
}, [region]);
|
|
332
334
|
const handleClick = (index) => {
|
|
333
335
|
if (index === 0) setNumfmt(null);
|
|
334
336
|
else if (index === menuOptions.length - 1) {
|
|
@@ -425,13 +427,7 @@ const MENU_OPTIONS = (currencySymbol) => {
|
|
|
425
427
|
};
|
|
426
428
|
function CurrencySymbolIconMenuItem(accessor) {
|
|
427
429
|
return {
|
|
428
|
-
icon:
|
|
429
|
-
const localeService = accessor.get(LocaleService);
|
|
430
|
-
subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
|
|
431
|
-
return localeService.localeChanged$.subscribe(() => {
|
|
432
|
-
subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
|
|
433
|
-
});
|
|
434
|
-
}),
|
|
430
|
+
icon: accessor.get(RegionService).currentRegion$.pipe(map((region) => getCurrencySymbolIconByLocale(region).icon)),
|
|
435
431
|
id: SetCurrencyCommand.id,
|
|
436
432
|
title: "sheets-numfmt-ui.currency",
|
|
437
433
|
tooltip: "sheets-numfmt-ui.currency",
|
|
@@ -493,9 +489,10 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
493
489
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
494
490
|
const commandService = accessor.get(ICommandService);
|
|
495
491
|
const localeService = accessor.get(LocaleService);
|
|
492
|
+
const regionService = accessor.get(RegionService);
|
|
496
493
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
497
494
|
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
|
|
498
|
-
const value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable((subscribe) => merge$1(selectionManagerService.selectionMoveEnd$, fromCallback(commandService.onCommandExecuted.bind(commandService)).pipe(filter(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
495
|
+
const value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable((subscribe) => merge$1(selectionManagerService.selectionMoveEnd$, regionService.currentRegion$, fromCallback(commandService.onCommandExecuted.bind(commandService)).pipe(filter(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
499
496
|
const selections = selectionManagerService.getCurrentSelections();
|
|
500
497
|
if (selections && selections[0]) {
|
|
501
498
|
var _workbook$getStyles$g, _worksheet$getCell;
|
|
@@ -504,7 +501,7 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
504
501
|
const col = range.startColumn;
|
|
505
502
|
const numfmtValue = (_workbook$getStyles$g = workbook.getStyles().get((_worksheet$getCell = worksheet.getCell(row, col)) === null || _worksheet$getCell === void 0 ? void 0 : _worksheet$getCell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n;
|
|
506
503
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
507
|
-
const currencySymbol = getCurrencySymbolByLocale(
|
|
504
|
+
const currencySymbol = getCurrencySymbolByLocale(regionService.getCurrentRegion());
|
|
508
505
|
let value = localeService.t("sheets-numfmt-ui.general");
|
|
509
506
|
if (isDefaultFormat(pattern)) {
|
|
510
507
|
subscribe.next(value);
|
|
@@ -541,25 +538,47 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
541
538
|
|
|
542
539
|
//#endregion
|
|
543
540
|
//#region src/menu/schema.ts
|
|
544
|
-
const menuSchema = { [RibbonStartGroup.
|
|
541
|
+
const menuSchema = { [RibbonStartGroup.NUMBER]: {
|
|
545
542
|
[OpenNumfmtPanelOperator.id]: {
|
|
546
543
|
order: 9,
|
|
544
|
+
gridLayout: {
|
|
545
|
+
row: 1,
|
|
546
|
+
column: 1,
|
|
547
|
+
columnSpan: 4,
|
|
548
|
+
width: 210
|
|
549
|
+
},
|
|
547
550
|
menuItemFactory: FactoryOtherMenuItem
|
|
548
551
|
},
|
|
549
552
|
[SetPercentCommand.id]: {
|
|
550
553
|
order: 9.1,
|
|
554
|
+
gridLayout: {
|
|
555
|
+
row: 2,
|
|
556
|
+
column: 1
|
|
557
|
+
},
|
|
551
558
|
menuItemFactory: PercentMenuItem
|
|
552
559
|
},
|
|
553
560
|
[SetCurrencyCommand.id]: {
|
|
554
561
|
order: 9.2,
|
|
562
|
+
gridLayout: {
|
|
563
|
+
row: 2,
|
|
564
|
+
column: 2
|
|
565
|
+
},
|
|
555
566
|
menuItemFactory: CurrencySymbolIconMenuItem
|
|
556
567
|
},
|
|
557
568
|
[AddDecimalCommand.id]: {
|
|
558
569
|
order: 9.3,
|
|
570
|
+
gridLayout: {
|
|
571
|
+
row: 2,
|
|
572
|
+
column: 3
|
|
573
|
+
},
|
|
559
574
|
menuItemFactory: AddDecimalMenuItem
|
|
560
575
|
},
|
|
561
576
|
[SubtractDecimalCommand.id]: {
|
|
562
577
|
order: 9.4,
|
|
578
|
+
gridLayout: {
|
|
579
|
+
row: 2,
|
|
580
|
+
column: 4
|
|
581
|
+
},
|
|
563
582
|
menuItemFactory: SubtractDecimalMenuItem
|
|
564
583
|
}
|
|
565
584
|
} };
|
|
@@ -567,7 +586,7 @@ const menuSchema = { [RibbonStartGroup.LAYOUT]: {
|
|
|
567
586
|
//#endregion
|
|
568
587
|
//#region package.json
|
|
569
588
|
var name = "@univerjs/sheets-numfmt-ui";
|
|
570
|
-
var version = "1.0.0-alpha.
|
|
589
|
+
var version = "1.0.0-alpha.7";
|
|
571
590
|
|
|
572
591
|
//#endregion
|
|
573
592
|
//#region src/config/config.ts
|
|
@@ -1249,11 +1268,16 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
1249
1268
|
this.disposeWithMe(this._iconManager.register({
|
|
1250
1269
|
AddDigitsIcon,
|
|
1251
1270
|
DollarIcon,
|
|
1271
|
+
DongIcon,
|
|
1252
1272
|
EuroIcon,
|
|
1253
1273
|
PercentIcon,
|
|
1254
1274
|
ReduceDigitsIcon,
|
|
1275
|
+
RialIcon,
|
|
1255
1276
|
RmbIcon,
|
|
1256
|
-
RoubleIcon
|
|
1277
|
+
RoubleIcon,
|
|
1278
|
+
RupiahIcon,
|
|
1279
|
+
WonIcon,
|
|
1280
|
+
ZlotyIcon
|
|
1257
1281
|
}));
|
|
1258
1282
|
}
|
|
1259
1283
|
_registerComponents() {
|
package/lib/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal,
|
|
1
|
+
import { AddDecimalCommand, CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY, SetCurrencyCommand, SetNumfmtCommand, SetPercentCommand, SheetsNumfmtCellContentController, SubtractDecimalCommand, UniverSheetsNumfmtPlugin, getCurrencyFormatOptions, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, getCurrencyType, getDateFormatOptions, getDecimalFromPattern, getNumberFormatOptions, getPatternPreview, getPatternPreviewIgnoreGeneral, getPatternType, isPatternHasDecimal, setPatternDecimal } from "@univerjs/sheets-numfmt";
|
|
2
2
|
import { ComponentManager, ILayoutService, IMenuManagerService, ISidebarService, IconManager, MenuItemType, RibbonStartGroup, getMenuHiddenObservable, useDependency, useObservable } from "@univerjs/ui";
|
|
3
|
-
import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
3
|
+
import { CellValueType, CommandType, DEFAULT_TEXT_FORMAT_EXCEL, DependentOn, Disposable, DisposableCollection, ICommandService, IConfigService, ILocalStorageService, IUniverInstanceService, Inject, Injector, InterceptorEffectEnum, LocaleService, Optional, Plugin, Range, RegionService, ThemeService, Tools, UniverInstanceType, currencySymbols, fromCallback, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isRealNum, isTextFormat, merge, numfmt, registerDependencies, toDisposable, touchDependencies, willLoseNumericPrecision } from "@univerjs/core";
|
|
4
4
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
5
5
|
import { AFTER_CELL_EDIT, BEFORE_CELL_EDIT, INTERCEPTOR_POINT, INumfmtService, RangeProtectionPermissionEditPoint, RemoveNumfmtMutation, SetNumfmtMutation, SetRangeValuesCommand, SheetInterceptorService, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, factoryRemoveNumfmtUndoMutation, factorySetNumfmtUndoMutation, transformCellsToRange } from "@univerjs/sheets";
|
|
6
6
|
import { CellAlertManagerService, CellAlertType, HoverManagerService, IEditorBridgeService, IRepeatLastActionService, RepeatLastActionPermission, SheetSkeletonManagerService, UniverSheetsUIPlugin, deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from "@univerjs/sheets-ui";
|
|
7
|
-
import { Observable, combineLatest, debounceTime, filter, merge as merge$1 } from "rxjs";
|
|
8
|
-
import { debounceTime as debounceTime$1, map, switchMap, tap } from "rxjs/operators";
|
|
7
|
+
import { Observable, combineLatest, debounceTime, filter, map, merge as merge$1 } from "rxjs";
|
|
8
|
+
import { debounceTime as debounceTime$1, map as map$1, switchMap, tap } from "rxjs/operators";
|
|
9
9
|
import { Button, Input, InputNumber, Select, SelectList, Separator, borderClassName, clsx, scrollbarClassName } from "@univerjs/design";
|
|
10
10
|
import { createContext, createElement, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { AddDigitsIcon, CheckMarkIcon, DollarIcon, EuroIcon, PercentIcon, ReduceDigitsIcon, RmbIcon, RoubleIcon } from "@univerjs/icons";
|
|
12
|
+
import { AddDigitsIcon, CheckMarkIcon, DollarIcon, DongIcon, EuroIcon, PercentIcon, ReduceDigitsIcon, RialIcon, RmbIcon, RoubleIcon, RupiahIcon, WonIcon, ZlotyIcon } from "@univerjs/icons";
|
|
13
13
|
import { stripErrorMargin } from "@univerjs/engine-formula";
|
|
14
14
|
|
|
15
15
|
//#region src/commands/operations/close.numfmt.panel.operation.ts
|
|
@@ -188,7 +188,7 @@ let SheetNumfmtUIController = class SheetNumfmtUIController extends Disposable {
|
|
|
188
188
|
if (commandInfo.id === OpenNumfmtPanelOperator.id) subscriber.next(true);
|
|
189
189
|
if (commandInfo.id === CloseNumfmtPanelOperator.id) subscriber.next(false);
|
|
190
190
|
});
|
|
191
|
-
}), this._selectionManagerService.selectionMoveEnd$.pipe(map((selectionInfos) => {
|
|
191
|
+
}), this._selectionManagerService.selectionMoveEnd$.pipe(map$1((selectionInfos) => {
|
|
192
192
|
if (!selectionInfos) return [];
|
|
193
193
|
return selectionInfos.map((selectionInfo) => selectionInfo.range);
|
|
194
194
|
}))]);
|
|
@@ -302,9 +302,11 @@ function MoreNumfmtType(props) {
|
|
|
302
302
|
function Options() {
|
|
303
303
|
const commandService = useDependency(ICommandService);
|
|
304
304
|
const localeService = useDependency(LocaleService);
|
|
305
|
+
const regionService = useDependency(RegionService);
|
|
305
306
|
const layoutService = useDependency(ILayoutService);
|
|
306
307
|
const sheetsNumfmtCellContentController = useDependency(SheetsNumfmtCellContentController);
|
|
307
308
|
const direction = useObservable(localeService.direction$, localeService.getDirection());
|
|
309
|
+
const region = useObservable(regionService.currentRegion$, regionService.getCurrentRegion());
|
|
308
310
|
const selectionManagerService = useDependency(SheetsSelectionsService);
|
|
309
311
|
const setNumfmt = (pattern) => {
|
|
310
312
|
const selection = selectionManagerService.getCurrentLastSelection();
|
|
@@ -327,8 +329,8 @@ function Options() {
|
|
|
327
329
|
layoutService.focus();
|
|
328
330
|
};
|
|
329
331
|
const menuOptions = useMemo(() => {
|
|
330
|
-
return MENU_OPTIONS(
|
|
331
|
-
}, [
|
|
332
|
+
return MENU_OPTIONS(getCurrencySymbolByLocale(region));
|
|
333
|
+
}, [region]);
|
|
332
334
|
const handleClick = (index) => {
|
|
333
335
|
if (index === 0) setNumfmt(null);
|
|
334
336
|
else if (index === menuOptions.length - 1) {
|
|
@@ -425,13 +427,7 @@ const MENU_OPTIONS = (currencySymbol) => {
|
|
|
425
427
|
};
|
|
426
428
|
function CurrencySymbolIconMenuItem(accessor) {
|
|
427
429
|
return {
|
|
428
|
-
icon:
|
|
429
|
-
const localeService = accessor.get(LocaleService);
|
|
430
|
-
subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
|
|
431
|
-
return localeService.localeChanged$.subscribe(() => {
|
|
432
|
-
subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
|
|
433
|
-
});
|
|
434
|
-
}),
|
|
430
|
+
icon: accessor.get(RegionService).currentRegion$.pipe(map((region) => getCurrencySymbolIconByLocale(region).icon)),
|
|
435
431
|
id: SetCurrencyCommand.id,
|
|
436
432
|
title: "sheets-numfmt-ui.currency",
|
|
437
433
|
tooltip: "sheets-numfmt-ui.currency",
|
|
@@ -493,9 +489,10 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
493
489
|
const univerInstanceService = accessor.get(IUniverInstanceService);
|
|
494
490
|
const commandService = accessor.get(ICommandService);
|
|
495
491
|
const localeService = accessor.get(LocaleService);
|
|
492
|
+
const regionService = accessor.get(RegionService);
|
|
496
493
|
const selectionManagerService = accessor.get(SheetsSelectionsService);
|
|
497
494
|
const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id];
|
|
498
|
-
const value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable((subscribe) => merge$1(selectionManagerService.selectionMoveEnd$, fromCallback(commandService.onCommandExecuted.bind(commandService)).pipe(filter(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
495
|
+
const value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable((subscribe) => merge$1(selectionManagerService.selectionMoveEnd$, regionService.currentRegion$, fromCallback(commandService.onCommandExecuted.bind(commandService)).pipe(filter(([commandInfo]) => commandList.includes(commandInfo.id)))).subscribe(() => {
|
|
499
496
|
const selections = selectionManagerService.getCurrentSelections();
|
|
500
497
|
if (selections && selections[0]) {
|
|
501
498
|
var _workbook$getStyles$g, _worksheet$getCell;
|
|
@@ -504,7 +501,7 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
504
501
|
const col = range.startColumn;
|
|
505
502
|
const numfmtValue = (_workbook$getStyles$g = workbook.getStyles().get((_worksheet$getCell = worksheet.getCell(row, col)) === null || _worksheet$getCell === void 0 ? void 0 : _worksheet$getCell.s)) === null || _workbook$getStyles$g === void 0 ? void 0 : _workbook$getStyles$g.n;
|
|
506
503
|
const pattern = numfmtValue === null || numfmtValue === void 0 ? void 0 : numfmtValue.pattern;
|
|
507
|
-
const currencySymbol = getCurrencySymbolByLocale(
|
|
504
|
+
const currencySymbol = getCurrencySymbolByLocale(regionService.getCurrentRegion());
|
|
508
505
|
let value = localeService.t("sheets-numfmt-ui.general");
|
|
509
506
|
if (isDefaultFormat(pattern)) {
|
|
510
507
|
subscribe.next(value);
|
|
@@ -541,25 +538,47 @@ function FactoryOtherMenuItem(accessor) {
|
|
|
541
538
|
|
|
542
539
|
//#endregion
|
|
543
540
|
//#region src/menu/schema.ts
|
|
544
|
-
const menuSchema = { [RibbonStartGroup.
|
|
541
|
+
const menuSchema = { [RibbonStartGroup.NUMBER]: {
|
|
545
542
|
[OpenNumfmtPanelOperator.id]: {
|
|
546
543
|
order: 9,
|
|
544
|
+
gridLayout: {
|
|
545
|
+
row: 1,
|
|
546
|
+
column: 1,
|
|
547
|
+
columnSpan: 4,
|
|
548
|
+
width: 210
|
|
549
|
+
},
|
|
547
550
|
menuItemFactory: FactoryOtherMenuItem
|
|
548
551
|
},
|
|
549
552
|
[SetPercentCommand.id]: {
|
|
550
553
|
order: 9.1,
|
|
554
|
+
gridLayout: {
|
|
555
|
+
row: 2,
|
|
556
|
+
column: 1
|
|
557
|
+
},
|
|
551
558
|
menuItemFactory: PercentMenuItem
|
|
552
559
|
},
|
|
553
560
|
[SetCurrencyCommand.id]: {
|
|
554
561
|
order: 9.2,
|
|
562
|
+
gridLayout: {
|
|
563
|
+
row: 2,
|
|
564
|
+
column: 2
|
|
565
|
+
},
|
|
555
566
|
menuItemFactory: CurrencySymbolIconMenuItem
|
|
556
567
|
},
|
|
557
568
|
[AddDecimalCommand.id]: {
|
|
558
569
|
order: 9.3,
|
|
570
|
+
gridLayout: {
|
|
571
|
+
row: 2,
|
|
572
|
+
column: 3
|
|
573
|
+
},
|
|
559
574
|
menuItemFactory: AddDecimalMenuItem
|
|
560
575
|
},
|
|
561
576
|
[SubtractDecimalCommand.id]: {
|
|
562
577
|
order: 9.4,
|
|
578
|
+
gridLayout: {
|
|
579
|
+
row: 2,
|
|
580
|
+
column: 4
|
|
581
|
+
},
|
|
563
582
|
menuItemFactory: SubtractDecimalMenuItem
|
|
564
583
|
}
|
|
565
584
|
} };
|
|
@@ -567,7 +586,7 @@ const menuSchema = { [RibbonStartGroup.LAYOUT]: {
|
|
|
567
586
|
//#endregion
|
|
568
587
|
//#region package.json
|
|
569
588
|
var name = "@univerjs/sheets-numfmt-ui";
|
|
570
|
-
var version = "1.0.0-alpha.
|
|
589
|
+
var version = "1.0.0-alpha.7";
|
|
571
590
|
|
|
572
591
|
//#endregion
|
|
573
592
|
//#region src/config/config.ts
|
|
@@ -1249,11 +1268,16 @@ let ComponentsController = class ComponentsController extends Disposable {
|
|
|
1249
1268
|
this.disposeWithMe(this._iconManager.register({
|
|
1250
1269
|
AddDigitsIcon,
|
|
1251
1270
|
DollarIcon,
|
|
1271
|
+
DongIcon,
|
|
1252
1272
|
EuroIcon,
|
|
1253
1273
|
PercentIcon,
|
|
1254
1274
|
ReduceDigitsIcon,
|
|
1275
|
+
RialIcon,
|
|
1255
1276
|
RmbIcon,
|
|
1256
|
-
RoubleIcon
|
|
1277
|
+
RoubleIcon,
|
|
1278
|
+
RupiahIcon,
|
|
1279
|
+
WonIcon,
|
|
1280
|
+
ZlotyIcon
|
|
1257
1281
|
}));
|
|
1258
1282
|
}
|
|
1259
1283
|
_registerComponents() {
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e==null?(t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId():e;if(!i)return;let a=this._renderManagerService.getRenderById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=(0,s.combineLatest)([new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(e.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let u=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(u.color){var l;let e=(l=this._themeService.getColorFromTheme(`${u.color}.500`))==null?u.color:l;return{...c,v:u.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:u.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=`sheets-numfmt-ui.moreNumfmtType`,C=`sheets-numfmt-ui.moreNumfmtType.options`;function w(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:t==null?i.t(`sheets-numfmt-ui.general`):t})}function T(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(n.ILayoutService),s=(0,n.useDependency)(t.SheetsNumfmtCellContentController),c=(0,n.useObservable)(i.direction$,i.getDirection()),f=(0,n.useDependency)(a.SheetsSelectionsService),p=n=>{let i=f.getCurrentLastSelection();if(!i)return;let a=i.range,s=[];r.Range.foreach(a,(e,r)=>{n?s.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):s.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:s}),o.focus()},m=(0,u.useMemo)(()=>E(t.localeCurrencySymbolMap.get(i.getCurrentLocale())),[i]),h=t=>{if(t===0)p(null);else if(t===m.length-1)e.executeCommand(x.id),o.focus();else{let e=m[t];e.pattern&&p(e.pattern)}};return(0,d.jsx)(`div`,{dir:c,className:`univer-grid univer-gap-1 univer-p-1.5`,children:m.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.jsxs)(`div`,{className:`univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>h(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,s.locale).result.trim():``})]},n))})}let E=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`h:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}];function D(e){return{icon:new s.Observable(n=>{let i=e.get(r.LocaleService);return n.next((0,t.getCurrencySymbolIconByLocale)(i.getCurrentLocale()).icon),i.localeChanged$.subscribe(()=>{n.next((0,t.getCurrencySymbolIconByLocale)(i.getCurrentLocale()).icon)})}),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function O(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function k(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function A(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ee(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(a.SheetsSelectionsService),d=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],f=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(u.selectionMoveEnd$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>d.includes(e.id)))).subscribe(()=>{let a=u.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,u=c.startRow,d=c.startColumn,f=(o=e.getStyles().get((s=n.getCell(u,d))==null?void 0:s.s))==null?void 0:o.n,p=f==null?void 0:f.pattern,m=(0,t.getCurrencySymbolByLocale)(l.getCurrentLocale()),h=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(p)){i.next(h);return}if(p){let e=E(m).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(p,e.pattern));h=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(h)}})));return{label:S,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:C,hoverable:!1,selectable:!1}}],value$:f,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let j={[n.RibbonStartGroup.LAYOUT]:{[x.id]:{order:9,menuItemFactory:ee},[t.SetPercentCommand.id]:{order:9.1,menuItemFactory:A},[t.SetCurrencyCommand.id]:{order:9.2,menuItemFactory:D},[t.AddDecimalCommand.id]:{order:9.3,menuItemFactory:O},[t.SubtractDecimalCommand.id]:{order:9.4,menuItemFactory:k}}};var te=`@univerjs/sheets-numfmt-ui`,ne=`1.0.0-alpha.6`;let re={};function M({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,u.useRef)(`_${oe()}`);return N(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function N(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...ie(e,n,i),...r},(ae(e,n).children||[]).map((r,a)=>N(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function ie(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ae(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function oe(){return Math.random().toString(36).substring(2,8)}M.displayName=`UniverIcon`;let se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},P=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:se}))});P.displayName=`AddDigitsIcon`;let ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},F=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:ce}))});F.displayName=`CheckMarkIcon`;let le={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},I=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:le}))});I.displayName=`DollarIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},L=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`euro-icon`,ref:t,icon:ue}))});L.displayName=`EuroIcon`;let de={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},R=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`percent-icon`,ref:t,icon:de}))});R.displayName=`PercentIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},z=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:fe}))});z.displayName=`ReduceDigitsIcon`;let pe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:pe}))});B.displayName=`RmbIcon`;let me={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(M,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:me}))});V.displayName=`RoubleIcon`;let H=(0,u.createContext)([]),U=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};U=y([v(0,(0,r.Inject)(r.ILocalStorageService))],U);let he=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function ge(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(H),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let _e=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function ve(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(H),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let W=`customFormat`,G=`numfmt_custom_pattern`;function ye(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(U),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),[p,m]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(W,p),c.getItem(G).then((e=[])=>{let t=[...new Set([p,...e||[]])].splice(0,10).filter(e=>!!e);c.setItem(G,t)}),p))},[c,a,p,s]);let[h,g]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(G).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix),...e==null?[]:e];return s.addHabit(W,[]).then(()=>s.getHabit(W,n))}).then(t=>{e||g([...new Set(t)])}),()=>{e=!0}},[c,s]);let _=e=>{m(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(p)},value:p,onChange:m,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:h.map(e=>(0,d.jsxs)(`div`,{onClick:()=>_(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:p===e&&(0,d.jsx)(F,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let be=e=>{let n=r.numfmt.getFormatInfo(e);return(0,t.getDateFormatOptions)().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(n.type)};function xe(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,u.useMemo)(t.getDateFormatOptions,[]),c=(0,n.useDependency)(r.LocaleService),[f,p]=(0,u.useState)(()=>{if(o){let e=s.find(e=>e.value===o);if(e)return e.value}return s[0].value});return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:s,onChange:e=>{e!==void 0&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheets-numfmt-ui.dateDes`)})]})}let Se=e=>!e;function Ce(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let we=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function Te(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let K=`numfmtCurrency`,Ee=e=>{let t=(0,n.useDependency)(U),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(K,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(K,e)}}},De=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}};function Oe(e){var i;let{defaultValue:a,defaultPattern:o,row:s,col:c}=e.value,f=(0,n.useDependency)(r.LocaleService),p=(0,u.useRef)(()=>``),m=De(),h=(0,u.useMemo)(()=>[{label:`sheets-numfmt-ui.general`,component:Ce},{label:`sheets-numfmt-ui.accounting`,component:ge},{label:`sheets-numfmt-ui.currency`,component:ve},{label:`sheets-numfmt-ui.date`,component:xe},{label:`sheets-numfmt-ui.thousandthPercentile`,component:Te},{label:`sheets-numfmt-ui.customFormat`,component:ye}].map(e=>({...e,label:f.t(e.label)})),[f]),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${s}_${c}_${o}`),{mark:b,userHabitCurrency:x}=Ee(()=>y(`${s}_${c}_${o}_userCurrency`)),S=(i=h.find(e=>e.label===g))==null?void 0:i.component;function C(){return[Se,he,_e,be,we].reduce((e,t,n)=>e||(t(o)?h[n].label:``),``)||h[0].label}let w=h.map(e=>({label:e.label,value:e.label})),T=t=>{_(t),m(()=>e.onChange({type:`change`,value:p.current()||``}))},E=(0,u.useCallback)(t=>{e.onChange({type:`change`,value:t})},[]),D=(0,u.useCallback)(e=>{p.current=e},[]),O=()=>{let n=p.current()||``,r=(0,t.getCurrencyType)(n);r&&b(r),e.onChange({type:`confirm`,value:n})},k=()=>{e.onChange({type:`cancel`,value:``})},A={onChange:E,onActionChange:D,defaultValue:a,defaultPattern:o};return(0,u.useEffect)(()=>{_(C()),y(`${s}_${c}_${o}`)},[s,c,o]),(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:T})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(H.Provider,{value:x,children:(0,u.createElement)(S,{...A,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:k,children:f.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:O,children:f.t(`sheets-numfmt-ui.confirm`)})]})]})}let q=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:P,DollarIcon:I,EuroIcon:L,PercentIcon:R,ReduceDigitsIcon:z,RmbIcon:B,RoubleIcon:V}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,Oe)),[[S,w],[C,T]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],q);let J=`SHEET_NUMFMT_ALERT`,Y=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{if(e){let a=e.location,s=this._context.unit,c=s.getActiveSheet();if(!c)return this._hideAlert();let l=a.unitId,u=a.subUnitId,d,f=c.getCell(a.row,a.col);if(f!=null&&f.s){let e=s.getStyles().get(f.s);e!=null&&e.n&&(d=e.n)}if(d||(d=this._numfmtService.getValue(l,u,a.row,a.col)),!d){this._hideAlert();return}if((0,r.isTextFormat)(d.pattern)&&r.Tools.isDefine(f==null?void 0:f.v)&&(0,r.isRealNum)(f.v)){var n,i;if((n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let e=this._cellAlertManagerService.currentAlert.get(J),r=e==null||(i=e.alert)==null?void 0:i.location;if(r&&r.row===a.row&&r.col===a.col&&r.subUnitId===a.subUnitId&&r.unitId===a.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:o.CellAlertType.ERROR,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:a,width:200,height:74,key:J});return}}this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(J)}};Y=y([v(1,(0,r.Inject)(o.HoverManagerService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService)],Y);let X=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};X=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],X);let ke=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},Z=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._editorBridgeService=i,_(this,`_collectEffectMutation`,ke()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s)switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`),i&&i(e)}default:return i&&i(e)}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=!(e==null||(o=e.p)==null||(o=o.body)==null)&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=(0,r.getNumfmtParseValueFilter)(u);if(l)if(Ae(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!d)return i(e)}else return i(e);if(d){if(!d.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});d.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(d.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});let a=(0,f.stripErrorMargin)(Number(d.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{var n;let t=e._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),i=t.getUnitId(),o=(n=t.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};let s=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!s.length)return{redos:[],undos:[]};let c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};Z=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Optional)(o.IEditorBridgeService))],Z);function Ae(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(j)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=re,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},re,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`sheets-numfmt-ui.config`,o)}onStarting(){this._injector.add([q]),this._injector.get(q),(0,r.registerDependencies)(this._injector,[[b],[Z],[U],[Q],[X]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[Z],[Q],[X]])}_registerRenderModules(){[[Y]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,te),_($,`version`,ne),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(o.UniverSheetsUIPlugin,t.UniverSheetsNumfmtPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=j,Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/sheets-numfmt"),require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-ui"),require("rxjs"),require("rxjs/operators"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/sheets-numfmt`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/engine-render`,`@univerjs/sheets`,`@univerjs/sheets-ui`,`rxjs`,`rxjs/operators`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsNumfmtUi={},e.UniverSheetsNumfmt,e.UniverUi,e.UniverCore,e.UniverEngineRender,e.UniverSheets,e.UniverSheetsUi,e.rxjs,e.rxjs.operators,e.UniverDesign,e.React,e.React,e.UniverEngineFormula))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let p={id:`sheet.operation.close.numfmt.panel`,type:r.CommandType.OPERATION,handler:()=>!0};function m(e){"@babel/helpers - typeof";return m=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},m(e)}function h(e,t){if(m(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(m(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function g(e){var t=h(e,`string`);return m(t)==`symbol`?t:t+``}function _(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(e,t){return function(n,r){t(n,r,e)}}function y(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let b=class extends r.Disposable{constructor(e,t,n,r,i,a,o,s,c,l){super(),this._sheetInterceptorService=e,this._themeService=t,this._univerInstanceService=n,this._commandService=r,this._selectionManagerService=i,this._renderManagerService=a,this._numfmtService=o,this._sidebarService=s,this._localeService=c,this._sheetsNumfmtCellContentController=l,_(this,`_previewPattern`,``),_(this,`_sidebarDisposable`,null),this._initRealTimeRenderingInterceptor(),this._initCommands(),this._initCloseListener(),this._commandExecutedListener(),this._initNumfmtLocalChange()}_initNumfmtLocalChange(){this.disposeWithMe((0,s.merge)(this._sheetsNumfmtCellContentController.locale$,this._localeService.currentLocale$).subscribe(()=>{this._forceUpdate()}))}openPanel(){var e;let n=this._sidebarService,i=this._selectionManagerService,a=this._commandService,o=this._univerInstanceService,s=this._numfmtService,c=this._localeService,l=(((e=i.getCurrentSelections())==null?void 0:e.map(e=>e.range))||[])[0];if(!l)return!1;let u=o.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),d=u.getActiveSheet();if(!d)return!1;let f=d.getCellRaw(l.startRow,l.startColumn),m=s.getValue(u.getUnitId(),d.getSheetId(),l.startRow,l.startColumn),h=``;m&&(h=m.pattern);let g=(f==null?void 0:f.t)===r.CellValueType.NUMBER?f.v:12345678,_={onChange:e=>{if(e.type===`change`)this._previewPattern=e.value,this._forceUpdate();else if(e.type===`confirm`){var o;let s=((o=i.getCurrentSelections())==null?void 0:o.map(e=>e.range))||[],c={values:[]},l=(0,t.getPatternType)(e.value);s.forEach(t=>{r.Range.foreach(t,(t,n)=>{c.values.push({row:t,col:n,pattern:e.value,type:l})})}),a.executeCommand(t.SetNumfmtCommand.id,c),n.close()}else e.type===`cancel`&&n.close()},value:{defaultPattern:h,defaultValue:g,row:l.startRow,col:l.startColumn}};return this._sidebarDisposable=n.open({header:{title:c.t(`sheets-numfmt-ui.title`)},children:{label:`SHEET_NUMFMT_PANEL`,..._},onClose:()=>{this._forceUpdate(),a.executeCommand(p.id)}}),!0}_forceUpdate(e){var t,n;let i=e==null?(t=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET))==null?void 0:t.getUnitId():e;if(!i)return;let a=this._renderManagerService.getRenderById(i);a==null||a.with(o.SheetSkeletonManagerService).reCalculate(),a==null||(n=a.mainComponent)==null||n.makeDirty()}_initCommands(){[x,p].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initRealTimeRenderingInterceptor(){let e=(0,s.combineLatest)([new s.Observable(e=>{this._commandService.onCommandExecuted(t=>{t.id===x.id&&e.next(!0),t.id===p.id&&e.next(!1)})}),this._selectionManagerService.selectionMoveEnd$.pipe((0,c.map)(e=>e?e.map(e=>e.range):[]))]);this.disposeWithMe((0,r.toDisposable)(e.pipe((0,c.switchMap)(([e,t])=>new s.Observable(n=>{let i=new r.DisposableCollection;return e&&t.length&&n.next({selectionRanges:t,disposableCollection:i}),()=>{i.dispose()}})),(0,c.tap)(()=>{this._previewPattern=null})).subscribe(({disposableCollection:e,selectionRanges:n})=>{var i;let o=this._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET);this.openPanel(),e.add(this._sheetInterceptorService.intercept(a.INTERCEPTOR_POINT.CELL_CONTENT,{priority:99,effect:r.InterceptorEffectEnum.Value|r.InterceptorEffectEnum.Style,handler:(e,i,a)=>{let{row:o,col:s}=i,c=a(e)||{};if(n.find(e=>e.startColumn<=s&&e.endColumn>=s&&e.startRow<=o&&e.endRow>=o)){let e=i.worksheet.getCellRaw(o,s),n=e==null?void 0:e.v,a=e==null?void 0:e.t;if(n==null||a!==r.CellValueType.NUMBER||this._previewPattern===null)return c;let u=(0,t.getPatternPreviewIgnoreGeneral)(this._previewPattern,n,this._sheetsNumfmtCellContentController.locale);if(u.color){var l;let e=(l=this._themeService.getColorFromTheme(`${u.color}.500`))==null?u.color:l;return{...c,v:u.result,t:r.CellValueType.STRING,s:{cl:{rgb:e}}}}return{...c,v:u.result,t:r.CellValueType.STRING}}return c}})),(i=this._renderManagerService.getRenderById(o.getUnitId()))==null||(i=i.mainComponent)==null||i.makeDirty()})))}_commandExecutedListener(){let e=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id];this.disposeWithMe(new s.Observable(t=>{let n=this._commandService.onCommandExecuted(n=>{if(e.includes(n.id)){let e=n.params;t.next(e.unitId)}});return()=>n.dispose()}).pipe((0,c.debounceTime)(16)).subscribe(e=>this._forceUpdate(e)))}_initCloseListener(){this._univerInstanceService.getCurrentTypeOfUnit$(r.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{if(!e){var t;(t=this._sidebarDisposable)==null||t.dispose(),this._sidebarDisposable=null}})}};b=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(r.ThemeService)),v(2,r.IUniverInstanceService),v(3,r.ICommandService),v(4,(0,r.Inject)(a.SheetsSelectionsService)),v(5,i.IRenderManagerService),v(6,a.INumfmtService),v(7,n.ISidebarService),v(8,(0,r.Inject)(r.LocaleService)),v(9,(0,r.Inject)(t.SheetsNumfmtCellContentController))],b);let x={id:`sheet.operation.open.numfmt.panel`,type:r.CommandType.OPERATION,handler:e=>(e.get(b).openPanel(),!0)},S=`sheets-numfmt-ui.moreNumfmtType`,C=`sheets-numfmt-ui.moreNumfmtType.options`;function w(e){let{value:t}=e,i=(0,n.useDependency)(r.LocaleService);return(0,d.jsx)(`span`,{className:`univer-text-sm`,children:t==null?i.t(`sheets-numfmt-ui.general`):t})}function ee(){let e=(0,n.useDependency)(r.ICommandService),i=(0,n.useDependency)(r.LocaleService),o=(0,n.useDependency)(r.RegionService),s=(0,n.useDependency)(n.ILayoutService),c=(0,n.useDependency)(t.SheetsNumfmtCellContentController),f=(0,n.useObservable)(i.direction$,i.getDirection()),p=(0,n.useObservable)(o.currentRegion$,o.getCurrentRegion()),m=(0,n.useDependency)(a.SheetsSelectionsService),h=n=>{let i=m.getCurrentLastSelection();if(!i)return;let a=i.range,o=[];r.Range.foreach(a,(e,r)=>{n?o.push({row:e,col:r,pattern:n,type:(0,t.getPatternType)(n)}):o.push({row:e,col:r})}),e.executeCommand(t.SetNumfmtCommand.id,{values:o}),s.focus()},g=(0,u.useMemo)(()=>T((0,t.getCurrencySymbolByLocale)(p)),[p]),_=t=>{if(t===0)h(null);else if(t===g.length-1)e.executeCommand(x.id),s.focus();else{let e=g[t];e.pattern&&h(e.pattern)}};return(0,d.jsx)(`div`,{dir:f,className:`univer-grid univer-gap-1 univer-p-1.5`,children:g.map((e,n)=>e===`|`?(0,d.jsx)(l.Separator,{},n):(0,d.jsxs)(`div`,{className:`univer-flex univer-h-7 univer-cursor-default univer-items-center univer-justify-between univer-gap-6 univer-rounded univer-px-2 univer-text-sm hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,onClick:()=>_(n),children:[(0,d.jsx)(`span`,{children:i.t(e.label)}),(0,d.jsx)(`span`,{className:`univer-text-xs univer-text-gray-500 dark:!univer-text-gray-400`,children:e.pattern?(0,t.getPatternPreview)(e.pattern||``,1220,c.locale).result.trim():``})]},n))})}let T=e=>[{label:`sheets-numfmt-ui.general`,pattern:null},{label:`sheets-numfmt-ui.text`,pattern:r.DEFAULT_TEXT_FORMAT_EXCEL},`|`,{label:`sheets-numfmt-ui.number`,pattern:`0`},{label:`sheets-numfmt-ui.percent`,pattern:`0.00%`},{label:`sheets-numfmt-ui.scientific`,pattern:`0.00E+00`},`|`,{label:`sheets-numfmt-ui.accounting`,pattern:`"${e}" #,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.financialValue`,pattern:`#,##0.00;[Red]#,##0.00`},{label:`sheets-numfmt-ui.currency`,pattern:`"${e}"#,##0.00_);[Red]("${e}"#,##0.00)`},{label:`sheets-numfmt-ui.roundingCurrency`,pattern:`"${e}"#,##0;[Red]"${e}"#,##0`},`|`,{label:`sheets-numfmt-ui.date`,pattern:`yyyy-mm-dd;@`},{label:`sheets-numfmt-ui.time`,pattern:`am/pm h":"mm":"ss`},{label:`sheets-numfmt-ui.dateTime`,pattern:`yyyy-m-d am/pm h:mm`},{label:`sheets-numfmt-ui.timeDuration`,pattern:`h:mm:ss`},`|`,{label:`sheets-numfmt-ui.moreFmt`,pattern:``}];function E(e){return{icon:e.get(r.RegionService).currentRegion$.pipe((0,s.map)(e=>(0,t.getCurrencySymbolIconByLocale)(e).icon)),id:t.SetCurrencyCommand.id,title:`sheets-numfmt-ui.currency`,tooltip:`sheets-numfmt-ui.currency`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function D(e){return{icon:`AddDigitsIcon`,id:t.AddDecimalCommand.id,title:`sheets-numfmt-ui.addDecimal`,tooltip:`sheets-numfmt-ui.addDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function O(e){return{icon:`ReduceDigitsIcon`,id:t.SubtractDecimalCommand.id,title:`sheets-numfmt-ui.subtractDecimal`,tooltip:`sheets-numfmt-ui.subtractDecimal`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function te(e){return{icon:`PercentIcon`,id:t.SetPercentCommand.id,title:`sheets-numfmt-ui.percent`,tooltip:`sheets-numfmt-ui.percent`,type:n.MenuItemType.BUTTON,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetEditPermission,a.WorksheetSetCellStylePermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}function ne(e){let i=e.get(r.IUniverInstanceService),c=e.get(r.ICommandService),l=e.get(r.LocaleService),u=e.get(r.RegionService),d=e.get(a.SheetsSelectionsService),f=[a.RemoveNumfmtMutation.id,a.SetNumfmtMutation.id],p=(0,o.deriveStateFromActiveSheet$)(i,``,({workbook:e,worksheet:n})=>new s.Observable(i=>(0,s.merge)(d.selectionMoveEnd$,u.currentRegion$,(0,r.fromCallback)(c.onCommandExecuted.bind(c)).pipe((0,s.filter)(([e])=>f.includes(e.id)))).subscribe(()=>{let a=d.getCurrentSelections();if(a&&a[0]){var o,s;let c=a[0].range,d=c.startRow,f=c.startColumn,p=(o=e.getStyles().get((s=n.getCell(d,f))==null?void 0:s.s))==null?void 0:o.n,m=p==null?void 0:p.pattern,h=(0,t.getCurrencySymbolByLocale)(u.getCurrentRegion()),g=l.t(`sheets-numfmt-ui.general`);if((0,r.isDefaultFormat)(m)){i.next(g);return}if(m){let e=T(h).filter(e=>typeof e==`object`&&e.pattern).find(e=>(0,r.isPatternEqualWithoutDecimal)(m,e.pattern));g=e&&typeof e==`object`&&e.pattern?l.t(e.label):l.t(`sheets-numfmt-ui.moreFmt`)}i.next(g)}})));return{label:S,id:x.id,tooltip:`sheets-numfmt-ui.title`,type:n.MenuItemType.SELECTOR,slot:!0,selections:[{label:{name:C,hoverable:!1,selectable:!1}}],value$:p,hidden$:(0,n.getMenuHiddenObservable)(e,r.UniverInstanceType.UNIVER_SHEET),disabled$:(0,o.getCurrentRangeDisable$)(e,{workbookTypes:[a.WorkbookEditablePermission],worksheetTypes:[a.WorksheetSetCellStylePermission,a.WorksheetEditPermission],rangeTypes:[a.RangeProtectionPermissionEditPoint]})}}let re={[n.RibbonStartGroup.NUMBER]:{[x.id]:{order:9,gridLayout:{row:1,column:1,columnSpan:4,width:210},menuItemFactory:ne},[t.SetPercentCommand.id]:{order:9.1,gridLayout:{row:2,column:1},menuItemFactory:te},[t.SetCurrencyCommand.id]:{order:9.2,gridLayout:{row:2,column:2},menuItemFactory:E},[t.AddDecimalCommand.id]:{order:9.3,gridLayout:{row:2,column:3},menuItemFactory:D},[t.SubtractDecimalCommand.id]:{order:9.4,gridLayout:{row:2,column:4},menuItemFactory:O}}};var ie=`@univerjs/sheets-numfmt-ui`,ae=`1.0.0-alpha.7`;let oe={};function k({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,u.useRef)(`_${le()}`);return A(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function A(e,t,n,r,i){return(0,u.createElement)(e.tag,{key:t,...se(e,n,i),...r},(ce(e,n).children||[]).map((r,a)=>A(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function se(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ce(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function le(){return Math.random().toString(36).substring(2,8)}k.displayName=`UniverIcon`;let ue={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.06641 3.49366C4.06641 2.27555 5.14145 1.3916 6.33307 1.3916C7.52469 1.3916 8.59974 2.27555 8.59974 3.49366V6.49777C8.59974 7.71586 7.52469 8.59982 6.33307 8.59982C5.14145 8.59982 4.06641 7.71586 4.06641 6.49777V3.49366ZM6.33307 2.5916C5.68376 2.5916 5.26641 3.05264 5.26641 3.49366V6.49777C5.26641 6.93878 5.68376 7.39982 6.33307 7.39982C6.98239 7.39982 7.39974 6.93878 7.39974 6.49777V3.49366C7.39974 3.05264 6.98239 2.5916 6.33307 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M10.0664 3.49366C10.0664 2.27555 11.1415 1.3916 12.3331 1.3916C13.5247 1.3916 14.5997 2.27555 14.5997 3.49366V6.49777C14.5997 7.71586 13.5247 8.59982 12.3331 8.59982C11.1415 8.59982 10.0664 7.71586 10.0664 6.49777V3.49366ZM12.3331 2.5916C11.6838 2.5916 11.2664 3.05264 11.2664 3.49366V6.49777C11.2664 6.93878 11.6838 7.39982 12.3331 7.39982C12.9824 7.39982 13.3997 6.93878 13.3997 6.49777V3.49366C13.3997 3.05264 12.9824 2.5916 12.3331 2.5916Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M12.4242 9.5417C12.1899 9.30739 11.81 9.30739 11.5756 9.5417C11.3413 9.77602 11.3413 10.1559 11.5756 10.3902L12.5514 11.366H6.3334C6.00203 11.366 5.7334 11.6346 5.7334 11.966C5.7334 12.2973 6.00203 12.566 6.3334 12.566H12.5514L11.5756 13.5417C11.3413 13.776 11.3413 14.1559 11.5756 14.3902C11.81 14.6245 12.1899 14.6245 12.4242 14.3902L14.4159 12.3985C14.5294 12.2893 14.6001 12.1359 14.6001 11.966C14.6001 11.796 14.5294 11.6426 14.4159 11.5334L12.4242 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},j=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`add-digits-icon`,ref:t,icon:ue}))});j.displayName=`AddDigitsIcon`;let de={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1544 3.75557C14.3887 3.98988 14.3887 4.36978 14.1544 4.6041L6.51409 12.2444C6.40157 12.3569 6.24896 12.4201 6.08983 12.4201C5.9307 12.4201 5.77808 12.3569 5.66556 12.2444L1.84541 8.42425C1.6111 8.18993 1.6111 7.81003 1.84541 7.57572C2.07973 7.34141 2.45963 7.34141 2.69394 7.57572L6.08983 10.9716L13.3059 3.75557C13.5402 3.52126 13.9201 3.52126 14.1544 3.75557Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},M=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`check-mark-icon`,ref:t,icon:de}))});M.displayName=`CheckMarkIcon`;let fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M7.3999 2.8999V1.6C7.3999 1.26863 7.66853 1 7.9999 1C8.33127 1 8.5999 1.26863 8.5999 1.6V2.8999H10.2044C11.6655 2.8999 12.8499 4.08431 12.8499 5.54536C12.8499 5.87673 12.5813 6.14536 12.2499 6.14536C11.9185 6.14536 11.6499 5.87673 11.6499 5.54536C11.6499 4.74705 11.0028 4.0999 10.2044 4.0999H5.7384C4.97155 4.0999 4.3499 4.72155 4.3499 5.4884C4.3499 6.14439 4.80899 6.71087 5.45074 6.84677L10.7977 7.97906C11.994 8.23242 12.8499 9.28849 12.8499 10.5114C12.8499 11.941 11.691 13.0999 10.2614 13.0999H8.5999V14.4C8.5999 14.7314 8.33127 15 7.9999 15C7.66853 15 7.3999 14.7314 7.3999 14.4V13.0999H5.79536C4.33431 13.0999 3.1499 11.9155 3.1499 10.4544C3.1499 10.1231 3.41853 9.85445 3.7499 9.85445C4.08127 9.85445 4.3499 10.1231 4.3499 10.4544C4.3499 11.2527 4.99705 11.8999 5.79536 11.8999H10.2614C11.0283 11.8999 11.6499 11.2782 11.6499 10.5114C11.6499 9.85542 11.1908 9.28893 10.5491 9.15303L5.20214 8.02074C4.00575 7.76739 3.1499 6.71132 3.1499 5.4884C3.1499 4.05881 4.30881 2.8999 5.7384 2.8999H7.3999Z`}}]},N=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dollar-icon`,ref:t,icon:fe}))});N.displayName=`DollarIcon`;let pe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M12.2058 3.459H11.2416V12.6604H9.6438V11.6962Q8.9091 12.844 7.4858 12.844Q5.8971 12.844 4.8456 11.6686Q3.7942 10.4932 3.7942 8.5739Q3.7942 6.5904 4.7814 5.4471Q5.7685 4.3038 7.4031 4.3038Q8.9183 4.3038 9.5887 5.3415V3.459H7.5041V2.1091H9.5887V1.2H11.2416V2.1091H12.2058V3.459ZM7.6143 11.4941Q8.5234 11.4941 9.0744 10.8008Q9.6254 10.1075 9.6254 8.7484Q9.6254 5.6629 7.5592 5.6629Q6.5491 5.6629 6.0211 6.4297Q5.493 7.1965 5.493 8.5923Q5.493 11.4941 7.6143 11.4941ZM11.2416 14.8H4.0421V13.4501H11.2416V14.8Z`}}]},P=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`dong-icon`,ref:t,icon:pe}))});P.displayName=`DongIcon`;let me={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.84964 5.80918C6.71946 3.63548 8.84516 2.2 11.3295 2.2C11.8324 2.2 12.3198 2.26279 12.7846 2.38065C13.1058 2.46209 13.4322 2.26773 13.5137 1.94652C13.5951 1.62532 13.4008 1.2989 13.0795 1.21746C12.5191 1.07535 11.9327 1 11.3295 1C8.17278 1 5.49724 2.96009 4.57394 5.80918H3.06582C2.73445 5.80918 2.46582 6.07781 2.46582 6.40918C2.46582 6.74055 2.73445 7.00918 3.06582 7.00918H4.29808C4.25287 7.33297 4.22949 7.66376 4.22949 8C4.22949 8.33608 4.25284 8.6667 4.29801 8.99033H3.06582C2.73445 8.99033 2.46582 9.25896 2.46582 9.59033C2.46582 9.9217 2.73445 10.1903 3.06582 10.1903H4.57378C5.49693 13.0397 8.1726 15 11.3295 15C11.9336 15 12.5209 14.9244 13.0821 14.7819C13.4033 14.7003 13.5975 14.3738 13.5159 14.0527C13.4344 13.7315 13.1079 13.5373 12.7867 13.6188C12.3213 13.737 11.8332 13.8 11.3295 13.8C8.84497 13.8 6.71914 12.3643 5.84944 10.1903H11.4291C11.7605 10.1903 12.0291 9.9217 12.0291 9.59033C12.0291 9.25896 11.7605 8.99033 11.4291 8.99033H5.51225C5.45783 8.66834 5.42949 8.33748 5.42949 8C5.42949 7.66235 5.45786 7.33133 5.51233 7.00918H11.4291C11.7605 7.00918 12.0291 6.74055 12.0291 6.40918C12.0291 6.07781 11.7605 5.80918 11.4291 5.80918H5.84964Z`}}]},F=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`euro-icon`,ref:t,icon:me}))});F.displayName=`EuroIcon`;let he={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.85059 4.06725C1.85059 2.84302 2.84302 1.85059 4.06725 1.85059C5.29148 1.85059 6.28392 2.84302 6.28392 4.06725C6.28392 5.29148 5.29148 6.28392 4.06725 6.28392C2.84302 6.28392 1.85059 5.29148 1.85059 4.06725ZM4.06725 2.95059C3.45053 2.95059 2.95059 3.45053 2.95059 4.06725C2.95059 4.68397 3.45053 5.18392 4.06725 5.18392C4.68397 5.18392 5.18392 4.68397 5.18392 4.06725C5.18392 3.45053 4.68397 2.95059 4.06725 2.95059Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M9.7168 11.933C9.7168 10.7087 10.7092 9.71631 11.9335 9.71631C13.1577 9.71631 14.1501 10.7087 14.1501 11.933C14.1501 13.1572 13.1577 14.1496 11.9335 14.1496C10.7092 14.1496 9.7168 13.1572 9.7168 11.933ZM11.9335 10.8163C11.3167 10.8163 10.8168 11.3163 10.8168 11.933C10.8168 12.5497 11.3167 13.0496 11.9335 13.0496C12.5502 13.0496 13.0501 12.5497 13.0501 11.933C13.0501 11.3163 12.5502 10.8163 11.9335 10.8163Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M13.5241 3.32407C13.7584 3.08975 13.7584 2.70986 13.5241 2.47554C13.2898 2.24123 12.9099 2.24123 12.6755 2.47554L2.47554 12.6755C2.24123 12.9099 2.24123 13.2898 2.47554 13.5241C2.70986 13.7584 3.08975 13.7584 3.32407 13.5241L13.5241 3.32407Z`}}]},I=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`percent-icon`,ref:t,icon:he}))});I.displayName=`PercentIcon`;let ge={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.33307 1.3916C5.14145 1.3916 4.06641 2.27555 4.06641 3.49366V6.49777C4.06641 7.71586 5.14145 8.59982 6.33307 8.59982C7.52469 8.59982 8.59974 7.71586 8.59974 6.49777V3.49366C8.59974 2.27555 7.52469 1.3916 6.33307 1.3916ZM5.26641 3.49366C5.26641 3.05264 5.68376 2.5916 6.33307 2.5916C6.98239 2.5916 7.39974 3.05264 7.39974 3.49366V6.49777C7.39974 6.93878 6.98239 7.39982 6.33307 7.39982C5.68376 7.39982 5.26641 6.93878 5.26641 6.49777V3.49366Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M7.90913 9.5417C8.14345 9.30739 8.52335 9.30739 8.75766 9.5417C8.99198 9.77602 8.99198 10.1559 8.75766 10.3902L7.78193 11.366H13.9999C14.3313 11.366 14.5999 11.6346 14.5999 11.966C14.5999 12.2973 14.3313 12.566 13.9999 12.566H7.78193L8.75766 13.5417C8.99198 13.776 8.99198 14.1559 8.75766 14.3902C8.52335 14.6245 8.14345 14.6245 7.90913 14.3902L5.91739 12.3985C5.80388 12.2893 5.73324 12.1359 5.73324 11.966C5.73324 11.796 5.80388 11.6426 5.91739 11.5334L7.90913 9.5417Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.3999 8.3002C1.3999 7.96882 1.66853 7.7002 1.9999 7.7002H2.33324C2.66461 7.7002 2.93324 7.96882 2.93324 8.3002C2.93324 8.63157 2.66461 8.9002 2.33324 8.9002H1.9999C1.66853 8.9002 1.3999 8.63157 1.3999 8.3002Z`}}]},L=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`reduce-digits-icon`,ref:t,icon:ge}))});L.displayName=`ReduceDigitsIcon`;let _e={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M6.7937 8.6977Q6.7937 9.5729 6.7228 9.9277Q6.6045 10.8264 5.7057 11.3704Q4.8543 11.8908 3.577 12.0327H3.4115Q2.6783 12.0327 2.2052 11.3468Q1.7795 10.7555 1.7795 9.9277Q1.7795 9.5965 1.945 8.887Q2.1343 8.0828 2.3944 7.8226Q2.4417 7.7517 2.5127 7.7517Q2.6546 7.7517 2.6546 7.9172Q2.6546 7.9882 2.489 8.4139Q2.3235 8.8397 2.3235 9.0762Q2.3235 9.904 2.7256 10.2588Q3.1277 10.6136 3.9791 10.6136Q4.9016 10.6136 5.6111 10.1878Q6.4863 9.6911 6.4153 8.8397Q6.2261 8.1774 5.8713 6.4271Q5.4456 4.2038 5.1617 3.0449Q4.9489 2.6191 4.807 2.4536Q4.9489 2.1934 5.0198 1.8859Q5.1617 1.2 5.28 1.2Q5.351 1.2 5.4456 1.4602Q5.5638 1.744 5.6821 1.8623Q6.1078 2.217 6.1551 2.288Q6.1551 2.3353 6.1788 2.3826Q6.2261 2.6191 5.9186 3.2577Q6.2024 4.535 6.4863 6.4271Q6.6991 7.8463 6.7937 8.6977ZM11.3586 8.9816Q11.3823 9.6911 11.0748 10.3061Q10.8856 10.7082 10.0577 10.7082Q9.3009 10.7082 8.8751 9.9277Q8.5677 9.4073 8.4021 7.8226Q8.1656 5.8122 7.9054 4.0146Q7.7398 3.0922 7.6452 2.6428L7.7871 1.9332Q7.8581 1.4602 7.929 1.4602Q7.9763 1.4602 8 1.5784Q8.2365 2.2407 8.4257 3.8963Q8.7096 6.167 8.8042 6.6637Q9.0643 8.5795 9.2299 8.9106Q9.3245 9.1235 9.5729 9.3127Q9.8212 9.5019 10.0577 9.5019Q10.72 9.5019 10.791 9.1471Q10.7437 8.9816 10.4835 8.6268Q10.2706 8.2957 10.247 8.0355L10.3889 7.657Q10.4598 7.4442 10.5781 7.2077Q10.6017 7.184 10.6254 7.184Q10.8383 7.184 11.0275 7.6334Q11.335 8.272 11.3586 8.9816ZM14.2205 10.7318Q14.2205 12.2219 13.511 13.3099Q13.1325 13.8776 12.2574 14.6108Q11.9736 14.8 11.4532 14.8Q10.9329 14.8 9.3245 14.4689Q9.2536 14.4689 9.1471 14.3624Q9.0407 14.256 9.0407 14.2087Q9.0643 14.185 9.0643 14.185L9.088 14.1614Q9.703 14.1141 10.0577 14.1141Q10.72 14.0904 11.0038 13.9722Q13.1089 13.1917 13.7475 11.2995Q13.6765 11.1339 13.2035 10.3061Q12.825 9.6438 12.825 9.3363Q12.825 9.289 12.9197 9.1471Q12.9433 9.1235 13.0379 8.7923Q13.1089 8.5558 13.1798 8.5558Q13.4637 8.5558 13.8657 9.3363Q14.2205 10.0459 14.2205 10.377V10.7318ZM10.6017 12.1273Q10.6254 12.1983 10.4243 12.6122Q10.2233 13.0261 10.105 13.0261Q9.9631 13.0261 9.6793 12.7777Q9.3955 12.5294 9.3245 12.3638Q9.632 11.536 9.7976 11.465Q9.8685 11.465 10.1997 11.7607Q10.5308 12.0563 10.6017 12.1273ZM9.1353 12.4584Q9.159 12.6003 8.9579 12.967Q8.7569 13.3336 8.6386 13.3336Q8.4967 13.3336 8.201 13.097Q7.9054 12.8605 7.9054 12.7423Q7.8344 12.553 8.3075 11.8198Q8.6386 11.9617 9.1353 12.4584Z`}}]},R=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rial-icon`,ref:t,icon:_e}))});R.displayName=`RialIcon`;let ve={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.9445 1.55649C12.2184 1.744 12.2895 2.11755 12.1033 2.39085L9.24342 6.58659H12.8001C13.1315 6.58659 13.4001 6.85522 13.4001 7.18659C13.4001 7.51796 13.1315 7.78659 12.8001 7.78659H8.5999V9.91276H13.2221C13.5534 9.91276 13.8221 10.1814 13.8221 10.5128C13.8221 10.8441 13.5534 11.1128 13.2221 11.1128H8.5999V14.0877C8.5999 14.4191 8.33127 14.6877 7.9999 14.6877C7.66853 14.6877 7.3999 14.4191 7.3999 14.0877V11.1128H2.77773C2.44636 11.1128 2.17773 10.8441 2.17773 10.5128C2.17773 10.1814 2.44636 9.91276 2.77773 9.91276H7.3999V7.78659H3.2001C2.86873 7.78659 2.6001 7.51796 2.6001 7.18659C2.6001 6.85522 2.86873 6.58659 3.2001 6.58659H6.75736L3.89753 2.39085C3.71125 2.11755 3.78234 1.744 4.05631 1.55649C4.33029 1.36899 4.7034 1.43854 4.88968 1.71184L7.94595 6.19577C7.96752 6.22741 7.98564 6.2604 8.00039 6.29429C8.01514 6.2604 8.03326 6.22741 8.05483 6.19577L11.1111 1.71184C11.2974 1.43854 11.6705 1.36899 11.9445 1.55649Z`}}]},z=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rmb-icon`,ref:t,icon:ve}))});z.displayName=`RmbIcon`;let ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M9.72502 1.02051H6.07803C4.97346 1.02051 4.07803 1.91594 4.07803 3.02051V7.57046H3.00039C2.66902 7.57046 2.40039 7.83909 2.40039 8.17046C2.40039 8.50183 2.66902 8.77046 3.00039 8.77046H4.07803V10.4854H3.00039C2.66902 10.4854 2.40039 10.754 2.40039 11.0854C2.40039 11.4167 2.66902 11.6854 3.00039 11.6854H4.07803V14.3795C4.07803 14.7108 4.34666 14.9795 4.67803 14.9795C5.0094 14.9795 5.27803 14.7108 5.27803 14.3795V11.6854H10.3637C10.695 11.6854 10.9637 11.4167 10.9637 11.0854C10.9637 10.754 10.695 10.4854 10.3637 10.4854H5.27803V8.77046H9.72503C11.8651 8.77046 13.6 7.03557 13.6 4.89548C13.6 2.75539 11.8651 1.02051 9.72502 1.02051ZM9.72503 7.57046H5.27803V3.12051C5.27803 2.62345 5.68097 2.22051 6.17803 2.22051H9.72502C11.2024 2.22051 12.4 3.41814 12.4 4.89548C12.4 6.37283 11.2024 7.57046 9.72503 7.57046Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},B=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rouble-icon`,ref:t,icon:ye}))});B.displayName=`RoubleIcon`;let be={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.5953 11.0279H7.1987Q5.9451 9.0475 5.6418 8.5953Q5.3384 8.1431 5.0035 7.8197Q4.6687 7.4963 4.3739 7.4104Q4.0791 7.3246 3.5926 7.3246H2.3104V11.0279H1.2V2.6367H4.9148Q5.6761 2.6367 6.1912 2.734Q6.7064 2.8313 7.0956 3.1433Q7.4848 3.4552 7.6938 3.9303Q7.9027 4.4054 7.9027 4.932Q7.9027 5.8822 7.3017 6.4603Q6.7007 7.0384 5.5502 7.1929V7.2158Q6.3916 7.5879 7.13 8.7441L8.5953 11.0279ZM2.3104 6.3286H4.6916Q5.4128 6.3286 5.8335 6.2056Q6.2542 6.0825 6.5061 5.7276Q6.7579 5.3727 6.7579 4.932Q6.7579 4.3596 6.3401 3.9589Q5.9222 3.5582 4.9606 3.5582H2.3104V6.3286ZM10.4842 5.7391Q11.0623 4.8175 12.2185 4.8175Q13.4148 4.8175 14.1074 5.6847Q14.8 6.5519 14.8 7.9428Q14.8 9.4253 14.033 10.2981Q13.266 11.171 12.1498 11.171Q11.171 11.171 10.5815 10.3926H10.5529V13.3633H9.5226V4.9549H10.4613V5.7391H10.4842ZM12.0811 10.3239Q12.8024 10.3239 13.2746 9.7258Q13.7468 9.1276 13.7468 7.9428Q13.7468 6.8266 13.2918 6.2256Q12.8367 5.6246 12.1269 5.6246Q11.3943 5.6246 10.9221 6.2943Q10.4498 6.964 10.4498 8.0286Q10.4498 9.1562 10.902 9.7401Q11.3542 10.3239 12.0811 10.3239Z`}}]},V=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`rupiah-icon`,ref:t,icon:be}))});V.displayName=`RupiahIcon`;let xe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M14.8 9.4486H12.955L11.8883 13.2829H10.5477L9.4811 9.4486H6.5189L5.4378 13.2829H4.0108L2.9874 9.4486H1.2V8.4685H2.7351L2.4541 7.409H1.2V6.436H2.1946L1.2 2.7171H2.6342L3.4919 6.436H6.1153L7.182 2.7171H8.8613L9.9135 6.436H12.4649L13.3802 2.7171H14.8L13.7622 6.436H14.8V7.409H13.5099L13.2144 8.4685H14.8V9.4486ZM8.645 6.436Q8.0757 4.3676 7.9892 4Q7.8667 4.6342 7.3261 6.436H8.645ZM12.2414 7.409H10.209L10.5045 8.4685H11.9748L12.2414 7.409ZM9.2144 8.4685L8.9189 7.409H7.0739L6.7856 8.4685H9.2144ZM5.8559 7.409H3.7297L3.9748 8.4685H5.5604L5.8559 7.409ZM11.7586 9.4486H10.7351Q11.0955 11.1063 11.1964 11.8054L11.7586 9.4486ZM5.2937 9.4486H4.1838Q4.573 11.1063 4.7027 11.8054Q4.955 10.7315 5.2937 9.4486Z`}}]},H=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`won-icon`,ref:t,icon:xe}))});H.displayName=`WonIcon`;let Se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M10.092 14.8H1.3716V13.4548L7.6428 6.2652Q6.5389 6.3302 5.7596 6.3302H1.7334V4.9572H9.7858V6.0426L4.4516 12.2767Q4.2939 12.4715 3.6352 13.1858Q3.4775 13.3342 3.4218 13.4363Q4.3774 13.3528 5.5277 13.3528H10.092V14.8ZM14.6284 6.9888L13.376 8.0557V14.8H11.7247V9.4843L10.5094 10.4862V9.0205L11.7247 8.0186V1.2H13.376V6.5899L14.6284 5.5323V6.9888Z`}}]},Ce=(0,u.forwardRef)(function(e,t){return(0,u.createElement)(k,Object.assign({},e,{id:`zloty-icon`,ref:t,icon:Se}))});Ce.displayName=`ZlotyIcon`;let U=(0,u.createContext)([]),W=class{constructor(e){this._localStorageService=e}_getKey(e){return`userHabitController_${e}`}async addHabit(e,t){let n=this._getKey(e);return this._localStorageService.getItem(n).then(e=>{e||this._localStorageService.setItem(n,t)})}markHabit(e,t){let n=this._getKey(e);this._localStorageService.getItem(n).then(e=>{if(e){let r=e.findIndex(e=>e===t);r>-1&&e.splice(r,1),e.unshift(t),this._localStorageService.setItem(n,e)}})}async getHabit(e,t){let n=this._getKey(e),r=await this._localStorageService.getItem(n);if(t&&r){let e=r.map((e,t,n)=>({value:e,priority:n.length-t}));return t.sort((t,n)=>{var r,i;let a=((r=e.find(e=>e.value===t))==null?void 0:r.priority)||-1;return(((i=e.find(e=>e.value===n))==null?void 0:i.priority)||-1)-a})}return r||[]}deleteHabit(e){this._localStorageService.removeItem(e)}};W=y([v(0,(0,r.Inject)(r.ILocalStorageService))],W);let we=e=>!!(0,t.getCurrencyType)(e)&&e.startsWith(`_(`);function Te(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,[s,c]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(i||``,2)),f=(0,u.useContext)(U),[p,m]=(0,u.useState)(()=>(0,t.getCurrencyType)(i)||f[0]),h=(0,u.useMemo)(()=>f.map(e=>({label:e,value:e})),[]),g=(0,n.useDependency)(r.LocaleService);return(0,u.useLayoutEffect)(()=>{a(()=>(0,t.setPatternDecimal)(`_("${p}"* #,##0${s>0?`.0`:``}_)`,s))},[s,a,p]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:s,step:1,precision:0,max:20,min:0,onChange:e=>{let n=e||0;c(n),o((0,t.setPatternDecimal)(`_("${p}"* #,##0${n>0?`.0`:``}_)`,n))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{options:h,value:p,onChange:e=>{m(e),o((0,t.setPatternDecimal)(`_("${e}"* #,##0${s>0?`.0`:``}_)`,s))}})})]})]}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:g.t(`sheets-numfmt-ui.accountingDes`)})]})}let Ee=e=>!!(0,t.getCurrencyType)(e)&&!e.startsWith(`_(`);function De(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useContext)(U),[c,f]=(0,u.useState)(()=>(0,t.getCurrencyType)(e.defaultPattern)||s[0]),[p,m]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,2)),[h,g]=(0,u.useState)(()=>{var n;let i=(0,t.getCurrencyFormatOptions)(c);return((n=i.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern)))==null?void 0:n.value)||i[0].value}),_=(0,u.useMemo)(()=>(0,t.getCurrencyFormatOptions)(c),[c]),v=(0,u.useMemo)(()=>s.map(e=>({label:e,value:e})),[s]);return(0,u.useLayoutEffect)(()=>{i(()=>(0,t.setPatternDecimal)(h,p))},[p,i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-between`,children:[(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-32`,children:(0,d.jsx)(l.InputNumber,{value:p,max:20,min:0,onChange:e=>{m(e||0),a((0,t.setPatternDecimal)(h,e||0))}})})]}),(0,d.jsxs)(`div`,{className:`option`,children:[(0,d.jsx)(`div`,{className:`univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2 univer-w-36`,children:(0,d.jsx)(l.Select,{value:c,options:v,onChange:e=>{if(e===void 0)return;f(e);let n=(0,t.getCurrencyFormatOptions)(e)[0].value;g(n),a((0,t.setPatternDecimal)(n,p))}})})]})]}),(0,d.jsx)(`div`,{className:`label univer-mt-4`,children:o.t(`sheets-numfmt-ui.negType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:h,options:_,onChange:e=>{e!==void 0&&(g(e),a((0,t.setPatternDecimal)(e,p)))}})}),(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.currencyDes`)})]})}let G=`customFormat`,K=`numfmt_custom_pattern`;function Oe(e){let{defaultPattern:i,onActionChange:a,onChange:o}=e,s=(0,n.useDependency)(W),c=(0,n.useDependency)(r.ILocalStorageService),f=(0,n.useDependency)(r.LocaleService),[p,m]=(0,u.useState)(i);(0,u.useLayoutEffect)(()=>{a(()=>(s.markHabit(G,p),c.getItem(K).then((e=[])=>{let t=[...new Set([p,...e||[]])].splice(0,10).filter(e=>!!e);c.setItem(K,t)}),p))},[c,a,p,s]);let[h,g]=(0,u.useState)([]);(0,u.useEffect)(()=>{let e=!1;return c.getItem(K).then(e=>{let n=[...t.CURRENCYFORMAT.map(e=>e.suffix(`$`)),...t.DATEFMTLISG.map(e=>e.suffix),...t.NUMBERFORMAT.map(e=>e.suffix),...e==null?[]:e];return s.addHabit(G,[]).then(()=>s.getHabit(G,n))}).then(t=>{e||g([...new Set(t)])}),()=>{e=!0}},[c,s]);let _=e=>{m(e),o(e)};return(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.customFormat`)}),(0,d.jsx)(l.Input,{placeholder:f.t(`sheets-numfmt-ui.customFormat`),onBlur:()=>{o(p)},value:p,onChange:m,className:`univer-mt-2 univer-w-full`}),(0,d.jsx)(`div`,{className:(0,l.clsx)(`univer-mt-2 univer-max-h-[400px] univer-overflow-auto univer-rounded-lg univer-p-2`,l.borderClassName),children:h.map(e=>(0,d.jsxs)(`div`,{onClick:()=>_(e),className:`univer-flex univer-cursor-pointer univer-items-center univer-gap-1.5 univer-py-1.5 univer-text-sm`,children:[(0,d.jsx)(`div`,{className:`univer-flex univer-w-4 univer-items-center univer-text-primary-600`,children:p===e&&(0,d.jsx)(M,{})}),(0,d.jsx)(`div`,{children:e})]},e))}),(0,d.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:f.t(`sheets-numfmt-ui.customFormatDes`)})]})}let ke=e=>{let n=r.numfmt.getFormatInfo(e);return(0,t.getDateFormatOptions)().map(e=>e.value).includes(e)||[`date`,`datetime`,`time`].includes(n.type)};function Ae(e){let{onActionChange:i,onChange:a,defaultPattern:o}=e,s=(0,u.useMemo)(t.getDateFormatOptions,[]),c=(0,n.useDependency)(r.LocaleService),[f,p]=(0,u.useState)(()=>{if(o){let e=s.find(e=>e.value===o);if(e)return e.value}return s[0].value});return(0,u.useLayoutEffect)(()=>{i(()=>f)},[i,f]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-numfmt-ui.dateType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{value:f,options:s,onChange:e=>{e!==void 0&&(p(e),a(e))}})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheets-numfmt-ui.dateDes`)})]})}let je=e=>!e;function Me(e){let t=(0,n.useDependency)(r.LocaleService),{onActionChange:i}=e;return(0,u.useLayoutEffect)(()=>{i(()=>``)},[i]),(0,d.jsx)(`div`,{children:(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:t.t(`sheets-numfmt-ui.generalDes`)})})}let Ne=e=>(0,t.getNumberFormatOptions)().some(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e));function Pe(e){let{onActionChange:i,onChange:a}=e,o=(0,n.useDependency)(r.LocaleService),s=(0,u.useMemo)(t.getNumberFormatOptions,[]),[c,f]=(0,u.useState)(()=>(0,t.getDecimalFromPattern)(e.defaultPattern||``,0)),[p,m]=(0,u.useState)(()=>{let t=s.find(t=>(0,r.isPatternEqualWithoutDecimal)(t.value,e.defaultPattern||``));return(t==null?void 0:t.value)||s[0].value}),h=(0,u.useMemo)(()=>(0,t.setPatternDecimal)(p,Number(c||0)),[p,c]),g=!(0,t.isPatternHasDecimal)(p);return(0,u.useLayoutEffect)(()=>{i(()=>h)},[i,h]),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:o.t(`sheets-numfmt-ui.decimalLength`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.InputNumber,{disabled:g,value:c,max:20,min:0,onChange:e=>{f(e||0),a((0,t.setPatternDecimal)(p,Number(e||0)))}})}),(0,d.jsxs)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-400`,children:[` `,o.t(`sheets-numfmt-ui.negType`)]}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.SelectList,{onChange:e=>{e!==void 0&&(f((0,t.getDecimalFromPattern)(e,0)),m(e),a(e))},options:s,value:p})}),(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm/5 univer-text-gray-600 dark:!univer-text-gray-200`,children:o.t(`sheets-numfmt-ui.thousandthPercentileDes`)})]})}let Fe=`numfmtCurrency`,Ie=e=>{let t=(0,n.useDependency)(W),[i,a]=(0,u.useState)(r.currencySymbols);return(0,u.useEffect)(()=>{t.addHabit(`numfmtCurrency`,[]).then(()=>{t.getHabit(Fe,[...r.currencySymbols]).then(t=>{a(t),e&&e(t)})})},[]),{userHabitCurrency:i,mark:e=>{t.markHabit(Fe,e)}}},Le=()=>{let e=(0,u.useRef)([]),[t,n]=(0,u.useState)({});return(0,u.useEffect)(()=>{e.current.forEach(e=>{e()}),e.current=[]},[t]),t=>{e.current.push(t),n({})}};function Re(e){var i;let{defaultValue:a,defaultPattern:o,row:s,col:c}=e.value,f=(0,n.useDependency)(r.LocaleService),p=(0,u.useRef)(()=>``),m=Le(),h=(0,u.useMemo)(()=>[{label:`sheets-numfmt-ui.general`,component:Me},{label:`sheets-numfmt-ui.accounting`,component:Te},{label:`sheets-numfmt-ui.currency`,component:De},{label:`sheets-numfmt-ui.date`,component:Ae},{label:`sheets-numfmt-ui.thousandthPercentile`,component:Pe},{label:`sheets-numfmt-ui.customFormat`,component:Oe}].map(e=>({...e,label:f.t(e.label)})),[f]),[g,_]=(0,u.useState)(C),[v,y]=(0,u.useState)(()=>`${s}_${c}_${o}`),{mark:b,userHabitCurrency:x}=Ie(()=>y(`${s}_${c}_${o}_userCurrency`)),S=(i=h.find(e=>e.label===g))==null?void 0:i.component;function C(){return[je,we,Ee,ke,Ne].reduce((e,t,n)=>e||(t(o)?h[n].label:``),``)||h[0].label}let w=h.map(e=>({label:e.label,value:e.label})),ee=t=>{_(t),m(()=>e.onChange({type:`change`,value:p.current()||``}))},T=(0,u.useCallback)(t=>{e.onChange({type:`change`,value:t})},[]),E=(0,u.useCallback)(e=>{p.current=e},[]),D=()=>{let n=p.current()||``,r=(0,t.getCurrencyType)(n);r&&b(r),e.onChange({type:`confirm`,value:n})},O=()=>{e.onChange({type:`cancel`,value:``})},te={onChange:T,onActionChange:E,defaultValue:a,defaultPattern:o};return(0,u.useEffect)(()=>{_(C()),y(`${s}_${c}_${o}`)},[s,c,o]),(0,d.jsxs)(`div`,{className:(0,l.clsx)(`univer-flex univer-h-full univer-flex-col univer-justify-between univer-overflow-y-auto univer-pb-5`,l.scrollbarClassName),children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`div`,{className:`univer-mt-3.5 univer-text-sm univer-text-gray-400`,children:f.t(`sheets-numfmt-ui.numfmtType`)}),(0,d.jsx)(`div`,{className:`univer-mt-2`,children:(0,d.jsx)(l.Select,{className:`univer-w-full`,value:g,options:w,onChange:ee})}),(0,d.jsx)(`div`,{children:S&&(0,d.jsx)(U.Provider,{value:x,children:(0,u.createElement)(S,{...te,key:v})})})]}),(0,d.jsxs)(`div`,{className:`univer-mb-5 univer-mt-3.5 univer-flex univer-justify-end univer-gap-2 rtl:univer-flex-row-reverse`,children:[(0,d.jsx)(l.Button,{onClick:O,children:f.t(`sheets-numfmt-ui.cancel`)}),(0,d.jsx)(l.Button,{variant:`primary`,onClick:D,children:f.t(`sheets-numfmt-ui.confirm`)})]})]})}let q=class extends r.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerComponents(),this._registerIcons()}_registerIcons(){this.disposeWithMe(this._iconManager.register({AddDigitsIcon:j,DollarIcon:N,DongIcon:P,EuroIcon:F,PercentIcon:I,ReduceDigitsIcon:L,RialIcon:R,RmbIcon:z,RoubleIcon:B,RupiahIcon:V,WonIcon:H,ZlotyIcon:Ce}))}_registerComponents(){this.disposeWithMe(this._componentManager.register(`SHEET_NUMFMT_PANEL`,Re)),[[S,w],[C,ee]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=y([v(0,(0,r.Inject)(n.ComponentManager)),v(1,(0,r.Inject)(n.IconManager))],q);let J=`SHEET_NUMFMT_ALERT`,Y=class extends r.Disposable{constructor(e,t,n,r,i,a){super(),this._context=e,this._hoverManagerService=t,this._cellAlertManagerService=n,this._localeService=r,this._numfmtService=i,this._configService=a,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,s.debounceTime)(100)).subscribe(e=>{if(e){let a=e.location,s=this._context.unit,c=s.getActiveSheet();if(!c)return this._hideAlert();let l=a.unitId,u=a.subUnitId,d,f=c.getCell(a.row,a.col);if(f!=null&&f.s){let e=s.getStyles().get(f.s);e!=null&&e.n&&(d=e.n)}if(d||(d=this._numfmtService.getValue(l,u,a.row,a.col)),!d){this._hideAlert();return}if((0,r.isTextFormat)(d.pattern)&&r.Tools.isDefine(f==null?void 0:f.v)&&(0,r.isRealNum)(f.v)){var n,i;if((n=this._configService.getConfig(t.SHEETS_NUMFMT_PLUGIN_CONFIG_KEY))!=null&&n.disableTextFormatAlert)return;let e=this._cellAlertManagerService.currentAlert.get(J),r=e==null||(i=e.alert)==null?void 0:i.location;if(r&&r.row===a.row&&r.col===a.col&&r.subUnitId===a.subUnitId&&r.unitId===a.unitId){this._hideAlert();return}this._cellAlertManagerService.showAlert({type:o.CellAlertType.ERROR,title:this._localeService.t(`sheets-numfmt-ui.info.error`),message:this._localeService.t(`sheets-numfmt-ui.info.forceStringInfo`),location:a,width:200,height:74,key:J});return}}this._hideAlert()}))}_hideAlert(){this._cellAlertManagerService.removeAlert(J)}};Y=y([v(1,(0,r.Inject)(o.HoverManagerService)),v(2,(0,r.Inject)(o.CellAlertManagerService)),v(3,(0,r.Inject)(r.LocaleService)),v(4,(0,r.Inject)(a.INumfmtService)),v(5,r.IConfigService)],Y);let X=class extends r.Disposable{constructor(e){super(),this._repeatLastActionService=e,this._initCommandRecording()}_initCommandRecording(){this._repeatLastActionService&&this.disposeWithMe(this._repeatLastActionService.registerRepeatableCommand(t.SetNumfmtCommand.id,(e,t)=>{if(!t)return;let{values:n}=t,r=n.find(e=>e.pattern);if(!r)return;let{pattern:i,type:a}=r,o=[],s=new Set;for(let t of e){let{startRow:e,startColumn:n,endRow:r,endColumn:c}=t;for(let t=e;t<=r;t++)for(let e=n;e<=c;e++){let n=`${t}-${e}`;s.has(n)||(s.add(n),o.push({row:t,col:e,pattern:i,type:a}))}}return{...t,values:o}},o.RepeatLastActionPermission.CellStyle))}};X=y([v(0,(0,r.Optional)(o.IRepeatLastActionService))],X);let ze=()=>{let e=[];return{add:(t,n,r,i,a)=>e.push({unitId:t,subUnitId:n,row:r,col:i,value:a}),getEffects:()=>e,clean:()=>{e=[]}}},Z=class extends r.Disposable{constructor(e,t,n,r,i){super(),this._sheetInterceptorService=e,this._numfmtService=t,this._univerInstanceService=n,this._injector=r,this._editorBridgeService=i,_(this,`_collectEffectMutation`,ze()),this._initInterceptorEditorStart(),this._initInterceptorEditorEnd(),this._initInterceptorCommands()}_initInterceptorEditorStart(){this._editorBridgeService&&this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.BEFORE_CELL_EDIT,{handler:(e,n,i)=>{let a=n.row,o=n.col,s=this._numfmtService.getValue(n.unitId,n.subUnitId,a,o);if(s)switch((0,t.getPatternType)(s.pattern)){case`scientific`:case`currency`:case`grouped`:case`number`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=(0,f.stripErrorMargin)(Number(e.v))),i&&i(e)}case`percent`:{let e={...n.worksheet.getCellRaw(a,o)};return(e==null?void 0:e.t)===r.CellValueType.NUMBER&&(0,r.isRealNum)(e.v)&&(e.v=`${(0,f.stripErrorMargin)(Number(e.v)*100)}%`),i&&i(e)}default:return i&&i(e)}return i(e)}})))}_initInterceptorEditorEnd(){this.disposeWithMe((0,r.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(a.AFTER_CELL_EDIT,{handler:(e,n,i)=>{var a,o;if(!(e!=null&&e.v)&&!(e!=null&&e.p))return i(e);this._collectEffectMutation.clean();let s=this._numfmtService.getValue(n.unitId,n.subUnitId,n.row,n.col),c=n.worksheet.getCellRaw(n.row,n.col);if((0,r.isTextFormat)(s==null?void 0:s.pattern)||e.t===r.CellValueType.FORCE_STRING)return i(e);let l=(a=e.p)==null?void 0:a.body,u=!(e==null||(o=e.p)==null||(o=o.body)==null)&&o.dataStream?e.p.body.dataStream.replace(/\r\n$/,``):String(e.v),d=(0,r.getNumfmtParseValueFilter)(u);if(l)if(Be(l)){let{dataStream:t}=l,n=t.replace(/\r\n$/,``),r=Number(n);if(Number.isNaN(r)&&!d)return i(e)}else return i(e);if(d){if(!d.z&&!(s!=null&&s.pattern)&&(c==null?void 0:c.t)!==r.CellValueType.STRING&&(c==null?void 0:c.t)!==r.CellValueType.FORCE_STRING&&(0,r.willLoseNumericPrecision)(u))return i({...e,p:void 0,v:u,t:r.CellValueType.FORCE_STRING});d.z&&(!(s!=null&&s.pattern)||(0,t.getPatternType)(d.z)!==(0,t.getPatternType)(s.pattern))&&this._collectEffectMutation.add(n.unitId,n.subUnitId,n.row,n.col,{pattern:d.z});let a=(0,f.stripErrorMargin)(Number(d.v),16);return i({...e,p:void 0,v:a,t:r.CellValueType.NUMBER})}return i(e)}})))}_initInterceptorCommands(){let e=this;this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations(t){switch(t.id){case a.SetRangeValuesCommand.id:{var n;let t=e._univerInstanceService.getCurrentUnitOfType(r.UniverInstanceType.UNIVER_SHEET),i=t.getUnitId(),o=(n=t.getActiveSheet())==null?void 0:n.getSheetId();if(!o)return{redos:[],undos:[]};let s=e._collectEffectMutation.getEffects();if(e._collectEffectMutation.clean(),!s.length)return{redos:[],undos:[]};let c=s.filter(e=>{var t;return!!((t=e.value)!=null&&t.pattern)}).map(e=>({row:e.row,col:e.col,pattern:e.value.pattern})),l=s.filter(e=>{var t;return!((t=e.value)!=null&&t.pattern)}).map(e=>({startRow:e.row,endColumn:e.col,startColumn:e.col,endRow:e.row})),u=[],d=[];if(c.length){let t={id:a.SetNumfmtMutation.id,params:(0,a.transformCellsToRange)(i,o,c)};u.push(t),d.push(...(0,a.factorySetNumfmtUndoMutation)(e._injector,t.params))}if(l.length){let t={id:a.RemoveNumfmtMutation.id,params:{unitId:i,subUnitId:o,ranges:l}};u.push(t),d.push(...(0,a.factoryRemoveNumfmtUndoMutation)(e._injector,t.params))}return{redos:u,undos:d.reverse()}}}return{redos:[],undos:[]}}}))}dispose(){super.dispose(),this._collectEffectMutation.clean()}};Z=y([v(0,(0,r.Inject)(a.SheetInterceptorService)),v(1,(0,r.Inject)(a.INumfmtService)),v(2,(0,r.Inject)(r.IUniverInstanceService)),v(3,(0,r.Inject)(r.Injector)),v(4,(0,r.Optional)(o.IEditorBridgeService))],Z);function Be(e){let{textRuns:t=[],paragraphs:n=[],customRanges:r,customBlocks:i=[]}=e,a=[`va`];return!(t.some(e=>!!(e.ts&&Object.keys(e.ts).some(e=>a.includes(e))))||n.some(e=>e.bullet)||n.length>=2||r!=null&&r.length||i.length>0)}let Q=class extends r.Disposable{constructor(e){super(),this._menuManagerService=e,this._initMenu()}_initMenu(){this._menuManagerService.mergeMenu(re)}};Q=y([v(0,n.IMenuManagerService)],Q);let $=class extends r.Plugin{constructor(e=oe,t,n,i){super(),this._config=e,this._injector=t,this._configService=n,this._renderManagerService=i;let{menu:a,...o}=(0,r.merge)({},oe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(`sheets-numfmt-ui.config`,o)}onStarting(){this._injector.add([q]),this._injector.get(q),(0,r.registerDependencies)(this._injector,[[b],[Z],[W],[Q],[X]])}onRendered(){this._registerRenderModules(),(0,r.touchDependencies)(this._injector,[[b],[Z],[Q],[X]])}_registerRenderModules(){[[Y]].forEach(e=>{this.disposeWithMe(this._renderManagerService.registerRenderModule(r.UniverInstanceType.UNIVER_SHEET,e))})}};_($,`pluginName`,`SHEET_NUMFMT_UI_PLUGIN`),_($,`packageName`,ie),_($,`version`,ae),_($,`type`,r.UniverInstanceType.UNIVER_SHEET),$=y([(0,r.DependentOn)(o.UniverSheetsUIPlugin,t.UniverSheetsNumfmtPlugin),v(1,(0,r.Inject)(r.Injector)),v(2,r.IConfigService),v(3,i.IRenderManagerService)],$),e.SheetsNumfmtUIMenuSchema=re,Object.defineProperty(e,"UniverSheetsNumfmtUIPlugin",{enumerable:!0,get:function(){return $}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-numfmt-ui",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Number format menus, editors, and previews for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,15 +58,15 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/core": "1.0.0-alpha.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/engine-render": "1.0.0-alpha.
|
|
65
|
-
"@univerjs/
|
|
66
|
-
"@univerjs/sheets
|
|
67
|
-
"@univerjs/sheets-
|
|
68
|
-
"@univerjs/ui": "1.0.0-alpha.
|
|
69
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/icons": "1.34.0",
|
|
62
|
+
"@univerjs/core": "1.0.0-alpha.7",
|
|
63
|
+
"@univerjs/engine-formula": "1.0.0-alpha.7",
|
|
64
|
+
"@univerjs/engine-render": "1.0.0-alpha.7",
|
|
65
|
+
"@univerjs/design": "1.0.0-alpha.7",
|
|
66
|
+
"@univerjs/sheets": "1.0.0-alpha.7",
|
|
67
|
+
"@univerjs/sheets-numfmt": "1.0.0-alpha.7",
|
|
68
|
+
"@univerjs/ui": "1.0.0-alpha.7",
|
|
69
|
+
"@univerjs/sheets-ui": "1.0.0-alpha.7"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"postcss": "^8.5.19",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"tailwindcss": "3.4.18",
|
|
76
76
|
"typescript": "^6.0.3",
|
|
77
77
|
"vitest": "^4.1.10",
|
|
78
|
-
"@univerjs-infra/shared": "1.0.0-alpha.
|
|
78
|
+
"@univerjs-infra/shared": "1.0.0-alpha.7"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"test": "vitest run",
|