@kanso-labs/react-native-kanso-ui 0.8.0 → 0.10.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 (253) hide show
  1. package/README.md +4 -3
  2. package/dist/autocomplete/index.js +15 -1
  3. package/dist/autocomplete/index.js.map +1 -1
  4. package/dist/badge/index.js +9 -70
  5. package/dist/badge/index.js.map +1 -1
  6. package/dist/button/group.d.ts +5 -0
  7. package/dist/button/group.js +115 -0
  8. package/dist/button/group.js.map +1 -0
  9. package/dist/button/index.d.ts +4 -1
  10. package/dist/button/index.js +45 -23
  11. package/dist/button/index.js.map +1 -1
  12. package/dist/button/palettes.d.ts +2 -0
  13. package/dist/button/slots.js +2 -1
  14. package/dist/button/slots.js.map +1 -1
  15. package/dist/calendar/index.js +351 -182
  16. package/dist/calendar/index.js.map +1 -1
  17. package/dist/calendar/styles.js +33 -2
  18. package/dist/calendar/styles.js.map +1 -1
  19. package/dist/carousel/arrangement.d.ts +5 -0
  20. package/dist/carousel/arrangement.js +123 -0
  21. package/dist/carousel/arrangement.js.map +1 -0
  22. package/dist/chequer/index.js +95 -0
  23. package/dist/chequer/index.js.map +1 -0
  24. package/dist/collection/index.d.ts +157 -0
  25. package/dist/collection/index.js +1331 -0
  26. package/dist/collection/index.js.map +1 -0
  27. package/dist/color-thumb/index.js +56 -0
  28. package/dist/color-thumb/index.js.map +1 -0
  29. package/dist/components/badge/index.d.ts +48 -0
  30. package/dist/components/badge/index.js +122 -0
  31. package/dist/components/badge/index.js.map +1 -0
  32. package/dist/{badge → components/badge}/styles.js +10 -6
  33. package/dist/components/badge/styles.js.map +1 -0
  34. package/dist/components/breadcrumbs/index.d.ts +66 -0
  35. package/dist/components/breadcrumbs/index.js +285 -0
  36. package/dist/components/breadcrumbs/index.js.map +1 -0
  37. package/dist/components/button/index.d.ts +4 -2
  38. package/dist/components/button/index.js +227 -188
  39. package/dist/components/button/index.js.map +1 -1
  40. package/dist/components/button-group/index.d.ts +87 -0
  41. package/dist/components/button-group/index.js +275 -0
  42. package/dist/components/button-group/index.js.map +1 -0
  43. package/dist/components/calendar/index.d.ts +11 -3
  44. package/dist/components/calendar/index.js +60 -45
  45. package/dist/components/calendar/index.js.map +1 -1
  46. package/dist/components/carousel/index.d.ts +72 -0
  47. package/dist/components/carousel/index.js +496 -0
  48. package/dist/components/carousel/index.js.map +1 -0
  49. package/dist/components/checkbox/index.d.ts +7 -1
  50. package/dist/components/checkbox/index.js +183 -138
  51. package/dist/components/checkbox/index.js.map +1 -1
  52. package/dist/components/checkbox-group/index.d.ts +92 -0
  53. package/dist/components/checkbox-group/index.js +306 -0
  54. package/dist/components/checkbox-group/index.js.map +1 -0
  55. package/dist/components/code/index.d.ts +25 -0
  56. package/dist/components/code/index.js +87 -0
  57. package/dist/components/code/index.js.map +1 -0
  58. package/dist/components/color-area/index.d.ts +85 -0
  59. package/dist/components/color-area/index.js +630 -0
  60. package/dist/components/color-area/index.js.map +1 -0
  61. package/dist/components/color-field/index.d.ts +144 -0
  62. package/dist/components/color-field/index.js +516 -0
  63. package/dist/components/color-field/index.js.map +1 -0
  64. package/dist/components/color-picker/index.d.ts +74 -0
  65. package/dist/components/color-picker/index.js +317 -0
  66. package/dist/components/color-picker/index.js.map +1 -0
  67. package/dist/components/color-slider/index.d.ts +82 -0
  68. package/dist/components/color-slider/index.js +456 -0
  69. package/dist/components/color-slider/index.js.map +1 -0
  70. package/dist/components/color-swatch/index.d.ts +46 -0
  71. package/dist/components/color-swatch/index.js +127 -0
  72. package/dist/components/color-swatch/index.js.map +1 -0
  73. package/dist/components/color-swatch-picker/index.d.ts +81 -0
  74. package/dist/components/color-swatch-picker/index.js +287 -0
  75. package/dist/components/color-swatch-picker/index.js.map +1 -0
  76. package/dist/components/color-wheel/index.d.ts +71 -0
  77. package/dist/components/color-wheel/index.js +407 -0
  78. package/dist/components/color-wheel/index.js.map +1 -0
  79. package/dist/components/combo-box/index.d.ts +193 -0
  80. package/dist/components/combo-box/index.js +616 -0
  81. package/dist/components/combo-box/index.js.map +1 -0
  82. package/dist/components/container/index.d.ts +47 -0
  83. package/dist/components/container/index.js +85 -0
  84. package/dist/components/container/index.js.map +1 -0
  85. package/dist/components/date-field/index.d.ts +120 -0
  86. package/dist/components/date-field/index.js +111 -0
  87. package/dist/components/date-field/index.js.map +1 -0
  88. package/dist/components/date-picker/index.d.ts +130 -0
  89. package/dist/components/date-picker/index.js +310 -0
  90. package/dist/components/date-picker/index.js.map +1 -0
  91. package/dist/components/date-range-picker/index.d.ts +139 -0
  92. package/dist/components/date-range-picker/index.js +421 -0
  93. package/dist/components/date-range-picker/index.js.map +1 -0
  94. package/dist/components/disclosure/index.d.ts +94 -0
  95. package/dist/components/disclosure/index.js +365 -0
  96. package/dist/components/disclosure/index.js.map +1 -0
  97. package/dist/components/disclosure-group/index.d.ts +61 -0
  98. package/dist/components/disclosure-group/index.js +100 -0
  99. package/dist/components/disclosure-group/index.js.map +1 -0
  100. package/dist/components/drop-zone/index.d.ts +113 -0
  101. package/dist/components/drop-zone/index.js +304 -0
  102. package/dist/components/drop-zone/index.js.map +1 -0
  103. package/dist/components/fab/index.d.ts +80 -0
  104. package/dist/components/fab/index.js +246 -0
  105. package/dist/components/fab/index.js.map +1 -0
  106. package/dist/components/fab-menu/index.d.ts +120 -0
  107. package/dist/components/fab-menu/index.js +640 -0
  108. package/dist/components/fab-menu/index.js.map +1 -0
  109. package/dist/components/feed/index.d.ts +57 -0
  110. package/dist/components/feed/index.js +167 -0
  111. package/dist/components/feed/index.js.map +1 -0
  112. package/dist/components/form/index.d.ts +3 -2
  113. package/dist/components/form/index.js.map +1 -1
  114. package/dist/components/icon-button/index.d.ts +4 -2
  115. package/dist/components/icon-button/index.js +204 -171
  116. package/dist/components/icon-button/index.js.map +1 -1
  117. package/dist/components/keycap/index.d.ts +27 -0
  118. package/dist/components/keycap/index.js +136 -0
  119. package/dist/components/keycap/index.js.map +1 -0
  120. package/dist/components/list/index.d.ts +15 -158
  121. package/dist/components/list/index.js +21 -1047
  122. package/dist/components/list/index.js.map +1 -1
  123. package/dist/components/list-box/index.d.ts +73 -0
  124. package/dist/components/list-box/index.js +82 -0
  125. package/dist/components/list-box/index.js.map +1 -0
  126. package/dist/components/loading-indicator/index.d.ts +32 -0
  127. package/dist/components/loading-indicator/index.js +174 -0
  128. package/dist/components/loading-indicator/index.js.map +1 -0
  129. package/dist/components/menu/index.js +1 -1
  130. package/dist/components/navigation-tree/index.d.ts +117 -0
  131. package/dist/components/navigation-tree/index.js +135 -0
  132. package/dist/components/navigation-tree/index.js.map +1 -0
  133. package/dist/components/number-field/index.js +132 -143
  134. package/dist/components/number-field/index.js.map +1 -1
  135. package/dist/components/range-calendar/index.d.ts +69 -0
  136. package/dist/components/range-calendar/index.js +144 -0
  137. package/dist/components/range-calendar/index.js.map +1 -0
  138. package/dist/components/search-view/index.d.ts +78 -0
  139. package/dist/components/search-view/index.js +570 -0
  140. package/dist/components/search-view/index.js.map +1 -0
  141. package/dist/components/select/index.d.ts +152 -0
  142. package/dist/components/select/index.js +419 -0
  143. package/dist/components/select/index.js.map +1 -0
  144. package/dist/components/separator/index.d.ts +3 -2
  145. package/dist/components/separator/index.js +29 -26
  146. package/dist/components/separator/index.js.map +1 -1
  147. package/dist/components/slider/index.d.ts +111 -0
  148. package/dist/components/slider/index.js +673 -0
  149. package/dist/components/slider/index.js.map +1 -0
  150. package/dist/components/split-button/index.d.ts +77 -0
  151. package/dist/components/split-button/index.js +354 -0
  152. package/dist/components/split-button/index.js.map +1 -0
  153. package/dist/components/supporting-pane/index.d.ts +44 -0
  154. package/dist/components/supporting-pane/index.js +109 -0
  155. package/dist/components/supporting-pane/index.js.map +1 -0
  156. package/dist/components/tabs/index.d.ts +196 -0
  157. package/dist/components/tabs/index.js +1137 -0
  158. package/dist/components/tabs/index.js.map +1 -0
  159. package/dist/components/text/index.d.ts +1 -1
  160. package/dist/components/text/index.js +49 -21
  161. package/dist/components/text/index.js.map +1 -1
  162. package/dist/components/text-area/index.d.ts +145 -0
  163. package/dist/components/text-area/index.js +231 -0
  164. package/dist/components/text-area/index.js.map +1 -0
  165. package/dist/components/time-field/index.d.ts +43 -0
  166. package/dist/components/time-field/index.js +107 -0
  167. package/dist/components/time-field/index.js.map +1 -0
  168. package/dist/components/time-picker/index.d.ts +65 -0
  169. package/dist/components/time-picker/index.js +1168 -0
  170. package/dist/components/time-picker/index.js.map +1 -0
  171. package/dist/components/toolbar/index.d.ts +53 -0
  172. package/dist/components/toolbar/index.js +185 -0
  173. package/dist/components/toolbar/index.js.map +1 -0
  174. package/dist/components/tooltip/index.d.ts +101 -0
  175. package/dist/components/tooltip/index.js +223 -0
  176. package/dist/components/tooltip/index.js.map +1 -0
  177. package/dist/components/tree/index.d.ts +112 -0
  178. package/dist/components/tree/index.js +157 -0
  179. package/dist/components/tree/index.js.map +1 -0
  180. package/dist/control/group.js +23 -0
  181. package/dist/control/group.js.map +1 -0
  182. package/dist/disclosure/chevron.js +75 -0
  183. package/dist/disclosure/chevron.js.map +1 -0
  184. package/dist/disclosure/index.js +7 -0
  185. package/dist/disclosure/index.js.map +1 -0
  186. package/dist/drop/index.d.ts +54 -0
  187. package/dist/drop/index.js +161 -0
  188. package/dist/drop/index.js.map +1 -0
  189. package/dist/fab/index.d.ts +19 -0
  190. package/dist/fab/index.js +147 -0
  191. package/dist/fab/index.js.map +1 -0
  192. package/dist/field/chevron.js +74 -0
  193. package/dist/field/chevron.js.map +1 -0
  194. package/dist/field/index.d.ts +2 -1
  195. package/dist/field/index.js +350 -153
  196. package/dist/field/index.js.map +1 -1
  197. package/dist/field/styles.js +27 -0
  198. package/dist/field/styles.js.map +1 -1
  199. package/dist/files/index.d.ts +18 -0
  200. package/dist/files/index.js +107 -0
  201. package/dist/files/index.js.map +1 -0
  202. package/dist/form/index.d.ts +6 -4
  203. package/dist/form/index.js +64 -85
  204. package/dist/form/index.js.map +1 -1
  205. package/dist/glyphs/index.js +92 -1
  206. package/dist/glyphs/index.js.map +1 -1
  207. package/dist/i18n/index.js +20 -1
  208. package/dist/i18n/index.js.map +1 -1
  209. package/dist/i18n/messages.js +1394 -34
  210. package/dist/i18n/messages.js.map +1 -1
  211. package/dist/index.d.ts +51 -6
  212. package/dist/index.js +47 -4
  213. package/dist/indicator/paths.js +23 -1
  214. package/dist/indicator/paths.js.map +1 -1
  215. package/dist/modal/index.js +96 -68
  216. package/dist/modal/index.js.map +1 -1
  217. package/dist/navigation/index.js +8 -5
  218. package/dist/navigation/index.js.map +1 -1
  219. package/dist/number/keyboard.js +16 -0
  220. package/dist/number/keyboard.js.map +1 -0
  221. package/dist/overlay/anchored.js +68 -38
  222. package/dist/overlay/anchored.js.map +1 -1
  223. package/dist/overlay/keyboard.js +57 -0
  224. package/dist/overlay/keyboard.js.map +1 -0
  225. package/dist/overlay/panel.js +173 -19
  226. package/dist/overlay/panel.js.map +1 -1
  227. package/dist/overlay/placement.js +16 -2
  228. package/dist/overlay/placement.js.map +1 -1
  229. package/dist/picker/index.js +322 -0
  230. package/dist/picker/index.js.map +1 -0
  231. package/dist/press/index.d.ts +2 -0
  232. package/dist/press/index.js +102 -100
  233. package/dist/press/index.js.map +1 -1
  234. package/dist/row/index.js +77 -69
  235. package/dist/row/index.js.map +1 -1
  236. package/dist/row/styles.js +13 -2
  237. package/dist/row/styles.js.map +1 -1
  238. package/dist/segments/field.js +277 -0
  239. package/dist/segments/field.js.map +1 -0
  240. package/dist/segments/index.js +574 -0
  241. package/dist/segments/index.js.map +1 -0
  242. package/dist/segments/styles.js +24 -0
  243. package/dist/segments/styles.js.map +1 -0
  244. package/dist/separator/index.js +7 -0
  245. package/dist/separator/index.js.map +1 -0
  246. package/dist/slider/index.js +145 -0
  247. package/dist/slider/index.js.map +1 -0
  248. package/dist/swatch/index.js +56 -0
  249. package/dist/swatch/index.js.map +1 -0
  250. package/dist/typography/size.js +14 -0
  251. package/dist/typography/size.js.map +1 -0
  252. package/package.json +11 -2
  253. package/dist/badge/styles.js.map +0 -1
@@ -0,0 +1,317 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { hitSlop, usePressFeedback } from "../../press/index.js";
4
+ import { useTypeRole } from "../../typography/roles.js";
5
+ import { withOpacity } from "../../theme/color.js";
6
+ import { useLocaleOf, useMessages } from "../../i18n/provider.js";
7
+ import { refsOf } from "../../ref/index.js";
8
+ import { PickedColorContext, colorNameOf } from "../../swatch/index.js";
9
+ import { ColorArea } from "../color-area/index.js";
10
+ import { ColorField } from "../color-field/index.js";
11
+ import { PickerPopup } from "../../picker/index.js";
12
+ import { ColorSlider } from "../color-slider/index.js";
13
+ import { ColorSwatch } from "../color-swatch/index.js";
14
+ import { c } from "react/compiler-runtime";
15
+ import { Pressable, StyleSheet, Text, View } from "react-native";
16
+ import { useRef, useState } from "react";
17
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
18
+ import { parseColor } from "react-stately";
19
+ import { useColorPickerState } from "react-stately/useColorPickerState";
20
+ import { useOverlayTriggerState } from "react-stately/useOverlayTriggerState";
21
+ //#region src/components/color-picker/index.tsx
22
+ const SWATCH = 24;
23
+ const SURFACE_WIDTH = 280;
24
+ const CHANNELS = parseColor("hsl(0, 0%, 0%)");
25
+ const stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) => StyleSheet.create({
26
+ body: {
27
+ boxSizing: "border-box",
28
+ gap: spacing.md,
29
+ maxWidth: "100%",
30
+ padding: spacing.lg,
31
+ width: SURFACE_WIDTH
32
+ },
33
+ disabled: { backgroundColor: withOpacity(colors.onSurface, stateLayerOpacity.disabledContainer) },
34
+ swatch: {
35
+ height: SWATCH,
36
+ width: SWATCH
37
+ },
38
+ trigger: {
39
+ alignItems: "center",
40
+ alignSelf: "flex-start",
41
+ backgroundColor: colors.surfaceContainerLow,
42
+ borderRadius: radii.pill,
43
+ boxSizing: "border-box",
44
+ flexDirection: "row",
45
+ gap: spacing.sm,
46
+ paddingHorizontal: spacing.md,
47
+ paddingVertical: spacing.sm
48
+ }
49
+ }));
50
+ /**
51
+ * A colour picked from a plane, a hue slider and a hex field, behind a
52
+ * trigger showing the colour. Pass `value` with `onChange` to control it, or
53
+ * `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,
54
+ * which this package re-exports.
55
+ *
56
+ * ```tsx
57
+ * <ColorPicker defaultValue="#6750A4" label="Label" />
58
+ * ```
59
+ *
60
+ * `alpha` adds the transparency slider. From the medium window size up the
61
+ * surface is docked under the trigger; below it, it opens centred over a
62
+ * scrim, as a date picker's does. `defaultOpen`, `isOpen` and `onOpenChange`
63
+ * reach the surface.
64
+ *
65
+ * Every part on the surface is this package's own, `ColorArea`,
66
+ * `ColorSlider` and `ColorField`, and they share the picker's value rather
67
+ * than taking it as props. Passing `children` replaces all of them, and a
68
+ * `ColorArea`, `ColorField`, `ColorSlider`, `ColorSwatch`,
69
+ * `ColorSwatchPicker` or `ColorWheel` among them takes the picker's value
70
+ * where it is given none of its own.
71
+ *
72
+ * `style`, `ref` and `testID` land on the trigger, which is what a layout
73
+ * places.
74
+ */
75
+ function ColorPicker(t0) {
76
+ const $ = c(68);
77
+ const { alpha: t1, children, defaultOpen, defaultValue, isDisabled: t2, isOpen, label, onChange, onOpenChange, ref, style, testID, value } = t0;
78
+ const alpha = t1 === void 0 ? false : t1;
79
+ const isDisabled = t2 === void 0 ? false : t2;
80
+ const theme = useTheme();
81
+ const { colors, radii, spacing, stateLayerOpacity } = theme;
82
+ const styles = stylesOf(theme);
83
+ const locale = useLocaleOf(void 0);
84
+ const messages = useMessages();
85
+ const labelRole = useTypeRole("labelLarge");
86
+ let t3;
87
+ if ($[0] !== defaultValue || $[1] !== onChange || $[2] !== value) {
88
+ t3 = {
89
+ defaultValue,
90
+ onChange,
91
+ value
92
+ };
93
+ $[0] = defaultValue;
94
+ $[1] = onChange;
95
+ $[2] = value;
96
+ $[3] = t3;
97
+ } else t3 = $[3];
98
+ const state = useColorPickerState(t3);
99
+ let t4;
100
+ if ($[4] !== defaultOpen || $[5] !== isOpen || $[6] !== onOpenChange) {
101
+ t4 = {
102
+ defaultOpen,
103
+ isOpen,
104
+ onOpenChange
105
+ };
106
+ $[4] = defaultOpen;
107
+ $[5] = isOpen;
108
+ $[6] = onOpenChange;
109
+ $[7] = t4;
110
+ } else t4 = $[7];
111
+ const overlay = useOverlayTriggerState(t4);
112
+ const { close, open: show } = overlay;
113
+ const anchor = useRef(null);
114
+ const [trigger, setTrigger] = useState(null);
115
+ let t5;
116
+ if ($[8] !== radii.pill) {
117
+ t5 = { borderRadius: radii.pill };
118
+ $[8] = radii.pill;
119
+ $[9] = t5;
120
+ } else t5 = $[9];
121
+ let t6;
122
+ if ($[10] !== colors.onSurface || $[11] !== isDisabled || $[12] !== t5) {
123
+ t6 = {
124
+ color: colors.onSurface,
125
+ corners: t5,
126
+ disabled: isDisabled
127
+ };
128
+ $[10] = colors.onSurface;
129
+ $[11] = isDisabled;
130
+ $[12] = t5;
131
+ $[13] = t6;
132
+ } else t6 = $[13];
133
+ const feedback = usePressFeedback(t6);
134
+ let t7;
135
+ if ($[14] !== locale || $[15] !== messages.transparent || $[16] !== state.color) {
136
+ t7 = colorNameOf(state.color, locale, messages.transparent);
137
+ $[14] = locale;
138
+ $[15] = messages.transparent;
139
+ $[16] = state.color;
140
+ $[17] = t7;
141
+ } else t7 = $[17];
142
+ const name = t7;
143
+ const T0 = Pressable;
144
+ const t8 = feedback.handlers;
145
+ const t9 = overlay.isOpen;
146
+ const t10 = `${label}, ${name}`;
147
+ const t11 = SWATCH + 2 * spacing.sm;
148
+ let t12;
149
+ if ($[18] !== t11) {
150
+ t12 = hitSlop(t11);
151
+ $[18] = t11;
152
+ $[19] = t12;
153
+ } else t12 = $[19];
154
+ let t13;
155
+ if ($[20] !== ref) {
156
+ t13 = refsOf(ref, anchor, setTrigger);
157
+ $[20] = ref;
158
+ $[21] = t13;
159
+ } else t13 = $[21];
160
+ const t14 = "button";
161
+ const t15 = composeStyles(styles.trigger, isDisabled ? styles.disabled : void 0, feedback.ring, style);
162
+ const t16 = feedback.layer;
163
+ let t17;
164
+ if ($[22] !== state.color || $[23] !== styles.swatch) {
165
+ t17 = /* @__PURE__ */ jsx(ColorSwatch, {
166
+ color: state.color,
167
+ style: styles.swatch
168
+ });
169
+ $[22] = state.color;
170
+ $[23] = styles.swatch;
171
+ $[24] = t17;
172
+ } else t17 = $[24];
173
+ let t18;
174
+ if ($[25] !== colors.onSurface || $[26] !== isDisabled || $[27] !== labelRole || $[28] !== stateLayerOpacity) {
175
+ t18 = composeStyles(labelRole, { color: isDisabled ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent) : colors.onSurface });
176
+ $[25] = colors.onSurface;
177
+ $[26] = isDisabled;
178
+ $[27] = labelRole;
179
+ $[28] = stateLayerOpacity;
180
+ $[29] = t18;
181
+ } else t18 = $[29];
182
+ let t19;
183
+ if ($[30] !== label || $[31] !== t18) {
184
+ t19 = /* @__PURE__ */ jsx(Text, {
185
+ style: t18,
186
+ children: label
187
+ });
188
+ $[30] = label;
189
+ $[31] = t18;
190
+ $[32] = t19;
191
+ } else t19 = $[32];
192
+ let t20;
193
+ if ($[33] !== T0 || $[34] !== feedback.handlers || $[35] !== feedback.layer || $[36] !== isDisabled || $[37] !== overlay.isOpen || $[38] !== show || $[39] !== t10 || $[40] !== t12 || $[41] !== t13 || $[42] !== t15 || $[43] !== t17 || $[44] !== t19 || $[45] !== testID) {
194
+ t20 = /* @__PURE__ */ jsxs(T0, {
195
+ ...t8,
196
+ "aria-expanded": t9,
197
+ "aria-label": t10,
198
+ disabled: isDisabled,
199
+ hitSlop: t12,
200
+ onPress: show,
201
+ ref: t13,
202
+ role: t14,
203
+ style: t15,
204
+ testID,
205
+ children: [
206
+ t16,
207
+ t17,
208
+ t19
209
+ ]
210
+ });
211
+ $[33] = T0;
212
+ $[34] = feedback.handlers;
213
+ $[35] = feedback.layer;
214
+ $[36] = isDisabled;
215
+ $[37] = overlay.isOpen;
216
+ $[38] = show;
217
+ $[39] = t10;
218
+ $[40] = t12;
219
+ $[41] = t13;
220
+ $[42] = t15;
221
+ $[43] = t17;
222
+ $[44] = t19;
223
+ $[45] = testID;
224
+ $[46] = t20;
225
+ } else t20 = $[46];
226
+ const t21 = overlay.isOpen;
227
+ let t22;
228
+ if ($[47] !== state) {
229
+ t22 = pickedOf(state);
230
+ $[47] = state;
231
+ $[48] = t22;
232
+ } else t22 = $[48];
233
+ let t23;
234
+ if ($[49] !== alpha || $[50] !== children || $[51] !== isDisabled || $[52] !== label || $[53] !== locale || $[54] !== styles.body) {
235
+ t23 = children ?? /* @__PURE__ */ jsxs(View, {
236
+ style: styles.body,
237
+ children: [
238
+ /* @__PURE__ */ jsx(ColorArea, {
239
+ "aria-label": label,
240
+ colorSpace: "hsl",
241
+ isDisabled,
242
+ xChannel: "saturation",
243
+ yChannel: "lightness"
244
+ }),
245
+ /* @__PURE__ */ jsx(ColorSlider, {
246
+ channel: "hue",
247
+ colorSpace: "hsl",
248
+ isDisabled,
249
+ label: CHANNELS.getChannelName("hue", locale)
250
+ }),
251
+ alpha ? /* @__PURE__ */ jsx(ColorSlider, {
252
+ channel: "alpha",
253
+ isDisabled,
254
+ label: CHANNELS.getChannelName("alpha", locale)
255
+ }) : null,
256
+ /* @__PURE__ */ jsx(ColorField, {
257
+ isDisabled,
258
+ label
259
+ })
260
+ ]
261
+ });
262
+ $[49] = alpha;
263
+ $[50] = children;
264
+ $[51] = isDisabled;
265
+ $[52] = label;
266
+ $[53] = locale;
267
+ $[54] = styles.body;
268
+ $[55] = t23;
269
+ } else t23 = $[55];
270
+ let t24;
271
+ if ($[56] !== t22 || $[57] !== t23) {
272
+ t24 = /* @__PURE__ */ jsx(PickedColorContext, {
273
+ value: t22,
274
+ children: t23
275
+ });
276
+ $[56] = t22;
277
+ $[57] = t23;
278
+ $[58] = t24;
279
+ } else t24 = $[58];
280
+ let t25;
281
+ if ($[59] !== close || $[60] !== label || $[61] !== overlay.isOpen || $[62] !== t24 || $[63] !== trigger) {
282
+ t25 = /* @__PURE__ */ jsx(PickerPopup, {
283
+ anchor,
284
+ close,
285
+ isOpen: t21,
286
+ label,
287
+ trigger,
288
+ children: t24
289
+ });
290
+ $[59] = close;
291
+ $[60] = label;
292
+ $[61] = overlay.isOpen;
293
+ $[62] = t24;
294
+ $[63] = trigger;
295
+ $[64] = t25;
296
+ } else t25 = $[64];
297
+ let t26;
298
+ if ($[65] !== t20 || $[66] !== t25) {
299
+ t26 = /* @__PURE__ */ jsxs(Fragment$1, { children: [t20, t25] });
300
+ $[65] = t20;
301
+ $[66] = t25;
302
+ $[67] = t26;
303
+ } else t26 = $[67];
304
+ return t26;
305
+ }
306
+ function pickedOf(state) {
307
+ return {
308
+ onChange: (color) => {
309
+ state.setColor(color);
310
+ },
311
+ value: state.color
312
+ };
313
+ }
314
+ //#endregion
315
+ export { ColorPicker };
316
+
317
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ComponentRef","ReactNode","Ref","HostInstance","StyleProp","TextStyle","View","ViewStyle","Color","ColorPickerState","useRef","useState","NativeView","Pressable","StyleSheet","Text","parseColor","useColorPickerState","useOverlayTriggerState","PickedColor","useLocaleOf","useMessages","PickerPopup","hitSlop","usePressFeedback","refsOf","colorNameOf","PickedColorContext","withOpacity","useTheme","composeStyles","themedStyles","useTypeRole","ColorArea","ColorField","ColorSlider","ColorSwatch","SWATCH","SURFACE_WIDTH","CHANNELS","stylesOf","colors","radii","spacing","stateLayerOpacity","create","body","boxSizing","gap","md","maxWidth","padding","lg","width","disabled","backgroundColor","onSurface","disabledContainer","swatch","height","trigger","alignItems","alignSelf","surfaceContainerLow","borderRadius","pill","flexDirection","sm","paddingHorizontal","paddingVertical","ColorPickerProps","alpha","children","defaultOpen","defaultValue","isDisabled","isOpen","label","onChange","value","onOpenChange","ref","style","testID","ColorPicker","t0","$","_c","t1","t2","undefined","theme","styles","locale","messages","labelRole","t3","state","t4","overlay","close","open","show","anchor","setTrigger","t5","t6","color","corners","feedback","t7","transparent","name","T0","t8","handlers","t9","t10","t11","t12","t13","t14","t15","ring","t16","layer","t17","t18","disabledContent","t19","t20","t21","t22","pickedOf","t23","getChannelName","t24","t25","t26","setColor","_c","NativeView"],"sources":["../../../src/components/color-picker/index.tsx"],"sourcesContent":["import type { ComponentRef, ReactNode, Ref } from 'react'\nimport type {\n HostInstance,\n StyleProp,\n TextStyle,\n View,\n ViewStyle,\n} from 'react-native'\nimport type { Color } from 'react-stately'\nimport type { ColorPickerState } from 'react-stately/useColorPickerState'\n\nimport { useRef, useState } from 'react'\nimport { View as NativeView, Pressable, StyleSheet, Text } from 'react-native'\nimport { parseColor } from 'react-stately'\nimport { useColorPickerState } from 'react-stately/useColorPickerState'\nimport { useOverlayTriggerState } from 'react-stately/useOverlayTriggerState'\n\nimport type { PickedColor } from '../../swatch'\n\nimport { useLocaleOf, useMessages } from '../../i18n/provider'\nimport { PickerPopup } from '../../picker'\nimport { hitSlop, usePressFeedback } from '../../press'\nimport { refsOf } from '../../ref'\nimport { colorNameOf, PickedColorContext } from '../../swatch'\nimport { withOpacity } from '../../theme/color'\nimport { useTheme } from '../../theme/scope'\nimport { composeStyles, themedStyles } from '../../theme/styles'\nimport { useTypeRole } from '../../typography/roles'\nimport { ColorArea } from '../color-area'\nimport { ColorField } from '../color-field'\nimport { ColorSlider } from '../color-slider'\nimport { ColorSwatch } from '../color-swatch'\n\n// Every colour control in one, as kanso-ui's ColorPicker composes them: a\n// swatch and a label as the trigger, and a plane, a hue slider, an alpha\n// slider and a hex field on the surface it opens. The value is React\n// Stately's `useColorPickerState`, which the controls on the surface take\n// through src/swatch's PickedColorContext, as React Aria's picker hands its\n// value to each control's context on web. So an arrangement passed as\n// `children` shares the value the same way, whatever it holds.\n//\n// Material Design carries no page for a colour picker. What it does carry is\n// the text fields page, which the field inside draws through, and the surface\n// a date picker opens on, which this one shares through src/picker. Three\n// choices are web's own, and kept.\n//\n// **The trigger is a swatch beside a name, not a swatch alone.** A swatch on\n// its own is a coloured square with no affordance, and a screen reader would\n// be told a colour rather than an action. It is a pill on surface container\n// low, the swatch at 24dp, the height of the label's line rather than a\n// swatch's own 40dp, and the label in label large, with the state layer and\n// ripple every control here draws in on surface. A screen reader hears the\n// label and then the colour, \"Label, dark purple\", where web's reads the\n// swatch's name first: the visible label leads, so a voice command that says\n// it finds the button.\n//\n// **Hue is a slider rather than a wheel.** A wheel and the plane want the\n// same room, and would make the surface square and large; the strip sits\n// under the plane at the width it already has. ColorWheel is for a picker\n// that wants to be round, which a call site builds as `children`.\n//\n// **It is docked from the medium window size up and modal below it**, the\n// date picker's pairing, through the same src/picker surface: a 280dp\n// surface anchored to a trigger is out of reach on a phone, and a centred one\n// on a tablet covers a form for no reason. Its dismissal, its motion and\n// where a screen reader goes are the date picker's.\n//\n// One thing the picker does that its parts do not. **The plane and the hue\n// slider are read in HSL.** A channel has to belong to the value's own space\n// or React Stately throws, and a hex is read as RGB, which has no saturation,\n// so `<ColorPicker defaultValue=\"#6750A4\" />` would throw outright. Reading\n// the two in HSL is what lets the picker take any notation. A change made on\n// either reports the colour in HSL, as React Stately's area and slider do on\n// web, and the field shows it as hex whatever space it is in.\n//\n// **Disabled reaches every control on the surface**, not only the trigger.\n// React Stately's picker state carries no disabled state, and the surface\n// opens independently of the trigger, so a disabled picker can still be on\n// screen: already open when a form disables it, or opened from outside. An\n// arrangement passed as `children` is the call site's own to disable.\n\n// The swatch in the trigger, at the height of the label's line rather than\n// the 40dp a swatch takes on its own.\nconst SWATCH = 24\n\n// The surface's width, as web's: room for the plane and a hex field.\nconst SURFACE_WIDTH = 280\n\n// Any HSL colour names the channels the two sliders draw. Their labels are\n// read off it in the locale, as React Stately words them, rather than written\n// here in English.\nconst CHANNELS = parseColor('hsl(0, 0%, 0%)')\n\nconst stylesOf = themedStyles(({ colors, radii, spacing, stateLayerOpacity }) =>\n StyleSheet.create({\n // What the surface holds, stacked: the plane, the sliders, then the\n // field. One column, so a picker reads top to bottom.\n body: {\n boxSizing: 'border-box',\n gap: spacing.md,\n maxWidth: '100%',\n padding: spacing.lg,\n width: SURFACE_WIDTH,\n },\n disabled: {\n backgroundColor: withOpacity(\n colors.onSurface,\n stateLayerOpacity.disabledContainer,\n ),\n },\n swatch: {\n height: SWATCH,\n width: SWATCH,\n },\n trigger: {\n alignItems: 'center',\n alignSelf: 'flex-start',\n backgroundColor: colors.surfaceContainerLow,\n borderRadius: radii.pill,\n boxSizing: 'border-box',\n flexDirection: 'row',\n gap: spacing.sm,\n paddingHorizontal: spacing.md,\n paddingVertical: spacing.sm,\n },\n }),\n)\n\ntype ColorPickerProps = {\n /** Whether the alpha slider is drawn under the hue one. @default false */\n readonly alpha?: boolean\n /**\n * Replaces everything on the surface, for a picker that arranges its own\n * parts. The colour controls in it take the picker's value.\n */\n readonly children?: ReactNode\n /** Whether the surface starts open, when the picker keeps its own open state. */\n readonly defaultOpen?: boolean\n /**\n * The colour the picker holds at first, when it keeps its own: a CSS colour\n * string, or a `Color` from `parseColor`.\n * @default '#000000'\n */\n readonly defaultValue?: Color | string\n /**\n * Whether the whole picker is inert: the trigger, and the plane, sliders\n * and field on the surface, which can be on screen while disabled since\n * the surface opens independently of the trigger. An arrangement passed as\n * `children` is the call site's own to disable.\n * @default false\n */\n readonly isDisabled?: boolean\n /** Whether the surface is open, for a call site holding it with `onOpenChange`. */\n readonly isOpen?: boolean\n /**\n * What the trigger says beside its swatch. Required: it is the button's\n * name, the surface's and the field's.\n */\n readonly label: string\n /** Called with the colour each time a control on the surface changes it. */\n readonly onChange?: (value: Color) => void\n /** Called when the surface opens or closes. */\n readonly onOpenChange?: (isOpen: boolean) => void\n readonly ref?: Ref<ComponentRef<typeof View>>\n readonly style?: StyleProp<ViewStyle>\n readonly testID?: string\n /** The colour, for a call site holding it itself with `onChange`. */\n readonly value?: Color | string\n}\n\n/**\n * A colour picked from a plane, a hue slider and a hex field, behind a\n * trigger showing the colour. Pass `value` with `onChange` to control it, or\n * `defaultValue`, as a CSS colour string or a `Color` from `parseColor`,\n * which this package re-exports.\n *\n * ```tsx\n * <ColorPicker defaultValue=\"#6750A4\" label=\"Label\" />\n * ```\n *\n * `alpha` adds the transparency slider. From the medium window size up the\n * surface is docked under the trigger; below it, it opens centred over a\n * scrim, as a date picker's does. `defaultOpen`, `isOpen` and `onOpenChange`\n * reach the surface.\n *\n * Every part on the surface is this package's own, `ColorArea`,\n * `ColorSlider` and `ColorField`, and they share the picker's value rather\n * than taking it as props. Passing `children` replaces all of them, and a\n * `ColorArea`, `ColorField`, `ColorSlider`, `ColorSwatch`,\n * `ColorSwatchPicker` or `ColorWheel` among them takes the picker's value\n * where it is given none of its own.\n *\n * `style`, `ref` and `testID` land on the trigger, which is what a layout\n * places.\n */\nfunction ColorPicker({\n alpha = false,\n children,\n defaultOpen,\n defaultValue,\n isDisabled = false,\n isOpen,\n label,\n onChange,\n onOpenChange,\n ref,\n style,\n testID,\n value,\n}: ColorPickerProps) {\n const theme = useTheme()\n const { colors, radii, spacing, stateLayerOpacity } = theme\n const styles = stylesOf(theme)\n const locale = useLocaleOf(undefined)\n const messages = useMessages()\n const labelRole = useTypeRole('labelLarge')\n const state = useColorPickerState({ defaultValue, onChange, value })\n const overlay = useOverlayTriggerState({ defaultOpen, isOpen, onOpenChange })\n // oxlint-disable-next-line typescript/unbound-method -- React Stately's setters are callbacks, and read no `this`\n const { close, open: show } = overlay\n const anchor = useRef<HostInstance | null>(null)\n const [trigger, setTrigger] = useState<HostInstance | null>(null)\n const feedback = usePressFeedback({\n color: colors.onSurface,\n corners: { borderRadius: radii.pill },\n disabled: isDisabled,\n })\n const name = colorNameOf(state.color, locale, messages.transparent)\n\n return (\n <>\n <Pressable\n {...feedback.handlers}\n aria-expanded={overlay.isOpen}\n aria-label={`${label}, ${name}`}\n disabled={isDisabled}\n hitSlop={hitSlop(SWATCH + 2 * spacing.sm)}\n onPress={show}\n ref={refsOf<HostInstance>(ref, anchor, setTrigger)}\n role=\"button\"\n style={composeStyles<ViewStyle>(\n styles.trigger,\n isDisabled ? styles.disabled : undefined,\n feedback.ring,\n style,\n )}\n testID={testID}\n >\n {feedback.layer}\n <ColorSwatch color={state.color} style={styles.swatch} />\n <Text\n style={composeStyles<TextStyle>(labelRole, {\n color: isDisabled\n ? withOpacity(colors.onSurface, stateLayerOpacity.disabledContent)\n : colors.onSurface,\n })}\n >\n {label}\n </Text>\n </Pressable>\n <PickerPopup\n anchor={anchor}\n close={close}\n isOpen={overlay.isOpen}\n label={label}\n trigger={trigger}\n >\n {/*\n Inside the surface rather than around the picker, since the surface\n is drawn in the overlay host, which context set around the picker\n does not reach.\n */}\n <PickedColorContext value={pickedOf(state)}>\n {children ?? (\n <NativeView style={styles.body}>\n <ColorArea\n aria-label={label}\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n xChannel=\"saturation\"\n yChannel=\"lightness\"\n />\n <ColorSlider\n channel=\"hue\"\n colorSpace=\"hsl\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('hue', locale)}\n />\n {alpha ? (\n <ColorSlider\n channel=\"alpha\"\n isDisabled={isDisabled}\n label={CHANNELS.getChannelName('alpha', locale)}\n />\n ) : null}\n <ColorField isDisabled={isDisabled} label={label} />\n </NativeView>\n )}\n </PickedColorContext>\n </PickerPopup>\n </>\n )\n}\n\n// Built by a call rather than written inline at the prop, which is what\n// react-perf's jsx-no-new-object-as-prop is after; the React Compiler\n// memoises the result on its inputs.\nfunction pickedOf(state: ColorPickerState): PickedColor {\n return {\n onChange: (color) => {\n state.setColor(color)\n },\n value: state.color,\n }\n}\n\nexport { ColorPicker }\nexport type { ColorPickerProps }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmFA,MAAMqC,SAAS;AAGf,MAAMC,gBAAgB;AAKtB,MAAMC,WAAWvB,WAAW,gBAAgB;AAE5C,MAAMwB,WAAWT,cAAc,EAAEU,QAAQC,OAAOC,SAASC,wBACvD9B,WAAW+B,OAAO;CAGhBC,MAAM;EACJ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AAT,SAAAS,EAAA,QAAAa,QAAAvB,UAAAU,EAAA,QAAAkD,OAAAlD,EAAA,QAAA1B,SAAA;EAtCvB6E,MAAA,oBAAC,aAAD;GACUlC;GACDH;GACC,QAAA+B;GACDtD;GACEjB;GAOT4E,UAAAA;EAZU,CAAA;EAuCElD,EAAA,MAAAc;EAAAd,EAAA,MAAAT;EAAAS,EAAA,MAAAa,QAAAvB;EAAAU,EAAA,MAAAkD;EAAAlD,EAAA,MAAA1B;EAAA0B,EAAA,MAAAmD;CAAA,OAAAA,MAAAnD,EAAA;CAAA,IAAAoD;CAAA,IAAApD,EAAA,QAAA4C,OAAA5C,EAAA,QAAAmD,KAAA;EArEhBC,MAAA,qBAAA,YAAA,EAAA,UAAA,CACER,KA6BAO,GAuCc,EAAA,CAAA;EACbnD,EAAA,MAAA4C;EAAA5C,EAAA,MAAAmD;EAAAnD,EAAA,MAAAoD;CAAA,OAAAA,MAAApD,EAAA;CAAA,OAtEHoD;AAsEG;AAOP,SAASL,SAASpC,OAAsC;CACtD,OAAO;EACLnB,WAAW6B,UAAU;GACnBV,MAAM0C,SAAShC,KAAK;EACtB;EACA5B,OAAOkB,MAAMU;CACf;AACF"}
@@ -0,0 +1,82 @@
1
+ import { StyleProp, View, ViewStyle } from "react-native";
2
+ import { ComponentRef, Ref } from "react";
3
+ import { Color, ColorChannel, ColorSpace } from "react-stately";
4
+ //#region src/components/color-slider/index.d.ts
5
+ type ColorSliderProps = {
6
+ /**
7
+ * The slider's name for a screen reader, when no `label` is drawn. Left
8
+ * out with the label too, the slider is named by its channel.
9
+ */
10
+ readonly 'aria-label'?: string;
11
+ /** Which channel of the colour the slider moves. */
12
+ readonly channel: ColorChannel;
13
+ /**
14
+ * The space the channel is read in, when the value is given in another: a
15
+ * hex or `rgb()` value has no hue until it is read as `hsl` or `hsb`.
16
+ */
17
+ readonly colorSpace?: ColorSpace;
18
+ /**
19
+ * The colour the slider starts at, when it keeps its own: a CSS colour
20
+ * string, or a `Color` from `parseColor`.
21
+ */
22
+ readonly defaultValue?: Color | string;
23
+ /**
24
+ * Draws the slider disabled, and takes no presses, drags or screen reader
25
+ * actions.
26
+ * @default false
27
+ */
28
+ readonly isDisabled?: boolean;
29
+ /** What the slider is for, drawn above the track. */
30
+ readonly label?: string;
31
+ /** Called with the colour as the channel moves. */
32
+ readonly onChange?: (value: Color) => void;
33
+ /** Called with the colour once a drag, a press or an action has ended. */
34
+ readonly onChangeEnd?: (value: Color) => void;
35
+ /**
36
+ * Along which axis the handle moves. A vertical slider is 240dp tall until
37
+ * `style` says otherwise.
38
+ * @default 'horizontal'
39
+ */
40
+ readonly orientation?: 'horizontal' | 'vertical';
41
+ readonly ref?: Ref<ComponentRef<typeof View>>;
42
+ /**
43
+ * Whether the channel's value is shown at the end of the label's line.
44
+ * @default true
45
+ */
46
+ readonly showValue?: boolean;
47
+ readonly style?: StyleProp<ViewStyle>;
48
+ readonly testID?: string;
49
+ /** The colour, for a call site holding it itself with `onChange`. */
50
+ readonly value?: Color | string;
51
+ };
52
+ /**
53
+ * A slider over one channel of a colour: hue, saturation, lightness, alpha
54
+ * and the rest. Its state is React Stately's, as web's is: pass `value` with
55
+ * `onChange` to control it, or `defaultValue`, as a CSS colour string or a
56
+ * `Color` from `parseColor`, which this package re-exports. One of the two is
57
+ * required.
58
+ *
59
+ * ```tsx
60
+ * <ColorSlider channel="hue" defaultValue="hsl(200, 100%, 50%)" label="Label" />
61
+ * ```
62
+ *
63
+ * **`channel` has to name a channel the value's own space has.** A hex or
64
+ * `rgb()` value is read as RGB, which has no hue, so `channel="hue"` against
65
+ * one throws rather than converting. Pass `colorSpace="hsl"` to convert it,
66
+ * or give the value in the space you mean to slide.
67
+ *
68
+ * A press on the track moves the handle there, and a drag carries it. A
69
+ * screen reader hears an adjustable control named by the label, with the
70
+ * channel's value and the colour's name. `style`, `ref` and `testID` land on
71
+ * the slider as a whole, which is the view a layout positions. With a
72
+ * `testID`, the drag and the press are registered with Gesture Handler as
73
+ * `<testID>-pan` and `<testID>-tap`, which its `getByGestureTestId` finds in
74
+ * a test.
75
+ *
76
+ * Inside a `ColorPicker` it takes the picker's colour where it is given no
77
+ * `value`, and reports a change to the picker before its own `onChange`.
78
+ */
79
+ declare function ColorSlider({ 'aria-label': ariaLabel, channel, colorSpace, defaultValue, isDisabled, label, onChange, onChangeEnd, orientation, ref, showValue, style, testID, value }: ColorSliderProps): import("react").JSX.Element;
80
+ //#endregion
81
+ export { ColorSlider, type ColorSliderProps };
82
+ //# sourceMappingURL=index.d.ts.map