@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
@@ -1,99 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/components/cta-dialog/trigger-item.tsx
21
- var trigger_item_exports = {};
22
- __export(trigger_item_exports, {
23
- TriggerItem: () => TriggerItem
24
- });
25
- module.exports = __toCommonJS(trigger_item_exports);
26
- var import_css2 = require("@cerberus/styled-system/css");
27
-
28
- // src/components/button/button.tsx
29
- var import_react = require("react");
30
- var import_css = require("@cerberus/styled-system/css");
31
- var import_recipes = require("@cerberus/styled-system/recipes");
32
- var import_jsx = require("@cerberus/styled-system/jsx");
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- var ButtonContext = (0, import_react.createContext)({
35
- pending: false
36
- });
37
- function Button(props) {
38
- const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
39
- const value = (0, import_react.useMemo)(() => ({ pending }), [pending]);
40
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
41
- "button",
42
- {
43
- ...nativeProps,
44
- disabled: pending || nativeProps.disabled,
45
- className: (0, import_css.cx)(
46
- nativeProps.className,
47
- (0, import_recipes.button)({
48
- palette,
49
- usage,
50
- shape,
51
- size
52
- })
53
- )
54
- }
55
- ) });
56
- }
57
-
58
- // src/components/cta-dialog/trigger-item.tsx
59
- var import_factory = require("@ark-ui/react/factory");
60
- var import_recipes2 = require("@cerberus/styled-system/recipes");
61
- var import_jsx_runtime2 = require("react/jsx-runtime");
62
- function TriggerItem(props) {
63
- const { asChild, children, ...buttonProps } = props;
64
- if (asChild) {
65
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
66
- import_factory.ark.div,
67
- {
68
- className: (0, import_css2.cx)(
69
- (0, import_recipes2.button)({
70
- shape: "rounded",
71
- usage: "ghost"
72
- }),
73
- (0, import_css2.css)({
74
- w: "1/2"
75
- })
76
- ),
77
- asChild: true,
78
- children
79
- }
80
- );
81
- }
82
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
83
- Button,
84
- {
85
- ...buttonProps,
86
- className: (0, import_css2.css)({
87
- w: "1/2"
88
- }),
89
- shape: "rounded",
90
- usage: "outlined",
91
- children
92
- }
93
- );
94
- }
95
- // Annotate the CommonJS export names for ESM import in node:
96
- 0 && (module.exports = {
97
- TriggerItem
98
- });
99
- //# sourceMappingURL=trigger-item.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/components/cta-dialog/trigger-item.tsx","../../../../src/components/button/button.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","'use client'\n\nimport {\n type ButtonHTMLAttributes,\n type PropsWithChildren,\n createContext,\n useContext,\n useMemo,\n} from 'react'\nimport { cx } from '@cerberus/styled-system/css'\nimport {\n button,\n type ButtonVariantProps,\n} from '@cerberus/styled-system/recipes'\nimport { Box } from '@cerberus/styled-system/jsx'\nimport { Show } from '../Show'\nimport { Spinner } from '../Spinner'\n\n/**\n * This module contains the Button component.\n * @module\n */\n\ninterface ButtonContextValue {\n pending: boolean\n}\n\nconst ButtonContext = createContext<ButtonContextValue>({\n pending: false,\n})\n\nexport type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> &\n ButtonVariantProps & {\n pending?: boolean\n }\n\n/**\n * A component that allows the user to perform actions\n * @see https://cerberus.digitalu.design/react/button\n */\nexport function Button(props: ButtonProps): JSX.Element {\n const { palette, usage, shape, size, pending = false, ...nativeProps } = props\n const value = useMemo(() => ({ pending }), [pending])\n\n return (\n <ButtonContext.Provider value={value}>\n <button\n {...nativeProps}\n disabled={pending || nativeProps.disabled}\n className={cx(\n nativeProps.className,\n button({\n palette,\n usage,\n shape,\n size,\n }),\n )}\n />\n </ButtonContext.Provider>\n )\n}\n\n/**\n * An icon to display in a button that utilizes the pending state to display\n * a loading spinner.\n */\nexport function ButtonIcon(props: PropsWithChildren<object>) {\n const { pending } = useContext(ButtonContext)\n return (\n <Show when={pending} fallback={<>{props.children}</>}>\n <Box w=\"4\">\n <Spinner />\n </Box>\n </Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,cAAwB;;;ACExB,mBAMO;AACP,iBAAmB;AACnB,qBAGO;AACP,iBAAoB;AAgCd;AAnBN,IAAM,oBAAgB,4BAAkC;AAAA,EACtD,SAAS;AACX,CAAC;AAWM,SAAS,OAAO,OAAiC;AACtD,QAAM,EAAE,SAAS,OAAO,OAAO,MAAM,UAAU,OAAO,GAAG,YAAY,IAAI;AACzE,QAAM,YAAQ,sBAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEpD,SACE,4CAAC,cAAc,UAAd,EAAuB,OACtB;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,UAAU,WAAW,YAAY;AAAA,MACjC,eAAW;AAAA,QACT,YAAY;AAAA,YACZ,uBAAO;AAAA,UACL;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACF,CAAC;AAAA,MACH;AAAA;AAAA,EACF,GACF;AAEJ;;;AD3DA,qBAAoB;AACpB,IAAAC,kBAAuB;AAoBjB,IAAAC,sBAAA;AALC,SAAS,YAAY,OAAyB;AACnD,QAAM,EAAE,SAAS,UAAU,GAAG,YAAY,IAAI;AAE9C,MAAI,SAAS;AACX,WACE;AAAA,MAAC,mBAAI;AAAA,MAAJ;AAAA,QACC,eAAW;AAAA,cACT,wBAAO;AAAA,YACL,OAAO;AAAA,YACP,OAAO;AAAA,UACT,CAAC;AAAA,cACD,iBAAI;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,eAAW,iBAAI;AAAA,QACb,GAAG;AAAA,MACL,CAAC;AAAA,MACD,OAAM;AAAA,MACN,OAAM;AAAA,MAEL;AAAA;AAAA,EACH;AAEJ;","names":["import_css","import_recipes","import_jsx_runtime"]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/components/cta-dialog/utils.ts
21
- var utils_exports = {};
22
- __export(utils_exports, {
23
- createCTAModalActions: () => createCTAModalActions
24
- });
25
- module.exports = __toCommonJS(utils_exports);
26
- function createCTAModalActions(providedActions) {
27
- if (providedActions.length !== 2) {
28
- throw new Error("CTAModal must include 2 actions");
29
- }
30
- if (providedActions.every(
31
- (action) => action == null ? void 0 : action.handleClick
32
- )) {
33
- return {
34
- type: "btnAction",
35
- _actions: providedActions
36
- };
37
- }
38
- return {
39
- type: "reactNode",
40
- _actions: providedActions
41
- };
42
- }
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- createCTAModalActions
46
- });
47
- //# sourceMappingURL=utils.cjs.map
@@ -1 +0,0 @@
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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkCO,SAAS,sBACd,iBACsB;AACtB,MAAI,gBAAgB,WAAW,GAAG;AAChC,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AAEA,MACE,gBAAgB;AAAA,IACd,CAAC,WAAY,iCAAuC;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,8 +0,0 @@
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
@@ -1 +0,0 @@
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,12 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=chunk-IKDXADLX.js.map
@@ -1,47 +0,0 @@
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
@@ -1 +0,0 @@
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,23 +0,0 @@
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
@@ -1 +0,0 @@
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 +0,0 @@
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":[]}
@@ -1,8 +0,0 @@
1
- "use client";
2
- import {
3
- CTAModalContext
4
- } from "../../chunk-4LSTU6WU.js";
5
- export {
6
- CTAModalContext
7
- };
8
- //# sourceMappingURL=context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,7 +0,0 @@
1
- import {
2
- createCTAModalActions
3
- } from "../../chunk-PLHYOCY3.js";
4
- export {
5
- createCTAModalActions
6
- };
7
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,34 +0,0 @@
1
- 'use client'
2
-
3
- import { createContext, type ReactNode } from 'react'
4
- import type { CTAModalActionReturn } from './utils'
5
-
6
- /**
7
- * This module provides the context for the cta modal.
8
- * @module
9
- */
10
-
11
- export interface ShowCTAModalOptions {
12
- /**
13
- * The heading of the cta modal.
14
- */
15
- heading: string
16
- /**
17
- * The description of the cta modal.
18
- */
19
- description?: string
20
- /**
21
- * The icon used for the modal Avatar.
22
- */
23
- icon?: ReactNode
24
- /**
25
- * The actions for the cta modal. Requires 2 actions.
26
- */
27
- actions: CTAModalActionReturn
28
- }
29
-
30
- export interface CTAModalValue {
31
- show: (options: ShowCTAModalOptions) => void
32
- }
33
-
34
- export const CTAModalContext = createContext<CTAModalValue | null>(null)
@@ -1,2 +0,0 @@
1
- export * from './provider'
2
- export * from './utils'
@@ -1,53 +0,0 @@
1
- import { css, cx } from '@cerberus/styled-system/css'
2
- import { Button, type ButtonProps } from '../button/button'
3
- import { ark } from '@ark-ui/react/factory'
4
- import { button } from '@cerberus/styled-system/recipes'
5
-
6
- /**
7
- * This module provides the trigger item for the cta modal.
8
- * @module 'react/cta-modal/trigger-item'
9
- */
10
-
11
- export interface TriggerItemProps extends ButtonProps {
12
- asChild?: boolean
13
- }
14
-
15
- /**
16
- * Trigger item for the cta modal which renders content based on the actions.
17
- * type.
18
- */
19
- export function TriggerItem(props: TriggerItemProps) {
20
- const { asChild, children, ...buttonProps } = props
21
-
22
- if (asChild) {
23
- return (
24
- <ark.div
25
- className={cx(
26
- button({
27
- shape: 'rounded',
28
- usage: 'ghost',
29
- }),
30
- css({
31
- w: '1/2',
32
- }),
33
- )}
34
- asChild
35
- >
36
- {children}
37
- </ark.div>
38
- )
39
- }
40
-
41
- return (
42
- <Button
43
- {...buttonProps}
44
- className={css({
45
- w: '1/2',
46
- })}
47
- shape="rounded"
48
- usage="outlined"
49
- >
50
- {children}
51
- </Button>
52
- )
53
- }
@@ -1,57 +0,0 @@
1
- import type { MouseEventHandler, ReactNode } from 'react'
2
-
3
- /**
4
- * This module provide utility functions for the cta modal.
5
- * @module 'react/cta-modal/utils'
6
- */
7
-
8
- export type CTAButtonAction = {
9
- /**
10
- * The text of the button.
11
- */
12
- text: string
13
- /**
14
- * The onClick handler for the button.
15
- */
16
- handleClick: MouseEventHandler<HTMLButtonElement>
17
- }
18
-
19
- export type CTAModalAction = (CTAButtonAction | ReactNode)[]
20
-
21
- export interface CTAModalActionReturn {
22
- /**
23
- * The type of the action content.
24
- */
25
- type: 'reactNode' | 'btnAction'
26
- /**
27
- * The actions for the cta modal. Max of 2 actions.
28
- */
29
- _actions: CTAModalAction
30
- }
31
-
32
- /**
33
- * Creates the action data to pass to the cta modal `show` method.
34
- */
35
- export function createCTAModalActions(
36
- providedActions: CTAModalAction,
37
- ): CTAModalActionReturn {
38
- if (providedActions.length !== 2) {
39
- throw new Error('CTAModal must include 2 actions')
40
- }
41
-
42
- if (
43
- providedActions.every(
44
- (action) => (action as unknown as CTAButtonAction)?.handleClick,
45
- )
46
- ) {
47
- return {
48
- type: 'btnAction',
49
- _actions: providedActions as CTAButtonAction[],
50
- }
51
- }
52
-
53
- return {
54
- type: 'reactNode',
55
- _actions: providedActions as ReactNode[],
56
- }
57
- }