@cdx-ui/components 0.1.7 → 0.2.1

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 (287) hide show
  1. package/coverage.svg +1 -1
  2. package/lib/commonjs/components/Calendar/flashCalendarAdapter.js +18 -0
  3. package/lib/commonjs/components/Calendar/flashCalendarAdapter.js.map +1 -1
  4. package/lib/commonjs/components/Calendar/index.js +32 -3
  5. package/lib/commonjs/components/Calendar/index.js.map +1 -1
  6. package/lib/commonjs/components/ColorArea/ColorAreaPaint.js +78 -0
  7. package/lib/commonjs/components/ColorArea/ColorAreaPaint.js.map +1 -0
  8. package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js +31 -0
  9. package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
  10. package/lib/commonjs/components/ColorArea/index.js +57 -0
  11. package/lib/commonjs/components/ColorArea/index.js.map +1 -0
  12. package/lib/commonjs/components/ColorArea/styles.js +12 -0
  13. package/lib/commonjs/components/ColorArea/styles.js.map +1 -0
  14. package/lib/commonjs/components/ColorField/index.js +138 -0
  15. package/lib/commonjs/components/ColorField/index.js.map +1 -0
  16. package/lib/commonjs/components/ColorField/styles.js +14 -0
  17. package/lib/commonjs/components/ColorField/styles.js.map +1 -0
  18. package/lib/commonjs/components/ColorPicker/index.js +88 -0
  19. package/lib/commonjs/components/ColorPicker/index.js.map +1 -0
  20. package/lib/commonjs/components/ColorPicker/styles.js +22 -0
  21. package/lib/commonjs/components/ColorPicker/styles.js.map +1 -0
  22. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js +68 -0
  23. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
  24. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js +41 -0
  25. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
  26. package/lib/commonjs/components/ColorSlider/index.js +123 -0
  27. package/lib/commonjs/components/ColorSlider/index.js.map +1 -0
  28. package/lib/commonjs/components/ColorSlider/styles.js +50 -0
  29. package/lib/commonjs/components/ColorSlider/styles.js.map +1 -0
  30. package/lib/commonjs/components/ColorSwatch/index.js +54 -0
  31. package/lib/commonjs/components/ColorSwatch/index.js.map +1 -0
  32. package/lib/commonjs/components/ColorSwatch/styles.js +25 -0
  33. package/lib/commonjs/components/ColorSwatch/styles.js.map +1 -0
  34. package/lib/commonjs/components/ColorSwatchPicker/index.js +110 -0
  35. package/lib/commonjs/components/ColorSwatchPicker/index.js.map +1 -0
  36. package/lib/commonjs/components/ColorSwatchPicker/styles.js +17 -0
  37. package/lib/commonjs/components/ColorSwatchPicker/styles.js.map +1 -0
  38. package/lib/commonjs/components/DatePicker/index.js +2 -0
  39. package/lib/commonjs/components/DatePicker/index.js.map +1 -1
  40. package/lib/commonjs/components/Field/index.js +4 -2
  41. package/lib/commonjs/components/Field/index.js.map +1 -1
  42. package/lib/commonjs/components/Heading/styles.js +3 -0
  43. package/lib/commonjs/components/Heading/styles.js.map +1 -1
  44. package/lib/commonjs/components/Icon/index.js +27 -3
  45. package/lib/commonjs/components/Icon/index.js.map +1 -1
  46. package/lib/commonjs/components/Icon/styles.js +19 -0
  47. package/lib/commonjs/components/Icon/styles.js.map +1 -0
  48. package/lib/commonjs/components/Text/index.js +13 -4
  49. package/lib/commonjs/components/Text/index.js.map +1 -1
  50. package/lib/commonjs/components/Text/styles.js +39 -3
  51. package/lib/commonjs/components/Text/styles.js.map +1 -1
  52. package/lib/commonjs/components/Toast/hooks.js +0 -1
  53. package/lib/commonjs/components/Toast/hooks.js.map +1 -1
  54. package/lib/commonjs/components/Toast/index.js +9 -6
  55. package/lib/commonjs/components/Toast/index.js.map +1 -1
  56. package/lib/commonjs/components/Toast/styles.js +36 -19
  57. package/lib/commonjs/components/Toast/styles.js.map +1 -1
  58. package/lib/commonjs/components/ToggleButton/index.js +5 -4
  59. package/lib/commonjs/components/ToggleButton/index.js.map +1 -1
  60. package/lib/commonjs/components/index.js +68 -0
  61. package/lib/commonjs/components/index.js.map +1 -1
  62. package/lib/commonjs/components/picker/surfaces.js +9 -2
  63. package/lib/commonjs/components/picker/surfaces.js.map +1 -1
  64. package/lib/commonjs/figma/Icon.figma.js +30 -3
  65. package/lib/commonjs/figma/Icon.figma.js.map +1 -1
  66. package/lib/commonjs/figma/Text.figma.js +15 -1
  67. package/lib/commonjs/figma/Text.figma.js.map +1 -1
  68. package/lib/commonjs/providers/toast/insets-container.js +15 -3
  69. package/lib/commonjs/providers/toast/insets-container.js.map +1 -1
  70. package/lib/commonjs/providers/toast/provider.js +1 -0
  71. package/lib/commonjs/providers/toast/provider.js.map +1 -1
  72. package/lib/commonjs/styles/constants.js +14 -1
  73. package/lib/commonjs/styles/constants.js.map +1 -1
  74. package/lib/module/components/Calendar/flashCalendarAdapter.js +17 -0
  75. package/lib/module/components/Calendar/flashCalendarAdapter.js.map +1 -1
  76. package/lib/module/components/Calendar/index.js +34 -5
  77. package/lib/module/components/Calendar/index.js.map +1 -1
  78. package/lib/module/components/ColorArea/ColorAreaPaint.js +74 -0
  79. package/lib/module/components/ColorArea/ColorAreaPaint.js.map +1 -0
  80. package/lib/module/components/ColorArea/ColorAreaPaint.web.js +27 -0
  81. package/lib/module/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
  82. package/lib/module/components/ColorArea/index.js +53 -0
  83. package/lib/module/components/ColorArea/index.js.map +1 -0
  84. package/lib/module/components/ColorArea/styles.js +8 -0
  85. package/lib/module/components/ColorArea/styles.js.map +1 -0
  86. package/lib/module/components/ColorField/index.js +134 -0
  87. package/lib/module/components/ColorField/index.js.map +1 -0
  88. package/lib/module/components/ColorField/styles.js +10 -0
  89. package/lib/module/components/ColorField/styles.js.map +1 -0
  90. package/lib/module/components/ColorPicker/index.js +79 -0
  91. package/lib/module/components/ColorPicker/index.js.map +1 -0
  92. package/lib/module/components/ColorPicker/styles.js +18 -0
  93. package/lib/module/components/ColorPicker/styles.js.map +1 -0
  94. package/lib/module/components/ColorSlider/ColorSliderRailPaint.js +64 -0
  95. package/lib/module/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
  96. package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js +37 -0
  97. package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
  98. package/lib/module/components/ColorSlider/index.js +119 -0
  99. package/lib/module/components/ColorSlider/index.js.map +1 -0
  100. package/lib/module/components/ColorSlider/styles.js +46 -0
  101. package/lib/module/components/ColorSlider/styles.js.map +1 -0
  102. package/lib/module/components/ColorSwatch/index.js +50 -0
  103. package/lib/module/components/ColorSwatch/index.js.map +1 -0
  104. package/lib/module/components/ColorSwatch/styles.js +21 -0
  105. package/lib/module/components/ColorSwatch/styles.js.map +1 -0
  106. package/lib/module/components/ColorSwatchPicker/index.js +106 -0
  107. package/lib/module/components/ColorSwatchPicker/index.js.map +1 -0
  108. package/lib/module/components/ColorSwatchPicker/styles.js +13 -0
  109. package/lib/module/components/ColorSwatchPicker/styles.js.map +1 -0
  110. package/lib/module/components/DatePicker/index.js +2 -0
  111. package/lib/module/components/DatePicker/index.js.map +1 -1
  112. package/lib/module/components/Field/index.js +4 -2
  113. package/lib/module/components/Field/index.js.map +1 -1
  114. package/lib/module/components/Heading/styles.js +3 -0
  115. package/lib/module/components/Heading/styles.js.map +1 -1
  116. package/lib/module/components/Icon/index.js +27 -3
  117. package/lib/module/components/Icon/index.js.map +1 -1
  118. package/lib/module/components/Icon/styles.js +16 -0
  119. package/lib/module/components/Icon/styles.js.map +1 -0
  120. package/lib/module/components/Text/index.js +14 -5
  121. package/lib/module/components/Text/index.js.map +1 -1
  122. package/lib/module/components/Text/styles.js +38 -2
  123. package/lib/module/components/Text/styles.js.map +1 -1
  124. package/lib/module/components/Toast/hooks.js +0 -1
  125. package/lib/module/components/Toast/hooks.js.map +1 -1
  126. package/lib/module/components/Toast/index.js +10 -7
  127. package/lib/module/components/Toast/index.js.map +1 -1
  128. package/lib/module/components/Toast/styles.js +35 -19
  129. package/lib/module/components/Toast/styles.js.map +1 -1
  130. package/lib/module/components/ToggleButton/index.js +3 -3
  131. package/lib/module/components/ToggleButton/index.js.map +1 -1
  132. package/lib/module/components/index.js +6 -0
  133. package/lib/module/components/index.js.map +1 -1
  134. package/lib/module/components/picker/surfaces.js +10 -3
  135. package/lib/module/components/picker/surfaces.js.map +1 -1
  136. package/lib/module/figma/Icon.figma.js +30 -3
  137. package/lib/module/figma/Icon.figma.js.map +1 -1
  138. package/lib/module/figma/Text.figma.js +15 -1
  139. package/lib/module/figma/Text.figma.js.map +1 -1
  140. package/lib/module/providers/toast/insets-container.js +15 -4
  141. package/lib/module/providers/toast/insets-container.js.map +1 -1
  142. package/lib/module/providers/toast/provider.js +2 -1
  143. package/lib/module/providers/toast/provider.js.map +1 -1
  144. package/lib/module/styles/constants.js +13 -0
  145. package/lib/module/styles/constants.js.map +1 -1
  146. package/lib/typescript/components/Alert/index.d.ts +1 -1
  147. package/lib/typescript/components/Alert/index.d.ts.map +1 -1
  148. package/lib/typescript/components/Avatar/index.d.ts +1 -1
  149. package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
  150. package/lib/typescript/components/Badge/styles.d.ts +3 -3
  151. package/lib/typescript/components/Breadcrumbs/styles.d.ts +1 -1
  152. package/lib/typescript/components/Button/index.d.ts +1 -1
  153. package/lib/typescript/components/Button/index.d.ts.map +1 -1
  154. package/lib/typescript/components/Button/styles.d.ts +4 -4
  155. package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts +3 -1
  156. package/lib/typescript/components/Calendar/flashCalendarAdapter.d.ts.map +1 -1
  157. package/lib/typescript/components/Calendar/index.d.ts.map +1 -1
  158. package/lib/typescript/components/Checkbox/index.d.ts +1 -1
  159. package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
  160. package/lib/typescript/components/Chip/index.d.ts +1 -1
  161. package/lib/typescript/components/Chip/index.d.ts.map +1 -1
  162. package/lib/typescript/components/Chip/styles.d.ts +3 -3
  163. package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts +5 -0
  164. package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts.map +1 -0
  165. package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts +5 -0
  166. package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts.map +1 -0
  167. package/lib/typescript/components/ColorArea/index.d.ts +20 -0
  168. package/lib/typescript/components/ColorArea/index.d.ts.map +1 -0
  169. package/lib/typescript/components/ColorArea/styles.d.ts +4 -0
  170. package/lib/typescript/components/ColorArea/styles.d.ts.map +1 -0
  171. package/lib/typescript/components/ColorField/index.d.ts +41 -0
  172. package/lib/typescript/components/ColorField/index.d.ts.map +1 -0
  173. package/lib/typescript/components/ColorField/styles.d.ts +13 -0
  174. package/lib/typescript/components/ColorField/styles.d.ts.map +1 -0
  175. package/lib/typescript/components/ColorPicker/index.d.ts +28 -0
  176. package/lib/typescript/components/ColorPicker/index.d.ts.map +1 -0
  177. package/lib/typescript/components/ColorPicker/styles.d.ts +9 -0
  178. package/lib/typescript/components/ColorPicker/styles.d.ts.map +1 -0
  179. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts +5 -0
  180. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts.map +1 -0
  181. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts +5 -0
  182. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts.map +1 -0
  183. package/lib/typescript/components/ColorSlider/index.d.ts +33 -0
  184. package/lib/typescript/components/ColorSlider/index.d.ts.map +1 -0
  185. package/lib/typescript/components/ColorSlider/styles.d.ts +14 -0
  186. package/lib/typescript/components/ColorSlider/styles.d.ts.map +1 -0
  187. package/lib/typescript/components/ColorSwatch/index.d.ts +19 -0
  188. package/lib/typescript/components/ColorSwatch/index.d.ts.map +1 -0
  189. package/lib/typescript/components/ColorSwatch/styles.d.ts +7 -0
  190. package/lib/typescript/components/ColorSwatch/styles.d.ts.map +1 -0
  191. package/lib/typescript/components/ColorSwatchPicker/index.d.ts +37 -0
  192. package/lib/typescript/components/ColorSwatchPicker/index.d.ts.map +1 -0
  193. package/lib/typescript/components/ColorSwatchPicker/styles.d.ts +5 -0
  194. package/lib/typescript/components/ColorSwatchPicker/styles.d.ts.map +1 -0
  195. package/lib/typescript/components/DatePicker/index.d.ts +1 -1
  196. package/lib/typescript/components/DatePicker/index.d.ts.map +1 -1
  197. package/lib/typescript/components/Divider/index.d.ts +1 -1
  198. package/lib/typescript/components/Divider/index.d.ts.map +1 -1
  199. package/lib/typescript/components/Field/index.d.ts +5 -0
  200. package/lib/typescript/components/Field/index.d.ts.map +1 -1
  201. package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
  202. package/lib/typescript/components/Icon/index.d.ts +14 -22
  203. package/lib/typescript/components/Icon/index.d.ts.map +1 -1
  204. package/lib/typescript/components/Icon/styles.d.ts +6 -0
  205. package/lib/typescript/components/Icon/styles.d.ts.map +1 -0
  206. package/lib/typescript/components/IconButton/styles.d.ts +2 -2
  207. package/lib/typescript/components/Input/index.d.ts +1 -1
  208. package/lib/typescript/components/Input/index.d.ts.map +1 -1
  209. package/lib/typescript/components/Link/index.d.ts +1 -1
  210. package/lib/typescript/components/Link/index.d.ts.map +1 -1
  211. package/lib/typescript/components/Menu/index.d.ts +2 -2
  212. package/lib/typescript/components/Menu/index.d.ts.map +1 -1
  213. package/lib/typescript/components/Select/index.d.ts +1 -1
  214. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  215. package/lib/typescript/components/Slider/styles.d.ts +3 -3
  216. package/lib/typescript/components/Text/index.d.ts +40 -3
  217. package/lib/typescript/components/Text/index.d.ts.map +1 -1
  218. package/lib/typescript/components/Text/styles.d.ts +9 -0
  219. package/lib/typescript/components/Text/styles.d.ts.map +1 -1
  220. package/lib/typescript/components/Toast/hooks.d.ts +1 -1
  221. package/lib/typescript/components/Toast/hooks.d.ts.map +1 -1
  222. package/lib/typescript/components/Toast/index.d.ts.map +1 -1
  223. package/lib/typescript/components/Toast/styles.d.ts +4 -0
  224. package/lib/typescript/components/Toast/styles.d.ts.map +1 -1
  225. package/lib/typescript/components/Toast/types.d.ts +1 -1
  226. package/lib/typescript/components/Toast/types.d.ts.map +1 -1
  227. package/lib/typescript/components/ToggleButton/index.d.ts +5 -3
  228. package/lib/typescript/components/ToggleButton/index.d.ts.map +1 -1
  229. package/lib/typescript/components/index.d.ts +6 -0
  230. package/lib/typescript/components/index.d.ts.map +1 -1
  231. package/lib/typescript/components/picker/surfaces.d.ts +5 -1
  232. package/lib/typescript/components/picker/surfaces.d.ts.map +1 -1
  233. package/lib/typescript/figma/Icon.figma.d.ts.map +1 -1
  234. package/lib/typescript/figma/Text.figma.d.ts.map +1 -1
  235. package/lib/typescript/providers/toast/insets-container.d.ts +12 -0
  236. package/lib/typescript/providers/toast/insets-container.d.ts.map +1 -1
  237. package/lib/typescript/providers/toast/types.d.ts +5 -0
  238. package/lib/typescript/providers/toast/types.d.ts.map +1 -1
  239. package/lib/typescript/styles/constants.d.ts +10 -0
  240. package/lib/typescript/styles/constants.d.ts.map +1 -1
  241. package/package.json +5 -5
  242. package/src/components/Alert/index.tsx +1 -1
  243. package/src/components/Avatar/index.tsx +1 -1
  244. package/src/components/Button/index.tsx +1 -1
  245. package/src/components/Calendar/flashCalendarAdapter.ts +13 -1
  246. package/src/components/Calendar/index.tsx +43 -5
  247. package/src/components/Checkbox/index.tsx +1 -1
  248. package/src/components/Chip/index.tsx +1 -1
  249. package/src/components/ColorArea/ColorAreaPaint.tsx +51 -0
  250. package/src/components/ColorArea/ColorAreaPaint.web.tsx +31 -0
  251. package/src/components/ColorArea/index.tsx +71 -0
  252. package/src/components/ColorArea/styles.ts +18 -0
  253. package/src/components/ColorField/index.tsx +181 -0
  254. package/src/components/ColorField/styles.ts +20 -0
  255. package/src/components/ColorPicker/index.tsx +110 -0
  256. package/src/components/ColorPicker/styles.ts +33 -0
  257. package/src/components/ColorSlider/ColorSliderRailPaint.tsx +60 -0
  258. package/src/components/ColorSlider/ColorSliderRailPaint.web.tsx +33 -0
  259. package/src/components/ColorSlider/index.tsx +147 -0
  260. package/src/components/ColorSlider/styles.ts +72 -0
  261. package/src/components/ColorSwatch/index.tsx +56 -0
  262. package/src/components/ColorSwatch/styles.ts +24 -0
  263. package/src/components/ColorSwatchPicker/index.tsx +150 -0
  264. package/src/components/ColorSwatchPicker/styles.ts +32 -0
  265. package/src/components/DatePicker/index.tsx +13 -3
  266. package/src/components/Divider/index.tsx +1 -1
  267. package/src/components/Field/index.tsx +9 -3
  268. package/src/components/Heading/styles.ts +3 -0
  269. package/src/components/Icon/index.tsx +46 -6
  270. package/src/components/Icon/styles.ts +15 -0
  271. package/src/components/Input/index.tsx +1 -1
  272. package/src/components/Link/index.tsx +1 -1
  273. package/src/components/Menu/index.tsx +2 -2
  274. package/src/components/Select/index.tsx +1 -1
  275. package/src/components/Text/index.tsx +32 -5
  276. package/src/components/Text/styles.ts +39 -1
  277. package/src/components/Toast/hooks.ts +0 -1
  278. package/src/components/Toast/index.tsx +14 -8
  279. package/src/components/Toast/styles.ts +47 -19
  280. package/src/components/Toast/types.ts +1 -1
  281. package/src/components/ToggleButton/index.tsx +9 -7
  282. package/src/components/index.ts +6 -0
  283. package/src/components/picker/surfaces.tsx +15 -2
  284. package/src/providers/toast/insets-container.tsx +23 -9
  285. package/src/providers/toast/provider.tsx +2 -2
  286. package/src/providers/toast/types.ts +5 -0
  287. package/src/styles/constants.ts +13 -0
@@ -0,0 +1,56 @@
1
+ import { forwardRef, type ComponentRef } from 'react';
2
+ import { View, type ViewProps } from 'react-native';
3
+ import {
4
+ Slot,
5
+ dataAttributes,
6
+ mergeDataAttributes,
7
+ useOptionalColorPickerContext,
8
+ type Color,
9
+ } from '@cdx-ui/primitives';
10
+ import { cn } from '@cdx-ui/utils';
11
+ import { colorSwatchVariants, type ColorSwatchVariantProps } from './styles';
12
+
13
+ export interface ColorSwatchProps extends ViewProps, ColorSwatchVariantProps {
14
+ asChild?: boolean;
15
+ color?: Color;
16
+ /** Visual dimension. `xs` = 16, `sm` = 24, and `lg` = 40. */
17
+ size?: 'xs' | 'sm' | 'lg';
18
+ /** Swatch outline shape. */
19
+ shape?: 'circle' | 'square';
20
+ className?: string;
21
+ }
22
+
23
+ interface ColorSwatchViewProps extends ColorSwatchProps {
24
+ slot: string;
25
+ }
26
+
27
+ export const ColorSwatchView = forwardRef<ComponentRef<typeof View>, ColorSwatchViewProps>(
28
+ ({ asChild, color, size = 'sm', shape = 'circle', slot, className, style, ...props }, ref) => {
29
+ const Comp = asChild ? Slot : View;
30
+
31
+ return (
32
+ <Comp
33
+ ref={ref}
34
+ className={cn(colorSwatchVariants({ size, shape }), className)}
35
+ style={[color ? { backgroundColor: color.toString('hex') } : undefined, style]}
36
+ {...props}
37
+ {...mergeDataAttributes(props, dataAttributes({ slot }))}
38
+ />
39
+ );
40
+ },
41
+ );
42
+
43
+ ColorSwatchView.displayName = 'ColorSwatchView';
44
+
45
+ export const ColorSwatch = forwardRef<ComponentRef<typeof View>, ColorSwatchProps>(
46
+ ({ color: colorProp, ...props }, ref) => {
47
+ const picker = useOptionalColorPickerContext();
48
+ const color = colorProp ?? picker?.value;
49
+
50
+ return <ColorSwatchView ref={ref} color={color} slot="color-swatch" {...props} />;
51
+ },
52
+ );
53
+
54
+ ColorSwatch.displayName = 'ColorSwatch';
55
+
56
+ export type { ColorSwatchVariantProps };
@@ -0,0 +1,24 @@
1
+ import { cva, type VariantProps } from '@cdx-ui/utils';
2
+
3
+ export const colorSwatchVariants = cva(
4
+ ['shrink-0 overflow-hidden border border-stroke-secondary'],
5
+ {
6
+ variants: {
7
+ size: {
8
+ xs: 'size-4',
9
+ sm: 'size-6',
10
+ lg: 'size-10',
11
+ },
12
+ shape: {
13
+ circle: 'rounded-[var(--border-radius-round)]',
14
+ square: 'rounded-[var(--border-radius-default)]',
15
+ },
16
+ },
17
+ defaultVariants: {
18
+ size: 'sm',
19
+ shape: 'circle',
20
+ },
21
+ },
22
+ );
23
+
24
+ export type ColorSwatchVariantProps = VariantProps<typeof colorSwatchVariants>;
@@ -0,0 +1,150 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { View } from 'react-native';
3
+ import { Check } from '@cdx-ui/icons';
4
+ import {
5
+ ColorSwatchPickerItem as ColorSwatchPickerItemPrimitive,
6
+ ColorSwatchPickerRoot as ColorSwatchPickerRootPrimitive,
7
+ Slot,
8
+ dataAttributes,
9
+ mergeDataAttributes,
10
+ useColorSwatchPickerItemContext,
11
+ useRadioContext,
12
+ type IColorSwatchPickerItemProps,
13
+ type IColorSwatchPickerProps,
14
+ } from '@cdx-ui/primitives';
15
+ import { cn } from '@cdx-ui/utils';
16
+ import { Icon, type IconProps } from '../Icon';
17
+ import { ColorSwatchView, type ColorSwatchProps } from '../ColorSwatch';
18
+ import {
19
+ colorSwatchPickerIndicatorIconVariants,
20
+ colorSwatchPickerIndicatorVariants,
21
+ colorSwatchPickerItemVariants,
22
+ colorSwatchPickerVariants,
23
+ } from './styles';
24
+
25
+ export interface ColorSwatchPickerProps extends IColorSwatchPickerProps {
26
+ asChild?: boolean;
27
+ className?: string;
28
+ }
29
+
30
+ const ColorSwatchPickerRoot = forwardRef<View, ColorSwatchPickerProps>(
31
+ ({ asChild, className, style, children, ...props }, ref) => (
32
+ <ColorSwatchPickerRootPrimitive
33
+ ref={ref}
34
+ asChild={asChild}
35
+ className={cn(colorSwatchPickerVariants(), className)}
36
+ style={style}
37
+ {...props}
38
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-swatch-picker' }))}
39
+ >
40
+ {children}
41
+ </ColorSwatchPickerRootPrimitive>
42
+ ),
43
+ );
44
+
45
+ ColorSwatchPickerRoot.displayName = 'ColorSwatchPicker';
46
+
47
+ export interface ColorSwatchPickerItemProps extends IColorSwatchPickerItemProps {
48
+ asChild?: boolean;
49
+ className?: string;
50
+ children?: ReactNode;
51
+ }
52
+
53
+ const ColorSwatchPickerItem = forwardRef<View, ColorSwatchPickerItemProps>(
54
+ ({ asChild, className, style, children, ...props }, ref) => (
55
+ <ColorSwatchPickerItemPrimitive
56
+ ref={ref}
57
+ asChild={asChild}
58
+ className={cn(colorSwatchPickerItemVariants(), className)}
59
+ style={style}
60
+ {...props}
61
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-swatch-picker-item' }))}
62
+ >
63
+ {children}
64
+ </ColorSwatchPickerItemPrimitive>
65
+ ),
66
+ );
67
+
68
+ ColorSwatchPickerItem.displayName = 'ColorSwatchPicker.Item';
69
+
70
+ export interface ColorSwatchPickerSwatchProps extends Omit<ColorSwatchProps, 'color'> {}
71
+
72
+ const ColorSwatchPickerSwatch = forwardRef<View, ColorSwatchPickerSwatchProps>((props, ref) => {
73
+ const { color } = useColorSwatchPickerItemContext();
74
+
75
+ return <ColorSwatchView ref={ref} color={color} slot="color-swatch-picker-swatch" {...props} />;
76
+ });
77
+
78
+ ColorSwatchPickerSwatch.displayName = 'ColorSwatchPicker.Swatch';
79
+
80
+ export interface ColorSwatchPickerIndicatorProps extends Omit<IconProps, 'as' | 'children'> {
81
+ asChild?: boolean;
82
+ as?: IconProps['as'];
83
+ className?: string;
84
+ children?: ReactNode;
85
+ }
86
+
87
+ const ColorSwatchPickerIndicator = ({
88
+ asChild,
89
+ as = Check,
90
+ className,
91
+ style,
92
+ children,
93
+ ...props
94
+ }: ColorSwatchPickerIndicatorProps) => {
95
+ const { isChecked } = useRadioContext();
96
+
97
+ if (!isChecked) {
98
+ return null;
99
+ }
100
+
101
+ const computedClassName = cn(colorSwatchPickerIndicatorIconVariants(), className);
102
+ const slotData = mergeDataAttributes(
103
+ props,
104
+ dataAttributes({ slot: 'color-swatch-picker-indicator' }),
105
+ );
106
+
107
+ return (
108
+ <View
109
+ className={colorSwatchPickerIndicatorVariants()}
110
+ accessibilityElementsHidden
111
+ aria-hidden
112
+ {...slotData}
113
+ >
114
+ {asChild ? (
115
+ <Slot
116
+ className={computedClassName}
117
+ style={style}
118
+ accessibilityElementsHidden
119
+ aria-hidden
120
+ {...props}
121
+ >
122
+ {children}
123
+ </Slot>
124
+ ) : (
125
+ <Icon
126
+ as={as}
127
+ className={computedClassName}
128
+ style={style}
129
+ accessibilityElementsHidden
130
+ aria-hidden
131
+ {...props}
132
+ />
133
+ )}
134
+ </View>
135
+ );
136
+ };
137
+
138
+ ColorSwatchPickerIndicator.displayName = 'ColorSwatchPicker.Indicator';
139
+
140
+ type ColorSwatchPickerCompoundComponent = typeof ColorSwatchPickerRoot & {
141
+ Item: typeof ColorSwatchPickerItem;
142
+ Swatch: typeof ColorSwatchPickerSwatch;
143
+ Indicator: typeof ColorSwatchPickerIndicator;
144
+ };
145
+
146
+ export const ColorSwatchPicker = Object.assign(ColorSwatchPickerRoot, {
147
+ Item: ColorSwatchPickerItem,
148
+ Swatch: ColorSwatchPickerSwatch,
149
+ Indicator: ColorSwatchPickerIndicator,
150
+ }) as ColorSwatchPickerCompoundComponent;
@@ -0,0 +1,32 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva } from '@cdx-ui/utils';
3
+ import { DISABLED_CURSOR, TRANSITION_COLORS } from '../../styles/constants';
4
+
5
+ export const colorSwatchPickerVariants = cva([
6
+ 'w-full flex-row flex-wrap justify-center gap-x-1 gap-y-2',
7
+ ]);
8
+
9
+ export const colorSwatchPickerItemVariants = cva([
10
+ 'relative min-h-11 min-w-11 items-center justify-center',
11
+ 'rounded-[var(--border-radius-default)]',
12
+ TRANSITION_COLORS,
13
+ DISABLED_CURSOR,
14
+ 'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
15
+ 'web:outline-none',
16
+ 'web:data-[focus-visible=true]:ring-2',
17
+ 'web:data-[focus-visible=true]:ring-stroke-focus',
18
+ 'web:data-[focus-visible=true]:ring-offset-2',
19
+ Platform.select({
20
+ default: 'data-[active=true]:bg-surface-action-tint-active',
21
+ web: [
22
+ 'data-[hover=true]:bg-surface-action-tint-hover',
23
+ 'data-[active=true]:data-[hover=true]:bg-surface-action-tint-active',
24
+ ].join(' '),
25
+ }),
26
+ ]);
27
+
28
+ export const colorSwatchPickerIndicatorVariants = cva([
29
+ 'pointer-events-none absolute inset-0 z-10 items-center justify-center',
30
+ ]);
31
+
32
+ export const colorSwatchPickerIndicatorIconVariants = cva('size-4 text-[var(--color-white)]');
@@ -91,12 +91,21 @@ DatePickerTriggerIndicator.displayName = 'DatePicker.TriggerIndicator';
91
91
 
92
92
  type DatePickerCalendarProps = Omit<
93
93
  CalendarProps,
94
- 'value' | 'onValueChange' | 'minValue' | 'maxValue'
94
+ 'value' | 'onValueChange' | 'minValue' | 'maxValue' | 'isDateUnavailable'
95
95
  >;
96
96
 
97
97
  const DatePickerCalendar = forwardRef<View, DatePickerCalendarProps>(({ ...props }, ref) => {
98
- const { value, onValueChange, open, setOpen, minValue, maxValue, locale, labels } =
99
- useDatePickerContext();
98
+ const {
99
+ value,
100
+ onValueChange,
101
+ open,
102
+ setOpen,
103
+ minValue,
104
+ maxValue,
105
+ isDateUnavailable,
106
+ locale,
107
+ labels,
108
+ } = useDatePickerContext();
100
109
 
101
110
  const handleValueChange = useCallback(
102
111
  (next: DateId | undefined) => {
@@ -115,6 +124,7 @@ const DatePickerCalendar = forwardRef<View, DatePickerCalendarProps>(({ ...props
115
124
  onValueChange={handleValueChange}
116
125
  minValue={minValue}
117
126
  maxValue={maxValue}
127
+ isDateUnavailable={isDateUnavailable}
118
128
  locale={locale}
119
129
  labels={labels}
120
130
  {...props}
@@ -22,7 +22,7 @@ export interface DividerProps extends ViewProps {
22
22
  children?: ReactNode;
23
23
  }
24
24
 
25
- export interface DividerLabelProps extends TextProps {
25
+ export interface DividerLabelProps extends Omit<TextProps, 'color'> {
26
26
  /** Renders the consumer's child element in place of the default `Text` host. */
27
27
  asChild?: boolean;
28
28
  className?: string;
@@ -177,14 +177,20 @@ FieldErrorIcon.displayName = 'Field.ErrorIcon';
177
177
  export interface FieldErrorProps extends ViewProps, FieldErrorVariantProps {
178
178
  asChild?: boolean;
179
179
  className?: string;
180
+ /**
181
+ * Error message. When omitted (or `null`), falls back to the message the field's control
182
+ * reports — for example `DatePicker`'s localized `minValue` / `maxValue` / `isDateUnavailable`
183
+ * message.
184
+ */
180
185
  children?: ReactNode;
181
186
  }
182
187
 
183
188
  const FieldError = forwardRef<View, FieldErrorProps>(
184
189
  ({ asChild, className, children, style, ...props }, ref) => {
185
- const { isInvalid, feedbackId, setHasFeedbackText } = useFormControlContext();
190
+ const { isInvalid, errorMessage, feedbackId, setHasFeedbackText } = useFormControlContext();
191
+ const content = children ?? errorMessage;
186
192
 
187
- const visible = Boolean(isInvalid && children);
193
+ const visible = Boolean(isInvalid && content);
188
194
 
189
195
  useEffect(() => {
190
196
  if (!visible) {
@@ -217,7 +223,7 @@ const FieldError = forwardRef<View, FieldErrorProps>(
217
223
  {...mergeDataAttributes(props, dataAttributes({ slot: 'field-error' }))}
218
224
  >
219
225
  <FieldErrorIcon />
220
- <Text className={textClassName}>{children}</Text>
226
+ <Text className={textClassName}>{content}</Text>
221
227
  </Comp>
222
228
  );
223
229
  },
@@ -19,6 +19,9 @@ export const headingStyle = cva(
19
19
  xs: 'heading-xs',
20
20
  },
21
21
  },
22
+ defaultVariants: {
23
+ size: 'lg',
24
+ },
22
25
  },
23
26
  );
24
27
 
@@ -1,13 +1,30 @@
1
+ import { useEffect } from 'react';
1
2
  import { withUniwind } from 'uniwind';
2
3
  import { cn } from '@cdx-ui/utils';
3
4
  import type { ForgeIcon, ForgeIconProps } from '@cdx-ui/icons';
5
+ import { CONTENT_COLOR } from '../../styles/constants';
6
+ import { iconStyle, type IconVariantProps } from './styles';
4
7
 
5
- export type IconProps = ForgeIconProps & {
8
+ export type IconColor = NonNullable<IconVariantProps['color']>;
9
+
10
+ type SvgColor = NonNullable<ForgeIconProps['color']>;
11
+
12
+ export type IconProps = Omit<ForgeIconProps, 'color'> & {
13
+ /**
14
+ * Semantic content color, mapped to the matching `text-content-*` token.
15
+ *
16
+ * Any other value is deprecated: it is passed to the SVG unchanged, as before
17
+ * the semantic colors existed, and warns once in development.
18
+ * @default 'primary'
19
+ */
20
+ color?: IconColor | (string & {}) | Exclude<SvgColor, string>;
6
21
  className?: string; // TODO: Why does this need to specified manually?
7
22
  as: ForgeIcon;
8
23
  };
9
24
 
10
- function IconImpl({ as: IconComponent, ...props }: IconProps) {
25
+ type IconImplProps = ForgeIconProps & Pick<IconProps, 'as' | 'className'>;
26
+
27
+ function IconImpl({ as: IconComponent, ...props }: IconImplProps) {
11
28
  return <IconComponent {...props} />;
12
29
  }
13
30
 
@@ -41,19 +58,42 @@ const StyledIcon = withUniwind(withUniwind(IconImpl), {
41
58
  * import { Icon } from '@cdx-ui/components';
42
59
  * import { ArrowRight } from '@cdx-ui/icons';
43
60
  *
44
- * <Icon as={ArrowRight} className="text-red-500 size-4" />
61
+ * <Icon as={ArrowRight} color="action" className="size-4" />
45
62
  * ```
46
63
  *
47
64
  * @param {ForgeIcon} as - The Forge icon component to render.
48
- * @param {string} className - Utility classes to style the icon using Uniwind.
65
+ * @param {IconColor} color - Semantic content color. Defaults to `primary`.
66
+ * @param {string} className - Utility classes for size and placement, merged after the defaults.
49
67
  * @param {number} size - Icon size (overrides the size class).
50
68
  * @param {...ForgeIconProps} ...props - Additional icon props passed to the "as" icon.
51
69
  */
52
- export function Icon({ as: IconComponent, className, ...props }: IconProps) {
70
+ let hasWarnedIconRawColor = false;
71
+
72
+ function isIconColor(color: NonNullable<IconProps['color']>): color is IconColor {
73
+ return typeof color === 'string' && Object.prototype.hasOwnProperty.call(CONTENT_COLOR, color);
74
+ }
75
+
76
+ export function Icon({ as: IconComponent, color = 'primary', className, ...props }: IconProps) {
77
+ const isSemantic = isIconColor(color);
78
+ const semanticColor = isSemantic ? color : null;
79
+ const rawColor = isSemantic ? undefined : color;
80
+
81
+ useEffect(() => {
82
+ if (__DEV__ && rawColor !== undefined && !hasWarnedIconRawColor) {
83
+ hasWarnedIconRawColor = true;
84
+ console.warn(
85
+ `[Icon] Passing a raw \`color\` value is deprecated and will be removed in a future major release. Use a semantic color (${Object.keys(CONTENT_COLOR).join(', ')}) instead.`,
86
+ );
87
+ }
88
+ }, [rawColor]);
89
+
90
+ // A raw color skips the color class and reaches the SVG directly; `withUniwind`
91
+ // only maps `color` from `className` when the prop is undefined.
53
92
  return (
54
93
  <StyledIcon
55
94
  as={IconComponent}
56
- className={cn('text-content-primary size-5', className)}
95
+ className={cn(iconStyle({ color: semanticColor }), className)}
96
+ color={rawColor}
57
97
  {...props}
58
98
  />
59
99
  );
@@ -0,0 +1,15 @@
1
+ import { cva, type VariantProps } from '@cdx-ui/utils';
2
+ import { CONTENT_COLOR } from '../../styles/constants';
3
+
4
+ // `shrink-0` matters on web only: react-native-svg renders a bare `<svg>`, which
5
+ // falls back to the browser's `flex-shrink: 1`. Yoga already defaults to 0.
6
+ export const iconStyle = cva(['size-5 shrink-0'], {
7
+ variants: {
8
+ color: CONTENT_COLOR,
9
+ },
10
+ defaultVariants: {
11
+ color: 'primary',
12
+ },
13
+ });
14
+
15
+ export type IconVariantProps = VariantProps<typeof iconStyle>;
@@ -151,7 +151,7 @@ InputSlot.displayName = 'Input.Slot';
151
151
  // INPUT ICON
152
152
  // =============================================================================
153
153
 
154
- export interface InputIconProps extends Omit<IconProps, 'children' | 'as'> {
154
+ export interface InputIconProps extends Omit<IconProps, 'children' | 'as' | 'color'> {
155
155
  /** Render the consumer's child element in place of the default icon host. */
156
156
  asChild?: boolean;
157
157
  /**
@@ -91,7 +91,7 @@ LinkLabel.displayName = 'Link.Label';
91
91
  // STYLED ICON COMPONENT
92
92
  // =============================================================================
93
93
 
94
- export interface LinkIconProps extends Omit<IconProps, 'children'> {}
94
+ export interface LinkIconProps extends Omit<IconProps, 'children' | 'color'> {}
95
95
 
96
96
  const LinkIcon = ({ className, style, as, ...props }: LinkIconProps) => {
97
97
  const { visited } = useLinkInteractionContext();
@@ -422,7 +422,7 @@ const MenuItemLabel = forwardRef<Text, MenuItemLabelProps>(
422
422
 
423
423
  MenuItemLabel.displayName = 'Menu.ItemLabel';
424
424
 
425
- export interface MenuItemIconProps extends Omit<IconProps, 'as' | 'children'> {
425
+ export interface MenuItemIconProps extends Omit<IconProps, 'as' | 'children' | 'color'> {
426
426
  asChild?: boolean;
427
427
  as?: IconProps['as'];
428
428
  position?: IconSlotPosition;
@@ -508,7 +508,7 @@ const MenuItemShortcut = forwardRef<Text, MenuItemShortcutProps>(
508
508
 
509
509
  MenuItemShortcut.displayName = 'Menu.ItemShortcut';
510
510
 
511
- export interface MenuItemIndicatorProps extends Omit<IconProps, 'as' | 'children'> {
511
+ export interface MenuItemIndicatorProps extends Omit<IconProps, 'as' | 'children' | 'color'> {
512
512
  asChild?: boolean;
513
513
  as?: IconProps['as'];
514
514
  isChecked?: boolean;
@@ -191,7 +191,7 @@ SelectValue.displayName = 'Select.Value';
191
191
  // STYLED ICON (styled-only, reads context for state=open / invalid)
192
192
  // =============================================================================
193
193
 
194
- export interface SelectIconProps extends Omit<IconProps, 'children' | 'as'> {
194
+ export interface SelectIconProps extends Omit<IconProps, 'children' | 'as' | 'color'> {
195
195
  asChild?: boolean;
196
196
  /**
197
197
  * Forge icon component to render. Required unless `asChild` is set, in which
@@ -1,16 +1,43 @@
1
1
  import { forwardRef, type ComponentPropsWithoutRef, type ComponentRef } from 'react';
2
2
  import { Text as RNText } from 'react-native';
3
+ import { useHasTextAncestor } from '@cdx-ui/primitives';
3
4
  import { cn } from '@cdx-ui/utils';
4
- import { textStyle, TextVariantProps } from './styles';
5
+ import { nestedTextStyle, textStyle, type TextVariantProps } from './styles';
5
6
 
6
- export type TextProps = TextVariantProps &
7
- ComponentPropsWithoutRef<typeof RNText> & { className?: string };
7
+ export type TextColor = NonNullable<TextVariantProps['color']>;
8
+ export type TextSize = NonNullable<TextVariantProps['size']>;
9
+ export type TextWeight = NonNullable<TextVariantProps['weight']>;
10
+
11
+ export type TextProps = Omit<TextVariantProps, 'color' | 'size' | 'weight'> &
12
+ ComponentPropsWithoutRef<typeof RNText> & {
13
+ /**
14
+ * Semantic content color, mapped to the matching `text-content-*` token.
15
+ * A `Text` nested inside another text element inherits its parent's color when omitted.
16
+ * @default 'primary'
17
+ */
18
+ color?: TextColor;
19
+ /**
20
+ * Body typography style. A nested `Text` inherits its parent's size when omitted, and
21
+ * setting it keeps the parent's font family and weight.
22
+ * @default 'md'
23
+ */
24
+ size?: TextSize;
25
+ /**
26
+ * Font weight. A nested `Text` inherits its parent's weight when omitted.
27
+ * @default 'normal'
28
+ */
29
+ weight?: TextWeight;
30
+ className?: string;
31
+ };
8
32
 
9
33
  export const Text = forwardRef<ComponentRef<typeof RNText>, TextProps>(function Text(
10
- { className, size = 'md', ...props },
34
+ { className, color, size, weight, italic, ...props },
11
35
  ref,
12
36
  ) {
13
- return <RNText className={cn(textStyle({ size }), className)} {...props} ref={ref} />;
37
+ const variants = { color, size, weight, italic };
38
+ const classes = useHasTextAncestor() ? nestedTextStyle(variants) : textStyle(variants);
39
+
40
+ return <RNText className={cn(classes, className)} {...props} ref={ref} />;
14
41
  });
15
42
 
16
43
  Text.displayName = 'Text';
@@ -1,9 +1,20 @@
1
1
  import { Platform } from 'react-native';
2
2
  import { cva, type VariantProps } from '@cdx-ui/utils';
3
+ import { CONTENT_COLOR } from '../../styles/constants';
4
+
5
+ const TEXT_WEIGHT = {
6
+ normal: 'font-normal',
7
+ medium: 'font-medium',
8
+ semibold: 'font-semibold',
9
+ bold: 'font-bold',
10
+ } as const;
11
+
12
+ const TEXT_ITALIC = {
13
+ true: 'italic',
14
+ } as const;
3
15
 
4
16
  export const textStyle = cva(
5
17
  [
6
- 'text-content-primary',
7
18
  Platform.select({
8
19
  web: 'font-body my-0 bg-transparent no-underline',
9
20
  default: '',
@@ -11,6 +22,7 @@ export const textStyle = cva(
11
22
  ],
12
23
  {
13
24
  variants: {
25
+ color: CONTENT_COLOR,
14
26
  size: {
15
27
  xl: 'body-xl',
16
28
  lg: 'body-lg',
@@ -18,8 +30,34 @@ export const textStyle = cva(
18
30
  sm: 'body-sm',
19
31
  xs: 'body-xs',
20
32
  },
33
+ weight: TEXT_WEIGHT,
34
+ italic: TEXT_ITALIC,
35
+ },
36
+ defaultVariants: {
37
+ color: 'primary',
38
+ size: 'md',
39
+ weight: 'normal',
21
40
  },
22
41
  },
23
42
  );
24
43
 
25
44
  export type TextVariantProps = VariantProps<typeof textStyle>;
45
+
46
+ // A `Text` inside another text element emits only the props it is given, with no
47
+ // base classes or defaults, so everything it omits inherits from the parent. Its
48
+ // sizes use the `-size` companions of the body styles, which leave the font
49
+ // family and weight to inherit too.
50
+ export const nestedTextStyle = cva([], {
51
+ variants: {
52
+ color: CONTENT_COLOR,
53
+ size: {
54
+ xl: 'body-xl-size',
55
+ lg: 'body-lg-size',
56
+ md: 'body-md-size',
57
+ sm: 'body-sm-size',
58
+ xs: 'body-xs-size',
59
+ } satisfies Record<NonNullable<TextVariantProps['size']>, string>,
60
+ weight: TEXT_WEIGHT,
61
+ italic: TEXT_ITALIC,
62
+ },
63
+ });
@@ -12,7 +12,6 @@ export function useButtonColor({
12
12
  color: ButtonProps['color'];
13
13
  toastColor: ToastColorInternal;
14
14
  }) {
15
- // TODO: Add toastActionVariants to styles.ts to restore color-aware action styling
16
15
  return useMemo(() => {
17
16
  if (color) return color;
18
17