@btndprojects/loam-ui-native 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/accordion/index.js +3 -0
- package/dist/adaptive/index.js +2 -0
- package/dist/alert/index.js +3 -0
- package/dist/analyzer/index.js +6 -0
- package/dist/announcement/index.js +6 -0
- package/dist/audio-player/index.js +3 -0
- package/dist/avatar/index.js +3 -0
- package/dist/avatar-group/index.js +3 -0
- package/dist/badge/index.js +5 -0
- package/dist/banner/index.js +2 -0
- package/dist/board/index.js +7 -0
- package/dist/button/index.js +5 -0
- package/dist/camera-permission/index.js +13 -0
- package/dist/capture-result/index.js +18 -0
- package/dist/card/index.js +4 -0
- package/dist/card-form/index.js +10 -0
- package/dist/carousel/index.js +2 -0
- package/dist/chart/index.js +6 -0
- package/dist/charts/index.js +7 -0
- package/dist/checkbox/index.js +7 -0
- package/dist/checklist/index.js +10 -0
- package/dist/checkout/index.js +13 -0
- package/dist/chip/index.js +7 -0
- package/dist/chunk-223Q2T2Q.js +229 -0
- package/dist/chunk-2A5NIQAK.js +254 -0
- package/dist/chunk-2GK6PHGE.js +363 -0
- package/dist/chunk-2WUTXHMU.js +1 -0
- package/dist/chunk-2ZZ7TDJ4.js +324 -0
- package/dist/chunk-35OFI3JG.js +499 -0
- package/dist/chunk-3ARE4TES.js +195 -0
- package/dist/chunk-3ECPOSKO.js +1 -0
- package/dist/chunk-3ENTMPQY.js +229 -0
- package/dist/chunk-3HJH6FF4.js +98 -0
- package/dist/chunk-3NMD74ZU.js +4 -0
- package/dist/chunk-3WPW4KUN.js +182 -0
- package/dist/chunk-47FWHGUN.js +394 -0
- package/dist/chunk-4BXMXBJO.js +141 -0
- package/dist/chunk-4DS5ZWVC.js +83 -0
- package/dist/chunk-4GBOGOTV.js +295 -0
- package/dist/chunk-4SZYY6AN.js +99 -0
- package/dist/chunk-4YIP3CWS.js +237 -0
- package/dist/chunk-4YQOR7JM.js +204 -0
- package/dist/chunk-4ZAHCY44.js +177 -0
- package/dist/chunk-52X2VYTD.js +228 -0
- package/dist/chunk-5P26LBDL.js +1 -0
- package/dist/chunk-5XLRYDAX.js +1 -0
- package/dist/chunk-5YNTNN5A.js +177 -0
- package/dist/chunk-66SG2H23.js +129 -0
- package/dist/chunk-6HT2LP62.js +504 -0
- package/dist/chunk-6N33LFQA.js +35 -0
- package/dist/chunk-6X6PQ443.js +432 -0
- package/dist/chunk-7CFF4HXS.js +126 -0
- package/dist/chunk-7O2FMUPT.js +755 -0
- package/dist/chunk-AI4DWZCD.js +162 -0
- package/dist/chunk-AWJOCGFZ.js +213 -0
- package/dist/chunk-AZRX6SAC.js +285 -0
- package/dist/chunk-B54QE2FN.js +1 -0
- package/dist/chunk-BC475SJH.js +1 -0
- package/dist/chunk-BEDBFJND.js +202 -0
- package/dist/chunk-BTTFCMKG.js +166 -0
- package/dist/chunk-BV3B2HYZ.js +1635 -0
- package/dist/chunk-C2NTXVWM.js +98 -0
- package/dist/chunk-CDRZHT42.js +424 -0
- package/dist/chunk-CJ5EOYZE.js +62 -0
- package/dist/chunk-CUMUNPXY.js +128 -0
- package/dist/chunk-CUS3ZSCU.js +1 -0
- package/dist/chunk-CYRBHQQZ.js +411 -0
- package/dist/chunk-DHWADYZX.js +144 -0
- package/dist/chunk-DKCSPATL.js +1 -0
- package/dist/chunk-DM5QUKKO.js +326 -0
- package/dist/chunk-DSJBXLUG.js +845 -0
- package/dist/chunk-DYBH2I6W.js +1 -0
- package/dist/chunk-DZ255O2F.js +1 -0
- package/dist/chunk-E35BPSGW.js +1 -0
- package/dist/chunk-EJBDRVIH.js +166 -0
- package/dist/chunk-F43NP42L.js +1 -0
- package/dist/chunk-F5XNPWS7.js +1024 -0
- package/dist/chunk-FIF2M24N.js +1521 -0
- package/dist/chunk-FOKG57CR.js +993 -0
- package/dist/chunk-G3HOYSF7.js +1 -0
- package/dist/chunk-GDKZTW34.js +395 -0
- package/dist/chunk-GL7B2DOW.js +134 -0
- package/dist/chunk-GNNJ4GCC.js +471 -0
- package/dist/chunk-GNZ56EUI.js +1 -0
- package/dist/chunk-H6NIOQHK.js +346 -0
- package/dist/chunk-H6PC7RDA.js +1 -0
- package/dist/chunk-HPPW424V.js +334 -0
- package/dist/chunk-HQOQIBJI.js +1 -0
- package/dist/chunk-HU2EQNRZ.js +44 -0
- package/dist/chunk-IIQTAY3J.js +715 -0
- package/dist/chunk-ITTYJZWX.js +271 -0
- package/dist/chunk-IVNRBPGC.js +1018 -0
- package/dist/chunk-J4KLDGI4.js +1 -0
- package/dist/chunk-J7Q7VCVC.js +254 -0
- package/dist/chunk-JDEOITQ2.js +1 -0
- package/dist/chunk-JNH2TYIN.js +96 -0
- package/dist/chunk-JRLTGLN4.js +1 -0
- package/dist/chunk-JTRJJLKL.js +1 -0
- package/dist/chunk-JUAMLEHX.js +379 -0
- package/dist/chunk-JXJB2X6M.js +131 -0
- package/dist/chunk-KMI5ML5I.js +262 -0
- package/dist/chunk-KTAC4MGE.js +4 -0
- package/dist/chunk-LAECSR4H.js +178 -0
- package/dist/chunk-LK4BCSGX.js +1 -0
- package/dist/chunk-LOE5YNN3.js +470 -0
- package/dist/chunk-LRJNDEIA.js +302 -0
- package/dist/chunk-LSS54GLJ.js +116 -0
- package/dist/chunk-LZLHELAG.js +137 -0
- package/dist/chunk-M2LUXGKZ.js +1 -0
- package/dist/chunk-MOUJOP55.js +425 -0
- package/dist/chunk-N32RGOA5.js +159 -0
- package/dist/chunk-N5ZNE2YE.js +1 -0
- package/dist/chunk-NBNCBML6.js +1 -0
- package/dist/chunk-NKB7BZYK.js +167 -0
- package/dist/chunk-NQYBUO3K.js +1795 -0
- package/dist/chunk-NY2U3PBI.js +59 -0
- package/dist/chunk-O4AEHWII.js +464 -0
- package/dist/chunk-O7AE6DAF.js +146 -0
- package/dist/chunk-OETCUXQP.js +134 -0
- package/dist/chunk-OOPPQH27.js +179 -0
- package/dist/chunk-OPXFZ4Y5.js +204 -0
- package/dist/chunk-P23EQNRQ.js +338 -0
- package/dist/chunk-PJXUJYS6.js +248 -0
- package/dist/chunk-PNWUWOBF.js +1 -0
- package/dist/chunk-PUPM2YGF.js +376 -0
- package/dist/chunk-PZXZJBMP.js +620 -0
- package/dist/chunk-Q72LJOVE.js +169 -0
- package/dist/chunk-QCDXZBC5.js +247 -0
- package/dist/chunk-QDYDBCFP.js +197 -0
- package/dist/chunk-QJJ6MADV.js +274 -0
- package/dist/chunk-QKXCPTFS.js +349 -0
- package/dist/chunk-QWCMU5B2.js +860 -0
- package/dist/chunk-RGQWWKLA.js +634 -0
- package/dist/chunk-RIBDXGUG.js +108 -0
- package/dist/chunk-RJQOOHT2.js +214 -0
- package/dist/chunk-RNGLIHFA.js +191 -0
- package/dist/chunk-RQ3HASCC.js +6 -0
- package/dist/chunk-RSOJT5YW.js +124 -0
- package/dist/chunk-RTIKSY6A.js +1 -0
- package/dist/chunk-RUZHTGKB.js +237 -0
- package/dist/chunk-RW6ZL2FQ.js +284 -0
- package/dist/chunk-S7F6XLTK.js +540 -0
- package/dist/chunk-SBMNWWBV.js +155 -0
- package/dist/chunk-SDTQPRRB.js +1 -0
- package/dist/chunk-SYNOJOQO.js +377 -0
- package/dist/chunk-T753XT36.js +1 -0
- package/dist/chunk-TKQYWZ5V.js +196 -0
- package/dist/chunk-TKVFVF5D.js +95 -0
- package/dist/chunk-TOXAGRDQ.js +144 -0
- package/dist/chunk-TUTI5HOZ.js +112 -0
- package/dist/chunk-U7TFM2JA.js +140 -0
- package/dist/chunk-UC2WGUP3.js +627 -0
- package/dist/chunk-UWFLYMAR.js +1126 -0
- package/dist/chunk-UWSZB7BJ.js +1 -0
- package/dist/chunk-UYG5L34B.js +87 -0
- package/dist/chunk-VBOXAEPI.js +336 -0
- package/dist/chunk-VCDBXW5H.js +188 -0
- package/dist/chunk-VCXPHHDS.js +1 -0
- package/dist/chunk-VEAYTRPX.js +414 -0
- package/dist/chunk-VFCUIDRT.js +1 -0
- package/dist/chunk-VQHPQEUH.js +273 -0
- package/dist/chunk-VXDZFJGP.js +874 -0
- package/dist/chunk-WS56BL3D.js +1 -0
- package/dist/chunk-WSW6ZFAQ.js +98 -0
- package/dist/chunk-WVKKJA6U.js +870 -0
- package/dist/chunk-XNUVB5OL.js +375 -0
- package/dist/chunk-XOSCY2CW.js +242 -0
- package/dist/chunk-XXXEFXY5.js +99 -0
- package/dist/chunk-Y5CSSPV4.js +1 -0
- package/dist/chunk-Y6DU4J47.js +1 -0
- package/dist/chunk-YC6WORFL.js +535 -0
- package/dist/chunk-YDGVJETP.js +60 -0
- package/dist/chunk-YF4NSSMT.js +366 -0
- package/dist/chunk-YG3ZJHGU.js +223 -0
- package/dist/chunk-YIJ55TBC.js +1 -0
- package/dist/chunk-YKZ4RZZF.js +1 -0
- package/dist/chunk-YLLCXTMC.js +37 -0
- package/dist/chunk-YTA74UZR.js +1 -0
- package/dist/chunk-Z7H7VSFZ.js +323 -0
- package/dist/chunk-ZK2H4O5P.js +1 -0
- package/dist/chunk-ZVFE5QGU.js +524 -0
- package/dist/coachmark/index.js +4 -0
- package/dist/code-block/index.js +4 -0
- package/dist/color-field/index.js +7 -0
- package/dist/commerce/index.js +20 -0
- package/dist/connectivity/index.js +2 -0
- package/dist/context-menu/index.js +5 -0
- package/dist/copy-button/index.js +3 -0
- package/dist/data-grid/index.js +24 -0
- package/dist/date-range-picker/index.js +13 -0
- package/dist/description-list/index.js +2 -0
- package/dist/dialog/index.js +3 -0
- package/dist/empty-state/index.js +3 -0
- package/dist/error-summary/index.js +3 -0
- package/dist/fab/index.js +2 -0
- package/dist/file-upload/index.js +9 -0
- package/dist/filter-bar/index.js +8 -0
- package/dist/flow-run/index.js +14 -0
- package/dist/form/index.js +3 -0
- package/dist/gallery/index.js +2 -0
- package/dist/header/index.js +5 -0
- package/dist/hold-to-confirm/index.js +4 -0
- package/dist/index.d.ts +22883 -0
- package/dist/index.js +158 -0
- package/dist/infinite-list/index.js +2 -0
- package/dist/inline-edit/index.js +5 -0
- package/dist/input/index.js +5 -0
- package/dist/interactions/index.js +2 -0
- package/dist/invoice/index.js +10 -0
- package/dist/kbd/index.js +1 -0
- package/dist/keyboard/index.js +3 -0
- package/dist/list-row/index.js +7 -0
- package/dist/log-viewer/index.js +2 -0
- package/dist/map-view/index.js +3 -0
- package/dist/markdown/index.js +6 -0
- package/dist/metric/index.js +4 -0
- package/dist/money/index.js +3 -0
- package/dist/nav-drawer/index.js +2 -0
- package/dist/navigation/index.js +2 -0
- package/dist/notification-center/index.js +16 -0
- package/dist/number-roll/index.js +3 -0
- package/dist/one-handed/index.js +5 -0
- package/dist/os-surfaces/index.js +3 -0
- package/dist/otp/index.js +7 -0
- package/dist/page-header/index.js +1 -0
- package/dist/payment-method/index.js +12 -0
- package/dist/payment-status/index.js +16 -0
- package/dist/permission/index.js +2 -0
- package/dist/picker/index.js +7 -0
- package/dist/progress/index.js +5 -0
- package/dist/pull-to-refresh/index.js +4 -0
- package/dist/radio-group/index.js +6 -0
- package/dist/rating/index.js +2 -0
- package/dist/receivables/index.js +20 -0
- package/dist/refund/index.js +16 -0
- package/dist/save-status/index.js +3 -0
- package/dist/scroll-area/index.js +1 -0
- package/dist/search-bar/index.js +5 -0
- package/dist/segmented-control/index.js +5 -0
- package/dist/sheet/index.js +4 -0
- package/dist/skeleton/index.js +2 -0
- package/dist/slider/index.js +5 -0
- package/dist/spinner/index.js +2 -0
- package/dist/split-button/index.js +7 -0
- package/dist/spotlight/index.js +2 -0
- package/dist/stage-timeline/index.js +4 -0
- package/dist/status-dot/index.js +2 -0
- package/dist/stepper/index.js +6 -0
- package/dist/streaming-text/index.js +3 -0
- package/dist/survey/index.js +19 -0
- package/dist/switch/index.js +5 -0
- package/dist/system-state/index.js +4 -0
- package/dist/tab-bar/index.js +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/textarea/index.js +6 -0
- package/dist/thinking/index.js +2 -0
- package/dist/timeline/index.js +4 -0
- package/dist/toast/index.js +2 -0
- package/dist/toolbar/index.js +2 -0
- package/dist/tour/index.js +11 -0
- package/dist/truncation-notice/index.js +2 -0
- package/dist/update-notice/index.js +11 -0
- package/dist/video-player/index.js +2 -0
- package/dist/viewfinder/index.js +5 -0
- package/dist/widget/index.js +4 -0
- package/dist/wizard/index.js +6 -0
- package/package.json +76 -3
- package/README.md +0 -3
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, Animated, Easing, Pressable, I18nManager } from 'react-native';
|
|
3
|
+
import { createStyleSheet, useLoamTheme, useStyles } from '@btndprojects/loam-theme-native';
|
|
4
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/spotlight/spotlight.tsx
|
|
7
|
+
var NO_INSETS = { top: 0, bottom: 0, left: 0, right: 0 };
|
|
8
|
+
var HostContext = React.createContext(null);
|
|
9
|
+
function TourOverlay({ children }) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
11
|
+
}
|
|
12
|
+
function TourHost({ children, style, insets }) {
|
|
13
|
+
const hostRef = React.useRef(null);
|
|
14
|
+
const size = React.useRef({ width: 0, height: 0 });
|
|
15
|
+
const insetsRef = React.useRef(NO_INSETS);
|
|
16
|
+
insetsRef.current = insets ? { ...NO_INSETS, ...insets } : NO_INSETS;
|
|
17
|
+
const value = React.useRef(null);
|
|
18
|
+
if (value.current === null) {
|
|
19
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
20
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
21
|
+
const pressListeners = /* @__PURE__ */ new Set();
|
|
22
|
+
const invalidate = () => {
|
|
23
|
+
listeners.forEach((fn) => fn());
|
|
24
|
+
};
|
|
25
|
+
value.current = {
|
|
26
|
+
hostRef,
|
|
27
|
+
size,
|
|
28
|
+
insets: insetsRef,
|
|
29
|
+
invalidate,
|
|
30
|
+
register: (name, ref) => {
|
|
31
|
+
anchors.set(name, ref);
|
|
32
|
+
invalidate();
|
|
33
|
+
return () => {
|
|
34
|
+
if (anchors.get(name) === ref) anchors.delete(name);
|
|
35
|
+
invalidate();
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
get: (name) => anchors.get(name) ?? null,
|
|
39
|
+
subscribe: (listener) => {
|
|
40
|
+
listeners.add(listener);
|
|
41
|
+
return () => listeners.delete(listener);
|
|
42
|
+
},
|
|
43
|
+
notifyPress: (name) => {
|
|
44
|
+
[...pressListeners].forEach((fn) => fn(name));
|
|
45
|
+
},
|
|
46
|
+
subscribePress: (listener) => {
|
|
47
|
+
pressListeners.add(listener);
|
|
48
|
+
return () => pressListeners.delete(listener);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const onLayout = (e) => {
|
|
53
|
+
size.current = { width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height };
|
|
54
|
+
value.current?.invalidate();
|
|
55
|
+
};
|
|
56
|
+
const kids = React.Children.toArray(children);
|
|
57
|
+
const overlays = kids.filter((k) => React.isValidElement(k) && k.type === TourOverlay);
|
|
58
|
+
const content = kids.filter((k) => !(React.isValidElement(k) && k.type === TourOverlay));
|
|
59
|
+
return /* @__PURE__ */ jsx(
|
|
60
|
+
View,
|
|
61
|
+
{
|
|
62
|
+
ref: hostRef,
|
|
63
|
+
style: [hostFill, style],
|
|
64
|
+
onLayout,
|
|
65
|
+
collapsable: false,
|
|
66
|
+
children: /* @__PURE__ */ jsxs(HostContext.Provider, { value: value.current, children: [
|
|
67
|
+
content,
|
|
68
|
+
overlays
|
|
69
|
+
] })
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
var hostFill = { flexGrow: 1 };
|
|
74
|
+
function useTourHost() {
|
|
75
|
+
return React.useContext(HostContext);
|
|
76
|
+
}
|
|
77
|
+
function useTourInsets() {
|
|
78
|
+
const host = React.useContext(HostContext);
|
|
79
|
+
return host ? host.insets.current : NO_INSETS;
|
|
80
|
+
}
|
|
81
|
+
function TourAnchor({ name, children, style }) {
|
|
82
|
+
const host = useTourHost();
|
|
83
|
+
const ref = React.useRef(null);
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
if (!host) return;
|
|
86
|
+
return host.register(name, ref);
|
|
87
|
+
}, [host, name]);
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
View,
|
|
90
|
+
{
|
|
91
|
+
ref,
|
|
92
|
+
style,
|
|
93
|
+
collapsable: false,
|
|
94
|
+
onLayout: host ? () => host.invalidate() : void 0,
|
|
95
|
+
onPointerUp: host ? () => host.notifyPress(name) : void 0,
|
|
96
|
+
children
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function sameRect(a, b) {
|
|
101
|
+
return a != null && a.x === b.x && a.y === b.y && a.width === b.width && a.height === b.height && a.containerWidth === b.containerWidth && a.containerHeight === b.containerHeight && a.direction === b.direction;
|
|
102
|
+
}
|
|
103
|
+
function useAnchorRect(name, options = {}) {
|
|
104
|
+
const { pollMs = 100, timeoutMs = 2600, onMissing } = options;
|
|
105
|
+
const host = useTourHost();
|
|
106
|
+
const [rect, setRect] = React.useState(null);
|
|
107
|
+
const missingRef = React.useRef(onMissing);
|
|
108
|
+
missingRef.current = onMissing;
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
if (!host || !name) {
|
|
111
|
+
setRect(null);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let alive = true;
|
|
115
|
+
let timer;
|
|
116
|
+
const started = Date.now();
|
|
117
|
+
const retry = () => {
|
|
118
|
+
if (!alive) return;
|
|
119
|
+
if (Date.now() - started >= timeoutMs) {
|
|
120
|
+
missingRef.current?.(name);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
timer = setTimeout(measure, pollMs);
|
|
124
|
+
};
|
|
125
|
+
const measure = () => {
|
|
126
|
+
if (!alive) return;
|
|
127
|
+
const target = host.get(name)?.current;
|
|
128
|
+
const hostNode = host.hostRef.current;
|
|
129
|
+
if (!target || !hostNode) {
|
|
130
|
+
retry();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
hostNode.measureInWindow((hx, hy, hw, hh) => {
|
|
134
|
+
if (!alive) return;
|
|
135
|
+
target.measureInWindow((x, y, w, h) => {
|
|
136
|
+
if (!alive) return;
|
|
137
|
+
if (w === 0 && h === 0) {
|
|
138
|
+
retry();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const next = {
|
|
142
|
+
x: x - hx,
|
|
143
|
+
y: y - hy,
|
|
144
|
+
width: w,
|
|
145
|
+
height: h,
|
|
146
|
+
containerWidth: hw || host.size.current.width,
|
|
147
|
+
containerHeight: hh || host.size.current.height,
|
|
148
|
+
direction: I18nManager.isRTL ? "rtl" : "ltr"
|
|
149
|
+
};
|
|
150
|
+
setRect((prev) => sameRect(prev, next) ? prev : next);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
measure();
|
|
155
|
+
const off = host.subscribe(measure);
|
|
156
|
+
return () => {
|
|
157
|
+
alive = false;
|
|
158
|
+
off();
|
|
159
|
+
if (timer) clearTimeout(timer);
|
|
160
|
+
};
|
|
161
|
+
}, [host, name, pollMs, timeoutMs]);
|
|
162
|
+
return rect;
|
|
163
|
+
}
|
|
164
|
+
function scrimRects(rect, pad) {
|
|
165
|
+
const left = rect.x - pad;
|
|
166
|
+
const top = rect.y - pad;
|
|
167
|
+
const width = rect.width + pad * 2;
|
|
168
|
+
const height = rect.height + pad * 2;
|
|
169
|
+
return [
|
|
170
|
+
{ left: 0, top: 0, right: 0, height: Math.max(0, top) },
|
|
171
|
+
{ left: 0, top: top + height, right: 0, bottom: 0 },
|
|
172
|
+
{ left: 0, top: Math.max(0, top), width: Math.max(0, left), height },
|
|
173
|
+
{ left: left + width, top: Math.max(0, top), right: 0, height }
|
|
174
|
+
];
|
|
175
|
+
}
|
|
176
|
+
function Spotlight({
|
|
177
|
+
target,
|
|
178
|
+
padding = 6,
|
|
179
|
+
radius,
|
|
180
|
+
motion = "full"
|
|
181
|
+
}) {
|
|
182
|
+
const theme = useLoamTheme();
|
|
183
|
+
const { styles } = useStyles(sheet);
|
|
184
|
+
const rect = useAnchorRect(target);
|
|
185
|
+
const fade = React.useRef(new Animated.Value(0)).current;
|
|
186
|
+
const animate = motion === "full" && !theme.reduceMotion;
|
|
187
|
+
React.useEffect(() => {
|
|
188
|
+
if (!rect) return;
|
|
189
|
+
Animated.timing(fade, {
|
|
190
|
+
toValue: 1,
|
|
191
|
+
duration: animate ? theme.motion.enter.duration : 0,
|
|
192
|
+
easing: Easing.bezier(...theme.motion.enter.easing),
|
|
193
|
+
useNativeDriver: true
|
|
194
|
+
}).start();
|
|
195
|
+
}, [rect, fade, animate, theme.motion.enter]);
|
|
196
|
+
if (!rect) return null;
|
|
197
|
+
const r = radius ?? theme.radius.md;
|
|
198
|
+
return /* @__PURE__ */ jsxs(Animated.View, { pointerEvents: "none", style: [styles.layer, { opacity: fade }], children: [
|
|
199
|
+
scrimRects(rect, padding).map((style, i) => /* @__PURE__ */ jsx(View, { style: [styles.scrim, style] }, i)),
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
View,
|
|
202
|
+
{
|
|
203
|
+
style: [
|
|
204
|
+
styles.ring,
|
|
205
|
+
{
|
|
206
|
+
left: rect.x - padding,
|
|
207
|
+
top: rect.y - padding,
|
|
208
|
+
width: rect.width + padding * 2,
|
|
209
|
+
height: rect.height + padding * 2,
|
|
210
|
+
borderRadius: r
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] });
|
|
216
|
+
}
|
|
217
|
+
function HighlightRing({
|
|
218
|
+
target,
|
|
219
|
+
padding = 5,
|
|
220
|
+
radius,
|
|
221
|
+
pulse = false,
|
|
222
|
+
motion = "full"
|
|
223
|
+
}) {
|
|
224
|
+
const theme = useLoamTheme();
|
|
225
|
+
const { styles } = useStyles(sheet);
|
|
226
|
+
const rect = useAnchorRect(target);
|
|
227
|
+
const breathe = React.useRef(new Animated.Value(1)).current;
|
|
228
|
+
React.useEffect(() => {
|
|
229
|
+
if (!pulse || motion === "none") return;
|
|
230
|
+
const loop = Animated.loop(
|
|
231
|
+
Animated.sequence([
|
|
232
|
+
Animated.timing(breathe, {
|
|
233
|
+
toValue: 0.35,
|
|
234
|
+
duration: theme.loop.pulse / 2,
|
|
235
|
+
easing: Easing.inOut(Easing.ease),
|
|
236
|
+
useNativeDriver: true
|
|
237
|
+
}),
|
|
238
|
+
Animated.timing(breathe, {
|
|
239
|
+
toValue: 1,
|
|
240
|
+
duration: theme.loop.pulse / 2,
|
|
241
|
+
easing: Easing.inOut(Easing.ease),
|
|
242
|
+
useNativeDriver: true
|
|
243
|
+
})
|
|
244
|
+
])
|
|
245
|
+
);
|
|
246
|
+
loop.start();
|
|
247
|
+
return () => loop.stop();
|
|
248
|
+
}, [pulse, motion, breathe, theme.loop.pulse]);
|
|
249
|
+
if (!rect) return null;
|
|
250
|
+
return /* @__PURE__ */ jsx(
|
|
251
|
+
Animated.View,
|
|
252
|
+
{
|
|
253
|
+
pointerEvents: "none",
|
|
254
|
+
style: [
|
|
255
|
+
styles.outline,
|
|
256
|
+
{
|
|
257
|
+
left: rect.x - padding,
|
|
258
|
+
top: rect.y - padding,
|
|
259
|
+
width: rect.width + padding * 2,
|
|
260
|
+
height: rect.height + padding * 2,
|
|
261
|
+
borderRadius: radius ?? theme.radius.md,
|
|
262
|
+
opacity: pulse ? breathe : 1
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
function Highlight({ kind = "spotlight", pulse, ...rest }) {
|
|
269
|
+
if (kind === "none") return null;
|
|
270
|
+
if (kind === "spotlight") return /* @__PURE__ */ jsx(Spotlight, { ...rest });
|
|
271
|
+
return /* @__PURE__ */ jsx(HighlightRing, { ...rest, pulse: kind === "pulse" || pulse });
|
|
272
|
+
}
|
|
273
|
+
var DOT = 12;
|
|
274
|
+
var OVERHANG = 5;
|
|
275
|
+
function Beacon({
|
|
276
|
+
target,
|
|
277
|
+
corner = "trailing-top",
|
|
278
|
+
accessibilityLabel = "What\u2019s new here",
|
|
279
|
+
pulsing = true,
|
|
280
|
+
onPress,
|
|
281
|
+
motion = "full"
|
|
282
|
+
}) {
|
|
283
|
+
const theme = useLoamTheme();
|
|
284
|
+
const { styles } = useStyles(sheet);
|
|
285
|
+
const rect = useAnchorRect(target ?? null);
|
|
286
|
+
const ring = React.useRef(new Animated.Value(0)).current;
|
|
287
|
+
const anchored = target != null;
|
|
288
|
+
React.useEffect(() => {
|
|
289
|
+
if (!pulsing || motion === "none") return;
|
|
290
|
+
const loop = Animated.loop(
|
|
291
|
+
Animated.timing(ring, {
|
|
292
|
+
toValue: 1,
|
|
293
|
+
duration: theme.loop.beacon,
|
|
294
|
+
easing: Easing.out(Easing.ease),
|
|
295
|
+
useNativeDriver: true
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
ring.setValue(0);
|
|
299
|
+
loop.start();
|
|
300
|
+
return () => loop.stop();
|
|
301
|
+
}, [pulsing, motion, ring, theme.loop.beacon]);
|
|
302
|
+
if (anchored && !rect) return null;
|
|
303
|
+
let placement;
|
|
304
|
+
if (rect) {
|
|
305
|
+
const rtl = rect.direction === "rtl";
|
|
306
|
+
const trailingX = rtl ? rect.x - OVERHANG - DOT : rect.x + rect.width - OVERHANG - DOT / 2;
|
|
307
|
+
const leadingX = rtl ? rect.x + rect.width - OVERHANG - DOT / 2 : rect.x - OVERHANG - DOT / 2;
|
|
308
|
+
placement = corner === "center" ? { left: rect.x + rect.width / 2 - DOT / 2, top: rect.y + rect.height / 2 - DOT / 2 } : {
|
|
309
|
+
left: corner.startsWith("trailing") ? trailingX : leadingX,
|
|
310
|
+
top: corner.endsWith("top") ? rect.y - OVERHANG : rect.y + rect.height - OVERHANG - DOT / 2
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const slop = Math.max(0, (theme.tapMin - DOT) / 2);
|
|
314
|
+
return /* @__PURE__ */ jsxs(
|
|
315
|
+
Pressable,
|
|
316
|
+
{
|
|
317
|
+
accessibilityRole: "button",
|
|
318
|
+
accessibilityLabel,
|
|
319
|
+
onPress,
|
|
320
|
+
hitSlop: { top: slop, bottom: slop, left: slop, right: slop },
|
|
321
|
+
style: [styles.beaconBox, anchored ? { position: "absolute", ...placement } : null],
|
|
322
|
+
children: [
|
|
323
|
+
pulsing ? /* @__PURE__ */ jsx(
|
|
324
|
+
Animated.View,
|
|
325
|
+
{
|
|
326
|
+
pointerEvents: "none",
|
|
327
|
+
style: [
|
|
328
|
+
styles.beaconRing,
|
|
329
|
+
{
|
|
330
|
+
opacity: ring.interpolate({ inputRange: [0, 0.7, 1], outputRange: [0.55, 0, 0] }),
|
|
331
|
+
transform: [{ scale: ring.interpolate({ inputRange: [0, 1], outputRange: [1, 2.8] }) }]
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
) : null,
|
|
336
|
+
/* @__PURE__ */ jsx(View, { style: styles.beaconDot })
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
var sheet = createStyleSheet((theme) => ({
|
|
342
|
+
// `box-none` on the layer, `none` on each panel: the overlay must not swallow
|
|
343
|
+
// a touch meant for the app underneath it.
|
|
344
|
+
layer: { position: "absolute", left: 0, top: 0, right: 0, bottom: 0 },
|
|
345
|
+
scrim: { position: "absolute", backgroundColor: theme.color.scrim },
|
|
346
|
+
// The ring is the *only* thing marking the target, which makes it a graphical
|
|
347
|
+
// object under SC 1.4.11 and holds it to 3:1 against both the scrim inside and
|
|
348
|
+
// the page outside. `focus.ringColor` is the accent lifted to clear that;
|
|
349
|
+
// the raw accent misses it in four of the shipped palettes.
|
|
350
|
+
ring: {
|
|
351
|
+
position: "absolute",
|
|
352
|
+
borderWidth: theme.borderWidth.heavy,
|
|
353
|
+
borderColor: theme.focus.ringColor
|
|
354
|
+
},
|
|
355
|
+
outline: {
|
|
356
|
+
position: "absolute",
|
|
357
|
+
borderWidth: theme.borderWidth.heavy,
|
|
358
|
+
borderColor: theme.focus.ringColor,
|
|
359
|
+
backgroundColor: theme.state.selected
|
|
360
|
+
},
|
|
361
|
+
beaconBox: { width: DOT, height: DOT, alignItems: "center", justifyContent: "center" },
|
|
362
|
+
beaconDot: {
|
|
363
|
+
width: DOT,
|
|
364
|
+
height: DOT,
|
|
365
|
+
borderRadius: theme.radius.full,
|
|
366
|
+
backgroundColor: theme.color.accent,
|
|
367
|
+
borderWidth: theme.borderWidth.heavy,
|
|
368
|
+
borderColor: theme.color.surface
|
|
369
|
+
},
|
|
370
|
+
beaconRing: {
|
|
371
|
+
position: "absolute",
|
|
372
|
+
width: DOT,
|
|
373
|
+
height: DOT,
|
|
374
|
+
borderRadius: theme.radius.full,
|
|
375
|
+
backgroundColor: theme.color.accent
|
|
376
|
+
}
|
|
377
|
+
}));
|
|
378
|
+
|
|
379
|
+
export { Beacon, Highlight, HighlightRing, Spotlight, TourAnchor, TourHost, TourOverlay, useAnchorRect, useTourHost, useTourInsets };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { useColorTransition } from './chunk-ITTYJZWX.js';
|
|
2
|
+
import { haptics } from './chunk-NY2U3PBI.js';
|
|
3
|
+
import { useResolvedMotion } from './chunk-6N33LFQA.js';
|
|
4
|
+
import { Icon } from './chunk-TKVFVF5D.js';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { Easing, Animated, Pressable, Platform } from 'react-native';
|
|
7
|
+
import { createStyleSheet, useLoamTheme, useStyles } from '@btndprojects/loam-theme-native';
|
|
8
|
+
import { jsx } from 'react/jsx-runtime';
|
|
9
|
+
|
|
10
|
+
var BOX = { sm: 16, md: 24 };
|
|
11
|
+
var GLYPH = { sm: 12, md: 14 };
|
|
12
|
+
var CHECK_STROKE = 3.5;
|
|
13
|
+
function nextChecked(current) {
|
|
14
|
+
return current === true ? false : true;
|
|
15
|
+
}
|
|
16
|
+
function useResolvedPlatform(explicit) {
|
|
17
|
+
const theme = useLoamTheme();
|
|
18
|
+
if (explicit) return explicit;
|
|
19
|
+
if (Platform.OS === "ios") return "ios";
|
|
20
|
+
if (Platform.OS === "android") return "android";
|
|
21
|
+
return theme.platform === "iOS" ? "ios" : "android";
|
|
22
|
+
}
|
|
23
|
+
function Checkbox({
|
|
24
|
+
checked,
|
|
25
|
+
defaultChecked = false,
|
|
26
|
+
onCheckedChange,
|
|
27
|
+
size = "md",
|
|
28
|
+
platform,
|
|
29
|
+
disabled = false,
|
|
30
|
+
motion = "full",
|
|
31
|
+
accessibilityLabel
|
|
32
|
+
}) {
|
|
33
|
+
const isControlled = checked !== void 0;
|
|
34
|
+
const [internal, setInternal] = React.useState(defaultChecked);
|
|
35
|
+
const value = isControlled ? checked : internal;
|
|
36
|
+
const isChecked = value === true;
|
|
37
|
+
const isIndeterminate = value === "indeterminate";
|
|
38
|
+
const isOn = isChecked || isIndeterminate;
|
|
39
|
+
const theme = useLoamTheme();
|
|
40
|
+
const os = useResolvedPlatform(platform);
|
|
41
|
+
const { styles } = useStyles(sheet, { shape: `${os}-${size}`, disabled });
|
|
42
|
+
const resolvedMotion = useResolvedMotion(motion);
|
|
43
|
+
const animateColour = resolvedMotion !== "none";
|
|
44
|
+
const animatePress = resolvedMotion === "full";
|
|
45
|
+
const easing = React.useMemo(() => Easing.bezier(...theme.easing.base), [theme.easing.base]);
|
|
46
|
+
const backgroundColor = useColorTransition(
|
|
47
|
+
isOn ? theme.color.accent : "transparent",
|
|
48
|
+
theme.duration.base,
|
|
49
|
+
easing,
|
|
50
|
+
animateColour
|
|
51
|
+
);
|
|
52
|
+
const borderColor = useColorTransition(
|
|
53
|
+
isOn ? theme.color.accent : theme.color.borderStrong,
|
|
54
|
+
theme.duration.base,
|
|
55
|
+
easing,
|
|
56
|
+
animateColour
|
|
57
|
+
);
|
|
58
|
+
const scale = React.useRef(new Animated.Value(1)).current;
|
|
59
|
+
const spring = (to) => Animated.spring(scale, {
|
|
60
|
+
toValue: to,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
...theme.spring.press
|
|
63
|
+
}).start();
|
|
64
|
+
const handlePress = () => {
|
|
65
|
+
const next = nextChecked(value);
|
|
66
|
+
if (!isControlled) setInternal(next);
|
|
67
|
+
haptics.impact("light");
|
|
68
|
+
onCheckedChange?.(next);
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ jsx(
|
|
71
|
+
Pressable,
|
|
72
|
+
{
|
|
73
|
+
accessibilityRole: "checkbox",
|
|
74
|
+
accessibilityLabel,
|
|
75
|
+
accessibilityState: { checked: isIndeterminate ? "mixed" : isChecked, disabled },
|
|
76
|
+
"aria-checked": isIndeterminate ? "mixed" : isChecked,
|
|
77
|
+
disabled,
|
|
78
|
+
onPress: disabled ? void 0 : handlePress,
|
|
79
|
+
onPressIn: disabled || !animatePress ? void 0 : () => spring(0.9),
|
|
80
|
+
onPressOut: disabled || !animatePress ? void 0 : () => spring(1),
|
|
81
|
+
children: /* @__PURE__ */ jsx(
|
|
82
|
+
Animated.View,
|
|
83
|
+
{
|
|
84
|
+
testID: "checkbox-box",
|
|
85
|
+
style: [styles.box, { backgroundColor, borderColor, transform: [{ scale }] }],
|
|
86
|
+
children: isOn ? /* @__PURE__ */ jsx(
|
|
87
|
+
Icon,
|
|
88
|
+
{
|
|
89
|
+
name: isIndeterminate ? "minus" : "check",
|
|
90
|
+
size: GLYPH[size],
|
|
91
|
+
color: theme.color.accentInk,
|
|
92
|
+
strokeWidth: CHECK_STROKE
|
|
93
|
+
}
|
|
94
|
+
) : null
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
function boxStyle(os, size, radius) {
|
|
101
|
+
return {
|
|
102
|
+
width: BOX[size],
|
|
103
|
+
height: BOX[size],
|
|
104
|
+
borderRadius: os === "ios" ? radius.full : radius.sm
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
var sheet = createStyleSheet((theme) => ({
|
|
108
|
+
// `backgroundColor` / `borderColor` are supplied at the use site as animated
|
|
109
|
+
// values so the box can travel between states over `duration.base`.
|
|
110
|
+
box: {
|
|
111
|
+
alignItems: "center",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
// The reference draws a `2px` edge — the static `w3` weight, not the
|
|
114
|
+
// contrast-reactive hairline, because the ring is part of the drawing.
|
|
115
|
+
borderWidth: theme.borderWidth.heavy,
|
|
116
|
+
variants: {
|
|
117
|
+
shape: {
|
|
118
|
+
"ios-sm": boxStyle("ios", "sm", theme.radius),
|
|
119
|
+
"ios-md": boxStyle("ios", "md", theme.radius),
|
|
120
|
+
"android-sm": boxStyle("android", "sm", theme.radius),
|
|
121
|
+
"android-md": boxStyle("android", "md", theme.radius)
|
|
122
|
+
},
|
|
123
|
+
disabled: {
|
|
124
|
+
true: { opacity: theme.state.disabledOpacity },
|
|
125
|
+
false: {}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
export { Checkbox };
|