reshaped 3.8.0-canary.6 → 3.8.0-canary.8

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 (223) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/bundle.css +1 -1
  3. package/dist/bundle.js +10 -10
  4. package/dist/components/Actionable/Actionable.module.css +1 -1
  5. package/dist/components/Alert/tests/Alert.stories.d.ts +6 -5
  6. package/dist/components/Alert/tests/Alert.stories.js +15 -2
  7. package/dist/components/Badge/Badge.module.css +1 -1
  8. package/dist/components/Badge/tests/Badge.stories.d.ts +5 -0
  9. package/dist/components/Badge/tests/Badge.stories.js +34 -0
  10. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.d.ts +8 -4
  11. package/dist/components/Breadcrumbs/tests/Breadcrumbs.stories.js +57 -1
  12. package/dist/components/Button/tests/Button.stories.d.ts +54 -12
  13. package/dist/components/Button/tests/Button.stories.js +725 -588
  14. package/dist/components/Card/Card.module.css +1 -1
  15. package/dist/components/Card/tests/Card.stories.d.ts +28 -6
  16. package/dist/components/Card/tests/Card.stories.js +110 -65
  17. package/dist/components/Carousel/Carousel.module.css +1 -1
  18. package/dist/components/Checkbox/Checkbox.module.css +1 -1
  19. package/dist/components/Checkbox/tests/Checkbox.stories.d.ts +20 -4
  20. package/dist/components/Checkbox/tests/Checkbox.stories.js +150 -79
  21. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.d.ts +9 -2
  22. package/dist/components/CheckboxGroup/tests/CheckboxGroup.stories.js +67 -35
  23. package/dist/components/Container/tests/Container.stories.d.ts +2 -0
  24. package/dist/components/Container/tests/Container.stories.js +14 -0
  25. package/dist/components/ContextMenu/tests/ContextMenu.stories.d.ts +10 -1
  26. package/dist/components/ContextMenu/tests/ContextMenu.stories.js +57 -13
  27. package/dist/components/Dismissible/tests/Dismissible.stories.d.ts +5 -0
  28. package/dist/components/Dismissible/tests/Dismissible.stories.js +30 -1
  29. package/dist/components/Divider/tests/Divider.stories.d.ts +8 -3
  30. package/dist/components/Divider/tests/Divider.stories.js +71 -41
  31. package/dist/components/DropdownMenu/DropdownMenu.js +4 -4
  32. package/dist/components/DropdownMenu/DropdownMenu.types.d.ts +2 -2
  33. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.d.ts +35 -6
  34. package/dist/components/DropdownMenu/tests/DropdownMenu.stories.js +222 -115
  35. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.d.ts +0 -15
  36. package/dist/components/DropdownMenu/tests/DropdownMenu.test.stories.js +0 -106
  37. package/dist/components/FileUpload/FileUpload.module.css +1 -1
  38. package/dist/components/Flyout/Flyout.module.css +1 -1
  39. package/dist/components/Flyout/utilities/flyout.js +0 -1
  40. package/dist/components/Flyout/utilities/getPositionFallbacks.js +3 -3
  41. package/dist/components/Flyout/utilities/isFullyVisible.d.ts +0 -2
  42. package/dist/components/Flyout/utilities/isFullyVisible.js +5 -7
  43. package/dist/components/FormControl/tests/FormControl.stories.d.ts +2 -0
  44. package/dist/components/FormControl/tests/FormControl.stories.js +35 -0
  45. package/dist/components/Hidden/Hidden.js +2 -1
  46. package/dist/components/Hidden/tests/Hidden.stories.d.ts +2 -0
  47. package/dist/components/Hidden/tests/Hidden.stories.js +9 -0
  48. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.d.ts +2 -0
  49. package/dist/components/HiddenVisually/tests/HiddenVisually.stories.js +9 -0
  50. package/dist/components/Hotkey/tests/Hotkey.stories.d.ts +2 -0
  51. package/dist/components/Hotkey/tests/Hotkey.stories.js +15 -0
  52. package/dist/components/Icon/tests/Icon.stories.d.ts +3 -0
  53. package/dist/components/Icon/tests/Icon.stories.js +23 -0
  54. package/dist/components/Link/tests/Link.stories.d.ts +28 -5
  55. package/dist/components/Link/tests/Link.stories.js +141 -58
  56. package/dist/components/Link/tests/Link.test.stories.d.ts +0 -13
  57. package/dist/components/Link/tests/Link.test.stories.js +0 -85
  58. package/dist/components/Loader/tests/Loader.stories.d.ts +11 -2
  59. package/dist/components/Loader/tests/Loader.stories.js +52 -25
  60. package/dist/components/Loader/tests/Loader.test.stories.d.ts +0 -3
  61. package/dist/components/Loader/tests/Loader.test.stories.js +0 -21
  62. package/dist/components/MenuItem/MenuItem.module.css +1 -1
  63. package/dist/components/MenuItem/tests/MenuItem.stories.d.ts +37 -7
  64. package/dist/components/MenuItem/tests/MenuItem.stories.js +218 -112
  65. package/dist/components/Modal/Modal.js +1 -1
  66. package/dist/components/Modal/Modal.module.css +1 -1
  67. package/dist/components/Modal/tests/Modal.stories.d.ts +53 -10
  68. package/dist/components/Modal/tests/Modal.stories.js +366 -214
  69. package/dist/components/Overlay/tests/Overlay.stories.d.ts +15 -1
  70. package/dist/components/Overlay/tests/Overlay.stories.js +135 -1
  71. package/dist/components/Pagination/tests/Pagination.stories.d.ts +14 -1
  72. package/dist/components/Pagination/tests/Pagination.stories.js +93 -15
  73. package/dist/components/PinField/tests/PinField.stories.d.ts +1 -1
  74. package/dist/components/PinField/tests/PinField.stories.js +1 -1
  75. package/dist/components/Popover/Popover.js +2 -2
  76. package/dist/components/Popover/Popover.module.css +1 -1
  77. package/dist/components/Popover/Popover.types.d.ts +2 -0
  78. package/dist/components/Progress/tests/Progress.stories.d.ts +19 -4
  79. package/dist/components/Progress/tests/Progress.stories.js +85 -49
  80. package/dist/components/Radio/Radio.module.css +1 -1
  81. package/dist/components/Radio/tests/Radio.stories.d.ts +25 -4
  82. package/dist/components/Radio/tests/Radio.stories.js +147 -65
  83. package/dist/components/RadioGroup/tests/RadioGroup.stories.d.ts +9 -2
  84. package/dist/components/RadioGroup/tests/RadioGroup.stories.js +64 -38
  85. package/dist/components/Reshaped/Reshaped.css +1 -1
  86. package/dist/components/Resizable/Resizable.js +4 -3
  87. package/dist/components/Scrim/tests/Scrim.stories.d.ts +10 -2
  88. package/dist/components/Scrim/tests/Scrim.stories.js +51 -31
  89. package/dist/components/ScrollArea/ScrollArea.module.css +1 -1
  90. package/dist/components/Select/Select.d.ts +8 -1
  91. package/dist/components/Select/Select.js +22 -48
  92. package/dist/components/Select/Select.module.css +1 -1
  93. package/dist/components/Select/Select.types.d.ts +83 -38
  94. package/dist/components/Select/SelectCustom.d.ts +3 -0
  95. package/dist/components/Select/SelectCustom.js +12 -0
  96. package/dist/components/Select/SelectCustomControlled.d.ts +4 -0
  97. package/dist/components/Select/SelectCustomControlled.js +102 -0
  98. package/dist/components/Select/SelectCustomUncontrolled.d.ts +4 -0
  99. package/dist/components/Select/SelectCustomUncontrolled.js +18 -0
  100. package/dist/components/Select/SelectEndContent.d.ts +3 -0
  101. package/dist/components/Select/SelectEndContent.js +12 -0
  102. package/dist/components/Select/SelectNative.d.ts +4 -0
  103. package/dist/components/Select/SelectNative.js +29 -0
  104. package/dist/components/Select/SelectOption.d.ts +4 -0
  105. package/dist/components/Select/SelectOption.js +15 -0
  106. package/dist/components/Select/SelectOptionGroup.d.ts +4 -0
  107. package/dist/components/Select/SelectOptionGroup.js +11 -0
  108. package/dist/components/Select/SelectRoot.d.ts +4 -0
  109. package/dist/components/Select/SelectRoot.js +21 -0
  110. package/dist/components/Select/SelectStartContent.d.ts +3 -0
  111. package/dist/components/Select/SelectStartContent.js +20 -0
  112. package/dist/components/Select/SelectTrigger.d.ts +4 -0
  113. package/dist/components/Select/SelectTrigger.js +16 -0
  114. package/dist/components/Select/tests/Select.stories.d.ts +38 -10
  115. package/dist/components/Select/tests/Select.stories.js +504 -175
  116. package/dist/components/Skeleton/tests/Skeleton.stories.d.ts +10 -2
  117. package/dist/components/Skeleton/tests/Skeleton.stories.js +46 -28
  118. package/dist/components/Slider/Slider.module.css +1 -1
  119. package/dist/components/Stepper/Stepper.js +2 -2
  120. package/dist/components/Stepper/Stepper.types.d.ts +2 -0
  121. package/dist/components/Stepper/tests/Stepper.stories.d.ts +18 -3
  122. package/dist/components/Stepper/tests/Stepper.stories.js +99 -47
  123. package/dist/components/Switch/Switch.module.css +1 -1
  124. package/dist/components/Switch/tests/Switch.stories.d.ts +10 -2
  125. package/dist/components/Switch/tests/Switch.stories.js +77 -23
  126. package/dist/components/Switch/tests/Switch.test.stories.d.ts +0 -10
  127. package/dist/components/Switch/tests/Switch.test.stories.js +0 -68
  128. package/dist/components/Table/Table.js +6 -3
  129. package/dist/components/Table/Table.module.css +1 -1
  130. package/dist/components/Table/tests/Table.stories.d.ts +25 -5
  131. package/dist/components/Table/tests/Table.stories.js +274 -177
  132. package/dist/components/Table/tests/Table.test.stories.d.ts +0 -5
  133. package/dist/components/Table/tests/Table.test.stories.js +0 -82
  134. package/dist/components/Tabs/Tabs.module.css +1 -1
  135. package/dist/components/TextArea/TextArea.module.css +1 -1
  136. package/dist/components/TextArea/tests/TextArea.stories.d.ts +41 -9
  137. package/dist/components/TextArea/tests/TextArea.stories.js +179 -93
  138. package/dist/components/TextField/TextField.js +1 -1
  139. package/dist/components/TextField/TextField.module.css +1 -1
  140. package/dist/components/TextField/tests/TextField.stories.d.ts +41 -11
  141. package/dist/components/TextField/tests/TextField.stories.js +206 -132
  142. package/dist/components/TextField/tests/TextField.test.stories.d.ts +0 -13
  143. package/dist/components/TextField/tests/TextField.test.stories.js +0 -88
  144. package/dist/components/Theme/Theme.module.css +1 -1
  145. package/dist/components/Timeline/Timeline.js +3 -2
  146. package/dist/components/Timeline/tests/Timeline.stories.d.ts +10 -2
  147. package/dist/components/Timeline/tests/Timeline.stories.js +69 -45
  148. package/dist/components/Timeline/tests/Timeline.test.stories.d.ts +0 -2
  149. package/dist/components/Timeline/tests/Timeline.test.stories.js +0 -21
  150. package/dist/components/Toast/tests/Toast.stories.d.ts +32 -8
  151. package/dist/components/Toast/tests/Toast.stories.js +109 -37
  152. package/dist/components/Tooltip/tests/Tooltip.stories.d.ts +18 -4
  153. package/dist/components/Tooltip/tests/Tooltip.stories.js +139 -107
  154. package/dist/components/Tooltip/tests/Tooltip.test.stories.d.ts +0 -6
  155. package/dist/components/Tooltip/tests/Tooltip.test.stories.js +0 -29
  156. package/dist/components/View/View.js +6 -4
  157. package/dist/components/View/tests/View.stories.d.ts +4 -0
  158. package/dist/components/View/tests/View.stories.js +39 -0
  159. package/dist/hooks/tests/useDrag.stories.js +1 -1
  160. package/dist/utilities/props.d.ts +3 -0
  161. package/dist/utilities/props.js +19 -0
  162. package/dist/utilities/scroll/disable.js +2 -2
  163. package/package.json +1 -1
  164. package/dist/components/Alert/tests/Alert.test.stories.d.ts +0 -15
  165. package/dist/components/Alert/tests/Alert.test.stories.js +0 -26
  166. package/dist/components/Badge/tests/Badge.test.stories.d.ts +0 -20
  167. package/dist/components/Badge/tests/Badge.test.stories.js +0 -46
  168. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.d.ts +0 -23
  169. package/dist/components/Breadcrumbs/tests/Breadcrumbs.test.stories.js +0 -76
  170. package/dist/components/Button/tests/Button.test.stories.d.ts +0 -28
  171. package/dist/components/Button/tests/Button.test.stories.js +0 -135
  172. package/dist/components/Card/tests/Card.test.stories.d.ts +0 -35
  173. package/dist/components/Card/tests/Card.test.stories.js +0 -54
  174. package/dist/components/Checkbox/tests/Checkbox.test.stories.d.ts +0 -25
  175. package/dist/components/Checkbox/tests/Checkbox.test.stories.js +0 -104
  176. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.d.ts +0 -22
  177. package/dist/components/CheckboxGroup/tests/CheckboxGroup.test.stories.js +0 -78
  178. package/dist/components/Container/tests/Container.test.stories.d.ts +0 -15
  179. package/dist/components/Container/tests/Container.test.stories.js +0 -26
  180. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.d.ts +0 -25
  181. package/dist/components/ContextMenu/tests/ContextMenu.test.stories.js +0 -53
  182. package/dist/components/Dismissible/tests/Dismissible.test.stories.d.ts +0 -19
  183. package/dist/components/Dismissible/tests/Dismissible.test.stories.js +0 -42
  184. package/dist/components/Divider/tests/Divider.test.stories.d.ts +0 -18
  185. package/dist/components/Divider/tests/Divider.test.stories.js +0 -47
  186. package/dist/components/FormControl/tests/FormControl.test.stories.d.ts +0 -20
  187. package/dist/components/FormControl/tests/FormControl.test.stories.js +0 -49
  188. package/dist/components/Hidden/tests/Hidden.test.stories.d.ts +0 -15
  189. package/dist/components/Hidden/tests/Hidden.test.stories.js +0 -20
  190. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.d.ts +0 -15
  191. package/dist/components/HiddenVisually/tests/HiddenVisually.test.stories.js +0 -20
  192. package/dist/components/Hotkey/tests/Hotkey.test.stories.d.ts +0 -15
  193. package/dist/components/Hotkey/tests/Hotkey.test.stories.js +0 -26
  194. package/dist/components/Icon/tests/Icon.test.stories.d.ts +0 -16
  195. package/dist/components/Icon/tests/Icon.test.stories.js +0 -35
  196. package/dist/components/MenuItem/tests/MenuItem.test.stories.d.ts +0 -27
  197. package/dist/components/MenuItem/tests/MenuItem.test.stories.js +0 -116
  198. package/dist/components/Modal/tests/Modal.test.stories.d.ts +0 -31
  199. package/dist/components/Modal/tests/Modal.test.stories.js +0 -149
  200. package/dist/components/Overlay/tests/Overlay.test.stories.d.ts +0 -28
  201. package/dist/components/Overlay/tests/Overlay.test.stories.js +0 -148
  202. package/dist/components/Pagination/tests/Pagination.test.stories.d.ts +0 -23
  203. package/dist/components/Pagination/tests/Pagination.test.stories.js +0 -86
  204. package/dist/components/Progress/tests/Progress.test.stories.d.ts +0 -16
  205. package/dist/components/Progress/tests/Progress.test.stories.js +0 -35
  206. package/dist/components/Radio/tests/Radio.test.stories.d.ts +0 -30
  207. package/dist/components/Radio/tests/Radio.test.stories.js +0 -118
  208. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.d.ts +0 -22
  209. package/dist/components/RadioGroup/tests/RadioGroup.test.stories.js +0 -78
  210. package/dist/components/Scrim/tests/Scrim.test.stories.d.ts +0 -15
  211. package/dist/components/Scrim/tests/Scrim.test.stories.js +0 -25
  212. package/dist/components/Select/tests/Select.test.stories.d.ts +0 -27
  213. package/dist/components/Select/tests/Select.test.stories.js +0 -132
  214. package/dist/components/Skeleton/tests/Skeleton.test.stories.d.ts +0 -15
  215. package/dist/components/Skeleton/tests/Skeleton.test.stories.js +0 -23
  216. package/dist/components/Stepper/tests/Stepper.test.stories.d.ts +0 -20
  217. package/dist/components/Stepper/tests/Stepper.test.stories.js +0 -28
  218. package/dist/components/TextArea/tests/TextArea.test.stories.d.ts +0 -28
  219. package/dist/components/TextArea/tests/TextArea.test.stories.js +0 -99
  220. package/dist/components/Toast/tests/Toast.test.stories.d.ts +0 -16
  221. package/dist/components/Toast/tests/Toast.test.stories.js +0 -101
  222. package/dist/components/View/tests/View.test.stories.d.ts +0 -24
  223. package/dist/components/View/tests/View.test.stories.js +0 -50
@@ -1,6 +1,7 @@
1
1
  import { Example } from "../../../utilities/storybook/index.js";
2
2
  import Radio from "../index.js";
3
3
  import View from "../../View/index.js";
4
+ import { expect, fn, userEvent } from "storybook/test";
4
5
  export default {
5
6
  title: "Components/Radio",
6
7
  component: Radio,
@@ -10,71 +11,152 @@ export default {
10
11
  },
11
12
  },
12
13
  };
13
- export const selection = () => (<Example>
14
- <Example.Item title="unselected">
15
- <Radio name="unselected" value="dog">
16
- Radio
17
- </Radio>
18
- </Example.Item>
19
-
20
- <Example.Item title="checked, uncontrolled">
21
- <Radio name="uncontrolled" value="dog" defaultChecked>
22
- Radio
23
- </Radio>
24
- </Example.Item>
25
-
26
- <Example.Item title="checked, controlled">
27
- <Radio name="controlled" value="dog" checked>
28
- Radio
29
- </Radio>
30
- </Example.Item>
31
- </Example>);
32
- export const size = () => (<Example>
33
- <Example.Item title="size: small">
34
- <View gap={4} direction="row">
35
- <Radio name="animal" value="dog" size="small" defaultChecked>
36
- Radio
37
- </Radio>
38
- </View>
39
- </Example.Item>
40
- <Example.Item title="size: medium">
41
- <View gap={4} direction="row">
42
- <Radio name="animal" value="dog" size="medium">
43
- Radio
44
- </Radio>
45
- </View>
46
- </Example.Item>
47
- <Example.Item title="size: large">
48
- <View gap={4} direction="row">
49
- <Radio name="animal" value="dog" size="large">
50
- Radio
51
- </Radio>
52
- </View>
53
- </Example.Item>
54
- <Example.Item title="size: responsive, s: small, m: large">
55
- <View gap={4} direction="row">
56
- <Radio name="animal" value="dog" size={{ s: "small", m: "large" }}>
14
+ export const size = {
15
+ name: "size",
16
+ render: () => (<Example>
17
+ <Example.Item title="size: small">
18
+ <View gap={4} direction="row">
19
+ <Radio name="animal" value="dog" size="small" defaultChecked>
20
+ Radio
21
+ </Radio>
22
+ </View>
23
+ </Example.Item>
24
+ <Example.Item title="size: medium">
25
+ <View gap={4} direction="row">
26
+ <Radio name="animal" value="dog" size="medium">
27
+ Radio
28
+ </Radio>
29
+ </View>
30
+ </Example.Item>
31
+ <Example.Item title="size: large">
32
+ <View gap={4} direction="row">
33
+ <Radio name="animal" value="dog" size="large">
34
+ Radio
35
+ </Radio>
36
+ </View>
37
+ </Example.Item>
38
+ <Example.Item title="size: responsive, s: small, m: large">
39
+ <View gap={4} direction="row">
40
+ <Radio name="animal" value="dog" size={{ s: "small", m: "large" }}>
41
+ Radio
42
+ </Radio>
43
+ </View>
44
+ </Example.Item>
45
+ </Example>),
46
+ };
47
+ export const error = {
48
+ name: "hasError",
49
+ render: () => (<Example>
50
+ <Example.Item title="error">
51
+ <Radio name="error" value="dog" hasError>
57
52
  Radio
58
53
  </Radio>
59
- </View>
60
- </Example.Item>
61
- </Example>);
62
- export const error = () => (<Example>
63
- <Example.Item title="error">
64
- <Radio name="error" value="dog" hasError>
65
- Radio
66
- </Radio>
67
- </Example.Item>
68
- </Example>);
69
- export const disabled = () => (<Example>
70
- <Example.Item title="disabled">
71
- <Radio name="disabled" value="dog" disabled>
72
- Radio
73
- </Radio>
74
- </Example.Item>
75
- <Example.Item title="disabled, checked">
76
- <Radio name="disabled-checked" value="dog" disabled checked>
77
- Radio
54
+ </Example.Item>
55
+ </Example>),
56
+ };
57
+ export const render = {
58
+ name: "name, value",
59
+ render: () => (<Radio name="test-name" value="test-value">
60
+ Content
61
+ </Radio>),
62
+ play: async ({ canvas }) => {
63
+ const input = canvas.getByRole("radio");
64
+ expect(input).toHaveAttribute("value", "test-value");
65
+ expect(input).toHaveAttribute("name", "test-name");
66
+ expect(input).not.toBeChecked();
67
+ },
68
+ };
69
+ export const checked = {
70
+ name: "checked, controlled",
71
+ args: {
72
+ handleChange: fn(),
73
+ },
74
+ render: (args) => (<Radio name="test-name" value="test-value" checked onChange={args.handleChange}>
75
+ Content
76
+ </Radio>),
77
+ play: async ({ canvas, args }) => {
78
+ const input = canvas.getByRole("radio");
79
+ expect(input).toBeChecked();
80
+ },
81
+ };
82
+ export const checkedFalse = {
83
+ name: "checked false, controlled",
84
+ args: {
85
+ handleChange: fn(),
86
+ },
87
+ render: (args) => (<Radio name="test-name" value="test-value" checked={false} onChange={args.handleChange}>
88
+ Content
89
+ </Radio>),
90
+ play: async ({ canvas, args }) => {
91
+ const input = canvas.getByRole("radio");
92
+ expect(input).not.toBeChecked();
93
+ await userEvent.click(input);
94
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
95
+ expect(args.handleChange).toHaveBeenCalledWith({
96
+ name: "test-name",
97
+ value: "test-value",
98
+ checked: true,
99
+ event: expect.objectContaining({ target: input }),
100
+ });
101
+ // Still not checked because it's controlled
102
+ expect(input).not.toBeChecked();
103
+ },
104
+ };
105
+ export const defaultChecked = {
106
+ name: "defaultChecked, uncontrolled",
107
+ args: {
108
+ handleChange: fn(),
109
+ },
110
+ render: (args) => (<Radio name="test-name" value="test-value" defaultChecked onChange={args.handleChange}>
111
+ Content
112
+ </Radio>),
113
+ play: async ({ canvas, args }) => {
114
+ const input = canvas.getByRole("radio");
115
+ expect(input).toBeChecked();
116
+ },
117
+ };
118
+ export const defaultCheckedFalse = {
119
+ name: "defaultChecked false, uncontrolled",
120
+ args: {
121
+ handleChange: fn(),
122
+ },
123
+ render: (args) => (<Radio name="test-name" value="test-value" onChange={args.handleChange}>
124
+ Content
125
+ </Radio>),
126
+ play: async ({ canvas, args }) => {
127
+ const input = canvas.getByRole("radio");
128
+ expect(input).not.toBeChecked();
129
+ await userEvent.click(input);
130
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
131
+ expect(args.handleChange).toHaveBeenCalledWith({
132
+ name: "test-name",
133
+ value: "test-value",
134
+ checked: true,
135
+ event: expect.objectContaining({ target: input }),
136
+ });
137
+ expect(input).toBeChecked();
138
+ },
139
+ };
140
+ export const disabled = {
141
+ name: "disabled",
142
+ render: () => (<Radio name="test-name" value="test-value" disabled>
143
+ Content
144
+ </Radio>),
145
+ play: async ({ canvas }) => {
146
+ const input = canvas.getByRole("radio");
147
+ expect(input).toBeDisabled();
148
+ },
149
+ };
150
+ export const className = {
151
+ name: "className, attributes",
152
+ render: () => (<div data-testid="root">
153
+ <Radio className="test-classname" attributes={{ id: "test-id" }} value="value">
154
+ Content
78
155
  </Radio>
79
- </Example.Item>
80
- </Example>);
156
+ </div>),
157
+ play: async ({ canvas }) => {
158
+ const root = canvas.getByTestId("root").firstChild;
159
+ expect(root).toHaveClass("test-classname");
160
+ expect(root).toHaveAttribute("id", "test-id");
161
+ },
162
+ };
@@ -1,3 +1,5 @@
1
+ import { StoryObj } from "@storybook/react-vite";
2
+ import { fn } from "storybook/test";
1
3
  declare const _default: {
2
4
  title: string;
3
5
  component: import("react").FC<import("./..").RadioGroupProps>;
@@ -8,5 +10,10 @@ declare const _default: {
8
10
  };
9
11
  };
10
12
  export default _default;
11
- export declare const selection: () => import("react").JSX.Element;
12
- export declare const disabled: () => import("react").JSX.Element;
13
+ export declare const value: StoryObj<{
14
+ handleChange: ReturnType<typeof fn>;
15
+ }>;
16
+ export declare const defaultValue: StoryObj<{
17
+ handleChange: ReturnType<typeof fn>;
18
+ }>;
19
+ export declare const disabled: StoryObj;
@@ -1,7 +1,6 @@
1
- import { Example } from "../../../utilities/storybook/index.js";
2
- import View from "../../View/index.js";
3
1
  import RadioGroup from "../index.js";
4
2
  import Radio from "../../Radio/index.js";
3
+ import { expect, fn, userEvent } from "storybook/test";
5
4
  export default {
6
5
  title: "Components/RadioGroup",
7
6
  component: RadioGroup,
@@ -11,41 +10,68 @@ export default {
11
10
  },
12
11
  },
13
12
  };
14
- export const selection = () => (<Example>
15
- <Example.Item title="unselected">
16
- <RadioGroup name="unselected">
17
- <View gap={3}>
18
- <Radio value="dog">Radio 1</Radio>
19
- <Radio value="cat">Radio 2</Radio>
20
- </View>
21
- </RadioGroup>
22
- </Example.Item>
13
+ export const value = {
14
+ name: "value, controlled",
15
+ args: {
16
+ handleChange: fn(),
17
+ },
18
+ render: (args) => (<RadioGroup name="test-name" value="1" onChange={args.handleChange}>
19
+ {/* checked should be ignored */}
20
+ <Radio value="1" checked={false}>
21
+ Content
22
+ </Radio>
23
23
 
24
- <Example.Item title="checked, uncontrolled">
25
- <RadioGroup name="uncontrolled" defaultValue={"dog"}>
26
- <View gap={3}>
27
- <Radio value="dog">Radio 1</Radio>
28
- <Radio value="cat">Radio 2</Radio>
29
- </View>
30
- </RadioGroup>
31
- </Example.Item>
24
+ <Radio value="2">Content 2</Radio>
25
+ </RadioGroup>),
26
+ play: async ({ canvas, args }) => {
27
+ const inputs = canvas.getAllByRole("radio");
28
+ expect(inputs[0]).toBeChecked();
29
+ await userEvent.click(inputs[1]);
30
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
31
+ expect(args.handleChange).toHaveBeenCalledWith({
32
+ name: "test-name",
33
+ value: "2",
34
+ event: expect.objectContaining({ target: inputs[1] }),
35
+ });
36
+ // Still checked because it's controlled
37
+ expect(inputs[0]).toBeChecked();
38
+ expect(inputs[1]).not.toBeChecked();
39
+ },
40
+ };
41
+ export const defaultValue = {
42
+ name: "defaultValue, uncontrolled",
43
+ args: {
44
+ handleChange: fn(),
45
+ },
46
+ render: (args) => (<RadioGroup name="test-name" defaultValue="1" onChange={args.handleChange}>
47
+ {/* checked should be ignored */}
48
+ <Radio value="1" checked={false}>
49
+ Content
50
+ </Radio>
32
51
 
33
- <Example.Item title="checked, controlled">
34
- <RadioGroup name="controlled" value={"dog"}>
35
- <View gap={3}>
36
- <Radio value="dog">Radio 1</Radio>
37
- <Radio value="cat">Radio 2</Radio>
38
- </View>
39
- </RadioGroup>
40
- </Example.Item>
41
- </Example>);
42
- export const disabled = () => (<Example>
43
- <Example.Item title="disabled">
44
- <RadioGroup name="disabled" disabled>
45
- <View gap={3}>
46
- <Radio value="dog">Dog</Radio>
47
- <Radio value="cat">Cat</Radio>
48
- </View>
49
- </RadioGroup>
50
- </Example.Item>
51
- </Example>);
52
+ <Radio value="2">Content 2</Radio>
53
+ </RadioGroup>),
54
+ play: async ({ canvas, args }) => {
55
+ const inputs = canvas.getAllByRole("radio");
56
+ expect(inputs[0]).toBeChecked();
57
+ await userEvent.click(inputs[1]);
58
+ expect(args.handleChange).toHaveBeenCalledTimes(1);
59
+ expect(args.handleChange).toHaveBeenCalledWith({
60
+ name: "test-name",
61
+ value: "2",
62
+ event: expect.objectContaining({ target: inputs[1] }),
63
+ });
64
+ expect(inputs[0]).not.toBeChecked();
65
+ expect(inputs[1]).toBeChecked();
66
+ },
67
+ };
68
+ export const disabled = {
69
+ name: "disabled",
70
+ render: () => (<RadioGroup name="test-name" disabled>
71
+ <Radio value="test-value">Content</Radio>
72
+ </RadioGroup>),
73
+ play: async ({ canvas }) => {
74
+ const input = canvas.getByRole("radio");
75
+ expect(input).toBeDisabled();
76
+ },
77
+ };
@@ -1 +1 @@
1
- @layer rs.reset{[data-rs-theme]{--rs-radius-circular:9999px;--rs-shadow-border-faded:0px 0px 0px 1px var(--rs-color-border-neutral-faded)}[data-rs-theme] blockquote,[data-rs-theme] body,[data-rs-theme] dd,[data-rs-theme] dl,[data-rs-theme] figcaption,[data-rs-theme] figure,[data-rs-theme] h1,[data-rs-theme] h2,[data-rs-theme] h3,[data-rs-theme] h4,[data-rs-theme] h5,[data-rs-theme] h6,[data-rs-theme] li,[data-rs-theme] ol,[data-rs-theme] p,[data-rs-theme] ul{margin:0;padding:0}[data-rs-theme] ol[class],[data-rs-theme] ul[class]{list-style:none}[data-rs-theme] textarea{resize:vertical}[data-rs-theme] table{border-collapse:collapse;border-spacing:0}[data-rs-theme] fieldset{border:0;margin:0;padding:0}[data-rs-theme] img{display:block;max-width:100%}[data-rs-theme] button,[data-rs-theme] input,[data-rs-theme] select,[data-rs-theme] textarea{font:inherit}[data-rs-theme] option{background:var(--rs-color-background-elevation-base)}[data-rs-theme] label{cursor:pointer}[data-rs-theme] input::placeholder,[data-rs-theme] textarea::placeholder{color:var(--rs-color-foreground-disabled)}html[data-rs-theme]{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}[data-rs-theme] *{box-sizing:border-box}[data-rs-theme] body,html[data-rs-theme]{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);min-height:100vh;scroll-behavior:smooth}}[data-rs-theme] body,[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);letter-spacing:var(--rs-letter-spacing-body-3);line-height:var(--rs-line-height-body-3)}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
1
+ @layer rs.reset{[data-rs-theme] blockquote,[data-rs-theme] body,[data-rs-theme] dd,[data-rs-theme] dl,[data-rs-theme] figcaption,[data-rs-theme] figure,[data-rs-theme] h1,[data-rs-theme] h2,[data-rs-theme] h3,[data-rs-theme] h4,[data-rs-theme] h5,[data-rs-theme] h6,[data-rs-theme] li,[data-rs-theme] ol,[data-rs-theme] p,[data-rs-theme] ul{margin:0;padding:0}[data-rs-theme] ol[class],[data-rs-theme] ul[class]{list-style:none}[data-rs-theme] textarea{resize:vertical}[data-rs-theme] table{border-collapse:collapse;border-spacing:0}[data-rs-theme] fieldset{border:0;margin:0;padding:0}[data-rs-theme] img{display:block;max-width:100%}[data-rs-theme] button,[data-rs-theme] input,[data-rs-theme] select,[data-rs-theme] textarea{font:inherit}[data-rs-theme] option{background:var(--rs-color-background-elevation-base)}[data-rs-theme] label{cursor:pointer}[data-rs-theme] input::placeholder,[data-rs-theme] textarea::placeholder{color:var(--rs-color-foreground-disabled)}html[data-rs-theme]{-webkit-text-size-adjust:100%;-webkit-font-smoothing:antialiased;font-size:100%;text-rendering:optimizelegibility;touch-action:manipulation}[data-rs-theme] *{box-sizing:border-box}[data-rs-theme] body,html[data-rs-theme]{background:var(--rs-color-background-page);color:var(--rs-color-foreground-neutral);min-height:100vh;scroll-behavior:smooth}}[data-rs-theme] body,[data-rs-theme]:not(html){font-family:var(--rs-font-family-body);font-size:var(--rs-font-size-body-3);font-weight:var(--rs-font-weight-regular);letter-spacing:var(--rs-letter-spacing-body-3);line-height:var(--rs-line-height-body-3)}[data-rs-color-mode=light]{color-scheme:light}[data-rs-color-mode=dark]{color-scheme:dark}@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}}[data-rs-no-transition] *,[data-rs-no-transition] :after,[data-rs-no-transition] :before{transition:none!important}
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import React from "react";
4
- import { classNames } from "../../utilities/props.js";
4
+ import { classNames, setComponentChildId, isMatchingComponentChildId } from "../../utilities/props.js";
5
5
  import View from "../View/index.js";
6
6
  import ResizableHandle, { ResizableHandleContext } from "./ResizableHandle.js";
7
7
  import s from "./Resizable.module.css";
@@ -113,10 +113,10 @@ const Resizable = (props) => {
113
113
  }, [horizontal]);
114
114
  const output = React.Children.map(children, (child) => {
115
115
  const isComponent = React.isValidElement(child);
116
- if (isComponent && child.props && child.type !== Resizable.Item) {
116
+ if (isComponent && child.props && !isMatchingComponentChildId(child, "Resizable.Item")) {
117
117
  return (_jsx(ResizableHandleContext.Provider, { value: { containerRef, index: currentHandleIndex++, onDrag, direction }, children: child }));
118
118
  }
119
- if (isComponent && child.props && child.type === Resizable.Item) {
119
+ if (isComponent && child.props && isMatchingComponentChildId(child, "Resizable.Item")) {
120
120
  const index = currentHandleIndex;
121
121
  return (_jsx(PrivateResizableItem, { ...child.props, index: currentItemIndex++, ref: (el) => {
122
122
  itemsRef.current[index] = { el, props: child.props };
@@ -127,6 +127,7 @@ const Resizable = (props) => {
127
127
  return (_jsx(View, { attributes: { ...attributes, ref: containerRef }, className: rootClassNames, height: height, direction: direction, align: "stretch", gap: gap, children: output }));
128
128
  };
129
129
  Resizable.Item = () => null;
130
+ setComponentChildId(Resizable.Item, "Resizable.Item");
130
131
  Resizable.Handle = ResizableHandle;
131
132
  Resizable.displayName = "Resizable";
132
133
  export default Resizable;
@@ -1,3 +1,4 @@
1
+ import { StoryObj } from "@storybook/react-vite";
1
2
  declare const _default: {
2
3
  title: string;
3
4
  component: import("react").FC<import("./..").ScrimProps>;
@@ -8,5 +9,12 @@ declare const _default: {
8
9
  };
9
10
  };
10
11
  export default _default;
11
- export declare const position: () => import("react").JSX.Element;
12
- export declare const composition: () => import("react").JSX.Element;
12
+ export declare const position: {
13
+ name: string;
14
+ render: () => import("react").JSX.Element;
15
+ };
16
+ export declare const className: StoryObj;
17
+ export declare const composition: {
18
+ name: string;
19
+ render: () => import("react").JSX.Element;
20
+ };
@@ -1,5 +1,6 @@
1
1
  import { Example, Placeholder } from "../../../utilities/storybook/index.js";
2
2
  import Scrim from "../index.js";
3
+ import { expect } from "storybook/test";
3
4
  export default {
4
5
  title: "Components/Scrim",
5
6
  component: Scrim,
@@ -9,39 +10,58 @@ export default {
9
10
  },
10
11
  },
11
12
  };
12
- export const position = () => (<Example>
13
- <Example.Item title="position: center">
14
- <Scrim backgroundSlot={<Placeholder h={200}/>}>Scrim</Scrim>
15
- </Example.Item>
13
+ export const position = {
14
+ name: "position",
15
+ render: () => (<Example>
16
+ <Example.Item title="position: center">
17
+ <Scrim backgroundSlot={<Placeholder h={200}/>}>Scrim</Scrim>
18
+ </Example.Item>
16
19
 
17
- <Example.Item title="position: bottom">
18
- <Scrim position="bottom" backgroundSlot={<Placeholder h={200}/>}>
19
- Scrim
20
- </Scrim>
21
- </Example.Item>
20
+ <Example.Item title="position: bottom">
21
+ <Scrim position="bottom" backgroundSlot={<Placeholder h={200}/>}>
22
+ Scrim
23
+ </Scrim>
24
+ </Example.Item>
22
25
 
23
- <Example.Item title="position: top">
24
- <Scrim position="top" backgroundSlot={<Placeholder h={200}/>}>
25
- Scrim
26
- </Scrim>
27
- </Example.Item>
26
+ <Example.Item title="position: top">
27
+ <Scrim position="top" backgroundSlot={<Placeholder h={200}/>}>
28
+ Scrim
29
+ </Scrim>
30
+ </Example.Item>
28
31
 
29
- <Example.Item title="position: start">
30
- <Scrim position="start" backgroundSlot={<Placeholder h={200}/>}>
31
- Scrim
32
- </Scrim>
33
- </Example.Item>
32
+ <Example.Item title="position: start">
33
+ <Scrim position="start" backgroundSlot={<Placeholder h={200}/>}>
34
+ Scrim
35
+ </Scrim>
36
+ </Example.Item>
34
37
 
35
- <Example.Item title="position: end">
36
- <Scrim position="end" backgroundSlot={<Placeholder h={200}/>}>
37
- Scrim
38
+ <Example.Item title="position: end">
39
+ <Scrim position="end" backgroundSlot={<Placeholder h={200}/>}>
40
+ Scrim
41
+ </Scrim>
42
+ </Example.Item>
43
+ </Example>),
44
+ };
45
+ export const className = {
46
+ name: "className, attributes",
47
+ render: () => (<div data-testid="root">
48
+ <Scrim className="test-classname" attributes={{ id: "test-id" }}>
49
+ Content
38
50
  </Scrim>
39
- </Example.Item>
40
- </Example>);
41
- export const composition = () => (<Example>
42
- <Example.Item title="without backgroundSlot, size is based on the parent component">
43
- <div style={{ height: 300, position: "relative" }}>
44
- <Scrim>Text</Scrim>
45
- </div>
46
- </Example.Item>
47
- </Example>);
51
+ </div>),
52
+ play: async ({ canvas }) => {
53
+ const root = canvas.getByTestId("root").firstChild;
54
+ expect(root).toHaveClass("test-classname");
55
+ expect(root).toHaveAttribute("id", "test-id");
56
+ },
57
+ };
58
+ export const composition = {
59
+ name: "test: composition",
60
+ render: () => (<Example>
61
+ <Example.Item title="without backgroundSlot, size is based on the parent component">
62
+ <div style={{ height: 300, position: "relative" }}>
63
+ <Scrim>Text</Scrim>
64
+ </div>
65
+ </Example.Item>
66
+ </Example>),
67
+ };
@@ -1 +1 @@
1
- .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){box-shadow:var(--rs-focus-shadow)}.scrollable{height:100%;outline:none;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:var(--rs-radius-circular);content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
1
+ .root{--rs-scroll-area-thumb-size:calc(var(--rs-unit-x1) * 1.5);--rs-scroll-area-thumb-offset:calc(var(--rs-unit-x1) / 2);height:100%;overflow:hidden;position:relative}[data-rs-keyboard] .root:has(.scrollable:focus){box-shadow:var(--rs-shadow-focus)}.scrollable{height:100%;outline:none;overflow:auto;position:relative;scrollbar-width:none;-webkit-overflow-scrolling:touch}.scrollable::-webkit-scrollbar{display:none;height:0;width:0}.content{display:inline-block;min-height:100%;min-width:100%;vertical-align:top}.scrollbar{box-sizing:initial;padding:var(--rs-scroll-area-thumb-offset);position:absolute}.thumb{height:100%;position:relative;width:100%}.thumb:before{background:var(--rs-color-foreground-neutral);border-radius:var(--rs-radius-circular);content:"";display:block;opacity:0;position:absolute;transition:opacity var(--rs-duration-fast) var(--rs-easing-standard)}.--scrollbar-y{inset-block:0;inset-inline-end:0;width:var(--rs-scroll-area-thumb-size)}.--scrollbar-y .thumb:before{height:calc(var(--rs-scroll-area-ratio) * 100%);inset-block-start:calc(var(--rs-scroll-area-position) * 100%);width:100%}.--scrollbar-x{height:var(--rs-scroll-area-thumb-size);inset-block-end:0;inset-inline:0}.--scrollbar-x .thumb:before{height:100%;inset-inline-start:calc(var(--rs-scroll-area-position) * 100%);width:calc(var(--rs-scroll-area-ratio) * 100%)}.--scrollbar-y:not(:last-child){inset-block-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--scrollbar-y~.--scrollbar-x{inset-inline-end:calc(var(--rs-scroll-area-thumb-size) + var(--rs-scroll-area-thumb-offset) * 2)}.--display-hover:hover>.scrollbar .thumb:before,.--display-visible .thumb:before{opacity:.2}.--display-hover:hover .--scrollbar-dragging .thumb:before,.--scrollbar-dragging .thumb:before,.scrollbar:hover .thumb:before{opacity:.32}
@@ -1,4 +1,11 @@
1
1
  import React from "react";
2
2
  import type * as T from "./Select.types";
3
- declare const Select: React.FC<T.Props>;
3
+ import SelectOption from "./SelectOption";
4
+ import SelectOptionGroup from "./SelectOptionGroup";
5
+ import SelectCustom from "./SelectCustom";
6
+ declare const Select: React.FC<T.NativeProps> & {
7
+ Custom: typeof SelectCustom;
8
+ Option: typeof SelectOption;
9
+ OptionGroup: typeof SelectOptionGroup;
10
+ };
4
11
  export default Select;
@@ -1,53 +1,27 @@
1
- "use client";
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import React from "react";
4
- import Icon from "../Icon/index.js";
5
- import { useFormControl } from "../FormControl/index.js";
6
- import Actionable from "../Actionable/index.js";
7
- import Text from "../Text/index.js";
8
- import IconArrow from "../../icons/ChevronVertical.js";
9
- import { classNames, responsiveClassNames, responsivePropDependency } from "../../utilities/props.js";
10
- import useElementId from "../../hooks/useElementId.js";
11
- import s from "./Select.module.css";
3
+ import SelectNative from "./SelectNative.js";
4
+ import SelectRoot from "./SelectRoot.js";
5
+ import SelectTrigger from "./SelectTrigger.js";
6
+ import SelectOption from "./SelectOption.js";
7
+ import SelectOptionGroup from "./SelectOptionGroup.js";
8
+ import SelectCustom from "./SelectCustom.js";
12
9
  const Select = (props) => {
13
- const { onChange, onClick, onFocus, onBlur, name, value, defaultValue, placeholder, options, children, icon, startSlot, size = "medium", variant = "outline", className, attributes, } = props;
14
- const [empty, setEmpty] = React.useState(value === undefined ? !defaultValue : !value);
15
- const formControl = useFormControl();
16
- const id = useElementId(props.id);
17
- const inputId = formControl?.attributes?.id || props.inputAttributes?.id || id;
18
- const disabled = formControl?.disabled || props.disabled;
19
- const hasError = formControl?.hasError || props.hasError;
20
- const inputAttributes = { ...props.inputAttributes, ...formControl?.attributes };
21
- const rootClassName = classNames(s.root, className, size && responsiveClassNames(s, "--size", size), hasError && s["--status-error"], disabled && s["--disabled"], empty && options && s["--placeholder"], variant && s[`--variant-${variant}`]);
22
- const handleChange = (event) => {
23
- const nextValue = event.target.value;
24
- // Uncontrolled placeholder
25
- if (value === undefined)
26
- setEmpty(!nextValue);
27
- if (!onChange)
28
- return;
29
- onChange({ name, value: nextValue, event });
30
- };
31
- // Controlled placeholder
32
- React.useEffect(() => {
33
- if (value === undefined)
34
- return;
35
- setEmpty(!value);
36
- }, [value]);
37
- const startContent = (startSlot || icon) && (_jsx("div", { className: s.slot, children: icon ? (_jsx(Icon, { size: responsivePropDependency(size, (size) => {
38
- if (size === "large")
39
- return 5;
40
- if (size === "xlarge")
41
- return 6;
42
- return 4;
43
- }), svg: icon })) : (startSlot) }));
44
- return (_jsxs("div", { ...attributes, className: rootClassName, children: [options ? (_jsxs(_Fragment, { children: [startContent, _jsxs("select", { ...inputAttributes, onFocus: (onFocus || inputAttributes?.onFocus), onBlur: (onBlur || inputAttributes?.onBlur), className: s.input, disabled: disabled, name: name, value: value, defaultValue: defaultValue, onChange: handleChange, id: inputId, children: [placeholder && _jsx("option", { value: "", children: placeholder }), options.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value)))] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Actionable, { className: s.input, disabled: disabled, disableFocusRing: true, onClick: onClick, attributes: {
45
- ...inputAttributes,
46
- onFocus: onFocus || inputAttributes?.onFocus,
47
- onBlur: onBlur || inputAttributes?.onBlur,
48
- }, children: [startContent, children ? _jsx(Text, { maxLines: 1, children: children }) : null, placeholder && !children ? _jsx(Text, { color: "neutral-faded", children: placeholder }) : null] }), _jsx("input", { type: "hidden", value: value, name: name })] })), _jsx("div", { className: s.arrow, children: _jsx(Icon, { svg: IconArrow, color: disabled ? "disabled" : "neutral-faded", size: responsivePropDependency(size, (size) => {
49
- return size === "large" || size === "xlarge" ? 5 : 4;
50
- }) }) })] }));
10
+ const { children } = props;
11
+ return (_jsx(SelectRoot, { ...props, children: (props) => {
12
+ const { options } = props;
13
+ const hasOptionChildren = React.Children.toArray(children).some((child) => {
14
+ return React.isValidElement(child) && child.type === "option";
15
+ });
16
+ const hasOptions = Boolean(options || hasOptionChildren);
17
+ if (!hasOptions) {
18
+ return _jsx(SelectTrigger, { ...props, children: children });
19
+ }
20
+ return (_jsxs(SelectNative, { ...props, children: [options?.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))), children] }));
21
+ } }));
51
22
  };
52
23
  Select.displayName = "Select";
24
+ Select.Custom = SelectCustom;
25
+ Select.Option = SelectOption;
26
+ Select.OptionGroup = SelectOptionGroup;
53
27
  export default Select;