@cdx-ui/components 0.0.1-alpha.21 → 0.0.1-alpha.23

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 (44) hide show
  1. package/lib/commonjs/components/AlertDialog/index.js +117 -0
  2. package/lib/commonjs/components/AlertDialog/index.js.map +1 -0
  3. package/lib/commonjs/components/Dialog/index.js +275 -0
  4. package/lib/commonjs/components/Dialog/index.js.map +1 -0
  5. package/lib/commonjs/components/Dialog/styles.js +63 -0
  6. package/lib/commonjs/components/Dialog/styles.js.map +1 -0
  7. package/lib/commonjs/components/ProgressSegmented/index.js +62 -0
  8. package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -0
  9. package/lib/commonjs/components/ProgressSegmented/styles.js +21 -0
  10. package/lib/commonjs/components/ProgressSegmented/styles.js.map +1 -0
  11. package/lib/commonjs/components/index.js +48 -12
  12. package/lib/commonjs/components/index.js.map +1 -1
  13. package/lib/module/components/AlertDialog/index.js +112 -0
  14. package/lib/module/components/AlertDialog/index.js.map +1 -0
  15. package/lib/module/components/Dialog/index.js +267 -0
  16. package/lib/module/components/Dialog/index.js.map +1 -0
  17. package/lib/module/components/Dialog/styles.js +60 -0
  18. package/lib/module/components/Dialog/styles.js.map +1 -0
  19. package/lib/module/components/ProgressSegmented/index.js +58 -0
  20. package/lib/module/components/ProgressSegmented/index.js.map +1 -0
  21. package/lib/module/components/ProgressSegmented/styles.js +17 -0
  22. package/lib/module/components/ProgressSegmented/styles.js.map +1 -0
  23. package/lib/module/components/index.js +4 -1
  24. package/lib/module/components/index.js.map +1 -1
  25. package/lib/typescript/components/AlertDialog/index.d.ts +30 -0
  26. package/lib/typescript/components/AlertDialog/index.d.ts.map +1 -0
  27. package/lib/typescript/components/Chip/styles.d.ts +3 -3
  28. package/lib/typescript/components/Dialog/index.d.ts +62 -0
  29. package/lib/typescript/components/Dialog/index.d.ts.map +1 -0
  30. package/lib/typescript/components/Dialog/styles.d.ts +14 -0
  31. package/lib/typescript/components/Dialog/styles.d.ts.map +1 -0
  32. package/lib/typescript/components/ProgressSegmented/index.d.ts +15 -0
  33. package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -0
  34. package/lib/typescript/components/ProgressSegmented/styles.d.ts +8 -0
  35. package/lib/typescript/components/ProgressSegmented/styles.d.ts.map +1 -0
  36. package/lib/typescript/components/index.d.ts +4 -1
  37. package/lib/typescript/components/index.d.ts.map +1 -1
  38. package/package.json +4 -4
  39. package/src/components/AlertDialog/index.tsx +124 -0
  40. package/src/components/Dialog/index.tsx +306 -0
  41. package/src/components/Dialog/styles.ts +88 -0
  42. package/src/components/ProgressSegmented/index.tsx +81 -0
  43. package/src/components/ProgressSegmented/styles.ts +19 -0
  44. package/src/components/index.ts +4 -1
@@ -1,12 +1,12 @@
1
1
  import { type VariantProps } from 'class-variance-authority';
2
2
  export declare const chipRootVariants: (props?: ({
3
- color?: "default" | "warning" | "success" | "info" | "error" | null | undefined;
3
+ color?: "warning" | "success" | "info" | "default" | "error" | null | undefined;
4
4
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
5
5
  export declare const chipLabelVariants: (props?: ({
6
- color?: "default" | "warning" | "success" | "info" | "error" | null | undefined;
6
+ color?: "warning" | "success" | "info" | "default" | "error" | null | undefined;
7
7
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
8
8
  export declare const chipIconVariants: (props?: ({
9
- color?: "default" | "warning" | "success" | "info" | "error" | null | undefined;
9
+ color?: "warning" | "success" | "info" | "default" | "error" | null | undefined;
10
10
  } & import("class-variance-authority/types").ClassProp) | undefined) => string;
11
11
  export type ChipVariants = VariantProps<typeof chipRootVariants>;
12
12
  //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { type ReactNode } from 'react';
2
+ import { Text, View, type ViewProps } from 'react-native';
3
+ import { type IDialogBodyProps, type IDialogCloseProps, type IDialogContentProps, type IDialogDescriptionProps, type IDialogFooterProps, type IDialogHeaderProps, type IDialogRootProps, type IDialogTitleProps, type IDialogTriggerProps } from '@cdx-ui/primitives';
4
+ import { type DialogVariantProps } from './styles';
5
+ export { useDialog } from '@cdx-ui/primitives';
6
+ export interface DialogRootProps extends Omit<ViewProps, 'children' | 'role'>, IDialogRootProps, DialogVariantProps {
7
+ className?: string;
8
+ }
9
+ declare const DialogRoot: import("react").ForwardRefExoticComponent<DialogRootProps & import("react").RefAttributes<View>>;
10
+ export interface DialogTriggerProps extends IDialogTriggerProps {
11
+ className?: string;
12
+ children?: ReactNode;
13
+ }
14
+ declare const DialogTrigger: import("react").ForwardRefExoticComponent<DialogTriggerProps & import("react").RefAttributes<View>>;
15
+ export interface DialogContentProps extends IDialogContentProps, DialogVariantProps {
16
+ className?: string;
17
+ children?: ReactNode;
18
+ }
19
+ declare const DialogContent: import("react").ForwardRefExoticComponent<DialogContentProps & import("react").RefAttributes<View>>;
20
+ export interface DialogHeaderProps extends IDialogHeaderProps {
21
+ className?: string;
22
+ children?: ReactNode;
23
+ }
24
+ declare const DialogHeader: import("react").ForwardRefExoticComponent<DialogHeaderProps & import("react").RefAttributes<View>>;
25
+ export interface DialogTitleProps extends IDialogTitleProps {
26
+ className?: string;
27
+ children?: ReactNode;
28
+ }
29
+ declare const DialogTitle: import("react").ForwardRefExoticComponent<DialogTitleProps & import("react").RefAttributes<Text>>;
30
+ export interface DialogDescriptionProps extends IDialogDescriptionProps {
31
+ className?: string;
32
+ children?: ReactNode;
33
+ }
34
+ declare const DialogDescription: import("react").ForwardRefExoticComponent<DialogDescriptionProps & import("react").RefAttributes<Text>>;
35
+ export interface DialogBodyProps extends IDialogBodyProps {
36
+ className?: string;
37
+ children?: ReactNode;
38
+ }
39
+ declare const DialogBody: import("react").ForwardRefExoticComponent<DialogBodyProps & import("react").RefAttributes<View>>;
40
+ export interface DialogFooterProps extends IDialogFooterProps {
41
+ className?: string;
42
+ children?: ReactNode;
43
+ }
44
+ declare const DialogFooter: import("react").ForwardRefExoticComponent<DialogFooterProps & import("react").RefAttributes<View>>;
45
+ export interface DialogCloseProps extends IDialogCloseProps {
46
+ className?: string;
47
+ children?: ReactNode;
48
+ }
49
+ declare const DialogClose: import("react").ForwardRefExoticComponent<DialogCloseProps & import("react").RefAttributes<View>>;
50
+ type DialogCompoundComponent = typeof DialogRoot & {
51
+ Trigger: typeof DialogTrigger;
52
+ Content: typeof DialogContent;
53
+ Header: typeof DialogHeader;
54
+ Title: typeof DialogTitle;
55
+ Description: typeof DialogDescription;
56
+ Body: typeof DialogBody;
57
+ Footer: typeof DialogFooter;
58
+ Close: typeof DialogClose;
59
+ };
60
+ export declare const Dialog: DialogCompoundComponent;
61
+ export type { DialogVariantProps } from './styles';
62
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/index.tsx"],"names":[],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ export declare const dialogOverlayVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
3
+ export declare const dialogContentVariants: (props?: ({
4
+ size?: "sm" | "md" | "lg" | "full" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export declare const dialogHeaderVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
7
+ export declare const dialogTitleVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
8
+ export declare const dialogDescriptionVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
9
+ export declare const dialogBodyVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
10
+ export declare const dialogFooterVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
11
+ export declare const dialogCloseVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
12
+ export declare const dialogCloseIconVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
13
+ export type DialogVariantProps = VariantProps<typeof dialogContentVariants>;
14
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/Dialog/styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAclE,eAAO,MAAM,qBAAqB,oFAA4D,CAAC;AAI/F,eAAO,MAAM,qBAAqB;;8EAqBjC,CAAC;AAIF,eAAO,MAAM,oBAAoB,oFAG/B,CAAC;AAIH,eAAO,MAAM,mBAAmB,oFAAqD,CAAC;AAItF,eAAO,MAAM,yBAAyB,oFAA8C,CAAC;AAIrF,eAAO,MAAM,kBAAkB,oFAAoC,CAAC;AAIpE,eAAO,MAAM,oBAAoB,oFAG/B,CAAC;AAIH,eAAO,MAAM,mBAAmB,oFAW9B,CAAC;AAIH,eAAO,MAAM,uBAAuB,oFAAiC,CAAC;AAEtE,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { View, type ViewProps } from 'react-native';
2
+ import { type ProgressSegmentedVariants } from './styles';
3
+ export interface ProgressSegmentedProps extends ViewProps, ProgressSegmentedVariants {
4
+ /** Current step (1-based index into the segment count) */
5
+ readonly step: number;
6
+ /** Total number of segments */
7
+ readonly total?: number;
8
+ /** When true, the current step segment is marked as complete rather than in-progress */
9
+ readonly isStepComplete?: boolean;
10
+ /** Returns the accessibility value text announced by screen readers. Receives the clamped step, total, and whether the step is complete. */
11
+ readonly getAccessibilityText?: (step: number, total: number, isStepComplete: boolean) => string;
12
+ readonly className?: string;
13
+ }
14
+ export declare const ProgressSegmented: import("react").ForwardRefExoticComponent<ProgressSegmentedProps & import("react").RefAttributes<View>>;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/ProgressSegmented/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAGL,KAAK,yBAAyB,EAC/B,MAAM,UAAU,CAAC;AAElB,MAAM,WAAW,sBAAuB,SAAQ,SAAS,EAAE,yBAAyB;IAClF,0DAA0D;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,4IAA4I;IAC5I,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,KAAK,MAAM,CAAC;IACjG,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,iBAAiB,yGAyD7B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type VariantProps } from 'class-variance-authority';
2
+ export declare const progressSegmentedVariants: (props?: import("class-variance-authority/types").ClassProp | undefined) => string;
3
+ export declare const segmentVariants: (props?: ({
4
+ state?: "complete" | "incomplete" | "inprogress" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ export type ProgressSegmentedVariants = VariantProps<typeof progressSegmentedVariants>;
7
+ export type SegmentVariants = VariantProps<typeof segmentVariants>;
8
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/components/ProgressSegmented/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAElE,eAAO,MAAM,yBAAyB,oFAAiC,CAAC;AAExE,eAAO,MAAM,eAAe;;8EAW1B,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,YAAY,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACvF,MAAM,MAAM,eAAe,GAAG,YAAY,CAAC,OAAO,eAAe,CAAC,CAAC"}
@@ -1,12 +1,15 @@
1
+ export * from './AlertDialog';
1
2
  export * from './Avatar';
2
3
  export * from './BottomSheet';
3
4
  export * from './Box';
4
5
  export * from './Button';
5
- export * from './Chip';
6
6
  export * from './Card';
7
7
  export * from './Checkbox';
8
+ export * from './Chip';
9
+ export * from './Dialog';
8
10
  export * from './Input';
9
11
  export * from './Link';
12
+ export * from './ProgressSegmented';
10
13
  export * from './Select';
11
14
  export * from './VirtualizedList';
12
15
  export * from './Switch';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cdx-ui/components",
3
- "version": "0.0.1-alpha.21",
3
+ "version": "0.0.1-alpha.23",
4
4
  "main": "lib/commonjs/index.js",
5
5
  "module": "lib/module/index.js",
6
6
  "react-native": "src/index.ts",
@@ -65,9 +65,9 @@
65
65
  "@gorhom/bottom-sheet": "^5.2.6",
66
66
  "class-variance-authority": "^0.7.1",
67
67
  "uniwind": "1.4.1",
68
- "@cdx-ui/primitives": "0.0.1-alpha.21",
69
- "@cdx-ui/utils": "0.0.1-alpha.21",
70
- "@cdx-ui/icons": "0.0.1-alpha.21"
68
+ "@cdx-ui/primitives": "0.0.1-alpha.23",
69
+ "@cdx-ui/utils": "0.0.1-alpha.23",
70
+ "@cdx-ui/icons": "0.0.1-alpha.23"
71
71
  },
72
72
  "devDependencies": {
73
73
  "@types/react": "*",
@@ -0,0 +1,124 @@
1
+ import React, { forwardRef } from 'react';
2
+ import { View } from 'react-native';
3
+ import { useDialog } from '@cdx-ui/primitives';
4
+ import { composeEventHandlers } from '@cdx-ui/utils';
5
+ import { Button, type ButtonProps } from '../Button';
6
+ import { Dialog, type DialogRootProps } from '../Dialog';
7
+
8
+ // =============================================================================
9
+ // ALERT DIALOG ROOT (Dialog with non-dismissible defaults + alertdialog role)
10
+ // =============================================================================
11
+
12
+ export interface AlertDialogRootProps extends DialogRootProps {}
13
+
14
+ const AlertDialogRoot = forwardRef<View, AlertDialogRootProps>(
15
+ (
16
+ {
17
+ closeOnBackdropPress = false,
18
+ closeOnEscKey = false,
19
+ role = 'alertdialog',
20
+ children,
21
+ ...props
22
+ },
23
+ ref,
24
+ ) => (
25
+ <Dialog
26
+ ref={ref}
27
+ closeOnBackdropPress={closeOnBackdropPress}
28
+ closeOnEscKey={closeOnEscKey}
29
+ role={role}
30
+ {...props}
31
+ >
32
+ {children}
33
+ </Dialog>
34
+ ),
35
+ );
36
+ AlertDialogRoot.displayName = 'AlertDialog';
37
+
38
+ // =============================================================================
39
+ // ALERT DIALOG ACTION
40
+ // =============================================================================
41
+
42
+ export interface AlertDialogActionProps extends Omit<ButtonProps, 'variant'> {
43
+ readonly asChild?: boolean;
44
+ }
45
+
46
+ const AlertDialogAction = forwardRef<View, AlertDialogActionProps>(
47
+ ({ asChild = false, children, color = 'action', className, ...props }, ref) => {
48
+ if (asChild && React.isValidElement(children)) {
49
+ return React.cloneElement(children as React.ReactElement<any>, {
50
+ ref,
51
+ className,
52
+ ...props,
53
+ });
54
+ }
55
+
56
+ return (
57
+ <Button ref={ref} variant="strong" color={color} className={className} {...props}>
58
+ <Button.Label>{children}</Button.Label>
59
+ </Button>
60
+ );
61
+ },
62
+ );
63
+ AlertDialogAction.displayName = 'AlertDialog.Action';
64
+
65
+ // =============================================================================
66
+ // ALERT DIALOG CANCEL
67
+ // =============================================================================
68
+
69
+ export interface AlertDialogCancelProps extends Omit<ButtonProps, 'variant'> {
70
+ readonly asChild?: boolean;
71
+ }
72
+
73
+ const AlertDialogCancel = forwardRef<View, AlertDialogCancelProps>(
74
+ ({ asChild = false, children, onPress, className, ...props }, ref) => {
75
+ const { onOpenChange } = useDialog();
76
+ const handlePress = composeEventHandlers(onPress, () => onOpenChange(false));
77
+
78
+ if (asChild && React.isValidElement(children)) {
79
+ return React.cloneElement(children as React.ReactElement<any>, {
80
+ ref,
81
+ onPress: handlePress,
82
+ className,
83
+ ...props,
84
+ });
85
+ }
86
+
87
+ return (
88
+ <Button ref={ref} variant="outline" onPress={handlePress} className={className} {...props}>
89
+ <Button.Label>{children}</Button.Label>
90
+ </Button>
91
+ );
92
+ },
93
+ );
94
+ AlertDialogCancel.displayName = 'AlertDialog.Cancel';
95
+
96
+ // =============================================================================
97
+ // COMPOUND EXPORT
98
+ // =============================================================================
99
+
100
+ type AlertDialogCompoundComponent = typeof AlertDialogRoot & {
101
+ Trigger: typeof Dialog.Trigger;
102
+ Content: typeof Dialog.Content;
103
+ Header: typeof Dialog.Header;
104
+ Title: typeof Dialog.Title;
105
+ Description: typeof Dialog.Description;
106
+ Body: typeof Dialog.Body;
107
+ Footer: typeof Dialog.Footer;
108
+ Close: typeof Dialog.Close;
109
+ Action: typeof AlertDialogAction;
110
+ Cancel: typeof AlertDialogCancel;
111
+ };
112
+
113
+ export const AlertDialog = Object.assign(AlertDialogRoot, {
114
+ Trigger: Dialog.Trigger,
115
+ Content: Dialog.Content,
116
+ Header: Dialog.Header,
117
+ Title: Dialog.Title,
118
+ Description: Dialog.Description,
119
+ Body: Dialog.Body,
120
+ Footer: Dialog.Footer,
121
+ Close: Dialog.Close,
122
+ Action: AlertDialogAction,
123
+ Cancel: AlertDialogCancel,
124
+ }) as AlertDialogCompoundComponent;
@@ -0,0 +1,306 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { Pressable, Text, View, type PressableProps, type ViewProps } from 'react-native';
3
+ import { Close as CloseIcon } from '@cdx-ui/icons';
4
+ import {
5
+ createDialog,
6
+ type IDialogBodyProps,
7
+ type IDialogCloseProps,
8
+ type IDialogContentProps,
9
+ type IDialogDescriptionProps,
10
+ type IDialogFooterProps,
11
+ type IDialogHeaderProps,
12
+ type IDialogRootProps,
13
+ type IDialogTitleProps,
14
+ type IDialogTriggerProps,
15
+ } from '@cdx-ui/primitives';
16
+ import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
17
+ import { Icon } from '../Icon';
18
+ import {
19
+ type DialogVariantProps,
20
+ dialogBodyVariants,
21
+ dialogCloseIconVariants,
22
+ dialogCloseVariants,
23
+ dialogContentVariants,
24
+ dialogDescriptionVariants,
25
+ dialogFooterVariants,
26
+ dialogHeaderVariants,
27
+ dialogOverlayVariants,
28
+ dialogTitleVariants,
29
+ } from './styles';
30
+
31
+ export { useDialog } from '@cdx-ui/primitives';
32
+
33
+ // =============================================================================
34
+ // STYLE CONTEXT
35
+ // =============================================================================
36
+
37
+ const SCOPE = 'DIALOG';
38
+
39
+ const Root = withStyleContext(View, SCOPE);
40
+
41
+ const useDialogStyleContext = () => useStyleContext(SCOPE) as DialogVariantProps;
42
+
43
+ // =============================================================================
44
+ // STYLED OVERLAY (internal — not consumer-facing)
45
+ // =============================================================================
46
+
47
+ const StyledOverlay = forwardRef<View, PressableProps & { className?: string }>(
48
+ ({ className, ...props }, ref) => (
49
+ <Pressable ref={ref} className={cn(dialogOverlayVariants(), className)} {...props} />
50
+ ),
51
+ );
52
+ StyledOverlay.displayName = 'Dialog.Overlay';
53
+
54
+ // =============================================================================
55
+ // CREATE DIALOG PRIMITIVE
56
+ // =============================================================================
57
+
58
+ const DialogPrimitive = createDialog({
59
+ Root,
60
+ Trigger: Pressable,
61
+ Overlay: StyledOverlay,
62
+ Content: View,
63
+ Header: View,
64
+ Title: Text,
65
+ Description: Text,
66
+ Body: View,
67
+ Footer: View,
68
+ Close: Pressable,
69
+ });
70
+
71
+ // =============================================================================
72
+ // STYLED ROOT
73
+ // =============================================================================
74
+
75
+ export interface DialogRootProps
76
+ extends Omit<ViewProps, 'children' | 'role'>, IDialogRootProps, DialogVariantProps {
77
+ className?: string;
78
+ }
79
+
80
+ const DialogRoot = forwardRef<View, DialogRootProps>(
81
+ ({ size = 'md', className, children, style, ...props }, ref) => (
82
+ <DialogPrimitive ref={ref} className={className} style={style} context={{ size }} {...props}>
83
+ {children}
84
+ </DialogPrimitive>
85
+ ),
86
+ );
87
+
88
+ DialogRoot.displayName = 'Dialog';
89
+
90
+ // =============================================================================
91
+ // STYLED TRIGGER
92
+ // =============================================================================
93
+
94
+ export interface DialogTriggerProps extends IDialogTriggerProps {
95
+ className?: string;
96
+ children?: ReactNode;
97
+ }
98
+
99
+ const DialogTrigger = forwardRef<View, DialogTriggerProps>(
100
+ ({ className, children, style, ...props }, ref) => (
101
+ <DialogPrimitive.Trigger ref={ref} className={className} style={style} {...props}>
102
+ {children}
103
+ </DialogPrimitive.Trigger>
104
+ ),
105
+ );
106
+
107
+ DialogTrigger.displayName = 'Dialog.Trigger';
108
+
109
+ // =============================================================================
110
+ // STYLED CONTENT
111
+ // =============================================================================
112
+
113
+ export interface DialogContentProps extends IDialogContentProps, DialogVariantProps {
114
+ className?: string;
115
+ children?: ReactNode;
116
+ }
117
+
118
+ const DialogContent = forwardRef<View, DialogContentProps>(
119
+ ({ size: sizeProp, className, children, style, ...props }, ref) => {
120
+ const { size: contextSize } = useDialogStyleContext();
121
+ const size = sizeProp ?? contextSize;
122
+ const computedClassName = cn(dialogContentVariants({ size }), className);
123
+
124
+ return (
125
+ <DialogPrimitive.Content ref={ref} className={computedClassName} style={style} {...props}>
126
+ {children}
127
+ </DialogPrimitive.Content>
128
+ );
129
+ },
130
+ );
131
+
132
+ DialogContent.displayName = 'Dialog.Content';
133
+
134
+ // =============================================================================
135
+ // STYLED HEADER
136
+ // =============================================================================
137
+
138
+ export interface DialogHeaderProps extends IDialogHeaderProps {
139
+ className?: string;
140
+ children?: ReactNode;
141
+ }
142
+
143
+ const DialogHeader = forwardRef<View, DialogHeaderProps>(
144
+ ({ className, children, style, ...props }, ref) => {
145
+ const computedClassName = cn(dialogHeaderVariants(), className);
146
+
147
+ return (
148
+ <DialogPrimitive.Header ref={ref} className={computedClassName} style={style} {...props}>
149
+ {children}
150
+ </DialogPrimitive.Header>
151
+ );
152
+ },
153
+ );
154
+
155
+ DialogHeader.displayName = 'Dialog.Header';
156
+
157
+ // =============================================================================
158
+ // STYLED TITLE
159
+ // =============================================================================
160
+
161
+ export interface DialogTitleProps extends IDialogTitleProps {
162
+ className?: string;
163
+ children?: ReactNode;
164
+ }
165
+
166
+ const DialogTitle = forwardRef<Text, DialogTitleProps>(
167
+ ({ className, children, style, ...props }, ref) => {
168
+ const computedClassName = cn(dialogTitleVariants(), className);
169
+
170
+ return (
171
+ <DialogPrimitive.Title ref={ref} className={computedClassName} style={style} {...props}>
172
+ {children}
173
+ </DialogPrimitive.Title>
174
+ );
175
+ },
176
+ );
177
+
178
+ DialogTitle.displayName = 'Dialog.Title';
179
+
180
+ // =============================================================================
181
+ // STYLED DESCRIPTION
182
+ // =============================================================================
183
+
184
+ export interface DialogDescriptionProps extends IDialogDescriptionProps {
185
+ className?: string;
186
+ children?: ReactNode;
187
+ }
188
+
189
+ const DialogDescription = forwardRef<Text, DialogDescriptionProps>(
190
+ ({ className, children, style, ...props }, ref) => {
191
+ const computedClassName = cn(dialogDescriptionVariants(), className);
192
+
193
+ return (
194
+ <DialogPrimitive.Description ref={ref} className={computedClassName} style={style} {...props}>
195
+ {children}
196
+ </DialogPrimitive.Description>
197
+ );
198
+ },
199
+ );
200
+
201
+ DialogDescription.displayName = 'Dialog.Description';
202
+
203
+ // =============================================================================
204
+ // STYLED BODY
205
+ // =============================================================================
206
+
207
+ export interface DialogBodyProps extends IDialogBodyProps {
208
+ className?: string;
209
+ children?: ReactNode;
210
+ }
211
+
212
+ const DialogBody = forwardRef<View, DialogBodyProps>(
213
+ ({ className, children, style, ...props }, ref) => {
214
+ const computedClassName = cn(dialogBodyVariants(), className);
215
+
216
+ return (
217
+ <DialogPrimitive.Body ref={ref} className={computedClassName} style={style} {...props}>
218
+ {children}
219
+ </DialogPrimitive.Body>
220
+ );
221
+ },
222
+ );
223
+
224
+ DialogBody.displayName = 'Dialog.Body';
225
+
226
+ // =============================================================================
227
+ // STYLED FOOTER
228
+ // =============================================================================
229
+
230
+ export interface DialogFooterProps extends IDialogFooterProps {
231
+ className?: string;
232
+ children?: ReactNode;
233
+ }
234
+
235
+ const DialogFooter = forwardRef<View, DialogFooterProps>(
236
+ ({ className, children, style, ...props }, ref) => {
237
+ const computedClassName = cn(dialogFooterVariants(), className);
238
+
239
+ return (
240
+ <DialogPrimitive.Footer ref={ref} className={computedClassName} style={style} {...props}>
241
+ {children}
242
+ </DialogPrimitive.Footer>
243
+ );
244
+ },
245
+ );
246
+
247
+ DialogFooter.displayName = 'Dialog.Footer';
248
+
249
+ // =============================================================================
250
+ // STYLED CLOSE
251
+ // =============================================================================
252
+
253
+ export interface DialogCloseProps extends IDialogCloseProps {
254
+ className?: string;
255
+ children?: ReactNode;
256
+ }
257
+
258
+ const DialogClose = forwardRef<View, DialogCloseProps>(
259
+ ({ className, accessibilityLabel = 'Close', children, style, ...props }, ref) => {
260
+ const computedClassName = cn(dialogCloseVariants(), className);
261
+
262
+ return (
263
+ <DialogPrimitive.Close
264
+ ref={ref}
265
+ className={computedClassName}
266
+ style={style}
267
+ hitSlop={12}
268
+ accessibilityRole="button"
269
+ accessibilityLabel={accessibilityLabel}
270
+ {...props}
271
+ >
272
+ {children ?? <Icon as={CloseIcon} className={dialogCloseIconVariants()} />}
273
+ </DialogPrimitive.Close>
274
+ );
275
+ },
276
+ );
277
+
278
+ DialogClose.displayName = 'Dialog.Close';
279
+
280
+ // =============================================================================
281
+ // COMPOUND COMPONENT
282
+ // =============================================================================
283
+
284
+ type DialogCompoundComponent = typeof DialogRoot & {
285
+ Trigger: typeof DialogTrigger;
286
+ Content: typeof DialogContent;
287
+ Header: typeof DialogHeader;
288
+ Title: typeof DialogTitle;
289
+ Description: typeof DialogDescription;
290
+ Body: typeof DialogBody;
291
+ Footer: typeof DialogFooter;
292
+ Close: typeof DialogClose;
293
+ };
294
+
295
+ export const Dialog = Object.assign(DialogRoot, {
296
+ Trigger: DialogTrigger,
297
+ Content: DialogContent,
298
+ Header: DialogHeader,
299
+ Title: DialogTitle,
300
+ Description: DialogDescription,
301
+ Body: DialogBody,
302
+ Footer: DialogFooter,
303
+ Close: DialogClose,
304
+ }) as DialogCompoundComponent;
305
+
306
+ export type { DialogVariantProps } from './styles';