@cerberus-design/react 1.0.0-rc.4 → 1.0.0-rc.6
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/dist/panda.buildinfo.json +23 -0
- package/package.json +9 -4
- package/src/components/AnimatingUploadIcon.tsx +0 -83
- package/src/components/accordion/index.ts +0 -3
- package/src/components/accordion/item-group.tsx +0 -70
- package/src/components/accordion/item-indicator.tsx +0 -27
- package/src/components/accordion/parts.ts +0 -53
- package/src/components/accordion/primitives.tsx +0 -86
- package/src/components/admonition/admonition.tsx +0 -62
- package/src/components/admonition/index.ts +0 -3
- package/src/components/admonition/match-avatar.tsx +0 -52
- package/src/components/admonition/parts.ts +0 -53
- package/src/components/admonition/primitives.tsx +0 -77
- package/src/components/avatar/avatar.tsx +0 -51
- package/src/components/avatar/index.ts +0 -5
- package/src/components/avatar/parts.ts +0 -37
- package/src/components/avatar/primitives.tsx +0 -38
- package/src/components/button/button.tsx +0 -62
- package/src/components/button/index.ts +0 -3
- package/src/components/button/parts.ts +0 -32
- package/src/components/button/primitives.tsx +0 -41
- package/src/components/carousel/carousel.tsx +0 -55
- package/src/components/carousel/index.ts +0 -3
- package/src/components/carousel/parts.ts +0 -71
- package/src/components/carousel/primitives.ts +0 -58
- package/src/components/checkbox/checkbox-icon.tsx +0 -39
- package/src/components/checkbox/checkbox.tsx +0 -42
- package/src/components/checkbox/index.ts +0 -3
- package/src/components/checkbox/parts.ts +0 -59
- package/src/components/checkbox/primitives.tsx +0 -77
- package/src/components/circular-progress/circular-progress.tsx +0 -49
- package/src/components/circular-progress/index.ts +0 -2
- package/src/components/circular-progress/primitives.ts +0 -80
- package/src/components/clipboard/copy-indicator.tsx +0 -22
- package/src/components/clipboard/copy-text.tsx +0 -13
- package/src/components/clipboard/index.ts +0 -2
- package/src/components/clipboard/parts.ts +0 -74
- package/src/components/clipboard/primitives.ts +0 -56
- package/src/components/clipboard/trigger.tsx +0 -14
- package/src/components/collapsible/index.ts +0 -2
- package/src/components/collapsible/parts.ts +0 -53
- package/src/components/collapsible/primitives.tsx +0 -53
- package/src/components/combobox/combobox.tsx +0 -67
- package/src/components/combobox/index.ts +0 -6
- package/src/components/combobox/item-group.tsx +0 -19
- package/src/components/combobox/item.tsx +0 -30
- package/src/components/combobox/parts.ts +0 -101
- package/src/components/combobox/primitives.tsx +0 -146
- package/src/components/combobox/use-stateful-collection.ts +0 -65
- package/src/components/cta-dialog/context.tsx +0 -38
- package/src/components/cta-dialog/index.ts +0 -2
- package/src/components/cta-dialog/provider.tsx +0 -186
- package/src/components/cta-dialog/trigger-item.tsx +0 -54
- package/src/components/cta-dialog/utils.ts +0 -57
- package/src/components/date-picker/calendar.tsx +0 -47
- package/src/components/date-picker/content.tsx +0 -21
- package/src/components/date-picker/date-picker.tsx +0 -20
- package/src/components/date-picker/day-view.tsx +0 -82
- package/src/components/date-picker/index.ts +0 -16
- package/src/components/date-picker/input.tsx +0 -26
- package/src/components/date-picker/month-view.tsx +0 -49
- package/src/components/date-picker/parts.ts +0 -167
- package/src/components/date-picker/primitives.tsx +0 -235
- package/src/components/date-picker/range-input.tsx +0 -38
- package/src/components/date-picker/trigger.tsx +0 -28
- package/src/components/date-picker/view-control-group.tsx +0 -54
- package/src/components/date-picker/year-view.tsx +0 -47
- package/src/components/dialog/close-icon-trigger.tsx +0 -36
- package/src/components/dialog/dialog.tsx +0 -42
- package/src/components/dialog/index.ts +0 -8
- package/src/components/dialog/parts.ts +0 -71
- package/src/components/dialog/primitives.tsx +0 -83
- package/src/components/feature-flag/feature-flag.tsx +0 -21
- package/src/components/feature-flag/index.ts +0 -1
- package/src/components/field/error-text.tsx +0 -19
- package/src/components/field/field.tsx +0 -93
- package/src/components/field/helper-text.tsx +0 -20
- package/src/components/field/index.ts +0 -7
- package/src/components/field/input.tsx +0 -47
- package/src/components/field/parts.ts +0 -77
- package/src/components/field/primitives.tsx +0 -135
- package/src/components/field/start-indicator.tsx +0 -23
- package/src/components/field/status-indicator.tsx +0 -58
- package/src/components/fieldset/fieldset.tsx +0 -54
- package/src/components/fieldset/index.ts +0 -3
- package/src/components/fieldset/parts.ts +0 -47
- package/src/components/fieldset/primitives.tsx +0 -48
- package/src/components/file-upload/file-status.tsx +0 -271
- package/src/components/file-upload/file-uploader.tsx +0 -60
- package/src/components/file-upload/helpers.ts +0 -28
- package/src/components/file-upload/img-preview.tsx +0 -41
- package/src/components/file-upload/index.ts +0 -6
- package/src/components/file-upload/parts.tsx +0 -132
- package/src/components/file-upload/primitives.ts +0 -161
- package/src/components/file-upload/utils.ts +0 -20
- package/src/components/for/for.tsx +0 -38
- package/src/components/for/index.ts +0 -1
- package/src/components/group/index.ts +0 -1
- package/src/components/group/primitives.ts +0 -7
- package/src/components/icon-button/button.tsx +0 -41
- package/src/components/icon-button/index.tsx +0 -2
- package/src/components/icon-button/primitives.ts +0 -19
- package/src/components/menu/index.ts +0 -2
- package/src/components/menu/menu.tsx +0 -144
- package/src/components/menu/primitives.ts +0 -84
- package/src/components/notifications/center.tsx +0 -88
- package/src/components/notifications/close-trigger.tsx +0 -21
- package/src/components/notifications/index.ts +0 -5
- package/src/components/notifications/match-icon.tsx +0 -41
- package/src/components/notifications/parts.ts +0 -53
- package/src/components/notifications/primitives.tsx +0 -66
- package/src/components/notifications/toaster.ts +0 -13
- package/src/components/notifications/types.ts +0 -44
- package/src/components/number-input/decrement-trigger.tsx +0 -16
- package/src/components/number-input/increment-trigger.tsx +0 -16
- package/src/components/number-input/index.ts +0 -3
- package/src/components/number-input/input.tsx +0 -33
- package/src/components/number-input/parts.ts +0 -65
- package/src/components/number-input/primitives.tsx +0 -74
- package/src/components/pagination/compact.tsx +0 -25
- package/src/components/pagination/index.ts +0 -6
- package/src/components/pagination/item-list.tsx +0 -34
- package/src/components/pagination/item.tsx +0 -6
- package/src/components/pagination/pagination.tsx +0 -53
- package/src/components/pagination/parts.ts +0 -65
- package/src/components/pagination/primitives.ts +0 -41
- package/src/components/pagination/triggers.tsx +0 -55
- package/src/components/pin-input/index.ts +0 -3
- package/src/components/pin-input/input.tsx +0 -22
- package/src/components/pin-input/parts.ts +0 -53
- package/src/components/pin-input/primitives.tsx +0 -46
- package/src/components/portal/index.ts +0 -1
- package/src/components/portal/portal.tsx +0 -28
- package/src/components/progress/index.ts +0 -2
- package/src/components/progress/primitives.ts +0 -37
- package/src/components/progress/progress-bar.tsx +0 -80
- package/src/components/radio/index.ts +0 -3
- package/src/components/radio/parts.ts +0 -65
- package/src/components/radio/primitives.tsx +0 -92
- package/src/components/radio/radio.tsx +0 -35
- package/src/components/rating/index.ts +0 -8
- package/src/components/rating/parts.tsx +0 -65
- package/src/components/rating/primitives.tsx +0 -64
- package/src/components/rating/rating.tsx +0 -75
- package/src/components/select/index.ts +0 -5
- package/src/components/select/option-group.tsx +0 -32
- package/src/components/select/option.tsx +0 -42
- package/src/components/select/parts.ts +0 -113
- package/src/components/select/primitives.tsx +0 -147
- package/src/components/select/select.tsx +0 -110
- package/src/components/show/index.ts +0 -1
- package/src/components/show/show.tsx +0 -48
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.tsx +0 -81
- package/src/components/split-button/button.tsx +0 -63
- package/src/components/split-button/index.tsx +0 -1
- package/src/components/switch/index.ts +0 -3
- package/src/components/switch/parts.ts +0 -53
- package/src/components/switch/primitives.tsx +0 -51
- package/src/components/switch/switch-indicator.tsx +0 -9
- package/src/components/switch/switch.tsx +0 -27
- package/src/components/table/index.ts +0 -3
- package/src/components/table/parts.ts +0 -83
- package/src/components/table/primitives.tsx +0 -115
- package/src/components/table/table.tsx +0 -73
- package/src/components/tabs/index.ts +0 -3
- package/src/components/tabs/parts.ts +0 -53
- package/src/components/tabs/primitives.tsx +0 -47
- package/src/components/tabs/tabs.tsx +0 -48
- package/src/components/tag/closable.tsx +0 -47
- package/src/components/tag/index.ts +0 -2
- package/src/components/tag/primitives.ts +0 -19
- package/src/components/tag/tag.tsx +0 -39
- package/src/components/text/index.ts +0 -1
- package/src/components/text/text.tsx +0 -55
- package/src/components/theme/index.ts +0 -1
- package/src/components/theme/theme.tsx +0 -34
- package/src/components/toggle/index.ts +0 -2
- package/src/components/toggle/parts.ts +0 -32
- package/src/components/toggle/primitives.tsx +0 -27
- package/src/components/tooltip/index.ts +0 -3
- package/src/components/tooltip/parts.ts +0 -59
- package/src/components/tooltip/primitives.ts +0 -56
- package/src/components/tooltip/tooltip.tsx +0 -46
- package/src/config/defineIcons.ts +0 -24
- package/src/config/icons/checkbox.icons.tsx +0 -98
- package/src/config/icons/default.ts +0 -69
- package/src/config/icons/pinned.icons.tsx +0 -31
- package/src/config/icons/sort.icons.tsx +0 -19
- package/src/config/index.ts +0 -41
- package/src/config/types.ts +0 -53
- package/src/context/cerberus.tsx +0 -53
- package/src/context/confirm-modal.tsx +0 -276
- package/src/context/feature-flags.tsx +0 -63
- package/src/context/field.tsx +0 -70
- package/src/context/navMenu.tsx +0 -89
- package/src/context/prompt-modal.tsx +0 -315
- package/src/context/theme.tsx +0 -83
- package/src/hooks/useModal.ts +0 -63
- package/src/hooks/useRootColors.ts +0 -72
- package/src/hooks/useTheme.ts +0 -121
- package/src/index.client.ts +0 -30
- package/src/index.ts +0 -76
- package/src/system/factory.ts +0 -32
- package/src/system/index.ts +0 -47
- package/src/system/primitive-factory.tsx +0 -180
- package/src/system/types.ts +0 -88
- package/src/types.ts +0 -23
- package/src/utils/index.ts +0 -51
- package/src/utils/localStorage.ts +0 -28
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Field,
|
|
3
|
-
type FieldHelperTextProps as ArkFieldHelperTextProps,
|
|
4
|
-
type FieldInputProps as ArkFieldInputProps,
|
|
5
|
-
type FieldLabelProps as ArkFieldLabelProps,
|
|
6
|
-
type FieldRootProps as ArkFieldRootProps,
|
|
7
|
-
type FieldTextareaProps as ArkFieldTextareaProps,
|
|
8
|
-
type FieldRequiredIndicatorProps as ArkFieldRequiredIndicatorProps,
|
|
9
|
-
} from '@ark-ui/react/field'
|
|
10
|
-
import { ark, type HTMLArkProps } from '@ark-ui/react'
|
|
11
|
-
import { field, type FieldVariantProps } from 'styled-system/recipes'
|
|
12
|
-
import { css, cx } from 'styled-system/css'
|
|
13
|
-
import {
|
|
14
|
-
createCerberusPrimitive,
|
|
15
|
-
type CerberusPrimitiveProps,
|
|
16
|
-
} from '../../system/index'
|
|
17
|
-
import { CerberusFieldInput } from './input'
|
|
18
|
-
import { CerberusFieldErrorText } from './error-text'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This module contains all the primitives of the Field component.
|
|
22
|
-
* @module 'field'
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
const { withSlotRecipe, withNoRecipe } = createCerberusPrimitive(field)
|
|
26
|
-
|
|
27
|
-
// Root
|
|
28
|
-
|
|
29
|
-
export type FieldRootProps = CerberusPrimitiveProps<
|
|
30
|
-
ArkFieldRootProps & FieldVariantProps
|
|
31
|
-
>
|
|
32
|
-
export const FieldRoot = withSlotRecipe(Field.Root, 'root')
|
|
33
|
-
|
|
34
|
-
// Label
|
|
35
|
-
|
|
36
|
-
function FieldLabelEl(props: FieldLabelProps) {
|
|
37
|
-
const { children, hideLabel, className, ...nativeProps } = props
|
|
38
|
-
return (
|
|
39
|
-
<Field.Label
|
|
40
|
-
{...nativeProps}
|
|
41
|
-
className={cx(className, hideLabel && css({ srOnly: true }))}
|
|
42
|
-
>
|
|
43
|
-
{children}
|
|
44
|
-
<Field.RequiredIndicator>(required)</Field.RequiredIndicator>
|
|
45
|
-
</Field.Label>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type FieldLabelProps = CerberusPrimitiveProps<ArkFieldLabelProps> & {
|
|
50
|
-
/**
|
|
51
|
-
* Whether to hide the label visually while keeping it accessible to screen readers.
|
|
52
|
-
*/
|
|
53
|
-
hideLabel?: boolean
|
|
54
|
-
}
|
|
55
|
-
export const FieldLabel = withSlotRecipe(FieldLabelEl, 'label')
|
|
56
|
-
|
|
57
|
-
// Required Indicator
|
|
58
|
-
|
|
59
|
-
function FieldRequiredIndicatorEl(props: FieldRequiredIndicatorProps) {
|
|
60
|
-
return (
|
|
61
|
-
<Field.RequiredIndicator {...props}>(required)</Field.RequiredIndicator>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type FieldRequiredIndicatorProps =
|
|
66
|
-
CerberusPrimitiveProps<ArkFieldRequiredIndicatorProps>
|
|
67
|
-
export const FieldRequiredIndicator = withNoRecipe(FieldRequiredIndicatorEl)
|
|
68
|
-
|
|
69
|
-
// Input
|
|
70
|
-
|
|
71
|
-
export type FieldInputRootProps = CerberusPrimitiveProps<
|
|
72
|
-
HTMLArkProps<'div'> & FieldVariantProps
|
|
73
|
-
>
|
|
74
|
-
export const FieldInputRoot = withSlotRecipe(ark.div, 'inputRoot')
|
|
75
|
-
|
|
76
|
-
export type FieldInputProps = CerberusPrimitiveProps<
|
|
77
|
-
ArkFieldInputProps & FieldVariantProps
|
|
78
|
-
>
|
|
79
|
-
export const FieldInput = withSlotRecipe(Field.Input, 'input')
|
|
80
|
-
|
|
81
|
-
// Helper Text
|
|
82
|
-
|
|
83
|
-
export type FieldHelperTextProps =
|
|
84
|
-
CerberusPrimitiveProps<ArkFieldHelperTextProps>
|
|
85
|
-
export const FieldHelperText = withSlotRecipe(Field.HelperText, 'helperText')
|
|
86
|
-
|
|
87
|
-
// Error Text
|
|
88
|
-
|
|
89
|
-
export type FieldErrorTextProps =
|
|
90
|
-
CerberusPrimitiveProps<ArkFieldHelperTextProps>
|
|
91
|
-
export const FieldErrorText = withSlotRecipe(
|
|
92
|
-
CerberusFieldErrorText,
|
|
93
|
-
'errorText',
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
// Textarea
|
|
97
|
-
|
|
98
|
-
export type FieldTextareaProps = CerberusPrimitiveProps<ArkFieldTextareaProps>
|
|
99
|
-
export const FieldTextarea = withSlotRecipe(Field.Textarea, 'textarea')
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* A named export for the FieldInput component.
|
|
103
|
-
* @description [Field Docs](https://cerberus.digitalu.design/react/field)
|
|
104
|
-
* @example
|
|
105
|
-
* ```tsx
|
|
106
|
-
* import { Input } from '@cerberus/react'
|
|
107
|
-
*
|
|
108
|
-
* <Field
|
|
109
|
-
* label="Enter your email"
|
|
110
|
-
* helperText="We'll never share your email with anyone else."
|
|
111
|
-
* errorText="Email is required."
|
|
112
|
-
* required
|
|
113
|
-
* >
|
|
114
|
-
* <Input type="email" />
|
|
115
|
-
* </Field>
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
export const Input = CerberusFieldInput
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* A named export for the FieldTextarea component.
|
|
122
|
-
* @description [Field Docs](https://cerberus.digitalu.design/react/field)
|
|
123
|
-
* @example
|
|
124
|
-
* ```tsx
|
|
125
|
-
* import { Textarea } from '@cerberus/react'
|
|
126
|
-
*
|
|
127
|
-
* <Field
|
|
128
|
-
* label="Comments"
|
|
129
|
-
* helperText="Your comments are valuable to us."
|
|
130
|
-
* >
|
|
131
|
-
* <Textarea />
|
|
132
|
-
* </Field>
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
export const Textarea = FieldTextarea
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { cx } from 'styled-system/css'
|
|
2
|
-
import { field } from 'styled-system/recipes'
|
|
3
|
-
import type { HTMLAttributes } from 'react'
|
|
4
|
-
|
|
5
|
-
export type FieldIndicatorProps = HTMLAttributes<HTMLSpanElement>
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* The start indicator displays an indicator at the start of the Input.
|
|
9
|
-
* @description [Field Docs](https://cerberus.digitalu.design/react/field)
|
|
10
|
-
*/
|
|
11
|
-
export function FieldStartIndicator(props: FieldIndicatorProps) {
|
|
12
|
-
const styles = field()
|
|
13
|
-
|
|
14
|
-
if (!props.children) return null
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<span
|
|
18
|
-
{...props}
|
|
19
|
-
data-part="start-indicator"
|
|
20
|
-
className={cx(props.className, styles.startIndicator)}
|
|
21
|
-
/>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useFieldContext } from '@ark-ui/react'
|
|
4
|
-
import { cx } from 'styled-system/css'
|
|
5
|
-
import { field } from 'styled-system/recipes'
|
|
6
|
-
import { useCerberusContext } from '../../context/cerberus'
|
|
7
|
-
import type { HTMLAttributes, ReactNode } from 'react'
|
|
8
|
-
|
|
9
|
-
export interface FieldStatusIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
10
|
-
/**
|
|
11
|
-
* The fallback content to display when the field is valid.
|
|
12
|
-
*/
|
|
13
|
-
fallback?: ReactNode
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The invalid status indicator for the Field component.
|
|
18
|
-
* @description [Field Docs](https://cerberus.digitalu.design/react/field)
|
|
19
|
-
* @example
|
|
20
|
-
* ```tsx
|
|
21
|
-
* <FieldRoot>
|
|
22
|
-
* <FieldStatusIndicator />
|
|
23
|
-
* </FieldRoot>
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export function FieldStatusIndicator(props: FieldStatusIndicatorProps) {
|
|
27
|
-
const { fallback, ...nativeProps } = props
|
|
28
|
-
|
|
29
|
-
const fieldContext = useFieldContext()
|
|
30
|
-
const styles = field()
|
|
31
|
-
|
|
32
|
-
const { icons } = useCerberusContext()
|
|
33
|
-
const { invalid: InvalidIcon } = icons
|
|
34
|
-
|
|
35
|
-
if (fieldContext?.invalid) {
|
|
36
|
-
return (
|
|
37
|
-
<span
|
|
38
|
-
{...nativeProps}
|
|
39
|
-
aria-hidden="true"
|
|
40
|
-
data-invalid
|
|
41
|
-
className={cx(nativeProps.className, styles.statusIndicator)}
|
|
42
|
-
>
|
|
43
|
-
<InvalidIcon />
|
|
44
|
-
</span>
|
|
45
|
-
)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<span
|
|
50
|
-
{...nativeProps}
|
|
51
|
-
aria-hidden="true"
|
|
52
|
-
data-part="end-indicator"
|
|
53
|
-
className={cx(nativeProps.className, styles.endIndicator)}
|
|
54
|
-
>
|
|
55
|
-
{fallback}
|
|
56
|
-
</span>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { splitProps } from '../../utils'
|
|
2
|
-
import { FieldsetParts } from './parts'
|
|
3
|
-
import type { FieldsetRootProps } from './primitives'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* This module contains the Fieldset component.
|
|
7
|
-
* @module Fieldset
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export interface FieldsetProps extends FieldsetRootProps {
|
|
11
|
-
/**
|
|
12
|
-
* The legend/title/label of the fieldset group.
|
|
13
|
-
*/
|
|
14
|
-
legend?: string
|
|
15
|
-
/**
|
|
16
|
-
* The description text for the fieldset group.
|
|
17
|
-
*/
|
|
18
|
-
helperText?: string
|
|
19
|
-
/**
|
|
20
|
-
* The error text for the fieldset group shown when the field is invalid.
|
|
21
|
-
*/
|
|
22
|
-
errorText?: string
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* A component used for grouping related fields in a form that is an
|
|
27
|
-
* abstraction of the Fieldset primitives.
|
|
28
|
-
* @description [Fieldset Docs](https://cerberus.digitalu.design/react/fieldset)
|
|
29
|
-
* @description [Primitive Docs](https://ark-ui.com/react/docs/components/fieldset)
|
|
30
|
-
*/
|
|
31
|
-
export function Fieldset(props: FieldsetProps) {
|
|
32
|
-
const [fieldsetProps, { usage }, rootProps] = splitProps(
|
|
33
|
-
props,
|
|
34
|
-
['legend', 'helperText', 'errorText', 'children'],
|
|
35
|
-
['usage'],
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<FieldsetParts.Root {...rootProps}>
|
|
40
|
-
<FieldsetParts.Legend usage={usage}>
|
|
41
|
-
{fieldsetProps.legend}
|
|
42
|
-
</FieldsetParts.Legend>
|
|
43
|
-
<FieldsetParts.HelperText usage={usage}>
|
|
44
|
-
{fieldsetProps.helperText}
|
|
45
|
-
</FieldsetParts.HelperText>
|
|
46
|
-
|
|
47
|
-
{fieldsetProps.children}
|
|
48
|
-
|
|
49
|
-
<FieldsetParts.ErrorText>
|
|
50
|
-
{fieldsetProps.errorText}
|
|
51
|
-
</FieldsetParts.ErrorText>
|
|
52
|
-
</FieldsetParts.Root>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { ElementType } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
FieldsetErrorText,
|
|
4
|
-
FieldsetHelperText,
|
|
5
|
-
FieldsetLegend,
|
|
6
|
-
FieldsetRoot,
|
|
7
|
-
} from './primitives'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* This module contains the parts of the Field component.
|
|
11
|
-
* @module 'field/parts'
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
interface FieldsetPartsValue {
|
|
15
|
-
/**
|
|
16
|
-
* The container of the field.
|
|
17
|
-
*/
|
|
18
|
-
Root: ElementType
|
|
19
|
-
/**
|
|
20
|
-
* The label of the field.
|
|
21
|
-
*/
|
|
22
|
-
Legend: ElementType
|
|
23
|
-
/**
|
|
24
|
-
* The text that displays when the field is valid.
|
|
25
|
-
*/
|
|
26
|
-
HelperText: ElementType
|
|
27
|
-
/**
|
|
28
|
-
* The text that displays when the field is invalid.
|
|
29
|
-
*/
|
|
30
|
-
ErrorText: ElementType
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* An Object containing the parts of the Field component. For users that
|
|
35
|
-
* prefer Object component syntax.
|
|
36
|
-
*
|
|
37
|
-
* @remarks
|
|
38
|
-
*
|
|
39
|
-
* When using object component syntax, you import the FieldParts object and
|
|
40
|
-
* the entire family of components vs. only what you use.
|
|
41
|
-
*/
|
|
42
|
-
export const FieldsetParts: FieldsetPartsValue = {
|
|
43
|
-
Root: FieldsetRoot,
|
|
44
|
-
Legend: FieldsetLegend,
|
|
45
|
-
HelperText: FieldsetHelperText,
|
|
46
|
-
ErrorText: FieldsetErrorText,
|
|
47
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Fieldset,
|
|
3
|
-
type FieldsetHelperTextProps as ArkFieldsetHelperText,
|
|
4
|
-
type FieldsetLegendProps as ArkFieldsetLegendProps,
|
|
5
|
-
type FieldsetRootProps as ArkFieldsetRootProps,
|
|
6
|
-
} from '@ark-ui/react/fieldset'
|
|
7
|
-
import { fieldset, type FieldsetVariantProps } from 'styled-system/recipes'
|
|
8
|
-
import {
|
|
9
|
-
createCerberusPrimitive,
|
|
10
|
-
type CerberusPrimitiveProps,
|
|
11
|
-
} from '../../system/index'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* This module contains all the primitives of the Fieldset component.
|
|
15
|
-
* @module 'react/fieldset'
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
const { withSlotRecipe } = createCerberusPrimitive(fieldset)
|
|
19
|
-
|
|
20
|
-
// Root
|
|
21
|
-
|
|
22
|
-
export const FieldsetRoot = withSlotRecipe(Fieldset.Root, 'root')
|
|
23
|
-
export type FieldsetRootProps = CerberusPrimitiveProps<
|
|
24
|
-
ArkFieldsetRootProps & FieldsetVariantProps
|
|
25
|
-
>
|
|
26
|
-
|
|
27
|
-
// Legend
|
|
28
|
-
|
|
29
|
-
export type FieldsetLegendProps = CerberusPrimitiveProps<
|
|
30
|
-
ArkFieldsetLegendProps & FieldsetVariantProps
|
|
31
|
-
>
|
|
32
|
-
export const FieldsetLegend = withSlotRecipe(Fieldset.Legend, 'legend')
|
|
33
|
-
|
|
34
|
-
// Helper Text
|
|
35
|
-
|
|
36
|
-
export type FieldsetHelperTextProps = CerberusPrimitiveProps<
|
|
37
|
-
ArkFieldsetHelperText & FieldsetVariantProps
|
|
38
|
-
>
|
|
39
|
-
export const FieldsetHelperText = withSlotRecipe(
|
|
40
|
-
Fieldset.HelperText,
|
|
41
|
-
'helperText',
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
// Error Text
|
|
45
|
-
|
|
46
|
-
export type FieldsetErrorTextProps =
|
|
47
|
-
CerberusPrimitiveProps<ArkFieldsetHelperText>
|
|
48
|
-
export const FieldsetErrorText = withSlotRecipe(Fieldset.ErrorText, 'errorText')
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useCallback,
|
|
5
|
-
useMemo,
|
|
6
|
-
type HTMLAttributes,
|
|
7
|
-
type MouseEvent,
|
|
8
|
-
} from 'react'
|
|
9
|
-
import { VStack } from 'styled-system/jsx'
|
|
10
|
-
import { css, cx } from 'styled-system/css'
|
|
11
|
-
import { hstack } from 'styled-system/patterns'
|
|
12
|
-
import { fileStatus, type FileStatusVariantProps } from 'styled-system/recipes'
|
|
13
|
-
import { useCerberusContext } from '../../context/cerberus'
|
|
14
|
-
import { Avatar } from '../avatar/avatar'
|
|
15
|
-
import { Field, FieldHelperText } from '../field/index'
|
|
16
|
-
import { IconButton } from '../icon-button/index'
|
|
17
|
-
import { ProgressBar, type ProgressBarProps } from '../progress/index'
|
|
18
|
-
import { Text } from '../text/index'
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* This module contains the FileStatus component.
|
|
22
|
-
* @module
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The available values of the fileStatus helper Object.
|
|
27
|
-
* @example
|
|
28
|
-
* ```tsx
|
|
29
|
-
* import { fileStatus } from '@cerberus/react'
|
|
30
|
-
* processStatus.TODO // 'todo'
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export type FileStatusKey = (typeof processStatus)[keyof typeof processStatus]
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The actions that can be performed on a file.
|
|
37
|
-
*/
|
|
38
|
-
export type FileStatusActions = 'cancel' | 'retry' | 'delete'
|
|
39
|
-
export interface FileBaseStatusProps extends Omit<
|
|
40
|
-
HTMLAttributes<HTMLDivElement>,
|
|
41
|
-
'onClick'
|
|
42
|
-
> {
|
|
43
|
-
/**
|
|
44
|
-
* A unique identifier for the file status. Required for accessibility.
|
|
45
|
-
*/
|
|
46
|
-
id: string
|
|
47
|
-
/**
|
|
48
|
-
* The name of the file.
|
|
49
|
-
*/
|
|
50
|
-
file: string
|
|
51
|
-
/**
|
|
52
|
-
* The percentage of the file that has been processed.
|
|
53
|
-
*/
|
|
54
|
-
now: ProgressBarProps['now']
|
|
55
|
-
/**
|
|
56
|
-
* The status of the file.
|
|
57
|
-
*/
|
|
58
|
-
status: processStatus
|
|
59
|
-
/**
|
|
60
|
-
* The action to perform on the file when a user clicks the
|
|
61
|
-
* button located at the end of the status card.
|
|
62
|
-
* @param status - The status of the file.
|
|
63
|
-
* @param e - The event object.
|
|
64
|
-
* @example
|
|
65
|
-
* ```tsx
|
|
66
|
-
* <FileStatus file="file.txt" now={0} status={processStatus.TODO} action={(status, e) => console.log(status, e)} />
|
|
67
|
-
* ```
|
|
68
|
-
* @default () => {}
|
|
69
|
-
*/
|
|
70
|
-
onClick: (status: FileStatusActions, e: MouseEvent<HTMLButtonElement>) => void
|
|
71
|
-
}
|
|
72
|
-
export type FileStatusProps = FileBaseStatusProps & FileStatusVariantProps
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* A helper object to represent the status of a file.
|
|
76
|
-
* @example
|
|
77
|
-
* ```tsx
|
|
78
|
-
* import { fileStatus } from '@cerberus/react'
|
|
79
|
-
* processStatus.TODO // 'todo'
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export const enum processStatus {
|
|
83
|
-
TODO = 'todo',
|
|
84
|
-
PROCESSING = 'processing',
|
|
85
|
-
DONE = 'done',
|
|
86
|
-
ERROR = 'error',
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* A component that displays the status of a file during file processing.
|
|
91
|
-
* @see https://cerberus.digitalu.design/react/file-uploader
|
|
92
|
-
* @example
|
|
93
|
-
* ```tsx
|
|
94
|
-
* <FileStatus file="file.txt" now={0} status={processStatus.TODO} action={(status, e) => console.log(status, e)} />
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
export function FileStatus(props: FileStatusProps) {
|
|
98
|
-
const { file, now, status, onClick, ...nativeProps } = props
|
|
99
|
-
const actionLabel = useMemo(() => getStatusActionLabel(status), [status])
|
|
100
|
-
const palette = useMemo(() => getPalette(status), [status])
|
|
101
|
-
const modalIconPalette = useMemo(() => getModalIconPalette(status), [status])
|
|
102
|
-
const styles = useMemo(() => {
|
|
103
|
-
switch (status as processStatus) {
|
|
104
|
-
case processStatus.TODO:
|
|
105
|
-
return fileStatus({ status: 'todo' })
|
|
106
|
-
case processStatus.PROCESSING:
|
|
107
|
-
return fileStatus({ status: 'processing' })
|
|
108
|
-
case processStatus.DONE:
|
|
109
|
-
return fileStatus({ status: 'done' })
|
|
110
|
-
case processStatus.ERROR:
|
|
111
|
-
return fileStatus({ status: 'error' })
|
|
112
|
-
default:
|
|
113
|
-
return fileStatus()
|
|
114
|
-
}
|
|
115
|
-
}, [status])
|
|
116
|
-
|
|
117
|
-
const handleClick = useCallback(
|
|
118
|
-
(e: MouseEvent<HTMLButtonElement>) => {
|
|
119
|
-
const actionStatus = getStatusActionLabel(
|
|
120
|
-
status,
|
|
121
|
-
).toLocaleLowerCase() as FileStatusActions
|
|
122
|
-
onClick(actionStatus, e)
|
|
123
|
-
},
|
|
124
|
-
[onClick, status],
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<div
|
|
129
|
-
{...nativeProps}
|
|
130
|
-
className={cx(nativeProps.className, styles.root, hstack())}
|
|
131
|
-
>
|
|
132
|
-
<Avatar
|
|
133
|
-
gradient={modalIconPalette}
|
|
134
|
-
fallback={<MatchFileStatusIcon size={24} status={status} />}
|
|
135
|
-
/>
|
|
136
|
-
|
|
137
|
-
<VStack alignItems="flex-start" gap="0.12rem" w="full">
|
|
138
|
-
<Text as="small" color="page.text.initial" textStyle="label-sm">
|
|
139
|
-
{file}
|
|
140
|
-
</Text>
|
|
141
|
-
<ProgressBar
|
|
142
|
-
id={props.id}
|
|
143
|
-
label="File upload status"
|
|
144
|
-
now={now}
|
|
145
|
-
size="sm"
|
|
146
|
-
/>
|
|
147
|
-
<Field label="" invalid={modalIconPalette === 'hades-dark'}>
|
|
148
|
-
<FieldHelperText
|
|
149
|
-
className={css({
|
|
150
|
-
color: 'page.text.100',
|
|
151
|
-
})}
|
|
152
|
-
id={`help:${file}`}
|
|
153
|
-
>
|
|
154
|
-
<MatchFileStatusText status={status} now={now} />
|
|
155
|
-
</FieldHelperText>
|
|
156
|
-
</Field>
|
|
157
|
-
</VStack>
|
|
158
|
-
|
|
159
|
-
<IconButton
|
|
160
|
-
ariaLabel={actionLabel}
|
|
161
|
-
onClick={handleClick}
|
|
162
|
-
palette={palette}
|
|
163
|
-
size="sm"
|
|
164
|
-
>
|
|
165
|
-
<MatchStatusAction status={status} />
|
|
166
|
-
</IconButton>
|
|
167
|
-
</div>
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface FileStatusElProps {
|
|
172
|
-
status: FileStatusProps['status']
|
|
173
|
-
size?: 16 | 20 | 24 | 32
|
|
174
|
-
now?: number
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function MatchFileStatusIcon(props: FileStatusElProps) {
|
|
178
|
-
const { icons } = useCerberusContext()
|
|
179
|
-
const {
|
|
180
|
-
waitingFileUploader: TodoIcon,
|
|
181
|
-
fileUploader: FileUploaderIcon,
|
|
182
|
-
invalidAlt: InvalidIcon,
|
|
183
|
-
successNotification: DoneIcon,
|
|
184
|
-
} = icons
|
|
185
|
-
|
|
186
|
-
switch (props.status as processStatus) {
|
|
187
|
-
case processStatus.TODO:
|
|
188
|
-
return <TodoIcon size={props.size} />
|
|
189
|
-
case processStatus.PROCESSING:
|
|
190
|
-
return <FileUploaderIcon size={props.size} />
|
|
191
|
-
case processStatus.DONE:
|
|
192
|
-
return <DoneIcon size={props.size} />
|
|
193
|
-
case processStatus.ERROR:
|
|
194
|
-
return <InvalidIcon size={props.size} />
|
|
195
|
-
default:
|
|
196
|
-
throw new Error('Unknown status')
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function MatchFileStatusText(props: FileStatusElProps) {
|
|
201
|
-
switch (props.status as processStatus) {
|
|
202
|
-
case processStatus.TODO:
|
|
203
|
-
return 'Waiting to upload'
|
|
204
|
-
case processStatus.PROCESSING:
|
|
205
|
-
return `${props.now}% Complete`
|
|
206
|
-
case processStatus.DONE:
|
|
207
|
-
return 'File uploaded successfully'
|
|
208
|
-
case processStatus.ERROR:
|
|
209
|
-
return 'There was an error uploading the file'
|
|
210
|
-
default:
|
|
211
|
-
throw new Error('Invalid status')
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function MatchStatusAction(props: FileStatusElProps) {
|
|
216
|
-
const { icons } = useCerberusContext()
|
|
217
|
-
const { close: CloseIcon, redo: RedoIcon, delete: TrashIcon } = icons
|
|
218
|
-
switch (props.status as processStatus) {
|
|
219
|
-
case processStatus.TODO:
|
|
220
|
-
case processStatus.PROCESSING:
|
|
221
|
-
return <CloseIcon />
|
|
222
|
-
case processStatus.ERROR:
|
|
223
|
-
return <RedoIcon />
|
|
224
|
-
case processStatus.DONE:
|
|
225
|
-
return <TrashIcon />
|
|
226
|
-
default:
|
|
227
|
-
throw new Error('Invalid status')
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function getStatusActionLabel(status: FileStatusKey) {
|
|
232
|
-
switch (status) {
|
|
233
|
-
case processStatus.TODO:
|
|
234
|
-
case processStatus.PROCESSING:
|
|
235
|
-
return 'Cancel'
|
|
236
|
-
case processStatus.ERROR:
|
|
237
|
-
return 'Retry'
|
|
238
|
-
case processStatus.DONE:
|
|
239
|
-
return 'Delete'
|
|
240
|
-
default:
|
|
241
|
-
return ''
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function getPalette(status: FileStatusKey) {
|
|
246
|
-
switch (status) {
|
|
247
|
-
case processStatus.TODO:
|
|
248
|
-
case processStatus.PROCESSING:
|
|
249
|
-
return 'danger'
|
|
250
|
-
case processStatus.ERROR:
|
|
251
|
-
return 'action'
|
|
252
|
-
case processStatus.DONE:
|
|
253
|
-
return 'danger'
|
|
254
|
-
default:
|
|
255
|
-
return 'action'
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function getModalIconPalette(status: FileStatusKey) {
|
|
260
|
-
switch (status) {
|
|
261
|
-
case processStatus.TODO:
|
|
262
|
-
case processStatus.PROCESSING:
|
|
263
|
-
return 'charon-light'
|
|
264
|
-
case processStatus.ERROR:
|
|
265
|
-
return 'hades-dark'
|
|
266
|
-
case processStatus.DONE:
|
|
267
|
-
return 'thanatos-dark'
|
|
268
|
-
default:
|
|
269
|
-
return 'charon-light'
|
|
270
|
-
}
|
|
271
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { PropsWithChildren } from 'react'
|
|
4
|
-
import { useCerberusContext } from '../../context/cerberus'
|
|
5
|
-
import { splitProps } from '../../utils'
|
|
6
|
-
import { Show } from '../show/index'
|
|
7
|
-
import { Avatar } from '../avatar/avatar'
|
|
8
|
-
import { formatFileTypes } from './utils'
|
|
9
|
-
import { ImgPreview } from './img-preview'
|
|
10
|
-
import { FileUploadParts } from './parts'
|
|
11
|
-
import { FileUploadRootProps } from './primitives'
|
|
12
|
-
|
|
13
|
-
export interface FileUploaderProps extends FileUploadRootProps {
|
|
14
|
-
/**
|
|
15
|
-
* The optional heading to display in the FileUploader component.
|
|
16
|
-
*/
|
|
17
|
-
heading?: string
|
|
18
|
-
/**
|
|
19
|
-
* Show a preview of the uploaded image.
|
|
20
|
-
*/
|
|
21
|
-
showPreview?: boolean
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* A component that allows the user to upload files.
|
|
26
|
-
* @see https://cerberus.digitalu.design/docs/components/file-uploader
|
|
27
|
-
*/
|
|
28
|
-
export function FileUploader(props: PropsWithChildren<FileUploaderProps>) {
|
|
29
|
-
const [elProps, rootProps] = splitProps(props, ['heading', 'showPreview'])
|
|
30
|
-
const { showPreview = true } = elProps
|
|
31
|
-
|
|
32
|
-
const { icons } = useCerberusContext()
|
|
33
|
-
const { waitingFileUploader: Icon } = icons
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<FileUploadParts.Root {...rootProps}>
|
|
37
|
-
<FileUploadParts.Dropzone>
|
|
38
|
-
<FileUploadParts.Icon>
|
|
39
|
-
<Avatar gradient="charon-light" fallback={<Icon />} />
|
|
40
|
-
</FileUploadParts.Icon>
|
|
41
|
-
|
|
42
|
-
<FileUploadParts.Content>
|
|
43
|
-
<Show when={elProps.heading}>
|
|
44
|
-
<FileUploadParts.Heading>{elProps.heading}</FileUploadParts.Heading>
|
|
45
|
-
</Show>
|
|
46
|
-
Import {formatFileTypes(rootProps.accept)} files
|
|
47
|
-
<FileUploadParts.Description>
|
|
48
|
-
Drag and drop files or click to upload
|
|
49
|
-
</FileUploadParts.Description>
|
|
50
|
-
</FileUploadParts.Content>
|
|
51
|
-
</FileUploadParts.Dropzone>
|
|
52
|
-
|
|
53
|
-
<Show when={showPreview} fallback={<>{props.children}</>}>
|
|
54
|
-
{() => <ImgPreview />}
|
|
55
|
-
</Show>
|
|
56
|
-
|
|
57
|
-
<FileUploadParts.HiddenInput />
|
|
58
|
-
</FileUploadParts.Root>
|
|
59
|
-
)
|
|
60
|
-
}
|