@cdx-ui/components 0.1.7 → 0.2.0

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 (260) hide show
  1. package/coverage.svg +1 -1
  2. package/lib/commonjs/components/ColorArea/ColorAreaPaint.js +78 -0
  3. package/lib/commonjs/components/ColorArea/ColorAreaPaint.js.map +1 -0
  4. package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js +31 -0
  5. package/lib/commonjs/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
  6. package/lib/commonjs/components/ColorArea/index.js +57 -0
  7. package/lib/commonjs/components/ColorArea/index.js.map +1 -0
  8. package/lib/commonjs/components/ColorArea/styles.js +12 -0
  9. package/lib/commonjs/components/ColorArea/styles.js.map +1 -0
  10. package/lib/commonjs/components/ColorField/index.js +138 -0
  11. package/lib/commonjs/components/ColorField/index.js.map +1 -0
  12. package/lib/commonjs/components/ColorField/styles.js +14 -0
  13. package/lib/commonjs/components/ColorField/styles.js.map +1 -0
  14. package/lib/commonjs/components/ColorPicker/index.js +88 -0
  15. package/lib/commonjs/components/ColorPicker/index.js.map +1 -0
  16. package/lib/commonjs/components/ColorPicker/styles.js +22 -0
  17. package/lib/commonjs/components/ColorPicker/styles.js.map +1 -0
  18. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js +68 -0
  19. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
  20. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js +41 -0
  21. package/lib/commonjs/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
  22. package/lib/commonjs/components/ColorSlider/index.js +123 -0
  23. package/lib/commonjs/components/ColorSlider/index.js.map +1 -0
  24. package/lib/commonjs/components/ColorSlider/styles.js +50 -0
  25. package/lib/commonjs/components/ColorSlider/styles.js.map +1 -0
  26. package/lib/commonjs/components/ColorSwatch/index.js +54 -0
  27. package/lib/commonjs/components/ColorSwatch/index.js.map +1 -0
  28. package/lib/commonjs/components/ColorSwatch/styles.js +25 -0
  29. package/lib/commonjs/components/ColorSwatch/styles.js.map +1 -0
  30. package/lib/commonjs/components/ColorSwatchPicker/index.js +110 -0
  31. package/lib/commonjs/components/ColorSwatchPicker/index.js.map +1 -0
  32. package/lib/commonjs/components/ColorSwatchPicker/styles.js +17 -0
  33. package/lib/commonjs/components/ColorSwatchPicker/styles.js.map +1 -0
  34. package/lib/commonjs/components/Heading/styles.js +3 -0
  35. package/lib/commonjs/components/Heading/styles.js.map +1 -1
  36. package/lib/commonjs/components/Icon/index.js +27 -3
  37. package/lib/commonjs/components/Icon/index.js.map +1 -1
  38. package/lib/commonjs/components/Icon/styles.js +19 -0
  39. package/lib/commonjs/components/Icon/styles.js.map +1 -0
  40. package/lib/commonjs/components/Text/index.js +13 -4
  41. package/lib/commonjs/components/Text/index.js.map +1 -1
  42. package/lib/commonjs/components/Text/styles.js +39 -3
  43. package/lib/commonjs/components/Text/styles.js.map +1 -1
  44. package/lib/commonjs/components/Toast/hooks.js +0 -1
  45. package/lib/commonjs/components/Toast/hooks.js.map +1 -1
  46. package/lib/commonjs/components/Toast/index.js +9 -6
  47. package/lib/commonjs/components/Toast/index.js.map +1 -1
  48. package/lib/commonjs/components/Toast/styles.js +36 -19
  49. package/lib/commonjs/components/Toast/styles.js.map +1 -1
  50. package/lib/commonjs/components/ToggleButton/index.js +5 -4
  51. package/lib/commonjs/components/ToggleButton/index.js.map +1 -1
  52. package/lib/commonjs/components/index.js +68 -0
  53. package/lib/commonjs/components/index.js.map +1 -1
  54. package/lib/commonjs/components/picker/surfaces.js +9 -2
  55. package/lib/commonjs/components/picker/surfaces.js.map +1 -1
  56. package/lib/commonjs/figma/Icon.figma.js +30 -3
  57. package/lib/commonjs/figma/Icon.figma.js.map +1 -1
  58. package/lib/commonjs/figma/Text.figma.js +15 -1
  59. package/lib/commonjs/figma/Text.figma.js.map +1 -1
  60. package/lib/commonjs/providers/toast/insets-container.js +15 -3
  61. package/lib/commonjs/providers/toast/insets-container.js.map +1 -1
  62. package/lib/commonjs/providers/toast/provider.js +1 -0
  63. package/lib/commonjs/providers/toast/provider.js.map +1 -1
  64. package/lib/commonjs/styles/constants.js +14 -1
  65. package/lib/commonjs/styles/constants.js.map +1 -1
  66. package/lib/module/components/ColorArea/ColorAreaPaint.js +74 -0
  67. package/lib/module/components/ColorArea/ColorAreaPaint.js.map +1 -0
  68. package/lib/module/components/ColorArea/ColorAreaPaint.web.js +27 -0
  69. package/lib/module/components/ColorArea/ColorAreaPaint.web.js.map +1 -0
  70. package/lib/module/components/ColorArea/index.js +53 -0
  71. package/lib/module/components/ColorArea/index.js.map +1 -0
  72. package/lib/module/components/ColorArea/styles.js +8 -0
  73. package/lib/module/components/ColorArea/styles.js.map +1 -0
  74. package/lib/module/components/ColorField/index.js +134 -0
  75. package/lib/module/components/ColorField/index.js.map +1 -0
  76. package/lib/module/components/ColorField/styles.js +10 -0
  77. package/lib/module/components/ColorField/styles.js.map +1 -0
  78. package/lib/module/components/ColorPicker/index.js +79 -0
  79. package/lib/module/components/ColorPicker/index.js.map +1 -0
  80. package/lib/module/components/ColorPicker/styles.js +18 -0
  81. package/lib/module/components/ColorPicker/styles.js.map +1 -0
  82. package/lib/module/components/ColorSlider/ColorSliderRailPaint.js +64 -0
  83. package/lib/module/components/ColorSlider/ColorSliderRailPaint.js.map +1 -0
  84. package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js +37 -0
  85. package/lib/module/components/ColorSlider/ColorSliderRailPaint.web.js.map +1 -0
  86. package/lib/module/components/ColorSlider/index.js +119 -0
  87. package/lib/module/components/ColorSlider/index.js.map +1 -0
  88. package/lib/module/components/ColorSlider/styles.js +46 -0
  89. package/lib/module/components/ColorSlider/styles.js.map +1 -0
  90. package/lib/module/components/ColorSwatch/index.js +50 -0
  91. package/lib/module/components/ColorSwatch/index.js.map +1 -0
  92. package/lib/module/components/ColorSwatch/styles.js +21 -0
  93. package/lib/module/components/ColorSwatch/styles.js.map +1 -0
  94. package/lib/module/components/ColorSwatchPicker/index.js +106 -0
  95. package/lib/module/components/ColorSwatchPicker/index.js.map +1 -0
  96. package/lib/module/components/ColorSwatchPicker/styles.js +13 -0
  97. package/lib/module/components/ColorSwatchPicker/styles.js.map +1 -0
  98. package/lib/module/components/Heading/styles.js +3 -0
  99. package/lib/module/components/Heading/styles.js.map +1 -1
  100. package/lib/module/components/Icon/index.js +27 -3
  101. package/lib/module/components/Icon/index.js.map +1 -1
  102. package/lib/module/components/Icon/styles.js +16 -0
  103. package/lib/module/components/Icon/styles.js.map +1 -0
  104. package/lib/module/components/Text/index.js +14 -5
  105. package/lib/module/components/Text/index.js.map +1 -1
  106. package/lib/module/components/Text/styles.js +38 -2
  107. package/lib/module/components/Text/styles.js.map +1 -1
  108. package/lib/module/components/Toast/hooks.js +0 -1
  109. package/lib/module/components/Toast/hooks.js.map +1 -1
  110. package/lib/module/components/Toast/index.js +10 -7
  111. package/lib/module/components/Toast/index.js.map +1 -1
  112. package/lib/module/components/Toast/styles.js +35 -19
  113. package/lib/module/components/Toast/styles.js.map +1 -1
  114. package/lib/module/components/ToggleButton/index.js +3 -3
  115. package/lib/module/components/ToggleButton/index.js.map +1 -1
  116. package/lib/module/components/index.js +6 -0
  117. package/lib/module/components/index.js.map +1 -1
  118. package/lib/module/components/picker/surfaces.js +10 -3
  119. package/lib/module/components/picker/surfaces.js.map +1 -1
  120. package/lib/module/figma/Icon.figma.js +30 -3
  121. package/lib/module/figma/Icon.figma.js.map +1 -1
  122. package/lib/module/figma/Text.figma.js +15 -1
  123. package/lib/module/figma/Text.figma.js.map +1 -1
  124. package/lib/module/providers/toast/insets-container.js +15 -4
  125. package/lib/module/providers/toast/insets-container.js.map +1 -1
  126. package/lib/module/providers/toast/provider.js +2 -1
  127. package/lib/module/providers/toast/provider.js.map +1 -1
  128. package/lib/module/styles/constants.js +13 -0
  129. package/lib/module/styles/constants.js.map +1 -1
  130. package/lib/typescript/components/Alert/index.d.ts +1 -1
  131. package/lib/typescript/components/Alert/index.d.ts.map +1 -1
  132. package/lib/typescript/components/Avatar/index.d.ts +1 -1
  133. package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
  134. package/lib/typescript/components/Badge/styles.d.ts +3 -3
  135. package/lib/typescript/components/Breadcrumbs/styles.d.ts +1 -1
  136. package/lib/typescript/components/Button/index.d.ts +1 -1
  137. package/lib/typescript/components/Button/index.d.ts.map +1 -1
  138. package/lib/typescript/components/Button/styles.d.ts +4 -4
  139. package/lib/typescript/components/Checkbox/index.d.ts +1 -1
  140. package/lib/typescript/components/Checkbox/index.d.ts.map +1 -1
  141. package/lib/typescript/components/Chip/index.d.ts +1 -1
  142. package/lib/typescript/components/Chip/index.d.ts.map +1 -1
  143. package/lib/typescript/components/Chip/styles.d.ts +3 -3
  144. package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts +5 -0
  145. package/lib/typescript/components/ColorArea/ColorAreaPaint.d.ts.map +1 -0
  146. package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts +5 -0
  147. package/lib/typescript/components/ColorArea/ColorAreaPaint.web.d.ts.map +1 -0
  148. package/lib/typescript/components/ColorArea/index.d.ts +20 -0
  149. package/lib/typescript/components/ColorArea/index.d.ts.map +1 -0
  150. package/lib/typescript/components/ColorArea/styles.d.ts +4 -0
  151. package/lib/typescript/components/ColorArea/styles.d.ts.map +1 -0
  152. package/lib/typescript/components/ColorField/index.d.ts +41 -0
  153. package/lib/typescript/components/ColorField/index.d.ts.map +1 -0
  154. package/lib/typescript/components/ColorField/styles.d.ts +13 -0
  155. package/lib/typescript/components/ColorField/styles.d.ts.map +1 -0
  156. package/lib/typescript/components/ColorPicker/index.d.ts +28 -0
  157. package/lib/typescript/components/ColorPicker/index.d.ts.map +1 -0
  158. package/lib/typescript/components/ColorPicker/styles.d.ts +9 -0
  159. package/lib/typescript/components/ColorPicker/styles.d.ts.map +1 -0
  160. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts +5 -0
  161. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.d.ts.map +1 -0
  162. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts +5 -0
  163. package/lib/typescript/components/ColorSlider/ColorSliderRailPaint.web.d.ts.map +1 -0
  164. package/lib/typescript/components/ColorSlider/index.d.ts +33 -0
  165. package/lib/typescript/components/ColorSlider/index.d.ts.map +1 -0
  166. package/lib/typescript/components/ColorSlider/styles.d.ts +14 -0
  167. package/lib/typescript/components/ColorSlider/styles.d.ts.map +1 -0
  168. package/lib/typescript/components/ColorSwatch/index.d.ts +19 -0
  169. package/lib/typescript/components/ColorSwatch/index.d.ts.map +1 -0
  170. package/lib/typescript/components/ColorSwatch/styles.d.ts +7 -0
  171. package/lib/typescript/components/ColorSwatch/styles.d.ts.map +1 -0
  172. package/lib/typescript/components/ColorSwatchPicker/index.d.ts +37 -0
  173. package/lib/typescript/components/ColorSwatchPicker/index.d.ts.map +1 -0
  174. package/lib/typescript/components/ColorSwatchPicker/styles.d.ts +5 -0
  175. package/lib/typescript/components/ColorSwatchPicker/styles.d.ts.map +1 -0
  176. package/lib/typescript/components/Divider/index.d.ts +1 -1
  177. package/lib/typescript/components/Divider/index.d.ts.map +1 -1
  178. package/lib/typescript/components/Heading/styles.d.ts.map +1 -1
  179. package/lib/typescript/components/Icon/index.d.ts +14 -22
  180. package/lib/typescript/components/Icon/index.d.ts.map +1 -1
  181. package/lib/typescript/components/Icon/styles.d.ts +6 -0
  182. package/lib/typescript/components/Icon/styles.d.ts.map +1 -0
  183. package/lib/typescript/components/IconButton/styles.d.ts +2 -2
  184. package/lib/typescript/components/Input/index.d.ts +1 -1
  185. package/lib/typescript/components/Input/index.d.ts.map +1 -1
  186. package/lib/typescript/components/Link/index.d.ts +1 -1
  187. package/lib/typescript/components/Link/index.d.ts.map +1 -1
  188. package/lib/typescript/components/Menu/index.d.ts +2 -2
  189. package/lib/typescript/components/Menu/index.d.ts.map +1 -1
  190. package/lib/typescript/components/Select/index.d.ts +1 -1
  191. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  192. package/lib/typescript/components/Slider/styles.d.ts +3 -3
  193. package/lib/typescript/components/Text/index.d.ts +40 -3
  194. package/lib/typescript/components/Text/index.d.ts.map +1 -1
  195. package/lib/typescript/components/Text/styles.d.ts +9 -0
  196. package/lib/typescript/components/Text/styles.d.ts.map +1 -1
  197. package/lib/typescript/components/Toast/hooks.d.ts +1 -1
  198. package/lib/typescript/components/Toast/hooks.d.ts.map +1 -1
  199. package/lib/typescript/components/Toast/index.d.ts.map +1 -1
  200. package/lib/typescript/components/Toast/styles.d.ts +4 -0
  201. package/lib/typescript/components/Toast/styles.d.ts.map +1 -1
  202. package/lib/typescript/components/Toast/types.d.ts +1 -1
  203. package/lib/typescript/components/Toast/types.d.ts.map +1 -1
  204. package/lib/typescript/components/ToggleButton/index.d.ts +5 -3
  205. package/lib/typescript/components/ToggleButton/index.d.ts.map +1 -1
  206. package/lib/typescript/components/index.d.ts +6 -0
  207. package/lib/typescript/components/index.d.ts.map +1 -1
  208. package/lib/typescript/components/picker/surfaces.d.ts +5 -1
  209. package/lib/typescript/components/picker/surfaces.d.ts.map +1 -1
  210. package/lib/typescript/figma/Icon.figma.d.ts.map +1 -1
  211. package/lib/typescript/figma/Text.figma.d.ts.map +1 -1
  212. package/lib/typescript/providers/toast/insets-container.d.ts +12 -0
  213. package/lib/typescript/providers/toast/insets-container.d.ts.map +1 -1
  214. package/lib/typescript/providers/toast/types.d.ts +5 -0
  215. package/lib/typescript/providers/toast/types.d.ts.map +1 -1
  216. package/lib/typescript/styles/constants.d.ts +10 -0
  217. package/lib/typescript/styles/constants.d.ts.map +1 -1
  218. package/package.json +5 -5
  219. package/src/components/Alert/index.tsx +1 -1
  220. package/src/components/Avatar/index.tsx +1 -1
  221. package/src/components/Button/index.tsx +1 -1
  222. package/src/components/Checkbox/index.tsx +1 -1
  223. package/src/components/Chip/index.tsx +1 -1
  224. package/src/components/ColorArea/ColorAreaPaint.tsx +51 -0
  225. package/src/components/ColorArea/ColorAreaPaint.web.tsx +31 -0
  226. package/src/components/ColorArea/index.tsx +71 -0
  227. package/src/components/ColorArea/styles.ts +18 -0
  228. package/src/components/ColorField/index.tsx +181 -0
  229. package/src/components/ColorField/styles.ts +20 -0
  230. package/src/components/ColorPicker/index.tsx +110 -0
  231. package/src/components/ColorPicker/styles.ts +33 -0
  232. package/src/components/ColorSlider/ColorSliderRailPaint.tsx +60 -0
  233. package/src/components/ColorSlider/ColorSliderRailPaint.web.tsx +33 -0
  234. package/src/components/ColorSlider/index.tsx +147 -0
  235. package/src/components/ColorSlider/styles.ts +72 -0
  236. package/src/components/ColorSwatch/index.tsx +56 -0
  237. package/src/components/ColorSwatch/styles.ts +24 -0
  238. package/src/components/ColorSwatchPicker/index.tsx +150 -0
  239. package/src/components/ColorSwatchPicker/styles.ts +32 -0
  240. package/src/components/Divider/index.tsx +1 -1
  241. package/src/components/Heading/styles.ts +3 -0
  242. package/src/components/Icon/index.tsx +46 -6
  243. package/src/components/Icon/styles.ts +15 -0
  244. package/src/components/Input/index.tsx +1 -1
  245. package/src/components/Link/index.tsx +1 -1
  246. package/src/components/Menu/index.tsx +2 -2
  247. package/src/components/Select/index.tsx +1 -1
  248. package/src/components/Text/index.tsx +32 -5
  249. package/src/components/Text/styles.ts +39 -1
  250. package/src/components/Toast/hooks.ts +0 -1
  251. package/src/components/Toast/index.tsx +14 -8
  252. package/src/components/Toast/styles.ts +47 -19
  253. package/src/components/Toast/types.ts +1 -1
  254. package/src/components/ToggleButton/index.tsx +9 -7
  255. package/src/components/index.ts +6 -0
  256. package/src/components/picker/surfaces.tsx +15 -2
  257. package/src/providers/toast/insets-container.tsx +23 -9
  258. package/src/providers/toast/provider.tsx +2 -2
  259. package/src/providers/toast/types.ts +5 -0
  260. package/src/styles/constants.ts +13 -0
@@ -0,0 +1,147 @@
1
+ import { forwardRef, type ReactNode } from 'react';
2
+ import { Text, View, type PressableStateCallbackType, type TextProps } from 'react-native';
3
+ import {
4
+ ColorSliderRail as ColorSliderRailPrimitive,
5
+ ColorSliderRoot as ColorSliderRootPrimitive,
6
+ ColorSliderThumb as ColorSliderThumbPrimitive,
7
+ Slot,
8
+ dataAttributes,
9
+ mergeDataAttributes,
10
+ useColorSliderContext,
11
+ type IColorSliderProps,
12
+ type IColorSliderRailProps,
13
+ type IColorSliderThumbProps,
14
+ } from '@cdx-ui/primitives';
15
+ import { cn } from '@cdx-ui/utils';
16
+ import { ColorSliderRailPaint } from './ColorSliderRailPaint';
17
+ import {
18
+ colorSliderOutputVariants,
19
+ colorSliderRailVariants,
20
+ colorSliderThumbVariants,
21
+ colorSliderVariants,
22
+ } from './styles';
23
+
24
+ export type ColorSliderProps = IColorSliderProps & {
25
+ readonly asChild?: boolean;
26
+ readonly className?: string;
27
+ readonly children?: ReactNode;
28
+ };
29
+
30
+ const ColorSliderRoot = forwardRef<View, ColorSliderProps>(
31
+ ({ asChild, className, style, orientation = 'horizontal', children, ...props }, ref) => (
32
+ <ColorSliderRootPrimitive
33
+ ref={ref}
34
+ asChild={asChild}
35
+ className={cn(colorSliderVariants({ orientation }), className)}
36
+ style={style}
37
+ orientation={orientation}
38
+ {...props}
39
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider' }))}
40
+ >
41
+ {children}
42
+ </ColorSliderRootPrimitive>
43
+ ),
44
+ );
45
+
46
+ ColorSliderRoot.displayName = 'ColorSlider';
47
+
48
+ export interface ColorSliderRailProps extends IColorSliderRailProps {
49
+ readonly className?: string;
50
+ readonly children?: ReactNode;
51
+ }
52
+
53
+ const ColorSliderRail = forwardRef<View, ColorSliderRailProps>(
54
+ ({ asChild, className, style, hitSlop, children, ...props }, ref) => {
55
+ const { orientation, thumbSize } = useColorSliderContext();
56
+ const endCap =
57
+ orientation === 'vertical'
58
+ ? { top: thumbSize.height / 2, bottom: thumbSize.height / 2 }
59
+ : { left: thumbSize.width / 2, right: thumbSize.width / 2 };
60
+
61
+ return (
62
+ <ColorSliderRailPrimitive
63
+ ref={ref}
64
+ asChild={asChild}
65
+ className={cn(colorSliderRailVariants({ orientation }), className)}
66
+ style={style}
67
+ hitSlop={hitSlop ?? endCap}
68
+ {...props}
69
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-rail' }))}
70
+ >
71
+ <ColorSliderRailPaint />
72
+ {children}
73
+ </ColorSliderRailPrimitive>
74
+ );
75
+ },
76
+ );
77
+
78
+ ColorSliderRail.displayName = 'ColorSlider.Rail';
79
+
80
+ export interface ColorSliderThumbProps extends IColorSliderThumbProps {
81
+ readonly className?: string;
82
+ readonly children?: ReactNode;
83
+ }
84
+
85
+ const ColorSliderThumb = forwardRef<View, ColorSliderThumbProps>(
86
+ ({ className, style, children, ...props }, ref) => {
87
+ const { value } = useColorSliderContext();
88
+ const fillStyle = { backgroundColor: value.toString('hex') };
89
+
90
+ return (
91
+ <ColorSliderThumbPrimitive
92
+ ref={ref}
93
+ className={cn(colorSliderThumbVariants(), className)}
94
+ style={
95
+ typeof style === 'function'
96
+ ? (state: PressableStateCallbackType) => [fillStyle, style(state)]
97
+ : [fillStyle, style]
98
+ }
99
+ {...props}
100
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-thumb' }))}
101
+ >
102
+ {children}
103
+ </ColorSliderThumbPrimitive>
104
+ );
105
+ },
106
+ );
107
+
108
+ ColorSliderThumb.displayName = 'ColorSlider.Thumb';
109
+
110
+ export interface ColorSliderOutputProps extends TextProps {
111
+ readonly asChild?: boolean;
112
+ readonly className?: string;
113
+ readonly children?: ReactNode;
114
+ }
115
+
116
+ const ColorSliderOutput = forwardRef<Text, ColorSliderOutputProps>(
117
+ ({ asChild, className, style, children, ...props }, ref) => {
118
+ const { valueLabel } = useColorSliderContext();
119
+ const Comp = asChild ? Slot : Text;
120
+
121
+ return (
122
+ <Comp
123
+ ref={ref}
124
+ className={cn(colorSliderOutputVariants(), className)}
125
+ style={style}
126
+ {...props}
127
+ {...mergeDataAttributes(props, dataAttributes({ slot: 'color-slider-output' }))}
128
+ >
129
+ {children ?? valueLabel}
130
+ </Comp>
131
+ );
132
+ },
133
+ );
134
+
135
+ ColorSliderOutput.displayName = 'ColorSlider.Output';
136
+
137
+ type ColorSliderCompoundComponent = typeof ColorSliderRoot & {
138
+ Rail: typeof ColorSliderRail;
139
+ Thumb: typeof ColorSliderThumb;
140
+ Output: typeof ColorSliderOutput;
141
+ };
142
+
143
+ export const ColorSlider = Object.assign(ColorSliderRoot, {
144
+ Rail: ColorSliderRail,
145
+ Thumb: ColorSliderThumb,
146
+ Output: ColorSliderOutput,
147
+ }) as ColorSliderCompoundComponent;
@@ -0,0 +1,72 @@
1
+ import { Platform } from 'react-native';
2
+ import { cva, type VariantProps } from '@cdx-ui/utils';
3
+ import { DISABLED_CURSOR } from '../../styles/constants';
4
+
5
+ export const colorSliderVariants = cva(
6
+ [
7
+ 'relative select-none',
8
+ 'data-[disabled=true]:opacity-[var(--opacity-disabled)]',
9
+ DISABLED_CURSOR,
10
+ ],
11
+ {
12
+ variants: {
13
+ orientation: {
14
+ horizontal: 'w-full',
15
+ vertical: 'h-48',
16
+ },
17
+ },
18
+ defaultVariants: {
19
+ orientation: 'horizontal',
20
+ },
21
+ },
22
+ );
23
+
24
+ // The rail inset equals the `size-5` thumb's radius so the thumb sits flush inside the pill ends.
25
+ export const colorSliderRailVariants = cva(['relative touch-none'], {
26
+ variants: {
27
+ orientation: {
28
+ horizontal: 'mx-2.5 h-5 w-auto',
29
+ vertical: 'my-2.5 w-5 flex-1',
30
+ },
31
+ },
32
+ defaultVariants: {
33
+ orientation: 'horizontal',
34
+ },
35
+ });
36
+
37
+ export const colorSliderRailPaintVariants = cva(
38
+ ['absolute overflow-hidden rounded-[var(--border-radius-round)]'],
39
+ {
40
+ variants: {
41
+ orientation: {
42
+ horizontal: '-inset-x-2.5 inset-y-0',
43
+ vertical: '-inset-y-2.5 inset-x-0',
44
+ },
45
+ },
46
+ defaultVariants: {
47
+ orientation: 'horizontal',
48
+ },
49
+ },
50
+ );
51
+
52
+ export const colorSliderThumbVariants = cva([
53
+ 'z-2 box-border size-5 rounded-[var(--border-radius-round)]',
54
+ 'border-2 border-surface-primary shadow-md',
55
+ 'transition-[transform,box-shadow,opacity] duration-150',
56
+ 'data-[dragging=true]:transition-none',
57
+ 'web:outline-none web:active:cursor-grabbing',
58
+ Platform.select({
59
+ default: 'data-[focus=true]:scale-105',
60
+ web: [
61
+ 'web:cursor-grab',
62
+ 'data-[hover=true]:scale-110',
63
+ 'data-[dragging=true]:scale-110',
64
+ 'data-[focus-visible=true]:ring-4',
65
+ 'data-[focus-visible=true]:ring-stroke-focus',
66
+ ].join(' '),
67
+ }),
68
+ ]);
69
+
70
+ export const colorSliderOutputVariants = cva(['text-sm font-medium text-content-primary']);
71
+
72
+ export type ColorSliderVariantProps = VariantProps<typeof colorSliderVariants>;
@@ -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)]');
@@ -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;
@@ -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