@rootnative/web 0.0.0-alpha.1 → 0.0.0-alpha.3
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/CHANGELOG.md +71 -1
- package/dist/StyleRegistryContext-ROsMlY4O.js +8 -0
- package/dist/StyleRegistryContext-ROsMlY4O.js.map +1 -0
- package/dist/assets-registry/index.d.ts +18 -0
- package/dist/assets-registry/index.js +12 -0
- package/dist/assets-registry/index.js.map +1 -0
- package/dist/compile-CVUjQrR9.js +400 -0
- package/dist/compile-CVUjQrR9.js.map +1 -0
- package/dist/{env-BQE0B2yw.js → env-DK5Mt9yX.js} +2 -2
- package/dist/{env-BQE0B2yw.js.map → env-DK5Mt9yX.js.map} +1 -1
- package/dist/index.d.ts +835 -112
- package/dist/index.js +2652 -1162
- package/dist/index.js.map +1 -1
- package/dist/{StyleRegistryContext-D6yDrZk0.js → registry-Aa_Od5m0.js} +32 -10
- package/dist/registry-Aa_Od5m0.js.map +1 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +8 -4
- package/dist/server/index.js.map +1 -1
- package/dist/style/index.d.ts +25 -0
- package/dist/style/index.js +35 -0
- package/dist/style/index.js.map +1 -0
- package/dist/vite/index.d.ts +9 -1
- package/dist/vite/index.js +137 -42
- package/dist/vite/index.js.map +1 -1
- package/llms.txt +280 -31
- package/package.json +14 -1
- package/dist/StyleRegistryContext-D6yDrZk0.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { i as matchesMedia, n as isProductionEnv, r as isTestEnv, t as hasDOM } from "./env-
|
|
2
|
-
import {
|
|
1
|
+
import { i as matchesMedia, n as isProductionEnv, r as isTestEnv, t as hasDOM } from "./env-DK5Mt9yX.js";
|
|
2
|
+
import { a as getStyleRegistry } from "./registry-Aa_Od5m0.js";
|
|
3
|
+
import { a as pointerEventsStyle, d as setLeftAndRightSwap, f as toCSSColor, i as joinClassNames, n as compileStyle, o as resolveStyle, r as flattenStyle, s as systemFontStack, t as compileReset, u as getLeftAndRightSwap } from "./compile-CVUjQrR9.js";
|
|
4
|
+
import { n as useStyleRegistry } from "./StyleRegistryContext-ROsMlY4O.js";
|
|
3
5
|
import normalizeColor from "@react-native/normalize-colors";
|
|
4
6
|
import { Children, Fragment, cloneElement, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal } from "react-dom";
|
|
6
9
|
// src/apis/AccessibilityInfo/index.ts
|
|
7
10
|
const mediaQueryOf = {
|
|
8
11
|
reduceMotionChanged: "(prefers-reduced-motion: reduce)",
|
|
@@ -83,39 +86,285 @@ const AccessibilityInfo = {
|
|
|
83
86
|
if (eventType === "focus" && target instanceof HTMLElement) target.focus();
|
|
84
87
|
}
|
|
85
88
|
};
|
|
89
|
+
// src/utils/scrollLock.ts
|
|
90
|
+
let locks = 0;
|
|
91
|
+
let pageOverflow = "";
|
|
92
|
+
let pageX = 0;
|
|
93
|
+
let pageY = 0;
|
|
94
|
+
const keepPlace = () => {
|
|
95
|
+
const viewport = window.visualViewport;
|
|
96
|
+
if (viewport !== null && viewport.scale === 1 && viewport.offsetTop > 0) window.scrollTo(pageX, pageY);
|
|
97
|
+
};
|
|
98
|
+
const lockScroll = () => {
|
|
99
|
+
const root = document.documentElement;
|
|
100
|
+
if (locks++ === 0) {
|
|
101
|
+
pageOverflow = root.style.overflow;
|
|
102
|
+
pageX = window.scrollX;
|
|
103
|
+
pageY = window.scrollY;
|
|
104
|
+
root.style.overflow = "hidden";
|
|
105
|
+
window.visualViewport?.addEventListener("scroll", keepPlace);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const unlockScroll = () => {
|
|
109
|
+
if (--locks === 0) {
|
|
110
|
+
document.documentElement.style.overflow = pageOverflow;
|
|
111
|
+
window.visualViewport?.removeEventListener("scroll", keepPlace);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
// src/utils/warn.ts
|
|
115
|
+
const warned = /* @__PURE__ */ new Set();
|
|
116
|
+
const warnOnce = (key, message) => {
|
|
117
|
+
if (isProductionEnv() || warned.has(key)) return;
|
|
118
|
+
warned.add(key);
|
|
119
|
+
console.warn(`[@rootnative/web] ${message}`);
|
|
120
|
+
};
|
|
86
121
|
// src/apis/Appearance/index.ts
|
|
87
122
|
const DARK_QUERY = "(prefers-color-scheme: dark)";
|
|
88
123
|
let override = null;
|
|
89
|
-
let last = null;
|
|
124
|
+
let last$1 = null;
|
|
90
125
|
let mediaList = null;
|
|
91
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
126
|
+
const listeners$1 = /* @__PURE__ */ new Set();
|
|
92
127
|
const system = () => matchesMedia(DARK_QUERY) ? "dark" : "light";
|
|
93
|
-
const current$
|
|
94
|
-
const notify = () => {
|
|
95
|
-
const next = current$
|
|
96
|
-
if (next === last) return;
|
|
97
|
-
last = next;
|
|
98
|
-
for (const listener of listeners) listener({ colorScheme: next });
|
|
128
|
+
const current$3 = () => override ?? system();
|
|
129
|
+
const notify$1 = () => {
|
|
130
|
+
const next = current$3();
|
|
131
|
+
if (next === last$1) return;
|
|
132
|
+
last$1 = next;
|
|
133
|
+
for (const listener of listeners$1) listener({ colorScheme: next });
|
|
99
134
|
};
|
|
100
|
-
const listen$
|
|
135
|
+
const listen$2 = () => {
|
|
101
136
|
if (mediaList !== null || !hasDOM() || typeof window.matchMedia !== "function") return;
|
|
102
137
|
mediaList = window.matchMedia(DARK_QUERY);
|
|
103
|
-
mediaList.addEventListener("change", notify);
|
|
138
|
+
mediaList.addEventListener("change", notify$1);
|
|
104
139
|
};
|
|
105
140
|
const Appearance = {
|
|
106
141
|
getColorScheme() {
|
|
107
|
-
return current$
|
|
142
|
+
return current$3();
|
|
108
143
|
},
|
|
109
144
|
setColorScheme(scheme) {
|
|
110
145
|
override = scheme === "light" || scheme === "dark" ? scheme : null;
|
|
111
146
|
if (hasDOM()) document.documentElement.style.colorScheme = override ?? "";
|
|
112
|
-
notify();
|
|
147
|
+
notify$1();
|
|
113
148
|
},
|
|
114
149
|
addChangeListener(listener) {
|
|
115
|
-
if (listeners.size === 0) last = current$
|
|
116
|
-
listeners.add(listener);
|
|
150
|
+
if (listeners$1.size === 0) last$1 = current$3();
|
|
151
|
+
listeners$1.add(listener);
|
|
152
|
+
listen$2();
|
|
153
|
+
return { remove: () => listeners$1.delete(listener) };
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
// src/apis/Alert/index.ts
|
|
157
|
+
const ALERT = "rn-alert";
|
|
158
|
+
const RULES$3 = [
|
|
159
|
+
`.${ALERT}{position:fixed;inset:auto;top:50%;left:50%;z-index:2147483647;box-sizing:border-box;min-width:min(280px,calc(100% - 48px));max-width:min(560px,calc(100% - 48px));max-height:calc(100% - 48px);margin:0;padding:24px 24px 8px;overflow:auto;border:0;border-radius:2px;background:#fff;color:rgba(0,0,0,.87);font-family:${systemFontStack};box-shadow:0 11px 15px -7px rgba(0,0,0,.2),0 24px 38px 3px rgba(0,0,0,.14),0 9px 46px 8px rgba(0,0,0,.12);transform:translate(-50%,-50%)}`,
|
|
160
|
+
`.${ALERT}:not([open]){display:none}`,
|
|
161
|
+
`.${ALERT}:focus{outline:none}`,
|
|
162
|
+
`.${ALERT}-title{margin:0;font-size:20px;font-weight:500;line-height:1.3;overflow-wrap:break-word}`,
|
|
163
|
+
`.${ALERT}-message{margin:0;font-size:16px;line-height:1.5;color:rgba(0,0,0,.6);white-space:pre-wrap;overflow-wrap:break-word}`,
|
|
164
|
+
`.${ALERT}-title+.${ALERT}-message{margin-top:16px}`,
|
|
165
|
+
`.${ALERT}-buttons{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px;margin:24px -16px 0}`,
|
|
166
|
+
`.${ALERT}-buttons[data-neutral]>:first-child{margin-inline-end:auto}`,
|
|
167
|
+
`.${ALERT}-button{min-width:64px;min-height:36px;padding:0 8px;border:0;border-radius:2px;background:transparent;color:#009688;font:inherit;font-size:14px;font-weight:500;cursor:pointer}`,
|
|
168
|
+
`.${ALERT}-button:hover{background:rgba(0,150,136,.08)}`,
|
|
169
|
+
`.${ALERT}-button[data-style=destructive]{color:#d32f2f}`,
|
|
170
|
+
`.${ALERT}[data-scheme=dark]{background:#424242;color:#fff}`,
|
|
171
|
+
`.${ALERT}[data-scheme=dark] .${ALERT}-message{color:rgba(255,255,255,.7)}`,
|
|
172
|
+
`.${ALERT}[data-scheme=dark] .${ALERT}-button{color:#80cbc4}`,
|
|
173
|
+
`.${ALERT}[data-scheme=dark] .${ALERT}-button[data-style=destructive]{color:#ef9a9a}`,
|
|
174
|
+
`@supports selector(:focus-visible){.${ALERT}-button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}}`,
|
|
175
|
+
`@supports selector(::backdrop){.${ALERT}::backdrop{background:rgba(0,0,0,.6)}}`
|
|
176
|
+
];
|
|
177
|
+
const openAlerts = /* @__PURE__ */ new Set();
|
|
178
|
+
let nextId = 0;
|
|
179
|
+
const lastIndexOf = (list, test) => {
|
|
180
|
+
for (let index = list.length - 1; index >= 0; index--) {
|
|
181
|
+
const button = list[index];
|
|
182
|
+
if (button !== void 0 && test(button)) return index;
|
|
183
|
+
}
|
|
184
|
+
return -1;
|
|
185
|
+
};
|
|
186
|
+
const isOutside = (event, element) => {
|
|
187
|
+
const box = element.getBoundingClientRect();
|
|
188
|
+
return event.clientX < box.left || event.clientX > box.right || event.clientY < box.top || event.clientY > box.bottom;
|
|
189
|
+
};
|
|
190
|
+
const show = (title, message, buttons, options) => {
|
|
191
|
+
if (!hasDOM()) return;
|
|
192
|
+
getStyleRegistry().staticClass(ALERT, RULES$3);
|
|
193
|
+
const id = `${ALERT}-${++nextId}`;
|
|
194
|
+
const dialog = document.createElement("dialog");
|
|
195
|
+
dialog.className = ALERT;
|
|
196
|
+
dialog.setAttribute("role", "alertdialog");
|
|
197
|
+
const style = options?.userInterfaceStyle;
|
|
198
|
+
dialog.dataset["scheme"] = style === "light" || style === "dark" ? style : Appearance.getColorScheme() ?? "light";
|
|
199
|
+
if (title) {
|
|
200
|
+
const heading = document.createElement("div");
|
|
201
|
+
heading.className = `${ALERT}-title`;
|
|
202
|
+
heading.id = `${id}-title`;
|
|
203
|
+
heading.textContent = title;
|
|
204
|
+
dialog.append(heading);
|
|
205
|
+
dialog.setAttribute("aria-labelledby", heading.id);
|
|
206
|
+
}
|
|
207
|
+
if (message) {
|
|
208
|
+
const body = document.createElement("div");
|
|
209
|
+
body.className = `${ALERT}-message`;
|
|
210
|
+
body.id = `${id}-message`;
|
|
211
|
+
body.textContent = message;
|
|
212
|
+
dialog.append(body);
|
|
213
|
+
dialog.setAttribute("aria-describedby", body.id);
|
|
214
|
+
}
|
|
215
|
+
const list = buttons === void 0 || buttons.length === 0 ? [{ text: "OK" }] : buttons;
|
|
216
|
+
const modal = typeof dialog.showModal === "function";
|
|
217
|
+
const focused = document.activeElement;
|
|
218
|
+
let closed = false;
|
|
219
|
+
const close = () => {
|
|
220
|
+
if (closed) return;
|
|
221
|
+
closed = true;
|
|
222
|
+
openAlerts.delete(entry);
|
|
223
|
+
if (modal) dialog.close();
|
|
224
|
+
else if (focused instanceof HTMLElement && focused.isConnected) focused.focus();
|
|
225
|
+
dialog.remove();
|
|
226
|
+
unlockScroll();
|
|
227
|
+
};
|
|
228
|
+
const entry = { close };
|
|
229
|
+
const press = (button) => {
|
|
230
|
+
close();
|
|
231
|
+
button.onPress?.();
|
|
232
|
+
};
|
|
233
|
+
const dismiss = () => {
|
|
234
|
+
close();
|
|
235
|
+
options?.onDismiss?.();
|
|
236
|
+
};
|
|
237
|
+
const cancel = () => {
|
|
238
|
+
const cancelButton = list[lastIndexOf(list, (button) => button.style === "cancel")];
|
|
239
|
+
if (cancelButton !== void 0) press(cancelButton);
|
|
240
|
+
else if (options?.cancelable === true) dismiss();
|
|
241
|
+
};
|
|
242
|
+
const row = document.createElement("div");
|
|
243
|
+
row.className = `${ALERT}-buttons`;
|
|
244
|
+
if (list.length >= 3) row.dataset["neutral"] = "";
|
|
245
|
+
const elements = list.map((button, index) => {
|
|
246
|
+
const element = document.createElement("button");
|
|
247
|
+
element.type = "button";
|
|
248
|
+
element.className = `${ALERT}-button`;
|
|
249
|
+
element.textContent = button.text || (index === list.length - 1 ? "OK" : "");
|
|
250
|
+
if (button.style === "destructive") element.dataset["style"] = "destructive";
|
|
251
|
+
element.addEventListener("click", () => press(button));
|
|
252
|
+
row.append(element);
|
|
253
|
+
return element;
|
|
254
|
+
});
|
|
255
|
+
dialog.append(row);
|
|
256
|
+
dialog.addEventListener("cancel", (event) => {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
cancel();
|
|
259
|
+
});
|
|
260
|
+
dialog.addEventListener("close", () => {
|
|
261
|
+
if (!closed) dialog.showModal();
|
|
262
|
+
});
|
|
263
|
+
dialog.addEventListener("click", (event) => {
|
|
264
|
+
if (event.target === dialog && isOutside(event, dialog) && options?.cancelable === true) dismiss();
|
|
265
|
+
});
|
|
266
|
+
if (!modal) dialog.addEventListener("keydown", (event) => {
|
|
267
|
+
if (event.key === "Escape") cancel();
|
|
268
|
+
});
|
|
269
|
+
document.body.append(dialog);
|
|
270
|
+
if (modal) dialog.showModal();
|
|
271
|
+
else dialog.setAttribute("open", "");
|
|
272
|
+
lockScroll();
|
|
273
|
+
openAlerts.add(entry);
|
|
274
|
+
const preferred = list.findIndex((button) => button.isPreferred === true);
|
|
275
|
+
const target = preferred >= 0 ? preferred : lastIndexOf(list, (button) => button.style === "cancel");
|
|
276
|
+
elements[target >= 0 ? target : 0]?.focus();
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* React Native's `Alert` on a `<dialog role="alertdialog">` with the look of Android's
|
|
280
|
+
* AlertDialog. It isn't part of the React tree, so it works from any handler.
|
|
281
|
+
*/
|
|
282
|
+
const Alert = {
|
|
283
|
+
alert: (title, message, buttons, options) => show(title, message, buttons, options),
|
|
284
|
+
prompt: () => {
|
|
285
|
+
warnOnce("alert-prompt", "Alert.prompt does nothing on the web yet, as on Android.");
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
// src/apis/AppState/index.ts
|
|
289
|
+
const handlers$2 = {
|
|
290
|
+
change: /* @__PURE__ */ new Set(),
|
|
291
|
+
memoryWarning: /* @__PURE__ */ new Set(),
|
|
292
|
+
blur: /* @__PURE__ */ new Set(),
|
|
293
|
+
focus: /* @__PURE__ */ new Set()
|
|
294
|
+
};
|
|
295
|
+
let pageHidden = false;
|
|
296
|
+
let last = null;
|
|
297
|
+
let visible = true;
|
|
298
|
+
let caughtUp = false;
|
|
299
|
+
let lastFocusEvent = null;
|
|
300
|
+
let listening$2 = false;
|
|
301
|
+
const read$2 = () => {
|
|
302
|
+
if (!hasDOM()) return "active";
|
|
303
|
+
return pageHidden || document.visibilityState !== "visible" ? "background" : "active";
|
|
304
|
+
};
|
|
305
|
+
const emit$1 = (next) => {
|
|
306
|
+
if (next === last) return;
|
|
307
|
+
last = next;
|
|
308
|
+
for (const handler of handlers$2.change) handler(next);
|
|
309
|
+
};
|
|
310
|
+
const notify = () => emit$1(read$2());
|
|
311
|
+
const onVisibilityChange = () => {
|
|
312
|
+
const next = document.visibilityState === "visible";
|
|
313
|
+
if (next !== visible) {
|
|
314
|
+
caughtUp = false;
|
|
315
|
+
visible = next;
|
|
316
|
+
notify();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
if (caughtUp) {
|
|
320
|
+
caughtUp = false;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
caughtUp = true;
|
|
324
|
+
emit$1(next || pageHidden ? "background" : "active");
|
|
325
|
+
notify();
|
|
326
|
+
};
|
|
327
|
+
const onPageHide = () => {
|
|
328
|
+
pageHidden = true;
|
|
329
|
+
notify();
|
|
330
|
+
};
|
|
331
|
+
const onPageShow = () => {
|
|
332
|
+
pageHidden = false;
|
|
333
|
+
notify();
|
|
334
|
+
};
|
|
335
|
+
const onWindowFocus = (event) => {
|
|
336
|
+
if (event.target !== window || event.type === lastFocusEvent) return;
|
|
337
|
+
lastFocusEvent = event.type;
|
|
338
|
+
for (const handler of handlers$2[event.type === "focus" ? "focus" : "blur"]) handler();
|
|
339
|
+
};
|
|
340
|
+
const listen$1 = () => {
|
|
341
|
+
if (listening$2 || !hasDOM()) return;
|
|
342
|
+
listening$2 = true;
|
|
343
|
+
last = read$2();
|
|
344
|
+
visible = document.visibilityState === "visible";
|
|
345
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
346
|
+
window.addEventListener("pagehide", onPageHide);
|
|
347
|
+
window.addEventListener("pageshow", onPageShow);
|
|
348
|
+
window.addEventListener("focus", onWindowFocus);
|
|
349
|
+
window.addEventListener("blur", onWindowFocus);
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* The app is `active` while its page is visible, and in the `background` while the page is
|
|
353
|
+
* hidden or unloads. A focus change of the window fires `blur` and `focus`, as on Android, and
|
|
354
|
+
* the state stays `active`.
|
|
355
|
+
*/
|
|
356
|
+
const AppState = {
|
|
357
|
+
get currentState() {
|
|
358
|
+
return read$2();
|
|
359
|
+
},
|
|
360
|
+
isAvailable: true,
|
|
361
|
+
addEventListener(type, handler) {
|
|
362
|
+
const set = handlers$2[type];
|
|
363
|
+
if (set === void 0) throw new Error(`Trying to subscribe to unknown event: ${String(type)}`);
|
|
364
|
+
const entry = handler;
|
|
365
|
+
set.add(entry);
|
|
117
366
|
listen$1();
|
|
118
|
-
return { remove: () =>
|
|
367
|
+
return { remove: () => set.delete(entry) };
|
|
119
368
|
}
|
|
120
369
|
};
|
|
121
370
|
// src/apis/BackHandler/index.ts
|
|
@@ -131,6 +380,46 @@ const BackHandler = {
|
|
|
131
380
|
},
|
|
132
381
|
exitApp: () => {}
|
|
133
382
|
};
|
|
383
|
+
// src/apis/Clipboard/index.ts
|
|
384
|
+
const clipboardAPI = () => hasDOM() ? navigator.clipboard : void 0;
|
|
385
|
+
const warnDeprecated = () => warnOnce("clipboard-deprecated", "Clipboard is deprecated in React Native, which will remove it in a future release.");
|
|
386
|
+
const warnRefused = (reason) => warnOnce("clipboard-write", `Clipboard.setString: the browser refused the copy. ${reason}`);
|
|
387
|
+
const copyWithTextarea = (content) => {
|
|
388
|
+
const focused = document.activeElement;
|
|
389
|
+
const textarea = document.createElement("textarea");
|
|
390
|
+
textarea.value = content;
|
|
391
|
+
textarea.setAttribute("readonly", "");
|
|
392
|
+
textarea.style.cssText = "position:fixed;top:0;left:0;opacity:0;pointer-events:none";
|
|
393
|
+
document.body.append(textarea);
|
|
394
|
+
textarea.select();
|
|
395
|
+
textarea.setSelectionRange(0, content.length);
|
|
396
|
+
const copied = document.execCommand("copy");
|
|
397
|
+
textarea.remove();
|
|
398
|
+
if (focused instanceof HTMLElement) focused.focus({ preventScroll: true });
|
|
399
|
+
if (!copied) warnRefused("Call setString from a press handler.");
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Reads and writes text on the clipboard with the async Clipboard API. Deprecated in React
|
|
403
|
+
* Native, so the first call logs a warning.
|
|
404
|
+
*/
|
|
405
|
+
const Clipboard = {
|
|
406
|
+
getString() {
|
|
407
|
+
warnDeprecated();
|
|
408
|
+
const api = clipboardAPI();
|
|
409
|
+
if (api === void 0 || typeof api.readText !== "function") return Promise.reject(/* @__PURE__ */ new Error("Clipboard.getString: this page can't read the clipboard. Reading needs https or localhost, and a browser with navigator.clipboard.readText."));
|
|
410
|
+
return api.readText();
|
|
411
|
+
},
|
|
412
|
+
setString(content) {
|
|
413
|
+
warnDeprecated();
|
|
414
|
+
if (!hasDOM()) return;
|
|
415
|
+
const api = clipboardAPI();
|
|
416
|
+
if (api === void 0 || typeof api.writeText !== "function") {
|
|
417
|
+
copyWithTextarea(content);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
api.writeText(content).catch((error) => warnRefused(String(error)));
|
|
421
|
+
}
|
|
422
|
+
};
|
|
134
423
|
// src/apis/Dimensions/index.ts
|
|
135
424
|
const serverSize = Object.freeze({
|
|
136
425
|
width: 0,
|
|
@@ -138,7 +427,7 @@ const serverSize = Object.freeze({
|
|
|
138
427
|
scale: 1,
|
|
139
428
|
fontScale: 1
|
|
140
429
|
});
|
|
141
|
-
const read = () => {
|
|
430
|
+
const read$1 = () => {
|
|
142
431
|
if (!hasDOM()) return {
|
|
143
432
|
window: serverSize,
|
|
144
433
|
screen: serverSize
|
|
@@ -162,28 +451,28 @@ const read = () => {
|
|
|
162
451
|
};
|
|
163
452
|
};
|
|
164
453
|
const sameSize = (a, b) => a.width === b.width && a.height === b.height && a.scale === b.scale && a.fontScale === b.fontScale;
|
|
165
|
-
let current$
|
|
454
|
+
let current$2 = null;
|
|
166
455
|
const handlers = /* @__PURE__ */ new Set();
|
|
167
|
-
let listening = false;
|
|
456
|
+
let listening$1 = false;
|
|
168
457
|
const refresh = () => {
|
|
169
|
-
const next = read();
|
|
170
|
-
if (current$
|
|
171
|
-
return current$
|
|
458
|
+
const next = read$1();
|
|
459
|
+
if (current$2 === null || !sameSize(current$2.window, next.window) || !sameSize(current$2.screen, next.screen)) current$2 = next;
|
|
460
|
+
return current$2;
|
|
172
461
|
};
|
|
173
|
-
const update = () => {
|
|
174
|
-
const previous = current$
|
|
462
|
+
const update$1 = () => {
|
|
463
|
+
const previous = current$2;
|
|
175
464
|
const value = refresh();
|
|
176
465
|
if (value === previous) return;
|
|
177
466
|
for (const handler of handlers) handler(value);
|
|
178
467
|
};
|
|
179
468
|
const listen = () => {
|
|
180
|
-
if (listening || !hasDOM()) return;
|
|
181
|
-
listening = true;
|
|
182
|
-
window.addEventListener("resize", update);
|
|
469
|
+
if (listening$1 || !hasDOM()) return;
|
|
470
|
+
listening$1 = true;
|
|
471
|
+
window.addEventListener("resize", update$1);
|
|
183
472
|
};
|
|
184
473
|
const Dimensions = {
|
|
185
474
|
get(dimension) {
|
|
186
|
-
return (current$
|
|
475
|
+
return (current$2 === null || !listening$1 ? refresh() : current$2)[dimension];
|
|
187
476
|
},
|
|
188
477
|
addEventListener(type, handler) {
|
|
189
478
|
if (type !== "change") throw new Error(`Dimensions: unknown event "${String(type)}"`);
|
|
@@ -196,7 +485,6 @@ const Dimensions = {
|
|
|
196
485
|
// src/apis/I18nManager/index.ts
|
|
197
486
|
let allowed = true;
|
|
198
487
|
let forced = false;
|
|
199
|
-
let swapLeftAndRight = true;
|
|
200
488
|
const documentIsRTL = () => hasDOM() && getComputedStyle(document.documentElement).direction === "rtl";
|
|
201
489
|
const isRTL = () => forced || allowed && documentIsRTL();
|
|
202
490
|
const I18nManager = {
|
|
@@ -204,11 +492,11 @@ const I18nManager = {
|
|
|
204
492
|
return isRTL();
|
|
205
493
|
},
|
|
206
494
|
get doLeftAndRightSwapInRTL() {
|
|
207
|
-
return
|
|
495
|
+
return getLeftAndRightSwap();
|
|
208
496
|
},
|
|
209
497
|
getConstants: () => ({
|
|
210
498
|
isRTL: isRTL(),
|
|
211
|
-
doLeftAndRightSwapInRTL:
|
|
499
|
+
doLeftAndRightSwapInRTL: getLeftAndRightSwap(),
|
|
212
500
|
localeIdentifier: hasDOM() ? navigator.language : void 0
|
|
213
501
|
}),
|
|
214
502
|
allowRTL: (allow) => {
|
|
@@ -219,620 +507,966 @@ const I18nManager = {
|
|
|
219
507
|
if (hasDOM()) document.documentElement.dir = force ? "rtl" : "";
|
|
220
508
|
},
|
|
221
509
|
swapLeftAndRightInRTL: (swap) => {
|
|
222
|
-
|
|
510
|
+
setLeftAndRightSwap(swap);
|
|
223
511
|
}
|
|
224
512
|
};
|
|
225
|
-
// src/apis/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
513
|
+
// src/apis/Keyboard/index.ts
|
|
514
|
+
/**
|
|
515
|
+
* Internal. Where the keyboard module reads the two browser objects. A test replaces them,
|
|
516
|
+
* because a headless browser shows no keyboard.
|
|
517
|
+
*/
|
|
518
|
+
const keyboardSources = {
|
|
519
|
+
visualViewport: () => window.visualViewport,
|
|
520
|
+
virtualKeyboard: () => navigator.virtualKeyboard
|
|
521
|
+
};
|
|
522
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
523
|
+
let observed = null;
|
|
524
|
+
let current$1 = null;
|
|
525
|
+
let frame = null;
|
|
526
|
+
const noTextInputTypes = /* @__PURE__ */ new Set([
|
|
527
|
+
"button",
|
|
528
|
+
"checkbox",
|
|
529
|
+
"color",
|
|
530
|
+
"file",
|
|
531
|
+
"hidden",
|
|
532
|
+
"image",
|
|
533
|
+
"radio",
|
|
534
|
+
"range",
|
|
535
|
+
"reset",
|
|
536
|
+
"submit"
|
|
537
|
+
]);
|
|
538
|
+
const isEditable = (element) => {
|
|
539
|
+
if (element instanceof HTMLTextAreaElement) return !element.readOnly && !element.disabled;
|
|
540
|
+
if (element instanceof HTMLInputElement) return !element.readOnly && !element.disabled && !noTextInputTypes.has(element.type);
|
|
541
|
+
return element instanceof HTMLElement && element.isContentEditable;
|
|
542
|
+
};
|
|
543
|
+
const read = () => {
|
|
544
|
+
if (!hasDOM()) return null;
|
|
545
|
+
const root = document.documentElement;
|
|
546
|
+
const virtualKeyboard = keyboardSources.virtualKeyboard();
|
|
547
|
+
if (virtualKeyboard?.overlaysContent === true) {
|
|
548
|
+
const { x, y, width, height } = virtualKeyboard.boundingRect;
|
|
549
|
+
return height > 0 ? {
|
|
550
|
+
screenX: x,
|
|
551
|
+
screenY: y,
|
|
552
|
+
width,
|
|
553
|
+
height
|
|
554
|
+
} : null;
|
|
248
555
|
}
|
|
249
|
-
const
|
|
556
|
+
const viewport = keyboardSources.visualViewport();
|
|
557
|
+
if (viewport === null || !isEditable(document.activeElement)) return null;
|
|
558
|
+
const height = Math.round(root.clientHeight - viewport.height * viewport.scale);
|
|
559
|
+
if (height <= 0) return null;
|
|
250
560
|
return {
|
|
251
|
-
|
|
252
|
-
|
|
561
|
+
screenX: 0,
|
|
562
|
+
screenY: Math.min(root.clientHeight - height + Math.round(viewport.offsetTop), root.clientHeight),
|
|
563
|
+
width: root.clientWidth,
|
|
564
|
+
height
|
|
253
565
|
};
|
|
254
566
|
};
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
const touchOf = (pointer, rect, timestamp) => ({
|
|
263
|
-
changedTouches: [],
|
|
264
|
-
identifier: pointer.id,
|
|
265
|
-
locationX: pointer.clientX - rect.left,
|
|
266
|
-
locationY: pointer.clientY - rect.top,
|
|
267
|
-
pageX: pointer.clientX + window.scrollX,
|
|
268
|
-
pageY: pointer.clientY + window.scrollY,
|
|
269
|
-
target: pointer.target,
|
|
270
|
-
timestamp,
|
|
271
|
-
touches: []
|
|
567
|
+
const hiddenMetrics = () => ({
|
|
568
|
+
screenX: 0,
|
|
569
|
+
screenY: hasDOM() ? document.documentElement.clientHeight : 0,
|
|
570
|
+
width: hasDOM() ? document.documentElement.clientWidth : 0,
|
|
571
|
+
height: 0
|
|
272
572
|
});
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
define$1(event.nativeEvent, {
|
|
278
|
-
...touch,
|
|
279
|
-
force: event.pressure,
|
|
280
|
-
touches,
|
|
281
|
-
changedTouches: [touch]
|
|
282
|
-
});
|
|
283
|
-
return event;
|
|
284
|
-
};
|
|
285
|
-
const pointerOf = (event) => ({
|
|
286
|
-
id: event.pointerId,
|
|
287
|
-
clientX: event.clientX,
|
|
288
|
-
clientY: event.clientY,
|
|
289
|
-
target: event.target
|
|
573
|
+
const toEvent = (endCoordinates) => ({
|
|
574
|
+
duration: 0,
|
|
575
|
+
easing: "keyboard",
|
|
576
|
+
endCoordinates
|
|
290
577
|
});
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
const dt = time - last.time;
|
|
297
|
-
state.dx += next.x - last.x;
|
|
298
|
-
state.dy += next.y - last.y;
|
|
299
|
-
state.vx = dt > 0 ? (next.x - last.x) / dt : 0;
|
|
300
|
-
state.vy = dt > 0 ? (next.y - last.y) / dt : 0;
|
|
301
|
-
}
|
|
302
|
-
state.moveX = next.x;
|
|
303
|
-
state.moveY = next.y;
|
|
304
|
-
state._accountsForMovesUpTo = time;
|
|
305
|
-
responder.last = {
|
|
306
|
-
x: next.x,
|
|
307
|
-
y: next.y,
|
|
308
|
-
time
|
|
309
|
-
};
|
|
578
|
+
const sameMetrics = (a, b) => a === b || a !== null && b !== null && a.screenX === b.screenX && a.screenY === b.screenY && a.width === b.width && a.height === b.height;
|
|
579
|
+
const emit = (name, event) => {
|
|
580
|
+
const set = listeners.get(name);
|
|
581
|
+
if (set === void 0) return;
|
|
582
|
+
for (const listener of set) listener(event);
|
|
310
583
|
};
|
|
311
|
-
const
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
responder.gestureState.numberActiveTouches = responder.pointers.size;
|
|
584
|
+
const update = () => {
|
|
585
|
+
frame = null;
|
|
586
|
+
const next = read();
|
|
587
|
+
if (sameMetrics(next, current$1)) return;
|
|
588
|
+
current$1 = next;
|
|
589
|
+
if (next === null) emit("keyboardDidHide", toEvent(hiddenMetrics()));
|
|
590
|
+
else emit("keyboardDidShow", toEvent(next));
|
|
319
591
|
};
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
const point = centroid(responder.pointers);
|
|
323
|
-
state.x0 = point.x;
|
|
324
|
-
state.y0 = point.y;
|
|
325
|
-
state.dx = 0;
|
|
326
|
-
state.dy = 0;
|
|
327
|
-
state.vx = 0;
|
|
328
|
-
state.vy = 0;
|
|
329
|
-
responder.last = {
|
|
330
|
-
x: point.x,
|
|
331
|
-
y: point.y,
|
|
332
|
-
time: event.timeStamp
|
|
333
|
-
};
|
|
334
|
-
responder.element = event.currentTarget;
|
|
335
|
-
current = responder;
|
|
336
|
-
grantEvent = event.nativeEvent;
|
|
337
|
-
for (const pointer of responder.pointers.values()) try {
|
|
338
|
-
responder.element.setPointerCapture(pointer.id);
|
|
339
|
-
} catch {}
|
|
340
|
-
responder.config.onPanResponderGrant?.(responderEvent, state);
|
|
341
|
-
responder.config.onPanResponderStart?.(responderEvent, state);
|
|
592
|
+
const schedule = () => {
|
|
593
|
+
if (frame === null) frame = requestAnimationFrame(update);
|
|
342
594
|
};
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
595
|
+
const startObserving = () => {
|
|
596
|
+
if (observed !== null || !hasDOM()) return;
|
|
597
|
+
observed = {
|
|
598
|
+
viewport: keyboardSources.visualViewport(),
|
|
599
|
+
virtualKeyboard: keyboardSources.virtualKeyboard()
|
|
600
|
+
};
|
|
601
|
+
current$1 = read();
|
|
602
|
+
observed.viewport?.addEventListener("resize", schedule);
|
|
603
|
+
observed.viewport?.addEventListener("scroll", schedule);
|
|
604
|
+
observed.virtualKeyboard?.addEventListener("geometrychange", schedule);
|
|
605
|
+
window.addEventListener("resize", schedule);
|
|
349
606
|
};
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
607
|
+
const stopObserving = () => {
|
|
608
|
+
if (observed === null) return;
|
|
609
|
+
for (const set of listeners.values()) if (set.size > 0) return;
|
|
610
|
+
observed.viewport?.removeEventListener("resize", schedule);
|
|
611
|
+
observed.viewport?.removeEventListener("scroll", schedule);
|
|
612
|
+
observed.virtualKeyboard?.removeEventListener("geometrychange", schedule);
|
|
613
|
+
window.removeEventListener("resize", schedule);
|
|
614
|
+
observed = null;
|
|
615
|
+
if (frame !== null) cancelAnimationFrame(frame);
|
|
616
|
+
frame = null;
|
|
617
|
+
current$1 = null;
|
|
355
618
|
};
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
619
|
+
const state = () => observed === null ? read() : current$1;
|
|
620
|
+
/**
|
|
621
|
+
* The keyboard of a phone or a tablet, as on Android: `keyboardDidShow` fires when the keyboard
|
|
622
|
+
* shows and when its height changes, and `keyboardDidHide` fires when it hides. The `Will` and
|
|
623
|
+
* `ChangeFrame` events never fire.
|
|
624
|
+
*/
|
|
625
|
+
const Keyboard = {
|
|
626
|
+
addListener(eventType, listener) {
|
|
627
|
+
let set = listeners.get(eventType);
|
|
628
|
+
if (set === void 0) {
|
|
629
|
+
set = /* @__PURE__ */ new Set();
|
|
630
|
+
listeners.set(eventType, set);
|
|
365
631
|
}
|
|
366
|
-
|
|
367
|
-
|
|
632
|
+
const entry = (event) => listener(event);
|
|
633
|
+
set.add(entry);
|
|
634
|
+
startObserving();
|
|
635
|
+
return { remove: () => {
|
|
636
|
+
set.delete(entry);
|
|
637
|
+
stopObserving();
|
|
638
|
+
} };
|
|
639
|
+
},
|
|
640
|
+
removeAllListeners(eventType) {
|
|
641
|
+
if (eventType === void 0 || eventType === null) listeners.clear();
|
|
642
|
+
else listeners.delete(eventType);
|
|
643
|
+
stopObserving();
|
|
644
|
+
},
|
|
645
|
+
dismiss() {
|
|
646
|
+
if (!hasDOM()) return;
|
|
647
|
+
const active = document.activeElement;
|
|
648
|
+
if (isEditable(active)) active.blur();
|
|
649
|
+
},
|
|
650
|
+
isVisible() {
|
|
651
|
+
return state() !== null;
|
|
652
|
+
},
|
|
653
|
+
metrics() {
|
|
654
|
+
return state() ?? void 0;
|
|
655
|
+
},
|
|
656
|
+
scheduleLayoutAnimation() {}
|
|
657
|
+
};
|
|
658
|
+
// src/apis/Linking/index.ts
|
|
659
|
+
const registrations = /* @__PURE__ */ new Map();
|
|
660
|
+
const addListener = (eventType, listener, context) => {
|
|
661
|
+
let set = registrations.get(eventType);
|
|
662
|
+
if (set === void 0) {
|
|
663
|
+
set = /* @__PURE__ */ new Set();
|
|
664
|
+
registrations.set(eventType, set);
|
|
368
665
|
}
|
|
369
|
-
|
|
666
|
+
const registration = {
|
|
667
|
+
listener,
|
|
668
|
+
context
|
|
669
|
+
};
|
|
670
|
+
const owner = set;
|
|
671
|
+
owner.add(registration);
|
|
672
|
+
return { remove: () => owner.delete(registration) };
|
|
370
673
|
};
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
674
|
+
const validate = (url) => {
|
|
675
|
+
if (typeof url !== "string") throw new Error(`Invalid URL: should be a string. Was: ${String(url)}`);
|
|
676
|
+
if (url === "") throw new Error("Invalid URL: cannot be empty");
|
|
677
|
+
};
|
|
678
|
+
const REFUSED_PROTOCOLS = /* @__PURE__ */ new Set(["javascript:", "data:"]);
|
|
679
|
+
const destination = (url) => {
|
|
680
|
+
if (!hasDOM()) return /* @__PURE__ */ new Error("Linking: there is no browser to open a URL in.");
|
|
681
|
+
let parsed;
|
|
682
|
+
try {
|
|
683
|
+
parsed = new URL(url, window.location.href);
|
|
684
|
+
} catch {
|
|
685
|
+
return /* @__PURE__ */ new Error(`Linking: "${url}" isn't a valid URL.`);
|
|
686
|
+
}
|
|
687
|
+
if (REFUSED_PROTOCOLS.has(parsed.protocol)) return /* @__PURE__ */ new Error(`Linking: refused to open a ${parsed.protocol} URL.`);
|
|
688
|
+
const web = parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
689
|
+
return {
|
|
690
|
+
href: parsed.href,
|
|
691
|
+
newTab: web && parsed.origin !== window.location.origin
|
|
387
692
|
};
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
693
|
+
};
|
|
694
|
+
const loadedURL = () => {
|
|
695
|
+
if (!hasDOM()) return null;
|
|
696
|
+
const [entry] = performance.getEntriesByType("navigation");
|
|
697
|
+
return entry?.name || window.location.href;
|
|
698
|
+
};
|
|
699
|
+
/** For tests: `location.assign` can't be replaced, so the tests replace this. */
|
|
700
|
+
const browserNavigation = { assign: (href) => window.location.assign(href) };
|
|
701
|
+
/**
|
|
702
|
+
* Opens URLs and reports the URL that the page loaded with. A URL of this site opens in this tab,
|
|
703
|
+
* a URL of another site in a new tab, and `mailto:`, `tel:`, and other schemes go to the system.
|
|
704
|
+
* The browser never fires `url`: back, forward, and links belong to the router.
|
|
705
|
+
*/
|
|
706
|
+
const Linking = {
|
|
707
|
+
addEventListener: (eventType, listener) => addListener(eventType, listener),
|
|
708
|
+
addListener,
|
|
709
|
+
emit(eventType, ...args) {
|
|
710
|
+
const set = registrations.get(eventType);
|
|
711
|
+
if (set === void 0) return;
|
|
712
|
+
for (const { listener, context } of Array.from(set)) Reflect.apply(listener, context, args);
|
|
713
|
+
},
|
|
714
|
+
removeAllListeners(eventType) {
|
|
715
|
+
if (eventType === void 0 || eventType === null) registrations.clear();
|
|
716
|
+
else registrations.delete(eventType);
|
|
717
|
+
},
|
|
718
|
+
listenerCount: (eventType) => registrations.get(eventType)?.size ?? 0,
|
|
719
|
+
openURL(url) {
|
|
720
|
+
validate(url);
|
|
721
|
+
const target = destination(url);
|
|
722
|
+
if (target instanceof Error) return Promise.reject(target);
|
|
723
|
+
if (!target.newTab) {
|
|
724
|
+
browserNavigation.assign(target.href);
|
|
725
|
+
return Promise.resolve();
|
|
401
726
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
if (pointer === void 0) return;
|
|
407
|
-
const responderEvent = toResponderEvent(event, responder, pointer);
|
|
408
|
-
responder.pointers.delete(event.pointerId);
|
|
409
|
-
const { config, gestureState } = responder;
|
|
410
|
-
const responding = current === responder;
|
|
411
|
-
if (responding && cancel) {
|
|
412
|
-
config.onPanResponderTerminate?.(responderEvent, gestureState);
|
|
413
|
-
responder.pointers.clear();
|
|
414
|
-
finish(responder);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (responding) config.onPanResponderEnd?.(responderEvent, gestureState);
|
|
418
|
-
if (responder.pointers.size === 0) {
|
|
419
|
-
if (responding) config.onPanResponderRelease?.(responderEvent, gestureState);
|
|
420
|
-
finish(responder);
|
|
421
|
-
} else rebase(responder, event.timeStamp);
|
|
422
|
-
};
|
|
423
|
-
return {
|
|
424
|
-
onPointerDownCapture: (event) => down(event, true),
|
|
425
|
-
onPointerDown: (event) => down(event, false),
|
|
426
|
-
onPointerMoveCapture: (event) => move(event, true),
|
|
427
|
-
onPointerMove: (event) => move(event, false),
|
|
428
|
-
onPointerUp: (event) => end(event, false),
|
|
429
|
-
onPointerCancel: (event) => end(event, true)
|
|
430
|
-
};
|
|
431
|
-
};
|
|
432
|
-
const PanResponder = { create(config) {
|
|
433
|
-
const responder = {
|
|
434
|
-
config,
|
|
435
|
-
gestureState: newGestureState(),
|
|
436
|
-
pointers: /* @__PURE__ */ new Map(),
|
|
437
|
-
element: null,
|
|
438
|
-
last: null
|
|
439
|
-
};
|
|
440
|
-
return {
|
|
441
|
-
panHandlers: createHandlers(responder),
|
|
442
|
-
getInteractionHandle: () => null
|
|
443
|
-
};
|
|
444
|
-
} };
|
|
445
|
-
// src/apis/PixelRatio/index.ts
|
|
446
|
-
const PixelRatio = {
|
|
447
|
-
get: () => Dimensions.get("window").scale,
|
|
448
|
-
getFontScale: () => Dimensions.get("window").fontScale,
|
|
449
|
-
getPixelSizeForLayoutSize: (layoutSize) => Math.round(layoutSize * PixelRatio.get()),
|
|
450
|
-
roundToNearestPixel: (layoutSize) => {
|
|
451
|
-
const ratio = PixelRatio.get();
|
|
452
|
-
return Math.round(layoutSize * ratio) / ratio;
|
|
727
|
+
const opened = window.open(target.href, "_blank");
|
|
728
|
+
if (opened === null) return Promise.reject(/* @__PURE__ */ new Error(`Linking: the browser blocked the new tab for ${target.href}. Call openURL from a press handler.`));
|
|
729
|
+
opened.opener = null;
|
|
730
|
+
return Promise.resolve();
|
|
453
731
|
},
|
|
454
|
-
|
|
732
|
+
canOpenURL(url) {
|
|
733
|
+
validate(url);
|
|
734
|
+
return Promise.resolve(!(destination(url) instanceof Error));
|
|
735
|
+
},
|
|
736
|
+
openSettings: () => Promise.reject(/* @__PURE__ */ new Error("Linking.openSettings: the web has no settings page for an app.")),
|
|
737
|
+
getInitialURL: () => Promise.resolve(loadedURL()),
|
|
738
|
+
sendIntent: () => Promise.reject(/* @__PURE__ */ new Error("Unsupported"))
|
|
455
739
|
};
|
|
456
|
-
// src/
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
740
|
+
// src/events/responderEvent.ts
|
|
741
|
+
const hasPoint = (event) => event.clientX !== void 0 && !(event.type === "click" && event.detail === 0);
|
|
742
|
+
const activeTypes = /* @__PURE__ */ new Set([
|
|
743
|
+
"pointerdown",
|
|
744
|
+
"pointermove",
|
|
745
|
+
"keydown"
|
|
746
|
+
]);
|
|
747
|
+
const define$1 = (target, fields) => {
|
|
748
|
+
for (const key in fields) {
|
|
749
|
+
if (key in target) continue;
|
|
750
|
+
Object.defineProperty(target, key, {
|
|
751
|
+
value: fields[key],
|
|
752
|
+
configurable: true
|
|
753
|
+
});
|
|
754
|
+
}
|
|
462
755
|
};
|
|
463
|
-
|
|
464
|
-
const
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
756
|
+
const toGestureResponderEvent = (event, element) => {
|
|
757
|
+
const native = event.nativeEvent;
|
|
758
|
+
if (!("locationX" in native)) {
|
|
759
|
+
const rect = element.getBoundingClientRect();
|
|
760
|
+
const point = hasPoint(native);
|
|
761
|
+
const clientX = point ? native.clientX ?? 0 : rect.left + rect.width / 2;
|
|
762
|
+
const clientY = point ? native.clientY ?? 0 : rect.top + rect.height / 2;
|
|
763
|
+
const touch = {
|
|
764
|
+
changedTouches: [],
|
|
765
|
+
force: native.pressure,
|
|
766
|
+
identifier: native.pointerId ?? 0,
|
|
767
|
+
locationX: clientX - rect.left,
|
|
768
|
+
locationY: clientY - rect.top,
|
|
769
|
+
pageX: clientX + window.scrollX,
|
|
770
|
+
pageY: clientY + window.scrollY,
|
|
771
|
+
target: native.target,
|
|
772
|
+
timestamp: event.timeStamp,
|
|
773
|
+
touches: []
|
|
774
|
+
};
|
|
775
|
+
define$1(native, {
|
|
776
|
+
...touch,
|
|
777
|
+
changedTouches: [touch],
|
|
778
|
+
touches: activeTypes.has(native.type) ? [touch] : []
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
return event;
|
|
782
|
+
};
|
|
783
|
+
const toMouseEvent = (event) => {
|
|
784
|
+
define$1(event.nativeEvent, { timestamp: event.timeStamp });
|
|
785
|
+
return event;
|
|
786
|
+
};
|
|
787
|
+
// src/events/press/Pressability.ts
|
|
788
|
+
const transitions = {
|
|
789
|
+
NOT_RESPONDER: { RESPONDER_GRANT: "RESPONDER_INACTIVE_PRESS_IN" },
|
|
790
|
+
RESPONDER_INACTIVE_PRESS_IN: {
|
|
791
|
+
DELAY: "RESPONDER_ACTIVE_PRESS_IN",
|
|
792
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
793
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
794
|
+
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
|
|
795
|
+
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
468
796
|
},
|
|
469
|
-
|
|
470
|
-
|
|
797
|
+
RESPONDER_INACTIVE_PRESS_OUT: {
|
|
798
|
+
DELAY: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
799
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
800
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
801
|
+
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
|
|
802
|
+
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT"
|
|
471
803
|
},
|
|
472
|
-
|
|
473
|
-
|
|
804
|
+
RESPONDER_ACTIVE_PRESS_IN: {
|
|
805
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
806
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
807
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
808
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
|
|
809
|
+
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
474
810
|
},
|
|
475
|
-
|
|
476
|
-
|
|
811
|
+
RESPONDER_ACTIVE_PRESS_OUT: {
|
|
812
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
813
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
814
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
|
|
815
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT"
|
|
477
816
|
},
|
|
478
|
-
|
|
479
|
-
|
|
817
|
+
RESPONDER_ACTIVE_LONG_PRESS_IN: {
|
|
818
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
819
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
820
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
821
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
|
|
822
|
+
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
|
|
480
823
|
},
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
824
|
+
RESPONDER_ACTIVE_LONG_PRESS_OUT: {
|
|
825
|
+
RESPONDER_RELEASE: "NOT_RESPONDER",
|
|
826
|
+
RESPONDER_TERMINATED: "NOT_RESPONDER",
|
|
827
|
+
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
|
|
828
|
+
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT"
|
|
484
829
|
}
|
|
485
830
|
};
|
|
486
|
-
|
|
487
|
-
const
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
const packed = normalizeColor(value);
|
|
498
|
-
if (packed === null || packed === void 0) return void 0;
|
|
499
|
-
const r = packed >>> 24 & 255;
|
|
500
|
-
const g = packed >>> 16 & 255;
|
|
501
|
-
const b = packed >>> 8 & 255;
|
|
502
|
-
const a = (packed & 255) / 255;
|
|
503
|
-
return a === 1 ? `rgb(${r},${g},${b})` : `rgba(${r},${g},${b},${round(a)})`;
|
|
504
|
-
};
|
|
505
|
-
const round = (n) => Math.round(n * 1e3) / 1e3;
|
|
506
|
-
// src/style/units.ts
|
|
507
|
-
const toUnit = (value, unit) => {
|
|
508
|
-
if (typeof value === "number") return value === 0 ? "0" : `${value}${unit}`;
|
|
509
|
-
return String(value);
|
|
510
|
-
};
|
|
511
|
-
const unitlessProperties = /* @__PURE__ */ new Set([
|
|
512
|
-
"aspectRatio",
|
|
513
|
-
"flex",
|
|
514
|
-
"flexGrow",
|
|
515
|
-
"flexShrink",
|
|
516
|
-
"fontWeight",
|
|
517
|
-
"lineClamp",
|
|
518
|
-
"WebkitLineClamp",
|
|
519
|
-
"opacity",
|
|
520
|
-
"zIndex",
|
|
521
|
-
"scale",
|
|
522
|
-
"shadowOpacity"
|
|
523
|
-
]);
|
|
524
|
-
// src/style/shadow.ts
|
|
525
|
-
const offsetOf = (value) => {
|
|
526
|
-
const o = value ?? {};
|
|
527
|
-
return {
|
|
528
|
-
x: typeof o.width === "number" ? o.width : 0,
|
|
529
|
-
y: typeof o.height === "number" ? o.height : 0
|
|
530
|
-
};
|
|
831
|
+
const isActive = (state) => state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
|
|
832
|
+
const isActivation = (state) => state === "RESPONDER_ACTIVE_PRESS_OUT" || state === "RESPONDER_ACTIVE_PRESS_IN";
|
|
833
|
+
const isPressIn = (state) => state === "RESPONDER_INACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_PRESS_IN" || state === "RESPONDER_ACTIVE_LONG_PRESS_IN";
|
|
834
|
+
const isTerminal = (signal) => signal === "RESPONDER_TERMINATED" || signal === "RESPONDER_RELEASE";
|
|
835
|
+
const DEFAULT_LONG_PRESS_DELAY_MS = 500;
|
|
836
|
+
const DEFAULT_MIN_PRESS_DURATION = 130;
|
|
837
|
+
const DEFAULT_PRESS_RECT_OFFSETS = {
|
|
838
|
+
bottom: 30,
|
|
839
|
+
left: 20,
|
|
840
|
+
right: 20,
|
|
841
|
+
top: 20
|
|
531
842
|
};
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
};
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
const color = toCSSColor(style["textShadowColor"] ?? "black");
|
|
544
|
-
if (color === void 0) return void 0;
|
|
545
|
-
return `${x}px ${y}px ${radius}px ${color}`;
|
|
546
|
-
};
|
|
547
|
-
const toCSSBoxShadow = (value) => {
|
|
548
|
-
if (typeof value === "string") return value;
|
|
549
|
-
if (!Array.isArray(value)) return void 0;
|
|
550
|
-
const shadows = value.map((s) => {
|
|
551
|
-
const parts = [
|
|
552
|
-
toUnit(s.offsetX, "px"),
|
|
553
|
-
toUnit(s.offsetY, "px"),
|
|
554
|
-
toUnit(s.blurRadius ?? 0, "px"),
|
|
555
|
-
toUnit(s.spreadDistance ?? 0, "px"),
|
|
556
|
-
toCSSColor(s.color ?? "black") ?? "black"
|
|
557
|
-
];
|
|
558
|
-
if (s.inset === true) parts.push("inset");
|
|
559
|
-
return parts.join(" ");
|
|
560
|
-
});
|
|
561
|
-
return shadows.length === 0 ? "none" : shadows.join(", ");
|
|
562
|
-
};
|
|
563
|
-
const lengthFilters = /* @__PURE__ */ new Set(["blur"]);
|
|
564
|
-
const angleFilters = /* @__PURE__ */ new Set(["hueRotate"]);
|
|
565
|
-
const toCSSFilter = (value) => {
|
|
566
|
-
if (typeof value === "string") return value;
|
|
567
|
-
if (!Array.isArray(value)) return void 0;
|
|
568
|
-
const parts = [];
|
|
569
|
-
for (const entry of value) for (const [name, raw] of Object.entries(entry)) {
|
|
570
|
-
const css = toFilterFunction(name, raw);
|
|
571
|
-
if (css !== void 0) parts.push(css);
|
|
572
|
-
}
|
|
573
|
-
return parts.length === 0 ? "none" : parts.join(" ");
|
|
574
|
-
};
|
|
575
|
-
const toFilterFunction = (name, raw) => {
|
|
576
|
-
if (name === "dropShadow") {
|
|
577
|
-
const shadow = typeof raw === "string" ? raw : dropShadow(raw);
|
|
578
|
-
return shadow === void 0 ? void 0 : `drop-shadow(${shadow})`;
|
|
579
|
-
}
|
|
580
|
-
const cssName = name === "hueRotate" ? "hue-rotate" : name;
|
|
581
|
-
if (typeof raw === "number") {
|
|
582
|
-
if (lengthFilters.has(name)) return `${cssName}(${raw}px)`;
|
|
583
|
-
if (angleFilters.has(name)) return `${cssName}(${raw}deg)`;
|
|
584
|
-
return `${cssName}(${raw})`;
|
|
585
|
-
}
|
|
586
|
-
if (typeof raw === "string") return `${cssName}(${raw})`;
|
|
587
|
-
};
|
|
588
|
-
const dropShadow = (v) => {
|
|
589
|
-
const color = toCSSColor(v["color"] ?? "black");
|
|
590
|
-
if (color === void 0) return void 0;
|
|
591
|
-
return [
|
|
592
|
-
toUnit(v["offsetX"] ?? 0, "px"),
|
|
593
|
-
toUnit(v["offsetY"] ?? 0, "px"),
|
|
594
|
-
toUnit(v["standardDeviation"] ?? 0, "px"),
|
|
595
|
-
color
|
|
596
|
-
].join(" ");
|
|
597
|
-
};
|
|
598
|
-
const withOpacity = (color, opacity) => {
|
|
599
|
-
if (opacity >= 1) return color;
|
|
600
|
-
const match = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(color);
|
|
601
|
-
if (match === null) return color;
|
|
602
|
-
const alpha = match[4] === void 0 ? 1 : Number(match[4]);
|
|
603
|
-
const a = Math.round(alpha * opacity * 1e3) / 1e3;
|
|
604
|
-
return `rgba(${match[1]},${match[2]},${match[3]},${a})`;
|
|
605
|
-
};
|
|
606
|
-
// src/style/transform.ts
|
|
607
|
-
const lengthFunctions = /* @__PURE__ */ new Set([
|
|
608
|
-
"translateX",
|
|
609
|
-
"translateY",
|
|
610
|
-
"translateZ",
|
|
611
|
-
"perspective"
|
|
612
|
-
]);
|
|
613
|
-
const toCSSTransform = (value) => {
|
|
614
|
-
if (typeof value === "string") return value;
|
|
615
|
-
if (!Array.isArray(value)) return void 0;
|
|
616
|
-
const parts = [];
|
|
617
|
-
for (const entry of value) {
|
|
618
|
-
if (entry === null || typeof entry !== "object") continue;
|
|
619
|
-
for (const [name, raw] of Object.entries(entry)) {
|
|
620
|
-
const css = toTransformFunction(name, raw);
|
|
621
|
-
if (css !== void 0) parts.push(css);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
return parts.length === 0 ? "none" : parts.join(" ");
|
|
625
|
-
};
|
|
626
|
-
const toTransformFunction = (name, raw) => {
|
|
627
|
-
if (name === "matrix" && Array.isArray(raw)) return `${raw.length === 16 ? "matrix3d" : "matrix"}(${raw.join(",")})`;
|
|
628
|
-
if (name === "translate" && Array.isArray(raw)) return `translate(${raw.map((v) => toUnit(v, "px")).join(",")})`;
|
|
629
|
-
if (typeof raw === "number") return lengthFunctions.has(name) ? `${name}(${raw}px)` : `${name}(${raw})`;
|
|
630
|
-
if (typeof raw === "string") return `${name}(${raw})`;
|
|
631
|
-
};
|
|
632
|
-
const toCSSTransformOrigin = (value) => {
|
|
633
|
-
if (typeof value === "string") return value;
|
|
634
|
-
if (!Array.isArray(value)) return void 0;
|
|
635
|
-
return value.map((v) => toUnit(v, "px")).join(" ");
|
|
636
|
-
};
|
|
637
|
-
// src/style/resolveStyle.ts
|
|
638
|
-
const colorProperties = /* @__PURE__ */ new Set([
|
|
639
|
-
"backgroundColor",
|
|
640
|
-
"borderBlockColor",
|
|
641
|
-
"borderBlockEndColor",
|
|
642
|
-
"borderBlockStartColor",
|
|
643
|
-
"borderBottomColor",
|
|
644
|
-
"borderColor",
|
|
645
|
-
"borderEndColor",
|
|
646
|
-
"borderLeftColor",
|
|
647
|
-
"borderRightColor",
|
|
648
|
-
"borderStartColor",
|
|
649
|
-
"borderTopColor",
|
|
650
|
-
"color",
|
|
651
|
-
"outlineColor",
|
|
652
|
-
"textDecorationColor"
|
|
653
|
-
]);
|
|
654
|
-
const renamedProperties = {
|
|
655
|
-
borderEndColor: "borderInlineEndColor",
|
|
656
|
-
borderEndWidth: "borderInlineEndWidth",
|
|
657
|
-
borderStartColor: "borderInlineStartColor",
|
|
658
|
-
borderStartWidth: "borderInlineStartWidth",
|
|
659
|
-
borderTopStartRadius: "borderStartStartRadius",
|
|
660
|
-
borderTopEndRadius: "borderStartEndRadius",
|
|
661
|
-
borderBottomStartRadius: "borderEndStartRadius",
|
|
662
|
-
borderBottomEndRadius: "borderEndEndRadius",
|
|
663
|
-
end: "insetInlineEnd",
|
|
664
|
-
marginEnd: "marginInlineEnd",
|
|
665
|
-
marginStart: "marginInlineStart",
|
|
666
|
-
paddingEnd: "paddingInlineEnd",
|
|
667
|
-
paddingStart: "paddingInlineStart",
|
|
668
|
-
start: "insetInlineStart",
|
|
669
|
-
writingDirection: "direction"
|
|
670
|
-
};
|
|
671
|
-
const expandedProperties = {
|
|
672
|
-
marginHorizontal: ["marginLeft", "marginRight"],
|
|
673
|
-
marginVertical: ["marginTop", "marginBottom"],
|
|
674
|
-
paddingHorizontal: ["paddingLeft", "paddingRight"],
|
|
675
|
-
paddingVertical: ["paddingTop", "paddingBottom"]
|
|
676
|
-
};
|
|
677
|
-
const ignoredProperties = /* @__PURE__ */ new Set([
|
|
678
|
-
"borderCurve",
|
|
679
|
-
"elevation",
|
|
680
|
-
"includeFontPadding",
|
|
681
|
-
"overlayColor",
|
|
682
|
-
"shadowColor",
|
|
683
|
-
"shadowOffset",
|
|
684
|
-
"shadowOpacity",
|
|
685
|
-
"shadowRadius",
|
|
686
|
-
"textShadowColor",
|
|
687
|
-
"textShadowOffset",
|
|
688
|
-
"textShadowRadius",
|
|
689
|
-
"tintColor"
|
|
690
|
-
]);
|
|
691
|
-
const fontWeightNames = {
|
|
692
|
-
ultralight: "200",
|
|
693
|
-
thin: "100",
|
|
694
|
-
light: "300",
|
|
695
|
-
regular: "400",
|
|
696
|
-
medium: "500",
|
|
697
|
-
semibold: "600",
|
|
698
|
-
condensedBold: "700",
|
|
699
|
-
condensed: "400",
|
|
700
|
-
heavy: "800",
|
|
701
|
-
black: "900"
|
|
702
|
-
};
|
|
703
|
-
const resizeModeToObjectFit = {
|
|
704
|
-
contain: "contain",
|
|
705
|
-
cover: "cover",
|
|
706
|
-
stretch: "fill",
|
|
707
|
-
center: "none",
|
|
708
|
-
repeat: "none"
|
|
843
|
+
let longPressDeactivationDistance = 10;
|
|
844
|
+
const normalizeDelay = (delay, min = 0, fallback = 0) => Math.max(min, delay ?? fallback);
|
|
845
|
+
const normalizeRect = (rect) => typeof rect === "number" ? {
|
|
846
|
+
bottom: rect,
|
|
847
|
+
left: rect,
|
|
848
|
+
right: rect,
|
|
849
|
+
top: rect
|
|
850
|
+
} : rect;
|
|
851
|
+
const claimed = /* @__PURE__ */ new WeakSet();
|
|
852
|
+
const claimPress = (event) => {
|
|
853
|
+
claimed.add(event);
|
|
709
854
|
};
|
|
710
|
-
const
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
center: "middle",
|
|
714
|
-
bottom: "bottom"
|
|
855
|
+
const pressing = /* @__PURE__ */ new Map();
|
|
856
|
+
const terminatePress = (event) => {
|
|
857
|
+
pressing.get(event.pointerId)?.terminate(event, true);
|
|
715
858
|
};
|
|
716
|
-
const
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
if (shadow !== void 0) out["textShadow"] = shadow;
|
|
859
|
+
const isPressClaimed = (event) => claimed.has(event);
|
|
860
|
+
const isActivationKey = (key) => key === "Enter" || key === " ";
|
|
861
|
+
const hasNativeActivation = (element) => {
|
|
862
|
+
switch (element.tagName) {
|
|
863
|
+
case "BUTTON":
|
|
864
|
+
case "INPUT":
|
|
865
|
+
case "SELECT":
|
|
866
|
+
case "SUMMARY":
|
|
867
|
+
case "TEXTAREA": return true;
|
|
868
|
+
case "A":
|
|
869
|
+
case "AREA": return element.hasAttribute("href");
|
|
870
|
+
default: return element.isContentEditable;
|
|
729
871
|
}
|
|
730
|
-
return out;
|
|
731
872
|
};
|
|
732
|
-
const
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
const origin = toCSSTransformOrigin(value);
|
|
745
|
-
if (origin !== void 0) out["transformOrigin"] = origin;
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
case "boxShadow": {
|
|
749
|
-
const shadow = toCSSBoxShadow(value);
|
|
750
|
-
if (shadow !== void 0) out["boxShadow"] = shadow;
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
|
-
case "filter": {
|
|
754
|
-
const filter = toCSSFilter(value);
|
|
755
|
-
if (filter !== void 0) out["filter"] = filter;
|
|
756
|
-
return;
|
|
757
|
-
}
|
|
758
|
-
case "fontWeight":
|
|
759
|
-
out["fontWeight"] = fontWeightNames[String(value)] ?? String(value);
|
|
760
|
-
return;
|
|
761
|
-
case "fontFamily":
|
|
762
|
-
out["fontFamily"] = value === "System" ? systemFontStack : String(value);
|
|
763
|
-
return;
|
|
764
|
-
case "fontVariant":
|
|
765
|
-
out["fontVariant"] = Array.isArray(value) ? value.join(" ") : String(value);
|
|
766
|
-
return;
|
|
767
|
-
case "fontVariationSettings":
|
|
768
|
-
out["fontVariationSettings"] = Array.isArray(value) ? value.map((v) => `'${v.axis}' ${v.value}`).join(", ") : String(value);
|
|
769
|
-
return;
|
|
770
|
-
case "resizeMode": {
|
|
771
|
-
const fit = resizeModeToObjectFit[String(value)];
|
|
772
|
-
if (fit !== void 0 && out["objectFit"] === void 0) out["objectFit"] = fit;
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
case "objectFit":
|
|
776
|
-
out["objectFit"] = String(value);
|
|
777
|
-
return;
|
|
778
|
-
case "textAlignVertical": {
|
|
779
|
-
const align = textAlignVerticalToVerticalAlign[String(value)];
|
|
780
|
-
if (align !== void 0 && out["verticalAlign"] === void 0) out["verticalAlign"] = align;
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
case "backgroundImage":
|
|
784
|
-
if (typeof value === "string") out["backgroundImage"] = value;
|
|
785
|
-
return;
|
|
786
|
-
}
|
|
787
|
-
if (colorProperties.has(name)) {
|
|
788
|
-
const color = toCSSColor(value);
|
|
789
|
-
if (color !== void 0) out[renamedProperties[name] ?? name] = color;
|
|
790
|
-
return;
|
|
873
|
+
const nativeControl = "a[href],area[href],audio[controls],button,input,select,summary,textarea,video[controls],[contenteditable]:not([contenteditable=\"false\"])";
|
|
874
|
+
const startsInNativeControl = (event) => {
|
|
875
|
+
const { currentTarget, target } = event;
|
|
876
|
+
if (!(target instanceof Element)) return false;
|
|
877
|
+
const control = target.closest(nativeControl);
|
|
878
|
+
return control !== null && control !== currentTarget && currentTarget.contains(control);
|
|
879
|
+
};
|
|
880
|
+
const TAP_CLICK_WINDOW_MS = 1e3;
|
|
881
|
+
const stopRetargetedClick = (element, releasedAt) => {
|
|
882
|
+
function end() {
|
|
883
|
+
window.removeEventListener("click", onClick, true);
|
|
884
|
+
window.removeEventListener("pointerdown", end, true);
|
|
791
885
|
}
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
if (style === null || style === void 0 || style === false || style === "") return void 0;
|
|
800
|
-
if (!Array.isArray(style)) return style;
|
|
801
|
-
let result;
|
|
802
|
-
for (const entry of style) {
|
|
803
|
-
const flat = flattenStyle(entry);
|
|
804
|
-
if (flat === void 0) continue;
|
|
805
|
-
result = result === void 0 ? { ...flat } : Object.assign(result, flat);
|
|
806
|
-
}
|
|
807
|
-
return result;
|
|
808
|
-
};
|
|
809
|
-
const cache = /* @__PURE__ */ new WeakMap();
|
|
810
|
-
const compileStyle = (style, registry = getStyleRegistry()) => {
|
|
811
|
-
const flat = flattenStyle(style);
|
|
812
|
-
if (flat === void 0) return "";
|
|
813
|
-
const cacheable = Object.isFrozen(flat);
|
|
814
|
-
let perRegistry = cache.get(registry);
|
|
815
|
-
if (cacheable) {
|
|
816
|
-
const cached = perRegistry?.get(flat);
|
|
817
|
-
if (cached !== void 0) return cached;
|
|
818
|
-
}
|
|
819
|
-
const classes = registry.classesFor(resolveStyle(flat));
|
|
820
|
-
if (cacheable) {
|
|
821
|
-
if (perRegistry === void 0) {
|
|
822
|
-
perRegistry = /* @__PURE__ */ new WeakMap();
|
|
823
|
-
cache.set(registry, perRegistry);
|
|
824
|
-
}
|
|
825
|
-
perRegistry.set(flat, classes);
|
|
886
|
+
function onClick(event) {
|
|
887
|
+
if (event.detail === 0) return;
|
|
888
|
+
end();
|
|
889
|
+
if (event.timeStamp - releasedAt > TAP_CLICK_WINDOW_MS) return;
|
|
890
|
+
if (event.target instanceof Node && element.contains(event.target)) return;
|
|
891
|
+
event.preventDefault();
|
|
892
|
+
event.stopImmediatePropagation();
|
|
826
893
|
}
|
|
827
|
-
|
|
894
|
+
window.addEventListener("click", onClick, true);
|
|
895
|
+
window.addEventListener("pointerdown", end, true);
|
|
828
896
|
};
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
897
|
+
const clear = (timer) => {
|
|
898
|
+
if (timer !== null) clearTimeout(timer);
|
|
899
|
+
return null;
|
|
900
|
+
};
|
|
901
|
+
var Pressability = class {
|
|
902
|
+
constructor(config) {
|
|
903
|
+
this.state = "NOT_RESPONDER";
|
|
904
|
+
this.element = null;
|
|
905
|
+
this.region = null;
|
|
906
|
+
this.pointerId = null;
|
|
907
|
+
this.key = null;
|
|
908
|
+
this.activatePosition = null;
|
|
909
|
+
this.activateTime = null;
|
|
910
|
+
this.hovered = false;
|
|
911
|
+
this.pointerClickPending = false;
|
|
912
|
+
this.cancelClick = false;
|
|
913
|
+
this.hoverInTimer = null;
|
|
914
|
+
this.hoverOutTimer = null;
|
|
915
|
+
this.longPressTimer = null;
|
|
916
|
+
this.pressDelayTimer = null;
|
|
917
|
+
this.pressOutTimer = null;
|
|
918
|
+
this.config = config;
|
|
919
|
+
this.handlers = this.createEventHandlers();
|
|
920
|
+
}
|
|
921
|
+
configure(config) {
|
|
922
|
+
this.config = config;
|
|
923
|
+
}
|
|
924
|
+
reset() {
|
|
925
|
+
this.hoverInTimer = clear(this.hoverInTimer);
|
|
926
|
+
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
927
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
928
|
+
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
929
|
+
this.pressOutTimer = clear(this.pressOutTimer);
|
|
930
|
+
if (this.pointerId !== null) pressing.delete(this.pointerId);
|
|
931
|
+
this.config = Object.freeze({});
|
|
932
|
+
}
|
|
933
|
+
getEventHandlers() {
|
|
934
|
+
return this.handlers;
|
|
935
|
+
}
|
|
936
|
+
terminate(event, clickFollows) {
|
|
937
|
+
const element = this.element;
|
|
938
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
939
|
+
this.pointerId = null;
|
|
940
|
+
pressing.delete(event.pointerId);
|
|
941
|
+
this.pointerClickPending = clickFollows;
|
|
942
|
+
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
943
|
+
}
|
|
944
|
+
static setLongPressDeactivationDistance(distance) {
|
|
945
|
+
longPressDeactivationDistance = distance;
|
|
946
|
+
}
|
|
947
|
+
createEventHandlers() {
|
|
948
|
+
return {
|
|
949
|
+
onPointerDown: (event) => {
|
|
950
|
+
const native = event.nativeEvent;
|
|
951
|
+
if (event.button !== 0 || claimed.has(native) || this.config.disabled === true) return;
|
|
952
|
+
if (startsInNativeControl(event)) return;
|
|
953
|
+
claimed.add(native);
|
|
954
|
+
if (this.pointerId !== null || this.key !== null) return;
|
|
955
|
+
const element = event.currentTarget;
|
|
956
|
+
this.pointerId = event.pointerId;
|
|
957
|
+
pressing.set(event.pointerId, this);
|
|
958
|
+
this.pointerClickPending = true;
|
|
959
|
+
try {
|
|
960
|
+
element.setPointerCapture(event.pointerId);
|
|
961
|
+
} catch {}
|
|
962
|
+
this.grant(element, toGestureResponderEvent(event, element));
|
|
963
|
+
},
|
|
964
|
+
onPointerMove: (event) => {
|
|
965
|
+
const element = this.element;
|
|
966
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
967
|
+
const pressEvent = toGestureResponderEvent(event, element);
|
|
968
|
+
this.config.onPressMove?.(pressEvent);
|
|
969
|
+
const region = this.region;
|
|
970
|
+
if (region === null) return;
|
|
971
|
+
const { pageX, pageY } = pressEvent.nativeEvent;
|
|
972
|
+
const start = this.activatePosition;
|
|
973
|
+
if (start !== null && Math.hypot(start.pageX - pageX, start.pageY - pageY) > longPressDeactivationDistance) this.longPressTimer = clear(this.longPressTimer);
|
|
974
|
+
if (this.isWithinRegion(pageX, pageY, region)) this.receiveSignal("ENTER_PRESS_RECT", pressEvent);
|
|
975
|
+
else {
|
|
976
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
977
|
+
this.receiveSignal("LEAVE_PRESS_RECT", pressEvent);
|
|
978
|
+
}
|
|
979
|
+
},
|
|
980
|
+
onPointerUp: (event) => {
|
|
981
|
+
const element = this.element;
|
|
982
|
+
if (event.pointerId !== this.pointerId || element === null) return;
|
|
983
|
+
this.pointerId = null;
|
|
984
|
+
pressing.delete(event.pointerId);
|
|
985
|
+
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
986
|
+
if (event.pointerType !== "mouse") stopRetargetedClick(element, event.timeStamp);
|
|
987
|
+
},
|
|
988
|
+
onPointerCancel: (event) => {
|
|
989
|
+
this.terminate(event, false);
|
|
990
|
+
},
|
|
991
|
+
onClick: (event) => {
|
|
992
|
+
const native = event.nativeEvent;
|
|
993
|
+
if (claimed.has(native) || startsInNativeControl(event)) return;
|
|
994
|
+
if (this.pointerClickPending && event.detail > 0) {
|
|
995
|
+
this.pointerClickPending = false;
|
|
996
|
+
claimed.add(native);
|
|
997
|
+
if (this.cancelClick) event.preventDefault();
|
|
998
|
+
return;
|
|
999
|
+
}
|
|
1000
|
+
if (this.config.disabled === true) return;
|
|
1001
|
+
claimed.add(native);
|
|
1002
|
+
this.config.onPress?.(toGestureResponderEvent(event, event.currentTarget));
|
|
1003
|
+
},
|
|
1004
|
+
onKeyDown: (event) => {
|
|
1005
|
+
if (!isActivationKey(event.key) || event.repeat || event.nativeEvent.isComposing) return;
|
|
1006
|
+
const element = event.currentTarget;
|
|
1007
|
+
if (event.target !== element || this.config.disabled === true) return;
|
|
1008
|
+
if (hasNativeActivation(element)) return;
|
|
1009
|
+
if (event.key === " ") event.preventDefault();
|
|
1010
|
+
if (this.pointerId !== null || this.key !== null) return;
|
|
1011
|
+
this.key = event.key;
|
|
1012
|
+
this.grant(element, toGestureResponderEvent(event, element));
|
|
1013
|
+
},
|
|
1014
|
+
onKeyUp: (event) => {
|
|
1015
|
+
const element = this.element;
|
|
1016
|
+
if (event.key !== this.key || element === null) return;
|
|
1017
|
+
this.key = null;
|
|
1018
|
+
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
1019
|
+
},
|
|
1020
|
+
onFocus: (event) => {
|
|
1021
|
+
this.config.onFocus?.(event);
|
|
1022
|
+
},
|
|
1023
|
+
onBlur: (event) => {
|
|
1024
|
+
const element = this.element;
|
|
1025
|
+
if (this.key !== null && element !== null && event.target === event.currentTarget) {
|
|
1026
|
+
this.key = null;
|
|
1027
|
+
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
1028
|
+
}
|
|
1029
|
+
this.config.onBlur?.(event);
|
|
1030
|
+
},
|
|
1031
|
+
onPointerEnter: (event) => {
|
|
1032
|
+
if (event.pointerType === "touch") return;
|
|
1033
|
+
this.hovered = true;
|
|
1034
|
+
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
1035
|
+
this.hover(event, this.config.onHoverIn, this.config.delayHoverIn, "in");
|
|
1036
|
+
},
|
|
1037
|
+
onPointerLeave: (event) => {
|
|
1038
|
+
if (!this.hovered) return;
|
|
1039
|
+
this.hovered = false;
|
|
1040
|
+
this.hoverInTimer = clear(this.hoverInTimer);
|
|
1041
|
+
this.hover(event, this.config.onHoverOut, this.config.delayHoverOut, "out");
|
|
1042
|
+
},
|
|
1043
|
+
onContextMenu: (event) => {
|
|
1044
|
+
if (this.pointerId !== null && this.config.onLongPress != null) event.preventDefault();
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
hover(event, callback, delay, direction) {
|
|
1049
|
+
if (callback == null) return;
|
|
1050
|
+
const hoverEvent = toMouseEvent(event);
|
|
1051
|
+
const wait = normalizeDelay(delay);
|
|
1052
|
+
if (wait === 0) {
|
|
1053
|
+
callback(hoverEvent);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
const timer = setTimeout(() => callback(hoverEvent), wait);
|
|
1057
|
+
if (direction === "in") this.hoverInTimer = timer;
|
|
1058
|
+
else this.hoverOutTimer = timer;
|
|
1059
|
+
}
|
|
1060
|
+
grant(element, event) {
|
|
1061
|
+
this.pressOutTimer = clear(this.pressOutTimer);
|
|
1062
|
+
this.element = element;
|
|
1063
|
+
this.cancelClick = false;
|
|
1064
|
+
this.state = "NOT_RESPONDER";
|
|
1065
|
+
this.receiveSignal("RESPONDER_GRANT", event);
|
|
1066
|
+
const delayPressIn = normalizeDelay(this.config.delayPressIn);
|
|
1067
|
+
if (delayPressIn > 0) this.pressDelayTimer = setTimeout(() => this.receiveSignal("DELAY", event), delayPressIn);
|
|
1068
|
+
else this.receiveSignal("DELAY", event);
|
|
1069
|
+
const delayLongPress = normalizeDelay(this.config.delayLongPress, 10, DEFAULT_LONG_PRESS_DELAY_MS - delayPressIn);
|
|
1070
|
+
this.longPressTimer = setTimeout(() => {
|
|
1071
|
+
if (this.state === "RESPONDER_ACTIVE_PRESS_IN" || this.state === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.receiveSignal("LONG_PRESS_DETECTED", event);
|
|
1072
|
+
}, delayLongPress + delayPressIn);
|
|
1073
|
+
}
|
|
1074
|
+
receiveSignal(signal, event) {
|
|
1075
|
+
const prevState = this.state;
|
|
1076
|
+
const nextState = transitions[prevState][signal];
|
|
1077
|
+
if (nextState === void 0 || nextState === prevState) return;
|
|
1078
|
+
this.performTransitionSideEffects(prevState, nextState, signal, event);
|
|
1079
|
+
this.state = nextState;
|
|
1080
|
+
}
|
|
1081
|
+
performTransitionSideEffects(prevState, nextState, signal, event) {
|
|
1082
|
+
if (isTerminal(signal)) {
|
|
1083
|
+
this.activatePosition = null;
|
|
1084
|
+
this.longPressTimer = clear(this.longPressTimer);
|
|
1085
|
+
}
|
|
1086
|
+
const isInitialTransition = prevState === "NOT_RESPONDER" && nextState === "RESPONDER_INACTIVE_PRESS_IN";
|
|
1087
|
+
const isActivationTransition = !isActivation(prevState) && isActivation(nextState);
|
|
1088
|
+
if (isInitialTransition || isActivationTransition) this.measureRegion();
|
|
1089
|
+
if (isPressIn(prevState) && signal === "LONG_PRESS_DETECTED") this.config.onLongPress?.(event);
|
|
1090
|
+
const isPrevActive = isActive(prevState);
|
|
1091
|
+
const isNextActive = isActive(nextState);
|
|
1092
|
+
if (!isPrevActive && isNextActive) this.activate(event);
|
|
1093
|
+
else if (isPrevActive && !isNextActive) this.deactivate(event);
|
|
1094
|
+
if (isPressIn(prevState) && signal === "RESPONDER_RELEASE") {
|
|
1095
|
+
if (!isNextActive && !isPrevActive) {
|
|
1096
|
+
this.activate(event);
|
|
1097
|
+
this.deactivate(event);
|
|
1098
|
+
}
|
|
1099
|
+
const { onLongPress, onPress } = this.config;
|
|
1100
|
+
if (onLongPress != null && prevState === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.cancelClick = true;
|
|
1101
|
+
else if (onPress != null) {
|
|
1102
|
+
onPress(event);
|
|
1103
|
+
if (event.isDefaultPrevented()) this.cancelClick = true;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
1107
|
+
}
|
|
1108
|
+
activate(event) {
|
|
1109
|
+
const { pageX, pageY } = event.nativeEvent;
|
|
1110
|
+
this.activatePosition = {
|
|
1111
|
+
pageX,
|
|
1112
|
+
pageY
|
|
1113
|
+
};
|
|
1114
|
+
this.activateTime = Date.now();
|
|
1115
|
+
this.config.onPressIn?.(event);
|
|
1116
|
+
}
|
|
1117
|
+
deactivate(event) {
|
|
1118
|
+
const { onPressOut } = this.config;
|
|
1119
|
+
if (onPressOut != null) {
|
|
1120
|
+
const minPressDuration = normalizeDelay(this.config.minPressDuration, 0, DEFAULT_MIN_PRESS_DURATION);
|
|
1121
|
+
const pressDuration = Date.now() - (this.activateTime ?? 0);
|
|
1122
|
+
const delayPressOut = Math.max(minPressDuration - pressDuration, normalizeDelay(this.config.delayPressOut));
|
|
1123
|
+
if (delayPressOut > 0) this.pressOutTimer = setTimeout(() => onPressOut(event), delayPressOut);
|
|
1124
|
+
else onPressOut(event);
|
|
1125
|
+
}
|
|
1126
|
+
this.activateTime = null;
|
|
1127
|
+
}
|
|
1128
|
+
measureRegion() {
|
|
1129
|
+
if (this.element === null) return;
|
|
1130
|
+
const rect = this.element.getBoundingClientRect();
|
|
1131
|
+
if (rect.width === 0 && rect.height === 0 && rect.top === 0 && rect.left === 0) return;
|
|
1132
|
+
this.region = {
|
|
1133
|
+
bottom: rect.bottom + window.scrollY,
|
|
1134
|
+
left: rect.left + window.scrollX,
|
|
1135
|
+
right: rect.right + window.scrollX,
|
|
1136
|
+
top: rect.top + window.scrollY
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
isWithinRegion(pageX, pageY, region) {
|
|
1140
|
+
const hitSlop = normalizeRect(this.config.hitSlop);
|
|
1141
|
+
const offset = normalizeRect(this.config.pressRectOffset);
|
|
1142
|
+
const bottom = region.bottom + (hitSlop?.bottom ?? 0) + (offset?.bottom ?? DEFAULT_PRESS_RECT_OFFSETS.bottom);
|
|
1143
|
+
const left = region.left - (hitSlop?.left ?? 0) - (offset?.left ?? DEFAULT_PRESS_RECT_OFFSETS.left);
|
|
1144
|
+
const right = region.right + (hitSlop?.right ?? 0) + (offset?.right ?? DEFAULT_PRESS_RECT_OFFSETS.right);
|
|
1145
|
+
const top = region.top - (hitSlop?.top ?? 0) - (offset?.top ?? DEFAULT_PRESS_RECT_OFFSETS.top);
|
|
1146
|
+
return pageX > left && pageX < right && pageY > top && pageY < bottom;
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1149
|
+
// src/apis/PanResponder/index.ts
|
|
1150
|
+
let current = null;
|
|
1151
|
+
let grantEvent = null;
|
|
1152
|
+
let nextStateID = 1;
|
|
1153
|
+
let listening = false;
|
|
1154
|
+
const blockNativeScroll = (event) => {
|
|
1155
|
+
if (current !== null && current.blocksNative && event.cancelable) event.preventDefault();
|
|
1156
|
+
};
|
|
1157
|
+
const listenForTouchMove = () => {
|
|
1158
|
+
if (listening || typeof document === "undefined") return;
|
|
1159
|
+
listening = true;
|
|
1160
|
+
document.addEventListener("touchmove", blockNativeScroll, { passive: false });
|
|
1161
|
+
};
|
|
1162
|
+
const newGestureState = () => ({
|
|
1163
|
+
stateID: nextStateID++,
|
|
1164
|
+
moveX: 0,
|
|
1165
|
+
moveY: 0,
|
|
1166
|
+
x0: 0,
|
|
1167
|
+
y0: 0,
|
|
1168
|
+
dx: 0,
|
|
1169
|
+
dy: 0,
|
|
1170
|
+
vx: 0,
|
|
1171
|
+
vy: 0,
|
|
1172
|
+
numberActiveTouches: 0,
|
|
1173
|
+
_accountsForMovesUpTo: 0
|
|
1174
|
+
});
|
|
1175
|
+
const centroid = (pointers) => {
|
|
1176
|
+
let x = 0;
|
|
1177
|
+
let y = 0;
|
|
1178
|
+
for (const pointer of pointers.values()) {
|
|
1179
|
+
x += pointer.clientX + window.scrollX;
|
|
1180
|
+
y += pointer.clientY + window.scrollY;
|
|
1181
|
+
}
|
|
1182
|
+
const count = pointers.size || 1;
|
|
1183
|
+
return {
|
|
1184
|
+
x: x / count,
|
|
1185
|
+
y: y / count
|
|
1186
|
+
};
|
|
1187
|
+
};
|
|
1188
|
+
const define = (target, fields) => {
|
|
1189
|
+
for (const key in fields) Object.defineProperty(target, key, {
|
|
1190
|
+
value: fields[key],
|
|
1191
|
+
configurable: true,
|
|
1192
|
+
writable: true
|
|
1193
|
+
});
|
|
1194
|
+
};
|
|
1195
|
+
const touchOf = (pointer, rect, timestamp) => ({
|
|
1196
|
+
changedTouches: [],
|
|
1197
|
+
identifier: pointer.id,
|
|
1198
|
+
locationX: pointer.clientX - rect.left,
|
|
1199
|
+
locationY: pointer.clientY - rect.top,
|
|
1200
|
+
pageX: pointer.clientX + window.scrollX,
|
|
1201
|
+
pageY: pointer.clientY + window.scrollY,
|
|
1202
|
+
target: pointer.target,
|
|
1203
|
+
timestamp,
|
|
1204
|
+
touches: []
|
|
1205
|
+
});
|
|
1206
|
+
const toResponderEvent = (event, responder, changed) => {
|
|
1207
|
+
const rect = (responder.element ?? event.currentTarget).getBoundingClientRect();
|
|
1208
|
+
const touches = [...responder.pointers.values()].map((p) => touchOf(p, rect, event.timeStamp));
|
|
1209
|
+
const touch = touchOf(changed, rect, event.timeStamp);
|
|
1210
|
+
define(event.nativeEvent, {
|
|
1211
|
+
...touch,
|
|
1212
|
+
force: event.pressure,
|
|
1213
|
+
touches,
|
|
1214
|
+
changedTouches: [touch]
|
|
1215
|
+
});
|
|
1216
|
+
return event;
|
|
1217
|
+
};
|
|
1218
|
+
const pointerOf = (event) => ({
|
|
1219
|
+
id: event.pointerId,
|
|
1220
|
+
clientX: event.clientX,
|
|
1221
|
+
clientY: event.clientY,
|
|
1222
|
+
target: event.target
|
|
1223
|
+
});
|
|
1224
|
+
const updateMove = (responder, time) => {
|
|
1225
|
+
const state = responder.gestureState;
|
|
1226
|
+
const next = centroid(responder.pointers);
|
|
1227
|
+
const last = responder.last;
|
|
1228
|
+
if (last !== null) {
|
|
1229
|
+
const dt = time - last.time;
|
|
1230
|
+
state.dx += next.x - last.x;
|
|
1231
|
+
state.dy += next.y - last.y;
|
|
1232
|
+
state.vx = dt > 0 ? (next.x - last.x) / dt : 0;
|
|
1233
|
+
state.vy = dt > 0 ? (next.y - last.y) / dt : 0;
|
|
1234
|
+
}
|
|
1235
|
+
state.moveX = next.x;
|
|
1236
|
+
state.moveY = next.y;
|
|
1237
|
+
state._accountsForMovesUpTo = time;
|
|
1238
|
+
responder.last = {
|
|
1239
|
+
x: next.x,
|
|
1240
|
+
y: next.y,
|
|
1241
|
+
time
|
|
1242
|
+
};
|
|
1243
|
+
};
|
|
1244
|
+
const rebase = (responder, time) => {
|
|
1245
|
+
const next = centroid(responder.pointers);
|
|
1246
|
+
responder.last = {
|
|
1247
|
+
x: next.x,
|
|
1248
|
+
y: next.y,
|
|
1249
|
+
time
|
|
1250
|
+
};
|
|
1251
|
+
responder.gestureState.numberActiveTouches = responder.pointers.size;
|
|
1252
|
+
};
|
|
1253
|
+
const grant = (responder, event, responderEvent) => {
|
|
1254
|
+
const state = responder.gestureState;
|
|
1255
|
+
const point = centroid(responder.pointers);
|
|
1256
|
+
state.x0 = point.x;
|
|
1257
|
+
state.y0 = point.y;
|
|
1258
|
+
state.dx = 0;
|
|
1259
|
+
state.dy = 0;
|
|
1260
|
+
state.vx = 0;
|
|
1261
|
+
state.vy = 0;
|
|
1262
|
+
responder.last = {
|
|
1263
|
+
x: point.x,
|
|
1264
|
+
y: point.y,
|
|
1265
|
+
time: event.timeStamp
|
|
1266
|
+
};
|
|
1267
|
+
responder.element = event.currentTarget;
|
|
1268
|
+
current = responder;
|
|
1269
|
+
grantEvent = event.nativeEvent;
|
|
1270
|
+
claimPress(event.nativeEvent);
|
|
1271
|
+
terminatePress(event);
|
|
1272
|
+
for (const pointer of responder.pointers.values()) try {
|
|
1273
|
+
responder.element.setPointerCapture(pointer.id);
|
|
1274
|
+
} catch {}
|
|
1275
|
+
responder.config.onPanResponderGrant?.(responderEvent, state);
|
|
1276
|
+
responder.blocksNative = responder.config.onShouldBlockNativeResponder?.(responderEvent, state) !== false;
|
|
1277
|
+
responder.config.onPanResponderStart?.(responderEvent, state);
|
|
1278
|
+
};
|
|
1279
|
+
const releaseCapture = (responder) => {
|
|
1280
|
+
const element = responder.element;
|
|
1281
|
+
if (element === null) return;
|
|
1282
|
+
for (const pointer of responder.pointers.values()) try {
|
|
1283
|
+
if (element.hasPointerCapture(pointer.id)) element.releasePointerCapture(pointer.id);
|
|
1284
|
+
} catch {}
|
|
1285
|
+
};
|
|
1286
|
+
const finish = (responder) => {
|
|
1287
|
+
releaseCapture(responder);
|
|
1288
|
+
if (current === responder) current = null;
|
|
1289
|
+
responder.element = null;
|
|
1290
|
+
responder.last = null;
|
|
1291
|
+
};
|
|
1292
|
+
const negotiate = (responder, event, responderEvent, predicate) => {
|
|
1293
|
+
if (current === responder) return;
|
|
1294
|
+
if (current !== null && grantEvent === event.nativeEvent) return;
|
|
1295
|
+
if (predicate === void 0 || !predicate(responderEvent, responder.gestureState)) return;
|
|
1296
|
+
if (current !== null) {
|
|
1297
|
+
const holder = current;
|
|
1298
|
+
if (holder.config.onPanResponderTerminationRequest?.(responderEvent, holder.gestureState) === false) {
|
|
1299
|
+
responder.config.onPanResponderReject?.(responderEvent, responder.gestureState);
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
holder.config.onPanResponderTerminate?.(responderEvent, holder.gestureState);
|
|
1303
|
+
finish(holder);
|
|
1304
|
+
}
|
|
1305
|
+
grant(responder, event, responderEvent);
|
|
1306
|
+
};
|
|
1307
|
+
const createHandlers = (responder) => {
|
|
1308
|
+
const down = (event, capture) => {
|
|
1309
|
+
const pointer = pointerOf(event);
|
|
1310
|
+
const first = responder.pointers.size === 0;
|
|
1311
|
+
if (capture) {
|
|
1312
|
+
if (first) responder.gestureState = newGestureState();
|
|
1313
|
+
responder.pointers.set(pointer.id, pointer);
|
|
1314
|
+
rebase(responder, event.timeStamp);
|
|
1315
|
+
}
|
|
1316
|
+
const responderEvent = toResponderEvent(event, responder, pointer);
|
|
1317
|
+
const { config } = responder;
|
|
1318
|
+
if (current === responder) {
|
|
1319
|
+
if (capture) config.onPanResponderStart?.(responderEvent, responder.gestureState);
|
|
1320
|
+
return;
|
|
1321
|
+
}
|
|
1322
|
+
if (!capture && isPressClaimed(event.nativeEvent)) return;
|
|
1323
|
+
negotiate(responder, event, responderEvent, capture ? config.onStartShouldSetPanResponderCapture : config.onStartShouldSetPanResponder);
|
|
1324
|
+
};
|
|
1325
|
+
const move = (event, capture) => {
|
|
1326
|
+
const pointer = responder.pointers.get(event.pointerId);
|
|
1327
|
+
if (pointer === void 0) return;
|
|
1328
|
+
if (capture) {
|
|
1329
|
+
pointer.clientX = event.clientX;
|
|
1330
|
+
pointer.clientY = event.clientY;
|
|
1331
|
+
updateMove(responder, event.timeStamp);
|
|
1332
|
+
}
|
|
1333
|
+
const responderEvent = toResponderEvent(event, responder, pointer);
|
|
1334
|
+
const { config } = responder;
|
|
1335
|
+
if (current === responder) {
|
|
1336
|
+
if (capture) config.onPanResponderMove?.(responderEvent, responder.gestureState);
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
negotiate(responder, event, responderEvent, capture ? config.onMoveShouldSetPanResponderCapture : config.onMoveShouldSetPanResponder);
|
|
1340
|
+
};
|
|
1341
|
+
const end = (event, cancel) => {
|
|
1342
|
+
const pointer = responder.pointers.get(event.pointerId);
|
|
1343
|
+
if (pointer === void 0) return;
|
|
1344
|
+
const responderEvent = toResponderEvent(event, responder, pointer);
|
|
1345
|
+
responder.pointers.delete(event.pointerId);
|
|
1346
|
+
const { config, gestureState } = responder;
|
|
1347
|
+
const responding = current === responder;
|
|
1348
|
+
if (responding && cancel) {
|
|
1349
|
+
config.onPanResponderTerminate?.(responderEvent, gestureState);
|
|
1350
|
+
responder.pointers.clear();
|
|
1351
|
+
finish(responder);
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
if (responding) config.onPanResponderEnd?.(responderEvent, gestureState);
|
|
1355
|
+
if (responder.pointers.size === 0) {
|
|
1356
|
+
if (responding) config.onPanResponderRelease?.(responderEvent, gestureState);
|
|
1357
|
+
finish(responder);
|
|
1358
|
+
} else rebase(responder, event.timeStamp);
|
|
1359
|
+
};
|
|
1360
|
+
return {
|
|
1361
|
+
onPointerDownCapture: (event) => down(event, true),
|
|
1362
|
+
onPointerDown: (event) => down(event, false),
|
|
1363
|
+
onPointerMoveCapture: (event) => move(event, true),
|
|
1364
|
+
onPointerMove: (event) => move(event, false),
|
|
1365
|
+
onPointerUp: (event) => end(event, false),
|
|
1366
|
+
onPointerCancel: (event) => end(event, true)
|
|
1367
|
+
};
|
|
1368
|
+
};
|
|
1369
|
+
const PanResponder = { create(config) {
|
|
1370
|
+
const responder = {
|
|
1371
|
+
config,
|
|
1372
|
+
gestureState: newGestureState(),
|
|
1373
|
+
pointers: /* @__PURE__ */ new Map(),
|
|
1374
|
+
element: null,
|
|
1375
|
+
last: null,
|
|
1376
|
+
blocksNative: true
|
|
1377
|
+
};
|
|
1378
|
+
listenForTouchMove();
|
|
1379
|
+
return {
|
|
1380
|
+
panHandlers: createHandlers(responder),
|
|
1381
|
+
getInteractionHandle: () => null
|
|
1382
|
+
};
|
|
1383
|
+
} };
|
|
1384
|
+
// src/apis/PixelRatio/index.ts
|
|
1385
|
+
const PixelRatio = {
|
|
1386
|
+
get: () => Dimensions.get("window").scale,
|
|
1387
|
+
getFontScale: () => Dimensions.get("window").fontScale,
|
|
1388
|
+
getPixelSizeForLayoutSize: (layoutSize) => Math.round(layoutSize * PixelRatio.get()),
|
|
1389
|
+
roundToNearestPixel: (layoutSize) => {
|
|
1390
|
+
const ratio = PixelRatio.get();
|
|
1391
|
+
return Math.round(layoutSize * ratio) / ratio;
|
|
1392
|
+
},
|
|
1393
|
+
startDetecting: () => {}
|
|
1394
|
+
};
|
|
1395
|
+
// src/reactNativeVersion.ts
|
|
1396
|
+
const reactNativeVersion = {
|
|
1397
|
+
major: 0,
|
|
1398
|
+
minor: 88,
|
|
1399
|
+
patch: 1,
|
|
1400
|
+
prerelease: void 0
|
|
1401
|
+
};
|
|
1402
|
+
// src/apis/Platform/index.ts
|
|
1403
|
+
const Platform = {
|
|
1404
|
+
OS: "web",
|
|
1405
|
+
get Version() {
|
|
1406
|
+
return hasDOM() ? navigator.userAgent : "";
|
|
1407
|
+
},
|
|
1408
|
+
get constants() {
|
|
1409
|
+
return { reactNativeVersion };
|
|
1410
|
+
},
|
|
1411
|
+
get isTV() {
|
|
1412
|
+
return false;
|
|
1413
|
+
},
|
|
1414
|
+
get isTesting() {
|
|
1415
|
+
return isTestEnv();
|
|
1416
|
+
},
|
|
1417
|
+
get isDisableAnimations() {
|
|
1418
|
+
return matchesMedia("(prefers-reduced-motion: reduce)");
|
|
1419
|
+
},
|
|
1420
|
+
select(spec) {
|
|
1421
|
+
if ("web" in spec) return spec.web;
|
|
1422
|
+
if ("default" in spec) return spec.default;
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
// src/apis/processColor/index.ts
|
|
1426
|
+
const processColor = (color) => {
|
|
1427
|
+
if (color === void 0 || color === null) return color;
|
|
1428
|
+
if (typeof color !== "string" && typeof color !== "number") return null;
|
|
1429
|
+
const rgba = normalizeColor(color);
|
|
1430
|
+
if (rgba === null || rgba === void 0) return null;
|
|
1431
|
+
return (rgba << 24 | rgba >>> 8) >>> 0;
|
|
1432
|
+
};
|
|
1433
|
+
// src/apis/Share/index.ts
|
|
1434
|
+
const isAbort = (error) => error instanceof DOMException && error.name === "AbortError";
|
|
1435
|
+
/**
|
|
1436
|
+
* Opens the browser's share sheet with `navigator.share`. It shares the title, the message,
|
|
1437
|
+
* and the URL. A closed sheet resolves `dismissedAction`, as on iOS.
|
|
1438
|
+
*/
|
|
1439
|
+
const Share = {
|
|
1440
|
+
share(content, options = {}) {
|
|
1441
|
+
if (typeof content !== "object" || content === null) throw new Error("Content to share must be a valid object");
|
|
1442
|
+
if (typeof content.url !== "string" && typeof content.message !== "string") throw new Error("At least one of URL or message is required");
|
|
1443
|
+
if (typeof options !== "object" || options === null) throw new Error("Options must be a valid object");
|
|
1444
|
+
if (!hasDOM() || typeof navigator.share !== "function") return Promise.reject(/* @__PURE__ */ new Error("Unsupported platform"));
|
|
1445
|
+
const data = {};
|
|
1446
|
+
if (typeof content.title === "string") data.title = content.title;
|
|
1447
|
+
if (typeof content.message === "string") data.text = content.message;
|
|
1448
|
+
if (typeof content.url === "string") data.url = content.url;
|
|
1449
|
+
return navigator.share(data).then(() => ({
|
|
1450
|
+
action: "sharedAction",
|
|
1451
|
+
activityType: null
|
|
1452
|
+
}), (error) => {
|
|
1453
|
+
if (isAbort(error)) return {
|
|
1454
|
+
action: "dismissedAction",
|
|
1455
|
+
activityType: null
|
|
1456
|
+
};
|
|
1457
|
+
throw error;
|
|
1458
|
+
});
|
|
1459
|
+
},
|
|
1460
|
+
sharedAction: "sharedAction",
|
|
1461
|
+
dismissedAction: "dismissedAction"
|
|
1462
|
+
};
|
|
1463
|
+
// src/apis/StyleSheet/index.ts
|
|
1464
|
+
const absoluteFillObject = {
|
|
1465
|
+
position: "absolute",
|
|
1466
|
+
left: 0,
|
|
1467
|
+
right: 0,
|
|
1468
|
+
top: 0,
|
|
1469
|
+
bottom: 0
|
|
836
1470
|
};
|
|
837
1471
|
const create = (styles) => {
|
|
838
1472
|
for (const key in styles) Object.freeze(styles[key]);
|
|
@@ -873,13 +1507,56 @@ const subscribe = (onChange) => {
|
|
|
873
1507
|
const getSnapshot = () => Dimensions.get("window");
|
|
874
1508
|
const getServerSnapshot = () => serverSnapshot;
|
|
875
1509
|
const useWindowDimensions = () => useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
1510
|
+
// src/apis/Vibration/index.ts
|
|
1511
|
+
const DEFAULT_LENGTH = 400;
|
|
1512
|
+
let repeatTimer;
|
|
1513
|
+
const canVibrate = () => hasDOM() && typeof navigator.vibrate === "function";
|
|
1514
|
+
const stopRepeat = () => {
|
|
1515
|
+
if (repeatTimer === void 0) return;
|
|
1516
|
+
clearTimeout(repeatTimer);
|
|
1517
|
+
repeatTimer = void 0;
|
|
1518
|
+
};
|
|
1519
|
+
/**
|
|
1520
|
+
* Vibrates the device with `navigator.vibrate`, with Android's rules: the durations apply, and
|
|
1521
|
+
* an array starts with a wait.
|
|
1522
|
+
*/
|
|
1523
|
+
const Vibration = {
|
|
1524
|
+
vibrate(pattern = DEFAULT_LENGTH, repeat = false) {
|
|
1525
|
+
let steps;
|
|
1526
|
+
if (typeof pattern === "number") steps = [pattern];
|
|
1527
|
+
else if (Array.isArray(pattern)) steps = [0, ...pattern];
|
|
1528
|
+
else throw new Error("Vibration pattern should be a number or array");
|
|
1529
|
+
stopRepeat();
|
|
1530
|
+
if (!canVibrate()) return;
|
|
1531
|
+
navigator.vibrate(steps);
|
|
1532
|
+
if (!repeat || typeof pattern === "number") return;
|
|
1533
|
+
const total = steps.reduce((sum, step) => sum + step, 0);
|
|
1534
|
+
if (total <= 0) return;
|
|
1535
|
+
const again = () => {
|
|
1536
|
+
navigator.vibrate(steps);
|
|
1537
|
+
repeatTimer = setTimeout(again, total);
|
|
1538
|
+
};
|
|
1539
|
+
repeatTimer = setTimeout(again, total);
|
|
1540
|
+
},
|
|
1541
|
+
cancel() {
|
|
1542
|
+
stopRepeat();
|
|
1543
|
+
if (canVibrate()) navigator.vibrate(0);
|
|
1544
|
+
}
|
|
1545
|
+
};
|
|
1546
|
+
// src/style/webStyle.ts
|
|
1547
|
+
/**
|
|
1548
|
+
* A frozen style for the internals of a component that uses CSS React Native doesn't have, such
|
|
1549
|
+
* as `overflowX` or `position: 'sticky'`. The compiler passes unknown names through to CSS.
|
|
1550
|
+
*/
|
|
1551
|
+
const webStyle = (style) => Object.freeze(style);
|
|
876
1552
|
// src/render/domProps.ts
|
|
877
1553
|
const liveRegionToAriaLive = {
|
|
878
1554
|
none: "off",
|
|
879
1555
|
polite: "polite",
|
|
880
1556
|
assertive: "assertive"
|
|
881
1557
|
};
|
|
882
|
-
const nativeHandler = /^on(Press|Layout|TextLayout|Accessibility|Magic|Responder|.*ShouldSet)/;
|
|
1558
|
+
const nativeHandler = /^on(Press|Layout|TextLayout|Accessibility|Magic|Responder|Refresh|.*ShouldSet)/;
|
|
1559
|
+
const isNativeHandler = (name) => nativeHandler.test(name);
|
|
883
1560
|
const passThrough = /* @__PURE__ */ new Set([
|
|
884
1561
|
"lang",
|
|
885
1562
|
"dir",
|
|
@@ -926,6 +1603,44 @@ const toDOMProps = (props) => {
|
|
|
926
1603
|
else if (focusable === false) out["tabIndex"] = -1;
|
|
927
1604
|
return out;
|
|
928
1605
|
};
|
|
1606
|
+
// src/render/hostMethods.ts
|
|
1607
|
+
const applyNativeProps = (element, nativeProps) => {
|
|
1608
|
+
const inline = element.style;
|
|
1609
|
+
for (const [name, value] of Object.entries(nativeProps)) {
|
|
1610
|
+
if (name !== "style") {
|
|
1611
|
+
warnOnce(`set-native-props-${name}`, `setNativeProps: only \`style\` works on the web. \`${name}\` has no effect.`);
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
const flat = flattenStyle(value);
|
|
1615
|
+
if (flat !== void 0) Object.assign(inline, resolveStyle(flat));
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
const hostMethods = (element) => ({
|
|
1619
|
+
measure: (callback) => {
|
|
1620
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
1621
|
+
const parent = element.parentElement?.getBoundingClientRect();
|
|
1622
|
+
callback(left - (parent?.left ?? 0), top - (parent?.top ?? 0), width, height, left, top);
|
|
1623
|
+
},
|
|
1624
|
+
measureInWindow: (callback) => {
|
|
1625
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
1626
|
+
callback(left, top, width, height);
|
|
1627
|
+
},
|
|
1628
|
+
measureLayout: (relativeToNativeNode, onSuccess, onFail) => {
|
|
1629
|
+
if (!(relativeToNativeNode instanceof Element) || !element.isConnected || !relativeToNativeNode.contains(element)) {
|
|
1630
|
+
onFail?.();
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const { left, top, width, height } = element.getBoundingClientRect();
|
|
1634
|
+
const ancestor = relativeToNativeNode.getBoundingClientRect();
|
|
1635
|
+
onSuccess(left - ancestor.left, top - ancestor.top, width, height);
|
|
1636
|
+
},
|
|
1637
|
+
setNativeProps: (nativeProps) => applyNativeProps(element, nativeProps)
|
|
1638
|
+
});
|
|
1639
|
+
const withHostMethods = (element) => {
|
|
1640
|
+
const instance = element;
|
|
1641
|
+
if (instance.measureInWindow === void 0) Object.assign(instance, hostMethods(element));
|
|
1642
|
+
return instance;
|
|
1643
|
+
};
|
|
929
1644
|
// src/render/resolveTag.ts
|
|
930
1645
|
const legacyRoleToRole = {
|
|
931
1646
|
header: "heading",
|
|
@@ -1027,23 +1742,17 @@ const resetStyle$2 = Object.freeze({
|
|
|
1027
1742
|
textDecoration: "none",
|
|
1028
1743
|
zIndex: 0
|
|
1029
1744
|
});
|
|
1030
|
-
const pointerEventsClass = (registry, value) => registry.staticClass(`rn-pe-${value}`, value === "box-none" ? [".rn-pe-box-none{pointer-events:none}", ".rn-pe-box-none>*{pointer-events:auto}"] : [".rn-pe-box-only{pointer-events:auto}", ".rn-pe-box-only>*{pointer-events:none}"]);
|
|
1031
1745
|
function View(props) {
|
|
1032
1746
|
return useViewElement(props);
|
|
1033
1747
|
}
|
|
1034
1748
|
function useViewElement(props, extraClassName) {
|
|
1035
1749
|
const { children, onLayout, pointerEvents, ref, style, ...rest } = props;
|
|
1036
1750
|
const element = useRef(null);
|
|
1037
|
-
useImperativeHandle(ref, () => element.current, []);
|
|
1751
|
+
useImperativeHandle(ref, () => withHostMethods(element.current), []);
|
|
1038
1752
|
useElementLayout(element, onLayout);
|
|
1039
1753
|
const registry = useStyleRegistry();
|
|
1040
1754
|
const { tag, role } = resolveTag(rest, "div", children != null);
|
|
1041
|
-
let className = compileStyle([
|
|
1042
|
-
resetStyle$2,
|
|
1043
|
-
style,
|
|
1044
|
-
pointerEvents === "none" || pointerEvents === "auto" ? { pointerEvents } : void 0
|
|
1045
|
-
], registry);
|
|
1046
|
-
if (pointerEvents === "box-none" || pointerEvents === "box-only") className = `${className} ${pointerEventsClass(registry, pointerEvents)}`;
|
|
1755
|
+
let className = joinClassNames(compileReset("rn-view", resetStyle$2, registry), compileStyle(pointerEvents === void 0 ? style : [style, pointerEventsStyle[pointerEvents]], registry));
|
|
1047
1756
|
if (extraClassName !== void 0) className = `${className} ${extraClassName}`;
|
|
1048
1757
|
const domProps = toDOMProps(rest);
|
|
1049
1758
|
if (role !== void 0) domProps["role"] = role;
|
|
@@ -1051,8 +1760,613 @@ function useViewElement(props, extraClassName) {
|
|
|
1051
1760
|
if (tag === "button") domProps["type"] = "button";
|
|
1052
1761
|
domProps["className"] = className;
|
|
1053
1762
|
domProps["ref"] = element;
|
|
1054
|
-
return createElement(tag, domProps, children);
|
|
1763
|
+
return createElement(tag, domProps, children);
|
|
1764
|
+
}
|
|
1765
|
+
// src/components/ActivityIndicator/index.tsx
|
|
1766
|
+
const GRAY = "#999999";
|
|
1767
|
+
const SPIN_CLASS = "rn-activity-indicator";
|
|
1768
|
+
const SPIN_RULES = ["@keyframes rn-activity-indicator-spin{to{transform:rotate(360deg)}}", `.${SPIN_CLASS}{animation:rn-activity-indicator-spin .75s linear infinite}`];
|
|
1769
|
+
const hiddenStyle$1 = webStyle({ visibility: "hidden" });
|
|
1770
|
+
const pausedStyle = { animationPlayState: "paused" };
|
|
1771
|
+
function ActivityIndicator(props) {
|
|
1772
|
+
const { animating = true, color = GRAY, hidesWhenStopped = true, onLayout, ref, size = "small", style, ...rest } = props;
|
|
1773
|
+
const spinClass = useStyleRegistry().staticClass(SPIN_CLASS, SPIN_RULES);
|
|
1774
|
+
const stroke = toCSSColor(color) ?? GRAY;
|
|
1775
|
+
const sizeStyle = size === "small" ? styles$4.sizeSmall : size === "large" ? styles$4.sizeLarge : {
|
|
1776
|
+
width: size,
|
|
1777
|
+
height: size
|
|
1778
|
+
};
|
|
1779
|
+
return /* @__PURE__ */ jsx(View, {
|
|
1780
|
+
onLayout,
|
|
1781
|
+
style: [styles$4.container, style],
|
|
1782
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
1783
|
+
role: "progressbar",
|
|
1784
|
+
...rest,
|
|
1785
|
+
ref,
|
|
1786
|
+
style: [sizeStyle, !animating && hidesWhenStopped && hiddenStyle$1],
|
|
1787
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
1788
|
+
"aria-hidden": true,
|
|
1789
|
+
className: spinClass,
|
|
1790
|
+
height: "100%",
|
|
1791
|
+
style: animating ? void 0 : pausedStyle,
|
|
1792
|
+
viewBox: "0 0 32 32",
|
|
1793
|
+
width: "100%",
|
|
1794
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
1795
|
+
cx: "16",
|
|
1796
|
+
cy: "16",
|
|
1797
|
+
fill: "none",
|
|
1798
|
+
opacity: "0.2",
|
|
1799
|
+
r: "14",
|
|
1800
|
+
stroke,
|
|
1801
|
+
strokeWidth: "4"
|
|
1802
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
1803
|
+
cx: "16",
|
|
1804
|
+
cy: "16",
|
|
1805
|
+
fill: "none",
|
|
1806
|
+
r: "14",
|
|
1807
|
+
stroke,
|
|
1808
|
+
strokeDasharray: "80",
|
|
1809
|
+
strokeDashoffset: "60",
|
|
1810
|
+
strokeWidth: "4"
|
|
1811
|
+
})]
|
|
1812
|
+
})
|
|
1813
|
+
})
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
const styles$4 = StyleSheet.create({
|
|
1817
|
+
container: {
|
|
1818
|
+
alignItems: "center",
|
|
1819
|
+
justifyContent: "center"
|
|
1820
|
+
},
|
|
1821
|
+
sizeSmall: {
|
|
1822
|
+
width: 20,
|
|
1823
|
+
height: 20
|
|
1824
|
+
},
|
|
1825
|
+
sizeLarge: {
|
|
1826
|
+
width: 36,
|
|
1827
|
+
height: 36
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
// src/events/press/usePressability.ts
|
|
1831
|
+
function usePressability(config) {
|
|
1832
|
+
const [pressability, setPressability] = useState(() => config == null ? null : new Pressability(config));
|
|
1833
|
+
if (pressability === null && config != null) setPressability(new Pressability(config));
|
|
1834
|
+
useInsertionEffect(() => {
|
|
1835
|
+
if (config != null && pressability !== null) pressability.configure(config);
|
|
1836
|
+
}, [config, pressability]);
|
|
1837
|
+
useInsertionEffect(() => {
|
|
1838
|
+
if (pressability === null) return void 0;
|
|
1839
|
+
return () => pressability.reset();
|
|
1840
|
+
}, [pressability]);
|
|
1841
|
+
return pressability === null ? null : pressability.getEventHandlers();
|
|
1842
|
+
}
|
|
1843
|
+
// src/events/press/mergeHandlers.ts
|
|
1844
|
+
const sharedHandlers = [
|
|
1845
|
+
"onClick",
|
|
1846
|
+
"onContextMenu",
|
|
1847
|
+
"onKeyDown",
|
|
1848
|
+
"onKeyUp",
|
|
1849
|
+
"onPointerCancel",
|
|
1850
|
+
"onPointerDown",
|
|
1851
|
+
"onPointerEnter",
|
|
1852
|
+
"onPointerLeave",
|
|
1853
|
+
"onPointerMove",
|
|
1854
|
+
"onPointerUp"
|
|
1855
|
+
];
|
|
1856
|
+
const mergeHandlers = (app, own) => {
|
|
1857
|
+
const merged = { ...own };
|
|
1858
|
+
for (const key of sharedHandlers) {
|
|
1859
|
+
const value = app[key];
|
|
1860
|
+
if (typeof value !== "function") continue;
|
|
1861
|
+
const appHandler = value;
|
|
1862
|
+
const ownHandler = own[key];
|
|
1863
|
+
merged[key] = (event) => {
|
|
1864
|
+
appHandler(event);
|
|
1865
|
+
ownHandler(event);
|
|
1866
|
+
};
|
|
1867
|
+
}
|
|
1868
|
+
return merged;
|
|
1869
|
+
};
|
|
1870
|
+
// src/components/Text/TextAncestorContext.ts
|
|
1871
|
+
const TextAncestorContext = createContext(false);
|
|
1872
|
+
// src/components/Text/index.tsx
|
|
1873
|
+
const resetStyle$1 = Object.freeze({
|
|
1874
|
+
backgroundColor: "transparent",
|
|
1875
|
+
border: "0 solid black",
|
|
1876
|
+
boxSizing: "border-box",
|
|
1877
|
+
color: "black",
|
|
1878
|
+
display: "inline",
|
|
1879
|
+
fontFamily: "System",
|
|
1880
|
+
fontSize: 14,
|
|
1881
|
+
listStyle: "none",
|
|
1882
|
+
margin: 0,
|
|
1883
|
+
padding: 0,
|
|
1884
|
+
position: "relative",
|
|
1885
|
+
textAlign: "start",
|
|
1886
|
+
textDecoration: "none",
|
|
1887
|
+
whiteSpace: "pre-wrap",
|
|
1888
|
+
wordWrap: "break-word"
|
|
1889
|
+
});
|
|
1890
|
+
const nestedResetStyle = Object.freeze({
|
|
1891
|
+
color: "inherit",
|
|
1892
|
+
font: "inherit",
|
|
1893
|
+
textAlign: "inherit",
|
|
1894
|
+
textDecoration: "inherit",
|
|
1895
|
+
whiteSpace: "inherit"
|
|
1896
|
+
});
|
|
1897
|
+
const singleLineStyle = Object.freeze({
|
|
1898
|
+
overflow: "hidden",
|
|
1899
|
+
textOverflow: "ellipsis",
|
|
1900
|
+
whiteSpace: "nowrap"
|
|
1901
|
+
});
|
|
1902
|
+
const multiLineStyle = (lines) => ({
|
|
1903
|
+
display: "-webkit-box",
|
|
1904
|
+
WebkitBoxOrient: "vertical",
|
|
1905
|
+
WebkitLineClamp: lines,
|
|
1906
|
+
overflow: "hidden"
|
|
1907
|
+
});
|
|
1908
|
+
const selectionClass$1 = (registry, color) => {
|
|
1909
|
+
const css = toCSSColor(color);
|
|
1910
|
+
if (css === void 0) return void 0;
|
|
1911
|
+
const name = `rn-sel-${css.replace(/[^a-z0-9]/g, "")}`;
|
|
1912
|
+
return registry.staticClass(name, [`.${name}::selection{background-color:${css}}`]);
|
|
1913
|
+
};
|
|
1914
|
+
function Text(props) {
|
|
1915
|
+
const { children, disabled, ellipsizeMode, numberOfLines, onBlur, onFocus, onLayout, onLongPress, onPress, onPressIn, onPressOut, pointerEvents, pressRetentionOffset, ref, selectable, selectionColor, style, suppressHighlighting: _suppressHighlighting, ...rest } = props;
|
|
1916
|
+
const nested = useContext(TextAncestorContext);
|
|
1917
|
+
const element = useRef(null);
|
|
1918
|
+
useImperativeHandle(ref, () => withHostMethods(element.current), []);
|
|
1919
|
+
useElementLayout(element, onLayout);
|
|
1920
|
+
const registry = useStyleRegistry();
|
|
1921
|
+
const pressable = (onPress != null || onLongPress != null) && disabled !== true;
|
|
1922
|
+
const handlers = usePressability(useMemo(() => pressable ? {
|
|
1923
|
+
pressRectOffset: pressRetentionOffset,
|
|
1924
|
+
onBlur,
|
|
1925
|
+
onFocus,
|
|
1926
|
+
onLongPress,
|
|
1927
|
+
onPress,
|
|
1928
|
+
onPressIn,
|
|
1929
|
+
onPressOut
|
|
1930
|
+
} : null, [
|
|
1931
|
+
pressable,
|
|
1932
|
+
pressRetentionOffset,
|
|
1933
|
+
onBlur,
|
|
1934
|
+
onFocus,
|
|
1935
|
+
onLongPress,
|
|
1936
|
+
onPress,
|
|
1937
|
+
onPressIn,
|
|
1938
|
+
onPressOut
|
|
1939
|
+
]));
|
|
1940
|
+
const roleProps = pressable && rest.role === void 0 && rest.accessibilityRole === void 0 ? {
|
|
1941
|
+
...rest,
|
|
1942
|
+
role: "link"
|
|
1943
|
+
} : rest;
|
|
1944
|
+
const { tag, role } = resolveTag(roleProps, "span", children != null);
|
|
1945
|
+
const lineStyle = numberOfLines === void 0 || numberOfLines < 1 ? void 0 : numberOfLines === 1 ? singleLineStyle : multiLineStyle(numberOfLines);
|
|
1946
|
+
const clipStyle = ellipsizeMode === "clip" ? { textOverflow: "clip" } : void 0;
|
|
1947
|
+
const selectStyle = selectable === false ? { userSelect: "none" } : void 0;
|
|
1948
|
+
const pointerStyle = pointerEvents === void 0 ? void 0 : pointerEventsStyle[pointerEvents];
|
|
1949
|
+
let className = joinClassNames(nested ? compileReset("rn-text-nested", nestedResetStyle, registry) : compileReset("rn-text", resetStyle$1, registry), compileStyle([
|
|
1950
|
+
style,
|
|
1951
|
+
lineStyle,
|
|
1952
|
+
clipStyle,
|
|
1953
|
+
selectStyle,
|
|
1954
|
+
pointerStyle
|
|
1955
|
+
], registry));
|
|
1956
|
+
if (selectionColor !== void 0) {
|
|
1957
|
+
const extra = selectionClass$1(registry, selectionColor);
|
|
1958
|
+
if (extra !== void 0) className = `${className} ${extra}`;
|
|
1959
|
+
}
|
|
1960
|
+
const domProps = toDOMProps(rest);
|
|
1961
|
+
if (role !== void 0) domProps["role"] = role;
|
|
1962
|
+
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
1963
|
+
if (tag === "button") domProps["type"] = "button";
|
|
1964
|
+
if (disabled === true) domProps["aria-disabled"] = true;
|
|
1965
|
+
if (pressable && handlers !== null) {
|
|
1966
|
+
Object.assign(domProps, mergeHandlers(rest, handlers));
|
|
1967
|
+
if (domProps["tabIndex"] === void 0 && tag !== "a" && tag !== "button") domProps["tabIndex"] = 0;
|
|
1968
|
+
} else {
|
|
1969
|
+
if (onFocus !== void 0) domProps["onFocus"] = onFocus;
|
|
1970
|
+
if (onBlur !== void 0) domProps["onBlur"] = onBlur;
|
|
1971
|
+
}
|
|
1972
|
+
domProps["className"] = className;
|
|
1973
|
+
domProps["ref"] = element;
|
|
1974
|
+
const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
|
|
1975
|
+
return createElement(tag, domProps, content);
|
|
1976
|
+
}
|
|
1977
|
+
// src/render/hitSlop.ts
|
|
1978
|
+
const hitSlopClass = (registry, hitSlop) => {
|
|
1979
|
+
if (hitSlop === void 0) return void 0;
|
|
1980
|
+
const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
|
|
1981
|
+
top: hitSlop,
|
|
1982
|
+
right: hitSlop,
|
|
1983
|
+
bottom: hitSlop,
|
|
1984
|
+
left: hitSlop
|
|
1985
|
+
} : hitSlop;
|
|
1986
|
+
if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
|
|
1987
|
+
const name = `rn-hs-${[
|
|
1988
|
+
top,
|
|
1989
|
+
right,
|
|
1990
|
+
bottom,
|
|
1991
|
+
left
|
|
1992
|
+
].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
|
|
1993
|
+
return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
|
|
1994
|
+
};
|
|
1995
|
+
// src/components/TouchableOpacity/index.tsx
|
|
1996
|
+
const EASE_IN_OUT_QUAD = "cubic-bezier(0.455, 0.03, 0.515, 0.955)";
|
|
1997
|
+
const DEFAULT_ACTIVE_OPACITY$1 = .2;
|
|
1998
|
+
const notCancelableStyle$2 = Object.freeze({ touchAction: "none" });
|
|
1999
|
+
const isTrue$1 = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
2000
|
+
const restingOpacity = (style) => {
|
|
2001
|
+
const opacity = flattenStyle(style)?.opacity;
|
|
2002
|
+
return typeof opacity === "number" ? opacity : 1;
|
|
2003
|
+
};
|
|
2004
|
+
function TouchableOpacity(props) {
|
|
2005
|
+
const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, ref, rejectResponderTermination, style, touchSoundDisabled, ...rest } = props;
|
|
2006
|
+
const element = useRef(null);
|
|
2007
|
+
const animation = useRef(null);
|
|
2008
|
+
const resting = restingOpacity(style);
|
|
2009
|
+
const resolvedDisabled = disabled ?? isTrue$1(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
2010
|
+
const fadeTo = useCallback((opacity, duration, settle) => {
|
|
2011
|
+
const node = element.current;
|
|
2012
|
+
if (node === null || typeof node.animate !== "function") return;
|
|
2013
|
+
const from = getComputedStyle(node).opacity;
|
|
2014
|
+
animation.current?.cancel();
|
|
2015
|
+
const next = node.animate([{ opacity: from }, { opacity: String(opacity) }], {
|
|
2016
|
+
duration,
|
|
2017
|
+
easing: EASE_IN_OUT_QUAD,
|
|
2018
|
+
fill: "forwards"
|
|
2019
|
+
});
|
|
2020
|
+
animation.current = next;
|
|
2021
|
+
if (settle) next.onfinish = () => {
|
|
2022
|
+
if (animation.current !== next) return;
|
|
2023
|
+
next.cancel();
|
|
2024
|
+
animation.current = null;
|
|
2025
|
+
};
|
|
2026
|
+
}, []);
|
|
2027
|
+
const handlers = usePressability(useMemo(() => ({
|
|
2028
|
+
cancelable: rejectResponderTermination !== true,
|
|
2029
|
+
disabled: resolvedDisabled,
|
|
2030
|
+
hitSlop,
|
|
2031
|
+
delayLongPress,
|
|
2032
|
+
delayPressIn,
|
|
2033
|
+
delayPressOut,
|
|
2034
|
+
minPressDuration: 0,
|
|
2035
|
+
pressRectOffset: pressRetentionOffset,
|
|
2036
|
+
android_disableSound: touchSoundDisabled,
|
|
2037
|
+
onBlur,
|
|
2038
|
+
onFocus,
|
|
2039
|
+
onLongPress,
|
|
2040
|
+
onPress,
|
|
2041
|
+
onPressIn: (event) => {
|
|
2042
|
+
const starts = event.type === "pointerdown" || event.type === "keydown";
|
|
2043
|
+
fadeTo(activeOpacity ?? DEFAULT_ACTIVE_OPACITY$1, starts ? 0 : 150, false);
|
|
2044
|
+
onPressIn?.(event);
|
|
2045
|
+
},
|
|
2046
|
+
onPressOut: (event) => {
|
|
2047
|
+
fadeTo(resting, 250, true);
|
|
2048
|
+
onPressOut?.(event);
|
|
2049
|
+
}
|
|
2050
|
+
}), [
|
|
2051
|
+
activeOpacity,
|
|
2052
|
+
delayLongPress,
|
|
2053
|
+
delayPressIn,
|
|
2054
|
+
delayPressOut,
|
|
2055
|
+
fadeTo,
|
|
2056
|
+
hitSlop,
|
|
2057
|
+
onBlur,
|
|
2058
|
+
onFocus,
|
|
2059
|
+
onLongPress,
|
|
2060
|
+
onPress,
|
|
2061
|
+
onPressIn,
|
|
2062
|
+
onPressOut,
|
|
2063
|
+
pressRetentionOffset,
|
|
2064
|
+
rejectResponderTermination,
|
|
2065
|
+
resolvedDisabled,
|
|
2066
|
+
resting,
|
|
2067
|
+
touchSoundDisabled
|
|
2068
|
+
]));
|
|
2069
|
+
const registry = useStyleRegistry();
|
|
2070
|
+
const previous = useRef({
|
|
2071
|
+
disabled,
|
|
2072
|
+
resting
|
|
2073
|
+
});
|
|
2074
|
+
useEffect(() => {
|
|
2075
|
+
if (previous.current.disabled === disabled && previous.current.resting === resting) return;
|
|
2076
|
+
previous.current = {
|
|
2077
|
+
disabled,
|
|
2078
|
+
resting
|
|
2079
|
+
};
|
|
2080
|
+
fadeTo(resting, 250, true);
|
|
2081
|
+
}, [
|
|
2082
|
+
disabled,
|
|
2083
|
+
fadeTo,
|
|
2084
|
+
resting
|
|
2085
|
+
]);
|
|
2086
|
+
useEffect(() => () => {
|
|
2087
|
+
animation.current?.cancel();
|
|
2088
|
+
}, []);
|
|
2089
|
+
const view = useViewElement({
|
|
2090
|
+
...rest,
|
|
2091
|
+
...mergeHandlers(rest, handlers),
|
|
2092
|
+
ref: element,
|
|
2093
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true,
|
|
2094
|
+
style: [style, rejectResponderTermination === true && notCancelableStyle$2],
|
|
2095
|
+
children,
|
|
2096
|
+
...resolvedDisabled === true && { "aria-disabled": true }
|
|
2097
|
+
}, hitSlopClass(registry, hitSlop));
|
|
2098
|
+
useImperativeHandle(ref, () => element.current, []);
|
|
2099
|
+
return view;
|
|
2100
|
+
}
|
|
2101
|
+
// src/components/Button/index.tsx
|
|
2102
|
+
function Button(props) {
|
|
2103
|
+
const { accessibilityActions: _accessibilityActions, accessibilityLanguage, accessibilityState, "aria-disabled": ariaDisabled, color, importantForAccessibility, onAccessibilityAction: _onAccessibilityAction, title, ...rest } = props;
|
|
2104
|
+
if (typeof title !== "string") throw new Error("The title prop of a Button must be a string");
|
|
2105
|
+
const disabled = props.disabled ?? ariaDisabled ?? accessibilityState?.disabled;
|
|
2106
|
+
const state = disabled === accessibilityState?.disabled ? accessibilityState : {
|
|
2107
|
+
...accessibilityState,
|
|
2108
|
+
disabled
|
|
2109
|
+
};
|
|
2110
|
+
return /* @__PURE__ */ jsx(TouchableOpacity, {
|
|
2111
|
+
...rest,
|
|
2112
|
+
...accessibilityLanguage !== void 0 && { lang: accessibilityLanguage },
|
|
2113
|
+
role: "button",
|
|
2114
|
+
accessibilityState: state,
|
|
2115
|
+
disabled,
|
|
2116
|
+
importantForAccessibility: importantForAccessibility === "no" ? "no-hide-descendants" : importantForAccessibility,
|
|
2117
|
+
style: [
|
|
2118
|
+
styles$3.button,
|
|
2119
|
+
color != null && color !== "" && { backgroundColor: color },
|
|
2120
|
+
disabled === true && styles$3.buttonDisabled
|
|
2121
|
+
],
|
|
2122
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
2123
|
+
style: [styles$3.text, disabled === true && styles$3.textDisabled],
|
|
2124
|
+
children: title
|
|
2125
|
+
})
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
const styles$3 = StyleSheet.create({
|
|
2129
|
+
button: {
|
|
2130
|
+
backgroundColor: "#2196F3",
|
|
2131
|
+
borderRadius: 2
|
|
2132
|
+
},
|
|
2133
|
+
text: {
|
|
2134
|
+
color: "white",
|
|
2135
|
+
fontWeight: "500",
|
|
2136
|
+
margin: 8,
|
|
2137
|
+
textAlign: "center"
|
|
2138
|
+
},
|
|
2139
|
+
buttonDisabled: { backgroundColor: "#dfdfdf" },
|
|
2140
|
+
textDisabled: { color: "#a1a1a1" }
|
|
2141
|
+
});
|
|
2142
|
+
const DRAG_RATE = .5;
|
|
2143
|
+
/**
|
|
2144
|
+
* The distance of the indicator for a finger distance. It follows the finger at half the speed,
|
|
2145
|
+
* and slows down past the target, so it never goes past twice the target.
|
|
2146
|
+
*/
|
|
2147
|
+
const pullOffset = (distance) => {
|
|
2148
|
+
const travel = Math.max(0, distance) * DRAG_RATE;
|
|
2149
|
+
if (travel <= 64) return travel;
|
|
2150
|
+
const extra = travel - 64;
|
|
2151
|
+
return 64 + 64 * extra / (extra + 64);
|
|
2152
|
+
};
|
|
2153
|
+
/** A release after this finger distance refreshes. */
|
|
2154
|
+
const releasesRefresh = (distance) => distance * DRAG_RATE > 64;
|
|
2155
|
+
// src/components/RefreshControl/index.tsx
|
|
2156
|
+
const ARC = "#000000";
|
|
2157
|
+
const DISC = "#FFFFFF";
|
|
2158
|
+
const ARC_LENGTH = 2 * Math.PI * 8.75;
|
|
2159
|
+
const INDICATOR_CLASS = "rn-refresh";
|
|
2160
|
+
const RULES$2 = [
|
|
2161
|
+
"@keyframes rn-refresh-spin{to{transform:rotate(360deg)}}",
|
|
2162
|
+
`.${INDICATOR_CLASS}{position:absolute;top:0;left:50%;z-index:1;display:flex;width:40px;height:40px;margin-left:-20px;border-radius:50%;box-shadow:0 1px 4px rgba(0,0,0,.3);pointer-events:none;opacity:0;transform:translateY(calc(var(--rn-refresh-top) - 100%));transition:transform .2s ease-out,opacity .2s}`,
|
|
2163
|
+
`.${INDICATOR_CLASS}[data-size=large]{width:56px;height:56px;margin-left:-28px}`,
|
|
2164
|
+
`.${INDICATOR_CLASS}[data-refreshing]{opacity:1;transform:translateY(calc(var(--rn-refresh-top) + 64px - 100%))}`,
|
|
2165
|
+
`.${INDICATOR_CLASS}>svg{width:100%;height:100%}`,
|
|
2166
|
+
`.${INDICATOR_CLASS}[data-refreshing]>svg{animation:rn-refresh-spin .75s linear infinite}`,
|
|
2167
|
+
`.${INDICATOR_CLASS} circle{stroke-dasharray:0 ${ARC_LENGTH}}`,
|
|
2168
|
+
`.${INDICATOR_CLASS}[data-refreshing] circle{stroke-dasharray:${ARC_LENGTH * .75} ${ARC_LENGTH}}`,
|
|
2169
|
+
`@media (prefers-reduced-motion:reduce){.${INDICATOR_CLASS}{transition:none}}`
|
|
2170
|
+
];
|
|
2171
|
+
const frameOf = (element) => {
|
|
2172
|
+
let toScreen = new DOMMatrix();
|
|
2173
|
+
for (let node = element; node !== null; node = node.parentElement) {
|
|
2174
|
+
const { transform } = getComputedStyle(node);
|
|
2175
|
+
if (transform !== "none") toScreen = new DOMMatrix(transform).multiply(toScreen);
|
|
2176
|
+
}
|
|
2177
|
+
return toScreen.inverse();
|
|
2178
|
+
};
|
|
2179
|
+
function RefreshControl(props) {
|
|
2180
|
+
const { children, colors, enabled = true, onRefresh, progressBackgroundColor, progressViewOffset = 0, refreshing, size = "default", style, tintColor, title, titleColor: _titleColor, ...rest } = props;
|
|
2181
|
+
const indicatorClass = useStyleRegistry().staticClass(INDICATOR_CLASS, RULES$2);
|
|
2182
|
+
const indicator = useRef(null);
|
|
2183
|
+
const latest = useRef({
|
|
2184
|
+
enabled,
|
|
2185
|
+
refreshing,
|
|
2186
|
+
onRefresh
|
|
2187
|
+
});
|
|
2188
|
+
useLayoutEffect(() => {
|
|
2189
|
+
latest.current = {
|
|
2190
|
+
enabled,
|
|
2191
|
+
refreshing,
|
|
2192
|
+
onRefresh
|
|
2193
|
+
};
|
|
2194
|
+
});
|
|
2195
|
+
useEffect(() => {
|
|
2196
|
+
const element = indicator.current;
|
|
2197
|
+
const area = element?.parentElement;
|
|
2198
|
+
if (!element || !area) return;
|
|
2199
|
+
const svg = element.firstElementChild;
|
|
2200
|
+
const arc = svg.firstElementChild;
|
|
2201
|
+
let gesture = null;
|
|
2202
|
+
let releaseTimer;
|
|
2203
|
+
const scrollTop = () => {
|
|
2204
|
+
const scroller = area.firstElementChild;
|
|
2205
|
+
return scroller instanceof HTMLElement && scroller !== element ? scroller.scrollTop : 0;
|
|
2206
|
+
};
|
|
2207
|
+
const draw = (distance) => {
|
|
2208
|
+
const offset = pullOffset(distance);
|
|
2209
|
+
const progress = Math.min(1, offset / 64);
|
|
2210
|
+
element.style.transition = "none";
|
|
2211
|
+
element.style.opacity = String(Math.min(1, offset / element.offsetHeight));
|
|
2212
|
+
element.style.transform = `translateY(calc(var(--rn-refresh-top) + ${offset}px - 100%))`;
|
|
2213
|
+
svg.style.transform = `rotate(${progress * 270}deg)`;
|
|
2214
|
+
arc.style.strokeDasharray = `${progress * .8 * ARC_LENGTH} ${ARC_LENGTH}`;
|
|
2215
|
+
};
|
|
2216
|
+
const clear = () => {
|
|
2217
|
+
element.style.transition = "";
|
|
2218
|
+
element.style.opacity = "";
|
|
2219
|
+
element.style.transform = "";
|
|
2220
|
+
svg.style.transform = "";
|
|
2221
|
+
arc.style.strokeDasharray = "";
|
|
2222
|
+
};
|
|
2223
|
+
const touchOf = (event) => Array.from(event.changedTouches).find((touch) => touch.identifier === gesture?.id);
|
|
2224
|
+
const onStart = (event) => {
|
|
2225
|
+
const touch = event.touches[0];
|
|
2226
|
+
const { enabled: on, refreshing: busy } = latest.current;
|
|
2227
|
+
gesture = event.touches.length === 1 && touch !== void 0 && on && !busy && scrollTop() <= 0 ? {
|
|
2228
|
+
id: touch.identifier,
|
|
2229
|
+
x: touch.clientX,
|
|
2230
|
+
y: touch.clientY,
|
|
2231
|
+
pulling: false,
|
|
2232
|
+
distance: 0,
|
|
2233
|
+
toLocal: frameOf(area)
|
|
2234
|
+
} : null;
|
|
2235
|
+
};
|
|
2236
|
+
const onMove = (event) => {
|
|
2237
|
+
const touch = touchOf(event);
|
|
2238
|
+
if (gesture === null || touch === void 0) return;
|
|
2239
|
+
const { a, b, c, d } = gesture.toLocal;
|
|
2240
|
+
const screenX = touch.clientX - gesture.x;
|
|
2241
|
+
const screenY = touch.clientY - gesture.y;
|
|
2242
|
+
const dx = a * screenX + c * screenY;
|
|
2243
|
+
const dy = b * screenX + d * screenY;
|
|
2244
|
+
if (!gesture.pulling) {
|
|
2245
|
+
if (dx === 0 && dy === 0) return;
|
|
2246
|
+
if (dy <= 0 || Math.abs(dx) > dy || scrollTop() > 0 || !event.cancelable) {
|
|
2247
|
+
gesture = null;
|
|
2248
|
+
return;
|
|
2249
|
+
}
|
|
2250
|
+
gesture.pulling = true;
|
|
2251
|
+
}
|
|
2252
|
+
event.preventDefault();
|
|
2253
|
+
gesture.distance = Math.max(0, dy);
|
|
2254
|
+
draw(gesture.distance);
|
|
2255
|
+
};
|
|
2256
|
+
const onEnd = (event) => {
|
|
2257
|
+
if (gesture === null || touchOf(event) === void 0) return;
|
|
2258
|
+
const { pulling, distance } = gesture;
|
|
2259
|
+
gesture = null;
|
|
2260
|
+
if (!pulling) return;
|
|
2261
|
+
const refresh = event.type === "touchend" && releasesRefresh(distance);
|
|
2262
|
+
if (refresh) element.setAttribute("data-refreshing", "");
|
|
2263
|
+
clear();
|
|
2264
|
+
if (!refresh) return;
|
|
2265
|
+
latest.current.onRefresh?.();
|
|
2266
|
+
releaseTimer = setTimeout(() => {
|
|
2267
|
+
if (!latest.current.refreshing) element.removeAttribute("data-refreshing");
|
|
2268
|
+
}, 0);
|
|
2269
|
+
};
|
|
2270
|
+
area.addEventListener("touchstart", onStart, { passive: true });
|
|
2271
|
+
area.addEventListener("touchmove", onMove, { passive: false });
|
|
2272
|
+
area.addEventListener("touchend", onEnd);
|
|
2273
|
+
area.addEventListener("touchcancel", onEnd);
|
|
2274
|
+
return () => {
|
|
2275
|
+
area.removeEventListener("touchstart", onStart);
|
|
2276
|
+
area.removeEventListener("touchmove", onMove);
|
|
2277
|
+
area.removeEventListener("touchend", onEnd);
|
|
2278
|
+
area.removeEventListener("touchcancel", onEnd);
|
|
2279
|
+
clearTimeout(releaseTimer);
|
|
2280
|
+
clear();
|
|
2281
|
+
};
|
|
2282
|
+
}, []);
|
|
2283
|
+
const indicatorStyle = {
|
|
2284
|
+
"--rn-refresh-top": `${progressViewOffset}px`,
|
|
2285
|
+
backgroundColor: toCSSColor(progressBackgroundColor) ?? DISC
|
|
2286
|
+
};
|
|
2287
|
+
const arcColor = toCSSColor(colors?.[0]) ?? toCSSColor(tintColor) ?? ARC;
|
|
2288
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
2289
|
+
...rest,
|
|
2290
|
+
"aria-busy": refreshing,
|
|
2291
|
+
style: [styles$2.area, style],
|
|
2292
|
+
children: [children, /* @__PURE__ */ jsx("div", {
|
|
2293
|
+
ref: indicator,
|
|
2294
|
+
"aria-hidden": !refreshing,
|
|
2295
|
+
"aria-label": title,
|
|
2296
|
+
className: indicatorClass,
|
|
2297
|
+
"data-refreshing": refreshing ? "" : void 0,
|
|
2298
|
+
"data-size": size === "large" ? "large" : void 0,
|
|
2299
|
+
role: "progressbar",
|
|
2300
|
+
style: indicatorStyle,
|
|
2301
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
2302
|
+
"aria-hidden": true,
|
|
2303
|
+
viewBox: "0 0 40 40",
|
|
2304
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
2305
|
+
cx: "20",
|
|
2306
|
+
cy: "20",
|
|
2307
|
+
fill: "none",
|
|
2308
|
+
r: "8.75",
|
|
2309
|
+
stroke: arcColor,
|
|
2310
|
+
strokeLinecap: "round",
|
|
2311
|
+
strokeWidth: "2.5"
|
|
2312
|
+
})
|
|
2313
|
+
})
|
|
2314
|
+
})]
|
|
2315
|
+
});
|
|
1055
2316
|
}
|
|
2317
|
+
const styles$2 = StyleSheet.create({ area: {
|
|
2318
|
+
position: "relative",
|
|
2319
|
+
overflow: "hidden"
|
|
2320
|
+
} });
|
|
2321
|
+
// src/style/splitLayoutProps.ts
|
|
2322
|
+
const OUTER = /* @__PURE__ */ new Set([
|
|
2323
|
+
"margin",
|
|
2324
|
+
"marginHorizontal",
|
|
2325
|
+
"marginVertical",
|
|
2326
|
+
"marginBottom",
|
|
2327
|
+
"marginTop",
|
|
2328
|
+
"marginLeft",
|
|
2329
|
+
"marginRight",
|
|
2330
|
+
"flex",
|
|
2331
|
+
"flexGrow",
|
|
2332
|
+
"flexShrink",
|
|
2333
|
+
"flexBasis",
|
|
2334
|
+
"alignSelf",
|
|
2335
|
+
"height",
|
|
2336
|
+
"minHeight",
|
|
2337
|
+
"maxHeight",
|
|
2338
|
+
"width",
|
|
2339
|
+
"minWidth",
|
|
2340
|
+
"maxWidth",
|
|
2341
|
+
"position",
|
|
2342
|
+
"left",
|
|
2343
|
+
"right",
|
|
2344
|
+
"bottom",
|
|
2345
|
+
"top",
|
|
2346
|
+
"transform",
|
|
2347
|
+
"transformOrigin",
|
|
2348
|
+
"rowGap",
|
|
2349
|
+
"columnGap",
|
|
2350
|
+
"gap"
|
|
2351
|
+
]);
|
|
2352
|
+
/**
|
|
2353
|
+
* Splits a flat style in two, as React Native's `splitLayoutProps` does: `outer` places the box,
|
|
2354
|
+
* `inner` is the rest. A wrapper takes `outer` and the wrapped box takes `inner`.
|
|
2355
|
+
*/
|
|
2356
|
+
const splitLayoutProps = (style) => {
|
|
2357
|
+
const outer = {};
|
|
2358
|
+
const inner = {};
|
|
2359
|
+
if (style == null) return {
|
|
2360
|
+
outer,
|
|
2361
|
+
inner
|
|
2362
|
+
};
|
|
2363
|
+
for (const [prop, value] of Object.entries(style)) if (OUTER.has(prop)) outer[prop] = value;
|
|
2364
|
+
else inner[prop] = value;
|
|
2365
|
+
return {
|
|
2366
|
+
outer,
|
|
2367
|
+
inner
|
|
2368
|
+
};
|
|
2369
|
+
};
|
|
1056
2370
|
// src/components/ScrollView/snap.ts
|
|
1057
2371
|
const nearest = (offset, candidates) => {
|
|
1058
2372
|
let best;
|
|
@@ -1089,33 +2403,37 @@ const snapTarget = (offset, viewport, contentSize, config) => {
|
|
|
1089
2403
|
return Math.abs(target - offset) < .5 ? void 0 : target;
|
|
1090
2404
|
};
|
|
1091
2405
|
// src/components/ScrollView/index.tsx
|
|
1092
|
-
const scrollerStyle =
|
|
2406
|
+
const scrollerStyle = webStyle({
|
|
1093
2407
|
flexGrow: 1,
|
|
1094
2408
|
flexShrink: 1,
|
|
1095
2409
|
overflowX: "hidden",
|
|
1096
2410
|
overflowY: "auto",
|
|
1097
2411
|
WebkitOverflowScrolling: "touch"
|
|
1098
2412
|
});
|
|
1099
|
-
const horizontalScrollerStyle =
|
|
2413
|
+
const horizontalScrollerStyle = webStyle({
|
|
1100
2414
|
flexDirection: "row",
|
|
1101
2415
|
overflowX: "auto",
|
|
1102
2416
|
overflowY: "hidden"
|
|
1103
2417
|
});
|
|
1104
|
-
const disabledScrollerStyle =
|
|
2418
|
+
const disabledScrollerStyle = webStyle({
|
|
1105
2419
|
overflowX: "hidden",
|
|
1106
2420
|
overflowY: "hidden"
|
|
1107
2421
|
});
|
|
2422
|
+
const refreshAreaStyle = Object.freeze({
|
|
2423
|
+
flexGrow: 1,
|
|
2424
|
+
flexShrink: 1
|
|
2425
|
+
});
|
|
1108
2426
|
const horizontalContentStyle = Object.freeze({ flexDirection: "row" });
|
|
1109
2427
|
const centerContentStyle = Object.freeze({
|
|
1110
2428
|
flexGrow: 1,
|
|
1111
2429
|
justifyContent: "center"
|
|
1112
2430
|
});
|
|
1113
|
-
const stickyStyle =
|
|
2431
|
+
const stickyStyle = webStyle({
|
|
1114
2432
|
position: "sticky",
|
|
1115
2433
|
top: 0,
|
|
1116
2434
|
zIndex: 10
|
|
1117
2435
|
});
|
|
1118
|
-
const invertedStickyStyle =
|
|
2436
|
+
const invertedStickyStyle = webStyle({
|
|
1119
2437
|
position: "sticky",
|
|
1120
2438
|
bottom: 0,
|
|
1121
2439
|
zIndex: 10
|
|
@@ -1331,6 +2649,7 @@ function ScrollView(props) {
|
|
|
1331
2649
|
children: items
|
|
1332
2650
|
});
|
|
1333
2651
|
const hideScrollbar = horizontal ? !showsHorizontalScrollIndicator : !showsVerticalScrollIndicator;
|
|
2652
|
+
const split = refreshControl === void 0 ? void 0 : splitLayoutProps(StyleSheet.flatten(style));
|
|
1334
2653
|
const scrollerElement = useViewElement({
|
|
1335
2654
|
...rest,
|
|
1336
2655
|
ref: scroller,
|
|
@@ -1338,7 +2657,7 @@ function ScrollView(props) {
|
|
|
1338
2657
|
scrollerStyle,
|
|
1339
2658
|
horizontal && horizontalScrollerStyle,
|
|
1340
2659
|
!scrollEnabled && disabledScrollerStyle,
|
|
1341
|
-
style
|
|
2660
|
+
split === void 0 ? style : split.inner
|
|
1342
2661
|
],
|
|
1343
2662
|
onScroll: handleScroll,
|
|
1344
2663
|
onScrollEnd: handleScrollEnd,
|
|
@@ -1386,7 +2705,7 @@ function ScrollView(props) {
|
|
|
1386
2705
|
getNativeScrollRef: () => element
|
|
1387
2706
|
});
|
|
1388
2707
|
}, [horizontal]);
|
|
1389
|
-
return refreshControl === void 0 ? scrollerElement : cloneElement(refreshControl,
|
|
2708
|
+
return refreshControl === void 0 || split === void 0 ? scrollerElement : cloneElement(refreshControl, { style: [refreshAreaStyle, split.outer] }, scrollerElement);
|
|
1390
2709
|
}
|
|
1391
2710
|
// src/components/FlatList/viewability.ts
|
|
1392
2711
|
const pixelsVisible = (top, bottom, viewport) => Math.max(0, Math.min(bottom, viewport) - Math.max(top, 0));
|
|
@@ -1570,7 +2889,7 @@ const createTrackers = (props) => {
|
|
|
1570
2889
|
return [];
|
|
1571
2890
|
};
|
|
1572
2891
|
function FlatList(props) {
|
|
1573
|
-
const { data, renderItem, ListItemComponent, keyExtractor = defaultKeyExtractor, getItemLayout: _getItemLayout, numColumns = 1, columnWrapperStyle, inverted, initialScrollIndex: _initialScrollIndex, ItemSeparatorComponent, ListEmptyComponent, ListHeaderComponent, ListHeaderComponentStyle, ListFooterComponent, ListFooterComponentStyle, CellRendererComponent, renderScrollComponent, horizontal = false, style, ref, onScroll: _onScroll, onContentSizeChange: _onContentSizeChange, onLayout: _onLayout, onEndReached: _onEndReached, onEndReachedThreshold: _onEndReachedThreshold, onStartReached: _onStartReached, onStartReachedThreshold: _onStartReachedThreshold, onViewableItemsChanged: _onViewableItemsChanged, viewabilityConfig: _viewabilityConfig, viewabilityConfigCallbackPairs: _viewabilityConfigCallbackPairs, onScrollToIndexFailed: _onScrollToIndexFailed,
|
|
2892
|
+
const { data, renderItem, ListItemComponent, keyExtractor = defaultKeyExtractor, getItemLayout: _getItemLayout, numColumns = 1, columnWrapperStyle, inverted, initialScrollIndex: _initialScrollIndex, ItemSeparatorComponent, ListEmptyComponent, ListHeaderComponent, ListHeaderComponentStyle, ListFooterComponent, ListFooterComponentStyle, CellRendererComponent, renderScrollComponent, horizontal = false, style, ref, onScroll: _onScroll, onContentSizeChange: _onContentSizeChange, onLayout: _onLayout, onEndReached: _onEndReached, onEndReachedThreshold: _onEndReachedThreshold, onStartReached: _onStartReached, onStartReachedThreshold: _onStartReachedThreshold, onViewableItemsChanged: _onViewableItemsChanged, viewabilityConfig: _viewabilityConfig, viewabilityConfigCallbackPairs: _viewabilityConfigCallbackPairs, onScrollToIndexFailed: _onScrollToIndexFailed, onRefresh, refreshing, progressViewOffset, extraData: _extraData, debug: _debug, disableVirtualization: _disableVirtualization, initialNumToRender: _initialNumToRender, maxToRenderPerBatch: _maxToRenderPerBatch, strictMode: _strictMode, updateCellsBatchingPeriod: _updateCellsBatchingPeriod, windowSize: _windowSize, legacyImplementation: _legacyImplementation, ...scrollViewProps } = props;
|
|
1574
2893
|
if (numColumns > 1 && horizontal) throw new Error("numColumns does not support horizontal.");
|
|
1575
2894
|
const latest = useRef(props);
|
|
1576
2895
|
useEffect(() => {
|
|
@@ -1874,21 +3193,27 @@ function FlatList(props) {
|
|
|
1874
3193
|
};
|
|
1875
3194
|
if (renderScrollComponent !== void 0) return /* @__PURE__ */ jsx(CustomScroller, {
|
|
1876
3195
|
...scrollProps,
|
|
3196
|
+
onRefresh,
|
|
3197
|
+
refreshing,
|
|
3198
|
+
progressViewOffset,
|
|
1877
3199
|
ref: scroller,
|
|
1878
3200
|
render: renderScrollComponent
|
|
1879
3201
|
});
|
|
3202
|
+
let refreshControl = scrollProps.refreshControl;
|
|
3203
|
+
if (onRefresh != null) {
|
|
3204
|
+
if (typeof refreshing !== "boolean") throw new Error("`refreshing` prop must be set as a boolean in order to use `onRefresh`, but got `" + JSON.stringify(refreshing ?? "undefined") + "`");
|
|
3205
|
+
refreshControl ??= /* @__PURE__ */ jsx(RefreshControl, {
|
|
3206
|
+
refreshing,
|
|
3207
|
+
onRefresh,
|
|
3208
|
+
progressViewOffset
|
|
3209
|
+
});
|
|
3210
|
+
}
|
|
1880
3211
|
return /* @__PURE__ */ jsx(ScrollView, {
|
|
1881
3212
|
...scrollProps,
|
|
3213
|
+
refreshControl,
|
|
1882
3214
|
ref: scroller
|
|
1883
3215
|
});
|
|
1884
3216
|
}
|
|
1885
|
-
// src/utils/warn.ts
|
|
1886
|
-
const warned = /* @__PURE__ */ new Set();
|
|
1887
|
-
const warnOnce = (key, message) => {
|
|
1888
|
-
if (isProductionEnv() || warned.has(key)) return;
|
|
1889
|
-
warned.add(key);
|
|
1890
|
-
console.warn(`[@rootnative/web] ${message}`);
|
|
1891
|
-
};
|
|
1892
3217
|
// src/components/Image/source.ts
|
|
1893
3218
|
const none = Object.freeze({
|
|
1894
3219
|
src: void 0,
|
|
@@ -2093,7 +3418,7 @@ function ImageComponent(props) {
|
|
|
2093
3418
|
const { alt, blurRadius, crossOrigin, decoding, defaultSource, fetchPriority, height, loading, onError, onLayout, onLoad, onLoadEnd, onLoadStart, ref, referrerPolicy, resizeMode: resizeModeProp, source, src, srcSet, style, tintColor: tintColorProp, width, fadeDuration: _fadeDuration, loadingIndicatorSource: _loadingIndicatorSource, onProgress: _onProgress, progressiveRenderingEnabled: _progressiveRenderingEnabled, resizeMethod: _resizeMethod, ...rest } = props;
|
|
2094
3419
|
const element = useRef(null);
|
|
2095
3420
|
const img = useRef(null);
|
|
2096
|
-
useImperativeHandle(ref, () => element.current, []);
|
|
3421
|
+
useImperativeHandle(ref, () => withHostMethods(element.current), []);
|
|
2097
3422
|
useElementLayout(element, onLayout);
|
|
2098
3423
|
const registry = useStyleRegistry();
|
|
2099
3424
|
const { resizeMode: styleResizeMode, objectFit, tintColor: styleTintColor, overlayColor: _overlayColor, ...userBoxStyle } = flattenStyle(style) ?? {};
|
|
@@ -2166,11 +3491,7 @@ function ImageComponent(props) {
|
|
|
2166
3491
|
width: userBoxStyle["width"] ?? width ?? resolved.width,
|
|
2167
3492
|
height: userBoxStyle["height"] ?? height ?? resolved.height
|
|
2168
3493
|
};
|
|
2169
|
-
const boxClassName = compileStyle([
|
|
2170
|
-
boxStyle,
|
|
2171
|
-
sizeStyle,
|
|
2172
|
-
userBoxStyle
|
|
2173
|
-
], registry);
|
|
3494
|
+
const boxClassName = joinClassNames(compileReset("rn-image", boxStyle, registry), compileStyle([sizeStyle, userBoxStyle], registry));
|
|
2174
3495
|
const label = alt ?? rest.accessibilityLabel ?? rest["aria-label"];
|
|
2175
3496
|
const domProps = toDOMProps(rest);
|
|
2176
3497
|
domProps["className"] = boxClassName;
|
|
@@ -2266,422 +3587,385 @@ function getSize(uri, success, failure) {
|
|
|
2266
3587
|
function getSizeWithHeaders(uri, headers, success, failure) {
|
|
2267
3588
|
const promise = fetchObjectURL(uri, headers).then((url) => loadSize(url).finally(() => URL.revokeObjectURL(url)));
|
|
2268
3589
|
return withCallbacks(promise, success, failure);
|
|
2269
|
-
}
|
|
2270
|
-
const Image = Object.assign(ImageComponent, {
|
|
2271
|
-
getSize,
|
|
2272
|
-
getSizeWithHeaders,
|
|
2273
|
-
prefetch: (url) => loadSize(url).then(() => true),
|
|
2274
|
-
queryCache: () => Promise.resolve({}),
|
|
2275
|
-
resolveAssetSource
|
|
2276
|
-
});
|
|
2277
|
-
// src/
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
const
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
};
|
|
2324
|
-
|
|
2325
|
-
const
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
}
|
|
2388
|
-
|
|
2389
|
-
const
|
|
2390
|
-
const
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
3590
|
+
}
|
|
3591
|
+
const Image = Object.assign(ImageComponent, {
|
|
3592
|
+
getSize,
|
|
3593
|
+
getSizeWithHeaders,
|
|
3594
|
+
prefetch: (url) => loadSize(url).then(() => true),
|
|
3595
|
+
queryCache: () => Promise.resolve({}),
|
|
3596
|
+
resolveAssetSource
|
|
3597
|
+
});
|
|
3598
|
+
// src/components/KeyboardAvoidingView/index.tsx
|
|
3599
|
+
/**
|
|
3600
|
+
* A view that moves out of the way of the keyboard, with the math of React Native 0.88. As on
|
|
3601
|
+
* native, the frame of the view comes from `onLayout`, so its `y` is relative to its parent.
|
|
3602
|
+
* `keyboardVerticalOffset` adds the distance to the top of the window.
|
|
3603
|
+
*/
|
|
3604
|
+
function KeyboardAvoidingView(props) {
|
|
3605
|
+
const { behavior, children, contentContainerStyle, enabled = true, keyboardVerticalOffset = 0, style, onLayout, ...rest } = props;
|
|
3606
|
+
const [bottom, setBottom] = useState(0);
|
|
3607
|
+
const [initialFrameHeight, setInitialFrameHeight] = useState(0);
|
|
3608
|
+
const frame = useRef(null);
|
|
3609
|
+
const keyboard = useRef(null);
|
|
3610
|
+
const latestBottom = useRef(0);
|
|
3611
|
+
const shownBottom = useRef(0);
|
|
3612
|
+
const initialHeight = useRef(0);
|
|
3613
|
+
const latest = useRef({
|
|
3614
|
+
behavior,
|
|
3615
|
+
enabled,
|
|
3616
|
+
keyboardVerticalOffset,
|
|
3617
|
+
onLayout
|
|
3618
|
+
});
|
|
3619
|
+
useEffect(() => {
|
|
3620
|
+
latest.current = {
|
|
3621
|
+
behavior,
|
|
3622
|
+
enabled,
|
|
3623
|
+
keyboardVerticalOffset,
|
|
3624
|
+
onLayout
|
|
3625
|
+
};
|
|
3626
|
+
});
|
|
3627
|
+
const [handlers] = useState(() => {
|
|
3628
|
+
const relativeKeyboardHeight = (keyboardFrame) => {
|
|
3629
|
+
const layout = frame.current;
|
|
3630
|
+
if (layout === null) return 0;
|
|
3631
|
+
const keyboardY = keyboardFrame.screenY - latest.current.keyboardVerticalOffset;
|
|
3632
|
+
if (latest.current.behavior === "height") return Math.max(shownBottom.current + layout.y + layout.height - keyboardY, 0);
|
|
3633
|
+
return Math.max(layout.y + layout.height - keyboardY, 0);
|
|
3634
|
+
};
|
|
3635
|
+
const update = () => {
|
|
3636
|
+
const event = keyboard.current;
|
|
3637
|
+
const next = event === null ? 0 : relativeKeyboardHeight(event.endCoordinates);
|
|
3638
|
+
if (event !== null && latestBottom.current === next) return;
|
|
3639
|
+
latestBottom.current = next;
|
|
3640
|
+
if (latest.current.enabled) {
|
|
3641
|
+
shownBottom.current = next;
|
|
3642
|
+
setBottom(next);
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
const handleLayout = (event) => {
|
|
3646
|
+
const old = frame.current;
|
|
3647
|
+
frame.current = event.nativeEvent.layout;
|
|
3648
|
+
if (initialHeight.current === 0) {
|
|
3649
|
+
initialHeight.current = frame.current.height;
|
|
3650
|
+
setInitialFrameHeight(frame.current.height);
|
|
3651
|
+
}
|
|
3652
|
+
if (old === null || old.height !== frame.current.height) update();
|
|
3653
|
+
latest.current.onLayout?.(event);
|
|
3654
|
+
};
|
|
3655
|
+
return {
|
|
3656
|
+
update,
|
|
3657
|
+
handleLayout
|
|
3658
|
+
};
|
|
3659
|
+
});
|
|
3660
|
+
useEffect(() => {
|
|
3661
|
+
const { update } = handlers;
|
|
3662
|
+
if (!Keyboard.isVisible()) {
|
|
3663
|
+
keyboard.current = null;
|
|
3664
|
+
update();
|
|
3665
|
+
}
|
|
3666
|
+
const subscriptions = [Keyboard.addListener("keyboardDidHide", () => {
|
|
3667
|
+
keyboard.current = null;
|
|
3668
|
+
update();
|
|
3669
|
+
}), Keyboard.addListener("keyboardDidShow", (event) => {
|
|
3670
|
+
keyboard.current = event;
|
|
3671
|
+
update();
|
|
3672
|
+
})];
|
|
3673
|
+
return () => {
|
|
3674
|
+
for (const subscription of subscriptions) subscription.remove();
|
|
3675
|
+
};
|
|
3676
|
+
}, [handlers]);
|
|
3677
|
+
useEffect(() => {
|
|
3678
|
+
if (enabled && shownBottom.current !== latestBottom.current) {
|
|
3679
|
+
shownBottom.current = latestBottom.current;
|
|
3680
|
+
setBottom(latestBottom.current);
|
|
3681
|
+
}
|
|
3682
|
+
}, [enabled]);
|
|
3683
|
+
const bottomHeight = enabled ? bottom : 0;
|
|
3684
|
+
const outerStyle = useMemo(() => {
|
|
3685
|
+
if (behavior === "padding") return [style, { paddingBottom: bottomHeight }];
|
|
3686
|
+
if (behavior === "height" && bottom > 0) return [style, {
|
|
3687
|
+
height: initialFrameHeight - bottomHeight,
|
|
3688
|
+
flex: 0
|
|
3689
|
+
}];
|
|
3690
|
+
return style;
|
|
3691
|
+
}, [
|
|
3692
|
+
behavior,
|
|
3693
|
+
bottom,
|
|
3694
|
+
bottomHeight,
|
|
3695
|
+
initialFrameHeight,
|
|
3696
|
+
style
|
|
3697
|
+
]);
|
|
3698
|
+
const innerStyle = useMemo(() => [contentContainerStyle, { bottom: bottomHeight }], [contentContainerStyle, bottomHeight]);
|
|
3699
|
+
return /* @__PURE__ */ jsx(View, {
|
|
3700
|
+
...rest,
|
|
3701
|
+
style: outerStyle,
|
|
3702
|
+
onLayout: handlers.handleLayout,
|
|
3703
|
+
children: behavior === "position" ? /* @__PURE__ */ jsx(View, {
|
|
3704
|
+
style: innerStyle,
|
|
3705
|
+
children
|
|
3706
|
+
}) : children
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3709
|
+
// src/components/Modal/index.tsx
|
|
3710
|
+
const MODAL_CLASS = "rn-modal";
|
|
3711
|
+
const RULES$1 = [
|
|
3712
|
+
`.${MODAL_CLASS}{position:fixed;inset:0;z-index:2147483647;box-sizing:border-box;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}`,
|
|
3713
|
+
`.${MODAL_CLASS}[open]{display:flex;flex-direction:column}`,
|
|
3714
|
+
`.${MODAL_CLASS}:not([open]){display:none}`,
|
|
3715
|
+
`.${MODAL_CLASS}:focus{outline:none}`,
|
|
3716
|
+
`.${MODAL_CLASS}[data-closing]{pointer-events:none}`,
|
|
3717
|
+
`@supports selector(::backdrop){.${MODAL_CLASS}::backdrop{background:transparent}}`
|
|
3718
|
+
];
|
|
3719
|
+
const DURATION_MS = 200;
|
|
3720
|
+
const motions = {
|
|
3721
|
+
slide: {
|
|
3722
|
+
property: "transform",
|
|
3723
|
+
hidden: "translateY(100%)",
|
|
3724
|
+
shown: "translateY(0)",
|
|
3725
|
+
easing: "cubic-bezier(0.37, 0, 0.63, 1)"
|
|
3726
|
+
},
|
|
3727
|
+
fade: {
|
|
3728
|
+
property: "opacity",
|
|
3729
|
+
hidden: "0",
|
|
3730
|
+
shown: "1",
|
|
3731
|
+
easing: "cubic-bezier(0.333, 0, 0.667, 0.333)"
|
|
2400
3732
|
}
|
|
2401
3733
|
};
|
|
2402
|
-
const
|
|
2403
|
-
const
|
|
2404
|
-
const
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
3734
|
+
const motionOf = (type) => type === "slide" || type === "fade" ? Platform.isDisableAnimations ? null : motions[type] : null;
|
|
3735
|
+
const animate = (element, motion, to, running) => {
|
|
3736
|
+
const from = running === null ? motion[to === "shown" ? "hidden" : "shown"] : getComputedStyle(element)[motion.property];
|
|
3737
|
+
running?.cancel();
|
|
3738
|
+
return element.animate([{ [motion.property]: from }, { [motion.property]: motion[to] }], {
|
|
3739
|
+
duration: DURATION_MS,
|
|
3740
|
+
easing: motion.easing,
|
|
3741
|
+
fill: to === "hidden" ? "forwards" : "none"
|
|
3742
|
+
});
|
|
2408
3743
|
};
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2411
|
-
|
|
3744
|
+
const HostContext = createContext(null);
|
|
3745
|
+
const createHost = () => {
|
|
3746
|
+
const children = /* @__PURE__ */ new Set();
|
|
3747
|
+
let shown = false;
|
|
3748
|
+
return {
|
|
3749
|
+
add: (child) => {
|
|
3750
|
+
children.add(child);
|
|
3751
|
+
if (shown) child.show();
|
|
3752
|
+
return () => {
|
|
3753
|
+
children.delete(child);
|
|
3754
|
+
};
|
|
3755
|
+
},
|
|
3756
|
+
showChildren: () => {
|
|
3757
|
+
shown = true;
|
|
3758
|
+
for (const child of children) child.show();
|
|
3759
|
+
},
|
|
3760
|
+
hideChildren: () => {
|
|
3761
|
+
shown = false;
|
|
3762
|
+
const list = Array.from(children);
|
|
3763
|
+
for (let index = list.length - 1; index >= 0; index--) list[index]?.hide();
|
|
3764
|
+
}
|
|
3765
|
+
};
|
|
2412
3766
|
};
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
this.longPressTimer = null;
|
|
2428
|
-
this.pressDelayTimer = null;
|
|
2429
|
-
this.pressOutTimer = null;
|
|
2430
|
-
this.config = config;
|
|
2431
|
-
this.handlers = this.createEventHandlers();
|
|
2432
|
-
}
|
|
2433
|
-
configure(config) {
|
|
2434
|
-
this.config = config;
|
|
2435
|
-
}
|
|
2436
|
-
reset() {
|
|
2437
|
-
this.hoverInTimer = clear(this.hoverInTimer);
|
|
2438
|
-
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
2439
|
-
this.longPressTimer = clear(this.longPressTimer);
|
|
2440
|
-
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
2441
|
-
this.pressOutTimer = clear(this.pressOutTimer);
|
|
2442
|
-
this.config = Object.freeze({});
|
|
3767
|
+
const subscribeNothing = () => () => {};
|
|
3768
|
+
const useIsClient = () => useSyncExternalStore(subscribeNothing, () => true, () => false);
|
|
3769
|
+
/**
|
|
3770
|
+
* React Native's `Modal` on a `<dialog>` in the top layer. `showModal()` makes the rest of the
|
|
3771
|
+
* page inert, keeps the focus inside, and turns Escape into `onRequestClose`.
|
|
3772
|
+
*/
|
|
3773
|
+
function Modal(props) {
|
|
3774
|
+
const { visible = true, onDismiss, animationType } = props;
|
|
3775
|
+
const shown = useIsClient() && visible;
|
|
3776
|
+
const [exiting, setExiting] = useState(false);
|
|
3777
|
+
const [lastShown, setLastShown] = useState(shown);
|
|
3778
|
+
if (lastShown !== shown) {
|
|
3779
|
+
setLastShown(shown);
|
|
3780
|
+
setExiting(!shown && animationType != null && animationType !== "none");
|
|
2443
3781
|
}
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
3782
|
+
const mounted = shown || exiting;
|
|
3783
|
+
const onExited = useCallback(() => setExiting(false), []);
|
|
3784
|
+
const dismiss = useRef(onDismiss);
|
|
3785
|
+
const wasMounted = useRef(false);
|
|
3786
|
+
useEffect(() => {
|
|
3787
|
+
dismiss.current = onDismiss;
|
|
3788
|
+
});
|
|
3789
|
+
useEffect(() => {
|
|
3790
|
+
if (wasMounted.current && !mounted) dismiss.current?.();
|
|
3791
|
+
wasMounted.current = mounted;
|
|
3792
|
+
}, [mounted]);
|
|
3793
|
+
return mounted ? createPortal(/* @__PURE__ */ jsx(ModalDialog, {
|
|
3794
|
+
...props,
|
|
3795
|
+
closing: !shown,
|
|
3796
|
+
onExited
|
|
3797
|
+
}), document.body) : null;
|
|
3798
|
+
}
|
|
3799
|
+
function ModalDialog(props) {
|
|
3800
|
+
const { children, style, transparent, backdropColor, onRequestClose, onShow, ref, modalRef, animationType, closing, onExited, visible: _visible, onDismiss: _onDismiss, allowSwipeDismissal: _allowSwipeDismissal, hardwareAccelerated: _hardwareAccelerated, navigationBarTranslucent: _navigationBarTranslucent, onOrientationChange: _onOrientationChange, presentationStyle: _presentationStyle, statusBarTranslucent: _statusBarTranslucent, supportedOrientations: _supportedOrientations, ...rest } = props;
|
|
3801
|
+
const className = useStyleRegistry().staticClass(MODAL_CLASS, RULES$1);
|
|
3802
|
+
const dialog = useRef(null);
|
|
3803
|
+
const open = useRef(false);
|
|
3804
|
+
const announced = useRef(false);
|
|
3805
|
+
const parent = useContext(HostContext);
|
|
3806
|
+
const [host] = useState(createHost);
|
|
3807
|
+
const animation = useRef(null);
|
|
3808
|
+
const latest = useRef({
|
|
3809
|
+
onRequestClose,
|
|
3810
|
+
onShow,
|
|
3811
|
+
onExited,
|
|
3812
|
+
animationType
|
|
3813
|
+
});
|
|
3814
|
+
useLayoutEffect(() => {
|
|
3815
|
+
latest.current = {
|
|
3816
|
+
onRequestClose,
|
|
3817
|
+
onShow,
|
|
3818
|
+
onExited,
|
|
3819
|
+
animationType
|
|
3820
|
+
};
|
|
3821
|
+
});
|
|
3822
|
+
useImperativeHandle(ref, () => dialog.current, []);
|
|
3823
|
+
useImperativeHandle(modalRef, () => dialog.current, []);
|
|
3824
|
+
useLayoutEffect(() => {
|
|
3825
|
+
const element = dialog.current;
|
|
3826
|
+
if (element === null) return;
|
|
3827
|
+
const modal = typeof element.showModal === "function";
|
|
3828
|
+
let focused = null;
|
|
3829
|
+
const layer = {
|
|
3830
|
+
show: () => {
|
|
3831
|
+
if (open.current) return;
|
|
3832
|
+
open.current = true;
|
|
3833
|
+
if (modal) element.showModal();
|
|
2477
3834
|
else {
|
|
2478
|
-
|
|
2479
|
-
|
|
3835
|
+
focused = document.activeElement;
|
|
3836
|
+
element.setAttribute("open", "");
|
|
3837
|
+
element.tabIndex = -1;
|
|
3838
|
+
element.focus();
|
|
2480
3839
|
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
const
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
this.pointerId = null;
|
|
2492
|
-
this.pointerClickPending = false;
|
|
2493
|
-
this.receiveSignal("RESPONDER_TERMINATED", toGestureResponderEvent(event, element));
|
|
2494
|
-
},
|
|
2495
|
-
onClick: (event) => {
|
|
2496
|
-
const native = event.nativeEvent;
|
|
2497
|
-
if (claimed.has(native) || startsInNativeControl(event)) return;
|
|
2498
|
-
if (this.pointerClickPending && event.detail > 0) {
|
|
2499
|
-
this.pointerClickPending = false;
|
|
2500
|
-
claimed.add(native);
|
|
2501
|
-
if (this.cancelClick) event.preventDefault();
|
|
3840
|
+
lockScroll();
|
|
3841
|
+
host.showChildren();
|
|
3842
|
+
const announce = () => {
|
|
3843
|
+
if (announced.current) return;
|
|
3844
|
+
announced.current = true;
|
|
3845
|
+
latest.current.onShow?.({ nativeEvent: null });
|
|
3846
|
+
};
|
|
3847
|
+
const motion = motionOf(latest.current.animationType);
|
|
3848
|
+
if (motion === null || typeof element.animate !== "function") {
|
|
3849
|
+
announce();
|
|
2502
3850
|
return;
|
|
2503
3851
|
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
if (event.target !== element || this.config.disabled === true) return;
|
|
2512
|
-
if (hasNativeActivation(element)) return;
|
|
2513
|
-
if (event.key === " ") event.preventDefault();
|
|
2514
|
-
if (this.pointerId !== null || this.key !== null) return;
|
|
2515
|
-
this.key = event.key;
|
|
2516
|
-
this.grant(element, toGestureResponderEvent(event, element));
|
|
2517
|
-
},
|
|
2518
|
-
onKeyUp: (event) => {
|
|
2519
|
-
const element = this.element;
|
|
2520
|
-
if (event.key !== this.key || element === null) return;
|
|
2521
|
-
this.key = null;
|
|
2522
|
-
this.receiveSignal("RESPONDER_RELEASE", toGestureResponderEvent(event, element));
|
|
2523
|
-
},
|
|
2524
|
-
onFocus: (event) => {
|
|
2525
|
-
this.config.onFocus?.(event);
|
|
3852
|
+
const next = animate(element, motion, "shown", null);
|
|
3853
|
+
animation.current = next;
|
|
3854
|
+
next.onfinish = () => {
|
|
3855
|
+
if (animation.current !== next) return;
|
|
3856
|
+
animation.current = null;
|
|
3857
|
+
announce();
|
|
3858
|
+
};
|
|
2526
3859
|
},
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
3860
|
+
hide: () => {
|
|
3861
|
+
if (!open.current) return;
|
|
3862
|
+
open.current = false;
|
|
3863
|
+
animation.current?.cancel();
|
|
3864
|
+
animation.current = null;
|
|
3865
|
+
host.hideChildren();
|
|
3866
|
+
if (modal) element.close();
|
|
3867
|
+
else {
|
|
3868
|
+
element.removeAttribute("open");
|
|
3869
|
+
if (focused instanceof HTMLElement && focused.isConnected) focused.focus();
|
|
2532
3870
|
}
|
|
2533
|
-
|
|
2534
|
-
},
|
|
2535
|
-
onPointerEnter: (event) => {
|
|
2536
|
-
if (event.pointerType === "touch") return;
|
|
2537
|
-
this.hovered = true;
|
|
2538
|
-
this.hoverOutTimer = clear(this.hoverOutTimer);
|
|
2539
|
-
this.hover(event, this.config.onHoverIn, this.config.delayHoverIn, "in");
|
|
2540
|
-
},
|
|
2541
|
-
onPointerLeave: (event) => {
|
|
2542
|
-
if (!this.hovered) return;
|
|
2543
|
-
this.hovered = false;
|
|
2544
|
-
this.hoverInTimer = clear(this.hoverInTimer);
|
|
2545
|
-
this.hover(event, this.config.onHoverOut, this.config.delayHoverOut, "out");
|
|
2546
|
-
},
|
|
2547
|
-
onContextMenu: (event) => {
|
|
2548
|
-
if (this.pointerId !== null && this.config.onLongPress != null) event.preventDefault();
|
|
3871
|
+
unlockScroll();
|
|
2549
3872
|
}
|
|
2550
3873
|
};
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
callback(hoverEvent);
|
|
2558
|
-
return;
|
|
2559
|
-
}
|
|
2560
|
-
const timer = setTimeout(() => callback(hoverEvent), wait);
|
|
2561
|
-
if (direction === "in") this.hoverInTimer = timer;
|
|
2562
|
-
else this.hoverOutTimer = timer;
|
|
2563
|
-
}
|
|
2564
|
-
grant(element, event) {
|
|
2565
|
-
this.pressOutTimer = clear(this.pressOutTimer);
|
|
2566
|
-
this.element = element;
|
|
2567
|
-
this.cancelClick = false;
|
|
2568
|
-
this.state = "NOT_RESPONDER";
|
|
2569
|
-
this.receiveSignal("RESPONDER_GRANT", event);
|
|
2570
|
-
const delayPressIn = normalizeDelay(this.config.delayPressIn);
|
|
2571
|
-
if (delayPressIn > 0) this.pressDelayTimer = setTimeout(() => this.receiveSignal("DELAY", event), delayPressIn);
|
|
2572
|
-
else this.receiveSignal("DELAY", event);
|
|
2573
|
-
const delayLongPress = normalizeDelay(this.config.delayLongPress, 10, DEFAULT_LONG_PRESS_DELAY_MS - delayPressIn);
|
|
2574
|
-
this.longPressTimer = setTimeout(() => {
|
|
2575
|
-
if (this.state === "RESPONDER_ACTIVE_PRESS_IN" || this.state === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.receiveSignal("LONG_PRESS_DETECTED", event);
|
|
2576
|
-
}, delayLongPress + delayPressIn);
|
|
2577
|
-
}
|
|
2578
|
-
receiveSignal(signal, event) {
|
|
2579
|
-
const prevState = this.state;
|
|
2580
|
-
const nextState = transitions[prevState][signal];
|
|
2581
|
-
if (nextState === void 0 || nextState === prevState) return;
|
|
2582
|
-
this.performTransitionSideEffects(prevState, nextState, signal, event);
|
|
2583
|
-
this.state = nextState;
|
|
2584
|
-
}
|
|
2585
|
-
performTransitionSideEffects(prevState, nextState, signal, event) {
|
|
2586
|
-
if (isTerminal(signal)) {
|
|
2587
|
-
this.activatePosition = null;
|
|
2588
|
-
this.longPressTimer = clear(this.longPressTimer);
|
|
2589
|
-
}
|
|
2590
|
-
const isInitialTransition = prevState === "NOT_RESPONDER" && nextState === "RESPONDER_INACTIVE_PRESS_IN";
|
|
2591
|
-
const isActivationTransition = !isActivation(prevState) && isActivation(nextState);
|
|
2592
|
-
if (isInitialTransition || isActivationTransition) this.measureRegion();
|
|
2593
|
-
if (isPressIn(prevState) && signal === "LONG_PRESS_DETECTED") this.config.onLongPress?.(event);
|
|
2594
|
-
const isPrevActive = isActive(prevState);
|
|
2595
|
-
const isNextActive = isActive(nextState);
|
|
2596
|
-
if (!isPrevActive && isNextActive) this.activate(event);
|
|
2597
|
-
else if (isPrevActive && !isNextActive) this.deactivate(event);
|
|
2598
|
-
if (isPressIn(prevState) && signal === "RESPONDER_RELEASE") {
|
|
2599
|
-
if (!isNextActive && !isPrevActive) {
|
|
2600
|
-
this.activate(event);
|
|
2601
|
-
this.deactivate(event);
|
|
2602
|
-
}
|
|
2603
|
-
const { onLongPress, onPress } = this.config;
|
|
2604
|
-
if (onLongPress != null && prevState === "RESPONDER_ACTIVE_LONG_PRESS_IN") this.cancelClick = true;
|
|
2605
|
-
else if (onPress != null) {
|
|
2606
|
-
onPress(event);
|
|
2607
|
-
if (event.isDefaultPrevented()) this.cancelClick = true;
|
|
2608
|
-
}
|
|
2609
|
-
}
|
|
2610
|
-
this.pressDelayTimer = clear(this.pressDelayTimer);
|
|
2611
|
-
}
|
|
2612
|
-
activate(event) {
|
|
2613
|
-
const { pageX, pageY } = event.nativeEvent;
|
|
2614
|
-
this.activatePosition = {
|
|
2615
|
-
pageX,
|
|
2616
|
-
pageY
|
|
3874
|
+
let remove;
|
|
3875
|
+
if (parent === null) layer.show();
|
|
3876
|
+
else remove = parent.add(layer);
|
|
3877
|
+
return () => {
|
|
3878
|
+
remove?.();
|
|
3879
|
+
layer.hide();
|
|
2617
3880
|
};
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
3881
|
+
}, [host, parent]);
|
|
3882
|
+
const wasClosing = useRef(false);
|
|
3883
|
+
useLayoutEffect(() => {
|
|
3884
|
+
const element = dialog.current;
|
|
3885
|
+
if (element === null || closing === wasClosing.current) return;
|
|
3886
|
+
wasClosing.current = closing;
|
|
3887
|
+
const motion = motionOf(latest.current.animationType);
|
|
3888
|
+
const canAnimate = motion !== null && typeof element.animate === "function";
|
|
3889
|
+
if (closing) {
|
|
3890
|
+
host.hideChildren();
|
|
3891
|
+
if (!canAnimate) {
|
|
3892
|
+
latest.current.onExited();
|
|
3893
|
+
return;
|
|
3894
|
+
}
|
|
3895
|
+
const next = animate(element, motion, "hidden", animation.current);
|
|
3896
|
+
animation.current = next;
|
|
3897
|
+
next.onfinish = () => {
|
|
3898
|
+
if (animation.current === next) latest.current.onExited();
|
|
3899
|
+
};
|
|
3900
|
+
return;
|
|
2629
3901
|
}
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
this.region = {
|
|
2637
|
-
bottom: rect.bottom + window.scrollY,
|
|
2638
|
-
left: rect.left + window.scrollX,
|
|
2639
|
-
right: rect.right + window.scrollX,
|
|
2640
|
-
top: rect.top + window.scrollY
|
|
3902
|
+
host.showChildren();
|
|
3903
|
+
if (!canAnimate || animation.current === null) return;
|
|
3904
|
+
const next = animate(element, motion, "shown", animation.current);
|
|
3905
|
+
animation.current = next;
|
|
3906
|
+
next.onfinish = () => {
|
|
3907
|
+
if (animation.current === next) animation.current = null;
|
|
2641
3908
|
};
|
|
2642
|
-
}
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
const
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
3909
|
+
}, [closing, host]);
|
|
3910
|
+
const requestClose = () => {
|
|
3911
|
+
latest.current.onRequestClose?.({ nativeEvent: null });
|
|
3912
|
+
};
|
|
3913
|
+
const handleCancel = (event) => {
|
|
3914
|
+
if (event.target !== event.currentTarget) return;
|
|
3915
|
+
event.preventDefault();
|
|
3916
|
+
if (!closing) requestClose();
|
|
3917
|
+
};
|
|
3918
|
+
const handleClose = (event) => {
|
|
3919
|
+
const element = event.currentTarget;
|
|
3920
|
+
if (event.target === element && open.current && !element.open) element.showModal();
|
|
3921
|
+
};
|
|
3922
|
+
const domProps = toDOMProps(rest);
|
|
3923
|
+
const appPointerDown = domProps["onPointerDown"];
|
|
3924
|
+
const appClick = domProps["onClick"];
|
|
3925
|
+
const appKeyDown = domProps["onKeyDown"];
|
|
3926
|
+
const containerStyle = transparent ? styles$1.transparent : backdropColor != null ? { backgroundColor: backdropColor } : void 0;
|
|
3927
|
+
return /* @__PURE__ */ jsx("dialog", {
|
|
3928
|
+
...domProps,
|
|
3929
|
+
ref: dialog,
|
|
3930
|
+
className,
|
|
3931
|
+
"data-closing": closing ? "" : void 0,
|
|
3932
|
+
onCancel: handleCancel,
|
|
3933
|
+
onClose: handleClose,
|
|
3934
|
+
onPointerDown: (event) => {
|
|
3935
|
+
appPointerDown?.(event);
|
|
3936
|
+
claimPress(event.nativeEvent);
|
|
3937
|
+
},
|
|
3938
|
+
onClick: (event) => {
|
|
3939
|
+
appClick?.(event);
|
|
3940
|
+
claimPress(event.nativeEvent);
|
|
3941
|
+
},
|
|
3942
|
+
onKeyDown: (event) => {
|
|
3943
|
+
appKeyDown?.(event);
|
|
3944
|
+
const element = event.currentTarget;
|
|
3945
|
+
if (event.key === "Escape" && typeof element.showModal !== "function" && event.target.closest("dialog") === element) requestClose();
|
|
3946
|
+
},
|
|
3947
|
+
children: /* @__PURE__ */ jsx(HostContext.Provider, {
|
|
3948
|
+
value: host,
|
|
3949
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
3950
|
+
style: [
|
|
3951
|
+
styles$1.container,
|
|
3952
|
+
style,
|
|
3953
|
+
containerStyle
|
|
3954
|
+
],
|
|
3955
|
+
children
|
|
3956
|
+
})
|
|
3957
|
+
})
|
|
3958
|
+
});
|
|
2665
3959
|
}
|
|
3960
|
+
const styles$1 = StyleSheet.create({
|
|
3961
|
+
container: {
|
|
3962
|
+
flex: 1,
|
|
3963
|
+
backgroundColor: "white"
|
|
3964
|
+
},
|
|
3965
|
+
transparent: { backgroundColor: "transparent" }
|
|
3966
|
+
});
|
|
2666
3967
|
// src/components/Pressable/index.tsx
|
|
2667
|
-
const notCancelableStyle = Object.freeze({ touchAction: "none" });
|
|
2668
|
-
const hitSlopClass = (registry, hitSlop) => {
|
|
2669
|
-
if (hitSlop === void 0) return void 0;
|
|
2670
|
-
const { top = 0, right = 0, bottom = 0, left = 0 } = typeof hitSlop === "number" ? {
|
|
2671
|
-
top: hitSlop,
|
|
2672
|
-
right: hitSlop,
|
|
2673
|
-
bottom: hitSlop,
|
|
2674
|
-
left: hitSlop
|
|
2675
|
-
} : hitSlop;
|
|
2676
|
-
if (top === 0 && right === 0 && bottom === 0 && left === 0) return void 0;
|
|
2677
|
-
const name = `rn-hs-${[
|
|
2678
|
-
top,
|
|
2679
|
-
right,
|
|
2680
|
-
bottom,
|
|
2681
|
-
left
|
|
2682
|
-
].map((n) => String(n).replace(/[^0-9]/g, "_")).join("-")}`;
|
|
2683
|
-
return registry.staticClass(name, [`.${name}::before{content:"";position:absolute;top:${-top}px;right:${-right}px;bottom:${-bottom}px;left:${-left}px;z-index:-1}`]);
|
|
2684
|
-
};
|
|
3968
|
+
const notCancelableStyle$1 = Object.freeze({ touchAction: "none" });
|
|
2685
3969
|
const isFocusVisible = (element) => {
|
|
2686
3970
|
try {
|
|
2687
3971
|
return element.matches(":focus-visible");
|
|
@@ -2689,31 +3973,6 @@ const isFocusVisible = (element) => {
|
|
|
2689
3973
|
return true;
|
|
2690
3974
|
}
|
|
2691
3975
|
};
|
|
2692
|
-
const sharedHandlers = [
|
|
2693
|
-
"onClick",
|
|
2694
|
-
"onContextMenu",
|
|
2695
|
-
"onKeyDown",
|
|
2696
|
-
"onKeyUp",
|
|
2697
|
-
"onPointerCancel",
|
|
2698
|
-
"onPointerDown",
|
|
2699
|
-
"onPointerEnter",
|
|
2700
|
-
"onPointerLeave",
|
|
2701
|
-
"onPointerMove",
|
|
2702
|
-
"onPointerUp"
|
|
2703
|
-
];
|
|
2704
|
-
const mergeHandlers = (app, own) => {
|
|
2705
|
-
const merged = { ...own };
|
|
2706
|
-
for (const key of sharedHandlers) {
|
|
2707
|
-
const first = app[key];
|
|
2708
|
-
if (first === void 0) continue;
|
|
2709
|
-
const second = own[key];
|
|
2710
|
-
merged[key] = (event) => {
|
|
2711
|
-
first(event);
|
|
2712
|
-
second(event);
|
|
2713
|
-
};
|
|
2714
|
-
}
|
|
2715
|
-
return merged;
|
|
2716
|
-
};
|
|
2717
3976
|
const Pressable = memo(function Pressable(props) {
|
|
2718
3977
|
const { android_disableSound, android_ripple: _androidRipple, blockNativeResponder, cancelable, children, delayHoverIn, delayHoverOut, delayLongPress, disabled, focusable, hitSlop, onBlur, onFocus, onHoverIn, onHoverOut, onLongPress, onPress, onPressIn, onPressMove, onPressOut, pressRetentionOffset, style, testOnly_pressed, unstable_pressDelay, ...rest } = props;
|
|
2719
3978
|
const [pressed, setPressed] = useState(false);
|
|
@@ -2790,7 +4049,7 @@ const Pressable = memo(function Pressable(props) {
|
|
|
2790
4049
|
...rest,
|
|
2791
4050
|
...mergeHandlers(rest, handlers),
|
|
2792
4051
|
focusable: disabled !== true && focusable !== false,
|
|
2793
|
-
style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle],
|
|
4052
|
+
style: [typeof style === "function" ? style(state) : style, cancelable === false && notCancelableStyle$1],
|
|
2794
4053
|
children: typeof children === "function" ? children(state) : children
|
|
2795
4054
|
};
|
|
2796
4055
|
if (disabled === true) viewProps["aria-disabled"] = true;
|
|
@@ -2903,91 +4162,86 @@ const StatusBar = Object.assign(StatusBarComponent, {
|
|
|
2903
4162
|
popStackEntry,
|
|
2904
4163
|
replaceStackEntry
|
|
2905
4164
|
});
|
|
2906
|
-
// src/components/
|
|
2907
|
-
const
|
|
2908
|
-
|
|
2909
|
-
const
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
const
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
const
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
}
|
|
2938
|
-
const
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
const
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
}
|
|
2976
|
-
disabled,
|
|
2977
|
-
onClick,
|
|
2978
|
-
onPress
|
|
2979
|
-
]);
|
|
2980
|
-
const domProps = toDOMProps(rest);
|
|
2981
|
-
if (role !== void 0) domProps["role"] = role;
|
|
2982
|
-
if (tag.length === 2 && tag[0] === "h") delete domProps["aria-level"];
|
|
2983
|
-
if (tag === "button") domProps["type"] = "button";
|
|
2984
|
-
if (disabled === true) domProps["aria-disabled"] = true;
|
|
2985
|
-
if (onPress !== void 0 || onClick !== void 0) domProps["onClick"] = handleClick;
|
|
2986
|
-
domProps["className"] = className;
|
|
2987
|
-
domProps["ref"] = element;
|
|
2988
|
-
const content = nested ? children : createElement(TextAncestorContext.Provider, { value: true }, children);
|
|
2989
|
-
return createElement(tag, domProps, content);
|
|
4165
|
+
// src/components/Switch/index.tsx
|
|
4166
|
+
const TRACK_OFF = "#939393";
|
|
4167
|
+
const TRACK_ON = "#A3D3CF";
|
|
4168
|
+
const THUMB_OFF = "#FAFAFA";
|
|
4169
|
+
const THUMB_ON = "#009688";
|
|
4170
|
+
const INPUT_CLASS = "rn-switch-input";
|
|
4171
|
+
const RULES = [
|
|
4172
|
+
`.${INPUT_CLASS}{position:absolute;inset:0;width:100%;height:100%;margin:0;padding:0;opacity:0;cursor:pointer;z-index:1}`,
|
|
4173
|
+
`.${INPUT_CLASS}:disabled{cursor:default}`,
|
|
4174
|
+
".rn-switch-track{height:70%;border-radius:9999px;transition:background-color .15s}",
|
|
4175
|
+
".rn-switch-row{position:absolute;inset:0;display:flex;border-radius:9999px}",
|
|
4176
|
+
".rn-switch-spacer{flex-grow:0;transition:flex-grow .15s}",
|
|
4177
|
+
".rn-switch-thumb{height:100%;aspect-ratio:1;border-radius:50%;box-shadow:0 1px 3px rgba(0,0,0,.5);transition:background-color .15s}",
|
|
4178
|
+
`.${INPUT_CLASS}:checked~.rn-switch-row>.rn-switch-spacer{flex-grow:1}`,
|
|
4179
|
+
`.${INPUT_CLASS}:focus-visible~.rn-switch-row{outline:auto;outline-offset:2px}`,
|
|
4180
|
+
"@media (prefers-reduced-motion:reduce){.rn-switch-track,.rn-switch-spacer,.rn-switch-thumb{transition:none}}"
|
|
4181
|
+
];
|
|
4182
|
+
function Switch(props) {
|
|
4183
|
+
const { accessibilityRole, accessibilityState, disabled, ios_backgroundColor: _iosBackgroundColor, onChange, onLayout, onTintColor: _onTintColor, onValueChange, pointerEvents, ref, role, style, thumbColor, thumbTintColor: _thumbTintColor, tintColor: _tintColor, trackColor, value, ...rest } = props;
|
|
4184
|
+
const inputClass = useStyleRegistry().staticClass(INPUT_CLASS, RULES);
|
|
4185
|
+
const on = value === true;
|
|
4186
|
+
const resolvedDisabled = disabled ?? accessibilityState?.disabled;
|
|
4187
|
+
const state = resolvedDisabled === accessibilityState?.disabled ? accessibilityState : {
|
|
4188
|
+
...accessibilityState,
|
|
4189
|
+
disabled: resolvedDisabled
|
|
4190
|
+
};
|
|
4191
|
+
const handleChange = (event) => {
|
|
4192
|
+
const next = event.target.checked;
|
|
4193
|
+
Object.assign(event.nativeEvent, { value: next });
|
|
4194
|
+
onChange?.(event);
|
|
4195
|
+
onValueChange?.(next);
|
|
4196
|
+
};
|
|
4197
|
+
const inputProps = toDOMProps({
|
|
4198
|
+
...rest,
|
|
4199
|
+
accessibilityState: state
|
|
4200
|
+
});
|
|
4201
|
+
inputProps["role"] = role ?? accessibilityRole ?? "switch";
|
|
4202
|
+
const track = toCSSColor(on ? trackColor?.true : trackColor?.false) ?? (on ? TRACK_ON : TRACK_OFF);
|
|
4203
|
+
const thumb = toCSSColor(thumbColor) ?? (on ? THUMB_ON : THUMB_OFF);
|
|
4204
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
4205
|
+
onLayout,
|
|
4206
|
+
pointerEvents,
|
|
4207
|
+
style: [
|
|
4208
|
+
styles.root,
|
|
4209
|
+
style,
|
|
4210
|
+
resolvedDisabled === true && styles.disabled
|
|
4211
|
+
],
|
|
4212
|
+
children: [
|
|
4213
|
+
/* @__PURE__ */ jsx("input", {
|
|
4214
|
+
...inputProps,
|
|
4215
|
+
checked: on,
|
|
4216
|
+
className: inputClass,
|
|
4217
|
+
disabled: resolvedDisabled === true,
|
|
4218
|
+
onChange: handleChange,
|
|
4219
|
+
ref,
|
|
4220
|
+
type: "checkbox"
|
|
4221
|
+
}),
|
|
4222
|
+
/* @__PURE__ */ jsx("div", {
|
|
4223
|
+
className: "rn-switch-track",
|
|
4224
|
+
style: { backgroundColor: track }
|
|
4225
|
+
}),
|
|
4226
|
+
/* @__PURE__ */ jsxs("div", {
|
|
4227
|
+
className: "rn-switch-row",
|
|
4228
|
+
children: [/* @__PURE__ */ jsx("div", { className: "rn-switch-spacer" }), /* @__PURE__ */ jsx("div", {
|
|
4229
|
+
className: "rn-switch-thumb",
|
|
4230
|
+
style: { backgroundColor: thumb }
|
|
4231
|
+
})]
|
|
4232
|
+
})
|
|
4233
|
+
]
|
|
4234
|
+
});
|
|
2990
4235
|
}
|
|
4236
|
+
const styles = StyleSheet.create({
|
|
4237
|
+
root: {
|
|
4238
|
+
alignSelf: "flex-start",
|
|
4239
|
+
width: 40,
|
|
4240
|
+
height: 20,
|
|
4241
|
+
justifyContent: "center"
|
|
4242
|
+
},
|
|
4243
|
+
disabled: { opacity: .5 }
|
|
4244
|
+
});
|
|
2991
4245
|
// src/components/TextInput/autocomplete.ts
|
|
2992
4246
|
const reactNativeToHTML = {
|
|
2993
4247
|
"address-line1": "address-line1",
|
|
@@ -3294,7 +4548,7 @@ function TextInputComponent(props) {
|
|
|
3294
4548
|
}, [wantsContentSize, reportContentSize]);
|
|
3295
4549
|
useImperativeHandle(ref, () => {
|
|
3296
4550
|
const element = field.current;
|
|
3297
|
-
return Object.assign(element, {
|
|
4551
|
+
return Object.assign(withHostMethods(element), {
|
|
3298
4552
|
clear: () => {
|
|
3299
4553
|
element.value = "";
|
|
3300
4554
|
grow(element);
|
|
@@ -3302,11 +4556,10 @@ function TextInputComponent(props) {
|
|
|
3302
4556
|
},
|
|
3303
4557
|
isFocused: () => document.activeElement === element,
|
|
3304
4558
|
getNativeRef: () => element,
|
|
3305
|
-
setNativeProps: (
|
|
3306
|
-
if (
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
}
|
|
4559
|
+
setNativeProps: ({ text, ...others }) => {
|
|
4560
|
+
if (text !== void 0) element.value = text;
|
|
4561
|
+
applyNativeProps(element, others);
|
|
4562
|
+
grow(element);
|
|
3310
4563
|
}
|
|
3311
4564
|
});
|
|
3312
4565
|
}, [grow]);
|
|
@@ -3316,12 +4569,7 @@ function TextInputComponent(props) {
|
|
|
3316
4569
|
if (caretHidden === true) colorStyle["caretColor"] = "transparent";
|
|
3317
4570
|
else if (caret !== void 0) colorStyle["caretColor"] = caret;
|
|
3318
4571
|
if (textAlign !== void 0) colorStyle["textAlign"] = textAlign;
|
|
3319
|
-
let className = compileStyle([
|
|
3320
|
-
resetStyle,
|
|
3321
|
-
multiline && textareaStyle,
|
|
3322
|
-
flat,
|
|
3323
|
-
colorStyle
|
|
3324
|
-
], registry);
|
|
4572
|
+
let className = joinClassNames(compileReset("rn-text-input", resetStyle, registry), multiline === true && compileReset("rn-text-input-multiline", textareaStyle, registry), compileStyle([flat, colorStyle], registry));
|
|
3325
4573
|
const placeholderName = placeholderClass(registry, placeholderTextColor);
|
|
3326
4574
|
if (placeholderName !== void 0) className = `${className} ${placeholderName}`;
|
|
3327
4575
|
const selectionName = selectionClass(registry, selectionColor);
|
|
@@ -3370,6 +4618,248 @@ const TextInput = Object.assign(TextInputComponent, { State: {
|
|
|
3370
4618
|
focusTextInput: (input) => input?.focus(),
|
|
3371
4619
|
blurTextInput: (input) => input?.blur()
|
|
3372
4620
|
} });
|
|
3373
|
-
|
|
4621
|
+
// src/components/TouchableHighlight/index.tsx
|
|
4622
|
+
const DEFAULT_ACTIVE_OPACITY = .85;
|
|
4623
|
+
const DEFAULT_UNDERLAY_COLOR = "black";
|
|
4624
|
+
const notCancelableStyle = Object.freeze({ touchAction: "none" });
|
|
4625
|
+
function TouchableHighlight(props) {
|
|
4626
|
+
const { activeOpacity, children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hasTVPreferredFocus: _hasTVPreferredFocus, hitSlop, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, onBlur, onFocus, onHideUnderlay, onLongPress, onPress, onPressIn, onPressOut, onShowUnderlay, pressRetentionOffset, rejectResponderTermination, style, testOnly_pressed, touchSoundDisabled, underlayColor, ...rest } = props;
|
|
4627
|
+
const [underlay, setUnderlay] = useState(false);
|
|
4628
|
+
const hideTimer = useRef(null);
|
|
4629
|
+
const resolvedDisabled = disabled ?? props.accessibilityState?.disabled;
|
|
4630
|
+
const hasPressHandler = onPress != null || onPressIn != null || onPressOut != null || onLongPress != null;
|
|
4631
|
+
const handlers = usePressability(useMemo(() => {
|
|
4632
|
+
const clearHideTimer = () => {
|
|
4633
|
+
if (hideTimer.current !== null) clearTimeout(hideTimer.current);
|
|
4634
|
+
hideTimer.current = null;
|
|
4635
|
+
};
|
|
4636
|
+
const show = () => {
|
|
4637
|
+
if (!hasPressHandler) return;
|
|
4638
|
+
setUnderlay(true);
|
|
4639
|
+
onShowUnderlay?.();
|
|
4640
|
+
};
|
|
4641
|
+
const hide = () => {
|
|
4642
|
+
clearHideTimer();
|
|
4643
|
+
if (testOnly_pressed === true || !hasPressHandler) return;
|
|
4644
|
+
setUnderlay(false);
|
|
4645
|
+
onHideUnderlay?.();
|
|
4646
|
+
};
|
|
4647
|
+
return {
|
|
4648
|
+
cancelable: rejectResponderTermination !== true,
|
|
4649
|
+
disabled: resolvedDisabled,
|
|
4650
|
+
hitSlop,
|
|
4651
|
+
delayLongPress,
|
|
4652
|
+
delayPressIn,
|
|
4653
|
+
delayPressOut,
|
|
4654
|
+
minPressDuration: 0,
|
|
4655
|
+
pressRectOffset: pressRetentionOffset,
|
|
4656
|
+
android_disableSound: touchSoundDisabled,
|
|
4657
|
+
onBlur,
|
|
4658
|
+
onFocus,
|
|
4659
|
+
onLongPress,
|
|
4660
|
+
onPress: (event) => {
|
|
4661
|
+
clearHideTimer();
|
|
4662
|
+
show();
|
|
4663
|
+
hideTimer.current = setTimeout(hide, delayPressOut ?? 0);
|
|
4664
|
+
onPress?.(event);
|
|
4665
|
+
},
|
|
4666
|
+
onPressIn: (event) => {
|
|
4667
|
+
clearHideTimer();
|
|
4668
|
+
show();
|
|
4669
|
+
onPressIn?.(event);
|
|
4670
|
+
},
|
|
4671
|
+
onPressOut: (event) => {
|
|
4672
|
+
if (hideTimer.current === null) hide();
|
|
4673
|
+
onPressOut?.(event);
|
|
4674
|
+
}
|
|
4675
|
+
};
|
|
4676
|
+
}, [
|
|
4677
|
+
delayLongPress,
|
|
4678
|
+
delayPressIn,
|
|
4679
|
+
delayPressOut,
|
|
4680
|
+
hasPressHandler,
|
|
4681
|
+
hitSlop,
|
|
4682
|
+
onBlur,
|
|
4683
|
+
onFocus,
|
|
4684
|
+
onHideUnderlay,
|
|
4685
|
+
onLongPress,
|
|
4686
|
+
onPress,
|
|
4687
|
+
onPressIn,
|
|
4688
|
+
onPressOut,
|
|
4689
|
+
onShowUnderlay,
|
|
4690
|
+
pressRetentionOffset,
|
|
4691
|
+
rejectResponderTermination,
|
|
4692
|
+
resolvedDisabled,
|
|
4693
|
+
testOnly_pressed,
|
|
4694
|
+
touchSoundDisabled
|
|
4695
|
+
]));
|
|
4696
|
+
const registry = useStyleRegistry();
|
|
4697
|
+
useEffect(() => () => {
|
|
4698
|
+
if (hideTimer.current !== null) clearTimeout(hideTimer.current);
|
|
4699
|
+
}, []);
|
|
4700
|
+
const pressed = underlay || testOnly_pressed === true;
|
|
4701
|
+
const child = Children.only(children);
|
|
4702
|
+
if (child.type === Fragment) warnOnce("TouchableHighlight-fragment", "TouchableHighlight does not support a Fragment as its child. Wrap the children in one View.");
|
|
4703
|
+
const content = child.type === Fragment ? child : cloneElement(child, { style: [child.props.style, pressed && { opacity: activeOpacity ?? DEFAULT_ACTIVE_OPACITY }] });
|
|
4704
|
+
return useViewElement({
|
|
4705
|
+
...rest,
|
|
4706
|
+
...mergeHandlers(rest, handlers),
|
|
4707
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true,
|
|
4708
|
+
style: [
|
|
4709
|
+
style,
|
|
4710
|
+
pressed && { backgroundColor: underlayColor ?? DEFAULT_UNDERLAY_COLOR },
|
|
4711
|
+
rejectResponderTermination === true && notCancelableStyle
|
|
4712
|
+
],
|
|
4713
|
+
children: content,
|
|
4714
|
+
...resolvedDisabled === true && { "aria-disabled": true }
|
|
4715
|
+
}, hitSlopClass(registry, hitSlop));
|
|
4716
|
+
}
|
|
4717
|
+
// src/components/TouchableWithoutFeedback/index.tsx
|
|
4718
|
+
const isTrue = (value) => value === void 0 ? void 0 : value === true || value === "true";
|
|
4719
|
+
function TouchableWithoutFeedback(props) {
|
|
4720
|
+
const { children, delayLongPress, delayPressIn, delayPressOut, disabled, focusable, hitSlop, onBlur, onFocus, onLongPress, onPress, onPressIn, onPressOut, pressRetentionOffset, rejectResponderTermination, style: _style, touchSoundDisabled, ...rest } = props;
|
|
4721
|
+
const resolvedDisabled = disabled ?? isTrue(props["aria-disabled"]) ?? props.accessibilityState?.disabled;
|
|
4722
|
+
const handlers = usePressability(useMemo(() => ({
|
|
4723
|
+
cancelable: rejectResponderTermination !== true,
|
|
4724
|
+
disabled: resolvedDisabled,
|
|
4725
|
+
hitSlop,
|
|
4726
|
+
delayLongPress,
|
|
4727
|
+
delayPressIn,
|
|
4728
|
+
delayPressOut,
|
|
4729
|
+
minPressDuration: 0,
|
|
4730
|
+
pressRectOffset: pressRetentionOffset,
|
|
4731
|
+
android_disableSound: touchSoundDisabled,
|
|
4732
|
+
onBlur,
|
|
4733
|
+
onFocus,
|
|
4734
|
+
onLongPress,
|
|
4735
|
+
onPress,
|
|
4736
|
+
onPressIn,
|
|
4737
|
+
onPressOut
|
|
4738
|
+
}), [
|
|
4739
|
+
delayLongPress,
|
|
4740
|
+
delayPressIn,
|
|
4741
|
+
delayPressOut,
|
|
4742
|
+
hitSlop,
|
|
4743
|
+
onBlur,
|
|
4744
|
+
onFocus,
|
|
4745
|
+
onLongPress,
|
|
4746
|
+
onPress,
|
|
4747
|
+
onPressIn,
|
|
4748
|
+
onPressOut,
|
|
4749
|
+
pressRetentionOffset,
|
|
4750
|
+
rejectResponderTermination,
|
|
4751
|
+
resolvedDisabled,
|
|
4752
|
+
touchSoundDisabled
|
|
4753
|
+
]));
|
|
4754
|
+
const element = Children.only(children);
|
|
4755
|
+
const passed = {};
|
|
4756
|
+
for (const [name, value] of Object.entries(rest)) if (value !== void 0) passed[name] = value;
|
|
4757
|
+
if (hitSlop !== void 0) passed["hitSlop"] = hitSlop;
|
|
4758
|
+
if (disabled != null) passed["accessibilityState"] = {
|
|
4759
|
+
...rest.accessibilityState,
|
|
4760
|
+
disabled
|
|
4761
|
+
};
|
|
4762
|
+
const merged = mergeHandlers(element.props, handlers);
|
|
4763
|
+
const childFocus = onFocus === void 0 ? element.props.onFocus : void 0;
|
|
4764
|
+
const childBlur = onBlur === void 0 ? element.props.onBlur : void 0;
|
|
4765
|
+
return cloneElement(element, {
|
|
4766
|
+
...passed,
|
|
4767
|
+
...merged,
|
|
4768
|
+
onFocus: childFocus === void 0 ? merged.onFocus : (event) => {
|
|
4769
|
+
merged.onFocus(event);
|
|
4770
|
+
childFocus(event);
|
|
4771
|
+
},
|
|
4772
|
+
onBlur: childBlur === void 0 ? merged.onBlur : (event) => {
|
|
4773
|
+
merged.onBlur(event);
|
|
4774
|
+
childBlur(event);
|
|
4775
|
+
},
|
|
4776
|
+
accessible: rest.accessible !== false,
|
|
4777
|
+
focusable: focusable !== false && onPress !== void 0 && disabled !== true
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4780
|
+
// src/components/TouchableNativeFeedback/index.tsx
|
|
4781
|
+
const TouchableNativeFeedback = Object.assign(function TouchableNativeFeedback(props) {
|
|
4782
|
+
const { background: _background, hasTVPreferredFocus: _hasTVPreferredFocus, nextFocusDown: _nextFocusDown, nextFocusForward: _nextFocusForward, nextFocusLeft: _nextFocusLeft, nextFocusRight: _nextFocusRight, nextFocusUp: _nextFocusUp, useForeground: _useForeground, ...rest } = props;
|
|
4783
|
+
return createElement(TouchableWithoutFeedback, rest);
|
|
4784
|
+
}, {
|
|
4785
|
+
SelectableBackground: (rippleRadius) => ({
|
|
4786
|
+
type: "ThemeAttrAndroid",
|
|
4787
|
+
attribute: "selectableItemBackground",
|
|
4788
|
+
rippleRadius
|
|
4789
|
+
}),
|
|
4790
|
+
SelectableBackgroundBorderless: (rippleRadius) => ({
|
|
4791
|
+
type: "ThemeAttrAndroid",
|
|
4792
|
+
attribute: "selectableItemBackgroundBorderless",
|
|
4793
|
+
rippleRadius
|
|
4794
|
+
}),
|
|
4795
|
+
Ripple: (color, borderless, rippleRadius) => ({
|
|
4796
|
+
type: "RippleAndroid",
|
|
4797
|
+
color: processColor(color),
|
|
4798
|
+
borderless,
|
|
4799
|
+
rippleRadius
|
|
4800
|
+
}),
|
|
4801
|
+
canUseNativeForeground: () => false
|
|
4802
|
+
});
|
|
4803
|
+
// src/compat/createElement/index.tsx
|
|
4804
|
+
const mappedProps = /* @__PURE__ */ new Set([
|
|
4805
|
+
"focusable",
|
|
4806
|
+
"importantForAccessibility",
|
|
4807
|
+
"nativeID",
|
|
4808
|
+
"testID"
|
|
4809
|
+
]);
|
|
4810
|
+
const isNativeOnly = (name) => mappedProps.has(name) || name.startsWith("accessibility") || isNativeHandler(name);
|
|
4811
|
+
function Host({ type, props }) {
|
|
4812
|
+
const registry = useStyleRegistry();
|
|
4813
|
+
const { className, style, ...rest } = props;
|
|
4814
|
+
const domProps = {};
|
|
4815
|
+
for (const name in rest) if (!isNativeOnly(name)) domProps[name] = rest[name];
|
|
4816
|
+
Object.assign(domProps, toDOMProps(rest));
|
|
4817
|
+
const compiled = compileStyle(style, registry);
|
|
4818
|
+
const classes = typeof className === "string" && className !== "" ? [className] : [];
|
|
4819
|
+
if (compiled !== "") classes.push(compiled);
|
|
4820
|
+
if (classes.length > 0) domProps["className"] = classes.join(" ");
|
|
4821
|
+
return createElement(type, domProps);
|
|
4822
|
+
}
|
|
4823
|
+
/**
|
|
4824
|
+
* Compat export. Renders `type` with React Native props: `style` compiles to class names, and
|
|
4825
|
+
* the accessibility props become ARIA attributes. Every other prop goes to the element as it
|
|
4826
|
+
* is. Libraries such as `react-native-svg` import it from `react-native` on the web.
|
|
4827
|
+
*/
|
|
4828
|
+
const unstable_createElement = (type, props) => {
|
|
4829
|
+
const hostProps = props ?? {};
|
|
4830
|
+
return createElement(Host, {
|
|
4831
|
+
key: hostProps["key"],
|
|
4832
|
+
type,
|
|
4833
|
+
props: hostProps
|
|
4834
|
+
});
|
|
4835
|
+
};
|
|
4836
|
+
// src/compat/findNodeHandle/index.ts
|
|
4837
|
+
const isElement = (value) => value.nodeType === 1;
|
|
4838
|
+
/**
|
|
4839
|
+
* Compat export. On native it returns the tag of a view. On the web it returns the DOM element
|
|
4840
|
+
* of a ref, of an element, or of a scroll component. A number comes back as it is. A class
|
|
4841
|
+
* component instance gives `null`, because React has no `findDOMNode`.
|
|
4842
|
+
*/
|
|
4843
|
+
const findNodeHandle = (componentOrHandle) => {
|
|
4844
|
+
if (typeof componentOrHandle === "number") return componentOrHandle;
|
|
4845
|
+
if (typeof componentOrHandle !== "object" || componentOrHandle === null) return null;
|
|
4846
|
+
if (isElement(componentOrHandle)) return componentOrHandle;
|
|
4847
|
+
const { getScrollableNode } = componentOrHandle;
|
|
4848
|
+
if (typeof getScrollableNode === "function") return findNodeHandle(getScrollableNode.call(componentOrHandle));
|
|
4849
|
+
if ("current" in componentOrHandle) return findNodeHandle(componentOrHandle.current);
|
|
4850
|
+
return null;
|
|
4851
|
+
};
|
|
4852
|
+
// src/compat/TurboModuleRegistry/index.ts
|
|
4853
|
+
/**
|
|
4854
|
+
* Compat export. A browser has no native modules, so `get` always returns `null`. A library
|
|
4855
|
+
* that reads its native module at import time then takes its JavaScript path.
|
|
4856
|
+
*/
|
|
4857
|
+
const TurboModuleRegistry = {
|
|
4858
|
+
get: () => null,
|
|
4859
|
+
getEnforcing: (name) => {
|
|
4860
|
+
throw new Error(`TurboModuleRegistry.getEnforcing(...): '${name}' could not be found. A browser has no native modules.`);
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
export { AccessibilityInfo, ActivityIndicator, Alert, AppState, Appearance, BackHandler, Button, Clipboard, Dimensions, FlatList, I18nManager, Image, Keyboard, KeyboardAvoidingView, Linking, Modal, PanResponder, PixelRatio, Platform, Pressable, RefreshControl, ScrollView, Share, StatusBar, StyleSheet, Switch, Text, TextAncestorContext, TextInput, TouchableHighlight, TouchableNativeFeedback, TouchableOpacity, TouchableWithoutFeedback, TurboModuleRegistry, Vibration, View, findNodeHandle, processColor, unstable_createElement, useColorScheme, usePressability, useWindowDimensions };
|
|
3374
4864
|
|
|
3375
4865
|
//# sourceMappingURL=index.js.map
|