@dloizides/ui-layout 1.39.3 → 1.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +242 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -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,110 @@ 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
|
+
const hardwareBackClose = reactNative.Platform.OS === "web" ? void 0 : onClose;
|
|
1961
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: hardwareBackClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.root, children: [
|
|
1962
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [reactNative.StyleSheet.absoluteFill, styles17.backdrop, { opacity: backdrop.style.opacity }] }),
|
|
1963
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1964
|
+
reactNative.Pressable,
|
|
1965
|
+
{
|
|
1966
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1967
|
+
accessibilityLabel: t(LAYOUT_I18N.dialogClose),
|
|
1968
|
+
accessibilityRole: "button",
|
|
1969
|
+
style: reactNative.StyleSheet.absoluteFill,
|
|
1970
|
+
testID: `${testID}-backdrop`,
|
|
1971
|
+
onPress: onClose
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1975
|
+
reactNative.Animated.View,
|
|
1976
|
+
{
|
|
1977
|
+
ref: panelRef,
|
|
1978
|
+
accessibilityViewIsModal: true,
|
|
1979
|
+
"aria-modal": true,
|
|
1980
|
+
"aria-label": accessibilityLabel ?? title,
|
|
1981
|
+
role: "dialog",
|
|
1982
|
+
style: [
|
|
1983
|
+
styles17.panel,
|
|
1984
|
+
isWide ? styles17.wide : null,
|
|
1985
|
+
panelSize,
|
|
1986
|
+
{ backgroundColor: theme.colors.surface },
|
|
1987
|
+
panel.style
|
|
1988
|
+
],
|
|
1989
|
+
testID,
|
|
1990
|
+
children: [
|
|
1991
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.header, children: [
|
|
1992
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.title, children: /* @__PURE__ */ jsxRuntime.jsx(AppText, { kind: "title" /* Title */, children: title }) }),
|
|
1993
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1994
|
+
reactNative.TouchableOpacity,
|
|
1995
|
+
{
|
|
1996
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1997
|
+
accessibilityLabel: t(LAYOUT_I18N.dialogClose),
|
|
1998
|
+
accessibilityRole: "button",
|
|
1999
|
+
style: styles17.close,
|
|
2000
|
+
testID: `${testID}-close`,
|
|
2001
|
+
onPress: onClose,
|
|
2002
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE2 })
|
|
2003
|
+
}
|
|
2004
|
+
)
|
|
2005
|
+
] }),
|
|
2006
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { contentContainerStyle: styles17.content, style: styles17.body, children }),
|
|
2007
|
+
hasFooter ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles17.footer, { borderColor: theme.colors.border }], testID: `${testID}-footer`, children: footer }) : null
|
|
2008
|
+
]
|
|
2009
|
+
}
|
|
2010
|
+
)
|
|
2011
|
+
] }) });
|
|
2012
|
+
};
|
|
1912
2013
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1913
2014
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1914
2015
|
var BUTTON_GAP = 12;
|
|
1915
|
-
var
|
|
2016
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
1916
2017
|
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1917
2018
|
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1918
2019
|
});
|
|
@@ -1931,7 +2032,7 @@ var ConfirmDialog = ({
|
|
|
1931
2032
|
const { theme, t } = uiFeedback.useUi();
|
|
1932
2033
|
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1933
2034
|
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1934
|
-
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2035
|
+
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.footer, children: [
|
|
1935
2036
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1936
2037
|
uiButtons.Button,
|
|
1937
2038
|
{
|
|
@@ -1967,27 +2068,27 @@ var ConfirmDialog = ({
|
|
|
1967
2068
|
title,
|
|
1968
2069
|
visible,
|
|
1969
2070
|
onClose: onCancel,
|
|
1970
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2071
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles18.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1971
2072
|
}
|
|
1972
2073
|
);
|
|
1973
2074
|
};
|
|
1974
|
-
var AccordionContext =
|
|
2075
|
+
var AccordionContext = React14.createContext(null);
|
|
1975
2076
|
function useAccordionContext() {
|
|
1976
|
-
const value =
|
|
2077
|
+
const value = React14.useContext(AccordionContext);
|
|
1977
2078
|
if (value === null) {
|
|
1978
2079
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1979
2080
|
}
|
|
1980
2081
|
return value;
|
|
1981
2082
|
}
|
|
1982
2083
|
var BOXED_GAP = 12;
|
|
1983
|
-
var
|
|
2084
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
1984
2085
|
container: { alignSelf: "stretch" },
|
|
1985
2086
|
boxed: { gap: BOXED_GAP }
|
|
1986
2087
|
});
|
|
1987
2088
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1988
2089
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1989
|
-
|
|
1990
|
-
if (!
|
|
2090
|
+
React14__default.default.Children.forEach(children, (child) => {
|
|
2091
|
+
if (!React14__default.default.isValidElement(child)) return;
|
|
1991
2092
|
const props = child.props;
|
|
1992
2093
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1993
2094
|
ids.add(props.id);
|
|
@@ -2010,14 +2111,14 @@ var Accordion = ({
|
|
|
2010
2111
|
style
|
|
2011
2112
|
}) => {
|
|
2012
2113
|
const isControlled = openIds !== void 0;
|
|
2013
|
-
const [internalOpen, setInternalOpen] =
|
|
2114
|
+
const [internalOpen, setInternalOpen] = React14.useState(
|
|
2014
2115
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
2015
2116
|
);
|
|
2016
|
-
const openSet =
|
|
2117
|
+
const openSet = React14.useMemo(
|
|
2017
2118
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
2018
2119
|
[isControlled, openIds, internalOpen]
|
|
2019
2120
|
);
|
|
2020
|
-
const toggle =
|
|
2121
|
+
const toggle = React14.useCallback(
|
|
2021
2122
|
(id) => {
|
|
2022
2123
|
const next = new Set(openSet);
|
|
2023
2124
|
const willOpen = !next.has(id);
|
|
@@ -2032,12 +2133,12 @@ var Accordion = ({
|
|
|
2032
2133
|
},
|
|
2033
2134
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
2034
2135
|
);
|
|
2035
|
-
const contextValue =
|
|
2136
|
+
const contextValue = React14.useMemo(
|
|
2036
2137
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
2037
2138
|
[openSet, toggle, allowMultiple, variant]
|
|
2038
2139
|
);
|
|
2039
|
-
const containerStyle =
|
|
2040
|
-
const base = variant === "boxed" ? [
|
|
2140
|
+
const containerStyle = React14.useMemo(() => {
|
|
2141
|
+
const base = variant === "boxed" ? [styles19.container, styles19.boxed] : [styles19.container];
|
|
2041
2142
|
if (style === void 0) return base;
|
|
2042
2143
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
2043
2144
|
}, [style, variant]);
|
|
@@ -2069,7 +2170,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
2069
2170
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
2070
2171
|
var BOX_MARKER_GAP = 6;
|
|
2071
2172
|
var BOX_MARKER = "\u25B8";
|
|
2072
|
-
var
|
|
2173
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2073
2174
|
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
2074
2175
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
2075
2176
|
header: {
|
|
@@ -2115,9 +2216,9 @@ var AccordionItem = ({
|
|
|
2115
2216
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
2116
2217
|
const bodyTestID = `${headerTestID}-body`;
|
|
2117
2218
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
2118
|
-
const [rotation] =
|
|
2219
|
+
const [rotation] = React14.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
2119
2220
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
2120
|
-
|
|
2221
|
+
React14.useEffect(() => {
|
|
2121
2222
|
reactNative.Animated.timing(rotation, {
|
|
2122
2223
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
2123
2224
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -2129,10 +2230,10 @@ var AccordionItem = ({
|
|
|
2129
2230
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
2130
2231
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
2131
2232
|
});
|
|
2132
|
-
const handlePress =
|
|
2233
|
+
const handlePress = React14.useCallback(() => {
|
|
2133
2234
|
if (!disabled) toggle(id);
|
|
2134
2235
|
}, [disabled, id, toggle]);
|
|
2135
|
-
const handleKeyDown2 =
|
|
2236
|
+
const handleKeyDown2 = React14.useCallback(
|
|
2136
2237
|
(event) => {
|
|
2137
2238
|
if (disabled) return;
|
|
2138
2239
|
const key = event.key ?? "";
|
|
@@ -2144,20 +2245,20 @@ var AccordionItem = ({
|
|
|
2144
2245
|
[disabled, id, toggle]
|
|
2145
2246
|
);
|
|
2146
2247
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
2147
|
-
const itemStyle =
|
|
2148
|
-
() => boxed ? [
|
|
2248
|
+
const itemStyle = React14.useMemo(
|
|
2249
|
+
() => boxed ? [styles20.boxItem, { borderColor: colors.border }] : [styles20.item, { borderTopColor: colors.border }],
|
|
2149
2250
|
[boxed, colors.border]
|
|
2150
2251
|
);
|
|
2151
|
-
const headerStyle =
|
|
2252
|
+
const headerStyle = React14.useMemo(
|
|
2152
2253
|
() => [
|
|
2153
|
-
|
|
2154
|
-
...boxed ? [
|
|
2254
|
+
styles20.header,
|
|
2255
|
+
...boxed ? [styles20.boxHeader] : [],
|
|
2155
2256
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
2156
2257
|
],
|
|
2157
2258
|
[boxed, disabled]
|
|
2158
2259
|
);
|
|
2159
2260
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
2160
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ?
|
|
2261
|
+
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
2262
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
2162
2263
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2163
2264
|
reactNative.Pressable,
|
|
@@ -2174,7 +2275,7 @@ var AccordionItem = ({
|
|
|
2174
2275
|
onPress: handlePress,
|
|
2175
2276
|
...keyboardProps,
|
|
2176
2277
|
children: [
|
|
2177
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2278
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles20.headerLeft, boxed ? styles20.headerLeftRow : null], children: [
|
|
2178
2279
|
boxed ? (
|
|
2179
2280
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
2180
2281
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2183,15 +2284,15 @@ var AccordionItem = ({
|
|
|
2183
2284
|
accessibilityElementsHidden: true,
|
|
2184
2285
|
"aria-hidden": true,
|
|
2185
2286
|
importantForAccessibility: "no-hide-descendants",
|
|
2186
|
-
style: [
|
|
2287
|
+
style: [styles20.marker, { transform: [{ rotate }] }],
|
|
2187
2288
|
testID: chevronTestID,
|
|
2188
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2289
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
2189
2290
|
}
|
|
2190
2291
|
)
|
|
2191
2292
|
) : null,
|
|
2192
2293
|
titleNode
|
|
2193
2294
|
] }),
|
|
2194
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2295
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles20.headerRight, children: [
|
|
2195
2296
|
right,
|
|
2196
2297
|
boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2197
2298
|
reactNative.Animated.View,
|
|
@@ -2199,7 +2300,7 @@ var AccordionItem = ({
|
|
|
2199
2300
|
accessibilityElementsHidden: true,
|
|
2200
2301
|
"aria-hidden": true,
|
|
2201
2302
|
importantForAccessibility: "no-hide-descendants",
|
|
2202
|
-
style: [
|
|
2303
|
+
style: [styles20.chevron, { transform: [{ rotate }] }],
|
|
2203
2304
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
2204
2305
|
}
|
|
2205
2306
|
)
|
|
@@ -2213,7 +2314,7 @@ var AccordionItem = ({
|
|
|
2213
2314
|
accessibilityLabel: resolvedLabel,
|
|
2214
2315
|
nativeID: bodyTestID,
|
|
2215
2316
|
role: ROLE_REGION,
|
|
2216
|
-
style: boxed ?
|
|
2317
|
+
style: boxed ? styles20.boxBody : styles20.body,
|
|
2217
2318
|
testID: bodyTestID,
|
|
2218
2319
|
children
|
|
2219
2320
|
}
|
|
@@ -2251,14 +2352,14 @@ function measureParentInnerWidth(node) {
|
|
|
2251
2352
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
2252
2353
|
}
|
|
2253
2354
|
function useAvailableWidth() {
|
|
2254
|
-
const [width, setWidth] =
|
|
2255
|
-
const nodeRef =
|
|
2256
|
-
const measureRef =
|
|
2355
|
+
const [width, setWidth] = React14.useState(UNMEASURED);
|
|
2356
|
+
const nodeRef = React14.useRef(null);
|
|
2357
|
+
const measureRef = React14.useCallback((node) => {
|
|
2257
2358
|
if (!IS_WEB4) return;
|
|
2258
2359
|
nodeRef.current = node;
|
|
2259
2360
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
2260
2361
|
}, []);
|
|
2261
|
-
|
|
2362
|
+
React14.useEffect(() => {
|
|
2262
2363
|
if (!IS_WEB4) return void 0;
|
|
2263
2364
|
const remeasure = () => {
|
|
2264
2365
|
const node = nodeRef.current;
|
|
@@ -2267,7 +2368,7 @@ function useAvailableWidth() {
|
|
|
2267
2368
|
window.addEventListener("resize", remeasure);
|
|
2268
2369
|
return () => window.removeEventListener("resize", remeasure);
|
|
2269
2370
|
}, []);
|
|
2270
|
-
const onLayout =
|
|
2371
|
+
const onLayout = React14.useCallback((event) => {
|
|
2271
2372
|
if (IS_WEB4) return;
|
|
2272
2373
|
setWidth(event.nativeEvent.layout.width);
|
|
2273
2374
|
}, []);
|
|
@@ -2276,7 +2377,7 @@ function useAvailableWidth() {
|
|
|
2276
2377
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
2277
2378
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
2278
2379
|
var UNMEASURED2 = 0;
|
|
2279
|
-
var
|
|
2380
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2280
2381
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
2281
2382
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
2282
2383
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -2296,8 +2397,8 @@ var TruncatedText = ({
|
|
|
2296
2397
|
accessibilityHint
|
|
2297
2398
|
}) => {
|
|
2298
2399
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
2299
|
-
const hostRef =
|
|
2300
|
-
const attachRef =
|
|
2400
|
+
const hostRef = React14.useRef(null);
|
|
2401
|
+
const attachRef = React14.useCallback(
|
|
2301
2402
|
(node) => {
|
|
2302
2403
|
hostRef.current = node;
|
|
2303
2404
|
measureRef(node);
|
|
@@ -2306,12 +2407,12 @@ var TruncatedText = ({
|
|
|
2306
2407
|
},
|
|
2307
2408
|
[value, measureRef]
|
|
2308
2409
|
);
|
|
2309
|
-
const flatStyle =
|
|
2310
|
-
() => reactNative.StyleSheet.flatten([
|
|
2410
|
+
const flatStyle = React14.useMemo(
|
|
2411
|
+
() => reactNative.StyleSheet.flatten([styles21.base, style]),
|
|
2311
2412
|
[style]
|
|
2312
2413
|
);
|
|
2313
2414
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
2314
|
-
const display =
|
|
2415
|
+
const display = React14.useMemo(() => {
|
|
2315
2416
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
2316
2417
|
const budget = charBudget(width, fontSize);
|
|
2317
2418
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -2322,7 +2423,7 @@ var TruncatedText = ({
|
|
|
2322
2423
|
ref: attachRef,
|
|
2323
2424
|
onLayout,
|
|
2324
2425
|
numberOfLines: 1,
|
|
2325
|
-
style: [
|
|
2426
|
+
style: [styles21.base, styles21.fill, style],
|
|
2326
2427
|
testID,
|
|
2327
2428
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
2328
2429
|
accessibilityLabel,
|
|
@@ -2393,17 +2494,17 @@ async function copyText(value, writer) {
|
|
|
2393
2494
|
// src/CopyableId/useCopyToClipboard.ts
|
|
2394
2495
|
var COPY_FEEDBACK_MS = 2e3;
|
|
2395
2496
|
function useCopyToClipboard(value, writer) {
|
|
2396
|
-
const [status, setStatus] =
|
|
2397
|
-
const timerRef =
|
|
2398
|
-
const mountedRef =
|
|
2399
|
-
|
|
2497
|
+
const [status, setStatus] = React14.useState("idle" /* Idle */);
|
|
2498
|
+
const timerRef = React14.useRef(null);
|
|
2499
|
+
const mountedRef = React14.useRef(true);
|
|
2500
|
+
React14.useEffect(() => {
|
|
2400
2501
|
mountedRef.current = true;
|
|
2401
2502
|
return () => {
|
|
2402
2503
|
mountedRef.current = false;
|
|
2403
2504
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2404
2505
|
};
|
|
2405
2506
|
}, []);
|
|
2406
|
-
const copy =
|
|
2507
|
+
const copy = React14.useCallback(() => {
|
|
2407
2508
|
void (async () => {
|
|
2408
2509
|
const ok = await copyText(value, writer);
|
|
2409
2510
|
if (!mountedRef.current) return;
|
|
@@ -2425,7 +2526,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
2425
2526
|
var ACTION_PADDING_H = 6;
|
|
2426
2527
|
var ACTION_PADDING_V = 2;
|
|
2427
2528
|
var ACTION_RADIUS = 6;
|
|
2428
|
-
var
|
|
2529
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
2429
2530
|
cell: { gap: CELL_GAP },
|
|
2430
2531
|
label: {
|
|
2431
2532
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -2467,7 +2568,7 @@ var styles21 = reactNative.StyleSheet.create({
|
|
|
2467
2568
|
var TONE_STEP = "500";
|
|
2468
2569
|
function useActionState(status) {
|
|
2469
2570
|
const { theme } = uiFeedback.useUi();
|
|
2470
|
-
return
|
|
2571
|
+
return React14.useMemo(() => {
|
|
2471
2572
|
const primary = theme.palette.primary[TONE_STEP];
|
|
2472
2573
|
if (status === "copied" /* Copied */) {
|
|
2473
2574
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
@@ -2490,14 +2591,14 @@ var CopyableId = ({
|
|
|
2490
2591
|
const { colors } = theme;
|
|
2491
2592
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
2492
2593
|
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:
|
|
2594
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles22.cell, style], testID, children: [
|
|
2595
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles22.label, { color: colors.textSecondary }], children: label }),
|
|
2596
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles22.row, children: [
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles22.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2497
2598
|
TruncatedText,
|
|
2498
2599
|
{
|
|
2499
2600
|
value,
|
|
2500
|
-
style: [
|
|
2601
|
+
style: [styles22.value, { color: colors.text }],
|
|
2501
2602
|
testID: `${testID}-value`,
|
|
2502
2603
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
2503
2604
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -2511,7 +2612,7 @@ var CopyableId = ({
|
|
|
2511
2612
|
accessibilityLabel: t(action.key),
|
|
2512
2613
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
2513
2614
|
testID: `${testID}-copy`,
|
|
2514
|
-
style: [
|
|
2615
|
+
style: [styles22.action, { color: action.color }],
|
|
2515
2616
|
children: t(action.key)
|
|
2516
2617
|
}
|
|
2517
2618
|
)
|
|
@@ -2536,15 +2637,15 @@ function formatBuildInfo(buildVersion, apiCommit) {
|
|
|
2536
2637
|
return `${base}${API_COMMIT_SEPARATOR}${shortenCommit(commit)}`;
|
|
2537
2638
|
}
|
|
2538
2639
|
function useApiCommit(apiBaseUrl, fetchImpl) {
|
|
2539
|
-
const [commit, setCommit] =
|
|
2540
|
-
const mountedRef =
|
|
2541
|
-
|
|
2640
|
+
const [commit, setCommit] = React14.useState(void 0);
|
|
2641
|
+
const mountedRef = React14.useRef(true);
|
|
2642
|
+
React14.useEffect(() => {
|
|
2542
2643
|
mountedRef.current = true;
|
|
2543
2644
|
return () => {
|
|
2544
2645
|
mountedRef.current = false;
|
|
2545
2646
|
};
|
|
2546
2647
|
}, []);
|
|
2547
|
-
|
|
2648
|
+
React14.useEffect(() => {
|
|
2548
2649
|
if (apiBaseUrl === void 0 || apiBaseUrl === "") return;
|
|
2549
2650
|
const doFetch = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
2550
2651
|
if (doFetch === void 0) return;
|
|
@@ -2566,7 +2667,7 @@ var FOOTER_PADDING_V = 6;
|
|
|
2566
2667
|
var FOOTER_PADDING_H = 12;
|
|
2567
2668
|
var FOOTER_FONT_SIZE = 11;
|
|
2568
2669
|
var FOOTER_OPACITY = 0.75;
|
|
2569
|
-
var
|
|
2670
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
2570
2671
|
footer: {
|
|
2571
2672
|
paddingVertical: FOOTER_PADDING_V,
|
|
2572
2673
|
paddingHorizontal: FOOTER_PADDING_H,
|
|
@@ -2591,8 +2692,8 @@ var BuildInfoFooter = ({
|
|
|
2591
2692
|
const fetchedCommit = useApiCommit(apiCommit === void 0 ? apiBaseUrl : void 0, fetchImpl);
|
|
2592
2693
|
const commit = apiCommit ?? fetchedCommit;
|
|
2593
2694
|
const label = formatBuildInfo(buildVersion, commit);
|
|
2594
|
-
const textStyle =
|
|
2595
|
-
() => [
|
|
2695
|
+
const textStyle = React14.useMemo(
|
|
2696
|
+
() => [styles23.text, { color: theme.colors.textSecondary }],
|
|
2596
2697
|
[theme.colors.textSecondary]
|
|
2597
2698
|
);
|
|
2598
2699
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2600,7 +2701,7 @@ var BuildInfoFooter = ({
|
|
|
2600
2701
|
{
|
|
2601
2702
|
accessibilityLabel: accessibilityLabel ?? label,
|
|
2602
2703
|
accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
|
|
2603
|
-
style: [
|
|
2704
|
+
style: [styles23.footer, style],
|
|
2604
2705
|
testID,
|
|
2605
2706
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
|
|
2606
2707
|
}
|
|
@@ -2611,7 +2712,7 @@ var BORDER = 2;
|
|
|
2611
2712
|
var GLYPH_SIZE = 14;
|
|
2612
2713
|
var GLYPH_LINE = 16;
|
|
2613
2714
|
var TICK = "\u2713";
|
|
2614
|
-
var
|
|
2715
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
2615
2716
|
circle: {
|
|
2616
2717
|
width: SIZE,
|
|
2617
2718
|
height: SIZE,
|
|
@@ -2628,14 +2729,14 @@ var CheckMark = ({ filled, accent, ring, glyphColor, testID }) => /* @__PURE__ *
|
|
|
2628
2729
|
"aria-hidden": true,
|
|
2629
2730
|
accessibilityElementsHidden: true,
|
|
2630
2731
|
importantForAccessibility: "no-hide-descendants",
|
|
2631
|
-
style: [
|
|
2732
|
+
style: [styles24.circle, { borderColor: filled ? accent : ring, backgroundColor: filled ? accent : void 0 }],
|
|
2632
2733
|
testID,
|
|
2633
|
-
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2734
|
+
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.glyph, { color: glyphColor }], children: TICK }) : null
|
|
2634
2735
|
}
|
|
2635
2736
|
);
|
|
2636
|
-
var ListRowToneContext =
|
|
2737
|
+
var ListRowToneContext = React14.createContext(null);
|
|
2637
2738
|
function useListRowTone() {
|
|
2638
|
-
return
|
|
2739
|
+
return React14.useContext(ListRowToneContext);
|
|
2639
2740
|
}
|
|
2640
2741
|
function useRowPalette() {
|
|
2641
2742
|
const { colors, palette, semantic } = uiFeedback.useUi().theme;
|
|
@@ -2753,7 +2854,7 @@ var PAD_V = 12;
|
|
|
2753
2854
|
var GAP = 4;
|
|
2754
2855
|
var MARK_GAP = 12;
|
|
2755
2856
|
var LINE_GAP = 8;
|
|
2756
|
-
var
|
|
2857
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
2757
2858
|
row: {
|
|
2758
2859
|
flexDirection: "row",
|
|
2759
2860
|
alignItems: "center",
|
|
@@ -2777,7 +2878,7 @@ function focusTarget(event) {
|
|
|
2777
2878
|
}
|
|
2778
2879
|
function slot(node, color, strong) {
|
|
2779
2880
|
if (typeof node !== "string") return node;
|
|
2780
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2881
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles25.shrink, strong ? styles25.strong : null, { color }], children: node });
|
|
2781
2882
|
}
|
|
2782
2883
|
var ListRow = ({
|
|
2783
2884
|
title,
|
|
@@ -2794,9 +2895,9 @@ var ListRow = ({
|
|
|
2794
2895
|
}) => {
|
|
2795
2896
|
const palette = useRowPalette();
|
|
2796
2897
|
const { colors } = uiFeedback.useUi().theme;
|
|
2797
|
-
const [focused, setFocused] =
|
|
2898
|
+
const [focused, setFocused] = React14.useState(false);
|
|
2798
2899
|
const rest = resolveRowLook(selectedStyle, { selected, hovered: false, pressed: false, focused }, palette);
|
|
2799
|
-
const tone =
|
|
2900
|
+
const tone = React14.useMemo(() => ({ textColor: rest.textColor, inverse: rest.inverse }), [rest.textColor, rest.inverse]);
|
|
2800
2901
|
const checkTestId = testID === void 0 ? void 0 : `${testID}-check`;
|
|
2801
2902
|
return /* @__PURE__ */ jsxRuntime.jsxs(ListRowToneContext.Provider, { value: tone, children: [
|
|
2802
2903
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2809,7 +2910,7 @@ var ListRow = ({
|
|
|
2809
2910
|
style: (state) => {
|
|
2810
2911
|
const { pressed, hovered } = state;
|
|
2811
2912
|
const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
|
|
2812
|
-
return [
|
|
2913
|
+
return [styles25.row, { borderTopColor: colors.border }, look.container];
|
|
2813
2914
|
},
|
|
2814
2915
|
testID,
|
|
2815
2916
|
onBlur: () => {
|
|
@@ -2822,14 +2923,14 @@ var ListRow = ({
|
|
|
2822
2923
|
...pressedProps(selected),
|
|
2823
2924
|
children: [
|
|
2824
2925
|
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:
|
|
2926
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.body, children: [
|
|
2927
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.line, children: [
|
|
2827
2928
|
slot(title, rest.titleColor, true),
|
|
2828
2929
|
slot(trailing, rest.textColor, true)
|
|
2829
2930
|
] }),
|
|
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:
|
|
2931
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles25.line, children: [
|
|
2932
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles25.shrink, children: slot(meta, rest.textColor, false) }),
|
|
2933
|
+
badges === void 0 ? null : /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles25.badges, children: badges })
|
|
2833
2934
|
] })
|
|
2834
2935
|
] })
|
|
2835
2936
|
]
|
|
@@ -2845,6 +2946,7 @@ exports.Accordion = Accordion;
|
|
|
2845
2946
|
exports.AccordionItem = AccordionItem;
|
|
2846
2947
|
exports.AppText = AppText;
|
|
2847
2948
|
exports.BUILD_INFO_PREFIX = BUILD_INFO_PREFIX;
|
|
2949
|
+
exports.BottomSheet = BottomSheet;
|
|
2848
2950
|
exports.BuildInfoFooter = BuildInfoFooter;
|
|
2849
2951
|
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
2850
2952
|
exports.ConfirmDialog = ConfirmDialog;
|