@dloizides/ui-layout 1.39.3 → 1.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +241 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React14 = require('react');
|
|
4
4
|
var reactNative = require('react-native');
|
|
5
5
|
var uiFeedback = require('@dloizides/ui-feedback');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -14,7 +14,7 @@ var rnWebHooks = require('@dloizides/rn-web-hooks');
|
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
16
|
|
|
17
|
-
var
|
|
17
|
+
var React14__default = /*#__PURE__*/_interopDefault(React14);
|
|
18
18
|
|
|
19
19
|
// src/Section/Section.tsx
|
|
20
20
|
|
|
@@ -44,7 +44,7 @@ var Section = ({
|
|
|
44
44
|
const { theme } = uiFeedback.useUi();
|
|
45
45
|
const isCard = variant === "card" /* Card */;
|
|
46
46
|
const fill = isCard ? theme.colors.background : theme.colors.surface;
|
|
47
|
-
const containerStyle =
|
|
47
|
+
const containerStyle = React14__default.default.useMemo(
|
|
48
48
|
() => [styles.card, isCard ? styles.raised : null, { borderColor: theme.colors.border, backgroundColor: fill }, style],
|
|
49
49
|
[theme.colors.border, fill, isCard, style]
|
|
50
50
|
);
|
|
@@ -106,6 +106,7 @@ var LAYOUT_TEST_IDS = {
|
|
|
106
106
|
/** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
|
|
107
107
|
modal: "modal",
|
|
108
108
|
sideSheet: "side-sheet",
|
|
109
|
+
bottomSheet: "bottom-sheet",
|
|
109
110
|
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
110
111
|
confirmDialog: "confirm-dialog",
|
|
111
112
|
accordion: "accordion",
|
|
@@ -213,7 +214,7 @@ var Heading = ({
|
|
|
213
214
|
testID
|
|
214
215
|
}) => {
|
|
215
216
|
const { theme } = uiFeedback.useUi();
|
|
216
|
-
const headingStyle =
|
|
217
|
+
const headingStyle = React14__default.default.useMemo(
|
|
217
218
|
() => [styles3.heading, { color: theme.colors.text }, style],
|
|
218
219
|
[theme.colors.text, style]
|
|
219
220
|
);
|
|
@@ -268,9 +269,9 @@ var StatusBadge = ({
|
|
|
268
269
|
accessibilityHint
|
|
269
270
|
}) => {
|
|
270
271
|
const { t } = uiFeedback.useUi();
|
|
271
|
-
const dynamicBadge =
|
|
272
|
-
const dashedColor =
|
|
273
|
-
const dynamicText =
|
|
272
|
+
const dynamicBadge = React14.useMemo(() => ({ backgroundColor }), [backgroundColor]);
|
|
273
|
+
const dashedColor = React14.useMemo(() => ({ borderColor: color }), [color]);
|
|
274
|
+
const dynamicText = React14.useMemo(() => ({ color }), [color]);
|
|
274
275
|
const hasIcon = icon !== void 0 && icon !== null;
|
|
275
276
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
276
277
|
reactNative.View,
|
|
@@ -290,9 +291,9 @@ function isPastStickyLine(sentinelTop, isIntersecting, topOffset) {
|
|
|
290
291
|
return !isIntersecting && sentinelTop < topOffset;
|
|
291
292
|
}
|
|
292
293
|
function useStuckSentinel(topOffset) {
|
|
293
|
-
const sentinelRef =
|
|
294
|
-
const [isStuck, setIsStuck] =
|
|
295
|
-
|
|
294
|
+
const sentinelRef = React14.useRef(null);
|
|
295
|
+
const [isStuck, setIsStuck] = React14.useState(false);
|
|
296
|
+
React14.useEffect(() => {
|
|
296
297
|
const node = sentinelRef.current;
|
|
297
298
|
if (node === null || typeof IntersectionObserver === "undefined") return void 0;
|
|
298
299
|
const observer = new IntersectionObserver(
|
|
@@ -313,9 +314,9 @@ function isKeyboardOpen(visibleHeight, tallestHeight) {
|
|
|
313
314
|
return visibleHeight < tallestHeight * KEYBOARD_HEIGHT_RATIO;
|
|
314
315
|
}
|
|
315
316
|
function useVisibleViewport() {
|
|
316
|
-
const [state, setState] =
|
|
317
|
-
const tallest =
|
|
318
|
-
|
|
317
|
+
const [state, setState] = React14.useState(INITIAL);
|
|
318
|
+
const tallest = React14.useRef({ width: 0, height: 0 });
|
|
319
|
+
React14.useEffect(() => {
|
|
319
320
|
const viewport = typeof window === "undefined" ? void 0 : window.visualViewport;
|
|
320
321
|
if (viewport === void 0 || viewport === null) return void 0;
|
|
321
322
|
const read = () => {
|
|
@@ -358,7 +359,7 @@ var StickyPreview = ({
|
|
|
358
359
|
const { offsetTop, keyboardOpen } = useVisibleViewport();
|
|
359
360
|
const { sentinelRef, isStuck } = useStuckSentinel(topOffset);
|
|
360
361
|
const isCompact = forceCompact || isStuck || keyboardOpen;
|
|
361
|
-
const pinned =
|
|
362
|
+
const pinned = React14.useMemo(() => {
|
|
362
363
|
const web = { position: "sticky", top: topOffset + offsetTop, zIndex: STICKY_Z_INDEX };
|
|
363
364
|
return reactNative.Platform.OS === WEB_PLATFORM ? web : {};
|
|
364
365
|
}, [offsetTop, topOffset]);
|
|
@@ -382,7 +383,7 @@ var StickyPreview = ({
|
|
|
382
383
|
] });
|
|
383
384
|
};
|
|
384
385
|
function useEscapeKey(enabled, onClose) {
|
|
385
|
-
|
|
386
|
+
React14.useEffect(() => {
|
|
386
387
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
387
388
|
const onKeyDown = (event) => {
|
|
388
389
|
if (event.key === "Escape") onClose();
|
|
@@ -439,8 +440,8 @@ function handleKeyDown(domNode, event) {
|
|
|
439
440
|
}
|
|
440
441
|
}
|
|
441
442
|
function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
442
|
-
const previousFocusRef =
|
|
443
|
-
|
|
443
|
+
const previousFocusRef = React14.useRef(null);
|
|
444
|
+
React14.useEffect(() => {
|
|
444
445
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
445
446
|
const domNode = containerRef.current;
|
|
446
447
|
if (!domNode) return;
|
|
@@ -457,7 +458,7 @@ function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
|
457
458
|
}, [containerRef, enabled, initialFocusTestID]);
|
|
458
459
|
}
|
|
459
460
|
function useScrollLock(enabled) {
|
|
460
|
-
|
|
461
|
+
React14.useEffect(() => {
|
|
461
462
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
462
463
|
const { body } = document;
|
|
463
464
|
const previousOverflow = body.style.overflow;
|
|
@@ -518,7 +519,7 @@ var Modal = ({
|
|
|
518
519
|
initialFocusTestID
|
|
519
520
|
}) => {
|
|
520
521
|
const { theme, t } = uiFeedback.useUi();
|
|
521
|
-
const dialogRef =
|
|
522
|
+
const dialogRef = React14.useRef(null);
|
|
522
523
|
const backdrop = uiMotion.useEnterExit({ visible });
|
|
523
524
|
const panel = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE });
|
|
524
525
|
const mounted = panel.mounted || backdrop.mounted;
|
|
@@ -527,7 +528,7 @@ var Modal = ({
|
|
|
527
528
|
useScrollLock(visible);
|
|
528
529
|
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
529
530
|
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
530
|
-
const dialogStyle =
|
|
531
|
+
const dialogStyle = React14.useMemo(
|
|
531
532
|
() => [styles6.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
532
533
|
[theme.colors.surface, size]
|
|
533
534
|
);
|
|
@@ -627,13 +628,13 @@ var PageFrame = ({
|
|
|
627
628
|
enlargeable = false
|
|
628
629
|
}) => {
|
|
629
630
|
const { t } = uiFeedback.useUi();
|
|
630
|
-
const [containerWidth, setContainerWidth] =
|
|
631
|
-
const [enlarged, setEnlarged] =
|
|
632
|
-
const onLayout =
|
|
631
|
+
const [containerWidth, setContainerWidth] = React14.useState(0);
|
|
632
|
+
const [enlarged, setEnlarged] = React14.useState(false);
|
|
633
|
+
const onLayout = React14.useCallback((event) => {
|
|
633
634
|
setContainerWidth(event.nativeEvent.layout.width);
|
|
634
635
|
}, []);
|
|
635
|
-
const open =
|
|
636
|
-
const close =
|
|
636
|
+
const open = React14.useCallback(() => setEnlarged(true), []);
|
|
637
|
+
const close = React14.useCallback(() => setEnlarged(false), []);
|
|
637
638
|
const frame = scaledFrame(containerWidth, pageSize);
|
|
638
639
|
const preview = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles7.outer, { height: frame.height }], testID, onLayout, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
639
640
|
reactNative.View,
|
|
@@ -902,7 +903,7 @@ var OptionRow = ({
|
|
|
902
903
|
}) => {
|
|
903
904
|
const { theme, t } = uiFeedback.useUi();
|
|
904
905
|
const { colors } = theme;
|
|
905
|
-
const handlePress =
|
|
906
|
+
const handlePress = React14.useCallback(() => {
|
|
906
907
|
onSelect();
|
|
907
908
|
}, [onSelect]);
|
|
908
909
|
const accentColor = theme.palette.primary["500"];
|
|
@@ -991,8 +992,8 @@ function isSameRect(a, b) {
|
|
|
991
992
|
return a.top === b.top && a.left === b.left && a.width === b.width && a.bottom === b.bottom;
|
|
992
993
|
}
|
|
993
994
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
994
|
-
const [rect, setRect] =
|
|
995
|
-
|
|
995
|
+
const [rect, setRect] = React14.useState(() => readAnchorRect(containerRef));
|
|
996
|
+
React14.useLayoutEffect(() => {
|
|
996
997
|
if (!IS_WEB) return void 0;
|
|
997
998
|
let frame = null;
|
|
998
999
|
let isDisposed = false;
|
|
@@ -1071,7 +1072,7 @@ function buildKeyHandler(params) {
|
|
|
1071
1072
|
}
|
|
1072
1073
|
function useMenuKeyboard(params) {
|
|
1073
1074
|
const { containerRef, menuRef, enabled, onClose } = params;
|
|
1074
|
-
|
|
1075
|
+
React14.useEffect(() => {
|
|
1075
1076
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1076
1077
|
const onKeyDown = buildKeyHandler(params);
|
|
1077
1078
|
const onMouseDown = (event) => {
|
|
@@ -1094,19 +1095,19 @@ function readViewportHeight() {
|
|
|
1094
1095
|
return IS_WEB2 && typeof window !== "undefined" ? window.innerHeight : 0;
|
|
1095
1096
|
}
|
|
1096
1097
|
function useMenuPlacement(rect, menuRef, itemCount) {
|
|
1097
|
-
const [menuHeight, setMenuHeight] =
|
|
1098
|
-
const [viewportHeight, setViewportHeight] =
|
|
1099
|
-
|
|
1098
|
+
const [menuHeight, setMenuHeight] = React14.useState(MENU_MAX_HEIGHT);
|
|
1099
|
+
const [viewportHeight, setViewportHeight] = React14.useState(readViewportHeight);
|
|
1100
|
+
React14.useLayoutEffect(() => {
|
|
1100
1101
|
const measured = toDomNode(menuRef)?.offsetHeight ?? 0;
|
|
1101
1102
|
if (measured > 0) setMenuHeight(measured);
|
|
1102
1103
|
}, [menuRef, itemCount]);
|
|
1103
|
-
|
|
1104
|
+
React14.useLayoutEffect(() => {
|
|
1104
1105
|
if (!IS_WEB2) return void 0;
|
|
1105
1106
|
const onResize = () => setViewportHeight(readViewportHeight());
|
|
1106
1107
|
window.addEventListener("resize", onResize);
|
|
1107
1108
|
return () => window.removeEventListener("resize", onResize);
|
|
1108
1109
|
}, []);
|
|
1109
|
-
return
|
|
1110
|
+
return React14.useMemo(
|
|
1110
1111
|
() => resolveMenuPlacement(rect ?? UNMEASURED_RECT, viewportHeight, menuHeight),
|
|
1111
1112
|
[rect, viewportHeight, menuHeight]
|
|
1112
1113
|
);
|
|
@@ -1159,29 +1160,29 @@ var InlineMenu = ({
|
|
|
1159
1160
|
}) => {
|
|
1160
1161
|
const { theme } = uiFeedback.useUi();
|
|
1161
1162
|
const { colors } = theme;
|
|
1162
|
-
const menuRef =
|
|
1163
|
+
const menuRef = React14.useRef(null);
|
|
1163
1164
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
1164
1165
|
const placement = useMenuPlacement(rect, menuRef, options.length);
|
|
1165
1166
|
const opensAbove = placement.bottom !== void 0;
|
|
1166
|
-
const selectedIndex =
|
|
1167
|
+
const selectedIndex = React14.useMemo(
|
|
1167
1168
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
1168
1169
|
[options, value]
|
|
1169
1170
|
);
|
|
1170
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
1171
|
-
const handleSelect =
|
|
1171
|
+
const [highlightedIndex, setHighlightedIndex] = React14.useState(() => selectedIndex);
|
|
1172
|
+
const handleSelect = React14.useCallback(
|
|
1172
1173
|
(optionValue) => {
|
|
1173
1174
|
if (isOpen) onSelect(optionValue);
|
|
1174
1175
|
},
|
|
1175
1176
|
[isOpen, onSelect]
|
|
1176
1177
|
);
|
|
1177
|
-
const selectAt =
|
|
1178
|
+
const selectAt = React14.useCallback(
|
|
1178
1179
|
(index) => {
|
|
1179
1180
|
const option = options[index];
|
|
1180
1181
|
if (option !== void 0) handleSelect(option.value);
|
|
1181
1182
|
},
|
|
1182
1183
|
[options, handleSelect]
|
|
1183
1184
|
);
|
|
1184
|
-
const selectHighlighted =
|
|
1185
|
+
const selectHighlighted = React14.useCallback(
|
|
1185
1186
|
() => {
|
|
1186
1187
|
selectAt(highlightedIndex);
|
|
1187
1188
|
},
|
|
@@ -1196,7 +1197,7 @@ var InlineMenu = ({
|
|
|
1196
1197
|
onSelectHighlighted: selectHighlighted,
|
|
1197
1198
|
onClose
|
|
1198
1199
|
});
|
|
1199
|
-
const popoverStyle =
|
|
1200
|
+
const popoverStyle = React14.useMemo(() => {
|
|
1200
1201
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
1201
1202
|
if (IS_WEB3) {
|
|
1202
1203
|
const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 0;
|
|
@@ -1342,7 +1343,7 @@ var ModalDropdown = ({
|
|
|
1342
1343
|
const { colors } = theme;
|
|
1343
1344
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
1344
1345
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
1345
|
-
const [isOpen, setIsOpen] =
|
|
1346
|
+
const [isOpen, setIsOpen] = React14.useState(false);
|
|
1346
1347
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
1347
1348
|
label: accessibilityLabel,
|
|
1348
1349
|
hint: accessibilityHint,
|
|
@@ -1350,10 +1351,10 @@ var ModalDropdown = ({
|
|
|
1350
1351
|
state: { expanded: isOpen },
|
|
1351
1352
|
testID
|
|
1352
1353
|
});
|
|
1353
|
-
const anchorRef =
|
|
1354
|
-
const triggerRef =
|
|
1354
|
+
const anchorRef = React14.useRef(null);
|
|
1355
|
+
const triggerRef = React14.useRef(null);
|
|
1355
1356
|
const popupProps = { "aria-haspopup": isMenu ? "menu" : "dialog" };
|
|
1356
|
-
const dialogRef =
|
|
1357
|
+
const dialogRef = React14.useRef(null);
|
|
1357
1358
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
1358
1359
|
const menuAnim = uiMotion.useEnterExit({
|
|
1359
1360
|
visible: isMenu && isOpen,
|
|
@@ -1365,17 +1366,17 @@ var ModalDropdown = ({
|
|
|
1365
1366
|
fromScale: POPOVER_ENTER_SCALE,
|
|
1366
1367
|
duration: POPOVER_MOTION_MS
|
|
1367
1368
|
});
|
|
1368
|
-
const selectedLabel =
|
|
1369
|
+
const selectedLabel = React14.useMemo(() => {
|
|
1369
1370
|
const found = options.find((opt) => opt.value === value);
|
|
1370
1371
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
1371
1372
|
}, [options, value, t]);
|
|
1372
|
-
const handleToggle =
|
|
1373
|
+
const handleToggle = React14.useCallback(() => {
|
|
1373
1374
|
setIsOpen((prev) => !prev);
|
|
1374
1375
|
}, []);
|
|
1375
|
-
const handleClose =
|
|
1376
|
+
const handleClose = React14.useCallback(() => {
|
|
1376
1377
|
setIsOpen(false);
|
|
1377
1378
|
}, []);
|
|
1378
|
-
const handleSelect =
|
|
1379
|
+
const handleSelect = React14.useCallback(
|
|
1379
1380
|
(optionValue) => {
|
|
1380
1381
|
onChange(optionValue);
|
|
1381
1382
|
setIsOpen(false);
|
|
@@ -1385,7 +1386,7 @@ var ModalDropdown = ({
|
|
|
1385
1386
|
);
|
|
1386
1387
|
const isHamburger = showHamburger;
|
|
1387
1388
|
const isCaret = showCaret && !isHamburger;
|
|
1388
|
-
const containerStyle =
|
|
1389
|
+
const containerStyle = React14.useMemo(
|
|
1389
1390
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
1390
1391
|
styles12.container,
|
|
1391
1392
|
isHamburger ? styles12.containerHamburger : isCaret ? styles12.containerMenu : null,
|
|
@@ -1393,30 +1394,30 @@ var ModalDropdown = ({
|
|
|
1393
1394
|
],
|
|
1394
1395
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
1395
1396
|
);
|
|
1396
|
-
const hamburgerStyle =
|
|
1397
|
+
const hamburgerStyle = React14.useMemo(
|
|
1397
1398
|
() => [styles12.hamburger, { color: colors.textSecondary }],
|
|
1398
1399
|
[colors.textSecondary]
|
|
1399
1400
|
);
|
|
1400
|
-
const caretStyle =
|
|
1401
|
+
const caretStyle = React14.useMemo(
|
|
1401
1402
|
() => [
|
|
1402
1403
|
styles12.caret,
|
|
1403
1404
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
1404
1405
|
],
|
|
1405
1406
|
[colors.textSecondary, isOpen]
|
|
1406
1407
|
);
|
|
1407
|
-
const optionTestIDFor =
|
|
1408
|
+
const optionTestIDFor = React14.useCallback(
|
|
1408
1409
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
1409
1410
|
[optionTestID, testID]
|
|
1410
1411
|
);
|
|
1411
|
-
const anchorStyle =
|
|
1412
|
+
const anchorStyle = React14.useMemo(
|
|
1412
1413
|
() => [styles12.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
1413
1414
|
[isMenu, isOpen]
|
|
1414
1415
|
);
|
|
1415
|
-
const modalContentStyle =
|
|
1416
|
+
const modalContentStyle = React14.useMemo(
|
|
1416
1417
|
() => [styles12.modalContent, { backgroundColor: colors.surface }],
|
|
1417
1418
|
[colors.surface]
|
|
1418
1419
|
);
|
|
1419
|
-
const renderModalOption =
|
|
1420
|
+
const renderModalOption = React14.useCallback(
|
|
1420
1421
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1421
1422
|
OptionRow,
|
|
1422
1423
|
{
|
|
@@ -1429,7 +1430,7 @@ var ModalDropdown = ({
|
|
|
1429
1430
|
),
|
|
1430
1431
|
[handleSelect, optionTestIDFor, selectedMarker, value]
|
|
1431
1432
|
);
|
|
1432
|
-
const keyExtractor =
|
|
1433
|
+
const keyExtractor = React14.useCallback((item) => String(item.value), []);
|
|
1433
1434
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
1434
1435
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
|
|
1435
1436
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -1505,11 +1506,11 @@ var TabsMenu = ({
|
|
|
1505
1506
|
collapsedTrigger = "caret" /* Caret */
|
|
1506
1507
|
}) => {
|
|
1507
1508
|
const { t } = uiFeedback.useUi();
|
|
1508
|
-
const options =
|
|
1509
|
+
const options = React14.useMemo(
|
|
1509
1510
|
() => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
|
|
1510
1511
|
[tabs]
|
|
1511
1512
|
);
|
|
1512
|
-
const optionTestID =
|
|
1513
|
+
const optionTestID = React14.useCallback(
|
|
1513
1514
|
(key) => {
|
|
1514
1515
|
const found = tabs.find((tab) => tab.key === key);
|
|
1515
1516
|
return found?.testID ?? `${idPrefix}-tab-${key}`;
|
|
@@ -1789,7 +1790,7 @@ var ModalShell = ({
|
|
|
1789
1790
|
}) => {
|
|
1790
1791
|
const { theme, t } = uiFeedback.useUi();
|
|
1791
1792
|
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1792
|
-
const containerStyle =
|
|
1793
|
+
const containerStyle = React14__default.default.useMemo(
|
|
1793
1794
|
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1794
1795
|
[theme.colors.background, contentStyle]
|
|
1795
1796
|
);
|
|
@@ -1864,7 +1865,7 @@ var SideSheet = ({
|
|
|
1864
1865
|
}) => {
|
|
1865
1866
|
const { theme, t } = uiFeedback.useUi();
|
|
1866
1867
|
const isWide = useIsWideViewport();
|
|
1867
|
-
const sheetRef =
|
|
1868
|
+
const sheetRef = React14.useRef(null);
|
|
1868
1869
|
const backdrop = uiMotion.useEnterExit({ visible });
|
|
1869
1870
|
const panel = uiMotion.useEnterExit({ visible, translateY: isWide ? 0 : PHONE_ENTER_OFFSET });
|
|
1870
1871
|
const edges = { borderColor: theme.colors.border };
|
|
@@ -1909,10 +1910,109 @@ var SideSheet = ({
|
|
|
1909
1910
|
)
|
|
1910
1911
|
] }) });
|
|
1911
1912
|
};
|
|
1913
|
+
var DEFAULT_MAX_HEIGHT_FRACTION = 0.92;
|
|
1914
|
+
var PERCENT = 100;
|
|
1915
|
+
var WIDE_MAX_WIDTH = 560;
|
|
1916
|
+
var TOP_CORNER = 16;
|
|
1917
|
+
var ENTER_OFFSET = 24;
|
|
1918
|
+
var CLOSE_ICON_SIZE2 = 18;
|
|
1919
|
+
var styles17 = reactNative.StyleSheet.create({
|
|
1920
|
+
root: { flex: 1 },
|
|
1921
|
+
backdrop: { backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
1922
|
+
panel: {
|
|
1923
|
+
position: "absolute",
|
|
1924
|
+
bottom: 0,
|
|
1925
|
+
left: 0,
|
|
1926
|
+
right: 0,
|
|
1927
|
+
overflow: "hidden",
|
|
1928
|
+
borderTopLeftRadius: TOP_CORNER,
|
|
1929
|
+
borderTopRightRadius: TOP_CORNER
|
|
1930
|
+
},
|
|
1931
|
+
wide: { maxWidth: WIDE_MAX_WIDTH, marginHorizontal: "auto" },
|
|
1932
|
+
header: { flexDirection: "row", alignItems: "center", gap: 8, paddingLeft: 16, paddingRight: 8, paddingTop: 8 },
|
|
1933
|
+
title: { flex: 1 },
|
|
1934
|
+
close: { minWidth: a11y.MIN_TOUCH_TARGET_PX, minHeight: a11y.MIN_TOUCH_TARGET_PX, alignItems: "center", justifyContent: "center" },
|
|
1935
|
+
body: { flexGrow: 0, flexShrink: 1 },
|
|
1936
|
+
content: { padding: 16, gap: 12 },
|
|
1937
|
+
footer: { padding: 16, borderTopWidth: 1 }
|
|
1938
|
+
});
|
|
1939
|
+
var BottomSheet = ({
|
|
1940
|
+
visible,
|
|
1941
|
+
onClose,
|
|
1942
|
+
title,
|
|
1943
|
+
children,
|
|
1944
|
+
footer,
|
|
1945
|
+
maxHeightFraction = DEFAULT_MAX_HEIGHT_FRACTION,
|
|
1946
|
+
testID = LAYOUT_TEST_IDS.bottomSheet,
|
|
1947
|
+
accessibilityLabel,
|
|
1948
|
+
initialFocusTestID
|
|
1949
|
+
}) => {
|
|
1950
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1951
|
+
const isWide = useIsWideViewport();
|
|
1952
|
+
const panelRef = React14.useRef(null);
|
|
1953
|
+
const backdrop = uiMotion.useEnterExit({ visible });
|
|
1954
|
+
const panel = uiMotion.useEnterExit({ visible, translateY: ENTER_OFFSET });
|
|
1955
|
+
const hasFooter = footer !== void 0 && footer !== null;
|
|
1956
|
+
const panelSize = { maxHeight: `${maxHeightFraction * PERCENT}%` };
|
|
1957
|
+
useFocusTrap(panelRef, visible && panel.mounted, initialFocusTestID);
|
|
1958
|
+
useEscapeKey(visible, onClose);
|
|
1959
|
+
useScrollLock(visible);
|
|
1960
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.root, children: [
|
|
1961
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [reactNative.StyleSheet.absoluteFill, styles17.backdrop, { opacity: backdrop.style.opacity }] }),
|
|
1962
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1963
|
+
reactNative.Pressable,
|
|
1964
|
+
{
|
|
1965
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1966
|
+
accessibilityLabel: t(LAYOUT_I18N.dialogClose),
|
|
1967
|
+
accessibilityRole: "button",
|
|
1968
|
+
style: reactNative.StyleSheet.absoluteFill,
|
|
1969
|
+
testID: `${testID}-backdrop`,
|
|
1970
|
+
onPress: onClose
|
|
1971
|
+
}
|
|
1972
|
+
),
|
|
1973
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1974
|
+
reactNative.Animated.View,
|
|
1975
|
+
{
|
|
1976
|
+
ref: panelRef,
|
|
1977
|
+
accessibilityViewIsModal: true,
|
|
1978
|
+
"aria-modal": true,
|
|
1979
|
+
"aria-label": accessibilityLabel ?? title,
|
|
1980
|
+
role: "dialog",
|
|
1981
|
+
style: [
|
|
1982
|
+
styles17.panel,
|
|
1983
|
+
isWide ? styles17.wide : null,
|
|
1984
|
+
panelSize,
|
|
1985
|
+
{ backgroundColor: theme.colors.surface },
|
|
1986
|
+
panel.style
|
|
1987
|
+
],
|
|
1988
|
+
testID,
|
|
1989
|
+
children: [
|
|
1990
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.header, children: [
|
|
1991
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.title, children: /* @__PURE__ */ jsxRuntime.jsx(AppText, { kind: "title" /* Title */, children: title }) }),
|
|
1992
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1993
|
+
reactNative.TouchableOpacity,
|
|
1994
|
+
{
|
|
1995
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1996
|
+
accessibilityLabel: t(LAYOUT_I18N.dialogClose),
|
|
1997
|
+
accessibilityRole: "button",
|
|
1998
|
+
style: styles17.close,
|
|
1999
|
+
testID: `${testID}-close`,
|
|
2000
|
+
onPress: onClose,
|
|
2001
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE2 })
|
|
2002
|
+
}
|
|
2003
|
+
)
|
|
2004
|
+
] }),
|
|
2005
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { contentContainerStyle: styles17.content, style: styles17.body, children }),
|
|
2006
|
+
hasFooter ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles17.footer, { borderColor: theme.colors.border }], testID: `${testID}-footer`, children: footer }) : null
|
|
2007
|
+
]
|
|
2008
|
+
}
|
|
2009
|
+
)
|
|
2010
|
+
] }) });
|
|
2011
|
+
};
|
|
1912
2012
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1913
2013
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1914
2014
|
var BUTTON_GAP = 12;
|
|
1915
|
-
var
|
|
2015
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
1916
2016
|
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1917
2017
|
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1918
2018
|
});
|
|
@@ -1931,7 +2031,7 @@ var ConfirmDialog = ({
|
|
|
1931
2031
|
const { theme, t } = uiFeedback.useUi();
|
|
1932
2032
|
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1933
2033
|
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1934
|
-
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2034
|
+
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.footer, children: [
|
|
1935
2035
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1936
2036
|
uiButtons.Button,
|
|
1937
2037
|
{
|
|
@@ -1967,27 +2067,27 @@ var ConfirmDialog = ({
|
|
|
1967
2067
|
title,
|
|
1968
2068
|
visible,
|
|
1969
2069
|
onClose: onCancel,
|
|
1970
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2070
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1971
2071
|
}
|
|
1972
2072
|
);
|
|
1973
2073
|
};
|
|
1974
|
-
var AccordionContext =
|
|
2074
|
+
var AccordionContext = React14.createContext(null);
|
|
1975
2075
|
function useAccordionContext() {
|
|
1976
|
-
const value =
|
|
2076
|
+
const value = React14.useContext(AccordionContext);
|
|
1977
2077
|
if (value === null) {
|
|
1978
2078
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1979
2079
|
}
|
|
1980
2080
|
return value;
|
|
1981
2081
|
}
|
|
1982
2082
|
var BOXED_GAP = 12;
|
|
1983
|
-
var
|
|
2083
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
1984
2084
|
container: { alignSelf: "stretch" },
|
|
1985
2085
|
boxed: { gap: BOXED_GAP }
|
|
1986
2086
|
});
|
|
1987
2087
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1988
2088
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1989
|
-
|
|
1990
|
-
if (!
|
|
2089
|
+
React14__default.default.Children.forEach(children, (child) => {
|
|
2090
|
+
if (!React14__default.default.isValidElement(child)) return;
|
|
1991
2091
|
const props = child.props;
|
|
1992
2092
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1993
2093
|
ids.add(props.id);
|
|
@@ -2010,14 +2110,14 @@ var Accordion = ({
|
|
|
2010
2110
|
style
|
|
2011
2111
|
}) => {
|
|
2012
2112
|
const isControlled = openIds !== void 0;
|
|
2013
|
-
const [internalOpen, setInternalOpen] =
|
|
2113
|
+
const [internalOpen, setInternalOpen] = React14.useState(
|
|
2014
2114
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
2015
2115
|
);
|
|
2016
|
-
const openSet =
|
|
2116
|
+
const openSet = React14.useMemo(
|
|
2017
2117
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
2018
2118
|
[isControlled, openIds, internalOpen]
|
|
2019
2119
|
);
|
|
2020
|
-
const toggle =
|
|
2120
|
+
const toggle = React14.useCallback(
|
|
2021
2121
|
(id) => {
|
|
2022
2122
|
const next = new Set(openSet);
|
|
2023
2123
|
const willOpen = !next.has(id);
|
|
@@ -2032,12 +2132,12 @@ var Accordion = ({
|
|
|
2032
2132
|
},
|
|
2033
2133
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
2034
2134
|
);
|
|
2035
|
-
const contextValue =
|
|
2135
|
+
const contextValue = React14.useMemo(
|
|
2036
2136
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
2037
2137
|
[openSet, toggle, allowMultiple, variant]
|
|
2038
2138
|
);
|
|
2039
|
-
const containerStyle =
|
|
2040
|
-
const base = variant === "boxed" ? [
|
|
2139
|
+
const containerStyle = React14.useMemo(() => {
|
|
2140
|
+
const base = variant === "boxed" ? [styles19.container, styles19.boxed] : [styles19.container];
|
|
2041
2141
|
if (style === void 0) return base;
|
|
2042
2142
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
2043
2143
|
}, [style, variant]);
|
|
@@ -2069,7 +2169,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
2069
2169
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
2070
2170
|
var BOX_MARKER_GAP = 6;
|
|
2071
2171
|
var BOX_MARKER = "\u25B8";
|
|
2072
|
-
var
|
|
2172
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2073
2173
|
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
2074
2174
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
2075
2175
|
header: {
|
|
@@ -2115,9 +2215,9 @@ var AccordionItem = ({
|
|
|
2115
2215
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
2116
2216
|
const bodyTestID = `${headerTestID}-body`;
|
|
2117
2217
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
2118
|
-
const [rotation] =
|
|
2218
|
+
const [rotation] = React14.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
2119
2219
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
2120
|
-
|
|
2220
|
+
React14.useEffect(() => {
|
|
2121
2221
|
reactNative.Animated.timing(rotation, {
|
|
2122
2222
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
2123
2223
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -2129,10 +2229,10 @@ var AccordionItem = ({
|
|
|
2129
2229
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
2130
2230
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
2131
2231
|
});
|
|
2132
|
-
const handlePress =
|
|
2232
|
+
const handlePress = React14.useCallback(() => {
|
|
2133
2233
|
if (!disabled) toggle(id);
|
|
2134
2234
|
}, [disabled, id, toggle]);
|
|
2135
|
-
const handleKeyDown2 =
|
|
2235
|
+
const handleKeyDown2 = React14.useCallback(
|
|
2136
2236
|
(event) => {
|
|
2137
2237
|
if (disabled) return;
|
|
2138
2238
|
const key = event.key ?? "";
|
|
@@ -2144,20 +2244,20 @@ var AccordionItem = ({
|
|
|
2144
2244
|
[disabled, id, toggle]
|
|
2145
2245
|
);
|
|
2146
2246
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
2147
|
-
const itemStyle =
|
|
2148
|
-
() => boxed ? [
|
|
2247
|
+
const itemStyle = React14.useMemo(
|
|
2248
|
+
() => boxed ? [styles20.boxItem, { borderColor: colors.border }] : [styles20.item, { borderTopColor: colors.border }],
|
|
2149
2249
|
[boxed, colors.border]
|
|
2150
2250
|
);
|
|
2151
|
-
const headerStyle =
|
|
2251
|
+
const headerStyle = React14.useMemo(
|
|
2152
2252
|
() => [
|
|
2153
|
-
|
|
2154
|
-
...boxed ? [
|
|
2253
|
+
styles20.header,
|
|
2254
|
+
...boxed ? [styles20.boxHeader] : [],
|
|
2155
2255
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
2156
2256
|
],
|
|
2157
2257
|
[boxed, disabled]
|
|
2158
2258
|
);
|
|
2159
2259
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
2160
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ?
|
|
2260
|
+
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ? styles20.boxTitle : styles20.title, { color: boxed ? colors.textSecondary : colors.text }], children: title }) : title;
|
|
2161
2261
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
2162
2262
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2163
2263
|
reactNative.Pressable,
|
|
@@ -2174,7 +2274,7 @@ var AccordionItem = ({
|
|
|
2174
2274
|
onPress: handlePress,
|
|
2175
2275
|
...keyboardProps,
|
|
2176
2276
|
children: [
|
|
2177
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2277
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles20.headerLeft, boxed ? styles20.headerLeftRow : null], children: [
|
|
2178
2278
|
boxed ? (
|
|
2179
2279
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
2180
2280
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2183,15 +2283,15 @@ var AccordionItem = ({
|
|
|
2183
2283
|
accessibilityElementsHidden: true,
|
|
2184
2284
|
"aria-hidden": true,
|
|
2185
2285
|
importantForAccessibility: "no-hide-descendants",
|
|
2186
|
-
style: [
|
|
2286
|
+
style: [styles20.marker, { transform: [{ rotate }] }],
|
|
2187
2287
|
testID: chevronTestID,
|
|
2188
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2288
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
2189
2289
|
}
|
|
2190
2290
|
)
|
|
2191
2291
|
) : null,
|
|
2192
2292
|
titleNode
|
|
2193
2293
|
] }),
|
|
2194
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2294
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles20.headerRight, children: [
|
|
2195
2295
|
right,
|
|
2196
2296
|
boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2197
2297
|
reactNative.Animated.View,
|
|
@@ -2199,7 +2299,7 @@ var AccordionItem = ({
|
|
|
2199
2299
|
accessibilityElementsHidden: true,
|
|
2200
2300
|
"aria-hidden": true,
|
|
2201
2301
|
importantForAccessibility: "no-hide-descendants",
|
|
2202
|
-
style: [
|
|
2302
|
+
style: [styles20.chevron, { transform: [{ rotate }] }],
|
|
2203
2303
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
2204
2304
|
}
|
|
2205
2305
|
)
|
|
@@ -2213,7 +2313,7 @@ var AccordionItem = ({
|
|
|
2213
2313
|
accessibilityLabel: resolvedLabel,
|
|
2214
2314
|
nativeID: bodyTestID,
|
|
2215
2315
|
role: ROLE_REGION,
|
|
2216
|
-
style: boxed ?
|
|
2316
|
+
style: boxed ? styles20.boxBody : styles20.body,
|
|
2217
2317
|
testID: bodyTestID,
|
|
2218
2318
|
children
|
|
2219
2319
|
}
|
|
@@ -2251,14 +2351,14 @@ function measureParentInnerWidth(node) {
|
|
|
2251
2351
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
2252
2352
|
}
|
|
2253
2353
|
function useAvailableWidth() {
|
|
2254
|
-
const [width, setWidth] =
|
|
2255
|
-
const nodeRef =
|
|
2256
|
-
const measureRef =
|
|
2354
|
+
const [width, setWidth] = React14.useState(UNMEASURED);
|
|
2355
|
+
const nodeRef = React14.useRef(null);
|
|
2356
|
+
const measureRef = React14.useCallback((node) => {
|
|
2257
2357
|
if (!IS_WEB4) return;
|
|
2258
2358
|
nodeRef.current = node;
|
|
2259
2359
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
2260
2360
|
}, []);
|
|
2261
|
-
|
|
2361
|
+
React14.useEffect(() => {
|
|
2262
2362
|
if (!IS_WEB4) return void 0;
|
|
2263
2363
|
const remeasure = () => {
|
|
2264
2364
|
const node = nodeRef.current;
|
|
@@ -2267,7 +2367,7 @@ function useAvailableWidth() {
|
|
|
2267
2367
|
window.addEventListener("resize", remeasure);
|
|
2268
2368
|
return () => window.removeEventListener("resize", remeasure);
|
|
2269
2369
|
}, []);
|
|
2270
|
-
const onLayout =
|
|
2370
|
+
const onLayout = React14.useCallback((event) => {
|
|
2271
2371
|
if (IS_WEB4) return;
|
|
2272
2372
|
setWidth(event.nativeEvent.layout.width);
|
|
2273
2373
|
}, []);
|
|
@@ -2276,7 +2376,7 @@ function useAvailableWidth() {
|
|
|
2276
2376
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
2277
2377
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
2278
2378
|
var UNMEASURED2 = 0;
|
|
2279
|
-
var
|
|
2379
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2280
2380
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
2281
2381
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
2282
2382
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -2296,8 +2396,8 @@ var TruncatedText = ({
|
|
|
2296
2396
|
accessibilityHint
|
|
2297
2397
|
}) => {
|
|
2298
2398
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
2299
|
-
const hostRef =
|
|
2300
|
-
const attachRef =
|
|
2399
|
+
const hostRef = React14.useRef(null);
|
|
2400
|
+
const attachRef = React14.useCallback(
|
|
2301
2401
|
(node) => {
|
|
2302
2402
|
hostRef.current = node;
|
|
2303
2403
|
measureRef(node);
|
|
@@ -2306,12 +2406,12 @@ var TruncatedText = ({
|
|
|
2306
2406
|
},
|
|
2307
2407
|
[value, measureRef]
|
|
2308
2408
|
);
|
|
2309
|
-
const flatStyle =
|
|
2310
|
-
() => reactNative.StyleSheet.flatten([
|
|
2409
|
+
const flatStyle = React14.useMemo(
|
|
2410
|
+
() => reactNative.StyleSheet.flatten([styles21.base, style]),
|
|
2311
2411
|
[style]
|
|
2312
2412
|
);
|
|
2313
2413
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
2314
|
-
const display =
|
|
2414
|
+
const display = React14.useMemo(() => {
|
|
2315
2415
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
2316
2416
|
const budget = charBudget(width, fontSize);
|
|
2317
2417
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -2322,7 +2422,7 @@ var TruncatedText = ({
|
|
|
2322
2422
|
ref: attachRef,
|
|
2323
2423
|
onLayout,
|
|
2324
2424
|
numberOfLines: 1,
|
|
2325
|
-
style: [
|
|
2425
|
+
style: [styles21.base, styles21.fill, style],
|
|
2326
2426
|
testID,
|
|
2327
2427
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
2328
2428
|
accessibilityLabel,
|
|
@@ -2393,17 +2493,17 @@ async function copyText(value, writer) {
|
|
|
2393
2493
|
// src/CopyableId/useCopyToClipboard.ts
|
|
2394
2494
|
var COPY_FEEDBACK_MS = 2e3;
|
|
2395
2495
|
function useCopyToClipboard(value, writer) {
|
|
2396
|
-
const [status, setStatus] =
|
|
2397
|
-
const timerRef =
|
|
2398
|
-
const mountedRef =
|
|
2399
|
-
|
|
2496
|
+
const [status, setStatus] = React14.useState("idle" /* Idle */);
|
|
2497
|
+
const timerRef = React14.useRef(null);
|
|
2498
|
+
const mountedRef = React14.useRef(true);
|
|
2499
|
+
React14.useEffect(() => {
|
|
2400
2500
|
mountedRef.current = true;
|
|
2401
2501
|
return () => {
|
|
2402
2502
|
mountedRef.current = false;
|
|
2403
2503
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2404
2504
|
};
|
|
2405
2505
|
}, []);
|
|
2406
|
-
const copy =
|
|
2506
|
+
const copy = React14.useCallback(() => {
|
|
2407
2507
|
void (async () => {
|
|
2408
2508
|
const ok = await copyText(value, writer);
|
|
2409
2509
|
if (!mountedRef.current) return;
|
|
@@ -2425,7 +2525,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
2425
2525
|
var ACTION_PADDING_H = 6;
|
|
2426
2526
|
var ACTION_PADDING_V = 2;
|
|
2427
2527
|
var ACTION_RADIUS = 6;
|
|
2428
|
-
var
|
|
2528
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
2429
2529
|
cell: { gap: CELL_GAP },
|
|
2430
2530
|
label: {
|
|
2431
2531
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -2467,7 +2567,7 @@ var styles21 = reactNative.StyleSheet.create({
|
|
|
2467
2567
|
var TONE_STEP = "500";
|
|
2468
2568
|
function useActionState(status) {
|
|
2469
2569
|
const { theme } = uiFeedback.useUi();
|
|
2470
|
-
return
|
|
2570
|
+
return React14.useMemo(() => {
|
|
2471
2571
|
const primary = theme.palette.primary[TONE_STEP];
|
|
2472
2572
|
if (status === "copied" /* Copied */) {
|
|
2473
2573
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
@@ -2490,14 +2590,14 @@ var CopyableId = ({
|
|
|
2490
2590
|
const { colors } = theme;
|
|
2491
2591
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
2492
2592
|
const action = useActionState(status);
|
|
2493
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2494
|
-
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2495
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2496
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
2593
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles22.cell, style], testID, children: [
|
|
2594
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.label, { color: colors.textSecondary }], children: label }),
|
|
2595
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles22.row, children: [
|
|
2596
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles22.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2497
2597
|
TruncatedText,
|
|
2498
2598
|
{
|
|
2499
2599
|
value,
|
|
2500
|
-
style: [
|
|
2600
|
+
style: [styles22.value, { color: colors.text }],
|
|
2501
2601
|
testID: `${testID}-value`,
|
|
2502
2602
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
2503
2603
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -2511,7 +2611,7 @@ var CopyableId = ({
|
|
|
2511
2611
|
accessibilityLabel: t(action.key),
|
|
2512
2612
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
2513
2613
|
testID: `${testID}-copy`,
|
|
2514
|
-
style: [
|
|
2614
|
+
style: [styles22.action, { color: action.color }],
|
|
2515
2615
|
children: t(action.key)
|
|
2516
2616
|
}
|
|
2517
2617
|
)
|
|
@@ -2536,15 +2636,15 @@ function formatBuildInfo(buildVersion, apiCommit) {
|
|
|
2536
2636
|
return `${base}${API_COMMIT_SEPARATOR}${shortenCommit(commit)}`;
|
|
2537
2637
|
}
|
|
2538
2638
|
function useApiCommit(apiBaseUrl, fetchImpl) {
|
|
2539
|
-
const [commit, setCommit] =
|
|
2540
|
-
const mountedRef =
|
|
2541
|
-
|
|
2639
|
+
const [commit, setCommit] = React14.useState(void 0);
|
|
2640
|
+
const mountedRef = React14.useRef(true);
|
|
2641
|
+
React14.useEffect(() => {
|
|
2542
2642
|
mountedRef.current = true;
|
|
2543
2643
|
return () => {
|
|
2544
2644
|
mountedRef.current = false;
|
|
2545
2645
|
};
|
|
2546
2646
|
}, []);
|
|
2547
|
-
|
|
2647
|
+
React14.useEffect(() => {
|
|
2548
2648
|
if (apiBaseUrl === void 0 || apiBaseUrl === "") return;
|
|
2549
2649
|
const doFetch = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
2550
2650
|
if (doFetch === void 0) return;
|
|
@@ -2566,7 +2666,7 @@ var FOOTER_PADDING_V = 6;
|
|
|
2566
2666
|
var FOOTER_PADDING_H = 12;
|
|
2567
2667
|
var FOOTER_FONT_SIZE = 11;
|
|
2568
2668
|
var FOOTER_OPACITY = 0.75;
|
|
2569
|
-
var
|
|
2669
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
2570
2670
|
footer: {
|
|
2571
2671
|
paddingVertical: FOOTER_PADDING_V,
|
|
2572
2672
|
paddingHorizontal: FOOTER_PADDING_H,
|
|
@@ -2591,8 +2691,8 @@ var BuildInfoFooter = ({
|
|
|
2591
2691
|
const fetchedCommit = useApiCommit(apiCommit === void 0 ? apiBaseUrl : void 0, fetchImpl);
|
|
2592
2692
|
const commit = apiCommit ?? fetchedCommit;
|
|
2593
2693
|
const label = formatBuildInfo(buildVersion, commit);
|
|
2594
|
-
const textStyle =
|
|
2595
|
-
() => [
|
|
2694
|
+
const textStyle = React14.useMemo(
|
|
2695
|
+
() => [styles23.text, { color: theme.colors.textSecondary }],
|
|
2596
2696
|
[theme.colors.textSecondary]
|
|
2597
2697
|
);
|
|
2598
2698
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2600,7 +2700,7 @@ var BuildInfoFooter = ({
|
|
|
2600
2700
|
{
|
|
2601
2701
|
accessibilityLabel: accessibilityLabel ?? label,
|
|
2602
2702
|
accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
|
|
2603
|
-
style: [
|
|
2703
|
+
style: [styles23.footer, style],
|
|
2604
2704
|
testID,
|
|
2605
2705
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
|
|
2606
2706
|
}
|
|
@@ -2611,7 +2711,7 @@ var BORDER = 2;
|
|
|
2611
2711
|
var GLYPH_SIZE = 14;
|
|
2612
2712
|
var GLYPH_LINE = 16;
|
|
2613
2713
|
var TICK = "\u2713";
|
|
2614
|
-
var
|
|
2714
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
2615
2715
|
circle: {
|
|
2616
2716
|
width: SIZE,
|
|
2617
2717
|
height: SIZE,
|
|
@@ -2628,14 +2728,14 @@ var CheckMark = ({ filled, accent, ring, glyphColor, testID }) => /* @__PURE__ *
|
|
|
2628
2728
|
"aria-hidden": true,
|
|
2629
2729
|
accessibilityElementsHidden: true,
|
|
2630
2730
|
importantForAccessibility: "no-hide-descendants",
|
|
2631
|
-
style: [
|
|
2731
|
+
style: [styles24.circle, { borderColor: filled ? accent : ring, backgroundColor: filled ? accent : void 0 }],
|
|
2632
2732
|
testID,
|
|
2633
|
-
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2733
|
+
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.glyph, { color: glyphColor }], children: TICK }) : null
|
|
2634
2734
|
}
|
|
2635
2735
|
);
|
|
2636
|
-
var ListRowToneContext =
|
|
2736
|
+
var ListRowToneContext = React14.createContext(null);
|
|
2637
2737
|
function useListRowTone() {
|
|
2638
|
-
return
|
|
2738
|
+
return React14.useContext(ListRowToneContext);
|
|
2639
2739
|
}
|
|
2640
2740
|
function useRowPalette() {
|
|
2641
2741
|
const { colors, palette, semantic } = uiFeedback.useUi().theme;
|
|
@@ -2753,7 +2853,7 @@ var PAD_V = 12;
|
|
|
2753
2853
|
var GAP = 4;
|
|
2754
2854
|
var MARK_GAP = 12;
|
|
2755
2855
|
var LINE_GAP = 8;
|
|
2756
|
-
var
|
|
2856
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
2757
2857
|
row: {
|
|
2758
2858
|
flexDirection: "row",
|
|
2759
2859
|
alignItems: "center",
|
|
@@ -2777,7 +2877,7 @@ function focusTarget(event) {
|
|
|
2777
2877
|
}
|
|
2778
2878
|
function slot(node, color, strong) {
|
|
2779
2879
|
if (typeof node !== "string") return node;
|
|
2780
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles25.shrink, strong ? styles25.strong : null, { color }], children: node });
|
|
2781
2881
|
}
|
|
2782
2882
|
var ListRow = ({
|
|
2783
2883
|
title,
|
|
@@ -2794,9 +2894,9 @@ var ListRow = ({
|
|
|
2794
2894
|
}) => {
|
|
2795
2895
|
const palette = useRowPalette();
|
|
2796
2896
|
const { colors } = uiFeedback.useUi().theme;
|
|
2797
|
-
const [focused, setFocused] =
|
|
2897
|
+
const [focused, setFocused] = React14.useState(false);
|
|
2798
2898
|
const rest = resolveRowLook(selectedStyle, { selected, hovered: false, pressed: false, focused }, palette);
|
|
2799
|
-
const tone =
|
|
2899
|
+
const tone = React14.useMemo(() => ({ textColor: rest.textColor, inverse: rest.inverse }), [rest.textColor, rest.inverse]);
|
|
2800
2900
|
const checkTestId = testID === void 0 ? void 0 : `${testID}-check`;
|
|
2801
2901
|
return /* @__PURE__ */ jsxRuntime.jsxs(ListRowToneContext.Provider, { value: tone, children: [
|
|
2802
2902
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2809,7 +2909,7 @@ var ListRow = ({
|
|
|
2809
2909
|
style: (state) => {
|
|
2810
2910
|
const { pressed, hovered } = state;
|
|
2811
2911
|
const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
|
|
2812
|
-
return [
|
|
2912
|
+
return [styles25.row, { borderTopColor: colors.border }, look.container];
|
|
2813
2913
|
},
|
|
2814
2914
|
testID,
|
|
2815
2915
|
onBlur: () => {
|
|
@@ -2822,14 +2922,14 @@ var ListRow = ({
|
|
|
2822
2922
|
...pressedProps(selected),
|
|
2823
2923
|
children: [
|
|
2824
2924
|
rest.showCheck ? /* @__PURE__ */ jsxRuntime.jsx(CheckMark, { accent: palette.accent, filled: rest.checkFilled, glyphColor: palette.background, ring: palette.border, testID: checkTestId }) : null,
|
|
2825
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2826
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2925
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.body, children: [
|
|
2926
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.line, children: [
|
|
2827
2927
|
slot(title, rest.titleColor, true),
|
|
2828
2928
|
slot(trailing, rest.textColor, true)
|
|
2829
2929
|
] }),
|
|
2830
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2831
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
2832
|
-
badges === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
2930
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.line, children: [
|
|
2931
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles25.shrink, children: slot(meta, rest.textColor, false) }),
|
|
2932
|
+
badges === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles25.badges, children: badges })
|
|
2833
2933
|
] })
|
|
2834
2934
|
] })
|
|
2835
2935
|
]
|
|
@@ -2845,6 +2945,7 @@ exports.Accordion = Accordion;
|
|
|
2845
2945
|
exports.AccordionItem = AccordionItem;
|
|
2846
2946
|
exports.AppText = AppText;
|
|
2847
2947
|
exports.BUILD_INFO_PREFIX = BUILD_INFO_PREFIX;
|
|
2948
|
+
exports.BottomSheet = BottomSheet;
|
|
2848
2949
|
exports.BuildInfoFooter = BuildInfoFooter;
|
|
2849
2950
|
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
2850
2951
|
exports.ConfirmDialog = ConfirmDialog;
|