@gooddata/sdk-ui-kit 11.13.0-alpha.2 → 11.13.0-alpha.4

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 (45) hide show
  1. package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableCheckbox.js +1 -1
  2. package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableCheckbox.js.map +1 -1
  3. package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableToolbar.js +2 -2
  4. package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableToolbar.js.map +1 -1
  5. package/esm/@ui/UiCheckbox/UiCheckbox.d.ts.map +1 -1
  6. package/esm/@ui/UiCheckbox/UiCheckbox.js +9 -1
  7. package/esm/@ui/UiCheckbox/UiCheckbox.js.map +1 -1
  8. package/esm/Dropdown/DropdownButton.js +1 -1
  9. package/esm/Dropdown/DropdownButton.js.map +1 -1
  10. package/esm/Dropdown/DropdownInvertableSelect.d.ts.map +1 -1
  11. package/esm/Dropdown/DropdownInvertableSelect.js +1 -1
  12. package/esm/Dropdown/DropdownInvertableSelect.js.map +1 -1
  13. package/esm/Dropdown/DropdownList.d.ts.map +1 -1
  14. package/esm/Dropdown/DropdownList.js +6 -2
  15. package/esm/Dropdown/DropdownList.js.map +1 -1
  16. package/esm/List/InvertableSelect/InvertableSelect.d.ts +3 -1
  17. package/esm/List/InvertableSelect/InvertableSelect.d.ts.map +1 -1
  18. package/esm/List/InvertableSelect/InvertableSelect.js +18 -4
  19. package/esm/List/InvertableSelect/InvertableSelect.js.map +1 -1
  20. package/esm/List/InvertableSelect/InvertableSelectSearchBar.d.ts +3 -1
  21. package/esm/List/InvertableSelect/InvertableSelectSearchBar.d.ts.map +1 -1
  22. package/esm/List/InvertableSelect/InvertableSelectSearchBar.js +2 -3
  23. package/esm/List/InvertableSelect/InvertableSelectSearchBar.js.map +1 -1
  24. package/esm/measureNumberFormat/hooks/useMetricTypePresets.d.ts +115 -0
  25. package/esm/measureNumberFormat/hooks/useMetricTypePresets.d.ts.map +1 -0
  26. package/esm/measureNumberFormat/hooks/useMetricTypePresets.js +113 -0
  27. package/esm/measureNumberFormat/hooks/useMetricTypePresets.js.map +1 -0
  28. package/esm/measureNumberFormat/index.d.ts +4 -1
  29. package/esm/measureNumberFormat/index.d.ts.map +1 -1
  30. package/esm/measureNumberFormat/index.js +4 -1
  31. package/esm/measureNumberFormat/index.js.map +1 -1
  32. package/esm/measureNumberFormat/presets/currencyPresets.d.ts +7 -1
  33. package/esm/measureNumberFormat/presets/currencyPresets.d.ts.map +1 -1
  34. package/esm/measureNumberFormat/presets/currencyPresets.js +18 -7
  35. package/esm/measureNumberFormat/presets/currencyPresets.js.map +1 -1
  36. package/esm/measureNumberFormat/presets/standardPresets.d.ts +34 -0
  37. package/esm/measureNumberFormat/presets/standardPresets.d.ts.map +1 -0
  38. package/esm/measureNumberFormat/presets/standardPresets.js +71 -0
  39. package/esm/measureNumberFormat/presets/standardPresets.js.map +1 -0
  40. package/esm/measureNumberFormat/presets/templates.d.ts +60 -0
  41. package/esm/measureNumberFormat/presets/templates.d.ts.map +1 -0
  42. package/esm/measureNumberFormat/presets/templates.js +183 -0
  43. package/esm/measureNumberFormat/presets/templates.js.map +1 -0
  44. package/esm/sdk-ui-kit.d.ts +231 -2
  45. package/package.json +9 -9
@@ -0,0 +1,113 @@
1
+ // (C) 2025 GoodData Corporation
2
+ import { useMemo } from "react";
3
+ import { createCurrencyPresets } from "../presets/currencyPresets.js";
4
+ import { DEFAULT_STANDARD_PRESET_PREFIX, createStandardPresets } from "../presets/standardPresets.js";
5
+ import { CURRENCY_TEMPLATE_IDS, DEFAULT_TEMPLATE_PREFIX, createAllTemplates } from "../presets/templates.js";
6
+ /**
7
+ * Hook that creates format presets and templates based on metric type.
8
+ *
9
+ * This hook encapsulates the logic for building format options that respect:
10
+ * - Metric type (CURRENCY vs standard)
11
+ * - Currency format override (creates "inherit" preset)
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const { presets, templates, inheritPreset } = useMetricTypePresets({
16
+ * metricType: "CURRENCY",
17
+ * currencyFormatOverride: "$#,##0.00",
18
+ * formatMessage: (d) => intl.formatMessage(d),
19
+ * });
20
+ * ```
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * // With custom message ID prefixes (e.g., for Analytical Designer)
25
+ * const { presets, templates } = useMetricTypePresets({
26
+ * metricType: undefined,
27
+ * formatMessage: (d) => intl.formatMessage(d),
28
+ * presetMessageIdPrefix: "measure_number_format.preset",
29
+ * templateMessageIdPrefix: "measure_number_format.template",
30
+ * });
31
+ * ```
32
+ *
33
+ * @internal
34
+ */
35
+ export function useMetricTypePresets({ metricType, currencyFormatOverride, formatMessage, presetMessageIdPrefix = DEFAULT_STANDARD_PRESET_PREFIX, templateMessageIdPrefix = DEFAULT_TEMPLATE_PREFIX, }) {
36
+ // Standard numeric presets
37
+ const standardPresets = useMemo(() => createStandardPresets(formatMessage, presetMessageIdPrefix), [formatMessage, presetMessageIdPrefix]);
38
+ // Base currency presets
39
+ const baseCurrencyPresets = useMemo(() => createCurrencyPresets(formatMessage, presetMessageIdPrefix), [formatMessage, presetMessageIdPrefix]);
40
+ // Currency presets, excluding the override format if it matches a preset
41
+ const currencyPresets = useMemo(() => {
42
+ if (!currencyFormatOverride) {
43
+ return baseCurrencyPresets;
44
+ }
45
+ return baseCurrencyPresets.filter((preset) => preset.format !== currencyFormatOverride);
46
+ }, [baseCurrencyPresets, currencyFormatOverride]);
47
+ // Inherit preset - only for CURRENCY when override exists
48
+ const inheritPreset = useMemo(() => {
49
+ if (metricType === "CURRENCY" && currencyFormatOverride) {
50
+ return {
51
+ name: formatMessage({ id: `${presetMessageIdPrefix}.inherit` }),
52
+ localIdentifier: "inherit",
53
+ format: currencyFormatOverride,
54
+ previewNumber: 1000.12,
55
+ };
56
+ }
57
+ return null;
58
+ }, [metricType, currencyFormatOverride, formatMessage, presetMessageIdPrefix]);
59
+ // Final presets based on metric type
60
+ const presets = useMemo(() => {
61
+ if (metricType === "CURRENCY") {
62
+ if (inheritPreset) {
63
+ return [inheritPreset, ...currencyPresets];
64
+ }
65
+ return currencyPresets;
66
+ }
67
+ return standardPresets;
68
+ }, [metricType, standardPresets, currencyPresets, inheritPreset]);
69
+ // Templates - for CURRENCY, show ONLY currency templates
70
+ const templates = useMemo(() => {
71
+ if (metricType === "CURRENCY") {
72
+ // For CURRENCY metrics, show only currency-specific templates
73
+ return createAllTemplates(formatMessage, templateMessageIdPrefix).filter((t) => CURRENCY_TEMPLATE_IDS.includes(t.localIdentifier));
74
+ }
75
+ // For non-CURRENCY, show all templates
76
+ return createAllTemplates(formatMessage, templateMessageIdPrefix);
77
+ }, [metricType, formatMessage, templateMessageIdPrefix]);
78
+ return {
79
+ presets,
80
+ templates,
81
+ inheritPreset,
82
+ };
83
+ }
84
+ /**
85
+ * Hook that creates standard numeric format presets.
86
+ * Use this when you don't need metric type awareness.
87
+ *
88
+ * @param formatMessage - Function to format localized messages
89
+ * @returns Array of standard format presets
90
+ * @internal
91
+ */
92
+ export function useStandardPresets(formatMessage) {
93
+ return useMemo(() => createStandardPresets(formatMessage), [formatMessage]);
94
+ }
95
+ /**
96
+ * Hook that creates all format templates.
97
+ * Use this when you need templates without metric type filtering.
98
+ *
99
+ * @param formatMessage - Function to format localized messages
100
+ * @param excludeCurrencyTemplates - Whether to exclude currency-specific templates
101
+ * @returns Array of format templates
102
+ * @internal
103
+ */
104
+ export function useFormatTemplates(formatMessage, excludeCurrencyTemplates = false) {
105
+ return useMemo(() => {
106
+ const allTemplates = createAllTemplates(formatMessage);
107
+ if (excludeCurrencyTemplates) {
108
+ return allTemplates.filter((t) => !CURRENCY_TEMPLATE_IDS.includes(t.localIdentifier));
109
+ }
110
+ return allTemplates;
111
+ }, [formatMessage, excludeCurrencyTemplates]);
112
+ }
113
+ //# sourceMappingURL=useMetricTypePresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMetricTypeP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ED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqD;IACpF,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,qBAAqB,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAC9B,aAAqD,EACrD,wBAAwB,GAAG,KAAK;IAEhC,OAAO,OAAO,CAAC,GAAG,EAAE;QAChB,MAAM,YAAY,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAC;QACvD,IAAI,wBAAwB,EAAE,CAAC;YAC3B,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC;QAC1F,CAAC;QACD,OAAO,YAAY,CAAC;IACxB,CAAC,EAAE,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAC,CAAC;AAClD,CAAC"}
@@ -4,5 +4,8 @@ export { MeasureNumberFormat } from "./MeasureNumberFormat.js";
4
4
  export { validateCurrencyFormat, isCurrencyFormat, type CurrencyFormatValidationErrorCode, type ICurrencyFormatValidationError, type ICurrencyFormatValidationOptions, type ICurrencyFormatValidationResult, } from "./validation/currencyFormatValidator.js";
5
5
  export { useCurrencyFormatDefaults } from "./hooks/useCurrencyFormatDefaults.js";
6
6
  export type { UseCurrencyFormatDefaultsConfig } from "./hooks/useCurrencyFormatDefaults.js";
7
- export { createCurrencyPresets, CURRENCY_PRESET_DEFINITIONS, type ICurrencyPresetDefinition, } from "./presets/currencyPresets.js";
7
+ export { createCurrencyPresets, CURRENCY_PRESET_DEFINITIONS, DEFAULT_CURRENCY_PRESET_PREFIX, type ICurrencyPresetDefinition, } from "./presets/currencyPresets.js";
8
+ export { createStandardPresets, STANDARD_PRESET_DEFINITIONS, DEFAULT_STANDARD_PRESET_PREFIX, type IStandardPresetDefinition, } from "./presets/standardPresets.js";
9
+ export { createTemplates, createAllTemplates, STANDARD_TEMPLATE_DEFINITIONS, CURRENCY_TEMPLATE_DEFINITIONS, ADVANCED_TEMPLATE_DEFINITIONS, CURRENCY_TEMPLATE_IDS, DEFAULT_TEMPLATE_PREFIX, type ITemplateDefinition, } from "./presets/templates.js";
10
+ export { useMetricTypePresets, useStandardPresets, useFormatTemplates, type UseMetricTypePresetsConfig, type UseMetricTypePresetsResult, } from "./hooks/useMetricTypePresets.js";
8
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/measureNumberFormat/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,iCAAiC,EACtC,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,GACvC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,YAAY,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,KAAK,yBAAyB,GACjC,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/measureNumberFormat/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAC7B,YAAY,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,KAAK,iCAAiC,EACtC,KAAK,8BAA8B,EACnC,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,GACvC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,YAAY,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAC5F,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,EAC9B,KAAK,yBAAyB,GACjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,EAC9B,KAAK,yBAAyB,GACjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,mBAAmB,GAC3B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,GAClC,MAAM,iCAAiC,CAAC"}
@@ -3,5 +3,8 @@ export * from "./typings.js";
3
3
  export { MeasureNumberFormat } from "./MeasureNumberFormat.js";
4
4
  export { validateCurrencyFormat, isCurrencyFormat, } from "./validation/currencyFormatValidator.js";
5
5
  export { useCurrencyFormatDefaults } from "./hooks/useCurrencyFormatDefaults.js";
6
- export { createCurrencyPresets, CURRENCY_PRESET_DEFINITIONS, } from "./presets/currencyPresets.js";
6
+ export { createCurrencyPresets, CURRENCY_PRESET_DEFINITIONS, DEFAULT_CURRENCY_PRESET_PREFIX, } from "./presets/currencyPresets.js";
7
+ export { createStandardPresets, STANDARD_PRESET_DEFINITIONS, DEFAULT_STANDARD_PRESET_PREFIX, } from "./presets/standardPresets.js";
8
+ export { createTemplates, createAllTemplates, STANDARD_TEMPLATE_DEFINITIONS, CURRENCY_TEMPLATE_DEFINITIONS, ADVANCED_TEMPLATE_DEFINITIONS, CURRENCY_TEMPLATE_IDS, DEFAULT_TEMPLATE_PREFIX, } from "./presets/templates.js";
9
+ export { useMetricTypePresets, useStandardPresets, useFormatTemplates, } from "./hooks/useMetricTypePresets.js";
7
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/measureNumberFormat/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACH,sBAAsB,EACtB,gBAAgB,GAKnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EACH,qBAAqB,EACrB,2BAA2B,GAE9B,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/measureNumberFormat/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAErC,cAAc,cAAc,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACH,sBAAsB,EACtB,gBAAgB,GAKnB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AAEjF,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,GAEjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,qBAAqB,EACrB,2BAA2B,EAC3B,8BAA8B,GAEjC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,EACrB,uBAAuB,GAE1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACH,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,GAGrB,MAAM,iCAAiC,CAAC"}
@@ -15,14 +15,20 @@ export interface ICurrencyPresetDefinition {
15
15
  * @internal
16
16
  */
17
17
  export declare const CURRENCY_PRESET_DEFINITIONS: readonly ICurrencyPresetDefinition[];
18
+ /**
19
+ * Default message ID prefix for currency preset definitions.
20
+ * @internal
21
+ */
22
+ export declare const DEFAULT_CURRENCY_PRESET_PREFIX = "metricComponent.numberFormat.preset";
18
23
  /**
19
24
  * Creates localized currency format presets.
20
25
  *
21
26
  * @param formatMessage - Function to format localized messages (e.g., from react-intl)
27
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
22
28
  * @returns Array of currency format presets with localized names
23
29
  * @internal
24
30
  */
25
31
  export declare function createCurrencyPresets(formatMessage: (descriptor: {
26
32
  id: string;
27
- }) => string): IFormatPreset[];
33
+ }) => string, messageIdPrefix?: string): IFormatPreset[];
28
34
  //# sourceMappingURL=currencyPresets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"currencyPresets.d.ts","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/currencyPresets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,yBAAyB,EAmBlE,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACjC,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,GACtD,aAAa,EAAE,CAOjB"}
1
+ {"version":3,"file":"currencyPresets.d.ts","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/currencyPresets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,yBAAyB,EAmBlE,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,8BAA8B,wCAAwC,CAAC;AAEpF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACjC,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,EACrD,eAAe,GAAE,MAAuC,GACzD,aAAa,EAAE,CAYjB"}
@@ -24,19 +24,30 @@ export const CURRENCY_PRESET_DEFINITIONS = [
24
24
  messageId: "metricComponent.numberFormat.preset.currencyRounded",
25
25
  },
26
26
  ];
27
+ /**
28
+ * Default message ID prefix for currency preset definitions.
29
+ * @internal
30
+ */
31
+ export const DEFAULT_CURRENCY_PRESET_PREFIX = "metricComponent.numberFormat.preset";
27
32
  /**
28
33
  * Creates localized currency format presets.
29
34
  *
30
35
  * @param formatMessage - Function to format localized messages (e.g., from react-intl)
36
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
31
37
  * @returns Array of currency format presets with localized names
32
38
  * @internal
33
39
  */
34
- export function createCurrencyPresets(formatMessage) {
35
- return CURRENCY_PRESET_DEFINITIONS.map((definition) => ({
36
- name: formatMessage({ id: definition.messageId }),
37
- localIdentifier: definition.localIdentifier,
38
- format: definition.format,
39
- previewNumber: definition.previewNumber,
40
- }));
40
+ export function createCurrencyPresets(formatMessage, messageIdPrefix = DEFAULT_CURRENCY_PRESET_PREFIX) {
41
+ return CURRENCY_PRESET_DEFINITIONS.map((definition) => {
42
+ // Extract the key part from the default message ID (e.g., "currency" from "metricComponent.numberFormat.preset.currency")
43
+ const keyPart = definition.messageId.replace(`${DEFAULT_CURRENCY_PRESET_PREFIX}.`, "");
44
+ const messageId = `${messageIdPrefix}.${keyPart}`;
45
+ return {
46
+ name: formatMessage({ id: messageId }),
47
+ localIdentifier: definition.localIdentifier,
48
+ format: definition.format,
49
+ previewNumber: definition.previewNumber,
50
+ };
51
+ });
41
52
  }
42
53
  //# sourceMappingURL=currencyPresets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"currencyPresets.js","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/currencyPresets.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAehC;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyC;IAC7E;QACI,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,WAAW;QACnB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,8CAA8C;KAC5D;IACD;QACI,eAAe,EAAE,yBAAyB;QAC1C,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,+CAA+C;KAC7D;IACD;QACI,eAAe,EAAE,kBAAkB;QACnC,MAAM,EAAE,QAAQ;QAChB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,qDAAqD;KACnE;CACK,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CACjC,aAAqD;IAErD,OAAO,2BAA2B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,EAAE,UAAU,CAAC,SAAS,EAAE,CAAC;QACjD,eAAe,EAAE,UAAU,CAAC,eAAe;QAC3C,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,aAAa,EAAE,UAAU,CAAC,aAAa;KAC1C,CAAC,CAAC,CAAC;AACR,CAAC"}
1
+ {"version":3,"file":"currencyPresets.js","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/currencyPresets.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAehC;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyC;IAC7E;QACI,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,WAAW;QACnB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,8CAA8C;KAC5D;IACD;QACI,eAAe,EAAE,yBAAyB;QAC1C,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,+CAA+C;KAC7D;IACD;QACI,eAAe,EAAE,kBAAkB;QACnC,MAAM,EAAE,QAAQ;QAChB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,qDAAqD;KACnE;CACK,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,qCAAqC,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACjC,aAAqD,EACrD,kBAA0B,8BAA8B;IAExD,OAAO,2BAA2B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClD,0HAA0H;QAC1H,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,8BAA8B,GAAG,EAAE,EAAE,CAAC,CAAC;QACvF,MAAM,SAAS,GAAG,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;QAClD,OAAO;YACH,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;YACtC,eAAe,EAAE,UAAU,CAAC,eAAe;YAC3C,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,aAAa,EAAE,UAAU,CAAC,aAAa;SAC1C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { type IFormatPreset } from "../typings.js";
2
+ /**
3
+ * Base standard preset definition without localized name.
4
+ * @internal
5
+ */
6
+ export interface IStandardPresetDefinition {
7
+ localIdentifier: string;
8
+ format: string;
9
+ previewNumber: number;
10
+ messageId: string;
11
+ }
12
+ /**
13
+ * Standard numeric preset definitions.
14
+ * These are the raw preset data that can be used to create localized presets.
15
+ * @internal
16
+ */
17
+ export declare const STANDARD_PRESET_DEFINITIONS: readonly IStandardPresetDefinition[];
18
+ /**
19
+ * Default message ID prefix for standard preset definitions.
20
+ * @internal
21
+ */
22
+ export declare const DEFAULT_STANDARD_PRESET_PREFIX = "metricComponent.numberFormat.preset";
23
+ /**
24
+ * Creates localized standard format presets.
25
+ *
26
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
27
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
28
+ * @returns Array of standard format presets with localized names
29
+ * @internal
30
+ */
31
+ export declare function createStandardPresets(formatMessage: (descriptor: {
32
+ id: string;
33
+ }) => string, messageIdPrefix?: string): IFormatPreset[];
34
+ //# sourceMappingURL=standardPresets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardPresets.d.ts","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/standardPresets.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACtC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,EAAE,SAAS,yBAAyB,EAqClE,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,8BAA8B,wCAAwC,CAAC;AAEpF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACjC,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,EACrD,eAAe,GAAE,MAAuC,GACzD,aAAa,EAAE,CAYjB"}
@@ -0,0 +1,71 @@
1
+ // (C) 2025 GoodData Corporation
2
+ /**
3
+ * Standard numeric preset definitions.
4
+ * These are the raw preset data that can be used to create localized presets.
5
+ * @internal
6
+ */
7
+ export const STANDARD_PRESET_DEFINITIONS = [
8
+ {
9
+ localIdentifier: "rounded",
10
+ format: "#,##0",
11
+ previewNumber: 1000.12,
12
+ messageId: "metricComponent.numberFormat.preset.rounded",
13
+ },
14
+ {
15
+ localIdentifier: "decimal-1",
16
+ format: "#,##0.0",
17
+ previewNumber: 1000.12,
18
+ messageId: "metricComponent.numberFormat.preset.decimal1",
19
+ },
20
+ {
21
+ localIdentifier: "decimal-2",
22
+ format: "#,##0.00",
23
+ previewNumber: 1000.12,
24
+ messageId: "metricComponent.numberFormat.preset.decimal2",
25
+ },
26
+ {
27
+ localIdentifier: "percent-rounded",
28
+ format: "#,##0%",
29
+ previewNumber: 0.1,
30
+ messageId: "metricComponent.numberFormat.preset.percentRounded",
31
+ },
32
+ {
33
+ localIdentifier: "percent-1",
34
+ format: "#,##0.0%",
35
+ previewNumber: 0.101,
36
+ messageId: "metricComponent.numberFormat.preset.percent1",
37
+ },
38
+ {
39
+ localIdentifier: "percent-2",
40
+ format: "#,##0.00%",
41
+ previewNumber: 0.1012,
42
+ messageId: "metricComponent.numberFormat.preset.percent2",
43
+ },
44
+ ];
45
+ /**
46
+ * Default message ID prefix for standard preset definitions.
47
+ * @internal
48
+ */
49
+ export const DEFAULT_STANDARD_PRESET_PREFIX = "metricComponent.numberFormat.preset";
50
+ /**
51
+ * Creates localized standard format presets.
52
+ *
53
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
54
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
55
+ * @returns Array of standard format presets with localized names
56
+ * @internal
57
+ */
58
+ export function createStandardPresets(formatMessage, messageIdPrefix = DEFAULT_STANDARD_PRESET_PREFIX) {
59
+ return STANDARD_PRESET_DEFINITIONS.map((definition) => {
60
+ // Extract the key part from the default message ID (e.g., "rounded" from "metricComponent.numberFormat.preset.rounded")
61
+ const keyPart = definition.messageId.replace(`${DEFAULT_STANDARD_PRESET_PREFIX}.`, "");
62
+ const messageId = `${messageIdPrefix}.${keyPart}`;
63
+ return {
64
+ name: formatMessage({ id: messageId }),
65
+ localIdentifier: definition.localIdentifier,
66
+ format: definition.format,
67
+ previewNumber: definition.previewNumber,
68
+ };
69
+ });
70
+ }
71
+ //# sourceMappingURL=standardPresets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standardPresets.js","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/standardPresets.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAehC;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAyC;IAC7E;QACI,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE,OAAO;QACf,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,6CAA6C;KAC3D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,SAAS;QACjB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,8CAA8C;KAC5D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,8CAA8C;KAC5D;IACD;QACI,eAAe,EAAE,iBAAiB;QAClC,MAAM,EAAE,QAAQ;QAChB,aAAa,EAAE,GAAG;QAClB,SAAS,EAAE,oDAAoD;KAClE;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,UAAU;QAClB,aAAa,EAAE,KAAK;QACpB,SAAS,EAAE,8CAA8C;KAC5D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,WAAW;QACnB,aAAa,EAAE,MAAM;QACrB,SAAS,EAAE,8CAA8C;KAC5D;CACK,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,qCAAqC,CAAC;AAEpF;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CACjC,aAAqD,EACrD,kBAA0B,8BAA8B;IAExD,OAAO,2BAA2B,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClD,wHAAwH;QACxH,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,8BAA8B,GAAG,EAAE,EAAE,CAAC,CAAC;QACvF,MAAM,SAAS,GAAG,GAAG,eAAe,IAAI,OAAO,EAAE,CAAC;QAClD,OAAO;YACH,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;YACtC,eAAe,EAAE,UAAU,CAAC,eAAe;YAC3C,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,aAAa,EAAE,UAAU,CAAC,aAAa;SAC1C,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { type IFormatTemplate } from "../typings.js";
2
+ /**
3
+ * Base template definition without localized name.
4
+ * @internal
5
+ */
6
+ export interface ITemplateDefinition {
7
+ localIdentifier: string;
8
+ format: string;
9
+ messageId: string;
10
+ }
11
+ /**
12
+ * Standard format template definitions (basic numeric formats).
13
+ * @internal
14
+ */
15
+ export declare const STANDARD_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
16
+ /**
17
+ * Currency format template definitions.
18
+ * @internal
19
+ */
20
+ export declare const CURRENCY_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
21
+ /**
22
+ * Advanced format template definitions (complex conditional formats).
23
+ * @internal
24
+ */
25
+ export declare const ADVANCED_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
26
+ /**
27
+ * Local identifiers of templates that are currency-specific.
28
+ * Used to filter templates when metric type is CURRENCY.
29
+ * @internal
30
+ */
31
+ export declare const CURRENCY_TEMPLATE_IDS: string[];
32
+ /**
33
+ * Default message ID prefix for template definitions.
34
+ * @internal
35
+ */
36
+ export declare const DEFAULT_TEMPLATE_PREFIX = "metricComponent.numberFormat.template";
37
+ /**
38
+ * Creates localized format templates.
39
+ *
40
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
41
+ * @param definitions - Template definitions to localize
42
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
43
+ * @returns Array of format templates with localized names
44
+ * @internal
45
+ */
46
+ export declare function createTemplates(formatMessage: (descriptor: {
47
+ id: string;
48
+ }) => string, definitions: readonly ITemplateDefinition[], messageIdPrefix?: string): IFormatTemplate[];
49
+ /**
50
+ * Creates all localized format templates (standard + currency + advanced).
51
+ *
52
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
53
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
54
+ * @returns Array of all format templates with localized names
55
+ * @internal
56
+ */
57
+ export declare function createAllTemplates(formatMessage: (descriptor: {
58
+ id: string;
59
+ }) => string, messageIdPrefix?: string): IFormatTemplate[];
60
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,mBAAmB,EA+B9D,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,mBAAmB,EAqB9D,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,6BAA6B,EAAE,SAAS,mBAAmB,EAuE9D,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,UAA8D,CAAC;AAEjG;;;GAGG;AACH,eAAO,MAAM,uBAAuB,0CAA0C,CAAC;AAE/E;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC3B,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,EACrD,WAAW,EAAE,SAAS,mBAAmB,EAAE,EAC3C,eAAe,GAAE,MAAgC,GAClD,eAAe,EAAE,CAWnB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAC9B,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,EACrD,eAAe,GAAE,MAAgC,GAClD,eAAe,EAAE,CAMnB"}
@@ -0,0 +1,183 @@
1
+ // (C) 2025 GoodData Corporation
2
+ /**
3
+ * Standard format template definitions (basic numeric formats).
4
+ * @internal
5
+ */
6
+ export const STANDARD_TEMPLATE_DEFINITIONS = [
7
+ {
8
+ localIdentifier: "rounded",
9
+ format: "#,##0",
10
+ messageId: "metricComponent.numberFormat.template.rounded",
11
+ },
12
+ {
13
+ localIdentifier: "decimal-1",
14
+ format: "#,##0.0",
15
+ messageId: "metricComponent.numberFormat.template.decimal1",
16
+ },
17
+ {
18
+ localIdentifier: "decimal-2",
19
+ format: "#,##0.00",
20
+ messageId: "metricComponent.numberFormat.template.decimal2",
21
+ },
22
+ {
23
+ localIdentifier: "percent-rounded",
24
+ format: "#,##0%",
25
+ messageId: "metricComponent.numberFormat.template.percentRounded",
26
+ },
27
+ {
28
+ localIdentifier: "percent-1",
29
+ format: "#,##0.0%",
30
+ messageId: "metricComponent.numberFormat.template.percent1",
31
+ },
32
+ {
33
+ localIdentifier: "percent-2",
34
+ format: "#,##0.00%",
35
+ messageId: "metricComponent.numberFormat.template.percent2",
36
+ },
37
+ ];
38
+ /**
39
+ * Currency format template definitions.
40
+ * @internal
41
+ */
42
+ export const CURRENCY_TEMPLATE_DEFINITIONS = [
43
+ {
44
+ localIdentifier: "currency",
45
+ format: "$#,##0.00",
46
+ messageId: "metricComponent.numberFormat.template.currency",
47
+ },
48
+ {
49
+ localIdentifier: "currency-shortened",
50
+ format: "[>=1000000000000]$#,,,,.0 T;\n" +
51
+ "[>=1000000000]$#,,,.0 B;\n" +
52
+ "[>=1000000]$#,,.0 M;\n" +
53
+ "[>=1000]$#,.0 K;\n" +
54
+ "[>=0]$#,##0;\n" +
55
+ "[<=-1000000000000]-$#,,,,.0 T;\n" +
56
+ "[<=-1000000000]-$#,,,.0 B;\n" +
57
+ "[<=-1000000]-$#,,.0 M;\n" +
58
+ "[<=-1000]-$#,.0 K;\n" +
59
+ "[<0]-$#,##0",
60
+ messageId: "metricComponent.numberFormat.template.currencyShortened",
61
+ },
62
+ ];
63
+ /**
64
+ * Advanced format template definitions (complex conditional formats).
65
+ * @internal
66
+ */
67
+ export const ADVANCED_TEMPLATE_DEFINITIONS = [
68
+ {
69
+ localIdentifier: "large-numbers-shortened",
70
+ format: "[>=1000000000000]#,,,,.0 T;\n" +
71
+ "[>=1000000000]#,,,.0 B;\n" +
72
+ "[>=1000000]#,,.0 M;\n" +
73
+ "[>=1000]#,.0 K;\n" +
74
+ "[>=0]#,##0;\n" +
75
+ "[<=-1000000000000]-#,,,,.0 T;\n" +
76
+ "[<=-1000000000]-#,,,.0 B;\n" +
77
+ "[<=-1000000]-#,,.0 M;\n" +
78
+ "[<=-1000]-#,.0 K;\n" +
79
+ "[<0]-#,##0",
80
+ messageId: "metricComponent.numberFormat.template.largeNumbersShortened",
81
+ },
82
+ {
83
+ localIdentifier: "large-numbers-shortened-with-colors",
84
+ format: "[>=1000000000000][green]#,,,,.0 T;\n" +
85
+ "[>=1000000000][green]#,,,.0 B;\n" +
86
+ "[>=1000000][green]#,,.0 M;\n" +
87
+ "[>=1000][black]#,.0 K;\n" +
88
+ "[>=0][black]#,##0;\n" +
89
+ "[<=-1000000000000][red]-#,,,,.0 T;\n" +
90
+ "[<=-1000000000][red]-#,,,.0 B;\n" +
91
+ "[<=-1000000][red]-#,,.0 M;\n" +
92
+ "[<=-1000][red]-#,.0 K;\n" +
93
+ "[<0][black]-#,##0",
94
+ messageId: "metricComponent.numberFormat.template.largeNumbersShortenedWithColors",
95
+ },
96
+ {
97
+ localIdentifier: "negative-numbers-red",
98
+ format: "[<0][red]-#,##0.0;\n[black]#,##0.0",
99
+ messageId: "metricComponent.numberFormat.template.negativeNumbersRed",
100
+ },
101
+ {
102
+ localIdentifier: "financial",
103
+ format: "[<0](#,##0.0);\n#,##0.0",
104
+ messageId: "metricComponent.numberFormat.template.financial",
105
+ },
106
+ {
107
+ localIdentifier: "decimal-without-thousands-separator",
108
+ format: "0.00",
109
+ messageId: "metricComponent.numberFormat.template.decimalWithoutThousandsSeparator",
110
+ },
111
+ {
112
+ localIdentifier: "conditional-colors",
113
+ format: "[<0][red]#,#.##;\n[<1000][black]#,0.##;\n[>=1000][green]#,#.##",
114
+ messageId: "metricComponent.numberFormat.template.conditionalColors",
115
+ },
116
+ {
117
+ localIdentifier: "trend-symbols",
118
+ format: "[<0][green]▲ #,##0.0%;\n[=0][black]#,##0.0%;\n[>0][red]▼ #,##0.0%",
119
+ messageId: "metricComponent.numberFormat.template.trendSymbols",
120
+ },
121
+ {
122
+ localIdentifier: "time-from-seconds",
123
+ format: "[>=86400]{{{86400||0d}}} {{{3600|24|00}}}h;\n" +
124
+ "[>=3600]{{{3600|24|00}}}h {{{60|60|00}}}m;\n" +
125
+ "[>=60]{{{60|60|00}}}m {{{|60.|00}}}s;\n" +
126
+ "[>0]{{{|60.|00.0}}}s;\n" +
127
+ "[=0]{{{|60.|0}}}",
128
+ messageId: "metricComponent.numberFormat.template.timeFromSeconds",
129
+ },
130
+ {
131
+ localIdentifier: "zero-instead-of-null",
132
+ format: "[=null]0.00;\n[>=0]#,#0.00;\n[<0]-#,#0.00",
133
+ messageId: "metricComponent.numberFormat.template.zeroInsteadOfNull",
134
+ },
135
+ ];
136
+ /**
137
+ * Local identifiers of templates that are currency-specific.
138
+ * Used to filter templates when metric type is CURRENCY.
139
+ * @internal
140
+ */
141
+ export const CURRENCY_TEMPLATE_IDS = CURRENCY_TEMPLATE_DEFINITIONS.map((t) => t.localIdentifier);
142
+ /**
143
+ * Default message ID prefix for template definitions.
144
+ * @internal
145
+ */
146
+ export const DEFAULT_TEMPLATE_PREFIX = "metricComponent.numberFormat.template";
147
+ /**
148
+ * Creates localized format templates.
149
+ *
150
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
151
+ * @param definitions - Template definitions to localize
152
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
153
+ * @returns Array of format templates with localized names
154
+ * @internal
155
+ */
156
+ export function createTemplates(formatMessage, definitions, messageIdPrefix = DEFAULT_TEMPLATE_PREFIX) {
157
+ return definitions.map((definition) => {
158
+ // Extract the key part from the default message ID (e.g., "rounded" from "metricComponent.numberFormat.template.rounded")
159
+ const keyPart = definition.messageId.replace(`${DEFAULT_TEMPLATE_PREFIX}.`, "");
160
+ const messageId = `${messageIdPrefix}.${keyPart}`;
161
+ return {
162
+ name: formatMessage({ id: messageId }),
163
+ localIdentifier: definition.localIdentifier,
164
+ format: definition.format,
165
+ };
166
+ });
167
+ }
168
+ /**
169
+ * Creates all localized format templates (standard + currency + advanced).
170
+ *
171
+ * @param formatMessage - Function to format localized messages (e.g., from react-intl)
172
+ * @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
173
+ * @returns Array of all format templates with localized names
174
+ * @internal
175
+ */
176
+ export function createAllTemplates(formatMessage, messageIdPrefix = DEFAULT_TEMPLATE_PREFIX) {
177
+ return [
178
+ ...createTemplates(formatMessage, STANDARD_TEMPLATE_DEFINITIONS, messageIdPrefix),
179
+ ...createTemplates(formatMessage, CURRENCY_TEMPLATE_DEFINITIONS, messageIdPrefix),
180
+ ...createTemplates(formatMessage, ADVANCED_TEMPLATE_DEFINITIONS, messageIdPrefix),
181
+ ];
182
+ }
183
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/measureNumberFormat/presets/templates.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAchC;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAmC;IACzE;QACI,eAAe,EAAE,SA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