@cerberus-design/react 0.16.0-next-4f6c716 → 0.16.0-next-270c731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/legacy/_tsup-dts-rollup.d.cts +82 -25
- package/build/legacy/components/cta-dialog/context.cjs +33 -0
- package/build/legacy/components/cta-dialog/context.cjs.map +1 -0
- package/build/legacy/components/cta-dialog/index.cjs +433 -0
- package/build/legacy/components/cta-dialog/index.cjs.map +1 -0
- package/build/legacy/{context/cta-modal.cjs → components/cta-dialog/provider.cjs} +187 -150
- package/build/legacy/components/cta-dialog/provider.cjs.map +1 -0
- package/build/legacy/components/cta-dialog/trigger-item.cjs +99 -0
- package/build/legacy/components/cta-dialog/trigger-item.cjs.map +1 -0
- package/build/legacy/components/cta-dialog/utils.cjs +47 -0
- package/build/legacy/components/cta-dialog/utils.cjs.map +1 -0
- package/build/legacy/components/for.cjs +3 -4
- package/build/legacy/components/for.cjs.map +1 -1
- package/build/legacy/index.cjs +771 -715
- package/build/legacy/index.cjs.map +1 -1
- package/build/modern/_tsup-dts-rollup.d.ts +82 -25
- package/build/modern/chunk-4LSTU6WU.js +8 -0
- package/build/modern/chunk-4LSTU6WU.js.map +1 -0
- package/build/modern/{chunk-P3SF56LT.js → chunk-6ICNCCPD.js} +4 -4
- package/build/modern/chunk-DXOKSZVQ.js +12 -0
- package/build/modern/chunk-DXOKSZVQ.js.map +1 -0
- package/build/modern/chunk-IKDXADLX.js +1 -0
- package/build/modern/chunk-MVO2GNUA.js +47 -0
- package/build/modern/chunk-MVO2GNUA.js.map +1 -0
- package/build/modern/{chunk-CMYD5KWA.js → chunk-O542MPR7.js} +4 -4
- package/build/modern/chunk-PLHYOCY3.js +23 -0
- package/build/modern/chunk-PLHYOCY3.js.map +1 -0
- package/build/modern/{chunk-ZDANBCM3.js → chunk-QEM3M4N3.js} +22 -31
- package/build/modern/chunk-QEM3M4N3.js.map +1 -0
- package/build/modern/{chunk-FMRWRVUS.js → chunk-Z4342DRO.js} +4 -4
- package/build/modern/components/cta-dialog/context.js +8 -0
- package/build/modern/components/cta-dialog/context.js.map +1 -0
- package/build/modern/components/cta-dialog/index.js +26 -0
- package/build/modern/components/cta-dialog/index.js.map +1 -0
- package/build/modern/components/cta-dialog/provider.js +22 -0
- package/build/modern/components/cta-dialog/provider.js.map +1 -0
- package/build/modern/components/cta-dialog/trigger-item.js +10 -0
- package/build/modern/components/cta-dialog/trigger-item.js.map +1 -0
- package/build/modern/components/cta-dialog/utils.js +7 -0
- package/build/modern/components/cta-dialog/utils.js.map +1 -0
- package/build/modern/components/for.js +1 -1
- package/build/modern/components/select/index.js +2 -2
- package/build/modern/components/select/select.js +2 -2
- package/build/modern/context/notification-center.js +2 -2
- package/build/modern/context/prompt-modal.js +2 -2
- package/build/modern/index.js +83 -76
- package/build/modern/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/cta-dialog/context.tsx +34 -0
- package/src/components/cta-dialog/index.ts +2 -0
- package/src/{context/cta-modal.tsx → components/cta-dialog/provider.tsx} +34 -68
- package/src/components/cta-dialog/trigger-item.tsx +53 -0
- package/src/components/cta-dialog/utils.ts +57 -0
- package/src/components/for.tsx +13 -18
- package/src/index.ts +1 -1
- package/build/legacy/context/cta-modal.cjs.map +0 -1
- package/build/modern/chunk-IIH363FO.js +0 -13
- package/build/modern/chunk-IIH363FO.js.map +0 -1
- package/build/modern/chunk-ZDANBCM3.js.map +0 -1
- package/build/modern/context/cta-modal.js +0 -19
- /package/build/modern/{chunk-P3SF56LT.js.map → chunk-6ICNCCPD.js.map} +0 -0
- /package/build/modern/{context/cta-modal.js.map → chunk-IKDXADLX.js.map} +0 -0
- /package/build/modern/{chunk-CMYD5KWA.js.map → chunk-O542MPR7.js.map} +0 -0
- /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<
|
|
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
|
|
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
|
|
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
|
|
2330
|
+
* The fallback to render when the array is empty.
|
|
2284
2331
|
*/
|
|
2285
|
-
fallback?:
|
|
2332
|
+
fallback?: JSX_3.Element;
|
|
2286
2333
|
/**
|
|
2287
|
-
* The
|
|
2334
|
+
* The children to render for each item in the array.
|
|
2288
2335
|
*/
|
|
2289
|
-
children: (item:
|
|
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
|
|
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.
|
|
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,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/components/cta-dialog/context.tsx
|
|
22
|
+
var context_exports = {};
|
|
23
|
+
__export(context_exports, {
|
|
24
|
+
CTAModalContext: () => CTAModalContext
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(context_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var CTAModalContext = (0, import_react.createContext)(null);
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
CTAModalContext
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=context.cjs.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":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAA8C;AA+BvC,IAAM,sBAAkB,4BAAoC,IAAI;","names":[]}
|
|
@@ -0,0 +1,433 @@
|
|
|
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/index.ts
|
|
21
|
+
var cta_dialog_exports = {};
|
|
22
|
+
__export(cta_dialog_exports, {
|
|
23
|
+
CTAModal: () => CTAModal,
|
|
24
|
+
createCTAModalActions: () => createCTAModalActions,
|
|
25
|
+
useCTAModal: () => useCTAModal
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(cta_dialog_exports);
|
|
28
|
+
|
|
29
|
+
// src/components/cta-dialog/provider.tsx
|
|
30
|
+
var import_react8 = require("react");
|
|
31
|
+
var import_jsx2 = require("@cerberus/styled-system/jsx");
|
|
32
|
+
|
|
33
|
+
// src/context/cerberus.tsx
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var CerberusContext = (0, import_react.createContext)(null);
|
|
37
|
+
function useCerberusContext() {
|
|
38
|
+
const context = (0, import_react.useContext)(CerberusContext);
|
|
39
|
+
if (!context) {
|
|
40
|
+
throw new Error("useCerberus must be used within a CerberusProvider");
|
|
41
|
+
}
|
|
42
|
+
return context;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/components/Show.tsx
|
|
46
|
+
var import_react2 = require("react");
|
|
47
|
+
function Show(props) {
|
|
48
|
+
const { when, children, fallback } = props;
|
|
49
|
+
const condition = (0, import_react2.useMemo)(() => when ?? false, [when]);
|
|
50
|
+
return (0, import_react2.useMemo)(() => {
|
|
51
|
+
if (condition) return children;
|
|
52
|
+
return fallback ?? null;
|
|
53
|
+
}, [condition, children, fallback]);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// src/components/for.tsx
|
|
57
|
+
function For(props) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!props.each || !props.each.length) {
|
|
60
|
+
return props.fallback || null;
|
|
61
|
+
}
|
|
62
|
+
return (_a = props.each) == null ? void 0 : _a.map(props.children);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// src/components/Avatar.tsx
|
|
66
|
+
var import_css = require("@cerberus/styled-system/css");
|
|
67
|
+
var import_patterns = require("@cerberus/styled-system/patterns");
|
|
68
|
+
var import_recipes = require("@cerberus/styled-system/recipes");
|
|
69
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
70
|
+
function Avatar(props) {
|
|
71
|
+
const {
|
|
72
|
+
ariaLabel,
|
|
73
|
+
as,
|
|
74
|
+
gradient,
|
|
75
|
+
size,
|
|
76
|
+
src,
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
icon,
|
|
80
|
+
...nativeProps
|
|
81
|
+
} = props;
|
|
82
|
+
const { icons } = useCerberusContext();
|
|
83
|
+
const { avatar: AvatarIcon } = icons;
|
|
84
|
+
const initials = (ariaLabel || "").split(" ").map((word) => word[0]).join("").slice(0, 2);
|
|
85
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
86
|
+
"div",
|
|
87
|
+
{
|
|
88
|
+
...nativeProps,
|
|
89
|
+
className: (0, import_css.cx)(
|
|
90
|
+
nativeProps.className,
|
|
91
|
+
(0, import_recipes.avatar)({ gradient, size }),
|
|
92
|
+
(0, import_patterns.circle)()
|
|
93
|
+
),
|
|
94
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
95
|
+
Show,
|
|
96
|
+
{
|
|
97
|
+
when: Boolean(src) || Boolean(as),
|
|
98
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
99
|
+
Show,
|
|
100
|
+
{
|
|
101
|
+
when: Boolean(initials),
|
|
102
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
103
|
+
Show,
|
|
104
|
+
{
|
|
105
|
+
when: Boolean(icon),
|
|
106
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
107
|
+
AvatarIcon,
|
|
108
|
+
{
|
|
109
|
+
size: iconSizeMap[size]
|
|
110
|
+
}
|
|
111
|
+
),
|
|
112
|
+
children: icon
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
children: initials
|
|
116
|
+
}
|
|
117
|
+
),
|
|
118
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
119
|
+
Show,
|
|
120
|
+
{
|
|
121
|
+
when: Boolean(as),
|
|
122
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
123
|
+
"img",
|
|
124
|
+
{
|
|
125
|
+
alt: props.ariaLabel,
|
|
126
|
+
className: (0, import_css.css)({
|
|
127
|
+
h: "full",
|
|
128
|
+
objectFit: "cover",
|
|
129
|
+
w: "full"
|
|
130
|
+
}),
|
|
131
|
+
decoding: "async",
|
|
132
|
+
loading: "lazy",
|
|
133
|
+
src,
|
|
134
|
+
height,
|
|
135
|
+
width
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
children: as
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
var iconSizeMap = {
|
|
147
|
+
xs: 16,
|
|
148
|
+
sm: 16,
|
|
149
|
+
md: 20,
|
|
150
|
+
lg: 34,
|
|
151
|
+
xl: 32,
|
|
152
|
+
"2xl": 32,
|
|
153
|
+
"3xl": 32,
|
|
154
|
+
"4xl": 32
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
// src/components/Dialog.tsx
|
|
158
|
+
var import_react4 = require("@ark-ui/react");
|
|
159
|
+
var import_recipes2 = require("@cerberus/styled-system/recipes");
|
|
160
|
+
|
|
161
|
+
// src/components/Portal.tsx
|
|
162
|
+
var import_react3 = require("@ark-ui/react");
|
|
163
|
+
var Portal = import_react3.Portal;
|
|
164
|
+
|
|
165
|
+
// src/components/Dialog.tsx
|
|
166
|
+
var import_css2 = require("@cerberus/styled-system/css");
|
|
167
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
168
|
+
function DialogProvider(props) {
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Dialog.Root, { ...props });
|
|
170
|
+
}
|
|
171
|
+
function Dialog(props) {
|
|
172
|
+
const { size, ...contentProps } = props;
|
|
173
|
+
const styles = (0, import_recipes2.dialog)({ size });
|
|
174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Portal, { children: [
|
|
175
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogBackdrop, { className: styles.backdrop }),
|
|
176
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogPositioner, { className: styles.positioner, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogContent, { className: styles.content, ...contentProps }) })
|
|
177
|
+
] });
|
|
178
|
+
}
|
|
179
|
+
function DialogHeading(props) {
|
|
180
|
+
const styles = (0, import_recipes2.dialog)();
|
|
181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react4.Dialog.Title, { ...props, className: (0, import_css2.cx)(props.className, styles.title) });
|
|
182
|
+
}
|
|
183
|
+
function DialogDescription(props) {
|
|
184
|
+
const styles = (0, import_recipes2.dialog)();
|
|
185
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
186
|
+
import_react4.Dialog.Description,
|
|
187
|
+
{
|
|
188
|
+
...props,
|
|
189
|
+
className: (0, import_css2.cx)(props.className, styles.description)
|
|
190
|
+
}
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
var DialogTrigger = import_react4.Dialog.Trigger;
|
|
194
|
+
var DialogCloseTrigger = import_react4.Dialog.CloseTrigger;
|
|
195
|
+
var DialogBackdrop = import_react4.Dialog.Backdrop;
|
|
196
|
+
var DialogPositioner = import_react4.Dialog.Positioner;
|
|
197
|
+
var DialogContent = import_react4.Dialog.Content;
|
|
198
|
+
|
|
199
|
+
// src/components/Dialog.client.tsx
|
|
200
|
+
var import_react5 = require("@ark-ui/react");
|
|
201
|
+
var import_recipes4 = require("@cerberus/styled-system/recipes");
|
|
202
|
+
var import_css4 = require("@cerberus/styled-system/css");
|
|
203
|
+
|
|
204
|
+
// src/components/IconButton.tsx
|
|
205
|
+
var import_css3 = require("@cerberus/styled-system/css");
|
|
206
|
+
var import_recipes3 = require("@cerberus/styled-system/recipes");
|
|
207
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
208
|
+
function IconButton(props) {
|
|
209
|
+
const { ariaLabel, palette, usage, size, ...nativeProps } = props;
|
|
210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
211
|
+
"button",
|
|
212
|
+
{
|
|
213
|
+
...nativeProps,
|
|
214
|
+
"aria-label": ariaLabel ?? "Icon Button",
|
|
215
|
+
className: (0, import_css3.cx)(
|
|
216
|
+
nativeProps.className,
|
|
217
|
+
(0, import_recipes3.iconButton)({
|
|
218
|
+
palette,
|
|
219
|
+
usage,
|
|
220
|
+
size
|
|
221
|
+
})
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// src/components/Dialog.client.tsx
|
|
228
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
229
|
+
function DialogCloseIconTrigger(props) {
|
|
230
|
+
const { icons } = useCerberusContext();
|
|
231
|
+
const { close: CloseIcon } = icons;
|
|
232
|
+
const styles = (0, import_recipes4.dialog)();
|
|
233
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
234
|
+
import_react5.Dialog.CloseTrigger,
|
|
235
|
+
{
|
|
236
|
+
...props,
|
|
237
|
+
className: (0, import_css4.cx)(props.className, styles.closeTrigger),
|
|
238
|
+
asChild: true,
|
|
239
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
240
|
+
IconButton,
|
|
241
|
+
{
|
|
242
|
+
ariaLabel: "Close dialog",
|
|
243
|
+
palette: "action",
|
|
244
|
+
size: "lg",
|
|
245
|
+
usage: "ghost",
|
|
246
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseIcon, {})
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// src/components/cta-dialog/context.tsx
|
|
254
|
+
var import_react6 = require("react");
|
|
255
|
+
var CTAModalContext = (0, import_react6.createContext)(null);
|
|
256
|
+
|
|
257
|
+
// src/components/cta-dialog/trigger-item.tsx
|
|
258
|
+
var import_css6 = require("@cerberus/styled-system/css");
|
|
259
|
+
|
|
260
|
+
// src/components/button/button.tsx
|
|
261
|
+
var import_react7 = require("react");
|
|
262
|
+
var import_css5 = require("@cerberus/styled-system/css");
|
|
263
|
+
var import_recipes5 = require("@cerberus/styled-system/recipes");
|
|
264
|
+
var import_jsx = require("@cerberus/styled-system/jsx");
|
|
265
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
266
|
+
var ButtonContext = (0, import_react7.createContext)({
|
|
267
|
+
pending: false
|
|
268
|
+
});
|
|
269
|
+
function Button(props) {
|
|
270
|
+
const { palette, usage, shape, size, pending = false, ...nativeProps } = props;
|
|
271
|
+
const value = (0, import_react7.useMemo)(() => ({ pending }), [pending]);
|
|
272
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ButtonContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
273
|
+
"button",
|
|
274
|
+
{
|
|
275
|
+
...nativeProps,
|
|
276
|
+
disabled: pending || nativeProps.disabled,
|
|
277
|
+
className: (0, import_css5.cx)(
|
|
278
|
+
nativeProps.className,
|
|
279
|
+
(0, import_recipes5.button)({
|
|
280
|
+
palette,
|
|
281
|
+
usage,
|
|
282
|
+
shape,
|
|
283
|
+
size
|
|
284
|
+
})
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
) });
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/components/cta-dialog/trigger-item.tsx
|
|
291
|
+
var import_factory = require("@ark-ui/react/factory");
|
|
292
|
+
var import_recipes6 = require("@cerberus/styled-system/recipes");
|
|
293
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
294
|
+
function TriggerItem(props) {
|
|
295
|
+
const { asChild, children, ...buttonProps } = props;
|
|
296
|
+
if (asChild) {
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
298
|
+
import_factory.ark.div,
|
|
299
|
+
{
|
|
300
|
+
className: (0, import_css6.cx)(
|
|
301
|
+
(0, import_recipes6.button)({
|
|
302
|
+
shape: "rounded",
|
|
303
|
+
usage: "ghost"
|
|
304
|
+
}),
|
|
305
|
+
(0, import_css6.css)({
|
|
306
|
+
w: "1/2"
|
|
307
|
+
})
|
|
308
|
+
),
|
|
309
|
+
asChild: true,
|
|
310
|
+
children
|
|
311
|
+
}
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
315
|
+
Button,
|
|
316
|
+
{
|
|
317
|
+
...buttonProps,
|
|
318
|
+
className: (0, import_css6.css)({
|
|
319
|
+
w: "1/2"
|
|
320
|
+
}),
|
|
321
|
+
shape: "rounded",
|
|
322
|
+
usage: "outlined",
|
|
323
|
+
children
|
|
324
|
+
}
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// src/components/cta-dialog/provider.tsx
|
|
329
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
330
|
+
function CTAModal(props) {
|
|
331
|
+
const [open, setOpen] = (0, import_react8.useState)(false);
|
|
332
|
+
const [content, setContent] = (0, import_react8.useState)(null);
|
|
333
|
+
const confirmIcon = content == null ? void 0 : content.icon;
|
|
334
|
+
const { icons } = useCerberusContext();
|
|
335
|
+
const { confirmModal: FallbackIcon } = icons;
|
|
336
|
+
const handleShow = (0, import_react8.useCallback)(
|
|
337
|
+
(options) => {
|
|
338
|
+
setContent({ ...options });
|
|
339
|
+
setOpen(true);
|
|
340
|
+
},
|
|
341
|
+
[setOpen]
|
|
342
|
+
);
|
|
343
|
+
const handleActionClick = (0, import_react8.useCallback)(
|
|
344
|
+
(event) => {
|
|
345
|
+
var _a;
|
|
346
|
+
const index = Number(event.currentTarget.getAttribute("data-index"));
|
|
347
|
+
const contentActions = content == null ? void 0 : content.actions;
|
|
348
|
+
const action = contentActions._actions[index];
|
|
349
|
+
(_a = action == null ? void 0 : action.handleClick) == null ? void 0 : _a.call(action, event);
|
|
350
|
+
setOpen(false);
|
|
351
|
+
},
|
|
352
|
+
[content, setOpen]
|
|
353
|
+
);
|
|
354
|
+
const value = (0, import_react8.useMemo)(
|
|
355
|
+
() => ({
|
|
356
|
+
show: handleShow
|
|
357
|
+
}),
|
|
358
|
+
[handleShow]
|
|
359
|
+
);
|
|
360
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(CTAModalContext.Provider, { value, children: [
|
|
361
|
+
props.children,
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogProvider, { open, onOpenChange: (e) => setOpen(e.open), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Dialog, { size: "sm", children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogCloseIconTrigger, {}),
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx2.VStack, { gap: "xl", w: "full", children: [
|
|
365
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx2.VStack, { alignItems: "flex-start", gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx2.VStack, { gap: "lg", w: "full", children: [
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
367
|
+
Avatar,
|
|
368
|
+
{
|
|
369
|
+
ariaLabel: "",
|
|
370
|
+
gradient: "charon-light",
|
|
371
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
372
|
+
Show,
|
|
373
|
+
{
|
|
374
|
+
when: Boolean(confirmIcon),
|
|
375
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FallbackIcon, { size: 24 }),
|
|
376
|
+
children: confirmIcon
|
|
377
|
+
}
|
|
378
|
+
),
|
|
379
|
+
src: ""
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogHeading, { children: content == null ? void 0 : content.heading }),
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DialogDescription, { children: content == null ? void 0 : content.description })
|
|
384
|
+
] }) }),
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_jsx2.HStack, { gap: "md", w: "full", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(For, { each: content == null ? void 0 : content.actions._actions, children: (action, index) => {
|
|
386
|
+
var _a;
|
|
387
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
388
|
+
Show,
|
|
389
|
+
{
|
|
390
|
+
when: ((_a = content == null ? void 0 : content.actions) == null ? void 0 : _a.type) === "btnAction",
|
|
391
|
+
fallback: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TriggerItem, { asChild: true, children: action }),
|
|
392
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TriggerItem, { "data-index": index, onClick: handleActionClick, children: action == null ? void 0 : action.text })
|
|
393
|
+
},
|
|
394
|
+
index
|
|
395
|
+
);
|
|
396
|
+
} }) })
|
|
397
|
+
] })
|
|
398
|
+
] }) })
|
|
399
|
+
] });
|
|
400
|
+
}
|
|
401
|
+
function useCTAModal() {
|
|
402
|
+
const context = (0, import_react8.useContext)(CTAModalContext);
|
|
403
|
+
if (context === null) {
|
|
404
|
+
throw new Error("useCTAModal must be used within a CTAModal Provider");
|
|
405
|
+
}
|
|
406
|
+
return context;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// src/components/cta-dialog/utils.ts
|
|
410
|
+
function createCTAModalActions(providedActions) {
|
|
411
|
+
if (providedActions.length !== 2) {
|
|
412
|
+
throw new Error("CTAModal must include 2 actions");
|
|
413
|
+
}
|
|
414
|
+
if (providedActions.every(
|
|
415
|
+
(action) => action == null ? void 0 : action.handleClick
|
|
416
|
+
)) {
|
|
417
|
+
return {
|
|
418
|
+
type: "btnAction",
|
|
419
|
+
_actions: providedActions
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
return {
|
|
423
|
+
type: "reactNode",
|
|
424
|
+
_actions: providedActions
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
428
|
+
0 && (module.exports = {
|
|
429
|
+
CTAModal,
|
|
430
|
+
createCTAModalActions,
|
|
431
|
+
useCTAModal
|
|
432
|
+
});
|
|
433
|
+
//# sourceMappingURL=index.cjs.map
|