@btndprojects/loam-ui-native 0.1.1 → 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/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-JNY4ZHAR.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-423B7SPN.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-HZ6CNMAF.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-HET4LLMX.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-FMYDDECK.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-YTFKPRUK.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
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { useLabels } from './chunk-APCWFOZW.js';
|
|
2
|
+
import { Icon } from './chunk-UXGIW7OK.js';
|
|
3
|
+
import { useResolvedMotion, motionTiming, springConfig, project, rubberband } from './chunk-J64KGCGX.js';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { View, ScrollView, Pressable, Text, Animated, PanResponder, Modal, Easing } from 'react-native';
|
|
6
|
+
import { createStyleSheet, useStyles, useLoamTheme } from '@btndprojects/loam-theme-native';
|
|
7
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
8
|
+
|
|
9
|
+
var DOT = {
|
|
10
|
+
/** Width of the active dot. */
|
|
11
|
+
activeWidth: 16,
|
|
12
|
+
/** Width of an inactive dot. */
|
|
13
|
+
idleWidth: 5
|
|
14
|
+
};
|
|
15
|
+
function Dot({ active }) {
|
|
16
|
+
const { styles } = useStyles(sheet);
|
|
17
|
+
const theme = useLoamTheme("gallery");
|
|
18
|
+
const progress = React.useRef(new Animated.Value(active ? 1 : 0)).current;
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
Animated.timing(progress, {
|
|
21
|
+
toValue: active ? 1 : 0,
|
|
22
|
+
duration: theme.duration.base,
|
|
23
|
+
easing: Easing.bezier(...theme.easing.base),
|
|
24
|
+
useNativeDriver: false
|
|
25
|
+
}).start();
|
|
26
|
+
}, [active, progress, theme.duration.base, theme.easing.base]);
|
|
27
|
+
return /* @__PURE__ */ jsx(
|
|
28
|
+
Animated.View,
|
|
29
|
+
{
|
|
30
|
+
style: [
|
|
31
|
+
styles.dot,
|
|
32
|
+
{
|
|
33
|
+
width: progress.interpolate({
|
|
34
|
+
inputRange: [0, 1],
|
|
35
|
+
outputRange: [DOT.idleWidth, DOT.activeWidth]
|
|
36
|
+
}),
|
|
37
|
+
// The carousel sits on imagery, so the dots use the mode-invariant
|
|
38
|
+
// media ink rather than a surface token: an indicator that inverted
|
|
39
|
+
// with the mode would vanish over a bright photo. The idle dot is the
|
|
40
|
+
// 0.38 alpha stop — the same value the system dims a disabled control
|
|
41
|
+
// to. Both were `#ffffff` / `rgba(255,255,255,0.4)` literals in the
|
|
42
|
+
// module constant above, which is why they could not follow a theme.
|
|
43
|
+
backgroundColor: progress.interpolate({
|
|
44
|
+
inputRange: [0, 1],
|
|
45
|
+
outputRange: [theme.white.a10, theme.media.ink]
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
var DEFAULT_LABELS = {
|
|
53
|
+
item: (position) => `Item ${position}`,
|
|
54
|
+
counter: (position, count) => `${position} / ${count}`,
|
|
55
|
+
close: "Close",
|
|
56
|
+
previous: "Previous image",
|
|
57
|
+
next: "Next image",
|
|
58
|
+
placeholder: (position, aspectRatio) => `Image ${position} \xB7 ${aspectRatio}`
|
|
59
|
+
};
|
|
60
|
+
function Gallery({
|
|
61
|
+
items,
|
|
62
|
+
columns = 3,
|
|
63
|
+
lightbox = true,
|
|
64
|
+
onSelect,
|
|
65
|
+
labels: labelsProp
|
|
66
|
+
}) {
|
|
67
|
+
const { styles } = useStyles(sheet);
|
|
68
|
+
const labels = useLabels("gallery", DEFAULT_LABELS, labelsProp);
|
|
69
|
+
const [openIndex, setOpenIndex] = React.useState(null);
|
|
70
|
+
const open = (i) => {
|
|
71
|
+
onSelect?.(i);
|
|
72
|
+
if (lightbox) setOpenIndex(i);
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.galleryRoot, children: [
|
|
75
|
+
/* @__PURE__ */ jsx(ScrollView, { contentContainerStyle: styles.grid, children: items.map((item, i) => /* @__PURE__ */ jsx(
|
|
76
|
+
Pressable,
|
|
77
|
+
{
|
|
78
|
+
accessibilityRole: "imagebutton",
|
|
79
|
+
accessibilityLabel: item.alt || labels.item(i + 1),
|
|
80
|
+
onPress: () => open(i),
|
|
81
|
+
style: [styles.tile, { width: `${100 / columns}%` }],
|
|
82
|
+
children: /* @__PURE__ */ jsxs(View, { style: styles.tileInner, children: [
|
|
83
|
+
item.render ? item.render() : /* @__PURE__ */ jsx(Text, { style: styles.tileIndex, children: i + 1 }),
|
|
84
|
+
item.duration ? /* @__PURE__ */ jsx(View, { style: styles.durationBadge, children: /* @__PURE__ */ jsx(Text, { style: styles.durationText, children: item.duration }) }) : null
|
|
85
|
+
] })
|
|
86
|
+
},
|
|
87
|
+
item.id
|
|
88
|
+
)) }),
|
|
89
|
+
openIndex != null ? /* @__PURE__ */ jsx(
|
|
90
|
+
GalleryLightbox,
|
|
91
|
+
{
|
|
92
|
+
items,
|
|
93
|
+
index: openIndex,
|
|
94
|
+
onIndexChange: setOpenIndex,
|
|
95
|
+
onClose: () => setOpenIndex(null),
|
|
96
|
+
labels: labelsProp
|
|
97
|
+
}
|
|
98
|
+
) : null
|
|
99
|
+
] });
|
|
100
|
+
}
|
|
101
|
+
function pinchDistance(e) {
|
|
102
|
+
const t = e.nativeEvent.touches;
|
|
103
|
+
if (!t || t.length < 2) return 0;
|
|
104
|
+
return Math.hypot(t[0].pageX - t[1].pageX, t[0].pageY - t[1].pageY);
|
|
105
|
+
}
|
|
106
|
+
function GalleryLightbox({
|
|
107
|
+
items,
|
|
108
|
+
index,
|
|
109
|
+
onIndexChange,
|
|
110
|
+
onClose,
|
|
111
|
+
maxZoom = 3,
|
|
112
|
+
motion = "full",
|
|
113
|
+
labels: labelsProp
|
|
114
|
+
}) {
|
|
115
|
+
const { styles } = useStyles(sheet);
|
|
116
|
+
const labels = useLabels("gallery", DEFAULT_LABELS, labelsProp);
|
|
117
|
+
const theme = useLoamTheme("gallery");
|
|
118
|
+
const level = useResolvedMotion(motion, "gallery");
|
|
119
|
+
const item = items[index];
|
|
120
|
+
const count = items.length;
|
|
121
|
+
const tx = React.useRef(new Animated.Value(0)).current;
|
|
122
|
+
const ty = React.useRef(new Animated.Value(0)).current;
|
|
123
|
+
const fade = React.useRef(new Animated.Value(1)).current;
|
|
124
|
+
const scale = React.useRef(new Animated.Value(1)).current;
|
|
125
|
+
const width = React.useRef(0);
|
|
126
|
+
const running = React.useRef(null);
|
|
127
|
+
const live = React.useRef({ index, count, level, theme, maxZoom, onIndexChange });
|
|
128
|
+
live.current = { index, count, level, theme, maxZoom, onIndexChange };
|
|
129
|
+
const gesture = React.useRef({ pinch0: 0, zoom: 1, zoomAtStart: 1, panX: 0, panY: 0, s: 1 });
|
|
130
|
+
const go = React.useCallback((delta) => {
|
|
131
|
+
const l = live.current;
|
|
132
|
+
l.onIndexChange((l.index + delta + l.count) % l.count);
|
|
133
|
+
}, []);
|
|
134
|
+
const leaveThen = React.useCallback(
|
|
135
|
+
(delta, velocity = 0) => {
|
|
136
|
+
const { level: lv, theme: th } = live.current;
|
|
137
|
+
const w = width.current || 320;
|
|
138
|
+
const g = gesture.current;
|
|
139
|
+
g.zoom = 1;
|
|
140
|
+
g.panX = 0;
|
|
141
|
+
g.panY = 0;
|
|
142
|
+
scale.setValue(1);
|
|
143
|
+
ty.setValue(0);
|
|
144
|
+
if (running.current) {
|
|
145
|
+
running.current.stop();
|
|
146
|
+
running.current = null;
|
|
147
|
+
tx.setValue(0);
|
|
148
|
+
fade.setValue(1);
|
|
149
|
+
go(delta);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (lv === "none") {
|
|
153
|
+
tx.setValue(0);
|
|
154
|
+
go(delta);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (lv === "reduced") {
|
|
158
|
+
const out2 = Animated.timing(fade, {
|
|
159
|
+
toValue: 0,
|
|
160
|
+
...motionTiming(lv),
|
|
161
|
+
useNativeDriver: true
|
|
162
|
+
});
|
|
163
|
+
running.current = out2;
|
|
164
|
+
out2.start(({ finished }) => {
|
|
165
|
+
running.current = null;
|
|
166
|
+
tx.setValue(0);
|
|
167
|
+
go(delta);
|
|
168
|
+
if (!finished) return fade.setValue(1);
|
|
169
|
+
Animated.timing(fade, { toValue: 1, ...motionTiming(lv), useNativeDriver: true }).start();
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const out = Animated.parallel([
|
|
174
|
+
Animated.spring(tx, {
|
|
175
|
+
toValue: -delta * w,
|
|
176
|
+
...springConfig(th, "fe", { velocity }),
|
|
177
|
+
useNativeDriver: true
|
|
178
|
+
}),
|
|
179
|
+
Animated.spring(fade, { toValue: 0, ...springConfig(th, "fe"), useNativeDriver: true })
|
|
180
|
+
]);
|
|
181
|
+
running.current = out;
|
|
182
|
+
out.start(({ finished }) => {
|
|
183
|
+
running.current = null;
|
|
184
|
+
if (!finished) return;
|
|
185
|
+
tx.setValue(delta * w * 0.35);
|
|
186
|
+
go(delta);
|
|
187
|
+
Animated.parallel([
|
|
188
|
+
Animated.spring(tx, { toValue: 0, ...springConfig(th, "ds"), useNativeDriver: true }),
|
|
189
|
+
Animated.spring(fade, { toValue: 1, ...springConfig(th, "de"), useNativeDriver: true })
|
|
190
|
+
]).start();
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
[fade, go, scale, tx, ty]
|
|
194
|
+
);
|
|
195
|
+
const settle = React.useCallback(() => {
|
|
196
|
+
const { theme: th, level: lv, maxZoom: max } = live.current;
|
|
197
|
+
const g = gesture.current;
|
|
198
|
+
const target = g.s < 1 ? 1 : g.s > max ? max : g.s;
|
|
199
|
+
g.zoom = target;
|
|
200
|
+
g.s = target;
|
|
201
|
+
if (target === 1) {
|
|
202
|
+
g.panX = 0;
|
|
203
|
+
g.panY = 0;
|
|
204
|
+
}
|
|
205
|
+
const spring = (v, to) => lv === "full" ? Animated.spring(v, { toValue: to, ...springConfig(th, "ds"), useNativeDriver: true }) : Animated.timing(v, { toValue: to, ...motionTiming(lv), useNativeDriver: true });
|
|
206
|
+
Animated.parallel([spring(scale, target), spring(tx, g.panX), spring(ty, g.panY)]).start();
|
|
207
|
+
}, [scale, tx, ty]);
|
|
208
|
+
const pan = React.useRef(
|
|
209
|
+
// Swipe and pinch share one responder on a full-screen modal with no
|
|
210
|
+
// competing gesture, and the native contract rules out a gesture library —
|
|
211
|
+
// the same reason `Sheet` and `Toast` use `PanResponder`.
|
|
212
|
+
// eslint-disable-next-line loam/no-pan-responder
|
|
213
|
+
PanResponder.create({
|
|
214
|
+
onStartShouldSetPanResponder: (e) => pinchDistance(e) > 0,
|
|
215
|
+
onMoveShouldSetPanResponder: (e, g) => pinchDistance(e) > 0 || gesture.current.zoom > 1 || Math.abs(g.dx) > 8 && Math.abs(g.dx) > Math.abs(g.dy),
|
|
216
|
+
onPanResponderTerminationRequest: () => false,
|
|
217
|
+
onPanResponderGrant: () => {
|
|
218
|
+
running.current?.stop();
|
|
219
|
+
running.current = null;
|
|
220
|
+
const g = gesture.current;
|
|
221
|
+
g.pinch0 = 0;
|
|
222
|
+
g.zoomAtStart = g.zoom;
|
|
223
|
+
g.s = g.zoom;
|
|
224
|
+
},
|
|
225
|
+
onPanResponderMove: (e, d) => {
|
|
226
|
+
const g = gesture.current;
|
|
227
|
+
const dist = pinchDistance(e);
|
|
228
|
+
if (dist > 0) {
|
|
229
|
+
if (!g.pinch0) {
|
|
230
|
+
g.pinch0 = dist;
|
|
231
|
+
g.zoomAtStart = g.s;
|
|
232
|
+
}
|
|
233
|
+
const raw = g.zoomAtStart * (dist / g.pinch0);
|
|
234
|
+
const max = live.current.maxZoom;
|
|
235
|
+
g.s = raw < 1 ? 1 - rubberband(1 - raw, 0.5) : raw > max ? max + rubberband(raw - max, max) : raw;
|
|
236
|
+
scale.setValue(g.s);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (g.pinch0) return;
|
|
240
|
+
if (g.zoom > 1) {
|
|
241
|
+
tx.setValue(g.panX + d.dx);
|
|
242
|
+
ty.setValue(g.panY + d.dy);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
tx.setValue(d.dx);
|
|
246
|
+
},
|
|
247
|
+
onPanResponderRelease: (_e, d) => {
|
|
248
|
+
const g = gesture.current;
|
|
249
|
+
if (g.pinch0) {
|
|
250
|
+
g.pinch0 = 0;
|
|
251
|
+
settle();
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (g.zoom > 1) {
|
|
255
|
+
const w2 = width.current || 320;
|
|
256
|
+
const reach = w2 * (g.zoom - 1) / 2;
|
|
257
|
+
g.panX = Math.max(-reach, Math.min(reach, g.panX + d.dx));
|
|
258
|
+
g.panY = Math.max(-reach, Math.min(reach, g.panY + d.dy));
|
|
259
|
+
settle();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const w = width.current || 320;
|
|
263
|
+
const aim = d.dx + project(d.vx * 1e3);
|
|
264
|
+
if (live.current.count > 1 && (Math.abs(d.dx) > w * 0.25 || Math.abs(aim) > w * 0.5)) {
|
|
265
|
+
leaveThen(aim < 0 ? 1 : -1, d.vx);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
Animated.spring(tx, {
|
|
269
|
+
toValue: 0,
|
|
270
|
+
...springConfig(live.current.theme, "fs", { velocity: d.vx }),
|
|
271
|
+
useNativeDriver: true
|
|
272
|
+
}).start();
|
|
273
|
+
},
|
|
274
|
+
onPanResponderTerminate: () => {
|
|
275
|
+
gesture.current.pinch0 = 0;
|
|
276
|
+
settle();
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
).current;
|
|
280
|
+
React.useEffect(() => {
|
|
281
|
+
return () => running.current?.stop();
|
|
282
|
+
}, []);
|
|
283
|
+
if (!item) return null;
|
|
284
|
+
const onLayout = (e) => {
|
|
285
|
+
width.current = e.nativeEvent.layout.width;
|
|
286
|
+
};
|
|
287
|
+
return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles.lightbox, children: [
|
|
288
|
+
/* @__PURE__ */ jsxs(View, { style: styles.lightboxBar, children: [
|
|
289
|
+
/* @__PURE__ */ jsx(Text, { style: styles.counter, children: labels.counter(index + 1, count) }),
|
|
290
|
+
/* @__PURE__ */ jsx(
|
|
291
|
+
Pressable,
|
|
292
|
+
{
|
|
293
|
+
accessibilityRole: "button",
|
|
294
|
+
accessibilityLabel: labels.close,
|
|
295
|
+
onPress: onClose,
|
|
296
|
+
style: styles.lightboxAction,
|
|
297
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "x", size: theme.icon.md, color: theme.media.ink })
|
|
298
|
+
}
|
|
299
|
+
)
|
|
300
|
+
] }),
|
|
301
|
+
/* @__PURE__ */ jsxs(View, { style: styles.lightboxStage, children: [
|
|
302
|
+
/* @__PURE__ */ jsx(
|
|
303
|
+
Pressable,
|
|
304
|
+
{
|
|
305
|
+
accessibilityRole: "button",
|
|
306
|
+
accessibilityLabel: labels.previous,
|
|
307
|
+
onPress: () => leaveThen(-1),
|
|
308
|
+
style: styles.lightboxNav,
|
|
309
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "chevron-left", size: theme.icon.lg, color: theme.media.ink })
|
|
310
|
+
}
|
|
311
|
+
),
|
|
312
|
+
/* @__PURE__ */ jsx(View, { style: styles.lightboxTrack, onLayout, ...pan.panHandlers, children: /* @__PURE__ */ jsx(
|
|
313
|
+
Animated.View,
|
|
314
|
+
{
|
|
315
|
+
testID: "gallery-lightbox-image",
|
|
316
|
+
accessibilityRole: "image",
|
|
317
|
+
accessibilityLabel: item.alt || labels.item(index + 1),
|
|
318
|
+
style: [
|
|
319
|
+
styles.lightboxImage,
|
|
320
|
+
{
|
|
321
|
+
aspectRatio: item.aspectRatio ?? 0.8,
|
|
322
|
+
opacity: fade,
|
|
323
|
+
transform: [{ translateX: tx }, { translateY: ty }, { scale }]
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
children: item.render ? item.render() : /* @__PURE__ */ jsx(Text, { style: styles.lightboxImageLabel, children: labels.placeholder(index + 1, String(item.aspectRatio ?? 0.8)) })
|
|
327
|
+
}
|
|
328
|
+
) }),
|
|
329
|
+
/* @__PURE__ */ jsx(
|
|
330
|
+
Pressable,
|
|
331
|
+
{
|
|
332
|
+
accessibilityRole: "button",
|
|
333
|
+
accessibilityLabel: labels.next,
|
|
334
|
+
onPress: () => leaveThen(1),
|
|
335
|
+
style: styles.lightboxNav,
|
|
336
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: theme.icon.lg, color: theme.media.ink })
|
|
337
|
+
}
|
|
338
|
+
)
|
|
339
|
+
] }),
|
|
340
|
+
/* @__PURE__ */ jsx(View, { style: styles.dots, accessibilityElementsHidden: true, importantForAccessibility: "no", children: items.map((it, i) => /* @__PURE__ */ jsx(Dot, { active: i === index }, it.id)) })
|
|
341
|
+
] }) });
|
|
342
|
+
}
|
|
343
|
+
var sheet = createStyleSheet((theme) => ({
|
|
344
|
+
galleryRoot: { flex: 1 },
|
|
345
|
+
grid: { flexDirection: "row", flexWrap: "wrap", padding: theme.space[2] },
|
|
346
|
+
tile: { padding: theme.space[2] },
|
|
347
|
+
tileInner: {
|
|
348
|
+
aspectRatio: 1,
|
|
349
|
+
backgroundColor: theme.color.surface3,
|
|
350
|
+
alignItems: "center",
|
|
351
|
+
justifyContent: "center",
|
|
352
|
+
overflow: "hidden"
|
|
353
|
+
},
|
|
354
|
+
tileIndex: {
|
|
355
|
+
fontFamily: theme.font.mono,
|
|
356
|
+
fontSize: theme.type.caption2.fontSize,
|
|
357
|
+
color: theme.color.text3
|
|
358
|
+
},
|
|
359
|
+
durationBadge: {
|
|
360
|
+
position: "absolute",
|
|
361
|
+
right: theme.space[4],
|
|
362
|
+
bottom: theme.space[4],
|
|
363
|
+
borderRadius: theme.radius.sm,
|
|
364
|
+
paddingHorizontal: theme.space[4],
|
|
365
|
+
paddingVertical: theme.space[1],
|
|
366
|
+
backgroundColor: theme.black.a12
|
|
367
|
+
},
|
|
368
|
+
durationText: {
|
|
369
|
+
fontFamily: theme.font.mono,
|
|
370
|
+
fontSize: theme.fontSize[10],
|
|
371
|
+
color: theme.media.ink
|
|
372
|
+
},
|
|
373
|
+
// Not `color.scrim`: a lightbox backdrop sits on imagery rather than on a
|
|
374
|
+
// token surface, and it is deliberately far heavier than a modal's scrim. The
|
|
375
|
+
// alpha ramp's top stop is cut at 0.92 for exactly this surface, so the value
|
|
376
|
+
// is a token now rather than the raw literal the doc leaves it as.
|
|
377
|
+
lightbox: { flex: 1, backgroundColor: theme.black.a14 },
|
|
378
|
+
lightboxBar: {
|
|
379
|
+
flexDirection: "row",
|
|
380
|
+
alignItems: "center",
|
|
381
|
+
justifyContent: "space-between",
|
|
382
|
+
paddingHorizontal: theme.space.s4,
|
|
383
|
+
paddingVertical: theme.space[14]
|
|
384
|
+
},
|
|
385
|
+
counter: {
|
|
386
|
+
fontFamily: theme.font.mono,
|
|
387
|
+
fontSize: theme.type.caption2.fontSize,
|
|
388
|
+
color: theme.media.ink,
|
|
389
|
+
opacity: theme.opacity[88]
|
|
390
|
+
},
|
|
391
|
+
lightboxAction: {
|
|
392
|
+
width: theme.tapMin,
|
|
393
|
+
height: theme.tapMin,
|
|
394
|
+
alignItems: "center",
|
|
395
|
+
justifyContent: "center"
|
|
396
|
+
},
|
|
397
|
+
lightboxStage: {
|
|
398
|
+
flex: 1,
|
|
399
|
+
flexDirection: "row",
|
|
400
|
+
alignItems: "center",
|
|
401
|
+
justifyContent: "center",
|
|
402
|
+
paddingHorizontal: theme.space[12]
|
|
403
|
+
},
|
|
404
|
+
lightboxNav: {
|
|
405
|
+
width: theme.tapMin,
|
|
406
|
+
height: theme.tapMin,
|
|
407
|
+
alignItems: "center",
|
|
408
|
+
justifyContent: "center"
|
|
409
|
+
},
|
|
410
|
+
lightboxTrack: { flex: 1, alignSelf: "stretch", justifyContent: "center" },
|
|
411
|
+
lightboxImage: {
|
|
412
|
+
width: "100%",
|
|
413
|
+
borderRadius: theme.radius.md,
|
|
414
|
+
backgroundColor: theme.color.surface3,
|
|
415
|
+
alignItems: "center",
|
|
416
|
+
justifyContent: "center"
|
|
417
|
+
},
|
|
418
|
+
lightboxImageLabel: {
|
|
419
|
+
fontFamily: theme.font.mono,
|
|
420
|
+
fontSize: theme.type.caption2.fontSize,
|
|
421
|
+
// Uppercase wants the caps tracking step, which is a ratio — multiply it by
|
|
422
|
+
// the size rather than restating the product as a bare 1.2.
|
|
423
|
+
letterSpacing: theme.type.caption2.fontSize * theme.tracking.caps,
|
|
424
|
+
textTransform: "uppercase",
|
|
425
|
+
color: theme.color.text3
|
|
426
|
+
},
|
|
427
|
+
dots: {
|
|
428
|
+
flexDirection: "row",
|
|
429
|
+
justifyContent: "center",
|
|
430
|
+
gap: DOT.idleWidth,
|
|
431
|
+
paddingVertical: theme.space.s4
|
|
432
|
+
},
|
|
433
|
+
// Width and background are animated per-dot; see {@link Dot}.
|
|
434
|
+
dot: { height: DOT.idleWidth, borderRadius: theme.radius.full }
|
|
435
|
+
}));
|
|
436
|
+
|
|
437
|
+
export { Gallery, GalleryLightbox };
|