@univerjs/sheets-numfmt 0.2.8 → 0.2.9

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/es/index.js CHANGED
@@ -2,16 +2,16 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 != "symbol" ? key2 + "" : key2, value);
5
- import { numfmt, LocaleType, Disposable, ObjectMatrix, CellValueType, Range, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, ThemeService, ICommandService, LocaleService, IUniverInstanceService, CommandType, IUndoRedoService, sequenceExecute, createIdentifier, runOnLifecycle, ILocalStorageService, useDependency, toDisposable, DisposableCollection, Injector, Optional, useInjector, Plugin, Tools, DependentOn } from "@univerjs/core";
6
- import { INTERCEPTOR_POINT, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService, INumfmtService, getSheetCommandTarget, transformCellsToRange, rangeMerge, factorySetNumfmtUndoMutation, RemoveNumfmtMutation, factoryRemoveNumfmtUndoMutation, SheetsSelectionsService, SetRangeValuesCommand, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint, UniverSheetsPlugin } from "@univerjs/sheets";
7
- import { SheetSkeletonManagerService, IEditorBridgeService, getCurrentRangeDisable$, deriveStateFromActiveSheet$, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
8
- import { switchMap, of, skip, Observable, combineLatest, merge } from "rxjs";
9
- import { IRenderManagerService, ITextSelectionRenderManager } from "@univerjs/engine-render";
10
- import { ComponentManager, ISidebarService, MenuItemType, MenuGroup, MenuPosition, getMenuHiddenObservable, IMenuService } from "@univerjs/ui";
5
+ import { numfmt, LocaleType, Disposable, ObjectMatrix, CellValueType, Range, UniverInstanceType, OnLifecycle, LifecycleStages, Inject, ThemeService, ICommandService, LocaleService, IUniverInstanceService, CommandType, IUndoRedoService, sequenceExecute, createIdentifier, runOnLifecycle, useDependency, useInjector, Injector, ILocalStorageService, toDisposable, DisposableCollection, Optional, Plugin, Tools, DependentOn } from "@univerjs/core";
6
+ import { INTERCEPTOR_POINT, InterceptCellContentPriority, SetNumfmtMutation, SetRangeValuesMutation, SheetInterceptorService, INumfmtService, getSheetCommandTarget, transformCellsToRange, rangeMerge, factorySetNumfmtUndoMutation, RemoveNumfmtMutation, factoryRemoveNumfmtUndoMutation, SheetsSelectionsService, WorkbookEditablePermission, WorksheetEditPermission, WorksheetSetCellStylePermission, RangeProtectionPermissionEditPoint, SetRangeValuesCommand, UniverSheetsPlugin } from "@univerjs/sheets";
7
+ import { getCurrentRangeDisable$, deriveStateFromActiveSheet$, SheetSkeletonManagerService, IEditorBridgeService, UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
8
+ import { switchMap, of, skip, Observable, merge, BehaviorSubject, combineLatest } from "rxjs";
9
+ import { ITextSelectionRenderManager, IRenderManagerService } from "@univerjs/engine-render";
10
+ import { MenuItemType, MenuGroup, MenuPosition, getMenuHiddenObservable, ComponentManager, IMenuService, ISidebarService } from "@univerjs/ui";
11
11
  import { map, switchMap as switchMap$1, tap, debounceTime } from "rxjs/operators";
12
+ import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
12
13
  import require$$0, { createContext, useState, useEffect, useRef, useContext, useMemo, forwardRef, createElement } from "react";
13
14
  import { InputNumber, Select, SelectList, Input, Button } from "@univerjs/design";
14
- import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
15
15
  const SHEET_NUMFMT_PLUGIN = "SHEET_NUMFMT_PLUGIN", getPatternType = /* @__PURE__ */ __name((pattern) => numfmt.getInfo(pattern).type || "unknown", "getPatternType"), getPatternPreview = /* @__PURE__ */ __name((pattern, value, _locale) => {
16
16
  const info = numfmt.getInfo(pattern), locale = _locale === LocaleType.ZH_CN ? "zh-CN" : "en", negInfo = info._partitions[1], result = numfmt.format(pattern, value, { locale });
17
17
  return value < 0 ? {
@@ -63,7 +63,7 @@ let SheetsNumfmtCellContentController = (_a = class extends Disposable {
63
63
  parameters: `${originCellValue.v}_${numfmtValue.pattern}`
64
64
  }), next({ ...cell, ...res });
65
65
  }, "handler"),
66
- priority: 10
66
+ priority: InterceptCellContentPriority.NUMFMT
67
67
  })), this.disposeWithMe(this._commandService.onCommandExecuted((commandInfo) => {
68
68
  if (commandInfo.id === SetNumfmtMutation.id) {
69
69
  const params = commandInfo.params;
@@ -308,21 +308,128 @@ const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0)
308
308
  suffix: /* @__PURE__ */ __name((suffix) => `"${suffix}"#,##0.00_);[Red]-"${suffix}"#,##0.00`, "suffix"),
309
309
  color: "red"
310
310
  }
311
- ], SetCurrencyCommand = {
312
- id: "sheet.command.numfmt.set.currency",
313
- type: CommandType.COMMAND,
314
- handler: /* @__PURE__ */ __name(async (accessor) => {
315
- const commandService = accessor.get(ICommandService), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
316
- if (!selections || !selections.length)
317
- return !1;
318
- const values = [], suffix = CURRENCYFORMAT[0].suffix("¥");
319
- return selections.forEach((selection) => {
320
- Range.foreach(selection.range, (row, col) => {
321
- values.push({ row, col, pattern: suffix, type: "currency" });
322
- });
323
- }), await commandService.executeCommand(SetNumfmtCommand.id, { values });
324
- }, "handler")
325
- }, SubtractDecimalCommand = {
311
+ ], currencySymbols = [
312
+ "$",
313
+ "£",
314
+ "¥",
315
+ "¤",
316
+ "֏",
317
+ "؋",
318
+ "",
319
+ "฿",
320
+ // '៛',
321
+ "",
322
+ "₦",
323
+ "₩",
324
+ "",
325
+ "₫",
326
+ "€",
327
+ "₭",
328
+ "₮",
329
+ "₱",
330
+ "₲",
331
+ "₴",
332
+ "₸",
333
+ "₹",
334
+ "₺",
335
+ "₼",
336
+ "₽",
337
+ "₾",
338
+ "₿"
339
+ ], countryCurrencyMap = {
340
+ US: "$",
341
+ // United States Dollar
342
+ CA: "C$",
343
+ // Canadian Dollar
344
+ GB: "£",
345
+ // British Pound Sterling
346
+ JP: "¥",
347
+ // Japanese Yen
348
+ IN: "₹",
349
+ // Indian Rupee
350
+ AU: "A$",
351
+ // Australian Dollar
352
+ CN: "¥",
353
+ // Chinese Yuan
354
+ KR: "₩",
355
+ // South Korean Won
356
+ RU: "₽",
357
+ // Russian Ruble
358
+ // Euro countries
359
+ AT: "€",
360
+ BE: "€",
361
+ CY: "€",
362
+ EE: "€",
363
+ FI: "€",
364
+ FR: "€",
365
+ DE: "€",
366
+ GR: "€",
367
+ IE: "€",
368
+ IT: "€",
369
+ LV: "€",
370
+ LT: "€",
371
+ LU: "€",
372
+ MT: "€",
373
+ NL: "€",
374
+ PT: "€",
375
+ SK: "€",
376
+ SI: "€",
377
+ ES: "€"
378
+ // Add more mappings as needed
379
+ }, MENU_OPTIONS = [
380
+ {
381
+ label: "sheet.numfmt.general",
382
+ pattern: null
383
+ },
384
+ {
385
+ label: "sheet.numfmt.text",
386
+ pattern: DEFAULT_TEXT_FORMAT
387
+ },
388
+ "|",
389
+ {
390
+ label: "sheet.numfmt.number",
391
+ pattern: "0"
392
+ },
393
+ "|",
394
+ {
395
+ label: "sheet.numfmt.accounting",
396
+ pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)'
397
+ },
398
+ {
399
+ label: "sheet.numfmt.financialValue",
400
+ pattern: "#,##0.00;[Red]#,##0.00"
401
+ },
402
+ {
403
+ label: "sheet.numfmt.currency",
404
+ pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)'
405
+ },
406
+ {
407
+ label: "sheet.numfmt.roundingCurrency",
408
+ pattern: '"¥"#,##0;[Red]"¥"#,##0'
409
+ },
410
+ "|",
411
+ {
412
+ label: "sheet.numfmt.date",
413
+ pattern: "yyyy-mm-dd;@"
414
+ },
415
+ {
416
+ label: "sheet.numfmt.time",
417
+ pattern: 'am/pm h":"mm":"ss'
418
+ },
419
+ {
420
+ label: "sheet.numfmt.dateTime",
421
+ pattern: "yyyy-m-d am/pm h:mm"
422
+ },
423
+ {
424
+ label: "sheet.numfmt.timeDuration",
425
+ pattern: "h:mm:ss"
426
+ },
427
+ "|",
428
+ {
429
+ label: "sheet.numfmt.moreFmt",
430
+ pattern: ""
431
+ }
432
+ ], SubtractDecimalCommand = {
326
433
  id: "sheet.command.numfmt.subtract.decimal.command",
327
434
  type: CommandType.COMMAND,
328
435
  handler: /* @__PURE__ */ __name(async (accessor) => {
@@ -363,13 +470,6 @@ const getDecimalFromPattern = /* @__PURE__ */ __name((pattern, defaultValue = 0)
363
470
  });
364
471
  }), await commandService.executeCommand(SetNumfmtCommand.id, { values });
365
472
  }, "handler")
366
- }, CloseNumfmtPanelOperator = {
367
- id: "sheet.operation.close.numfmt.panel",
368
- type: CommandType.OPERATION,
369
- handler: /* @__PURE__ */ __name(() => (
370
- // do nothing,just notify panel is closed
371
- !0
372
- ), "handler")
373
473
  }, INumfmtController = createIdentifier("INumfmtController");
374
474
  runOnLifecycle(LifecycleStages.Rendered, INumfmtController);
375
475
  const OpenNumfmtPanelOperator = {
@@ -401,41 +501,223 @@ reactJsxRuntime_production_min.jsx = q;
401
501
  reactJsxRuntime_production_min.jsxs = q;
402
502
  jsxRuntime.exports = reactJsxRuntime_production_min;
403
503
  var jsxRuntimeExports = jsxRuntime.exports;
404
- const UserHabitCurrencyContext = createContext([]), currencySymbols = [
405
- "$",
406
- "£",
407
- "¥",
408
- "¤",
409
- "֏",
410
- "؋",
411
- "৳",
412
- "฿",
413
- // '៛',
414
- "₡",
415
- "₦",
416
- "₩",
417
- "",
418
- "₫",
419
- "€",
420
- "₭",
421
- "₮",
422
- "₱",
423
- "₲",
424
- "₴",
425
- "₸",
426
- "",
427
- "",
428
- "",
429
- "₽",
430
- "",
431
- "₿"
432
- ];
504
+ const MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType", OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options", MoreNumfmtType = /* @__PURE__ */ __name((props) => {
505
+ var _a8;
506
+ const localeService = useDependency(LocaleService), value = (_a8 = props.value) != null ? _a8 : localeService.t("sheet.numfmt.general");
507
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "more-numfmt-type", children: value });
508
+ }, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
509
+ const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), injector = useInjector(), selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
510
+ const selection = selectionManagerService.getCurrentLastSelection();
511
+ if (!selection)
512
+ return;
513
+ const textSelectionRenderManager = injector.get(ITextSelectionRenderManager), range = selection.range, values = [];
514
+ Range.foreach(range, (row, col) => {
515
+ pattern ? values.push({ row, col, pattern, type: getPatternType(pattern) }) : values.push({ row, col });
516
+ }), commandService.executeCommand(SetNumfmtCommand.id, { values }), textSelectionRenderManager.focus();
517
+ }, "setNumfmt"), handleOnclick = /* @__PURE__ */ __name((index) => {
518
+ if (index === 0)
519
+ setNumfmt(null);
520
+ else if (index === MENU_OPTIONS.length - 1)
521
+ commandService.executeCommand(OpenNumfmtPanelOperator.id);
522
+ else {
523
+ const item = MENU_OPTIONS[index];
524
+ item.pattern && setNumfmt(item.pattern);
525
+ }
526
+ }, "handleOnclick"), defaultValue = 1220;
527
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "more-numfmt-type-options", children: MENU_OPTIONS.map((item, index) => item === "|" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "line m-t-4", onClick: /* @__PURE__ */ __name((e) => e.stopPropagation(), "onClick") }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
528
+ "div",
529
+ {
530
+ className: "option-item m-t-4",
531
+ onClick: /* @__PURE__ */ __name(() => {
532
+ handleOnclick(index);
533
+ }, "onClick"),
534
+ children: [
535
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t(item.label) }),
536
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-l-26", children: item.pattern ? getPatternPreview(item.pattern || "", defaultValue, localeService.getCurrentLocale()).result : "" })
537
+ ]
538
+ },
539
+ index
540
+ )) });
541
+ }, "Options"), SetPercentCommand = {
542
+ id: "sheet.command.numfmt.set.percent",
543
+ type: CommandType.COMMAND,
544
+ handler: /* @__PURE__ */ __name(async (accessor) => {
545
+ const commandService = accessor.get(ICommandService), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
546
+ if (!selections || !selections.length)
547
+ return !1;
548
+ const values = [], suffix = "0%";
549
+ return selections.forEach((selection) => {
550
+ Range.foreach(selection.range, (row, col) => {
551
+ values.push({ row, col, pattern: suffix, type: "percent" });
552
+ });
553
+ }), await commandService.executeCommand(SetNumfmtCommand.id, { values });
554
+ }, "handler")
555
+ }, CurrencyMenuItem = /* @__PURE__ */ __name((accessor) => ({
556
+ icon: new Observable((subscribe) => {
557
+ const numfmtMenuController = accessor.get(NumfmtMenuController);
558
+ function getIconKey(symbol2) {
559
+ return {
560
+ [countryCurrencyMap.US]: "DollarSingle",
561
+ [countryCurrencyMap.RU]: "RoubleSingle",
562
+ [countryCurrencyMap.CN]: "RmbSingle",
563
+ [countryCurrencyMap.AT]: "EuroSingle"
564
+ }[symbol2] || "DollarSingle";
565
+ }
566
+ __name(getIconKey, "getIconKey");
567
+ const symbol = countryCurrencyMap[numfmtMenuController.getCurrencySymbol()] || "$";
568
+ return subscribe.next(getIconKey(symbol)), numfmtMenuController.currencySymbol$.subscribe((code) => {
569
+ const symbol2 = countryCurrencyMap[code] || "$";
570
+ subscribe.next(getIconKey(symbol2));
571
+ });
572
+ }),
573
+ id: SetCurrencyCommand.id,
574
+ title: "sheet.numfmt.currency",
575
+ tooltip: "sheet.numfmt.currency",
576
+ type: MenuItemType.BUTTON,
577
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
578
+ positions: [MenuPosition.TOOLBAR_START],
579
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
580
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
581
+ }), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
582
+ icon: "AddDigitsSingle",
583
+ id: AddDecimalCommand.id,
584
+ title: "sheet.numfmt.addDecimal",
585
+ tooltip: "sheet.numfmt.addDecimal",
586
+ type: MenuItemType.BUTTON,
587
+ positions: [MenuPosition.TOOLBAR_START],
588
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
589
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
590
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
591
+ }), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
592
+ icon: "ReduceDigitsSingle",
593
+ id: SubtractDecimalCommand.id,
594
+ title: "sheet.numfmt.subtractDecimal",
595
+ tooltip: "sheet.numfmt.subtractDecimal",
596
+ type: MenuItemType.BUTTON,
597
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
598
+ positions: [MenuPosition.TOOLBAR_START],
599
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
600
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
601
+ }), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
602
+ icon: "PercentSingle",
603
+ id: SetPercentCommand.id,
604
+ title: "sheet.numfmt.percent",
605
+ tooltip: "sheet.numfmt.percent",
606
+ type: MenuItemType.BUTTON,
607
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
608
+ positions: [MenuPosition.TOOLBAR_START],
609
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
610
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
611
+ }), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
612
+ const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), localeService = accessor.get(LocaleService), selectionManagerService = accessor.get(SheetsSelectionsService), value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable(
613
+ (subscribe) => merge(
614
+ selectionManagerService.selectionMoveEnd$,
615
+ new Observable((commandSubscribe) => {
616
+ const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id], disposable = commandService.onCommandExecuted((commandInfo) => {
617
+ commandList.includes(commandInfo.id) && commandSubscribe.next(null);
618
+ });
619
+ return () => disposable.dispose();
620
+ })
621
+ ).subscribe(() => {
622
+ var _a8, _b;
623
+ const selections = selectionManagerService.getCurrentSelections();
624
+ if (selections && selections[0]) {
625
+ const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((_a8 = worksheet.getCell(row, col)) == null ? void 0 : _a8.s)) == null ? void 0 : _b.n, pattern = numfmtValue == null ? void 0 : numfmtValue.pattern;
626
+ let value = localeService.t("sheet.numfmt.general");
627
+ if (pattern) {
628
+ const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
629
+ (item2) => isPatternEqualWithoutDecimal(pattern, item2.pattern)
630
+ );
631
+ item && typeof item == "object" && item.pattern ? value = localeService.t(item.label) : value = localeService.t("sheet.numfmt.moreFmt");
632
+ }
633
+ subscribe.next(value);
634
+ }
635
+ })
636
+ ));
637
+ return {
638
+ label: MORE_NUMFMT_TYPE_KEY,
639
+ id: OpenNumfmtPanelOperator.id,
640
+ tooltip: "sheet.numfmt.title",
641
+ type: MenuItemType.SELECTOR,
642
+ group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
643
+ positions: [MenuPosition.TOOLBAR_START],
644
+ selections: [
645
+ {
646
+ label: {
647
+ name: OPTIONS_KEY,
648
+ hoverable: !1
649
+ }
650
+ }
651
+ ],
652
+ value$,
653
+ hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
654
+ disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
655
+ };
656
+ }, "FactoryOtherMenuItem");
433
657
  var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
434
658
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
435
659
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
436
- return kind && result && __defProp$5(target, key2, result), result;
437
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5"), _a2;
438
- let UserHabitController = (_a2 = class {
660
+ return kind && result && __defProp$5(target, key2, result), result;
661
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$5");
662
+ const DefaultSheetNumfmtConfig = {};
663
+ var _a2;
664
+ let NumfmtMenuController = (_a2 = class extends Disposable {
665
+ constructor(_config, _injector, _componentManager, _menuService) {
666
+ super();
667
+ __publicField(this, "_currencySymbol$", new BehaviorSubject("US"));
668
+ __publicField(this, "currencySymbol$", this._currencySymbol$.asObservable());
669
+ this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._initMenu();
670
+ }
671
+ _initMenu() {
672
+ const { menu = {} } = this._config;
673
+ [PercentMenuItem, AddDecimalMenuItem, SubtractDecimalMenuItem, CurrencyMenuItem, FactoryOtherMenuItem].forEach((factory) => {
674
+ this.disposeWithMe(this._menuService.addMenuItem(factory(this._injector), menu));
675
+ }), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
676
+ }
677
+ /**
678
+ * Set the currency symbol by setting the country code.
679
+ */
680
+ setCurrencySymbolByCountryCode(symbol) {
681
+ this._currencySymbol$.next(symbol);
682
+ }
683
+ getCurrencySymbol() {
684
+ return this._currencySymbol$.getValue();
685
+ }
686
+ }, __name(_a2, "NumfmtMenuController"), _a2);
687
+ NumfmtMenuController = __decorateClass$5([
688
+ OnLifecycle(LifecycleStages.Rendered, NumfmtMenuController),
689
+ __decorateParam$5(1, Inject(Injector)),
690
+ __decorateParam$5(2, Inject(ComponentManager)),
691
+ __decorateParam$5(3, Inject(IMenuService))
692
+ ], NumfmtMenuController);
693
+ const SetCurrencyCommand = {
694
+ id: "sheet.command.numfmt.set.currency",
695
+ type: CommandType.COMMAND,
696
+ handler: /* @__PURE__ */ __name(async (accessor) => {
697
+ const commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), numfmtMenuController = accessor.get(NumfmtMenuController), symbol = countryCurrencyMap[numfmtMenuController.getCurrencySymbol()] || "$", selections = selectionManagerService.getCurrentSelections();
698
+ if (!selections || !selections.length)
699
+ return !1;
700
+ const values = [], suffix = CURRENCYFORMAT[0].suffix(symbol);
701
+ return selections.forEach((selection) => {
702
+ Range.foreach(selection.range, (row, col) => {
703
+ values.push({ row, col, pattern: suffix, type: "currency" });
704
+ });
705
+ }), await commandService.executeCommand(SetNumfmtCommand.id, { values });
706
+ }, "handler")
707
+ }, CloseNumfmtPanelOperator = {
708
+ id: "sheet.operation.close.numfmt.panel",
709
+ type: CommandType.OPERATION,
710
+ handler: /* @__PURE__ */ __name(() => (
711
+ // do nothing,just notify panel is closed
712
+ !0
713
+ ), "handler")
714
+ }, UserHabitCurrencyContext = createContext([]);
715
+ var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
716
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
717
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
718
+ return kind && result && __defProp$4(target, key2, result), result;
719
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4"), _a3;
720
+ let UserHabitController = (_a3 = class {
439
721
  constructor(_localStorageService) {
440
722
  this._localStorageService = _localStorageService;
441
723
  }
@@ -478,9 +760,9 @@ let UserHabitController = (_a2 = class {
478
760
  deleteHabit(habit) {
479
761
  this._localStorageService.removeItem(habit);
480
762
  }
481
- }, __name(_a2, "UserHabitController"), _a2);
482
- UserHabitController = __decorateClass$5([
483
- __decorateParam$5(0, Inject(ILocalStorageService))
763
+ }, __name(_a3, "UserHabitController"), _a3);
764
+ UserHabitController = __decorateClass$4([
765
+ __decorateParam$4(0, Inject(ILocalStorageService))
484
766
  ], UserHabitController);
485
767
  const key$1 = "numfmtCurrency", useCurrencyOptions = /* @__PURE__ */ __name((onOptionChange) => {
486
768
  const userHabitController = useDependency(UserHabitController), [options, optionsSet] = useState(currencySymbols);
@@ -764,27 +1046,13 @@ const SheetNumfmtPanel = /* @__PURE__ */ __name((props) => {
764
1046
  /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "primary", size: "small", onClick: handleConfirm, children: t("sheet.numfmt.confirm") })
765
1047
  ] })
766
1048
  ] });
767
- }, "SheetNumfmtPanel"), SetPercentCommand = {
768
- id: "sheet.command.numfmt.set.percent",
769
- type: CommandType.COMMAND,
770
- handler: /* @__PURE__ */ __name(async (accessor) => {
771
- const commandService = accessor.get(ICommandService), selections = accessor.get(SheetsSelectionsService).getCurrentSelections();
772
- if (!selections || !selections.length)
773
- return !1;
774
- const values = [], suffix = "0%";
775
- return selections.forEach((selection) => {
776
- Range.foreach(selection.range, (row, col) => {
777
- values.push({ row, col, pattern: suffix, type: "percent" });
778
- });
779
- }), await commandService.executeCommand(SetNumfmtCommand.id, { values });
780
- }, "handler")
781
- };
782
- var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
783
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1049
+ }, "SheetNumfmtPanel");
1050
+ var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1051
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
784
1052
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
785
- return kind && result && __defProp$4(target, key2, result), result;
786
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$4"), _a3;
787
- let NumfmtController = (_a3 = class extends Disposable {
1053
+ return kind && result && __defProp$3(target, key2, result), result;
1054
+ }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3"), _a4;
1055
+ let NumfmtController = (_a4 = class extends Disposable {
788
1056
  constructor(_sheetInterceptorService, _themeService, _univerInstanceService, _commandService, _selectionManagerService, _renderManagerService, _numfmtService, _componentManager, _sidebarService, _localeService) {
789
1057
  super();
790
1058
  /**
@@ -952,25 +1220,25 @@ let NumfmtController = (_a3 = class extends Disposable {
952
1220
  unit || ((_a8 = this._sidebarDisposable) == null || _a8.dispose(), this._sidebarDisposable = null);
953
1221
  });
954
1222
  }
955
- }, __name(_a3, "NumfmtController"), _a3);
956
- NumfmtController = __decorateClass$4([
1223
+ }, __name(_a4, "NumfmtController"), _a4);
1224
+ NumfmtController = __decorateClass$3([
957
1225
  OnLifecycle(LifecycleStages.Rendered, NumfmtController),
958
- __decorateParam$4(0, Inject(SheetInterceptorService)),
959
- __decorateParam$4(1, Inject(ThemeService)),
960
- __decorateParam$4(2, IUniverInstanceService),
961
- __decorateParam$4(3, ICommandService),
962
- __decorateParam$4(4, Inject(SheetsSelectionsService)),
963
- __decorateParam$4(5, IRenderManagerService),
964
- __decorateParam$4(6, INumfmtService),
965
- __decorateParam$4(7, Inject(ComponentManager)),
966
- __decorateParam$4(8, ISidebarService),
967
- __decorateParam$4(9, Inject(LocaleService))
1226
+ __decorateParam$3(0, Inject(SheetInterceptorService)),
1227
+ __decorateParam$3(1, Inject(ThemeService)),
1228
+ __decorateParam$3(2, IUniverInstanceService),
1229
+ __decorateParam$3(3, ICommandService),
1230
+ __decorateParam$3(4, Inject(SheetsSelectionsService)),
1231
+ __decorateParam$3(5, IRenderManagerService),
1232
+ __decorateParam$3(6, INumfmtService),
1233
+ __decorateParam$3(7, Inject(ComponentManager)),
1234
+ __decorateParam$3(8, ISidebarService),
1235
+ __decorateParam$3(9, Inject(LocaleService))
968
1236
  ], NumfmtController);
969
- var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
970
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1237
+ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1238
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
971
1239
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
972
- return kind && result && __defProp$3(target, key2, result), result;
973
- }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$3");
1240
+ return kind && result && __defProp$2(target, key2, result), result;
1241
+ }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2");
974
1242
  const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
975
1243
  let list = [];
976
1244
  return {
@@ -981,8 +1249,8 @@ const createCollectEffectMutation = /* @__PURE__ */ __name(() => {
981
1249
  }, "clean")
982
1250
  };
983
1251
  }, "createCollectEffectMutation");
984
- var _a4;
985
- let NumfmtEditorController = (_a4 = class extends Disposable {
1252
+ var _a5;
1253
+ let NumfmtEditorController = (_a5 = class extends Disposable {
986
1254
  constructor(_sheetInterceptorService, _numfmtService, _univerInstanceService, _injector, _editorBridgeService) {
987
1255
  super();
988
1256
  // collect effect mutations when edit end and push this to commands stack in next commands progress
@@ -1143,234 +1411,33 @@ let NumfmtEditorController = (_a4 = class extends Disposable {
1143
1411
  })
1144
1412
  );
1145
1413
  }
1146
- }, __name(_a4, "NumfmtEditorController"), _a4);
1147
- NumfmtEditorController = __decorateClass$3([
1414
+ }, __name(_a5, "NumfmtEditorController"), _a5);
1415
+ NumfmtEditorController = __decorateClass$2([
1148
1416
  OnLifecycle(LifecycleStages.Rendered, NumfmtEditorController),
1149
- __decorateParam$3(0, Inject(SheetInterceptorService)),
1150
- __decorateParam$3(1, Inject(INumfmtService)),
1151
- __decorateParam$3(2, Inject(IUniverInstanceService)),
1152
- __decorateParam$3(3, Inject(Injector)),
1153
- __decorateParam$3(4, Optional(IEditorBridgeService))
1417
+ __decorateParam$2(0, Inject(SheetInterceptorService)),
1418
+ __decorateParam$2(1, Inject(INumfmtService)),
1419
+ __decorateParam$2(2, Inject(IUniverInstanceService)),
1420
+ __decorateParam$2(3, Inject(Injector)),
1421
+ __decorateParam$2(4, Optional(IEditorBridgeService))
1154
1422
  ], NumfmtEditorController);
1155
1423
  function isNumeric(str) {
1156
1424
  return /^-?\d+(\.\d+)?$/.test(str);
1157
1425
  }
1158
1426
  __name(isNumeric, "isNumeric");
1159
- var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1160
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1427
+ var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1428
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1161
1429
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
1162
- return kind && result && __defProp$2(target, key2, result), result;
1163
- }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$2"), _a5;
1164
- let NumfmtI18nController = (_a5 = class extends Disposable {
1430
+ return kind && result && __defProp$1(target, key2, result), result;
1431
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1"), _a6;
1432
+ let NumfmtI18nController = (_a6 = class extends Disposable {
1165
1433
  constructor(_localeService) {
1166
1434
  super(), this._localeService = _localeService;
1167
1435
  }
1168
- }, __name(_a5, "NumfmtI18nController"), _a5);
1169
- NumfmtI18nController = __decorateClass$2([
1436
+ }, __name(_a6, "NumfmtI18nController"), _a6);
1437
+ NumfmtI18nController = __decorateClass$1([
1170
1438
  OnLifecycle(LifecycleStages.Rendered, NumfmtI18nController),
1171
- __decorateParam$2(0, Inject(LocaleService))
1439
+ __decorateParam$1(0, Inject(LocaleService))
1172
1440
  ], NumfmtI18nController);
1173
- const MENU_OPTIONS = [
1174
- {
1175
- label: "sheet.numfmt.general",
1176
- pattern: null
1177
- },
1178
- {
1179
- label: "sheet.numfmt.text",
1180
- pattern: DEFAULT_TEXT_FORMAT
1181
- },
1182
- "|",
1183
- {
1184
- label: "sheet.numfmt.number",
1185
- pattern: "0"
1186
- },
1187
- "|",
1188
- {
1189
- label: "sheet.numfmt.accounting",
1190
- pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)'
1191
- },
1192
- {
1193
- label: "sheet.numfmt.financialValue",
1194
- pattern: "#,##0.00;[Red]#,##0.00"
1195
- },
1196
- {
1197
- label: "sheet.numfmt.currency",
1198
- pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)'
1199
- },
1200
- {
1201
- label: "sheet.numfmt.roundingCurrency",
1202
- pattern: '"¥"#,##0;[Red]"¥"#,##0'
1203
- },
1204
- "|",
1205
- {
1206
- label: "sheet.numfmt.date",
1207
- pattern: "yyyy-mm-dd;@"
1208
- },
1209
- {
1210
- label: "sheet.numfmt.time",
1211
- pattern: 'am/pm h":"mm":"ss'
1212
- },
1213
- {
1214
- label: "sheet.numfmt.dateTime",
1215
- pattern: "yyyy-m-d am/pm h:mm"
1216
- },
1217
- {
1218
- label: "sheet.numfmt.timeDuration",
1219
- pattern: "h:mm:ss"
1220
- },
1221
- "|",
1222
- {
1223
- label: "sheet.numfmt.moreFmt",
1224
- pattern: ""
1225
- }
1226
- ], MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType", OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options", MoreNumfmtType = /* @__PURE__ */ __name((props) => {
1227
- var _a8;
1228
- const localeService = useDependency(LocaleService), value = (_a8 = props.value) != null ? _a8 : localeService.t("sheet.numfmt.general");
1229
- return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "more-numfmt-type", children: value });
1230
- }, "MoreNumfmtType"), Options = /* @__PURE__ */ __name(() => {
1231
- const commandService = useDependency(ICommandService), localeService = useDependency(LocaleService), injector = useInjector(), selectionManagerService = useDependency(SheetsSelectionsService), setNumfmt = /* @__PURE__ */ __name((pattern) => {
1232
- const selection = selectionManagerService.getCurrentLastSelection();
1233
- if (!selection)
1234
- return;
1235
- const textSelectionRenderManager = injector.get(ITextSelectionRenderManager), range = selection.range, values = [];
1236
- Range.foreach(range, (row, col) => {
1237
- pattern ? values.push({ row, col, pattern, type: getPatternType(pattern) }) : values.push({ row, col });
1238
- }), commandService.executeCommand(SetNumfmtCommand.id, { values }), textSelectionRenderManager.focus();
1239
- }, "setNumfmt"), handleOnclick = /* @__PURE__ */ __name((index) => {
1240
- if (index === 0)
1241
- setNumfmt(null);
1242
- else if (index === MENU_OPTIONS.length - 1)
1243
- commandService.executeCommand(OpenNumfmtPanelOperator.id);
1244
- else {
1245
- const item = MENU_OPTIONS[index];
1246
- item.pattern && setNumfmt(item.pattern);
1247
- }
1248
- }, "handleOnclick"), defaultValue = 1220;
1249
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "more-numfmt-type-options", children: MENU_OPTIONS.map((item, index) => item === "|" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "line m-t-4", onClick: /* @__PURE__ */ __name((e) => e.stopPropagation(), "onClick") }, index) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
1250
- "div",
1251
- {
1252
- className: "option-item m-t-4",
1253
- onClick: /* @__PURE__ */ __name(() => {
1254
- handleOnclick(index);
1255
- }, "onClick"),
1256
- children: [
1257
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: localeService.t(item.label) }),
1258
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "m-l-26", children: item.pattern ? getPatternPreview(item.pattern || "", defaultValue, localeService.getCurrentLocale()).result : "" })
1259
- ]
1260
- },
1261
- index
1262
- )) });
1263
- }, "Options"), CurrencyMenuItem = /* @__PURE__ */ __name((accessor) => ({
1264
- icon: "RmbSingle",
1265
- id: SetCurrencyCommand.id,
1266
- title: "sheet.numfmt.currency",
1267
- tooltip: "sheet.numfmt.currency",
1268
- type: MenuItemType.BUTTON,
1269
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1270
- positions: [MenuPosition.TOOLBAR_START],
1271
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1272
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1273
- }), "CurrencyMenuItem"), AddDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
1274
- icon: "AddDigitsSingle",
1275
- id: AddDecimalCommand.id,
1276
- title: "sheet.numfmt.addDecimal",
1277
- tooltip: "sheet.numfmt.addDecimal",
1278
- type: MenuItemType.BUTTON,
1279
- positions: [MenuPosition.TOOLBAR_START],
1280
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1281
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1282
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1283
- }), "AddDecimalMenuItem"), SubtractDecimalMenuItem = /* @__PURE__ */ __name((accessor) => ({
1284
- icon: "ReduceDigitsSingle",
1285
- id: SubtractDecimalCommand.id,
1286
- title: "sheet.numfmt.subtractDecimal",
1287
- tooltip: "sheet.numfmt.subtractDecimal",
1288
- type: MenuItemType.BUTTON,
1289
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1290
- positions: [MenuPosition.TOOLBAR_START],
1291
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1292
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1293
- }), "SubtractDecimalMenuItem"), PercentMenuItem = /* @__PURE__ */ __name((accessor) => ({
1294
- icon: "PercentSingle",
1295
- id: SetPercentCommand.id,
1296
- title: "sheet.numfmt.percent",
1297
- tooltip: "sheet.numfmt.percent",
1298
- type: MenuItemType.BUTTON,
1299
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1300
- positions: [MenuPosition.TOOLBAR_START],
1301
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1302
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1303
- }), "PercentMenuItem"), FactoryOtherMenuItem = /* @__PURE__ */ __name((accessor) => {
1304
- accessor.get(INumfmtService);
1305
- const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), localeService = accessor.get(LocaleService), selectionManagerService = accessor.get(SheetsSelectionsService), value$ = deriveStateFromActiveSheet$(univerInstanceService, "", ({ workbook, worksheet }) => new Observable(
1306
- (subscribe) => merge(
1307
- selectionManagerService.selectionMoveEnd$,
1308
- new Observable((commandSubscribe) => {
1309
- const commandList = [RemoveNumfmtMutation.id, SetNumfmtMutation.id], disposable = commandService.onCommandExecuted((commandInfo) => {
1310
- commandList.includes(commandInfo.id) && commandSubscribe.next(null);
1311
- });
1312
- return () => disposable.dispose();
1313
- })
1314
- ).subscribe(() => {
1315
- var _a8, _b;
1316
- const selections = selectionManagerService.getCurrentSelections();
1317
- if (selections && selections[0]) {
1318
- const range = selections[0].range, row = range.startRow, col = range.startColumn, numfmtValue = (_b = workbook.getStyles().get((_a8 = worksheet.getCell(row, col)) == null ? void 0 : _a8.s)) == null ? void 0 : _b.n, pattern = numfmtValue == null ? void 0 : numfmtValue.pattern;
1319
- let value = localeService.t("sheet.numfmt.general");
1320
- if (pattern) {
1321
- const item = MENU_OPTIONS.filter((item2) => typeof item2 == "object" && item2.pattern).find(
1322
- (item2) => isPatternEqualWithoutDecimal(pattern, item2.pattern)
1323
- );
1324
- item && typeof item == "object" && item.pattern ? value = localeService.t(item.label) : value = localeService.t("sheet.numfmt.moreFmt");
1325
- }
1326
- subscribe.next(value);
1327
- }
1328
- })
1329
- ));
1330
- return {
1331
- label: MORE_NUMFMT_TYPE_KEY,
1332
- id: OpenNumfmtPanelOperator.id,
1333
- tooltip: "sheet.numfmt.title",
1334
- type: MenuItemType.SELECTOR,
1335
- group: MenuGroup.TOOLBAR_FORMULAS_INSERT,
1336
- positions: [MenuPosition.TOOLBAR_START],
1337
- selections: [
1338
- {
1339
- label: {
1340
- name: OPTIONS_KEY,
1341
- hoverable: !1
1342
- }
1343
- }
1344
- ],
1345
- value$,
1346
- hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
1347
- disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetSetCellStylePermission, WorksheetEditPermission], rangeTypes: [RangeProtectionPermissionEditPoint] })
1348
- };
1349
- }, "FactoryOtherMenuItem");
1350
- var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1351
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1352
- (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
1353
- return kind && result && __defProp$1(target, key2, result), result;
1354
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key2) => decorator(target, key2, index), "__decorateParam$1");
1355
- const DefaultSheetNumfmtConfig = {};
1356
- var _a6;
1357
- let NumfmtMenuController = (_a6 = class extends Disposable {
1358
- constructor(_config, _injector, _componentManager, _menuService) {
1359
- super(), this._config = _config, this._injector = _injector, this._componentManager = _componentManager, this._menuService = _menuService, this._initMenu();
1360
- }
1361
- _initMenu() {
1362
- const { menu = {} } = this._config;
1363
- [PercentMenuItem, AddDecimalMenuItem, SubtractDecimalMenuItem, CurrencyMenuItem, FactoryOtherMenuItem].forEach((factory) => {
1364
- this.disposeWithMe(this._menuService.addMenuItem(factory(this._injector), menu));
1365
- }), this.disposeWithMe(this._componentManager.register(MORE_NUMFMT_TYPE_KEY, MoreNumfmtType)), this.disposeWithMe(this._componentManager.register(OPTIONS_KEY, Options));
1366
- }
1367
- }, __name(_a6, "NumfmtMenuController"), _a6);
1368
- NumfmtMenuController = __decorateClass$1([
1369
- OnLifecycle(LifecycleStages.Rendered, NumfmtMenuController),
1370
- __decorateParam$1(1, Inject(Injector)),
1371
- __decorateParam$1(2, Inject(ComponentManager)),
1372
- __decorateParam$1(3, Inject(IMenuService))
1373
- ], NumfmtMenuController);
1374
1441
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key2, value) => key2 in obj ? __defProp2(obj, key2, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key2] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key2, kind) => {
1375
1442
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key2) : target, i = decorators.length - 1, decorator; i >= 0; i--)
1376
1443
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key2, result) : decorator(result)) || result);
@@ -1400,11 +1467,13 @@ UniverSheetsNumfmtPlugin = __decorateClass([
1400
1467
  export {
1401
1468
  AddDecimalCommand,
1402
1469
  CloseNumfmtPanelOperator,
1470
+ NumfmtMenuController,
1403
1471
  OpenNumfmtPanelOperator,
1404
1472
  SetCurrencyCommand,
1405
1473
  SetNumfmtCommand,
1406
1474
  SetPercentCommand,
1407
1475
  SubtractDecimalCommand,
1408
1476
  UniverSheetsNumfmtPlugin,
1477
+ countryCurrencyMap,
1409
1478
  getPatternPreview
1410
1479
  };