@cerberus-design/react 0.16.0-next-270c731 → 0.16.0

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 +25 -82
  2. package/build/legacy/components/for.cjs +4 -3
  3. package/build/legacy/components/for.cjs.map +1 -1
  4. package/build/legacy/{components/cta-dialog/provider.cjs → context/cta-modal.cjs} +150 -187
  5. package/build/legacy/context/cta-modal.cjs.map +1 -0
  6. package/build/legacy/index.cjs +715 -771
  7. package/build/legacy/index.cjs.map +1 -1
  8. package/build/modern/_tsup-dts-rollup.d.ts +25 -82
  9. package/build/modern/{chunk-O542MPR7.js → chunk-CMYD5KWA.js} +4 -4
  10. package/build/modern/{chunk-Z4342DRO.js → chunk-FMRWRVUS.js} +4 -4
  11. package/build/modern/chunk-IIH363FO.js +13 -0
  12. package/build/modern/chunk-IIH363FO.js.map +1 -0
  13. package/build/modern/{chunk-6ICNCCPD.js → chunk-P3SF56LT.js} +4 -4
  14. package/build/modern/{chunk-QEM3M4N3.js → chunk-ZDANBCM3.js} +31 -22
  15. package/build/modern/chunk-ZDANBCM3.js.map +1 -0
  16. package/build/modern/components/for.js +1 -1
  17. package/build/modern/components/select/index.js +2 -2
  18. package/build/modern/components/select/select.js +2 -2
  19. package/build/modern/context/cta-modal.js +19 -0
  20. package/build/modern/context/notification-center.js +2 -2
  21. package/build/modern/context/prompt-modal.js +2 -2
  22. package/build/modern/index.js +76 -83
  23. package/build/modern/index.js.map +1 -1
  24. package/package.json +2 -2
  25. package/src/components/for.tsx +18 -13
  26. package/src/{components/cta-dialog/provider.tsx → context/cta-modal.tsx} +68 -34
  27. package/src/index.ts +1 -1
  28. package/build/legacy/components/cta-dialog/context.cjs +0 -33
  29. package/build/legacy/components/cta-dialog/context.cjs.map +0 -1
  30. package/build/legacy/components/cta-dialog/index.cjs +0 -433
  31. package/build/legacy/components/cta-dialog/index.cjs.map +0 -1
  32. package/build/legacy/components/cta-dialog/provider.cjs.map +0 -1
  33. package/build/legacy/components/cta-dialog/trigger-item.cjs +0 -99
  34. package/build/legacy/components/cta-dialog/trigger-item.cjs.map +0 -1
  35. package/build/legacy/components/cta-dialog/utils.cjs +0 -47
  36. package/build/legacy/components/cta-dialog/utils.cjs.map +0 -1
  37. package/build/modern/chunk-4LSTU6WU.js +0 -8
  38. package/build/modern/chunk-4LSTU6WU.js.map +0 -1
  39. package/build/modern/chunk-DXOKSZVQ.js +0 -12
  40. package/build/modern/chunk-DXOKSZVQ.js.map +0 -1
  41. package/build/modern/chunk-IKDXADLX.js +0 -1
  42. package/build/modern/chunk-MVO2GNUA.js +0 -47
  43. package/build/modern/chunk-MVO2GNUA.js.map +0 -1
  44. package/build/modern/chunk-PLHYOCY3.js +0 -23
  45. package/build/modern/chunk-PLHYOCY3.js.map +0 -1
  46. package/build/modern/chunk-QEM3M4N3.js.map +0 -1
  47. package/build/modern/components/cta-dialog/context.js +0 -8
  48. package/build/modern/components/cta-dialog/context.js.map +0 -1
  49. package/build/modern/components/cta-dialog/index.js +0 -26
  50. package/build/modern/components/cta-dialog/index.js.map +0 -1
  51. package/build/modern/components/cta-dialog/provider.js +0 -22
  52. package/build/modern/components/cta-dialog/provider.js.map +0 -1
  53. package/build/modern/components/cta-dialog/trigger-item.js +0 -10
  54. package/build/modern/components/cta-dialog/trigger-item.js.map +0 -1
  55. package/build/modern/components/cta-dialog/utils.js +0 -7
  56. package/build/modern/components/cta-dialog/utils.js.map +0 -1
  57. package/src/components/cta-dialog/context.tsx +0 -34
  58. package/src/components/cta-dialog/index.ts +0 -2
  59. package/src/components/cta-dialog/trigger-item.tsx +0 -53
  60. package/src/components/cta-dialog/utils.ts +0 -57
  61. /package/build/modern/{chunk-O542MPR7.js.map → chunk-CMYD5KWA.js.map} +0 -0
  62. /package/build/modern/{chunk-Z4342DRO.js.map → chunk-FMRWRVUS.js.map} +0 -0
  63. /package/build/modern/{chunk-6ICNCCPD.js.map → chunk-P3SF56LT.js.map} +0 -0
  64. /package/build/modern/{chunk-IKDXADLX.js.map → context/cta-modal.js.map} +0 -0
@@ -103,7 +103,6 @@ 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';
107
106
  import { KeyboardCode } from '@dnd-kit/core';
108
107
  import { KeyboardCodes } from '@dnd-kit/core';
109
108
  import { KeyboardCoordinateGetter } from '@dnd-kit/core';
@@ -120,7 +119,7 @@ import { Menu as Menu_2 } from '@ark-ui/react';
120
119
  import { Modifier } from '@dnd-kit/core';
121
120
  import { Modifiers } from '@dnd-kit/core';
122
121
  import { MouseEvent as MouseEvent_2 } from 'react';
123
- import type { MouseEventHandler } from 'react';
122
+ import { MouseEventHandler } from 'react';
124
123
  import { MouseSensor } from '@dnd-kit/core';
125
124
  import { MouseSensorOptions } from '@dnd-kit/core';
126
125
  import { NotificationVariantProps } from '@cerberus/styled-system/recipes';
@@ -951,14 +950,6 @@ declare interface ConfirmModalValue {
951
950
  export { ConfirmModalValue }
952
951
  export { ConfirmModalValue as ConfirmModalValue_alias_1 }
953
952
 
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
-
962
953
  declare function createNavTriggerProps(values: NavTriggerAriaValues): NavTriggerAriaReturn;
963
954
  export { createNavTriggerProps }
964
955
  export { createNavTriggerProps as createNavTriggerProps_alias_1 }
@@ -976,28 +967,6 @@ export { createSelectCollection }
976
967
  export { createSelectCollection as createSelectCollection_alias_1 }
977
968
  export { createSelectCollection as createSelectCollection_alias_2 }
978
969
 
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
- */
1001
970
  /**
1002
971
  * Provides a CTA modal to the app.
1003
972
  * @see https://cerberus.digitalu.design/react/cta-modal
@@ -1030,35 +999,19 @@ export { CTAButtonAction as CTAButtonAction_alias_2 }
1030
999
  * }, [cta])
1031
1000
  * ```
1032
1001
  */
1033
- declare function CTAModal(props: PropsWithChildren<object>): JSX_2.Element;
1002
+ declare function CTAModal(props: PropsWithChildren<CTAModalProviderProps>): JSX_2.Element;
1034
1003
  export { CTAModal }
1035
1004
  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 }
1056
1005
 
1057
- export declare const CTAModalContext: Context<CTAModalValue | null>;
1006
+ declare type CTAModalProviderProps = PropsWithChildren<unknown>;
1007
+ export { CTAModalProviderProps }
1008
+ export { CTAModalProviderProps as CTAModalProviderProps_alias_1 }
1058
1009
 
1059
- export declare interface CTAModalValue {
1010
+ declare interface CTAModalValue {
1060
1011
  show: (options: ShowCTAModalOptions) => void;
1061
1012
  }
1013
+ export { CTAModalValue }
1014
+ export { CTAModalValue as CTAModalValue_alias_1 }
1062
1015
 
1063
1016
  declare type CustomThemes<K extends string = DefaultThemes> = 'cerberus' | K;
1064
1017
  export { CustomThemes }
@@ -2272,7 +2225,7 @@ export { FileUploaderProps as FileUploaderProps_alias_1 }
2272
2225
  * </For>
2273
2226
  * ```
2274
2227
  */
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;
2228
+ declare function For<T extends string | number | Record<string, unknown> | object | undefined>(props: ForProps<T>): ReactNode;
2276
2229
  export { For }
2277
2230
  export { For as For_alias_1 }
2278
2231
 
@@ -2321,19 +2274,19 @@ declare function formatNotifyCount(count: number): string;
2321
2274
  export { formatNotifyCount }
2322
2275
  export { formatNotifyCount as formatNotifyCount_alias_1 }
2323
2276
 
2324
- declare interface ForProps<T extends readonly unknown[], U extends JSX_3.Element> {
2277
+ declare interface ForProps<T> {
2325
2278
  /**
2326
- * The array to iterate over.
2279
+ * The array to iterate over
2327
2280
  */
2328
- each: T | undefined | null | false;
2281
+ each: T[];
2329
2282
  /**
2330
- * The fallback to render when the array is empty.
2283
+ * The fallback content to render when the array is empty
2331
2284
  */
2332
- fallback?: JSX_3.Element;
2285
+ fallback?: ReactNode;
2333
2286
  /**
2334
- * The children to render for each item in the array.
2287
+ * The render function to render each item in the array
2335
2288
  */
2336
- children: (item: T[number], index: number) => U;
2289
+ children: (item: Exclude<T, undefined>, index: number) => ReactNode;
2337
2290
  }
2338
2291
  export { ForProps }
2339
2292
  export { ForProps as ForProps_alias_1 }
@@ -3873,10 +3826,10 @@ export { ShowConfirmModalOptions }
3873
3826
  export { ShowConfirmModalOptions as ShowConfirmModalOptions_alias_1 }
3874
3827
 
3875
3828
  /**
3876
- * This module provides the context for the cta modal.
3829
+ * This module provides a context and hook for the cta modal.
3877
3830
  * @module
3878
3831
  */
3879
- export declare interface ShowCTAModalOptions {
3832
+ declare interface ShowCTAModalOptions {
3880
3833
  /**
3881
3834
  * The heading of the cta modal.
3882
3835
  */
@@ -3890,10 +3843,15 @@ export declare interface ShowCTAModalOptions {
3890
3843
  */
3891
3844
  icon?: ReactNode;
3892
3845
  /**
3893
- * The actions for the cta modal. Requires 2 actions.
3846
+ * The actions for the cta modal. Max of 2 actions.
3894
3847
  */
3895
- actions: CTAModalActionReturn;
3848
+ actions: {
3849
+ text: string;
3850
+ onClick: MouseEventHandler<HTMLButtonElement>;
3851
+ }[];
3896
3852
  }
3853
+ export { ShowCTAModalOptions }
3854
+ export { ShowCTAModalOptions as ShowCTAModalOptions_alias_1 }
3897
3855
 
3898
3856
  /**
3899
3857
  * This module provides a context and hook for the prompt modal.
@@ -4631,20 +4589,6 @@ export { trapFocus as trapFocus_alias_1 }
4631
4589
 
4632
4590
  export { TraversalOrder }
4633
4591
 
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
-
4648
4592
  declare type TrProps = TableHTMLAttributes<HTMLTableRowElement>;
4649
4593
  export { TrProps }
4650
4594
  export { TrProps as TrProps_alias_1 }
@@ -4680,7 +4624,6 @@ export { useConfirmModal as useConfirmModal_alias_1 }
4680
4624
  declare function useCTAModal(): CTAModalValue;
4681
4625
  export { useCTAModal }
4682
4626
  export { useCTAModal as useCTAModal_alias_1 }
4683
- export { useCTAModal as useCTAModal_alias_2 }
4684
4627
 
4685
4628
  /**
4686
4629
  * @deprecated use the DatePicker family instead
@@ -1,6 +1,3 @@
1
- import {
2
- Text
3
- } from "./chunk-RU5LOXWI.js";
4
1
  import {
5
2
  Dialog,
6
3
  DialogDescription,
@@ -10,6 +7,9 @@ import {
10
7
  import {
11
8
  Avatar
12
9
  } 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-O542MPR7.js.map
212
+ //# sourceMappingURL=chunk-CMYD5KWA.js.map
@@ -7,6 +7,9 @@ import {
7
7
  import {
8
8
  NotificationHeading
9
9
  } from "./chunk-SLHYBPJ5.js";
10
+ import {
11
+ Portal
12
+ } from "./chunk-IQJDVFPP.js";
10
13
  import {
11
14
  addNotification,
12
15
  clearNotificationState,
@@ -14,9 +17,6 @@ import {
14
17
  removeNotification,
15
18
  updateNotificationState
16
19
  } 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-Z4342DRO.js.map
180
+ //# sourceMappingURL=chunk-FMRWRVUS.js.map
@@ -0,0 +1,13 @@
1
+ // src/components/for.tsx
2
+ function For(props) {
3
+ const mappableChildren = props.children;
4
+ if (props.each?.length === 0) {
5
+ return props.fallback || null;
6
+ }
7
+ return props.each?.map(mappableChildren);
8
+ }
9
+
10
+ export {
11
+ For
12
+ };
13
+ //# sourceMappingURL=chunk-IIH363FO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/for.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\n\nexport interface ForProps<T> {\n /**\n * The array to iterate over\n */\n each: T[]\n /**\n * The fallback content to render when the array is empty\n */\n fallback?: ReactNode\n /**\n * The render function to render each item in the array\n */\n children: (item: Exclude<T, undefined>, index: number) => ReactNode\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<\n T extends string | number | Record<string, unknown> | object | undefined,\n>(props: ForProps<T>) {\n const mappableChildren = props.children as unknown as (\n item: T,\n index: number,\n ) => ReactNode\n\n if (props.each?.length === 0) {\n return props.fallback || null\n }\n\n return props.each?.map(mappableChildren) as ReactNode\n}\n"],"mappings":";AA6BO,SAAS,IAEd,OAAoB;AACpB,QAAM,mBAAmB,MAAM;AAK/B,MAAI,MAAM,MAAM,WAAW,GAAG;AAC5B,WAAO,MAAM,YAAY;AAAA,EAC3B;AAEA,SAAO,MAAM,MAAM,IAAI,gBAAgB;AACzC;","names":[]}
@@ -1,9 +1,9 @@
1
- import {
2
- SelectParts
3
- } from "./chunk-XTNGF4D6.js";
4
1
  import {
5
2
  Portal
6
3
  } from "./chunk-IQJDVFPP.js";
4
+ import {
5
+ SelectParts
6
+ } from "./chunk-XTNGF4D6.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-6ICNCCPD.js.map
47
+ //# sourceMappingURL=chunk-P3SF56LT.js.map
@@ -1,12 +1,3 @@
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";
10
1
  import {
11
2
  DialogCloseIconTrigger
12
3
  } from "./chunk-6BN3XKQF.js";
@@ -22,19 +13,26 @@ import {
22
13
  import {
23
14
  useCerberusContext
24
15
  } from "./chunk-GITT5645.js";
16
+ import {
17
+ Button
18
+ } from "./chunk-6KZVE4HC.js";
25
19
  import {
26
20
  Show
27
21
  } from "./chunk-BUVVRQLZ.js";
28
22
 
29
- // src/components/cta-dialog/provider.tsx
23
+ // src/context/cta-modal.tsx
30
24
  import {
25
+ createContext,
31
26
  useCallback,
32
27
  useContext,
33
28
  useMemo,
34
29
  useState
35
30
  } from "react";
36
- import { HStack, VStack } from "@cerberus/styled-system/jsx";
31
+ import { HStack } from "@cerberus/styled-system/jsx";
32
+ import { css } from "@cerberus/styled-system/css";
33
+ import { VStack } from "@cerberus/styled-system/jsx";
37
34
  import { jsx, jsxs } from "react/jsx-runtime";
35
+ var CTAModalContext = createContext(null);
38
36
  function CTAModal(props) {
39
37
  const [open, setOpen] = useState(false);
40
38
  const [content, setContent] = useState(null);
@@ -43,6 +41,12 @@ function CTAModal(props) {
43
41
  const { confirmModal: FallbackIcon } = icons;
44
42
  const handleShow = useCallback(
45
43
  (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
+ }
46
50
  setContent({ ...options });
47
51
  setOpen(true);
48
52
  },
@@ -50,10 +54,10 @@ function CTAModal(props) {
50
54
  );
51
55
  const handleActionClick = useCallback(
52
56
  (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);
57
+ const index = event.currentTarget.getAttribute("data-index");
58
+ const action = content?.actions[Number(index)];
59
+ const { onClick } = action || {};
60
+ onClick?.(event);
57
61
  setOpen(false);
58
62
  },
59
63
  [content, setOpen]
@@ -89,15 +93,20 @@ function CTAModal(props) {
89
93
  /* @__PURE__ */ jsx(DialogHeading, { children: content?.heading }),
90
94
  /* @__PURE__ */ jsx(DialogDescription, { children: content?.description })
91
95
  ] }) }),
92
- /* @__PURE__ */ jsx(HStack, { gap: "md", w: "full", children: /* @__PURE__ */ jsx(For, { each: content?.actions._actions, children: (action, index) => /* @__PURE__ */ jsx(
93
- Show,
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,
94
98
  {
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 })
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
98
107
  },
99
108
  index
100
- ) }) })
109
+ )) }) })
101
110
  ] })
102
111
  ] }) })
103
112
  ] });
@@ -114,4 +123,4 @@ export {
114
123
  CTAModal,
115
124
  useCTAModal
116
125
  };
117
- //# sourceMappingURL=chunk-QEM3M4N3.js.map
126
+ //# sourceMappingURL=chunk-ZDANBCM3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/cta-modal.tsx"],"sourcesContent":["'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useState,\n type MouseEvent,\n type MouseEventHandler,\n type PropsWithChildren,\n type ReactNode,\n} from 'react'\nimport { Button } from '../components/button/button'\nimport { Show } from '../components/Show'\nimport { Avatar } from '../components/Avatar'\nimport { useCerberusContext } from './cerberus'\nimport { HStack } from '@cerberus/styled-system/jsx'\nimport { css } from '@cerberus/styled-system/css'\nimport { VStack } from '@cerberus/styled-system/jsx'\nimport {\n Dialog,\n DialogDescription,\n DialogHeading,\n DialogProvider,\n} from '../components/Dialog'\nimport { DialogCloseIconTrigger } from '../components/Dialog.client'\n\n/**\n * This module provides a context and hook 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. Max of 2 actions.\n */\n actions: {\n text: string\n onClick: MouseEventHandler<HTMLButtonElement>\n }[]\n}\n\nexport interface CTAModalValue {\n show: (options: ShowCTAModalOptions) => void\n}\n\nconst CTAModalContext = createContext<CTAModalValue | null>(null)\n\nexport type CTAModalProviderProps = PropsWithChildren<unknown>\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<CTAModalProviderProps>) {\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 const maxActions = 2\n if (options.actions.length > maxActions) {\n throw new Error(\n `CTA Modal only supports a maximum of ${maxActions} actions.`,\n )\n }\n setContent({ ...options })\n setOpen(true)\n },\n [setOpen],\n )\n\n const handleActionClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n const index = event.currentTarget.getAttribute('data-index')\n const action = content?.actions[Number(index)]\n const { onClick } = action || {}\n onClick?.(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 <Show when={Boolean(content?.actions?.length)}>\n {content?.actions?.map((action, index) => (\n <Button\n data-index={index}\n className={css({\n w: '1/2',\n })}\n key={index}\n onClick={handleActionClick}\n shape=\"rounded\"\n usage=\"outlined\"\n >\n {action.text}\n </Button>\n ))}\n </Show>\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,EACA;AAAA,OAKK;AAKP,SAAS,cAAc;AACvB,SAAS,WAAW;AACpB,SAAS,cAAc;AA0Hb,cAII,YAJJ;AAlFV,IAAM,kBAAkB,cAAoC,IAAI;AAoCzD,SAAS,SAAS,OAAiD;AACxE,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,YAAM,aAAa;AACnB,UAAI,QAAQ,QAAQ,SAAS,YAAY;AACvC,cAAM,IAAI;AAAA,UACR,wCAAwC,UAAU;AAAA,QACpD;AAAA,MACF;AACA,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,MAAM,cAAc,aAAa,YAAY;AAC3D,YAAM,SAAS,SAAS,QAAQ,OAAO,KAAK,CAAC;AAC7C,YAAM,EAAE,QAAQ,IAAI,UAAU,CAAC;AAC/B,gBAAU,KAAK;AACf,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,QAAK,MAAM,QAAQ,SAAS,SAAS,MAAM,GACzC,mBAAS,SAAS,IAAI,CAAC,QAAQ,UAC9B;AAAA,UAAC;AAAA;AAAA,YACC,cAAY;AAAA,YACZ,WAAW,IAAI;AAAA,cACb,GAAG;AAAA,YACL,CAAC;AAAA,YAED,SAAS;AAAA,YACT,OAAM;AAAA,YACN,OAAM;AAAA,YAEL,iBAAO;AAAA;AAAA,UALH;AAAA,QAMP,CACD,GACH,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":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  For
3
- } from "../chunk-DXOKSZVQ.js";
3
+ } from "../chunk-IIH363FO.js";
4
4
  export {
5
5
  For
6
6
  };
@@ -6,7 +6,8 @@ import {
6
6
  import {
7
7
  Option,
8
8
  Select
9
- } from "../../chunk-6ICNCCPD.js";
9
+ } from "../../chunk-P3SF56LT.js";
10
+ import "../../chunk-IQJDVFPP.js";
10
11
  import {
11
12
  SelectParts
12
13
  } from "../../chunk-XTNGF4D6.js";
@@ -28,7 +29,6 @@ import {
28
29
  SelectValueText,
29
30
  createSelectCollection
30
31
  } 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-6ICNCCPD.js";
5
+ } from "../../chunk-P3SF56LT.js";
6
+ import "../../chunk-IQJDVFPP.js";
6
7
  import "../../chunk-XTNGF4D6.js";
7
8
  import "../../chunk-QCBLRACK.js";
8
- import "../../chunk-IQJDVFPP.js";
9
9
  import "../../chunk-GITT5645.js";
10
10
  import "../../chunk-BUVVRQLZ.js";
11
11
  export {
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import {
3
+ CTAModal,
4
+ useCTAModal
5
+ } from "../chunk-ZDANBCM3.js";
6
+ import "../chunk-6BN3XKQF.js";
7
+ import "../chunk-TFL56AYR.js";
8
+ import "../chunk-APD6IX5R.js";
9
+ import "../chunk-SXLPDPOZ.js";
10
+ import "../chunk-IQJDVFPP.js";
11
+ import "../chunk-GITT5645.js";
12
+ import "../chunk-6KZVE4HC.js";
13
+ import "../chunk-7SYJFI5E.js";
14
+ import "../chunk-BUVVRQLZ.js";
15
+ export {
16
+ CTAModal,
17
+ useCTAModal
18
+ };
19
+ //# sourceMappingURL=cta-modal.js.map
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  NotificationCenter,
4
4
  useNotificationCenter
5
- } from "../chunk-Z4342DRO.js";
5
+ } from "../chunk-FMRWRVUS.js";
6
6
  import "../chunk-RDRD6ACD.js";
7
7
  import "../chunk-UXY3KCC3.js";
8
8
  import "../chunk-SLHYBPJ5.js";
9
- import "../chunk-V3M3ZOQI.js";
10
9
  import "../chunk-IQJDVFPP.js";
10
+ import "../chunk-V3M3ZOQI.js";
11
11
  import "../chunk-GITT5645.js";
12
12
  import "../chunk-6KZVE4HC.js";
13
13
  import "../chunk-7SYJFI5E.js";
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  PromptModal,
4
4
  usePromptModal
5
- } from "../chunk-O542MPR7.js";
6
- import "../chunk-RU5LOXWI.js";
5
+ } from "../chunk-CMYD5KWA.js";
7
6
  import "../chunk-TFL56AYR.js";
8
7
  import "../chunk-SXLPDPOZ.js";
9
8
  import "../chunk-IQJDVFPP.js";
9
+ import "../chunk-RU5LOXWI.js";
10
10
  import "../chunk-TYPULJMJ.js";
11
11
  import "../chunk-FBS7AX76.js";
12
12
  import "../chunk-6I2FW4WI.js";