@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,125 @@
1
+ import React from 'react';
2
+ declare const searchInputStories: {
3
+ title: string;
4
+ component: React.FC<import("./MultiSearchDropdown").MultiSearchDropdownProps>;
5
+ tags: string[];
6
+ parameters: {
7
+ docs: {
8
+ description: {
9
+ component: string;
10
+ };
11
+ };
12
+ };
13
+ argTypes: {
14
+ menuMaxHeight: {
15
+ options: string[];
16
+ control: {
17
+ type: string;
18
+ };
19
+ };
20
+ width: {
21
+ options: string[];
22
+ control: {
23
+ type: string;
24
+ };
25
+ };
26
+ disabled: {};
27
+ id: {};
28
+ name: {};
29
+ options: {
30
+ control: null;
31
+ };
32
+ onChange: {
33
+ control: null;
34
+ };
35
+ onBlur: {
36
+ control: null;
37
+ };
38
+ onFocus: {
39
+ control: null;
40
+ };
41
+ onSelect: {
42
+ control: null;
43
+ };
44
+ inputRef: {
45
+ control: null;
46
+ };
47
+ };
48
+ args: {
49
+ label: string;
50
+ options: {
51
+ data: {
52
+ job: string;
53
+ };
54
+ html: string;
55
+ text: string;
56
+ }[];
57
+ control: {
58
+ type: string;
59
+ };
60
+ };
61
+ };
62
+ export default searchInputStories;
63
+ export declare const Overview: {
64
+ render: (args: any) => JSX.Element;
65
+ };
66
+ export declare const GetSelectedItem: {
67
+ render: () => JSX.Element;
68
+ parameters: {
69
+ docs: {
70
+ description: {
71
+ story: string;
72
+ };
73
+ };
74
+ };
75
+ };
76
+ export declare const SetDefaultValue: {
77
+ render: () => JSX.Element;
78
+ parameters: {
79
+ docs: {
80
+ description: {
81
+ story: string;
82
+ };
83
+ };
84
+ };
85
+ };
86
+ export declare const Disabled: {
87
+ render: () => JSX.Element;
88
+ parameters: {
89
+ docs: {
90
+ description: {
91
+ story: string;
92
+ };
93
+ };
94
+ };
95
+ };
96
+ export declare const Required: {
97
+ render: () => JSX.Element;
98
+ parameters: {
99
+ docs: {
100
+ description: {
101
+ story: string;
102
+ };
103
+ };
104
+ };
105
+ };
106
+ export declare const ErrorStatus: {
107
+ render: () => JSX.Element;
108
+ parameters: {
109
+ docs: {
110
+ description: {
111
+ story: string;
112
+ };
113
+ };
114
+ };
115
+ };
116
+ export declare const WithHelptext: {
117
+ render: () => JSX.Element;
118
+ parameters: {
119
+ docs: {
120
+ description: {
121
+ story: string;
122
+ };
123
+ };
124
+ };
125
+ };
@@ -1,10 +1,8 @@
1
- /* eslint-disable no-unused-vars */
2
- import React, { useState } from 'react';
1
+ import React, { useRef, useState } from 'react';
3
2
  import theme from '@clad-ui/theme';
4
- import { guideImageClass } from '../../storybook/GuideImage';
5
3
  import Grid from '../../components/Grid/Grid';
6
4
  import Col from '../../components/Grid/Col';
7
- import MultiSearchDropdown from './MultiSearchDropdown';
5
+ import MultiSearchDropdown, { type MultiSearchDropdownOption } from './MultiSearchDropdown';
8
6
 
9
7
  const { sizes } = theme;
10
8
  const OPTIONS = [
@@ -132,16 +130,18 @@ export default searchInputStories;
132
130
 
133
131
  export const Overview = {
134
132
  render: (args) => {
135
- const [value, setValue] = useState([]);
133
+ const inputRef = useRef<HTMLInputElement>();
134
+ const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
136
135
 
137
- const onSelect = (v, e) => {
136
+ const onSelect = (v) => {
138
137
  const temp = [...value, v];
139
138
  setValue(temp);
139
+ console.log(inputRef.current ? inputRef.current.value : 'No input ref');
140
140
  };
141
- const onClear = (e) => {
141
+ const onClear = () => {
142
142
  setValue([]);
143
143
  };
144
- const onRemoveOption = (deleted, e) => {
144
+ const onRemoveOption = (deleted: MultiSearchDropdownOption) => {
145
145
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
146
146
  setValue(afterDeleteValues);
147
147
  };
@@ -151,6 +151,7 @@ export const Overview = {
151
151
  <Col>
152
152
  <MultiSearchDropdown
153
153
  {...args}
154
+ inputRef={inputRef}
154
155
  onSelect={onSelect}
155
156
  value={value}
156
157
  onClearData={onClear}
@@ -164,15 +165,15 @@ export const Overview = {
164
165
 
165
166
  export const GetSelectedItem = {
166
167
  render: () => {
167
- const [value, setValue] = useState([]);
168
- const onSelect = (v, e) => {
168
+ const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
169
+ const onSelect = (v) => {
169
170
  const temp = [...value, v];
170
171
  setValue(temp);
171
172
  };
172
- const onClear = (e) => {
173
+ const onClear = () => {
173
174
  setValue([]);
174
175
  };
175
- const onRemoveOption = (deleted, e) => {
176
+ const onRemoveOption = (deleted) => {
176
177
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
177
178
  setValue(afterDeleteValues);
178
179
  };
@@ -213,15 +214,15 @@ export const SetDefaultValue = {
213
214
  { data: { job: 'job A' }, html: 'Lao động phổ thông', text: 'Lao động phổ thông' },
214
215
  { data: { job: 'job B' }, html: 'Tạp vụ', text: 'Tạp vụ' },
215
216
  ]);
216
- const onSelect = (v, e) => {
217
+ const onSelect = (v) => {
217
218
  const temp = [...value, v];
218
219
  setValue(temp);
219
220
  };
220
221
 
221
- const onClear = (e) => {
222
+ const onClear = () => {
222
223
  setValue([]);
223
224
  };
224
- const onRemoveOption = (deleted, e) => {
225
+ const onRemoveOption = (deleted) => {
225
226
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
226
227
  setValue(afterDeleteValues);
227
228
  };
@@ -263,15 +264,15 @@ export const Disabled = {
263
264
  { data: { job: 'job A' }, html: 'Lao động phổ thông', text: 'Lao động phổ thông' },
264
265
  { data: { job: 'job B' }, html: 'Tạp vụ', text: 'Tạp vụ' },
265
266
  ]);
266
- const onSelect = (v, e) => {
267
+ const onSelect = (v) => {
267
268
  const temp = [...value, v];
268
269
  setValue(temp);
269
270
  };
270
271
 
271
- const onClear = (e) => {
272
+ const onClear = () => {
272
273
  setValue([]);
273
274
  };
274
- const onRemoveOption = (deleted, e) => {
275
+ const onRemoveOption = (deleted) => {
275
276
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
276
277
  setValue(afterDeleteValues);
277
278
  };
@@ -315,15 +316,15 @@ export const Disabled = {
315
316
 
316
317
  export const Required = {
317
318
  render: () => {
318
- const [value, setValue] = useState([]);
319
- const onSelect = (v, e) => {
319
+ const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
320
+ const onSelect = (v) => {
320
321
  const temp = [...value, v];
321
322
  setValue(temp);
322
323
  };
323
- const onClear = (e) => {
324
+ const onClear = () => {
324
325
  setValue([]);
325
326
  };
326
- const onRemoveOption = (deleted, e) => {
327
+ const onRemoveOption = (deleted) => {
327
328
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
328
329
  setValue(afterDeleteValues);
329
330
  };
@@ -362,15 +363,15 @@ export const Required = {
362
363
 
363
364
  export const ErrorStatus = {
364
365
  render: () => {
365
- const [value, setValue] = useState([]);
366
- const onSelect = (v, e) => {
366
+ const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
367
+ const onSelect = (v) => {
367
368
  const temp = [...value, v];
368
369
  setValue(temp);
369
370
  };
370
- const onClear = (e) => {
371
+ const onClear = () => {
371
372
  setValue([]);
372
373
  };
373
- const onRemoveOption = (deleted, e) => {
374
+ const onRemoveOption = (deleted) => {
374
375
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
375
376
  setValue(afterDeleteValues);
376
377
  };
@@ -410,15 +411,15 @@ export const ErrorStatus = {
410
411
 
411
412
  export const WithHelptext = {
412
413
  render: () => {
413
- const [value, setValue] = useState([]);
414
- const onSelect = (v, e) => {
414
+ const [value, setValue] = useState<MultiSearchDropdownOption[]>([]);
415
+ const onSelect = (v) => {
415
416
  const temp = [...value, v];
416
417
  setValue(temp);
417
418
  };
418
- const onClear = (e) => {
419
+ const onClear = () => {
419
420
  setValue([]);
420
421
  };
421
- const onRemoveOption = (deleted, e) => {
422
+ const onRemoveOption = (deleted) => {
422
423
  const afterDeleteValues = value.filter((va) => va.data !== deleted.data);
423
424
  setValue(afterDeleteValues);
424
425
  };
@@ -1,23 +1,24 @@
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
- /**
5
- * @type {any}
6
- */
7
- export const MultiSearchDropdownWrapper: any;
8
- export const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
9
- export const MultiSearchDropdownLabelClass: import("@linaria/core").LinariaClassName;
10
- export const StyledSearchInput: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & Record<never, unknown> & {
11
- as?: import("react").ElementType<any> | undefined;
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 MultiSearchDropdownWrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
5
+ as?: import("react").ElementType;
12
6
  }>;
13
- export const ChipArrayWrapperClass: import("@linaria/core").LinariaClassName;
14
- export const ActionGroupWrapperClass: import("@linaria/core").LinariaClassName;
15
- export const ClearInputIconClass: import("@linaria/core").LinariaClassName;
16
- export const DisabledClass: import("@linaria/core").LinariaClassName;
17
- export const Paragraph: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & Record<never, unknown> & {
18
- as?: import("react").ElementType<any> | undefined;
7
+ declare const MultiSearchDropdownLabelClass: import("@linaria/core").LinariaClassName;
8
+ declare const searchDropdownIconClass: import("@linaria/core").LinariaClassName;
9
+ declare const ClearInputIconClass: import("@linaria/core").LinariaClassName;
10
+ declare const StyledSearchInput: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLInputElement> & import("react").InputHTMLAttributes<HTMLInputElement> & Record<never, unknown> & {
11
+ as?: import("react").ElementType;
19
12
  }>;
20
- /**
21
- * @type {React.FC<any>}
22
- */
23
- export const Wrapper: React.FC<any>;
13
+ declare const ChipArrayWrapperClass: import("@linaria/core").LinariaClassName;
14
+ declare const ActionGroupWrapperClass: import("@linaria/core").LinariaClassName;
15
+ declare const DisabledClass: import("@linaria/core").LinariaClassName;
16
+ declare const Paragraph: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLParagraphElement> & import("react").HTMLAttributes<HTMLParagraphElement> & Record<never, unknown> & {
17
+ as?: import("react").ElementType;
18
+ }>;
19
+ declare const Wrapper: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
20
+ width: string;
21
+ } & {
22
+ as?: import("react").ElementType;
23
+ }>;
24
+ export { menuClass, optionClass, invertedArrowClass, MultiSearchDropdownWrapper, searchDropdownIconClass, MultiSearchDropdownLabelClass, StyledSearchInput, ChipArrayWrapperClass, ActionGroupWrapperClass, ClearInputIconClass, DisabledClass, Paragraph, Wrapper, };
@@ -75,9 +75,6 @@ const invertedArrowClass = css`
75
75
  display: inline-table;
76
76
  `;
77
77
 
78
- /**
79
- * @type {any}
80
- */
81
78
  const MultiSearchDropdownWrapper = styled.div`
82
79
  position: relative;
83
80
  width: ${sizes.full};
@@ -236,10 +233,7 @@ const Paragraph = styled.p`
236
233
  text-align: left;
237
234
  `;
238
235
 
239
- /**
240
- * @type {React.FC<any>}
241
- */
242
- const Wrapper = styled.div`
236
+ const Wrapper = styled.div<{ width: string }>`
243
237
  width: ${({ width }) => sizes[width]};
244
238
  `;
245
239
 
@@ -1,7 +1,7 @@
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
5
  import { cx } from '../../utils';
6
6
  import normalizeArrowKey from '../../utils/_normalizeArrowKey';
7
7
 
@@ -9,7 +9,7 @@ import noop from '../../utils/noop';
9
9
  import ChevronDownFilled from '../../icons/ChevronDownFilled';
10
10
  import ShapeIcon from '../../components/ShapeIcon/ShapeIcon';
11
11
  import Chip from '../../components/Chip/Chip';
12
- import { Close } from '../../icons';
12
+ import Close from '../../icons/Close';
13
13
  import {
14
14
  menuClass,
15
15
  optionClass,
@@ -27,20 +27,17 @@ import {
27
27
  } from './MultiSearchDropdown.styles';
28
28
 
29
29
  const { sizes } = theme;
30
- const keysOfSizes = [...Object.keys(sizes)] as const;
31
30
 
32
- type Size = (typeof keysOfSizes)[number];
33
-
34
- type OptionPropType = {
31
+ export type MultiSearchDropdownOption = {
35
32
  /** to display at input */
36
33
  text: string;
37
34
  /** to display in dropdown items */
38
35
  html: string;
39
36
  /** arbitrary data object */
40
- data: Record<string, any>;
37
+ data: unknown;
41
38
  };
42
39
 
43
- export type MultiSearchDropdownProps = {
40
+ export interface MultiSearchDropdownProps {
44
41
  /**
45
42
  * The id attribute of this component
46
43
  */
@@ -48,27 +45,27 @@ export type MultiSearchDropdownProps = {
48
45
  /**
49
46
  * Value data of this component.
50
47
  */
51
- value?: OptionPropType[];
48
+ value?: MultiSearchDropdownOption[];
52
49
  /**
53
50
  * Options array to provide for the dropdown menu, manually control option when delete/ add
54
51
  */
55
- options?: OptionPropType[];
52
+ options?: MultiSearchDropdownOption[];
56
53
  /**
57
54
  * Callback when user either add or remove option
58
55
  */
59
- onChange?: any;
56
+ onChange?: (value: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
60
57
  /**
61
58
  * Callback when user types in the search text field
62
59
  */
63
- onInput?: any;
60
+ onInput?: (e: React.ChangeEvent<HTMLInputElement>) => void;
64
61
  /**
65
62
  * Callback when user select option
66
63
  */
67
- onSelect?: any;
64
+ onSelect?: (value: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
68
65
  /**
69
66
  * Callback when remove option
70
67
  */
71
- onRemoveOption?: any;
68
+ onRemoveOption?: (deletedValue: MultiSearchDropdownOption, e: React.SyntheticEvent) => void;
72
69
  /**
73
70
  * Input name
74
71
  */
@@ -84,19 +81,19 @@ export type MultiSearchDropdownProps = {
84
81
  /**
85
82
  * Input width
86
83
  */
87
- width?: Size;
84
+ width?: Sizes;
88
85
  /**
89
86
  * Callback when input is blur
90
87
  */
91
- onBlur?: (e: React.SyntheticEvent) => void;
88
+ onBlur?: (e: React.FocusEvent<HTMLInputElement>) => void;
92
89
  /**
93
90
  * Callback when input is focus
94
91
  */
95
- onFocus?: () => void;
92
+ onFocus?: (e: React.FocusEvent<HTMLInputElement>) => void;
96
93
  /**
97
94
  * If allow to remove input content with clear icon
98
95
  */
99
- onClearData?: (e: React.SyntheticEvent) => void;
96
+ onClearData?: (e: React.MouseEvent<HTMLElement>) => void;
100
97
  /**
101
98
  * Empty string on no options
102
99
  */
@@ -104,7 +101,7 @@ export type MultiSearchDropdownProps = {
104
101
  /**
105
102
  * Input menu max-height
106
103
  */
107
- menuMaxHeight?: Size;
104
+ menuMaxHeight?: Sizes;
108
105
  /**
109
106
  * Disable the input
110
107
  */
@@ -117,6 +114,10 @@ export type MultiSearchDropdownProps = {
117
114
  * Promp a helptext below input group (useful when implemented with form validation)
118
115
  */
119
116
  helptext?: string;
117
+ /**
118
+ * Custom helptext
119
+ */
120
+ helptextClassName?: string;
120
121
  /**
121
122
  * Input status (useful when implemented with form validation)
122
123
  */
@@ -125,7 +126,7 @@ export type MultiSearchDropdownProps = {
125
126
  * Component classname
126
127
  */
127
128
  className?: string;
128
- };
129
+ }
129
130
 
130
131
  /**
131
132
  * Search Input component that carefully takes care of accessibility
@@ -134,7 +135,6 @@ and allow keyboard controls.
134
135
  * `✅ Stable`
135
136
  *
136
137
  */
137
-
138
138
  const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
139
139
  id,
140
140
  label = '',
@@ -153,13 +153,13 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
153
153
  disabled = false,
154
154
  required = false,
155
155
  helptext = '',
156
+ helptextClassName = '',
156
157
  status = 'default',
157
158
  className = '',
158
159
  ...props
159
160
  }) => {
160
161
  const { useState, useRef, useEffect } = React;
161
- const defaultInputRef = useRef();
162
- const textFieldRef = inputRef ?? defaultInputRef;
162
+ const dropdownWrapperRef = useRef<HTMLDivElement>(null);
163
163
  const [menuOpen, setMenuOpen] = useState(false);
164
164
  const [values, setValues] = useState(value);
165
165
  // const [inputWidth, setInputWidth] = useState(0);
@@ -173,7 +173,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
173
173
  const [textInput, setTextInput] = useState('');
174
174
  // only show the menu, when we have actual items to show
175
175
  const showMenu = menuOpen;
176
- const searchTextRef = useRef<HTMLInputElement>(null);
176
+ const searchTextRef = inputRef ?? useRef<HTMLInputElement>(null);
177
177
 
178
178
  useEffect(() => {
179
179
  // Remove option in values array
@@ -215,7 +215,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
215
215
  },
216
216
  });
217
217
 
218
- setTriggerRef(textFieldRef.current);
218
+ setTriggerRef(dropdownWrapperRef.current);
219
219
 
220
220
  const onWrapperClick = (e) => {
221
221
  if (!menuOpen) {
@@ -228,7 +228,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
228
228
  return e;
229
229
  };
230
230
 
231
- const handleOnBlur = (e) => {
231
+ const handleOnBlur = (e: React.FocusEvent<HTMLInputElement>) => {
232
232
  setTextInput('');
233
233
  setFocus(false);
234
234
  setFilteredOptions(modifiedOptions);
@@ -426,10 +426,10 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
426
426
  )}
427
427
  role="tab"
428
428
  tabIndex={0}
429
- onClick={disabled ? null : onWrapperClick}
430
- onKeyUp={disabled ? null : handleKeyUp}
431
- onKeyDown={disabled ? null : handleKeyDown}
432
- ref={defaultInputRef}
429
+ onClick={disabled ? undefined : onWrapperClick}
430
+ onKeyUp={disabled ? undefined : handleKeyUp}
431
+ onKeyDown={disabled ? undefined : handleKeyDown}
432
+ ref={dropdownWrapperRef}
433
433
  {...props}
434
434
  >
435
435
  <p className={cx(MultiSearchDropdownLabelClass, (focus || value.length > 0) && 'focus')}>
@@ -486,7 +486,7 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
486
486
  role="tab"
487
487
  tabIndex={0}
488
488
  >
489
- <ShapeIcon bg="transparent" color="neutralDark" radius="circle" size="md">
489
+ <ShapeIcon bg="none" color="text" radius="circle" size="md">
490
490
  <ChevronDownFilled className="arrow" />
491
491
  </ShapeIcon>
492
492
  </span>
@@ -495,10 +495,11 @@ const MultiSearchDropdown: React.FC<MultiSearchDropdownProps> = ({
495
495
  value={value.length ? value.length : ''}
496
496
  required={required}
497
497
  onBlur={handleOnBlur}
498
+ readOnly
498
499
  hidden
499
500
  />
500
501
  </MultiSearchDropdownWrapper>
501
- <Paragraph>{helptext}</Paragraph>
502
+ <Paragraph className={helptextClassName}>{helptext}</Paragraph>
502
503
  </Wrapper>
503
504
  );
504
505
  };
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
- export type PopupProps = {
2
+ import { type ButtonColor } from '../../components/Button/Button';
3
+ export interface PopupProps {
3
4
  /**
4
5
  * Dialog className (can be used to add more styles to mainIcon by targeting `main-icon` class in case of using a custom string)
5
6
  */
@@ -51,28 +52,28 @@ export type PopupProps = {
51
52
  /**
52
53
  * Callback when close icon is clicked. Normally, it is used to update `open` prop to close the dialog.
53
54
  */
54
- onClose?: () => void;
55
+ onClose?: React.MouseEventHandler<HTMLElement>;
55
56
  /**
56
57
  * Callback when dialog main button is clicked
57
58
  */
58
- onPrimaryButtonClick?: () => void;
59
+ onPrimaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
59
60
  /**
60
61
  * Callback when dialog secondary button is clicked
61
62
  */
62
- onSecondaryButtonClick?: () => void;
63
+ onSecondaryButtonClick?: React.MouseEventHandler<HTMLButtonElement>;
63
64
  /**
64
65
  * Primary Button Color
65
66
  */
66
- primaryColor?: 'accent' | 'caution' | 'chotot' | 'critical' | 'error' | 'info' | 'neutral' | 'positive' | 'primary' | 'success' | 'tertiary';
67
+ primaryColor?: ButtonColor;
67
68
  /**
68
69
  * Secondary Button Color
69
70
  */
70
- secondaryColor?: 'accent' | 'caution' | 'chotot' | 'critical' | 'error' | 'info' | 'neutral' | 'positive' | 'primary' | 'success' | 'tertiary';
71
+ secondaryColor?: ButtonColor;
71
72
  /**
72
73
  * To apply `overflow-y: visible` for the `ChildrenWrapper` in some specific case that have to use some `custom Dropdown relatives` inside Popup
73
74
  */
74
75
  childrenOverflowVisible?: boolean;
75
- };
76
+ }
76
77
  /**
77
78
  * Popup is a window sitting overtop of the main content to provide information or inquire confirmation.
78
79
  * Popup is very intrusive toward user and should be used sparingly.