Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat: optimize the currency format in the built-in menu to the one corresponding to the language pack. (#5688)

wpxp1234560cda1d120394
diff --git a/examples/src/sheets/main.ts b/examples/src/sheets/main.ts
index e732762c7f..e5e409c8fd 100644
--- a/examples/src/sheets/main.ts
+++ b/examples/src/sheets/main.ts
@@ -22,7 +22,16 @@ import { UniverDocsUIPlugin } from '@univerjs/docs-ui';
import { UniverFormulaEnginePlugin } from '@univerjs/engine-formula';
import { UniverRenderEnginePlugin } from '@univerjs/engine-render';
import { DEFAULT_WORKBOOK_DATA_DEMO } from '@univerjs/mockdata';
+import caES from '@univerjs/mockdata/locales/ca-ES';
+import enUS from '@univerjs/mockdata/locales/en-US';
+import esES from '@univerjs/mockdata/locales/es-ES';
+import faIR from '@univerjs/mockdata/locales/fa-IR';
+import frFR from '@univerjs/mockdata/locales/fr-FR';
+import koKR from '@univerjs/mockdata/locales/ko-KR';
+import ruRU from '@univerjs/mockdata/locales/ru-RU';
+import viVN from '@univerjs/mockdata/locales/vi-VN';
import zhCN from '@univerjs/mockdata/locales/zh-CN';
+import zhTW from '@univerjs/mockdata/locales/zh-TW';
import { UniverNetworkPlugin } from '@univerjs/network';
import { UniverRPCMainThreadPlugin } from '@univerjs/rpc';
import { UniverSheetsPlugin } from '@univerjs/sheets';
@@ -89,7 +98,16 @@ function createNewInstance() {
darkMode: localStorage.getItem('local.darkMode') === 'dark',
locale: LocaleType.ZH_CN,
locales: {
+ [LocaleType.CA_ES]: caES,
+ [LocaleType.EN_US]: enUS,
+ [LocaleType.ES_ES]: esES,
+ [LocaleType.FA_IR]: faIR,
+ [LocaleType.FR_FR]: frFR,
+ [LocaleType.KO_KR]: koKR,
+ [LocaleType.RU_RU]: ruRU,
+ [LocaleType.VI_VN]: viVN,
[LocaleType.ZH_CN]: zhCN,
+ [LocaleType.ZH_TW]: zhTW,
},
logLevel: LogLevel.VERBOSE,
});
diff --git a/packages/engine-formula/src/engine/utils/numfmt-kit.ts b/packages/engine-formula/src/engine/utils/numfmt-kit.ts
index fd2b19cc7a..51b47ffc3d 100644
--- a/packages/engine-formula/src/engine/utils/numfmt-kit.ts
+++ b/packages/engine-formula/src/engine/utils/numfmt-kit.ts
@@ -283,15 +283,9 @@ export function comparePatternPriority(previousPattern: string, nextPattern: str
/**
* Get the currency symbol based on the locale
- * Now define it here
- * TODO: import from sheet-numfmt currencySymbolMap later
- *
- * @param locale
- * @returns
*/
-const countryCurrencySymbolMap = new Map<LocaleType, string>([
+const localeCurrencySymbolMap = new Map<LocaleType, string>([
[LocaleType.EN_US, '$'],
- // [LocaleType.JA_JP, '¥'],
[LocaleType.RU_RU, '₽'],
[LocaleType.VI_VN, '₫'],
[LocaleType.ZH_CN, '¥'],
@@ -304,7 +298,7 @@ const countryCurrencySymbolMap = new Map<LocaleType, string>([
]);
function getCurrencySymbol(locale: LocaleType): string {
- return countryCurrencySymbolMap.get(locale) || '$';
+ return localeCurrencySymbolMap.get(locale) || '$';
}
export function getCurrencyFormat(locale: LocaleType, numberDigits: number = 2): string {
diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts b/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
index ac95bea3bd..d91f019055 100644
--- a/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/menu.schema.ts
@@ -18,13 +18,13 @@ import type { MenuSchemaType } from '@univerjs/ui';
import { AddDecimalCommand, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
import { RibbonDataGroup } from '@univerjs/ui';
import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
-import { AddDecimalMenuItem, CurrencyMenuItem, FactoryOtherMenuItem, PercentMenuItem, SubtractDecimalMenuItem } from './menu';
+import { AddDecimalMenuItem, CurrencySymbolIconMenuItem, FactoryOtherMenuItem, PercentMenuItem, SubtractDecimalMenuItem } from './menu';
export const menuSchema: MenuSchemaType = {
[RibbonDataGroup.FORMULAS]: {
[SetCurrencyCommand.id]: {
order: 0,
- menuItemFactory: CurrencyMenuItem,
+ menuItemFactory: CurrencySymbolIconMenuItem,
},
[AddDecimalCommand.id]: {
order: 1,
diff --git a/packages/sheets-numfmt-ui/src/controllers/menu.ts b/packages/sheets-numfmt-ui/src/controllers/menu.ts
index f48d635164..bd5a7ef9e0 100644
--- a/packages/sheets-numfmt-ui/src/controllers/menu.ts
+++ b/packages/sheets-numfmt-ui/src/controllers/menu.ts
@@ -26,94 +26,85 @@ import {
WorksheetEditPermission,
WorksheetSetCellStylePermission,
} from '@univerjs/sheets';
-import { AddDecimalCommand, countryCurrencyMap, MenuCurrencyService, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
+import { AddDecimalCommand, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, SetCurrencyCommand, SetPercentCommand, SubtractDecimalCommand } from '@univerjs/sheets-numfmt';
import { deriveStateFromActiveSheet$, getCurrentRangeDisable$ } from '@univerjs/sheets-ui';
import { getMenuHiddenObservable, MenuItemType } from '@univerjs/ui';
import { filter, merge, Observable } from 'rxjs';
import { OpenNumfmtPanelOperator } from '../commands/operations/open.numfmt.panel.operation';
import { MORE_NUMFMT_TYPE_KEY, OPTIONS_KEY } from '../views/components/MoreNumfmtType';
-export const MENU_OPTIONS: Array<{ label: string; pattern: string | null } | '|'> = [
- {
- label: 'sheet.numfmt.general',
- pattern: null,
- },
- {
- label: 'sheet.numfmt.text',
- pattern: DEFAULT_TEXT_FORMAT_EXCEL,
- },
- '|',
- {
- label: 'sheet.numfmt.number',
- pattern: '0',
- },
- {
- label: 'sheet.numfmt.percent',
- pattern: '0.00%',
- },
- {
- label: 'sheet.numfmt.scientific',
- pattern: '0.00E+00',
- },
- '|',
- {
- label: 'sheet.numfmt.accounting',
- pattern: '"¥" #,##0.00_);[Red]("¥"#,##0.00)',
- },
- {
- label: 'sheet.numfmt.financialValue',
- pattern: '#,##0.00;[Red]#,##0.00',
- },
- {
- label: 'sheet.numfmt.currency',
- pattern: '"¥"#,##0.00_);[Red]("¥"#,##0.00)',
- },
- {
- label: 'sheet.numfmt.roundingCurrency',
- pattern: '"¥"#,##0;[Red]"¥"#,##0',
- },
- '|',
- {
- label: 'sheet.numfmt.date',
- pattern: 'yyyy-mm-dd;@',
- },
- {
- label: 'sheet.numfmt.time',
- pattern: 'am/pm h":"mm":"ss',
- },
- {
- label: 'sheet.numfmt.dateTime',
- pattern: 'yyyy-m-d am/pm h:mm',
- },
- {
- label: 'sheet.numfmt.timeDuration',
- pattern: 'h:mm:ss',
- },
- '|',
- {
- label: 'sheet.numfmt.moreFmt',
- pattern: '',
- },
-];
+export const MENU_OPTIONS = (currencySymbol: string): Array<{ label: string; pattern: string | null } | '|'> => {
+ return [
+ {
+ label: 'sheet.numfmt.general',
+ pattern: null,
+ },
+ {
+ label: 'sheet.numfmt.text',
+ pattern: DEFAULT_TEXT_FORMAT_EXCEL,
+ },
+ '|',
+ {
+ label: 'sheet.numfmt.number',
+ pattern: '0',
+ },
+ {
+ label: 'sheet.numfmt.percent',
+ pattern: '0.00%',
+ },
+ {
+ label: 'sheet.numfmt.scientific',
+ pattern: '0.00E+00',
+ },
+ '|',
+ {
+ label: 'sheet.numfmt.accounting',
+ pattern: `"${currencySymbol}" #,##0.00_);[Red]("${currencySymbol}"#,##0.00)`,
+ },
+ {
+ label: 'sheet.numfmt.financialValue',
+ pattern: '#,##0.00;[Red]#,##0.00',
+ },
+ {
+ label: 'sheet.numfmt.currency',
+ pattern: `"${currencySymbol}"#,##0.00_);[Red]("${currencySymbol}"#,##0.00)`,
+ },
+ {
+ label: 'sheet.numfmt.roundingCurrency',
+ pattern: `"${currencySymbol}"#,##0;[Red]"${currencySymbol}"#,##0`,
+ },
+ '|',
+ {
+ label: 'sheet.numfmt.date',
+ pattern: 'yyyy-mm-dd;@',
+ },
+ {
+ label: 'sheet.numfmt.time',
+ pattern: 'am/pm h":"mm":"ss',
+ },
+ {
+ label: 'sheet.numfmt.dateTime',
+ pattern: 'yyyy-m-d am/pm h:mm',
+ },
+ {
+ label: 'sheet.numfmt.timeDuration',
+ pattern: 'h:mm:ss',
+ },
+ '|',
+ {
+ label: 'sheet.numfmt.moreFmt',
+ pattern: '',
+ },
+ ] as Array<{ label: string; pattern: string | null } | '|'>;
+};
-export const CurrencyMenuItem = (accessor: IAccessor) => {
+export const CurrencySymbolIconMenuItem = (accessor: IAccessor) => {
return {
icon: new Observable<string>((subscribe) => {
- const menuCurrencyService = accessor.get(MenuCurrencyService);
- function getIconKey(symbol: string) {
- const iconMap: Record<string, string> = {
- [countryCurrencyMap.US]: 'DollarIcon',
- [countryCurrencyMap.RU]: 'RoubleIcon',
- [countryCurrencyMap.CN]: 'RmbIcon',
- [countryCurrencyMap.AT]: 'EuroIcon',
- };
- return iconMap[symbol] ?? 'DollarIcon';
- }
- const symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] ?? '$';
- subscribe.next(getIconKey(symbol));
- return menuCurrencyService.currencySymbol$.subscribe((code) => {
- const symbol = countryCurrencyMap[code] ?? '$';
- subscribe.next(getIconKey(symbol));
+ const localeService = accessor.get(LocaleService);
+ subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
+ return localeService.localeChanged$.subscribe(() => {
+ subscribe.next(getCurrencySymbolIconByLocale(localeService.getCurrentLocale()).icon);
});
}),
id: SetCurrencyCommand.id,
@@ -122,7 +113,6 @@ export const CurrencyMenuItem = (accessor: IAccessor) => {
type: MenuItemType.BUTTON,
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
disabled$: getCurrentRangeDisable$(accessor, { workbookTypes: [WorkbookEditablePermission], worksheetTypes: [WorksheetEditPermission, WorksheetSetCellStylePermission], rangeTypes: [RangeProtectionPermissionEditPoint] }),
-
};
};
@@ -187,6 +177,7 @@ export const FactoryOtherMenuItem = (accessor: IAccessor): IMenuSelectorItem =>
const col = range.startColumn;
const numfmtValue = workbook.getStyles().get(worksheet.getCell(row, col)?.s)?.n;
const pattern = numfmtValue?.pattern;
+ const currencySymbol = getCurrencySymbolByLocale(localeService.getCurrentLocale());
// Adapts the 'General' obtained during import, or the 'General' set manually
let value: string = localeService.t('sheet.numfmt.general');
@@ -197,7 +188,7 @@ export const FactoryOtherMenuItem = (accessor: IAccessor): IMenuSelectorItem =>
}
if (pattern) {
- const item = MENU_OPTIONS.filter((item) => typeof item === 'object' && item.pattern).find(
+ const item = MENU_OPTIONS(currencySymbol).filter((item) => typeof item === 'object' && item.pattern).find(
(item) => isPatternEqualWithoutDecimal(pattern, (item as { pattern: string }).pattern)
);
if (item && typeof item === 'object' && item.pattern) {
diff --git a/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsx b/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsx
index ffc8210617..b394e3de6f 100644
--- a/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsx
+++ b/packages/sheets-numfmt-ui/src/views/components/MoreNumfmtType.tsx
@@ -18,8 +18,9 @@ import type { FormatType } from '@univerjs/sheets';
import { ICommandService, LocaleService, Range } from '@univerjs/core';
import { Separator } from '@univerjs/design';
import { SheetsSelectionsService } from '@univerjs/sheets';
-import { getPatternPreview, getPatternType, SetNumfmtCommand, SheetsNumfmtCellContentController } from '@univerjs/sheets-numfmt';
+import { getPatternPreview, getPatternType, localeCurrencySymbolMap, SetNumfmtCommand, SheetsNumfmtCellContentController } from '@univerjs/sheets-numfmt';
import { ILayoutService, useDependency } from '@univerjs/ui';
+import { useMemo } from 'react';
import { OpenNumfmtPanelOperator } from '../../commands/operations/open.numfmt.panel.operation';
import { MENU_OPTIONS } from '../../controllers/menu';
@@ -60,15 +61,20 @@ export const Options = () => {
layoutService.focus();
};
+
+ const menuOptions = useMemo(() => {
+ const currencySymbol = localeCurrencySymbolMap.get(localeService.getCurrentLocale()) as string;
+ return MENU_OPTIONS(currencySymbol);
+ }, [localeService]);
const handleOnclick = (index: number) => {
if (index === 0) {
setNumfmt(null);
- } else if (index === MENU_OPTIONS.length - 1) {
+ } else if (index === menuOptions.length - 1) {
// CATUION: This is a command, not a menu item
commandService.executeCommand(OpenNumfmtPanelOperator.id);
layoutService.focus();
} else {
- const item = MENU_OPTIONS[index] as { pattern: string };
+ const item = menuOptions[index] as { pattern: string };
item.pattern && setNumfmt(item.pattern);
}
};
@@ -77,7 +83,7 @@ export const Options = () => {
return (
<div className="univer-grid univer-gap-1 univer-p-1.5">
- {MENU_OPTIONS.map((item, index) => {
+ {menuOptions.map((item, index) => {
if (item === '|') {
return <Separator key={index} />;
}
diff --git a/packages/sheets-numfmt/src/base/const/currency-symbols.ts b/packages/sheets-numfmt/src/base/const/currency-symbols.ts
index 7d9cb516f9..a1eea6b3fc 100644
--- a/packages/sheets-numfmt/src/base/const/currency-symbols.ts
+++ b/packages/sheets-numfmt/src/base/const/currency-symbols.ts
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+import { LocaleType } from '@univerjs/core';
+
export const currencySymbols = [
'$',
'£',
@@ -23,7 +25,7 @@ export const currencySymbols = [
'؋',
'৳',
'฿',
- // '៛',
+ '៛',
'₡',
'₦',
'₩',
@@ -42,37 +44,80 @@ export const currencySymbols = [
'₽',
'₾',
'₿',
+ '﷼',
];
-export const countryCurrencyMap = {
- US: '$', // United States Dollar
- CA: 'C$', // Canadian Dollar
- GB: '£', // British Pound Sterling
- JP: '¥', // Japanese Yen
- IN: '₹', // Indian Rupee
- AU: 'A$', // Australian Dollar
- CN: '¥', // Chinese Yuan
- KR: '₩', // South Korean Won
- RU: '₽', // Russian Ruble
- // Euro countries
- AT: '€',
- BE: '€',
- CY: '€',
- EE: '€',
- FI: '€',
- FR: '€',
- DE: '€',
- GR: '€',
- IE: '€',
- IT: '€',
- LV: '€',
- LT: '€',
- LU: '€',
- MT: '€',
- NL: '€',
- PT: '€',
- SK: '€',
- SI: '€',
- ES: '€',
- // Add more mappings as needed
-};
+export const localeCurrencySymbolMap = new Map<LocaleType, string>([
+ [LocaleType.EN_US, '$'],
+ [LocaleType.RU_RU, '₽'],
+ [LocaleType.VI_VN, '₫'],
+ [LocaleType.ZH_CN, '¥'],
+ [LocaleType.ZH_TW, 'NT$'],
+ [LocaleType.FR_FR, '€'],
+ [LocaleType.FA_IR, '﷼'],
+ [LocaleType.KO_KR, '₩'],
+ [LocaleType.ES_ES, '€'],
+ [LocaleType.CA_ES, '€'],
+]);
+
+/**
+ * Get the currency symbol icon based on the locale.
+ * TODO@wpxp123456: supplement more currency symbols icons. missing icons: ₩, ₫, NT$, ﷼.
+ */
+export function getCurrencySymbolIconByLocale(locale: LocaleType) {
+ switch (locale) {
+ case LocaleType.CA_ES:
+ case LocaleType.ES_ES:
+ case LocaleType.FR_FR:
+ return {
+ icon: 'EuroIcon',
+ symbol: localeCurrencySymbolMap.get(locale) || '€',
+ locale,
+ };
+ case LocaleType.RU_RU:
+ return {
+ icon: 'RoubleIcon',
+ symbol: localeCurrencySymbolMap.get(locale) || '₽',
+ locale,
+ };
+ case LocaleType.ZH_CN:
+ return {
+ icon: 'RmbIcon',
+ symbol: localeCurrencySymbolMap.get(locale) || '¥',
+ locale,
+ };
+ case LocaleType.EN_US:
+ default:
+ return {
+ icon: 'DollarIcon',
+ symbol: '$',
+ locale: LocaleType.EN_US,
+ };
+ }
+}
+
+/**
+ * Get the currency symbol by locale.
+ */
+export function getCurrencySymbolByLocale(locale: LocaleType): string {
+ return localeCurrencySymbolMap.get(locale) || '$';
+}
+
+/**
+ * Get the currency format string based on the locale and number of digits.
+ */
+export function getCurrencyFormat(locale: LocaleType, numberDigits: number = 2): string {
+ let _numberDigits = numberDigits;
+
+ if (numberDigits > 127) {
+ _numberDigits = 127;
+ }
+
+ let decimal = '';
+
+ if (_numberDigits > 0) {
+ decimal = `.${'0'.repeat(_numberDigits)}`;
+ }
+
+ return `"${getCurrencySymbolByLocale(locale)}"#,##0${decimal}_);[Red]("${getCurrencySymbolByLocale(locale)}"#,##0${decimal})`;
+}
diff --git a/packages/sheets-numfmt/src/commands/commands/set-currency.command.ts b/packages/sheets-numfmt/src/commands/commands/set-currency.command.ts
index e198418204..429372a495 100644
--- a/packages/sheets-numfmt/src/commands/commands/set-currency.command.ts
+++ b/packages/sheets-numfmt/src/commands/commands/set-currency.command.ts
@@ -16,34 +16,38 @@
import type { IAccessor, ICommand } from '@univerjs/core';
import type { ISetNumfmtCommandParams } from './set-numfmt.command';
-import { CommandType, ICommandService, Range } from '@univerjs/core';
+import { CommandType, ICommandService, LocaleService, Range } from '@univerjs/core';
import { SheetsSelectionsService } from '@univerjs/sheets';
-import { countryCurrencyMap } from '../../base/const/currency-symbols';
-import { CURRENCYFORMAT } from '../../base/const/formatdetail';
-import { MenuCurrencyService } from '../../service/menu.currency.service';
+import { getCurrencyFormat, getCurrencySymbolIconByLocale } from '../../base/const/currency-symbols';
import { SetNumfmtCommand } from './set-numfmt.command';
+/**
+ * This command is triggered by clicking the currency symbol icon in the menu.
+ * So the currency format is determined by the currency symbol icon.
+ */
export const SetCurrencyCommand: ICommand = {
id: 'sheet.command.numfmt.set.currency',
type: CommandType.COMMAND,
handler: async (accessor: IAccessor) => {
const commandService = accessor.get(ICommandService);
const selectionManagerService = accessor.get(SheetsSelectionsService);
- const menuCurrencyService = accessor.get(MenuCurrencyService);
- const symbol = countryCurrencyMap[menuCurrencyService.getCurrencySymbol()] || '$';
+ const localeService = accessor.get(LocaleService);
+
const selections = selectionManagerService.getCurrentSelections();
if (!selections || !selections.length) {
return false;
}
- const values: ISetNumfmtCommandParams['values'] = [];
- const suffix = CURRENCYFORMAT[4].suffix(symbol);
+ const values: ISetNumfmtCommandParams['values'] = [];
+ const currencySymbolIcon = getCurrencySymbolIconByLocale(localeService.getCurrentLocale());
+ const currencyFormat = getCurrencyFormat(currencySymbolIcon.locale);
selections.forEach((selection) => {
Range.foreach(selection.range, (row, col) => {
- values.push({ row, col, pattern: suffix, type: 'currency' });
+ values.push({ row, col, pattern: currencyFormat, type: 'currency' });
});
});
+
const result = await commandService.executeCommand(SetNumfmtCommand.id, { values });
return result;
},
diff --git a/packages/sheets-numfmt/src/controllers/numfmt-currency.controller.ts b/packages/sheets-numfmt/src/controllers/numfmt-currency.controller.ts
deleted file mode 100644
index 531b039879..0000000000
--- a/packages/sheets-numfmt/src/controllers/numfmt-currency.controller.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { countryCurrencyMap } from '../base/const/currency-symbols';
-import { Disposable } from '@univerjs/core';
-import { BehaviorSubject } from 'rxjs';
-
-export class NumfmtCurrencyController extends Disposable {
- private _currencySymbol$ = new BehaviorSubject<keyof typeof countryCurrencyMap>('US');
- public readonly currencySymbol$ = this._currencySymbol$.asObservable();
-
- /**
- * Set the currency symbol by setting the country code.
- */
- public setCurrencySymbolByCountryCode(symbol: keyof typeof countryCurrencyMap) {
- this._currencySymbol$.next(symbol);
- }
-
- public getCurrencySymbol() {
- return this._currencySymbol$.getValue();
- }
-}
diff --git a/packages/sheets-numfmt/src/index.ts b/packages/sheets-numfmt/src/index.ts
index 5327494ce9..e37a2ded8e 100644
--- a/packages/sheets-numfmt/src/index.ts
+++ b/packages/sheets-numfmt/src/index.ts
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-export { countryCurrencyMap } from './base/const/currency-symbols';
-export { currencySymbols } from './base/const/currency-symbols';
+export { currencySymbols, getCurrencyFormat, getCurrencySymbolByLocale, getCurrencySymbolIconByLocale, localeCurrencySymbolMap } from './base/const/currency-symbols';
export { CURRENCYFORMAT, DATEFMTLISG, NUMBERFORMAT } from './base/const/formatdetail';
export { AddDecimalCommand } from './commands/commands/add-decimal.command';
export { SetCurrencyCommand } from './commands/commands/set-currency.command';
@@ -26,7 +25,6 @@ export { SHEETS_NUMFMT_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
export type { IUniverSheetsNumfmtConfig } from './controllers/config.schema';
export { SheetsNumfmtCellContentController } from './controllers/numfmt-cell-content.controller';
export { UniverSheetsNumfmtPlugin } from './plugin';
-export { MenuCurrencyService } from './service/menu.currency.service';
export { getCurrencyType } from './utils/currency';
export { getDecimalFromPattern, getDecimalString, isPatternHasDecimal, setPatternDecimal } from './utils/decimal';
export { getCurrencyFormatOptions, getCurrencyOptions, getDateFormatOptions, getNumberFormatOptions } from './utils/options';
diff --git a/packages/sheets-numfmt/src/plugin.ts b/packages/sheets-numfmt/src/plugin.ts
index bb198eba6c..d7ca3c4f29 100644
--- a/packages/sheets-numfmt/src/plugin.ts
+++ b/packages/sheets-numfmt/src/plugin.ts
@@ -25,8 +25,6 @@ import { SetPercentCommand } from './commands/commands/set-percent.command';
import { SubtractDecimalCommand } from './commands/commands/subtract-decimal.command';
import { defaultPluginConfig, SHEETS_NUMFMT_PLUGIN_CONFIG_KEY } from './controllers/config.schema';
import { SheetsNumfmtCellContentController } from './controllers/numfmt-cell-content.controller';
-import { NumfmtCurrencyController } from './controllers/numfmt-currency.controller';
-import { MenuCurrencyService } from './service/menu.currency.service';
@DependentOn(UniverSheetsPlugin)
export class UniverSheetsNumfmtPlugin extends Plugin {
@@ -54,8 +52,6 @@ export class UniverSheetsNumfmtPlugin extends Plugin {
override onStarting(): void {
registerDependencies(this._injector, [
[SheetsNumfmtCellContentController],
- [MenuCurrencyService],
- [NumfmtCurrencyController],
]);
touchDependencies(this._injector, [
@@ -64,10 +60,6 @@ export class UniverSheetsNumfmtPlugin extends Plugin {
}
override onRendered(): void {
- touchDependencies(this._injector, [
- [NumfmtCurrencyController],
- ]);
-
[
AddDecimalCommand,
SubtractDecimalCommand,
diff --git a/packages/sheets-numfmt/src/service/menu.currency.service.ts b/packages/sheets-numfmt/src/service/menu.currency.service.ts
deleted file mode 100644
index bf265fa41f..0000000000
--- a/packages/sheets-numfmt/src/service/menu.currency.service.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2023-present DreamNum Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import type { countryCurrencyMap } from '../base/const/currency-symbols';
-import { BehaviorSubject } from 'rxjs';
-
-export class MenuCurrencyService {
- private _currencySymbol$ = new BehaviorSubject<keyof typeof countryCurrencyMap>('US');
- public readonly currencySymbol$ = this._currencySymbol$.asObservable();
-
- /**
- * Set the currency symbol by setting the country code.
- */
- public setCurrencySymbolByCountryCode(symbol: keyof typeof countryCurrencyMap) {
- this._currencySymbol$.next(symbol);
- }
-
- public getCurrencySymbol() {
- return this._currencySymbol$.getValue();
- }
-}