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

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 (262) hide show
  1. package/README.md +2 -2
  2. package/lib/commonjs/components/Avatar/index.js +156 -0
  3. package/lib/commonjs/components/Avatar/index.js.map +1 -0
  4. package/lib/commonjs/components/Avatar/styles.js +80 -0
  5. package/lib/commonjs/components/Avatar/styles.js.map +1 -0
  6. package/lib/commonjs/components/BottomSheet/index.js +248 -0
  7. package/lib/commonjs/components/BottomSheet/index.js.map +1 -0
  8. package/lib/commonjs/components/BottomSheet/styles.js +61 -0
  9. package/lib/commonjs/components/BottomSheet/styles.js.map +1 -0
  10. package/lib/commonjs/components/Box/Box.js +1 -0
  11. package/lib/commonjs/components/Box/Box.js.map +1 -1
  12. package/lib/commonjs/components/Button/index.js +28 -13
  13. package/lib/commonjs/components/Button/index.js.map +1 -1
  14. package/lib/commonjs/components/Button/styles.js +323 -139
  15. package/lib/commonjs/components/Button/styles.js.map +1 -1
  16. package/lib/commonjs/components/Card/index.js +104 -0
  17. package/lib/commonjs/components/Card/index.js.map +1 -0
  18. package/lib/commonjs/components/Card/styles.js +28 -0
  19. package/lib/commonjs/components/Card/styles.js.map +1 -0
  20. package/lib/commonjs/components/Checkbox/index.js +180 -0
  21. package/lib/commonjs/components/Checkbox/index.js.map +1 -0
  22. package/lib/commonjs/components/Checkbox/styles.js +68 -0
  23. package/lib/commonjs/components/Checkbox/styles.js.map +1 -0
  24. package/lib/commonjs/components/Chip/index.js +103 -0
  25. package/lib/commonjs/components/Chip/index.js.map +1 -0
  26. package/lib/commonjs/components/Chip/styles.js +50 -0
  27. package/lib/commonjs/components/Chip/styles.js.map +1 -0
  28. package/lib/commonjs/components/Heading/index.js +35 -0
  29. package/lib/commonjs/components/Heading/index.js.map +1 -0
  30. package/lib/commonjs/components/Heading/styles.js +24 -0
  31. package/lib/commonjs/components/Heading/styles.js.map +1 -0
  32. package/lib/commonjs/components/Icon/index.js +61 -0
  33. package/lib/commonjs/components/Icon/index.js.map +1 -0
  34. package/lib/commonjs/components/Input/index.js +10 -16
  35. package/lib/commonjs/components/Input/index.js.map +1 -1
  36. package/lib/commonjs/components/Input/styles.js +16 -30
  37. package/lib/commonjs/components/Input/styles.js.map +1 -1
  38. package/lib/commonjs/components/Link/index.js +94 -0
  39. package/lib/commonjs/components/Link/index.js.map +1 -0
  40. package/lib/commonjs/components/Link/styles.js +16 -0
  41. package/lib/commonjs/components/Link/styles.js.map +1 -0
  42. package/lib/commonjs/components/Select/index.js +11 -12
  43. package/lib/commonjs/components/Select/index.js.map +1 -1
  44. package/lib/commonjs/components/Select/styles.js +29 -53
  45. package/lib/commonjs/components/Select/styles.js.map +1 -1
  46. package/lib/commonjs/components/Stack/HStack.js +8 -21
  47. package/lib/commonjs/components/Stack/HStack.js.map +1 -1
  48. package/lib/commonjs/components/Stack/VStack.js +8 -21
  49. package/lib/commonjs/components/Stack/VStack.js.map +1 -1
  50. package/lib/commonjs/components/Stack/styles.js +39 -0
  51. package/lib/commonjs/components/Stack/styles.js.map +1 -0
  52. package/lib/commonjs/components/Switch/BaseSwitch.js +46 -0
  53. package/lib/commonjs/components/Switch/BaseSwitch.js.map +1 -0
  54. package/lib/commonjs/components/Switch/BaseSwitch.web.js +56 -0
  55. package/lib/commonjs/components/Switch/BaseSwitch.web.js.map +1 -0
  56. package/lib/commonjs/components/Switch/index.js +13 -0
  57. package/lib/commonjs/components/Switch/index.js.map +1 -0
  58. package/lib/commonjs/components/Switch/styles.js +128 -0
  59. package/lib/commonjs/components/Switch/styles.js.map +1 -0
  60. package/lib/commonjs/components/Text/index.js +18 -9
  61. package/lib/commonjs/components/Text/index.js.map +1 -1
  62. package/lib/commonjs/components/Text/styles.js +24 -0
  63. package/lib/commonjs/components/Text/styles.js.map +1 -0
  64. package/lib/commonjs/components/VirtualizedList/index.js +19 -0
  65. package/lib/commonjs/components/VirtualizedList/index.js.map +1 -0
  66. package/lib/commonjs/components/index.js +120 -0
  67. package/lib/commonjs/components/index.js.map +1 -1
  68. package/lib/commonjs/metro/withCdxMetroConfig.js +24 -0
  69. package/lib/commonjs/metro/withCdxMetroConfig.js.map +1 -0
  70. package/lib/commonjs/styles/index.js +17 -0
  71. package/lib/commonjs/styles/index.js.map +1 -0
  72. package/lib/commonjs/styles/primitives.js +123 -0
  73. package/lib/commonjs/styles/primitives.js.map +1 -0
  74. package/lib/module/components/Avatar/index.js +152 -0
  75. package/lib/module/components/Avatar/index.js.map +1 -0
  76. package/lib/module/components/Avatar/styles.js +77 -0
  77. package/lib/module/components/Avatar/styles.js.map +1 -0
  78. package/lib/module/components/BottomSheet/index.js +242 -0
  79. package/lib/module/components/BottomSheet/index.js.map +1 -0
  80. package/lib/module/components/BottomSheet/styles.js +58 -0
  81. package/lib/module/components/BottomSheet/styles.js.map +1 -0
  82. package/lib/module/components/Box/Box.js +1 -0
  83. package/lib/module/components/Box/Box.js.map +1 -1
  84. package/lib/module/components/Button/index.js +29 -14
  85. package/lib/module/components/Button/index.js.map +1 -1
  86. package/lib/module/components/Button/styles.js +322 -138
  87. package/lib/module/components/Button/styles.js.map +1 -1
  88. package/lib/module/components/Card/index.js +100 -0
  89. package/lib/module/components/Card/index.js.map +1 -0
  90. package/lib/module/components/Card/styles.js +25 -0
  91. package/lib/module/components/Card/styles.js.map +1 -0
  92. package/lib/module/components/Checkbox/index.js +176 -0
  93. package/lib/module/components/Checkbox/index.js.map +1 -0
  94. package/lib/module/components/Checkbox/styles.js +64 -0
  95. package/lib/module/components/Checkbox/styles.js.map +1 -0
  96. package/lib/module/components/Chip/index.js +99 -0
  97. package/lib/module/components/Chip/index.js.map +1 -0
  98. package/lib/module/components/Chip/styles.js +46 -0
  99. package/lib/module/components/Chip/styles.js.map +1 -0
  100. package/lib/module/components/Heading/index.js +31 -0
  101. package/lib/module/components/Heading/index.js.map +1 -0
  102. package/lib/module/components/Heading/styles.js +20 -0
  103. package/lib/module/components/Heading/styles.js.map +1 -0
  104. package/lib/module/components/Icon/index.js +57 -0
  105. package/lib/module/components/Icon/index.js.map +1 -0
  106. package/lib/module/components/Input/index.js +10 -16
  107. package/lib/module/components/Input/index.js.map +1 -1
  108. package/lib/module/components/Input/styles.js +16 -30
  109. package/lib/module/components/Input/styles.js.map +1 -1
  110. package/lib/module/components/Link/index.js +85 -0
  111. package/lib/module/components/Link/index.js.map +1 -0
  112. package/lib/module/components/Link/styles.js +12 -0
  113. package/lib/module/components/Link/styles.js.map +1 -0
  114. package/lib/module/components/Select/index.js +12 -13
  115. package/lib/module/components/Select/index.js.map +1 -1
  116. package/lib/module/components/Select/styles.js +29 -53
  117. package/lib/module/components/Select/styles.js.map +1 -1
  118. package/lib/module/components/Stack/HStack.js +8 -21
  119. package/lib/module/components/Stack/HStack.js.map +1 -1
  120. package/lib/module/components/Stack/VStack.js +8 -21
  121. package/lib/module/components/Stack/VStack.js.map +1 -1
  122. package/lib/module/components/Stack/styles.js +35 -0
  123. package/lib/module/components/Stack/styles.js.map +1 -0
  124. package/lib/module/components/Switch/BaseSwitch.js +42 -0
  125. package/lib/module/components/Switch/BaseSwitch.js.map +1 -0
  126. package/lib/module/components/Switch/BaseSwitch.web.js +52 -0
  127. package/lib/module/components/Switch/BaseSwitch.web.js.map +1 -0
  128. package/lib/module/components/Switch/index.js +9 -0
  129. package/lib/module/components/Switch/index.js.map +1 -0
  130. package/lib/module/components/Switch/styles.js +125 -0
  131. package/lib/module/components/Switch/styles.js.map +1 -0
  132. package/lib/module/components/Text/index.js +19 -1
  133. package/lib/module/components/Text/index.js.map +1 -1
  134. package/lib/module/components/Text/styles.js +20 -0
  135. package/lib/module/components/Text/styles.js.map +1 -0
  136. package/lib/module/components/VirtualizedList/index.js +15 -0
  137. package/lib/module/components/VirtualizedList/index.js.map +1 -0
  138. package/lib/module/components/index.js +10 -0
  139. package/lib/module/components/index.js.map +1 -1
  140. package/lib/module/metro/withCdxMetroConfig.js +20 -0
  141. package/lib/module/metro/withCdxMetroConfig.js.map +1 -0
  142. package/lib/module/styles/index.js +4 -0
  143. package/lib/module/styles/index.js.map +1 -0
  144. package/lib/module/styles/primitives.js +119 -0
  145. package/lib/module/styles/primitives.js.map +1 -0
  146. package/lib/typescript/components/Avatar/index.d.ts +40 -0
  147. package/lib/typescript/components/Avatar/index.d.ts.map +1 -0
  148. package/lib/typescript/components/Avatar/styles.d.ts +16 -0
  149. package/lib/typescript/components/Avatar/styles.d.ts.map +1 -0
  150. package/lib/typescript/components/BottomSheet/index.d.ts +61 -0
  151. package/lib/typescript/components/BottomSheet/index.d.ts.map +1 -0
  152. package/lib/typescript/components/BottomSheet/styles.d.ts +16 -0
  153. package/lib/typescript/components/BottomSheet/styles.d.ts.map +1 -0
  154. package/lib/typescript/components/Box/Box.d.ts +1 -0
  155. package/lib/typescript/components/Box/Box.d.ts.map +1 -1
  156. package/lib/typescript/components/Button/index.d.ts +6 -3
  157. package/lib/typescript/components/Button/index.d.ts.map +1 -1
  158. package/lib/typescript/components/Button/styles.d.ts +14 -8
  159. package/lib/typescript/components/Button/styles.d.ts.map +1 -1
  160. package/lib/typescript/components/Card/index.d.ts +30 -0
  161. package/lib/typescript/components/Card/index.d.ts.map +1 -0
  162. package/lib/typescript/components/Card/styles.d.ts +6 -0
  163. package/lib/typescript/components/Card/styles.d.ts.map +1 -0
  164. package/lib/typescript/components/Checkbox/index.d.ts +46 -0
  165. package/lib/typescript/components/Checkbox/index.d.ts.map +1 -0
  166. package/lib/typescript/components/Checkbox/styles.d.ts +18 -0
  167. package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -0
  168. package/lib/typescript/components/Chip/index.d.ts +27 -0
  169. package/lib/typescript/components/Chip/index.d.ts.map +1 -0
  170. package/lib/typescript/components/Chip/styles.d.ts +12 -0
  171. package/lib/typescript/components/Chip/styles.d.ts.map +1 -0
  172. package/lib/typescript/components/Heading/index.d.ts +10 -0
  173. package/lib/typescript/components/Heading/index.d.ts.map +1 -0
  174. package/lib/typescript/components/Heading/styles.d.ts +6 -0
  175. package/lib/typescript/components/Heading/styles.d.ts.map +1 -0
  176. package/lib/typescript/components/Icon/index.d.ts +27 -0
  177. package/lib/typescript/components/Icon/index.d.ts.map +1 -0
  178. package/lib/typescript/components/Input/index.d.ts +6 -4
  179. package/lib/typescript/components/Input/index.d.ts.map +1 -1
  180. package/lib/typescript/components/Input/styles.d.ts +5 -7
  181. package/lib/typescript/components/Input/styles.d.ts.map +1 -1
  182. package/lib/typescript/components/Link/index.d.ts +26 -0
  183. package/lib/typescript/components/Link/index.d.ts.map +1 -0
  184. package/lib/typescript/components/Link/styles.d.ts +4 -0
  185. package/lib/typescript/components/Link/styles.d.ts.map +1 -0
  186. package/lib/typescript/components/Select/index.d.ts +6 -3
  187. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  188. package/lib/typescript/components/Select/styles.d.ts +6 -8
  189. package/lib/typescript/components/Select/styles.d.ts.map +1 -1
  190. package/lib/typescript/components/Stack/HStack.d.ts +1 -12
  191. package/lib/typescript/components/Stack/HStack.d.ts.map +1 -1
  192. package/lib/typescript/components/Stack/VStack.d.ts +1 -12
  193. package/lib/typescript/components/Stack/VStack.d.ts.map +1 -1
  194. package/lib/typescript/components/Stack/styles.d.ts +10 -0
  195. package/lib/typescript/components/Stack/styles.d.ts.map +1 -0
  196. package/lib/typescript/components/Switch/BaseSwitch.d.ts +9 -0
  197. package/lib/typescript/components/Switch/BaseSwitch.d.ts.map +1 -0
  198. package/lib/typescript/components/Switch/BaseSwitch.web.d.ts +15 -0
  199. package/lib/typescript/components/Switch/BaseSwitch.web.d.ts.map +1 -0
  200. package/lib/typescript/components/Switch/index.d.ts +8 -0
  201. package/lib/typescript/components/Switch/index.d.ts.map +1 -0
  202. package/lib/typescript/components/Switch/styles.d.ts +26 -0
  203. package/lib/typescript/components/Switch/styles.d.ts.map +1 -0
  204. package/lib/typescript/components/Text/index.d.ts +9 -1
  205. package/lib/typescript/components/Text/index.d.ts.map +1 -1
  206. package/lib/typescript/components/Text/styles.d.ts +6 -0
  207. package/lib/typescript/components/Text/styles.d.ts.map +1 -0
  208. package/lib/typescript/components/VirtualizedList/index.d.ts +8 -0
  209. package/lib/typescript/components/VirtualizedList/index.d.ts.map +1 -0
  210. package/lib/typescript/components/index.d.ts +10 -0
  211. package/lib/typescript/components/index.d.ts.map +1 -1
  212. package/lib/typescript/metro/withCdxMetroConfig.d.ts +19 -0
  213. package/lib/typescript/metro/withCdxMetroConfig.d.ts.map +1 -0
  214. package/lib/typescript/styles/index.d.ts +2 -0
  215. package/lib/typescript/styles/index.d.ts.map +1 -0
  216. package/lib/typescript/styles/primitives.d.ts +85 -0
  217. package/lib/typescript/styles/primitives.d.ts.map +1 -0
  218. package/package.json +22 -13
  219. package/src/components/Avatar/index.tsx +174 -0
  220. package/src/components/Avatar/styles.ts +83 -0
  221. package/src/components/BottomSheet/index.tsx +316 -0
  222. package/src/components/BottomSheet/styles.ts +79 -0
  223. package/src/components/Box/Box.tsx +1 -0
  224. package/src/components/Button/index.tsx +23 -15
  225. package/src/components/Button/styles.ts +353 -144
  226. package/src/components/Card/index.tsx +115 -0
  227. package/src/components/Card/styles.ts +41 -0
  228. package/src/components/Checkbox/index.tsx +209 -0
  229. package/src/components/Checkbox/styles.ts +103 -0
  230. package/src/components/Chip/index.tsx +91 -0
  231. package/src/components/Chip/styles.ts +51 -0
  232. package/src/components/Heading/index.tsx +36 -0
  233. package/src/components/Heading/styles.tsx +26 -0
  234. package/src/components/Icon/index.tsx +54 -0
  235. package/src/components/Input/index.tsx +9 -20
  236. package/src/components/Input/styles.ts +42 -37
  237. package/src/components/Link/index.tsx +83 -0
  238. package/src/components/Link/styles.ts +20 -0
  239. package/src/components/Select/index.tsx +12 -11
  240. package/src/components/Select/styles.ts +63 -74
  241. package/src/components/Stack/HStack.tsx +8 -19
  242. package/src/components/Stack/VStack.tsx +8 -23
  243. package/src/components/Stack/styles.ts +37 -0
  244. package/src/components/Switch/BaseSwitch.tsx +38 -0
  245. package/src/components/Switch/BaseSwitch.web.tsx +69 -0
  246. package/src/components/Switch/index.tsx +13 -0
  247. package/src/components/Switch/styles.ts +120 -0
  248. package/src/components/Text/index.tsx +16 -0
  249. package/src/components/Text/styles.tsx +26 -0
  250. package/src/components/VirtualizedList/index.tsx +19 -0
  251. package/src/components/index.ts +10 -0
  252. package/src/metro/withCdxMetroConfig.ts +29 -0
  253. package/src/styles/index.ts +1 -0
  254. package/src/styles/primitives.ts +107 -0
  255. package/lib/commonjs/components/Text/Text.js +0 -30
  256. package/lib/commonjs/components/Text/Text.js.map +0 -1
  257. package/lib/module/components/Text/Text.js +0 -26
  258. package/lib/module/components/Text/Text.js.map +0 -1
  259. package/lib/typescript/components/Text/Text.d.ts +0 -11
  260. package/lib/typescript/components/Text/Text.d.ts.map +0 -1
  261. package/src/components/Text/Text.tsx +0 -58
  262. package/src/components/Text/index.ts +0 -1
@@ -0,0 +1,115 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { View, type ViewProps } from 'react-native';
3
+ import { cn } from '@cdx-ui/utils';
4
+ import {
5
+ cardContentVariants,
6
+ cardFooterVariants,
7
+ cardHeaderVariants,
8
+ cardRootVariants,
9
+ } from './styles';
10
+
11
+ // =============================================================================
12
+ // STYLED ROOT COMPONENT
13
+ // =============================================================================
14
+
15
+ export interface CardProps extends ViewProps {
16
+ className?: string;
17
+ children?: ReactNode;
18
+ }
19
+
20
+ const CardRoot = forwardRef<View, CardProps>(({ className, children, style, ...props }, ref) => {
21
+ const computedClassName = cn(cardRootVariants(), className);
22
+
23
+ return (
24
+ <View ref={ref} className={computedClassName} style={style} {...props}>
25
+ {children}
26
+ </View>
27
+ );
28
+ });
29
+
30
+ CardRoot.displayName = 'Card';
31
+
32
+ // =============================================================================
33
+ // STYLED HEADER COMPONENT
34
+ // =============================================================================
35
+
36
+ export interface CardHeaderProps extends ViewProps {
37
+ className?: string;
38
+ children?: ReactNode;
39
+ }
40
+
41
+ const CardHeader = forwardRef<View, CardHeaderProps>(
42
+ ({ className, children, style, ...props }, ref) => {
43
+ const computedClassName = cn(cardHeaderVariants(), className);
44
+
45
+ return (
46
+ <View ref={ref} className={computedClassName} style={style} {...props}>
47
+ {children}
48
+ </View>
49
+ );
50
+ },
51
+ );
52
+
53
+ CardHeader.displayName = 'Card.Header';
54
+
55
+ // =============================================================================
56
+ // STYLED CONTENT COMPONENT
57
+ // =============================================================================
58
+
59
+ export interface CardContentProps extends ViewProps {
60
+ className?: string;
61
+ children?: ReactNode;
62
+ }
63
+
64
+ const CardContent = forwardRef<View, CardContentProps>(
65
+ ({ className, children, style, ...props }, ref) => {
66
+ const computedClassName = cn(cardContentVariants(), className);
67
+
68
+ return (
69
+ <View ref={ref} className={computedClassName} style={style} {...props}>
70
+ {children}
71
+ </View>
72
+ );
73
+ },
74
+ );
75
+
76
+ CardContent.displayName = 'Card.Content';
77
+
78
+ // =============================================================================
79
+ // STYLED FOOTER COMPONENT
80
+ // =============================================================================
81
+
82
+ export interface CardFooterProps extends ViewProps {
83
+ className?: string;
84
+ children?: ReactNode;
85
+ }
86
+
87
+ const CardFooter = forwardRef<View, CardFooterProps>(
88
+ ({ className, children, style, ...props }, ref) => {
89
+ const computedClassName = cn(cardFooterVariants(), className);
90
+
91
+ return (
92
+ <View ref={ref} className={computedClassName} style={style} {...props}>
93
+ {children}
94
+ </View>
95
+ );
96
+ },
97
+ );
98
+
99
+ CardFooter.displayName = 'Card.Footer';
100
+
101
+ // =============================================================================
102
+ // COMPOUND COMPONENT
103
+ // =============================================================================
104
+
105
+ type CardCompoundComponent = typeof CardRoot & {
106
+ Header: typeof CardHeader;
107
+ Content: typeof CardContent;
108
+ Footer: typeof CardFooter;
109
+ };
110
+
111
+ export const Card = CardRoot as CardCompoundComponent;
112
+
113
+ Card.Header = CardHeader;
114
+ Card.Content = CardContent;
115
+ Card.Footer = CardFooter;
@@ -0,0 +1,41 @@
1
+ import { cva } from 'class-variance-authority';
2
+ import {
3
+ COLOR_BG_PRIMARY,
4
+ COLOR_BORDER_DEFAULT,
5
+ COLOR_TEXT_PRIMARY,
6
+ RADIUS_SM,
7
+ SHADOW_SM,
8
+ } from '../../styles/primitives';
9
+
10
+ // ── Root ────────────────────────────────────────────────────
11
+
12
+ export const cardRootVariants = cva([
13
+ COLOR_BG_PRIMARY,
14
+ `border ${COLOR_BORDER_DEFAULT}`,
15
+ RADIUS_SM,
16
+ SHADOW_SM,
17
+ 'overflow-hidden',
18
+ ]);
19
+
20
+ // ── Header ──────────────────────────────────────────────────
21
+
22
+ export const cardHeaderVariants = cva([
23
+ 'flex-row items-center justify-between p-4 border-b border-t-8',
24
+ COLOR_BORDER_DEFAULT,
25
+ ]);
26
+
27
+ // ── Title ───────────────────────────────────────────────────
28
+
29
+ export const cardTitleVariants = cva(['flex-1']);
30
+
31
+ // ── Content ─────────────────────────────────────────────────
32
+
33
+ export const cardContentVariants = cva([COLOR_TEXT_PRIMARY, 'p-4']);
34
+
35
+ // ── Footer ──────────────────────────────────────────────────
36
+
37
+ export const cardFooterVariants = cva([
38
+ 'p-4 border-t',
39
+ COLOR_BORDER_DEFAULT,
40
+ 'flex-row items-center gap-2',
41
+ ]);
@@ -0,0 +1,209 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
3
+ import { Check, CheckIndeterminateSmall } from '@cdx-ui/icons';
4
+ import { createCheckbox, type ICheckboxProps } from '@cdx-ui/primitives';
5
+ import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
6
+ import { Icon, IconProps } from '../Icon';
7
+ import {
8
+ type CheckboxVariantProps,
9
+ checkboxGroupVariants,
10
+ checkboxIconVariants,
11
+ checkboxIndicatorVariants,
12
+ checkboxLabelVariants,
13
+ checkboxRootVariants,
14
+ } from './styles';
15
+
16
+ const SCOPE = 'CHECKBOX';
17
+
18
+ const Root = withStyleContext(Pressable, SCOPE);
19
+
20
+ const useCheckboxStyleContext = () => useStyleContext(SCOPE) as CheckboxVariantProps;
21
+
22
+ const CheckboxPrimitive = createCheckbox({
23
+ Root,
24
+ Indicator: View,
25
+ Icon: View,
26
+ Label: Text,
27
+ Group: View,
28
+ });
29
+
30
+ // =============================================================================
31
+ // CHECKBOX ROOT
32
+ // =============================================================================
33
+
34
+ export interface CheckboxProps extends ICheckboxProps, CheckboxVariantProps {
35
+ className?: string;
36
+ children?: ReactNode;
37
+ }
38
+
39
+ const CheckboxRoot = forwardRef<View, CheckboxProps>(
40
+ ({ size = 'default', className, isIndeterminate, children, style, ...props }, ref) => {
41
+ const computedClassName = cn(checkboxRootVariants({ size }), className);
42
+
43
+ return (
44
+ <CheckboxPrimitive
45
+ ref={ref as any}
46
+ className={computedClassName}
47
+ isIndeterminate={isIndeterminate}
48
+ style={style}
49
+ context={{ size }}
50
+ {...props}
51
+ >
52
+ <CheckboxIndicator>
53
+ <CheckboxPrimitive.Icon>
54
+ <CheckboxIcon as={isIndeterminate ? CheckIndeterminateSmall : Check} />
55
+ </CheckboxPrimitive.Icon>
56
+ </CheckboxIndicator>
57
+ {children}
58
+ </CheckboxPrimitive>
59
+ );
60
+ },
61
+ );
62
+
63
+ CheckboxRoot.displayName = 'Checkbox';
64
+
65
+ // =============================================================================
66
+ // CHECKBOX INDICATOR
67
+ // =============================================================================
68
+
69
+ export interface CheckboxIndicatorProps extends ViewProps {
70
+ className?: string;
71
+ children?: ReactNode;
72
+ }
73
+
74
+ const CheckboxIndicator = forwardRef<View, CheckboxIndicatorProps>(
75
+ ({ className, children, style, ...props }, ref) => {
76
+ const { size } = useCheckboxStyleContext();
77
+ const computedClassName = cn(checkboxIndicatorVariants({ size }), className);
78
+
79
+ return (
80
+ <CheckboxPrimitive.Indicator
81
+ ref={ref as any}
82
+ className={computedClassName}
83
+ style={style}
84
+ {...props}
85
+ >
86
+ {children}
87
+ </CheckboxPrimitive.Indicator>
88
+ );
89
+ },
90
+ );
91
+
92
+ CheckboxIndicator.displayName = 'Checkbox.Indicator';
93
+
94
+ // =============================================================================
95
+ // CHECKBOX ICON
96
+ // =============================================================================
97
+
98
+ export interface CheckboxIconProps extends Omit<IconProps, 'children'> {}
99
+
100
+ const CheckboxIcon = ({ className, style, ...props }: CheckboxIconProps) => {
101
+ const { size } = useCheckboxStyleContext();
102
+ const computedClassName = cn(checkboxIconVariants({ size }), className);
103
+
104
+ return <Icon className={computedClassName} style={style} {...props} />;
105
+ };
106
+
107
+ CheckboxIcon.displayName = 'Checkbox.Icon';
108
+
109
+ // =============================================================================
110
+ // CHECKBOX LABEL
111
+ // =============================================================================
112
+
113
+ export interface CheckboxLabelProps extends TextProps {
114
+ className?: string;
115
+ children?: ReactNode;
116
+ }
117
+
118
+ const CheckboxLabel = forwardRef<Text, CheckboxLabelProps>(
119
+ ({ className, children, style, ...props }, ref) => {
120
+ const { size } = useCheckboxStyleContext();
121
+ const computedClassName = cn(checkboxLabelVariants({ size }), className);
122
+
123
+ return (
124
+ <CheckboxPrimitive.Label
125
+ ref={ref as any}
126
+ className={computedClassName}
127
+ style={style}
128
+ {...props}
129
+ >
130
+ {children}
131
+ </CheckboxPrimitive.Label>
132
+ );
133
+ },
134
+ );
135
+
136
+ CheckboxLabel.displayName = 'Checkbox.Label';
137
+
138
+ // =============================================================================
139
+ // CHECKBOX GROUP
140
+ // =============================================================================
141
+
142
+ export interface CheckboxGroupProps extends ViewProps {
143
+ className?: string;
144
+ children?: ReactNode;
145
+ value?: string[];
146
+ onChange?: (value: string[]) => void;
147
+ isDisabled?: boolean;
148
+ isInvalid?: boolean;
149
+ isReadOnly?: boolean;
150
+ direction?: 'column' | 'row';
151
+ }
152
+
153
+ const CheckboxGroup = forwardRef<View, CheckboxGroupProps>(
154
+ (
155
+ {
156
+ className,
157
+ children,
158
+ style,
159
+ direction = 'column',
160
+ value,
161
+ onChange,
162
+ isDisabled,
163
+ isInvalid,
164
+ isReadOnly,
165
+ ...viewProps
166
+ },
167
+ ref,
168
+ ) => {
169
+ const computedClassName = cn(checkboxGroupVariants({ direction }), className);
170
+
171
+ return (
172
+ <CheckboxPrimitive.Group
173
+ ref={ref as any}
174
+ className={computedClassName}
175
+ style={style}
176
+ value={value ?? []}
177
+ onChange={onChange}
178
+ isDisabled={isDisabled}
179
+ isInvalid={isInvalid}
180
+ isReadOnly={isReadOnly}
181
+ {...viewProps}
182
+ >
183
+ {children}
184
+ </CheckboxPrimitive.Group>
185
+ );
186
+ },
187
+ );
188
+
189
+ CheckboxGroup.displayName = 'Checkbox.Group';
190
+
191
+ // =============================================================================
192
+ // COMPOUND COMPONENT
193
+ // =============================================================================
194
+
195
+ type CheckboxCompoundComponent = typeof CheckboxRoot & {
196
+ Indicator: typeof CheckboxIndicator;
197
+ Icon: typeof CheckboxIcon;
198
+ Label: typeof CheckboxLabel;
199
+ Group: typeof CheckboxGroup;
200
+ };
201
+
202
+ export const Checkbox = Object.assign(CheckboxRoot, {
203
+ Indicator: CheckboxIndicator,
204
+ Icon: CheckboxIcon,
205
+ Label: CheckboxLabel,
206
+ Group: CheckboxGroup,
207
+ }) as CheckboxCompoundComponent;
208
+
209
+ export type { CheckboxVariantProps };
@@ -0,0 +1,103 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import {
4
+ COLOR_BG_PRIMARY,
5
+ COLOR_BORDER_STRONG,
6
+ COLOR_TEXT_PRIMARY,
7
+ DISABLED_CURSOR,
8
+ DISABLED_OPACITY,
9
+ TRANSITION_COLORS,
10
+ } from '../../styles/primitives';
11
+
12
+ export const checkboxRootVariants = cva(
13
+ ['flex-row items-center', DISABLED_OPACITY, DISABLED_CURSOR],
14
+ {
15
+ variants: {
16
+ size: {
17
+ small: 'gap-2',
18
+ default: 'gap-2.5',
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ size: 'default',
23
+ },
24
+ },
25
+ );
26
+
27
+ export const checkboxIndicatorVariants = cva(
28
+ [
29
+ 'items-center justify-center',
30
+ 'rounded',
31
+ 'border-2',
32
+ COLOR_BORDER_STRONG,
33
+ COLOR_BG_PRIMARY,
34
+ 'data-[checked=true]:bg-slate-900 data-[checked=true]:border-slate-900',
35
+ 'data-[indeterminate=true]:bg-slate-900 data-[indeterminate=true]:border-slate-900',
36
+ 'data-[disabled=true]:opacity-50',
37
+ 'data-[invalid=true]:border-red-500',
38
+ 'data-[checked=true]:data-[invalid=true]:bg-red-500 data-[checked=true]:data-[invalid=true]:border-red-500',
39
+ 'data-[indeterminate=true]:data-[invalid=true]:bg-red-500 data-[indeterminate=true]:data-[invalid=true]:border-red-500',
40
+ Platform.select({
41
+ web: [
42
+ TRANSITION_COLORS,
43
+ 'data-[hover=true]:data-[checked=false]:data-[indeterminate=false]:border-slate-400 data-[hover=true]:data-[checked=false]:data-[indeterminate=false]:bg-slate-50',
44
+ 'data-[focus-visible=true]:ring-2 data-[focus-visible=true]:ring-slate-400/50 data-[focus-visible=true]:ring-offset-2',
45
+ 'data-[invalid=true]:data-[hover=true]:border-red-400',
46
+ 'data-[invalid=true]:data-[focus-visible=true]:ring-red-400/50',
47
+ ].join(' '),
48
+ default: '',
49
+ }),
50
+ ],
51
+ {
52
+ variants: {
53
+ size: {
54
+ small: 'h-4 w-4',
55
+ default: 'h-5 w-5',
56
+ },
57
+ },
58
+ defaultVariants: {
59
+ size: 'default',
60
+ },
61
+ },
62
+ );
63
+
64
+ export const checkboxIconVariants = cva(['text-white'], {
65
+ variants: {
66
+ size: {
67
+ small: 'h-3 w-3',
68
+ default: 'h-3.5 w-3.5',
69
+ },
70
+ },
71
+ defaultVariants: {
72
+ size: 'default',
73
+ },
74
+ });
75
+
76
+ export const checkboxLabelVariants = cva(
77
+ [COLOR_TEXT_PRIMARY, 'data-[disabled=true]:text-slate-400'],
78
+ {
79
+ variants: {
80
+ size: {
81
+ small: 'text-sm',
82
+ default: 'text-base',
83
+ },
84
+ },
85
+ defaultVariants: {
86
+ size: 'default',
87
+ },
88
+ },
89
+ );
90
+
91
+ export const checkboxGroupVariants = cva([], {
92
+ variants: {
93
+ direction: {
94
+ column: 'gap-2',
95
+ row: 'flex-row gap-4',
96
+ },
97
+ },
98
+ defaultVariants: {
99
+ direction: 'column',
100
+ },
101
+ });
102
+
103
+ export type CheckboxVariantProps = VariantProps<typeof checkboxRootVariants>;
@@ -0,0 +1,91 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { View, Text as RNText, type ViewProps, type TextProps } from 'react-native';
3
+ import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
4
+ import { Icon, type IconProps } from '../Icon';
5
+ import { chipRootVariants, chipLabelVariants, chipIconVariants, ChipVariants } from './styles';
6
+
7
+ const SCOPE = 'CHIP';
8
+
9
+ const Root = withStyleContext(View, SCOPE);
10
+
11
+ const useChipStyleContext = () => useStyleContext(SCOPE) as ChipVariants;
12
+
13
+ // =============================================================================
14
+ // STYLED ROOT COMPONENT
15
+ // =============================================================================
16
+
17
+ export interface ChipProps extends ViewProps, ChipVariants {
18
+ children?: ReactNode;
19
+ className?: string;
20
+ }
21
+
22
+ const ChipRoot = forwardRef<View, ChipProps>(
23
+ ({ children, color = 'default', className, style, ...props }, ref) => {
24
+ const computedClassName = cn(chipRootVariants({ color }), className);
25
+
26
+ return (
27
+ <Root ref={ref} className={computedClassName} style={style} context={{ color }} {...props}>
28
+ {children}
29
+ </Root>
30
+ );
31
+ },
32
+ );
33
+
34
+ ChipRoot.displayName = 'Chip';
35
+
36
+ // =============================================================================
37
+ // STYLED LABEL COMPONENT
38
+ // =============================================================================
39
+
40
+ export interface ChipLabelProps extends TextProps {
41
+ className?: string;
42
+ children?: ReactNode;
43
+ }
44
+
45
+ const ChipLabel = forwardRef<RNText, ChipLabelProps>(
46
+ ({ className, children, style, ...props }, ref) => {
47
+ const { color } = useChipStyleContext();
48
+
49
+ const computedClassName = cn(chipLabelVariants({ color }), className);
50
+
51
+ return (
52
+ <RNText ref={ref} className={computedClassName} style={style} {...props}>
53
+ {children}
54
+ </RNText>
55
+ );
56
+ },
57
+ );
58
+
59
+ ChipLabel.displayName = 'Chip.Label';
60
+
61
+ // =============================================================================
62
+ // STYLED ICON COMPONENT
63
+ // =============================================================================
64
+
65
+ export interface ChipIconProps extends Omit<IconProps, 'children'> {}
66
+
67
+ const ChipIcon = ({ className, style, as, ...props }: ChipIconProps) => {
68
+ const { color } = useChipStyleContext();
69
+
70
+ const computedClassName = cn(chipIconVariants({ color }), className);
71
+
72
+ return <Icon as={as} className={computedClassName} style={style} {...props} />;
73
+ };
74
+
75
+ ChipIcon.displayName = 'Chip.Icon';
76
+
77
+ // =============================================================================
78
+ // COMPOUND COMPONENT EXPORT
79
+ // =============================================================================
80
+
81
+ type ChipCompoundComponent = typeof ChipRoot & {
82
+ Label: typeof ChipLabel;
83
+ Icon: typeof ChipIcon;
84
+ };
85
+
86
+ export const Chip = Object.assign(ChipRoot, {
87
+ Label: ChipLabel,
88
+ Icon: ChipIcon,
89
+ }) as ChipCompoundComponent;
90
+
91
+ export { type ChipVariants } from './styles';
@@ -0,0 +1,51 @@
1
+ import { cva, type VariantProps } from 'class-variance-authority';
2
+
3
+ export const chipRootVariants = cva(
4
+ ['flex-row items-center justify-center rounded-full px-2.5 py-0.5 gap-1.5 self-start'],
5
+ {
6
+ variants: {
7
+ color: {
8
+ default: 'bg-slate-200',
9
+ error: 'bg-red-200',
10
+ info: 'bg-blue-200',
11
+ success: 'bg-green-200',
12
+ warning: 'bg-yellow-200',
13
+ },
14
+ },
15
+ defaultVariants: {
16
+ color: 'default',
17
+ },
18
+ },
19
+ );
20
+
21
+ export const chipLabelVariants = cva(['text-sm font-medium tracking-wider'], {
22
+ variants: {
23
+ color: {
24
+ default: 'text-slate-900',
25
+ error: 'text-red-900',
26
+ info: 'text-blue-900',
27
+ success: 'text-green-900',
28
+ warning: 'text-yellow-900',
29
+ },
30
+ },
31
+ defaultVariants: {
32
+ color: 'default',
33
+ },
34
+ });
35
+
36
+ export const chipIconVariants = cva(['size-4'], {
37
+ variants: {
38
+ color: {
39
+ default: 'text-slate-900',
40
+ error: 'text-red-900',
41
+ info: 'text-blue-900',
42
+ success: 'text-green-900',
43
+ warning: 'text-yellow-900',
44
+ },
45
+ },
46
+ defaultVariants: {
47
+ color: 'default',
48
+ },
49
+ });
50
+
51
+ export type ChipVariants = VariantProps<typeof chipRootVariants>;
@@ -0,0 +1,36 @@
1
+ import { forwardRef, memo, type ComponentRef, type ComponentPropsWithoutRef } from 'react';
2
+ import { Text } from 'react-native';
3
+ import { cn } from '@cdx-ui/utils';
4
+ import { headingStyle, type HeadingVariantProps } from './styles';
5
+
6
+ const sizeToLevel = {
7
+ xl: 1,
8
+ lg: 2,
9
+ md: 3,
10
+ sm: 4,
11
+ xs: 5,
12
+ } as const;
13
+
14
+ export type HeadingProps = HeadingVariantProps &
15
+ ComponentPropsWithoutRef<typeof Text> & {
16
+ className?: string;
17
+ };
18
+
19
+ export const Heading = memo(
20
+ forwardRef<ComponentRef<typeof Text>, HeadingProps>(function Heading(
21
+ { className, size = 'lg', ...props },
22
+ ref,
23
+ ) {
24
+ return (
25
+ <Text
26
+ role="heading"
27
+ aria-level={sizeToLevel[size ?? 'lg']}
28
+ className={cn(headingStyle({ size }), className)}
29
+ {...props}
30
+ ref={ref}
31
+ />
32
+ );
33
+ }),
34
+ );
35
+
36
+ Heading.displayName = 'Heading';
@@ -0,0 +1,26 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import { COLOR_TEXT_PRIMARY } from '../../styles/primitives';
4
+
5
+ export const headingStyle = cva(
6
+ [
7
+ `${COLOR_TEXT_PRIMARY} font-semibold tracking-tight my-0`,
8
+ Platform.select({
9
+ web: 'font-sans bg-transparent display-inline no-underline',
10
+ default: '',
11
+ }),
12
+ ],
13
+ {
14
+ variants: {
15
+ size: {
16
+ xl: 'text-6xl',
17
+ lg: 'text-5xl',
18
+ md: 'text-4xl',
19
+ sm: 'text-3xl',
20
+ xs: 'text-2xl',
21
+ },
22
+ },
23
+ },
24
+ );
25
+
26
+ export type HeadingVariantProps = VariantProps<typeof headingStyle>;