@btndprojects/loam-ui-native 0.0.0-stage → 0.1.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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/dist/accordion/index.js +3 -0
  3. package/dist/adaptive/index.js +2 -0
  4. package/dist/alert/index.js +3 -0
  5. package/dist/analyzer/index.js +6 -0
  6. package/dist/announcement/index.js +6 -0
  7. package/dist/audio-player/index.js +3 -0
  8. package/dist/avatar/index.js +3 -0
  9. package/dist/avatar-group/index.js +3 -0
  10. package/dist/badge/index.js +5 -0
  11. package/dist/banner/index.js +2 -0
  12. package/dist/board/index.js +7 -0
  13. package/dist/button/index.js +5 -0
  14. package/dist/camera-permission/index.js +13 -0
  15. package/dist/capture-result/index.js +18 -0
  16. package/dist/card/index.js +4 -0
  17. package/dist/card-form/index.js +10 -0
  18. package/dist/carousel/index.js +2 -0
  19. package/dist/chart/index.js +6 -0
  20. package/dist/charts/index.js +7 -0
  21. package/dist/checkbox/index.js +7 -0
  22. package/dist/checklist/index.js +10 -0
  23. package/dist/checkout/index.js +13 -0
  24. package/dist/chip/index.js +7 -0
  25. package/dist/chunk-223Q2T2Q.js +229 -0
  26. package/dist/chunk-2A5NIQAK.js +254 -0
  27. package/dist/chunk-2GK6PHGE.js +363 -0
  28. package/dist/chunk-2WUTXHMU.js +1 -0
  29. package/dist/chunk-2ZZ7TDJ4.js +324 -0
  30. package/dist/chunk-35OFI3JG.js +499 -0
  31. package/dist/chunk-3ARE4TES.js +195 -0
  32. package/dist/chunk-3ECPOSKO.js +1 -0
  33. package/dist/chunk-3ENTMPQY.js +229 -0
  34. package/dist/chunk-3HJH6FF4.js +98 -0
  35. package/dist/chunk-3NMD74ZU.js +4 -0
  36. package/dist/chunk-3WPW4KUN.js +182 -0
  37. package/dist/chunk-47FWHGUN.js +394 -0
  38. package/dist/chunk-4BXMXBJO.js +141 -0
  39. package/dist/chunk-4DS5ZWVC.js +83 -0
  40. package/dist/chunk-4GBOGOTV.js +295 -0
  41. package/dist/chunk-4SZYY6AN.js +99 -0
  42. package/dist/chunk-4YIP3CWS.js +237 -0
  43. package/dist/chunk-4YQOR7JM.js +204 -0
  44. package/dist/chunk-4ZAHCY44.js +177 -0
  45. package/dist/chunk-52X2VYTD.js +228 -0
  46. package/dist/chunk-5P26LBDL.js +1 -0
  47. package/dist/chunk-5XLRYDAX.js +1 -0
  48. package/dist/chunk-5YNTNN5A.js +177 -0
  49. package/dist/chunk-66SG2H23.js +129 -0
  50. package/dist/chunk-6HT2LP62.js +504 -0
  51. package/dist/chunk-6N33LFQA.js +35 -0
  52. package/dist/chunk-6X6PQ443.js +432 -0
  53. package/dist/chunk-7CFF4HXS.js +126 -0
  54. package/dist/chunk-7O2FMUPT.js +755 -0
  55. package/dist/chunk-AI4DWZCD.js +162 -0
  56. package/dist/chunk-AWJOCGFZ.js +213 -0
  57. package/dist/chunk-AZRX6SAC.js +285 -0
  58. package/dist/chunk-B54QE2FN.js +1 -0
  59. package/dist/chunk-BC475SJH.js +1 -0
  60. package/dist/chunk-BEDBFJND.js +202 -0
  61. package/dist/chunk-BTTFCMKG.js +166 -0
  62. package/dist/chunk-BV3B2HYZ.js +1635 -0
  63. package/dist/chunk-C2NTXVWM.js +98 -0
  64. package/dist/chunk-CDRZHT42.js +424 -0
  65. package/dist/chunk-CJ5EOYZE.js +62 -0
  66. package/dist/chunk-CUMUNPXY.js +128 -0
  67. package/dist/chunk-CUS3ZSCU.js +1 -0
  68. package/dist/chunk-CYRBHQQZ.js +411 -0
  69. package/dist/chunk-DHWADYZX.js +144 -0
  70. package/dist/chunk-DKCSPATL.js +1 -0
  71. package/dist/chunk-DM5QUKKO.js +326 -0
  72. package/dist/chunk-DSJBXLUG.js +845 -0
  73. package/dist/chunk-DYBH2I6W.js +1 -0
  74. package/dist/chunk-DZ255O2F.js +1 -0
  75. package/dist/chunk-E35BPSGW.js +1 -0
  76. package/dist/chunk-EJBDRVIH.js +166 -0
  77. package/dist/chunk-F43NP42L.js +1 -0
  78. package/dist/chunk-F5XNPWS7.js +1024 -0
  79. package/dist/chunk-FIF2M24N.js +1521 -0
  80. package/dist/chunk-FOKG57CR.js +993 -0
  81. package/dist/chunk-G3HOYSF7.js +1 -0
  82. package/dist/chunk-GDKZTW34.js +395 -0
  83. package/dist/chunk-GL7B2DOW.js +134 -0
  84. package/dist/chunk-GNNJ4GCC.js +471 -0
  85. package/dist/chunk-GNZ56EUI.js +1 -0
  86. package/dist/chunk-H6NIOQHK.js +346 -0
  87. package/dist/chunk-H6PC7RDA.js +1 -0
  88. package/dist/chunk-HPPW424V.js +334 -0
  89. package/dist/chunk-HQOQIBJI.js +1 -0
  90. package/dist/chunk-HU2EQNRZ.js +44 -0
  91. package/dist/chunk-IIQTAY3J.js +715 -0
  92. package/dist/chunk-ITTYJZWX.js +271 -0
  93. package/dist/chunk-IVNRBPGC.js +1018 -0
  94. package/dist/chunk-J4KLDGI4.js +1 -0
  95. package/dist/chunk-J7Q7VCVC.js +254 -0
  96. package/dist/chunk-JDEOITQ2.js +1 -0
  97. package/dist/chunk-JNH2TYIN.js +96 -0
  98. package/dist/chunk-JRLTGLN4.js +1 -0
  99. package/dist/chunk-JTRJJLKL.js +1 -0
  100. package/dist/chunk-JUAMLEHX.js +379 -0
  101. package/dist/chunk-JXJB2X6M.js +131 -0
  102. package/dist/chunk-KMI5ML5I.js +262 -0
  103. package/dist/chunk-KTAC4MGE.js +4 -0
  104. package/dist/chunk-LAECSR4H.js +178 -0
  105. package/dist/chunk-LK4BCSGX.js +1 -0
  106. package/dist/chunk-LOE5YNN3.js +470 -0
  107. package/dist/chunk-LRJNDEIA.js +302 -0
  108. package/dist/chunk-LSS54GLJ.js +116 -0
  109. package/dist/chunk-LZLHELAG.js +137 -0
  110. package/dist/chunk-M2LUXGKZ.js +1 -0
  111. package/dist/chunk-MOUJOP55.js +425 -0
  112. package/dist/chunk-N32RGOA5.js +159 -0
  113. package/dist/chunk-N5ZNE2YE.js +1 -0
  114. package/dist/chunk-NBNCBML6.js +1 -0
  115. package/dist/chunk-NKB7BZYK.js +167 -0
  116. package/dist/chunk-NQYBUO3K.js +1795 -0
  117. package/dist/chunk-NY2U3PBI.js +59 -0
  118. package/dist/chunk-O4AEHWII.js +464 -0
  119. package/dist/chunk-O7AE6DAF.js +146 -0
  120. package/dist/chunk-OETCUXQP.js +134 -0
  121. package/dist/chunk-OOPPQH27.js +179 -0
  122. package/dist/chunk-OPXFZ4Y5.js +204 -0
  123. package/dist/chunk-P23EQNRQ.js +338 -0
  124. package/dist/chunk-PJXUJYS6.js +248 -0
  125. package/dist/chunk-PNWUWOBF.js +1 -0
  126. package/dist/chunk-PUPM2YGF.js +376 -0
  127. package/dist/chunk-PZXZJBMP.js +620 -0
  128. package/dist/chunk-Q72LJOVE.js +169 -0
  129. package/dist/chunk-QCDXZBC5.js +247 -0
  130. package/dist/chunk-QDYDBCFP.js +197 -0
  131. package/dist/chunk-QJJ6MADV.js +274 -0
  132. package/dist/chunk-QKXCPTFS.js +349 -0
  133. package/dist/chunk-QWCMU5B2.js +860 -0
  134. package/dist/chunk-RGQWWKLA.js +634 -0
  135. package/dist/chunk-RIBDXGUG.js +108 -0
  136. package/dist/chunk-RJQOOHT2.js +214 -0
  137. package/dist/chunk-RNGLIHFA.js +191 -0
  138. package/dist/chunk-RQ3HASCC.js +6 -0
  139. package/dist/chunk-RSOJT5YW.js +124 -0
  140. package/dist/chunk-RTIKSY6A.js +1 -0
  141. package/dist/chunk-RUZHTGKB.js +237 -0
  142. package/dist/chunk-RW6ZL2FQ.js +284 -0
  143. package/dist/chunk-S7F6XLTK.js +540 -0
  144. package/dist/chunk-SBMNWWBV.js +155 -0
  145. package/dist/chunk-SDTQPRRB.js +1 -0
  146. package/dist/chunk-SYNOJOQO.js +377 -0
  147. package/dist/chunk-T753XT36.js +1 -0
  148. package/dist/chunk-TKQYWZ5V.js +196 -0
  149. package/dist/chunk-TKVFVF5D.js +95 -0
  150. package/dist/chunk-TOXAGRDQ.js +144 -0
  151. package/dist/chunk-TUTI5HOZ.js +112 -0
  152. package/dist/chunk-U7TFM2JA.js +140 -0
  153. package/dist/chunk-UC2WGUP3.js +627 -0
  154. package/dist/chunk-UWFLYMAR.js +1126 -0
  155. package/dist/chunk-UWSZB7BJ.js +1 -0
  156. package/dist/chunk-UYG5L34B.js +87 -0
  157. package/dist/chunk-VBOXAEPI.js +336 -0
  158. package/dist/chunk-VCDBXW5H.js +188 -0
  159. package/dist/chunk-VCXPHHDS.js +1 -0
  160. package/dist/chunk-VEAYTRPX.js +414 -0
  161. package/dist/chunk-VFCUIDRT.js +1 -0
  162. package/dist/chunk-VQHPQEUH.js +273 -0
  163. package/dist/chunk-VXDZFJGP.js +874 -0
  164. package/dist/chunk-WS56BL3D.js +1 -0
  165. package/dist/chunk-WSW6ZFAQ.js +98 -0
  166. package/dist/chunk-WVKKJA6U.js +870 -0
  167. package/dist/chunk-XNUVB5OL.js +375 -0
  168. package/dist/chunk-XOSCY2CW.js +242 -0
  169. package/dist/chunk-XXXEFXY5.js +99 -0
  170. package/dist/chunk-Y5CSSPV4.js +1 -0
  171. package/dist/chunk-Y6DU4J47.js +1 -0
  172. package/dist/chunk-YC6WORFL.js +535 -0
  173. package/dist/chunk-YDGVJETP.js +60 -0
  174. package/dist/chunk-YF4NSSMT.js +366 -0
  175. package/dist/chunk-YG3ZJHGU.js +223 -0
  176. package/dist/chunk-YIJ55TBC.js +1 -0
  177. package/dist/chunk-YKZ4RZZF.js +1 -0
  178. package/dist/chunk-YLLCXTMC.js +37 -0
  179. package/dist/chunk-YTA74UZR.js +1 -0
  180. package/dist/chunk-Z7H7VSFZ.js +323 -0
  181. package/dist/chunk-ZK2H4O5P.js +1 -0
  182. package/dist/chunk-ZVFE5QGU.js +524 -0
  183. package/dist/coachmark/index.js +4 -0
  184. package/dist/code-block/index.js +4 -0
  185. package/dist/color-field/index.js +7 -0
  186. package/dist/commerce/index.js +20 -0
  187. package/dist/connectivity/index.js +2 -0
  188. package/dist/context-menu/index.js +5 -0
  189. package/dist/copy-button/index.js +3 -0
  190. package/dist/data-grid/index.js +24 -0
  191. package/dist/date-range-picker/index.js +13 -0
  192. package/dist/description-list/index.js +2 -0
  193. package/dist/dialog/index.js +3 -0
  194. package/dist/empty-state/index.js +3 -0
  195. package/dist/error-summary/index.js +3 -0
  196. package/dist/fab/index.js +2 -0
  197. package/dist/file-upload/index.js +9 -0
  198. package/dist/filter-bar/index.js +8 -0
  199. package/dist/flow-run/index.js +14 -0
  200. package/dist/form/index.js +3 -0
  201. package/dist/gallery/index.js +2 -0
  202. package/dist/header/index.js +5 -0
  203. package/dist/hold-to-confirm/index.js +4 -0
  204. package/dist/index.d.ts +22883 -0
  205. package/dist/index.js +158 -0
  206. package/dist/infinite-list/index.js +2 -0
  207. package/dist/inline-edit/index.js +5 -0
  208. package/dist/input/index.js +5 -0
  209. package/dist/interactions/index.js +2 -0
  210. package/dist/invoice/index.js +10 -0
  211. package/dist/kbd/index.js +1 -0
  212. package/dist/keyboard/index.js +3 -0
  213. package/dist/list-row/index.js +7 -0
  214. package/dist/log-viewer/index.js +2 -0
  215. package/dist/map-view/index.js +3 -0
  216. package/dist/markdown/index.js +6 -0
  217. package/dist/metric/index.js +4 -0
  218. package/dist/money/index.js +3 -0
  219. package/dist/nav-drawer/index.js +2 -0
  220. package/dist/navigation/index.js +2 -0
  221. package/dist/notification-center/index.js +16 -0
  222. package/dist/number-roll/index.js +3 -0
  223. package/dist/one-handed/index.js +5 -0
  224. package/dist/os-surfaces/index.js +3 -0
  225. package/dist/otp/index.js +7 -0
  226. package/dist/page-header/index.js +1 -0
  227. package/dist/payment-method/index.js +12 -0
  228. package/dist/payment-status/index.js +16 -0
  229. package/dist/permission/index.js +2 -0
  230. package/dist/picker/index.js +7 -0
  231. package/dist/progress/index.js +5 -0
  232. package/dist/pull-to-refresh/index.js +4 -0
  233. package/dist/radio-group/index.js +6 -0
  234. package/dist/rating/index.js +2 -0
  235. package/dist/receivables/index.js +20 -0
  236. package/dist/refund/index.js +16 -0
  237. package/dist/save-status/index.js +3 -0
  238. package/dist/scroll-area/index.js +1 -0
  239. package/dist/search-bar/index.js +5 -0
  240. package/dist/segmented-control/index.js +5 -0
  241. package/dist/sheet/index.js +4 -0
  242. package/dist/skeleton/index.js +2 -0
  243. package/dist/slider/index.js +5 -0
  244. package/dist/spinner/index.js +2 -0
  245. package/dist/split-button/index.js +7 -0
  246. package/dist/spotlight/index.js +2 -0
  247. package/dist/stage-timeline/index.js +4 -0
  248. package/dist/status-dot/index.js +2 -0
  249. package/dist/stepper/index.js +6 -0
  250. package/dist/streaming-text/index.js +3 -0
  251. package/dist/survey/index.js +19 -0
  252. package/dist/switch/index.js +5 -0
  253. package/dist/system-state/index.js +4 -0
  254. package/dist/tab-bar/index.js +2 -0
  255. package/dist/tabs/index.js +2 -0
  256. package/dist/textarea/index.js +6 -0
  257. package/dist/thinking/index.js +2 -0
  258. package/dist/timeline/index.js +4 -0
  259. package/dist/toast/index.js +2 -0
  260. package/dist/toolbar/index.js +2 -0
  261. package/dist/tour/index.js +11 -0
  262. package/dist/truncation-notice/index.js +2 -0
  263. package/dist/update-notice/index.js +11 -0
  264. package/dist/video-player/index.js +2 -0
  265. package/dist/viewfinder/index.js +5 -0
  266. package/dist/widget/index.js +4 -0
  267. package/dist/wizard/index.js +6 -0
  268. package/package.json +76 -3
  269. package/README.md +0 -3
@@ -0,0 +1,98 @@
1
+ import { Icon } from './chunk-TKVFVF5D.js';
2
+ import * as React from 'react';
3
+ import { Animated, Easing, View, Text, Pressable } from 'react-native';
4
+ import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+
7
+ function ErrorSummary({
8
+ errors,
9
+ title = "There's a problem",
10
+ onFocusField,
11
+ motion = "full"
12
+ }) {
13
+ const { styles } = useStyles(sheet);
14
+ const theme = useLoamTheme();
15
+ const animated = motion === "full" && !theme.reduceMotion;
16
+ const progress = React.useRef(new Animated.Value(animated ? 0 : 1)).current;
17
+ const enterEasing = React.useMemo(
18
+ () => Easing.bezier(...theme.motion.enter.easing),
19
+ [theme.motion.enter.easing]
20
+ );
21
+ React.useEffect(() => {
22
+ if (!animated) {
23
+ progress.setValue(1);
24
+ return;
25
+ }
26
+ Animated.timing(progress, {
27
+ toValue: 1,
28
+ duration: theme.motion.enter.duration,
29
+ easing: enterEasing,
30
+ useNativeDriver: true
31
+ }).start();
32
+ }, [animated, progress, enterEasing, theme.motion.enter.duration]);
33
+ if (errors.length === 0) return null;
34
+ const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [-4, 0] });
35
+ return /* @__PURE__ */ jsxs(
36
+ Animated.View,
37
+ {
38
+ accessibilityRole: "alert",
39
+ accessibilityLabel: title,
40
+ style: [styles.region, { opacity: progress, transform: [{ translateY }] }],
41
+ children: [
42
+ /* @__PURE__ */ jsxs(View, { style: styles.header, children: [
43
+ /* @__PURE__ */ jsx(Icon, { name: "alert-circle", size: theme.icon.sm, color: theme.color.dangerOnSoft }),
44
+ /* @__PURE__ */ jsx(Text, { style: styles.title, children: title })
45
+ ] }),
46
+ /* @__PURE__ */ jsx(View, { style: styles.list, children: errors.map((err) => /* @__PURE__ */ jsx(
47
+ Pressable,
48
+ {
49
+ accessibilityRole: "link",
50
+ accessibilityLabel: err.message,
51
+ onPress: () => onFocusField?.(err.fieldId),
52
+ hitSlop: { top: theme.space[6], bottom: theme.space[6] },
53
+ children: /* @__PURE__ */ jsx(Text, { style: styles.link, children: err.message })
54
+ },
55
+ err.fieldId
56
+ )) })
57
+ ]
58
+ }
59
+ );
60
+ }
61
+ var sheet = createStyleSheet((theme) => ({
62
+ // Danger tone via the soft tint + on-soft ink (clears AA), with the tone edge
63
+ // that carries the meaning under high contrast (where the tint collapses).
64
+ region: {
65
+ gap: theme.space.s2,
66
+ padding: theme.space.s3,
67
+ borderRadius: theme.radius.md,
68
+ backgroundColor: theme.color.dangerSoft,
69
+ borderWidth: theme.borderWidth.base,
70
+ borderColor: theme.edge.danger
71
+ },
72
+ header: {
73
+ flexDirection: "row",
74
+ alignItems: "center",
75
+ gap: theme.space.s2
76
+ },
77
+ title: {
78
+ fontFamily: theme.font.sans,
79
+ fontWeight: theme.fontWeight.bold,
80
+ fontSize: theme.type.subheadline.fontSize,
81
+ lineHeight: theme.type.subheadline.lineHeight,
82
+ color: theme.color.dangerOnSoft
83
+ },
84
+ list: {
85
+ gap: theme.space.s1,
86
+ paddingStart: theme.space.s1
87
+ },
88
+ link: {
89
+ fontFamily: theme.font.sans,
90
+ fontWeight: theme.fontWeight.medium,
91
+ fontSize: theme.type.footnote.fontSize,
92
+ lineHeight: theme.type.footnote.lineHeight,
93
+ color: theme.color.dangerOnSoft,
94
+ textDecorationLine: "underline"
95
+ }
96
+ }));
97
+
98
+ export { ErrorSummary };
@@ -0,0 +1,424 @@
1
+ import { DRAG_CURSOR } from './chunk-KTAC4MGE.js';
2
+ import { Input } from './chunk-ITTYJZWX.js';
3
+ import { haptics } from './chunk-NY2U3PBI.js';
4
+ import * as React from 'react';
5
+ import { PanResponder, View, StyleSheet } from 'react-native';
6
+ import { Svg, Defs, LinearGradient, Stop, Rect } from 'react-native-svg';
7
+ import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
8
+ import { jsxs, jsx } from 'react/jsx-runtime';
9
+
10
+ var GEOMETRY = {
11
+ sm: { plane: 120, hue: 12, thumb: 16 },
12
+ md: { plane: 160, hue: 14, thumb: 18 }
13
+ };
14
+ function clamp(n, lo, hi) {
15
+ return Math.max(lo, Math.min(hi, n));
16
+ }
17
+ function hsvToRgb({ h, s, v }) {
18
+ const sat = s / 100;
19
+ const val = v / 100;
20
+ const c = val * sat;
21
+ const hp = h % 360 / 60;
22
+ const x = c * (1 - Math.abs(hp % 2 - 1));
23
+ let r = 0;
24
+ let g = 0;
25
+ let b = 0;
26
+ if (hp >= 0 && hp < 1) [r, g, b] = [c, x, 0];
27
+ else if (hp < 2) [r, g, b] = [x, c, 0];
28
+ else if (hp < 3) [r, g, b] = [0, c, x];
29
+ else if (hp < 4) [r, g, b] = [0, x, c];
30
+ else if (hp < 5) [r, g, b] = [x, 0, c];
31
+ else [r, g, b] = [c, 0, x];
32
+ const m = val - c;
33
+ return [Math.round((r + m) * 255), Math.round((g + m) * 255), Math.round((b + m) * 255)];
34
+ }
35
+ function rgbToHsv(r, g, b) {
36
+ const rn = r / 255;
37
+ const gn = g / 255;
38
+ const bn = b / 255;
39
+ const max = Math.max(rn, gn, bn);
40
+ const min = Math.min(rn, gn, bn);
41
+ const d = max - min;
42
+ let h = 0;
43
+ if (d !== 0) {
44
+ if (max === rn) h = (gn - bn) / d % 6;
45
+ else if (max === gn) h = (bn - rn) / d + 2;
46
+ else h = (rn - gn) / d + 4;
47
+ h *= 60;
48
+ if (h < 0) h += 360;
49
+ }
50
+ const s = max === 0 ? 0 : d / max * 100;
51
+ return { h, s, v: max * 100 };
52
+ }
53
+ function byteHex(n) {
54
+ return clamp(Math.round(n), 0, 255).toString(16).padStart(2, "0").toUpperCase();
55
+ }
56
+ function rgbToHex(r, g, b) {
57
+ return `#${byteHex(r)}${byteHex(g)}${byteHex(b)}`;
58
+ }
59
+ function normalizeHex(input) {
60
+ const raw = input.trim().replace(/^#/, "");
61
+ if (/^[0-9a-fA-F]{3}$/.test(raw)) {
62
+ const [a, b, c] = raw;
63
+ return `#${a}${a}${b}${b}${c}${c}`.toUpperCase();
64
+ }
65
+ if (/^[0-9a-fA-F]{6}$/.test(raw)) return `#${raw.toUpperCase()}`;
66
+ return null;
67
+ }
68
+ function hexToRgb(input) {
69
+ const hex = normalizeHex(input);
70
+ if (!hex) return null;
71
+ return [
72
+ parseInt(hex.slice(1, 3), 16),
73
+ parseInt(hex.slice(3, 5), 16),
74
+ parseInt(hex.slice(5, 7), 16)
75
+ ];
76
+ }
77
+ function hsvToHex(hsv) {
78
+ return rgbToHex(...hsvToRgb(hsv));
79
+ }
80
+ function hexToHsv(hex, prevHue) {
81
+ const rgb = hexToRgb(hex);
82
+ if (!rgb) return null;
83
+ const hsv = rgbToHsv(...rgb);
84
+ if (hsv.s === 0) hsv.h = prevHue;
85
+ return hsv;
86
+ }
87
+ function ColorField({
88
+ value,
89
+ defaultValue = "#4A7C59",
90
+ onValueChange,
91
+ showInput = true,
92
+ disabled = false,
93
+ size = "md",
94
+ accessibilityLabel,
95
+ style
96
+ }) {
97
+ const isControlled = value !== void 0;
98
+ const initialHsv = React.useMemo(
99
+ () => hexToHsv(value ?? defaultValue, 0) ?? { h: 0, s: 0, v: 0 },
100
+ // Initial only — later syncing is handled by the effect below.
101
+ // eslint-disable-next-line react-hooks/exhaustive-deps
102
+ []
103
+ );
104
+ const [hsv, setHsv] = React.useState(initialHsv);
105
+ const [hexText, setHexText] = React.useState(() => hsvToHex(initialHsv));
106
+ const { styles } = useStyles(sheet, { size, disabled });
107
+ const theme = useLoamTheme();
108
+ const hex = hsvToHex(hsv);
109
+ const hueColor = hsvToHex({ h: hsv.h, s: 100, v: 100 });
110
+ const planeRef = React.useRef(null);
111
+ const hueRef = React.useRef(null);
112
+ const planeBox = React.useRef({ w: 0, h: 0, x: 0, y: 0 });
113
+ const hueBox = React.useRef({ w: 0, x: 0 });
114
+ const hsvRef = React.useRef(hsv);
115
+ hsvRef.current = hsv;
116
+ const disabledRef = React.useRef(disabled);
117
+ disabledRef.current = disabled;
118
+ const editingHex = React.useRef(false);
119
+ const [planeW, setPlaneW] = React.useState(0);
120
+ const [hueW, setHueW] = React.useState(0);
121
+ const commit = React.useCallback(
122
+ (next, syncText = true) => {
123
+ hsvRef.current = next;
124
+ if (!isControlled) setHsv(next);
125
+ if (syncText) setHexText(hsvToHex(next));
126
+ onValueChange?.(hsvToHex(next));
127
+ },
128
+ [isControlled, onValueChange]
129
+ );
130
+ React.useEffect(() => {
131
+ if (!isControlled || value === void 0) return;
132
+ const next = hexToHsv(value, hsvRef.current.h);
133
+ if (!next || hsvToHex(next) === hsvToHex(hsvRef.current)) return;
134
+ setHsv(next);
135
+ if (!editingHex.current) setHexText(hsvToHex(next));
136
+ }, [value]);
137
+ const planeFromXY = React.useRef(() => {
138
+ });
139
+ planeFromXY.current = (pageX, pageY) => {
140
+ const { w, h, x, y } = planeBox.current;
141
+ if (!w || !h) return;
142
+ const s = clamp((pageX - x) / w * 100, 0, 100);
143
+ const v = clamp((1 - (pageY - y) / h) * 100, 0, 100);
144
+ commit({ ...hsvRef.current, s, v });
145
+ };
146
+ const hueFromX = React.useRef(() => {
147
+ });
148
+ hueFromX.current = (pageX) => {
149
+ const { w, x } = hueBox.current;
150
+ if (!w) return;
151
+ const h = clamp((pageX - x) / w * 360, 0, 360);
152
+ commit({ ...hsvRef.current, h });
153
+ };
154
+ const planePan = React.useRef(
155
+ PanResponder.create({
156
+ onStartShouldSetPanResponder: () => !disabledRef.current,
157
+ onMoveShouldSetPanResponder: () => !disabledRef.current,
158
+ onPanResponderGrant: (e) => {
159
+ haptics.impact("light");
160
+ planeFromXY.current(e.nativeEvent.pageX, e.nativeEvent.pageY);
161
+ },
162
+ onPanResponderMove: (e) => planeFromXY.current(e.nativeEvent.pageX, e.nativeEvent.pageY)
163
+ })
164
+ ).current;
165
+ const huePan = React.useRef(
166
+ PanResponder.create({
167
+ onStartShouldSetPanResponder: () => !disabledRef.current,
168
+ onMoveShouldSetPanResponder: () => !disabledRef.current,
169
+ onPanResponderGrant: (e) => {
170
+ haptics.impact("light");
171
+ hueFromX.current(e.nativeEvent.pageX);
172
+ },
173
+ onPanResponderMove: (e) => hueFromX.current(e.nativeEvent.pageX)
174
+ })
175
+ ).current;
176
+ const onPlaneLayout = (e) => {
177
+ const { width, height } = e.nativeEvent.layout;
178
+ planeBox.current.w = width;
179
+ planeBox.current.h = height;
180
+ setPlaneW(width);
181
+ planeRef.current?.measureInWindow?.((x, y) => {
182
+ planeBox.current.x = x;
183
+ planeBox.current.y = y;
184
+ });
185
+ };
186
+ const onHueLayout = (e) => {
187
+ const { width } = e.nativeEvent.layout;
188
+ hueBox.current.w = width;
189
+ setHueW(width);
190
+ hueRef.current?.measureInWindow?.((x) => {
191
+ hueBox.current.x = x;
192
+ });
193
+ };
194
+ const onHexChange = (text) => {
195
+ setHexText(text);
196
+ const next = hexToHsv(text, hsvRef.current.h);
197
+ if (next) commit(next, false);
198
+ };
199
+ const geo = GEOMETRY[size];
200
+ const planeThumbX = hsv.s / 100 * planeW - geo.thumb / 2;
201
+ const planeThumbY = (1 - hsv.v / 100) * geo.plane - geo.thumb / 2;
202
+ const hueThumbX = hsv.h / 360 * hueW - geo.thumb / 2;
203
+ const hexValid = normalizeHex(hexText) !== null;
204
+ return /* @__PURE__ */ jsxs(View, { style: [styles.wrap, style], children: [
205
+ /* @__PURE__ */ jsxs(
206
+ View,
207
+ {
208
+ ref: planeRef,
209
+ onLayout: onPlaneLayout,
210
+ accessibilityRole: "adjustable",
211
+ accessibilityLabel: accessibilityLabel ? `${accessibilityLabel}, saturation and brightness` : "Saturation and brightness",
212
+ accessibilityValue: {
213
+ text: `Saturation ${Math.round(hsv.s)} percent, brightness ${Math.round(hsv.v)} percent`
214
+ },
215
+ accessibilityState: { disabled },
216
+ "aria-valuemin": 0,
217
+ "aria-valuemax": 100,
218
+ "aria-valuenow": Math.round(hsv.v),
219
+ "aria-valuetext": `Saturation ${Math.round(hsv.s)} percent, brightness ${Math.round(hsv.v)} percent`,
220
+ style: [styles.plane, !disabled && DRAG_CURSOR],
221
+ ...disabled ? {} : planePan.panHandlers,
222
+ children: [
223
+ planeW > 0 ? /* @__PURE__ */ jsxs(Svg, { width: planeW, height: geo.plane, style: StyleSheet.absoluteFill, children: [
224
+ /* @__PURE__ */ jsxs(Defs, { children: [
225
+ /* @__PURE__ */ jsxs(LinearGradient, { id: "loam-cf-sat", x1: "0", y1: "0", x2: "1", y2: "0", children: [
226
+ /* @__PURE__ */ jsx(Stop, { offset: "0", stopColor: "#ffffff", stopOpacity: 1 }),
227
+ /* @__PURE__ */ jsx(Stop, { offset: "1", stopColor: "#ffffff", stopOpacity: 0 })
228
+ ] }),
229
+ /* @__PURE__ */ jsxs(LinearGradient, { id: "loam-cf-val", x1: "0", y1: "0", x2: "0", y2: "1", children: [
230
+ /* @__PURE__ */ jsx(Stop, { offset: "0", stopColor: "#000000", stopOpacity: 0 }),
231
+ /* @__PURE__ */ jsx(Stop, { offset: "1", stopColor: "#000000", stopOpacity: 1 })
232
+ ] })
233
+ ] }),
234
+ /* @__PURE__ */ jsx(Rect, { x: "0", y: "0", width: planeW, height: geo.plane, fill: hueColor }),
235
+ /* @__PURE__ */ jsx(Rect, { x: "0", y: "0", width: planeW, height: geo.plane, fill: "url(#loam-cf-sat)" }),
236
+ /* @__PURE__ */ jsx(Rect, { x: "0", y: "0", width: planeW, height: geo.plane, fill: "url(#loam-cf-val)" })
237
+ ] }) : null,
238
+ /* @__PURE__ */ jsx(
239
+ View,
240
+ {
241
+ style: [
242
+ styles.thumb,
243
+ { transform: [{ translateX: planeThumbX }, { translateY: planeThumbY }] }
244
+ ]
245
+ }
246
+ )
247
+ ]
248
+ }
249
+ ),
250
+ /* @__PURE__ */ jsxs(
251
+ View,
252
+ {
253
+ ref: hueRef,
254
+ onLayout: onHueLayout,
255
+ accessibilityRole: "adjustable",
256
+ accessibilityLabel: accessibilityLabel ? `${accessibilityLabel}, hue` : "Hue",
257
+ accessibilityValue: { min: 0, max: 360, now: Math.round(hsv.h) },
258
+ accessibilityState: { disabled },
259
+ "aria-valuemin": 0,
260
+ "aria-valuemax": 360,
261
+ "aria-valuenow": Math.round(hsv.h),
262
+ style: [styles.hue, !disabled && DRAG_CURSOR],
263
+ ...disabled ? {} : huePan.panHandlers,
264
+ children: [
265
+ hueW > 0 ? /* @__PURE__ */ jsxs(Svg, { width: hueW, height: geo.hue, style: StyleSheet.absoluteFill, children: [
266
+ /* @__PURE__ */ jsx(Defs, { children: /* @__PURE__ */ jsxs(LinearGradient, { id: "loam-cf-hue", x1: "0", y1: "0", x2: "1", y2: "0", children: [
267
+ /* @__PURE__ */ jsx(Stop, { offset: "0", stopColor: "#ff0000" }),
268
+ /* @__PURE__ */ jsx(Stop, { offset: "0.17", stopColor: "#ffff00" }),
269
+ /* @__PURE__ */ jsx(Stop, { offset: "0.33", stopColor: "#00ff00" }),
270
+ /* @__PURE__ */ jsx(Stop, { offset: "0.5", stopColor: "#00ffff" }),
271
+ /* @__PURE__ */ jsx(Stop, { offset: "0.67", stopColor: "#0000ff" }),
272
+ /* @__PURE__ */ jsx(Stop, { offset: "0.83", stopColor: "#ff00ff" }),
273
+ /* @__PURE__ */ jsx(Stop, { offset: "1", stopColor: "#ff0000" })
274
+ ] }) }),
275
+ /* @__PURE__ */ jsx(
276
+ Rect,
277
+ {
278
+ x: "0",
279
+ y: "0",
280
+ width: hueW,
281
+ height: geo.hue,
282
+ rx: geo.hue / 2,
283
+ fill: "url(#loam-cf-hue)"
284
+ }
285
+ )
286
+ ] }) : null,
287
+ /* @__PURE__ */ jsx(View, { style: [styles.thumb, styles.hueThumb, { transform: [{ translateX: hueThumbX }] }] })
288
+ ]
289
+ }
290
+ ),
291
+ showInput ? /* @__PURE__ */ jsxs(View, { style: styles.row, children: [
292
+ /* @__PURE__ */ jsx(View, { style: [styles.preview, { backgroundColor: hex }] }),
293
+ /* @__PURE__ */ jsx(View, { style: styles.inputWrap, children: /* @__PURE__ */ jsx(
294
+ Input,
295
+ {
296
+ value: hexText,
297
+ onChangeText: onHexChange,
298
+ onFocus: () => {
299
+ editingHex.current = true;
300
+ },
301
+ onBlur: () => {
302
+ editingHex.current = false;
303
+ setHexText(hex);
304
+ },
305
+ editable: !disabled,
306
+ autoCapitalize: "characters",
307
+ autoCorrect: false,
308
+ maxLength: 7,
309
+ size: size === "sm" ? "sm" : "md",
310
+ validationState: hexValid ? "default" : "invalid",
311
+ showStatusIcon: false,
312
+ accessibilityLabel: "Hex colour",
313
+ style: { fontFamily: theme.font.mono }
314
+ }
315
+ ) })
316
+ ] }) : null
317
+ ] });
318
+ }
319
+ var HEAVY_SHADOW_RATIO = 1.2;
320
+ var sheet = createStyleSheet((theme) => ({
321
+ // The per-size `width` is the picker's preferred measure: a plane a little wider
322
+ // than it is tall, which also leaves the swatch and the hex field a line they
323
+ // both fit on. The caller's `style` merges after it, so it is a default rather
324
+ // than a floor, and `maxWidth` keeps it from overflowing a narrower container.
325
+ wrap: {
326
+ flexDirection: "column",
327
+ gap: theme.space.s3,
328
+ maxWidth: "100%",
329
+ variants: {
330
+ size: {
331
+ sm: { width: GEOMETRY.sm.plane + theme.space[20] },
332
+ md: { width: GEOMETRY.md.plane + theme.space[40] }
333
+ },
334
+ disabled: {
335
+ true: { opacity: theme.state.disabledOpacity },
336
+ false: {}
337
+ }
338
+ }
339
+ },
340
+ plane: {
341
+ width: "100%",
342
+ borderRadius: theme.radius.md,
343
+ borderWidth: theme.borderWidth.base,
344
+ borderColor: theme.color.border,
345
+ overflow: "hidden",
346
+ variants: {
347
+ size: {
348
+ sm: { height: GEOMETRY.sm.plane },
349
+ md: { height: GEOMETRY.md.plane }
350
+ },
351
+ disabled: {}
352
+ }
353
+ },
354
+ hue: {
355
+ width: "100%",
356
+ justifyContent: "center",
357
+ borderRadius: theme.radius.full,
358
+ variants: {
359
+ size: {
360
+ sm: { height: GEOMETRY.sm.hue },
361
+ md: { height: GEOMETRY.md.hue }
362
+ },
363
+ disabled: {}
364
+ }
365
+ },
366
+ // A hollow ring so the colour underneath shows through; positioned at 0,0 and
367
+ // moved with translate transforms.
368
+ thumb: {
369
+ position: "absolute",
370
+ top: 0,
371
+ left: 0,
372
+ // Let drags fall through to the plane/rail underneath.
373
+ pointerEvents: "none",
374
+ borderRadius: theme.radius.full,
375
+ backgroundColor: "transparent",
376
+ borderWidth: theme.borderWidth.thick,
377
+ borderColor: theme.color.knob,
378
+ // The reference's thumb elevation is tighter and more opaque than the
379
+ // switch knob's (`0 1px 3px` at .3 vs `0 2px 5px` at .25), so the geometry
380
+ // is overridden — but the *colour* comes from the theme's knob shadow,
381
+ // which carries the accent tint that `--sh-*` does on the web. A hardcoded
382
+ // `#000000` here made this one of the only shadows in the system that
383
+ // ignored the tint.
384
+ ...theme.shadow.knob,
385
+ shadowOffset: { width: 0, height: theme.space[1] },
386
+ shadowOpacity: theme.shadow.knob.shadowOpacity * HEAVY_SHADOW_RATIO,
387
+ shadowRadius: theme.space[3],
388
+ variants: {
389
+ size: {
390
+ sm: { width: GEOMETRY.sm.thumb, height: GEOMETRY.sm.thumb },
391
+ md: { width: GEOMETRY.md.thumb, height: GEOMETRY.md.thumb }
392
+ },
393
+ disabled: {}
394
+ }
395
+ },
396
+ // The hue thumb rides the vertical centre of the (short) rail.
397
+ hueThumb: {
398
+ top: "50%",
399
+ variants: {
400
+ size: {
401
+ sm: { marginTop: -16 / 2 },
402
+ md: { marginTop: -18 / 2 }
403
+ },
404
+ disabled: {}
405
+ }
406
+ },
407
+ row: {
408
+ flexDirection: "row",
409
+ alignItems: "center",
410
+ gap: theme.space.s2
411
+ },
412
+ preview: {
413
+ width: theme.space[32],
414
+ height: theme.space[32],
415
+ borderRadius: theme.radius.sm,
416
+ borderWidth: theme.borderWidth.base,
417
+ borderColor: theme.color.border
418
+ },
419
+ inputWrap: {
420
+ flex: 1
421
+ }
422
+ }));
423
+
424
+ export { ColorField };
@@ -0,0 +1,62 @@
1
+ import { Spinner } from './chunk-O7AE6DAF.js';
2
+ import * as React from 'react';
3
+ import { FlatList, View } from 'react-native';
4
+ import { createStyleSheet, useStyles } from '@btndprojects/loam-theme-native';
5
+ import { jsx, Fragment } from 'react/jsx-runtime';
6
+
7
+ function loadMoreIfNeeded(opts) {
8
+ if (opts.hasMore && !opts.loading) opts.onLoadMore();
9
+ }
10
+ var FOOTER_SPINNER_SIZE = "lg";
11
+ function Footer() {
12
+ const { styles } = useStyles(sheet);
13
+ return /* @__PURE__ */ jsx(View, { style: styles.footer, children: /* @__PURE__ */ jsx(Spinner, { size: FOOTER_SPINNER_SIZE, accessibilityLabel: "Loading more" }) });
14
+ }
15
+ function InfiniteList({
16
+ data,
17
+ renderItem,
18
+ keyExtractor,
19
+ onLoadMore,
20
+ hasMore = true,
21
+ loading = false,
22
+ onEndReachedThreshold = 0.2,
23
+ // Accepted for API parity but intentionally inert — a virtualized list must
24
+ // not animate (recycled rows would flicker). Destructured so it is never
25
+ // forwarded onto the underlying FlatList.
26
+ motion: _motion = "full"
27
+ }) {
28
+ const { styles } = useStyles(sheet);
29
+ const handleEndReached = React.useCallback(() => {
30
+ loadMoreIfNeeded({ hasMore, loading, onLoadMore });
31
+ }, [hasMore, loading, onLoadMore]);
32
+ const renderFlatItem = React.useCallback(
33
+ ({ item, index }) => /* @__PURE__ */ jsx(Fragment, { children: renderItem(item, index) }),
34
+ [renderItem]
35
+ );
36
+ return /* @__PURE__ */ jsx(
37
+ FlatList,
38
+ {
39
+ focusable: true,
40
+ data,
41
+ renderItem: renderFlatItem,
42
+ keyExtractor,
43
+ onEndReached: handleEndReached,
44
+ onEndReachedThreshold,
45
+ contentContainerStyle: styles.content,
46
+ ListFooterComponent: loading ? /* @__PURE__ */ jsx(Footer, {}) : null
47
+ }
48
+ );
49
+ }
50
+ var sheet = createStyleSheet((theme) => ({
51
+ content: {
52
+ gap: theme.space.s3,
53
+ padding: theme.space.s4
54
+ },
55
+ footer: {
56
+ alignItems: "center",
57
+ justifyContent: "center",
58
+ padding: theme.space.s4
59
+ }
60
+ }));
61
+
62
+ export { InfiniteList };