@cerberus-design/react 0.15.0-next-e0ce56e → 0.15.0-next-739c492
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 +313 -112
- package/build/legacy/components/Checkbox.cjs +27 -35
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- 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/{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 +261 -0
- package/build/legacy/components/field/index.cjs.map +1 -0
- package/build/legacy/components/field/parts.cjs +184 -0
- package/build/legacy/components/field/parts.cjs.map +1 -0
- package/build/legacy/components/field/primitives.cjs +186 -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/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 +1156 -1067
- 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 +313 -112
- 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-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-7VA5SXTY.js +31 -0
- package/build/modern/chunk-7VA5SXTY.js.map +1 -0
- package/build/modern/chunk-7YVOZULL.js +23 -0
- package/build/modern/chunk-7YVOZULL.js.map +1 -0
- package/build/modern/{chunk-KU2AWAK3.js → chunk-B2A6QFKT.js} +4 -17
- package/build/modern/chunk-B2A6QFKT.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-C5NL3X7W.js +96 -0
- package/build/modern/chunk-C5NL3X7W.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-Z7FGXAND.js → chunk-FMRWRVUS.js} +2 -2
- package/build/modern/{chunk-NGOLRISW.js → chunk-FVE4GBB7.js} +9 -8
- package/build/modern/chunk-FVE4GBB7.js.map +1 -0
- package/build/modern/{chunk-7P7OWBGV.js → chunk-G2VFEBY4.js} +8 -8
- package/build/modern/chunk-G2VFEBY4.js.map +1 -0
- package/build/modern/{chunk-XQICKZH4.js → chunk-GENS32QO.js} +10 -8
- package/build/modern/chunk-GENS32QO.js.map +1 -0
- package/build/modern/{chunk-Q4IV5NUT.js → chunk-GNPGG4ND.js} +37 -40
- package/build/modern/chunk-GNPGG4ND.js.map +1 -0
- package/build/modern/{chunk-7S47NSGR.js → chunk-H54FR7IP.js} +2 -2
- package/build/modern/chunk-IGSC4IEA.js +37 -0
- package/build/modern/chunk-IGSC4IEA.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-3RGRHMJQ.js → chunk-LCN7LYTU.js} +5 -5
- 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-TYPULJMJ.js +1 -0
- package/build/modern/chunk-Z52R6ABJ.js +21 -0
- package/build/modern/chunk-Z52R6ABJ.js.map +1 -0
- package/build/modern/components/Checkbox.js +1 -2
- package/build/modern/components/DatePicker.client.js +3 -4
- package/build/modern/components/Fieldset.js +1 -2
- package/build/modern/components/FieldsetLabel.js +1 -1
- package/build/modern/components/FileStatus.js +9 -3
- 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/deprecated/FieldMessage.js +8 -0
- package/build/modern/components/deprecated/Label.js +17 -0
- package/build/modern/components/field/field.js +14 -0
- package/build/modern/components/field/index.js +42 -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 +24 -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/context/confirm-modal.js +2 -2
- 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 +10 -5
- package/build/modern/hooks/useDate.js +1 -1
- package/build/modern/index.js +85 -62
- package/build/modern/index.js.map +1 -1
- package/build/modern/utils/index.js +5 -3
- package/package.json +2 -2
- package/src/components/Checkbox.tsx +13 -9
- 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/{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 +71 -0
- package/src/components/field/primitives.tsx +197 -0
- package/src/components/field/start-indicator.tsx +23 -0
- package/src/components/field/status-indicator.tsx +58 -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 +4 -6
- package/src/utils/index.ts +30 -0
- 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.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/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/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/{chunk-3RGRHMJQ.js.map → chunk-LCN7LYTU.js.map} +0 -0
- /package/build/modern/{components/FieldMessage.js.map → chunk-TYPULJMJ.js.map} +0 -0
- /package/build/modern/components/{Input.js.map → deprecated/FieldMessage.js.map} +0 -0
- /package/build/modern/components/{Label.js.map → deprecated/Label.js.map} +0 -0
- /package/build/modern/components/{Textarea.js.map → field/field.js.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerberus-design/react",
|
|
3
|
-
"version": "0.15.0-next-
|
|
3
|
+
"version": "0.15.0-next-739c492",
|
|
4
4
|
"description": "The Cerberus Design React component library.",
|
|
5
5
|
"browserslist": "> 0.25%, not dead",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"react-dom": "^18",
|
|
27
27
|
"tsup": "^8.1.0",
|
|
28
28
|
"@cerberus-design/configs": "0.0.0",
|
|
29
|
-
"@cerberus/styled-system": "npm:@cerberus-design/styled-system@0.15.0-next-
|
|
29
|
+
"@cerberus/styled-system": "npm:@cerberus-design/styled-system@0.15.0-next-739c492"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
import { vstack } from '@cerberus/styled-system/patterns'
|
|
8
8
|
import { cx } from '@cerberus/styled-system/css'
|
|
9
9
|
import type { InputHTMLAttributes } from 'react'
|
|
10
|
-
import { Show } from './Show'
|
|
11
|
-
import { useFieldContext } from '../context/field'
|
|
12
10
|
import { useCerberusContext } from '../context/cerberus'
|
|
11
|
+
import { Show } from './Show'
|
|
12
|
+
import { useFieldContext } from '@ark-ui/react/field'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* This module contains the Checkbox component.
|
|
@@ -19,13 +19,13 @@ import { useCerberusContext } from '../context/cerberus'
|
|
|
19
19
|
export type CheckboxProps = CheckboxVariantProps &
|
|
20
20
|
Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'id'> & {
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* @deprecated
|
|
23
23
|
*/
|
|
24
24
|
describedBy?: string
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* @deprecated use the Field.ids.control instead
|
|
27
27
|
*/
|
|
28
|
-
id
|
|
28
|
+
id?: string
|
|
29
29
|
/**
|
|
30
30
|
* Used to display a mixed checked state.
|
|
31
31
|
* @description [ARIA Mixed State](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/examples/checkbox-mixed/)
|
|
@@ -46,8 +46,9 @@ export type CheckboxProps = CheckboxVariantProps &
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
export function Checkbox(props: CheckboxProps) {
|
|
49
|
-
const {
|
|
50
|
-
const { invalid,
|
|
49
|
+
const { size, checked, mixed, ...nativeProps } = props
|
|
50
|
+
const { invalid, disabled, readOnly, required, ariaDescribedby, ids } =
|
|
51
|
+
useFieldContext()
|
|
51
52
|
const styles = checkbox({ size })
|
|
52
53
|
const { icons } = useCerberusContext()
|
|
53
54
|
const { checkbox: CheckIcon, indeterminate: IndeterminateIcon } = icons
|
|
@@ -71,10 +72,13 @@ export function Checkbox(props: CheckboxProps) {
|
|
|
71
72
|
>
|
|
72
73
|
<input
|
|
73
74
|
{...nativeProps}
|
|
74
|
-
{...
|
|
75
|
-
{...(
|
|
75
|
+
{...(disabled && { disabled: true })}
|
|
76
|
+
{...(readOnly && { readOnly: true })}
|
|
77
|
+
{...(required && { required: true })}
|
|
78
|
+
{...(ariaDescribedby && { 'aria-describedby': ariaDescribedby })}
|
|
76
79
|
{...(invalid && { 'aria-invalid': true })}
|
|
77
80
|
{...(mixed && { 'aria-checked': 'mixed' })}
|
|
81
|
+
id={ids.control}
|
|
78
82
|
className={cx('peer', nativeProps.className, styles.input)}
|
|
79
83
|
type="checkbox"
|
|
80
84
|
/>
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
import { Portal } from './Portal'
|
|
13
13
|
import { datePicker, iconButton } from '@cerberus/styled-system/recipes'
|
|
14
14
|
import { css, cx } from '@cerberus/styled-system/css'
|
|
15
|
-
import { useFieldContext } from '../context/field'
|
|
16
15
|
import {
|
|
17
16
|
DatePickerView,
|
|
18
17
|
DatePickerContext,
|
|
@@ -50,12 +49,10 @@ const datePickerStyles = datePicker()
|
|
|
50
49
|
* ```
|
|
51
50
|
*/
|
|
52
51
|
export function DatePicker(props: DatePickerRootProps) {
|
|
53
|
-
const states = useFieldContext()
|
|
54
|
-
|
|
55
|
-
// TODO: Remove this once the bug is fixed: https://github.com/chakra-ui/ark/issues/3112
|
|
56
|
-
|
|
57
52
|
// There is a bug with the Root component that causes random date selection
|
|
58
53
|
// onBlur after the first selection if the format prop is used.
|
|
54
|
+
// ref: https://github.com/chakra-ui/ark/issues/3112#event-16047829195
|
|
55
|
+
|
|
59
56
|
// const handleFormat = useCallback((value: DateValue) => {
|
|
60
57
|
// return formatISOToMilitary(value.toString())
|
|
61
58
|
// }, [])
|
|
@@ -63,7 +60,6 @@ export function DatePicker(props: DatePickerRootProps) {
|
|
|
63
60
|
return (
|
|
64
61
|
<ArkDP.Root
|
|
65
62
|
{...props}
|
|
66
|
-
{...states}
|
|
67
63
|
positioning={{
|
|
68
64
|
placement: 'bottom-start',
|
|
69
65
|
}}
|
|
@@ -157,14 +153,11 @@ export function DatePickerTrigger(props: DatePickerTriggerProps) {
|
|
|
157
153
|
* ```
|
|
158
154
|
*/
|
|
159
155
|
export function DatePickerInput(props: DatePickerInputProps) {
|
|
160
|
-
const { invalid, ...fieldStates } = useFieldContext()
|
|
161
156
|
return (
|
|
162
157
|
<ArkDP.Control className={datePickerStyles.control}>
|
|
163
158
|
<DatePickerTrigger />
|
|
164
159
|
<ArkDP.Input
|
|
165
160
|
{...props}
|
|
166
|
-
{...fieldStates}
|
|
167
|
-
{...(invalid && { 'aria-invalid': true })}
|
|
168
161
|
className={cx(props.className, datePickerStyles.input)}
|
|
169
162
|
placeholder={props.placeholder ?? 'DD MMM YYYY'}
|
|
170
163
|
maxLength={11}
|
|
@@ -200,7 +193,6 @@ export interface RangePickerInputProps
|
|
|
200
193
|
* ```
|
|
201
194
|
*/
|
|
202
195
|
export function RangePickerInput(props: RangePickerInputProps) {
|
|
203
|
-
const { invalid, ...fieldStates } = useFieldContext()
|
|
204
196
|
const { defaultValue, ...nativeProps } = props
|
|
205
197
|
|
|
206
198
|
const startDate = useMemo(() => defaultValue?.[0], [defaultValue])
|
|
@@ -211,8 +203,6 @@ export function RangePickerInput(props: RangePickerInputProps) {
|
|
|
211
203
|
<DatePickerTrigger />
|
|
212
204
|
<ArkDP.Input
|
|
213
205
|
{...nativeProps}
|
|
214
|
-
{...fieldStates}
|
|
215
|
-
{...(invalid && { 'aria-invalid': true })}
|
|
216
206
|
data-range-input
|
|
217
207
|
defaultValue={startDate}
|
|
218
208
|
className={cx(props.className, datePickerStyles.input)}
|
|
@@ -222,8 +212,6 @@ export function RangePickerInput(props: RangePickerInputProps) {
|
|
|
222
212
|
/>
|
|
223
213
|
<ArkDP.Input
|
|
224
214
|
{...nativeProps}
|
|
225
|
-
{...fieldStates}
|
|
226
|
-
{...(invalid && { 'aria-invalid': true })}
|
|
227
215
|
data-range-input
|
|
228
216
|
defaultValue={endDate}
|
|
229
217
|
data-range-end-input
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
+
import { useFieldContext } from '@ark-ui/react/field'
|
|
3
4
|
import { css, cx } from '@cerberus/styled-system/css'
|
|
4
5
|
import type { FieldsetHTMLAttributes } from 'react'
|
|
5
|
-
import { useFieldContext } from '../context/field'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This module contains the Fieldset component.
|
|
@@ -45,12 +45,12 @@ export type FieldsetProps = FieldsetHTMLAttributes<HTMLFieldSetElement>
|
|
|
45
45
|
* }
|
|
46
46
|
*/
|
|
47
47
|
export function Fieldset(props: FieldsetProps) {
|
|
48
|
-
const { invalid,
|
|
48
|
+
const { invalid, disabled } = useFieldContext()
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<fieldset
|
|
52
52
|
{...props}
|
|
53
|
-
{
|
|
53
|
+
disabled={disabled}
|
|
54
54
|
{...(invalid && { 'aria-invalid': true })}
|
|
55
55
|
className={cx(
|
|
56
56
|
props.className,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { cx } from '@cerberus/styled-system/css'
|
|
2
2
|
import { label, type LabelVariantProps } from '@cerberus/styled-system/recipes'
|
|
3
|
-
import type { LabelProps } from './Label'
|
|
3
|
+
import type { LabelProps } from './deprecated/Label'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This module contains the FieldsetLabel component.
|
|
7
7
|
* @module FieldsetLabel
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export type FieldsetLabelProps = LabelProps &
|
|
10
|
+
export type FieldsetLabelProps = LabelProps &
|
|
11
|
+
LabelVariantProps & {
|
|
12
|
+
htmlFor?: string
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Used for labeling inputs that are children of a Fieldset group.
|
|
@@ -12,12 +12,11 @@ import {
|
|
|
12
12
|
} from '@cerberus/styled-system/recipes'
|
|
13
13
|
import { css, cx } from '@cerberus/styled-system/css'
|
|
14
14
|
import { hstack, vstack } from '@cerberus/styled-system/patterns'
|
|
15
|
-
import { Field } from '../context/field'
|
|
16
15
|
import { useCerberusContext } from '../context/cerberus'
|
|
17
|
-
import { FieldMessage } from './FieldMessage'
|
|
18
16
|
import { ProgressBar, type ProgressBarProps } from './ProgressBar'
|
|
19
17
|
import { IconButton } from './IconButton'
|
|
20
18
|
import { Avatar } from './Avatar'
|
|
19
|
+
import { Field, FieldHelperText } from './field/index'
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* This module contains the FileStatus component.
|
|
@@ -157,15 +156,15 @@ export function FileStatus(props: FileStatusProps) {
|
|
|
157
156
|
now={now}
|
|
158
157
|
size="sm"
|
|
159
158
|
/>
|
|
160
|
-
<Field invalid={modalIconPalette === 'hades-dark'}>
|
|
161
|
-
<
|
|
159
|
+
<Field label="" invalid={modalIconPalette === 'hades-dark'}>
|
|
160
|
+
<FieldHelperText
|
|
162
161
|
className={css({
|
|
163
162
|
color: 'page.text.100',
|
|
164
163
|
})}
|
|
165
164
|
id={`help:${file}`}
|
|
166
165
|
>
|
|
167
166
|
<MatchFileStatusText status={status} now={now} />
|
|
168
|
-
</
|
|
167
|
+
</FieldHelperText>
|
|
169
168
|
</Field>
|
|
170
169
|
</div>
|
|
171
170
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { css, cx } from '@cerberus/styled-system/css'
|
|
4
|
-
import { type HTMLAttributes } from 'react'
|
|
5
|
-
import { useFieldContext } from '../context/field'
|
|
6
|
-
import { Show } from './Show'
|
|
7
4
|
import { label, type LabelVariantProps } from '@cerberus/styled-system/recipes'
|
|
8
5
|
import { hstack } from '@cerberus/styled-system/patterns'
|
|
6
|
+
import { type HTMLAttributes } from 'react'
|
|
7
|
+
import { Show } from './Show'
|
|
8
|
+
import { useFieldContext } from '@ark-ui/react/field'
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* This module contains the Fieldset component.
|
|
@@ -50,12 +50,11 @@ export type LegendProps = HTMLAttributes<HTMLLegendElement> & LabelVariantProps
|
|
|
50
50
|
*/
|
|
51
51
|
export function Legend(props: LegendProps) {
|
|
52
52
|
const { size, ...nativeProps } = props
|
|
53
|
-
const { invalid,
|
|
53
|
+
const { invalid, required } = useFieldContext()
|
|
54
54
|
|
|
55
55
|
return (
|
|
56
56
|
<legend
|
|
57
57
|
{...nativeProps}
|
|
58
|
-
{...formState}
|
|
59
58
|
{...(invalid && { 'aria-invalid': true })}
|
|
60
59
|
className={cx(
|
|
61
60
|
nativeProps.className,
|
|
@@ -69,7 +68,7 @@ export function Legend(props: LegendProps) {
|
|
|
69
68
|
)}
|
|
70
69
|
>
|
|
71
70
|
{nativeProps.children}
|
|
72
|
-
<Show when={
|
|
71
|
+
<Show when={required}>
|
|
73
72
|
<span
|
|
74
73
|
className={css({
|
|
75
74
|
color: 'page.text.100',
|
package/src/components/Radio.tsx
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { Field } from '@ark-ui/react/field'
|
|
3
2
|
import { cx } from '@cerberus/styled-system/css'
|
|
4
3
|
import { hstack } from '@cerberus/styled-system/patterns'
|
|
5
4
|
import { radio } from '@cerberus/styled-system/recipes'
|
|
6
5
|
import type { RecipeVariantProps } from '@cerberus/styled-system/types'
|
|
7
6
|
import type { InputHTMLAttributes, PropsWithChildren } from 'react'
|
|
8
|
-
import { useFieldContext } from '../context/field'
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* This module contains the Radio component.
|
|
@@ -45,7 +43,6 @@ export type RadioProps = RadioBaseProps & RadioRecipe
|
|
|
45
43
|
*/
|
|
46
44
|
export function Radio(props: PropsWithChildren<RadioProps>) {
|
|
47
45
|
const { children, size, ...nativeProps } = props
|
|
48
|
-
const { invalid, ...state } = useFieldContext()
|
|
49
46
|
const styles = radio({ size })
|
|
50
47
|
|
|
51
48
|
return (
|
|
@@ -59,10 +56,8 @@ export function Radio(props: PropsWithChildren<RadioProps>) {
|
|
|
59
56
|
)}
|
|
60
57
|
tabIndex={0}
|
|
61
58
|
>
|
|
62
|
-
<
|
|
59
|
+
<Field.Input
|
|
63
60
|
{...nativeProps}
|
|
64
|
-
{...state}
|
|
65
|
-
{...(invalid && { 'aria-invalid': true })}
|
|
66
61
|
className={cx(nativeProps.className, styles.input)}
|
|
67
62
|
tabIndex={-1}
|
|
68
63
|
type="radio"
|
|
@@ -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.
|
|
@@ -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,71 @@
|
|
|
1
|
+
import type { ElementType } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
FieldErrorText,
|
|
4
|
+
FieldHelperText,
|
|
5
|
+
FieldInput,
|
|
6
|
+
FieldLabel,
|
|
7
|
+
FieldRoot,
|
|
8
|
+
FieldTextarea,
|
|
9
|
+
} from './primitives'
|
|
10
|
+
import { FieldStatusIndicator } from './status-indicator'
|
|
11
|
+
import { FieldStartIndicator } from './start-indicator'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This module contains the parts of the Field component.
|
|
15
|
+
* @module 'field/parts'
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
interface FieldPartsValue {
|
|
19
|
+
/**
|
|
20
|
+
* The container of the field.
|
|
21
|
+
*/
|
|
22
|
+
Root: ElementType
|
|
23
|
+
/**
|
|
24
|
+
* The label of the field.
|
|
25
|
+
*/
|
|
26
|
+
Label: ElementType
|
|
27
|
+
/**
|
|
28
|
+
* The input of the field.
|
|
29
|
+
*/
|
|
30
|
+
Input: ElementType
|
|
31
|
+
/**
|
|
32
|
+
* The textarea of the field.
|
|
33
|
+
*/
|
|
34
|
+
Textarea: ElementType
|
|
35
|
+
/**
|
|
36
|
+
* The text that displays when the field is valid.
|
|
37
|
+
*/
|
|
38
|
+
HelperText: ElementType
|
|
39
|
+
/**
|
|
40
|
+
* The text that displays when the field is invalid.
|
|
41
|
+
*/
|
|
42
|
+
ErrorText: ElementType
|
|
43
|
+
/**
|
|
44
|
+
* The indicator that appears at the start of the field.
|
|
45
|
+
*/
|
|
46
|
+
StartIndicator: ElementType
|
|
47
|
+
/**
|
|
48
|
+
* The status indicator of the field.
|
|
49
|
+
*/
|
|
50
|
+
StatusIndicator: ElementType
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* An Object containing the parts of the Field component. For users that
|
|
55
|
+
* prefer Object component syntax.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
*
|
|
59
|
+
* When using object component syntax, you import the FieldParts object and
|
|
60
|
+
* the entire family of components vs. only what you use.
|
|
61
|
+
*/
|
|
62
|
+
export const FieldParts: FieldPartsValue = {
|
|
63
|
+
Root: FieldRoot,
|
|
64
|
+
Label: FieldLabel,
|
|
65
|
+
Input: FieldInput,
|
|
66
|
+
Textarea: FieldTextarea,
|
|
67
|
+
HelperText: FieldHelperText,
|
|
68
|
+
ErrorText: FieldErrorText,
|
|
69
|
+
StartIndicator: FieldStartIndicator,
|
|
70
|
+
StatusIndicator: FieldStatusIndicator,
|
|
71
|
+
}
|