@cerberus-design/react 0.15.0-next-e0ce56e → 0.15.0-next-5d7dc1e

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 (246) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +491 -119
  2. package/build/legacy/components/DatePicker.client.cjs +67 -89
  3. package/build/legacy/components/DatePicker.client.cjs.map +1 -1
  4. package/build/legacy/components/Fieldset.cjs +4 -17
  5. package/build/legacy/components/Fieldset.cjs.map +1 -1
  6. package/build/legacy/components/FieldsetLabel.cjs.map +1 -1
  7. package/build/legacy/components/FileStatus.cjs +126 -79
  8. package/build/legacy/components/FileStatus.cjs.map +1 -1
  9. package/build/legacy/components/Legend.cjs +10 -22
  10. package/build/legacy/components/Legend.cjs.map +1 -1
  11. package/build/legacy/components/Radio.cjs +4 -21
  12. package/build/legacy/components/Radio.cjs.map +1 -1
  13. package/build/legacy/components/Select.cjs +19 -54
  14. package/build/legacy/components/Select.cjs.map +1 -1
  15. package/build/legacy/components/Toggle.cjs +17 -24
  16. package/build/legacy/components/Toggle.cjs.map +1 -1
  17. package/build/legacy/components/button/button.cjs +1 -1
  18. package/build/legacy/components/button/button.cjs.map +1 -1
  19. package/build/legacy/components/button/index.cjs +1 -1
  20. package/build/legacy/components/button/index.cjs.map +1 -1
  21. package/build/legacy/components/button/parts.cjs +1 -1
  22. package/build/legacy/components/button/parts.cjs.map +1 -1
  23. package/build/legacy/components/checkbox/checkbox-icon.cjs +121 -0
  24. package/build/legacy/components/checkbox/checkbox-icon.cjs.map +1 -0
  25. package/build/legacy/components/checkbox/checkbox.cjs +165 -0
  26. package/build/legacy/components/checkbox/checkbox.cjs.map +1 -0
  27. package/build/legacy/components/checkbox/index.cjs +179 -0
  28. package/build/legacy/components/checkbox/index.cjs.map +1 -0
  29. package/build/legacy/components/checkbox/parts.cjs +89 -0
  30. package/build/legacy/components/checkbox/parts.cjs.map +1 -0
  31. package/build/legacy/components/checkbox/primitives.cjs +87 -0
  32. package/build/legacy/components/checkbox/primitives.cjs.map +1 -0
  33. package/build/legacy/components/{FieldMessage.cjs → deprecated/FieldMessage.cjs} +4 -17
  34. package/build/legacy/components/deprecated/FieldMessage.cjs.map +1 -0
  35. package/build/legacy/components/{Textarea.cjs → deprecated/Label.cjs} +24 -36
  36. package/build/legacy/components/deprecated/Label.cjs.map +1 -0
  37. package/build/legacy/components/field/field.cjs +130 -0
  38. package/build/legacy/components/field/field.cjs.map +1 -0
  39. package/build/legacy/components/field/index.cjs +267 -0
  40. package/build/legacy/components/field/index.cjs.map +1 -0
  41. package/build/legacy/components/field/parts.cjs +188 -0
  42. package/build/legacy/components/field/parts.cjs.map +1 -0
  43. package/build/legacy/components/field/primitives.cjs +191 -0
  44. package/build/legacy/components/field/primitives.cjs.map +1 -0
  45. package/build/legacy/components/field/start-indicator.cjs +45 -0
  46. package/build/legacy/components/field/start-indicator.cjs.map +1 -0
  47. package/build/legacy/components/field/status-indicator.cjs +78 -0
  48. package/build/legacy/components/field/status-indicator.cjs.map +1 -0
  49. package/build/legacy/components/for.cjs +38 -0
  50. package/build/legacy/components/for.cjs.map +1 -0
  51. package/build/legacy/context/confirm-modal.cjs +1 -1
  52. package/build/legacy/context/confirm-modal.cjs.map +1 -1
  53. package/build/legacy/context/cta-modal.cjs +1 -1
  54. package/build/legacy/context/cta-modal.cjs.map +1 -1
  55. package/build/legacy/context/field.cjs +23 -4
  56. package/build/legacy/context/field.cjs.map +1 -1
  57. package/build/legacy/context/notification-center.cjs.map +1 -1
  58. package/build/legacy/context/prompt-modal.cjs +168 -166
  59. package/build/legacy/context/prompt-modal.cjs.map +1 -1
  60. package/build/legacy/hooks/useDate.cjs.map +1 -1
  61. package/build/legacy/index.cjs +1274 -1123
  62. package/build/legacy/index.cjs.map +1 -1
  63. package/build/legacy/utils/index.cjs +22 -2
  64. package/build/legacy/utils/index.cjs.map +1 -1
  65. package/build/modern/_tsup-dts-rollup.d.ts +491 -119
  66. package/build/modern/{chunk-2JX27W6Y.js → chunk-2BIHLH4V.js} +2 -2
  67. package/build/modern/chunk-2BIHLH4V.js.map +1 -0
  68. package/build/modern/{chunk-3ZDFQO25.js → chunk-6EUC3SUI.js} +4 -7
  69. package/build/modern/chunk-6EUC3SUI.js.map +1 -0
  70. package/build/modern/chunk-6I2FW4WI.js +33 -0
  71. package/build/modern/chunk-6I2FW4WI.js.map +1 -0
  72. package/build/modern/{chunk-MER66QUY.js → chunk-6KZVE4HC.js} +1 -1
  73. package/build/modern/{chunk-MER66QUY.js.map → chunk-6KZVE4HC.js.map} +1 -1
  74. package/build/modern/{chunk-FTPZHG6J.js → chunk-6WOJAMZV.js} +3 -9
  75. package/build/modern/chunk-6WOJAMZV.js.map +1 -0
  76. package/build/modern/chunk-77FJSNGD.js +13 -0
  77. package/build/modern/chunk-77FJSNGD.js.map +1 -0
  78. package/build/modern/chunk-BL7G3577.js +29 -0
  79. package/build/modern/chunk-BL7G3577.js.map +1 -0
  80. package/build/modern/chunk-BPRF34DU.js +62 -0
  81. package/build/modern/chunk-BPRF34DU.js.map +1 -0
  82. package/build/modern/{chunk-7P7OWBGV.js → chunk-CF3EHG42.js} +10 -10
  83. package/build/modern/chunk-CF3EHG42.js.map +1 -0
  84. package/build/modern/{chunk-Q4IV5NUT.js → chunk-CMYD5KWA.js} +40 -43
  85. package/build/modern/chunk-CMYD5KWA.js.map +1 -0
  86. package/build/modern/chunk-CNA2VKAH.js +43 -0
  87. package/build/modern/chunk-CNA2VKAH.js.map +1 -0
  88. package/build/modern/chunk-EL4MX2PG.js +22 -0
  89. package/build/modern/chunk-EL4MX2PG.js.map +1 -0
  90. package/build/modern/chunk-FBS7AX76.js +37 -0
  91. package/build/modern/chunk-FBS7AX76.js.map +1 -0
  92. package/build/modern/{chunk-KU2AWAK3.js → chunk-FK52US7K.js} +7 -20
  93. package/build/modern/chunk-FK52US7K.js.map +1 -0
  94. package/build/modern/{chunk-Z7FGXAND.js → chunk-FMRWRVUS.js} +2 -2
  95. package/build/modern/{chunk-XQICKZH4.js → chunk-GENS32QO.js} +10 -8
  96. package/build/modern/chunk-GENS32QO.js.map +1 -0
  97. package/build/modern/{chunk-7S47NSGR.js → chunk-H54FR7IP.js} +2 -2
  98. package/build/modern/chunk-KWZ3CEG6.js +23 -0
  99. package/build/modern/chunk-KWZ3CEG6.js.map +1 -0
  100. package/build/modern/{chunk-JWIJHSI6.js → chunk-L7N24B6B.js} +3 -6
  101. package/build/modern/chunk-L7N24B6B.js.map +1 -0
  102. package/build/modern/chunk-LT62577B.js +23 -0
  103. package/build/modern/chunk-LT62577B.js.map +1 -0
  104. package/build/modern/{chunk-3BM6MZ4A.js → chunk-MWRO5QYD.js} +1 -1
  105. package/build/modern/chunk-MWRO5QYD.js.map +1 -0
  106. package/build/modern/{chunk-PZAZKQMO.js → chunk-OYT7RGC7.js} +1 -1
  107. package/build/modern/chunk-OYT7RGC7.js.map +1 -0
  108. package/build/modern/{chunk-ILQW5VZT.js → chunk-RBNOEAWJ.js} +4 -7
  109. package/build/modern/chunk-RBNOEAWJ.js.map +1 -0
  110. package/build/modern/{chunk-5QONP7GT.js → chunk-S2X5OEPK.js} +2 -10
  111. package/build/modern/chunk-S2X5OEPK.js.map +1 -0
  112. package/build/modern/chunk-TIJAFPHQ.js +1 -0
  113. package/build/modern/chunk-TYPULJMJ.js +1 -0
  114. package/build/modern/chunk-UNN4LHRS.js +31 -0
  115. package/build/modern/chunk-UNN4LHRS.js.map +1 -0
  116. package/build/modern/chunk-VSTOSLFS.js +100 -0
  117. package/build/modern/chunk-VSTOSLFS.js.map +1 -0
  118. package/build/modern/chunk-Z52R6ABJ.js +21 -0
  119. package/build/modern/chunk-Z52R6ABJ.js.map +1 -0
  120. package/build/modern/{chunk-3RGRHMJQ.js → chunk-ZDANBCM3.js} +2 -2
  121. package/build/modern/components/AccordionItemGroup.js +1 -1
  122. package/build/modern/components/DatePicker.client.js +4 -5
  123. package/build/modern/components/Fieldset.js +1 -2
  124. package/build/modern/components/FieldsetLabel.js +1 -1
  125. package/build/modern/components/FileStatus.js +10 -4
  126. package/build/modern/components/Legend.js +1 -2
  127. package/build/modern/components/Radio.js +1 -3
  128. package/build/modern/components/Select.js +1 -2
  129. package/build/modern/components/Toggle.js +1 -2
  130. package/build/modern/components/button/button.js +1 -1
  131. package/build/modern/components/button/index.js +2 -2
  132. package/build/modern/components/button/parts.js +2 -2
  133. package/build/modern/components/checkbox/checkbox-icon.js +12 -0
  134. package/build/modern/components/checkbox/checkbox.js +13 -0
  135. package/build/modern/components/checkbox/index.js +30 -0
  136. package/build/modern/components/checkbox/parts.js +8 -0
  137. package/build/modern/components/checkbox/parts.js.map +1 -0
  138. package/build/modern/components/checkbox/primitives.js +17 -0
  139. package/build/modern/components/checkbox/primitives.js.map +1 -0
  140. package/build/modern/components/deprecated/FieldMessage.js +8 -0
  141. package/build/modern/components/deprecated/FieldMessage.js.map +1 -0
  142. package/build/modern/components/deprecated/Label.js +17 -0
  143. package/build/modern/components/deprecated/Label.js.map +1 -0
  144. package/build/modern/components/field/field.js +14 -0
  145. package/build/modern/components/field/field.js.map +1 -0
  146. package/build/modern/components/field/index.js +44 -0
  147. package/build/modern/components/field/index.js.map +1 -0
  148. package/build/modern/components/field/parts.js +11 -0
  149. package/build/modern/components/field/parts.js.map +1 -0
  150. package/build/modern/components/field/primitives.js +26 -0
  151. package/build/modern/components/field/primitives.js.map +1 -0
  152. package/build/modern/components/field/start-indicator.js +7 -0
  153. package/build/modern/components/field/start-indicator.js.map +1 -0
  154. package/build/modern/components/field/status-indicator.js +9 -0
  155. package/build/modern/components/field/status-indicator.js.map +1 -0
  156. package/build/modern/components/for.js +7 -0
  157. package/build/modern/components/for.js.map +1 -0
  158. package/build/modern/context/confirm-modal.js +3 -3
  159. package/build/modern/context/cta-modal.js +4 -4
  160. package/build/modern/context/field.js +34 -4
  161. package/build/modern/context/field.js.map +1 -1
  162. package/build/modern/context/notification-center.js +2 -2
  163. package/build/modern/context/prompt-modal.js +12 -7
  164. package/build/modern/hooks/useDate.js +1 -1
  165. package/build/modern/index.js +131 -82
  166. package/build/modern/index.js.map +1 -1
  167. package/build/modern/utils/index.js +5 -3
  168. package/package.json +2 -2
  169. package/src/components/DatePicker.client.tsx +2 -14
  170. package/src/components/Fieldset.tsx +3 -3
  171. package/src/components/FieldsetLabel.tsx +5 -2
  172. package/src/components/FileStatus.tsx +4 -5
  173. package/src/components/Legend.tsx +5 -6
  174. package/src/components/Radio.tsx +2 -7
  175. package/src/components/Select.tsx +1 -16
  176. package/src/components/Toggle.tsx +14 -7
  177. package/src/components/button/button.tsx +1 -1
  178. package/src/components/button/parts.ts +6 -0
  179. package/src/components/checkbox/checkbox-icon.tsx +39 -0
  180. package/src/components/checkbox/checkbox.tsx +48 -0
  181. package/src/components/checkbox/index.ts +3 -0
  182. package/src/components/checkbox/parts.ts +59 -0
  183. package/src/components/checkbox/primitives.tsx +104 -0
  184. package/src/components/{FieldMessage.tsx → deprecated/FieldMessage.tsx} +2 -13
  185. package/src/components/deprecated/Label.tsx +24 -0
  186. package/src/components/field/field.tsx +77 -0
  187. package/src/components/field/index.ts +5 -0
  188. package/src/components/field/parts.ts +77 -0
  189. package/src/components/field/primitives.tsx +204 -0
  190. package/src/components/field/start-indicator.tsx +23 -0
  191. package/src/components/field/status-indicator.tsx +58 -0
  192. package/src/components/for.tsx +43 -0
  193. package/src/context/field.tsx +6 -5
  194. package/src/context/prompt-modal.tsx +16 -18
  195. package/src/hooks/useDate.ts +1 -7
  196. package/src/index.ts +6 -7
  197. package/src/utils/index.ts +30 -0
  198. package/build/legacy/components/Checkbox.cjs +0 -113
  199. package/build/legacy/components/Checkbox.cjs.map +0 -1
  200. package/build/legacy/components/FieldMessage.cjs.map +0 -1
  201. package/build/legacy/components/Input.cjs +0 -95
  202. package/build/legacy/components/Input.cjs.map +0 -1
  203. package/build/legacy/components/Label.cjs +0 -93
  204. package/build/legacy/components/Label.cjs.map +0 -1
  205. package/build/legacy/components/Textarea.cjs.map +0 -1
  206. package/build/modern/chunk-2JX27W6Y.js.map +0 -1
  207. package/build/modern/chunk-3BM6MZ4A.js.map +0 -1
  208. package/build/modern/chunk-3ZDFQO25.js.map +0 -1
  209. package/build/modern/chunk-5QONP7GT.js.map +0 -1
  210. package/build/modern/chunk-7P7OWBGV.js.map +0 -1
  211. package/build/modern/chunk-C5EHJUS5.js +0 -10
  212. package/build/modern/chunk-C5EHJUS5.js.map +0 -1
  213. package/build/modern/chunk-FTPZHG6J.js.map +0 -1
  214. package/build/modern/chunk-ILQW5VZT.js.map +0 -1
  215. package/build/modern/chunk-JIJM6JFJ.js +0 -36
  216. package/build/modern/chunk-JIJM6JFJ.js.map +0 -1
  217. package/build/modern/chunk-JWIJHSI6.js.map +0 -1
  218. package/build/modern/chunk-KU2AWAK3.js.map +0 -1
  219. package/build/modern/chunk-NGOLRISW.js +0 -63
  220. package/build/modern/chunk-NGOLRISW.js.map +0 -1
  221. package/build/modern/chunk-NMF2HYWO.js +0 -50
  222. package/build/modern/chunk-NMF2HYWO.js.map +0 -1
  223. package/build/modern/chunk-PZAZKQMO.js.map +0 -1
  224. package/build/modern/chunk-Q4IV5NUT.js.map +0 -1
  225. package/build/modern/chunk-UZDVOIW5.js +0 -33
  226. package/build/modern/chunk-UZDVOIW5.js.map +0 -1
  227. package/build/modern/chunk-VYCU7I4J.js +0 -43
  228. package/build/modern/chunk-VYCU7I4J.js.map +0 -1
  229. package/build/modern/chunk-XQICKZH4.js.map +0 -1
  230. package/build/modern/components/Checkbox.js +0 -11
  231. package/build/modern/components/FieldMessage.js +0 -9
  232. package/build/modern/components/Input.js +0 -11
  233. package/build/modern/components/Label.js +0 -10
  234. package/build/modern/components/Textarea.js +0 -9
  235. package/src/components/Checkbox.tsx +0 -93
  236. package/src/components/Input.tsx +0 -69
  237. package/src/components/Label.tsx +0 -69
  238. package/src/components/Textarea.tsx +0 -52
  239. /package/build/modern/{chunk-Z7FGXAND.js.map → chunk-FMRWRVUS.js.map} +0 -0
  240. /package/build/modern/{chunk-7S47NSGR.js.map → chunk-H54FR7IP.js.map} +0 -0
  241. /package/build/modern/{components/Checkbox.js.map → chunk-TIJAFPHQ.js.map} +0 -0
  242. /package/build/modern/{components/FieldMessage.js.map → chunk-TYPULJMJ.js.map} +0 -0
  243. /package/build/modern/{chunk-3RGRHMJQ.js.map → chunk-ZDANBCM3.js.map} +0 -0
  244. /package/build/modern/components/{Input.js.map → checkbox/checkbox-icon.js.map} +0 -0
  245. /package/build/modern/components/{Label.js.map → checkbox/checkbox.js.map} +0 -0
  246. /package/build/modern/components/{Textarea.js.map → checkbox/index.js.map} +0 -0
@@ -19,7 +19,6 @@ import { HStack } from '@cerberus/styled-system/jsx'
19
19
  import { useCerberusContext } from '../context/cerberus'
20
20
  import { Portal } from './Portal'
21
21
  import { Show } from './Show'
22
- import { Text } from './Text'
23
22
  import {
24
23
  SelectContent,
25
24
  SelectControl,
@@ -29,7 +28,6 @@ import {
29
28
  SelectItemGroupLabel,
30
29
  SelectItemIndicator,
31
30
  SelectItemText,
32
- SelectLabel,
33
31
  SelectPositioner,
34
32
  SelectRoot,
35
33
  SelectTrigger,
@@ -68,10 +66,6 @@ export interface BaseSelectProps {
68
66
  * The placeholder text when no option is selected.
69
67
  */
70
68
  placeholder?: string
71
- /**
72
- * The label of the select.
73
- */
74
- label: string
75
69
  }
76
70
 
77
71
  export type SelectProps = SelectRootProps<SelectCollectionItem> &
@@ -110,7 +104,7 @@ export type SelectProps = SelectRootProps<SelectCollectionItem> &
110
104
  * }
111
105
  */
112
106
  export function Select(props: SelectProps) {
113
- const { collection, label, placeholder, size, ...rootProps } = props
107
+ const { collection, placeholder, size, ...rootProps } = props
114
108
  const { icons } = useCerberusContext()
115
109
  const { selectArrow: SelectArrow, invalid: InvalidIcon } = icons
116
110
 
@@ -118,15 +112,6 @@ export function Select(props: SelectProps) {
118
112
 
119
113
  return (
120
114
  <SelectRoot className={styles.root} collection={collection} {...rootProps}>
121
- <SelectLabel className={styles.label}>
122
- {label}
123
- <Show when={props.required}>
124
- <Text as="span" color="page.text.100">
125
- (required)
126
- </Text>
127
- </Show>
128
- </SelectLabel>
129
-
130
115
  <SelectControl className={styles.control}>
131
116
  <SelectTrigger className={styles.trigger}>
132
117
  <SelectValueText placeholder={placeholder} />
@@ -1,13 +1,13 @@
1
1
  'use client'
2
2
 
3
+ import { useFieldContext } from '@ark-ui/react/field'
4
+ import type { InputHTMLAttributes } from 'react'
3
5
  import { cx } from '@cerberus/styled-system/css'
4
6
  import { hstack, vstack } from '@cerberus/styled-system/patterns'
5
7
  import {
6
8
  toggle,
7
9
  type ToggleVariantProps,
8
10
  } from '@cerberus/styled-system/recipes'
9
- import type { InputHTMLAttributes } from 'react'
10
- import { useFieldContext } from '../context/field'
11
11
  import { useCerberusContext } from '../context/cerberus'
12
12
 
13
13
  /**
@@ -20,7 +20,7 @@ export type ToggleBase = Omit<
20
20
  'size' | 'id' | 'value'
21
21
  > & {
22
22
  /**
23
- * The FieldMessage providing context for the Toggle.
23
+ * @deprecated
24
24
  */
25
25
  describedBy?: string
26
26
  /**
@@ -56,9 +56,12 @@ export type ToggleProps = ToggleBase & ToggleVariantProps
56
56
  * ```
57
57
  */
58
58
  export function Toggle(props: ToggleProps) {
59
- const { size, describedBy, ...nativeProps } = props
59
+ const { size, ...nativeProps } = props
60
60
  const styles = toggle({ size })
61
- const { invalid, ...state } = useFieldContext()
61
+
62
+ const { invalid, disabled, readOnly, required, ariaDescribedby } =
63
+ useFieldContext()
64
+
62
65
  const { icons } = useCerberusContext()
63
66
  const CheckedIcon = icons.toggleChecked
64
67
 
@@ -69,8 +72,12 @@ export function Toggle(props: ToggleProps) {
69
72
  >
70
73
  <input
71
74
  {...nativeProps}
72
- {...state}
73
- {...(describedBy && { 'aria-describedby': describedBy })}
75
+ {...(disabled && { disabled: true })}
76
+ {...(readOnly && { readOnly: true })}
77
+ {...(required && { required: true })}
78
+ {...(ariaDescribedby && {
79
+ 'aria-describedby': ariaDescribedby,
80
+ })}
74
81
  {...(invalid && { 'aria-invalid': true })}
75
82
  className={cx('peer', styles.input)}
76
83
  role="switch"
@@ -12,9 +12,9 @@ import {
12
12
  button,
13
13
  type ButtonVariantProps,
14
14
  } from '@cerberus/styled-system/recipes'
15
+ import { Box } from '@cerberus/styled-system/jsx'
15
16
  import { Show } from '../Show'
16
17
  import { Spinner } from '../Spinner'
17
- import { Box } from '@cerberus/styled-system/jsx'
18
18
 
19
19
  /**
20
20
  * This module contains the Button component.
@@ -7,7 +7,13 @@ import { Button, ButtonIcon } from './button'
7
7
  */
8
8
 
9
9
  interface ButtonPartsValue {
10
+ /**
11
+ * The context provider of the button.
12
+ */
10
13
  Root: ElementType
14
+ /**
15
+ * The icon of the button.
16
+ */
11
17
  Icon: ElementType
12
18
  }
13
19
 
@@ -0,0 +1,39 @@
1
+ 'use client'
2
+
3
+ import { useCerberusContext } from '../../context/cerberus'
4
+ import { CheckboxParts } from './parts'
5
+ import { Show } from '../Show'
6
+
7
+ /**
8
+ * This module contains the Checkbox Icon component.
9
+ * @module
10
+ */
11
+
12
+ interface CheckboxIconProps {
13
+ indeterminate?: boolean
14
+ }
15
+
16
+ /**
17
+ * Checkbox component
18
+ * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)
19
+ * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
20
+ * @see https://cerberus.digitalu.design/react/checkbox
21
+ * @example
22
+ * ```tsx
23
+ * <Field>
24
+ * <Checkbox id="legal" checked={checked.legal} onChange={handleChange} />
25
+ * </Field>
26
+ * ```
27
+ */
28
+ export function CheckboxIcon(props: CheckboxIconProps) {
29
+ const { icons } = useCerberusContext()
30
+ const { checkbox: CheckIcon, indeterminate: IndeterminateIcon } = icons
31
+
32
+ return (
33
+ <CheckboxParts.Indicator indeterminate={props.indeterminate}>
34
+ <Show when={props.indeterminate} fallback={<CheckIcon />}>
35
+ <IndeterminateIcon />
36
+ </Show>
37
+ </CheckboxParts.Indicator>
38
+ )
39
+ }
@@ -0,0 +1,48 @@
1
+ import type { CheckboxRootProps } from '@ark-ui/react'
2
+ import { type CheckboxVariantProps } from '@cerberus/styled-system/recipes'
3
+ import { Show } from '../Show'
4
+ import { Text } from '../Text'
5
+ import { CheckboxParts } from './parts'
6
+ import { CheckboxIcon } from './checkbox-icon'
7
+
8
+ /**
9
+ * This module contains the Checkbox component.
10
+ * @module
11
+ */
12
+
13
+ export type CheckboxProps = CheckboxVariantProps & CheckboxRootProps
14
+
15
+ /**
16
+ * Checkbox component
17
+ * @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)
18
+ * @definition [ARIA Forms](https://www.a11yproject.com/checklist/#forms)
19
+ * @see https://cerberus.digitalu.design/react/checkbox
20
+ * @example
21
+ * ```tsx
22
+ * <Field>
23
+ * <Checkbox id="legal" checked={checked.legal} onChange={handleChange} />
24
+ * </Field>
25
+ * ```
26
+ */
27
+ export function Checkbox(props: CheckboxProps) {
28
+ const { size, children, ...rootProps } = props
29
+
30
+ return (
31
+ <CheckboxParts.Root {...rootProps}>
32
+ <CheckboxParts.Control size={size}>
33
+ <CheckboxIcon indeterminate={rootProps.checked === 'indeterminate'} />
34
+ </CheckboxParts.Control>
35
+
36
+ <CheckboxParts.Label size={size}>
37
+ {children}
38
+ <Show when={props.required}>
39
+ <Text as="span" data-part="required-indicator">
40
+ (required)
41
+ </Text>
42
+ </Show>
43
+ </CheckboxParts.Label>
44
+
45
+ <CheckboxParts.HiddenInput />
46
+ </CheckboxParts.Root>
47
+ )
48
+ }
@@ -0,0 +1,3 @@
1
+ export * from './checkbox'
2
+ export * from './parts'
3
+ export * from './primitives'
@@ -0,0 +1,59 @@
1
+ import type { ElementType } from 'react'
2
+ import {
3
+ CheckboxRoot,
4
+ CheckboxLabel,
5
+ CheckboxControl,
6
+ CheckboxIndicator,
7
+ CheckboxHiddenInput,
8
+ CheckboxGroup,
9
+ } from './primitives'
10
+
11
+ /**
12
+ * This module contains the parts of the Field component.
13
+ * @module 'field/parts'
14
+ */
15
+
16
+ interface CheckboxPartsValue {
17
+ /**
18
+ * The container of the field.
19
+ */
20
+ Root: ElementType
21
+ /**
22
+ * The label of the field.
23
+ */
24
+ Label: ElementType
25
+ /**
26
+ * The control of the field.
27
+ */
28
+ Control: ElementType
29
+ /**
30
+ * The indicator of the field.
31
+ */
32
+ Indicator: ElementType
33
+ /**
34
+ * The hidden input of the field.
35
+ */
36
+ HiddenInput: ElementType
37
+ /**
38
+ * The checkbox group component.
39
+ */
40
+ Group: ElementType
41
+ }
42
+
43
+ /**
44
+ * An Object containing the parts of the Checkbox component. For users that
45
+ * prefer Object component syntax.
46
+ *
47
+ * @remarks
48
+ *
49
+ * When using object component syntax, you import the CheckboxParts object and
50
+ * the entire family of components vs. only what you use.
51
+ */
52
+ export const CheckboxParts: CheckboxPartsValue = {
53
+ Root: CheckboxRoot,
54
+ Label: CheckboxLabel,
55
+ Control: CheckboxControl,
56
+ Indicator: CheckboxIndicator,
57
+ HiddenInput: CheckboxHiddenInput,
58
+ Group: CheckboxGroup,
59
+ }
@@ -0,0 +1,104 @@
1
+ import {
2
+ Checkbox,
3
+ type CheckboxControlProps,
4
+ type CheckboxGroupProps,
5
+ type CheckboxIndicatorProps,
6
+ type CheckboxLabelProps,
7
+ type CheckboxRootProps,
8
+ } from '@ark-ui/react'
9
+ import { cx } from '@cerberus/styled-system/css'
10
+ import {
11
+ checkbox,
12
+ type CheckboxVariantProps,
13
+ } from '@cerberus/styled-system/recipes'
14
+
15
+ /**
16
+ * This module contains the Checkbox primitives.
17
+ * @module 'react/checkbox'
18
+ */
19
+
20
+ /**
21
+ * Checkbox Root component used to provide the context to all other checkbox
22
+ * primitives.
23
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
24
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
25
+ */
26
+ export function CheckboxRoot(props: CheckboxRootProps) {
27
+ const styles = checkbox()
28
+ return (
29
+ <Checkbox.Root {...props} className={cx(styles.root, props.className)} />
30
+ )
31
+ }
32
+
33
+ /**
34
+ * Checkbox Label component used to display the label of the checkbox.
35
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
36
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
37
+ */
38
+ export function CheckboxLabel(
39
+ props: CheckboxLabelProps & CheckboxVariantProps,
40
+ ) {
41
+ const { size, ...labelProps } = props
42
+ const styles = checkbox({ size })
43
+ return (
44
+ <Checkbox.Label
45
+ {...labelProps}
46
+ className={cx(styles.label, labelProps.className)}
47
+ />
48
+ )
49
+ }
50
+
51
+ /**
52
+ * Checkbox Control component used to display the control of the checkbox.
53
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
54
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
55
+ */
56
+ export function CheckboxControl(
57
+ props: CheckboxControlProps & CheckboxVariantProps,
58
+ ) {
59
+ const { size, ...controlProps } = props
60
+ const styles = checkbox({ size })
61
+ return (
62
+ <Checkbox.Control
63
+ {...controlProps}
64
+ className={cx(styles.control, controlProps.className)}
65
+ />
66
+ )
67
+ }
68
+
69
+ /**
70
+ * Checkbox Indicator component used to display the indicator of the checkbox.
71
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
72
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
73
+ */
74
+ export function CheckboxIndicator(props: CheckboxIndicatorProps) {
75
+ const styles = checkbox()
76
+ return (
77
+ <Checkbox.Indicator
78
+ {...props}
79
+ className={cx(styles.indicator, props.className)}
80
+ />
81
+ )
82
+ }
83
+
84
+ /**
85
+ * Checkbox HiddenInput component used to provide the native checkbox input.
86
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
87
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
88
+ */
89
+ export function CheckboxHiddenInput(props: CheckboxControlProps) {
90
+ return <Checkbox.HiddenInput {...props} />
91
+ }
92
+
93
+ /**
94
+ * Checkbox Group is used to group checkboxes together in a consistently styled
95
+ * way.
96
+ * @definition [Cerberus Docs](https://cerberus.digitalu.design/react/checkbox)
97
+ * @definition [Primitive Docs](https://ark-ui.com/react/docs/components/checkbox)
98
+ */
99
+ export function CheckboxGroup(props: CheckboxGroupProps) {
100
+ const styles = checkbox()
101
+ return (
102
+ <Checkbox.Group {...props} className={cx(styles.group, props.className)} />
103
+ )
104
+ }
@@ -6,7 +6,7 @@ import {
6
6
  fieldMessage,
7
7
  type FieldMessageVariantProps,
8
8
  } from '@cerberus/styled-system/recipes'
9
- import { useFieldContext } from '../context/field'
9
+ import { useFieldContext } from '@ark-ui/react/field'
10
10
 
11
11
  /**
12
12
  * This module contains the FieldMessage component.
@@ -25,18 +25,7 @@ export interface FieldMessageBaseProps
25
25
  export type FieldMessageProps = FieldMessageBaseProps & FieldMessageVariantProps
26
26
 
27
27
  /**
28
- * A component that provides feedback about the field.
29
- * @see https://cerberus.digitalu.design/react/field-message
30
- * @example
31
- * ```tsx
32
- * <Field>
33
- * <Label htmlFor="first_name">First Name</Label>
34
- * <Input aria-describedBy="help:first_name" id="first_name" type="text" />
35
- * <FieldMessage id="help:first_name">
36
- * This will only be used in your account information.
37
- * </FieldMessage>
38
- * </Field>
39
- * ```
28
+ * @deprecated use FieldHelperText, FieldErrorText, or FieldParts instead
40
29
  */
41
30
  export function FieldMessage(props: FieldMessageProps) {
42
31
  const { invalid } = useFieldContext()
@@ -0,0 +1,24 @@
1
+ import type { HTMLAttributes, PropsWithChildren } from 'react'
2
+ import { label, type LabelVariantProps } from '@cerberus/styled-system/recipes'
3
+ import { cx } from '@cerberus/styled-system/css'
4
+ import { FieldLabel } from '../field'
5
+
6
+ /**
7
+ * This module contains the Label component.
8
+ * @module
9
+ */
10
+ export type LabelBaseProps = HTMLAttributes<HTMLLabelElement>
11
+ export type LabelProps = LabelBaseProps & LabelVariantProps
12
+
13
+ /**
14
+ * @deprecated Use FieldLabel or FieldParts.Label instead.
15
+ */
16
+ export function Label(props: PropsWithChildren<LabelProps>) {
17
+ const { size, ...nativeProps } = props
18
+ return (
19
+ <FieldLabel
20
+ {...nativeProps}
21
+ className={cx(label({ size }), props.className)}
22
+ />
23
+ )
24
+ }
@@ -0,0 +1,77 @@
1
+ import { type FieldRootProps } from '@ark-ui/react/field'
2
+ import { splitProps } from '../../utils/index'
3
+ import {
4
+ FieldErrorText,
5
+ FieldHelperText,
6
+ FieldLabel,
7
+ FieldRoot,
8
+ } from './primitives'
9
+ import { HStack } from '@cerberus/styled-system/jsx'
10
+ import { Show } from '../Show'
11
+
12
+ export interface FieldProps extends FieldRootProps {
13
+ /**
14
+ * The label of the field.
15
+ */
16
+ label?: string
17
+ /**
18
+ * The helper text of the field.
19
+ */
20
+ helperText?: string
21
+ /**
22
+ * A helper text positioned at the end of the field. Good for Textarea fields.
23
+ */
24
+ secondaryHelperText?: string
25
+ /**
26
+ * The error text of the field. Shown when the field is invalid.
27
+ */
28
+ errorText?: string
29
+ }
30
+
31
+ /**
32
+ * The Field component is the context provider for all FieldParts and displays
33
+ * the label, helperText, and ErrorText.
34
+ * @description [Field Docs](https://cerberus.digitalu.design/react/field)
35
+ * @example
36
+ * ```tsx
37
+ * <Field
38
+ * ids={{
39
+ * control: 'firstName',
40
+ * }}
41
+ * label="Label"
42
+ * helperText="This is what people will see on your profile."
43
+ * errorText="A first name is required to create an account."
44
+ * required
45
+ * >
46
+ * <Input name="firstName" type="text" />
47
+ * </Field>
48
+ * ```
49
+ */
50
+ export function Field(props: FieldProps) {
51
+ const [statusProps, fieldProps, rootProps] = splitProps(
52
+ props,
53
+ ['disabled', 'required', 'readOnly', 'invalid'],
54
+ ['label', 'helperText', 'secondaryHelperText', 'errorText', 'children'],
55
+ )
56
+
57
+ return (
58
+ <FieldRoot {...statusProps} {...rootProps}>
59
+ <Show when={Boolean(fieldProps.label)}>
60
+ <FieldLabel>{fieldProps.label}</FieldLabel>
61
+ </Show>
62
+
63
+ {fieldProps.children}
64
+
65
+ <Show when={Boolean(fieldProps.helperText && !statusProps.invalid)}>
66
+ <HStack justifyContent="space-between" w="full">
67
+ <FieldHelperText>{fieldProps.helperText}</FieldHelperText>
68
+ <Show when={Boolean(fieldProps.secondaryHelperText)}>
69
+ <FieldHelperText>{fieldProps.secondaryHelperText}</FieldHelperText>
70
+ </Show>
71
+ </HStack>
72
+ </Show>
73
+
74
+ <FieldErrorText>{fieldProps.errorText}</FieldErrorText>
75
+ </FieldRoot>
76
+ )
77
+ }
@@ -0,0 +1,5 @@
1
+ export * from './field'
2
+ export * from './primitives'
3
+ export * from './start-indicator'
4
+ export * from './status-indicator'
5
+ export * from './parts'
@@ -0,0 +1,77 @@
1
+ import type { ElementType } from 'react'
2
+ import {
3
+ FieldErrorText,
4
+ FieldHelperText,
5
+ FieldInput,
6
+ FieldLabel,
7
+ FieldRequiredIndicator,
8
+ FieldRoot,
9
+ FieldTextarea,
10
+ } from './primitives'
11
+ import { FieldStatusIndicator } from './status-indicator'
12
+ import { FieldStartIndicator } from './start-indicator'
13
+
14
+ /**
15
+ * This module contains the parts of the Field component.
16
+ * @module 'field/parts'
17
+ */
18
+
19
+ interface FieldPartsValue {
20
+ /**
21
+ * The container of the field.
22
+ */
23
+ Root: ElementType
24
+ /**
25
+ * The label of the field.
26
+ */
27
+ Label: ElementType
28
+ /**
29
+ * The input of the field.
30
+ */
31
+ Input: ElementType
32
+ /**
33
+ * The textarea of the field.
34
+ */
35
+ Textarea: ElementType
36
+ /**
37
+ * The text that displays when the field is valid.
38
+ */
39
+ HelperText: ElementType
40
+ /**
41
+ * The text that displays when the field is invalid.
42
+ */
43
+ ErrorText: ElementType
44
+ /**
45
+ * The indicator that appears at the start of the field.
46
+ */
47
+ StartIndicator: ElementType
48
+ /**
49
+ * The status indicator of the field.
50
+ */
51
+ StatusIndicator: ElementType
52
+ /**
53
+ * The indicator that appears at the end of the field.
54
+ */
55
+ RequiredIndicator: ElementType
56
+ }
57
+
58
+ /**
59
+ * An Object containing the parts of the Field component. For users that
60
+ * prefer Object component syntax.
61
+ *
62
+ * @remarks
63
+ *
64
+ * When using object component syntax, you import the FieldParts object and
65
+ * the entire family of components vs. only what you use.
66
+ */
67
+ export const FieldParts: FieldPartsValue = {
68
+ Root: FieldRoot,
69
+ Label: FieldLabel,
70
+ Input: FieldInput,
71
+ Textarea: FieldTextarea,
72
+ HelperText: FieldHelperText,
73
+ ErrorText: FieldErrorText,
74
+ StartIndicator: FieldStartIndicator,
75
+ StatusIndicator: FieldStatusIndicator,
76
+ RequiredIndicator: FieldRequiredIndicator,
77
+ }