@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,630 @@
1
+ import { useTheme } from "../../theme/scope.js";
2
+ import { composeStyles, themedStyles } from "../../theme/styles.js";
3
+ import { useLocaleOf } from "../../i18n/provider.js";
4
+ import { HIDDEN } from "../../glyphs/hidden.js";
5
+ import { ColorThumb } from "../../color-thumb/index.js";
6
+ import { ADJUSTABLE, percentOf } from "../../slider/index.js";
7
+ import { usePickedColor } from "../../swatch/index.js";
8
+ import { c } from "react/compiler-runtime";
9
+ import { I18nManager, StyleSheet, View } from "react-native";
10
+ import { useId, useState } from "react";
11
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
+ import Svg, { Defs, LinearGradient, Mask, Rect, Stop } from "react-native-svg";
13
+ import { Gesture, GestureDetector, GestureHandlerRootView } from "react-native-gesture-handler";
14
+ import { parseColor } from "react-stately";
15
+ import { useColorAreaState } from "react-stately/useColorAreaState";
16
+ //#region src/components/color-area/index.tsx
17
+ const SLOP = 10;
18
+ const TARGET = 48;
19
+ const HUES = [
20
+ 0,
21
+ 60,
22
+ 120,
23
+ 180,
24
+ 240,
25
+ 300,
26
+ 360
27
+ ];
28
+ const BLACK = "rgb(0, 0, 0)";
29
+ const WHITE = "rgb(255, 255, 255)";
30
+ const styles = StyleSheet.create({
31
+ half: { flexGrow: 1 },
32
+ root: {
33
+ aspectRatio: 1,
34
+ boxSizing: "border-box",
35
+ width: "100%"
36
+ },
37
+ seat: {
38
+ alignItems: "center",
39
+ flexDirection: "row",
40
+ height: TARGET,
41
+ justifyContent: "center",
42
+ marginStart: -24,
43
+ marginTop: -24,
44
+ position: "absolute",
45
+ width: TARGET
46
+ },
47
+ thumb: {
48
+ alignItems: "center",
49
+ justifyContent: "center",
50
+ pointerEvents: "none",
51
+ ...StyleSheet.absoluteFill
52
+ }
53
+ });
54
+ const stylesOf = themedStyles(({ radii, stateLayerOpacity }) => StyleSheet.create({
55
+ disabled: { opacity: stateLayerOpacity.disabledContent },
56
+ plane: {
57
+ borderRadius: radii.sm,
58
+ overflow: "hidden",
59
+ ...StyleSheet.absoluteFill
60
+ }
61
+ }));
62
+ function adjustOf(state, axis, isDisabled) {
63
+ return (event) => {
64
+ const { actionName } = event.nativeEvent;
65
+ if (isDisabled || actionName !== "increment" && actionName !== "decrement") return;
66
+ const up = actionName === "increment";
67
+ state.setDragging(true);
68
+ if (axis === "x") {
69
+ if (up) state.incrementX(state.xChannelStep);
70
+ else state.decrementX(state.xChannelStep);
71
+ } else if (up) state.incrementY(state.yChannelStep);
72
+ else state.decrementY(state.yChannelStep);
73
+ state.setDragging(false);
74
+ };
75
+ }
76
+ /**
77
+ * Two channels of a colour as a plane, with a handle where they meet. Its
78
+ * state is React Stately's, as web's is: pass `value` with `onChange` to
79
+ * control it, or `defaultValue`, as a CSS colour string or a `Color` from
80
+ * `parseColor`, which this package re-exports.
81
+ *
82
+ * ```tsx
83
+ * <ColorArea
84
+ * defaultValue="hsl(200, 100%, 50%)"
85
+ * xChannel="saturation"
86
+ * yChannel="lightness"
87
+ * />
88
+ * ```
89
+ *
90
+ * **`xChannel` and `yChannel` have to name channels the value's own space
91
+ * has.** A hex or `rgb()` value is read as RGB, which has no saturation, so
92
+ * naming one against it throws rather than converting. Pass `colorSpace` to
93
+ * convert it, or give the value in the space you mean to work in.
94
+ *
95
+ * **`alpha` is a channel here only in RGB.** Asked for it in HSL, the plane
96
+ * quietly draws saturation and lightness instead, as React Aria's does.
97
+ *
98
+ * A press on the plane moves the handle there, and a drag carries it. A
99
+ * screen reader adjusts each channel apart, through two halves of the
100
+ * handle, each named by its channel. `style`, `ref` and `testID` land on the
101
+ * square, whose width `style` sets. With a `testID`, the drag and the press
102
+ * are registered with Gesture Handler as `<testID>-pan` and `<testID>-tap`,
103
+ * which its `getByGestureTestId` finds in a test.
104
+ *
105
+ * Inside a `ColorPicker` it takes the picker's colour where it is given no
106
+ * `value`, and reports a change to the picker before its own `onChange`.
107
+ */
108
+ function ColorArea(t0) {
109
+ const $ = c(66);
110
+ const { "aria-label": ariaLabel, colorSpace, defaultValue, isDisabled: t1, onChange, onChangeEnd, ref, style, testID, value, xChannel, yChannel } = t0;
111
+ const isDisabled = t1 === void 0 ? false : t1;
112
+ const own = stylesOf(useTheme());
113
+ const locale = useLocaleOf(void 0);
114
+ const picked = usePickedColor(value, onChange);
115
+ let t2;
116
+ if ($[0] !== colorSpace || $[1] !== defaultValue || $[2] !== isDisabled || $[3] !== onChangeEnd || $[4] !== picked.onChange || $[5] !== picked.value || $[6] !== xChannel || $[7] !== yChannel) {
117
+ t2 = {
118
+ colorSpace,
119
+ defaultValue,
120
+ isDisabled,
121
+ onChange: picked.onChange,
122
+ onChangeEnd,
123
+ value: picked.value,
124
+ xChannel,
125
+ yChannel
126
+ };
127
+ $[0] = colorSpace;
128
+ $[1] = defaultValue;
129
+ $[2] = isDisabled;
130
+ $[3] = onChangeEnd;
131
+ $[4] = picked.onChange;
132
+ $[5] = picked.value;
133
+ $[6] = xChannel;
134
+ $[7] = yChannel;
135
+ $[8] = t2;
136
+ } else t2 = $[8];
137
+ const state = useColorAreaState(t2);
138
+ let t3;
139
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
140
+ t3 = {
141
+ height: 0,
142
+ width: 0
143
+ };
144
+ $[9] = t3;
145
+ } else t3 = $[9];
146
+ const [size, setSize] = useState(t3);
147
+ let t4;
148
+ if ($[10] !== isDisabled || $[11] !== size || $[12] !== state || $[13] !== testID) {
149
+ t4 = {
150
+ isDisabled,
151
+ size,
152
+ state,
153
+ testID
154
+ };
155
+ $[10] = isDisabled;
156
+ $[11] = size;
157
+ $[12] = state;
158
+ $[13] = testID;
159
+ $[14] = t4;
160
+ } else t4 = $[14];
161
+ const gesture = usePlaneGesture(t4);
162
+ const { x, y } = state.getThumbPosition();
163
+ const { channels } = state;
164
+ const T0 = View;
165
+ const t5 = composeStyles(styles.root, isDisabled ? own.disabled : void 0, style);
166
+ const T1 = GestureHandlerRootView;
167
+ const t6 = StyleSheet;
168
+ const T2 = GestureDetector;
169
+ const T3 = View;
170
+ let t7;
171
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
172
+ t7 = sizeTo(setSize);
173
+ $[15] = t7;
174
+ } else t7 = $[15];
175
+ const t8 = StyleSheet;
176
+ const t9 = own.plane;
177
+ let t10;
178
+ if ($[16] !== state) {
179
+ t10 = layersOf(state);
180
+ $[16] = state;
181
+ $[17] = t10;
182
+ } else t10 = $[17];
183
+ let t11;
184
+ if ($[18] !== t10) {
185
+ t11 = /* @__PURE__ */ jsx(Plane, { layers: t10 });
186
+ $[18] = t10;
187
+ $[19] = t11;
188
+ } else t11 = $[19];
189
+ let t12;
190
+ if ($[20] !== own || $[21] !== t11) {
191
+ t12 = /* @__PURE__ */ jsx(View, {
192
+ style: t9,
193
+ children: t11
194
+ });
195
+ $[20] = own;
196
+ $[21] = t11;
197
+ $[22] = t12;
198
+ } else t12 = $[22];
199
+ const T4 = View;
200
+ const t13 = composeStyles(styles.seat, {
201
+ start: percentOf(x),
202
+ top: percentOf(y)
203
+ });
204
+ let t14;
205
+ if ($[23] !== ariaLabel || $[24] !== channels.xChannel || $[25] !== isDisabled || $[26] !== locale || $[27] !== state) {
206
+ t14 = /* @__PURE__ */ jsx(Half, {
207
+ axis: "x",
208
+ channel: channels.xChannel,
209
+ isDisabled,
210
+ label: ariaLabel,
211
+ locale,
212
+ state
213
+ });
214
+ $[23] = ariaLabel;
215
+ $[24] = channels.xChannel;
216
+ $[25] = isDisabled;
217
+ $[26] = locale;
218
+ $[27] = state;
219
+ $[28] = t14;
220
+ } else t14 = $[28];
221
+ let t15;
222
+ if ($[29] !== ariaLabel || $[30] !== channels.yChannel || $[31] !== isDisabled || $[32] !== locale || $[33] !== state) {
223
+ t15 = /* @__PURE__ */ jsx(Half, {
224
+ axis: "y",
225
+ channel: channels.yChannel,
226
+ isDisabled,
227
+ label: ariaLabel,
228
+ locale,
229
+ state
230
+ });
231
+ $[29] = ariaLabel;
232
+ $[30] = channels.yChannel;
233
+ $[31] = isDisabled;
234
+ $[32] = locale;
235
+ $[33] = state;
236
+ $[34] = t15;
237
+ } else t15 = $[34];
238
+ let t16;
239
+ if ($[35] !== state) {
240
+ t16 = state.getDisplayColor();
241
+ $[35] = state;
242
+ $[36] = t16;
243
+ } else t16 = $[36];
244
+ let t17;
245
+ if ($[37] !== state.isDragging || $[38] !== t16) {
246
+ t17 = /* @__PURE__ */ jsx(View, {
247
+ style: styles.thumb,
248
+ children: /* @__PURE__ */ jsx(ColorThumb, {
249
+ color: t16,
250
+ dragging: state.isDragging
251
+ })
252
+ });
253
+ $[37] = state.isDragging;
254
+ $[38] = t16;
255
+ $[39] = t17;
256
+ } else t17 = $[39];
257
+ let t18;
258
+ if ($[40] !== T4 || $[41] !== t13 || $[42] !== t14 || $[43] !== t15 || $[44] !== t17) {
259
+ t18 = /* @__PURE__ */ jsxs(T4, {
260
+ style: t13,
261
+ children: [
262
+ t14,
263
+ t15,
264
+ t17
265
+ ]
266
+ });
267
+ $[40] = T4;
268
+ $[41] = t13;
269
+ $[42] = t14;
270
+ $[43] = t15;
271
+ $[44] = t17;
272
+ $[45] = t18;
273
+ } else t18 = $[45];
274
+ let t19;
275
+ if ($[46] !== T3 || $[47] !== t12 || $[48] !== t18 || $[49] !== t7 || $[50] !== t8.absoluteFill) {
276
+ t19 = /* @__PURE__ */ jsxs(T3, {
277
+ onLayout: t7,
278
+ style: t8.absoluteFill,
279
+ children: [t12, t18]
280
+ });
281
+ $[46] = T3;
282
+ $[47] = t12;
283
+ $[48] = t18;
284
+ $[49] = t7;
285
+ $[50] = t8.absoluteFill;
286
+ $[51] = t19;
287
+ } else t19 = $[51];
288
+ let t20;
289
+ if ($[52] !== T2 || $[53] !== gesture || $[54] !== t19) {
290
+ t20 = /* @__PURE__ */ jsx(T2, {
291
+ gesture,
292
+ children: t19
293
+ });
294
+ $[52] = T2;
295
+ $[53] = gesture;
296
+ $[54] = t19;
297
+ $[55] = t20;
298
+ } else t20 = $[55];
299
+ let t21;
300
+ if ($[56] !== T1 || $[57] !== t20 || $[58] !== t6.absoluteFill) {
301
+ t21 = /* @__PURE__ */ jsx(T1, {
302
+ style: t6.absoluteFill,
303
+ children: t20
304
+ });
305
+ $[56] = T1;
306
+ $[57] = t20;
307
+ $[58] = t6.absoluteFill;
308
+ $[59] = t21;
309
+ } else t21 = $[59];
310
+ let t22;
311
+ if ($[60] !== T0 || $[61] !== ref || $[62] !== t21 || $[63] !== t5 || $[64] !== testID) {
312
+ t22 = /* @__PURE__ */ jsx(T0, {
313
+ ref,
314
+ style: t5,
315
+ testID,
316
+ children: t21
317
+ });
318
+ $[60] = T0;
319
+ $[61] = ref;
320
+ $[62] = t21;
321
+ $[63] = t5;
322
+ $[64] = testID;
323
+ $[65] = t22;
324
+ } else t22 = $[65];
325
+ return t22;
326
+ }
327
+ function cssOf(color) {
328
+ return color.toFormat("rgb").withChannelValue("alpha", 1).toString("css");
329
+ }
330
+ function fadeOf(color) {
331
+ return [{
332
+ color,
333
+ offset: 0,
334
+ opacity: 1
335
+ }, {
336
+ color,
337
+ offset: 1,
338
+ opacity: 0
339
+ }];
340
+ }
341
+ function Half(t0) {
342
+ const $ = c(29);
343
+ const { axis, channel, isDisabled, label, locale, state } = t0;
344
+ const color = state.value;
345
+ let t1;
346
+ if ($[0] !== channel || $[1] !== color || $[2] !== locale) {
347
+ t1 = color.getChannelName(channel, locale);
348
+ $[0] = channel;
349
+ $[1] = color;
350
+ $[2] = locale;
351
+ $[3] = t1;
352
+ } else t1 = $[3];
353
+ const name = t1;
354
+ let t2;
355
+ if ($[4] !== channel || $[5] !== color) {
356
+ t2 = color.getChannelRange(channel);
357
+ $[4] = channel;
358
+ $[5] = color;
359
+ $[6] = t2;
360
+ } else t2 = $[6];
361
+ const { maxValue, minValue } = t2;
362
+ const t3 = label === void 0 ? name : `${label}, ${name}`;
363
+ let t4;
364
+ if ($[7] !== channel || $[8] !== color) {
365
+ t4 = color.getChannelValue(channel);
366
+ $[7] = channel;
367
+ $[8] = color;
368
+ $[9] = t4;
369
+ } else t4 = $[9];
370
+ let t5;
371
+ if ($[10] !== channel || $[11] !== color || $[12] !== locale) {
372
+ t5 = color.formatChannelValue(channel, locale);
373
+ $[10] = channel;
374
+ $[11] = color;
375
+ $[12] = locale;
376
+ $[13] = t5;
377
+ } else t5 = $[13];
378
+ let t6;
379
+ if ($[14] !== locale || $[15] !== state) {
380
+ t6 = state.getDisplayColor().getColorName(locale);
381
+ $[14] = locale;
382
+ $[15] = state;
383
+ $[16] = t6;
384
+ } else t6 = $[16];
385
+ const t7 = `${t5}, ${t6}`;
386
+ let t8;
387
+ if ($[17] !== axis || $[18] !== isDisabled || $[19] !== state) {
388
+ t8 = adjustOf(state, axis, isDisabled);
389
+ $[17] = axis;
390
+ $[18] = isDisabled;
391
+ $[19] = state;
392
+ $[20] = t8;
393
+ } else t8 = $[20];
394
+ let t9;
395
+ if ($[21] !== isDisabled || $[22] !== maxValue || $[23] !== minValue || $[24] !== t3 || $[25] !== t4 || $[26] !== t7 || $[27] !== t8) {
396
+ t9 = /* @__PURE__ */ jsx(View, {
397
+ accessibilityActions: ADJUSTABLE,
398
+ accessible: true,
399
+ "aria-disabled": isDisabled,
400
+ "aria-label": t3,
401
+ "aria-valuemax": maxValue,
402
+ "aria-valuemin": minValue,
403
+ "aria-valuenow": t4,
404
+ "aria-valuetext": t7,
405
+ onAccessibilityAction: t8,
406
+ role: "slider",
407
+ style: styles.half
408
+ });
409
+ $[21] = isDisabled;
410
+ $[22] = maxValue;
411
+ $[23] = minValue;
412
+ $[24] = t3;
413
+ $[25] = t4;
414
+ $[26] = t7;
415
+ $[27] = t8;
416
+ $[28] = t9;
417
+ } else t9 = $[28];
418
+ return t9;
419
+ }
420
+ function layersOf(state) {
421
+ const { xChannel, yChannel, zChannel } = state.channels;
422
+ const space = state.value.getColorSpace();
423
+ const zValue = state.value.getChannelValue(zChannel);
424
+ if (space === "rgb") {
425
+ const corner = (xEnd, yEnd) => cssOf(parseColor(BLACK).withChannelValue(zChannel, zValue).withChannelValue(xChannel, state.value.getChannelRange(xChannel)[xEnd]).withChannelValue(yChannel, state.value.getChannelRange(yChannel)[yEnd]));
426
+ return [{
427
+ axis: "x",
428
+ stops: rowOf(corner("minValue", "minValue"), corner("maxValue", "minValue"))
429
+ }, {
430
+ axis: "x",
431
+ rising: true,
432
+ stops: rowOf(corner("minValue", "maxValue"), corner("maxValue", "maxValue"))
433
+ }];
434
+ }
435
+ const base = parseColor(space === "hsl" ? "hsl(0, 100%, 50%)" : "hsb(0, 100%, 100%)").withChannelValue(zChannel, zValue);
436
+ const layers = zChannel === "hue" ? [{ color: cssOf(base) }] : [];
437
+ for (const channel of state.value.getColorChannels()) if (channel !== zChannel) layers.push({
438
+ axis: channel === xChannel ? "x" : "y",
439
+ stops: stopsOf(channel, base)
440
+ });
441
+ return layers;
442
+ }
443
+ function Plane(t0) {
444
+ const $ = c(19);
445
+ const { layers } = t0;
446
+ const id = `plane${useId()}`;
447
+ const reversed = I18nManager.isRTL;
448
+ let t1;
449
+ if ($[0] !== id || $[1] !== layers) {
450
+ t1 = layers.some(_temp) ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs(LinearGradient, {
451
+ id: `${id}-rise`,
452
+ x1: 0,
453
+ x2: 0,
454
+ y1: 1,
455
+ y2: 0,
456
+ children: [/* @__PURE__ */ jsx(Stop, {
457
+ offset: 0,
458
+ stopColor: BLACK
459
+ }), /* @__PURE__ */ jsx(Stop, {
460
+ offset: 1,
461
+ stopColor: WHITE
462
+ })]
463
+ }), /* @__PURE__ */ jsx(Mask, {
464
+ id: `${id}-mask`,
465
+ children: /* @__PURE__ */ jsx(Rect, {
466
+ fill: `url(#${id}-rise)`,
467
+ height: "100%",
468
+ width: "100%"
469
+ })
470
+ })] }) : null;
471
+ $[0] = id;
472
+ $[1] = layers;
473
+ $[2] = t1;
474
+ } else t1 = $[2];
475
+ let t2;
476
+ if ($[3] !== id || $[4] !== layers) {
477
+ let t3;
478
+ if ($[6] !== id) {
479
+ t3 = (layer_0, index) => "stops" in layer_0 ? /* @__PURE__ */ jsx(LinearGradient, {
480
+ id: `${id}-${index}`,
481
+ x1: layer_0.axis === "x" && reversed ? 1 : 0,
482
+ x2: layer_0.axis === "y" || reversed ? 0 : 1,
483
+ y1: layer_0.axis === "y" ? 1 : 0,
484
+ y2: 0,
485
+ children: layer_0.stops.map(_temp2)
486
+ }, index) : null;
487
+ $[6] = id;
488
+ $[7] = t3;
489
+ } else t3 = $[7];
490
+ t2 = layers.map(t3);
491
+ $[3] = id;
492
+ $[4] = layers;
493
+ $[5] = t2;
494
+ } else t2 = $[5];
495
+ let t3;
496
+ if ($[8] !== t1 || $[9] !== t2) {
497
+ t3 = /* @__PURE__ */ jsxs(Defs, { children: [t1, t2] });
498
+ $[8] = t1;
499
+ $[9] = t2;
500
+ $[10] = t3;
501
+ } else t3 = $[10];
502
+ let t4;
503
+ if ($[11] !== id || $[12] !== layers) {
504
+ let t5;
505
+ if ($[14] !== id) {
506
+ t5 = (layer_1, index_0) => /* @__PURE__ */ jsx(Rect, {
507
+ fill: "stops" in layer_1 ? `url(#${id}-${index_0})` : layer_1.color,
508
+ height: "100%",
509
+ mask: "rising" in layer_1 && layer_1.rising ? `url(#${id}-mask)` : void 0,
510
+ width: "100%"
511
+ }, index_0);
512
+ $[14] = id;
513
+ $[15] = t5;
514
+ } else t5 = $[15];
515
+ t4 = layers.map(t5);
516
+ $[11] = id;
517
+ $[12] = layers;
518
+ $[13] = t4;
519
+ } else t4 = $[13];
520
+ let t5;
521
+ if ($[16] !== t3 || $[17] !== t4) {
522
+ t5 = /* @__PURE__ */ jsxs(Svg, {
523
+ ...HIDDEN,
524
+ height: "100%",
525
+ style: StyleSheet.absoluteFill,
526
+ width: "100%",
527
+ children: [t3, t4]
528
+ });
529
+ $[16] = t3;
530
+ $[17] = t4;
531
+ $[18] = t5;
532
+ } else t5 = $[18];
533
+ return t5;
534
+ }
535
+ function _temp2(stop) {
536
+ return /* @__PURE__ */ jsx(Stop, {
537
+ offset: stop.offset,
538
+ stopColor: stop.color,
539
+ stopOpacity: stop.opacity
540
+ }, `${stop.offset}${stop.color}`);
541
+ }
542
+ function _temp(layer) {
543
+ return "rising" in layer && layer.rising;
544
+ }
545
+ function rowOf(start, end) {
546
+ return [{
547
+ color: start,
548
+ offset: 0,
549
+ opacity: 1
550
+ }, {
551
+ color: end,
552
+ offset: 1,
553
+ opacity: 1
554
+ }];
555
+ }
556
+ function sizeTo(set) {
557
+ return ({ nativeEvent }) => {
558
+ set({
559
+ height: nativeEvent.layout.height,
560
+ width: nativeEvent.layout.width
561
+ });
562
+ };
563
+ }
564
+ function stopsOf(channel, base) {
565
+ if (channel === "hue") return HUES.map((hue, index) => ({
566
+ color: cssOf(base.withChannelValue("hue", hue)),
567
+ offset: index / (HUES.length - 1),
568
+ opacity: 1
569
+ }));
570
+ if (channel === "saturation") return fadeOf(cssOf(base.withChannelValue("saturation", 0)));
571
+ if (channel === "lightness") return [
572
+ {
573
+ color: BLACK,
574
+ offset: 0,
575
+ opacity: 1
576
+ },
577
+ {
578
+ color: BLACK,
579
+ offset: .5,
580
+ opacity: 0
581
+ },
582
+ {
583
+ color: WHITE,
584
+ offset: .5,
585
+ opacity: 0
586
+ },
587
+ {
588
+ color: WHITE,
589
+ offset: 1,
590
+ opacity: 1
591
+ }
592
+ ];
593
+ return fadeOf(BLACK);
594
+ }
595
+ /**
596
+ * The plane's pan and tap. Each reads a press's place as a fraction of the
597
+ * way across the plane, from the start, and down it, and sets both channels
598
+ * there. The pan holds the plane as dragged until it lets go, which is what
599
+ * lifts the handle and what `onChangeEnd` waits for; the tap moves it and
600
+ * lets it go at once.
601
+ *
602
+ * Both run on the JavaScript thread, since every move sets React state.
603
+ */
604
+ function usePlaneGesture({ isDisabled, size, state, testID }) {
605
+ function setFrom(x, y) {
606
+ if (size.width <= 0 || size.height <= 0) return;
607
+ const across = x / size.width;
608
+ state.setColorFromPoint(I18nManager.isRTL ? 1 - across : across, y / size.height);
609
+ }
610
+ const pan = Gesture.Pan().minDistance(SLOP).enabled(!isDisabled).runOnJS(true).onStart(({ x, y }) => {
611
+ state.setDragging(true);
612
+ setFrom(x, y);
613
+ }).onUpdate(({ x, y }) => {
614
+ setFrom(x, y);
615
+ }).onFinalize(() => {
616
+ state.setDragging(false);
617
+ });
618
+ const tap = Gesture.Tap().maxDistance(SLOP).enabled(!isDisabled).runOnJS(true).onEnd(({ x, y }, success) => {
619
+ if (success) {
620
+ state.setDragging(true);
621
+ setFrom(x, y);
622
+ state.setDragging(false);
623
+ }
624
+ });
625
+ return Gesture.Race(testID === void 0 ? pan : pan.withTestId(`${testID}-pan`), testID === void 0 ? tap : tap.withTestId(`${testID}-tap`));
626
+ }
627
+ //#endregion
628
+ export { ColorArea };
629
+
630
+ //# sourceMappingURL=index.js.map