@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.
- package/build/legacy/_tsup-dts-rollup.d.cts +491 -119
- package/build/legacy/components/DatePicker.client.cjs +67 -89
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/components/Fieldset.cjs +4 -17
- package/build/legacy/components/Fieldset.cjs.map +1 -1
- package/build/legacy/components/FieldsetLabel.cjs.map +1 -1
- package/build/legacy/components/FileStatus.cjs +126 -79
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/Legend.cjs +10 -22
- package/build/legacy/components/Legend.cjs.map +1 -1
- package/build/legacy/components/Radio.cjs +4 -21
- package/build/legacy/components/Radio.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +19 -54
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +17 -24
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/components/button/button.cjs +1 -1
- package/build/legacy/components/button/button.cjs.map +1 -1
- package/build/legacy/components/button/index.cjs +1 -1
- package/build/legacy/components/button/index.cjs.map +1 -1
- package/build/legacy/components/button/parts.cjs +1 -1
- package/build/legacy/components/button/parts.cjs.map +1 -1
- package/build/legacy/components/checkbox/checkbox-icon.cjs +121 -0
- package/build/legacy/components/checkbox/checkbox-icon.cjs.map +1 -0
- package/build/legacy/components/checkbox/checkbox.cjs +165 -0
- package/build/legacy/components/checkbox/checkbox.cjs.map +1 -0
- package/build/legacy/components/checkbox/index.cjs +179 -0
- package/build/legacy/components/checkbox/index.cjs.map +1 -0
- package/build/legacy/components/checkbox/parts.cjs +89 -0
- package/build/legacy/components/checkbox/parts.cjs.map +1 -0
- package/build/legacy/components/checkbox/primitives.cjs +87 -0
- package/build/legacy/components/checkbox/primitives.cjs.map +1 -0
- package/build/legacy/components/{FieldMessage.cjs → deprecated/FieldMessage.cjs} +4 -17
- package/build/legacy/components/deprecated/FieldMessage.cjs.map +1 -0
- package/build/legacy/components/{Textarea.cjs → deprecated/Label.cjs} +24 -36
- package/build/legacy/components/deprecated/Label.cjs.map +1 -0
- package/build/legacy/components/field/field.cjs +130 -0
- package/build/legacy/components/field/field.cjs.map +1 -0
- package/build/legacy/components/field/index.cjs +267 -0
- package/build/legacy/components/field/index.cjs.map +1 -0
- package/build/legacy/components/field/parts.cjs +188 -0
- package/build/legacy/components/field/parts.cjs.map +1 -0
- package/build/legacy/components/field/primitives.cjs +191 -0
- package/build/legacy/components/field/primitives.cjs.map +1 -0
- package/build/legacy/components/field/start-indicator.cjs +45 -0
- package/build/legacy/components/field/start-indicator.cjs.map +1 -0
- package/build/legacy/components/field/status-indicator.cjs +78 -0
- package/build/legacy/components/field/status-indicator.cjs.map +1 -0
- package/build/legacy/components/for.cjs +38 -0
- package/build/legacy/components/for.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +1 -1
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +1 -1
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/field.cjs +23 -4
- package/build/legacy/context/field.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +168 -166
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/hooks/useDate.cjs.map +1 -1
- package/build/legacy/index.cjs +1274 -1123
- package/build/legacy/index.cjs.map +1 -1
- package/build/legacy/utils/index.cjs +22 -2
- package/build/legacy/utils/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +491 -119
- package/build/modern/{chunk-2JX27W6Y.js → chunk-2BIHLH4V.js} +2 -2
- package/build/modern/chunk-2BIHLH4V.js.map +1 -0
- package/build/modern/{chunk-3ZDFQO25.js → chunk-6EUC3SUI.js} +4 -7
- package/build/modern/chunk-6EUC3SUI.js.map +1 -0
- package/build/modern/chunk-6I2FW4WI.js +33 -0
- package/build/modern/chunk-6I2FW4WI.js.map +1 -0
- package/build/modern/{chunk-MER66QUY.js → chunk-6KZVE4HC.js} +1 -1
- package/build/modern/{chunk-MER66QUY.js.map → chunk-6KZVE4HC.js.map} +1 -1
- package/build/modern/{chunk-FTPZHG6J.js → chunk-6WOJAMZV.js} +3 -9
- package/build/modern/chunk-6WOJAMZV.js.map +1 -0
- package/build/modern/chunk-77FJSNGD.js +13 -0
- package/build/modern/chunk-77FJSNGD.js.map +1 -0
- package/build/modern/chunk-BL7G3577.js +29 -0
- package/build/modern/chunk-BL7G3577.js.map +1 -0
- package/build/modern/chunk-BPRF34DU.js +62 -0
- package/build/modern/chunk-BPRF34DU.js.map +1 -0
- package/build/modern/{chunk-7P7OWBGV.js → chunk-CF3EHG42.js} +10 -10
- package/build/modern/chunk-CF3EHG42.js.map +1 -0
- package/build/modern/{chunk-Q4IV5NUT.js → chunk-CMYD5KWA.js} +40 -43
- package/build/modern/chunk-CMYD5KWA.js.map +1 -0
- package/build/modern/chunk-CNA2VKAH.js +43 -0
- package/build/modern/chunk-CNA2VKAH.js.map +1 -0
- package/build/modern/chunk-EL4MX2PG.js +22 -0
- package/build/modern/chunk-EL4MX2PG.js.map +1 -0
- package/build/modern/chunk-FBS7AX76.js +37 -0
- package/build/modern/chunk-FBS7AX76.js.map +1 -0
- package/build/modern/{chunk-KU2AWAK3.js → chunk-FK52US7K.js} +7 -20
- package/build/modern/chunk-FK52US7K.js.map +1 -0
- package/build/modern/{chunk-Z7FGXAND.js → chunk-FMRWRVUS.js} +2 -2
- package/build/modern/{chunk-XQICKZH4.js → chunk-GENS32QO.js} +10 -8
- package/build/modern/chunk-GENS32QO.js.map +1 -0
- package/build/modern/{chunk-7S47NSGR.js → chunk-H54FR7IP.js} +2 -2
- package/build/modern/chunk-KWZ3CEG6.js +23 -0
- package/build/modern/chunk-KWZ3CEG6.js.map +1 -0
- package/build/modern/{chunk-JWIJHSI6.js → chunk-L7N24B6B.js} +3 -6
- package/build/modern/chunk-L7N24B6B.js.map +1 -0
- package/build/modern/chunk-LT62577B.js +23 -0
- package/build/modern/chunk-LT62577B.js.map +1 -0
- package/build/modern/{chunk-3BM6MZ4A.js → chunk-MWRO5QYD.js} +1 -1
- package/build/modern/chunk-MWRO5QYD.js.map +1 -0
- package/build/modern/{chunk-PZAZKQMO.js → chunk-OYT7RGC7.js} +1 -1
- package/build/modern/chunk-OYT7RGC7.js.map +1 -0
- package/build/modern/{chunk-ILQW5VZT.js → chunk-RBNOEAWJ.js} +4 -7
- package/build/modern/chunk-RBNOEAWJ.js.map +1 -0
- package/build/modern/{chunk-5QONP7GT.js → chunk-S2X5OEPK.js} +2 -10
- package/build/modern/chunk-S2X5OEPK.js.map +1 -0
- package/build/modern/chunk-TIJAFPHQ.js +1 -0
- package/build/modern/chunk-TYPULJMJ.js +1 -0
- package/build/modern/chunk-UNN4LHRS.js +31 -0
- package/build/modern/chunk-UNN4LHRS.js.map +1 -0
- package/build/modern/chunk-VSTOSLFS.js +100 -0
- package/build/modern/chunk-VSTOSLFS.js.map +1 -0
- package/build/modern/chunk-Z52R6ABJ.js +21 -0
- package/build/modern/chunk-Z52R6ABJ.js.map +1 -0
- package/build/modern/{chunk-3RGRHMJQ.js → chunk-ZDANBCM3.js} +2 -2
- package/build/modern/components/AccordionItemGroup.js +1 -1
- package/build/modern/components/DatePicker.client.js +4 -5
- package/build/modern/components/Fieldset.js +1 -2
- package/build/modern/components/FieldsetLabel.js +1 -1
- package/build/modern/components/FileStatus.js +10 -4
- package/build/modern/components/Legend.js +1 -2
- package/build/modern/components/Radio.js +1 -3
- package/build/modern/components/Select.js +1 -2
- package/build/modern/components/Toggle.js +1 -2
- package/build/modern/components/button/button.js +1 -1
- package/build/modern/components/button/index.js +2 -2
- package/build/modern/components/button/parts.js +2 -2
- package/build/modern/components/checkbox/checkbox-icon.js +12 -0
- package/build/modern/components/checkbox/checkbox.js +13 -0
- package/build/modern/components/checkbox/index.js +30 -0
- package/build/modern/components/checkbox/parts.js +8 -0
- package/build/modern/components/checkbox/parts.js.map +1 -0
- package/build/modern/components/checkbox/primitives.js +17 -0
- package/build/modern/components/checkbox/primitives.js.map +1 -0
- package/build/modern/components/deprecated/FieldMessage.js +8 -0
- package/build/modern/components/deprecated/FieldMessage.js.map +1 -0
- package/build/modern/components/deprecated/Label.js +17 -0
- package/build/modern/components/deprecated/Label.js.map +1 -0
- package/build/modern/components/field/field.js +14 -0
- package/build/modern/components/field/field.js.map +1 -0
- package/build/modern/components/field/index.js +44 -0
- package/build/modern/components/field/index.js.map +1 -0
- package/build/modern/components/field/parts.js +11 -0
- package/build/modern/components/field/parts.js.map +1 -0
- package/build/modern/components/field/primitives.js +26 -0
- package/build/modern/components/field/primitives.js.map +1 -0
- package/build/modern/components/field/start-indicator.js +7 -0
- package/build/modern/components/field/start-indicator.js.map +1 -0
- package/build/modern/components/field/status-indicator.js +9 -0
- package/build/modern/components/field/status-indicator.js.map +1 -0
- package/build/modern/components/for.js +7 -0
- package/build/modern/components/for.js.map +1 -0
- package/build/modern/context/confirm-modal.js +3 -3
- package/build/modern/context/cta-modal.js +4 -4
- package/build/modern/context/field.js +34 -4
- package/build/modern/context/field.js.map +1 -1
- package/build/modern/context/notification-center.js +2 -2
- package/build/modern/context/prompt-modal.js +12 -7
- package/build/modern/hooks/useDate.js +1 -1
- package/build/modern/index.js +131 -82
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +5 -3
- package/package.json +2 -2
- package/src/components/DatePicker.client.tsx +2 -14
- package/src/components/Fieldset.tsx +3 -3
- package/src/components/FieldsetLabel.tsx +5 -2
- package/src/components/FileStatus.tsx +4 -5
- package/src/components/Legend.tsx +5 -6
- package/src/components/Radio.tsx +2 -7
- package/src/components/Select.tsx +1 -16
- package/src/components/Toggle.tsx +14 -7
- package/src/components/button/button.tsx +1 -1
- package/src/components/button/parts.ts +6 -0
- package/src/components/checkbox/checkbox-icon.tsx +39 -0
- package/src/components/checkbox/checkbox.tsx +48 -0
- package/src/components/checkbox/index.ts +3 -0
- package/src/components/checkbox/parts.ts +59 -0
- package/src/components/checkbox/primitives.tsx +104 -0
- package/src/components/{FieldMessage.tsx → deprecated/FieldMessage.tsx} +2 -13
- package/src/components/deprecated/Label.tsx +24 -0
- package/src/components/field/field.tsx +77 -0
- package/src/components/field/index.ts +5 -0
- package/src/components/field/parts.ts +77 -0
- package/src/components/field/primitives.tsx +204 -0
- package/src/components/field/start-indicator.tsx +23 -0
- package/src/components/field/status-indicator.tsx +58 -0
- package/src/components/for.tsx +43 -0
- package/src/context/field.tsx +6 -5
- package/src/context/prompt-modal.tsx +16 -18
- package/src/hooks/useDate.ts +1 -7
- package/src/index.ts +6 -7
- package/src/utils/index.ts +30 -0
- package/build/legacy/components/Checkbox.cjs +0 -113
- package/build/legacy/components/Checkbox.cjs.map +0 -1
- package/build/legacy/components/FieldMessage.cjs.map +0 -1
- package/build/legacy/components/Input.cjs +0 -95
- package/build/legacy/components/Input.cjs.map +0 -1
- package/build/legacy/components/Label.cjs +0 -93
- package/build/legacy/components/Label.cjs.map +0 -1
- package/build/legacy/components/Textarea.cjs.map +0 -1
- package/build/modern/chunk-2JX27W6Y.js.map +0 -1
- package/build/modern/chunk-3BM6MZ4A.js.map +0 -1
- package/build/modern/chunk-3ZDFQO25.js.map +0 -1
- package/build/modern/chunk-5QONP7GT.js.map +0 -1
- package/build/modern/chunk-7P7OWBGV.js.map +0 -1
- package/build/modern/chunk-C5EHJUS5.js +0 -10
- package/build/modern/chunk-C5EHJUS5.js.map +0 -1
- package/build/modern/chunk-FTPZHG6J.js.map +0 -1
- package/build/modern/chunk-ILQW5VZT.js.map +0 -1
- package/build/modern/chunk-JIJM6JFJ.js +0 -36
- package/build/modern/chunk-JIJM6JFJ.js.map +0 -1
- package/build/modern/chunk-JWIJHSI6.js.map +0 -1
- package/build/modern/chunk-KU2AWAK3.js.map +0 -1
- package/build/modern/chunk-NGOLRISW.js +0 -63
- package/build/modern/chunk-NGOLRISW.js.map +0 -1
- package/build/modern/chunk-NMF2HYWO.js +0 -50
- package/build/modern/chunk-NMF2HYWO.js.map +0 -1
- package/build/modern/chunk-PZAZKQMO.js.map +0 -1
- package/build/modern/chunk-Q4IV5NUT.js.map +0 -1
- package/build/modern/chunk-UZDVOIW5.js +0 -33
- package/build/modern/chunk-UZDVOIW5.js.map +0 -1
- package/build/modern/chunk-VYCU7I4J.js +0 -43
- package/build/modern/chunk-VYCU7I4J.js.map +0 -1
- package/build/modern/chunk-XQICKZH4.js.map +0 -1
- package/build/modern/components/Checkbox.js +0 -11
- package/build/modern/components/FieldMessage.js +0 -9
- package/build/modern/components/Input.js +0 -11
- package/build/modern/components/Label.js +0 -10
- package/build/modern/components/Textarea.js +0 -9
- package/src/components/Checkbox.tsx +0 -93
- package/src/components/Input.tsx +0 -69
- package/src/components/Label.tsx +0 -69
- package/src/components/Textarea.tsx +0 -52
- /package/build/modern/{chunk-Z7FGXAND.js.map → chunk-FMRWRVUS.js.map} +0 -0
- /package/build/modern/{chunk-7S47NSGR.js.map → chunk-H54FR7IP.js.map} +0 -0
- /package/build/modern/{components/Checkbox.js.map → chunk-TIJAFPHQ.js.map} +0 -0
- /package/build/modern/{components/FieldMessage.js.map → chunk-TYPULJMJ.js.map} +0 -0
- /package/build/modern/{chunk-3RGRHMJQ.js.map → chunk-ZDANBCM3.js.map} +0 -0
- /package/build/modern/components/{Input.js.map → checkbox/checkbox-icon.js.map} +0 -0
- /package/build/modern/components/{Label.js.map → checkbox/checkbox.js.map} +0 -0
- /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,
|
|
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
|
-
*
|
|
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,
|
|
59
|
+
const { size, ...nativeProps } = props
|
|
60
60
|
const styles = toggle({ size })
|
|
61
|
-
|
|
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
|
-
{...
|
|
73
|
-
{...(
|
|
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.
|
|
@@ -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,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 '
|
|
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
|
-
*
|
|
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,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
|
+
}
|