@cerberus-design/react 0.14.2-next-a928afd → 0.14.2-next-0052cda
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/_tsup-dts-rollup.d.cts +111 -34
- package/build/legacy/components/Accordion.cjs +4 -187
- package/build/legacy/components/Accordion.cjs.map +1 -1
- package/build/legacy/components/Accordion.client.cjs +64 -0
- package/build/legacy/components/Accordion.client.cjs.map +1 -0
- package/build/legacy/components/AccordionItemGroup.cjs +41 -185
- package/build/legacy/components/AccordionItemGroup.cjs.map +1 -1
- package/build/legacy/components/Admonition.cjs +89 -239
- package/build/legacy/components/Admonition.cjs.map +1 -1
- package/build/legacy/components/Admonition.client.cjs +219 -0
- package/build/legacy/components/Admonition.client.cjs.map +1 -0
- package/build/legacy/components/AnimatingUploadIcon.cjs.map +1 -1
- package/build/legacy/components/Avatar.cjs +23 -174
- package/build/legacy/components/Avatar.cjs.map +1 -1
- package/build/legacy/components/Checkbox.cjs +22 -168
- package/build/legacy/components/Checkbox.cjs.map +1 -1
- package/build/legacy/components/DatePicker.client.cjs +119 -268
- package/build/legacy/components/DatePicker.client.cjs.map +1 -1
- package/build/legacy/components/DatePicker.server.cjs +17 -271
- package/build/legacy/components/DatePicker.server.cjs.map +1 -1
- package/build/legacy/components/FileStatus.cjs +62 -212
- package/build/legacy/components/FileStatus.cjs.map +1 -1
- package/build/legacy/components/FileUploader.cjs +29 -180
- package/build/legacy/components/FileUploader.cjs.map +1 -1
- package/build/legacy/components/Input.cjs +20 -172
- package/build/legacy/components/Input.cjs.map +1 -1
- package/build/legacy/components/Notification.cjs +25 -176
- package/build/legacy/components/Notification.cjs.map +1 -1
- package/build/legacy/components/Select.cjs +26 -178
- package/build/legacy/components/Select.cjs.map +1 -1
- package/build/legacy/components/Tag.cjs +16 -167
- package/build/legacy/components/Tag.cjs.map +1 -1
- package/build/legacy/components/Toggle.cjs +20 -172
- package/build/legacy/components/Toggle.cjs.map +1 -1
- package/build/legacy/config/defineIcons.cjs +3 -39
- package/build/legacy/config/defineIcons.cjs.map +1 -1
- package/build/legacy/config/{cerbIcons.cjs → index.cjs} +22 -29
- package/build/legacy/config/index.cjs.map +1 -0
- package/build/legacy/config/types.cjs +19 -0
- package/build/legacy/config/types.cjs.map +1 -0
- package/build/legacy/context/cerberus.cjs +46 -0
- package/build/legacy/context/cerberus.cjs.map +1 -0
- package/build/legacy/context/confirm-modal.cjs +58 -207
- package/build/legacy/context/confirm-modal.cjs.map +1 -1
- package/build/legacy/context/cta-modal.cjs +57 -209
- package/build/legacy/context/cta-modal.cjs.map +1 -1
- package/build/legacy/context/notification-center.cjs +55 -206
- package/build/legacy/context/notification-center.cjs.map +1 -1
- package/build/legacy/context/prompt-modal.cjs +83 -233
- package/build/legacy/context/prompt-modal.cjs.map +1 -1
- package/build/legacy/index.cjs +950 -930
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +111 -34
- package/build/modern/{chunk-BVCXVZAF.js → chunk-25HMVHLT.js} +6 -5
- package/build/modern/chunk-25HMVHLT.js.map +1 -0
- package/build/modern/chunk-36N4527B.js +1 -0
- package/build/modern/chunk-5EWCH7AI.js +82 -0
- package/build/modern/chunk-5EWCH7AI.js.map +1 -0
- package/build/modern/chunk-5SNLQZYP.js +25 -0
- package/build/modern/chunk-5SNLQZYP.js.map +1 -0
- package/build/modern/{chunk-6BH5J5GF.js → chunk-CCTLGF5U.js} +18 -17
- package/build/modern/chunk-CCTLGF5U.js.map +1 -0
- package/build/modern/{chunk-HKJMLWVP.js → chunk-EDARV2EI.js} +5 -4
- package/build/modern/chunk-EDARV2EI.js.map +1 -0
- package/build/modern/{chunk-FXLLRVAM.js → chunk-EMNBMH7Z.js} +13 -11
- package/build/modern/chunk-EMNBMH7Z.js.map +1 -0
- package/build/modern/{chunk-PVIMOXSO.js → chunk-GCQMH4QA.js} +5 -4
- package/build/modern/chunk-GCQMH4QA.js.map +1 -0
- package/build/modern/chunk-GITT5645.js +20 -0
- package/build/modern/chunk-GITT5645.js.map +1 -0
- package/build/modern/{chunk-TJCFYL5W.js → chunk-IGHMP4WA.js} +1 -20
- package/build/modern/chunk-IGHMP4WA.js.map +1 -0
- package/build/modern/chunk-ISCJ542I.js +82 -0
- package/build/modern/chunk-ISCJ542I.js.map +1 -0
- package/build/modern/{chunk-HVKM54BA.js → chunk-IW3LIRDG.js} +1 -1
- package/build/modern/chunk-IW3LIRDG.js.map +1 -0
- package/build/modern/{chunk-KWJ5FKX7.js → chunk-JQCRDZNI.js} +8 -6
- package/build/modern/chunk-JQCRDZNI.js.map +1 -0
- package/build/modern/chunk-KDDPAJMR.js +9 -0
- package/build/modern/chunk-KDDPAJMR.js.map +1 -0
- package/build/modern/{chunk-JJZQGR7A.js → chunk-KF35CYT4.js} +8 -6
- package/build/modern/chunk-KF35CYT4.js.map +1 -0
- package/build/modern/{chunk-XOROL3JY.js → chunk-KKHL3ZO4.js} +5 -4
- package/build/modern/chunk-KKHL3ZO4.js.map +1 -0
- package/build/modern/{chunk-U36UZJGZ.js → chunk-MZ3UCDUL.js} +5 -4
- package/build/modern/chunk-MZ3UCDUL.js.map +1 -0
- package/build/modern/{chunk-T2JOPPGL.js → chunk-N24COMHJ.js} +11 -4
- package/build/modern/chunk-N24COMHJ.js.map +1 -0
- package/build/modern/{chunk-CVTON5DQ.js → chunk-N3L3PEMF.js} +2 -2
- package/build/modern/chunk-NJSETNRL.js +68 -0
- package/build/modern/chunk-NJSETNRL.js.map +1 -0
- package/build/modern/{chunk-XXWR7UGH.js → chunk-QKZZHZL4.js} +22 -21
- package/build/modern/chunk-QKZZHZL4.js.map +1 -0
- package/build/modern/{chunk-KPUYKHLW.js → chunk-UMF2TWZN.js} +59 -9
- package/build/modern/chunk-UMF2TWZN.js.map +1 -0
- package/build/modern/{chunk-QK7R2XJM.js → chunk-XQICKZH4.js} +6 -5
- package/build/modern/chunk-XQICKZH4.js.map +1 -0
- package/build/modern/chunk-XZGXRRSQ.js +31 -0
- package/build/modern/chunk-XZGXRRSQ.js.map +1 -0
- package/build/modern/{chunk-5OVH3INN.js → chunk-Z64YZ5IH.js} +18 -18
- package/build/modern/chunk-Z64YZ5IH.js.map +1 -0
- package/build/modern/components/Accordion.client.js +9 -0
- package/build/modern/components/Accordion.client.js.map +1 -0
- package/build/modern/components/Accordion.js +1 -7
- package/build/modern/components/AccordionItemGroup.js +4 -6
- package/build/modern/components/Admonition.client.js +11 -0
- package/build/modern/components/Admonition.client.js.map +1 -0
- package/build/modern/components/Admonition.js +4 -6
- package/build/modern/components/AnimatingUploadIcon.js +1 -1
- package/build/modern/components/Avatar.js +3 -5
- package/build/modern/components/Checkbox.js +2 -5
- package/build/modern/components/DatePicker.client.js +8 -7
- package/build/modern/components/DatePicker.server.js +3 -13
- package/build/modern/components/FileStatus.js +4 -7
- package/build/modern/components/FileUploader.js +3 -6
- package/build/modern/components/Input.js +2 -5
- package/build/modern/components/Notification.js +2 -5
- package/build/modern/components/Select.js +2 -5
- package/build/modern/components/Tag.js +3 -5
- package/build/modern/components/Toggle.js +2 -5
- package/build/modern/config/defineIcons.js +2 -5
- package/build/modern/config/index.js +14 -0
- package/build/modern/config/index.js.map +1 -0
- package/build/modern/config/types.js +2 -0
- package/build/modern/config/types.js.map +1 -0
- package/build/modern/context/cerberus.js +10 -0
- package/build/modern/context/cerberus.js.map +1 -0
- package/build/modern/context/confirm-modal.js +6 -9
- package/build/modern/context/cta-modal.js +6 -9
- package/build/modern/context/notification-center.js +3 -6
- package/build/modern/context/prompt-modal.js +8 -11
- package/build/modern/index.js +105 -94
- package/build/modern/index.js.map +1 -1
- package/package.json +4 -8
- package/src/components/Accordion.client.tsx +46 -0
- package/src/components/Accordion.tsx +0 -37
- package/src/components/AccordionItemGroup.tsx +1 -1
- package/src/components/Admonition.client.tsx +73 -0
- package/src/components/Admonition.tsx +1 -70
- package/src/components/AnimatingUploadIcon.tsx +3 -3
- package/src/components/Avatar.tsx +5 -2
- package/src/components/Checkbox.tsx +10 -3
- package/src/components/DatePicker.client.tsx +79 -7
- package/src/components/DatePicker.server.tsx +2 -75
- package/src/components/FileStatus.tsx +5 -3
- package/src/components/FileUploader.tsx +3 -2
- package/src/components/Input.tsx +4 -2
- package/src/components/Notification.tsx +7 -4
- package/src/components/Select.tsx +5 -2
- package/src/components/Tag.tsx +5 -2
- package/src/components/Toggle.tsx +4 -3
- package/src/config/defineIcons.ts +28 -16
- package/src/config/index.ts +28 -0
- package/src/config/types.ts +42 -0
- package/src/context/cerberus.tsx +44 -0
- package/src/context/confirm-modal.tsx +4 -2
- package/src/context/cta-modal.tsx +5 -4
- package/src/context/prompt-modal.tsx +4 -2
- package/src/index.ts +3 -1
- package/build/legacy/config/cerbIcons.cjs.map +0 -1
- package/build/modern/chunk-5OVH3INN.js.map +0 -1
- package/build/modern/chunk-6BH5J5GF.js.map +0 -1
- package/build/modern/chunk-BC5SZDYY.js +0 -132
- package/build/modern/chunk-BC5SZDYY.js.map +0 -1
- package/build/modern/chunk-BVCXVZAF.js.map +0 -1
- package/build/modern/chunk-CRII2HNX.js +0 -55
- package/build/modern/chunk-CRII2HNX.js.map +0 -1
- package/build/modern/chunk-FXLLRVAM.js.map +0 -1
- package/build/modern/chunk-HKJMLWVP.js.map +0 -1
- package/build/modern/chunk-HVKM54BA.js.map +0 -1
- package/build/modern/chunk-JJZQGR7A.js.map +0 -1
- package/build/modern/chunk-KPUYKHLW.js.map +0 -1
- package/build/modern/chunk-KWJ5FKX7.js.map +0 -1
- package/build/modern/chunk-PVIMOXSO.js.map +0 -1
- package/build/modern/chunk-QK7R2XJM.js.map +0 -1
- package/build/modern/chunk-QMF5ZNDG.js +0 -27
- package/build/modern/chunk-QMF5ZNDG.js.map +0 -1
- package/build/modern/chunk-QQOWWMZ3.js +0 -138
- package/build/modern/chunk-QQOWWMZ3.js.map +0 -1
- package/build/modern/chunk-T2JOPPGL.js.map +0 -1
- package/build/modern/chunk-TJCFYL5W.js.map +0 -1
- package/build/modern/chunk-U36UZJGZ.js.map +0 -1
- package/build/modern/chunk-XOROL3JY.js.map +0 -1
- package/build/modern/chunk-XXWR7UGH.js.map +0 -1
- package/build/modern/config/cerbIcons.js +0 -9
- package/src/config/cerbIcons.ts +0 -73
- /package/build/modern/{config/cerbIcons.js.map → chunk-36N4527B.js.map} +0 -0
- /package/build/modern/{chunk-CVTON5DQ.js.map → chunk-N3L3PEMF.js.map} +0 -0
|
@@ -13,8 +13,6 @@ import { AvatarVariantProps } from '@cerberus/styled-system/recipes';
|
|
|
13
13
|
import { ButtonHTMLAttributes } from 'react';
|
|
14
14
|
import { ButtonVariantProps } from '@cerberus/styled-system/recipes';
|
|
15
15
|
import { CancelDrop } from '@dnd-kit/core';
|
|
16
|
-
import { CarbonIconProps } from '@cerberus/icons';
|
|
17
|
-
import { CarbonIconType } from '@cerberus/icons';
|
|
18
16
|
import { ChangeEvent } from 'react';
|
|
19
17
|
import { CheckboxVariantProps } from '@cerberus/styled-system/recipes';
|
|
20
18
|
import { ClientRect as ClientRect_2 } from '@dnd-kit/core';
|
|
@@ -159,10 +157,6 @@ import { UseDroppableArguments } from '@dnd-kit/core';
|
|
|
159
157
|
import { useSensor } from '@dnd-kit/core';
|
|
160
158
|
import { useSensors } from '@dnd-kit/core';
|
|
161
159
|
|
|
162
|
-
declare let $cerberusIcons: Required<DefinedIcons>;
|
|
163
|
-
export { $cerberusIcons }
|
|
164
|
-
export { $cerberusIcons as $cerberusIcons_alias_1 }
|
|
165
|
-
|
|
166
160
|
/**
|
|
167
161
|
* The context provider for the Accordion family.
|
|
168
162
|
* @definition [Accordion docs](https://cerberus.digitalu.design/react/accordion)
|
|
@@ -405,7 +399,9 @@ export declare function AnimatingUploadIcon(props: AnimatingUploadIconProps): JS
|
|
|
405
399
|
* This module contains an animating icon to use for the FileStatus component.
|
|
406
400
|
* @module
|
|
407
401
|
*/
|
|
408
|
-
export declare
|
|
402
|
+
export declare interface AnimatingUploadIconProps {
|
|
403
|
+
size?: 16 | 20 | 24 | 32;
|
|
404
|
+
}
|
|
409
405
|
|
|
410
406
|
export { Announcements }
|
|
411
407
|
|
|
@@ -523,6 +519,19 @@ export { ButtonProps as ButtonProps_alias_1 }
|
|
|
523
519
|
|
|
524
520
|
export { CancelDrop }
|
|
525
521
|
|
|
522
|
+
/**
|
|
523
|
+
* Cerberus configuration provider.
|
|
524
|
+
* @param props.config The Cerberus configuration created with
|
|
525
|
+
* `makeSystemConfig` helper.
|
|
526
|
+
*/
|
|
527
|
+
declare function CerberusProvider(props: PropsWithChildren<CerberusProviderProps>): JSX_2.Element;
|
|
528
|
+
export { CerberusProvider }
|
|
529
|
+
export { CerberusProvider as CerberusProvider_alias_1 }
|
|
530
|
+
|
|
531
|
+
declare interface CerberusProviderProps {
|
|
532
|
+
config: SystemConfig;
|
|
533
|
+
}
|
|
534
|
+
|
|
526
535
|
/**
|
|
527
536
|
* Checkbox component
|
|
528
537
|
* @definition [ARIA Target Size](https://www.w3.org/WAI/WCAG21/Understanding/target-size.html#:~:text=Understanding%20SC%202.5.,%3ATarget%20Size%20(Level%20AAA)&text=The%20size%20of%20the%20target,Equivalent)
|
|
@@ -1043,8 +1052,6 @@ export { defaultDropAnimation }
|
|
|
1043
1052
|
|
|
1044
1053
|
export { defaultDropAnimationSideEffects }
|
|
1045
1054
|
|
|
1046
|
-
export declare const defaultIcons: DefinedIcons;
|
|
1047
|
-
|
|
1048
1055
|
export { defaultScreenReaderInstructions }
|
|
1049
1056
|
|
|
1050
1057
|
/**
|
|
@@ -1055,34 +1062,51 @@ declare type DefaultThemes = 'cerberus' | 'acheron';
|
|
|
1055
1062
|
export { DefaultThemes }
|
|
1056
1063
|
export { DefaultThemes as DefaultThemes_alias_1 }
|
|
1057
1064
|
|
|
1058
|
-
|
|
1059
|
-
accordionIndicator
|
|
1060
|
-
avatar
|
|
1061
|
-
calendar
|
|
1062
|
-
calendarPrev
|
|
1063
|
-
calendarNext
|
|
1064
|
-
checkbox?:
|
|
1065
|
-
close
|
|
1066
|
-
confirmModal
|
|
1067
|
-
delete
|
|
1068
|
-
promptModal
|
|
1069
|
-
waitingFileUploader
|
|
1070
|
-
fileUploader?:
|
|
1071
|
-
indeterminate?:
|
|
1072
|
-
infoNotification
|
|
1073
|
-
successNotification
|
|
1074
|
-
warningNotification
|
|
1075
|
-
dangerNotification
|
|
1076
|
-
invalid:
|
|
1077
|
-
invalidAlt
|
|
1078
|
-
redo
|
|
1079
|
-
selectArrow
|
|
1080
|
-
toggleChecked
|
|
1065
|
+
declare interface DefinedIcons<T extends IconType = IconType> {
|
|
1066
|
+
accordionIndicator: T;
|
|
1067
|
+
avatar: T;
|
|
1068
|
+
calendar: T;
|
|
1069
|
+
calendarPrev: T;
|
|
1070
|
+
calendarNext: T;
|
|
1071
|
+
checkbox?: T;
|
|
1072
|
+
close: T;
|
|
1073
|
+
confirmModal: T;
|
|
1074
|
+
delete: T;
|
|
1075
|
+
promptModal: T;
|
|
1076
|
+
waitingFileUploader: T;
|
|
1077
|
+
fileUploader?: T;
|
|
1078
|
+
indeterminate?: T;
|
|
1079
|
+
infoNotification: T;
|
|
1080
|
+
successNotification: T;
|
|
1081
|
+
warningNotification: T;
|
|
1082
|
+
dangerNotification: T;
|
|
1083
|
+
invalid: T;
|
|
1084
|
+
invalidAlt: T;
|
|
1085
|
+
redo: T;
|
|
1086
|
+
selectArrow: T;
|
|
1087
|
+
toggleChecked: T;
|
|
1081
1088
|
}
|
|
1089
|
+
export { DefinedIcons }
|
|
1090
|
+
export { DefinedIcons as DefinedIcons_alias_1 }
|
|
1091
|
+
export { DefinedIcons as DefinedIcons_alias_2 }
|
|
1082
1092
|
|
|
1083
|
-
|
|
1093
|
+
/**
|
|
1094
|
+
* Defines the icons that will be used in Cerberus React components via the
|
|
1095
|
+
* CerberusProvider.
|
|
1096
|
+
* @param icons The icons that will be used in Cerberus React components.
|
|
1097
|
+
* @returns Icons object compatible with the CerberusProvider SystemConfig.
|
|
1098
|
+
* @example
|
|
1099
|
+
* ```tsx
|
|
1100
|
+
* const icons = defineIcons({
|
|
1101
|
+
* accordionIndicator: MyAccordionIndicatorIcon,
|
|
1102
|
+
* ...
|
|
1103
|
+
* })
|
|
1104
|
+
* ```
|
|
1105
|
+
*/
|
|
1106
|
+
declare function defineIcons<T extends IconType>(icons: DefinedIcons): Required<DefinedIcons<T>>;
|
|
1084
1107
|
export { defineIcons }
|
|
1085
1108
|
export { defineIcons as defineIcons_alias_1 }
|
|
1109
|
+
export { defineIcons as defineIcons_alias_2 }
|
|
1086
1110
|
|
|
1087
1111
|
declare interface DestructiveConfirmOptions extends BaseConfirmOptions {
|
|
1088
1112
|
/**
|
|
@@ -1613,7 +1637,10 @@ declare interface IconButtonRawProps extends ButtonHTMLAttributes<HTMLButtonElem
|
|
|
1613
1637
|
export { IconButtonRawProps }
|
|
1614
1638
|
export { IconButtonRawProps as IconButtonRawProps_alias_1 }
|
|
1615
1639
|
|
|
1616
|
-
|
|
1640
|
+
declare type IconType = ElementType;
|
|
1641
|
+
export { IconType }
|
|
1642
|
+
export { IconType as IconType_alias_1 }
|
|
1643
|
+
export { IconType as IconType_alias_2 }
|
|
1617
1644
|
|
|
1618
1645
|
/**
|
|
1619
1646
|
* Indeterminate icon for Checkbox component
|
|
@@ -1773,6 +1800,34 @@ declare type LegendProps = HTMLAttributes<HTMLLegendElement> & LabelVariantProps
|
|
|
1773
1800
|
export { LegendProps }
|
|
1774
1801
|
export { LegendProps as LegendProps_alias_1 }
|
|
1775
1802
|
|
|
1803
|
+
/**
|
|
1804
|
+
* Create a system configuration object to be used on the CerberusProvider.
|
|
1805
|
+
* @param options The system configuration options you want to customize.
|
|
1806
|
+
* @returns A CerberusProvider-compatible system configuration object.
|
|
1807
|
+
* @example
|
|
1808
|
+
* ```tsx
|
|
1809
|
+
* const icons = defineIcons({
|
|
1810
|
+
* accordionIndicator: MyAccordionIndicatorIcon,
|
|
1811
|
+
* ...
|
|
1812
|
+
* })
|
|
1813
|
+
* const config = makeSystemConfig({
|
|
1814
|
+
* icons,
|
|
1815
|
+
* })
|
|
1816
|
+
*
|
|
1817
|
+
* // In your app
|
|
1818
|
+
* <CerberusProvider config={config}>
|
|
1819
|
+
* <App />
|
|
1820
|
+
* </CerberusProvider>
|
|
1821
|
+
* ```
|
|
1822
|
+
*/
|
|
1823
|
+
declare function makeSystemConfig(options: SystemConfig): SystemConfig;
|
|
1824
|
+
export { makeSystemConfig }
|
|
1825
|
+
export { makeSystemConfig as makeSystemConfig_alias_1 }
|
|
1826
|
+
|
|
1827
|
+
export declare function MatchAvatar(props: MatchAvatarProps): JSX_2.Element;
|
|
1828
|
+
|
|
1829
|
+
declare type MatchAvatarProps = AdmonitionVariantProps;
|
|
1830
|
+
|
|
1776
1831
|
export { MeasuringConfiguration }
|
|
1777
1832
|
|
|
1778
1833
|
export { MeasuringFrequency }
|
|
@@ -2803,6 +2858,20 @@ declare type StaticTagProps = HTMLAttributes<HTMLSpanElement> & TagVariantProps
|
|
|
2803
2858
|
export { StaticTagProps }
|
|
2804
2859
|
export { StaticTagProps as StaticTagProps_alias_1 }
|
|
2805
2860
|
|
|
2861
|
+
/**
|
|
2862
|
+
* This module contains the types for the Cerberus React configuration.
|
|
2863
|
+
* @module config.types
|
|
2864
|
+
*/
|
|
2865
|
+
declare interface SystemConfig {
|
|
2866
|
+
/**
|
|
2867
|
+
* The icons that will be used in Cerberus React components.
|
|
2868
|
+
*/
|
|
2869
|
+
icons: Required<DefinedIcons>;
|
|
2870
|
+
}
|
|
2871
|
+
export { SystemConfig }
|
|
2872
|
+
export { SystemConfig as SystemConfig_alias_1 }
|
|
2873
|
+
export { SystemConfig as SystemConfig_alias_2 }
|
|
2874
|
+
|
|
2806
2875
|
/**
|
|
2807
2876
|
* The trigger for the Tabs group.
|
|
2808
2877
|
* @definition [Tabs docs](https://cerberus.digitalu.design/react/tabs)
|
|
@@ -3344,6 +3413,14 @@ export { TrProps as TrProps_alias_1 }
|
|
|
3344
3413
|
|
|
3345
3414
|
export { UniqueIdentifier }
|
|
3346
3415
|
|
|
3416
|
+
/**
|
|
3417
|
+
* Returns the Cerberus configuration context.
|
|
3418
|
+
* @returns The Cerberus configuration context.
|
|
3419
|
+
*/
|
|
3420
|
+
declare function useCerberusContext(): SystemConfig;
|
|
3421
|
+
export { useCerberusContext }
|
|
3422
|
+
export { useCerberusContext as useCerberusContext_alias_1 }
|
|
3423
|
+
|
|
3347
3424
|
declare function useConfirmModal(): ConfirmModalValue;
|
|
3348
3425
|
export { useConfirmModal }
|
|
3349
3426
|
export { useConfirmModal as useConfirmModal_alias_1 }
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Avatar
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GCQMH4QA.js";
|
|
4
4
|
import {
|
|
5
5
|
Show
|
|
6
6
|
} from "./chunk-BUVVRQLZ.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
useCerberusContext
|
|
9
|
+
} from "./chunk-GITT5645.js";
|
|
10
10
|
|
|
11
11
|
// src/components/FileUploader.tsx
|
|
12
12
|
import { cx } from "@cerberus/styled-system/css";
|
|
@@ -14,8 +14,9 @@ import { vstack } from "@cerberus/styled-system/patterns";
|
|
|
14
14
|
import { fileUploader } from "@cerberus/styled-system/recipes";
|
|
15
15
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
16
16
|
function FileUploader(props) {
|
|
17
|
+
const { icons } = useCerberusContext();
|
|
17
18
|
const styles = fileUploader();
|
|
18
|
-
const { waitingFileUploader: Icon } =
|
|
19
|
+
const { waitingFileUploader: Icon } = icons;
|
|
19
20
|
return /* @__PURE__ */ jsxs(
|
|
20
21
|
"div",
|
|
21
22
|
{
|
|
@@ -72,4 +73,4 @@ function FileUploader(props) {
|
|
|
72
73
|
export {
|
|
73
74
|
FileUploader
|
|
74
75
|
};
|
|
75
|
-
//# sourceMappingURL=chunk-
|
|
76
|
+
//# sourceMappingURL=chunk-25HMVHLT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FileUploader.tsx"],"sourcesContent":["'use client'\n\nimport { cx } from '@cerberus/styled-system/css'\nimport { vstack } from '@cerberus/styled-system/patterns'\nimport { type InputHTMLAttributes } from 'react'\nimport { Show } from './Show'\nimport { fileUploader } from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../context/cerberus'\nimport { Avatar } from './Avatar'\n\nexport interface FileUploaderProps\n extends InputHTMLAttributes<HTMLInputElement> {\n /**\n * The optional heading to display in the FileUploader component.\n */\n heading?: string\n /**\n * The name of the file input element.\n */\n name: string\n /**\n * Disable the FileUploader component. Good for single-use file uploads.\n */\n disabled?: boolean\n}\n\n/**\n * A component that allows the user to upload files.\n * @see https://cerberus.digitalu.design/react/file-uploader\n */\nexport function FileUploader(props: FileUploaderProps) {\n const { icons } = useCerberusContext()\n const styles = fileUploader()\n const { waitingFileUploader: Icon } = icons\n\n return (\n <div\n {...(props.disabled ? { 'aria-disabled': true } : {})}\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.container,\n )}\n >\n <div className={styles.icon}>\n <Avatar\n gradient=\"charon-light\"\n ariaLabel=\"\"\n icon={<Icon />}\n size=\"md\"\n src=\"\"\n />\n </div>\n\n <label\n className={cx(\n vstack({\n justify: 'center',\n }),\n styles.label,\n )}\n htmlFor={props.name}\n >\n <Show when={Boolean(props.heading)}>\n <p className={styles.heading}>{props.heading}</p>\n </Show>\n Import {props.accept?.replace(',', ', ')} files\n <p className={styles.description}>Click to select files</p>\n <input\n {...props}\n className={cx(props.className, styles.input)}\n type=\"file\"\n />\n </label>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AAEA,SAAS,UAAU;AACnB,SAAS,cAAc;AAGvB,SAAS,oBAAoB;AA2Cb,cAMV,YANU;AAnBT,SAAS,aAAa,OAA0B;AACrD,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,SAAS,aAAa;AAC5B,QAAM,EAAE,qBAAqB,KAAK,IAAI;AAEtC,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAI,MAAM,WAAW,EAAE,iBAAiB,KAAK,IAAI,CAAC;AAAA,MACnD,WAAW;AAAA,QACT,OAAO;AAAA,UACL,SAAS;AAAA,QACX,CAAC;AAAA,QACD,OAAO;AAAA,MACT;AAAA,MAEA;AAAA,4BAAC,SAAI,WAAW,OAAO,MACrB;AAAA,UAAC;AAAA;AAAA,YACC,UAAS;AAAA,YACT,WAAU;AAAA,YACV,MAAM,oBAAC,QAAK;AAAA,YACZ,MAAK;AAAA,YACL,KAAI;AAAA;AAAA,QACN,GACF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW;AAAA,cACT,OAAO;AAAA,gBACL,SAAS;AAAA,cACX,CAAC;AAAA,cACD,OAAO;AAAA,YACT;AAAA,YACA,SAAS,MAAM;AAAA,YAEf;AAAA,kCAAC,QAAK,MAAM,QAAQ,MAAM,OAAO,GAC/B,8BAAC,OAAE,WAAW,OAAO,SAAU,gBAAM,SAAQ,GAC/C;AAAA,cAAO;AAAA,cACC,MAAM,QAAQ,QAAQ,KAAK,IAAI;AAAA,cAAE;AAAA,cACzC,oBAAC,OAAE,WAAW,OAAO,aAAa,mCAAqB;AAAA,cACvD;AAAA,gBAAC;AAAA;AAAA,kBACE,GAAG;AAAA,kBACJ,WAAW,GAAG,MAAM,WAAW,OAAO,KAAK;AAAA,kBAC3C,MAAK;AAAA;AAAA,cACP;AAAA;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-36N4527B.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/components/DatePicker.server.tsx
|
|
2
|
+
import {
|
|
3
|
+
DatePicker as ArkDP
|
|
4
|
+
} from "@ark-ui/react";
|
|
5
|
+
import { cx } from "@cerberus/styled-system/css";
|
|
6
|
+
import { datePicker, label } from "@cerberus/styled-system/recipes";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var datePickerStyles = datePicker();
|
|
9
|
+
function DatePickerLabel(props) {
|
|
10
|
+
const { className, ...arkProps } = props;
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
ArkDP.Label,
|
|
13
|
+
{
|
|
14
|
+
...arkProps,
|
|
15
|
+
className: cx(
|
|
16
|
+
className,
|
|
17
|
+
label({
|
|
18
|
+
size: "sm"
|
|
19
|
+
})
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function DatePickerViewControl(props) {
|
|
25
|
+
return /* @__PURE__ */ jsx(
|
|
26
|
+
ArkDP.Control,
|
|
27
|
+
{
|
|
28
|
+
...props,
|
|
29
|
+
className: cx(props.className, datePickerStyles.viewControl)
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function DatePickerTable(props) {
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
ArkDP.Table,
|
|
36
|
+
{
|
|
37
|
+
...props,
|
|
38
|
+
className: cx(props.className, datePickerStyles.table)
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function DatePickerTableHeader(props) {
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
ArkDP.TableHeader,
|
|
45
|
+
{
|
|
46
|
+
...props,
|
|
47
|
+
className: cx(props.className, datePickerStyles.tableHeader)
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function DatePickerTableCell(props) {
|
|
52
|
+
return /* @__PURE__ */ jsx(
|
|
53
|
+
ArkDP.TableCell,
|
|
54
|
+
{
|
|
55
|
+
...props,
|
|
56
|
+
className: cx(props.className, datePickerStyles.tableCell)
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function DatePickerTableCellTrigger(props) {
|
|
61
|
+
return /* @__PURE__ */ jsx(
|
|
62
|
+
ArkDP.TableCellTrigger,
|
|
63
|
+
{
|
|
64
|
+
...props,
|
|
65
|
+
className: cx(props.className, datePickerStyles.tableCellTrigger)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
var DatePickerView = ArkDP.View;
|
|
70
|
+
var DatePickerContext = ArkDP.Context;
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
DatePickerLabel,
|
|
74
|
+
DatePickerViewControl,
|
|
75
|
+
DatePickerTable,
|
|
76
|
+
DatePickerTableHeader,
|
|
77
|
+
DatePickerTableCell,
|
|
78
|
+
DatePickerTableCellTrigger,
|
|
79
|
+
DatePickerView,
|
|
80
|
+
DatePickerContext
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=chunk-5EWCH7AI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/DatePicker.server.tsx"],"sourcesContent":["import {\n DatePicker as ArkDP,\n type DatePickerLabelProps,\n type DatePickerTableCellProps,\n type DatePickerTableCellTriggerProps,\n type DatePickerTableHeaderProps,\n type DatePickerTableProps,\n type DatePickerViewControlProps,\n} from '@ark-ui/react'\nimport { cx } from '@cerberus/styled-system/css'\nimport { datePicker, label } from '@cerberus/styled-system/recipes'\n\n/**\n * This module contains the DatePicker server family components.\n * @module DatePicker\n */\n\n// We are not exposing this to the public API\nconst datePickerStyles = datePicker()\n\n/**\n * The label component for the DatePicker.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerLabel>\n * <DatePickerLabel.Label>...</DatePickerLabel.Label>\n * </DatePickerLabel>\n * ```\n */\nexport function DatePickerLabel(props: DatePickerLabelProps) {\n const { className, ...arkProps } = props\n return (\n <ArkDP.Label\n {...arkProps}\n className={cx(\n className,\n label({\n size: 'sm',\n }),\n )}\n />\n )\n}\n\n/**\n * The control component for the DatePicker which wraps the triggers to switch\n * between calendar views.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerViewControl>\n * <PrevTrigger />\n * <ViewTrigger />\n * <NextTrigger />\n * </DatePickerViewControl>\n * ```\n */\nexport function DatePickerViewControl(props: DatePickerViewControlProps) {\n return (\n <ArkDP.Control\n {...props}\n className={cx(props.className, datePickerStyles.viewControl)}\n />\n )\n}\n\n/**\n * The table component for the DatePicker.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerTable />\n * ```\n */\nexport function DatePickerTable(props: DatePickerTableProps) {\n return (\n <ArkDP.Table\n {...props}\n className={cx(props.className, datePickerStyles.table)}\n />\n )\n}\n\n/**\n * The header component for the DatePicker table.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerTableHeader />\n * ```\n */\nexport function DatePickerTableHeader(props: DatePickerTableHeaderProps) {\n return (\n <ArkDP.TableHeader\n {...props}\n className={cx(props.className, datePickerStyles.tableHeader)}\n />\n )\n}\n\n/**\n * The cell component for the DatePicker table.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerTableCell />\n * ```\n */\nexport function DatePickerTableCell(props: DatePickerTableCellProps) {\n return (\n <ArkDP.TableCell\n {...props}\n className={cx(props.className, datePickerStyles.tableCell)}\n />\n )\n}\n\n/**\n * The cell component for the DatePicker table.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerTableCell />\n * ```\n */\nexport function DatePickerTableCellTrigger(\n props: DatePickerTableCellTriggerProps,\n) {\n return (\n <ArkDP.TableCellTrigger\n {...props}\n className={cx(props.className, datePickerStyles.tableCellTrigger)}\n />\n )\n}\n\n/**\n * The view container which wraps the control and content components.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerView />\n * ```\n */\nexport const DatePickerView = ArkDP.View\n\n/**\n * The context component for the DatePicker which provides the DatePicker state.\n * @definition [datePicker docs](https://cerberus.digitalu.design/react/date-picker)\n * @example\n * ```tsx\n * <DatePickerContext />\n * ```\n */\nexport const DatePickerContext = ArkDP.Context\n"],"mappings":";AAAA;AAAA,EACE,cAAc;AAAA,OAOT;AACP,SAAS,UAAU;AACnB,SAAS,YAAY,aAAa;AAuB9B;AAfJ,IAAM,mBAAmB,WAAW;AAY7B,SAAS,gBAAgB,OAA6B;AAC3D,QAAM,EAAE,WAAW,GAAG,SAAS,IAAI;AACnC,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT;AAAA,QACA,MAAM;AAAA,UACJ,MAAM;AAAA,QACR,CAAC;AAAA,MACH;AAAA;AAAA,EACF;AAEJ;AAeO,SAAS,sBAAsB,OAAmC;AACvE,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,iBAAiB,WAAW;AAAA;AAAA,EAC7D;AAEJ;AAUO,SAAS,gBAAgB,OAA6B;AAC3D,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,iBAAiB,KAAK;AAAA;AAAA,EACvD;AAEJ;AAUO,SAAS,sBAAsB,OAAmC;AACvE,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,iBAAiB,WAAW;AAAA;AAAA,EAC7D;AAEJ;AAUO,SAAS,oBAAoB,OAAiC;AACnE,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,iBAAiB,SAAS;AAAA;AAAA,EAC3D;AAEJ;AAUO,SAAS,2BACd,OACA;AACA,SACE;AAAA,IAAC,MAAM;AAAA,IAAN;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,GAAG,MAAM,WAAW,iBAAiB,gBAAgB;AAAA;AAAA,EAClE;AAEJ;AAUO,IAAM,iBAAiB,MAAM;AAU7B,IAAM,oBAAoB,MAAM;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckmarkIcon,
|
|
3
|
+
IndeterminateIcon
|
|
4
|
+
} from "./chunk-E3PAEB7Y.js";
|
|
5
|
+
import {
|
|
6
|
+
AnimatingUploadIcon
|
|
7
|
+
} from "./chunk-IW3LIRDG.js";
|
|
8
|
+
|
|
9
|
+
// src/config/defineIcons.ts
|
|
10
|
+
var defaultIcons = {
|
|
11
|
+
checkbox: CheckmarkIcon,
|
|
12
|
+
fileUploader: AnimatingUploadIcon,
|
|
13
|
+
indeterminate: IndeterminateIcon
|
|
14
|
+
};
|
|
15
|
+
function defineIcons(icons) {
|
|
16
|
+
return {
|
|
17
|
+
...defaultIcons,
|
|
18
|
+
...icons
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
defineIcons
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-5SNLQZYP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/config/defineIcons.ts"],"sourcesContent":["import { CheckmarkIcon, IndeterminateIcon } from './icons/checkbox.icons'\nimport { AnimatingUploadIcon } from '../components/AnimatingUploadIcon'\nimport type { DefinedIcons, IconType } from './types'\n\nconst defaultIcons: Pick<\n DefinedIcons,\n 'checkbox' | 'fileUploader' | 'indeterminate'\n> = {\n checkbox: CheckmarkIcon,\n fileUploader: AnimatingUploadIcon,\n indeterminate: IndeterminateIcon,\n}\n\n/**\n * Defines the icons that will be used in Cerberus React components via the\n * CerberusProvider.\n * @param icons The icons that will be used in Cerberus React components.\n * @returns Icons object compatible with the CerberusProvider SystemConfig.\n * @example\n * ```tsx\n * const icons = defineIcons({\n * accordionIndicator: MyAccordionIndicatorIcon,\n * ...\n * })\n * ```\n */\nexport function defineIcons<T extends IconType>(\n icons: DefinedIcons,\n): Required<DefinedIcons<T>> {\n return {\n ...defaultIcons,\n ...icons,\n } as Required<DefinedIcons<T>>\n}\n"],"mappings":";;;;;;;;;AAIA,IAAM,eAGF;AAAA,EACF,UAAU;AAAA,EACV,cAAc;AAAA,EACd,eAAe;AACjB;AAeO,SAAS,YACd,OAC2B;AAC3B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;","names":[]}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Modal
|
|
3
|
-
} from "./chunk-BE4EOU2P.js";
|
|
4
|
-
import {
|
|
5
|
-
ModalDescription
|
|
6
|
-
} from "./chunk-Q7BRMIBR.js";
|
|
7
1
|
import {
|
|
8
2
|
ModalHeader
|
|
9
3
|
} from "./chunk-XY6WL55R.js";
|
|
10
4
|
import {
|
|
11
5
|
ModalHeading
|
|
12
6
|
} from "./chunk-2UXE5PDG.js";
|
|
7
|
+
import {
|
|
8
|
+
Modal
|
|
9
|
+
} from "./chunk-BE4EOU2P.js";
|
|
10
|
+
import {
|
|
11
|
+
ModalDescription
|
|
12
|
+
} from "./chunk-Q7BRMIBR.js";
|
|
13
13
|
import {
|
|
14
14
|
Portal
|
|
15
15
|
} from "./chunk-IQJDVFPP.js";
|
|
16
|
+
import {
|
|
17
|
+
Avatar
|
|
18
|
+
} from "./chunk-GCQMH4QA.js";
|
|
16
19
|
import {
|
|
17
20
|
Button
|
|
18
21
|
} from "./chunk-EXGKZGML.js";
|
|
19
|
-
import {
|
|
20
|
-
Avatar
|
|
21
|
-
} from "./chunk-PVIMOXSO.js";
|
|
22
22
|
import {
|
|
23
23
|
Show
|
|
24
24
|
} from "./chunk-BUVVRQLZ.js";
|
|
25
|
-
import {
|
|
26
|
-
trapFocus
|
|
27
|
-
} from "./chunk-JIZQFTW6.js";
|
|
28
|
-
import {
|
|
29
|
-
$cerberusIcons
|
|
30
|
-
} from "./chunk-QMF5ZNDG.js";
|
|
31
25
|
import {
|
|
32
26
|
useModal
|
|
33
27
|
} from "./chunk-KGQG5JGW.js";
|
|
28
|
+
import {
|
|
29
|
+
useCerberusContext
|
|
30
|
+
} from "./chunk-GITT5645.js";
|
|
31
|
+
import {
|
|
32
|
+
trapFocus
|
|
33
|
+
} from "./chunk-JIZQFTW6.js";
|
|
34
34
|
|
|
35
35
|
// src/context/confirm-modal.tsx
|
|
36
36
|
import {
|
|
@@ -51,8 +51,9 @@ function ConfirmModal(props) {
|
|
|
51
51
|
const resolveRef = useRef(null);
|
|
52
52
|
const [content, setContent] = useState(null);
|
|
53
53
|
const focusTrap = trapFocus(modalRef);
|
|
54
|
-
const ConfirmIcon = $cerberusIcons.confirmModal;
|
|
55
54
|
const kind = content?.kind ?? "non-destructive";
|
|
55
|
+
const { icons } = useCerberusContext();
|
|
56
|
+
const { confirmModal: ConfirmIcon } = icons;
|
|
56
57
|
const palette = useMemo(
|
|
57
58
|
() => kind === "destructive" ? "danger" : "action",
|
|
58
59
|
[kind]
|
|
@@ -170,4 +171,4 @@ export {
|
|
|
170
171
|
ConfirmModal,
|
|
171
172
|
useConfirmModal
|
|
172
173
|
};
|
|
173
|
-
//# sourceMappingURL=chunk-
|
|
174
|
+
//# sourceMappingURL=chunk-CCTLGF5U.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/confirm-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Portal } from '../components/Portal'\nimport { Button } from '../components/Button'\nimport { css } from '@cerberus/styled-system/css'\nimport { hstack } from '@cerberus/styled-system/patterns'\nimport { trapFocus } from '../aria-helpers/trap-focus.aria'\nimport { Show } from '../components/Show'\nimport { Modal } from '../components/Modal'\nimport { useModal } from '../hooks/useModal'\nimport { ModalHeader } from '../components/ModalHeader'\nimport { ModalHeading } from '../components/ModalHeading'\nimport { ModalDescription } from '../components/ModalDescription'\nimport { Avatar } from '../components/Avatar'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from './cerberus'\n\n/**\n * This module provides a context and hook for the confirm modal.\n * @module\n */\n\nexport interface BaseConfirmOptions {\n /**\n * The heading of the confirm modal.\n */\n heading: string\n /**\n * The text for the action button.\n */\n actionText: string\n /**\n * The text for the cancel button.\n */\n cancelText: string\n}\n\nexport interface DestructiveConfirmOptions extends BaseConfirmOptions {\n /**\n * The kind of confirm modal to show.\n */\n kind?: 'destructive'\n /**\n * The description of the confirm modal. Can only be a string for destructive confirm modals.\n */\n description?: string\n}\n\nexport interface NonDestructiveConfirmModalOptions extends BaseConfirmOptions {\n /**\n * The kind of confirm modal to show.\n * @default 'non-destructive'\n */\n kind?: 'non-destructive'\n /**\n * The description of the confirm modal. Can be a ReactNode for non-destructive kind if you need to display text links.\n * @example\n * ```tsx\n * description: <>Use a Fragment because we put the content within a Paragraph tag.</>\n */\n description?: ReactNode\n}\n\nexport type ShowConfirmModalOptions =\n | NonDestructiveConfirmModalOptions\n | DestructiveConfirmOptions\n\nexport type ShowResult =\n | ((value: boolean | PromiseLike<boolean>) => void)\n | null\n\nexport interface ConfirmModalValue {\n show: (options: ShowConfirmModalOptions) => Promise<boolean>\n}\n\nconst ConfirmModalContext = createContext<ConfirmModalValue | null>(null)\n\nexport type ConfirmModalProviderProps = PropsWithChildren<unknown>\n\n/**\n * Provides a confirm modal to the app.\n * @see https://cerberus.digitalu.design/react/confirm-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <ConfirmModal>\n * <SomeFeatureSection />\n * </ConfirmModal>\n *\n * // Use the hook to show the confirm modal.\n * const confirm = useConfirmModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await confirm.show({\n * heading: 'Add new payment method?',\n * description:\n * 'This will add a new payment method to your account to be billed for future purchases.',\n * actionText: 'Yes, add payment method',\n * cancelText: 'No, cancel',\n * })\n * setConsent(userConsent)\n * }, [confirm])\n * ```\n */\nexport function ConfirmModal(\n props: PropsWithChildren<ConfirmModalProviderProps>,\n) {\n const { modalRef, show, close } = useModal()\n const resolveRef = useRef<ShowResult>(null)\n const [content, setContent] = useState<ShowConfirmModalOptions | null>(null)\n const focusTrap = trapFocus(modalRef)\n const kind = content?.kind ?? 'non-destructive'\n\n const { icons } = useCerberusContext()\n const { confirmModal: ConfirmIcon } = icons\n\n const palette = useMemo(\n () => (kind === 'destructive' ? 'danger' : 'action'),\n [kind],\n )\n\n const handleChoice = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const target = e.currentTarget as HTMLButtonElement\n if (target.value === 'true') {\n resolveRef.current?.(true)\n }\n resolveRef.current?.(false)\n close()\n },\n [close],\n )\n\n const handleShow = useCallback(\n (options: ShowConfirmModalOptions) => {\n return new Promise<boolean>((resolve) => {\n setContent({ ...options })\n show()\n resolveRef.current = resolve\n })\n },\n [show],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <ConfirmModalContext.Provider value={value}>\n {props.children}\n\n <Portal>\n <Modal onKeyDown={focusTrap} ref={modalRef}>\n <VStack gap=\"xl\" w=\"full\">\n <ModalHeader>\n <div\n className={hstack({\n justify: 'center',\n w: 'full',\n })}\n >\n <Show\n when={palette === 'danger'}\n fallback={\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n }\n >\n <Avatar\n ariaLabel=\"\"\n gradient=\"hades-dark\"\n icon={<ConfirmIcon size={24} />}\n src=\"\"\n />\n </Show>\n </div>\n <ModalHeading>{content?.heading}</ModalHeading>\n <ModalDescription>{content?.description}</ModalDescription>\n </ModalHeader>\n\n <HStack gap=\"4\" w=\"full\">\n <Button\n autoFocus\n className={css({\n w: '1/2',\n })}\n name=\"confirm\"\n onClick={handleChoice}\n palette={palette}\n value=\"true\"\n >\n {content?.actionText}\n </Button>\n <Button\n className={css({\n w: '1/2',\n })}\n name=\"cancel\"\n onClick={handleChoice}\n usage=\"outlined\"\n value=\"false\"\n >\n {content?.cancelText}\n </Button>\n </HStack>\n </VStack>\n </Modal>\n </Portal>\n </ConfirmModalContext.Provider>\n )\n}\n\nexport function useConfirmModal(): ConfirmModalValue {\n const context = useContext(ConfirmModalContext)\n if (context === null) {\n throw new Error(\n 'useConfirmModal must be used within a ConfirmModal Provider',\n )\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAGP,SAAS,WAAW;AACpB,SAAS,cAAc;AASvB,SAAS,QAAQ,cAAc;AAgJnB,SAagB,KAbhB;AAnFZ,IAAM,sBAAsB,cAAwC,IAAI;AA6BjE,SAAS,aACd,OACA;AACA,QAAM,EAAE,UAAU,MAAM,MAAM,IAAI,SAAS;AAC3C,QAAM,aAAa,OAAmB,IAAI;AAC1C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAyC,IAAI;AAC3E,QAAM,YAAY,UAAU,QAAQ;AACpC,QAAM,OAAO,SAAS,QAAQ;AAE9B,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,cAAc,YAAY,IAAI;AAEtC,QAAM,UAAU;AAAA,IACd,MAAO,SAAS,gBAAgB,WAAW;AAAA,IAC3C,CAAC,IAAI;AAAA,EACP;AAEA,QAAM,eAAe;AAAA,IACnB,CAAC,MAAqC;AACpC,YAAM,SAAS,EAAE;AACjB,UAAI,OAAO,UAAU,QAAQ;AAC3B,mBAAW,UAAU,IAAI;AAAA,MAC3B;AACA,iBAAW,UAAU,KAAK;AAC1B,YAAM;AAAA,IACR;AAAA,IACA,CAAC,KA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AAAA,YACD,MAAK;AAAA,YACL,SAAS;AAAA,YACT;AAAA,YACA,OAAM;AAAA,YAEL,mBAAS;AAAA;AAAA,QACZ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,IAAI;AAAA,cACb,GAAG;AAAA,YACL,CAAC;AAAA,YACD,MAAK;AAAA,YACL,SAAS;AAAA,YACT,OAAM;AAAA,YACN,OAAM;AAAA,YAEL,mBAAS;AAAA;AAAA,QACZ;AAAA,SACF;AAAA,OACF,GACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,kBAAqC;AACnD,QAAM,UAAU,WAAW,mBAAmB;AAC9C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
Show
|
|
3
3
|
} from "./chunk-BUVVRQLZ.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
useCerberusContext
|
|
6
|
+
} from "./chunk-GITT5645.js";
|
|
7
7
|
|
|
8
8
|
// src/components/Tag.tsx
|
|
9
9
|
import { css, cx } from "@cerberus/styled-system/css";
|
|
@@ -18,7 +18,8 @@ function Tag(props) {
|
|
|
18
18
|
const isClosable = Boolean(onClick);
|
|
19
19
|
const shape = isClosable ? "pill" : initShape;
|
|
20
20
|
const closableStyles = isClosable ? closableCss : "";
|
|
21
|
-
const {
|
|
21
|
+
const { icons } = useCerberusContext();
|
|
22
|
+
const { close: Close } = icons;
|
|
22
23
|
return /* @__PURE__ */ jsxs(
|
|
23
24
|
"span",
|
|
24
25
|
{
|
|
@@ -61,4 +62,4 @@ var closableCss = css({
|
|
|
61
62
|
export {
|
|
62
63
|
Tag
|
|
63
64
|
};
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
65
|
+
//# sourceMappingURL=chunk-EDARV2EI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Tag.tsx"],"sourcesContent":["'use client'\n\nimport type {\n HTMLAttributes,\n MouseEventHandler,\n PropsWithChildren,\n} from 'react'\nimport { Show } from './Show'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport {\n iconButton,\n tag,\n type TagVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the tag component.\n * @module\n */\n\nexport type StaticTagProps = HTMLAttributes<HTMLSpanElement> &\n TagVariantProps & {\n /**\n * The action to be performed when the tag is clicked. Not available when\n * the palette or gradient props are provided.\n */\n onClick?: never\n }\n\nexport type ClickableTagProps = HTMLAttributes<HTMLSpanElement> & {\n /**\n * The gradient to apply to the tag. Not available when the onClick prop is\n * provided.\n */\n gradient?: never\n /**\n * The palette to use for the tag. Not available when the onClick prop is\n * provided.\n */\n palette?: never\n /**\n * The action to be performed when the tag is clicked.\n */\n onClick: MouseEventHandler<HTMLSpanElement>\n /**\n * The shape of the tag. Not available when the onClick prop is provided.\n * @type 'pill' | 'rounded'\n * @default 'pill'\n */\n shape?: never\n /**\n * The usage of the tag. Not available when the onClick prop is provided.\n * @type 'filled' | 'outlined'\n * @default 'filled'\n */\n usage?: never\n}\n\nexport type TagProps = StaticTagProps | ClickableTagProps\n\n/**\n * The Tag component is used to display a meta descriptions.\n * @see https://cerberus.digitalu.design/react/tag\n * @example\n * ```tsx\n * <Tag>Tag</Tag>\n * ```\n */\nexport function Tag(props: PropsWithChildren<TagProps>): JSX.Element {\n const { shape: initShape, gradient, onClick, usage, ...nativeProps } = props\n const palette = props?.palette ?? 'page'\n const isClosable = Boolean(onClick)\n const shape = isClosable ? 'pill' : initShape\n const closableStyles = isClosable ? closableCss : ''\n const { icons } = useCerberusContext()\n const { close: Close } = icons\n\n return (\n <span\n {...nativeProps}\n className={cx(\n nativeProps.className,\n tag({\n gradient,\n palette,\n shape,\n usage,\n }),\n closableStyles,\n )}\n >\n {props.children}\n\n <Show when={isClosable}>\n <button\n aria-label=\"Close\"\n className={iconButton({\n palette: 'action',\n usage: 'filled',\n size: 'sm',\n })}\n onClick={onClick}\n >\n <Close />\n </button>\n </Show>\n </span>\n )\n}\n\nconst closableCss = css({\n bgColor: 'action.bg.active',\n color: 'action.text.initial',\n paddingInlineEnd: '0',\n})\n"],"mappings":";;;;;;;;AAQA,SAAS,KAAK,UAAU;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAkEH,SAyBM,KAzBN;AAVG,SAAS,IAAI,OAAiD;AACnE,QAAM,EAAE,OAAO,WAAW,UAAU,SAAS,OAAO,GAAG,YAAY,IAAI;AACvE,QAAM,UAAU,OAAO,WAAW;AAClC,QAAM,aAAa,QAAQ,OAAO;AAClC,QAAM,QAAQ,aAAa,SAAS;AACpC,QAAM,iBAAiB,aAAa,cAAc;AAClD,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,OAAO,MAAM,IAAI;AAEzB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW;AAAA,QACT,YAAY;AAAA,QACZ,IAAI;AAAA,UACF;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,QACD;AAAA,MACF;AAAA,MAEC;AAAA,cAAM;AAAA,QAEP,oBAAC,QAAK,MAAM,YACV;AAAA,UAAC;AAAA;AAAA,YACC,cAAW;AAAA,YACX,WAAW,WAAW;AAAA,cACpB,SAAS;AAAA,cACT,OAAO;AAAA,cACP,MAAM;AAAA,YACR,CAAC;AAAA,YACD;AAAA,YAEA,8BAAC,SAAM;AAAA;AAAA,QACT,GACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAM,cAAc,IAAI;AAAA,EACtB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,kBAAkB;AACpB,CAAC;","names":[]}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ProgressBar
|
|
3
3
|
} from "./chunk-WZJ5UQNM.js";
|
|
4
|
+
import {
|
|
5
|
+
IconButton
|
|
6
|
+
} from "./chunk-APD6IX5R.js";
|
|
4
7
|
import {
|
|
5
8
|
FieldMessage
|
|
6
9
|
} from "./chunk-JWIJHSI6.js";
|
|
10
|
+
import {
|
|
11
|
+
Avatar
|
|
12
|
+
} from "./chunk-GCQMH4QA.js";
|
|
7
13
|
import {
|
|
8
14
|
Field
|
|
9
15
|
} from "./chunk-UZDVOIW5.js";
|
|
10
16
|
import {
|
|
11
|
-
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
Avatar
|
|
15
|
-
} from "./chunk-PVIMOXSO.js";
|
|
16
|
-
import {
|
|
17
|
-
$cerberusIcons
|
|
18
|
-
} from "./chunk-QMF5ZNDG.js";
|
|
17
|
+
useCerberusContext
|
|
18
|
+
} from "./chunk-GITT5645.js";
|
|
19
19
|
|
|
20
20
|
// src/components/FileStatus.tsx
|
|
21
21
|
import {
|
|
@@ -134,12 +134,13 @@ function FileStatus(props) {
|
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
function MatchFileStatusIcon(props) {
|
|
137
|
+
const { icons } = useCerberusContext();
|
|
137
138
|
const {
|
|
138
139
|
waitingFileUploader: TodoIcon,
|
|
139
140
|
fileUploader: FileUploaderIcon,
|
|
140
141
|
invalidAlt: InvalidIcon,
|
|
141
142
|
successNotification: DoneIcon
|
|
142
|
-
} =
|
|
143
|
+
} = icons;
|
|
143
144
|
switch (props.status) {
|
|
144
145
|
case "todo" /* TODO */:
|
|
145
146
|
return /* @__PURE__ */ jsx(TodoIcon, { size: props.size });
|
|
@@ -168,7 +169,8 @@ function MatchFileStatusText(props) {
|
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
function MatchStatusAction(props) {
|
|
171
|
-
const {
|
|
172
|
+
const { icons } = useCerberusContext();
|
|
173
|
+
const { close: CloseIcon, redo: RedoIcon, delete: TrashIcon } = icons;
|
|
172
174
|
switch (props.status) {
|
|
173
175
|
case "todo" /* TODO */:
|
|
174
176
|
case "processing" /* PROCESSING */:
|
|
@@ -225,4 +227,4 @@ export {
|
|
|
225
227
|
processStatus,
|
|
226
228
|
FileStatus
|
|
227
229
|
};
|
|
228
|
-
//# sourceMappingURL=chunk-
|
|
230
|
+
//# sourceMappingURL=chunk-EMNBMH7Z.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/FileStatus.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n useMemo,\n type HTMLAttributes,\n type MouseEvent,\n} from 'react'\nimport {\n fileStatus,\n type FileStatusVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { hstack, vstack } from '@cerberus/styled-system/patterns'\nimport { Field } from '../context/field'\nimport { useCerberusContext } from '../context/cerberus'\nimport { FieldMessage } from './FieldMessage'\nimport { ProgressBar, type ProgressBarProps } from './ProgressBar'\nimport { IconButton } from './IconButton'\nimport { Avatar } from './Avatar'\n\n/**\n * This module contains the FileStatus component.\n * @module\n */\n\n/**\n * The available values of the fileStatus helper Object.\n * @example\n * ```tsx\n * import { fileStatus } from '@cerberus/react'\n * processStatus.TODO // 'todo'\n * ```\n */\nexport type FileStatusKey = (typeof processStatus)[keyof typeof processStatus]\n\n/**\n * The actions that can be performed on a file.\n */\nexport type FileStatusActions = 'cancel' | 'retry' | 'delete'\nexport interface FileBaseStatusProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'onClick'> {\n /**\n * A unique identifier for the file status. Required for accessibility.\n */\n id: string\n /**\n * The name of the file.\n */\n file: string\n /**\n * The percentage of the file that has been processed.\n */\n now: ProgressBarProps['now']\n /**\n * The status of the file.\n */\n status: processStatus\n /**\n * The action to perform on the file when a user clicks the\n * button located at the end of the status card.\n * @param status - The status of the file.\n * @param e - The event object.\n * @example\n * ```tsx\n * <FileStatus file=\"file.txt\" now={0} status={processStatus.TODO} action={(status, e) => console.log(status, e)} />\n * ```\n * @default () => {}\n */\n onClick: (status: FileStatusActions, e: MouseEvent<HTMLButtonElement>) => void\n}\nexport type FileStatusProps = FileBaseStatusProps & FileStatusVariantProps\n\n/**\n * A helper object to represent the status of a file.\n * @example\n * ```tsx\n * import { fileStatus } from '@cerberus/react'\n * processStatus.TODO // 'todo'\n * ```\n */\nexport const enum processStatus {\n TODO = 'todo',\n PROCESSING = 'processing',\n DONE = 'done',\n ERROR = 'error',\n}\n\n/**\n * A component that displays the status of a file during file processing.\n * @see https://cerberus.digitalu.design/react/file-uploader\n * @example\n * ```tsx\n * <FileStatus file=\"file.txt\" now={0} status={processStatus.TODO} action={(status, e) => console.log(status, e)} />\n * ```\n */\nexport function FileStatus(props: FileStatusProps) {\n const { file, now, status, onClick, ...nativeProps } = props\n const actionLabel = useMemo(() => getStatusActionLabel(status), [status])\n const palette = useMemo(() => getPalette(status), [status])\n const modalIconPalette = useMemo(() => getModalIconPalette(status), [status])\n const styles = useMemo(() => {\n switch (status) {\n case processStatus.TODO:\n return fileStatus({ status: 'todo' })\n case processStatus.PROCESSING:\n return fileStatus({ status: 'processing' })\n case processStatus.DONE:\n return fileStatus({ status: 'done' })\n case processStatus.ERROR:\n return fileStatus({ status: 'error' })\n default:\n return fileStatus()\n }\n }, [status])\n\n const handleClick = useCallback(\n (e: MouseEvent<HTMLButtonElement>) => {\n const actionStatus = getStatusActionLabel(\n status,\n ).toLocaleLowerCase() as FileStatusActions\n onClick(actionStatus, e)\n },\n [onClick],\n )\n\n return (\n <div\n {...nativeProps}\n className={cx(nativeProps.className, styles.root, hstack())}\n >\n <Avatar\n ariaLabel=\"\"\n gradient={modalIconPalette}\n icon={<MatchFileStatusIcon size={24} status={status} />}\n src=\"\"\n />\n\n <div\n className={vstack({\n alignItems: 'flex-start',\n gap: '0.12rem',\n w: 'full',\n })}\n >\n <small\n className={css({\n color: 'page.text.initial',\n textStyle: 'label-sm',\n })}\n >\n {file}\n </small>\n <ProgressBar\n id={props.id}\n label=\"File upload status\"\n now={now}\n size=\"sm\"\n />\n <Field invalid={modalIconPalette === 'hades-dark'}>\n <FieldMessage\n className={css({\n color: 'page.text.100',\n })}\n id={`help:${file}`}\n >\n <MatchFileStatusText status={status} now={now} />\n </FieldMessage>\n </Field>\n </div>\n\n <IconButton\n ariaLabel={actionLabel}\n onClick={handleClick}\n palette={palette}\n size=\"sm\"\n >\n <MatchStatusAction status={status} />\n </IconButton>\n </div>\n )\n}\n\ninterface FileStatusElProps {\n status: FileStatusProps['status']\n size?: 16 | 20 | 24 | 32\n now?: number\n}\n\nfunction MatchFileStatusIcon(props: FileStatusElProps) {\n const { icons } = useCerberusContext()\n const {\n waitingFileUploader: TodoIcon,\n fileUploader: FileUploaderIcon,\n invalidAlt: InvalidIcon,\n successNotification: DoneIcon,\n } = icons\n\n switch (props.status) {\n case processStatus.TODO:\n return <TodoIcon size={props.size} />\n case processStatus.PROCESSING:\n return <FileUploaderIcon size={props.size} />\n case processStatus.DONE:\n return <DoneIcon size={props.size} />\n case processStatus.ERROR:\n return <InvalidIcon size={props.size} />\n default:\n throw new Error('Unknown status')\n }\n}\n\nfunction MatchFileStatusText(props: FileStatusElProps) {\n switch (props.status) {\n case processStatus.TODO:\n return 'Waiting to upload'\n case processStatus.PROCESSING:\n return `${props.now}% Complete`\n case processStatus.DONE:\n return 'File uploaded successfully'\n case processStatus.ERROR:\n return 'There was an error uploading the file'\n default:\n throw new Error('Invalid status')\n }\n}\n\nfunction MatchStatusAction(props: FileStatusElProps) {\n const { icons } = useCerberusContext()\n const { close: CloseIcon, redo: RedoIcon, delete: TrashIcon } = icons\n switch (props.status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return <CloseIcon />\n case processStatus.ERROR:\n return <RedoIcon />\n case processStatus.DONE:\n return <TrashIcon />\n default:\n throw new Error('Invalid status')\n }\n}\n\nfunction getStatusActionLabel(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'Cancel'\n case processStatus.ERROR:\n return 'Retry'\n case processStatus.DONE:\n return 'Delete'\n default:\n return ''\n }\n}\n\nfunction getPalette(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'danger'\n case processStatus.ERROR:\n return 'action'\n case processStatus.DONE:\n return 'danger'\n default:\n return 'action'\n }\n}\n\nfunction getModalIconPalette(status: FileStatusKey) {\n switch (status) {\n case processStatus.TODO:\n case processStatus.PROCESSING:\n return 'charon-light'\n case processStatus.ERROR:\n return 'hades-dark'\n case processStatus.DONE:\n return 'thanatos-light'\n default:\n return 'charon-light'\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,OAEK;AACP,SAAS,KAAK,UAAU;AACxB,SAAS,QAAQ,cAAc;AAyHjB,cAIR,YAJQ;AArDP,IAAW,gBAAX,kBAAWA,mBAAX;AACL,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,gBAAa;AACb,EAAAA,eAAA,UAAO;AACP,EAAAA,eAAA,WAAQ;AAJQ,SAAAA;AAAA,GAAA;AAeX,SAAS,WAAW,OAAwB;AACjD,QAAM,EAAE,MAAM,KAAK,QAAQ,SAAS,GAAG,YAAY,IAAI;AACvD,QAAM,cAAc,QAAQ,MAAM,qBAAqB,MAAM,GAAG,CAAC,MAAM,CAAC;AACxE,QAAM,UAAU,QAAQ,MAAM,WAAW,MAAM,GAAG,CAAC,MAAM,CAAC;AAC1D,QAAM,mBAAmB,QAAQ,MAAM,oBAAoB,MAAM,GAAG,CAAC,MAAM,CAAC;AAC5E,QAAM,SAAS,QAAQ,MAAM;AAC3B,YAAQ,QAAQ;AAAA,MACd,KAAK;AACH,eAAO,WAAW,EAAE,QAAQ,OAAO,CAAC;AAAA,MACtC,KAAK;AACH,eAAO,WAAW,EAAE,QAAQ,aAAa,CAAC;AAAA,MAC5C,KAAK;AACH,eAAO,WAAW,EAAE,QAAQ,OAAO,C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AgB;AAAA,EACpC;AACF;AAEA,SAAS,qBAAqB,QAAuB;AACnD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,WAAW,QAAuB;AACzC,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,oBAAoB,QAAuB;AAClD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;","names":["processStatus"]}
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
Show
|
|
3
3
|
} from "./chunk-BUVVRQLZ.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./chunk-
|
|
5
|
+
useCerberusContext
|
|
6
|
+
} from "./chunk-GITT5645.js";
|
|
7
7
|
|
|
8
8
|
// src/components/Avatar.tsx
|
|
9
9
|
import { css, cx } from "@cerberus/styled-system/css";
|
|
@@ -24,7 +24,8 @@ function Avatar(props) {
|
|
|
24
24
|
icon,
|
|
25
25
|
...nativeProps
|
|
26
26
|
} = props;
|
|
27
|
-
const {
|
|
27
|
+
const { icons } = useCerberusContext();
|
|
28
|
+
const { avatar: AvatarIcon } = icons;
|
|
28
29
|
const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
|
|
29
30
|
return /* @__PURE__ */ jsx(
|
|
30
31
|
"div",
|
|
@@ -101,4 +102,4 @@ var iconSizeMap = {
|
|
|
101
102
|
export {
|
|
102
103
|
Avatar
|
|
103
104
|
};
|
|
104
|
-
//# sourceMappingURL=chunk-
|
|
105
|
+
//# sourceMappingURL=chunk-GCQMH4QA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["'use client'\n\nimport { css, cx } from '@cerberus/styled-system/css'\nimport { circle } from '@cerberus/styled-system/patterns'\nimport {\n avatar,\n type AvatarVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport type { HtmlHTMLAttributes, ReactNode } from 'react'\nimport { Show } from './Show'\nimport { useCerberusContext } from '../context/cerberus'\n\n/**\n * This module contains the Avatar component.\n * @module\n */\n\nexport type SharedAvatarProps = {\n /**\n * An optional icon to show when no src or ariaLabel is provided.\n */\n icon?: ReactNode\n /**\n * The size of the avatar.\n */\n width?: number\n /**\n * The size of the avatar.\n */\n height?: number\n}\nexport type AvatarImageProps = HtmlHTMLAttributes<HTMLImageElement> &\n SharedAvatarProps & {\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel: string\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as?: never\n /**\n * The source of the image.\n */\n src: string\n }\nexport type AvatarAsProps = SharedAvatarProps & {\n /**\n * An optional element to replace the image. Recommended for Next.js Image component.\n */\n as: ReactNode\n /**\n * The aria-label for the avatar needed for accessibility.\n */\n ariaLabel?: never\n /**\n * The source of the image.\n */\n src?: never\n}\n\nexport type AvatarProps = (HtmlHTMLAttributes<HTMLDivElement> &\n AvatarVariantProps) &\n (AvatarImageProps | AvatarAsProps)\n\n/**\n * The Avatar component is used to represent a user or entity. It will show an image if src provided, otherwise it will show the ariaLabel of the ariaLabel. If the ariaLabel is empty, it will show a `defineIcons().avatar` icon.\n * @see https://cerberus.digitalu.design/react/avatar\n * @example\n * ```tsx\n * <Avatar\n * ariaLabel=\"Protector Cerberus\"\n * src=\"https://cerberus.digitalu.design/logo.svg\"\n * />\n * ```\n */\nexport function Avatar(props: AvatarProps) {\n const {\n ariaLabel,\n as,\n gradient,\n size,\n src,\n width,\n height,\n icon,\n ...nativeProps\n } = props\n const { icons } = useCerberusContext()\n const { avatar: AvatarIcon } = icons\n const initials = (ariaLabel || '')\n .split(' ')\n .map((word) => word[0])\n .join('')\n .slice(0, 2)\n\n return (\n <div\n {...nativeProps}\n className={cx(\n nativeProps.className,\n avatar({ gradient, size }),\n circle(),\n )}\n >\n <Show\n when={Boolean(src) || Boolean(as)}\n fallback={\n <Show\n when={Boolean(initials)}\n fallback={\n <Show\n when={Boolean(icon)}\n fallback={\n <AvatarIcon\n size={iconSizeMap[size as keyof typeof iconSizeMap]}\n />\n }\n >\n {icon}\n </Show>\n }\n >\n {initials}\n </Show>\n }\n >\n <Show\n when={Boolean(as)}\n fallback={\n <img\n alt={props.ariaLabel}\n className={css({\n h: 'full',\n objectFit: 'cover',\n w: 'full',\n })}\n decoding=\"async\"\n loading=\"lazy\"\n src={src}\n height={height}\n width={width}\n />\n }\n >\n {as}\n </Show>\n </Show>\n </div>\n )\n}\n\nconst iconSizeMap = {\n xs: 16,\n sm: 16,\n md: 20,\n lg: 34,\n xl: 32,\n '2xl': 32,\n '3xl': 32,\n '4xl': 32,\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,KAAK,UAAU;AACxB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,OAEK;AA2GW;AAtCX,SAAS,OAAO,OAAoB;AACzC,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG;AAAA,EACL,IAAI;AACJ,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,QAAQ,WAAW,IAAI;AAC/B,QAAM,YAAY,aAAa,IAC5B,MAAM,GAAG,EACT,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,EACrB,KAAK,EAAE,EACP,MAAM,GAAG,CAAC;AAEb,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,M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