@univerjs/sheets-numfmt 0.2.7 → 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.
Files changed (39) hide show
  1. package/lib/cjs/index.js +2 -2
  2. package/lib/es/index.js +389 -319
  3. package/lib/index.css +1 -1
  4. package/lib/types/base/const/CURRENCY-SYMBOLS.d.ts +30 -0
  5. package/lib/types/base/types/index.d.ts +0 -1
  6. package/lib/types/commands/commands/add-decimal.command.d.ts +0 -1
  7. package/lib/types/commands/commands/set-currency.command.d.ts +0 -1
  8. package/lib/types/commands/commands/set-numfmt.command.d.ts +0 -1
  9. package/lib/types/commands/commands/set-percent.command.d.ts +0 -1
  10. package/lib/types/commands/commands/subtract-decimal.command.d.ts +0 -1
  11. package/lib/types/commands/operations/close.numfmt.panel.operation.d.ts +0 -1
  12. package/lib/types/commands/operations/open.numfmt.panel.operation.d.ts +0 -1
  13. package/lib/types/components/accounting/index.d.ts +0 -1
  14. package/lib/types/components/currency/index.d.ts +0 -1
  15. package/lib/types/components/custom-format/index.d.ts +0 -1
  16. package/lib/types/components/date/index.d.ts +0 -1
  17. package/lib/types/components/general/index.d.ts +0 -1
  18. package/lib/types/components/index.d.ts +0 -1
  19. package/lib/types/components/more-numfmt-type/MoreNumfmtType.d.ts +0 -1
  20. package/lib/types/components/stories/Panel.stories.d.ts +0 -1
  21. package/lib/types/components/thousandth-percentile/index.d.ts +0 -1
  22. package/lib/types/controllers/__tests__/test.util.d.ts +0 -1
  23. package/lib/types/controllers/numfmt.cell-content.controller.d.ts +0 -1
  24. package/lib/types/controllers/numfmt.controller.d.ts +0 -1
  25. package/lib/types/controllers/numfmt.editor.controller.d.ts +0 -1
  26. package/lib/types/controllers/numfmt.i18n.controller.d.ts +0 -1
  27. package/lib/types/controllers/numfmt.menu.controller.d.ts +8 -1
  28. package/lib/types/controllers/user-habit.controller.d.ts +0 -1
  29. package/lib/types/index.d.ts +2 -0
  30. package/lib/types/locale/en-US.d.ts +0 -1
  31. package/lib/types/locale/ru-RU.d.ts +0 -1
  32. package/lib/types/locale/vi-VN.d.ts +0 -1
  33. package/lib/types/locale/zh-TW.d.ts +0 -1
  34. package/lib/types/menu/menu.d.ts +1 -2
  35. package/lib/types/numfmt-plugin.d.ts +0 -1
  36. package/lib/types/utils/mutation.d.ts +0 -1
  37. package/lib/types/utils/pattern.d.ts +0 -1
  38. package/lib/umd/index.js +2 -2
  39. package/package.json +19 -19
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:flex-end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.univer-custom-format-title{margin-top:16px}.univer-custom-format-input{margin-top:8px;width:100%}.univer-custom-format-history-list{margin-top:8px;padding:8px;border-radius:8px;border:1px solid var(---Grey-200, #e5e5e5);max-height:400px;overflow:scroll}.univer-custom-format-history-list-item{padding:6px 0;display:flex;gap:6px;align-items:center;cursor:pointer}.univer-custom-format-history-list-item-icon-wrap{width:16px;display:flex;align-items:center;color:#274fee}.univer-custom-format-des{margin-top:8px;color:var(---Grey-600, #7a7a7a);font-size:12px;font-style:normal;font-weight:400;line-height:16px}.more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}
1
+ .more-numfmt-type{display:flex;flex-shrink:0;padding:0 4px;font-size:13px;color:var(--black)}.more-numfmt-type .icon{display:flex;align-items:center;height:auto;padding-left:8px;color:rgb(var(--grey-400))}.more-numfmt-type-options .line{width:100%;height:1px;background-color:rgb(var(--grey-200))}.more-numfmt-type-options .m-t-4{margin-top:4px}.more-numfmt-type-options .option-item{display:flex;align-items:center;justify-content:space-between;height:28px;padding:0 8px;font-size:13px}.more-numfmt-type-options .option-item:hover{background-color:rgb(var(--grey-100));border-radius:var(--border-radius-base)}.more-numfmt-type-options .m-l-26{margin-left:26px}.numfmt-panel{overflow-y:auto;display:flex;flex-direction:column;justify-content:space-between;height:100%}.numfmt-panel .group-title{font-size:16px;color:rgba(var(--color-black))}.numfmt-panel .label{font-size:15px;color:rgba(var(--grey-400))}.numfmt-panel .describe{font-size:13px;line-height:20px;color:rgba(var(--grey-600))}.numfmt-panel .preview{height:36px;padding:0 16px;font-size:14px;line-height:36px;color:var(--color-black);border:1px solid rgb(var(--grey-200));border-radius:4px}.numfmt-panel .btn-list{display:flex;justify-content:flex-end}.numfmt-panel .m-r-12{margin-right:12px}.numfmt-panel .m-t-16{margin-top:16px}.numfmt-panel .m-t-14{margin-top:14px}.numfmt-panel .m-t-8{margin-top:8px}.numfmt-panel .m-b-20{margin-bottom:20px}.options{display:flex;justify-content:space-between}.options .w-140{width:140px}.options .w-120{width:120px}.univer-custom-format-title{margin-top:16px}.univer-custom-format-input{margin-top:8px;width:100%}.univer-custom-format-history-list{margin-top:8px;padding:8px;border-radius:8px;border:1px solid var(---Grey-200, #e5e5e5);max-height:400px;overflow:scroll}.univer-custom-format-history-list-item{padding:6px 0;display:flex;gap:6px;align-items:center;cursor:pointer}.univer-custom-format-history-list-item-icon-wrap{width:16px;display:flex;align-items:center;color:#274fee}.univer-custom-format-des{margin-top:8px;color:var(---Grey-600, #7a7a7a);font-size:12px;font-style:normal;font-weight:400;line-height:16px}
@@ -14,3 +14,33 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const currencySymbols: string[];
17
+ export declare const countryCurrencyMap: {
18
+ US: string;
19
+ CA: string;
20
+ GB: string;
21
+ JP: string;
22
+ IN: string;
23
+ AU: string;
24
+ CN: string;
25
+ KR: string;
26
+ RU: string;
27
+ AT: string;
28
+ BE: string;
29
+ CY: string;
30
+ EE: string;
31
+ FI: string;
32
+ FR: string;
33
+ DE: string;
34
+ GR: string;
35
+ IE: string;
36
+ IT: string;
37
+ LV: string;
38
+ LT: string;
39
+ LU: string;
40
+ MT: string;
41
+ NL: string;
42
+ PT: string;
43
+ SK: string;
44
+ SI: string;
45
+ ES: string;
46
+ };
@@ -1,5 +1,4 @@
1
1
  import { MutableRefObject } from 'react';
2
-
3
2
  export interface IBusinessComponentProps {
4
3
  onChange: (result: string) => void;
5
4
  defaultValue: number;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const AddDecimalCommand: ICommand;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const SetCurrencyCommand: ICommand;
@@ -1,6 +1,5 @@
1
1
  import { ICommand } from '@univerjs/core';
2
2
  import { FormatType } from '@univerjs/sheets';
3
-
4
3
  export interface ISetNumfmtCommandParams {
5
4
  unitId?: string;
6
5
  subUnitId?: string;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const SetPercentCommand: ICommand;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const SubtractDecimalCommand: ICommand;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const CloseNumfmtPanelOperator: ICommand;
@@ -1,3 +1,2 @@
1
1
  import { ICommand } from '@univerjs/core';
2
-
3
2
  export declare const OpenNumfmtPanelOperator: ICommand;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare const isAccountingPanel: (pattern: string) => boolean;
5
4
  export declare const AccountingPanel: FC<IBusinessComponentProps>;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare const isCurrencyPanel: (pattern: string) => boolean;
5
4
  export declare const CurrencyPanel: FC<IBusinessComponentProps>;
@@ -1,4 +1,3 @@
1
1
  import { default as React } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare function CustomFormat(props: IBusinessComponentProps): React.JSX.Element;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare const isDatePanel: (pattern: string) => boolean;
5
4
  export declare const DatePanel: FC<IBusinessComponentProps>;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare const isGeneralPanel: (pattern: string) => boolean;
5
4
  export declare const GeneralPanel: FC<IBusinessComponentProps>;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
-
3
2
  export interface ISheetNumfmtPanelProps {
4
3
  value: {
5
4
  defaultValue: number;
@@ -1,5 +1,4 @@
1
1
  import { default as React } from 'react';
2
-
3
2
  export declare const MORE_NUMFMT_TYPE_KEY = "sheet.numfmt.moreNumfmtType";
4
3
  export declare const OPTIONS_KEY = "sheet.numfmt.moreNumfmtType.options";
5
4
  export declare const MoreNumfmtType: (props: {
@@ -1,6 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
  import { ISheetNumfmtPanelProps } from '../index';
3
-
4
3
  declare const meta: Meta;
5
4
  export default meta;
6
5
  export declare const Test: StoryObj<ISheetNumfmtPanelProps>;
@@ -1,5 +1,4 @@
1
1
  import { FC } from 'react';
2
2
  import { IBusinessComponentProps } from '../../base/types';
3
-
4
3
  export declare const isThousandthPercentilePanel: (pattern: string) => boolean;
5
4
  export declare const ThousandthPercentilePanel: FC<IBusinessComponentProps>;
@@ -1,5 +1,4 @@
1
1
  import { Dependency, Univer } from '@univerjs/core';
2
-
3
2
  export declare const createTestBed: (dependencies?: Dependency[]) => {
4
3
  univer: Univer;
5
4
  get: {
@@ -1,6 +1,5 @@
1
1
  import { Disposable, ICommandService, IUniverInstanceService, LocaleService, ThemeService } from '@univerjs/core';
2
2
  import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
3
-
4
3
  export declare class SheetsNumfmtCellContentController extends Disposable {
5
4
  private readonly _instanceService;
6
5
  private _sheetInterceptorService;
@@ -3,7 +3,6 @@ import { IRenderManagerService } from '@univerjs/engine-render';
3
3
  import { INumfmtService, SheetInterceptorService, SheetsSelectionsService } from '@univerjs/sheets';
4
4
  import { ComponentManager, ISidebarService } from '@univerjs/ui';
5
5
  import { INumfmtController } from './type';
6
-
7
6
  export declare class NumfmtController extends Disposable implements INumfmtController {
8
7
  private _sheetInterceptorService;
9
8
  private _themeService;
@@ -1,7 +1,6 @@
1
1
  import { Disposable, Injector, IUniverInstanceService } from '@univerjs/core';
2
2
  import { INumfmtService, SheetInterceptorService } from '@univerjs/sheets';
3
3
  import { IEditorBridgeService } from '@univerjs/sheets-ui';
4
-
5
4
  export declare class NumfmtEditorController extends Disposable {
6
5
  private _sheetInterceptorService;
7
6
  private _numfmtService;
@@ -1,5 +1,4 @@
1
1
  import { Disposable, LocaleService } from '@univerjs/core';
2
-
3
2
  export declare class NumfmtI18nController extends Disposable {
4
3
  private _localeService;
5
4
  constructor(_localeService: LocaleService);
@@ -1,6 +1,6 @@
1
1
  import { Disposable, Injector } from '@univerjs/core';
2
2
  import { MenuConfig, ComponentManager, IMenuService } from '@univerjs/ui';
3
-
3
+ import { countryCurrencyMap } from '../base/const/CURRENCY-SYMBOLS';
4
4
  export interface IUniverSheetsNumfmtConfig {
5
5
  menu: MenuConfig;
6
6
  }
@@ -10,6 +10,13 @@ export declare class NumfmtMenuController extends Disposable {
10
10
  private _injector;
11
11
  private _componentManager;
12
12
  private _menuService;
13
+ private _currencySymbol$;
14
+ readonly currencySymbol$: import('rxjs').Observable<"AT" | "US" | "CA" | "GB" | "JP" | "IN" | "AU" | "CN" | "KR" | "RU" | "BE" | "CY" | "EE" | "FI" | "FR" | "DE" | "GR" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PT" | "SK" | "SI" | "ES">;
13
15
  constructor(_config: Partial<IUniverSheetsNumfmtConfig>, _injector: Injector, _componentManager: ComponentManager, _menuService: IMenuService);
14
16
  private _initMenu;
17
+ /**
18
+ * Set the currency symbol by setting the country code.
19
+ */
20
+ setCurrencySymbolByCountryCode(symbol: keyof typeof countryCurrencyMap): void;
21
+ getCurrencySymbol(): "AT" | "US" | "CA" | "GB" | "JP" | "IN" | "AU" | "CN" | "KR" | "RU" | "BE" | "CY" | "EE" | "FI" | "FR" | "DE" | "GR" | "IE" | "IT" | "LV" | "LT" | "LU" | "MT" | "NL" | "PT" | "SK" | "SI" | "ES";
15
22
  }
@@ -1,5 +1,4 @@
1
1
  import { ILocalStorageService } from '@univerjs/core';
2
-
3
2
  type HabitValue = string | number;
4
3
  interface IUserHabitController {
5
4
  addHabit(habit: string, initValue: HabitValue[]): Promise<void>;
@@ -15,6 +15,8 @@
15
15
  */
16
16
  export { UniverSheetsNumfmtPlugin } from './numfmt-plugin';
17
17
  export { getPatternPreview } from './utils/pattern';
18
+ export { NumfmtMenuController } from './controllers/numfmt.menu.controller';
19
+ export { countryCurrencyMap } from './base/const/CURRENCY-SYMBOLS';
18
20
  export { AddDecimalCommand } from './commands/commands/add-decimal.command';
19
21
  export { SetCurrencyCommand } from './commands/commands/set-currency.command';
20
22
  export { type ISetNumfmtCommandParams, SetNumfmtCommand } from './commands/commands/set-numfmt.command';
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,4 +1,3 @@
1
1
  import { default as zhCN } from './zh-CN';
2
-
3
2
  declare const locale: typeof zhCN;
4
3
  export default locale;
@@ -1,9 +1,8 @@
1
1
  import { IMenuSelectorItem, MenuGroup, MenuItemType, MenuPosition } from '@univerjs/ui';
2
2
  import { IAccessor } from '@univerjs/core';
3
3
  import { Observable } from 'rxjs';
4
-
5
4
  export declare const CurrencyMenuItem: (accessor: IAccessor) => {
6
- icon: string;
5
+ icon: Observable<string>;
7
6
  id: string;
8
7
  title: string;
9
8
  tooltip: string;
@@ -1,6 +1,5 @@
1
1
  import { Injector, Plugin, UniverInstanceType } from '@univerjs/core';
2
2
  import { IUniverSheetsNumfmtConfig } from './controllers/numfmt.menu.controller';
3
-
4
3
  export declare class UniverSheetsNumfmtPlugin extends Plugin {
5
4
  private readonly _config;
6
5
  readonly _injector: Injector;
@@ -1,3 +1,2 @@
1
1
  import { IMutationInfo } from '@univerjs/core';
2
-
3
2
  export declare const mergeNumfmtMutations: (list: IMutationInfo[]) => IMutationInfo<object>[];
@@ -1,6 +1,5 @@
1
1
  import { LocaleType } from '@univerjs/core';
2
2
  import { FormatType } from '@univerjs/sheets';
3
-
4
3
  export declare const getPatternType: (pattern: string) => FormatType;
5
4
  export declare const getPatternPreview: (pattern: string, value: number, _locale?: LocaleType) => {
6
5
  result: any;