@synerise/ds-format-picker 1.1.23 → 1.1.25
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/CHANGELOG.md +8 -0
- package/README.md +26 -21
- package/dist/FomartPicker.types.d.ts +1 -1
- package/dist/FomartPicker.types.js +1 -1
- package/dist/FormatPicker.d.ts +2 -2
- package/dist/FormatPicker.js +104 -120
- package/dist/FormatSettings/FormatSettings.d.ts +2 -2
- package/dist/FormatSettings/FormatSettings.js +87 -143
- package/dist/FormatSettings/FormatSettings.styles.d.ts +11 -11
- package/dist/FormatSettings/FormatSettings.styles.js +36 -39
- package/dist/FormatSettings/FormatSettings.types.d.ts +2 -2
- package/dist/FormatSettings/FormatSettings.types.js +1 -1
- package/dist/index.js +4 -1
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/package.json +14 -14
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.25](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@1.1.24...@synerise/ds-format-picker@1.1.25) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-format-picker
|
|
9
|
+
|
|
10
|
+
## [1.1.24](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@1.1.23...@synerise/ds-format-picker@1.1.24) (2026-03-20)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-format-picker
|
|
13
|
+
|
|
6
14
|
## [1.1.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-format-picker@1.1.22...@synerise/ds-format-picker@1.1.23) (2026-03-09)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-format-picker
|
package/README.md
CHANGED
|
@@ -37,31 +37,36 @@ import FormatPicker from '@synerise/ds-format-picker'
|
|
|
37
37
|
|
|
38
38
|
## API
|
|
39
39
|
|
|
40
|
-
| Property | Description
|
|
41
|
-
| ---------------------- |
|
|
42
|
-
| format |
|
|
43
|
-
| value | Example
|
|
44
|
-
| onDataFormatChange |
|
|
45
|
-
| onCurrencyChange |
|
|
46
|
-
| onUseSeparatorChange |
|
|
47
|
-
| onCompactNumbersChange |
|
|
48
|
-
| onFixedLengthChange |
|
|
49
|
-
| onSetDefault | Set default
|
|
50
|
-
|
|
|
51
|
-
|
|
|
40
|
+
| Property | Description | Type | Default |
|
|
41
|
+
| ---------------------- | ------------------------------------------------------ | ------------------------------------------- | --------------- |
|
|
42
|
+
| format | Current format configuration | `FormattingValue` | - |
|
|
43
|
+
| value | Example number shown in the trigger button label | `number` | - |
|
|
44
|
+
| onDataFormatChange | Called when user selects a data format | `(format: FormattingDataFormat) => void` | - |
|
|
45
|
+
| onCurrencyChange | Called when a currency is selected | `(currency: CurrencyType) => void` | - |
|
|
46
|
+
| onUseSeparatorChange | Called when the 1000-separator checkbox changes | `(useSeparator: boolean) => void` | - |
|
|
47
|
+
| onCompactNumbersChange | Called when the compact numbers checkbox changes | `(compactNumbers: boolean) => void` | - |
|
|
48
|
+
| onFixedLengthChange | Called when decimal places are incremented/decremented | `(fixedLength: number) => void` | - |
|
|
49
|
+
| onSetDefault | If provided, renders a "Set default" footer button | `() => void` | - |
|
|
50
|
+
| onFormattedValueChange | Called whenever the formatted display value changes | `(formattedValue: string) => void` | - |
|
|
51
|
+
| text | Override any subset of UI labels | `Partial<FormatPickerTexts>` | - |
|
|
52
|
+
| currenciesConfig | Custom currency list for the cash dropdown | `CurrencyConfig[]` | USD/EUR/PLN/JPY |
|
|
53
|
+
| buttonType | DS button type for the trigger button | `string` | `'tertiary'` |
|
|
54
|
+
| disabled | Disables the trigger and all panel controls | `boolean` | - |
|
|
55
|
+
| maxFixedLength | Upper bound for decimal places | `number` | - |
|
|
52
56
|
|
|
53
57
|
### Texts
|
|
54
58
|
|
|
55
59
|
| Property | Description | Type | Default |
|
|
56
60
|
| -------------- | --------------------------------- | ------------------------ | -------------------- |
|
|
57
|
-
| header | Header of format settings | string
|
|
58
|
-
| format | Format label | string
|
|
59
|
-
| numeric | Numeric type of format tooltip | string
|
|
60
|
-
| cash | Cash type of format tooltip | string
|
|
61
|
-
| percentage | Percentage type of format tooltip | string
|
|
62
|
-
| setDefault | Set default format button label | string
|
|
63
|
-
| useSeparator | Use 1000 separator checkbox label | string
|
|
64
|
-
| compactNumbers
|
|
61
|
+
| header | Header of format settings | `string \| ReactNode` | `Number format` |
|
|
62
|
+
| format | Format label | `string \| ReactNode` | `Format` |
|
|
63
|
+
| numeric | Numeric type of format tooltip | `string \| ReactNode` | `Numeric` |
|
|
64
|
+
| cash | Cash type of format tooltip | `string \| ReactNode` | `Cash` |
|
|
65
|
+
| percentage | Percentage type of format tooltip | `string \| ReactNode` | `Percentage` |
|
|
66
|
+
| setDefault | Set default format button label | `string \| ReactNode` | `Set default` |
|
|
67
|
+
| useSeparator | Use 1000 separator checkbox label | `string \| ReactNode` | `Use 1000 separator` |
|
|
68
|
+
| compactNumbers | Compact numbers checkbox label | `string \| ReactNode` | `Use compact numbers` |
|
|
69
|
+
| currencyMenuItemPrefix | Prefix shown before the example value in currency rows | `string` | `'e.g.'` |
|
|
65
70
|
|
|
66
71
|
### FormattingValue
|
|
67
72
|
|
|
@@ -75,7 +80,7 @@ import FormatPicker from '@synerise/ds-format-picker'
|
|
|
75
80
|
|
|
76
81
|
### CurrencyType
|
|
77
82
|
|
|
78
|
-
|
|
83
|
+
`string` — any currency code string. The default `currenciesConfig` includes `USD`, `EUR`, `PLN`, `JPY`, but the type is not restricted to those values.
|
|
79
84
|
|
|
80
85
|
### FormattingDataFormat
|
|
81
86
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/FormatPicker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormatPickerProps } from './FomartPicker.types';
|
|
3
3
|
declare const FormatPicker: ({ onUseSeparatorChange, onFixedLengthChange, onDataFormatChange, onCurrencyChange, onCompactNumbersChange, onSetDefault, onFormattedValueChange, value, format, text, currenciesConfig, buttonType, disabled, maxFixedLength, }: FormatPickerProps) => React.JSX.Element;
|
|
4
4
|
export default FormatPicker;
|
package/dist/FormatPicker.js
CHANGED
|
@@ -1,135 +1,119 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useIntl } from
|
|
4
|
-
import Button from
|
|
5
|
-
import { useDataFormat } from
|
|
6
|
-
import Dropdown from
|
|
7
|
-
import Icon, { HashM } from
|
|
8
|
-
import FormatSettings from
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
formatValue
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, [text, intl]);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useCallback, useEffect } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import Button from "@synerise/ds-button";
|
|
5
|
+
import { useDataFormat } from "@synerise/ds-core";
|
|
6
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
7
|
+
import Icon, { HashM } from "@synerise/ds-icon";
|
|
8
|
+
import FormatSettings from "./FormatSettings/FormatSettings.js";
|
|
9
|
+
const FormatPicker = ({
|
|
10
|
+
onUseSeparatorChange,
|
|
11
|
+
onFixedLengthChange,
|
|
12
|
+
onDataFormatChange,
|
|
13
|
+
onCurrencyChange,
|
|
14
|
+
onCompactNumbersChange,
|
|
15
|
+
onSetDefault,
|
|
16
|
+
onFormattedValueChange,
|
|
17
|
+
value,
|
|
18
|
+
format,
|
|
19
|
+
text,
|
|
20
|
+
currenciesConfig,
|
|
21
|
+
buttonType = "tertiary",
|
|
22
|
+
disabled,
|
|
23
|
+
maxFixedLength
|
|
24
|
+
}) => {
|
|
25
|
+
const intl = useIntl();
|
|
26
|
+
const {
|
|
27
|
+
formatValue
|
|
28
|
+
} = useDataFormat();
|
|
29
|
+
const texts = useMemo(() => ({
|
|
30
|
+
header: intl.formatMessage({
|
|
31
|
+
id: "DS.FORMAT-PICKER.HEADER",
|
|
32
|
+
defaultMessage: "Number format"
|
|
33
|
+
}),
|
|
34
|
+
format: intl.formatMessage({
|
|
35
|
+
id: "DS.FORMAT-PICKER.FORMAT",
|
|
36
|
+
defaultMessage: "Format"
|
|
37
|
+
}),
|
|
38
|
+
numeric: intl.formatMessage({
|
|
39
|
+
id: "DS.FORMAT-PICKER.NUMERIC",
|
|
40
|
+
defaultMessage: "Numeric"
|
|
41
|
+
}),
|
|
42
|
+
cash: intl.formatMessage({
|
|
43
|
+
id: "DS.FORMAT-PICKER.CASH",
|
|
44
|
+
defaultMessage: "Cash"
|
|
45
|
+
}),
|
|
46
|
+
percentage: intl.formatMessage({
|
|
47
|
+
id: "DS.FORMAT-PICKER.PERCENTAGE",
|
|
48
|
+
defaultMessage: "Percentage"
|
|
49
|
+
}),
|
|
50
|
+
setDefault: intl.formatMessage({
|
|
51
|
+
id: "DS.FORMAT-PICKER.SET-DEFAULT",
|
|
52
|
+
defaultMessage: "Set default"
|
|
53
|
+
}),
|
|
54
|
+
useSeparator: intl.formatMessage({
|
|
55
|
+
id: "DS.FORMAT-PICKER.USE-SEPARATOR",
|
|
56
|
+
defaultMessage: "Use 1000 separator"
|
|
57
|
+
}),
|
|
58
|
+
currencyMenuItemPrefix: intl.formatMessage({
|
|
59
|
+
id: "DS.FORMAT-PICKER.EG",
|
|
60
|
+
defaultMessage: "e.g."
|
|
61
|
+
}),
|
|
62
|
+
compactNumbers: intl.formatMessage({
|
|
63
|
+
id: "DS.FORMAT-PICKER.COMPACT-NUMBERS",
|
|
64
|
+
defaultMessage: "Use compact numbers"
|
|
65
|
+
}),
|
|
66
|
+
...text
|
|
67
|
+
}), [text, intl]);
|
|
68
|
+
const getFormattedValue = useCallback((overrideOptions) => {
|
|
69
|
+
const {
|
|
70
|
+
useSeparator,
|
|
71
|
+
compactNumbers,
|
|
72
|
+
currency,
|
|
73
|
+
dataFormat,
|
|
74
|
+
fixedLength
|
|
75
|
+
} = format;
|
|
76
|
+
let options = {
|
|
75
77
|
useGrouping: useSeparator
|
|
76
78
|
};
|
|
77
79
|
if (compactNumbers) {
|
|
78
80
|
options = {
|
|
79
|
-
notation:
|
|
81
|
+
notation: "compact"
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
|
-
if (dataFormat ===
|
|
83
|
-
options =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
if (dataFormat === "cash" && currency) {
|
|
85
|
+
options = {
|
|
86
|
+
...options,
|
|
87
|
+
currency,
|
|
88
|
+
style: "currency"
|
|
89
|
+
};
|
|
87
90
|
}
|
|
88
|
-
if (dataFormat ===
|
|
89
|
-
options =
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
if (dataFormat === "percent") {
|
|
92
|
+
options = {
|
|
93
|
+
...options,
|
|
94
|
+
suffix: compactNumbers ? " %" : "%"
|
|
95
|
+
};
|
|
92
96
|
}
|
|
93
|
-
if (typeof fixedLength ===
|
|
94
|
-
options =
|
|
97
|
+
if (typeof fixedLength === "number") {
|
|
98
|
+
options = {
|
|
99
|
+
...options,
|
|
95
100
|
minimumFractionDigits: fixedLength,
|
|
96
|
-
maximumFractionDigits: fixedLength
|
|
97
|
-
|
|
101
|
+
maximumFractionDigits: fixedLength,
|
|
102
|
+
...overrideOptions
|
|
103
|
+
};
|
|
98
104
|
}
|
|
99
105
|
return formatValue(value, options);
|
|
100
106
|
}, [value, format, formatValue]);
|
|
101
|
-
useEffect(
|
|
107
|
+
useEffect(() => {
|
|
102
108
|
onFormattedValueChange && onFormattedValueChange(getFormattedValue());
|
|
103
109
|
}, [getFormattedValue, onFormattedValueChange]);
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
onSetDefault: onSetDefault,
|
|
114
|
-
format: format,
|
|
115
|
-
text: texts,
|
|
116
|
-
currenciesConfig: currenciesConfig,
|
|
117
|
-
disabled: disabled,
|
|
118
|
-
getFormattedValue: getFormattedValue,
|
|
119
|
-
maxFixedLength: maxFixedLength
|
|
120
|
-
}),
|
|
121
|
-
placement: "topCenter",
|
|
122
|
-
popoverProps: {
|
|
123
|
-
testId: 'format-picker'
|
|
124
|
-
},
|
|
125
|
-
size: "auto",
|
|
126
|
-
asChild: true
|
|
127
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
128
|
-
type: buttonType,
|
|
129
|
-
mode: "icon-label",
|
|
130
|
-
disabled: disabled
|
|
131
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
132
|
-
component: /*#__PURE__*/React.createElement(HashM, null)
|
|
133
|
-
}), texts.format + " " + getFormattedValue()));
|
|
110
|
+
return /* @__PURE__ */ jsx(Dropdown, { trigger: ["click"], disabled, overlay: /* @__PURE__ */ jsx(FormatSettings, { onCurrencyChange, onFixedLengthChange, onDataFormatChange, onCompactNumbersChange, onUseSeparatorChange, onSetDefault, format, text: texts, currenciesConfig, disabled, getFormattedValue, maxFixedLength }), placement: "topCenter", popoverProps: {
|
|
111
|
+
testId: "format-picker"
|
|
112
|
+
}, size: "auto", asChild: true, children: /* @__PURE__ */ jsxs(Button, { type: buttonType, mode: "icon-label", disabled, children: [
|
|
113
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(HashM, {}) }),
|
|
114
|
+
`${texts.format} ${getFormattedValue()}`
|
|
115
|
+
] }) });
|
|
116
|
+
};
|
|
117
|
+
export {
|
|
118
|
+
FormatPicker as default
|
|
134
119
|
};
|
|
135
|
-
export default FormatPicker;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { FormatSettingsProps } from './FormatSettings.types';
|
|
3
3
|
declare const FormatSettings: ({ onCompactNumbersChange, onCurrencyChange, onDataFormatChange, onFixedLengthChange, onUseSeparatorChange, onSetDefault, getFormattedValue, format, text, currenciesConfig, disabled, maxFixedLength, }: FormatSettingsProps) => React.JSX.Element;
|
|
4
4
|
export default FormatSettings;
|
|
@@ -1,161 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import Button from "@synerise/ds-button";
|
|
5
|
+
import ButtonGroup from "@synerise/ds-button-group";
|
|
6
|
+
import Checkbox from "@synerise/ds-checkbox";
|
|
7
|
+
import Dropdown from "@synerise/ds-dropdown";
|
|
8
|
+
import Icon, { CommaDecM, CommaIncM, AngleDownS, HashM, PercentM, Coin2M } from "@synerise/ds-icon";
|
|
9
|
+
import Radio from "@synerise/ds-radio";
|
|
10
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
11
|
+
import { Title } from "@synerise/ds-typography";
|
|
12
|
+
import { FormatSettingsContainer, FormatSettingsWrapper, FormatSettings as FormatSettings$1, WrapperButtons, FixedLengthButton, FormatOptions, DropdownTrigger, DropdownValue, DropdownWrapper, ListItem, FormatFooter } from "./FormatSettings.styles.js";
|
|
13
|
+
const DEFAULT_CURRENCIES_CONFIG = [{
|
|
14
|
+
currency: "USD",
|
|
15
|
+
label: "Dollar (US)"
|
|
15
16
|
}, {
|
|
16
|
-
currency:
|
|
17
|
-
label:
|
|
17
|
+
currency: "EUR",
|
|
18
|
+
label: "Euro (EU)"
|
|
18
19
|
}, {
|
|
19
|
-
currency:
|
|
20
|
-
label:
|
|
20
|
+
currency: "PLN",
|
|
21
|
+
label: "Złoty (PL)"
|
|
21
22
|
}, {
|
|
22
|
-
currency:
|
|
23
|
-
label:
|
|
23
|
+
currency: "JPY",
|
|
24
|
+
label: "Yen (JP)"
|
|
24
25
|
}];
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
var intl = useIntl();
|
|
55
|
-
var handleSelectCurrency = function handleSelectCurrency(currency) {
|
|
26
|
+
const getFormattingTypes = (intl, text) => [{
|
|
27
|
+
format: "numeric",
|
|
28
|
+
icon: /* @__PURE__ */ jsx(HashM, {}),
|
|
29
|
+
tooltip: text.numeric
|
|
30
|
+
}, {
|
|
31
|
+
format: "percent",
|
|
32
|
+
icon: /* @__PURE__ */ jsx(PercentM, {}),
|
|
33
|
+
tooltip: text.percentage
|
|
34
|
+
}, {
|
|
35
|
+
format: "cash",
|
|
36
|
+
icon: /* @__PURE__ */ jsx(Coin2M, {}),
|
|
37
|
+
tooltip: text.cash
|
|
38
|
+
}];
|
|
39
|
+
const FormatSettings = ({
|
|
40
|
+
onCompactNumbersChange,
|
|
41
|
+
onCurrencyChange,
|
|
42
|
+
onDataFormatChange,
|
|
43
|
+
onFixedLengthChange,
|
|
44
|
+
onUseSeparatorChange,
|
|
45
|
+
onSetDefault,
|
|
46
|
+
getFormattedValue,
|
|
47
|
+
format,
|
|
48
|
+
text,
|
|
49
|
+
currenciesConfig = DEFAULT_CURRENCIES_CONFIG,
|
|
50
|
+
disabled,
|
|
51
|
+
maxFixedLength
|
|
52
|
+
}) => {
|
|
53
|
+
const intl = useIntl();
|
|
54
|
+
const handleSelectCurrency = (currency) => {
|
|
56
55
|
onCurrencyChange(currency);
|
|
57
56
|
};
|
|
58
|
-
|
|
57
|
+
const handleDecreaseFixedLength = useCallback(() => {
|
|
59
58
|
if (format.fixedLength > 0) {
|
|
60
59
|
onFixedLengthChange(format.fixedLength - 1);
|
|
61
60
|
} else {
|
|
62
61
|
onFixedLengthChange(0);
|
|
63
62
|
}
|
|
64
63
|
}, [onFixedLengthChange, format]);
|
|
65
|
-
|
|
66
|
-
if (maxFixedLength ===
|
|
64
|
+
const handleIncreaseFixedLength = useCallback(() => {
|
|
65
|
+
if (maxFixedLength === void 0 || maxFixedLength > format.fixedLength) {
|
|
67
66
|
onFixedLengthChange(format.fixedLength + 1);
|
|
68
67
|
}
|
|
69
68
|
}, [onFixedLengthChange, format, maxFixedLength]);
|
|
70
|
-
|
|
71
|
-
return currenciesConfig.find(
|
|
72
|
-
return currency.currency === format.currency;
|
|
73
|
-
});
|
|
69
|
+
const selectedCurrency = useMemo(() => {
|
|
70
|
+
return currenciesConfig.find((currency) => currency.currency === format.currency);
|
|
74
71
|
}, [currenciesConfig, format]);
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return onDataFormatChange(type.format);
|
|
95
|
-
},
|
|
96
|
-
disabled: disabled
|
|
97
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
98
|
-
component: type.icon
|
|
99
|
-
})));
|
|
100
|
-
}))), /*#__PURE__*/React.createElement(S.WrapperButtons, {
|
|
101
|
-
buttonsPosition: "right"
|
|
102
|
-
}, /*#__PURE__*/React.createElement(S.FixedLengthButton, {
|
|
103
|
-
type: "secondary",
|
|
104
|
-
mode: "icon",
|
|
105
|
-
onClick: handleDecreaseFixedLength,
|
|
106
|
-
disabled: disabled
|
|
107
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
108
|
-
component: /*#__PURE__*/React.createElement(CommaDecM, null)
|
|
109
|
-
})), /*#__PURE__*/React.createElement(S.FixedLengthButton, {
|
|
110
|
-
type: "secondary",
|
|
111
|
-
mode: "icon",
|
|
112
|
-
onClick: handleIncreaseFixedLength,
|
|
113
|
-
disabled: disabled
|
|
114
|
-
}, /*#__PURE__*/React.createElement(Icon, {
|
|
115
|
-
component: /*#__PURE__*/React.createElement(CommaIncM, null)
|
|
116
|
-
})))), /*#__PURE__*/React.createElement(S.FormatOptions, null, format.dataFormat === 'cash' && /*#__PURE__*/React.createElement(Dropdown, {
|
|
117
|
-
trigger: ['click'],
|
|
118
|
-
disabled: disabled,
|
|
119
|
-
hideOnItemClick: true,
|
|
120
|
-
popoverProps: {
|
|
121
|
-
testId: 'format-picker-settings'
|
|
122
|
-
},
|
|
123
|
-
asChild: true,
|
|
124
|
-
size: "match-trigger",
|
|
125
|
-
overlay: /*#__PURE__*/React.createElement(S.DropdownWrapper, null, currenciesConfig.map(function (_ref2) {
|
|
126
|
-
var currency = _ref2.currency,
|
|
127
|
-
label = _ref2.label;
|
|
128
|
-
return /*#__PURE__*/React.createElement(S.ListItem, {
|
|
129
|
-
key: currency,
|
|
130
|
-
suffixel: text.currencyMenuItemPrefix + " " + getFormattedValue({
|
|
131
|
-
currency: currency
|
|
132
|
-
}),
|
|
133
|
-
onClick: function onClick() {
|
|
72
|
+
return /* @__PURE__ */ jsxs(FormatSettingsContainer, { "data-testid": "ds-format-picker-overlay", children: [
|
|
73
|
+
/* @__PURE__ */ jsxs(FormatSettingsWrapper, { children: [
|
|
74
|
+
/* @__PURE__ */ jsx(Title, { level: 6, children: text.header }),
|
|
75
|
+
/* @__PURE__ */ jsxs(FormatSettings$1, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx(Radio.Group, { defaultValue: format.dataFormat, onChange: (event) => onDataFormatChange(event.target.value), children: /* @__PURE__ */ jsx(ButtonGroup, { children: getFormattingTypes(intl, text).map((type) => /* @__PURE__ */ jsx(Tooltip, { trigger: ["hover"], title: type.tooltip, children: /* @__PURE__ */ jsx(Button, { type: type.format === format.dataFormat ? "primary" : "secondary", mode: "icon", "data-testid": `ds-format-picker-type-${type.format}`, onClick: () => onDataFormatChange(type.format), disabled, children: /* @__PURE__ */ jsx(Icon, { component: type.icon }) }) }, type.format)) }) }),
|
|
77
|
+
/* @__PURE__ */ jsxs(WrapperButtons, { buttonsPosition: "right", children: [
|
|
78
|
+
/* @__PURE__ */ jsx(FixedLengthButton, { type: "secondary", mode: "icon", onClick: handleDecreaseFixedLength, disabled, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CommaDecM, {}) }) }),
|
|
79
|
+
/* @__PURE__ */ jsx(FixedLengthButton, { type: "secondary", mode: "icon", onClick: handleIncreaseFixedLength, disabled, children: /* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(CommaIncM, {}) }) })
|
|
80
|
+
] })
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsxs(FormatOptions, { children: [
|
|
83
|
+
format.dataFormat === "cash" && /* @__PURE__ */ jsx(Dropdown, { trigger: ["click"], disabled, hideOnItemClick: true, popoverProps: {
|
|
84
|
+
testId: "format-picker-settings"
|
|
85
|
+
}, asChild: true, size: "match-trigger", overlay: /* @__PURE__ */ jsx(DropdownWrapper, { children: currenciesConfig.map(({
|
|
86
|
+
currency,
|
|
87
|
+
label
|
|
88
|
+
}) => /* @__PURE__ */ jsx(ListItem, { suffixel: `${text.currencyMenuItemPrefix} ${getFormattedValue({
|
|
89
|
+
currency
|
|
90
|
+
})}`, onClick: () => {
|
|
134
91
|
handleSelectCurrency(currency);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}, text.useSeparator), /*#__PURE__*/React.createElement(Checkbox, {
|
|
149
|
-
onChange: function onChange(event) {
|
|
150
|
-
return onCompactNumbersChange(event.target.checked);
|
|
151
|
-
},
|
|
152
|
-
checked: format.compactNumbers,
|
|
153
|
-
disabled: disabled
|
|
154
|
-
}, text.compactNumbers))), onSetDefault && /*#__PURE__*/React.createElement(S.FormatFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
155
|
-
"data-testid": "ds-format-picker-default-trigger",
|
|
156
|
-
type: "ghost",
|
|
157
|
-
onClick: onSetDefault,
|
|
158
|
-
disabled: disabled
|
|
159
|
-
}, text.setDefault)));
|
|
92
|
+
}, children: label }, currency)) }), children: /* @__PURE__ */ jsxs(DropdownTrigger, { "data-testid": "ds-format-picker-currency-trigger", children: [
|
|
93
|
+
/* @__PURE__ */ jsx(DropdownValue, { children: selectedCurrency?.label }),
|
|
94
|
+
/* @__PURE__ */ jsx(Icon, { component: /* @__PURE__ */ jsx(AngleDownS, {}) })
|
|
95
|
+
] }) }),
|
|
96
|
+
/* @__PURE__ */ jsx(Checkbox, { onChange: (event) => onUseSeparatorChange(event.target.checked), checked: format.useSeparator, disabled, children: text.useSeparator }),
|
|
97
|
+
/* @__PURE__ */ jsx(Checkbox, { onChange: (event) => onCompactNumbersChange(event.target.checked), checked: format.compactNumbers, disabled, children: text.compactNumbers })
|
|
98
|
+
] })
|
|
99
|
+
] }),
|
|
100
|
+
onSetDefault && /* @__PURE__ */ jsx(FormatFooter, { children: /* @__PURE__ */ jsx(Button, { "data-testid": "ds-format-picker-default-trigger", type: "ghost", onClick: onSetDefault, disabled, children: text.setDefault }) })
|
|
101
|
+
] });
|
|
102
|
+
};
|
|
103
|
+
export {
|
|
104
|
+
FormatSettings as default
|
|
160
105
|
};
|
|
161
|
-
export default FormatSettings;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export declare const FormatSettingsContainer: import(
|
|
4
|
-
export declare const FormatSettingsWrapper: import(
|
|
5
|
-
export declare const FormatSettings: import(
|
|
6
|
-
export declare const FormatOptions: import(
|
|
7
|
-
export declare const FormatFooter: import(
|
|
8
|
-
export declare const DropdownTrigger: import(
|
|
9
|
-
export declare const DropdownValue: import(
|
|
10
|
-
export declare const DropdownWrapper: import(
|
|
1
|
+
import { StyledButton } from '@synerise/ds-button';
|
|
2
|
+
import { StyledListItem } from '@synerise/ds-list-item';
|
|
3
|
+
export declare const FormatSettingsContainer: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const FormatSettingsWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const FormatSettings: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const FormatOptions: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const FormatFooter: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
8
|
+
export declare const DropdownTrigger: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
9
|
+
export declare const DropdownValue: import('styled-components').StyledComponent<"span", any, {}, never>;
|
|
10
|
+
export declare const DropdownWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
11
11
|
export declare const ListItem: StyledListItem;
|
|
12
12
|
export declare const FixedLengthButton: StyledButton;
|
|
13
|
-
export declare const WrapperButtons: import(
|
|
13
|
+
export declare const WrapperButtons: import('styled-components').StyledComponent<({ className, children, title, description, size, fullWidth, buttonsPosition, disabled, splitMode, compact, error, }: import('@synerise/ds-button-group').ButtonGroupProps) => React.JSX.Element, any, {}, never>;
|
|
@@ -1,65 +1,62 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
import Button from
|
|
3
|
-
import ButtonGroup from
|
|
4
|
-
import DSListItem from
|
|
5
|
-
import { SuffixWrapper } from
|
|
6
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import Button from "@synerise/ds-button";
|
|
3
|
+
import ButtonGroup from "@synerise/ds-button-group";
|
|
4
|
+
import DSListItem from "@synerise/ds-list-item";
|
|
5
|
+
import { SuffixWrapper } from "@synerise/ds-list-item/dist/components/Text/Text.styles";
|
|
6
|
+
const FormatSettingsContainer = /* @__PURE__ */ styled.div.withConfig({
|
|
7
7
|
displayName: "FormatSettingsstyles__FormatSettingsContainer",
|
|
8
8
|
componentId: "sc-ipk0xd-0"
|
|
9
|
-
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:stretch;background-color:", ";min-width:268px;.ds-title{margin-bottom:8px;}"],
|
|
10
|
-
|
|
11
|
-
});
|
|
12
|
-
export var FormatSettingsWrapper = styled.div.withConfig({
|
|
9
|
+
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:stretch;background-color:", ";min-width:268px;.ds-title{margin-bottom:8px;}"], (props) => props.theme.palette.white);
|
|
10
|
+
const FormatSettingsWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
13
11
|
displayName: "FormatSettingsstyles__FormatSettingsWrapper",
|
|
14
12
|
componentId: "sc-ipk0xd-1"
|
|
15
13
|
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:stretch;width:100%;padding:20px 20px 0;"]);
|
|
16
|
-
|
|
14
|
+
const FormatSettings = /* @__PURE__ */ styled.div.withConfig({
|
|
17
15
|
displayName: "FormatSettingsstyles__FormatSettings",
|
|
18
16
|
componentId: "sc-ipk0xd-2"
|
|
19
17
|
})(["display:flex;flex-direction:row;align-items:flex-start;width:100%;justify-content:space-between;"]);
|
|
20
|
-
|
|
18
|
+
const FormatOptions = /* @__PURE__ */ styled.div.withConfig({
|
|
21
19
|
displayName: "FormatSettingsstyles__FormatOptions",
|
|
22
20
|
componentId: "sc-ipk0xd-3"
|
|
23
21
|
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;margin-top:20px;width:100%;.ds-dropdown-menu{width:100%;}.ds-checkbox{padding:0;margin-bottom:16px;}"]);
|
|
24
|
-
|
|
22
|
+
const FormatFooter = /* @__PURE__ */ styled.div.withConfig({
|
|
25
23
|
displayName: "FormatSettingsstyles__FormatFooter",
|
|
26
24
|
componentId: "sc-ipk0xd-4"
|
|
27
|
-
})(["background-color:", ";padding:8px 10px;border-top:1px solid ", ";width:100%;"],
|
|
28
|
-
|
|
29
|
-
}, function (props) {
|
|
30
|
-
return props.theme.palette['grey-100'];
|
|
31
|
-
});
|
|
32
|
-
export var DropdownTrigger = styled.div.withConfig({
|
|
25
|
+
})(["background-color:", ";padding:8px 10px;border-top:1px solid ", ";width:100%;"], (props) => props.theme.palette["grey-050"], (props) => props.theme.palette["grey-100"]);
|
|
26
|
+
const DropdownTrigger = /* @__PURE__ */ styled.div.withConfig({
|
|
33
27
|
displayName: "FormatSettingsstyles__DropdownTrigger",
|
|
34
28
|
componentId: "sc-ipk0xd-5"
|
|
35
|
-
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0 8px 0 12px;height:32px;border-radius:3px;border:1px solid ", ";width:100%;margin-bottom:20px;"],
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
export var DropdownValue = styled.span.withConfig({
|
|
29
|
+
})(["display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0 8px 0 12px;height:32px;border-radius:3px;border:1px solid ", ";width:100%;margin-bottom:20px;"], (props) => props.theme.palette["grey-300"]);
|
|
30
|
+
const DropdownValue = /* @__PURE__ */ styled.span.withConfig({
|
|
39
31
|
displayName: "FormatSettingsstyles__DropdownValue",
|
|
40
32
|
componentId: "sc-ipk0xd-6"
|
|
41
|
-
})(["font-size:13px;line-height:18px;font-weight:400;color:", ";"],
|
|
42
|
-
|
|
43
|
-
});
|
|
44
|
-
export var DropdownWrapper = styled.div.withConfig({
|
|
33
|
+
})(["font-size:13px;line-height:18px;font-weight:400;color:", ";"], (props) => props.theme.palette["grey-700"]);
|
|
34
|
+
const DropdownWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
45
35
|
displayName: "FormatSettingsstyles__DropdownWrapper",
|
|
46
36
|
componentId: "sc-ipk0xd-7"
|
|
47
|
-
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;width:100%;padding:8px;background:", ";"],
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
export var ListItem = styled(DSListItem).withConfig({
|
|
37
|
+
})(["display:flex;flex-direction:column;align-items:flex-start;justify-content:flex-start;width:100%;padding:8px;background:", ";"], (props) => props.theme.palette.white);
|
|
38
|
+
const ListItem = /* @__PURE__ */ styled(DSListItem).withConfig({
|
|
51
39
|
displayName: "FormatSettingsstyles__ListItem",
|
|
52
40
|
componentId: "sc-ipk0xd-8"
|
|
53
|
-
})(["font-weight:500;width:100%;color:", ";", "{color:", ";font-weight:400;}"],
|
|
54
|
-
|
|
55
|
-
}, SuffixWrapper, function (props) {
|
|
56
|
-
return props.theme.palette['grey-500'];
|
|
57
|
-
});
|
|
58
|
-
export var FixedLengthButton = styled(Button).withConfig({
|
|
41
|
+
})(["font-weight:500;width:100%;color:", ";", "{color:", ";font-weight:400;}"], (props) => props.theme.palette["grey-700"], SuffixWrapper, (props) => props.theme.palette["grey-500"]);
|
|
42
|
+
const FixedLengthButton = /* @__PURE__ */ styled(Button).withConfig({
|
|
59
43
|
displayName: "FormatSettingsstyles__FixedLengthButton",
|
|
60
44
|
componentId: "sc-ipk0xd-9"
|
|
61
45
|
})(["&&&{padding:4px;}"]);
|
|
62
|
-
|
|
46
|
+
const WrapperButtons = /* @__PURE__ */ styled(ButtonGroup).withConfig({
|
|
63
47
|
displayName: "FormatSettingsstyles__WrapperButtons",
|
|
64
48
|
componentId: "sc-ipk0xd-10"
|
|
65
|
-
})(["&&&{padding-left:8px;}"]);
|
|
49
|
+
})(["&&&{padding-left:8px;}"]);
|
|
50
|
+
export {
|
|
51
|
+
DropdownTrigger,
|
|
52
|
+
DropdownValue,
|
|
53
|
+
DropdownWrapper,
|
|
54
|
+
FixedLengthButton,
|
|
55
|
+
FormatFooter,
|
|
56
|
+
FormatOptions,
|
|
57
|
+
FormatSettings,
|
|
58
|
+
FormatSettingsContainer,
|
|
59
|
+
FormatSettingsWrapper,
|
|
60
|
+
ListItem,
|
|
61
|
+
WrapperButtons
|
|
62
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { NumberToFormatOptions } from '@synerise/ds-core';
|
|
2
|
+
import { FormatPickerProps, FormatPickerTexts } from '../FomartPicker.types';
|
|
3
3
|
export type FormatSettingsProps = Omit<FormatPickerProps, 'text' | 'value'> & {
|
|
4
4
|
getFormattedValue: (options: NumberToFormatOptions) => string;
|
|
5
5
|
text: FormatPickerTexts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
package/dist/index.js
CHANGED
package/dist/modules.d.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-format-picker",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
4
4
|
"description": "FormatPicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "vite build",
|
|
20
20
|
"build:css": "node ../../../scripts/style/less.js",
|
|
21
21
|
"build:js": "babel --delete-dir-on-start --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
|
-
"build:watch": "
|
|
22
|
+
"build:watch": "vite build --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
25
|
"prepublish": "pnpm run build",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-button": "^1.5.
|
|
39
|
-
"@synerise/ds-button-group": "^1.1.
|
|
40
|
-
"@synerise/ds-checkbox": "^1.2.
|
|
41
|
-
"@synerise/ds-dropdown": "^1.3.
|
|
42
|
-
"@synerise/ds-icon": "^1.
|
|
43
|
-
"@synerise/ds-list-item": "^1.4.
|
|
44
|
-
"@synerise/ds-radio": "^1.1.
|
|
45
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
46
|
-
"@synerise/ds-typography": "^1.1.
|
|
47
|
-
"@synerise/ds-utils": "^1.
|
|
38
|
+
"@synerise/ds-button": "^1.5.18",
|
|
39
|
+
"@synerise/ds-button-group": "^1.1.43",
|
|
40
|
+
"@synerise/ds-checkbox": "^1.2.21",
|
|
41
|
+
"@synerise/ds-dropdown": "^1.3.2",
|
|
42
|
+
"@synerise/ds-icon": "^1.15.1",
|
|
43
|
+
"@synerise/ds-list-item": "^1.4.10",
|
|
44
|
+
"@synerise/ds-radio": "^1.1.3",
|
|
45
|
+
"@synerise/ds-tooltip": "^1.4.10",
|
|
46
|
+
"@synerise/ds-typography": "^1.1.13",
|
|
47
|
+
"@synerise/ds-utils": "^1.7.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@synerise/ds-core": "*",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
53
53
|
"styled-components": "^5.3.3"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "e4ecca8944fc9b41c1b9d59c8bcad5e5e2013225"
|
|
56
56
|
}
|