@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
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
/* eslint-disable react/no-danger */
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useLayer } from 'react-laag';
|
|
4
|
-
import theme from '@clad-ui/theme';
|
|
4
|
+
import theme, { type Sizes } from '@clad-ui/theme';
|
|
5
|
+
import Search from '../../icons/Search';
|
|
5
6
|
import { cx } from '../../utils';
|
|
6
7
|
import noop from '../../utils/noop';
|
|
7
8
|
import ChevronDownFilled from '../../icons/ChevronDownFilled';
|
|
8
|
-
import ShapeIcon from '../../components/ShapeIcon/ShapeIcon';
|
|
9
9
|
import normalizeArrowKey from '../../utils/_normalizeArrowKey';
|
|
10
|
-
import Input from '../../components/Input/Input';
|
|
11
10
|
import {
|
|
12
11
|
menuClass,
|
|
13
12
|
optionClass,
|
|
@@ -15,35 +14,41 @@ import {
|
|
|
15
14
|
searchInputWrapperClass,
|
|
16
15
|
searchDropdownIconClass,
|
|
17
16
|
} from './SearchInput.styles';
|
|
17
|
+
import Input from '../../components/Input/Input';
|
|
18
18
|
|
|
19
19
|
const { sizes } = theme;
|
|
20
|
-
const keysOfSizes = [...Object.keys(sizes)] as const;
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
text?: string;
|
|
27
|
-
// to display in dropdown items
|
|
21
|
+
export interface SearchInputOption {
|
|
22
|
+
/** to display at input */
|
|
23
|
+
text: string;
|
|
24
|
+
/** to display in dropdown items, with HTML format capability */
|
|
28
25
|
html?: string;
|
|
29
|
-
|
|
30
|
-
data?:
|
|
31
|
-
}
|
|
26
|
+
/** arbitrary data object */
|
|
27
|
+
data?: any;
|
|
28
|
+
}
|
|
32
29
|
|
|
33
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Value data for this component, the text always reflects the input value, while selected is the selected option from the dropdown menu.
|
|
32
|
+
*/
|
|
33
|
+
export interface SearchInputValue {
|
|
34
34
|
text: string;
|
|
35
|
-
selected
|
|
36
|
-
}
|
|
35
|
+
selected?: SearchInputOption;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface SearchInputEvent extends React.ChangeEvent<HTMLInputElement> {
|
|
39
|
+
value: SearchInputValue;
|
|
40
|
+
}
|
|
37
41
|
|
|
38
|
-
|
|
42
|
+
// TODO: extends from InputProps
|
|
43
|
+
export interface SearchInputProps {
|
|
39
44
|
/**
|
|
40
45
|
* The id attribute of this component
|
|
41
46
|
*/
|
|
42
|
-
id?: string
|
|
47
|
+
id?: string;
|
|
43
48
|
/**
|
|
44
49
|
* Value data of this component.
|
|
45
50
|
*/
|
|
46
|
-
value?:
|
|
51
|
+
value?: SearchInputValue;
|
|
47
52
|
/**
|
|
48
53
|
* Variant to choose between SearchDropdown/ Input
|
|
49
54
|
*/
|
|
@@ -51,19 +56,19 @@ export type SearchInputProps = {
|
|
|
51
56
|
/**
|
|
52
57
|
* Options array to provide for the dropdown menu
|
|
53
58
|
*/
|
|
54
|
-
options?:
|
|
59
|
+
options?: SearchInputOption[];
|
|
55
60
|
/**
|
|
56
61
|
* Callback when user types in the search text field
|
|
57
62
|
*/
|
|
58
|
-
onInput?:
|
|
63
|
+
onInput?: (event: SearchInputEvent) => void;
|
|
59
64
|
/**
|
|
60
65
|
* Callback when user selects an item on the dropdown menu
|
|
61
66
|
*/
|
|
62
|
-
onSelect?:
|
|
67
|
+
onSelect?: (event: SearchInputEvent) => void;
|
|
63
68
|
/**
|
|
64
69
|
* Callback when user either types in text field or makes selection
|
|
65
70
|
*/
|
|
66
|
-
onChange?:
|
|
71
|
+
onChange?: (event: SearchInputEvent) => void;
|
|
67
72
|
/**
|
|
68
73
|
* Input name
|
|
69
74
|
*/
|
|
@@ -83,11 +88,11 @@ export type SearchInputProps = {
|
|
|
83
88
|
/**
|
|
84
89
|
* Callback when input is blur
|
|
85
90
|
*/
|
|
86
|
-
onBlur?: React.FocusEventHandler
|
|
91
|
+
onBlur?: React.FocusEventHandler<HTMLElement>;
|
|
87
92
|
/**
|
|
88
93
|
* Callback when input is focus
|
|
89
94
|
*/
|
|
90
|
-
onFocus?: React.FocusEventHandler
|
|
95
|
+
onFocus?: React.FocusEventHandler<HTMLElement>;
|
|
91
96
|
/**
|
|
92
97
|
* Disable the input
|
|
93
98
|
*/
|
|
@@ -98,6 +103,7 @@ export type SearchInputProps = {
|
|
|
98
103
|
required?: boolean;
|
|
99
104
|
/**
|
|
100
105
|
* If allow to remove input content with clear icon
|
|
106
|
+
* @default true
|
|
101
107
|
*/
|
|
102
108
|
allowClear?: boolean;
|
|
103
109
|
/**
|
|
@@ -108,6 +114,10 @@ export type SearchInputProps = {
|
|
|
108
114
|
* Promp a helptext below input (useful when implemented with form validation)
|
|
109
115
|
*/
|
|
110
116
|
helptext?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Custom helptext
|
|
119
|
+
*/
|
|
120
|
+
helptextClassName?: string;
|
|
111
121
|
/**
|
|
112
122
|
* Show a icon that contains tooltip
|
|
113
123
|
*/
|
|
@@ -119,12 +129,16 @@ export type SearchInputProps = {
|
|
|
119
129
|
/**
|
|
120
130
|
* Input width
|
|
121
131
|
*/
|
|
122
|
-
width?:
|
|
132
|
+
width?: Sizes;
|
|
123
133
|
/**
|
|
124
134
|
* Input menu max-height
|
|
125
135
|
*/
|
|
126
|
-
menuMaxHeight?:
|
|
127
|
-
|
|
136
|
+
menuMaxHeight?: Sizes;
|
|
137
|
+
/**
|
|
138
|
+
* Show search icon or not
|
|
139
|
+
*/
|
|
140
|
+
showSearchIcon?: boolean;
|
|
141
|
+
}
|
|
128
142
|
/**
|
|
129
143
|
* Search Input component that carefully takes care of accessibility and allow keyboard controls.
|
|
130
144
|
*
|
|
@@ -148,7 +162,9 @@ const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
148
162
|
// tooltip = '',
|
|
149
163
|
// inputMode = 'text',
|
|
150
164
|
// width = 'full',
|
|
165
|
+
allowClear = true,
|
|
151
166
|
menuMaxHeight = '$sm',
|
|
167
|
+
showSearchIcon = false,
|
|
152
168
|
...inputProps
|
|
153
169
|
}) => {
|
|
154
170
|
const { useState, useRef } = React;
|
|
@@ -181,7 +197,7 @@ const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
181
197
|
|
|
182
198
|
setTriggerRef(textFieldRef.current);
|
|
183
199
|
|
|
184
|
-
const doSelect = (event, selected) => {
|
|
200
|
+
const doSelect = (event: SearchInputEvent, selected: SearchInputOption) => {
|
|
185
201
|
if (selected && event) {
|
|
186
202
|
event.value = {
|
|
187
203
|
text: selected.text,
|
|
@@ -197,14 +213,14 @@ const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
197
213
|
return onChange?.(event);
|
|
198
214
|
};
|
|
199
215
|
|
|
200
|
-
const handleInputChange = (e) => {
|
|
216
|
+
const handleInputChange = (e: SearchInputEvent) => {
|
|
201
217
|
// this is vanilla input's value
|
|
202
218
|
const text = e?.target?.value ?? '';
|
|
203
219
|
// augment event with more complex value object
|
|
204
220
|
if (e) {
|
|
205
221
|
e.value = {
|
|
206
222
|
text,
|
|
207
|
-
selected:
|
|
223
|
+
selected: undefined,
|
|
208
224
|
};
|
|
209
225
|
}
|
|
210
226
|
onInput?.(e);
|
|
@@ -285,10 +301,12 @@ const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
285
301
|
>
|
|
286
302
|
<Input
|
|
287
303
|
{...inputProps}
|
|
304
|
+
allowClear={allowClear}
|
|
288
305
|
inputRef={textFieldRef}
|
|
289
306
|
value={textValue}
|
|
290
307
|
onChange={handleInputChange}
|
|
291
308
|
onFocus={variant === 'dropdown' ? onDropdownFocus : noop}
|
|
309
|
+
icon={!!showSearchIcon && <Search width={20} height={20} />}
|
|
292
310
|
/>
|
|
293
311
|
{!!showMenu &&
|
|
294
312
|
renderLayer(
|
|
@@ -320,9 +338,10 @@ const SearchInput: React.FC<SearchInputProps> = ({
|
|
|
320
338
|
)}
|
|
321
339
|
{variant === 'dropdown' && (
|
|
322
340
|
<span className={cx(searchDropdownIconClass, showMenu ? invertedArrowClass : '')}>
|
|
323
|
-
<
|
|
324
|
-
|
|
325
|
-
|
|
341
|
+
<ChevronDownFilled
|
|
342
|
+
className="arrow"
|
|
343
|
+
style={{ fontSize: '1.5rem', color: inputProps?.disabled && theme.colors.iconDisabled }}
|
|
344
|
+
/>
|
|
326
345
|
</span>
|
|
327
346
|
)}
|
|
328
347
|
</div>
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
type TagCloudOption = {
|
|
2
|
+
export type TagCloudOption = {
|
|
3
3
|
value: string;
|
|
4
4
|
label: string;
|
|
5
5
|
};
|
|
6
|
-
export type
|
|
6
|
+
export type TagCloudValue<T extends boolean | undefined = undefined> = T extends true ? string[] : string;
|
|
7
|
+
/**
|
|
8
|
+
* Tag Cloud change event, value is stored in target.value
|
|
9
|
+
*/
|
|
10
|
+
export interface TagCloudChangeEvent<Multi extends boolean | undefined = undefined> extends Event {
|
|
11
|
+
target: Omit<EventTarget, 'value'> & {
|
|
12
|
+
value: TagCloudValue<Multi>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface TagCloudProps {
|
|
7
16
|
/**
|
|
8
17
|
* Tag cloud className
|
|
9
18
|
*/
|
|
@@ -19,11 +28,11 @@ export type TagCloudProps = {
|
|
|
19
28
|
/**
|
|
20
29
|
* Value of the active chip(s)
|
|
21
30
|
*/
|
|
22
|
-
value?:
|
|
31
|
+
value?: TagCloudValue<this['multiple']>;
|
|
23
32
|
/**
|
|
24
33
|
* Change event
|
|
25
34
|
*/
|
|
26
|
-
onChange?: () => void;
|
|
35
|
+
onChange?: (event: TagCloudChangeEvent<this['multiple']>) => void;
|
|
27
36
|
/**
|
|
28
37
|
* Whether this tag cloud requires at least 1 option or not
|
|
29
38
|
*/
|
|
@@ -39,7 +48,7 @@ export type TagCloudProps = {
|
|
|
39
48
|
/**
|
|
40
49
|
* Tag cloud ref
|
|
41
50
|
*/
|
|
42
|
-
tagCloudRef?: React.RefObject<HTMLDivElement
|
|
51
|
+
tagCloudRef?: React.RefObject<HTMLDivElement>;
|
|
43
52
|
/**
|
|
44
53
|
* Tag cloud status (useful when implemented with validation)
|
|
45
54
|
*/
|
|
@@ -52,7 +61,11 @@ export type TagCloudProps = {
|
|
|
52
61
|
* Chip variant
|
|
53
62
|
*/
|
|
54
63
|
variant?: 'normal' | 'outline';
|
|
55
|
-
|
|
64
|
+
/**
|
|
65
|
+
* selected Text FontWeight
|
|
66
|
+
*/
|
|
67
|
+
selectedTextStyle?: 'bold' | 'normal';
|
|
68
|
+
}
|
|
56
69
|
/**
|
|
57
70
|
* Tag Cloud pattern, including multiple Chip components
|
|
58
71
|
*
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const tagCloudStories: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: React.FC<import("./TagCloud").TagCloudProps>;
|
|
5
|
+
tags: string[];
|
|
6
|
+
parameters: {
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
argTypes: {
|
|
14
|
+
maxSelection: {
|
|
15
|
+
control: {
|
|
16
|
+
type: string;
|
|
17
|
+
min: number;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
required: {};
|
|
21
|
+
multiple: {};
|
|
22
|
+
status: {};
|
|
23
|
+
tagCloudRef: {
|
|
24
|
+
control: null;
|
|
25
|
+
};
|
|
26
|
+
onChange: {
|
|
27
|
+
control: null;
|
|
28
|
+
};
|
|
29
|
+
className: {
|
|
30
|
+
control: null;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
args: {
|
|
34
|
+
label: string;
|
|
35
|
+
options: {
|
|
36
|
+
value: string;
|
|
37
|
+
label: string;
|
|
38
|
+
}[];
|
|
39
|
+
control: {
|
|
40
|
+
type: string;
|
|
41
|
+
};
|
|
42
|
+
value: string;
|
|
43
|
+
helptext: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export default tagCloudStories;
|
|
47
|
+
export declare const Overview: {
|
|
48
|
+
render: (args: any) => JSX.Element;
|
|
49
|
+
};
|
|
50
|
+
export declare const BoldAndNormalSelected: {
|
|
51
|
+
render: () => JSX.Element;
|
|
52
|
+
name: string;
|
|
53
|
+
parameters: {
|
|
54
|
+
docs: {
|
|
55
|
+
description: {
|
|
56
|
+
story: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
export declare const OutlineVariant: {
|
|
62
|
+
render: () => JSX.Element;
|
|
63
|
+
name: string;
|
|
64
|
+
parameters: {
|
|
65
|
+
docs: {
|
|
66
|
+
description: {
|
|
67
|
+
story: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export declare const WithHelptext: {
|
|
73
|
+
render: () => JSX.Element;
|
|
74
|
+
name: string;
|
|
75
|
+
parameters: {
|
|
76
|
+
docs: {
|
|
77
|
+
description: {
|
|
78
|
+
story: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
export declare const SingleActive: {
|
|
84
|
+
render: () => JSX.Element;
|
|
85
|
+
name: string;
|
|
86
|
+
parameters: {
|
|
87
|
+
docs: {
|
|
88
|
+
description: {
|
|
89
|
+
story: string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
export declare const MultiActive: {
|
|
95
|
+
render: () => JSX.Element;
|
|
96
|
+
name: string;
|
|
97
|
+
parameters: {
|
|
98
|
+
docs: {
|
|
99
|
+
description: {
|
|
100
|
+
story: string;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export declare const WithMaxSelection: {
|
|
106
|
+
render: () => JSX.Element;
|
|
107
|
+
name: string;
|
|
108
|
+
parameters: {
|
|
109
|
+
docs: {
|
|
110
|
+
description: {
|
|
111
|
+
story: string;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare const IsRequired: {
|
|
117
|
+
render: () => JSX.Element;
|
|
118
|
+
name: string;
|
|
119
|
+
parameters: {
|
|
120
|
+
docs: {
|
|
121
|
+
description: {
|
|
122
|
+
story: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
export declare const ErrorStatus: {
|
|
128
|
+
render: () => JSX.Element;
|
|
129
|
+
name: string;
|
|
130
|
+
parameters: {
|
|
131
|
+
docs: {
|
|
132
|
+
description: {
|
|
133
|
+
story: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
export declare const WithoutLabel: {
|
|
139
|
+
render: () => JSX.Element;
|
|
140
|
+
name: string;
|
|
141
|
+
parameters: {
|
|
142
|
+
docs: {
|
|
143
|
+
description: {
|
|
144
|
+
story: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
export declare const WithClassName: {
|
|
150
|
+
render: () => JSX.Element;
|
|
151
|
+
name: string;
|
|
152
|
+
parameters: {
|
|
153
|
+
docs: {
|
|
154
|
+
description: {
|
|
155
|
+
story: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import { css } from '@linaria/core';
|
|
3
3
|
import { guideImageClass } from '../../storybook/GuideImage';
|
|
4
|
-
import TagCloud from './TagCloud';
|
|
4
|
+
import TagCloud, { type TagCloudChangeEvent } from './TagCloud';
|
|
5
5
|
|
|
6
6
|
const gridClass = css`
|
|
7
7
|
/* stylelint-disable declaration-no-important */
|
|
@@ -98,7 +98,7 @@ export const Overview = {
|
|
|
98
98
|
if (args.value) setValue(args.value);
|
|
99
99
|
}, [args.value]);
|
|
100
100
|
|
|
101
|
-
const onTagCloudChanged = ({ target }) => {
|
|
101
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
102
102
|
setValue(target.value);
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -106,11 +106,56 @@ export const Overview = {
|
|
|
106
106
|
},
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
+
export const BoldAndNormalSelected = {
|
|
110
|
+
render: () => {
|
|
111
|
+
const [value, setValue] = useState('automatic');
|
|
112
|
+
const onTagCloudChanged = ({ target }) => {
|
|
113
|
+
setValue(target.value);
|
|
114
|
+
};
|
|
115
|
+
return (
|
|
116
|
+
<>
|
|
117
|
+
Bold Text (by default)
|
|
118
|
+
<TagCloud
|
|
119
|
+
label="Gear box"
|
|
120
|
+
options={[
|
|
121
|
+
{ value: 'automatic', label: 'Automatic' },
|
|
122
|
+
{ value: 'manual', label: 'Manual' },
|
|
123
|
+
{ value: 'semi', label: 'Semi-automatic' },
|
|
124
|
+
]}
|
|
125
|
+
value={value}
|
|
126
|
+
onChange={onTagCloudChanged}
|
|
127
|
+
/>
|
|
128
|
+
Normal Text
|
|
129
|
+
<TagCloud
|
|
130
|
+
label="Gear box"
|
|
131
|
+
options={[
|
|
132
|
+
{ value: 'automatic', label: 'Automatic' },
|
|
133
|
+
{ value: 'manual', label: 'Manual' },
|
|
134
|
+
{ value: 'semi', label: 'Semi-automatic' },
|
|
135
|
+
]}
|
|
136
|
+
value={value}
|
|
137
|
+
onChange={onTagCloudChanged}
|
|
138
|
+
selectedTextStyle="normal"
|
|
139
|
+
/>
|
|
140
|
+
</>
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
name: 'With helptext',
|
|
145
|
+
|
|
146
|
+
parameters: {
|
|
147
|
+
docs: {
|
|
148
|
+
description: {
|
|
149
|
+
story: 'Bold and normal selected text style.',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
109
154
|
|
|
110
155
|
export const OutlineVariant = {
|
|
111
156
|
render: () => {
|
|
112
157
|
const [value, setValue] = useState('automatic');
|
|
113
|
-
const onTagCloudChanged = ({ target }) => {
|
|
158
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
114
159
|
setValue(target.value);
|
|
115
160
|
};
|
|
116
161
|
return (
|
|
@@ -143,7 +188,7 @@ export const OutlineVariant = {
|
|
|
143
188
|
export const WithHelptext = {
|
|
144
189
|
render: () => {
|
|
145
190
|
const [value, setValue] = useState('automatic');
|
|
146
|
-
const onTagCloudChanged = ({ target }) => {
|
|
191
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
147
192
|
setValue(target.value);
|
|
148
193
|
};
|
|
149
194
|
return (
|
|
@@ -175,7 +220,7 @@ export const WithHelptext = {
|
|
|
175
220
|
export const SingleActive = {
|
|
176
221
|
render: () => {
|
|
177
222
|
const [value, setValue] = useState('automatic');
|
|
178
|
-
const onTagCloudChanged = ({ target }) => {
|
|
223
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
179
224
|
setValue(target.value);
|
|
180
225
|
};
|
|
181
226
|
return (
|
|
@@ -205,8 +250,8 @@ export const SingleActive = {
|
|
|
205
250
|
|
|
206
251
|
export const MultiActive = {
|
|
207
252
|
render: () => {
|
|
208
|
-
const [value, setValue] = useState([]);
|
|
209
|
-
const onTagCloudChanged = ({ target }) => {
|
|
253
|
+
const [value, setValue] = useState<string[]>([]);
|
|
254
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent<true>) => {
|
|
210
255
|
setValue(target.value);
|
|
211
256
|
};
|
|
212
257
|
return (
|
|
@@ -242,8 +287,8 @@ export const MultiActive = {
|
|
|
242
287
|
|
|
243
288
|
export const WithMaxSelection = {
|
|
244
289
|
render: () => {
|
|
245
|
-
const [value, setValue] = useState([]);
|
|
246
|
-
const onTagCloudChanged = ({ target }) => {
|
|
290
|
+
const [value, setValue] = useState<string[]>([]);
|
|
291
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent<true>) => {
|
|
247
292
|
setValue(target.value);
|
|
248
293
|
};
|
|
249
294
|
const label = `Mô tả bản thân (${value.length}/5)`;
|
|
@@ -284,7 +329,7 @@ export const WithMaxSelection = {
|
|
|
284
329
|
export const IsRequired = {
|
|
285
330
|
render: () => {
|
|
286
331
|
const [value, setValue] = useState('automatic');
|
|
287
|
-
const onTagCloudChanged = ({ target }) => {
|
|
332
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
288
333
|
setValue(target.value);
|
|
289
334
|
};
|
|
290
335
|
return (
|
|
@@ -316,10 +361,10 @@ export const IsRequired = {
|
|
|
316
361
|
|
|
317
362
|
export const ErrorStatus = {
|
|
318
363
|
render: () => {
|
|
319
|
-
const [value, setValue] = useState([]);
|
|
364
|
+
const [value, setValue] = useState<string[]>([]);
|
|
320
365
|
const status = value.length < 2 ? 'error' : 'default';
|
|
321
366
|
|
|
322
|
-
const onTagCloudChanged = ({ target }) => {
|
|
367
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent<true>) => {
|
|
323
368
|
setValue(target.value);
|
|
324
369
|
};
|
|
325
370
|
return (
|
|
@@ -356,7 +401,7 @@ export const ErrorStatus = {
|
|
|
356
401
|
export const WithoutLabel = {
|
|
357
402
|
render: () => {
|
|
358
403
|
const [value, setValue] = useState('automatic');
|
|
359
|
-
const onTagCloudChanged = ({ target }) => {
|
|
404
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
360
405
|
setValue(target.value);
|
|
361
406
|
};
|
|
362
407
|
return (
|
|
@@ -392,7 +437,7 @@ export const WithClassName = {
|
|
|
392
437
|
`;
|
|
393
438
|
|
|
394
439
|
const [value, setValue] = useState('automatic');
|
|
395
|
-
const onTagCloudChanged = ({ target }) => {
|
|
440
|
+
const onTagCloudChanged = ({ target }: TagCloudChangeEvent) => {
|
|
396
441
|
setValue(target.value);
|
|
397
442
|
};
|
|
398
443
|
return (
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
as?: import("react").ElementType
|
|
1
|
+
declare const StyledTagCloud: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
|
|
2
|
+
as?: import("react").ElementType;
|
|
3
3
|
}>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
declare const StyledLabel: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLLabelElement> & import("react").LabelHTMLAttributes<HTMLLabelElement> & {
|
|
5
|
+
selectedTextStyle?: string;
|
|
6
|
+
} & {
|
|
7
|
+
as?: import("react").ElementType;
|
|
6
8
|
}>;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
declare const Paragraph: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & {
|
|
10
|
+
helptextColor: string;
|
|
11
|
+
} & {
|
|
12
|
+
as?: import("react").ElementType;
|
|
13
|
+
}>;
|
|
14
|
+
export { StyledTagCloud, StyledLabel, Paragraph };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { styled } from '@linaria/react';
|
|
2
2
|
import theme from '@clad-ui/theme';
|
|
3
3
|
|
|
4
|
-
const { colors, fontSizes,
|
|
4
|
+
const { colors, fontSizes, space, lineHeights, sizes } = theme;
|
|
5
5
|
|
|
6
6
|
const StyledTagCloud = styled.div`
|
|
7
7
|
.chip-wrapper {
|
|
@@ -15,12 +15,12 @@ const StyledTagCloud = styled.div`
|
|
|
15
15
|
}
|
|
16
16
|
`;
|
|
17
17
|
|
|
18
|
-
const StyledLabel = styled.label
|
|
18
|
+
const StyledLabel = styled.label<{ selectedTextStyle?: string }>`
|
|
19
19
|
display: block;
|
|
20
20
|
font-size: ${fontSizes.xxs};
|
|
21
21
|
color: ${colors.textTertiary};
|
|
22
22
|
line-height: ${lineHeights.xl};
|
|
23
|
-
font-weight: ${
|
|
23
|
+
font-weight: ${({ selectedTextStyle }) => (selectedTextStyle ? selectedTextStyle : 'bold')};
|
|
24
24
|
|
|
25
25
|
&.required::after {
|
|
26
26
|
content: '*';
|
|
@@ -29,10 +29,9 @@ const StyledLabel = styled.label`
|
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const Paragraph = styled.p`
|
|
32
|
+
const Paragraph = styled.p<{
|
|
33
|
+
helptextColor: string;
|
|
34
|
+
}>`
|
|
36
35
|
color: ${({ helptextColor }) => helptextColor};
|
|
37
36
|
font-size: ${fontSizes.xxs};
|
|
38
37
|
min-height: ${sizes.xxs};
|