@btndprojects/loam-ui-native 0.1.0 → 0.2.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.
- package/README.md +56 -0
- package/dist/accordion/index.js +5 -3
- package/dist/adaptive/index.js +6 -2
- package/dist/alert/index.js +5 -2
- package/dist/analyzer/index.js +9 -6
- package/dist/announcement/index.js +8 -5
- package/dist/audio-player/index.js +5 -3
- package/dist/avatar/index.js +5 -2
- package/dist/avatar-group/index.js +7 -3
- package/dist/badge/index.js +7 -4
- package/dist/banner/index.js +5 -2
- package/dist/board/index.js +11 -6
- package/dist/button/index.js +6 -3
- package/dist/camera-permission/index.js +15 -12
- package/dist/capture-result/index.js +19 -16
- package/dist/card/index.js +6 -3
- package/dist/card-form/index.js +12 -8
- package/dist/carousel/index.js +4 -2
- package/dist/chart/index.js +8 -5
- package/dist/charts/index.js +8 -6
- package/dist/chat/index.js +16 -0
- package/dist/checkbox/index.js +6 -4
- package/dist/checklist/index.js +11 -8
- package/dist/checkout/index.js +16 -11
- package/dist/chip/index.js +7 -4
- package/dist/{chunk-XNUVB5OL.js → chunk-2OLKPG4E.js} +92 -28
- package/dist/{chunk-RUZHTGKB.js → chunk-2PKYGLQ6.js} +71 -40
- package/dist/{chunk-UC2WGUP3.js → chunk-2SWKL3AJ.js} +91 -252
- package/dist/{chunk-AI4DWZCD.js → chunk-2SY63FCH.js} +63 -16
- package/dist/{chunk-F5XNPWS7.js → chunk-2TXERVVA.js} +92 -35
- package/dist/chunk-36EC2T6P.js +581 -0
- package/dist/chunk-3DUWIYV5.js +437 -0
- package/dist/{chunk-RGQWWKLA.js → chunk-3QMEOFW5.js} +275 -71
- package/dist/chunk-3WEZCGHX.js +265 -0
- package/dist/chunk-46MMSDGL.js +194 -0
- package/dist/{chunk-7O2FMUPT.js → chunk-4IZXHVFJ.js} +297 -92
- package/dist/{chunk-LAECSR4H.js → chunk-5LAAAXFP.js} +14 -8
- package/dist/{chunk-2A5NIQAK.js → chunk-5RENVKBQ.js} +134 -46
- package/dist/{chunk-2ZZ7TDJ4.js → chunk-5UTRIXQ6.js} +37 -31
- package/dist/{chunk-LOE5YNN3.js → chunk-5VFZRGVD.js} +37 -10
- package/dist/{chunk-52X2VYTD.js → chunk-67IZZ2MJ.js} +115 -60
- package/dist/{chunk-UYG5L34B.js → chunk-6YAQBXB3.js} +10 -4
- package/dist/{chunk-BTTFCMKG.js → chunk-74FLKD24.js} +94 -23
- package/dist/{chunk-ITTYJZWX.js → chunk-7BUIKDD6.js} +73 -18
- package/dist/{chunk-FOKG57CR.js → chunk-7OVVSVEZ.js} +273 -109
- package/dist/chunk-AEB7KCHQ.js +287 -0
- package/dist/chunk-APCWFOZW.js +28 -0
- package/dist/chunk-AWKQIE5I.js +139 -0
- package/dist/{chunk-VCDBXW5H.js → chunk-B7N4ASYE.js} +86 -42
- package/dist/{chunk-IVNRBPGC.js → chunk-C4GTDLRC.js} +104 -20
- package/dist/{chunk-4ZAHCY44.js → chunk-C6APNDVA.js} +12 -5
- package/dist/{chunk-4SZYY6AN.js → chunk-CMTVNF3D.js} +18 -13
- package/dist/{chunk-WVKKJA6U.js → chunk-CPTOADB2.js} +151 -96
- package/dist/chunk-D5N5QWI7.js +1325 -0
- package/dist/{chunk-IIQTAY3J.js → chunk-DN7MNQIP.js} +113 -29
- package/dist/{chunk-47FWHGUN.js → chunk-DVGBZ3TX.js} +84 -23
- package/dist/chunk-DW3L54DQ.js +305 -0
- package/dist/{chunk-3ARE4TES.js → chunk-E2E3I5W2.js} +69 -18
- package/dist/{chunk-DHWADYZX.js → chunk-EDCBJV7J.js} +41 -28
- package/dist/{chunk-WSW6ZFAQ.js → chunk-ENP3BMZU.js} +4 -4
- package/dist/{chunk-OOPPQH27.js → chunk-EVOIGUBI.js} +43 -19
- package/dist/{chunk-VEAYTRPX.js → chunk-EY4DD67D.js} +165 -97
- package/dist/{chunk-223Q2T2Q.js → chunk-F3H33DQX.js} +132 -61
- package/dist/{chunk-CYRBHQQZ.js → chunk-F5B3UINI.js} +68 -35
- package/dist/{chunk-6X6PQ443.js → chunk-FAJI7BSC.js} +20 -9
- package/dist/{chunk-MOUJOP55.js → chunk-FUMHAAF3.js} +96 -29
- package/dist/{chunk-6HT2LP62.js → chunk-FV6HMP7W.js} +192 -73
- package/dist/{chunk-S7F6XLTK.js → chunk-FYWNRX4F.js} +76 -47
- package/dist/{chunk-YG3ZJHGU.js → chunk-FZGAAOKS.js} +30 -8
- package/dist/{chunk-YDGVJETP.js → chunk-G3AFC24V.js} +1 -1
- package/dist/{chunk-EJBDRVIH.js → chunk-G6UESEVN.js} +15 -8
- package/dist/chunk-GDKVKNR2.js +339 -0
- package/dist/chunk-GEIGMWNF.js +10 -0
- package/dist/{chunk-JUAMLEHX.js → chunk-H7DWSL4O.js} +24 -12
- package/dist/chunk-HJFFOOJ4.js +1 -0
- package/dist/{chunk-RW6ZL2FQ.js → chunk-HJLPZA4X.js} +106 -21
- package/dist/chunk-HYEOQWT7.js +647 -0
- package/dist/chunk-I2KLQ2HA.js +19 -0
- package/dist/{chunk-CJ5EOYZE.js → chunk-I4FHVKEC.js} +11 -5
- package/dist/{chunk-JNH2TYIN.js → chunk-IDM7JJMO.js} +19 -5
- package/dist/{chunk-O4AEHWII.js → chunk-IPUNJMAQ.js} +141 -49
- package/dist/{chunk-J7Q7VCVC.js → chunk-IT6FUXXG.js} +13 -6
- package/dist/{chunk-QJJ6MADV.js → chunk-IVKMZ7BB.js} +80 -28
- package/dist/{chunk-Z7H7VSFZ.js → chunk-IXKWIFWZ.js} +17 -6
- package/dist/chunk-J64KGCGX.js +55 -0
- package/dist/chunk-JBMLWFSJ.js +270 -0
- package/dist/{chunk-4BXMXBJO.js → chunk-JJLPBRVZ.js} +22 -11
- package/dist/chunk-JLC6PM5S.js +406 -0
- package/dist/chunk-JUYWSSKW.js +335 -0
- package/dist/{chunk-7CFF4HXS.js → chunk-JV5YOTOB.js} +49 -11
- package/dist/{chunk-LZLHELAG.js → chunk-KFJGFLMW.js} +29 -8
- package/dist/{chunk-O7AE6DAF.js → chunk-KQZ3GLHR.js} +18 -8
- package/dist/{chunk-N32RGOA5.js → chunk-LKFC4CS7.js} +80 -24
- package/dist/{chunk-YC6WORFL.js → chunk-LMPHCVJJ.js} +82 -50
- package/dist/{chunk-3WPW4KUN.js → chunk-LQP4KEXZ.js} +45 -13
- package/dist/{chunk-TKQYWZ5V.js → chunk-LUMVGO2K.js} +47 -31
- package/dist/{chunk-AWJOCGFZ.js → chunk-M656FYNH.js} +25 -13
- package/dist/{chunk-35OFI3JG.js → chunk-MKSNFG7H.js} +73 -20
- package/dist/{chunk-4GBOGOTV.js → chunk-NBEF4EPJ.js} +16 -6
- package/dist/chunk-NNCOFLNE.js +24 -0
- package/dist/{chunk-4YQOR7JM.js → chunk-NTQ2F3AU.js} +73 -20
- package/dist/{chunk-QCDXZBC5.js → chunk-O5V4TG3V.js} +126 -44
- package/dist/{chunk-U7TFM2JA.js → chunk-OJQUBQWA.js} +3 -3
- package/dist/{chunk-VQHPQEUH.js → chunk-OWAMM2DK.js} +13 -6
- package/dist/chunk-PID3NJB7.js +405 -0
- package/dist/{chunk-66SG2H23.js → chunk-PMMTGBBS.js} +27 -17
- package/dist/{chunk-RIBDXGUG.js → chunk-PNF3NKB5.js} +49 -16
- package/dist/{chunk-JXJB2X6M.js → chunk-Q6NKEPRE.js} +81 -32
- package/dist/chunk-QDZGFXQD.js +176 -0
- package/dist/{chunk-SYNOJOQO.js → chunk-QEYFDRHR.js} +60 -26
- package/dist/{chunk-VBOXAEPI.js → chunk-QHAITQIF.js} +97 -22
- package/dist/{chunk-VXDZFJGP.js → chunk-QHTVYA65.js} +230 -76
- package/dist/{chunk-TUTI5HOZ.js → chunk-QIKT7LIB.js} +14 -8
- package/dist/{chunk-3ENTMPQY.js → chunk-QP3KMOVF.js} +82 -42
- package/dist/{chunk-GNNJ4GCC.js → chunk-QPWDDJJ4.js} +62 -148
- package/dist/{chunk-QWCMU5B2.js → chunk-QRUMA22E.js} +205 -80
- package/dist/{chunk-ZVFE5QGU.js → chunk-QYPE5JX3.js} +50 -10
- package/dist/{chunk-PUPM2YGF.js → chunk-ROCUG24E.js} +76 -36
- package/dist/{chunk-NQYBUO3K.js → chunk-RU3ZPNL6.js} +333 -142
- package/dist/{chunk-TOXAGRDQ.js → chunk-RXSCIO6W.js} +14 -5
- package/dist/{chunk-FIF2M24N.js → chunk-SATMR6SG.js} +631 -203
- package/dist/{chunk-4YIP3CWS.js → chunk-SHHY5OMK.js} +7 -5
- package/dist/chunk-SKWO3SZF.js +2284 -0
- package/dist/{chunk-YF4NSSMT.js → chunk-SWS5JQIF.js} +41 -13
- package/dist/{chunk-CUMUNPXY.js → chunk-T5LTPKX6.js} +15 -7
- package/dist/{chunk-H6NIOQHK.js → chunk-TDMG26JI.js} +26 -6
- package/dist/{chunk-UWFLYMAR.js → chunk-TLCIR6RG.js} +267 -126
- package/dist/{chunk-SBMNWWBV.js → chunk-TN2ZNJUI.js} +47 -9
- package/dist/{chunk-5YNTNN5A.js → chunk-TQVAIKFD.js} +106 -41
- package/dist/chunk-TRGFFU6A.js +1456 -0
- package/dist/{chunk-2GK6PHGE.js → chunk-TY4MTKQJ.js} +100 -22
- package/dist/{chunk-AZRX6SAC.js → chunk-U23FYWME.js} +15 -7
- package/dist/{chunk-PZXZJBMP.js → chunk-U5NLHYV6.js} +26 -12
- package/dist/chunk-UQEN55EY.js +1 -0
- package/dist/chunk-UQGBTPXH.js +218 -0
- package/dist/chunk-UXGIW7OK.js +116 -0
- package/dist/{chunk-PJXUJYS6.js → chunk-UYGDJWMN.js} +55 -30
- package/dist/{chunk-QDYDBCFP.js → chunk-V2OEB75Z.js} +50 -51
- package/dist/{chunk-LSS54GLJ.js → chunk-VAOAKWUK.js} +34 -13
- package/dist/{chunk-DM5QUKKO.js → chunk-VDPK5CY4.js} +18 -6
- package/dist/chunk-W23G6JLF.js +37 -0
- package/dist/{chunk-CDRZHT42.js → chunk-W63AJTM7.js} +276 -12
- package/dist/{chunk-XXXEFXY5.js → chunk-W74TXYFB.js} +13 -5
- package/dist/{chunk-LRJNDEIA.js → chunk-WRDSPUE7.js} +144 -29
- package/dist/{chunk-C2NTXVWM.js → chunk-XBZGDDMR.js} +11 -4
- package/dist/{chunk-BV3B2HYZ.js → chunk-XIDTBCBA.js} +189 -131
- package/dist/{chunk-DSJBXLUG.js → chunk-XN4KG3P4.js} +348 -153
- package/dist/chunk-XQXMLMH3.js +211 -0
- package/dist/{chunk-HPPW424V.js → chunk-XTORZWRF.js} +19 -8
- package/dist/{chunk-P23EQNRQ.js → chunk-YAAHPATV.js} +181 -30
- package/dist/{chunk-KMI5ML5I.js → chunk-YXOAPXMU.js} +57 -18
- package/dist/{chunk-RJQOOHT2.js → chunk-ZECZOOSB.js} +59 -28
- package/dist/{chunk-QKXCPTFS.js → chunk-ZLTO5VQI.js} +121 -31
- package/dist/{chunk-BEDBFJND.js → chunk-ZVATDZOM.js} +16 -18
- package/dist/coachmark/index.js +6 -3
- package/dist/code-block/index.js +5 -3
- package/dist/color-field/index.js +6 -4
- package/dist/commerce/index.js +19 -16
- package/dist/connectivity/index.js +5 -2
- package/dist/context-menu/index.js +5 -3
- package/dist/copy-button/index.js +4 -2
- package/dist/data-grid/index.js +21 -16
- package/dist/date-range-picker/index.js +11 -8
- package/dist/description-list/index.js +3 -1
- package/dist/dialog/index.js +4 -2
- package/dist/empty-state/index.js +4 -2
- package/dist/error-summary/index.js +4 -2
- package/dist/fab/index.js +5 -2
- package/dist/file-manager/index.js +28 -0
- package/dist/file-upload/index.js +10 -7
- package/dist/filter-bar/index.js +9 -6
- package/dist/flow-run/index.js +15 -12
- package/dist/form/index.js +5 -3
- package/dist/gallery/index.js +5 -2
- package/dist/hold-to-confirm/index.js +4 -2
- package/dist/index.d.ts +9557 -2985
- package/dist/index.js +355 -122
- package/dist/infinite-list/index.js +4 -2
- package/dist/inline-edit/index.js +6 -4
- package/dist/input/index.js +5 -3
- package/dist/interactions/index.js +2 -1
- package/dist/invoice/index.js +13 -9
- package/dist/kbd/index.js +5 -1
- package/dist/keyboard/index.js +4 -2
- package/dist/list-row/index.js +6 -4
- package/dist/log-viewer/index.js +4 -2
- package/dist/map-view/index.js +5 -3
- package/dist/markdown/index.js +9 -6
- package/dist/metric/index.js +7 -4
- package/dist/money/index.js +9 -3
- package/dist/nav-drawer/index.js +4 -2
- package/dist/nav-header/index.js +9 -0
- package/dist/navigation/index.js +5 -2
- package/dist/notification-center/index.js +12 -10
- package/dist/number-roll/index.js +5 -2
- package/dist/one-handed/index.js +5 -3
- package/dist/os-surfaces/index.js +6 -3
- package/dist/otp/index.js +7 -4
- package/dist/page-header/index.js +1 -0
- package/dist/pagination/index.js +6 -0
- package/dist/payment-method/index.js +14 -10
- package/dist/payment-status/index.js +17 -14
- package/dist/permission/index.js +5 -2
- package/dist/picker/index.js +11 -6
- package/dist/progress/index.js +6 -3
- package/dist/pull-to-refresh/index.js +4 -2
- package/dist/radio-group/index.js +6 -4
- package/dist/rating/index.js +5 -2
- package/dist/receivables/index.js +21 -16
- package/dist/refund/index.js +18 -14
- package/dist/save-status/index.js +5 -3
- package/dist/scroll-area/index.js +3 -1
- package/dist/search-field/index.js +8 -0
- package/dist/segmented-control/index.js +4 -3
- package/dist/sheet/index.js +5 -3
- package/dist/skeleton/index.js +3 -1
- package/dist/slider/index.js +4 -2
- package/dist/sortable/index.js +7 -0
- package/dist/spinner/index.js +3 -1
- package/dist/split-button/index.js +9 -6
- package/dist/spotlight/index.js +3 -1
- package/dist/stage-timeline/index.js +5 -3
- package/dist/status-dot/index.js +4 -2
- package/dist/stepper/index.js +7 -4
- package/dist/streaming-text/index.js +3 -2
- package/dist/survey/index.js +18 -15
- package/dist/switch/index.js +5 -3
- package/dist/system-state/index.js +7 -4
- package/dist/tab-bar/index.js +5 -2
- package/dist/tabs/index.js +4 -2
- package/dist/tags-input/index.js +10 -0
- package/dist/textarea/index.js +6 -4
- package/dist/thinking/index.js +3 -1
- package/dist/time-field/index.js +12 -0
- package/dist/time-range-control/index.js +22 -0
- package/dist/timeline/index.js +4 -2
- package/dist/toast/index.js +4 -2
- package/dist/toolbar/index.js +4 -2
- package/dist/tour/index.js +12 -9
- package/dist/truncation-notice/index.js +5 -2
- package/dist/update-notice/index.js +12 -9
- package/dist/video-player/index.js +5 -2
- package/dist/viewfinder/index.js +6 -4
- package/dist/widget/index.js +7 -4
- package/dist/wizard/index.js +7 -4
- package/package.json +13 -12
- package/dist/chunk-6N33LFQA.js +0 -35
- package/dist/chunk-GDKZTW34.js +0 -395
- package/dist/chunk-GL7B2DOW.js +0 -134
- package/dist/chunk-NKB7BZYK.js +0 -167
- package/dist/chunk-OETCUXQP.js +0 -134
- package/dist/chunk-OPXFZ4Y5.js +0 -204
- package/dist/chunk-Q72LJOVE.js +0 -169
- package/dist/chunk-RNGLIHFA.js +0 -191
- package/dist/chunk-RQ3HASCC.js +0 -6
- package/dist/chunk-RSOJT5YW.js +0 -124
- package/dist/chunk-TKVFVF5D.js +0 -95
- package/dist/chunk-XOSCY2CW.js +0 -242
- package/dist/header/index.js +0 -5
- package/dist/search-bar/index.js +0 -5
- /package/dist/{chunk-3ECPOSKO.js → chunk-3UG6JUCV.js} +0 -0
- /package/dist/{chunk-JRLTGLN4.js → chunk-5WWRTEPS.js} +0 -0
- /package/dist/{chunk-RTIKSY6A.js → chunk-5Z5ZYMOJ.js} +0 -0
|
@@ -1,198 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
1
|
+
import { DEFAULT_LABELS, MonthList } from './chunk-DW3L54DQ.js';
|
|
2
|
+
import { Sheet } from './chunk-QYPE5JX3.js';
|
|
3
|
+
import { Input } from './chunk-7BUIKDD6.js';
|
|
4
|
+
import { Button } from './chunk-E2E3I5W2.js';
|
|
5
|
+
import { useLabels, useLoamLocale } from './chunk-APCWFOZW.js';
|
|
6
|
+
import { Icon } from './chunk-UXGIW7OK.js';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { View, Text, Pressable, ScrollView } from 'react-native';
|
|
7
9
|
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
+
import { dateZone, resolveDateValue, validateDateValue, DATE_PRESETS, PRESET_GROUP_ORDER, valueLabel, presetGroupLabel, presetLabel, preset, timeLabel, durationLabel, stamp, rangeLabel, absolute, endOf } from '@btndprojects/loam-date';
|
|
11
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
10
12
|
|
|
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
13
|
var MONTH_RADIUS = 6;
|
|
197
14
|
function DateRangePicker({
|
|
198
15
|
value: controlled,
|
|
@@ -200,7 +17,7 @@ function DateRangePicker({
|
|
|
200
17
|
onChange,
|
|
201
18
|
mode = "range",
|
|
202
19
|
label,
|
|
203
|
-
placeholder
|
|
20
|
+
placeholder: placeholderProp,
|
|
204
21
|
presets = true,
|
|
205
22
|
customPresets,
|
|
206
23
|
constraints,
|
|
@@ -209,20 +26,26 @@ function DateRangePicker({
|
|
|
209
26
|
weekNumbers = false,
|
|
210
27
|
time = false,
|
|
211
28
|
ampm,
|
|
212
|
-
locale,
|
|
29
|
+
locale: localeProp,
|
|
213
30
|
timeZone,
|
|
214
31
|
now,
|
|
215
32
|
dayMeta,
|
|
216
33
|
clearable = true,
|
|
217
34
|
disabled = false,
|
|
218
35
|
applyMode = "apply",
|
|
219
|
-
style
|
|
36
|
+
style,
|
|
37
|
+
motion = "full",
|
|
38
|
+
labels: labelsProp
|
|
220
39
|
}) {
|
|
221
|
-
const { styles } = useStyles(
|
|
222
|
-
const
|
|
223
|
-
const
|
|
40
|
+
const { styles } = useStyles(sheet);
|
|
41
|
+
const labels = useLabels("dateRangePicker", DEFAULT_LABELS, labelsProp);
|
|
42
|
+
const contextLocale = useLoamLocale();
|
|
43
|
+
const locale = localeProp ?? contextLocale;
|
|
44
|
+
const placeholder = placeholderProp ?? labels.anyTime;
|
|
45
|
+
const theme = useLoamTheme("date-range-picker");
|
|
46
|
+
const Z = React.useMemo(() => dateZone(timeZone), [timeZone]);
|
|
224
47
|
const clock = now ?? Date.now();
|
|
225
|
-
const ctx =
|
|
48
|
+
const ctx = React.useMemo(
|
|
226
49
|
() => ({
|
|
227
50
|
Z,
|
|
228
51
|
now: clock,
|
|
@@ -235,30 +58,41 @@ function DateRangePicker({
|
|
|
235
58
|
placeholder,
|
|
236
59
|
time,
|
|
237
60
|
locale,
|
|
238
|
-
customPresets
|
|
61
|
+
customPresets,
|
|
62
|
+
labels
|
|
239
63
|
}),
|
|
240
|
-
[
|
|
64
|
+
[
|
|
65
|
+
Z,
|
|
66
|
+
clock,
|
|
67
|
+
weekStartsOn,
|
|
68
|
+
fiscalStart,
|
|
69
|
+
time,
|
|
70
|
+
ampm,
|
|
71
|
+
mode,
|
|
72
|
+
constraints,
|
|
73
|
+
placeholder,
|
|
74
|
+
locale,
|
|
75
|
+
customPresets,
|
|
76
|
+
labels
|
|
77
|
+
]
|
|
241
78
|
);
|
|
242
|
-
const [internal, setInternal] =
|
|
79
|
+
const [internal, setInternal] = React.useState(defaultValue);
|
|
243
80
|
const committed = controlled !== void 0 ? controlled : internal;
|
|
244
|
-
const [open, setOpen] =
|
|
245
|
-
const [draft, setDraft] =
|
|
246
|
-
const [anchor, setAnchor] =
|
|
247
|
-
const [view, setView] =
|
|
248
|
-
const [viewNonce, setViewNonce] =
|
|
81
|
+
const [open, setOpen] = React.useState(false);
|
|
82
|
+
const [draft, setDraft] = React.useState(committed);
|
|
83
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
84
|
+
const [view, setView] = React.useState(null);
|
|
85
|
+
const [viewNonce, setViewNonce] = React.useState(0);
|
|
249
86
|
const openSheet = () => {
|
|
250
87
|
setDraft(committed);
|
|
251
88
|
setAnchor(null);
|
|
252
89
|
setView(null);
|
|
253
90
|
setOpen(true);
|
|
254
91
|
};
|
|
255
|
-
const resolved =
|
|
256
|
-
const committedResolved =
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
);
|
|
260
|
-
const validation = React2.useMemo(() => validateDateValue(draft, ctx), [draft, ctx]);
|
|
261
|
-
const commit = React2.useCallback(
|
|
92
|
+
const resolved = React.useMemo(() => resolveDateValue(draft, ctx), [draft, ctx]);
|
|
93
|
+
const committedResolved = React.useMemo(() => resolveDateValue(committed, ctx), [committed, ctx]);
|
|
94
|
+
const validation = React.useMemo(() => validateDateValue(draft, ctx), [draft, ctx]);
|
|
95
|
+
const commit = React.useCallback(
|
|
262
96
|
(next) => {
|
|
263
97
|
if (controlled === void 0) setInternal(next);
|
|
264
98
|
onChange?.(next, resolveDateValue(next, ctx));
|
|
@@ -270,8 +104,8 @@ function DateRangePicker({
|
|
|
270
104
|
setView(null);
|
|
271
105
|
if (applyMode === "live") commit(next);
|
|
272
106
|
};
|
|
273
|
-
const [startClock, setStartClock] =
|
|
274
|
-
const [endClock, setEndClock] =
|
|
107
|
+
const [startClock, setStartClock] = React.useState(null);
|
|
108
|
+
const [endClock, setEndClock] = React.useState(null);
|
|
275
109
|
const pick = (ms) => {
|
|
276
110
|
const dayStart = Z.startOfDay(ms);
|
|
277
111
|
if (mode === "single") {
|
|
@@ -312,7 +146,7 @@ function DateRangePicker({
|
|
|
312
146
|
const to = which === "end" && resolved.to != null ? withTime(Z, Z.startOfDay(resolved.to - 1), minutes) : resolved.to;
|
|
313
147
|
setDraftValue(absolute(from, to, ctx.granularity));
|
|
314
148
|
};
|
|
315
|
-
const rail =
|
|
149
|
+
const rail = React.useMemo(() => {
|
|
316
150
|
if (presets === false) return [];
|
|
317
151
|
const all = [...DATE_PRESETS, ...customPresets ?? []];
|
|
318
152
|
const allowed = Array.isArray(presets) ? all.filter((p) => presets.includes(p.id)) : all;
|
|
@@ -324,7 +158,7 @@ function DateRangePicker({
|
|
|
324
158
|
)
|
|
325
159
|
);
|
|
326
160
|
}, [presets, customPresets, constraints?.disableFuture, time]);
|
|
327
|
-
const railGroups =
|
|
161
|
+
const railGroups = React.useMemo(() => {
|
|
328
162
|
const byGroup = /* @__PURE__ */ new Map();
|
|
329
163
|
for (const p of rail) {
|
|
330
164
|
const list = byGroup.get(p.group) ?? [];
|
|
@@ -345,8 +179,8 @@ function DateRangePicker({
|
|
|
345
179
|
Pressable,
|
|
346
180
|
{
|
|
347
181
|
accessibilityRole: "button",
|
|
348
|
-
accessibilityLabel: label ?
|
|
349
|
-
accessibilityHint:
|
|
182
|
+
accessibilityLabel: label ? labels.triggerNamed(label, triggerLabel) : triggerLabel,
|
|
183
|
+
accessibilityHint: labels.triggerHint,
|
|
350
184
|
accessibilityState: { disabled },
|
|
351
185
|
disabled,
|
|
352
186
|
onPress: openSheet,
|
|
@@ -375,7 +209,7 @@ function DateRangePicker({
|
|
|
375
209
|
{
|
|
376
210
|
open,
|
|
377
211
|
onClose: () => setOpen(false),
|
|
378
|
-
title: label ?? (mode === "single" ?
|
|
212
|
+
title: label ?? (mode === "single" ? labels.pickDate : labels.pickRange),
|
|
379
213
|
detents: ["half", "full"],
|
|
380
214
|
children: /* @__PURE__ */ jsxs(View, { style: styles.panel, children: [
|
|
381
215
|
railGroups.length > 0 ? /* @__PURE__ */ jsx(
|
|
@@ -385,7 +219,7 @@ function DateRangePicker({
|
|
|
385
219
|
showsHorizontalScrollIndicator: false,
|
|
386
220
|
contentContainerStyle: styles.rail,
|
|
387
221
|
children: railGroups.map(({ group, items }) => /* @__PURE__ */ jsxs(View, { style: styles.railGroup, children: [
|
|
388
|
-
/* @__PURE__ */ jsx(Text, { style: styles.railGroupLabel, children: group }),
|
|
222
|
+
/* @__PURE__ */ jsx(Text, { style: styles.railGroupLabel, children: presetGroupLabel(group, labels) }),
|
|
389
223
|
/* @__PURE__ */ jsx(View, { style: styles.railChips, children: items.map((p) => {
|
|
390
224
|
const on = activePreset === p.id;
|
|
391
225
|
return /* @__PURE__ */ jsx(
|
|
@@ -393,7 +227,7 @@ function DateRangePicker({
|
|
|
393
227
|
{
|
|
394
228
|
accessibilityRole: "button",
|
|
395
229
|
accessibilityState: { selected: on },
|
|
396
|
-
accessibilityLabel: p
|
|
230
|
+
accessibilityLabel: presetLabel(p, labels),
|
|
397
231
|
onPress: () => {
|
|
398
232
|
setAnchor(null);
|
|
399
233
|
setDraftValue(preset(p.id));
|
|
@@ -403,7 +237,7 @@ function DateRangePicker({
|
|
|
403
237
|
on && styles.chipOn,
|
|
404
238
|
pressed && styles.pressed
|
|
405
239
|
],
|
|
406
|
-
children: /* @__PURE__ */ jsx(Text, { style: [styles.chipText, on && styles.chipTextOn], children: p
|
|
240
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles.chipText, on && styles.chipTextOn], children: presetLabel(p, labels) })
|
|
407
241
|
},
|
|
408
242
|
p.id
|
|
409
243
|
);
|
|
@@ -424,6 +258,8 @@ function DateRangePicker({
|
|
|
424
258
|
dayMeta,
|
|
425
259
|
weekNumbers,
|
|
426
260
|
scrollNonce: viewNonce,
|
|
261
|
+
motion,
|
|
262
|
+
labels,
|
|
427
263
|
onPick: pick
|
|
428
264
|
}
|
|
429
265
|
) }),
|
|
@@ -434,27 +270,37 @@ function DateRangePicker({
|
|
|
434
270
|
size: "sm",
|
|
435
271
|
style: styles.clock,
|
|
436
272
|
placeholder: "09:00",
|
|
437
|
-
accessibilityLabel:
|
|
273
|
+
accessibilityLabel: labels.startTime,
|
|
438
274
|
defaultValue: resolved.from != null ? timeLabel(Z, resolved.from, false) : "",
|
|
439
275
|
onChangeText: (text) => applyClock("start", text)
|
|
440
276
|
}
|
|
441
277
|
),
|
|
442
|
-
/* @__PURE__ */ jsx(Text, { style: styles.clockDash, children:
|
|
278
|
+
/* @__PURE__ */ jsx(Text, { style: styles.clockDash, children: labels.timeTo }),
|
|
443
279
|
/* @__PURE__ */ jsx(
|
|
444
280
|
Input,
|
|
445
281
|
{
|
|
446
282
|
size: "sm",
|
|
447
283
|
style: styles.clock,
|
|
448
284
|
placeholder: "17:00",
|
|
449
|
-
accessibilityLabel:
|
|
285
|
+
accessibilityLabel: labels.endTime,
|
|
450
286
|
defaultValue: resolved.to != null ? timeLabel(Z, resolved.to, false) : "",
|
|
451
287
|
onChangeText: (text) => applyClock("end", text)
|
|
452
288
|
}
|
|
453
289
|
)
|
|
454
290
|
] }) : null,
|
|
455
|
-
/* @__PURE__ */ jsx(
|
|
291
|
+
/* @__PURE__ */ jsx(
|
|
292
|
+
Receipt,
|
|
293
|
+
{
|
|
294
|
+
Z,
|
|
295
|
+
resolved,
|
|
296
|
+
ctx,
|
|
297
|
+
validation,
|
|
298
|
+
anchor,
|
|
299
|
+
labels
|
|
300
|
+
}
|
|
301
|
+
),
|
|
456
302
|
/* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
|
|
457
|
-
clearable ? /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: () => setDraftValue(null), children:
|
|
303
|
+
clearable ? /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", onPress: () => setDraftValue(null), children: labels.clearButton }) : null,
|
|
458
304
|
/* @__PURE__ */ jsx(
|
|
459
305
|
Button,
|
|
460
306
|
{
|
|
@@ -464,11 +310,11 @@ function DateRangePicker({
|
|
|
464
310
|
setView(clock);
|
|
465
311
|
setViewNonce((n) => n + 1);
|
|
466
312
|
},
|
|
467
|
-
children:
|
|
313
|
+
children: labels.goToToday
|
|
468
314
|
}
|
|
469
315
|
),
|
|
470
316
|
/* @__PURE__ */ jsx(View, { style: styles.footerSpacer }),
|
|
471
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: () => setOpen(false), children:
|
|
317
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", size: "sm", onPress: () => setOpen(false), children: labels.cancel }),
|
|
472
318
|
/* @__PURE__ */ jsx(
|
|
473
319
|
Button,
|
|
474
320
|
{
|
|
@@ -478,7 +324,7 @@ function DateRangePicker({
|
|
|
478
324
|
commit(draft);
|
|
479
325
|
setOpen(false);
|
|
480
326
|
},
|
|
481
|
-
children:
|
|
327
|
+
children: labels.apply
|
|
482
328
|
}
|
|
483
329
|
)
|
|
484
330
|
] })
|
|
@@ -492,25 +338,18 @@ function Receipt({
|
|
|
492
338
|
resolved,
|
|
493
339
|
ctx,
|
|
494
340
|
validation,
|
|
495
|
-
anchor
|
|
341
|
+
anchor,
|
|
342
|
+
labels
|
|
496
343
|
}) {
|
|
497
|
-
const { styles } = useStyles(
|
|
498
|
-
const duration = durationLabel(resolved.from, resolved.to);
|
|
344
|
+
const { styles } = useStyles(sheet);
|
|
345
|
+
const duration = durationLabel(resolved.from, resolved.to, labels);
|
|
499
346
|
const half = anchor !== null;
|
|
500
|
-
return /* @__PURE__ */ jsxs(
|
|
501
|
-
|
|
502
|
-
{
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
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
|
-
);
|
|
347
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.receipt, role: "status", accessibilityLiveRegion: "polite", children: [
|
|
348
|
+
/* @__PURE__ */ jsx(Text, { style: styles.receiptRange, children: half ? labels.pickOtherEnd(stamp(Z, anchor, ctx)) : rangeLabel(Z, resolved.from, resolved.to, ctx) }),
|
|
349
|
+
!half && duration ? /* @__PURE__ */ jsx(Text, { style: styles.receiptMeta, children: duration }) : null,
|
|
350
|
+
!half && resolved.kind && !resolved.exact ? /* @__PURE__ */ jsx(Text, { style: styles.receiptMeta, children: labels.reResolvesNote }) : null,
|
|
351
|
+
validation.message ? /* @__PURE__ */ jsx(Text, { style: validation.ok ? styles.receiptWarn : styles.receiptError, children: validation.message }) : null
|
|
352
|
+
] });
|
|
514
353
|
}
|
|
515
354
|
function withTime(Z, ms, minutes) {
|
|
516
355
|
const start = Z.startOfDay(ms);
|
|
@@ -524,7 +363,7 @@ function parseClock(text) {
|
|
|
524
363
|
if (h > 23 || mi > 59) return null;
|
|
525
364
|
return h * 60 + mi;
|
|
526
365
|
}
|
|
527
|
-
var
|
|
366
|
+
var sheet = createStyleSheet((theme) => ({
|
|
528
367
|
root: { alignSelf: "stretch", gap: theme.space.s1 },
|
|
529
368
|
fieldLabel: {
|
|
530
369
|
fontFamily: theme.font.sans,
|
|
@@ -624,4 +463,4 @@ var sheet2 = createStyleSheet((theme) => ({
|
|
|
624
463
|
pressed: { opacity: theme.state.pressedOpacity }
|
|
625
464
|
}));
|
|
626
465
|
|
|
627
|
-
export { DateRangePicker
|
|
466
|
+
export { DateRangePicker };
|
|
@@ -1,14 +1,38 @@
|
|
|
1
|
-
import { useColorTransition } from './chunk-
|
|
1
|
+
import { useColorTransition } from './chunk-7BUIKDD6.js';
|
|
2
|
+
import { NAMED_ROLE } from './chunk-W23G6JLF.js';
|
|
2
3
|
import { haptics } from './chunk-NY2U3PBI.js';
|
|
3
|
-
import {
|
|
4
|
-
import { Icon } from './chunk-
|
|
4
|
+
import { useLabels } from './chunk-APCWFOZW.js';
|
|
5
|
+
import { Icon } from './chunk-UXGIW7OK.js';
|
|
6
|
+
import { useResolvedMotion, springConfig } from './chunk-J64KGCGX.js';
|
|
5
7
|
import * as React from 'react';
|
|
6
|
-
import { Easing, Animated, Text, Pressable, View } from 'react-native';
|
|
8
|
+
import { Easing, Animated, Text, Pressable, View, LayoutAnimation } from 'react-native';
|
|
7
9
|
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
8
10
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
9
11
|
|
|
12
|
+
function SlideIn({ children }) {
|
|
13
|
+
const theme = useLoamTheme("chip");
|
|
14
|
+
const p = React.useRef(new Animated.Value(0)).current;
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
Animated.spring(p, { ...springConfig(theme, "fs"), toValue: 1, useNativeDriver: true }).start();
|
|
17
|
+
}, [p, theme]);
|
|
18
|
+
const from = theme.rtl ? 6 : -6;
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
Animated.View,
|
|
21
|
+
{
|
|
22
|
+
style: {
|
|
23
|
+
opacity: p.interpolate({ inputRange: [0, 1], outputRange: [0, 1], extrapolate: "clamp" }),
|
|
24
|
+
transform: [{ translateX: p.interpolate({ inputRange: [0, 1], outputRange: [from, 0] }) }]
|
|
25
|
+
},
|
|
26
|
+
children
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
var DEFAULT_LABELS = {
|
|
31
|
+
remove: "Remove",
|
|
32
|
+
removeNamed: (name) => `Remove ${name}`
|
|
33
|
+
};
|
|
10
34
|
function useForeground(variant, isSelected) {
|
|
11
|
-
const theme = useLoamTheme();
|
|
35
|
+
const theme = useLoamTheme("chip");
|
|
12
36
|
if (isSelected) return theme.color.accentOnSoft;
|
|
13
37
|
if (variant === "input") return theme.color.onSurface;
|
|
14
38
|
return theme.color.onSurface2;
|
|
@@ -29,16 +53,18 @@ function Chip({
|
|
|
29
53
|
leadingIcon,
|
|
30
54
|
disabled = false,
|
|
31
55
|
motion = "full",
|
|
32
|
-
accessibilityLabel
|
|
56
|
+
accessibilityLabel,
|
|
57
|
+
labels: labelsProp
|
|
33
58
|
}) {
|
|
34
|
-
const
|
|
59
|
+
const labels = useLabels("chip", DEFAULT_LABELS, labelsProp);
|
|
60
|
+
const resolvedMotion = useResolvedMotion(motion, "chip");
|
|
35
61
|
const animateColour = resolvedMotion !== "none";
|
|
36
62
|
const animatePress = resolvedMotion === "full";
|
|
37
63
|
const variant = variantProp === "filled" ? "input" : variantProp === "outline" ? "filter" : variantProp ?? (legacySelectable ? "filter" : "input");
|
|
38
64
|
const isFilter = variant === "filter";
|
|
39
65
|
const isSelected = isFilter && selected;
|
|
40
66
|
const { styles } = useStyles(sheet, { size, disabled });
|
|
41
|
-
const theme = useLoamTheme();
|
|
67
|
+
const theme = useLoamTheme("chip");
|
|
42
68
|
const fg = useForeground(variant, isSelected);
|
|
43
69
|
const iconSize = theme.ctl.icon[size];
|
|
44
70
|
const slopY = Math.max(0, (theme.hit[size] - theme.ctl[size]) / 2);
|
|
@@ -47,18 +73,18 @@ function Chip({
|
|
|
47
73
|
const restingFill = variant === "input" ? theme.color.surface2 : theme.color.surface;
|
|
48
74
|
const backgroundColor = useColorTransition(
|
|
49
75
|
isSelected ? theme.color.accentSoft : restingFill,
|
|
50
|
-
theme.duration
|
|
76
|
+
theme.spring.fe.duration,
|
|
51
77
|
easing,
|
|
52
78
|
animateColour
|
|
53
79
|
);
|
|
54
80
|
const edgeTarget = isSelected ? theme.color.accent : variant === "input" ? theme.color.border : theme.color.borderStrong;
|
|
55
|
-
const borderColor = useColorTransition(edgeTarget, theme.duration
|
|
81
|
+
const borderColor = useColorTransition(edgeTarget, theme.spring.fe.duration, easing, animateColour);
|
|
56
82
|
const borderWidth = variant === "input" ? theme.borderWidth.base : theme.borderWidth.thick;
|
|
57
83
|
const scale = React.useRef(new Animated.Value(1)).current;
|
|
58
84
|
const spring = (to) => Animated.spring(scale, {
|
|
85
|
+
...springConfig(theme, "fs"),
|
|
59
86
|
toValue: to,
|
|
60
|
-
useNativeDriver: true
|
|
61
|
-
...theme.spring.press
|
|
87
|
+
useNativeDriver: true
|
|
62
88
|
}).start();
|
|
63
89
|
const handlePress = () => {
|
|
64
90
|
if (isFilter) {
|
|
@@ -70,12 +96,20 @@ function Chip({
|
|
|
70
96
|
};
|
|
71
97
|
const handleRemove = (event) => {
|
|
72
98
|
event.stopPropagation();
|
|
99
|
+
if (animatePress) {
|
|
100
|
+
const fs = theme.spring.fs;
|
|
101
|
+
LayoutAnimation.configureNext({
|
|
102
|
+
duration: fs.duration,
|
|
103
|
+
update: { type: "spring", springDamping: fs.dampingRatio },
|
|
104
|
+
delete: { type: "easeInEaseOut", property: "opacity" }
|
|
105
|
+
});
|
|
106
|
+
}
|
|
73
107
|
onRemove?.();
|
|
74
108
|
};
|
|
75
109
|
const leading = isSelected ? "check" : leadingIcon;
|
|
76
|
-
const resolvedRemoveLabel = removeLabel ?? (children ?
|
|
110
|
+
const resolvedRemoveLabel = removeLabel ?? (children ? labels.removeNamed(children) : labels.remove);
|
|
77
111
|
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
-
leading ? /* @__PURE__ */ jsx(Icon, { name: leading, size: iconSize, color: fg }) : null,
|
|
112
|
+
leading ? isSelected && animatePress ? /* @__PURE__ */ jsx(SlideIn, { children: /* @__PURE__ */ jsx(Icon, { name: leading, size: iconSize, color: fg }) }) : /* @__PURE__ */ jsx(Icon, { name: leading, size: iconSize, color: fg }) : null,
|
|
79
113
|
children !== void 0 ? /* @__PURE__ */ jsx(Text, { style: [styles.label, { color: fg }], children }) : null
|
|
80
114
|
] });
|
|
81
115
|
return /* @__PURE__ */ jsxs(
|
|
@@ -98,13 +132,26 @@ function Chip({
|
|
|
98
132
|
style: styles.body,
|
|
99
133
|
children: body
|
|
100
134
|
}
|
|
101
|
-
) : /* @__PURE__ */ jsx(
|
|
135
|
+
) : /* @__PURE__ */ jsx(
|
|
136
|
+
View,
|
|
137
|
+
{
|
|
138
|
+
accessibilityRole: NAMED_ROLE,
|
|
139
|
+
accessibilityLabel: accessibilityLabel ?? children,
|
|
140
|
+
style: styles.body,
|
|
141
|
+
children: body
|
|
142
|
+
}
|
|
143
|
+
),
|
|
102
144
|
removable ? /* @__PURE__ */ jsx(
|
|
103
145
|
Pressable,
|
|
104
146
|
{
|
|
105
147
|
accessibilityRole: "button",
|
|
106
148
|
accessibilityLabel: resolvedRemoveLabel,
|
|
107
|
-
hitSlop:
|
|
149
|
+
hitSlop: {
|
|
150
|
+
top: Math.max(8, (theme.tapMin - iconSize) / 2),
|
|
151
|
+
bottom: Math.max(8, (theme.tapMin - iconSize) / 2),
|
|
152
|
+
left: theme.space[2],
|
|
153
|
+
right: theme.space[2]
|
|
154
|
+
},
|
|
108
155
|
disabled,
|
|
109
156
|
onPress: disabled ? void 0 : handleRemove,
|
|
110
157
|
children: /* @__PURE__ */ jsx(Icon, { name: "x", size: iconSize, color: fg })
|