@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.
Files changed (224) hide show
  1. package/README.md +3 -3
  2. package/components/Announcer/Announcer.d.ts +9 -4
  3. package/components/Announcer/Announcer.stories.d.ts +142 -0
  4. package/components/Announcer/{Announcer.stories.js → Announcer.stories.tsx} +36 -31
  5. package/components/Announcer/Announcer.styles.d.ts +24 -12
  6. package/components/Announcer/{Announcer.styles.js → Announcer.styles.ts} +43 -18
  7. package/components/Announcer/Announcer.tsx +62 -47
  8. package/components/Badge/Badge.d.ts +4 -2
  9. package/components/Badge/Badge.stories.d.ts +61 -0
  10. package/components/Badge/{Badge.stories.js → Badge.stories.tsx} +5 -5
  11. package/components/Badge/Badge.styles.d.ts +20 -5
  12. package/components/Badge/{Badge.styles.js → Badge.styles.ts} +14 -1
  13. package/components/Badge/Badge.tsx +8 -4
  14. package/components/Box/Box.d.ts +3 -3
  15. package/components/Box/Box.stories.d.ts +240 -0
  16. package/components/Box/{Box.stories.js → Box.stories.tsx} +2 -2
  17. package/components/Box/Box.styles.d.ts +19 -4
  18. package/components/Box/{Box.styles.js → Box.styles.ts} +17 -4
  19. package/components/Box/Box.tsx +4 -4
  20. package/components/Breadcrumbs/Breadcrumbs.d.ts +2 -2
  21. package/components/Breadcrumbs/Breadcrumbs.stories.d.ts +52 -0
  22. package/components/Breadcrumbs/{Breadcrumbs.stories.js → Breadcrumbs.stories.tsx} +17 -15
  23. package/components/Breadcrumbs/Breadcrumbs.styles.d.ts +5 -4
  24. package/components/Breadcrumbs/Breadcrumbs.tsx +2 -2
  25. package/components/Button/Button.d.ts +21 -6
  26. package/components/Button/Button.stories.d.ts +103 -0
  27. package/components/Button/{Button.stories.js → Button.stories.tsx} +5 -1
  28. package/components/Button/Button.styles.d.ts +1 -1
  29. package/components/Button/{Button.styles.js → Button.styles.ts} +100 -6
  30. package/components/Button/Button.tsx +51 -18
  31. package/components/Button/ButtonLink.d.ts +4 -4
  32. package/components/Button/ButtonLink.stories.d.ts +30 -0
  33. package/components/Button/ButtonLink.styles.d.ts +1 -1
  34. package/components/Button/ButtonLink.tsx +5 -5
  35. package/components/Button/IconButton.d.ts +3 -29
  36. package/components/Button/IconButton.stories.d.ts +60 -0
  37. package/components/Button/{IconButton.stories.js → IconButton.stories.tsx} +27 -0
  38. package/components/Button/IconButton.tsx +2 -42
  39. package/components/Checkbox/Checkbox.d.ts +3 -3
  40. package/components/Checkbox/Checkbox.stories.d.ts +88 -0
  41. package/components/Checkbox/Checkbox.styles.d.ts +2 -2
  42. package/components/Checkbox/Checkbox.tsx +3 -6
  43. package/components/Chip/Chip.d.ts +5 -4
  44. package/components/Chip/Chip.stories.d.ts +153 -0
  45. package/components/Chip/{Chip.stories.js → Chip.stories.tsx} +4 -5
  46. package/components/Chip/Chip.styles.d.ts +11 -8
  47. package/components/Chip/{Chip.styles.js → Chip.styles.ts} +4 -4
  48. package/components/Chip/Chip.tsx +19 -12
  49. package/components/CurrencyInput/CurrencyInput.d.ts +3 -56
  50. package/components/CurrencyInput/CurrencyInput.stories.d.ts +104 -0
  51. package/components/CurrencyInput/{CurrencyInput.stories.js → CurrencyInput.stories.tsx} +2 -2
  52. package/components/CurrencyInput/CurrencyInput.styles.d.ts +16 -10
  53. package/components/CurrencyInput/{CurrencyInput.styles.js → CurrencyInput.styles.ts} +23 -9
  54. package/components/CurrencyInput/CurrencyInput.tsx +7 -61
  55. package/components/Dropdown/Dropdown.d.ts +22 -7
  56. package/components/Dropdown/Dropdown.stories.d.ts +148 -0
  57. package/components/Dropdown/{Dropdown.stories.js → Dropdown.stories.tsx} +115 -1
  58. package/components/Dropdown/Dropdown.styles.d.ts +10 -0
  59. package/components/Dropdown/Dropdown.styles.ts +42 -0
  60. package/components/Dropdown/Dropdown.tsx +120 -24
  61. package/components/Grid/Col.d.ts +2 -2
  62. package/components/Grid/Col.tsx +6 -3
  63. package/components/Grid/Grid.styles.d.ts +25 -5
  64. package/components/Grid/{Grid.styles.js → Grid.styles.ts} +16 -3
  65. package/components/Grid/aGrid.stories.d.ts +127 -0
  66. package/components/Grid/bCol.stories.d.ts +74 -0
  67. package/components/Input/Input.d.ts +14 -10
  68. package/components/Input/Input.stories.d.ts +226 -0
  69. package/components/Input/{Input.stories.js → Input.stories.tsx} +20 -16
  70. package/components/Input/Input.styles.d.ts +22 -11
  71. package/components/Input/{Input.styles.js → Input.styles.ts} +29 -7
  72. package/components/Input/Input.tsx +22 -20
  73. package/components/Popover/Popover.d.ts +44 -0
  74. package/components/Popover/Popover.stories.d.ts +53 -0
  75. package/components/Popover/Popover.stories.tsx +133 -0
  76. package/components/Popover/Popover.tsx +121 -0
  77. package/components/RadioButton/RadioButton.d.ts +5 -6
  78. package/components/RadioButton/RadioButton.stories.d.ts +94 -0
  79. package/components/RadioButton/RadioButton.styles.d.ts +7 -3
  80. package/components/RadioButton/{RadioButton.styles.js → RadioButton.styles.ts} +1 -1
  81. package/components/RadioButton/RadioButton.tsx +5 -11
  82. package/components/RowItem/RowItem.d.ts +27 -9
  83. package/components/RowItem/RowItem.stories.d.ts +131 -0
  84. package/components/RowItem/RowItem.stories.tsx +710 -0
  85. package/components/RowItem/RowItem.styles.d.ts +31 -10
  86. package/components/RowItem/{RowItem.styles.js → RowItem.styles.ts} +41 -13
  87. package/components/RowItem/RowItem.tsx +106 -42
  88. package/components/ShapeIcon/ShapeIcon.d.ts +23 -16
  89. package/components/ShapeIcon/ShapeIcon.stories.d.ts +91 -0
  90. package/components/ShapeIcon/{ShapeIcon.stories.js → ShapeIcon.stories.tsx} +21 -8
  91. package/components/ShapeIcon/ShapeIcon.styles.d.ts +8 -3
  92. package/components/ShapeIcon/{ShapeIcon.styles.js → ShapeIcon.styles.ts} +6 -3
  93. package/components/ShapeIcon/ShapeIcon.tsx +25 -21
  94. package/components/Slider/Slider.d.ts +9 -7
  95. package/components/Slider/Slider.stories.d.ts +81 -0
  96. package/components/Slider/{Slider.stories.js → Slider.stories.tsx} +7 -7
  97. package/components/Slider/Slider.styles.d.ts +15 -11
  98. package/components/Slider/{Slider.styles.js → Slider.styles.ts} +1 -1
  99. package/components/Slider/Slider.tsx +21 -16
  100. package/components/Snack/Snack.d.ts +4 -5
  101. package/components/Snack/Snack.stories.d.ts +87 -0
  102. package/components/Snack/Snack.styles.d.ts +9 -8
  103. package/components/Snack/{Snack.styles.js → Snack.styles.ts} +4 -4
  104. package/components/Snack/Snack.tsx +14 -11
  105. package/components/Tabs/Tab.d.ts +6 -6
  106. package/components/Tabs/Tab.tsx +6 -7
  107. package/components/Tabs/Tabs.d.ts +7 -4
  108. package/components/Tabs/Tabs.stories.d.ts +64 -0
  109. package/components/Tabs/{Tabs.stories.js → Tabs.stories.tsx} +2 -2
  110. package/components/Tabs/Tabs.styles.d.ts +30 -12
  111. package/components/Tabs/{Tabs.styles.js → Tabs.styles.ts} +4 -4
  112. package/components/Tabs/Tabs.tsx +11 -7
  113. package/components/TextArea/TextArea.d.ts +24 -11
  114. package/components/TextArea/TextArea.stories.d.ts +151 -0
  115. package/components/TextArea/{TextArea.stories.js → TextArea.stories.tsx} +5 -96
  116. package/components/TextArea/TextArea.styles.d.ts +18 -16
  117. package/components/TextArea/{TextArea.styles.js → TextArea.styles.ts} +39 -19
  118. package/components/TextArea/TextArea.tsx +85 -31
  119. package/components/TextLabel/TextLabel.d.ts +35 -0
  120. package/components/TextLabel/TextLabel.stories.d.ts +40 -0
  121. package/components/TextLabel/TextLabel.stories.tsx +177 -0
  122. package/components/TextLabel/TextLabel.styles.d.ts +9 -0
  123. package/components/TextLabel/TextLabel.styles.ts +24 -0
  124. package/components/TextLabel/TextLabel.tsx +112 -0
  125. package/components/ToggleSwitch/ToggleSwitch.d.ts +2 -2
  126. package/components/ToggleSwitch/ToggleSwitch.stories.d.ts +38 -0
  127. package/components/ToggleSwitch/ToggleSwitch.styles.d.ts +21 -14
  128. package/components/ToggleSwitch/{ToggleSwitch.styles.js → ToggleSwitch.styles.ts} +8 -12
  129. package/components/ToggleSwitch/ToggleSwitch.tsx +12 -6
  130. package/components/Tooltip/Tooltip.d.ts +9 -3
  131. package/components/Tooltip/Tooltip.spec.js +5 -3
  132. package/components/Tooltip/Tooltip.styles.d.ts +7 -8
  133. package/components/Tooltip/Tooltip.tsx +10 -3
  134. package/components/index.d.ts +2 -0
  135. package/components/index.ts +2 -0
  136. package/icons/PrivateSellerAvatar.d.ts +3 -0
  137. package/icons/PrivateSellerAvatar.js +3 -0
  138. package/icons/Sda.d.ts +5 -2
  139. package/icons/Sda.js +7 -7
  140. package/icons/VerifiedShop.d.ts +3 -0
  141. package/icons/VerifiedShop.js +3 -0
  142. package/package.json +6 -6
  143. package/patterns/Drawer/Drawer.d.ts +13 -13
  144. package/patterns/Drawer/Drawer.stories.d.ts +90 -0
  145. package/patterns/Drawer/{Drawer.stories.js → Drawer.stories.tsx} +25 -0
  146. package/patterns/Drawer/Drawer.styles.d.ts +30 -26
  147. package/patterns/Drawer/{Drawer.styles.js → Drawer.styles.ts} +2 -5
  148. package/patterns/Drawer/Drawer.tsx +20 -41
  149. package/patterns/EmptyState/EmptyState.d.ts +5 -4
  150. package/patterns/EmptyState/EmptyState.stories.d.ts +40 -0
  151. package/patterns/EmptyState/EmptyState.styles.d.ts +10 -10
  152. package/patterns/EmptyState/{EmptyState.styles.js → EmptyState.styles.ts} +5 -4
  153. package/patterns/EmptyState/EmptyState.tsx +14 -12
  154. package/patterns/InputGroup/InputGroup.d.ts +4 -0
  155. package/patterns/InputGroup/InputGroup.styles.d.ts +5 -4
  156. package/patterns/InputGroup/InputGroup.tsx +11 -5
  157. package/patterns/LegacyDialog/DialogMainIcon.d.ts +1 -0
  158. package/patterns/LegacyDialog/DialogMainIcon.js +51 -0
  159. package/patterns/LegacyDialog/LegacyDialog.d.ts +3 -3
  160. package/patterns/LegacyDialog/LegacyDialog.styles.d.ts +8 -10
  161. package/patterns/LegacyDialog/LegacyDialog.styles.js +1 -46
  162. package/patterns/LegacyDialog/LegacyDialog.tsx +5 -11
  163. package/patterns/LegacyPopup/LegacyPopup.d.ts +4 -4
  164. package/patterns/LegacyPopup/LegacyPopup.styles.d.ts +18 -13
  165. package/patterns/LegacyPopup/{LegacyPopup.styles.js → LegacyPopup.styles.ts} +3 -1
  166. package/patterns/LegacyPopup/LegacyPopup.tsx +4 -6
  167. package/patterns/MultiSearchDropdown/MultiSearchDropdown.d.ts +20 -17
  168. package/patterns/MultiSearchDropdown/MultiSearchDropdown.stories.d.ts +125 -0
  169. package/patterns/MultiSearchDropdown/{MultiSearchDropdown.stories.js → MultiSearchDropdown.stories.tsx} +31 -30
  170. package/patterns/MultiSearchDropdown/MultiSearchDropdown.styles.d.ts +22 -21
  171. package/patterns/MultiSearchDropdown/{MultiSearchDropdown.styles.js → MultiSearchDropdown.styles.ts} +1 -7
  172. package/patterns/MultiSearchDropdown/MultiSearchDropdown.tsx +33 -32
  173. package/patterns/Popup/Popup.d.ts +8 -7
  174. package/patterns/Popup/Popup.stories.d.ts +102 -0
  175. package/patterns/Popup/Popup.styles.d.ts +41 -30
  176. package/patterns/Popup/{Popup.styles.js → Popup.styles.ts} +26 -33
  177. package/patterns/Popup/Popup.tsx +14 -33
  178. package/patterns/SearchInput/SearchInput.d.ts +38 -21
  179. package/patterns/SearchInput/SearchInput.stories.d.ts +186 -0
  180. package/patterns/SearchInput/{SearchInput.stories.js → SearchInput.stories.tsx} +78 -45
  181. package/patterns/SearchInput/SearchInput.styles.d.ts +6 -5
  182. package/patterns/SearchInput/{SearchInput.styles.js → SearchInput.styles.ts} +7 -4
  183. package/patterns/SearchInput/SearchInput.tsx +53 -34
  184. package/patterns/TagCloud/TagCloud.d.ts +19 -6
  185. package/patterns/TagCloud/TagCloud.stories.d.ts +159 -0
  186. package/patterns/TagCloud/{TagCloud.stories.js → TagCloud.stories.tsx} +59 -14
  187. package/patterns/TagCloud/TagCloud.styles.d.ts +12 -8
  188. package/patterns/TagCloud/{TagCloud.styles.js → TagCloud.styles.ts} +6 -7
  189. package/patterns/TagCloud/TagCloud.tsx +24 -8
  190. package/patterns/TagCloud/TagCloudMultiActive.d.ts +6 -4
  191. package/patterns/TagCloud/TagCloudMultiActive.tsx +5 -5
  192. package/patterns/TagCloud/TagCloudSingleActive.d.ts +5 -2
  193. package/patterns/TagCloud/TagCloudSingleActive.tsx +18 -5
  194. package/patterns/patterns-index.spec.js +1 -1
  195. package/storybook/GuideImage.d.ts +2 -2
  196. package/storybook/Swatch.d.ts +2 -2
  197. package/theme/__snapshots__/chotot.spec.js.snap +2 -2
  198. package/theme/chotot-color1.d.ts +7 -14
  199. package/theme/chotot.d.ts +32 -32
  200. package/theme/chotot.js +4 -4
  201. package/theme/ct-job.d.ts +6 -14
  202. package/theme/ct-pty.d.ts +6 -8
  203. package/theme/mudah.d.ts +14 -13
  204. package/types.d.ts +0 -9
  205. package/utils/_simulateChangeEvent.d.ts +18 -3
  206. package/utils/_simulateChangeEvent.js +13 -6
  207. package/utils/_simulateChangeEvent.spec.js +1 -1
  208. package/utils/cx.d.ts +8 -4
  209. package/utils/cx.js +8 -4
  210. package/utils/sx.d.ts +12 -4192
  211. package/components/RowItem/RowItem.stories.js +0 -560
  212. /package/components/Breadcrumbs/{Breadcrumbs.styles.js → Breadcrumbs.styles.ts} +0 -0
  213. /package/components/Button/{ButtonLink.stories.js → ButtonLink.stories.tsx} +0 -0
  214. /package/components/Button/{ButtonLink.styles.js → ButtonLink.styles.ts} +0 -0
  215. /package/components/Checkbox/{Checkbox.stories.js → Checkbox.stories.tsx} +0 -0
  216. /package/components/Checkbox/{Checkbox.styles.js → Checkbox.styles.ts} +0 -0
  217. /package/components/Grid/{aGrid.stories.js → aGrid.stories.tsx} +0 -0
  218. /package/components/Grid/{bCol.stories.js → bCol.stories.tsx} +0 -0
  219. /package/components/RadioButton/{RadioButton.stories.js → RadioButton.stories.tsx} +0 -0
  220. /package/components/Snack/{Snack.stories.js → Snack.stories.tsx} +0 -0
  221. /package/components/ToggleSwitch/{ToggleSwitch.stories.js → ToggleSwitch.stories.tsx} +0 -0
  222. /package/patterns/EmptyState/{EmptyState.stories.js → EmptyState.stories.tsx} +0 -0
  223. /package/patterns/InputGroup/{InputGroup.styles.js → InputGroup.styles.ts} +0 -0
  224. /package/patterns/Popup/{Popup.stories.js → Popup.stories.tsx} +0 -0
@@ -0,0 +1,186 @@
1
+ import React from 'react';
2
+ declare const searchInputStories: {
3
+ title: string;
4
+ component: React.FC<import("./SearchInput").SearchInputProps>;
5
+ tags: string[];
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: string;
10
+ };
11
+ };
12
+ };
13
+ argTypes: {
14
+ width: {
15
+ options: string[];
16
+ control: {
17
+ type: string;
18
+ };
19
+ };
20
+ menuMaxHeight: {
21
+ options: string[];
22
+ control: {
23
+ type: string;
24
+ };
25
+ };
26
+ type: {};
27
+ disabled: {};
28
+ required: {};
29
+ allowClear: {};
30
+ status: {};
31
+ tooltip: {};
32
+ inputMode: {};
33
+ id: {};
34
+ name: {};
35
+ value: {
36
+ control: {
37
+ disable: boolean;
38
+ };
39
+ };
40
+ options: {
41
+ control: null;
42
+ };
43
+ onChange: {
44
+ control: null;
45
+ };
46
+ onBlur: {
47
+ control: null;
48
+ };
49
+ onFocus: {
50
+ control: null;
51
+ };
52
+ onInput: {
53
+ control: null;
54
+ };
55
+ onSelect: {
56
+ control: null;
57
+ };
58
+ inputRef: {
59
+ control: null;
60
+ };
61
+ };
62
+ args: {
63
+ label: string;
64
+ helptext: string;
65
+ value: {
66
+ selected: {
67
+ data: {
68
+ brand: string;
69
+ category: string;
70
+ name: string;
71
+ };
72
+ html: string;
73
+ text: string;
74
+ };
75
+ text: string;
76
+ };
77
+ options: {
78
+ data: {
79
+ brand: string;
80
+ category: string;
81
+ name: string;
82
+ };
83
+ html: string;
84
+ text: string;
85
+ }[];
86
+ };
87
+ };
88
+ export default searchInputStories;
89
+ export declare const Overview: {
90
+ render: (args: any) => JSX.Element;
91
+ };
92
+ export declare const ValueBinding: {
93
+ render: () => JSX.Element;
94
+ parameters: {
95
+ docs: {
96
+ description: {
97
+ story: string;
98
+ };
99
+ };
100
+ };
101
+ };
102
+ export declare const MenuMaxHeight: {
103
+ render: () => JSX.Element;
104
+ name: string;
105
+ parameters: {
106
+ docs: {
107
+ description: {
108
+ story: string;
109
+ };
110
+ };
111
+ };
112
+ };
113
+ export declare const AllowClear: {
114
+ render: () => JSX.Element;
115
+ name: string;
116
+ parameters: {
117
+ docs: {
118
+ description: {
119
+ story: string;
120
+ };
121
+ };
122
+ };
123
+ };
124
+ export declare const Required: {
125
+ render: () => JSX.Element;
126
+ name: string;
127
+ parameters: {
128
+ docs: {
129
+ description: {
130
+ story: string;
131
+ };
132
+ };
133
+ };
134
+ };
135
+ export declare const ErrorStatus: {
136
+ render: () => JSX.Element;
137
+ parameters: {
138
+ docs: {
139
+ description: {
140
+ story: string;
141
+ };
142
+ };
143
+ };
144
+ };
145
+ export declare const DropdownVariant: {
146
+ render: () => JSX.Element;
147
+ parameters: {
148
+ docs: {
149
+ description: {
150
+ story: string;
151
+ };
152
+ };
153
+ };
154
+ };
155
+ export declare const Events: {
156
+ render: () => JSX.Element;
157
+ name: string;
158
+ parameters: {
159
+ docs: {
160
+ description: {
161
+ story: string;
162
+ };
163
+ };
164
+ };
165
+ };
166
+ export declare const AsyncSearching: {
167
+ render: () => JSX.Element;
168
+ name: string;
169
+ parameters: {
170
+ docs: {
171
+ description: {
172
+ story: string;
173
+ };
174
+ };
175
+ };
176
+ };
177
+ export declare const WithSearchIcon: {
178
+ render: () => JSX.Element;
179
+ parameters: {
180
+ docs: {
181
+ description: {
182
+ story: string;
183
+ };
184
+ };
185
+ };
186
+ };
@@ -3,6 +3,7 @@ import theme from '@clad-ui/theme';
3
3
  import debounce from 'lodash/debounce';
4
4
  import { guideImageClass } from '../../storybook/GuideImage';
5
5
  import SearchInput from './SearchInput';
6
+ import type { SearchInputOption, SearchInputEvent, SearchInputValue } from './SearchInput';
6
7
  import Grid from '../../components/Grid/Grid';
7
8
  import Col from '../../components/Grid/Col';
8
9
  import Button from '../../components/Button/Button';
@@ -101,10 +102,10 @@ Note:
101
102
  export default searchInputStories;
102
103
 
103
104
  export const Overview = {
104
- render: (args) => {
105
- const [value, setValue] = useState(null);
105
+ render: (args: any) => {
106
+ const [value, setValue] = useState<SearchInputValue>({ text: '' });
106
107
 
107
- const handleSearchInput = (event) => {
108
+ const handleSearchInput = (event: SearchInputEvent) => {
108
109
  setValue(event.value);
109
110
  };
110
111
 
@@ -115,12 +116,12 @@ export const Overview = {
115
116
  {...args}
116
117
  value={value}
117
118
  onChange={handleSearchInput}
118
- options={searchItems(value?.text)}
119
+ options={searchItems(value.text)}
119
120
  />
120
121
  <p>
121
122
  Selected data:{' '}
122
- {value?.selected
123
- ? `{name: "${value?.selected?.data?.name}", brand: "${value.selected?.data?.brand}"}`
123
+ {value.selected
124
+ ? `{name: "${value.selected.data?.name}", brand: "${value.selected.data?.brand}"}`
124
125
  : '[No data]'}
125
126
  </p>
126
127
  </Col>
@@ -131,9 +132,9 @@ export const Overview = {
131
132
 
132
133
  export const ValueBinding = {
133
134
  render: () => {
134
- const [value, setValue] = useState({ text: '', selected: null });
135
+ const [value, setValue] = useState<SearchInputValue>({ text: '' });
135
136
 
136
- const handleSearchInput = (event) => {
137
+ const handleSearchInput = (event: SearchInputEvent) => {
137
138
  setValue(event.value);
138
139
  };
139
140
 
@@ -146,11 +147,11 @@ export const ValueBinding = {
146
147
  value={value}
147
148
  onInput={handleSearchInput}
148
149
  onSelect={handleSearchInput}
149
- options={searchItems(value?.text)}
150
+ options={searchItems(value.text)}
150
151
  />
151
152
  <p>
152
153
  Selected data:{' '}
153
- {value.selected
154
+ {value?.selected
154
155
  ? `{name: "${value.selected?.data?.name}", brand: "${value.selected?.data?.brand}"}`
155
156
  : '[No data]'}
156
157
  </p>
@@ -171,14 +172,14 @@ export const ValueBinding = {
171
172
 
172
173
  export const MenuMaxHeight = {
173
174
  render: () => {
174
- const [value1, setValue1] = useState({ text: '', selected: null });
175
- const [value2, setValue2] = useState({ text: '', selected: null });
175
+ const [value1, setValue1] = useState({ text: '' });
176
+ const [value2, setValue2] = useState({ text: '' });
176
177
 
177
- const handleSearchInput1 = (event) => {
178
+ const handleSearchInput1 = (event: SearchInputEvent) => {
178
179
  setValue1(event.value);
179
180
  };
180
181
 
181
- const handleSearchInput2 = (event) => {
182
+ const handleSearchInput2 = (event: SearchInputEvent) => {
182
183
  setValue2(event.value);
183
184
  };
184
185
 
@@ -191,7 +192,7 @@ export const MenuMaxHeight = {
191
192
  label="Search used phones on Chợ Tốt"
192
193
  value={value1}
193
194
  onInput={handleSearchInput1}
194
- options={searchItems(value1?.text)}
195
+ options={searchItems(value1.text)}
195
196
  />
196
197
  <p>menuMaxHeight=&quot;$md&quot;</p>
197
198
  <SearchInput
@@ -199,7 +200,7 @@ export const MenuMaxHeight = {
199
200
  label="Search used phones on Chợ Tốt"
200
201
  value={value2}
201
202
  onInput={handleSearchInput2}
202
- options={searchItems(value2?.text)}
203
+ options={searchItems(value2.text)}
203
204
  />
204
205
  </Col>
205
206
  </Grid>
@@ -219,9 +220,9 @@ export const MenuMaxHeight = {
219
220
 
220
221
  export const AllowClear = {
221
222
  render: () => {
222
- const [value, setValue] = useState({ text: '', selected: null });
223
+ const [value, setValue] = useState({ text: '' });
223
224
 
224
- const handleSearchInput = (event) => {
225
+ const handleSearchInput = (event: SearchInputEvent) => {
225
226
  setValue(event.value);
226
227
  };
227
228
 
@@ -233,7 +234,7 @@ export const AllowClear = {
233
234
  label="Search used phones on Chợ Tốt"
234
235
  value={value}
235
236
  onChange={handleSearchInput}
236
- options={searchItems(value?.text)}
237
+ options={searchItems(value.text)}
237
238
  />
238
239
  </Col>
239
240
  </Grid>
@@ -253,9 +254,9 @@ export const AllowClear = {
253
254
 
254
255
  export const Required = {
255
256
  render: () => {
256
- const [value, setValue] = useState({ text: '', selected: null });
257
+ const [value, setValue] = useState({ text: '' });
257
258
 
258
- const handleSearchInput = (event) => {
259
+ const handleSearchInput = (event: SearchInputEvent) => {
259
260
  setValue(event.value);
260
261
  };
261
262
 
@@ -267,7 +268,7 @@ export const Required = {
267
268
  label="Search used phones on Chợ Tốt"
268
269
  value={value}
269
270
  onChange={handleSearchInput}
270
- options={searchItems(value?.text)}
271
+ options={searchItems(value.text)}
271
272
  />
272
273
  </Col>
273
274
  </Grid>
@@ -288,10 +289,10 @@ export const Required = {
288
289
 
289
290
  export const ErrorStatus = {
290
291
  render: () => {
291
- const [value, setValue] = useState({ text: '', selected: null });
292
- const status = value?.text.trim() === '' ? 'error' : 'default';
292
+ const [value, setValue] = useState({ text: '' });
293
+ const status = value.text.trim() === '' ? 'error' : 'default';
293
294
 
294
- const handleSearchInput = (event) => {
295
+ const handleSearchInput = (event: SearchInputEvent) => {
295
296
  setValue(event.value);
296
297
  };
297
298
 
@@ -303,7 +304,7 @@ export const ErrorStatus = {
303
304
  label="Search used phones on Chợ Tốt"
304
305
  value={value}
305
306
  onChange={handleSearchInput}
306
- options={searchItems(value?.text)}
307
+ options={searchItems(value.text)}
307
308
  />
308
309
  </Col>
309
310
  </Grid>
@@ -322,9 +323,9 @@ export const ErrorStatus = {
322
323
 
323
324
  export const DropdownVariant = {
324
325
  render: () => {
325
- const [value, setValue] = useState({ text: '', selected: null });
326
+ const [value, setValue] = useState<SearchInputValue>({ text: '' });
326
327
 
327
- const handleSearchInput = (event) => {
328
+ const handleSearchInput = (event: SearchInputEvent) => {
328
329
  setValue(event.value);
329
330
  };
330
331
 
@@ -337,10 +338,10 @@ export const DropdownVariant = {
337
338
  label="Search used phones on Chợ Tốt"
338
339
  value={value}
339
340
  onChange={handleSearchInput}
340
- options={dropdownItems(value?.text)}
341
+ options={dropdownItems(value.text)}
341
342
  />
342
343
  </Col>
343
- <Col>Selected value: {!!value?.selected && value?.text}</Col>
344
+ <Col>Selected value: {!!value.selected && value.text}</Col>
344
345
  </Grid>
345
346
  );
346
347
  },
@@ -362,18 +363,18 @@ const lessItems = [
362
363
 
363
364
  export const Events = {
364
365
  render: () => {
365
- const [value, setValue] = useState({ text: '', selected: null });
366
+ const [value, setValue] = useState<SearchInputValue>({ text: '' });
366
367
  const [typeValue, setTypeValue] = useState('');
367
368
  const [countChange, setCountChange] = useState(0);
368
369
  const [countInput, setCountInput] = useState(0);
369
370
  const [countSelect, setCountSelect] = useState(0);
370
371
 
371
- const handleSearchInput = (event) => {
372
+ const handleSearchInput = (event: SearchInputEvent) => {
372
373
  setCountChange(countChange + 1);
373
374
  setValue(event.value);
374
375
  };
375
376
 
376
- const handleType = (event) => {
377
+ const handleType = (event: SearchInputEvent) => {
377
378
  setCountInput(countInput + 1);
378
379
  setTypeValue(event.target.value);
379
380
  };
@@ -383,7 +384,7 @@ export const Events = {
383
384
  };
384
385
 
385
386
  const handleReset = () => {
386
- setValue({ text: '', selected: null });
387
+ setValue({ text: '' });
387
388
  setTypeValue('');
388
389
  setCountChange(0);
389
390
  setCountInput(0);
@@ -399,7 +400,7 @@ export const Events = {
399
400
  label="Search used phones on Chợ Tốt"
400
401
  value={value}
401
402
  onChange={handleSearchInput}
402
- options={searchItems(value?.text, lessItems)}
403
+ options={searchItems(value.text, lessItems)}
403
404
  onInput={handleType}
404
405
  onSelect={handleSelect}
405
406
  />
@@ -415,9 +416,9 @@ export const Events = {
415
416
  onSelect has been called: <strong>{countSelect}</strong> time(s)
416
417
  </p>
417
418
  <br />
418
- <p>Current text in input: {value?.text}</p>
419
+ <p>Current text in input: {value.text}</p>
419
420
  <p>Text typed from keyboard: {typeValue}</p>
420
- <p>Text selected from option menu: {value?.selected?.text}</p>
421
+ <p>Text selected from option menu: {value.selected?.text}</p>
421
422
  <Button onClick={handleReset}>Reset</Button>
422
423
  </Col>
423
424
  </Grid>
@@ -438,11 +439,11 @@ export const Events = {
438
439
 
439
440
  export const AsyncSearching = {
440
441
  render: () => {
441
- const [value, setValue] = useState({ text: '', selected: null });
442
- const [options, setOptions] = useState([]);
442
+ const [value, setValue] = useState<SearchInputValue>({ text: '' });
443
+ const [options, setOptions] = useState<SearchInputOption[]>([]);
443
444
 
444
- const simulateFetchingData = (query) =>
445
- new Promise((resolve) => {
445
+ const simulateFetchingData = (query: string) =>
446
+ new Promise<SearchInputOption[]>((resolve) => {
446
447
  setTimeout(() => {
447
448
  resolve(searchItems(query));
448
449
  }, 500);
@@ -461,8 +462,8 @@ export const AsyncSearching = {
461
462
  );
462
463
 
463
464
  // move fetch API logic to onInput so that it's not called when value is selected from option menu
464
- const handleType = (event) => {
465
- handleFetch(event.value.text);
465
+ const handleType = (event: SearchInputEvent) => {
466
+ handleFetch(event.value.text)?.catch(console.error);
466
467
  };
467
468
 
468
469
  const handleSearchInput = (event) => {
@@ -530,8 +531,8 @@ const items = [
530
531
  ];
531
532
 
532
533
  // demo and simulate data transformation for the SearchInput component
533
- function searchItems(qs = '', optionData = null) {
534
- const data = optionData ? [...optionData] : [...items];
534
+ function searchItems(qs = '', optionData = items) {
535
+ const data = [...optionData]; // copy the array to avoid mutation
535
536
  // to simplify stuff, convert all strings to lower case
536
537
  qs = qs.trim().toLowerCase();
537
538
  if (qs.trim()) {
@@ -586,3 +587,35 @@ function dropdownItems(qs = '', optionData = null) {
586
587
  };
587
588
  });
588
589
  }
590
+
591
+ export const WithSearchIcon = {
592
+ render: () => {
593
+ const [value, setValue] = useState({ text: '' });
594
+
595
+ const handleSearchInput = (event: SearchInputEvent) => {
596
+ setValue(event.value);
597
+ };
598
+
599
+ return (
600
+ <Grid rowCols={[1, 1, 2]}>
601
+ <Col>
602
+ <SearchInput
603
+ allowClear
604
+ showSearchIcon
605
+ label="Search used phones on Chợ Tốt"
606
+ value={value}
607
+ onChange={handleSearchInput}
608
+ options={searchItems(value.text)}
609
+ />
610
+ </Col>
611
+ </Grid>
612
+ );
613
+ },
614
+ parameters: {
615
+ docs: {
616
+ description: {
617
+ story: '`showSearchIcon` enable a search icon on the lefticon',
618
+ },
619
+ },
620
+ },
621
+ };
@@ -1,5 +1,6 @@
1
- export const menuClass: import("@linaria/core").LinariaClassName;
2
- export const optionClass: import("@linaria/core").LinariaClassName;
3
- export const invertedArrowClass: import("@linaria/core").LinariaClassName;
4
- export const searchInputWrapperClass: import("@linaria/core").LinariaClassName;
5
- export const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
1
+ declare const menuClass: import("@linaria/core").LinariaClassName;
2
+ declare const optionClass: import("@linaria/core").LinariaClassName;
3
+ declare const invertedArrowClass: import("@linaria/core").LinariaClassName;
4
+ declare const searchInputWrapperClass: import("@linaria/core").LinariaClassName;
5
+ declare const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
6
+ export { menuClass, optionClass, invertedArrowClass, searchInputWrapperClass, searchDropdownIconClass, };
@@ -1,11 +1,11 @@
1
1
  import { css } from '@linaria/core';
2
2
  import theme from '@clad-ui/theme';
3
3
 
4
- const { colors, zIndices, sizes, space, radii, shadows, fontSizes } = theme;
4
+ const { colors, zIndices, sizes, space, radii, fontSizes } = theme;
5
5
 
6
6
  const menuClass = css`
7
7
  border-radius: ${radii.sm};
8
- box-shadow: ${shadows.sm};
8
+ box-shadow: 0 4px 8px 0 #59595926;
9
9
  list-style: none;
10
10
  margin: 0;
11
11
  overflow-y: auto;
@@ -13,6 +13,8 @@ const menuClass = css`
13
13
  position: fixed;
14
14
  z-index: calc(${zIndices.modal} + ${zIndices.up});
15
15
  font-size: ${fontSizes.sm};
16
+ scrollbar-color: ${colors.gray200} ${colors.gray200};
17
+ scrollbar-width: thin;
16
18
 
17
19
  /* Only show background shadow scroll on non-webkit browsers */
18
20
  @supports not (background: -webkit-named-image(i)) {
@@ -37,7 +39,7 @@ const optionClass = css`
37
39
  padding: ${space.xs} 0 ${space.xs} ${space.sm};
38
40
 
39
41
  &.highlight {
40
- background-color: ${colors.backgroundTertiary};
42
+ background-color: ${colors.backgroundSecondary};
41
43
  }
42
44
 
43
45
  & > mark {
@@ -58,6 +60,7 @@ const invertedArrowClass = css`
58
60
  `;
59
61
  const searchInputWrapperClass = css`
60
62
  position: relative;
63
+
61
64
  & > div button {
62
65
  padding-right: ${space.xl};
63
66
 
@@ -71,7 +74,7 @@ const searchDropdownIconClass = css`
71
74
  background: transparent;
72
75
  outline: none;
73
76
  border: none;
74
- height: ${sizes.xl};
77
+ height: 40px;
75
78
  min-width: ${sizes.xxs};
76
79
  position: absolute;
77
80
  top: ${space.xxxs};