@cerberus-design/react 0.16.0-next-4f6c716 → 0.16.0-next-feeb186

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 (64) hide show
  1. package/build/legacy/_tsup-dts-rollup.d.cts +82 -25
  2. package/build/legacy/components/cta-dialog/context.cjs +33 -0
  3. package/build/legacy/components/cta-dialog/context.cjs.map +1 -0
  4. package/build/legacy/components/cta-dialog/index.cjs +433 -0
  5. package/build/legacy/components/cta-dialog/index.cjs.map +1 -0
  6. package/build/legacy/{context/cta-modal.cjs → components/cta-dialog/provider.cjs} +187 -150
  7. package/build/legacy/components/cta-dialog/provider.cjs.map +1 -0
  8. package/build/legacy/components/cta-dialog/trigger-item.cjs +99 -0
  9. package/build/legacy/components/cta-dialog/trigger-item.cjs.map +1 -0
  10. package/build/legacy/components/cta-dialog/utils.cjs +47 -0
  11. package/build/legacy/components/cta-dialog/utils.cjs.map +1 -0
  12. package/build/legacy/components/for.cjs +3 -4
  13. package/build/legacy/components/for.cjs.map +1 -1
  14. package/build/legacy/index.cjs +771 -715
  15. package/build/legacy/index.cjs.map +1 -1
  16. package/build/modern/_tsup-dts-rollup.d.ts +82 -25
  17. package/build/modern/chunk-4LSTU6WU.js +8 -0
  18. package/build/modern/chunk-4LSTU6WU.js.map +1 -0
  19. package/build/modern/{chunk-P3SF56LT.js → chunk-6ICNCCPD.js} +4 -4
  20. package/build/modern/chunk-DXOKSZVQ.js +12 -0
  21. package/build/modern/chunk-DXOKSZVQ.js.map +1 -0
  22. package/build/modern/chunk-IKDXADLX.js +1 -0
  23. package/build/modern/chunk-MVO2GNUA.js +47 -0
  24. package/build/modern/chunk-MVO2GNUA.js.map +1 -0
  25. package/build/modern/{chunk-CMYD5KWA.js → chunk-O542MPR7.js} +4 -4
  26. package/build/modern/chunk-PLHYOCY3.js +23 -0
  27. package/build/modern/chunk-PLHYOCY3.js.map +1 -0
  28. package/build/modern/{chunk-ZDANBCM3.js → chunk-QEM3M4N3.js} +22 -31
  29. package/build/modern/chunk-QEM3M4N3.js.map +1 -0
  30. package/build/modern/{chunk-FMRWRVUS.js → chunk-Z4342DRO.js} +4 -4
  31. package/build/modern/components/cta-dialog/context.js +8 -0
  32. package/build/modern/components/cta-dialog/context.js.map +1 -0
  33. package/build/modern/components/cta-dialog/index.js +26 -0
  34. package/build/modern/components/cta-dialog/index.js.map +1 -0
  35. package/build/modern/components/cta-dialog/provider.js +22 -0
  36. package/build/modern/components/cta-dialog/provider.js.map +1 -0
  37. package/build/modern/components/cta-dialog/trigger-item.js +10 -0
  38. package/build/modern/components/cta-dialog/trigger-item.js.map +1 -0
  39. package/build/modern/components/cta-dialog/utils.js +7 -0
  40. package/build/modern/components/cta-dialog/utils.js.map +1 -0
  41. package/build/modern/components/for.js +1 -1
  42. package/build/modern/components/select/index.js +2 -2
  43. package/build/modern/components/select/select.js +2 -2
  44. package/build/modern/context/notification-center.js +2 -2
  45. package/build/modern/context/prompt-modal.js +2 -2
  46. package/build/modern/index.js +83 -76
  47. package/build/modern/index.js.map +1 -1
  48. package/package.json +2 -2
  49. package/src/components/cta-dialog/context.tsx +34 -0
  50. package/src/components/cta-dialog/index.ts +2 -0
  51. package/src/{context/cta-modal.tsx → components/cta-dialog/provider.tsx} +34 -68
  52. package/src/components/cta-dialog/trigger-item.tsx +53 -0
  53. package/src/components/cta-dialog/utils.ts +57 -0
  54. package/src/components/for.tsx +13 -18
  55. package/src/index.ts +1 -1
  56. package/build/legacy/context/cta-modal.cjs.map +0 -1
  57. package/build/modern/chunk-IIH363FO.js +0 -13
  58. package/build/modern/chunk-IIH363FO.js.map +0 -1
  59. package/build/modern/chunk-ZDANBCM3.js.map +0 -1
  60. package/build/modern/context/cta-modal.js +0 -19
  61. /package/build/modern/{chunk-P3SF56LT.js.map → chunk-6ICNCCPD.js.map} +0 -0
  62. /package/build/modern/{context/cta-modal.js.map → chunk-IKDXADLX.js.map} +0 -0
  63. /package/build/modern/{chunk-CMYD5KWA.js.map → chunk-O542MPR7.js.map} +0 -0
  64. /package/build/modern/{chunk-FMRWRVUS.js.map → chunk-Z4342DRO.js.map} +0 -0
@@ -103,6 +103,7 @@ import { HtmlHTMLAttributes } from 'react';
103
103
  import { IconButtonVariantProps } from '@cerberus/styled-system/recipes';
104
104
  import { InputHTMLAttributes } from 'react';
105
105
  import { JSX as JSX_2 } from 'react/jsx-runtime';
106
+ import type { JSX as JSX_3 } from 'react';
106
107
  import { KeyboardCode } from '@dnd-kit/core';
107
108
  import { KeyboardCodes } from '@dnd-kit/core';
108
109
  import { KeyboardCoordinateGetter } from '@dnd-kit/core';
@@ -119,7 +120,7 @@ import { Menu as Menu_2 } from '@ark-ui/react';
119
120
  import { Modifier } from '@dnd-kit/core';
120
121
  import { Modifiers } from '@dnd-kit/core';
121
122
  import { MouseEvent as MouseEvent_2 } from 'react';
122
- import { MouseEventHandler } from 'react';
123
+ import type { MouseEventHandler } from 'react';
123
124
  import { MouseSensor } from '@dnd-kit/core';
124
125
  import { MouseSensorOptions } from '@dnd-kit/core';
125
126
  import { NotificationVariantProps } from '@cerberus/styled-system/recipes';
@@ -950,6 +951,14 @@ declare interface ConfirmModalValue {
950
951
  export { ConfirmModalValue }
951
952
  export { ConfirmModalValue as ConfirmModalValue_alias_1 }
952
953
 
954
+ /**
955
+ * Creates the action data to pass to the cta modal `show` method.
956
+ */
957
+ declare function createCTAModalActions(providedActions: CTAModalAction): CTAModalActionReturn;
958
+ export { createCTAModalActions }
959
+ export { createCTAModalActions as createCTAModalActions_alias_1 }
960
+ export { createCTAModalActions as createCTAModalActions_alias_2 }
961
+
953
962
  declare function createNavTriggerProps(values: NavTriggerAriaValues): NavTriggerAriaReturn;
954
963
  export { createNavTriggerProps }
955
964
  export { createNavTriggerProps as createNavTriggerProps_alias_1 }
@@ -967,6 +976,28 @@ export { createSelectCollection }
967
976
  export { createSelectCollection as createSelectCollection_alias_1 }
968
977
  export { createSelectCollection as createSelectCollection_alias_2 }
969
978
 
979
+ /**
980
+ * This module provide utility functions for the cta modal.
981
+ * @module 'react/cta-modal/utils'
982
+ */
983
+ declare type CTAButtonAction = {
984
+ /**
985
+ * The text of the button.
986
+ */
987
+ text: string;
988
+ /**
989
+ * The onClick handler for the button.
990
+ */
991
+ handleClick: MouseEventHandler<HTMLButtonElement>;
992
+ };
993
+ export { CTAButtonAction }
994
+ export { CTAButtonAction as CTAButtonAction_alias_1 }
995
+ export { CTAButtonAction as CTAButtonAction_alias_2 }
996
+
997
+ /**
998
+ * This module provides the provider and hook for the cta modal.
999
+ * @module 'react/cta-modal/provider'
1000
+ */
970
1001
  /**
971
1002
  * Provides a CTA modal to the app.
972
1003
  * @see https://cerberus.digitalu.design/react/cta-modal
@@ -999,19 +1030,35 @@ export { createSelectCollection as createSelectCollection_alias_2 }
999
1030
  * }, [cta])
1000
1031
  * ```
1001
1032
  */
1002
- declare function CTAModal(props: PropsWithChildren<CTAModalProviderProps>): JSX_2.Element;
1033
+ declare function CTAModal(props: PropsWithChildren<object>): JSX_2.Element;
1003
1034
  export { CTAModal }
1004
1035
  export { CTAModal as CTAModal_alias_1 }
1036
+ export { CTAModal as CTAModal_alias_2 }
1037
+
1038
+ declare type CTAModalAction = (CTAButtonAction | ReactNode)[];
1039
+ export { CTAModalAction }
1040
+ export { CTAModalAction as CTAModalAction_alias_1 }
1041
+ export { CTAModalAction as CTAModalAction_alias_2 }
1042
+
1043
+ declare interface CTAModalActionReturn {
1044
+ /**
1045
+ * The type of the action content.
1046
+ */
1047
+ type: 'reactNode' | 'btnAction';
1048
+ /**
1049
+ * The actions for the cta modal. Max of 2 actions.
1050
+ */
1051
+ _actions: CTAModalAction;
1052
+ }
1053
+ export { CTAModalActionReturn }
1054
+ export { CTAModalActionReturn as CTAModalActionReturn_alias_1 }
1055
+ export { CTAModalActionReturn as CTAModalActionReturn_alias_2 }
1005
1056
 
1006
- declare type CTAModalProviderProps = PropsWithChildren<unknown>;
1007
- export { CTAModalProviderProps }
1008
- export { CTAModalProviderProps as CTAModalProviderProps_alias_1 }
1057
+ export declare const CTAModalContext: Context<CTAModalValue | null>;
1009
1058
 
1010
- declare interface CTAModalValue {
1059
+ export declare interface CTAModalValue {
1011
1060
  show: (options: ShowCTAModalOptions) => void;
1012
1061
  }
1013
- export { CTAModalValue }
1014
- export { CTAModalValue as CTAModalValue_alias_1 }
1015
1062
 
1016
1063
  declare type CustomThemes<K extends string = DefaultThemes> = 'cerberus' | K;
1017
1064
  export { CustomThemes }
@@ -2225,7 +2272,7 @@ export { FileUploaderProps as FileUploaderProps_alias_1 }
2225
2272
  * </For>
2226
2273
  * ```
2227
2274
  */
2228
- declare function For<T extends string | number | Record<string, unknown> | object | undefined>(props: ForProps<T>): ReactNode;
2275
+ declare function For<T extends readonly unknown[], U extends JSX_3.Element>(props: ForProps<T, U>): string | number | boolean | JSX_3.Element | Iterable<ReactNode> | null | undefined;
2229
2276
  export { For }
2230
2277
  export { For as For_alias_1 }
2231
2278
 
@@ -2274,19 +2321,19 @@ declare function formatNotifyCount(count: number): string;
2274
2321
  export { formatNotifyCount }
2275
2322
  export { formatNotifyCount as formatNotifyCount_alias_1 }
2276
2323
 
2277
- declare interface ForProps<T> {
2324
+ declare interface ForProps<T extends readonly unknown[], U extends JSX_3.Element> {
2278
2325
  /**
2279
- * The array to iterate over
2326
+ * The array to iterate over.
2280
2327
  */
2281
- each: T[];
2328
+ each: T | undefined | null | false;
2282
2329
  /**
2283
- * The fallback content to render when the array is empty
2330
+ * The fallback to render when the array is empty.
2284
2331
  */
2285
- fallback?: ReactNode;
2332
+ fallback?: JSX_3.Element;
2286
2333
  /**
2287
- * The render function to render each item in the array
2334
+ * The children to render for each item in the array.
2288
2335
  */
2289
- children: (item: Exclude<T, undefined>, index: number) => ReactNode;
2336
+ children: (item: T[number], index: number) => U;
2290
2337
  }
2291
2338
  export { ForProps }
2292
2339
  export { ForProps as ForProps_alias_1 }
@@ -3826,10 +3873,10 @@ export { ShowConfirmModalOptions }
3826
3873
  export { ShowConfirmModalOptions as ShowConfirmModalOptions_alias_1 }
3827
3874
 
3828
3875
  /**
3829
- * This module provides a context and hook for the cta modal.
3876
+ * This module provides the context for the cta modal.
3830
3877
  * @module
3831
3878
  */
3832
- declare interface ShowCTAModalOptions {
3879
+ export declare interface ShowCTAModalOptions {
3833
3880
  /**
3834
3881
  * The heading of the cta modal.
3835
3882
  */
@@ -3843,15 +3890,10 @@ declare interface ShowCTAModalOptions {
3843
3890
  */
3844
3891
  icon?: ReactNode;
3845
3892
  /**
3846
- * The actions for the cta modal. Max of 2 actions.
3893
+ * The actions for the cta modal. Requires 2 actions.
3847
3894
  */
3848
- actions: {
3849
- text: string;
3850
- onClick: MouseEventHandler<HTMLButtonElement>;
3851
- }[];
3895
+ actions: CTAModalActionReturn;
3852
3896
  }
3853
- export { ShowCTAModalOptions }
3854
- export { ShowCTAModalOptions as ShowCTAModalOptions_alias_1 }
3855
3897
 
3856
3898
  /**
3857
3899
  * This module provides a context and hook for the prompt modal.
@@ -4589,6 +4631,20 @@ export { trapFocus as trapFocus_alias_1 }
4589
4631
 
4590
4632
  export { TraversalOrder }
4591
4633
 
4634
+ /**
4635
+ * Trigger item for the cta modal which renders content based on the actions.
4636
+ * type.
4637
+ */
4638
+ export declare function TriggerItem(props: TriggerItemProps): JSX_2.Element;
4639
+
4640
+ /**
4641
+ * This module provides the trigger item for the cta modal.
4642
+ * @module 'react/cta-modal/trigger-item'
4643
+ */
4644
+ export declare interface TriggerItemProps extends ButtonProps {
4645
+ asChild?: boolean;
4646
+ }
4647
+
4592
4648
  declare type TrProps = TableHTMLAttributes<HTMLTableRowElement>;
4593
4649
  export { TrProps }
4594
4650
  export { TrProps as TrProps_alias_1 }
@@ -4624,6 +4680,7 @@ export { useConfirmModal as useConfirmModal_alias_1 }
4624
4680
  declare function useCTAModal(): CTAModalValue;
4625
4681
  export { useCTAModal }
4626
4682
  export { useCTAModal as useCTAModal_alias_1 }
4683
+ export { useCTAModal as useCTAModal_alias_2 }
4627
4684
 
4628
4685
  /**
4629
4686
  * @deprecated use the DatePicker family instead
@@ -0,0 +1,8 @@
1
+ // src/components/cta-dialog/context.tsx
2
+ import { createContext } from "react";
3
+ var CTAModalContext = createContext(null);
4
+
5
+ export {
6
+ CTAModalContext
7
+ };
8
+ //# sourceMappingURL=chunk-4LSTU6WU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/cta-dialog/context.tsx"],"sourcesContent":["'use client'\n\nimport { createContext, type ReactNode } from 'react'\nimport type { CTAModalActionReturn } from './utils'\n\n/**\n * This module provides the context for the cta modal.\n * @module\n */\n\nexport interface ShowCTAModalOptions {\n /**\n * The heading of the cta modal.\n */\n heading: string\n /**\n * The description of the cta modal.\n */\n description?: string\n /**\n * The icon used for the modal Avatar.\n */\n icon?: ReactNode\n /**\n * The actions for the cta modal. Requires 2 actions.\n */\n actions: CTAModalActionReturn\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nexport const CTAModalContext = createContext<CTAModalValue | null>(null)\n"],"mappings":";AAEA,SAAS,qBAAqC;AA+BvC,IAAM,kBAAkB,cAAoC,IAAI;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- Portal
3
- } from "./chunk-IQJDVFPP.js";
4
1
  import {
5
2
  SelectParts
6
3
  } from "./chunk-XTNGF4D6.js";
4
+ import {
5
+ Portal
6
+ } from "./chunk-IQJDVFPP.js";
7
7
  import {
8
8
  useCerberusContext
9
9
  } from "./chunk-GITT5645.js";
@@ -44,4 +44,4 @@ export {
44
44
  Select,
45
45
  Option
46
46
  };
47
- //# sourceMappingURL=chunk-P3SF56LT.js.map
47
+ //# sourceMappingURL=chunk-6ICNCCPD.js.map
@@ -0,0 +1,12 @@
1
+ // src/components/for.tsx
2
+ function For(props) {
3
+ if (!props.each || !props.each.length) {
4
+ return props.fallback || null;
5
+ }
6
+ return props.each?.map(props.children);
7
+ }
8
+
9
+ export {
10
+ For
11
+ };
12
+ //# sourceMappingURL=chunk-DXOKSZVQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/for.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\n\nexport interface ForProps<T extends readonly unknown[], U extends JSX.Element> {\n /**\n * The array to iterate over.\n */\n each: T | undefined | null | false\n /**\n * The fallback to render when the array is empty.\n */\n fallback?: JSX.Element\n /**\n * The children to render for each item in the array.\n */\n children: (item: T[number], index: number) => U\n}\n\n/**\n * The For component is used to iterate over an array and render a list of\n * components or display a fallback when the array is empty.\n * Inspired by the `<For>` component from SolidJS.\n *\n * @example\n * ```tsx\n * <For each={['a', 'b', 'c']}>\n * {(item, index) => <div key={index}>{item}</div>}\n * </For>\n * ```\n */\nexport function For<T extends readonly unknown[], U extends JSX.Element>(\n props: ForProps<T, U>,\n) {\n if (!props.each || !props.each.length) {\n return props.fallback || null\n }\n\n return props.each?.map(props.children) as ReactNode\n}\n"],"mappings":";AA6BO,SAAS,IACd,OACA;AACA,MAAI,CAAC,MAAM,QAAQ,CAAC,MAAM,KAAK,QAAQ;AACrC,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SAAO,MAAM,MAAM,IAAI,MAAM,QAAQ;AACvC;","names":[]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-IKDXADLX.js.map
@@ -0,0 +1,47 @@
1
+ import {
2
+ Button
3
+ } from "./chunk-6KZVE4HC.js";
4
+
5
+ // src/components/cta-dialog/trigger-item.tsx
6
+ import { css, cx } from "@cerberus/styled-system/css";
7
+ import { ark } from "@ark-ui/react/factory";
8
+ import { button } from "@cerberus/styled-system/recipes";
9
+ import { jsx } from "react/jsx-runtime";
10
+ function TriggerItem(props) {
11
+ const { asChild, children, ...buttonProps } = props;
12
+ if (asChild) {
13
+ return /* @__PURE__ */ jsx(
14
+ ark.div,
15
+ {
16
+ className: cx(
17
+ button({
18
+ shape: "rounded",
19
+ usage: "ghost"
20
+ }),
21
+ css({
22
+ w: "1/2"
23
+ })
24
+ ),
25
+ asChild: true,
26
+ children
27
+ }
28
+ );
29
+ }
30
+ return /* @__PURE__ */ jsx(
31
+ Button,
32
+ {
33
+ ...buttonProps,
34
+ className: css({
35
+ w: "1/2"
36
+ }),
37
+ shape: "rounded",
38
+ usage: "outlined",
39
+ children
40
+ }
41
+ );
42
+ }
43
+
44
+ export {
45
+ TriggerItem
46
+ };
47
+ //# sourceMappingURL=chunk-MVO2GNUA.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/cta-dialog/trigger-item.tsx"],"sourcesContent":["import { css, cx } from '@cerberus/styled-system/css'\nimport { Button, type ButtonProps } from '../button/button'\nimport { ark } from '@ark-ui/react/factory'\nimport { button } from '@cerberus/styled-system/recipes'\n\n/**\n * This module provides the trigger item for the cta modal.\n * @module 'react/cta-modal/trigger-item'\n */\n\nexport interface TriggerItemProps extends ButtonProps {\n asChild?: boolean\n}\n\n/**\n * Trigger item for the cta modal which renders content based on the actions.\n * type.\n */\nexport function TriggerItem(props: TriggerItemProps) {\n const { asChild, children, ...buttonProps } = props\n\n if (asChild) {\n return (\n <ark.div\n className={cx(\n button({\n shape: 'rounded',\n usage: 'ghost',\n }),\n css({\n w: '1/2',\n }),\n )}\n asChild\n >\n {children}\n </ark.div>\n )\n }\n\n return (\n <Button\n {...buttonProps}\n className={css({\n w: '1/2',\n })}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {children}\n </Button>\n )\n}\n"],"mappings":";;;;;AAAA,SAAS,KAAK,UAAU;AAExB,SAAS,WAAW;AACpB,SAAS,cAAc;AAoBjB;AALC,SAAS,YAAY,OAAyB;AACnD,QAAM,EAAE,SAAS,UAAU,GAAG,YAAY,IAAI;AAE9C,MAAI,SAAS;AACX,WACE;AAAA,MAAC,IAAI;AAAA,MAAJ;AAAA,QACC,WAAW;AAAA,UACT,OAAO;AAAA,YACL,OAAO;AAAA,YACP,OAAO;AAAA,UACT,CAAC;AAAA,UACD,IAAI;AAAA,YACF,GAAG;AAAA,UACL,CAAC;AAAA,QACH;AAAA,QACA,SAAO;AAAA,QAEN;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,WAAW,IAAI;AAAA,QACb,GAAG;AAAA,MACL,CAAC;AAAA,MACD,OAAM;AAAA,MACN,OAAM;AAAA,MAEL;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -1,3 +1,6 @@
1
+ import {
2
+ Text
3
+ } from "./chunk-RU5LOXWI.js";
1
4
  import {
2
5
  Dialog,
3
6
  DialogDescription,
@@ -7,9 +10,6 @@ import {
7
10
  import {
8
11
  Avatar
9
12
  } from "./chunk-SXLPDPOZ.js";
10
- import {
11
- Text
12
- } from "./chunk-RU5LOXWI.js";
13
13
  import {
14
14
  FieldLabel,
15
15
  FieldRoot,
@@ -209,4 +209,4 @@ export {
209
209
  PromptModal,
210
210
  usePromptModal
211
211
  };
212
- //# sourceMappingURL=chunk-CMYD5KWA.js.map
212
+ //# sourceMappingURL=chunk-O542MPR7.js.map
@@ -0,0 +1,23 @@
1
+ // src/components/cta-dialog/utils.ts
2
+ function createCTAModalActions(providedActions) {
3
+ if (providedActions.length !== 2) {
4
+ throw new Error("CTAModal must include 2 actions");
5
+ }
6
+ if (providedActions.every(
7
+ (action) => action?.handleClick
8
+ )) {
9
+ return {
10
+ type: "btnAction",
11
+ _actions: providedActions
12
+ };
13
+ }
14
+ return {
15
+ type: "reactNode",
16
+ _actions: providedActions
17
+ };
18
+ }
19
+
20
+ export {
21
+ createCTAModalActions
22
+ };
23
+ //# sourceMappingURL=chunk-PLHYOCY3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/cta-dialog/utils.ts"],"sourcesContent":["import type { MouseEventHandler, ReactNode } from 'react'\n\n/**\n * This module provide utility functions for the cta modal.\n * @module 'react/cta-modal/utils'\n */\n\nexport type CTAButtonAction = {\n /**\n * The text of the button.\n */\n text: string\n /**\n * The onClick handler for the button.\n */\n handleClick: MouseEventHandler<HTMLButtonElement>\n}\n\nexport type CTAModalAction = (CTAButtonAction | ReactNode)[]\n\nexport interface CTAModalActionReturn {\n /**\n * The type of the action content.\n */\n type: 'reactNode' | 'btnAction'\n /**\n * The actions for the cta modal. Max of 2 actions.\n */\n _actions: CTAModalAction\n}\n\n/**\n * Creates the action data to pass to the cta modal `show` method.\n */\nexport function createCTAModalActions(\n providedActions: CTAModalAction,\n): CTAModalActionReturn {\n if (providedActions.length !== 2) {\n throw new Error('CTAModal must include 2 actions')\n }\n\n if (\n providedActions.every(\n (action) => (action as unknown as CTAButtonAction)?.handleClick,\n )\n ) {\n return {\n type: 'btnAction',\n _actions: providedActions as CTAButtonAction[],\n }\n }\n\n return {\n type: 'reactNode',\n _actions: providedActions as ReactNode[],\n }\n}\n"],"mappings":";AAkCO,SAAS,sBACd,iBACsB;AACtB,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,MACE,gBAAgB;AAAA,IACd,CAAC,WAAY,QAAuC;AAAA,EACtD,GACA;AACA,WAAO;AAAA,MACL,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,UAAU;AAAA,EACZ;AACF;","names":[]}
@@ -1,3 +1,12 @@
1
+ import {
2
+ CTAModalContext
3
+ } from "./chunk-4LSTU6WU.js";
4
+ import {
5
+ TriggerItem
6
+ } from "./chunk-MVO2GNUA.js";
7
+ import {
8
+ For
9
+ } from "./chunk-DXOKSZVQ.js";
1
10
  import {
2
11
  DialogCloseIconTrigger
3
12
  } from "./chunk-6BN3XKQF.js";
@@ -13,26 +22,19 @@ import {
13
22
  import {
14
23
  useCerberusContext
15
24
  } from "./chunk-GITT5645.js";
16
- import {
17
- Button
18
- } from "./chunk-6KZVE4HC.js";
19
25
  import {
20
26
  Show
21
27
  } from "./chunk-BUVVRQLZ.js";
22
28
 
23
- // src/context/cta-modal.tsx
29
+ // src/components/cta-dialog/provider.tsx
24
30
  import {
25
- createContext,
26
31
  useCallback,
27
32
  useContext,
28
33
  useMemo,
29
34
  useState
30
35
  } from "react";
31
- import { HStack } from "@cerberus/styled-system/jsx";
32
- import { css } from "@cerberus/styled-system/css";
33
- import { VStack } from "@cerberus/styled-system/jsx";
36
+ import { HStack, VStack } from "@cerberus/styled-system/jsx";
34
37
  import { jsx, jsxs } from "react/jsx-runtime";
35
- var CTAModalContext = createContext(null);
36
38
  function CTAModal(props) {
37
39
  const [open, setOpen] = useState(false);
38
40
  const [content, setContent] = useState(null);
@@ -41,12 +43,6 @@ function CTAModal(props) {
41
43
  const { confirmModal: FallbackIcon } = icons;
42
44
  const handleShow = useCallback(
43
45
  (options) => {
44
- const maxActions = 2;
45
- if (options.actions.length > maxActions) {
46
- throw new Error(
47
- `CTA Modal only supports a maximum of ${maxActions} actions.`
48
- );
49
- }
50
46
  setContent({ ...options });
51
47
  setOpen(true);
52
48
  },
@@ -54,10 +50,10 @@ function CTAModal(props) {
54
50
  );
55
51
  const handleActionClick = useCallback(
56
52
  (event) => {
57
- const index = event.currentTarget.getAttribute("data-index");
58
- const action = content?.actions[Number(index)];
59
- const { onClick } = action || {};
60
- onClick?.(event);
53
+ const index = Number(event.currentTarget.getAttribute("data-index"));
54
+ const contentActions = content?.actions;
55
+ const action = contentActions._actions[index];
56
+ action?.handleClick?.(event);
61
57
  setOpen(false);
62
58
  },
63
59
  [content, setOpen]
@@ -93,20 +89,15 @@ function CTAModal(props) {
93
89
  /* @__PURE__ */ jsx(DialogHeading, { children: content?.heading }),
94
90
  /* @__PURE__ */ jsx(DialogDescription, { children: content?.description })
95
91
  ] }) }),
96
- /* @__PURE__ */ jsx(HStack, { gap: "md", w: "full", children: /* @__PURE__ */ jsx(Show, { when: Boolean(content?.actions?.length), children: content?.actions?.map((action, index) => /* @__PURE__ */ jsx(
97
- Button,
92
+ /* @__PURE__ */ jsx(HStack, { gap: "md", w: "full", children: /* @__PURE__ */ jsx(For, { each: content?.actions._actions, children: (action, index) => /* @__PURE__ */ jsx(
93
+ Show,
98
94
  {
99
- "data-index": index,
100
- className: css({
101
- w: "1/2"
102
- }),
103
- onClick: handleActionClick,
104
- shape: "rounded",
105
- usage: "outlined",
106
- children: action.text
95
+ when: content?.actions?.type === "btnAction",
96
+ fallback: /* @__PURE__ */ jsx(TriggerItem, { asChild: true, children: action }),
97
+ children: /* @__PURE__ */ jsx(TriggerItem, { "data-index": index, onClick: handleActionClick, children: action?.text })
107
98
  },
108
99
  index
109
- )) }) })
100
+ ) }) })
110
101
  ] })
111
102
  ] }) })
112
103
  ] });
@@ -123,4 +114,4 @@ export {
123
114
  CTAModal,
124
115
  useCTAModal
125
116
  };
126
- //# sourceMappingURL=chunk-ZDANBCM3.js.map
117
+ //# sourceMappingURL=chunk-QEM3M4N3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/cta-dialog/provider.tsx"],"sourcesContent":["'use client'\n\nimport {\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { HStack, VStack } from '@cerberus/styled-system/jsx'\nimport { useCerberusContext } from '../../context/cerberus'\nimport { Show } from '../Show'\nimport { For } from '../for'\nimport { Avatar } from '../Avatar'\nimport {\n Dialog,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../Dialog'\nimport { DialogCloseIconTrigger } from '../Dialog.client'\nimport type { CTAButtonAction, CTAModalActionReturn } from './utils'\nimport {\n CTAModalContext,\n type CTAModalValue,\n type ShowCTAModalOptions,\n} from './context'\nimport { TriggerItem } from './trigger-item'\n\n/**\n * This module provides the provider and hook for the cta modal.\n * @module 'react/cta-modal/provider'\n */\n\n/**\n * Provides a CTA modal to the app.\n * @see https://cerberus.digitalu.design/react/cta-modal\n * @example\n * ```tsx\n * // Wrap the Provider around the root of the feature.\n * <CTAModal>\n * <SomeFeatureSection />\n * </CTAModal>\n *\n * // Use the hook to show the cta modal.\n * const cta = useCTAModal()\n *\n * const handleClick = useCallback(async () => {\n * const userConsent = await cta.show({\n * heading: 'Create or copy a Cohort',\n * description:\n * 'Create a new cohort or copy and existing one.',\n * icon: <Copy size={24} />,\n * actions: [\n * {\n * text: 'Create Cohort',\n * onClick: () => {},\n * {\n * text: 'Copy Cohort',\n * onClick: () => {}\n * }\n * })\n * setConsent(userConsent)\n * }, [cta])\n * ```\n */\nexport function CTAModal(props: PropsWithChildren<object>) {\n const [open, setOpen] = useState<boolean>(false)\n const [content, setContent] = useState<ShowCTAModalOptions | null>(null)\n const confirmIcon = content?.icon\n\n const { icons } = useCerberusContext()\n const { confirmModal: FallbackIcon } = icons\n\n const handleShow = useCallback(\n (options: ShowCTAModalOptions) => {\n setContent({ ...options })\n setOpen(true)\n },\n [setOpen],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = Number(event.currentTarget.getAttribute('data-index'))\n const contentActions = content?.actions as CTAModalActionReturn\n const action = contentActions._actions[index] as CTAButtonAction\n action?.handleClick?.(event)\n setOpen(false)\n },\n [content, setOpen],\n )\n\n const value = useMemo(\n () => ({\n show: handleShow,\n }),\n [handleShow],\n )\n\n return (\n <CTAModalContext.Provider value={value}>\n {props.children}\n\n <DialogProvider open={open} onOpenChange={(e) => setOpen(e.open)}>\n <Dialog size=\"sm\">\n <DialogCloseIconTrigger />\n\n <VStack gap=\"xl\" w=\"full\">\n <VStack alignItems=\"flex-start\" gap=\"md\" w=\"full\">\n <VStack gap=\"lg\" w=\"full\">\n <Avatar\n ariaLabel=\"\"\n gradient=\"charon-light\"\n icon={\n <Show\n when={Boolean(confirmIcon)}\n fallback={<FallbackIcon size={24} />}\n >\n {confirmIcon}\n </Show>\n }\n src=\"\"\n />\n <DialogHeading>{content?.heading}</DialogHeading>\n <DialogDescription>{content?.description}</DialogDescription>\n </VStack>\n </VStack>\n\n <HStack gap=\"md\" w=\"full\">\n <For each={content?.actions._actions}>\n {(action, index) => (\n <Show\n key={index}\n when={content?.actions?.type === 'btnAction'}\n fallback={\n <TriggerItem asChild>{action as ReactNode}</TriggerItem>\n }\n >\n <TriggerItem data-index={index} onClick={handleActionClick}>\n {(action as CTAButtonAction)?.text}\n </TriggerItem>\n </Show>\n )}\n </For>\n </HStack>\n </VStack>\n </Dialog>\n </DialogProvider>\n </CTAModalContext.Provider>\n )\n}\n\nexport function useCTAModal(): CTAModalValue {\n const context = useContext(CTAModalContext)\n if (context === null) {\n throw new Error('useCTAModal must be used within a CTAModal Provider')\n }\n return context\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,SAAS,QAAQ,cAAc;AAiGrB,cAII,YAJJ;AAxCH,SAAS,SAAS,OAAkC;AACzD,QAAM,CAAC,MAAM,OAAO,IAAI,SAAkB,KAAK;AAC/C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAqC,IAAI;AACvE,QAAM,cAAc,SAAS;AAE7B,QAAM,EAAE,MAAM,IAAI,mBAAmB;AACrC,QAAM,EAAE,cAAc,aAAa,IAAI;AAEvC,QAAM,aAAa;AAAA,IACjB,CAAC,YAAiC;AAChC,iBAAW,EAAE,GAAG,QAAQ,CAAC;AACzB,cAAQ,IAAI;AAAA,IACd;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,oBAAoB;AAAA,IACxB,CAAC,UAAyC;AACxC,YAAM,QAAQ,OAAO,MAAM,cAAc,aAAa,YAAY,CAAC;AACnE,YAAM,iBAAiB,SAAS;AAChC,YAAM,SAAS,eAAe,SAAS,KAAK;AAC5C,cAAQ,cAAc,KAAK;AAC3B,cAAQ,KAAK;AAAA,IACf;AAAA,IACA,CAAC,SAAS,OAAO;AAAA,EACnB;AAEA,QAAM,QAAQ;AAAA,IACZ,OAAO;AAAA,MACL,MAAM;AAAA,IACR;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,SACE,qBAAC,gBAAgB,UAAhB,EAAyB,OACvB;AAAA,UAAM;AAAA,IAEP,oBAAC,kBAAe,MAAY,cAAc,CAAC,MAAM,QAAQ,EAAE,IAAI,GAC7D,+BAAC,UAAO,MAAK,MACX;AAAA,0BAAC,0BAAuB;AAAA,MAExB,qBAAC,UAAO,KAAI,MAAK,GAAE,QACjB;AAAA,4BAAC,UAAO,YAAW,cAAa,KAAI,MAAK,GAAE,QACzC,+BAAC,UAAO,KAAI,MAAK,GAAE,QACjB;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAU;AAAA,cACV,UAAS;AAAA,cACT,MACE;AAAA,gBAAC;AAAA;AAAA,kBACC,MAAM,QAAQ,WAAW;AAAA,kBACzB,UAAU,oBAAC,gBAAa,MAAM,IAAI;AAAA,kBAEjC;AAAA;AAAA,cACH;AAAA,cAEF,KAAI;AAAA;AAAA,UACN;AAAA,UACA,oBAAC,iBAAe,mBAAS,SAAQ;AAAA,UACjC,oBAAC,qBAAmB,mBAAS,aAAY;AAAA,WAC3C,GACF;AAAA,QAEA,oBAAC,UAAO,KAAI,MAAK,GAAE,QACjB,8BAAC,OAAI,MAAM,SAAS,QAAQ,UACzB,WAAC,QAAQ,UACR;AAAA,UAAC;AAAA;AAAA,YAEC,MAAM,SAAS,SAAS,SAAS;AAAA,YACjC,UACE,oBAAC,eAAY,SAAO,MAAE,kBAAoB;AAAA,YAG5C,8BAAC,eAAY,cAAY,OAAO,SAAS,mBACrC,kBAA4B,MAChC;AAAA;AAAA,UARK;AAAA,QASP,GAEJ,GACF;AAAA,SACF;AAAA,OACF,GACF;AAAA,KACF;AAEJ;AAEO,SAAS,cAA6B;AAC3C,QAAM,UAAU,WAAW,eAAe;AAC1C,MAAI,YAAY,MAAM;AACpB,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACvE;AACA,SAAO;AACT;","names":[]}
@@ -7,9 +7,6 @@ import {
7
7
  import {
8
8
  NotificationHeading
9
9
  } from "./chunk-SLHYBPJ5.js";
10
- import {
11
- Portal
12
- } from "./chunk-IQJDVFPP.js";
13
10
  import {
14
11
  addNotification,
15
12
  clearNotificationState,
@@ -17,6 +14,9 @@ import {
17
14
  removeNotification,
18
15
  updateNotificationState
19
16
  } from "./chunk-V3M3ZOQI.js";
17
+ import {
18
+ Portal
19
+ } from "./chunk-IQJDVFPP.js";
20
20
  import {
21
21
  Button
22
22
  } from "./chunk-6KZVE4HC.js";
@@ -177,4 +177,4 @@ export {
177
177
  NotificationCenter,
178
178
  useNotificationCenter
179
179
  };
180
- //# sourceMappingURL=chunk-FMRWRVUS.js.map
180
+ //# sourceMappingURL=chunk-Z4342DRO.js.map
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import {
3
+ CTAModalContext
4
+ } from "../../chunk-4LSTU6WU.js";
5
+ export {
6
+ CTAModalContext
7
+ };
8
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,26 @@
1
+ import "../../chunk-IKDXADLX.js";
2
+ import {
3
+ CTAModal,
4
+ useCTAModal
5
+ } from "../../chunk-QEM3M4N3.js";
6
+ import "../../chunk-4LSTU6WU.js";
7
+ import "../../chunk-MVO2GNUA.js";
8
+ import "../../chunk-DXOKSZVQ.js";
9
+ import "../../chunk-6BN3XKQF.js";
10
+ import "../../chunk-APD6IX5R.js";
11
+ import "../../chunk-TFL56AYR.js";
12
+ import "../../chunk-SXLPDPOZ.js";
13
+ import "../../chunk-IQJDVFPP.js";
14
+ import {
15
+ createCTAModalActions
16
+ } from "../../chunk-PLHYOCY3.js";
17
+ import "../../chunk-GITT5645.js";
18
+ import "../../chunk-6KZVE4HC.js";
19
+ import "../../chunk-7SYJFI5E.js";
20
+ import "../../chunk-BUVVRQLZ.js";
21
+ export {
22
+ CTAModal,
23
+ createCTAModalActions,
24
+ useCTAModal
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import {
3
+ CTAModal,
4
+ useCTAModal
5
+ } from "../../chunk-QEM3M4N3.js";
6
+ import "../../chunk-4LSTU6WU.js";
7
+ import "../../chunk-MVO2GNUA.js";
8
+ import "../../chunk-DXOKSZVQ.js";
9
+ import "../../chunk-6BN3XKQF.js";
10
+ import "../../chunk-APD6IX5R.js";
11
+ import "../../chunk-TFL56AYR.js";
12
+ import "../../chunk-SXLPDPOZ.js";
13
+ import "../../chunk-IQJDVFPP.js";
14
+ import "../../chunk-GITT5645.js";
15
+ import "../../chunk-6KZVE4HC.js";
16
+ import "../../chunk-7SYJFI5E.js";
17
+ import "../../chunk-BUVVRQLZ.js";
18
+ export {
19
+ CTAModal,
20
+ useCTAModal
21
+ };
22
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,10 @@
1
+ import {
2
+ TriggerItem
3
+ } from "../../chunk-MVO2GNUA.js";
4
+ import "../../chunk-6KZVE4HC.js";
5
+ import "../../chunk-7SYJFI5E.js";
6
+ import "../../chunk-BUVVRQLZ.js";
7
+ export {
8
+ TriggerItem
9
+ };
10
+ //# sourceMappingURL=trigger-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ createCTAModalActions
3
+ } from "../../chunk-PLHYOCY3.js";
4
+ export {
5
+ createCTAModalActions
6
+ };
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  For
3
- } from "../chunk-IIH363FO.js";
3
+ } from "../chunk-DXOKSZVQ.js";
4
4
  export {
5
5
  For
6
6
  };
@@ -6,8 +6,7 @@ import {
6
6
  import {
7
7
  Option,
8
8
  Select
9
- } from "../../chunk-P3SF56LT.js";
10
- import "../../chunk-IQJDVFPP.js";
9
+ } from "../../chunk-6ICNCCPD.js";
11
10
  import {
12
11
  SelectParts
13
12
  } from "../../chunk-XTNGF4D6.js";
@@ -29,6 +28,7 @@ import {
29
28
  SelectValueText,
30
29
  createSelectCollection
31
30
  } from "../../chunk-QCBLRACK.js";
31
+ import "../../chunk-IQJDVFPP.js";
32
32
  import "../../chunk-GITT5645.js";
33
33
  import "../../chunk-BUVVRQLZ.js";
34
34
  export {
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  Option,
4
4
  Select
5
- } from "../../chunk-P3SF56LT.js";
6
- import "../../chunk-IQJDVFPP.js";
5
+ } from "../../chunk-6ICNCCPD.js";
7
6
  import "../../chunk-XTNGF4D6.js";
8
7
  import "../../chunk-QCBLRACK.js";
8
+ import "../../chunk-IQJDVFPP.js";
9
9
  import "../../chunk-GITT5645.js";
10
10
  import "../../chunk-BUVVRQLZ.js";
11
11
  export {
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  NotificationCenter,
4
4
  useNotificationCenter
5
- } from "../chunk-FMRWRVUS.js";
5
+ } from "../chunk-Z4342DRO.js";
6
6
  import "../chunk-RDRD6ACD.js";
7
7
  import "../chunk-UXY3KCC3.js";
8
8
  import "../chunk-SLHYBPJ5.js";
9
- import "../chunk-IQJDVFPP.js";
10
9
  import "../chunk-V3M3ZOQI.js";
10
+ import "../chunk-IQJDVFPP.js";
11
11
  import "../chunk-GITT5645.js";
12
12
  import "../chunk-6KZVE4HC.js";
13
13
  import "../chunk-7SYJFI5E.js";