@commercetools/nimbus 0.0.1 → 0.0.3

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 (302) hide show
  1. package/dist/index.d.ts +1412 -0
  2. package/dist/index.js +11183 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.umd.cjs +27 -0
  5. package/dist/index.umd.cjs.map +1 -0
  6. package/package.json +33 -6
  7. package/.storybook/apca-check/index.ts +0 -150
  8. package/.storybook/main.ts +0 -64
  9. package/.storybook/preview.tsx +0 -92
  10. package/.storybook/vitest.setup.ts +0 -13
  11. package/docs/architecture-decisions/adr-0001-consumer-component-apis.md +0 -177
  12. package/docs/architecture-decisions/adr-0002-compound-component-extraction.md +0 -82
  13. package/src/components/accordion/accordion-context.tsx +0 -17
  14. package/src/components/accordion/accordion.mdx +0 -172
  15. package/src/components/accordion/accordion.recipe.tsx +0 -98
  16. package/src/components/accordion/accordion.slots.tsx +0 -39
  17. package/src/components/accordion/accordion.stories.tsx +0 -188
  18. package/src/components/accordion/accordion.tsx +0 -16
  19. package/src/components/accordion/accordion.types.tsx +0 -54
  20. package/src/components/accordion/components/accordion-content.tsx +0 -28
  21. package/src/components/accordion/components/accordion-group.tsx +0 -27
  22. package/src/components/accordion/components/accordion-header.tsx +0 -63
  23. package/src/components/accordion/components/accordion-item.tsx +0 -87
  24. package/src/components/accordion/index.ts +0 -2
  25. package/src/components/alert/alert.mdx +0 -92
  26. package/src/components/alert/alert.recipe.tsx +0 -65
  27. package/src/components/alert/alert.slots.tsx +0 -46
  28. package/src/components/alert/alert.stories.tsx +0 -308
  29. package/src/components/alert/alert.tsx +0 -18
  30. package/src/components/alert/alert.types.tsx +0 -70
  31. package/src/components/alert/components/alert.actions.tsx +0 -27
  32. package/src/components/alert/components/alert.description.tsx +0 -27
  33. package/src/components/alert/components/alert.dismiss-button.tsx +0 -41
  34. package/src/components/alert/components/alert.root.tsx +0 -92
  35. package/src/components/alert/components/alert.title.tsx +0 -29
  36. package/src/components/alert/index.ts +0 -2
  37. package/src/components/avatar/avatar.mdx +0 -80
  38. package/src/components/avatar/avatar.recipe.tsx +0 -36
  39. package/src/components/avatar/avatar.slots.tsx +0 -16
  40. package/src/components/avatar/avatar.stories.tsx +0 -136
  41. package/src/components/avatar/avatar.tsx +0 -34
  42. package/src/components/avatar/avatar.types.ts +0 -33
  43. package/src/components/avatar/index.ts +0 -2
  44. package/src/components/badge/badge.mdx +0 -91
  45. package/src/components/badge/badge.recipe.tsx +0 -72
  46. package/src/components/badge/badge.slots.tsx +0 -8
  47. package/src/components/badge/badge.stories.tsx +0 -124
  48. package/src/components/badge/badge.tsx +0 -35
  49. package/src/components/badge/badge.types.tsx +0 -40
  50. package/src/components/badge/index.ts +0 -2
  51. package/src/components/bleed/bleed.tsx +0 -1
  52. package/src/components/bleed/index.ts +0 -1
  53. package/src/components/box/box.mdx +0 -115
  54. package/src/components/box/box.stories.tsx +0 -71
  55. package/src/components/box/box.tsx +0 -11
  56. package/src/components/box/index.ts +0 -1
  57. package/src/components/button/button.mdx +0 -169
  58. package/src/components/button/button.recipe.ts +0 -185
  59. package/src/components/button/button.slots.tsx +0 -45
  60. package/src/components/button/button.stories.tsx +0 -369
  61. package/src/components/button/button.tsx +0 -37
  62. package/src/components/button/button.types.ts +0 -14
  63. package/src/components/button/index.ts +0 -2
  64. package/src/components/card/card.mdx +0 -92
  65. package/src/components/card/card.recipe.tsx +0 -71
  66. package/src/components/card/card.slots.tsx +0 -50
  67. package/src/components/card/card.stories.tsx +0 -175
  68. package/src/components/card/card.tsx +0 -9
  69. package/src/components/card/card.types.ts +0 -22
  70. package/src/components/card/components/card.content.tsx +0 -29
  71. package/src/components/card/components/card.header.tsx +0 -28
  72. package/src/components/card/components/card.root.tsx +0 -62
  73. package/src/components/card/index.ts +0 -2
  74. package/src/components/checkbox/checkbox.mdx +0 -78
  75. package/src/components/checkbox/checkbox.recipe.tsx +0 -116
  76. package/src/components/checkbox/checkbox.slots.tsx +0 -33
  77. package/src/components/checkbox/checkbox.stories.tsx +0 -200
  78. package/src/components/checkbox/checkbox.tsx +0 -77
  79. package/src/components/checkbox/checkbox.types.tsx +0 -22
  80. package/src/components/checkbox/index.ts +0 -2
  81. package/src/components/code/code.mdx +0 -17
  82. package/src/components/code/code.recipe.ts +0 -63
  83. package/src/components/code/code.tsx +0 -1
  84. package/src/components/code/index.ts +0 -1
  85. package/src/components/dialog/dialog.mdx +0 -20
  86. package/src/components/dialog/dialog.recipe.ts +0 -254
  87. package/src/components/dialog/dialog.tsx +0 -61
  88. package/src/components/dialog/index.ts +0 -1
  89. package/src/components/em/em.mdx +0 -17
  90. package/src/components/em/em.tsx +0 -1
  91. package/src/components/em/index.ts +0 -1
  92. package/src/components/flex/flex.mdx +0 -41
  93. package/src/components/flex/flex.tsx +0 -1
  94. package/src/components/flex/index.ts +0 -1
  95. package/src/components/grid/grid.mdx +0 -156
  96. package/src/components/grid/grid.stories.tsx +0 -151
  97. package/src/components/grid/grid.tsx +0 -29
  98. package/src/components/grid/index.ts +0 -1
  99. package/src/components/heading/heading.mdx +0 -23
  100. package/src/components/heading/heading.recipe.ts +0 -49
  101. package/src/components/heading/heading.tsx +0 -1
  102. package/src/components/heading/index.ts +0 -1
  103. package/src/components/highlight/highlight.mdx +0 -18
  104. package/src/components/highlight/highlight.tsx +0 -1
  105. package/src/components/highlight/index.ts +0 -1
  106. package/src/components/icon-button/icon-button.mdx +0 -98
  107. package/src/components/icon-button/icon-button.stories.tsx +0 -188
  108. package/src/components/icon-button/icon-button.tsx +0 -21
  109. package/src/components/icon-button/icon-button.types.tsx +0 -10
  110. package/src/components/icon-button/index.ts +0 -2
  111. package/src/components/index.ts +0 -33
  112. package/src/components/input/index.ts +0 -1
  113. package/src/components/input/input.mdx +0 -20
  114. package/src/components/input/input.recipe.ts +0 -95
  115. package/src/components/input/input.tsx +0 -1
  116. package/src/components/input-group/index.ts +0 -1
  117. package/src/components/input-group/input-group.mdx +0 -20
  118. package/src/components/input-group/input-group.tsx +0 -44
  119. package/src/components/kbd/index.ts +0 -1
  120. package/src/components/kbd/kbd.mdx +0 -18
  121. package/src/components/kbd/kbd.recipe.ts +0 -57
  122. package/src/components/kbd/kbd.tsx +0 -1
  123. package/src/components/link/index.ts +0 -2
  124. package/src/components/link/link.mdx +0 -77
  125. package/src/components/link/link.recipe.ts +0 -52
  126. package/src/components/link/link.slots.tsx +0 -29
  127. package/src/components/link/link.stories.tsx +0 -204
  128. package/src/components/link/link.tsx +0 -38
  129. package/src/components/link/link.types.tsx +0 -26
  130. package/src/components/list/index.ts +0 -1
  131. package/src/components/list/list.mdx +0 -18
  132. package/src/components/list/list.recipe.ts +0 -68
  133. package/src/components/list/list.tsx +0 -9
  134. package/src/components/loading-spinner/index.ts +0 -2
  135. package/src/components/loading-spinner/loading-spinner.mdx +0 -92
  136. package/src/components/loading-spinner/loading-spinner.recipe.tsx +0 -70
  137. package/src/components/loading-spinner/loading-spinner.slots.tsx +0 -38
  138. package/src/components/loading-spinner/loading-spinner.stories.tsx +0 -97
  139. package/src/components/loading-spinner/loading-spinner.tsx +0 -50
  140. package/src/components/loading-spinner/loading-spinner.types.tsx +0 -21
  141. package/src/components/nimbus-provider/color-mode.tsx +0 -32
  142. package/src/components/nimbus-provider/index.ts +0 -2
  143. package/src/components/nimbus-provider/nimbus-provider.mdx +0 -21
  144. package/src/components/nimbus-provider/nimbus-provider.tsx +0 -51
  145. package/src/components/select/components/select.clear-button.tsx +0 -31
  146. package/src/components/select/components/select.option-group.tsx +0 -48
  147. package/src/components/select/components/select.option.tsx +0 -21
  148. package/src/components/select/components/select.options.tsx +0 -23
  149. package/src/components/select/components/select.root.tsx +0 -81
  150. package/src/components/select/index.ts +0 -2
  151. package/src/components/select/select.mdx +0 -170
  152. package/src/components/select/select.recipe.tsx +0 -216
  153. package/src/components/select/select.slots.tsx +0 -58
  154. package/src/components/select/select.stories.tsx +0 -841
  155. package/src/components/select/select.tsx +0 -18
  156. package/src/components/select/select.types.tsx +0 -37
  157. package/src/components/simple-grid/index.ts +0 -1
  158. package/src/components/simple-grid/simple-grid.mdx +0 -133
  159. package/src/components/simple-grid/simple-grid.stories.tsx +0 -143
  160. package/src/components/simple-grid/simple-grid.tsx +0 -31
  161. package/src/components/stack/index.ts +0 -1
  162. package/src/components/stack/stack.mdx +0 -88
  163. package/src/components/stack/stack.stories.tsx +0 -82
  164. package/src/components/stack/stack.tsx +0 -15
  165. package/src/components/table/index.ts +0 -1
  166. package/src/components/table/table.mdx +0 -23
  167. package/src/components/table/table.recipe.ts +0 -170
  168. package/src/components/table/table.tsx +0 -43
  169. package/src/components/text/index.ts +0 -1
  170. package/src/components/text/text.mdx +0 -244
  171. package/src/components/text/text.tsx +0 -23
  172. package/src/components/text-input/index.ts +0 -2
  173. package/src/components/text-input/text-input.mdx +0 -118
  174. package/src/components/text-input/text-input.recipe.tsx +0 -68
  175. package/src/components/text-input/text-input.slots.tsx +0 -24
  176. package/src/components/text-input/text-input.stories.tsx +0 -282
  177. package/src/components/text-input/text-input.tsx +0 -39
  178. package/src/components/text-input/text-input.types.ts +0 -7
  179. package/src/components/toggle-button-group/components/toggle-button-group.button.tsx +0 -14
  180. package/src/components/toggle-button-group/components/toggle-button-group.root.tsx +0 -15
  181. package/src/components/toggle-button-group/index.ts +0 -2
  182. package/src/components/toggle-button-group/toggle-button-group.mdx +0 -94
  183. package/src/components/toggle-button-group/toggle-button-group.recipe.tsx +0 -64
  184. package/src/components/toggle-button-group/toggle-button-group.slots.tsx +0 -26
  185. package/src/components/toggle-button-group/toggle-button-group.stories.tsx +0 -311
  186. package/src/components/toggle-button-group/toggle-button-group.tsx +0 -12
  187. package/src/components/toggle-button-group/toggle-button-group.types.tsx +0 -62
  188. package/src/components/tooltip/index.ts +0 -4
  189. package/src/components/tooltip/make-element-focusable.stories.tsx +0 -56
  190. package/src/components/tooltip/make-element-focusable.tsx +0 -57
  191. package/src/components/tooltip/tooltip-trigger.stories.tsx +0 -157
  192. package/src/components/tooltip/tooltip-trigger.tsx +0 -15
  193. package/src/components/tooltip/tooltip.mdx +0 -48
  194. package/src/components/tooltip/tooltip.recipe.ts +0 -26
  195. package/src/components/tooltip/tooltip.slots.ts +0 -35
  196. package/src/components/tooltip/tooltip.stories.tsx +0 -139
  197. package/src/components/tooltip/tooltip.tsx +0 -31
  198. package/src/components/tooltip/tooltip.types.ts +0 -44
  199. package/src/components/visually-hidden/index.ts +0 -1
  200. package/src/components/visually-hidden/visually-hidden.mdx +0 -61
  201. package/src/components/visually-hidden/visually-hidden.stories.tsx +0 -124
  202. package/src/components/visually-hidden/visually-hidden.tsx +0 -18
  203. package/src/docs/accessibility.mdx +0 -21
  204. package/src/docs/background.mdx +0 -154
  205. package/src/docs/border.mdx +0 -226
  206. package/src/docs/changelog.mdx +0 -17
  207. package/src/docs/components-layout.mdx +0 -22
  208. package/src/docs/components.mdx +0 -17
  209. package/src/docs/data-display.mdx +0 -23
  210. package/src/docs/display.mdx +0 -55
  211. package/src/docs/effects.mdx +0 -73
  212. package/src/docs/feedback.mdx +0 -22
  213. package/src/docs/filters.mdx +0 -268
  214. package/src/docs/flex-and-grid.mdx +0 -445
  215. package/src/docs/forms.mdx +0 -22
  216. package/src/docs/generated/index.mdx +0 -16
  217. package/src/docs/getting-started.mdx +0 -17
  218. package/src/docs/home.mdx +0 -56
  219. package/src/docs/hooks.mdx +0 -16
  220. package/src/docs/inputs.mdx +0 -21
  221. package/src/docs/installation.mdx +0 -60
  222. package/src/docs/interactivity.mdx +0 -278
  223. package/src/docs/known-issues.mdx +0 -19
  224. package/src/docs/layout.mdx +0 -301
  225. package/src/docs/list.mdx +0 -82
  226. package/src/docs/markdown.mdx +0 -234
  227. package/src/docs/media.mdx +0 -22
  228. package/src/docs/naivgation.mdx +0 -22
  229. package/src/docs/playground.mdx +0 -16
  230. package/src/docs/rfcs-component-structure-rfcs.mdx +0 -17
  231. package/src/docs/rfcs-component-structure.mdx +0 -74
  232. package/src/docs/rfcs-hook-structure.mdx +0 -59
  233. package/src/docs/sizing.mdx +0 -210
  234. package/src/docs/spacing.mdx +0 -193
  235. package/src/docs/style-props-typography.mdx +0 -373
  236. package/src/docs/style-props.mdx +0 -15
  237. package/src/docs/svg.mdx +0 -58
  238. package/src/docs/tables.mdx +0 -95
  239. package/src/docs/toc.mdx +0 -39
  240. package/src/docs/tokens/animations.mdx +0 -68
  241. package/src/docs/tokens/aspect-ratios.mdx +0 -21
  242. package/src/docs/tokens/blurs.mdx +0 -20
  243. package/src/docs/tokens/borders.mdx +0 -25
  244. package/src/docs/tokens/breakpoints.mdx +0 -35
  245. package/src/docs/tokens/colors.mdx +0 -86
  246. package/src/docs/tokens/cursors.mdx +0 -21
  247. package/src/docs/tokens/radii.mdx +0 -23
  248. package/src/docs/tokens/shadows.mdx +0 -21
  249. package/src/docs/tokens/sizes.mdx +0 -54
  250. package/src/docs/tokens/spacing.mdx +0 -35
  251. package/src/docs/tokens/typography.mdx +0 -61
  252. package/src/docs/tokens/z-indices.mdx +0 -23
  253. package/src/docs/tokens-other.mdx +0 -17
  254. package/src/docs/tokens.mdx +0 -16
  255. package/src/docs/transforms.mdx +0 -150
  256. package/src/docs/transitions.mdx +0 -164
  257. package/src/docs/typography.mdx +0 -17
  258. package/src/docs/utilities.mdx +0 -17
  259. package/src/hooks/index.ts +0 -2
  260. package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.mdx +0 -54
  261. package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.ts +0 -1
  262. package/src/hooks/use-hotkeys/use-hotkeys.mdx +0 -48
  263. package/src/hooks/use-hotkeys/use-hotkeys.stories.tsx +0 -69
  264. package/src/hooks/use-hotkeys/use-hotkeys.ts +0 -1
  265. package/src/index.ts +0 -3
  266. package/src/test/utils.tsx +0 -20
  267. package/src/theme/animation-styles.ts +0 -52
  268. package/src/theme/breakpoints.ts +0 -32
  269. package/src/theme/global-css.ts +0 -53
  270. package/src/theme/index.ts +0 -35
  271. package/src/theme/keyframes.ts +0 -192
  272. package/src/theme/layer-styles.ts +0 -12
  273. package/src/theme/recipes/index.ts +0 -21
  274. package/src/theme/semantic-tokens/colors.ts +0 -55
  275. package/src/theme/semantic-tokens/index.ts +0 -9
  276. package/src/theme/semantic-tokens/radii.ts +0 -3
  277. package/src/theme/semantic-tokens/shadows.ts +0 -4
  278. package/src/theme/slot-recipes/index.ts +0 -15
  279. package/src/theme/text-styles.ts +0 -8
  280. package/src/theme/tokens/animations.ts +0 -4
  281. package/src/theme/tokens/aspect-ratios.ts +0 -5
  282. package/src/theme/tokens/blurs.ts +0 -5
  283. package/src/theme/tokens/borders.ts +0 -4
  284. package/src/theme/tokens/colors.ts +0 -8
  285. package/src/theme/tokens/cursor.ts +0 -4
  286. package/src/theme/tokens/durations.ts +0 -4
  287. package/src/theme/tokens/easings.ts +0 -4
  288. package/src/theme/tokens/font-sizes.ts +0 -4
  289. package/src/theme/tokens/font-weights.ts +0 -4
  290. package/src/theme/tokens/fonts.ts +0 -4
  291. package/src/theme/tokens/index.ts +0 -57
  292. package/src/theme/tokens/letter-spacings.ts +0 -24
  293. package/src/theme/tokens/line-heights.ts +0 -4
  294. package/src/theme/tokens/radii.ts +0 -4
  295. package/src/theme/tokens/sizes.ts +0 -120
  296. package/src/theme/tokens/spacing.ts +0 -4
  297. package/src/theme/tokens/z-index.ts +0 -4
  298. package/src/utils/extractStyleProps.ts +0 -26
  299. package/src/utils/fixedForwardRef.ts +0 -17
  300. package/tsconfig.json +0 -38
  301. package/vite.config.ts +0 -54
  302. package/vitest.config.ts +0 -50
@@ -1,81 +0,0 @@
1
- import { forwardRef } from "react";
2
- import { chakra, useSlotRecipe } from "@chakra-ui/react";
3
-
4
- import {
5
- KeyboardArrowDown as DropdownIndicatorIcon,
6
- Loop as SpinnerIcon,
7
- } from "@commercetools/nimbus-icons";
8
-
9
- import { Flex, Box } from "@/components";
10
- import {
11
- Button as RaButton,
12
- Popover as RaPopover,
13
- Select as RaSelect,
14
- SelectValue as RaSelectValue,
15
- } from "react-aria-components";
16
- import {
17
- SelectRootSlot,
18
- SelectTriggerSlot,
19
- SelectTriggerLabelSlot,
20
- } from "./../select.slots";
21
- import { SelectClearButton } from "./select.clear-button";
22
- import { type SelectRootProps } from "./../select.types";
23
- import { selectSlotRecipe } from "../select.recipe";
24
- import { extractStyleProps } from "@/utils/extractStyleProps";
25
-
26
- export const SelectRoot = forwardRef<HTMLDivElement, SelectRootProps>(
27
- ({ children, isLoading, isDisabled, ...props }, ref) => {
28
- const recipe = useSlotRecipe({ recipe: selectSlotRecipe });
29
- const [recipeProps, restRecipeProps] = recipe.splitVariantProps(props);
30
- const [styleProps, restProps] = extractStyleProps(restRecipeProps);
31
-
32
- const raSelectProps = {
33
- ...restProps,
34
- isDisabled: isLoading || isDisabled,
35
- };
36
-
37
- return (
38
- <SelectRootSlot asChild ref={ref} {...recipeProps} {...styleProps}>
39
- <RaSelect {...raSelectProps}>
40
- <chakra.div position="relative">
41
- <SelectTriggerSlot zIndex={0} asChild>
42
- <RaButton>
43
- <SelectTriggerLabelSlot asChild>
44
- <RaSelectValue />
45
- </SelectTriggerLabelSlot>
46
- </RaButton>
47
- </SelectTriggerSlot>
48
- <Flex
49
- position="absolute"
50
- top="0"
51
- bottom="0"
52
- zIndex={1}
53
- right="400"
54
- pointerEvents="none"
55
- >
56
- <Flex width="600" my="auto">
57
- <SelectClearButton />
58
- </Flex>
59
-
60
- <Flex my="auto" w="600" h="600" pointerEvents="none">
61
- <Box color="neutral.9" asChild m="auto" w="400" h="400">
62
- {isLoading ? (
63
- <Box asChild animation="spin" animationDuration="slowest">
64
- <SpinnerIcon />
65
- </Box>
66
- ) : (
67
- <DropdownIndicatorIcon />
68
- )}
69
- </Box>
70
- </Flex>
71
- </Flex>
72
- </chakra.div>
73
-
74
- <RaPopover>{children}</RaPopover>
75
- </RaSelect>
76
- </SelectRootSlot>
77
- );
78
- }
79
- );
80
-
81
- SelectRoot.displayName = "Select.Root";
@@ -1,2 +0,0 @@
1
- export * from "./select";
2
- export * from "./select.types";
@@ -1,170 +0,0 @@
1
- ---
2
- id: Components-Select
3
- title: Select
4
- description:
5
- displays a collapsible list of options and allows a user to select one of
6
- them.
7
- documentState: InitialDraft
8
- order: 999
9
- menu:
10
- - Components
11
- - Inputs
12
- - Select
13
- tags:
14
- - component
15
- ---
16
-
17
- # Select
18
-
19
- A select displays a collapsible list of options and allows a user to select one
20
- of them.
21
-
22
- ## Basic Usage
23
-
24
- ```jsx-live
25
- const App = () => (
26
- <Select.Root aria-label="Select a fruit" data-testid="select">
27
- <Select.Options>
28
- <Select.Option>Apples</Select.Option>
29
- <Select.Option>Bananas</Select.Option>
30
- <Select.Option>Oranges</Select.Option>
31
- <Select.Option>Cherries</Select.Option>
32
- </Select.Options>
33
- </Select.Root>
34
- )
35
- ```
36
-
37
- ### Sizes
38
-
39
- Available sizes.
40
-
41
- ```jsx-live
42
- const App = () => {
43
-
44
- const sizes = ['md', 'sm'];
45
-
46
- return (
47
- <Stack direction="horizontal" alignItems="center">
48
- {sizes.map(size => (
49
- <Select.Root size={size} key={size} aria-label="Select a fruit" data-testid="select">
50
- <Select.Options>
51
- <Select.Option>Apples</Select.Option>
52
- <Select.Option>Bananas</Select.Option>
53
- <Select.Option>Oranges</Select.Option>
54
- <Select.Option>Cherries</Select.Option>
55
- </Select.Options>
56
- </Select.Root>
57
- ))}
58
- </Stack>
59
- )
60
- }
61
- ```
62
-
63
- ### Variants
64
-
65
- Available variants.
66
-
67
- ```jsx-live
68
- const App = () => {
69
-
70
- const variants = ['outline', 'ghost'];
71
-
72
- return (
73
- <Stack direction="horizontal" alignItems="center">
74
- {variants.map(variant => (
75
- <Select.Root variant={variant} key={variant} aria-label="Select a fruit" data-testid="select">
76
- <Select.Options>
77
- <Select.Option>Apples</Select.Option>
78
- <Select.Option>Bananas</Select.Option>
79
- <Select.Option>Oranges</Select.Option>
80
- <Select.Option>Cherries</Select.Option>
81
- </Select.Options>
82
- </Select.Root>
83
- ))}
84
- </Stack>
85
- )
86
- }
87
- ```
88
-
89
- ### Label + Descriptions
90
-
91
- You can add descriptions to the labels.
92
-
93
- ```jsx-live
94
- const App = () => {
95
- return (
96
- <Select.Root aria-label="Select some fruit(s)" data-testid="select">
97
- <Select.Options>
98
- {/** Variant A - plain html-tags with slot property */}
99
- <Select.Option textValue="Apple">
100
- <p slot="label">Apple</p>
101
- <p slot="description">A classic and versatile fruit.</p>
102
- </Select.Option>
103
- {/** Variant B - text component with slot property */}
104
- <Select.Option textValue="Banana">
105
- <Text slot="label">Banana</Text>
106
- <Text slot="description">A good source of potassium.</Text>
107
- </Select.Option>
108
- <Select.Option textValue="Oranges">
109
- <Text slot="label">Oranges</Text>
110
- <Text slot="description">Rich in vitamin C.</Text>
111
- </Select.Option>
112
- <Select.Option textValue="Strawberries">
113
- <Text slot="label">Strawberries</Text>
114
- <Text slot="description">Sweet and full of antioxidants.</Text>
115
- </Select.Option>
116
- <Select.Option textValue="Grapes">
117
- <Text slot="label">Grapes</Text>
118
- <Text slot="description">
119
- Available in various colors and flavors.
120
- </Text>
121
- </Select.Option>
122
- </Select.Options>
123
- </Select.Root>
124
- )
125
- }
126
- ```
127
-
128
- ### Controlled usage
129
-
130
- ```jsx-live
131
- const App = () => {
132
- const [animal, setAnimal] = useState<Key>("Bison");
133
-
134
- const options = [
135
- { id: 1, name: "Koala" },
136
- { id: 2, name: "Kangaroo" },
137
- { id: 3, name: "Platypus" },
138
- { id: 4, name: "Bald Eagle" },
139
- { id: 5, name: "Bison" },
140
- { id: 6, name: "Skunk" },
141
- ];
142
-
143
-
144
- return (
145
- <Box>
146
- <Box mb="400">Selection: {animal}</Box>
147
- <Select.Root
148
- defaultSelectedKey={animal}
149
- selectedKey={animal}
150
- onSelectionChange={setAnimal}
151
- aria-label="Select your new pet"
152
- data-testid="select"
153
- >
154
- <Select.Options items={options}>
155
- {(item) => (
156
- <Select.Option id={item.name}>{item.name}</Select.Option>
157
- )}
158
- </Select.Options>
159
- </Select.Root>
160
- </Box>
161
- );
162
- }
163
- ```
164
-
165
- ## Props
166
-
167
- <PropTables
168
- root="Select"
169
- ids="SelectRoot, SelectOptions, SelectOptionGroup, SelectOption"
170
- />
@@ -1,216 +0,0 @@
1
- import { defineSlotRecipe } from "@chakra-ui/react";
2
-
3
- /**
4
- * Recipe configuration for the Select component.
5
- * Defines the styling variants and base styles using Chakra UI's recipe system.
6
- */
7
- export const selectSlotRecipe = defineSlotRecipe({
8
- slots: [
9
- "root",
10
- "trigger",
11
- "triggerLabel",
12
- "options",
13
- "optionGroup",
14
- "option",
15
- ],
16
- // Unique class name prefix for the component
17
- className: "nimbus-select",
18
-
19
- // Base styles applied to all instances of the component
20
- base: {
21
- // RA <Select>
22
- root: {
23
- colorPalette: "primary",
24
- display: "inline-block",
25
- position: "relative",
26
- maxWidth: "100%",
27
- borderRadius: "200",
28
- // [data-focused]
29
- // [data-focus-visible]
30
- // [data-open]
31
- // [data-invalid]
32
- // [data-required]
33
- "&[data-disabled]": {
34
- layerStyle: "disabled",
35
- pointerEvents: "none",
36
- },
37
- },
38
- trigger: {
39
- cursor: "button",
40
- display: "inline-flex",
41
- focusRing: "outside",
42
- alignItems: "flex-start",
43
- borderRadius: "200",
44
- color: "neutral.12",
45
- width: "100%",
46
- userSelect: "none",
47
- boxShadow: "inset 0 0 0 var(--border-width) var(--border-color)",
48
-
49
- "& span": {
50
- display: "inline-block",
51
- my: "auto",
52
- },
53
- '& [slot="description"]': {
54
- display: "none",
55
- },
56
-
57
- "[data-invalid] &": {
58
- "--border-width": "sizes.50",
59
- "--border-color": "colors.error.7",
60
- },
61
-
62
- // [data-hovered]
63
- // [data-pressed]
64
- // [data-focused]
65
- // [data-focus-visible]
66
- // [data-disabled]
67
- // [data-pending]
68
- },
69
- triggerLabel: {
70
- // *Magic*
71
- // the trigger-label defines the overall width of the select,
72
- // but since we position 2 buttons/icons next to it, we need to account for
73
- // their width as well and reserve some space for them
74
- // = label-button-gap + button-size + icon-size
75
- // = 8px + 24px + 24px
76
- // = 56px * 25 = 1400 token
77
- "--button-safespace": "sizes.1400",
78
- color: "neutral.12",
79
- textAlign: "left",
80
- marginRight: "var(--button-safespace)",
81
- maxWidth: "100%",
82
- whiteSpace: "nowrap",
83
- overflow: "hidden",
84
- textOverflow: "ellipsis",
85
-
86
- "&[data-placeholder]": {
87
- opacity: 0.5,
88
- },
89
- "[data-invalid] &": {
90
- color: "error.11",
91
- },
92
- },
93
- // Popover
94
- options: {
95
- "--scrollbar-color": "colors.neutral.8",
96
- "--scrollbar-bg": "colors.neutral.3",
97
-
98
- bg: "bg",
99
- borderRadius: "200",
100
- boxShadow: "5",
101
- minWidth: "var(--trigger-width)",
102
- p: "200",
103
- focusRing: "outside",
104
- maxHeight: "40svh",
105
- overflowY: "auto",
106
- scrollbarWidth: "thin",
107
- scrollbarColor: "var(--scrollbar-color) var(--scrollbar-bg)",
108
- // [data-trigger="..."]
109
- // [data-placement="left | right | top | bottom"]
110
- // [data-entering]
111
- // [data-exiting]
112
- },
113
- // Option group header
114
- optionGroup: {
115
- textStyle: "xs",
116
- color: "neutral.11",
117
- fontWeight: "600",
118
- lineHeight: "350",
119
- letterSpacing: "25",
120
- textTransform: "uppercase",
121
- p: "200",
122
- borderBottom: "solid-25",
123
- borderColor: "neutral.6",
124
- mx: "-200",
125
- mt: "200",
126
- mb: "300",
127
- },
128
- // ListBoxItem
129
- option: {
130
- focusRing: "outside",
131
- cursor: "menuitem",
132
- color: "neutral.12",
133
- textStyle: "sm",
134
- p: "200",
135
- borderRadius: "200",
136
- whiteSpace: "nowrap",
137
- overflow: "hidden",
138
- textOverflow: "ellipsis",
139
-
140
- '&[aria-selected="true"], &[data-focused="true"]': {
141
- bg: "primary.4",
142
- },
143
-
144
- '& [slot="label"]': {
145
- display: "block",
146
- },
147
-
148
- '& [slot="description"]': {
149
- display: "block",
150
- color: "neutral.11",
151
- textStyle: "xs",
152
- },
153
-
154
- '&[data-disabled="true"]': {
155
- layerStyle: "disabled",
156
- },
157
- },
158
- },
159
-
160
- // Available variants for customizing the component's appearance
161
- variants: {
162
- // Size variants from smallest to largest
163
- size: {
164
- sm: {
165
- root: {},
166
- trigger: {
167
- h: "800",
168
- px: "400",
169
- textStyle: "sm",
170
- },
171
- },
172
- md: {
173
- root: {},
174
- trigger: {
175
- h: "1000",
176
- px: "400",
177
- textStyle: "md",
178
- },
179
- }, // Medium
180
- },
181
-
182
- // Visual style variants
183
- variant: {
184
- outline: {
185
- root: {
186
- bg: "bg",
187
- "&:hover": {
188
- bg: "primary.2",
189
- },
190
- },
191
- trigger: {
192
- "--border-width": "sizes.25",
193
- "--border-color": "colors.neutral.7",
194
- },
195
- },
196
- ghost: {
197
- root: {
198
- bg: "transparent",
199
- "&:hover": {
200
- bg: "primaryAlpha.2",
201
- },
202
- },
203
- trigger: {
204
- "--border-width": "sizes.25",
205
- "--border-color": "transparent",
206
- },
207
- },
208
- },
209
- },
210
-
211
- // Default variant values when not explicitly specified
212
- defaultVariants: {
213
- size: "md",
214
- variant: "outline",
215
- },
216
- });
@@ -1,58 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-empty-object-type */
2
- import {
3
- createSlotRecipeContext,
4
- type HTMLChakraProps,
5
- type RecipeVariantProps,
6
- } from "@chakra-ui/react";
7
- import { selectSlotRecipe } from "./select.recipe";
8
- import { type SelectProps as RaSelectProps } from "react-aria-components";
9
-
10
- const { withProvider, withContext } = createSlotRecipeContext({
11
- key: "select",
12
- });
13
-
14
- // Select
15
- export interface SelectRootSlotProps
16
- extends HTMLChakraProps<
17
- "div",
18
- RecipeVariantProps<typeof selectSlotRecipe> & RaSelectProps<object>
19
- > {}
20
- export const SelectRootSlot = withProvider<HTMLDivElement, SelectRootSlotProps>(
21
- "div",
22
- "root"
23
- );
24
-
25
- // Trigger Button
26
- export interface SelectTriggerSlotProps extends HTMLChakraProps<"button"> {}
27
- export const SelectTriggerSlot = withContext<
28
- HTMLButtonElement,
29
- SelectTriggerSlotProps
30
- >("button", "trigger");
31
-
32
- // Trigger Button Label
33
- export interface SelectTriggerLabelSlotProps extends HTMLChakraProps<"span"> {}
34
- export const SelectTriggerLabelSlot = withContext<
35
- HTMLButtonElement,
36
- SelectTriggerLabelSlotProps
37
- >("span", "triggerLabel");
38
-
39
- // ListBox
40
- export interface SelectOptionsSlotProps extends HTMLChakraProps<"div"> {}
41
- export const SelectOptionsSlot = withContext<
42
- HTMLDivElement,
43
- SelectOptionsSlotProps
44
- >("div", "options");
45
-
46
- // ListBoxItem
47
- export interface SelectOptionSlotProps extends HTMLChakraProps<"div"> {}
48
- export const SelectOptionSlot = withContext<
49
- HTMLDivElement,
50
- SelectOptionSlotProps
51
- >("div", "option");
52
-
53
- // OptionGroup
54
- export interface SelectOptionGroupSlotProps extends HTMLChakraProps<"div"> {}
55
- export const SelectOptionGroupSlot = withContext<
56
- HTMLDivElement,
57
- SelectOptionGroupSlotProps
58
- >("div", "optionGroup");