@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,10 @@
1
+ declare const Menu: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLUListElement> & import("react").HTMLAttributes<HTMLUListElement> & Record<never, unknown> & {
2
+ as?: import("react").ElementType;
3
+ }>;
4
+ declare const Item: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLLIElement> & import("react").LiHTMLAttributes<HTMLLIElement> & Record<never, unknown> & {
5
+ as?: import("react").ElementType;
6
+ }>;
7
+ declare const LeftIcon: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & Record<never, unknown> & {
8
+ as?: import("react").ElementType;
9
+ }>;
10
+ export { Menu, Item, LeftIcon };
@@ -0,0 +1,42 @@
1
+ import { styled } from '@linaria/react';
2
+ import theme from '@clad-ui/theme';
3
+
4
+ const { colors, space, radii, borders, zIndices } = theme;
5
+
6
+ const Menu = styled.ul`
7
+ background: white;
8
+ border: ${borders.sm};
9
+ border-radius: ${radii.md};
10
+ box-shadow: 0 4px 8px 0 #59595926;
11
+ padding: ${space.xxs} ${space.none};
12
+ list-style: none;
13
+ overflow: hidden;
14
+ overflow-y: auto;
15
+ scrollbar-color: ${colors.gray200} ${colors.gray200};
16
+ scrollbar-width: thin;
17
+ z-index: ${zIndices.dropdown};
18
+ `;
19
+
20
+ const Item = styled.li`
21
+ display: flex;
22
+ align-items: center;
23
+ gap: ${space.xs};
24
+ color: ${colors.textPrimary};
25
+ cursor: pointer;
26
+ padding: ${space.xs} ${space.md};
27
+
28
+ &:hover,
29
+ &.selected {
30
+ background-color: ${colors.backgroundSecondary};
31
+ }
32
+ `;
33
+
34
+ const LeftIcon = styled.div`
35
+ display: flex;
36
+ position: absolute;
37
+ height: 100%;
38
+ align-items: center;
39
+ left: 0;
40
+ `;
41
+
42
+ export { Menu, Item, LeftIcon };
@@ -1,12 +1,14 @@
1
- import theme from '@clad-ui/theme';
1
+ import theme, { type Sizes } from '@clad-ui/theme';
2
2
  import * as React from 'react';
3
+ import { useLayer } from 'react-laag';
3
4
  import { cx } from '../../utils';
4
5
  import noop from '../../utils/noop';
5
6
  import ChevronDownFilled from '../../icons/ChevronDownFilled';
6
7
 
7
- import inputClasses, { Container, InputWrapper, Paragraph } from '../Input/Input.styles.js';
8
+ import inputClasses, { Container, InputWrapper, Paragraph } from '../Input/Input.styles';
9
+ import { Menu, Item, LeftIcon } from './Dropdown.styles';
8
10
 
9
- const { sizes } = theme;
11
+ const { sizes, colors } = theme;
10
12
  const keysOfSizes = [...Object.keys(sizes)] as const;
11
13
 
12
14
  type Size = (typeof keysOfSizes)[number];
@@ -14,9 +16,10 @@ type Size = (typeof keysOfSizes)[number];
14
16
  type DropdownOption = {
15
17
  value: string;
16
18
  label: string;
19
+ icon?: React.ReactElement;
17
20
  };
18
21
 
19
- export type DropdownProps = {
22
+ export interface DropdownProps {
20
23
  /**
21
24
  * Custom class to override dropdown's style.
22
25
  */
@@ -40,19 +43,19 @@ export type DropdownProps = {
40
43
  /**
41
44
  * Callback when user click / tap on the input
42
45
  */
43
- onClick?: (event: React.MouseEvent<HTMLSelectElement>) => void;
46
+ onClick?: React.MouseEventHandler<HTMLSelectElement>;
44
47
  /**
45
48
  * Callback when user input
46
49
  */
47
- onChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;
50
+ onChange?: React.ChangeEventHandler<HTMLSelectElement>;
48
51
  /**
49
52
  * Callback when user blur
50
53
  */
51
- onBlur?: (event: React.FocusEvent<HTMLSelectElement>) => void;
54
+ onBlur?: React.FocusEventHandler<HTMLSelectElement>;
52
55
  /**
53
56
  * Callback when user focus
54
57
  */
55
- onFocus?: (event: React.FocusEvent<HTMLSelectElement>) => void;
58
+ onFocus?: React.FocusEventHandler<HTMLSelectElement>;
56
59
  /**
57
60
  * Disabled dropdown
58
61
  */
@@ -74,21 +77,33 @@ export type DropdownProps = {
74
77
  */
75
78
  helptext?: string;
76
79
  /**
77
- * Dropdown options. Options is an array and each array item is an object with shape of `{value: string, label: string}`.
80
+ * Custom helptext
81
+ */
82
+ helptextClassName?: string;
83
+ /**
84
+ * Dropdown options. Options is an array and each array item is an object with shape of `{value: string, label: string, icon?: ReactElement}`.
78
85
  */
79
86
  options?: DropdownOption[];
80
87
  /**
81
88
  * Dropdown width
82
89
  */
83
90
  width?: Size;
84
- };
91
+ menuMaxHeight?: Sizes;
92
+ /**
93
+ * Icon to be displayed on the left side of the dropdown
94
+ */
95
+ icon?: React.ReactElement;
96
+ /**
97
+ * Padding for icon (default is 20px). This is available when icon is provided.
98
+ */
99
+ paddingForIcon?: number;
100
+ }
85
101
 
86
102
  /**
87
103
  * Dropdown component that wraps around HTML Select element
88
104
  *
89
105
  * `✅ Stable`
90
106
  */
91
-
92
107
  const Dropdown: React.FC<DropdownProps> = ({
93
108
  className = '',
94
109
  id = '',
@@ -103,12 +118,37 @@ const Dropdown: React.FC<DropdownProps> = ({
103
118
  required = false,
104
119
  status = 'default',
105
120
  helptext = '',
121
+ helptextClassName = '',
106
122
  inputRef = null,
107
123
  options = [],
108
124
  width = 'full',
125
+ menuMaxHeight = '$sm',
126
+ icon,
127
+ paddingForIcon = 28,
109
128
  }) => {
110
- const defaultDropdownRef = React.useRef();
111
- const ref = inputRef ?? defaultDropdownRef;
129
+ const defaultDropdownRef = React.useRef<HTMLSelectElement>(null);
130
+ const inputWrapperRef = React.useRef<HTMLDivElement>(null);
131
+ const ref = (inputRef ?? defaultDropdownRef) as React.RefObject<HTMLSelectElement>;
132
+ const [menuOpen, setMenuOpen] = React.useState(false);
133
+ const iconPadding = icon ? paddingForIcon : 0;
134
+
135
+ const {
136
+ renderLayer,
137
+ triggerProps: { ref: setTriggerRef },
138
+ layerProps,
139
+ triggerBounds,
140
+ } = useLayer({
141
+ isOpen: menuOpen,
142
+ auto: true,
143
+ snap: true,
144
+ placement: 'bottom-start',
145
+ possiblePlacements: ['top-start', 'bottom-start'],
146
+ triggerOffset: 2,
147
+ onOutsideClick: () => {
148
+ setMenuOpen(false);
149
+ },
150
+ });
151
+ setTriggerRef(inputWrapperRef.current);
112
152
 
113
153
  const selectClassName = cx(
114
154
  inputClasses,
@@ -118,11 +158,7 @@ const Dropdown: React.FC<DropdownProps> = ({
118
158
  required && 'required'
119
159
  );
120
160
 
121
- /**
122
- * @type {{[key: string]: any }}
123
- */
124
161
  const attrs = {
125
- onMouseDown: onClick,
126
162
  onChange,
127
163
  onBlur,
128
164
  onFocus,
@@ -157,14 +193,45 @@ const Dropdown: React.FC<DropdownProps> = ({
157
193
  </option>
158
194
  );
159
195
 
196
+ const handleSelectClick = (event: React.MouseEvent<HTMLSelectElement>) => {
197
+ onClick(event);
198
+ if (event.isDefaultPrevented()) return;
199
+
200
+ event.preventDefault();
201
+ ref.current?.focus();
202
+ if (!options.length) return;
203
+
204
+ setMenuOpen(!menuOpen);
205
+ };
206
+
207
+ const handleOptionClick = (event: React.MouseEvent<HTMLLIElement>) => {
208
+ if (ref.current) {
209
+ ref.current.value = event.currentTarget.getAttribute('value') || '';
210
+ const selectEvent = new Event('change', { bubbles: true });
211
+ ref.current.dispatchEvent(selectEvent);
212
+ ref.current.focus();
213
+ }
214
+ setMenuOpen(false);
215
+ };
216
+
160
217
  return (
161
218
  <Container containerWidth={containerWidth} className={className}>
162
- <InputWrapper className={cx('wrapper', disabled && 'disabled', isWithError && 'error')}>
163
- <select className={'select ' + selectClassName} ref={ref} {...attrs}>
219
+ <InputWrapper
220
+ style={{ paddingLeft: iconPadding }}
221
+ className={cx('wrapper', disabled && 'disabled', isWithError && 'error')}
222
+ ref={inputWrapperRef}
223
+ >
224
+ {icon ? <LeftIcon>{icon}</LeftIcon> : null}
225
+ <select
226
+ className={'select ' + selectClassName}
227
+ ref={ref}
228
+ {...attrs}
229
+ onMouseDown={handleSelectClick}
230
+ >
164
231
  {selectOptions}
165
232
  </select>
166
233
  {!!label && (
167
- <label className="label" htmlFor={id}>
234
+ <label style={{ marginLeft: iconPadding }} className="label" htmlFor={id}>
168
235
  {label}
169
236
  </label>
170
237
  )}
@@ -174,15 +241,44 @@ const Dropdown: React.FC<DropdownProps> = ({
174
241
  height: '24px',
175
242
  position: 'absolute',
176
243
  right: '8px',
177
- stroke: '#8C8C8C',
178
244
  top: '12px',
179
- color: '#8C8C8C',
180
245
  }}
181
246
  >
182
- <ChevronDownFilled className="arrow" style={{ fontSize: '1.5rem' }} />
247
+ <ChevronDownFilled
248
+ className="arrow"
249
+ style={{ fontSize: '1.5rem', color: disabled && colors.iconDisabled }}
250
+ />
183
251
  </span>
184
252
  </InputWrapper>
185
- <Paragraph className="helptext">{helptext}</Paragraph>
253
+ <Paragraph className={cx('helptext', helptextClassName)}>{helptext}</Paragraph>
254
+
255
+ {menuOpen
256
+ ? renderLayer(
257
+ <Menu
258
+ role="listbox"
259
+ {...layerProps}
260
+ style={{
261
+ ...layerProps.style,
262
+ width: (triggerBounds?.width || 0) + 2,
263
+ left: (triggerBounds?.left || 0) - 1,
264
+ maxHeight: sizes[menuMaxHeight],
265
+ }}
266
+ >
267
+ {options.map((option) => (
268
+ <Item
269
+ role="menuitem"
270
+ key={option.value}
271
+ value={option.value}
272
+ onClick={handleOptionClick}
273
+ className={option.value === value ? 'selected' : ''}
274
+ >
275
+ {option.icon}
276
+ {option.label}
277
+ </Item>
278
+ ))}
279
+ </Menu>
280
+ )
281
+ : null}
186
282
  </Container>
187
283
  );
188
284
  };
@@ -6,7 +6,7 @@ declare const getSpans: (span: any, defaultValue: any) => string[];
6
6
  *
7
7
  * `✅ Stable`
8
8
  */
9
- export type ColProps = {
9
+ export interface ColProps {
10
10
  /**
11
11
  * [Responsive Prop] Column span
12
12
  */
@@ -31,7 +31,7 @@ export type ColProps = {
31
31
  * Content inside column
32
32
  */
33
33
  children: React.ReactNode;
34
- };
34
+ }
35
35
  declare const Col: React.FC<ColProps>;
36
36
  export { getWidthByPctFromSpan, getSpans };
37
37
  export default Col;
@@ -19,7 +19,7 @@ const getSpans = (span, defaultValue) =>
19
19
  * `✅ Stable`
20
20
  */
21
21
 
22
- export type ColProps = {
22
+ export interface ColProps {
23
23
  /**
24
24
  * [Responsive Prop] Column span
25
25
  */
@@ -44,7 +44,7 @@ export type ColProps = {
44
44
  * Content inside column
45
45
  */
46
46
  children: React.ReactNode;
47
- };
47
+ }
48
48
 
49
49
  const Col: React.FC<ColProps> = ({
50
50
  span = null,
@@ -56,7 +56,10 @@ const Col: React.FC<ColProps> = ({
56
56
  }) => {
57
57
  const classes = cx(className, span && 'withSpan', offset && 'withOffset');
58
58
  const alignSelf = (align === 'start' && 'flex-start') || (align === 'end' && 'flex-end') || align; // no need to transform 'center'
59
- const colOrder = (order === 'first' && '-1') || (order === 'last' && '13') || order;
59
+ const colOrder =
60
+ (order === 'first' && -1) ||
61
+ (order === 'last' && 13) ||
62
+ (typeof order === 'number' ? order : 0); // Ensure colOrder is always a number
60
63
  const spans = getSpans(span, 'initial');
61
64
  const offsets = getSpans(offset, 'initial');
62
65
 
@@ -1,12 +1,32 @@
1
1
  /**
2
- * @type {React.FC<any>}
2
+ * @type {any}
3
3
  */
4
- export const Container: React.FC<any>;
4
+ declare const StyledCol: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
5
+ alignSelf: string;
6
+ colOrder: number;
7
+ spans: string[];
8
+ offsets: string[];
9
+ } & {
10
+ as?: import("react").ElementType;
11
+ }>;
5
12
  /**
6
13
  * @type {any}
7
14
  */
8
- export const StyledGrid: any;
15
+ declare const StyledGrid: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
16
+ alignItems: string;
17
+ justifyContent: string;
18
+ colWidths: string[];
19
+ } & {
20
+ as?: import("react").ElementType;
21
+ }>;
9
22
  /**
10
- * @type {any}
23
+ * @type {React.FC<any>}
11
24
  */
12
- export const StyledCol: any;
25
+ declare const Container: import("@linaria/react").StyledMeta & import("react").FunctionComponent<import("react").ClassAttributes<HTMLDivElement> & import("react").HTMLAttributes<HTMLDivElement> & {
26
+ containerWidths: string[];
27
+ gutterxs: number[];
28
+ gutterys: number[];
29
+ } & {
30
+ as?: import("react").ElementType;
31
+ }>;
32
+ export { Container, StyledGrid, StyledCol };
@@ -6,7 +6,12 @@ const { mediaQueries, breakpoints } = theme;
6
6
  /**
7
7
  * @type {any}
8
8
  */
9
- const StyledCol = styled.div`
9
+ const StyledCol = styled.div<{
10
+ alignSelf: string;
11
+ colOrder: number;
12
+ spans: string[];
13
+ offsets: string[];
14
+ }>`
10
15
  flex: 1 0 0%;
11
16
  align-self: ${({ alignSelf }) => alignSelf};
12
17
  order: ${({ colOrder }) => colOrder};
@@ -68,7 +73,11 @@ const StyledCol = styled.div`
68
73
  /**
69
74
  * @type {any}
70
75
  */
71
- const StyledGrid = styled.div`
76
+ const StyledGrid = styled.div<{
77
+ alignItems: string;
78
+ justifyContent: string;
79
+ colWidths: string[];
80
+ }>`
72
81
  display: flex;
73
82
  flex-wrap: wrap;
74
83
  align-items: ${({ alignItems }) => alignItems};
@@ -107,7 +116,11 @@ const StyledGrid = styled.div`
107
116
  /**
108
117
  * @type {React.FC<any>}
109
118
  */
110
- const Container = styled.div`
119
+ const Container = styled.div<{
120
+ containerWidths: string[];
121
+ gutterxs: number[];
122
+ gutterys: number[];
123
+ }>`
111
124
  margin-right: auto;
112
125
  margin-left: auto;
113
126
 
@@ -0,0 +1,127 @@
1
+ import React from 'react';
2
+ declare const gridStories: {
3
+ title: string;
4
+ component: React.FC<import("./Grid").GridProps>;
5
+ subcomponents: {
6
+ Col: React.FC<import("./Col").ColProps>;
7
+ };
8
+ parameters: {
9
+ docs: {
10
+ description: {
11
+ component: string;
12
+ };
13
+ };
14
+ };
15
+ argTypes: {
16
+ width: {
17
+ options: string[];
18
+ };
19
+ rowCols: {
20
+ control: {
21
+ type: string;
22
+ };
23
+ };
24
+ align: {};
25
+ justify: {};
26
+ gutter: {
27
+ options: string[];
28
+ };
29
+ children: {
30
+ control: {
31
+ type: string;
32
+ min: number;
33
+ max: number;
34
+ step: number;
35
+ };
36
+ };
37
+ className: {
38
+ control: null;
39
+ };
40
+ gutterx: {
41
+ control: null;
42
+ };
43
+ guttery: {
44
+ control: null;
45
+ };
46
+ };
47
+ args: {
48
+ width: string;
49
+ gutter: string;
50
+ children: number;
51
+ };
52
+ };
53
+ export default gridStories;
54
+ export declare const GridSystem: {
55
+ render: (args: any) => JSX.Element;
56
+ };
57
+ export declare const GridWidth: {
58
+ render: () => JSX.Element;
59
+ parameters: {
60
+ docs: {
61
+ description: {
62
+ story: string;
63
+ };
64
+ };
65
+ };
66
+ };
67
+ export declare const RowCols: {
68
+ render: () => JSX.Element;
69
+ name: string;
70
+ parameters: {
71
+ docs: {
72
+ description: {
73
+ story: string;
74
+ };
75
+ };
76
+ };
77
+ };
78
+ export declare const VerticalAlign: {
79
+ render: () => JSX.Element;
80
+ parameters: {
81
+ docs: {
82
+ description: {
83
+ story: string;
84
+ };
85
+ };
86
+ };
87
+ };
88
+ export declare const HorizontalJustify: {
89
+ render: () => JSX.Element;
90
+ parameters: {
91
+ docs: {
92
+ description: {
93
+ story: string;
94
+ };
95
+ };
96
+ };
97
+ };
98
+ export declare const ColumnSpacing: {
99
+ render: () => JSX.Element;
100
+ parameters: {
101
+ docs: {
102
+ description: {
103
+ story: string;
104
+ };
105
+ };
106
+ };
107
+ };
108
+ export declare const HorizontalSpace: {
109
+ render: () => JSX.Element;
110
+ parameters: {
111
+ docs: {
112
+ description: {
113
+ story: string;
114
+ };
115
+ };
116
+ };
117
+ };
118
+ export declare const VerticalSpace: {
119
+ render: () => JSX.Element;
120
+ parameters: {
121
+ docs: {
122
+ description: {
123
+ story: string;
124
+ };
125
+ };
126
+ };
127
+ };
@@ -0,0 +1,74 @@
1
+ import React from 'react';
2
+ declare const gridStories: {
3
+ title: string;
4
+ component: React.FC<import("./Col").ColProps>;
5
+ tags: string[];
6
+ argTypes: {
7
+ span: {
8
+ control: {
9
+ type: string;
10
+ };
11
+ };
12
+ align: {};
13
+ offset: {
14
+ control: {
15
+ type: string;
16
+ };
17
+ };
18
+ order: {};
19
+ children: {
20
+ table: {
21
+ disable: boolean;
22
+ };
23
+ };
24
+ className: {
25
+ table: {
26
+ disable: boolean;
27
+ };
28
+ };
29
+ };
30
+ };
31
+ export default gridStories;
32
+ export declare const Component: {
33
+ render: (args: any) => JSX.Element;
34
+ };
35
+ export declare const ColumnSpan: {
36
+ render: () => JSX.Element;
37
+ parameters: {
38
+ docs: {
39
+ description: {
40
+ story: string;
41
+ };
42
+ };
43
+ };
44
+ };
45
+ export declare const ColumnOffset: {
46
+ render: () => JSX.Element;
47
+ parameters: {
48
+ docs: {
49
+ description: {
50
+ story: string;
51
+ };
52
+ };
53
+ };
54
+ };
55
+ export declare const ColumnAlign: {
56
+ render: () => JSX.Element;
57
+ parameters: {
58
+ docs: {
59
+ description: {
60
+ story: string;
61
+ };
62
+ };
63
+ };
64
+ };
65
+ export declare const ColumnOrder: {
66
+ render: () => JSX.Element;
67
+ parameters: {
68
+ docs: {
69
+ description: {
70
+ story: string;
71
+ };
72
+ };
73
+ };
74
+ };
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
- declare const keysOfSizes: readonly string[];
3
- type Size = (typeof keysOfSizes)[number];
4
- export type InputProps = {
2
+ import { type Sizes } from '@clad-ui/theme';
3
+ export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
5
4
  /**
6
5
  * Input name
7
6
  */
@@ -25,23 +24,23 @@ export type InputProps = {
25
24
  /**
26
25
  * Callback when user input
27
26
  */
28
- onChange?: React.ChangeEventHandler;
27
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
29
28
  /**
30
29
  * Callback when user blur
31
30
  */
32
- onBlur?: React.FocusEventHandler;
31
+ onBlur?: React.FocusEventHandler<HTMLInputElement>;
33
32
  /**
34
33
  * Callback when keydown
35
34
  */
36
- onKeyDown?: React.KeyboardEventHandler;
35
+ onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>;
37
36
  /**
38
37
  * Callback when keyup
39
38
  */
40
- onKeyUp?: React.KeyboardEventHandler;
39
+ onKeyUp?: React.KeyboardEventHandler<HTMLInputElement>;
41
40
  /**
42
41
  * Callback when user focus
43
42
  */
44
- onFocus?: React.FocusEventHandler;
43
+ onFocus?: React.FocusEventHandler<HTMLInputElement>;
45
44
  /**
46
45
  * Disabled input
47
46
  */
@@ -56,6 +55,7 @@ export type InputProps = {
56
55
  id?: string;
57
56
  /**
58
57
  * If allow to remove input content with clear icon
58
+ * @default true
59
59
  */
60
60
  allowClear?: boolean;
61
61
  /**
@@ -66,6 +66,10 @@ export type InputProps = {
66
66
  * Promp a helptext below input (useful when implemented with form validation)
67
67
  */
68
68
  helptext?: string;
69
+ /**
70
+ * Custom helptext
71
+ */
72
+ helptextClassName?: string;
69
73
  /**
70
74
  * Show entered password
71
75
  */
@@ -88,7 +92,7 @@ export type InputProps = {
88
92
  /**
89
93
  * Input width
90
94
  */
91
- width?: Size;
95
+ width?: Sizes;
92
96
  /**
93
97
  * Maximum number of characters allowed. 0, null and undefined mean no limitation
94
98
  */
@@ -105,7 +109,7 @@ export type InputProps = {
105
109
  * Input placeholder
106
110
  */
107
111
  placeholder?: string;
108
- };
112
+ }
109
113
  /**
110
114
  * Text Input component that has floating label, caption, and info tooltip.
111
115
  *