@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.
Files changed (210) hide show
  1. package/dist/panda.buildinfo.json +23 -0
  2. package/package.json +9 -4
  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,101 +0,0 @@
1
- import type { ElementType } from 'react'
2
- import {
3
- ComboboxClearTrigger,
4
- ComboboxContent,
5
- ComboboxControl,
6
- ComboboxInput,
7
- ComboboxItem,
8
- ComboboxItemGroup,
9
- ComboboxItemGroupLabel,
10
- ComboboxItemIndicator,
11
- ComboboxItemText,
12
- ComboboxLabel,
13
- ComboboxPositioner,
14
- ComboboxRoot,
15
- ComboboxTrigger,
16
- } from './primitives'
17
-
18
- /**
19
- * This module contains the parts of the Combobox parts.
20
- * @module 'combobox/parts'
21
- */
22
-
23
- interface ComboboxPartsValue {
24
- /**
25
- * The context provider for the Select component.
26
- */
27
- Root: ElementType
28
- /**
29
- * The label that appears above the select input.
30
- */
31
- Label: ElementType
32
- /**
33
- * The control that wraps the select trigger.
34
- */
35
- Control: ElementType
36
- /**
37
- * The filterable input of the combobox.
38
- */
39
- Input: ElementType
40
- /**
41
- * The trigger that opens the dropdown.
42
- */
43
- Trigger: ElementType
44
- /**
45
- * The trigger to clear the select input.
46
- */
47
- ClearTrigger: ElementType
48
- /**
49
- * The positioner that wraps the content.
50
- */
51
- Positioner: ElementType
52
- /**
53
- * The content of the select component.
54
- */
55
- Content: ElementType
56
- /**
57
- * A group of items in the select component.
58
- */
59
- ItemGroup: ElementType
60
- /**
61
- * The label for a group of items in the select component.
62
- */
63
- ItemGroupLabel: ElementType
64
- /**
65
- * An individual item in the select component.
66
- */
67
- Item: ElementType
68
- /**
69
- * The text that labels a single radio of the field.
70
- */
71
- ItemText: ElementType
72
- /**
73
- * The indicator that appears when the item has been selected.
74
- */
75
- ItemIndicator: ElementType
76
- }
77
-
78
- /**
79
- * An Object containing the parts of the Radio component. For users that
80
- * prefer Object component syntax.
81
- *
82
- * @remarks
83
- *
84
- * When using object component syntax, you import the ComboboxParts object and
85
- * the entire family of components vs. only what you use.
86
- */
87
- export const ComboboxParts: ComboboxPartsValue = {
88
- Root: ComboboxRoot,
89
- Label: ComboboxLabel,
90
- Control: ComboboxControl,
91
- Input: ComboboxInput,
92
- Trigger: ComboboxTrigger,
93
- ClearTrigger: ComboboxClearTrigger,
94
- Positioner: ComboboxPositioner,
95
- Content: ComboboxContent,
96
- ItemGroup: ComboboxItemGroup,
97
- ItemGroupLabel: ComboboxItemGroupLabel,
98
- Item: ComboboxItem,
99
- ItemText: ComboboxItemText,
100
- ItemIndicator: ComboboxItemIndicator,
101
- }
@@ -1,146 +0,0 @@
1
- import {
2
- Combobox,
3
- type ComboboxClearTriggerProps as ArkComboboxClearTriggerProps,
4
- type ComboboxContentProps as ArkComboboxContentProps,
5
- type ComboboxControlProps as ArkComboboxControlProps,
6
- type ComboboxInputProps as ArkComboboxInputProps,
7
- type ComboboxItemGroupLabelProps as ArkComboboxItemGroupLabelProps,
8
- type ComboboxItemGroupProps as ArkComboboxItemGroupProps,
9
- type ComboboxItemIndicatorProps as ArkComboboxItemIndicatorProps,
10
- type ComboboxItemProps as ArkComboboxItemProps,
11
- type ComboboxItemTextProps as ArkComboboxItemTextProps,
12
- type ComboboxLabelProps as ArkComboboxLabelProps,
13
- type ComboboxPositionerProps as ArkComboboxPositionerProps,
14
- type ComboboxRootProps as ArkComboboxRootProps,
15
- type ComboboxTriggerProps as ArkComboboxTriggerProps,
16
- } from '@ark-ui/react/combobox'
17
- import { ark, type HTMLArkProps } from '@ark-ui/react/factory'
18
- import type { SelectCollectionItem } from '../select/select'
19
- import { combobox, type ComboboxVariantProps } from 'styled-system/recipes'
20
- import {
21
- createCerberusPrimitive,
22
- type CerberusPrimitiveProps,
23
- } from '../../system/index'
24
-
25
- /**
26
- * This module contains the primitives of the Combobox.
27
- * @module 'combobox/primitives'
28
- */
29
-
30
- const { withSlotRecipe } = createCerberusPrimitive(combobox)
31
-
32
- /**
33
- * The ComboboxRoot component is the context provider for the Combobox
34
- * component.
35
- */
36
-
37
- export const ComboboxRoot = withSlotRecipe(Combobox.Root, 'root')
38
- export type ComboboxRootProps = CerberusPrimitiveProps<
39
- ArkComboboxRootProps<SelectCollectionItem> & ComboboxVariantProps
40
- >
41
-
42
- /**
43
- * The label that appears above the combobox input.
44
- */
45
- export const ComboboxLabel = withSlotRecipe(Combobox.Label, 'label')
46
- export type ComboboxLabelProps = CerberusPrimitiveProps<ArkComboboxLabelProps>
47
-
48
- /**
49
- * The control that wraps the combobox input.
50
- */
51
- export const ComboboxControl = withSlotRecipe(Combobox.Control, 'control')
52
- export type ComboboxControlProps =
53
- CerberusPrimitiveProps<ArkComboboxControlProps>
54
-
55
- /**
56
- * The input of the combobox.
57
- */
58
- export const ComboboxInput = withSlotRecipe(Combobox.Input, 'input')
59
- export type ComboboxInputProps = CerberusPrimitiveProps<ArkComboboxInputProps>
60
-
61
- /**
62
- * The trigger that opens the dropdown.
63
- */
64
- export const ComboboxTrigger = withSlotRecipe(Combobox.Trigger, 'trigger')
65
- export type ComboboxTriggerProps =
66
- CerberusPrimitiveProps<ArkComboboxTriggerProps>
67
-
68
- /**
69
- * The trigger to clear the combobox input.
70
- */
71
- export const ComboboxClearTrigger = withSlotRecipe(
72
- Combobox.ClearTrigger,
73
- 'clearTrigger',
74
- )
75
- export type ComboboxClearTriggerProps =
76
- CerberusPrimitiveProps<ArkComboboxClearTriggerProps>
77
-
78
- /**
79
- * The positioner that wraps the content.
80
- */
81
- export const ComboboxPositioner = withSlotRecipe(
82
- Combobox.Positioner,
83
- 'positioner',
84
- )
85
- export type ComboboxPositionerProps =
86
- CerberusPrimitiveProps<ArkComboboxPositionerProps>
87
-
88
- /**
89
- * The content of the combobox component.
90
- */
91
- export const ComboboxContent = withSlotRecipe(Combobox.Content, 'content')
92
- export type ComboboxContentProps = CerberusPrimitiveProps<
93
- ArkComboboxContentProps & ComboboxVariantProps
94
- >
95
-
96
- /**
97
- * A group of items in the combobox component.
98
- */
99
- export const ComboboxItemGroup = withSlotRecipe(Combobox.ItemGroup, 'itemGroup')
100
- export type ComboboxItemGroupProps =
101
- CerberusPrimitiveProps<ArkComboboxItemGroupProps>
102
-
103
- /**
104
- * The label for a group of items in the combobox component.
105
- */
106
- export const ComboboxItemGroupLabel = withSlotRecipe(
107
- Combobox.ItemGroupLabel,
108
- 'itemGroupLabel',
109
- )
110
- export type ComboboxItemGroupLabelProps =
111
- CerberusPrimitiveProps<ArkComboboxItemGroupLabelProps>
112
-
113
- /**
114
- * An individual item in the combobox component.
115
- */
116
- export const ComboboxItem = withSlotRecipe(Combobox.Item, 'item')
117
- export type ComboboxItemProps = CerberusPrimitiveProps<ArkComboboxItemProps>
118
-
119
- /**
120
- * The text that labels a single item of the combobox.
121
- */
122
- export const ComboboxItemText = withSlotRecipe(Combobox.ItemText, 'itemText')
123
- export type ComboboxItemTextProps =
124
- CerberusPrimitiveProps<ArkComboboxItemTextProps>
125
-
126
- /**
127
- * The indicator that appears when the item has been selected.
128
- */
129
- export const ComboboxItemIndicator = withSlotRecipe(
130
- Combobox.ItemIndicator,
131
- 'itemIndicator',
132
- )
133
- export type ComboboxItemIndicatorProps =
134
- CerberusPrimitiveProps<ArkComboboxItemIndicatorProps>
135
-
136
- /**
137
- * The icon that appears at the start of the combobox input.
138
- */
139
- export const ComboboxStartIcon = withSlotRecipe(ark.span, 'startIcon')
140
- export type ComboboxStartIconProps = CerberusPrimitiveProps<
141
- HTMLArkProps<'span'>
142
- >
143
-
144
- // We are only doing this to make the API consistent
145
- export const ComboItemText = ComboboxItemText
146
- export type ComboboxInputValueChangeDetails = Combobox.InputValueChangeDetails
@@ -1,65 +0,0 @@
1
- 'use client'
2
-
3
- import { useCallback, useMemo, useState } from 'react'
4
- import type { ComboboxInputValueChangeDetails } from '@ark-ui/react/combobox'
5
- import type { SelectCollectionItem } from '../select/select'
6
- import { createSelectCollection } from '../select/primitives'
7
-
8
- /**
9
- * This module contains a custom hook that provides a stateful collection for
10
- * the Combobox component.
11
- */
12
-
13
- export interface StatefulCollectionReturn {
14
- /**
15
- * The collection of items.
16
- */
17
- collection: ReturnType<typeof createSelectCollection>
18
- /**
19
- * The filter value split into an array of characters.
20
- */
21
- filterChars: string[]
22
- /**
23
- * The function to handle input changes.
24
- */
25
- handleInputChange: (details: ComboboxInputValueChangeDetails) => void
26
- }
27
-
28
- /**
29
- * This hook provides a stateful collection for the Combobox component.
30
- * It returns a collection of items and a function to handle input changes.
31
- * @param initialItems - The initial collection of items.
32
- * @return An object containing the collection and a function to handle input changes.
33
- */
34
- export function useStatefulCollection(
35
- initialItems: SelectCollectionItem[] = [],
36
- ): StatefulCollectionReturn {
37
- const [items, setItems] = useState(initialItems)
38
- const [filterValue, setFilterValue] = useState<string[]>([])
39
-
40
- const collection = useMemo(() => createSelectCollection(items), [items])
41
-
42
- const handleInputChange = useCallback(
43
- (details: ComboboxInputValueChangeDetails) => {
44
- if (details.inputValue === '') {
45
- return setItems(initialItems)
46
- }
47
- setItems((prev) =>
48
- prev.filter((item) =>
49
- item.value.includes(details.inputValue.toLowerCase()),
50
- ),
51
- )
52
- setFilterValue(details.inputValue.split(''))
53
- },
54
- [initialItems],
55
- )
56
-
57
- return useMemo(
58
- () => ({
59
- collection,
60
- filterChars: filterValue,
61
- handleInputChange,
62
- }),
63
- [collection, filterValue, handleInputChange],
64
- )
65
- }
@@ -1,38 +0,0 @@
1
- 'use client'
2
-
3
- import { createContext, type ReactNode } from 'react'
4
- import type { CTAModalActionReturn } from './utils'
5
-
6
- /**
7
- * This module provides the context for the cta modal.
8
- * @module
9
- */
10
-
11
- export interface ShowCTAModalOptions {
12
- /**
13
- * The heading of the cta modal.
14
- */
15
- heading: string
16
- /**
17
- * The description of the cta modal.
18
- */
19
- description?: string
20
- /**
21
- * The content of the cta modal.
22
- */
23
- content?: ReactNode
24
- /**
25
- * The icon used for the modal Avatar.
26
- */
27
- icon?: ReactNode
28
- /**
29
- * The actions for the cta modal. Requires 2 actions.
30
- */
31
- actions: CTAModalActionReturn
32
- }
33
-
34
- export interface CTAModalValue {
35
- show: (options: ShowCTAModalOptions) => void
36
- }
37
-
38
- export const CTAModalContext = createContext<CTAModalValue | null>(null)
@@ -1,2 +0,0 @@
1
- export * from './provider'
2
- export * from './utils'
@@ -1,186 +0,0 @@
1
- 'use client'
2
-
3
- import {
4
- useCallback,
5
- useContext,
6
- useMemo,
7
- useState,
8
- type MouseEvent,
9
- type PropsWithChildren,
10
- type ReactNode,
11
- } from 'react'
12
- import { HStack, VStack } from 'styled-system/jsx'
13
- import { useCerberusContext } from '../../context/cerberus'
14
- import { Show } from '../show/index'
15
- import { For } from '../for/index'
16
- import { Avatar } from '../avatar/avatar'
17
- import {
18
- Dialog,
19
- DialogDescription,
20
- DialogHeading,
21
- DialogProvider,
22
- DialogRootProps,
23
- } from '../dialog/index'
24
- import { DialogCloseIconTrigger } from '../dialog/close-icon-trigger'
25
- import type { CTAButtonAction, CTAModalActionReturn } from './utils'
26
- import {
27
- CTAModalContext,
28
- type CTAModalValue,
29
- type ShowCTAModalOptions,
30
- } from './context'
31
- import { TriggerItem } from './trigger-item'
32
-
33
- /**
34
- * This module provides the provider and hook for the cta modal.
35
- * @module 'react/cta-modal/provider'
36
- */
37
-
38
- /**
39
- * Provides a CTA modal to the app.
40
- * @see https://cerberus.digitalu.design/react/cta-modal
41
- * @example
42
- * ```tsx
43
- * // Wrap the Provider around the root of the feature.
44
- * <CTAModal>
45
- * <SomeFeatureSection />
46
- * </CTAModal>
47
- *
48
- * // Use the hook to show the cta modal.
49
- * const cta = useCTAModal()
50
- *
51
- * const handleClick = useCallback(async () => {
52
- * const userConsent = await cta.show({
53
- * heading: 'Create or copy a Cohort',
54
- * description:
55
- * 'Create a new cohort or copy and existing one.',
56
- * icon: <Copy size={24} />,
57
- * actions: [
58
- * {
59
- * text: 'Create Cohort',
60
- * onClick: () => {},
61
- * {
62
- * text: 'Copy Cohort',
63
- * onClick: () => {}
64
- * }
65
- * })
66
- * setConsent(userConsent)
67
- * }, [cta])
68
- * ```
69
- */
70
- export function CTAModal(props: PropsWithChildren<DialogRootProps>) {
71
- const { children, ...rootProps } = props
72
-
73
- const [open, setOpen] = useState<boolean>(false)
74
- const [content, setContent] = useState<ShowCTAModalOptions | null>(null)
75
-
76
- const confirmIcon = content?.icon
77
-
78
- const { icons } = useCerberusContext()
79
- const { confirmModal: FallbackIcon } = icons
80
-
81
- const handleShow = useCallback(
82
- (options: ShowCTAModalOptions) => {
83
- setContent({ ...options })
84
- setOpen(true)
85
- },
86
- [setOpen],
87
- )
88
-
89
- const handleActionClick = useCallback(
90
- (event: MouseEvent<HTMLButtonElement>) => {
91
- const index = Number(event.currentTarget.getAttribute('data-index'))
92
- const contentActions = content?.actions as CTAModalActionReturn
93
- const action = contentActions._actions[index] as CTAButtonAction
94
- action?.handleClick?.(event)
95
- setOpen(false)
96
- },
97
- [content, setOpen],
98
- )
99
-
100
- const value = useMemo(
101
- () => ({
102
- show: handleShow,
103
- }),
104
- [handleShow],
105
- )
106
-
107
- return (
108
- <CTAModalContext.Provider value={value}>
109
- {children}
110
-
111
- <DialogProvider
112
- lazyMount
113
- open={open}
114
- onOpenChange={(e) => setOpen(e.open)}
115
- unmountOnExit
116
- {...rootProps}
117
- >
118
- <Dialog
119
- size="sm"
120
- style={{
121
- '--dialog-content-min-h': 'auto',
122
- }}
123
- >
124
- <DialogCloseIconTrigger />
125
-
126
- <VStack gap="xl" w="full">
127
- <VStack alignItems="flex-start" gap="md" w="full">
128
- <VStack gap="lg" w="full">
129
- <Avatar
130
- gradient="charon-light"
131
- fallback={
132
- <Show
133
- when={confirmIcon}
134
- fallback={<FallbackIcon size={24} />}
135
- >
136
- {confirmIcon}
137
- </Show>
138
- }
139
- />
140
- <DialogHeading>{content?.heading}</DialogHeading>
141
-
142
- <Show when={content?.description}>
143
- <DialogDescription textAlign="center">
144
- {content?.description}
145
- </DialogDescription>
146
- </Show>
147
-
148
- <Show when={content?.content}>
149
- <DialogDescription textAlign="center">
150
- {content?.content}
151
- </DialogDescription>
152
- </Show>
153
- </VStack>
154
- </VStack>
155
-
156
- <HStack gap="md" w="full">
157
- <For each={content?.actions._actions}>
158
- {(action, index) => (
159
- <Show
160
- key={index}
161
- when={content?.actions?.type === 'btnAction'}
162
- fallback={
163
- <TriggerItem asChild>{action as ReactNode}</TriggerItem>
164
- }
165
- >
166
- <TriggerItem data-index={index} onClick={handleActionClick}>
167
- {(action as CTAButtonAction)?.text}
168
- </TriggerItem>
169
- </Show>
170
- )}
171
- </For>
172
- </HStack>
173
- </VStack>
174
- </Dialog>
175
- </DialogProvider>
176
- </CTAModalContext.Provider>
177
- )
178
- }
179
-
180
- export function useCTAModal(): CTAModalValue {
181
- const context = useContext(CTAModalContext)
182
- if (context === null) {
183
- throw new Error('useCTAModal must be used within a CTAModal Provider')
184
- }
185
- return context
186
- }
@@ -1,54 +0,0 @@
1
- import { ark } from '@ark-ui/react/factory'
2
- import { css, cx } from 'styled-system/css'
3
- import { button } from 'styled-system/recipes'
4
- import { CerberusProps } from '../../system/types'
5
- import { Button, type ButtonProps } from '../button/button'
6
-
7
- /**
8
- * This module provides the trigger item for the cta modal.
9
- * @module 'react/cta-modal/trigger-item'
10
- */
11
-
12
- export interface TriggerItemProps extends ButtonProps {
13
- asChild?: boolean
14
- }
15
-
16
- /**
17
- * Trigger item for the cta modal which renders content based on the actions.
18
- * type.
19
- */
20
- export function TriggerItem(props: CerberusProps<'button'> & TriggerItemProps) {
21
- const { asChild, children, ...buttonProps } = props
22
-
23
- if (asChild) {
24
- return (
25
- <ark.div
26
- className={cx(
27
- button({
28
- shape: 'rounded',
29
- usage: 'ghost',
30
- }),
31
- css({
32
- w: '1/2',
33
- }),
34
- )}
35
- asChild
36
- >
37
- {children}
38
- </ark.div>
39
- )
40
- }
41
-
42
- return (
43
- <Button
44
- {...buttonProps}
45
- className={css({
46
- w: '1/2',
47
- })}
48
- shape="rounded"
49
- usage="outlined"
50
- >
51
- {children}
52
- </Button>
53
- )
54
- }
@@ -1,57 +0,0 @@
1
- import type { MouseEventHandler, ReactNode } from 'react'
2
-
3
- /**
4
- * This module provide utility functions for the cta modal.
5
- * @module 'react/cta-modal/utils'
6
- */
7
-
8
- export type CTAButtonAction = {
9
- /**
10
- * The text of the button.
11
- */
12
- text: string
13
- /**
14
- * The onClick handler for the button.
15
- */
16
- handleClick: MouseEventHandler<HTMLButtonElement>
17
- }
18
-
19
- export type CTAModalAction = (CTAButtonAction | ReactNode)[]
20
-
21
- export interface CTAModalActionReturn {
22
- /**
23
- * The type of the action content.
24
- */
25
- type: 'reactNode' | 'btnAction'
26
- /**
27
- * The actions for the cta modal. Max of 2 actions.
28
- */
29
- _actions: CTAModalAction
30
- }
31
-
32
- /**
33
- * Creates the action data to pass to the cta modal `show` method.
34
- */
35
- export function createCTAModalActions(
36
- providedActions: CTAModalAction,
37
- ): CTAModalActionReturn {
38
- if (providedActions.length !== 2) {
39
- throw new Error('CTAModal must include 2 actions')
40
- }
41
-
42
- if (
43
- providedActions.every(
44
- (action) => (action as unknown as CTAButtonAction)?.handleClick,
45
- )
46
- ) {
47
- return {
48
- type: 'btnAction',
49
- _actions: providedActions as CTAButtonAction[],
50
- }
51
- }
52
-
53
- return {
54
- type: 'reactNode',
55
- _actions: providedActions as ReactNode[],
56
- }
57
- }
@@ -1,47 +0,0 @@
1
- import { splitProps } from '../../utils/index'
2
- import { DatePickerContent } from './content'
3
- import { DatePickerDayView } from './day-view'
4
- import { DatePickerMonthView } from './month-view'
5
- import { DatePickerYearView } from './year-view'
6
- import { DatePickerContentProps } from './primitives'
7
-
8
- /**
9
- * This module contains an abstraction of the DatePicker component.
10
- * @module 'date-picker/calendar'
11
- */
12
-
13
- export interface DatePickerCalendarProps {
14
- /**
15
- * @deprecated - this is no longer needed.
16
- */
17
- withModal?: boolean
18
- }
19
-
20
- /**
21
- * An abstraction of the DatePicker content components that contain the
22
- * different calendar views and controls.
23
- * @definition [Date Picker docs](https://cerberus.digitalu.design/react/date-picker)
24
- * @example
25
- * ```tsx
26
- * <Field>
27
- * <DatePicker name="start_date">
28
- * <DatePickerLabel>Start date</DatePickerLabel>
29
- * <DatePickerInput />
30
- * <DatePickerCalendar />
31
- * </DatePicker>
32
- * </Field>
33
- * ```
34
- */
35
- export function DatePickerCalendar(
36
- props: DatePickerCalendarProps & DatePickerContentProps,
37
- ) {
38
- const [, contentProps] = splitProps(props, ['withModal'])
39
-
40
- return (
41
- <DatePickerContent {...contentProps}>
42
- <DatePickerDayView />
43
- <DatePickerMonthView view="month" />
44
- <DatePickerYearView view="year" />
45
- </DatePickerContent>
46
- )
47
- }