@cerberus-design/react 1.0.0-rc.5 → 1.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/dist/panda.buildinfo.json +349 -0
  2. package/package.json +8 -5
  3. package/src/components/AnimatingUploadIcon.tsx +0 -83
  4. package/src/components/accordion/index.ts +0 -3
  5. package/src/components/accordion/item-group.tsx +0 -70
  6. package/src/components/accordion/item-indicator.tsx +0 -27
  7. package/src/components/accordion/parts.ts +0 -53
  8. package/src/components/accordion/primitives.tsx +0 -86
  9. package/src/components/admonition/admonition.tsx +0 -62
  10. package/src/components/admonition/index.ts +0 -3
  11. package/src/components/admonition/match-avatar.tsx +0 -52
  12. package/src/components/admonition/parts.ts +0 -53
  13. package/src/components/admonition/primitives.tsx +0 -77
  14. package/src/components/avatar/avatar.tsx +0 -51
  15. package/src/components/avatar/index.ts +0 -5
  16. package/src/components/avatar/parts.ts +0 -37
  17. package/src/components/avatar/primitives.tsx +0 -38
  18. package/src/components/button/button.tsx +0 -62
  19. package/src/components/button/index.ts +0 -3
  20. package/src/components/button/parts.ts +0 -32
  21. package/src/components/button/primitives.tsx +0 -41
  22. package/src/components/carousel/carousel.tsx +0 -55
  23. package/src/components/carousel/index.ts +0 -3
  24. package/src/components/carousel/parts.ts +0 -71
  25. package/src/components/carousel/primitives.ts +0 -58
  26. package/src/components/checkbox/checkbox-icon.tsx +0 -39
  27. package/src/components/checkbox/checkbox.tsx +0 -42
  28. package/src/components/checkbox/index.ts +0 -3
  29. package/src/components/checkbox/parts.ts +0 -59
  30. package/src/components/checkbox/primitives.tsx +0 -77
  31. package/src/components/circular-progress/circular-progress.tsx +0 -49
  32. package/src/components/circular-progress/index.ts +0 -2
  33. package/src/components/circular-progress/primitives.ts +0 -80
  34. package/src/components/clipboard/copy-indicator.tsx +0 -22
  35. package/src/components/clipboard/copy-text.tsx +0 -13
  36. package/src/components/clipboard/index.ts +0 -2
  37. package/src/components/clipboard/parts.ts +0 -74
  38. package/src/components/clipboard/primitives.ts +0 -56
  39. package/src/components/clipboard/trigger.tsx +0 -14
  40. package/src/components/collapsible/index.ts +0 -2
  41. package/src/components/collapsible/parts.ts +0 -53
  42. package/src/components/collapsible/primitives.tsx +0 -53
  43. package/src/components/combobox/combobox.tsx +0 -67
  44. package/src/components/combobox/index.ts +0 -6
  45. package/src/components/combobox/item-group.tsx +0 -19
  46. package/src/components/combobox/item.tsx +0 -30
  47. package/src/components/combobox/parts.ts +0 -101
  48. package/src/components/combobox/primitives.tsx +0 -146
  49. package/src/components/combobox/use-stateful-collection.ts +0 -65
  50. package/src/components/cta-dialog/context.tsx +0 -38
  51. package/src/components/cta-dialog/index.ts +0 -2
  52. package/src/components/cta-dialog/provider.tsx +0 -186
  53. package/src/components/cta-dialog/trigger-item.tsx +0 -54
  54. package/src/components/cta-dialog/utils.ts +0 -57
  55. package/src/components/date-picker/calendar.tsx +0 -47
  56. package/src/components/date-picker/content.tsx +0 -21
  57. package/src/components/date-picker/date-picker.tsx +0 -20
  58. package/src/components/date-picker/day-view.tsx +0 -82
  59. package/src/components/date-picker/index.ts +0 -16
  60. package/src/components/date-picker/input.tsx +0 -26
  61. package/src/components/date-picker/month-view.tsx +0 -49
  62. package/src/components/date-picker/parts.ts +0 -167
  63. package/src/components/date-picker/primitives.tsx +0 -235
  64. package/src/components/date-picker/range-input.tsx +0 -38
  65. package/src/components/date-picker/trigger.tsx +0 -28
  66. package/src/components/date-picker/view-control-group.tsx +0 -54
  67. package/src/components/date-picker/year-view.tsx +0 -47
  68. package/src/components/dialog/close-icon-trigger.tsx +0 -36
  69. package/src/components/dialog/dialog.tsx +0 -42
  70. package/src/components/dialog/index.ts +0 -8
  71. package/src/components/dialog/parts.ts +0 -71
  72. package/src/components/dialog/primitives.tsx +0 -83
  73. package/src/components/feature-flag/feature-flag.tsx +0 -21
  74. package/src/components/feature-flag/index.ts +0 -1
  75. package/src/components/field/error-text.tsx +0 -19
  76. package/src/components/field/field.tsx +0 -93
  77. package/src/components/field/helper-text.tsx +0 -20
  78. package/src/components/field/index.ts +0 -7
  79. package/src/components/field/input.tsx +0 -47
  80. package/src/components/field/parts.ts +0 -77
  81. package/src/components/field/primitives.tsx +0 -135
  82. package/src/components/field/start-indicator.tsx +0 -23
  83. package/src/components/field/status-indicator.tsx +0 -58
  84. package/src/components/fieldset/fieldset.tsx +0 -54
  85. package/src/components/fieldset/index.ts +0 -3
  86. package/src/components/fieldset/parts.ts +0 -47
  87. package/src/components/fieldset/primitives.tsx +0 -48
  88. package/src/components/file-upload/file-status.tsx +0 -271
  89. package/src/components/file-upload/file-uploader.tsx +0 -60
  90. package/src/components/file-upload/helpers.ts +0 -28
  91. package/src/components/file-upload/img-preview.tsx +0 -41
  92. package/src/components/file-upload/index.ts +0 -6
  93. package/src/components/file-upload/parts.tsx +0 -132
  94. package/src/components/file-upload/primitives.ts +0 -161
  95. package/src/components/file-upload/utils.ts +0 -20
  96. package/src/components/for/for.tsx +0 -38
  97. package/src/components/for/index.ts +0 -1
  98. package/src/components/group/index.ts +0 -1
  99. package/src/components/group/primitives.ts +0 -7
  100. package/src/components/icon-button/button.tsx +0 -41
  101. package/src/components/icon-button/index.tsx +0 -2
  102. package/src/components/icon-button/primitives.ts +0 -19
  103. package/src/components/menu/index.ts +0 -2
  104. package/src/components/menu/menu.tsx +0 -144
  105. package/src/components/menu/primitives.ts +0 -84
  106. package/src/components/notifications/center.tsx +0 -88
  107. package/src/components/notifications/close-trigger.tsx +0 -21
  108. package/src/components/notifications/index.ts +0 -5
  109. package/src/components/notifications/match-icon.tsx +0 -41
  110. package/src/components/notifications/parts.ts +0 -53
  111. package/src/components/notifications/primitives.tsx +0 -66
  112. package/src/components/notifications/toaster.ts +0 -13
  113. package/src/components/notifications/types.ts +0 -44
  114. package/src/components/number-input/decrement-trigger.tsx +0 -16
  115. package/src/components/number-input/increment-trigger.tsx +0 -16
  116. package/src/components/number-input/index.ts +0 -3
  117. package/src/components/number-input/input.tsx +0 -33
  118. package/src/components/number-input/parts.ts +0 -65
  119. package/src/components/number-input/primitives.tsx +0 -74
  120. package/src/components/pagination/compact.tsx +0 -25
  121. package/src/components/pagination/index.ts +0 -6
  122. package/src/components/pagination/item-list.tsx +0 -34
  123. package/src/components/pagination/item.tsx +0 -6
  124. package/src/components/pagination/pagination.tsx +0 -53
  125. package/src/components/pagination/parts.ts +0 -65
  126. package/src/components/pagination/primitives.ts +0 -41
  127. package/src/components/pagination/triggers.tsx +0 -55
  128. package/src/components/pin-input/index.ts +0 -3
  129. package/src/components/pin-input/input.tsx +0 -22
  130. package/src/components/pin-input/parts.ts +0 -53
  131. package/src/components/pin-input/primitives.tsx +0 -46
  132. package/src/components/portal/index.ts +0 -1
  133. package/src/components/portal/portal.tsx +0 -28
  134. package/src/components/progress/index.ts +0 -2
  135. package/src/components/progress/primitives.ts +0 -37
  136. package/src/components/progress/progress-bar.tsx +0 -80
  137. package/src/components/radio/index.ts +0 -3
  138. package/src/components/radio/parts.ts +0 -65
  139. package/src/components/radio/primitives.tsx +0 -92
  140. package/src/components/radio/radio.tsx +0 -35
  141. package/src/components/rating/index.ts +0 -8
  142. package/src/components/rating/parts.tsx +0 -65
  143. package/src/components/rating/primitives.tsx +0 -64
  144. package/src/components/rating/rating.tsx +0 -75
  145. package/src/components/select/index.ts +0 -5
  146. package/src/components/select/option-group.tsx +0 -32
  147. package/src/components/select/option.tsx +0 -42
  148. package/src/components/select/parts.ts +0 -113
  149. package/src/components/select/primitives.tsx +0 -147
  150. package/src/components/select/select.tsx +0 -110
  151. package/src/components/show/index.ts +0 -1
  152. package/src/components/show/show.tsx +0 -48
  153. package/src/components/spinner/index.ts +0 -1
  154. package/src/components/spinner/spinner.tsx +0 -81
  155. package/src/components/split-button/button.tsx +0 -63
  156. package/src/components/split-button/index.tsx +0 -1
  157. package/src/components/switch/index.ts +0 -3
  158. package/src/components/switch/parts.ts +0 -53
  159. package/src/components/switch/primitives.tsx +0 -51
  160. package/src/components/switch/switch-indicator.tsx +0 -9
  161. package/src/components/switch/switch.tsx +0 -27
  162. package/src/components/table/index.ts +0 -3
  163. package/src/components/table/parts.ts +0 -83
  164. package/src/components/table/primitives.tsx +0 -115
  165. package/src/components/table/table.tsx +0 -73
  166. package/src/components/tabs/index.ts +0 -3
  167. package/src/components/tabs/parts.ts +0 -53
  168. package/src/components/tabs/primitives.tsx +0 -47
  169. package/src/components/tabs/tabs.tsx +0 -48
  170. package/src/components/tag/closable.tsx +0 -47
  171. package/src/components/tag/index.ts +0 -2
  172. package/src/components/tag/primitives.ts +0 -19
  173. package/src/components/tag/tag.tsx +0 -39
  174. package/src/components/text/index.ts +0 -1
  175. package/src/components/text/text.tsx +0 -55
  176. package/src/components/theme/index.ts +0 -1
  177. package/src/components/theme/theme.tsx +0 -34
  178. package/src/components/toggle/index.ts +0 -2
  179. package/src/components/toggle/parts.ts +0 -32
  180. package/src/components/toggle/primitives.tsx +0 -27
  181. package/src/components/tooltip/index.ts +0 -3
  182. package/src/components/tooltip/parts.ts +0 -59
  183. package/src/components/tooltip/primitives.ts +0 -56
  184. package/src/components/tooltip/tooltip.tsx +0 -46
  185. package/src/config/defineIcons.ts +0 -24
  186. package/src/config/icons/checkbox.icons.tsx +0 -98
  187. package/src/config/icons/default.ts +0 -69
  188. package/src/config/icons/pinned.icons.tsx +0 -31
  189. package/src/config/icons/sort.icons.tsx +0 -19
  190. package/src/config/index.ts +0 -41
  191. package/src/config/types.ts +0 -53
  192. package/src/context/cerberus.tsx +0 -53
  193. package/src/context/confirm-modal.tsx +0 -276
  194. package/src/context/feature-flags.tsx +0 -63
  195. package/src/context/field.tsx +0 -70
  196. package/src/context/navMenu.tsx +0 -89
  197. package/src/context/prompt-modal.tsx +0 -315
  198. package/src/context/theme.tsx +0 -83
  199. package/src/hooks/useModal.ts +0 -63
  200. package/src/hooks/useRootColors.ts +0 -72
  201. package/src/hooks/useTheme.ts +0 -121
  202. package/src/index.client.ts +0 -30
  203. package/src/index.ts +0 -76
  204. package/src/system/factory.ts +0 -32
  205. package/src/system/index.ts +0 -47
  206. package/src/system/primitive-factory.tsx +0 -180
  207. package/src/system/types.ts +0 -88
  208. package/src/types.ts +0 -23
  209. package/src/utils/index.ts +0 -51
  210. package/src/utils/localStorage.ts +0 -28
@@ -1,161 +0,0 @@
1
- import {
2
- FileUpload,
3
- type FileUploadContextProps as ArkFileUploadContextProps,
4
- type FileUploadRootProps as ArkFileUploadRootProps,
5
- type FileUploadLabelProps as ArkFileUploadLabelProps,
6
- type FileUploadDropzoneProps as ArkFileUploadDropzoneProps,
7
- type FileUploadTriggerProps as ArkFileUploadTriggerProps,
8
- type FileUploadClearTriggerProps as ArkFileUploadClearTriggerProps,
9
- type FileUploadItemGroupProps as ArkFileUploadItemGroupProps,
10
- type FileUploadItemProps as ArkFileUploadItemProps,
11
- type FileUploadItemPreviewProps as ArkFileUploadItemPreviewProps,
12
- type FileUploadItemPreviewImageProps as ArkFileUploadItemPreviewImageProps,
13
- type FileUploadItemNameProps as ArkFileUploadItemNameProps,
14
- type FileUploadItemSizeTextProps as ArkFileUploadItemSizeTextProps,
15
- type FileUploadItemDeleteTriggerProps as ArkFileUploadItemDeleteTriggerProps,
16
- type FileUploadHiddenInputProps as ArkFileUploadHiddenInputProps,
17
- } from '@ark-ui/react/file-upload'
18
- import {
19
- fileUploader,
20
- type FileUploaderVariantProps,
21
- } from 'styled-system/recipes'
22
- import {
23
- createCerberusPrimitive,
24
- type CerberusPrimitiveProps,
25
- } from '../../system/index'
26
-
27
- const { withSlotRecipe, withNoRecipe } = createCerberusPrimitive(fileUploader)
28
-
29
- // Root
30
-
31
- export type FileUploadRootProps = CerberusPrimitiveProps<
32
- ArkFileUploadRootProps & FileUploaderVariantProps
33
- >
34
- export const FileUploadRoot = withSlotRecipe(FileUpload.Root, 'root')
35
-
36
- // Dropzone
37
-
38
- export type FileUploadDropzoneProps =
39
- CerberusPrimitiveProps<ArkFileUploadDropzoneProps>
40
- export const FileUploadDropzone = withSlotRecipe(
41
- FileUpload.Dropzone,
42
- 'dropzone',
43
- )
44
-
45
- // Label
46
-
47
- export type FileUploadLabelProps =
48
- CerberusPrimitiveProps<ArkFileUploadLabelProps>
49
- export const FileUploadLabel = withSlotRecipe(FileUpload.Label, 'label')
50
-
51
- // Trigger
52
-
53
- export type FileUploadTriggerProps =
54
- CerberusPrimitiveProps<ArkFileUploadTriggerProps>
55
- export const FileUploadTrigger = withSlotRecipe(FileUpload.Trigger, 'trigger')
56
-
57
- // ClearTrigger
58
-
59
- export type FileUploadClearTriggerProps =
60
- CerberusPrimitiveProps<ArkFileUploadClearTriggerProps>
61
- export const FileUploadClearTrigger = withSlotRecipe(
62
- FileUpload.ClearTrigger,
63
- 'clearTrigger',
64
- )
65
-
66
- // ItemGroup
67
-
68
- export type FileUploadItemGroupProps =
69
- CerberusPrimitiveProps<ArkFileUploadItemGroupProps>
70
- export const FileUploadItemGroup = withSlotRecipe(
71
- FileUpload.ItemGroup,
72
- 'itemGroup',
73
- )
74
-
75
- // Item
76
-
77
- export type FileUploadItemProps = CerberusPrimitiveProps<ArkFileUploadItemProps>
78
- export const FileUploadItem = withSlotRecipe(FileUpload.Item, 'item')
79
-
80
- // ItemPreview
81
-
82
- export type FileUploadItemPreviewProps =
83
- CerberusPrimitiveProps<ArkFileUploadItemPreviewProps>
84
- export const FileUploadItemPreview = withSlotRecipe(
85
- FileUpload.ItemPreview,
86
- 'itemPreview',
87
- )
88
-
89
- // ItemPreviewImage
90
-
91
- export type FileUploadItemPreviewImageProps =
92
- CerberusPrimitiveProps<ArkFileUploadItemPreviewImageProps>
93
- export const FileUploadItemPreviewImage = withSlotRecipe(
94
- FileUpload.ItemPreviewImage,
95
- 'itemPreviewImage',
96
- )
97
-
98
- // ItemName
99
-
100
- export type FileUploadItemNameProps =
101
- CerberusPrimitiveProps<ArkFileUploadItemNameProps>
102
- export const FileUploadItemName = withSlotRecipe(
103
- FileUpload.ItemName,
104
- 'itemName',
105
- )
106
-
107
- // ItemSizeText
108
-
109
- export type FileUploadItemSizeTextProps =
110
- CerberusPrimitiveProps<ArkFileUploadItemSizeTextProps>
111
- export const FileUploadItemSizeText = withSlotRecipe(
112
- FileUpload.ItemSizeText,
113
- 'itemSizeText',
114
- )
115
-
116
- // ItemDeleteTrigger
117
-
118
- export type FileUploadItemDeleteTriggerProps =
119
- CerberusPrimitiveProps<ArkFileUploadItemDeleteTriggerProps>
120
- export const FileUploadItemDeleteTrigger = withSlotRecipe(
121
- FileUpload.ItemDeleteTrigger,
122
- 'itemDeleteTrigger',
123
- )
124
-
125
- // HiddenInput
126
-
127
- export type FileUploadHiddenInputProps =
128
- CerberusPrimitiveProps<ArkFileUploadHiddenInputProps>
129
- export const FileUploadHiddenInput = withNoRecipe(FileUpload.HiddenInput)
130
-
131
- // Context
132
-
133
- export type FileUploadContextProps =
134
- CerberusPrimitiveProps<ArkFileUploadContextProps>
135
- export const FileUploadContext = withNoRecipe(FileUpload.Context)
136
-
137
- // Content
138
-
139
- export type FileUploadContentProps = CerberusPrimitiveProps<HTMLDivElement>
140
- export const FileUploadContent = withSlotRecipe('div', 'label')
141
-
142
- // Icon
143
-
144
- export type FileUploadIconProps = CerberusPrimitiveProps<HTMLDivElement>
145
- export const FileUploadIcon = withSlotRecipe('div', 'icon')
146
-
147
- // Heading
148
-
149
- export type FileUploadHeadingProps =
150
- CerberusPrimitiveProps<HTMLParagraphElement>
151
- export const FileUploadHeading = withSlotRecipe('p', 'heading')
152
-
153
- // Description
154
-
155
- export type FileUploadDescriptionProps =
156
- CerberusPrimitiveProps<HTMLParagraphElement>
157
- export const FileUploadDescription = withSlotRecipe('p', 'description')
158
-
159
- // Types
160
-
161
- export type { UseFileUploadContext } from '@ark-ui/react'
@@ -1,20 +0,0 @@
1
- import { FileUploadRootProps } from '@ark-ui/react'
2
-
3
- /**
4
- * Format a given file type string into a human-readable format.
5
- * @param accept FileUploadRootProps['accept']
6
- * @returns string (e.g., ".png, .jpg, .svg")
7
- */
8
- export function formatFileTypes(accept: FileUploadRootProps['accept']): string {
9
- if (Array.isArray(accept)) return accept.join(', ')
10
- if (typeof accept === 'object') return Object.keys(accept).join(', ')
11
-
12
- if (typeof accept === 'string') {
13
- if (accept.includes('/*')) {
14
- return `any ${accept.split('/')[0]}`
15
- }
16
- return accept.split(',').join(', ')
17
- }
18
-
19
- return 'any'
20
- }
@@ -1,38 +0,0 @@
1
- import type { ReactNode, JSX } from 'react'
2
-
3
- export interface ForProps<T extends readonly unknown[], U extends JSX.Element> {
4
- /**
5
- * The array to iterate over.
6
- */
7
- each: T | undefined | null | false
8
- /**
9
- * The fallback to render when the array is empty.
10
- */
11
- fallback?: JSX.Element
12
- /**
13
- * The children to render for each item in the array.
14
- */
15
- children: (item: T[number], index: number) => U
16
- }
17
-
18
- /**
19
- * The For component is used to iterate over an array and render a list of
20
- * components or display a fallback when the array is empty.
21
- * Inspired by the `<For>` component from SolidJS.
22
- *
23
- * @example
24
- * ```tsx
25
- * <For each={['a', 'b', 'c']}>
26
- * {(item, index) => <div key={index}>{item}</div>}
27
- * </For>
28
- * ```
29
- */
30
- export function For<T extends readonly unknown[], U extends JSX.Element>(
31
- props: ForProps<T, U>,
32
- ) {
33
- if (!props.each || !props.each.length) {
34
- return props.fallback || null
35
- }
36
-
37
- return <>{props.each?.map(props.children) as ReactNode}</>
38
- }
@@ -1 +0,0 @@
1
- export * from './for'
@@ -1 +0,0 @@
1
- export * from './primitives'
@@ -1,7 +0,0 @@
1
- import { group, type GroupVariantProps } from 'styled-system/recipes'
2
- import { type CerberusProps, createCerberusPrimitive } from '../../system/index'
3
-
4
- const { withRecipe } = createCerberusPrimitive(group)
5
-
6
- export type GroupProps = CerberusProps<'div'> & GroupVariantProps
7
- export const Group = withRecipe('div')
@@ -1,41 +0,0 @@
1
- import { IconButtonRoot, type IconButtonRootProps } from './primitives'
2
-
3
- /**
4
- * This module contains the Icon Button component.
5
- * @module
6
- */
7
-
8
- type NonClipboardIconButtonProps = {
9
- /**
10
- * The aria-label attribute for the icon button.
11
- */
12
- ariaLabel: string
13
- clipboard?: never
14
- }
15
-
16
- type ClipboardIconButtonProps = {
17
- ariaLabel?: never
18
- /**
19
- * If true, the icon button is used as a clipboard trigger.
20
- * In this case, the aria-label defaults to "Copy to clipboard".
21
- */
22
- clipboard: true
23
- }
24
-
25
- export type IconButtonProps = IconButtonRootProps &
26
- (NonClipboardIconButtonProps | ClipboardIconButtonProps)
27
- /**
28
- * A component that allows the user to perform actions using an icon
29
- * @see https://cerberus.digitalu.design/react/icon-button
30
- */
31
- export function IconButton(props: IconButtonProps) {
32
- const { ariaLabel, clipboard, ...rootProps } = props
33
- return (
34
- <IconButtonRoot
35
- {...rootProps}
36
- {...(!clipboard && { 'aria-label': ariaLabel })}
37
- data-scope="icon-button"
38
- data-part="root"
39
- />
40
- )
41
- }
@@ -1,2 +0,0 @@
1
- export * from './button'
2
- export * from './primitives'
@@ -1,19 +0,0 @@
1
- import { ark } from '@ark-ui/react/factory'
2
- import { HTMLAttributes } from 'react'
3
- import { iconButton, type IconButtonVariantProps } from 'styled-system/recipes'
4
- import {
5
- CerberusPrimitiveProps,
6
- createCerberusPrimitive,
7
- } from '../../system/index'
8
-
9
- /**
10
- * This module contains the IconButton component primitives.
11
- * @module @cerberus-design/react/components/icon-button/primitives
12
- */
13
-
14
- const { withRecipe } = createCerberusPrimitive(iconButton)
15
-
16
- export type IconButtonRootProps = CerberusPrimitiveProps<
17
- HTMLAttributes<HTMLButtonElement> & IconButtonVariantProps
18
- >
19
- export const IconButtonRoot = withRecipe(ark.button)
@@ -1,2 +0,0 @@
1
- export * from './primitives'
2
- export * from './menu'
@@ -1,144 +0,0 @@
1
- import {
2
- MenuContentEl,
3
- MenuItemEl,
4
- MenuItemGroupEl,
5
- MenuItemGroupLabelEl,
6
- MenuPositioner,
7
- MenuRoot,
8
- MenuSeparatorEl,
9
- MenuTriggerEl,
10
- type MenuContentProps,
11
- type MenuTriggerProps,
12
- } from './primitives'
13
-
14
- /**
15
- * This module contains the Menu named abstractions component.
16
- * @module @cerberus-design/react/components/menu
17
- */
18
-
19
- /**
20
- * The root Menu component which controls the menu.
21
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
22
- *
23
- * @example
24
- * ```tsx
25
- * <Menu>
26
- * <MenuTrigger>Trigger</MenuTrigger>
27
- * </Menu>
28
- */
29
- export const Menu = MenuRoot
30
-
31
- /**
32
- * The MenuTrigger component opens/closes the Menu.
33
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
34
- * @example
35
- * ```tsx
36
- * <Menu>
37
- * <MenuTrigger>
38
- * <Button>Trigger</Button>
39
- * </MenuTrigger>
40
- * </Menu>
41
- */
42
- export function MenuTrigger(props: MenuTriggerProps) {
43
- return <MenuTriggerEl {...props} asChild />
44
- }
45
-
46
- /**
47
- * The MenuContent component is the container for the menu items.
48
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
49
- * @example
50
- * ```tsx
51
- * <Menu>
52
- * <MenuTrigger>
53
- * <Button>Trigger</Button>
54
- * </MenuTrigger>
55
- * <MenuContent>
56
- * <MenuItem value="item_1">Item 1</MenuItem>
57
- * <MenuItem value="item_2">Item 2</MenuItem>
58
- * </MenuContent>
59
- * </Menu>
60
- */
61
- export function MenuContent(props: MenuContentProps) {
62
- return (
63
- <MenuPositioner>
64
- <MenuContentEl {...props} />
65
- </MenuPositioner>
66
- )
67
- }
68
-
69
- /**
70
- * The MenuItem component is a single item in the menu.
71
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
72
- * @example
73
- * ```tsx
74
- * <Menu>
75
- * <MenuTrigger>
76
- * <Button>Trigger</Button>
77
- * </MenuTrigger>
78
- * <MenuContent>
79
- * <MenuItem value="item_1">Item 1</MenuItem>
80
- * <MenuItem value="item_2">Item 2</MenuItem>
81
- * </MenuContent>
82
- * </Menu>
83
- */
84
- export const MenuItem = MenuItemEl
85
-
86
- /**
87
- * The MenuItemGroup component is a group of menu items.
88
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
89
- * @example
90
- * ```tsx
91
- * <Menu>
92
- * <MenuTrigger>
93
- * <Button>Trigger</Button>
94
- * </MenuTrigger>
95
- * <MenuContent>
96
- * <MenuItemGroup>
97
- * <MenuItem value="item_1">Item 1</MenuItem>
98
- * <MenuItem value="item_2">Item 2</MenuItem>
99
- * </MenuItemGroup>
100
- * </MenuContent>
101
- * </Menu>
102
- */
103
- export const MenuItemGroup = MenuItemGroupEl
104
-
105
- /**
106
- * The MenuItemGroupLabel component is the label for a group of menu items.
107
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
108
- * @example
109
- * ```tsx
110
- * <Menu>
111
- * <MenuTrigger>
112
- * <Button>Trigger</Button>
113
- * </MenuTrigger>
114
- * <MenuContent>
115
- * <MenuItemGroup>
116
- * <MenuItemGroupLabel>Group Label</MenuItemGroupLabel>
117
- * <MenuItem value="item_1">Item 1</MenuItem>
118
- * <MenuItem value="item_2">Item 2</MenuItem>
119
- * </MenuItemGroup>
120
- * </MenuContent>
121
- * </Menu>
122
- */
123
- export const MenuGroupLabel = MenuItemGroupLabelEl
124
-
125
- /**
126
- * The MenuSeparator component is a visual divider between menu items.
127
- * @definition [Cerberus docs](https://cerberus.digitalu.design/react/menu/dev)
128
- * @example
129
- * ```tsx
130
- * <Menu>
131
- * <MenuTrigger>
132
- * <Button>Trigger</Button>
133
- * </MenuTrigger>
134
- * <MenuContent>
135
- * <MenuItemGroup>
136
- * <MenuGroupLabel>Group Label</MenuGroupLabel>
137
- * <MenuSeparator />
138
- * <MenuItem value="item_1">Item 1</MenuItem>
139
- * <MenuItem value="item_2">Item 2</MenuItem>
140
- * </MenuItemGroup>
141
- * </MenuContent>
142
- * </Menu>
143
- */
144
- export const MenuSeparator = MenuSeparatorEl
@@ -1,84 +0,0 @@
1
- import {
2
- Menu as ArkMenu,
3
- type MenuRootProps as ArkMenuRootProps,
4
- type MenuTriggerProps as ArkMenuTriggerProps,
5
- type MenuTriggerItemProps as ArkMenuTriggerItemProps,
6
- type MenuIndicatorProps as ArkMenuIndicatorProps,
7
- type MenuPositionerProps as ArkMenuPositionerProps,
8
- type MenuContentProps as ArkMenuContentProps,
9
- type MenuItemProps as ArkMenuItemProps,
10
- type MenuItemGroupProps as ArkMenuItemGroupProps,
11
- type MenuItemGroupLabelProps as ArkMenuItemGroupLabelProps,
12
- type MenuSeparatorProps as ArkMenuSeparatorProps,
13
- } from '@ark-ui/react'
14
- import { menu } from 'styled-system/recipes'
15
- import {
16
- createCerberusPrimitive,
17
- type CerberusPrimitiveProps,
18
- } from '../../system/index'
19
-
20
- /**
21
- * This module contains the Menu component primitives.
22
- * @module @cerberus-design/react/components/menu/primitives
23
- */
24
-
25
- const { withSlotRecipe, withNoRecipe } = createCerberusPrimitive(menu)
26
-
27
- // Root
28
-
29
- export type MenuRootProps = CerberusPrimitiveProps<ArkMenuRootProps>
30
- export const MenuRoot = withSlotRecipe(ArkMenu.Root, 'root')
31
-
32
- // Trigger
33
-
34
- export type MenuTriggerProps = CerberusPrimitiveProps<ArkMenuTriggerProps>
35
- export const MenuTriggerEl = withNoRecipe(ArkMenu.Trigger)
36
-
37
- // TriggerItem
38
-
39
- export type MenuTriggerItemProps =
40
- CerberusPrimitiveProps<ArkMenuTriggerItemProps>
41
- export const MenuTriggerItem = withNoRecipe(ArkMenu.TriggerItem)
42
-
43
- // Indicator
44
-
45
- export type MenuIndicatorProps = CerberusPrimitiveProps<ArkMenuIndicatorProps>
46
- export const MenuIndicator = withNoRecipe(ArkMenu.Indicator)
47
-
48
- // Positioner
49
-
50
- export type MenuPositionerProps = CerberusPrimitiveProps<ArkMenuPositionerProps>
51
- export const MenuPositioner = withSlotRecipe(ArkMenu.Positioner, 'positioner')
52
-
53
- // Content
54
-
55
- export type MenuContentProps = CerberusPrimitiveProps<ArkMenuContentProps>
56
- export const MenuContentEl = withSlotRecipe(ArkMenu.Content, 'content')
57
-
58
- // Item
59
-
60
- export type MenuItemProps = CerberusPrimitiveProps<ArkMenuItemProps>
61
- export const MenuItemEl = withSlotRecipe(ArkMenu.Item, 'item')
62
-
63
- // ItemGroup
64
-
65
- export type MenuItemGroupProps = CerberusPrimitiveProps<ArkMenuItemGroupProps>
66
- export const MenuItemGroupEl = withNoRecipe(ArkMenu.ItemGroup)
67
-
68
- // ItemGroupLabel
69
-
70
- export type MenuItemGroupLabelProps =
71
- CerberusPrimitiveProps<ArkMenuItemGroupLabelProps>
72
- export const MenuItemGroupLabelEl = withSlotRecipe(
73
- ArkMenu.ItemGroupLabel,
74
- 'itemGroupLabel',
75
- )
76
-
77
- // Separator
78
-
79
- export type MenuSeparatorProps = CerberusPrimitiveProps<ArkMenuSeparatorProps>
80
- export const MenuSeparatorEl = withSlotRecipe(ArkMenu.Separator, 'separator')
81
-
82
- // Types
83
-
84
- export type { MenuSelectionDetails } from '@ark-ui/react/menu'
@@ -1,88 +0,0 @@
1
- 'use client'
2
-
3
- import { Toaster, type CreateToasterReturn } from '@ark-ui/react/toast'
4
- import { Box } from 'styled-system/jsx'
5
- import { Button, type ButtonProps } from '../button/button'
6
- import { Show } from '../show/index'
7
- import { NotificationParts } from './parts'
8
- import type {
9
- NotifyOptions,
10
- NotifyOptionsType,
11
- UseNotificationCenterReturn,
12
- } from './types'
13
- import { MatchNotificationIcon } from './match-icon'
14
- import { ToastCloseTrigger } from './close-trigger'
15
- import { toaster } from './toaster'
16
-
17
- /**
18
- * This module contains an abstraction of the Notification parts.
19
- * @module 'notification/center'
20
- */
21
-
22
- export function getEmphasis(type: NotifyOptionsType) {
23
- return type.includes('subtle') ? 'low' : 'high'
24
- }
25
-
26
- export interface NotificationCenterProps {
27
- toaster?: CreateToasterReturn
28
- }
29
-
30
- /**
31
- * The NotificationCenter component is an abstraction for the Notification
32
- * component. It manages displaying all the toasts in the center.
33
- */
34
- export function NotificationCenter(props: NotificationCenterProps) {
35
- const cachedToaster = props.toaster || toaster
36
-
37
- return (
38
- <Toaster toaster={cachedToaster}>
39
- {(toast) => (
40
- <NotificationParts.Root
41
- key={toast.id}
42
- data-emphasis={getEmphasis(
43
- (toast.type ?? 'info') as NotifyOptionsType,
44
- )}
45
- >
46
- <MatchNotificationIcon
47
- type={toast.type as NotifyOptions['palette']}
48
- />
49
-
50
- <Box flex="1" paddingBlock="sm">
51
- <NotificationParts.Heading>{toast.title}</NotificationParts.Heading>
52
- <NotificationParts.Description>
53
- {toast.description}
54
- </NotificationParts.Description>
55
- <Show when={toast.action}>
56
- <NotificationParts.ActionTrigger asChild>
57
- <Button
58
- palette={toast.type as ButtonProps['palette']}
59
- usage="ghost"
60
- size="sm"
61
- >
62
- {toast.action?.label}
63
- </Button>
64
- </NotificationParts.ActionTrigger>
65
- </Show>
66
- </Box>
67
-
68
- <ToastCloseTrigger />
69
- </NotificationParts.Root>
70
- )}
71
- </Toaster>
72
- )
73
- }
74
-
75
- /**
76
- * @deprecated use `toaster` instead
77
- */
78
- export function useNotificationCenter(): UseNotificationCenterReturn {
79
- function notify(options: NotifyOptions) {
80
- toaster.create({
81
- title: options.heading,
82
- description: options.description,
83
- type: options.palette,
84
- action: options.action,
85
- })
86
- }
87
- return { ...toaster, notify }
88
- }
@@ -1,21 +0,0 @@
1
- 'use client'
2
-
3
- import { useCerberusContext } from '../../context/cerberus'
4
- import { NotificationParts } from './parts'
5
- import type { NotificationCloseTriggerProps } from './primitives'
6
-
7
- /**
8
- * This private module contains a abstraction of the close trigger primitive.
9
- * @module 'notification/close-trigger'
10
- */
11
-
12
- export function ToastCloseTrigger(props: NotificationCloseTriggerProps) {
13
- const { icons } = useCerberusContext()
14
- const { close: CloseIcon } = icons
15
-
16
- return (
17
- <NotificationParts.CloseTrigger {...props}>
18
- <CloseIcon />
19
- </NotificationParts.CloseTrigger>
20
- )
21
- }
@@ -1,5 +0,0 @@
1
- export * from './parts'
2
- export * from './primitives'
3
- export * from './center'
4
- export * from './types'
5
- export * from './toaster'
@@ -1,41 +0,0 @@
1
- 'use client'
2
-
3
- import { ark } from '@ark-ui/react/factory'
4
- import { toast } from 'styled-system/recipes'
5
- import { useCerberusContext } from '../../context/cerberus'
6
- import { Spinner } from '../spinner/index'
7
- import type { NotifyOptions, NotifyOptionsType } from './types'
8
- import { getEmphasis } from './center'
9
-
10
- /**
11
- * This private module contains a component that returns the correct icon for a
12
- * notification based on the palette. If there is no result, it is assumed to
13
- * be a 'loading' type.
14
- * @module 'notification/match-icon'
15
- */
16
-
17
- interface MatchNotificationIconProps {
18
- type?: NotifyOptions['palette']
19
- }
20
-
21
- export function MatchNotificationIcon(props: MatchNotificationIconProps) {
22
- const { icons } = useCerberusContext()
23
- const type = props.type?.split('-')[0] || 'info'
24
- const styles = toast()
25
-
26
- const key = `${type}Notification` as keyof typeof icons
27
- const Icon = icons[key] || ToastLoadingIcon
28
-
29
- return (
30
- <ark.div
31
- data-emphasis={getEmphasis(props.type as NotifyOptionsType)}
32
- className={styles.icon}
33
- >
34
- <Icon />
35
- </ark.div>
36
- )
37
- }
38
-
39
- function ToastLoadingIcon() {
40
- return <Spinner size="1rem" />
41
- }