@chotot/clad-ui 1.2.5 → 1.3.1
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/README.md +3 -3
- package/components/Announcer/Announcer.d.ts +9 -4
- package/components/Announcer/Announcer.stories.d.ts +142 -0
- package/components/Announcer/{Announcer.stories.js → Announcer.stories.tsx} +36 -31
- package/components/Announcer/Announcer.styles.d.ts +24 -12
- package/components/Announcer/{Announcer.styles.js → Announcer.styles.ts} +43 -18
- package/components/Announcer/Announcer.tsx +62 -47
- package/components/Badge/Badge.d.ts +4 -2
- package/components/Badge/Badge.stories.d.ts +61 -0
- package/components/Badge/{Badge.stories.js → Badge.stories.tsx} +5 -5
- package/components/Badge/Badge.styles.d.ts +20 -5
- package/components/Badge/{Badge.styles.js → Badge.styles.ts} +14 -1
- package/components/Badge/Badge.tsx +8 -4
- package/components/Box/Box.d.ts +3 -3
- package/components/Box/Box.stories.d.ts +240 -0
- package/components/Box/{Box.stories.js → Box.stories.tsx} +2 -2
- package/components/Box/Box.styles.d.ts +19 -4
- package/components/Box/{Box.styles.js → Box.styles.ts} +17 -4
- package/components/Box/Box.tsx +4 -4
- package/components/Breadcrumbs/Breadcrumbs.d.ts +2 -2
- package/components/Breadcrumbs/Breadcrumbs.stories.d.ts +52 -0
- package/components/Breadcrumbs/{Breadcrumbs.stories.js → Breadcrumbs.stories.tsx} +17 -15
- package/components/Breadcrumbs/Breadcrumbs.styles.d.ts +5 -4
- package/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
- package/components/Button/Button.d.ts +21 -6
- package/components/Button/Button.stories.d.ts +103 -0
- package/components/Button/{Button.stories.js → Button.stories.tsx} +5 -1
- package/components/Button/Button.styles.d.ts +1 -1
- package/components/Button/{Button.styles.js → Button.styles.ts} +100 -6
- package/components/Button/Button.tsx +51 -18
- package/components/Button/ButtonLink.d.ts +4 -4
- package/components/Button/ButtonLink.stories.d.ts +30 -0
- package/components/Button/ButtonLink.styles.d.ts +1 -1
- package/components/Button/ButtonLink.tsx +5 -5
- package/components/Button/IconButton.d.ts +3 -29
- package/components/Button/IconButton.stories.d.ts +60 -0
- package/components/Button/{IconButton.stories.js → IconButton.stories.tsx} +27 -0
- package/components/Button/IconButton.tsx +2 -42
- package/components/Checkbox/Checkbox.d.ts +3 -3
- package/components/Checkbox/Checkbox.stories.d.ts +88 -0
- package/components/Checkbox/Checkbox.styles.d.ts +2 -2
- package/components/Checkbox/Checkbox.tsx +3 -6
- package/components/Chip/Chip.d.ts +5 -4
- package/components/Chip/Chip.stories.d.ts +153 -0
- package/components/Chip/{Chip.stories.js → Chip.stories.tsx} +4 -5
- package/components/Chip/Chip.styles.d.ts +11 -8
- package/components/Chip/{Chip.styles.js → Chip.styles.ts} +4 -4
- package/components/Chip/Chip.tsx +19 -12
- package/components/CurrencyInput/CurrencyInput.d.ts +3 -56
- package/components/CurrencyInput/CurrencyInput.stories.d.ts +104 -0
- package/components/CurrencyInput/{CurrencyInput.stories.js → CurrencyInput.stories.tsx} +2 -2
- package/components/CurrencyInput/CurrencyInput.styles.d.ts +16 -10
- package/components/CurrencyInput/{CurrencyInput.styles.js → CurrencyInput.styles.ts} +23 -9
- package/components/CurrencyInput/CurrencyInput.tsx +7 -61
- package/components/Dropdown/Dropdown.d.ts +22 -7
- package/components/Dropdown/Dropdown.stories.d.ts +148 -0
- package/components/Dropdown/{Dropdown.stories.js → Dropdown.stories.tsx} +115 -1
- package/components/Dropdown/Dropdown.styles.d.ts +10 -0
- package/components/Dropdown/Dropdown.styles.ts +42 -0
- package/components/Dropdown/Dropdown.tsx +120 -24
- package/components/Grid/Col.d.ts +2 -2
- package/components/Grid/Col.tsx +6 -3
- package/components/Grid/Grid.styles.d.ts +25 -5
- package/components/Grid/{Grid.styles.js → Grid.styles.ts} +16 -3
- package/components/Grid/aGrid.stories.d.ts +127 -0
- package/components/Grid/bCol.stories.d.ts +74 -0
- package/components/Input/Input.d.ts +14 -10
- package/components/Input/Input.stories.d.ts +226 -0
- package/components/Input/{Input.stories.js → Input.stories.tsx} +20 -16
- package/components/Input/Input.styles.d.ts +22 -11
- package/components/Input/{Input.styles.js → Input.styles.ts} +29 -7
- package/components/Input/Input.tsx +22 -20
- package/components/Popover/Popover.d.ts +44 -0
- package/components/Popover/Popover.stories.d.ts +53 -0
- package/components/Popover/Popover.stories.tsx +133 -0
- package/components/Popover/Popover.tsx +121 -0
- package/components/RadioButton/RadioButton.d.ts +5 -6
- package/components/RadioButton/RadioButton.stories.d.ts +94 -0
- package/components/RadioButton/RadioButton.styles.d.ts +7 -3
- package/components/RadioButton/{RadioButton.styles.js → RadioButton.styles.ts} +1 -1
- package/components/RadioButton/RadioButton.tsx +5 -11
- package/components/RowItem/RowItem.d.ts +27 -9
- package/components/RowItem/RowItem.stories.d.ts +131 -0
- package/components/RowItem/RowItem.stories.tsx +710 -0
- package/components/RowItem/RowItem.styles.d.ts +31 -10
- package/components/RowItem/{RowItem.styles.js → RowItem.styles.ts} +41 -13
- package/components/RowItem/RowItem.tsx +106 -42
- package/components/ShapeIcon/ShapeIcon.d.ts +23 -16
- package/components/ShapeIcon/ShapeIcon.stories.d.ts +91 -0
- package/components/ShapeIcon/{ShapeIcon.stories.js → ShapeIcon.stories.tsx} +21 -8
- package/components/ShapeIcon/ShapeIcon.styles.d.ts +8 -3
- package/components/ShapeIcon/{ShapeIcon.styles.js → ShapeIcon.styles.ts} +6 -3
- package/components/ShapeIcon/ShapeIcon.tsx +25 -21
- package/components/Slider/Slider.d.ts +9 -7
- package/components/Slider/Slider.stories.d.ts +81 -0
- package/components/Slider/{Slider.stories.js → Slider.stories.tsx} +7 -7
- package/components/Slider/Slider.styles.d.ts +15 -11
- package/components/Slider/{Slider.styles.js → Slider.styles.ts} +1 -1
- package/components/Slider/Slider.tsx +21 -16
- package/components/Snack/Snack.d.ts +4 -5
- package/components/Snack/Snack.stories.d.ts +87 -0
- package/components/Snack/Snack.styles.d.ts +9 -8
- package/components/Snack/{Snack.styles.js → Snack.styles.ts} +4 -4
- package/components/Snack/Snack.tsx +14 -11
- package/components/Tabs/Tab.d.ts +6 -6
- package/components/Tabs/Tab.tsx +6 -7
- package/components/Tabs/Tabs.d.ts +7 -4
- package/components/Tabs/Tabs.stories.d.ts +64 -0
- package/components/Tabs/{Tabs.stories.js → Tabs.stories.tsx} +2 -2
- package/components/Tabs/Tabs.styles.d.ts +30 -12
- package/components/Tabs/{Tabs.styles.js → Tabs.styles.ts} +4 -4
- package/components/Tabs/Tabs.tsx +11 -7
- package/components/TextArea/TextArea.d.ts +24 -11
- package/components/TextArea/TextArea.stories.d.ts +151 -0
- package/components/TextArea/{TextArea.stories.js → TextArea.stories.tsx} +5 -96
- package/components/TextArea/TextArea.styles.d.ts +18 -16
- package/components/TextArea/{TextArea.styles.js → TextArea.styles.ts} +39 -19
- package/components/TextArea/TextArea.tsx +85 -31
- package/components/TextLabel/TextLabel.d.ts +35 -0
- package/components/TextLabel/TextLabel.stories.d.ts +40 -0
- package/components/TextLabel/TextLabel.stories.tsx +177 -0
- package/components/TextLabel/TextLabel.styles.d.ts +9 -0
- package/components/TextLabel/TextLabel.styles.ts +24 -0
- package/components/TextLabel/TextLabel.tsx +112 -0
- package/components/ToggleSwitch/ToggleSwitch.d.ts +2 -2
- package/components/ToggleSwitch/ToggleSwitch.stories.d.ts +38 -0
- package/components/ToggleSwitch/ToggleSwitch.styles.d.ts +21 -14
- package/components/ToggleSwitch/{ToggleSwitch.styles.js → ToggleSwitch.styles.ts} +8 -12
- package/components/ToggleSwitch/ToggleSwitch.tsx +12 -6
- package/components/Tooltip/Tooltip.d.ts +9 -3
- package/components/Tooltip/Tooltip.spec.js +5 -3
- package/components/Tooltip/Tooltip.styles.d.ts +7 -8
- package/components/Tooltip/Tooltip.tsx +10 -3
- package/components/index.d.ts +2 -0
- package/components/index.ts +2 -0
- package/icons/PrivateSellerAvatar.d.ts +3 -0
- package/icons/PrivateSellerAvatar.js +3 -0
- package/icons/Sda.d.ts +5 -2
- package/icons/Sda.js +7 -7
- package/icons/VerifiedShop.d.ts +3 -0
- package/icons/VerifiedShop.js +3 -0
- package/package.json +6 -6
- package/patterns/Drawer/Drawer.d.ts +13 -13
- package/patterns/Drawer/Drawer.stories.d.ts +90 -0
- package/patterns/Drawer/{Drawer.stories.js → Drawer.stories.tsx} +25 -0
- package/patterns/Drawer/Drawer.styles.d.ts +30 -26
- package/patterns/Drawer/{Drawer.styles.js → Drawer.styles.ts} +2 -5
- package/patterns/Drawer/Drawer.tsx +20 -41
- package/patterns/EmptyState/EmptyState.d.ts +5 -4
- package/patterns/EmptyState/EmptyState.stories.d.ts +40 -0
- package/patterns/EmptyState/EmptyState.styles.d.ts +10 -10
- package/patterns/EmptyState/{EmptyState.styles.js → EmptyState.styles.ts} +5 -4
- package/patterns/EmptyState/EmptyState.tsx +14 -12
- package/patterns/InputGroup/InputGroup.d.ts +4 -0
- package/patterns/InputGroup/InputGroup.styles.d.ts +5 -4
- package/patterns/InputGroup/InputGroup.tsx +11 -5
- package/patterns/LegacyDialog/DialogMainIcon.d.ts +1 -0
- package/patterns/LegacyDialog/DialogMainIcon.js +51 -0
- package/patterns/LegacyDialog/LegacyDialog.d.ts +3 -3
- package/patterns/LegacyDialog/LegacyDialog.styles.d.ts +8 -10
- package/patterns/LegacyDialog/LegacyDialog.styles.js +1 -46
- package/patterns/LegacyDialog/LegacyDialog.tsx +5 -11
- package/patterns/LegacyPopup/LegacyPopup.d.ts +4 -4
- package/patterns/LegacyPopup/LegacyPopup.styles.d.ts +18 -13
- package/patterns/LegacyPopup/{LegacyPopup.styles.js → LegacyPopup.styles.ts} +3 -1
- package/patterns/LegacyPopup/LegacyPopup.tsx +4 -6
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts +20 -17
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.stories.d.ts +125 -0
- package/patterns/MultiSearchDropdown/{MultiSearchDropdown.stories.js → MultiSearchDropdown.stories.tsx} +31 -30
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts +22 -21
- package/patterns/MultiSearchDropdown/{MultiSearchDropdown.styles.js → MultiSearchDropdown.styles.ts} +1 -7
- package/patterns/MultiSearchDropdown/MultiSearchDropdown.tsx +33 -32
- package/patterns/Popup/Popup.d.ts +8 -7
- package/patterns/Popup/Popup.stories.d.ts +102 -0
- package/patterns/Popup/Popup.styles.d.ts +41 -30
- package/patterns/Popup/{Popup.styles.js → Popup.styles.ts} +26 -33
- package/patterns/Popup/Popup.tsx +14 -33
- package/patterns/SearchInput/SearchInput.d.ts +38 -21
- package/patterns/SearchInput/SearchInput.stories.d.ts +186 -0
- package/patterns/SearchInput/{SearchInput.stories.js → SearchInput.stories.tsx} +78 -45
- package/patterns/SearchInput/SearchInput.styles.d.ts +6 -5
- package/patterns/SearchInput/{SearchInput.styles.js → SearchInput.styles.ts} +7 -4
- package/patterns/SearchInput/SearchInput.tsx +53 -34
- package/patterns/TagCloud/TagCloud.d.ts +19 -6
- package/patterns/TagCloud/TagCloud.stories.d.ts +159 -0
- package/patterns/TagCloud/{TagCloud.stories.js → TagCloud.stories.tsx} +59 -14
- package/patterns/TagCloud/TagCloud.styles.d.ts +12 -8
- package/patterns/TagCloud/{TagCloud.styles.js → TagCloud.styles.ts} +6 -7
- package/patterns/TagCloud/TagCloud.tsx +24 -8
- package/patterns/TagCloud/TagCloudMultiActive.d.ts +6 -4
- package/patterns/TagCloud/TagCloudMultiActive.tsx +5 -5
- package/patterns/TagCloud/TagCloudSingleActive.d.ts +5 -2
- package/patterns/TagCloud/TagCloudSingleActive.tsx +18 -5
- package/patterns/patterns-index.spec.js +1 -1
- package/storybook/GuideImage.d.ts +2 -2
- package/storybook/Swatch.d.ts +2 -2
- package/theme/__snapshots__/chotot.spec.js.snap +2 -2
- package/theme/chotot-color1.d.ts +7 -14
- package/theme/chotot.d.ts +32 -32
- package/theme/chotot.js +4 -4
- package/theme/ct-job.d.ts +6 -14
- package/theme/ct-pty.d.ts +6 -8
- package/theme/mudah.d.ts +14 -13
- package/types.d.ts +0 -9
- package/utils/_simulateChangeEvent.d.ts +18 -3
- package/utils/_simulateChangeEvent.js +13 -6
- package/utils/_simulateChangeEvent.spec.js +1 -1
- package/utils/cx.d.ts +8 -4
- package/utils/cx.js +8 -4
- package/utils/sx.d.ts +12 -4192
- package/components/RowItem/RowItem.stories.js +0 -560
- /package/components/Breadcrumbs/{Breadcrumbs.styles.js → Breadcrumbs.styles.ts} +0 -0
- /package/components/Button/{ButtonLink.stories.js → ButtonLink.stories.tsx} +0 -0
- /package/components/Button/{ButtonLink.styles.js → ButtonLink.styles.ts} +0 -0
- /package/components/Checkbox/{Checkbox.stories.js → Checkbox.stories.tsx} +0 -0
- /package/components/Checkbox/{Checkbox.styles.js → Checkbox.styles.ts} +0 -0
- /package/components/Grid/{aGrid.stories.js → aGrid.stories.tsx} +0 -0
- /package/components/Grid/{bCol.stories.js → bCol.stories.tsx} +0 -0
- /package/components/RadioButton/{RadioButton.stories.js → RadioButton.stories.tsx} +0 -0
- /package/components/Snack/{Snack.stories.js → Snack.stories.tsx} +0 -0
- /package/components/ToggleSwitch/{ToggleSwitch.stories.js → ToggleSwitch.stories.tsx} +0 -0
- /package/patterns/EmptyState/{EmptyState.stories.js → EmptyState.stories.tsx} +0 -0
- /package/patterns/InputGroup/{InputGroup.styles.js → InputGroup.styles.ts} +0 -0
- /package/patterns/Popup/{Popup.stories.js → Popup.stories.tsx} +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const currencyInputStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./CurrencyInput").CurrencyInputProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
disabled: {};
|
|
15
|
+
required: {};
|
|
16
|
+
status: {};
|
|
17
|
+
width: {
|
|
18
|
+
options: string[];
|
|
19
|
+
control: {
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
suffix: {};
|
|
24
|
+
allowNegativeValue: {};
|
|
25
|
+
decimalsLimit: {};
|
|
26
|
+
maxDigits: {};
|
|
27
|
+
id: {
|
|
28
|
+
control: null;
|
|
29
|
+
};
|
|
30
|
+
name: {
|
|
31
|
+
control: null;
|
|
32
|
+
};
|
|
33
|
+
value: {
|
|
34
|
+
control: null;
|
|
35
|
+
};
|
|
36
|
+
onChange: {
|
|
37
|
+
control: null;
|
|
38
|
+
};
|
|
39
|
+
onFormatChange: {
|
|
40
|
+
control: null;
|
|
41
|
+
};
|
|
42
|
+
onBlur: {
|
|
43
|
+
control: null;
|
|
44
|
+
};
|
|
45
|
+
onFocus: {
|
|
46
|
+
control: null;
|
|
47
|
+
};
|
|
48
|
+
inputRef: {
|
|
49
|
+
control: null;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
args: {
|
|
53
|
+
label: string;
|
|
54
|
+
helptext: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export default currencyInputStories;
|
|
58
|
+
export declare const Overview: {
|
|
59
|
+
render: (args: any) => JSX.Element;
|
|
60
|
+
};
|
|
61
|
+
export declare const ValueBinding: {
|
|
62
|
+
render: () => JSX.Element;
|
|
63
|
+
parameters: {
|
|
64
|
+
docs: {
|
|
65
|
+
description: {
|
|
66
|
+
story: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export declare const Required: {
|
|
72
|
+
render: () => JSX.Element;
|
|
73
|
+
parameters: {
|
|
74
|
+
docs: {
|
|
75
|
+
description: {
|
|
76
|
+
story: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare const ErrorStatus: {
|
|
82
|
+
render: () => JSX.Element;
|
|
83
|
+
parameters: {
|
|
84
|
+
docs: {
|
|
85
|
+
description: {
|
|
86
|
+
story: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export declare const Disabled: {
|
|
92
|
+
render: () => JSX.Element;
|
|
93
|
+
parameters: {
|
|
94
|
+
docs: {
|
|
95
|
+
description: {
|
|
96
|
+
story: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export declare const DebounceExample: {
|
|
102
|
+
render: () => JSX.Element;
|
|
103
|
+
name: string;
|
|
104
|
+
};
|
|
@@ -183,12 +183,12 @@ export const Disabled = {
|
|
|
183
183
|
|
|
184
184
|
export const DebounceExample = {
|
|
185
185
|
render: () => {
|
|
186
|
-
const inputRef = useRef(null);
|
|
186
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
187
187
|
const [text, setText] = useState('');
|
|
188
188
|
|
|
189
189
|
const handleFetch = useCallback(
|
|
190
190
|
debounce(() => {
|
|
191
|
-
const { value } = inputRef.current;
|
|
191
|
+
const { value } = inputRef.current as HTMLInputElement;
|
|
192
192
|
// eslint-disable-next-line no-alert
|
|
193
193
|
if (value) alert('Searching for: ' + value);
|
|
194
194
|
}, 1000),
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
export default inputClasses;
|
|
2
1
|
declare const inputClasses: import("@linaria/core").LinariaClassName;
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export default inputClasses;
|
|
3
|
+
declare const inputFocusClasses: import("@linaria/core").LinariaClassName;
|
|
4
|
+
declare const Container: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
|
|
5
|
+
containerWidth: string;
|
|
6
|
+
} & {
|
|
7
|
+
as?: import("react").ElementType;
|
|
8
|
+
}>;
|
|
9
|
+
declare const Paragraph: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & Record<never, unknown> & {
|
|
10
|
+
as?: import("react").ElementType;
|
|
10
11
|
}>;
|
|
11
12
|
/**
|
|
12
13
|
* @type {React.FC<any>}
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
declare const InputWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
16
|
+
as?: import("react").ElementType;
|
|
17
|
+
}>;
|
|
15
18
|
/**
|
|
16
19
|
* @type {any}
|
|
17
20
|
*/
|
|
18
|
-
|
|
21
|
+
declare const SuffixWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
22
|
+
as?: import("react").ElementType;
|
|
23
|
+
}>;
|
|
24
|
+
export { inputFocusClasses, InputWrapper, Paragraph, Container, SuffixWrapper };
|
|
@@ -48,8 +48,9 @@ const inputClasses = css`
|
|
|
48
48
|
|
|
49
49
|
&.hasValue + label,
|
|
50
50
|
&:-webkit-autofill + label {
|
|
51
|
-
transform: scale(0.
|
|
51
|
+
transform: scale(0.7857) translateY(-10px);
|
|
52
52
|
font-weight: ${fontWeights.bold};
|
|
53
|
+
color: ${colors.textPrimary};
|
|
53
54
|
}
|
|
54
55
|
`;
|
|
55
56
|
|
|
@@ -57,15 +58,12 @@ export default inputClasses;
|
|
|
57
58
|
|
|
58
59
|
const inputFocusClasses = css`
|
|
59
60
|
&:focus + label {
|
|
60
|
-
transform: scale(0.
|
|
61
|
+
transform: scale(0.7857) translateY(-10px);
|
|
61
62
|
font-weight: ${fontWeights.bold};
|
|
62
63
|
}
|
|
63
64
|
`;
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
* @type {React.FC<any>}
|
|
67
|
-
*/
|
|
68
|
-
const Container = styled.div`
|
|
66
|
+
const Container = styled.div<{ containerWidth: string }>`
|
|
69
67
|
width: ${({ containerWidth }) => containerWidth};
|
|
70
68
|
`;
|
|
71
69
|
|
|
@@ -89,8 +87,25 @@ const InputWrapper = styled.div`
|
|
|
89
87
|
border: ${borderWidths.sm} ${borderStyles.solid} ${colors.borderRegular};
|
|
90
88
|
background-color: ${colors.backgroundPrimary};
|
|
91
89
|
|
|
90
|
+
&:hover {
|
|
91
|
+
border: ${borderWidths.sm} ${borderStyles.solid} ${colors.borderBlack};
|
|
92
|
+
transition: all 0.3s ease;
|
|
93
|
+
}
|
|
94
|
+
|
|
92
95
|
&:focus-within {
|
|
93
96
|
border-color: ${colors.borderBrand};
|
|
97
|
+
|
|
98
|
+
&:not(.error) > label {
|
|
99
|
+
color: ${colors.textBrand};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
& > label {
|
|
103
|
+
color: ${colors.textPrimary};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
&.error > label {
|
|
108
|
+
color: ${colors.textError};
|
|
94
109
|
}
|
|
95
110
|
|
|
96
111
|
&.error {
|
|
@@ -102,7 +117,7 @@ const InputWrapper = styled.div`
|
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
&.disabled {
|
|
105
|
-
border-color: ${colors.
|
|
120
|
+
border-color: ${colors.borderRegular};
|
|
106
121
|
background-color: ${colors.backgroundSecondary};
|
|
107
122
|
}
|
|
108
123
|
|
|
@@ -148,7 +163,6 @@ const InputWrapper = styled.div`
|
|
|
148
163
|
color: ${colors.iconTertiary};
|
|
149
164
|
pointer-events: none;
|
|
150
165
|
}
|
|
151
|
-
|
|
152
166
|
`;
|
|
153
167
|
|
|
154
168
|
/**
|
|
@@ -158,7 +172,7 @@ const SuffixWrapper = styled.div`
|
|
|
158
172
|
position: absolute;
|
|
159
173
|
top: 20px;
|
|
160
174
|
right: ${space.sm};
|
|
161
|
-
color: ${colors.
|
|
175
|
+
color: ${colors.textPrimary};
|
|
162
176
|
`;
|
|
163
177
|
|
|
164
178
|
export { inputFocusClasses, InputWrapper, Paragraph, Container, SuffixWrapper };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import theme from '@clad-ui/theme';
|
|
3
|
+
import { type InputProps } from '../Input/Input';
|
|
3
4
|
import { cx, noop } from '../../utils';
|
|
4
5
|
import formatValue from './utils/_formatValue';
|
|
5
6
|
import cleanValue from './utils/_cleanValue';
|
|
@@ -9,69 +10,15 @@ import inputClasses, {
|
|
|
9
10
|
InputWrapper,
|
|
10
11
|
Paragraph,
|
|
11
12
|
SuffixWrapper,
|
|
12
|
-
} from './CurrencyInput.styles
|
|
13
|
+
} from './CurrencyInput.styles';
|
|
13
14
|
|
|
14
15
|
const { sizes } = theme;
|
|
15
|
-
const keysOfSizes = [...Object.keys(sizes)] as const;
|
|
16
|
-
type Size = (typeof keysOfSizes)[number];
|
|
17
16
|
|
|
18
|
-
export
|
|
19
|
-
/**
|
|
20
|
-
* Input name
|
|
21
|
-
*/
|
|
22
|
-
name?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Input label
|
|
25
|
-
*/
|
|
26
|
-
label?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Input ref (implement with useRef() hooks)
|
|
29
|
-
*/
|
|
30
|
-
inputRef?: React.MutableRefObject<any> | React.RefCallback<HTMLInputElement>;
|
|
31
|
-
/**
|
|
32
|
-
* The input content value
|
|
33
|
-
*/
|
|
34
|
-
value?: number | string;
|
|
35
|
-
/**
|
|
36
|
-
* Callback when user input. Return event value with numeric value in string. eg: 1200.25
|
|
37
|
-
*/
|
|
38
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
17
|
+
export interface CurrencyInputProps extends InputProps {
|
|
39
18
|
/**
|
|
40
19
|
* Callback when user input. Return formatted value. eg: 1.200,25
|
|
41
20
|
*/
|
|
42
21
|
onFormatChange?: (value: string) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Callback when user blur
|
|
45
|
-
*/
|
|
46
|
-
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Callback when user focus
|
|
49
|
-
*/
|
|
50
|
-
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
51
|
-
/**
|
|
52
|
-
* Disabled input
|
|
53
|
-
*/
|
|
54
|
-
disabled?: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Whether this input is required or not
|
|
57
|
-
*/
|
|
58
|
-
required?: boolean;
|
|
59
|
-
/**
|
|
60
|
-
* The id of input
|
|
61
|
-
*/
|
|
62
|
-
id?: string;
|
|
63
|
-
/**
|
|
64
|
-
* Input status (useful when implemented with form validation)
|
|
65
|
-
*/
|
|
66
|
-
status?: 'default' | 'error';
|
|
67
|
-
/**
|
|
68
|
-
* Promp a helptext below input (useful when implemented with form validation)
|
|
69
|
-
*/
|
|
70
|
-
helptext?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Input width
|
|
73
|
-
*/
|
|
74
|
-
width?: Size;
|
|
75
22
|
/**
|
|
76
23
|
* Suffix. eg: đ, $ or £,...
|
|
77
24
|
*/
|
|
@@ -96,7 +43,7 @@ export type CurrencyInputProps = {
|
|
|
96
43
|
* Allow negative value
|
|
97
44
|
*/
|
|
98
45
|
allowNegativeValue?: boolean;
|
|
99
|
-
}
|
|
46
|
+
}
|
|
100
47
|
|
|
101
48
|
/**
|
|
102
49
|
* CurrencyInput component allows users to input money amount with numeric keyboard,
|
|
@@ -126,6 +73,7 @@ const CurrencyInput: React.FC<CurrencyInputProps> = ({
|
|
|
126
73
|
decimalSeparator = ',',
|
|
127
74
|
maxDigits = 12,
|
|
128
75
|
decimalsLimit = 0,
|
|
76
|
+
helptextClassName = '',
|
|
129
77
|
}) => {
|
|
130
78
|
const { useState, useRef, useEffect, useCallback } = React;
|
|
131
79
|
|
|
@@ -149,7 +97,7 @@ const CurrencyInput: React.FC<CurrencyInputProps> = ({
|
|
|
149
97
|
const [stateValue, setStateValue] = useState(formattedStateValue);
|
|
150
98
|
const [dirty, setDirty] = useState(false);
|
|
151
99
|
const [cursor, setCursor] = useState(0);
|
|
152
|
-
const defaultInputRef = useRef();
|
|
100
|
+
const defaultInputRef = useRef<HTMLInputElement>(null);
|
|
153
101
|
const ref = inputRef ?? defaultInputRef;
|
|
154
102
|
|
|
155
103
|
// Prevent cursor jumping if editing value
|
|
@@ -332,11 +280,9 @@ const CurrencyInput: React.FC<CurrencyInputProps> = ({
|
|
|
332
280
|
</SuffixWrapper>
|
|
333
281
|
)}
|
|
334
282
|
</InputWrapper>
|
|
335
|
-
<Paragraph>{helptext}</Paragraph>
|
|
283
|
+
<Paragraph className={helptextClassName}>{helptext}</Paragraph>
|
|
336
284
|
</Container>
|
|
337
285
|
);
|
|
338
286
|
};
|
|
339
287
|
|
|
340
|
-
|
|
341
|
-
|
|
342
288
|
export default CurrencyInput;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { type Sizes } from '@clad-ui/theme';
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
declare const keysOfSizes: readonly string[];
|
|
3
4
|
type Size = (typeof keysOfSizes)[number];
|
|
4
5
|
type DropdownOption = {
|
|
5
6
|
value: string;
|
|
6
7
|
label: string;
|
|
8
|
+
icon?: React.ReactElement;
|
|
7
9
|
};
|
|
8
|
-
export
|
|
10
|
+
export interface DropdownProps {
|
|
9
11
|
/**
|
|
10
12
|
* Custom class to override dropdown's style.
|
|
11
13
|
*/
|
|
@@ -29,19 +31,19 @@ export type DropdownProps = {
|
|
|
29
31
|
/**
|
|
30
32
|
* Callback when user click / tap on the input
|
|
31
33
|
*/
|
|
32
|
-
onClick?:
|
|
34
|
+
onClick?: React.MouseEventHandler<HTMLSelectElement>;
|
|
33
35
|
/**
|
|
34
36
|
* Callback when user input
|
|
35
37
|
*/
|
|
36
|
-
onChange?:
|
|
38
|
+
onChange?: React.ChangeEventHandler<HTMLSelectElement>;
|
|
37
39
|
/**
|
|
38
40
|
* Callback when user blur
|
|
39
41
|
*/
|
|
40
|
-
onBlur?:
|
|
42
|
+
onBlur?: React.FocusEventHandler<HTMLSelectElement>;
|
|
41
43
|
/**
|
|
42
44
|
* Callback when user focus
|
|
43
45
|
*/
|
|
44
|
-
onFocus?:
|
|
46
|
+
onFocus?: React.FocusEventHandler<HTMLSelectElement>;
|
|
45
47
|
/**
|
|
46
48
|
* Disabled dropdown
|
|
47
49
|
*/
|
|
@@ -63,14 +65,27 @@ export type DropdownProps = {
|
|
|
63
65
|
*/
|
|
64
66
|
helptext?: string;
|
|
65
67
|
/**
|
|
66
|
-
*
|
|
68
|
+
* Custom helptext
|
|
69
|
+
*/
|
|
70
|
+
helptextClassName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Dropdown options. Options is an array and each array item is an object with shape of `{value: string, label: string, icon?: ReactElement}`.
|
|
67
73
|
*/
|
|
68
74
|
options?: DropdownOption[];
|
|
69
75
|
/**
|
|
70
76
|
* Dropdown width
|
|
71
77
|
*/
|
|
72
78
|
width?: Size;
|
|
73
|
-
|
|
79
|
+
menuMaxHeight?: Sizes;
|
|
80
|
+
/**
|
|
81
|
+
* Icon to be displayed on the left side of the dropdown
|
|
82
|
+
*/
|
|
83
|
+
icon?: React.ReactElement;
|
|
84
|
+
/**
|
|
85
|
+
* Padding for icon (default is 20px). This is available when icon is provided.
|
|
86
|
+
*/
|
|
87
|
+
paddingForIcon?: number;
|
|
88
|
+
}
|
|
74
89
|
/**
|
|
75
90
|
* Dropdown component that wraps around HTML Select element
|
|
76
91
|
*
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const defaultDropdown: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./Dropdown").DropdownProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
width: {
|
|
15
|
+
options: string[];
|
|
16
|
+
};
|
|
17
|
+
disabled: {};
|
|
18
|
+
required: {};
|
|
19
|
+
status: {};
|
|
20
|
+
id: {
|
|
21
|
+
control: null;
|
|
22
|
+
};
|
|
23
|
+
name: {
|
|
24
|
+
control: null;
|
|
25
|
+
};
|
|
26
|
+
value: {
|
|
27
|
+
control: null;
|
|
28
|
+
};
|
|
29
|
+
onChange: {
|
|
30
|
+
control: null;
|
|
31
|
+
};
|
|
32
|
+
onBlur: {
|
|
33
|
+
control: null;
|
|
34
|
+
};
|
|
35
|
+
onFocus: {
|
|
36
|
+
control: null;
|
|
37
|
+
};
|
|
38
|
+
inputRef: {
|
|
39
|
+
control: null;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
args: {
|
|
43
|
+
options: {
|
|
44
|
+
value: string;
|
|
45
|
+
label: string;
|
|
46
|
+
}[];
|
|
47
|
+
label: string;
|
|
48
|
+
helptext: string;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default defaultDropdown;
|
|
52
|
+
export declare const Overview: {
|
|
53
|
+
render: (args: any) => JSX.Element;
|
|
54
|
+
};
|
|
55
|
+
export declare const ValueBinding: {
|
|
56
|
+
render: () => JSX.Element;
|
|
57
|
+
parameters: {
|
|
58
|
+
docs: {
|
|
59
|
+
description: {
|
|
60
|
+
story: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export declare const WithHelptext: {
|
|
66
|
+
render: () => JSX.Element;
|
|
67
|
+
parameters: {
|
|
68
|
+
docs: {
|
|
69
|
+
description: {
|
|
70
|
+
story: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export declare const WithIcon: {
|
|
76
|
+
render: () => JSX.Element;
|
|
77
|
+
parameters: {
|
|
78
|
+
docs: {
|
|
79
|
+
description: {
|
|
80
|
+
story: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export declare const WithLongOptions: {
|
|
86
|
+
render: () => JSX.Element;
|
|
87
|
+
};
|
|
88
|
+
export declare const Required: {
|
|
89
|
+
render: () => JSX.Element;
|
|
90
|
+
parameters: {
|
|
91
|
+
docs: {
|
|
92
|
+
description: {
|
|
93
|
+
story: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export declare const ErrorStatus: {
|
|
99
|
+
render: () => JSX.Element;
|
|
100
|
+
parameters: {
|
|
101
|
+
docs: {
|
|
102
|
+
description: {
|
|
103
|
+
story: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
export declare const Disabled: {
|
|
109
|
+
render: () => JSX.Element;
|
|
110
|
+
parameters: {
|
|
111
|
+
docs: {
|
|
112
|
+
description: {
|
|
113
|
+
story: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export declare const CustomClass: {
|
|
119
|
+
render: () => JSX.Element;
|
|
120
|
+
parameters: {
|
|
121
|
+
docs: {
|
|
122
|
+
description: {
|
|
123
|
+
story: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare const CustomDropdownExample: {
|
|
129
|
+
render: () => JSX.Element;
|
|
130
|
+
name: string;
|
|
131
|
+
parameters: {
|
|
132
|
+
docs: {
|
|
133
|
+
description: {
|
|
134
|
+
story: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export declare const DropdownOnDrawer: {
|
|
140
|
+
render: () => JSX.Element;
|
|
141
|
+
parameters: {
|
|
142
|
+
docs: {
|
|
143
|
+
description: {
|
|
144
|
+
story: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
@@ -6,6 +6,7 @@ import Grid from '../Grid/Grid';
|
|
|
6
6
|
import Col from '../Grid/Col';
|
|
7
7
|
import Drawer from '../../patterns/Drawer/Drawer';
|
|
8
8
|
import Button from '../Button/Button';
|
|
9
|
+
import { Heart } from '../../icons';
|
|
9
10
|
|
|
10
11
|
const { sizes } = theme;
|
|
11
12
|
|
|
@@ -130,6 +131,72 @@ export const WithHelptext = {
|
|
|
130
131
|
},
|
|
131
132
|
};
|
|
132
133
|
|
|
134
|
+
export const WithIcon = {
|
|
135
|
+
render: () => {
|
|
136
|
+
const [value, setValue] = useState('');
|
|
137
|
+
return (
|
|
138
|
+
<Grid rowCols={[1, 2]}>
|
|
139
|
+
<Col>
|
|
140
|
+
<Dropdown
|
|
141
|
+
label="Chọn tỉnh thành"
|
|
142
|
+
value={value}
|
|
143
|
+
onChange={(e) => setValue(e.target.value)}
|
|
144
|
+
helptext="Vui lòng chọn tỉnh thành"
|
|
145
|
+
icon={<Heart style={{ width: '20px', height: '20px', marginLeft: '12px' }} />}
|
|
146
|
+
options={[
|
|
147
|
+
{
|
|
148
|
+
value: 'hcm',
|
|
149
|
+
label: 'Tp Hồ Chí Minh',
|
|
150
|
+
icon: <Heart style={{ width: '20px', height: '20px' }} />,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
value: 'hn',
|
|
154
|
+
label: 'Hà Nội',
|
|
155
|
+
icon: <Heart style={{ width: '20px', height: '20px' }} />,
|
|
156
|
+
},
|
|
157
|
+
]}
|
|
158
|
+
/>
|
|
159
|
+
</Col>
|
|
160
|
+
</Grid>
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
parameters: {
|
|
165
|
+
docs: {
|
|
166
|
+
description: {
|
|
167
|
+
story: 'You can add an icon to the options by passing `icon` prop to the options',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const WithLongOptions = {
|
|
174
|
+
render: () => {
|
|
175
|
+
const [value, setValue] = useState('');
|
|
176
|
+
return (
|
|
177
|
+
<Grid rowCols={[1, 2]}>
|
|
178
|
+
<Col>
|
|
179
|
+
<Dropdown
|
|
180
|
+
label="Options"
|
|
181
|
+
value={value}
|
|
182
|
+
onChange={(e) => setValue(e.target.value)}
|
|
183
|
+
options={[
|
|
184
|
+
{ value: '1', label: 'Option 1' },
|
|
185
|
+
{ value: '2', label: 'Option 2' },
|
|
186
|
+
{ value: '3', label: 'Option 3' },
|
|
187
|
+
{ value: '4', label: 'Option 4' },
|
|
188
|
+
{ value: '5', label: 'Option 5' },
|
|
189
|
+
{ value: '6', label: 'Option 6' },
|
|
190
|
+
{ value: '7', label: 'Option 7' },
|
|
191
|
+
{ value: '8', label: 'Option 8' },
|
|
192
|
+
]}
|
|
193
|
+
/>
|
|
194
|
+
</Col>
|
|
195
|
+
</Grid>
|
|
196
|
+
);
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
|
|
133
200
|
export const Required = {
|
|
134
201
|
render: () => {
|
|
135
202
|
const [value, setValue] = useState('');
|
|
@@ -279,7 +346,7 @@ export const CustomClass = {
|
|
|
279
346
|
|
|
280
347
|
export const CustomDropdownExample = {
|
|
281
348
|
render: () => {
|
|
282
|
-
const inputRef = useRef(null);
|
|
349
|
+
const inputRef = useRef<HTMLSelectElement>(null);
|
|
283
350
|
const [popupOpen, setPopupOpen] = useState(false);
|
|
284
351
|
const [value, setValue] = useState('');
|
|
285
352
|
|
|
@@ -335,3 +402,50 @@ export const CustomDropdownExample = {
|
|
|
335
402
|
},
|
|
336
403
|
},
|
|
337
404
|
};
|
|
405
|
+
|
|
406
|
+
export const DropdownOnDrawer = {
|
|
407
|
+
render: () => {
|
|
408
|
+
const [popupOpen, setPopupOpen] = useState(false);
|
|
409
|
+
const [value, setValue] = useState('');
|
|
410
|
+
|
|
411
|
+
return (
|
|
412
|
+
<>
|
|
413
|
+
<Grid rowCols={[1, 2]}>
|
|
414
|
+
<Col>
|
|
415
|
+
<Button onClick={() => setPopupOpen(true)}>Show Popup</Button>
|
|
416
|
+
</Col>
|
|
417
|
+
<Col>
|
|
418
|
+
<Dropdown
|
|
419
|
+
value={value}
|
|
420
|
+
label="Chọn tỉnh thành"
|
|
421
|
+
options={[
|
|
422
|
+
{ value: 'hcm', label: 'Tp Hồ Chí Minh' },
|
|
423
|
+
{ value: 'hn', label: 'Hà Nội' },
|
|
424
|
+
]}
|
|
425
|
+
onChange={(e) => setValue(e.target.value)}
|
|
426
|
+
/>
|
|
427
|
+
</Col>
|
|
428
|
+
</Grid>
|
|
429
|
+
<Drawer open={popupOpen} onClose={() => setPopupOpen(false)}>
|
|
430
|
+
<Dropdown
|
|
431
|
+
value={value}
|
|
432
|
+
label="Chọn tỉnh thành"
|
|
433
|
+
options={[
|
|
434
|
+
{ value: 'hcm', label: 'Tp Hồ Chí Minh' },
|
|
435
|
+
{ value: 'hn', label: 'Hà Nội' },
|
|
436
|
+
]}
|
|
437
|
+
onChange={(e) => setValue(e.target.value)}
|
|
438
|
+
/>
|
|
439
|
+
</Drawer>
|
|
440
|
+
</>
|
|
441
|
+
);
|
|
442
|
+
},
|
|
443
|
+
|
|
444
|
+
parameters: {
|
|
445
|
+
docs: {
|
|
446
|
+
description: {
|
|
447
|
+
story: 'This example demonstrate Dropdown inside a Drawer',
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
};
|