@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
@@ -0,0 +1,88 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import {
4
+ COLOR_BG_INVERSE,
5
+ COLOR_BG_PRIMARY,
6
+ COLOR_BORDER_DEFAULT,
7
+ COLOR_TEXT_PRIMARY,
8
+ COLOR_TEXT_SECONDARY,
9
+ RADIUS_MD,
10
+ SHADOW_MD,
11
+ TRANSITION_COLORS,
12
+ } from '../../styles/primitives';
13
+
14
+ // ── Overlay ─────────────────────────────────────────────────
15
+
16
+ export const dialogOverlayVariants = cva(['absolute inset-0', COLOR_BG_INVERSE, 'opacity-50']);
17
+
18
+ // ── Content ─────────────────────────────────────────────────
19
+
20
+ export const dialogContentVariants = cva(
21
+ [
22
+ COLOR_BG_PRIMARY,
23
+ `border ${COLOR_BORDER_DEFAULT}`,
24
+ RADIUS_MD,
25
+ Platform.select({ web: SHADOW_MD, default: '' }),
26
+ 'max-h-[85vh] overflow-hidden',
27
+ ],
28
+ {
29
+ variants: {
30
+ size: {
31
+ sm: 'w-[90%] max-w-sm',
32
+ md: 'w-[90%] max-w-md',
33
+ lg: 'w-[90%] max-w-lg',
34
+ full: 'w-full mx-4',
35
+ },
36
+ },
37
+ defaultVariants: {
38
+ size: 'md',
39
+ },
40
+ },
41
+ );
42
+
43
+ // ── Header ──────────────────────────────────────────────────
44
+
45
+ export const dialogHeaderVariants = cva([
46
+ 'flex-row items-center justify-between shrink-0',
47
+ 'px-6 pt-6 pb-2',
48
+ ]);
49
+
50
+ // ── Title ───────────────────────────────────────────────────
51
+
52
+ export const dialogTitleVariants = cva(['text-lg font-semibold', COLOR_TEXT_PRIMARY]);
53
+
54
+ // ── Description ─────────────────────────────────────────────
55
+
56
+ export const dialogDescriptionVariants = cva(['text-sm mt-1', COLOR_TEXT_SECONDARY]);
57
+
58
+ // ── Body ────────────────────────────────────────────────────
59
+
60
+ export const dialogBodyVariants = cva(['px-6 py-4 shrink min-h-0']);
61
+
62
+ // ── Footer ──────────────────────────────────────────────────
63
+
64
+ export const dialogFooterVariants = cva([
65
+ 'flex-row items-center justify-end shrink-0',
66
+ 'gap-3 px-6 pt-2 pb-6',
67
+ ]);
68
+
69
+ // ── Close ───────────────────────────────────────────────────
70
+
71
+ export const dialogCloseVariants = cva([
72
+ 'p-1 -m-1 rounded-full',
73
+ TRANSITION_COLORS,
74
+ Platform.select({
75
+ default: 'data-[active=true]:opacity-70',
76
+ web: [
77
+ 'data-[hover=true]:bg-slate-100',
78
+ 'data-[active=true]:bg-slate-200',
79
+ 'data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-slate-400/50 data-[focus-visible=true]:ring-offset-2',
80
+ ].join(' '),
81
+ }),
82
+ ]);
83
+
84
+ // ── Close Icon ──────────────────────────────────────────────
85
+
86
+ export const dialogCloseIconVariants = cva(['size-5 text-slate-500']);
87
+
88
+ export type DialogVariantProps = VariantProps<typeof dialogContentVariants>;
@@ -0,0 +1,81 @@
1
+ import { forwardRef, useMemo } from 'react';
2
+ import { View, type ViewProps } from 'react-native';
3
+ import { cn } from '@cdx-ui/utils';
4
+ import {
5
+ progressSegmentedVariants,
6
+ segmentVariants,
7
+ type ProgressSegmentedVariants,
8
+ } from './styles';
9
+
10
+ export interface ProgressSegmentedProps extends ViewProps, ProgressSegmentedVariants {
11
+ /** Current step (1-based index into the segment count) */
12
+ readonly step: number;
13
+ /** Total number of segments */
14
+ readonly total?: number;
15
+ /** When true, the current step segment is marked as complete rather than in-progress */
16
+ readonly isStepComplete?: boolean;
17
+ /** Returns the accessibility value text announced by screen readers. Receives the clamped step, total, and whether the step is complete. */
18
+ readonly getAccessibilityText?: (step: number, total: number, isStepComplete: boolean) => string;
19
+ readonly className?: string;
20
+ }
21
+
22
+ export const ProgressSegmented = forwardRef<View, ProgressSegmentedProps>(
23
+ (
24
+ {
25
+ step,
26
+ total = 5,
27
+ isStepComplete = false,
28
+ getAccessibilityText,
29
+ className,
30
+ accessibilityLabel = 'Progress',
31
+ ...props
32
+ },
33
+ ref,
34
+ ) => {
35
+ const clampedStep = Math.max(0, Math.min(step, total));
36
+
37
+ const segments = useMemo(() => {
38
+ return Array.from({ length: total }, (_, index) => {
39
+ const segmentIndex = index + 1;
40
+ let state: 'complete' | 'incomplete' | 'inprogress' = 'incomplete';
41
+
42
+ if (segmentIndex < clampedStep || (isStepComplete && segmentIndex === clampedStep)) {
43
+ state = 'complete';
44
+ } else if (segmentIndex === clampedStep) {
45
+ state = 'inprogress';
46
+ }
47
+
48
+ return state;
49
+ });
50
+ }, [total, clampedStep, isStepComplete]);
51
+
52
+ let accessibilityText = `Step ${String(clampedStep)} of ${String(total)}`;
53
+ if (getAccessibilityText) {
54
+ accessibilityText = getAccessibilityText(clampedStep, total, isStepComplete);
55
+ } else if (isStepComplete) {
56
+ accessibilityText = `Step ${String(clampedStep)} of ${String(total)}, completed`;
57
+ }
58
+
59
+ return (
60
+ <View
61
+ ref={ref}
62
+ accessibilityRole="progressbar"
63
+ accessibilityLabel={accessibilityLabel}
64
+ accessibilityValue={{
65
+ min: 0,
66
+ max: total,
67
+ now: clampedStep,
68
+ text: accessibilityText,
69
+ }}
70
+ className={cn(progressSegmentedVariants(), className)}
71
+ {...props}
72
+ >
73
+ {segments.map((state, index) => (
74
+ <View key={index} className={cn(segmentVariants({ state }))} />
75
+ ))}
76
+ </View>
77
+ );
78
+ },
79
+ );
80
+
81
+ ProgressSegmented.displayName = 'ProgressSegmented';
@@ -0,0 +1,19 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority';
2
+
3
+ export const progressSegmentedVariants = cva(['flex-row gap-1 w-full']);
4
+
5
+ export const segmentVariants = cva(['flex-1 h-2 rounded'], {
6
+ variants: {
7
+ state: {
8
+ complete: 'bg-slate-900',
9
+ incomplete: 'bg-slate-300',
10
+ inprogress: 'bg-gradient-to-r from-slate-900 from-50% to-slate-300 to-50%',
11
+ },
12
+ },
13
+ defaultVariants: {
14
+ state: 'incomplete',
15
+ },
16
+ });
17
+
18
+ export type ProgressSegmentedVariants = VariantProps<typeof progressSegmentedVariants>;
19
+ export type SegmentVariants = VariantProps<typeof segmentVariants>;
@@ -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';