@cdx-ui/components 0.0.1-beta.3 → 0.0.1-beta.31

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 (242) hide show
  1. package/README.md +18 -11
  2. package/lib/commonjs/components/Button/styles.js +2 -2
  3. package/lib/commonjs/components/Button/styles.js.map +1 -1
  4. package/lib/commonjs/components/Card/index.js +22 -4
  5. package/lib/commonjs/components/Card/index.js.map +1 -1
  6. package/lib/commonjs/components/Card/styles.js +27 -5
  7. package/lib/commonjs/components/Card/styles.js.map +1 -1
  8. package/lib/commonjs/components/Checkbox/index.js +5 -29
  9. package/lib/commonjs/components/Checkbox/index.js.map +1 -1
  10. package/lib/commonjs/components/Checkbox/styles.js +39 -47
  11. package/lib/commonjs/components/Checkbox/styles.js.map +1 -1
  12. package/lib/commonjs/components/Field/index.js +8 -2
  13. package/lib/commonjs/components/Field/index.js.map +1 -1
  14. package/lib/commonjs/components/Field/styles.js +4 -4
  15. package/lib/commonjs/components/Field/styles.js.map +1 -1
  16. package/lib/commonjs/components/Heading/styles.js +1 -1
  17. package/lib/commonjs/components/Heading/styles.js.map +1 -1
  18. package/lib/commonjs/components/Icon/index.js +1 -2
  19. package/lib/commonjs/components/Icon/index.js.map +1 -1
  20. package/lib/commonjs/components/IconButton/index.js +6 -1
  21. package/lib/commonjs/components/IconButton/index.js.map +1 -1
  22. package/lib/commonjs/components/IconButton/styles.js +135 -10
  23. package/lib/commonjs/components/IconButton/styles.js.map +1 -1
  24. package/lib/commonjs/components/Input/styles.js +7 -6
  25. package/lib/commonjs/components/Input/styles.js.map +1 -1
  26. package/lib/commonjs/components/ListItem/index.js +283 -0
  27. package/lib/commonjs/components/ListItem/index.js.map +1 -0
  28. package/lib/commonjs/components/ListItem/styles.js +130 -0
  29. package/lib/commonjs/components/ListItem/styles.js.map +1 -0
  30. package/lib/commonjs/components/ProgressSegmented/index.js +22 -10
  31. package/lib/commonjs/components/ProgressSegmented/index.js.map +1 -1
  32. package/lib/commonjs/components/Radio/index.js +167 -0
  33. package/lib/commonjs/components/Radio/index.js.map +1 -0
  34. package/lib/commonjs/components/Radio/styles.js +31 -0
  35. package/lib/commonjs/components/Radio/styles.js.map +1 -0
  36. package/lib/commonjs/components/Text/styles.js +2 -2
  37. package/lib/commonjs/components/Text/styles.js.map +1 -1
  38. package/lib/commonjs/components/Tile/index.js +251 -0
  39. package/lib/commonjs/components/Tile/index.js.map +1 -0
  40. package/lib/commonjs/components/Tile/styles.js +52 -0
  41. package/lib/commonjs/components/Tile/styles.js.map +1 -0
  42. package/lib/commonjs/components/index.js +36 -0
  43. package/lib/commonjs/components/index.js.map +1 -1
  44. package/lib/commonjs/figma/Button.figma.js +70 -0
  45. package/lib/commonjs/figma/Button.figma.js.map +1 -0
  46. package/lib/commonjs/figma/Card.Header.figma.js +28 -0
  47. package/lib/commonjs/figma/Card.Header.figma.js.map +1 -0
  48. package/lib/commonjs/figma/Card.figma.js +42 -0
  49. package/lib/commonjs/figma/Card.figma.js.map +1 -0
  50. package/lib/commonjs/figma/Checkbox.figma.js +55 -0
  51. package/lib/commonjs/figma/Checkbox.figma.js.map +1 -0
  52. package/lib/commonjs/figma/Field.Input.figma.js +57 -0
  53. package/lib/commonjs/figma/Field.Input.figma.js.map +1 -0
  54. package/lib/commonjs/figma/Field.Select.figma.js +57 -0
  55. package/lib/commonjs/figma/Field.Select.figma.js.map +1 -0
  56. package/lib/commonjs/figma/Heading.figma.js +30 -0
  57. package/lib/commonjs/figma/Heading.figma.js.map +1 -0
  58. package/lib/commonjs/figma/Icon.figma.js +20 -0
  59. package/lib/commonjs/figma/Icon.figma.js.map +1 -0
  60. package/lib/commonjs/figma/IconButton.figma.js +47 -0
  61. package/lib/commonjs/figma/IconButton.figma.js.map +1 -0
  62. package/lib/commonjs/figma/Input.figma.js +52 -0
  63. package/lib/commonjs/figma/Input.figma.js.map +1 -0
  64. package/lib/commonjs/figma/ProgressSegmented.figma.js +39 -0
  65. package/lib/commonjs/figma/ProgressSegmented.figma.js.map +1 -0
  66. package/lib/commonjs/figma/Radio.figma.js +38 -0
  67. package/lib/commonjs/figma/Radio.figma.js.map +1 -0
  68. package/lib/commonjs/figma/Select.figma.js +53 -0
  69. package/lib/commonjs/figma/Select.figma.js.map +1 -0
  70. package/lib/commonjs/figma/Text.figma.js +29 -0
  71. package/lib/commonjs/figma/Text.figma.js.map +1 -0
  72. package/lib/commonjs/figma/icons.figma.batch.js +27 -0
  73. package/lib/commonjs/figma/icons.figma.batch.js.map +1 -0
  74. package/lib/commonjs/figma/icons.figma.batch.json +17705 -0
  75. package/lib/commonjs/styles/primitives.js +36 -2
  76. package/lib/commonjs/styles/primitives.js.map +1 -1
  77. package/lib/module/components/Button/styles.js +2 -2
  78. package/lib/module/components/Button/styles.js.map +1 -1
  79. package/lib/module/components/Card/index.js +23 -4
  80. package/lib/module/components/Card/index.js.map +1 -1
  81. package/lib/module/components/Card/styles.js +27 -5
  82. package/lib/module/components/Card/styles.js.map +1 -1
  83. package/lib/module/components/Checkbox/index.js +6 -30
  84. package/lib/module/components/Checkbox/index.js.map +1 -1
  85. package/lib/module/components/Checkbox/styles.js +40 -48
  86. package/lib/module/components/Checkbox/styles.js.map +1 -1
  87. package/lib/module/components/Field/index.js +9 -3
  88. package/lib/module/components/Field/index.js.map +1 -1
  89. package/lib/module/components/Field/styles.js +4 -4
  90. package/lib/module/components/Field/styles.js.map +1 -1
  91. package/lib/module/components/Heading/styles.js +1 -1
  92. package/lib/module/components/Heading/styles.js.map +1 -1
  93. package/lib/module/components/Icon/index.js +1 -2
  94. package/lib/module/components/Icon/index.js.map +1 -1
  95. package/lib/module/components/IconButton/index.js +6 -1
  96. package/lib/module/components/IconButton/index.js.map +1 -1
  97. package/lib/module/components/IconButton/styles.js +135 -10
  98. package/lib/module/components/IconButton/styles.js.map +1 -1
  99. package/lib/module/components/Input/styles.js +7 -6
  100. package/lib/module/components/Input/styles.js.map +1 -1
  101. package/lib/module/components/ListItem/index.js +226 -0
  102. package/lib/module/components/ListItem/index.js.map +1 -0
  103. package/lib/module/components/ListItem/styles.js +127 -0
  104. package/lib/module/components/ListItem/styles.js.map +1 -0
  105. package/lib/module/components/ProgressSegmented/index.js +23 -11
  106. package/lib/module/components/ProgressSegmented/index.js.map +1 -1
  107. package/lib/module/components/Radio/index.js +164 -0
  108. package/lib/module/components/Radio/index.js.map +1 -0
  109. package/lib/module/components/Radio/styles.js +27 -0
  110. package/lib/module/components/Radio/styles.js.map +1 -0
  111. package/lib/module/components/Text/styles.js +2 -2
  112. package/lib/module/components/Text/styles.js.map +1 -1
  113. package/lib/module/components/Tile/index.js +243 -0
  114. package/lib/module/components/Tile/index.js.map +1 -0
  115. package/lib/module/components/Tile/styles.js +48 -0
  116. package/lib/module/components/Tile/styles.js.map +1 -0
  117. package/lib/module/components/index.js +3 -0
  118. package/lib/module/components/index.js.map +1 -1
  119. package/lib/module/figma/Button.figma.js +64 -0
  120. package/lib/module/figma/Button.figma.js.map +1 -0
  121. package/lib/module/figma/Card.Header.figma.js +22 -0
  122. package/lib/module/figma/Card.Header.figma.js.map +1 -0
  123. package/lib/module/figma/Card.figma.js +36 -0
  124. package/lib/module/figma/Card.figma.js.map +1 -0
  125. package/lib/module/figma/Checkbox.figma.js +49 -0
  126. package/lib/module/figma/Checkbox.figma.js.map +1 -0
  127. package/lib/module/figma/Field.Input.figma.js +51 -0
  128. package/lib/module/figma/Field.Input.figma.js.map +1 -0
  129. package/lib/module/figma/Field.Select.figma.js +51 -0
  130. package/lib/module/figma/Field.Select.figma.js.map +1 -0
  131. package/lib/module/figma/Heading.figma.js +24 -0
  132. package/lib/module/figma/Heading.figma.js.map +1 -0
  133. package/lib/module/figma/Icon.figma.js +14 -0
  134. package/lib/module/figma/Icon.figma.js.map +1 -0
  135. package/lib/module/figma/IconButton.figma.js +41 -0
  136. package/lib/module/figma/IconButton.figma.js.map +1 -0
  137. package/lib/module/figma/Input.figma.js +46 -0
  138. package/lib/module/figma/Input.figma.js.map +1 -0
  139. package/lib/module/figma/ProgressSegmented.figma.js +33 -0
  140. package/lib/module/figma/ProgressSegmented.figma.js.map +1 -0
  141. package/lib/module/figma/Radio.figma.js +32 -0
  142. package/lib/module/figma/Radio.figma.js.map +1 -0
  143. package/lib/module/figma/Select.figma.js +47 -0
  144. package/lib/module/figma/Select.figma.js.map +1 -0
  145. package/lib/module/figma/Text.figma.js +23 -0
  146. package/lib/module/figma/Text.figma.js.map +1 -0
  147. package/lib/module/figma/icons.figma.batch.js +22 -0
  148. package/lib/module/figma/icons.figma.batch.js.map +1 -0
  149. package/lib/module/figma/icons.figma.batch.json +17705 -0
  150. package/lib/module/styles/primitives.js +36 -2
  151. package/lib/module/styles/primitives.js.map +1 -1
  152. package/lib/typescript/components/Card/index.d.ts +4 -3
  153. package/lib/typescript/components/Card/index.d.ts.map +1 -1
  154. package/lib/typescript/components/Card/styles.d.ts +13 -3
  155. package/lib/typescript/components/Card/styles.d.ts.map +1 -1
  156. package/lib/typescript/components/Checkbox/index.d.ts +1 -2
  157. package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
  158. package/lib/typescript/components/Checkbox/styles.d.ts +4 -14
  159. package/lib/typescript/components/Checkbox/styles.d.ts.map +1 -1
  160. package/lib/typescript/components/Field/FieldLabel.web.d.ts +2 -2
  161. package/lib/typescript/components/Field/FieldLabel.web.d.ts.map +1 -1
  162. package/lib/typescript/components/Field/index.d.ts.map +1 -1
  163. package/lib/typescript/components/Field/styles.d.ts.map +1 -1
  164. package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
  165. package/lib/typescript/components/Icon/index.d.ts.map +1 -1
  166. package/lib/typescript/components/IconButton/index.d.ts.map +1 -1
  167. package/lib/typescript/components/IconButton/styles.d.ts +6 -2
  168. package/lib/typescript/components/IconButton/styles.d.ts.map +1 -1
  169. package/lib/typescript/components/Input/styles.d.ts.map +1 -1
  170. package/lib/typescript/components/ListItem/index.d.ts +49 -0
  171. package/lib/typescript/components/ListItem/index.d.ts.map +1 -0
  172. package/lib/typescript/components/ListItem/styles.d.ts +30 -0
  173. package/lib/typescript/components/ListItem/styles.d.ts.map +1 -0
  174. package/lib/typescript/components/ProgressSegmented/index.d.ts +14 -3
  175. package/lib/typescript/components/ProgressSegmented/index.d.ts.map +1 -1
  176. package/lib/typescript/components/Radio/index.d.ts +40 -0
  177. package/lib/typescript/components/Radio/index.d.ts.map +1 -0
  178. package/lib/typescript/components/Radio/styles.d.ts +8 -0
  179. package/lib/typescript/components/Radio/styles.d.ts.map +1 -0
  180. package/lib/typescript/components/Text/styles.d.ts.map +1 -1
  181. package/lib/typescript/components/Tile/index.d.ts +70 -0
  182. package/lib/typescript/components/Tile/index.d.ts.map +1 -0
  183. package/lib/typescript/components/Tile/styles.d.ts +18 -0
  184. package/lib/typescript/components/Tile/styles.d.ts.map +1 -0
  185. package/lib/typescript/components/index.d.ts +3 -0
  186. package/lib/typescript/components/index.d.ts.map +1 -1
  187. package/lib/typescript/figma/Button.figma.d.ts +8 -0
  188. package/lib/typescript/figma/Button.figma.d.ts.map +1 -0
  189. package/lib/typescript/figma/Card.Header.figma.d.ts +8 -0
  190. package/lib/typescript/figma/Card.Header.figma.d.ts.map +1 -0
  191. package/lib/typescript/figma/Card.figma.d.ts +8 -0
  192. package/lib/typescript/figma/Card.figma.d.ts.map +1 -0
  193. package/lib/typescript/figma/Checkbox.figma.d.ts +8 -0
  194. package/lib/typescript/figma/Checkbox.figma.d.ts.map +1 -0
  195. package/lib/typescript/figma/Field.Input.figma.d.ts +8 -0
  196. package/lib/typescript/figma/Field.Input.figma.d.ts.map +1 -0
  197. package/lib/typescript/figma/Field.Select.figma.d.ts +8 -0
  198. package/lib/typescript/figma/Field.Select.figma.d.ts.map +1 -0
  199. package/lib/typescript/figma/Heading.figma.d.ts +8 -0
  200. package/lib/typescript/figma/Heading.figma.d.ts.map +1 -0
  201. package/lib/typescript/figma/Icon.figma.d.ts +8 -0
  202. package/lib/typescript/figma/Icon.figma.d.ts.map +1 -0
  203. package/lib/typescript/figma/IconButton.figma.d.ts +8 -0
  204. package/lib/typescript/figma/IconButton.figma.d.ts.map +1 -0
  205. package/lib/typescript/figma/Input.figma.d.ts +8 -0
  206. package/lib/typescript/figma/Input.figma.d.ts.map +1 -0
  207. package/lib/typescript/figma/ProgressSegmented.figma.d.ts +8 -0
  208. package/lib/typescript/figma/ProgressSegmented.figma.d.ts.map +1 -0
  209. package/lib/typescript/figma/Radio.figma.d.ts +8 -0
  210. package/lib/typescript/figma/Radio.figma.d.ts.map +1 -0
  211. package/lib/typescript/figma/Select.figma.d.ts +8 -0
  212. package/lib/typescript/figma/Select.figma.d.ts.map +1 -0
  213. package/lib/typescript/figma/Text.figma.d.ts +8 -0
  214. package/lib/typescript/figma/Text.figma.d.ts.map +1 -0
  215. package/lib/typescript/figma/icons.figma.batch.d.ts +14 -0
  216. package/lib/typescript/figma/icons.figma.batch.d.ts.map +1 -0
  217. package/lib/typescript/styles/primitives.d.ts +35 -0
  218. package/lib/typescript/styles/primitives.d.ts.map +1 -1
  219. package/package.json +5 -5
  220. package/src/components/Button/styles.ts +2 -2
  221. package/src/components/Card/index.tsx +41 -16
  222. package/src/components/Card/styles.ts +43 -23
  223. package/src/components/Checkbox/index.tsx +8 -19
  224. package/src/components/Checkbox/styles.ts +82 -86
  225. package/src/components/Field/FieldLabel.web.tsx +1 -1
  226. package/src/components/Field/index.tsx +10 -3
  227. package/src/components/Field/styles.ts +5 -4
  228. package/src/components/Heading/{styles.tsx → styles.ts} +1 -1
  229. package/src/components/Icon/index.tsx +1 -2
  230. package/src/components/IconButton/index.tsx +3 -2
  231. package/src/components/IconButton/styles.ts +136 -10
  232. package/src/components/Input/styles.ts +13 -8
  233. package/src/components/ListItem/index.tsx +285 -0
  234. package/src/components/ListItem/styles.ts +153 -0
  235. package/src/components/ProgressSegmented/index.tsx +49 -14
  236. package/src/components/Radio/index.tsx +192 -0
  237. package/src/components/Radio/styles.ts +59 -0
  238. package/src/components/Text/{styles.tsx → styles.ts} +2 -2
  239. package/src/components/Tile/index.tsx +296 -0
  240. package/src/components/Tile/styles.ts +82 -0
  241. package/src/components/index.ts +3 -0
  242. package/src/styles/primitives.ts +36 -2
@@ -0,0 +1,192 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { Pressable, Text, type TextProps, View, type ViewProps } from 'react-native';
3
+ import { createRadio, dataAttributes, type IRadioProps } from '@cdx-ui/primitives';
4
+ import { cn } from '@cdx-ui/utils';
5
+ import {
6
+ radioGroupVariants,
7
+ radioIndicatorVariants,
8
+ radioInnerDotVariants,
9
+ radioLabelVariants,
10
+ radioRootVariants,
11
+ } from './styles';
12
+
13
+ // =============================================================================
14
+ // STYLED INDICATOR BASE
15
+ // =============================================================================
16
+
17
+ const RadioIndicatorBase = forwardRef<View, ViewProps & { className?: string }>(
18
+ ({ className, children, style, ...props }, ref) => {
19
+ // On web, data attributes arrive as `dataSet: { checked: true }`.
20
+ // On native, they arrive as individual `data-checked: "true"` props.
21
+ const ds = (props as any).dataSet;
22
+ const isChecked = ds ? ds.checked === true : (props as any)['data-checked'] === 'true';
23
+ const isInvalid = ds ? ds.invalid === true : (props as any)['data-invalid'] === 'true';
24
+ const isHovered = ds ? ds.hover === true : (props as any)['data-hover'] === 'true';
25
+
26
+ return (
27
+ <View ref={ref} className={cn(radioIndicatorVariants(), className)} style={style} {...props}>
28
+ <View
29
+ className={cn(radioInnerDotVariants())}
30
+ {...dataAttributes({ checked: isChecked, invalid: isInvalid, hover: isHovered })}
31
+ />
32
+ {children}
33
+ </View>
34
+ );
35
+ },
36
+ );
37
+
38
+ RadioIndicatorBase.displayName = 'Radio.IndicatorBase';
39
+
40
+ // =============================================================================
41
+ // PRIMITIVE ASSEMBLY
42
+ // =============================================================================
43
+
44
+ const RadioPrimitive = createRadio({
45
+ Root: Pressable,
46
+ Indicator: RadioIndicatorBase,
47
+ Label: Text,
48
+ Group: View,
49
+ });
50
+
51
+ // =============================================================================
52
+ // RADIO ROOT
53
+ // =============================================================================
54
+
55
+ export interface RadioProps extends IRadioProps {
56
+ className?: string;
57
+ children?: ReactNode;
58
+ }
59
+
60
+ const RadioRoot = forwardRef<View, RadioProps>(({ className, children, style, ...props }, ref) => {
61
+ const computedClassName = cn(radioRootVariants(), className);
62
+
63
+ return (
64
+ <RadioPrimitive ref={ref as any} className={computedClassName} style={style} {...props}>
65
+ {children}
66
+ </RadioPrimitive>
67
+ );
68
+ });
69
+
70
+ RadioRoot.displayName = 'Radio';
71
+
72
+ // =============================================================================
73
+ // RADIO INDICATOR
74
+ // =============================================================================
75
+
76
+ export interface RadioIndicatorProps extends ViewProps {
77
+ className?: string;
78
+ children?: ReactNode;
79
+ }
80
+
81
+ const RadioIndicator = forwardRef<View, RadioIndicatorProps>(
82
+ ({ className, children, style, ...props }, ref) => {
83
+ return (
84
+ <RadioPrimitive.Indicator ref={ref as any} className={className} style={style} {...props}>
85
+ {children}
86
+ </RadioPrimitive.Indicator>
87
+ );
88
+ },
89
+ );
90
+
91
+ RadioIndicator.displayName = 'Radio.Indicator';
92
+
93
+ // =============================================================================
94
+ // RADIO LABEL
95
+ // =============================================================================
96
+
97
+ export interface RadioLabelProps extends TextProps {
98
+ className?: string;
99
+ children?: ReactNode;
100
+ }
101
+
102
+ const RadioLabel = forwardRef<Text, RadioLabelProps>(
103
+ ({ className, children, style, ...props }, ref) => {
104
+ const computedClassName = cn(radioLabelVariants(), className);
105
+
106
+ return (
107
+ <RadioPrimitive.Label ref={ref as any} className={computedClassName} style={style} {...props}>
108
+ {children}
109
+ </RadioPrimitive.Label>
110
+ );
111
+ },
112
+ );
113
+
114
+ RadioLabel.displayName = 'Radio.Label';
115
+
116
+ // =============================================================================
117
+ // RADIO GROUP
118
+ // =============================================================================
119
+
120
+ export interface RadioGroupProps extends ViewProps {
121
+ className?: string;
122
+ children?: ReactNode;
123
+ value?: string;
124
+ defaultValue?: string;
125
+ onChange?: (value: string) => void;
126
+ isDisabled?: boolean;
127
+ isInvalid?: boolean;
128
+ isRequired?: boolean;
129
+ isReadOnly?: boolean;
130
+ direction?: 'column' | 'row';
131
+ name?: string;
132
+ }
133
+
134
+ const RadioGroup = forwardRef<View, RadioGroupProps>(
135
+ (
136
+ {
137
+ className,
138
+ children,
139
+ style,
140
+ direction = 'column',
141
+ value,
142
+ defaultValue,
143
+ onChange,
144
+ isDisabled,
145
+ isInvalid,
146
+ isRequired,
147
+ isReadOnly,
148
+ name,
149
+ ...viewProps
150
+ },
151
+ ref,
152
+ ) => {
153
+ const computedClassName = cn(radioGroupVariants({ direction }), className);
154
+
155
+ return (
156
+ <RadioPrimitive.Group
157
+ ref={ref as any}
158
+ className={computedClassName}
159
+ style={style}
160
+ value={value}
161
+ defaultValue={defaultValue}
162
+ onChange={onChange}
163
+ isDisabled={isDisabled}
164
+ isInvalid={isInvalid}
165
+ isRequired={isRequired}
166
+ isReadOnly={isReadOnly}
167
+ name={name}
168
+ {...viewProps}
169
+ >
170
+ {children}
171
+ </RadioPrimitive.Group>
172
+ );
173
+ },
174
+ );
175
+
176
+ RadioGroup.displayName = 'Radio.Group';
177
+
178
+ // =============================================================================
179
+ // COMPOUND COMPONENT
180
+ // =============================================================================
181
+
182
+ type RadioCompoundComponent = typeof RadioRoot & {
183
+ Indicator: typeof RadioIndicator;
184
+ Label: typeof RadioLabel;
185
+ Group: typeof RadioGroup;
186
+ };
187
+
188
+ export const Radio = Object.assign(RadioRoot, {
189
+ Indicator: RadioIndicator,
190
+ Label: RadioLabel,
191
+ Group: RadioGroup,
192
+ }) as RadioCompoundComponent;
@@ -0,0 +1,59 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva } from 'class-variance-authority';
3
+ import { DISABLED_CURSOR, TRANSITION_COLORS } from '../../styles/primitives';
4
+
5
+ export const radioRootVariants = cva([
6
+ 'flex-row items-center gap-2',
7
+ 'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
8
+ DISABLED_CURSOR,
9
+ ]);
10
+
11
+ export const radioIndicatorVariants = cva([
12
+ 'items-center justify-center',
13
+ 'rounded-[var(--border-radius-round)]',
14
+ 'border-[length:var(--border-width-selected)]',
15
+ 'h-5 w-5',
16
+ 'bg-surface-primary',
17
+ 'data-[checked=false]:border-content-secondary',
18
+ 'data-[checked=true]:border-stroke-action',
19
+ 'data-[invalid=true]:border-stroke-danger',
20
+ 'data-[checked=true]:data-[invalid=true]:border-stroke-danger',
21
+ Platform.select({
22
+ web: [
23
+ TRANSITION_COLORS,
24
+ 'data-[hover=true]:data-[checked=true]:border-surface-action-strong-hover',
25
+ 'data-[hover=true]:data-[invalid=true]:border-surface-danger-strong-hover',
26
+ 'web:data-[focus-visible=true]:outline-none',
27
+ 'web:data-[focus-visible=true]:ring-2 web:data-[focus-visible=true]:ring-[var(--color-stroke-ring)] web:data-[focus-visible=true]:ring-offset-2',
28
+ ].join(' '),
29
+ default: '',
30
+ }),
31
+ ]);
32
+
33
+ export const radioInnerDotVariants = cva([
34
+ 'rounded-[var(--border-radius-round)]',
35
+ 'h-2.5 w-2.5',
36
+ 'scale-0',
37
+ 'data-[checked=true]:scale-100',
38
+ 'bg-surface-action-strong',
39
+ 'data-[invalid=true]:bg-surface-danger-strong',
40
+ Platform.select({
41
+ web: [
42
+ 'data-[hover=true]:bg-surface-action-strong-hover',
43
+ 'data-[hover=true]:data-[invalid=true]:bg-surface-danger-strong-hover',
44
+ ].join(' '),
45
+ default: '',
46
+ }),
47
+ ]);
48
+
49
+ export const radioLabelVariants = cva(['body-md', 'text-content-primary']);
50
+
51
+ export const radioGroupVariants = cva([], {
52
+ variants: {
53
+ direction: {
54
+ column: 'gap-2',
55
+ row: 'flex-row gap-4',
56
+ },
57
+ },
58
+ defaultVariants: { direction: 'column' },
59
+ });
@@ -3,9 +3,9 @@ import { cva, type VariantProps } from 'class-variance-authority';
3
3
 
4
4
  export const textStyle = cva(
5
5
  [
6
- `text-content-primary font-normal`,
6
+ 'text-content-primary',
7
7
  Platform.select({
8
- web: 'font-sans my-0 bg-transparent display-inline no-underline',
8
+ web: 'font-body my-0 bg-transparent no-underline',
9
9
  default: '',
10
10
  }),
11
11
  ],
@@ -0,0 +1,296 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { Pressable, Text, View, type TextProps, type ViewProps } from 'react-native';
3
+ import {
4
+ createTile,
5
+ type ITileGroupMultipleProps,
6
+ type ITileGroupSingleProps,
7
+ type ITileIndicatorProps,
8
+ type ITileLeadingSlotProps,
9
+ type ITileProps,
10
+ type ITileTrailingSlotProps,
11
+ useTileContext,
12
+ } from '@cdx-ui/primitives';
13
+ import { Check } from '@cdx-ui/icons';
14
+ import { dataAttributes } from '@cdx-ui/primitives';
15
+ import { cn, useStyleContext, withStyleContext } from '@cdx-ui/utils';
16
+ import { checkboxIndicatorVariants, checkboxIconVariants } from '../Checkbox/styles';
17
+ import { Icon } from '../Icon';
18
+ import { radioIndicatorVariants, radioInnerDotVariants } from '../Radio/styles';
19
+ import {
20
+ tileContentVariants,
21
+ tileDescriptionVariants,
22
+ tileGroupVariants,
23
+ tileIndicatorVariants,
24
+ tileLeadingSlotVariants,
25
+ tileRootVariants,
26
+ tileTitleVariants,
27
+ tileTrailingSlotVariants,
28
+ type TileGroupVariantProps,
29
+ type TileVariantProps,
30
+ } from './styles';
31
+
32
+ const TILE_SCOPE = 'TILE';
33
+ const TILE_GROUP_SCOPE = 'TILE_GROUP';
34
+
35
+ const RootPressable = withStyleContext(Pressable, TILE_SCOPE);
36
+ const GroupView = withStyleContext(View, TILE_GROUP_SCOPE);
37
+
38
+ interface TileGroupStyleContext {
39
+ shape?: TileVariantProps['shape'];
40
+ }
41
+
42
+ const useTileGroupStyleContext = (): TileGroupStyleContext => {
43
+ // `useStyleContext` types the result as a `Record`, but at runtime the value is
44
+ // `undefined` when no provider is in scope (e.g. standalone Tile). Cast through
45
+ // `unknown` to acknowledge that.
46
+ const ctx = useStyleContext(TILE_GROUP_SCOPE) as unknown as TileGroupStyleContext | undefined;
47
+ return ctx ?? {};
48
+ };
49
+
50
+ const TilePrimitive = createTile({
51
+ Pressable: RootPressable,
52
+ Group: GroupView,
53
+ LeadingSlot: View,
54
+ Content: View,
55
+ Title: Text,
56
+ Description: Text,
57
+ Indicator: View,
58
+ TrailingSlot: View,
59
+ });
60
+
61
+ // =============================================================================
62
+ // TILE GROUP
63
+ // =============================================================================
64
+
65
+ /**
66
+ * Discriminated union mirroring `ITileGroupProps`, with `className` and layout variants added at
67
+ * the styled layer. Distributing the intersection across each branch keeps `interface … extends`
68
+ * ergonomics and avoids tripping `@typescript-eslint` on `(union) & { ... }`.
69
+ *
70
+ * `direction` and `spacing` constrain the group layout to the three supported patterns:
71
+ * - `direction="column"` + `spacing="default"` — vertical stack with gaps (default).
72
+ * - `direction="column"` + `spacing="none"` — tight vertical stack (rows touch).
73
+ * - `direction="row"` + `spacing="default"` — side-by-side horizontal layout.
74
+ *
75
+ * `shape` (when set) is propagated to child `Tile`s via `withStyleContext`, matching the
76
+ * Avatar size-propagation pattern. A per-tile `shape` prop overrides the inherited value.
77
+ */
78
+ export interface TileGroupSingleProps extends ITileGroupSingleProps, TileGroupVariantProps {
79
+ className?: string;
80
+ /** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
81
+ shape?: TileVariantProps['shape'];
82
+ }
83
+ export interface TileGroupMultipleProps extends ITileGroupMultipleProps, TileGroupVariantProps {
84
+ className?: string;
85
+ /** Visual shape inherited by child `Tile`s. Per-tile `shape` overrides this. */
86
+ shape?: TileVariantProps['shape'];
87
+ }
88
+ export type TileGroupProps = TileGroupSingleProps | TileGroupMultipleProps;
89
+
90
+ const TileGroup = forwardRef<View, TileGroupProps>(
91
+ ({ className, style, children, direction, spacing, shape, ...props }, ref) => (
92
+ <TilePrimitive.Group
93
+ ref={ref as never}
94
+ className={cn(tileGroupVariants({ direction, spacing }), className)}
95
+ style={style}
96
+ context={{ shape }}
97
+ {...props}
98
+ >
99
+ {children}
100
+ </TilePrimitive.Group>
101
+ ),
102
+ );
103
+
104
+ TileGroup.displayName = 'Tile.Group';
105
+
106
+ // =============================================================================
107
+ // TILE ROOT
108
+ // =============================================================================
109
+
110
+ export interface TileProps extends ITileProps, TileVariantProps {
111
+ className?: string;
112
+ }
113
+
114
+ const TileRoot = forwardRef<View, TileProps>(
115
+ ({ shape: shapeProp, showSeparator, className, style, context, ...props }, ref) => {
116
+ const { shape: inheritedShape } = useTileGroupStyleContext();
117
+ const shape = shapeProp ?? inheritedShape ?? 'card';
118
+ const computedClassName = cn(tileRootVariants({ shape, showSeparator }), className);
119
+
120
+ return (
121
+ <TilePrimitive
122
+ ref={ref as never}
123
+ className={computedClassName}
124
+ context={{ ...context, shape }}
125
+ style={style}
126
+ {...props}
127
+ />
128
+ );
129
+ },
130
+ );
131
+
132
+ TileRoot.displayName = 'Tile';
133
+
134
+ // =============================================================================
135
+ // SLOTS
136
+ // =============================================================================
137
+
138
+ export interface TileLeadingSlotProps extends ITileLeadingSlotProps {
139
+ className?: string;
140
+ }
141
+
142
+ const TileLeadingSlot = forwardRef<View, TileLeadingSlotProps>(
143
+ ({ className, style, ...props }, ref) => (
144
+ <TilePrimitive.LeadingSlot
145
+ ref={ref as never}
146
+ className={cn(tileLeadingSlotVariants(), className)}
147
+ style={style}
148
+ {...props}
149
+ />
150
+ ),
151
+ );
152
+
153
+ TileLeadingSlot.displayName = 'Tile.LeadingSlot';
154
+
155
+ export interface TileContentProps extends ViewProps {
156
+ className?: string;
157
+ }
158
+
159
+ const TileContent = forwardRef<View, TileContentProps>(({ className, style, ...props }, ref) => (
160
+ <TilePrimitive.Content
161
+ ref={ref as never}
162
+ className={cn(tileContentVariants(), className)}
163
+ style={style}
164
+ {...props}
165
+ />
166
+ ));
167
+
168
+ TileContent.displayName = 'Tile.Content';
169
+
170
+ export interface TileTitleProps extends TextProps {
171
+ className?: string;
172
+ }
173
+
174
+ const TileTitle = forwardRef<Text, TileTitleProps>(
175
+ ({ className, style, numberOfLines = 1, ...props }, ref) => (
176
+ <TilePrimitive.Title
177
+ ref={ref as never}
178
+ className={cn(tileTitleVariants(), className)}
179
+ style={style}
180
+ numberOfLines={numberOfLines}
181
+ {...props}
182
+ />
183
+ ),
184
+ );
185
+
186
+ TileTitle.displayName = 'Tile.Title';
187
+
188
+ export interface TileDescriptionProps extends TextProps {
189
+ className?: string;
190
+ }
191
+
192
+ const TileDescription = forwardRef<Text, TileDescriptionProps>(
193
+ ({ className, style, ...props }, ref) => (
194
+ <TilePrimitive.Description
195
+ ref={ref as never}
196
+ className={cn(tileDescriptionVariants(), className)}
197
+ style={style}
198
+ {...props}
199
+ />
200
+ ),
201
+ );
202
+
203
+ TileDescription.displayName = 'Tile.Description';
204
+
205
+ /**
206
+ * Decorative selection affordance. Renders pure CVA-styled Views — no interactive hooks,
207
+ * no nested Pressable, zero runtime overhead. The Tile root owns the press target and
208
+ * ARIA role; this subtree is `aria-hidden` via `createTileIndicator`.
209
+ *
210
+ * The visual is inferred from the tile context: `single` (radio semantics) → radio ring,
211
+ * `multiple` (checkbox semantics) → checkbox square. An explicit `indicatorType` prop
212
+ * overrides — primarily for standalone tiles that want a radio-style visual.
213
+ */
214
+ function TileIndicatorVisual({ indicatorType }: { indicatorType?: 'radio' | 'checkbox' }) {
215
+ const { isSelected, isDisabled, selectionType } = useTileContext();
216
+ const effectiveType: 'radio' | 'checkbox' =
217
+ indicatorType ?? (selectionType === 'single' ? 'radio' : 'checkbox');
218
+ const stateAttrs = dataAttributes({ checked: isSelected, disabled: isDisabled });
219
+
220
+ if (effectiveType === 'radio') {
221
+ return (
222
+ <View className={radioIndicatorVariants()} {...stateAttrs}>
223
+ <View
224
+ className={radioInnerDotVariants()}
225
+ {...dataAttributes({ checked: isSelected, invalid: false })}
226
+ />
227
+ </View>
228
+ );
229
+ }
230
+
231
+ return (
232
+ <View className={cn(checkboxIndicatorVariants())} {...stateAttrs}>
233
+ {isSelected && <Icon as={Check} className={checkboxIconVariants()} />}
234
+ </View>
235
+ );
236
+ }
237
+
238
+ export interface TileIndicatorProps extends ITileIndicatorProps {
239
+ className?: string;
240
+ children?: ReactNode;
241
+ }
242
+
243
+ const TileIndicator = forwardRef<View, TileIndicatorProps>(
244
+ ({ className, children, style, indicatorType, ...props }, ref) => (
245
+ <TilePrimitive.Indicator
246
+ ref={ref as never}
247
+ className={cn(tileIndicatorVariants(), className)}
248
+ style={style}
249
+ indicatorType={indicatorType}
250
+ {...props}
251
+ >
252
+ {children ?? <TileIndicatorVisual indicatorType={indicatorType} />}
253
+ </TilePrimitive.Indicator>
254
+ ),
255
+ );
256
+
257
+ TileIndicator.displayName = 'Tile.Indicator';
258
+
259
+ export interface TileTrailingSlotProps extends ITileTrailingSlotProps {
260
+ className?: string;
261
+ }
262
+
263
+ const TileTrailingSlot = forwardRef<View, TileTrailingSlotProps>(
264
+ ({ className, style, ...props }, ref) => (
265
+ <TilePrimitive.TrailingSlot
266
+ ref={ref as never}
267
+ className={cn(tileTrailingSlotVariants(), className)}
268
+ style={style}
269
+ {...props}
270
+ />
271
+ ),
272
+ );
273
+
274
+ TileTrailingSlot.displayName = 'Tile.TrailingSlot';
275
+
276
+ type TileCompound = typeof TileRoot & {
277
+ Group: typeof TileGroup;
278
+ LeadingSlot: typeof TileLeadingSlot;
279
+ Content: typeof TileContent;
280
+ Title: typeof TileTitle;
281
+ Description: typeof TileDescription;
282
+ Indicator: typeof TileIndicator;
283
+ TrailingSlot: typeof TileTrailingSlot;
284
+ };
285
+
286
+ export const Tile = Object.assign(TileRoot, {
287
+ Group: TileGroup,
288
+ LeadingSlot: TileLeadingSlot,
289
+ Content: TileContent,
290
+ Title: TileTitle,
291
+ Description: TileDescription,
292
+ Indicator: TileIndicator,
293
+ TrailingSlot: TileTrailingSlot,
294
+ }) as TileCompound;
295
+
296
+ export { useTileContext };
@@ -0,0 +1,82 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from 'class-variance-authority';
3
+ import { TRANSITION_COLORS } from '../../styles/primitives';
4
+
5
+ export const tileGroupVariants = cva(['flex w-full'], {
6
+ variants: {
7
+ direction: {
8
+ column: 'flex-col',
9
+ row: 'flex-row',
10
+ },
11
+ spacing: {
12
+ default: 'gap-2',
13
+ none: 'gap-0',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ direction: 'column',
18
+ spacing: 'default',
19
+ },
20
+ });
21
+
22
+ export type TileGroupVariantProps = VariantProps<typeof tileGroupVariants>;
23
+
24
+ export const tileRootVariants = cva(
25
+ [
26
+ 'flex-row self-stretch gap-3 px-4 py-3',
27
+ 'data-[disabled=true]:opacity-50',
28
+ TRANSITION_COLORS,
29
+ Platform.select({
30
+ web: [
31
+ 'outline-none',
32
+ 'data-[hover=true]:data-[disabled=false]:bg-surface-action-tint-hover',
33
+ 'data-[active=true]:data-[disabled=false]:data-[hover=true]:bg-surface-action-tint-active',
34
+ 'data-[hover=true]:data-[disabled=false]:data-[state=unselected]:border-stroke-action',
35
+ 'focus-visible:data-[disabled=false]:ring-2 focus-visible:data-[disabled=false]:ring-stroke-focus focus-visible:data-[disabled=false]:ring-offset-2',
36
+ ].join(' '),
37
+ default: [
38
+ 'data-[active=true]:bg-surface-action-tint-hover',
39
+ 'data-[active=true]:border-stroke-action',
40
+ ].join(' '),
41
+ }),
42
+ ],
43
+ {
44
+ variants: {
45
+ shape: {
46
+ flat: 'rounded-none border-0 bg-transparent',
47
+ card: [
48
+ 'rounded-xl border-1 border-solid',
49
+ 'border-stroke-secondary',
50
+ 'bg-surface-primary',
51
+ 'data-[state=selected]:border-stroke-action',
52
+ 'data-[state=selected]:border-1.5',
53
+ 'data-[state=selected]:bg-surface-action-tint',
54
+ ].join(' '),
55
+ },
56
+ showSeparator: {
57
+ true: [
58
+ 'border-b border-solid border-stroke-secondary! native:data-[active=true]:border-stroke-secondary', // Override border-stroke-action on hover
59
+ ],
60
+ false: '',
61
+ },
62
+ },
63
+ defaultVariants: {
64
+ shape: 'card',
65
+ showSeparator: false,
66
+ },
67
+ },
68
+ );
69
+
70
+ export const tileLeadingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
71
+
72
+ export const tileTrailingSlotVariants = cva(['flex shrink-0 items-center justify-center']);
73
+
74
+ export const tileContentVariants = cva(['min-w-0 flex-1 flex-col gap-0.5 no-underline']);
75
+
76
+ export const tileTitleVariants = cva(['text-base font-medium text-content-primary no-underline']);
77
+
78
+ export const tileDescriptionVariants = cva(['text-sm text-content-secondary no-underline']);
79
+
80
+ export const tileIndicatorVariants = cva(['flex shrink-0 items-center justify-center']);
81
+
82
+ export type TileVariantProps = VariantProps<typeof tileRootVariants>;
@@ -13,11 +13,14 @@ export * from './Image';
13
13
  export * from './Input';
14
14
  export * from './OtpInput';
15
15
  export * from './Link';
16
+ export * from './ListItem';
16
17
  export * from './ProgressBar';
17
18
  export * from './ProgressSegmented';
19
+ export * from './Radio';
18
20
  export * from './Select';
19
21
  export * from './VirtualizedList';
20
22
  export * from './Switch';
23
+ export * from './Tile';
21
24
  export { HStack, VStack } from './Stack';
22
25
  export * from './Heading';
23
26
  export * from './Text';