@btndprojects/loam-ui-native 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -2
  3. package/dist/accordion/index.js +3 -0
  4. package/dist/adaptive/index.js +2 -0
  5. package/dist/alert/index.js +3 -0
  6. package/dist/analyzer/index.js +6 -0
  7. package/dist/announcement/index.js +6 -0
  8. package/dist/audio-player/index.js +3 -0
  9. package/dist/avatar/index.js +3 -0
  10. package/dist/avatar-group/index.js +3 -0
  11. package/dist/badge/index.js +5 -0
  12. package/dist/banner/index.js +2 -0
  13. package/dist/board/index.js +7 -0
  14. package/dist/button/index.js +5 -0
  15. package/dist/camera-permission/index.js +13 -0
  16. package/dist/capture-result/index.js +18 -0
  17. package/dist/card/index.js +4 -0
  18. package/dist/card-form/index.js +10 -0
  19. package/dist/carousel/index.js +2 -0
  20. package/dist/chart/index.js +6 -0
  21. package/dist/charts/index.js +7 -0
  22. package/dist/checkbox/index.js +7 -0
  23. package/dist/checklist/index.js +10 -0
  24. package/dist/checkout/index.js +13 -0
  25. package/dist/chip/index.js +7 -0
  26. package/dist/chunk-223Q2T2Q.js +229 -0
  27. package/dist/chunk-2A5NIQAK.js +254 -0
  28. package/dist/chunk-2GK6PHGE.js +363 -0
  29. package/dist/chunk-2WUTXHMU.js +1 -0
  30. package/dist/chunk-2ZZ7TDJ4.js +324 -0
  31. package/dist/chunk-35OFI3JG.js +499 -0
  32. package/dist/chunk-3ARE4TES.js +195 -0
  33. package/dist/chunk-3ECPOSKO.js +1 -0
  34. package/dist/chunk-3ENTMPQY.js +229 -0
  35. package/dist/chunk-3HJH6FF4.js +98 -0
  36. package/dist/chunk-3NMD74ZU.js +4 -0
  37. package/dist/chunk-3WPW4KUN.js +182 -0
  38. package/dist/chunk-423B7SPN.js +993 -0
  39. package/dist/chunk-47FWHGUN.js +394 -0
  40. package/dist/chunk-4BXMXBJO.js +141 -0
  41. package/dist/chunk-4DS5ZWVC.js +83 -0
  42. package/dist/chunk-4GBOGOTV.js +295 -0
  43. package/dist/chunk-4SZYY6AN.js +99 -0
  44. package/dist/chunk-4YIP3CWS.js +237 -0
  45. package/dist/chunk-4YQOR7JM.js +204 -0
  46. package/dist/chunk-4ZAHCY44.js +177 -0
  47. package/dist/chunk-52X2VYTD.js +228 -0
  48. package/dist/chunk-5P26LBDL.js +1 -0
  49. package/dist/chunk-5XLRYDAX.js +1 -0
  50. package/dist/chunk-5YNTNN5A.js +177 -0
  51. package/dist/chunk-6HT2LP62.js +504 -0
  52. package/dist/chunk-6N33LFQA.js +35 -0
  53. package/dist/chunk-6X6PQ443.js +432 -0
  54. package/dist/chunk-7CFF4HXS.js +126 -0
  55. package/dist/chunk-7O2FMUPT.js +755 -0
  56. package/dist/chunk-AI4DWZCD.js +162 -0
  57. package/dist/chunk-AWJOCGFZ.js +213 -0
  58. package/dist/chunk-AZRX6SAC.js +285 -0
  59. package/dist/chunk-B54QE2FN.js +1 -0
  60. package/dist/chunk-BC475SJH.js +1 -0
  61. package/dist/chunk-BEDBFJND.js +202 -0
  62. package/dist/chunk-BTTFCMKG.js +166 -0
  63. package/dist/chunk-BV3B2HYZ.js +1635 -0
  64. package/dist/chunk-C2NTXVWM.js +98 -0
  65. package/dist/chunk-CDRZHT42.js +424 -0
  66. package/dist/chunk-CJ5EOYZE.js +62 -0
  67. package/dist/chunk-CUMUNPXY.js +128 -0
  68. package/dist/chunk-CUS3ZSCU.js +1 -0
  69. package/dist/chunk-CYRBHQQZ.js +411 -0
  70. package/dist/chunk-DHWADYZX.js +144 -0
  71. package/dist/chunk-DKCSPATL.js +1 -0
  72. package/dist/chunk-DM5QUKKO.js +326 -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-FMYDDECK.js +1521 -0
  80. package/dist/chunk-G3HOYSF7.js +1 -0
  81. package/dist/chunk-GDKZTW34.js +395 -0
  82. package/dist/chunk-GL7B2DOW.js +134 -0
  83. package/dist/chunk-GNNJ4GCC.js +471 -0
  84. package/dist/chunk-GNZ56EUI.js +1 -0
  85. package/dist/chunk-H6NIOQHK.js +346 -0
  86. package/dist/chunk-H6PC7RDA.js +1 -0
  87. package/dist/chunk-HET4LLMX.js +129 -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-HZ6CNMAF.js +870 -0
  92. package/dist/chunk-IIQTAY3J.js +715 -0
  93. package/dist/chunk-ITTYJZWX.js +271 -0
  94. package/dist/chunk-IVNRBPGC.js +1018 -0
  95. package/dist/chunk-J4KLDGI4.js +1 -0
  96. package/dist/chunk-J7Q7VCVC.js +254 -0
  97. package/dist/chunk-JDEOITQ2.js +1 -0
  98. package/dist/chunk-JNH2TYIN.js +96 -0
  99. package/dist/chunk-JNY4ZHAR.js +634 -0
  100. package/dist/chunk-JRLTGLN4.js +1 -0
  101. package/dist/chunk-JTRJJLKL.js +1 -0
  102. package/dist/chunk-JUAMLEHX.js +379 -0
  103. package/dist/chunk-JXJB2X6M.js +131 -0
  104. package/dist/chunk-KMI5ML5I.js +262 -0
  105. package/dist/chunk-KTAC4MGE.js +4 -0
  106. package/dist/chunk-LAECSR4H.js +178 -0
  107. package/dist/chunk-LK4BCSGX.js +1 -0
  108. package/dist/chunk-LOE5YNN3.js +470 -0
  109. package/dist/chunk-LRJNDEIA.js +302 -0
  110. package/dist/chunk-LSS54GLJ.js +116 -0
  111. package/dist/chunk-LZLHELAG.js +137 -0
  112. package/dist/chunk-M2LUXGKZ.js +1 -0
  113. package/dist/chunk-MOUJOP55.js +425 -0
  114. package/dist/chunk-N32RGOA5.js +159 -0
  115. package/dist/chunk-N5ZNE2YE.js +1 -0
  116. package/dist/chunk-NBNCBML6.js +1 -0
  117. package/dist/chunk-NKB7BZYK.js +167 -0
  118. package/dist/chunk-NQYBUO3K.js +1795 -0
  119. package/dist/chunk-NY2U3PBI.js +59 -0
  120. package/dist/chunk-O4AEHWII.js +464 -0
  121. package/dist/chunk-O7AE6DAF.js +146 -0
  122. package/dist/chunk-OETCUXQP.js +134 -0
  123. package/dist/chunk-OOPPQH27.js +179 -0
  124. package/dist/chunk-OPXFZ4Y5.js +204 -0
  125. package/dist/chunk-P23EQNRQ.js +338 -0
  126. package/dist/chunk-PJXUJYS6.js +248 -0
  127. package/dist/chunk-PNWUWOBF.js +1 -0
  128. package/dist/chunk-PUPM2YGF.js +376 -0
  129. package/dist/chunk-PZXZJBMP.js +620 -0
  130. package/dist/chunk-Q72LJOVE.js +169 -0
  131. package/dist/chunk-QCDXZBC5.js +247 -0
  132. package/dist/chunk-QDYDBCFP.js +197 -0
  133. package/dist/chunk-QJJ6MADV.js +274 -0
  134. package/dist/chunk-QKXCPTFS.js +349 -0
  135. package/dist/chunk-QWCMU5B2.js +860 -0
  136. package/dist/chunk-RIBDXGUG.js +108 -0
  137. package/dist/chunk-RJQOOHT2.js +214 -0
  138. package/dist/chunk-RNGLIHFA.js +191 -0
  139. package/dist/chunk-RQ3HASCC.js +6 -0
  140. package/dist/chunk-RSOJT5YW.js +124 -0
  141. package/dist/chunk-RTIKSY6A.js +1 -0
  142. package/dist/chunk-RUZHTGKB.js +237 -0
  143. package/dist/chunk-RW6ZL2FQ.js +284 -0
  144. package/dist/chunk-S7F6XLTK.js +540 -0
  145. package/dist/chunk-SBMNWWBV.js +155 -0
  146. package/dist/chunk-SDTQPRRB.js +1 -0
  147. package/dist/chunk-SYNOJOQO.js +377 -0
  148. package/dist/chunk-T753XT36.js +1 -0
  149. package/dist/chunk-TKQYWZ5V.js +196 -0
  150. package/dist/chunk-TKVFVF5D.js +95 -0
  151. package/dist/chunk-TOXAGRDQ.js +144 -0
  152. package/dist/chunk-TUTI5HOZ.js +112 -0
  153. package/dist/chunk-U7TFM2JA.js +140 -0
  154. package/dist/chunk-UC2WGUP3.js +627 -0
  155. package/dist/chunk-UWFLYMAR.js +1126 -0
  156. package/dist/chunk-UWSZB7BJ.js +1 -0
  157. package/dist/chunk-UYG5L34B.js +87 -0
  158. package/dist/chunk-VBOXAEPI.js +336 -0
  159. package/dist/chunk-VCDBXW5H.js +188 -0
  160. package/dist/chunk-VCXPHHDS.js +1 -0
  161. package/dist/chunk-VEAYTRPX.js +414 -0
  162. package/dist/chunk-VFCUIDRT.js +1 -0
  163. package/dist/chunk-VQHPQEUH.js +273 -0
  164. package/dist/chunk-VXDZFJGP.js +874 -0
  165. package/dist/chunk-WS56BL3D.js +1 -0
  166. package/dist/chunk-WSW6ZFAQ.js +98 -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-YTFKPRUK.js +845 -0
  181. package/dist/chunk-Z7H7VSFZ.js +323 -0
  182. package/dist/chunk-ZK2H4O5P.js +1 -0
  183. package/dist/chunk-ZVFE5QGU.js +524 -0
  184. package/dist/coachmark/index.js +4 -0
  185. package/dist/code-block/index.js +4 -0
  186. package/dist/color-field/index.js +7 -0
  187. package/dist/commerce/index.js +20 -0
  188. package/dist/connectivity/index.js +2 -0
  189. package/dist/context-menu/index.js +5 -0
  190. package/dist/copy-button/index.js +3 -0
  191. package/dist/data-grid/index.js +24 -0
  192. package/dist/date-range-picker/index.js +13 -0
  193. package/dist/description-list/index.js +2 -0
  194. package/dist/dialog/index.js +3 -0
  195. package/dist/empty-state/index.js +3 -0
  196. package/dist/error-summary/index.js +3 -0
  197. package/dist/fab/index.js +2 -0
  198. package/dist/file-upload/index.js +9 -0
  199. package/dist/filter-bar/index.js +8 -0
  200. package/dist/flow-run/index.js +14 -0
  201. package/dist/form/index.js +3 -0
  202. package/dist/gallery/index.js +2 -0
  203. package/dist/header/index.js +5 -0
  204. package/dist/hold-to-confirm/index.js +4 -0
  205. package/dist/index.d.ts +22883 -0
  206. package/dist/index.js +158 -0
  207. package/dist/infinite-list/index.js +2 -0
  208. package/dist/inline-edit/index.js +5 -0
  209. package/dist/input/index.js +5 -0
  210. package/dist/interactions/index.js +2 -0
  211. package/dist/invoice/index.js +10 -0
  212. package/dist/kbd/index.js +1 -0
  213. package/dist/keyboard/index.js +3 -0
  214. package/dist/list-row/index.js +7 -0
  215. package/dist/log-viewer/index.js +2 -0
  216. package/dist/map-view/index.js +3 -0
  217. package/dist/markdown/index.js +6 -0
  218. package/dist/metric/index.js +4 -0
  219. package/dist/money/index.js +3 -0
  220. package/dist/nav-drawer/index.js +2 -0
  221. package/dist/navigation/index.js +2 -0
  222. package/dist/notification-center/index.js +16 -0
  223. package/dist/number-roll/index.js +3 -0
  224. package/dist/one-handed/index.js +5 -0
  225. package/dist/os-surfaces/index.js +3 -0
  226. package/dist/otp/index.js +7 -0
  227. package/dist/page-header/index.js +1 -0
  228. package/dist/payment-method/index.js +12 -0
  229. package/dist/payment-status/index.js +16 -0
  230. package/dist/permission/index.js +2 -0
  231. package/dist/picker/index.js +7 -0
  232. package/dist/progress/index.js +5 -0
  233. package/dist/pull-to-refresh/index.js +4 -0
  234. package/dist/radio-group/index.js +6 -0
  235. package/dist/rating/index.js +2 -0
  236. package/dist/receivables/index.js +20 -0
  237. package/dist/refund/index.js +16 -0
  238. package/dist/save-status/index.js +3 -0
  239. package/dist/scroll-area/index.js +1 -0
  240. package/dist/search-bar/index.js +5 -0
  241. package/dist/segmented-control/index.js +5 -0
  242. package/dist/sheet/index.js +4 -0
  243. package/dist/skeleton/index.js +2 -0
  244. package/dist/slider/index.js +5 -0
  245. package/dist/spinner/index.js +2 -0
  246. package/dist/split-button/index.js +7 -0
  247. package/dist/spotlight/index.js +2 -0
  248. package/dist/stage-timeline/index.js +4 -0
  249. package/dist/status-dot/index.js +2 -0
  250. package/dist/stepper/index.js +6 -0
  251. package/dist/streaming-text/index.js +3 -0
  252. package/dist/survey/index.js +19 -0
  253. package/dist/switch/index.js +5 -0
  254. package/dist/system-state/index.js +4 -0
  255. package/dist/tab-bar/index.js +2 -0
  256. package/dist/tabs/index.js +2 -0
  257. package/dist/textarea/index.js +6 -0
  258. package/dist/thinking/index.js +2 -0
  259. package/dist/timeline/index.js +4 -0
  260. package/dist/toast/index.js +2 -0
  261. package/dist/toolbar/index.js +2 -0
  262. package/dist/tour/index.js +11 -0
  263. package/dist/truncation-notice/index.js +2 -0
  264. package/dist/update-notice/index.js +11 -0
  265. package/dist/video-player/index.js +2 -0
  266. package/dist/viewfinder/index.js +5 -0
  267. package/dist/widget/index.js +4 -0
  268. package/dist/wizard/index.js +6 -0
  269. package/package.json +76 -3
@@ -0,0 +1,627 @@
1
+ import { Sheet } from './chunk-ZVFE5QGU.js';
2
+ import { Input } from './chunk-ITTYJZWX.js';
3
+ import { Button } from './chunk-3ARE4TES.js';
4
+ import { Icon } from './chunk-TKVFVF5D.js';
5
+ import * as React2 from 'react';
6
+ import { ScrollView, View, Text, Pressable } from 'react-native';
7
+ import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
8
+ import { monthGrid, weekdayOrder, WEEKDAY_ABBR, dayDisabled, WEEKDAY_NAMES, dayLabel, dateZone, resolveDateValue, validateDateValue, DATE_PRESETS, PRESET_GROUP_ORDER, valueLabel, preset, timeLabel, durationLabel, stamp, rangeLabel, absolute, endOf } from '@btndprojects/loam-date';
9
+ import { jsx, jsxs } from 'react/jsx-runtime';
10
+
11
+ function MonthList({
12
+ Z,
13
+ anchorMs,
14
+ radius,
15
+ ctx,
16
+ from,
17
+ to,
18
+ constraints,
19
+ dayMeta,
20
+ weekNumbers = false,
21
+ onPick,
22
+ scrollNonce = 0
23
+ }) {
24
+ const { styles } = useStyles(sheet);
25
+ const months = React2.useMemo(() => {
26
+ const out = [];
27
+ for (let i = -radius; i <= radius; i += 1) {
28
+ out.push(monthGrid(Z, Z.addMonths(Z.startOfMonth(anchorMs), i), ctx));
29
+ }
30
+ return out;
31
+ }, [Z, anchorMs, radius, ctx]);
32
+ const order = weekdayOrder(ctx.weekStartsOn ?? 1);
33
+ const scroller = React2.useRef(null);
34
+ const offsets = React2.useRef([]);
35
+ const anchorKey = Z.monthKey(anchorMs);
36
+ React2.useEffect(() => {
37
+ const y = offsets.current[radius];
38
+ if (y != null) scroller.current?.scrollTo({ y, animated: false });
39
+ }, [anchorKey, radius, scrollNonce]);
40
+ const measure = (index) => (event) => {
41
+ offsets.current[index] = event.nativeEvent.layout.y;
42
+ if (index === radius) scroller.current?.scrollTo({ y: event.nativeEvent.layout.y, animated: false });
43
+ };
44
+ return /* @__PURE__ */ jsx(ScrollView, { ref: scroller, showsVerticalScrollIndicator: true, children: months.map((item, index) => /* @__PURE__ */ jsxs(View, { style: styles.month, onLayout: measure(index), children: [
45
+ /* @__PURE__ */ jsx(Text, { style: styles.monthLabel, role: "heading", ...{ "aria-level": 3 }, children: item.label }),
46
+ /* @__PURE__ */ jsxs(View, { style: styles.weekdayRow, children: [
47
+ weekNumbers ? /* @__PURE__ */ jsx(View, { style: styles.weekNumber }) : null,
48
+ order.map((dow) => /* @__PURE__ */ jsx(View, { style: styles.weekdayCell, children: /* @__PURE__ */ jsx(Text, { style: styles.weekdayText, ...{ "aria-hidden": true }, children: WEEKDAY_ABBR[dow] }) }, dow))
49
+ ] }),
50
+ item.weeks.map((week) => /* @__PURE__ */ jsxs(View, { style: styles.weekRow, children: [
51
+ weekNumbers ? /* @__PURE__ */ jsx(View, { style: styles.weekNumber, children: /* @__PURE__ */ jsx(Text, { style: styles.weekNumberText, children: week.week }) }) : null,
52
+ week.days.map(
53
+ (day) => (
54
+ // A day borrowed from the neighbouring month is **not** rendered
55
+ // as a cell here, unlike in the web picker's two-month view. In a
56
+ // continuous scroll that month is a thumb-flick away, so a
57
+ // borrowed day is not a shortcut — it is the same date appearing
58
+ // twice, pickable twice, and announced twice. The blank keeps the
59
+ // six-row height so the grid does not jump.
60
+ day.inMonth ? /* @__PURE__ */ jsx(
61
+ DayCell,
62
+ {
63
+ Z,
64
+ day,
65
+ ctx,
66
+ from,
67
+ to,
68
+ constraints,
69
+ meta: dayMeta?.(day.ms),
70
+ onPick
71
+ },
72
+ day.key
73
+ ) : /* @__PURE__ */ jsx(View, { style: styles.dayBlank }, day.key)
74
+ )
75
+ )
76
+ ] }, `${week.week}-${week.days[0].key}`))
77
+ ] }, `${item.y}-${item.mo}`)) });
78
+ }
79
+ function DayCell({
80
+ Z,
81
+ day,
82
+ ctx,
83
+ from,
84
+ to,
85
+ constraints,
86
+ meta,
87
+ onPick
88
+ }) {
89
+ const { styles } = useStyles(sheet);
90
+ const theme = useLoamTheme();
91
+ const reason = dayDisabled(Z, day.ms, constraints, ctx, meta);
92
+ const disabled = reason !== false || meta?.loading === true;
93
+ const today = Z.sameDay(day.ms, ctx.now ?? Date.now());
94
+ const dayEnd = Z.endOfDay(day.ms);
95
+ const isStart = from != null && Z.sameDay(day.ms, from);
96
+ const isEnd = to != null && Z.sameDay(day.ms, to - 1);
97
+ const inside = from != null && to != null && day.ms >= from && dayEnd < to;
98
+ const selection = isStart && isEnd ? "both" : isStart ? "start" : isEnd ? "end" : inside ? "inside" : "none";
99
+ const role = selection === "both" ? ", the whole range" : selection === "start" ? ", range start" : selection === "end" ? ", range end" : selection === "inside" ? ", in the range" : "";
100
+ const name = `${WEEKDAY_NAMES[day.dow]} ${dayLabel(Z, day.ms, { longMonth: true, locale: ctx.locale })}${today ? ", today" : ""}${role}${reason ? `, unavailable: ${reason}` : ""}`;
101
+ return /* @__PURE__ */ jsxs(
102
+ Pressable,
103
+ {
104
+ accessibilityRole: "button",
105
+ accessibilityLabel: name,
106
+ accessibilityState: { selected: selection !== "none", disabled },
107
+ disabled,
108
+ onPress: () => onPick(day.ms),
109
+ style: ({ pressed }) => [
110
+ styles.day,
111
+ inside && styles.dayInside,
112
+ (isStart || isEnd) && styles.dayEnd,
113
+ pressed && !disabled && styles.pressed
114
+ ],
115
+ children: [
116
+ /* @__PURE__ */ jsx(
117
+ Text,
118
+ {
119
+ style: [
120
+ styles.dayText,
121
+ today && styles.dayToday,
122
+ (isStart || isEnd) && styles.dayEndText,
123
+ disabled && styles.dayDisabled
124
+ ],
125
+ children: day.day
126
+ }
127
+ ),
128
+ meta?.density != null && meta.density > 0 ? /* @__PURE__ */ jsx(
129
+ View,
130
+ {
131
+ style: [
132
+ styles.densityBar,
133
+ {
134
+ height: Math.max(theme.borderWidth.heavy, Math.round(meta.density * theme.space.s2))
135
+ }
136
+ ]
137
+ }
138
+ ) : null
139
+ ]
140
+ }
141
+ );
142
+ }
143
+ var sheet = createStyleSheet((theme) => ({
144
+ month: { gap: theme.space.s1, paddingBottom: theme.space.s4 },
145
+ monthLabel: {
146
+ fontFamily: theme.font.sans,
147
+ fontSize: theme.type.headline.fontSize,
148
+ lineHeight: theme.type.headline.lineHeight,
149
+ fontWeight: theme.type.headline.fontWeight,
150
+ color: theme.color.text,
151
+ paddingVertical: theme.space.s1
152
+ },
153
+ weekdayRow: { flexDirection: "row" },
154
+ weekdayCell: { flex: 1, alignItems: "center", paddingVertical: theme.space[2] },
155
+ weekdayText: {
156
+ fontFamily: theme.font.sans,
157
+ fontSize: theme.type.caption2.fontSize,
158
+ lineHeight: theme.type.caption2.lineHeight,
159
+ color: theme.color.text2
160
+ },
161
+ weekRow: { flexDirection: "row", alignItems: "stretch" },
162
+ weekNumber: { width: theme.space.s6, alignItems: "center", justifyContent: "center" },
163
+ weekNumberText: {
164
+ fontFamily: theme.font.mono,
165
+ fontSize: theme.type.caption2.fontSize,
166
+ color: theme.color.text3
167
+ },
168
+ day: {
169
+ flex: 1,
170
+ minHeight: theme.tapMin,
171
+ alignItems: "center",
172
+ justifyContent: "center",
173
+ gap: theme.space[1]
174
+ },
175
+ // The in-range wash is a state layer, not a tint: it has to composite over the
176
+ // sheet surface and over a pressed cell without either turning muddy.
177
+ dayInside: { backgroundColor: theme.state.selected },
178
+ dayEnd: { backgroundColor: theme.color.accent, borderRadius: theme.radius.md },
179
+ dayText: {
180
+ fontFamily: theme.font.sans,
181
+ fontSize: theme.type.subheadline.fontSize,
182
+ lineHeight: theme.type.subheadline.lineHeight,
183
+ color: theme.color.text
184
+ },
185
+ dayBlank: { flex: 1, minHeight: theme.tapMin },
186
+ dayToday: { fontWeight: theme.fontWeight.bold, color: theme.color.accentOnSoft },
187
+ dayEndText: { color: theme.color.accentInk, fontWeight: theme.fontWeight.bold },
188
+ dayDisabled: { color: theme.color.text3, textDecorationLine: "line-through" },
189
+ densityBar: {
190
+ width: theme.space.s3,
191
+ borderRadius: theme.radius.full,
192
+ backgroundColor: theme.color.accent
193
+ },
194
+ pressed: { opacity: theme.state.pressedOpacity }
195
+ }));
196
+ var MONTH_RADIUS = 6;
197
+ function DateRangePicker({
198
+ value: controlled,
199
+ defaultValue = null,
200
+ onChange,
201
+ mode = "range",
202
+ label,
203
+ placeholder = "Any time",
204
+ presets = true,
205
+ customPresets,
206
+ constraints,
207
+ weekStartsOn = 1,
208
+ fiscalStart = 0,
209
+ weekNumbers = false,
210
+ time = false,
211
+ ampm,
212
+ locale,
213
+ timeZone,
214
+ now,
215
+ dayMeta,
216
+ clearable = true,
217
+ disabled = false,
218
+ applyMode = "apply",
219
+ style
220
+ }) {
221
+ const { styles } = useStyles(sheet2);
222
+ const theme = useLoamTheme();
223
+ const Z = React2.useMemo(() => dateZone(timeZone), [timeZone]);
224
+ const clock = now ?? Date.now();
225
+ const ctx = React2.useMemo(
226
+ () => ({
227
+ Z,
228
+ now: clock,
229
+ weekStartsOn,
230
+ fiscalStart,
231
+ granularity: time ? "minute" : "day",
232
+ ampm,
233
+ mode,
234
+ constraints,
235
+ placeholder,
236
+ time,
237
+ locale,
238
+ customPresets
239
+ }),
240
+ [Z, clock, weekStartsOn, fiscalStart, time, ampm, mode, constraints, placeholder, locale, customPresets]
241
+ );
242
+ const [internal, setInternal] = React2.useState(defaultValue);
243
+ const committed = controlled !== void 0 ? controlled : internal;
244
+ const [open, setOpen] = React2.useState(false);
245
+ const [draft, setDraft] = React2.useState(committed);
246
+ const [anchor, setAnchor] = React2.useState(null);
247
+ const [view, setView] = React2.useState(null);
248
+ const [viewNonce, setViewNonce] = React2.useState(0);
249
+ const openSheet = () => {
250
+ setDraft(committed);
251
+ setAnchor(null);
252
+ setView(null);
253
+ setOpen(true);
254
+ };
255
+ const resolved = React2.useMemo(() => resolveDateValue(draft, ctx), [draft, ctx]);
256
+ const committedResolved = React2.useMemo(
257
+ () => resolveDateValue(committed, ctx),
258
+ [committed, ctx]
259
+ );
260
+ const validation = React2.useMemo(() => validateDateValue(draft, ctx), [draft, ctx]);
261
+ const commit = React2.useCallback(
262
+ (next) => {
263
+ if (controlled === void 0) setInternal(next);
264
+ onChange?.(next, resolveDateValue(next, ctx));
265
+ },
266
+ [controlled, onChange, ctx]
267
+ );
268
+ const setDraftValue = (next) => {
269
+ setDraft(next);
270
+ setView(null);
271
+ if (applyMode === "live") commit(next);
272
+ };
273
+ const [startClock, setStartClock] = React2.useState(null);
274
+ const [endClock, setEndClock] = React2.useState(null);
275
+ const pick = (ms) => {
276
+ const dayStart = Z.startOfDay(ms);
277
+ if (mode === "single") {
278
+ setAnchor(null);
279
+ setDraftValue(
280
+ absolute(
281
+ withTime(Z, dayStart, startClock),
282
+ time ? withTime(Z, dayStart, endClock ?? startClock) : endOf(Z, dayStart, "day", ctx),
283
+ ctx.granularity
284
+ )
285
+ );
286
+ return;
287
+ }
288
+ if (anchor === null) {
289
+ setAnchor(dayStart);
290
+ setDraftValue(absolute(withTime(Z, dayStart, startClock), null, ctx.granularity));
291
+ return;
292
+ }
293
+ const [a, b] = dayStart < anchor ? [dayStart, anchor] : [anchor, dayStart];
294
+ setAnchor(null);
295
+ setDraftValue(
296
+ absolute(
297
+ withTime(Z, a, startClock),
298
+ // The end is **exclusive**: a range that ends "on the 7th" runs to
299
+ // midnight on the 8th. `displayEnd` is what turns that back into "7th"
300
+ // for the reader, and it is the one place that conversion happens.
301
+ time ? withTime(Z, b, endClock) : endOf(Z, b, "day", ctx),
302
+ ctx.granularity
303
+ )
304
+ );
305
+ };
306
+ const applyClock = (which, text) => {
307
+ const minutes = parseClock(text);
308
+ if (which === "start") setStartClock(minutes);
309
+ else setEndClock(minutes);
310
+ if (minutes === null || resolved.from == null) return;
311
+ const from = which === "start" ? withTime(Z, resolved.from, minutes) : resolved.from;
312
+ const to = which === "end" && resolved.to != null ? withTime(Z, Z.startOfDay(resolved.to - 1), minutes) : resolved.to;
313
+ setDraftValue(absolute(from, to, ctx.granularity));
314
+ };
315
+ const rail = React2.useMemo(() => {
316
+ if (presets === false) return [];
317
+ const all = [...DATE_PRESETS, ...customPresets ?? []];
318
+ const allowed = Array.isArray(presets) ? all.filter((p) => presets.includes(p.id)) : all;
319
+ return allowed.filter(
320
+ (p) => (
321
+ // A future preset in a field that refuses the future is a chip that only
322
+ // ever produces a refusal.
323
+ (!p.future || !constraints?.disableFuture) && (!p.time || time)
324
+ )
325
+ );
326
+ }, [presets, customPresets, constraints?.disableFuture, time]);
327
+ const railGroups = React2.useMemo(() => {
328
+ const byGroup = /* @__PURE__ */ new Map();
329
+ for (const p of rail) {
330
+ const list = byGroup.get(p.group) ?? [];
331
+ list.push(p);
332
+ byGroup.set(p.group, list);
333
+ }
334
+ return PRESET_GROUP_ORDER.filter((g) => byGroup.has(g)).map((g) => ({
335
+ group: g,
336
+ items: byGroup.get(g)
337
+ }));
338
+ }, [rail]);
339
+ const activePreset = resolved.presetId ?? null;
340
+ const triggerLabel = valueLabel(committed, ctx);
341
+ const anchorMs = view ?? resolved.from ?? committedResolved.from ?? clock;
342
+ return /* @__PURE__ */ jsxs(View, { style: [styles.root, style], children: [
343
+ label ? /* @__PURE__ */ jsx(Text, { style: styles.fieldLabel, children: label }) : null,
344
+ /* @__PURE__ */ jsxs(
345
+ Pressable,
346
+ {
347
+ accessibilityRole: "button",
348
+ accessibilityLabel: label ? `${label}, ${triggerLabel}` : triggerLabel,
349
+ accessibilityHint: "Double tap to change the date range",
350
+ accessibilityState: { disabled },
351
+ disabled,
352
+ onPress: openSheet,
353
+ style: ({ pressed }) => [
354
+ styles.trigger,
355
+ disabled && styles.triggerDisabled,
356
+ pressed && styles.pressed
357
+ ],
358
+ children: [
359
+ /* @__PURE__ */ jsx(Icon, { name: "calendar", size: theme.icon.sm, color: theme.color.text2 }),
360
+ /* @__PURE__ */ jsx(
361
+ Text,
362
+ {
363
+ numberOfLines: 1,
364
+ style: [styles.triggerText, !committed && styles.triggerPlaceholder],
365
+ children: triggerLabel
366
+ }
367
+ ),
368
+ committed && !committedResolved.exact ? /* @__PURE__ */ jsx(Icon, { name: "refresh", size: theme.icon.xs, color: theme.color.text3 }) : null,
369
+ /* @__PURE__ */ jsx(Icon, { name: "chevron-down", size: theme.icon.sm, color: theme.color.text2 })
370
+ ]
371
+ }
372
+ ),
373
+ /* @__PURE__ */ jsx(
374
+ Sheet,
375
+ {
376
+ open,
377
+ onClose: () => setOpen(false),
378
+ title: label ?? (mode === "single" ? "Pick a date" : "Pick a range"),
379
+ detents: ["half", "full"],
380
+ children: /* @__PURE__ */ jsxs(View, { style: styles.panel, children: [
381
+ railGroups.length > 0 ? /* @__PURE__ */ jsx(
382
+ ScrollView,
383
+ {
384
+ horizontal: true,
385
+ showsHorizontalScrollIndicator: false,
386
+ contentContainerStyle: styles.rail,
387
+ children: railGroups.map(({ group, items }) => /* @__PURE__ */ jsxs(View, { style: styles.railGroup, children: [
388
+ /* @__PURE__ */ jsx(Text, { style: styles.railGroupLabel, children: group }),
389
+ /* @__PURE__ */ jsx(View, { style: styles.railChips, children: items.map((p) => {
390
+ const on = activePreset === p.id;
391
+ return /* @__PURE__ */ jsx(
392
+ Pressable,
393
+ {
394
+ accessibilityRole: "button",
395
+ accessibilityState: { selected: on },
396
+ accessibilityLabel: p.label,
397
+ onPress: () => {
398
+ setAnchor(null);
399
+ setDraftValue(preset(p.id));
400
+ },
401
+ style: ({ pressed }) => [
402
+ styles.chip,
403
+ on && styles.chipOn,
404
+ pressed && styles.pressed
405
+ ],
406
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.chipText, on && styles.chipTextOn], children: p.label })
407
+ },
408
+ p.id
409
+ );
410
+ }) })
411
+ ] }, group))
412
+ }
413
+ ) : null,
414
+ /* @__PURE__ */ jsx(View, { style: styles.calendar, children: /* @__PURE__ */ jsx(
415
+ MonthList,
416
+ {
417
+ Z,
418
+ anchorMs,
419
+ radius: MONTH_RADIUS,
420
+ ctx,
421
+ from: anchor ?? resolved.from,
422
+ to: anchor === null ? resolved.to : null,
423
+ constraints,
424
+ dayMeta,
425
+ weekNumbers,
426
+ scrollNonce: viewNonce,
427
+ onPick: pick
428
+ }
429
+ ) }),
430
+ time ? /* @__PURE__ */ jsxs(View, { style: styles.clocks, children: [
431
+ /* @__PURE__ */ jsx(
432
+ Input,
433
+ {
434
+ size: "sm",
435
+ style: styles.clock,
436
+ placeholder: "09:00",
437
+ accessibilityLabel: "Start time, 24-hour",
438
+ defaultValue: resolved.from != null ? timeLabel(Z, resolved.from, false) : "",
439
+ onChangeText: (text) => applyClock("start", text)
440
+ }
441
+ ),
442
+ /* @__PURE__ */ jsx(Text, { style: styles.clockDash, children: "to" }),
443
+ /* @__PURE__ */ jsx(
444
+ Input,
445
+ {
446
+ size: "sm",
447
+ style: styles.clock,
448
+ placeholder: "17:00",
449
+ accessibilityLabel: "End time, 24-hour",
450
+ defaultValue: resolved.to != null ? timeLabel(Z, resolved.to, false) : "",
451
+ onChangeText: (text) => applyClock("end", text)
452
+ }
453
+ )
454
+ ] }) : null,
455
+ /* @__PURE__ */ jsx(Receipt, { Z, resolved, ctx, validation, anchor }),
456
+ /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
457
+ clearable ? /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: () => setDraftValue(null), children: "Clear" }) : null,
458
+ /* @__PURE__ */ jsx(
459
+ Button,
460
+ {
461
+ variant: "ghost",
462
+ size: "sm",
463
+ onPress: () => {
464
+ setView(clock);
465
+ setViewNonce((n) => n + 1);
466
+ },
467
+ children: "Go to today"
468
+ }
469
+ ),
470
+ /* @__PURE__ */ jsx(View, { style: styles.footerSpacer }),
471
+ /* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: () => setOpen(false), children: "Cancel" }),
472
+ /* @__PURE__ */ jsx(
473
+ Button,
474
+ {
475
+ size: "sm",
476
+ disabled: !validation.ok || anchor !== null,
477
+ onPress: () => {
478
+ commit(draft);
479
+ setOpen(false);
480
+ },
481
+ children: "Apply"
482
+ }
483
+ )
484
+ ] })
485
+ ] })
486
+ }
487
+ )
488
+ ] });
489
+ }
490
+ function Receipt({
491
+ Z,
492
+ resolved,
493
+ ctx,
494
+ validation,
495
+ anchor
496
+ }) {
497
+ const { styles } = useStyles(sheet2);
498
+ const duration = durationLabel(resolved.from, resolved.to);
499
+ const half = anchor !== null;
500
+ return /* @__PURE__ */ jsxs(
501
+ View,
502
+ {
503
+ style: styles.receipt,
504
+ role: "status",
505
+ ...{ "aria-live": "polite" },
506
+ children: [
507
+ /* @__PURE__ */ jsx(Text, { style: styles.receiptRange, children: half ? `${stamp(Z, anchor, ctx)} \u2014 pick the other end` : rangeLabel(Z, resolved.from, resolved.to, ctx) }),
508
+ !half && duration ? /* @__PURE__ */ jsx(Text, { style: styles.receiptMeta, children: duration }) : null,
509
+ !half && resolved.kind && !resolved.exact ? /* @__PURE__ */ jsx(Text, { style: styles.receiptMeta, children: "Re-resolves on load" }) : null,
510
+ validation.message ? /* @__PURE__ */ jsx(Text, { style: validation.ok ? styles.receiptWarn : styles.receiptError, children: validation.message }) : null
511
+ ]
512
+ }
513
+ );
514
+ }
515
+ function withTime(Z, ms, minutes) {
516
+ const start = Z.startOfDay(ms);
517
+ return minutes === null ? start : start + minutes * 6e4;
518
+ }
519
+ function parseClock(text) {
520
+ const match = /^(\d{1,2}):(\d{2})$/.exec(text.trim());
521
+ if (!match) return null;
522
+ const h = Number(match[1]);
523
+ const mi = Number(match[2]);
524
+ if (h > 23 || mi > 59) return null;
525
+ return h * 60 + mi;
526
+ }
527
+ var sheet2 = createStyleSheet((theme) => ({
528
+ root: { alignSelf: "stretch", gap: theme.space.s1 },
529
+ fieldLabel: {
530
+ fontFamily: theme.font.sans,
531
+ fontSize: theme.type.footnote.fontSize,
532
+ lineHeight: theme.type.footnote.lineHeight,
533
+ color: theme.color.text2
534
+ },
535
+ trigger: {
536
+ flexDirection: "row",
537
+ alignItems: "center",
538
+ gap: theme.space.s2,
539
+ minHeight: theme.tapMin,
540
+ paddingHorizontal: theme.space.s3,
541
+ borderRadius: theme.radius.md,
542
+ borderWidth: theme.borderWidth.thick,
543
+ borderColor: theme.color.border,
544
+ backgroundColor: theme.color.surface
545
+ },
546
+ triggerDisabled: { opacity: theme.state.disabledOpacity },
547
+ triggerText: {
548
+ flex: 1,
549
+ fontFamily: theme.font.sans,
550
+ fontSize: theme.type.body.fontSize,
551
+ lineHeight: theme.type.body.lineHeight,
552
+ color: theme.color.text
553
+ },
554
+ triggerPlaceholder: { color: theme.color.text3 },
555
+ panel: { gap: theme.space.s3 },
556
+ rail: { gap: theme.space.s4, paddingBottom: theme.space.s1 },
557
+ railGroup: { gap: theme.space.s1 },
558
+ railGroupLabel: {
559
+ fontFamily: theme.font.sans,
560
+ fontSize: theme.type.caption2.fontSize,
561
+ lineHeight: theme.type.caption2.lineHeight,
562
+ fontWeight: theme.fontWeight.bold,
563
+ color: theme.color.text2
564
+ },
565
+ railChips: { flexDirection: "row", gap: theme.space.s1 },
566
+ chip: {
567
+ minHeight: theme.tapMin,
568
+ justifyContent: "center",
569
+ paddingHorizontal: theme.space.s3,
570
+ borderRadius: theme.radius.full,
571
+ borderWidth: theme.borderWidth.base,
572
+ borderColor: theme.color.border,
573
+ backgroundColor: theme.color.surface
574
+ },
575
+ chipOn: { borderColor: theme.edge.accent, backgroundColor: theme.color.accentSoft },
576
+ chipText: {
577
+ fontFamily: theme.font.sans,
578
+ fontSize: theme.type.footnote.fontSize,
579
+ lineHeight: theme.type.footnote.lineHeight,
580
+ color: theme.color.text
581
+ },
582
+ chipTextOn: { color: theme.color.accentOnSoft, fontWeight: theme.fontWeight.bold },
583
+ calendar: { height: theme.space[256], minHeight: theme.space[224] },
584
+ clocks: { flexDirection: "row", alignItems: "center", gap: theme.space.s2 },
585
+ clock: { flex: 1 },
586
+ clockDash: {
587
+ fontFamily: theme.font.sans,
588
+ fontSize: theme.type.footnote.fontSize,
589
+ color: theme.color.text2
590
+ },
591
+ receipt: {
592
+ gap: theme.space[2],
593
+ padding: theme.space.s3,
594
+ borderRadius: theme.radius.lg,
595
+ backgroundColor: theme.color.surface2
596
+ },
597
+ receiptRange: {
598
+ fontFamily: theme.font.sans,
599
+ fontSize: theme.type.callout.fontSize,
600
+ lineHeight: theme.type.callout.lineHeight,
601
+ fontWeight: theme.fontWeight.bold,
602
+ color: theme.color.text
603
+ },
604
+ receiptMeta: {
605
+ fontFamily: theme.font.sans,
606
+ fontSize: theme.type.caption1.fontSize,
607
+ lineHeight: theme.type.caption1.lineHeight,
608
+ color: theme.color.text2
609
+ },
610
+ receiptWarn: {
611
+ fontFamily: theme.font.sans,
612
+ fontSize: theme.type.caption1.fontSize,
613
+ lineHeight: theme.type.caption1.lineHeight,
614
+ color: theme.color.warnOnSoft
615
+ },
616
+ receiptError: {
617
+ fontFamily: theme.font.sans,
618
+ fontSize: theme.type.caption1.fontSize,
619
+ lineHeight: theme.type.caption1.lineHeight,
620
+ color: theme.color.dangerOnSoft
621
+ },
622
+ footer: { flexDirection: "row", alignItems: "center", gap: theme.space.s1 },
623
+ footerSpacer: { flex: 1 },
624
+ pressed: { opacity: theme.state.pressedOpacity }
625
+ }));
626
+
627
+ export { DateRangePicker, MonthList };