@gooddata/sdk-ui-kit 11.13.0-alpha.2 → 11.13.0-alpha.3
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/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableCheckbox.js +1 -1
- package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableCheckbox.js.map +1 -1
- package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableToolbar.js +2 -2
- package/esm/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableToolbar.js.map +1 -1
- package/esm/@ui/UiCheckbox/UiCheckbox.d.ts.map +1 -1
- package/esm/@ui/UiCheckbox/UiCheckbox.js +9 -1
- package/esm/@ui/UiCheckbox/UiCheckbox.js.map +1 -1
- package/esm/Dropdown/DropdownButton.js +1 -1
- package/esm/Dropdown/DropdownButton.js.map +1 -1
- package/esm/measureNumberFormat/hooks/useMetricTypePresets.d.ts +115 -0
- package/esm/measureNumberFormat/hooks/useMetricTypePresets.d.ts.map +1 -0
- package/esm/measureNumberFormat/hooks/useMetricTypePresets.js +113 -0
- package/esm/measureNumberFormat/hooks/useMetricTypePresets.js.map +1 -0
- package/esm/measureNumberFormat/index.d.ts +4 -1
- package/esm/measureNumberFormat/index.d.ts.map +1 -1
- package/esm/measureNumberFormat/index.js +4 -1
- package/esm/measureNumberFormat/index.js.map +1 -1
- package/esm/measureNumberFormat/presets/currencyPresets.d.ts +7 -1
- package/esm/measureNumberFormat/presets/currencyPresets.d.ts.map +1 -1
- package/esm/measureNumberFormat/presets/currencyPresets.js +18 -7
- package/esm/measureNumberFormat/presets/currencyPresets.js.map +1 -1
- package/esm/measureNumberFormat/presets/standardPresets.d.ts +34 -0
- package/esm/measureNumberFormat/presets/standardPresets.d.ts.map +1 -0
- package/esm/measureNumberFormat/presets/standardPresets.js +71 -0
- package/esm/measureNumberFormat/presets/standardPresets.js.map +1 -0
- package/esm/measureNumberFormat/presets/templates.d.ts +60 -0
- package/esm/measureNumberFormat/presets/templates.d.ts.map +1 -0
- package/esm/measureNumberFormat/presets/templates.js +183 -0
- package/esm/measureNumberFormat/presets/templates.js.map +1 -0
- package/esm/sdk-ui-kit.d.ts +227 -1
- package/package.json +9 -9
|
@@ -5,7 +5,7 @@ import { UiCheckbox } from "../../UiCheckbox/UiCheckbox.js";
|
|
|
5
5
|
import { e } from "../asyncTableBem.js";
|
|
6
6
|
import { ASYNC_TABLE_SELECTED_COUNT_ID } from "./constants.js";
|
|
7
7
|
export function UiAsyncTableCheckbox({ onChange, checked, indeterminate, disabled, ariaLabel, isCellFocused, header, cellRef, }) {
|
|
8
|
-
return (_jsx("div", { className: e("cell", { checkbox: true, focused: isCellFocused ?? false }), role: header ?
|
|
8
|
+
return (_jsx("div", { className: e("cell", { checkbox: true, focused: isCellFocused ?? false }), role: header ? undefined : "gridcell", "aria-labelledby": header ? undefined : getColumnHeaderId("checkbox"), "aria-describedby": header ? ASYNC_TABLE_SELECTED_COUNT_ID : undefined, onClick: (e) => {
|
|
9
9
|
stopPropagationCallback(e, onChange);
|
|
10
10
|
}, onKeyDown: (e) => {
|
|
11
11
|
if (isActionKey(e)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiAsyncTableCheckbox.js","sourceRoot":"","sources":["../../../../src/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableCheckbox.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAExC,OAAO,EAAE,6BAA6B,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,UAAU,oBAAoB,CAAC,EACjC,QAAQ,EACR,OAAO,EACP,aAAa,EACb,QA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C,CAAC,EAAE,EAAE;YACb,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,uBAAuB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACzC,CAAC;QACL,CAAC,EACD,GAAG,EAAE,OAA8B,YAEnC,KAAC,UAAU,IACP,OAAO,EAAE,OAAO,IAAI,KAAK,EACzB,cAAc,QACd,aAAa,EAAE,aAAa,EAC5B,QAAQ,EAAE,QAAQ,EAClB,mBAAmB,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,SAAS,EAC1D,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3B,GACA,CACT,CAAC;AACN,CAAC"}
|
|
@@ -31,8 +31,8 @@ const useAsyncTableToolbar = ({ filters, isFiltersTooLarge, bulkActions, selecte
|
|
|
31
31
|
return !!selectedItemIds?.length;
|
|
32
32
|
}, [selectedItemIds]);
|
|
33
33
|
const isCheckboxIndeterminate = useMemo(() => {
|
|
34
|
-
return !!bulkActions && selectedItemIds?.length !== items.length;
|
|
35
|
-
}, [bulkActions, selectedItemIds, items]);
|
|
34
|
+
return !!bulkActions && isCheckboxChecked && selectedItemIds?.length !== items.length;
|
|
35
|
+
}, [bulkActions, isCheckboxChecked, selectedItemIds, items]);
|
|
36
36
|
const checkboxAriaLabel = accessibilityConfig?.checkboxAllAriaLabel;
|
|
37
37
|
const renderBulkActions = useCallback(() => {
|
|
38
38
|
const selectedCount = selectedItemIds?.length ?? 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiAsyncTableToolbar.js","sourceRoot":"","sources":["../../../../src/@ui/UiAsyncTable/UiAsyncTable/UiAsyncTableToolbar.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAEhC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAE,MA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EACF,cAAK,SAAS,EAAE,CAAC,CAAC,gBAAgB,CAAC,YAC/B,KAAC,KAAK,IACF,QAAQ,QACR,IAAI,EAAC,QAAQ,EACb,OAAO,QACP,UAAU,QACV,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE;oCACjB,SAAS,EAAE,mBAAmB,EAAE,eAAe,IAAI,WAAW;iCACjE,EACD,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACpD,GACA,IACP,CACN,CAAC,CAAC,CAAC,IAAI,EACP,0BAA0B,CAAC,CAAC,CAAC,0BAA0B,EAAE,CAAC,CAAC,CAAC,IAAI,IAC/D,CACT,CAAC;IACN,CAAC,EAAE;QACC,QAAQ;QACR,0BAA0B;QAC1B,IAAI;QACJ,WAAW;QACX,cAAc;QACd,mBAAmB,EAAE,eAAe;QACpC,eAAe;KAClB,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,OAAO,OAAO,EAAE,MAAM,IAAI,WAAW,CAAC;IAC1C,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAE3B,OAAO;QACH,UAAU;QACV,iBAAiB;QACjB,aAAa;QACb,mBAAmB;KACtB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCheckbox.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiCheckbox/UiCheckbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"UiCheckbox.d.ts","sourceRoot":"","sources":["../../../src/@ui/UiCheckbox/UiCheckbox.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAqB,MAAM,OAAO,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAI1E;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IACtD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,wBAAwB,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAID;;GAEG;AACH,wBAAgB,UAAU,CAAC,EACvB,OAAO,EACP,QAAmB,EACnB,cAAsB,EACtB,aAAqB,EACrB,QAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,KAAK,GACR,EAAE,eAAe,2CA0BjB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2025 GoodData Corporation
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
2
4
|
import { accessibilityConfigToAttributes } from "../../typings/utilities.js";
|
|
3
5
|
import { bem } from "../@utils/bem.js";
|
|
4
6
|
const { b, e } = bem("gd-ui-kit-checkbox");
|
|
@@ -6,6 +8,12 @@ const { b, e } = bem("gd-ui-kit-checkbox");
|
|
|
6
8
|
* @internal
|
|
7
9
|
*/
|
|
8
10
|
export function UiCheckbox({ checked, onChange = () => { }, preventDefault = false, indeterminate = false, disabled = false, accessibilityConfig, tabIndex, label, }) {
|
|
9
|
-
|
|
11
|
+
const inputRef = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (inputRef.current) {
|
|
14
|
+
inputRef.current.indeterminate = indeterminate;
|
|
15
|
+
}
|
|
16
|
+
}, [indeterminate]);
|
|
17
|
+
return (_jsxs("label", { className: b(), children: [_jsx("input", { ref: inputRef, type: "checkbox", className: e("input"), checked: checked, onChange: onChange, disabled: disabled, onClick: (e) => preventDefault && e.stopPropagation(), tabIndex: tabIndex, ...accessibilityConfigToAttributes(accessibilityConfig) }), _jsx("span", { className: e("box", { checked, indeterminate, disabled }) }), label ? _jsx("span", { className: e("label") + " gd-label", children: label }) : null] }));
|
|
10
18
|
}
|
|
11
19
|
//# sourceMappingURL=UiCheckbox.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCheckbox.js","sourceRoot":"","sources":["../../../src/@ui/UiCheckbox/UiCheckbox.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"UiCheckbox.js","sourceRoot":"","sources":["../../../src/@ui/UiCheckbox/UiCheckbox.tsx"],"names":[],"mappings":";AAAA,gCAAgC;AAEhC,OAAO,EAAe,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAGvD,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAgBvC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAE3C;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,EACvB,OAAO,EACP,QAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,EACnB,cAAc,GAAG,KAAK,EACtB,aAAa,GAAG,KAAK,EACrB,QAAQ,GAAG,KAAK,EAChB,mBAAmB,EACnB,QAAQ,EACR,KAAK,GACS;IACd,MAAM,QAAQ,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEhD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,aAAa,CAAC;QACnD,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO,CACH,iBAAO,SAAS,EAAE,CAAC,EAAE,a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,iBAAiB,EACjB;QACI,iBAAiB,EAAE,OAAO;QAC1B,kBAAkB,EAAE,MAAM;QAC1B,WAAW,EAAE,MAAM;QACnB,eAAe,EAAE,WAAW;KAC/B,EACD,SAAS,CACZ,CAAC;IAEF,MAAM,yBAAyB,GAAG,CAC9B,UAAU;QACN,CAAC,CAAC;YACI,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,UAAU;YACnB,SAAS;YACT,cAAc;YACd,YAAY;YACZ,eAAe;YACf,YAAY;
|
|
1
|
+
{"version":3,"file":"DropdownButton.js","sourceRoot":"","sources":["../../src/Dropdown/DropdownButton.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AA4B7C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,EAC3B,EAAE,EACF,SAAS,EACT,mBAAmB,EAEnB,KAAK,EACL,KAAK,GAAG,KAAK,EACb,QAAQ,EAER,MAAM,EACN,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,WAAW,GAAG,KAAK,EACnB,OAAO,EACP,QAAQ,EACR,UAAU,EACV,SAAS,GACU;IACnB,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,GAC7F,mBAAmB,IAAI,EAAE,CAAC;IAE9B,MAAM,aAAa,GAAG,EAAE,CACpB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB;QACI,iBAAiB,EAAE,OAAO;QAC1B,kBAAkB,EAAE,MAAM;QAC1B,WAAW,EAAE,MAAM;QACnB,eAAe,EAAE,WAAW;KAC/B,EACD,SAAS,CACZ,CAAC;IAEF,MAAM,yBAAyB,GAAG,CAC9B,UAAU;QACN,CAAC,CAAC;YACI,UAAU,EAAE,MAAM;YAClB,OAAO,EAAE,UAAU;YACnB,SAAS;YACT,cAAc;YACd,YAAY;YACZ,eAAe;YACf,YAAY,EAAE,YAAY,IAAI,UAAU;YACxC,IAAI,EAAE,IAAI,IAAI,UAAU;YACxB,SAAS;SACZ;QACH,CAAC,CAAC;YACI,SAAS;YACT,cAAc;YACd,YAAY;YACZ,YAAY;YACZ,IAAI,EAAE,IAAI,IAAI,UAAU;SAC3B,CAC2B,CAAC;IAEvC,OAAO,CACH,KAAC,MAAM,IACH,EAAE,EAAE,EAAE,EACN,mBAAmB,EAAE,yBAAyB,EAC9C,KAAK,EAAE,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,EAC7D,SAAS,EAAE,aAAa,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,sBAAsB,EACjE,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,SAAS,YAEb,QAAQ,GACJ,CACZ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { MetricType } from "@gooddata/sdk-model";
|
|
2
|
+
import { type IFormatPreset, type IFormatTemplate } from "../typings.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for the useMetricTypePresets hook.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export interface UseMetricTypePresetsConfig {
|
|
8
|
+
/**
|
|
9
|
+
* The metric type. When "CURRENCY", currency-specific presets are shown.
|
|
10
|
+
* When undefined, standard numeric presets are shown.
|
|
11
|
+
*/
|
|
12
|
+
metricType?: MetricType;
|
|
13
|
+
/**
|
|
14
|
+
* The currency format override from workspace settings.
|
|
15
|
+
* When set and metricType is "CURRENCY", an "inherit" preset is added.
|
|
16
|
+
*/
|
|
17
|
+
currencyFormatOverride?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Function to format localized messages (e.g., from react-intl).
|
|
20
|
+
*/
|
|
21
|
+
formatMessage: (descriptor: {
|
|
22
|
+
id: string;
|
|
23
|
+
}) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional prefix for preset message IDs.
|
|
26
|
+
* Default: "metricComponent.numberFormat.preset"
|
|
27
|
+
*
|
|
28
|
+
* Use this to customize the translation keys for presets.
|
|
29
|
+
* For example, set to "measure_number_format.preset" for Analytical Designer compatibility.
|
|
30
|
+
*/
|
|
31
|
+
presetMessageIdPrefix?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional prefix for template message IDs.
|
|
34
|
+
* Default: "metricComponent.numberFormat.template"
|
|
35
|
+
*
|
|
36
|
+
* Use this to customize the translation keys for templates.
|
|
37
|
+
* For example, set to "measure_number_format.template" for Analytical Designer compatibility.
|
|
38
|
+
*/
|
|
39
|
+
templateMessageIdPrefix?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result from the useMetricTypePresets hook.
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
export interface UseMetricTypePresetsResult {
|
|
46
|
+
/**
|
|
47
|
+
* Format presets based on metric type.
|
|
48
|
+
* For CURRENCY: currency presets with optional inherit preset.
|
|
49
|
+
* For other types: standard numeric presets.
|
|
50
|
+
*/
|
|
51
|
+
presets: IFormatPreset[];
|
|
52
|
+
/**
|
|
53
|
+
* Format templates. For CURRENCY metrics, currency templates are excluded
|
|
54
|
+
* from the general list (they're already in presets).
|
|
55
|
+
*/
|
|
56
|
+
templates: IFormatTemplate[];
|
|
57
|
+
/**
|
|
58
|
+
* The inherit preset if available (only for CURRENCY with override).
|
|
59
|
+
*/
|
|
60
|
+
inheritPreset: IFormatPreset | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Hook that creates format presets and templates based on metric type.
|
|
64
|
+
*
|
|
65
|
+
* This hook encapsulates the logic for building format options that respect:
|
|
66
|
+
* - Metric type (CURRENCY vs standard)
|
|
67
|
+
* - Currency format override (creates "inherit" preset)
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const { presets, templates, inheritPreset } = useMetricTypePresets({
|
|
72
|
+
* metricType: "CURRENCY",
|
|
73
|
+
* currencyFormatOverride: "$#,##0.00",
|
|
74
|
+
* formatMessage: (d) => intl.formatMessage(d),
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* // With custom message ID prefixes (e.g., for Analytical Designer)
|
|
81
|
+
* const { presets, templates } = useMetricTypePresets({
|
|
82
|
+
* metricType: undefined,
|
|
83
|
+
* formatMessage: (d) => intl.formatMessage(d),
|
|
84
|
+
* presetMessageIdPrefix: "measure_number_format.preset",
|
|
85
|
+
* templateMessageIdPrefix: "measure_number_format.template",
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
export declare function useMetricTypePresets({ metricType, currencyFormatOverride, formatMessage, presetMessageIdPrefix, templateMessageIdPrefix, }: UseMetricTypePresetsConfig): UseMetricTypePresetsResult;
|
|
92
|
+
/**
|
|
93
|
+
* Hook that creates standard numeric format presets.
|
|
94
|
+
* Use this when you don't need metric type awareness.
|
|
95
|
+
*
|
|
96
|
+
* @param formatMessage - Function to format localized messages
|
|
97
|
+
* @returns Array of standard format presets
|
|
98
|
+
* @internal
|
|
99
|
+
*/
|
|
100
|
+
export declare function useStandardPresets(formatMessage: (descriptor: {
|
|
101
|
+
id: string;
|
|
102
|
+
}) => string): IFormatPreset[];
|
|
103
|
+
/**
|
|
104
|
+
* Hook that creates all format templates.
|
|
105
|
+
* Use this when you need templates without metric type filtering.
|
|
106
|
+
*
|
|
107
|
+
* @param formatMessage - Function to format localized messages
|
|
108
|
+
* @param excludeCurrencyTemplates - Whether to exclude currency-specific templates
|
|
109
|
+
* @returns Array of format templates
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export declare function useFormatTemplates(formatMessage: (descriptor: {
|
|
113
|
+
id: string;
|
|
114
|
+
}) => string, excludeCurrencyTemplates?: boolean): IFormatTemplate[];
|
|
115
|
+
//# sourceMappingURL=useMetricTypePresets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMetricTypePresets.d.ts","sourceRoot":"","sources":["../../../src/measureNumberFormat/hooks/useMetricTypePresets.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAKtD,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzE;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IAExB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvC;;OAEG;IACH,aAAa,EAAE,CAAC,UAAU,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAC;IAEtD;;;;;;OAMG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B;;;;;;OAMG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACvC;;;;OAIG;IACH,OAAO,EAAE,aAAa,EAAE,CAAC;IAEzB;;;OAGG;IACH,SAAS,EAAE,eAAe,EAAE,CAAC;IAE7B;;OAEG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,oBAAoB,CAAC,EACjC,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,qBAAsD,EACtD,uBAAiD,GACpD,EAAE,0BAA0B,GAAG,0BAA0B,CA8DzD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,GAAG,aAAa,EAAE,CAEzG;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAC9B,aAAa,EAAE,CAAC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,KAAK,MAAM,EACrD,wBAAwB,UAAQ,GACjC,eAAe,EAAE,CAQnB"}
|
|
@@ -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":"useMetricTypePresets.js","sourceRoot":"","sources":["../../../src/measureNumberFormat/hooks/useMetricTypePresets.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAEhC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIhC,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtG,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAoE7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,oBAAoB,CAAC,EACjC,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,qBAAqB,GAAG,8BAA8B,EACtD,uBAAuB,GAAG,uBAAuB,GACxB;IACzB,2BAA2B;IAC3B,MAAM,eAAe,GAAG,OAAO,CAC3B,GAAG,EAAE,CAAC,qBAAqB,CAAC,aAAa,EAAE,qBAAqB,CAAC,EACjE,CAAC,aAAa,EAAE,qBAAqB,CAAC,CACzC,CAAC;IAEF,wBAAwB;IACxB,MAAM,mBAAmB,GAAG,OAAO,CAC/B,GAAG,EAAE,CAAC,qBAAqB,CAAC,aAAa,EAAE,qBAAqB,CAAC,EACjE,CAAC,aAAa,EAAE,qBAAqB,CAAC,CACzC,CAAC;IAEF,yEAAyE;IACzE,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE;QACjC,IAAI,CAAC,sBAAsB,EAAE,CAAC;YAC1B,OAAO,mB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AAC,CAAC,CAAC,eAAe,CAAC,CACpD,CAAC;QACN,CAAC;QACD,uCAAuC;QACvC,OAAO,kBAAkB,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC;IACtE,CAAC,EAAE,CAAC,UAAU,EAAE,aAAa,EAAE,uBAAuB,CAAC,CAAC,CAAC;IAEzD,OAAO;QACH,OAAO;QACP,SAAS;QACT,aAAa;KAChB,CAAC;AACN,CAAC;AAED;;;;;;;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,
|
|
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
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
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,SAAS;QAC1B,MAAM,EAAE,OAAO;QACf,SAAS,EAAE,+CAA+C;KAC7D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,gDAAgD;KAC9D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,gDAAgD;KAC9D;IACD;QACI,eAAe,EAAE,iBAAiB;QAClC,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,sDAAsD;KACpE;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,gDAAgD;KAC9D;IACD;QACI,eAAe,EAAE,WAAW;QAC5B,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,gDAAgD;KAC9D;CACK,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAmC;IACzE;QACI,eAAe,EAAE,UAAU;QAC3B,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,gDAAgD;KAC9D;IACD;QACI,eAAe,EAAE,oBAAoB;QACrC,MAAM,EACF,gCAAgC;YAChC,4BAA4B;YAC5B,wBAAwB;YACxB,oBAAoB;YACpB,gBAAgB;YAChB,kC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,EAAE,2CAA2C;QACnD,SAAS,EAAE,yDAAyD;KACvE;CACK,CAAC;AAEX;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,6BAA6B,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;AAEjG;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,uCAAuC,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC3B,aAAqD,EACrD,WAA2C,EAC3C,kBAA0B,uBAAuB;IAEjD,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;QAClC,0HAA0H;QAC1H,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,uBAAuB,GAAG,EAAE,EAAE,CAAC,CAAC;QAChF,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;SAC5B,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAC9B,aAAqD,EACrD,kBAA0B,uBAAuB;IAEjD,OAAO;QACH,GAAG,eAAe,CAAC,aAAa,EAAE,6BAA6B,EAAE,eAAe,CAAC;QACjF,GAAG,eAAe,CAAC,aAAa,EAAE,6BAA6B,EAAE,eAAe,CAAC;QACjF,GAAG,eAAe,CAAC,aAAa,EAAE,6BAA6B,EAAE,eAAe,CAAC;KACpF,CAAC;AACN,CAAC"}
|
package/esm/sdk-ui-kit.d.ts
CHANGED
|
@@ -121,6 +121,12 @@ export declare function AddGranteeBase({ appliedGrantees, addedGrantees, current
|
|
|
121
121
|
*/
|
|
122
122
|
export declare type AddMessageType = (message: MessageDescriptor, options?: MessageParameters) => IMessage;
|
|
123
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Advanced format template definitions (complex conditional formats).
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
export declare const ADVANCED_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
|
|
129
|
+
|
|
124
130
|
/**
|
|
125
131
|
* @internal
|
|
126
132
|
*/
|
|
@@ -468,16 +474,54 @@ export declare function ContentDivider({ className }: {
|
|
|
468
474
|
*/
|
|
469
475
|
export declare type CopyCodeOriginType = "keyboard" | "button";
|
|
470
476
|
|
|
477
|
+
/**
|
|
478
|
+
* Creates all localized format templates (standard + currency + advanced).
|
|
479
|
+
*
|
|
480
|
+
* @param formatMessage - Function to format localized messages (e.g., from react-intl)
|
|
481
|
+
* @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
|
|
482
|
+
* @returns Array of all format templates with localized names
|
|
483
|
+
* @internal
|
|
484
|
+
*/
|
|
485
|
+
export declare function createAllTemplates(formatMessage: (descriptor: {
|
|
486
|
+
id: string;
|
|
487
|
+
}) => string, messageIdPrefix?: string): IFormatTemplate[];
|
|
488
|
+
|
|
471
489
|
/**
|
|
472
490
|
* Creates localized currency format presets.
|
|
473
491
|
*
|
|
474
492
|
* @param formatMessage - Function to format localized messages (e.g., from react-intl)
|
|
493
|
+
* @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
|
|
475
494
|
* @returns Array of currency format presets with localized names
|
|
476
495
|
* @internal
|
|
477
496
|
*/
|
|
478
497
|
export declare function createCurrencyPresets(formatMessage: (descriptor: {
|
|
479
498
|
id: string;
|
|
480
|
-
}) => string): IFormatPreset[];
|
|
499
|
+
}) => string, messageIdPrefix?: string): IFormatPreset[];
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Creates localized standard format presets.
|
|
503
|
+
*
|
|
504
|
+
* @param formatMessage - Function to format localized messages (e.g., from react-intl)
|
|
505
|
+
* @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.preset")
|
|
506
|
+
* @returns Array of standard format presets with localized names
|
|
507
|
+
* @internal
|
|
508
|
+
*/
|
|
509
|
+
export declare function createStandardPresets(formatMessage: (descriptor: {
|
|
510
|
+
id: string;
|
|
511
|
+
}) => string, messageIdPrefix?: string): IFormatPreset[];
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Creates localized format templates.
|
|
515
|
+
*
|
|
516
|
+
* @param formatMessage - Function to format localized messages (e.g., from react-intl)
|
|
517
|
+
* @param definitions - Template definitions to localize
|
|
518
|
+
* @param messageIdPrefix - Optional prefix for message IDs (default: "metricComponent.numberFormat.template")
|
|
519
|
+
* @returns Array of format templates with localized names
|
|
520
|
+
* @internal
|
|
521
|
+
*/
|
|
522
|
+
export declare function createTemplates(formatMessage: (descriptor: {
|
|
523
|
+
id: string;
|
|
524
|
+
}) => string, definitions: readonly ITemplateDefinition[], messageIdPrefix?: string): IFormatTemplate[];
|
|
481
525
|
|
|
482
526
|
/**
|
|
483
527
|
* Base currency preset definitions.
|
|
@@ -486,6 +530,19 @@ export declare function createCurrencyPresets(formatMessage: (descriptor: {
|
|
|
486
530
|
*/
|
|
487
531
|
export declare const CURRENCY_PRESET_DEFINITIONS: readonly ICurrencyPresetDefinition[];
|
|
488
532
|
|
|
533
|
+
/**
|
|
534
|
+
* Currency format template definitions.
|
|
535
|
+
* @internal
|
|
536
|
+
*/
|
|
537
|
+
export declare const CURRENCY_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Local identifiers of templates that are currency-specific.
|
|
541
|
+
* Used to filter templates when metric type is CURRENCY.
|
|
542
|
+
* @internal
|
|
543
|
+
*/
|
|
544
|
+
export declare const CURRENCY_TEMPLATE_IDS: string[];
|
|
545
|
+
|
|
489
546
|
/**
|
|
490
547
|
* @alpha
|
|
491
548
|
*/
|
|
@@ -515,6 +572,12 @@ export declare class Datepicker extends PureComponent<IDatePickerOwnProps> {
|
|
|
515
572
|
render(): JSX.Element;
|
|
516
573
|
}
|
|
517
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Default message ID prefix for currency preset definitions.
|
|
577
|
+
* @internal
|
|
578
|
+
*/
|
|
579
|
+
export declare const DEFAULT_CURRENCY_PRESET_PREFIX = "metricComponent.numberFormat.preset";
|
|
580
|
+
|
|
518
581
|
/**
|
|
519
582
|
* @internal
|
|
520
583
|
*/
|
|
@@ -525,6 +588,18 @@ export declare const DEFAULT_ITEM_HEIGHT = 28;
|
|
|
525
588
|
*/
|
|
526
589
|
export declare const DEFAULT_MOBILE_ITEM_HEIGHT = 40;
|
|
527
590
|
|
|
591
|
+
/**
|
|
592
|
+
* Default message ID prefix for standard preset definitions.
|
|
593
|
+
* @internal
|
|
594
|
+
*/
|
|
595
|
+
export declare const DEFAULT_STANDARD_PRESET_PREFIX = "metricComponent.numberFormat.preset";
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Default message ID prefix for template definitions.
|
|
599
|
+
* @internal
|
|
600
|
+
*/
|
|
601
|
+
export declare const DEFAULT_TEMPLATE_PREFIX = "metricComponent.numberFormat.template";
|
|
602
|
+
|
|
528
603
|
/**
|
|
529
604
|
* Dummy theme metadata object which represents the default colors of GD.
|
|
530
605
|
*
|
|
@@ -5399,6 +5474,17 @@ export declare const isSpaceKey: (event: KeyboardEvent_2) => boolean;
|
|
|
5399
5474
|
*/
|
|
5400
5475
|
export declare const isTabKey: (event: KeyboardEvent_2) => boolean;
|
|
5401
5476
|
|
|
5477
|
+
/**
|
|
5478
|
+
* Base standard preset definition without localized name.
|
|
5479
|
+
* @internal
|
|
5480
|
+
*/
|
|
5481
|
+
export declare interface IStandardPresetDefinition {
|
|
5482
|
+
localIdentifier: string;
|
|
5483
|
+
format: string;
|
|
5484
|
+
previewNumber: number;
|
|
5485
|
+
messageId: string;
|
|
5486
|
+
}
|
|
5487
|
+
|
|
5402
5488
|
/**
|
|
5403
5489
|
* @internal
|
|
5404
5490
|
*/
|
|
@@ -5540,6 +5626,16 @@ export declare interface ITabsState {
|
|
|
5540
5626
|
*/
|
|
5541
5627
|
export declare function Item({ checked, subMenu, disabled, className, children, style, onClick, }: IItemProps): JSX.Element;
|
|
5542
5628
|
|
|
5629
|
+
/**
|
|
5630
|
+
* Base template definition without localized name.
|
|
5631
|
+
* @internal
|
|
5632
|
+
*/
|
|
5633
|
+
export declare interface ITemplateDefinition {
|
|
5634
|
+
localIdentifier: string;
|
|
5635
|
+
format: string;
|
|
5636
|
+
messageId: string;
|
|
5637
|
+
}
|
|
5638
|
+
|
|
5543
5639
|
/**
|
|
5544
5640
|
* @internal
|
|
5545
5641
|
*/
|
|
@@ -7047,6 +7143,19 @@ export declare const Spinner: NamedExoticComponent<ISpinnerProps>;
|
|
|
7047
7143
|
*/
|
|
7048
7144
|
export declare type SpinnerSize = "large" | "small";
|
|
7049
7145
|
|
|
7146
|
+
/**
|
|
7147
|
+
* Standard numeric preset definitions.
|
|
7148
|
+
* These are the raw preset data that can be used to create localized presets.
|
|
7149
|
+
* @internal
|
|
7150
|
+
*/
|
|
7151
|
+
export declare const STANDARD_PRESET_DEFINITIONS: readonly IStandardPresetDefinition[];
|
|
7152
|
+
|
|
7153
|
+
/**
|
|
7154
|
+
* Standard format template definitions (basic numeric formats).
|
|
7155
|
+
* @internal
|
|
7156
|
+
*/
|
|
7157
|
+
export declare const STANDARD_TEMPLATE_DEFINITIONS: readonly ITemplateDefinition[];
|
|
7158
|
+
|
|
7050
7159
|
/**
|
|
7051
7160
|
* Properties for BEM modifiers.
|
|
7052
7161
|
*
|
|
@@ -8324,6 +8433,19 @@ export declare function useFocusWithinContainer(idToFocus?: string | null): {
|
|
|
8324
8433
|
containerRef: RefObject<HTMLElement | null>;
|
|
8325
8434
|
};
|
|
8326
8435
|
|
|
8436
|
+
/**
|
|
8437
|
+
* Hook that creates all format templates.
|
|
8438
|
+
* Use this when you need templates without metric type filtering.
|
|
8439
|
+
*
|
|
8440
|
+
* @param formatMessage - Function to format localized messages
|
|
8441
|
+
* @param excludeCurrencyTemplates - Whether to exclude currency-specific templates
|
|
8442
|
+
* @returns Array of format templates
|
|
8443
|
+
* @internal
|
|
8444
|
+
*/
|
|
8445
|
+
export declare function useFormatTemplates(formatMessage: (descriptor: {
|
|
8446
|
+
id: string;
|
|
8447
|
+
}) => string, excludeCurrencyTemplates?: boolean): IFormatTemplate[];
|
|
8448
|
+
|
|
8327
8449
|
/**
|
|
8328
8450
|
* Internal context hook used to provide header search drop-down state to the components.
|
|
8329
8451
|
* @internal
|
|
@@ -8399,6 +8521,98 @@ export declare function useListWithActionsKeyboardNavigation<Item, Action extend
|
|
|
8399
8521
|
*/
|
|
8400
8522
|
export declare const useMediaQuery: (mediaQueryName: keyof IMediaQueries) => boolean;
|
|
8401
8523
|
|
|
8524
|
+
/**
|
|
8525
|
+
* Hook that creates format presets and templates based on metric type.
|
|
8526
|
+
*
|
|
8527
|
+
* This hook encapsulates the logic for building format options that respect:
|
|
8528
|
+
* - Metric type (CURRENCY vs standard)
|
|
8529
|
+
* - Currency format override (creates "inherit" preset)
|
|
8530
|
+
*
|
|
8531
|
+
* @example
|
|
8532
|
+
* ```tsx
|
|
8533
|
+
* const { presets, templates, inheritPreset } = useMetricTypePresets({
|
|
8534
|
+
* metricType: "CURRENCY",
|
|
8535
|
+
* currencyFormatOverride: "$#,##0.00",
|
|
8536
|
+
* formatMessage: (d) => intl.formatMessage(d),
|
|
8537
|
+
* });
|
|
8538
|
+
* ```
|
|
8539
|
+
*
|
|
8540
|
+
* @example
|
|
8541
|
+
* ```tsx
|
|
8542
|
+
* // With custom message ID prefixes (e.g., for Analytical Designer)
|
|
8543
|
+
* const { presets, templates } = useMetricTypePresets({
|
|
8544
|
+
* metricType: undefined,
|
|
8545
|
+
* formatMessage: (d) => intl.formatMessage(d),
|
|
8546
|
+
* presetMessageIdPrefix: "measure_number_format.preset",
|
|
8547
|
+
* templateMessageIdPrefix: "measure_number_format.template",
|
|
8548
|
+
* });
|
|
8549
|
+
* ```
|
|
8550
|
+
*
|
|
8551
|
+
* @internal
|
|
8552
|
+
*/
|
|
8553
|
+
export declare function useMetricTypePresets({ metricType, currencyFormatOverride, formatMessage, presetMessageIdPrefix, templateMessageIdPrefix, }: UseMetricTypePresetsConfig): UseMetricTypePresetsResult;
|
|
8554
|
+
|
|
8555
|
+
/**
|
|
8556
|
+
* Configuration for the useMetricTypePresets hook.
|
|
8557
|
+
* @internal
|
|
8558
|
+
*/
|
|
8559
|
+
export declare interface UseMetricTypePresetsConfig {
|
|
8560
|
+
/**
|
|
8561
|
+
* The metric type. When "CURRENCY", currency-specific presets are shown.
|
|
8562
|
+
* When undefined, standard numeric presets are shown.
|
|
8563
|
+
*/
|
|
8564
|
+
metricType?: MetricType;
|
|
8565
|
+
/**
|
|
8566
|
+
* The currency format override from workspace settings.
|
|
8567
|
+
* When set and metricType is "CURRENCY", an "inherit" preset is added.
|
|
8568
|
+
*/
|
|
8569
|
+
currencyFormatOverride?: string | null;
|
|
8570
|
+
/**
|
|
8571
|
+
* Function to format localized messages (e.g., from react-intl).
|
|
8572
|
+
*/
|
|
8573
|
+
formatMessage: (descriptor: {
|
|
8574
|
+
id: string;
|
|
8575
|
+
}) => string;
|
|
8576
|
+
/**
|
|
8577
|
+
* Optional prefix for preset message IDs.
|
|
8578
|
+
* Default: "metricComponent.numberFormat.preset"
|
|
8579
|
+
*
|
|
8580
|
+
* Use this to customize the translation keys for presets.
|
|
8581
|
+
* For example, set to "measure_number_format.preset" for Analytical Designer compatibility.
|
|
8582
|
+
*/
|
|
8583
|
+
presetMessageIdPrefix?: string;
|
|
8584
|
+
/**
|
|
8585
|
+
* Optional prefix for template message IDs.
|
|
8586
|
+
* Default: "metricComponent.numberFormat.template"
|
|
8587
|
+
*
|
|
8588
|
+
* Use this to customize the translation keys for templates.
|
|
8589
|
+
* For example, set to "measure_number_format.template" for Analytical Designer compatibility.
|
|
8590
|
+
*/
|
|
8591
|
+
templateMessageIdPrefix?: string;
|
|
8592
|
+
}
|
|
8593
|
+
|
|
8594
|
+
/**
|
|
8595
|
+
* Result from the useMetricTypePresets hook.
|
|
8596
|
+
* @internal
|
|
8597
|
+
*/
|
|
8598
|
+
export declare interface UseMetricTypePresetsResult {
|
|
8599
|
+
/**
|
|
8600
|
+
* Format presets based on metric type.
|
|
8601
|
+
* For CURRENCY: currency presets with optional inherit preset.
|
|
8602
|
+
* For other types: standard numeric presets.
|
|
8603
|
+
*/
|
|
8604
|
+
presets: IFormatPreset[];
|
|
8605
|
+
/**
|
|
8606
|
+
* Format templates. For CURRENCY metrics, currency templates are excluded
|
|
8607
|
+
* from the general list (they're already in presets).
|
|
8608
|
+
*/
|
|
8609
|
+
templates: IFormatTemplate[];
|
|
8610
|
+
/**
|
|
8611
|
+
* The inherit preset if available (only for CURRENCY with override).
|
|
8612
|
+
*/
|
|
8613
|
+
inheritPreset: IFormatPreset | null;
|
|
8614
|
+
}
|
|
8615
|
+
|
|
8402
8616
|
/**
|
|
8403
8617
|
* Hook to get current instance of the {@link OverlayController}
|
|
8404
8618
|
*
|
|
@@ -8468,6 +8682,18 @@ export declare const useScrollContext: () => {
|
|
|
8468
8682
|
scrollIntoView: (_element: HTMLElement, _bottomMargin?: number, _isElementInvisibleCheck?: isElementInvisibleType) => void;
|
|
8469
8683
|
};
|
|
8470
8684
|
|
|
8685
|
+
/**
|
|
8686
|
+
* Hook that creates standard numeric format presets.
|
|
8687
|
+
* Use this when you don't need metric type awareness.
|
|
8688
|
+
*
|
|
8689
|
+
* @param formatMessage - Function to format localized messages
|
|
8690
|
+
* @returns Array of standard format presets
|
|
8691
|
+
* @internal
|
|
8692
|
+
*/
|
|
8693
|
+
export declare function useStandardPresets(formatMessage: (descriptor: {
|
|
8694
|
+
id: string;
|
|
8695
|
+
}) => string): IFormatPreset[];
|
|
8696
|
+
|
|
8471
8697
|
/**
|
|
8472
8698
|
* @internal
|
|
8473
8699
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gooddata/sdk-ui-kit",
|
|
3
|
-
"version": "11.13.0-alpha.
|
|
3
|
+
"version": "11.13.0-alpha.3",
|
|
4
4
|
"description": "GoodData SDK - UI Building Components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -76,11 +76,11 @@
|
|
|
76
76
|
"tslib": "2.8.1",
|
|
77
77
|
"unified": "^11.0.5",
|
|
78
78
|
"uuid": "^11.1.0",
|
|
79
|
-
"@gooddata/sdk-backend-spi": "11.13.0-alpha.
|
|
80
|
-
"@gooddata/sdk-model": "11.13.0-alpha.
|
|
81
|
-
"@gooddata/
|
|
82
|
-
"@gooddata/sdk-ui-theme-provider": "11.13.0-alpha.
|
|
83
|
-
"@gooddata/
|
|
79
|
+
"@gooddata/sdk-backend-spi": "11.13.0-alpha.3",
|
|
80
|
+
"@gooddata/sdk-model": "11.13.0-alpha.3",
|
|
81
|
+
"@gooddata/sdk-ui": "11.13.0-alpha.3",
|
|
82
|
+
"@gooddata/sdk-ui-theme-provider": "11.13.0-alpha.3",
|
|
83
|
+
"@gooddata/util": "11.13.0-alpha.3"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@gooddata/stylelint-config": "^5.0.0",
|
|
@@ -130,9 +130,9 @@
|
|
|
130
130
|
"typescript": "5.8.3",
|
|
131
131
|
"vitest": "3.2.4",
|
|
132
132
|
"vitest-dom": "0.1.1",
|
|
133
|
-
"@gooddata/
|
|
134
|
-
"@gooddata/
|
|
135
|
-
"@gooddata/sdk-backend-mockingbird": "11.13.0-alpha.
|
|
133
|
+
"@gooddata/reference-workspace": "11.13.0-alpha.3",
|
|
134
|
+
"@gooddata/eslint-config": "11.13.0-alpha.3",
|
|
135
|
+
"@gooddata/sdk-backend-mockingbird": "11.13.0-alpha.3"
|
|
136
136
|
},
|
|
137
137
|
"peerDependencies": {
|
|
138
138
|
"react": "^18.0.0 || ^19.0.0",
|