@dloizides/ui-layout 1.39.2 → 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 +245 -141
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -48
- 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}`;
|
|
@@ -1772,7 +1773,10 @@ var styles15 = reactNative.StyleSheet.create({
|
|
|
1772
1773
|
justifyContent: "space-between"
|
|
1773
1774
|
},
|
|
1774
1775
|
closeButton: {
|
|
1775
|
-
|
|
1776
|
+
minWidth: a11y.MIN_TOUCH_TARGET_PX,
|
|
1777
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
1778
|
+
alignItems: "center",
|
|
1779
|
+
justifyContent: "center",
|
|
1776
1780
|
borderRadius: 6
|
|
1777
1781
|
}
|
|
1778
1782
|
});
|
|
@@ -1786,7 +1790,7 @@ var ModalShell = ({
|
|
|
1786
1790
|
}) => {
|
|
1787
1791
|
const { theme, t } = uiFeedback.useUi();
|
|
1788
1792
|
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1789
|
-
const containerStyle =
|
|
1793
|
+
const containerStyle = React14__default.default.useMemo(
|
|
1790
1794
|
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1791
1795
|
[theme.colors.background, contentStyle]
|
|
1792
1796
|
);
|
|
@@ -1861,7 +1865,7 @@ var SideSheet = ({
|
|
|
1861
1865
|
}) => {
|
|
1862
1866
|
const { theme, t } = uiFeedback.useUi();
|
|
1863
1867
|
const isWide = useIsWideViewport();
|
|
1864
|
-
const sheetRef =
|
|
1868
|
+
const sheetRef = React14.useRef(null);
|
|
1865
1869
|
const backdrop = uiMotion.useEnterExit({ visible });
|
|
1866
1870
|
const panel = uiMotion.useEnterExit({ visible, translateY: isWide ? 0 : PHONE_ENTER_OFFSET });
|
|
1867
1871
|
const edges = { borderColor: theme.colors.border };
|
|
@@ -1906,10 +1910,109 @@ var SideSheet = ({
|
|
|
1906
1910
|
)
|
|
1907
1911
|
] }) });
|
|
1908
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
|
+
};
|
|
1909
2012
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1910
2013
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1911
2014
|
var BUTTON_GAP = 12;
|
|
1912
|
-
var
|
|
2015
|
+
var styles18 = reactNative.StyleSheet.create({
|
|
1913
2016
|
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1914
2017
|
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1915
2018
|
});
|
|
@@ -1928,7 +2031,7 @@ var ConfirmDialog = ({
|
|
|
1928
2031
|
const { theme, t } = uiFeedback.useUi();
|
|
1929
2032
|
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1930
2033
|
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1931
|
-
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2034
|
+
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles18.footer, children: [
|
|
1932
2035
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1933
2036
|
uiButtons.Button,
|
|
1934
2037
|
{
|
|
@@ -1964,27 +2067,27 @@ var ConfirmDialog = ({
|
|
|
1964
2067
|
title,
|
|
1965
2068
|
visible,
|
|
1966
2069
|
onClose: onCancel,
|
|
1967
|
-
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 })
|
|
1968
2071
|
}
|
|
1969
2072
|
);
|
|
1970
2073
|
};
|
|
1971
|
-
var AccordionContext =
|
|
2074
|
+
var AccordionContext = React14.createContext(null);
|
|
1972
2075
|
function useAccordionContext() {
|
|
1973
|
-
const value =
|
|
2076
|
+
const value = React14.useContext(AccordionContext);
|
|
1974
2077
|
if (value === null) {
|
|
1975
2078
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1976
2079
|
}
|
|
1977
2080
|
return value;
|
|
1978
2081
|
}
|
|
1979
2082
|
var BOXED_GAP = 12;
|
|
1980
|
-
var
|
|
2083
|
+
var styles19 = reactNative.StyleSheet.create({
|
|
1981
2084
|
container: { alignSelf: "stretch" },
|
|
1982
2085
|
boxed: { gap: BOXED_GAP }
|
|
1983
2086
|
});
|
|
1984
2087
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1985
2088
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1986
|
-
|
|
1987
|
-
if (!
|
|
2089
|
+
React14__default.default.Children.forEach(children, (child) => {
|
|
2090
|
+
if (!React14__default.default.isValidElement(child)) return;
|
|
1988
2091
|
const props = child.props;
|
|
1989
2092
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1990
2093
|
ids.add(props.id);
|
|
@@ -2007,14 +2110,14 @@ var Accordion = ({
|
|
|
2007
2110
|
style
|
|
2008
2111
|
}) => {
|
|
2009
2112
|
const isControlled = openIds !== void 0;
|
|
2010
|
-
const [internalOpen, setInternalOpen] =
|
|
2113
|
+
const [internalOpen, setInternalOpen] = React14.useState(
|
|
2011
2114
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
2012
2115
|
);
|
|
2013
|
-
const openSet =
|
|
2116
|
+
const openSet = React14.useMemo(
|
|
2014
2117
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
2015
2118
|
[isControlled, openIds, internalOpen]
|
|
2016
2119
|
);
|
|
2017
|
-
const toggle =
|
|
2120
|
+
const toggle = React14.useCallback(
|
|
2018
2121
|
(id) => {
|
|
2019
2122
|
const next = new Set(openSet);
|
|
2020
2123
|
const willOpen = !next.has(id);
|
|
@@ -2029,12 +2132,12 @@ var Accordion = ({
|
|
|
2029
2132
|
},
|
|
2030
2133
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
2031
2134
|
);
|
|
2032
|
-
const contextValue =
|
|
2135
|
+
const contextValue = React14.useMemo(
|
|
2033
2136
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
2034
2137
|
[openSet, toggle, allowMultiple, variant]
|
|
2035
2138
|
);
|
|
2036
|
-
const containerStyle =
|
|
2037
|
-
const base = variant === "boxed" ? [
|
|
2139
|
+
const containerStyle = React14.useMemo(() => {
|
|
2140
|
+
const base = variant === "boxed" ? [styles19.container, styles19.boxed] : [styles19.container];
|
|
2038
2141
|
if (style === void 0) return base;
|
|
2039
2142
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
2040
2143
|
}, [style, variant]);
|
|
@@ -2066,7 +2169,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
2066
2169
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
2067
2170
|
var BOX_MARKER_GAP = 6;
|
|
2068
2171
|
var BOX_MARKER = "\u25B8";
|
|
2069
|
-
var
|
|
2172
|
+
var styles20 = reactNative.StyleSheet.create({
|
|
2070
2173
|
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
2071
2174
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
2072
2175
|
header: {
|
|
@@ -2112,9 +2215,9 @@ var AccordionItem = ({
|
|
|
2112
2215
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
2113
2216
|
const bodyTestID = `${headerTestID}-body`;
|
|
2114
2217
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
2115
|
-
const [rotation] =
|
|
2218
|
+
const [rotation] = React14.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
2116
2219
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
2117
|
-
|
|
2220
|
+
React14.useEffect(() => {
|
|
2118
2221
|
reactNative.Animated.timing(rotation, {
|
|
2119
2222
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
2120
2223
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -2126,10 +2229,10 @@ var AccordionItem = ({
|
|
|
2126
2229
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
2127
2230
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
2128
2231
|
});
|
|
2129
|
-
const handlePress =
|
|
2232
|
+
const handlePress = React14.useCallback(() => {
|
|
2130
2233
|
if (!disabled) toggle(id);
|
|
2131
2234
|
}, [disabled, id, toggle]);
|
|
2132
|
-
const handleKeyDown2 =
|
|
2235
|
+
const handleKeyDown2 = React14.useCallback(
|
|
2133
2236
|
(event) => {
|
|
2134
2237
|
if (disabled) return;
|
|
2135
2238
|
const key = event.key ?? "";
|
|
@@ -2141,20 +2244,20 @@ var AccordionItem = ({
|
|
|
2141
2244
|
[disabled, id, toggle]
|
|
2142
2245
|
);
|
|
2143
2246
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
2144
|
-
const itemStyle =
|
|
2145
|
-
() => boxed ? [
|
|
2247
|
+
const itemStyle = React14.useMemo(
|
|
2248
|
+
() => boxed ? [styles20.boxItem, { borderColor: colors.border }] : [styles20.item, { borderTopColor: colors.border }],
|
|
2146
2249
|
[boxed, colors.border]
|
|
2147
2250
|
);
|
|
2148
|
-
const headerStyle =
|
|
2251
|
+
const headerStyle = React14.useMemo(
|
|
2149
2252
|
() => [
|
|
2150
|
-
|
|
2151
|
-
...boxed ? [
|
|
2253
|
+
styles20.header,
|
|
2254
|
+
...boxed ? [styles20.boxHeader] : [],
|
|
2152
2255
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
2153
2256
|
],
|
|
2154
2257
|
[boxed, disabled]
|
|
2155
2258
|
);
|
|
2156
2259
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
2157
|
-
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;
|
|
2158
2261
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
2159
2262
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2160
2263
|
reactNative.Pressable,
|
|
@@ -2171,7 +2274,7 @@ var AccordionItem = ({
|
|
|
2171
2274
|
onPress: handlePress,
|
|
2172
2275
|
...keyboardProps,
|
|
2173
2276
|
children: [
|
|
2174
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2277
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles20.headerLeft, boxed ? styles20.headerLeftRow : null], children: [
|
|
2175
2278
|
boxed ? (
|
|
2176
2279
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
2177
2280
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2180,15 +2283,15 @@ var AccordionItem = ({
|
|
|
2180
2283
|
accessibilityElementsHidden: true,
|
|
2181
2284
|
"aria-hidden": true,
|
|
2182
2285
|
importantForAccessibility: "no-hide-descendants",
|
|
2183
|
-
style: [
|
|
2286
|
+
style: [styles20.marker, { transform: [{ rotate }] }],
|
|
2184
2287
|
testID: chevronTestID,
|
|
2185
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2288
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles20.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
2186
2289
|
}
|
|
2187
2290
|
)
|
|
2188
2291
|
) : null,
|
|
2189
2292
|
titleNode
|
|
2190
2293
|
] }),
|
|
2191
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2294
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles20.headerRight, children: [
|
|
2192
2295
|
right,
|
|
2193
2296
|
boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2194
2297
|
reactNative.Animated.View,
|
|
@@ -2196,7 +2299,7 @@ var AccordionItem = ({
|
|
|
2196
2299
|
accessibilityElementsHidden: true,
|
|
2197
2300
|
"aria-hidden": true,
|
|
2198
2301
|
importantForAccessibility: "no-hide-descendants",
|
|
2199
|
-
style: [
|
|
2302
|
+
style: [styles20.chevron, { transform: [{ rotate }] }],
|
|
2200
2303
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
2201
2304
|
}
|
|
2202
2305
|
)
|
|
@@ -2210,7 +2313,7 @@ var AccordionItem = ({
|
|
|
2210
2313
|
accessibilityLabel: resolvedLabel,
|
|
2211
2314
|
nativeID: bodyTestID,
|
|
2212
2315
|
role: ROLE_REGION,
|
|
2213
|
-
style: boxed ?
|
|
2316
|
+
style: boxed ? styles20.boxBody : styles20.body,
|
|
2214
2317
|
testID: bodyTestID,
|
|
2215
2318
|
children
|
|
2216
2319
|
}
|
|
@@ -2248,14 +2351,14 @@ function measureParentInnerWidth(node) {
|
|
|
2248
2351
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
2249
2352
|
}
|
|
2250
2353
|
function useAvailableWidth() {
|
|
2251
|
-
const [width, setWidth] =
|
|
2252
|
-
const nodeRef =
|
|
2253
|
-
const measureRef =
|
|
2354
|
+
const [width, setWidth] = React14.useState(UNMEASURED);
|
|
2355
|
+
const nodeRef = React14.useRef(null);
|
|
2356
|
+
const measureRef = React14.useCallback((node) => {
|
|
2254
2357
|
if (!IS_WEB4) return;
|
|
2255
2358
|
nodeRef.current = node;
|
|
2256
2359
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
2257
2360
|
}, []);
|
|
2258
|
-
|
|
2361
|
+
React14.useEffect(() => {
|
|
2259
2362
|
if (!IS_WEB4) return void 0;
|
|
2260
2363
|
const remeasure = () => {
|
|
2261
2364
|
const node = nodeRef.current;
|
|
@@ -2264,7 +2367,7 @@ function useAvailableWidth() {
|
|
|
2264
2367
|
window.addEventListener("resize", remeasure);
|
|
2265
2368
|
return () => window.removeEventListener("resize", remeasure);
|
|
2266
2369
|
}, []);
|
|
2267
|
-
const onLayout =
|
|
2370
|
+
const onLayout = React14.useCallback((event) => {
|
|
2268
2371
|
if (IS_WEB4) return;
|
|
2269
2372
|
setWidth(event.nativeEvent.layout.width);
|
|
2270
2373
|
}, []);
|
|
@@ -2273,7 +2376,7 @@ function useAvailableWidth() {
|
|
|
2273
2376
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
2274
2377
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
2275
2378
|
var UNMEASURED2 = 0;
|
|
2276
|
-
var
|
|
2379
|
+
var styles21 = reactNative.StyleSheet.create({
|
|
2277
2380
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
2278
2381
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
2279
2382
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -2293,8 +2396,8 @@ var TruncatedText = ({
|
|
|
2293
2396
|
accessibilityHint
|
|
2294
2397
|
}) => {
|
|
2295
2398
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
2296
|
-
const hostRef =
|
|
2297
|
-
const attachRef =
|
|
2399
|
+
const hostRef = React14.useRef(null);
|
|
2400
|
+
const attachRef = React14.useCallback(
|
|
2298
2401
|
(node) => {
|
|
2299
2402
|
hostRef.current = node;
|
|
2300
2403
|
measureRef(node);
|
|
@@ -2303,12 +2406,12 @@ var TruncatedText = ({
|
|
|
2303
2406
|
},
|
|
2304
2407
|
[value, measureRef]
|
|
2305
2408
|
);
|
|
2306
|
-
const flatStyle =
|
|
2307
|
-
() => reactNative.StyleSheet.flatten([
|
|
2409
|
+
const flatStyle = React14.useMemo(
|
|
2410
|
+
() => reactNative.StyleSheet.flatten([styles21.base, style]),
|
|
2308
2411
|
[style]
|
|
2309
2412
|
);
|
|
2310
2413
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
2311
|
-
const display =
|
|
2414
|
+
const display = React14.useMemo(() => {
|
|
2312
2415
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
2313
2416
|
const budget = charBudget(width, fontSize);
|
|
2314
2417
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -2319,7 +2422,7 @@ var TruncatedText = ({
|
|
|
2319
2422
|
ref: attachRef,
|
|
2320
2423
|
onLayout,
|
|
2321
2424
|
numberOfLines: 1,
|
|
2322
|
-
style: [
|
|
2425
|
+
style: [styles21.base, styles21.fill, style],
|
|
2323
2426
|
testID,
|
|
2324
2427
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
2325
2428
|
accessibilityLabel,
|
|
@@ -2390,17 +2493,17 @@ async function copyText(value, writer) {
|
|
|
2390
2493
|
// src/CopyableId/useCopyToClipboard.ts
|
|
2391
2494
|
var COPY_FEEDBACK_MS = 2e3;
|
|
2392
2495
|
function useCopyToClipboard(value, writer) {
|
|
2393
|
-
const [status, setStatus] =
|
|
2394
|
-
const timerRef =
|
|
2395
|
-
const mountedRef =
|
|
2396
|
-
|
|
2496
|
+
const [status, setStatus] = React14.useState("idle" /* Idle */);
|
|
2497
|
+
const timerRef = React14.useRef(null);
|
|
2498
|
+
const mountedRef = React14.useRef(true);
|
|
2499
|
+
React14.useEffect(() => {
|
|
2397
2500
|
mountedRef.current = true;
|
|
2398
2501
|
return () => {
|
|
2399
2502
|
mountedRef.current = false;
|
|
2400
2503
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
2401
2504
|
};
|
|
2402
2505
|
}, []);
|
|
2403
|
-
const copy =
|
|
2506
|
+
const copy = React14.useCallback(() => {
|
|
2404
2507
|
void (async () => {
|
|
2405
2508
|
const ok = await copyText(value, writer);
|
|
2406
2509
|
if (!mountedRef.current) return;
|
|
@@ -2422,7 +2525,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
2422
2525
|
var ACTION_PADDING_H = 6;
|
|
2423
2526
|
var ACTION_PADDING_V = 2;
|
|
2424
2527
|
var ACTION_RADIUS = 6;
|
|
2425
|
-
var
|
|
2528
|
+
var styles22 = reactNative.StyleSheet.create({
|
|
2426
2529
|
cell: { gap: CELL_GAP },
|
|
2427
2530
|
label: {
|
|
2428
2531
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -2464,7 +2567,7 @@ var styles21 = reactNative.StyleSheet.create({
|
|
|
2464
2567
|
var TONE_STEP = "500";
|
|
2465
2568
|
function useActionState(status) {
|
|
2466
2569
|
const { theme } = uiFeedback.useUi();
|
|
2467
|
-
return
|
|
2570
|
+
return React14.useMemo(() => {
|
|
2468
2571
|
const primary = theme.palette.primary[TONE_STEP];
|
|
2469
2572
|
if (status === "copied" /* Copied */) {
|
|
2470
2573
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
@@ -2487,14 +2590,14 @@ var CopyableId = ({
|
|
|
2487
2590
|
const { colors } = theme;
|
|
2488
2591
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
2489
2592
|
const action = useActionState(status);
|
|
2490
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
2491
|
-
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2492
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2493
|
-
/* @__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(
|
|
2494
2597
|
TruncatedText,
|
|
2495
2598
|
{
|
|
2496
2599
|
value,
|
|
2497
|
-
style: [
|
|
2600
|
+
style: [styles22.value, { color: colors.text }],
|
|
2498
2601
|
testID: `${testID}-value`,
|
|
2499
2602
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
2500
2603
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -2508,7 +2611,7 @@ var CopyableId = ({
|
|
|
2508
2611
|
accessibilityLabel: t(action.key),
|
|
2509
2612
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
2510
2613
|
testID: `${testID}-copy`,
|
|
2511
|
-
style: [
|
|
2614
|
+
style: [styles22.action, { color: action.color }],
|
|
2512
2615
|
children: t(action.key)
|
|
2513
2616
|
}
|
|
2514
2617
|
)
|
|
@@ -2533,15 +2636,15 @@ function formatBuildInfo(buildVersion, apiCommit) {
|
|
|
2533
2636
|
return `${base}${API_COMMIT_SEPARATOR}${shortenCommit(commit)}`;
|
|
2534
2637
|
}
|
|
2535
2638
|
function useApiCommit(apiBaseUrl, fetchImpl) {
|
|
2536
|
-
const [commit, setCommit] =
|
|
2537
|
-
const mountedRef =
|
|
2538
|
-
|
|
2639
|
+
const [commit, setCommit] = React14.useState(void 0);
|
|
2640
|
+
const mountedRef = React14.useRef(true);
|
|
2641
|
+
React14.useEffect(() => {
|
|
2539
2642
|
mountedRef.current = true;
|
|
2540
2643
|
return () => {
|
|
2541
2644
|
mountedRef.current = false;
|
|
2542
2645
|
};
|
|
2543
2646
|
}, []);
|
|
2544
|
-
|
|
2647
|
+
React14.useEffect(() => {
|
|
2545
2648
|
if (apiBaseUrl === void 0 || apiBaseUrl === "") return;
|
|
2546
2649
|
const doFetch = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
2547
2650
|
if (doFetch === void 0) return;
|
|
@@ -2563,7 +2666,7 @@ var FOOTER_PADDING_V = 6;
|
|
|
2563
2666
|
var FOOTER_PADDING_H = 12;
|
|
2564
2667
|
var FOOTER_FONT_SIZE = 11;
|
|
2565
2668
|
var FOOTER_OPACITY = 0.75;
|
|
2566
|
-
var
|
|
2669
|
+
var styles23 = reactNative.StyleSheet.create({
|
|
2567
2670
|
footer: {
|
|
2568
2671
|
paddingVertical: FOOTER_PADDING_V,
|
|
2569
2672
|
paddingHorizontal: FOOTER_PADDING_H,
|
|
@@ -2588,8 +2691,8 @@ var BuildInfoFooter = ({
|
|
|
2588
2691
|
const fetchedCommit = useApiCommit(apiCommit === void 0 ? apiBaseUrl : void 0, fetchImpl);
|
|
2589
2692
|
const commit = apiCommit ?? fetchedCommit;
|
|
2590
2693
|
const label = formatBuildInfo(buildVersion, commit);
|
|
2591
|
-
const textStyle =
|
|
2592
|
-
() => [
|
|
2694
|
+
const textStyle = React14.useMemo(
|
|
2695
|
+
() => [styles23.text, { color: theme.colors.textSecondary }],
|
|
2593
2696
|
[theme.colors.textSecondary]
|
|
2594
2697
|
);
|
|
2595
2698
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2597,7 +2700,7 @@ var BuildInfoFooter = ({
|
|
|
2597
2700
|
{
|
|
2598
2701
|
accessibilityLabel: accessibilityLabel ?? label,
|
|
2599
2702
|
accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
|
|
2600
|
-
style: [
|
|
2703
|
+
style: [styles23.footer, style],
|
|
2601
2704
|
testID,
|
|
2602
2705
|
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
|
|
2603
2706
|
}
|
|
@@ -2608,7 +2711,7 @@ var BORDER = 2;
|
|
|
2608
2711
|
var GLYPH_SIZE = 14;
|
|
2609
2712
|
var GLYPH_LINE = 16;
|
|
2610
2713
|
var TICK = "\u2713";
|
|
2611
|
-
var
|
|
2714
|
+
var styles24 = reactNative.StyleSheet.create({
|
|
2612
2715
|
circle: {
|
|
2613
2716
|
width: SIZE,
|
|
2614
2717
|
height: SIZE,
|
|
@@ -2625,14 +2728,14 @@ var CheckMark = ({ filled, accent, ring, glyphColor, testID }) => /* @__PURE__ *
|
|
|
2625
2728
|
"aria-hidden": true,
|
|
2626
2729
|
accessibilityElementsHidden: true,
|
|
2627
2730
|
importantForAccessibility: "no-hide-descendants",
|
|
2628
|
-
style: [
|
|
2731
|
+
style: [styles24.circle, { borderColor: filled ? accent : ring, backgroundColor: filled ? accent : void 0 }],
|
|
2629
2732
|
testID,
|
|
2630
|
-
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2733
|
+
children: filled ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles24.glyph, { color: glyphColor }], children: TICK }) : null
|
|
2631
2734
|
}
|
|
2632
2735
|
);
|
|
2633
|
-
var ListRowToneContext =
|
|
2736
|
+
var ListRowToneContext = React14.createContext(null);
|
|
2634
2737
|
function useListRowTone() {
|
|
2635
|
-
return
|
|
2738
|
+
return React14.useContext(ListRowToneContext);
|
|
2636
2739
|
}
|
|
2637
2740
|
function useRowPalette() {
|
|
2638
2741
|
const { colors, palette, semantic } = uiFeedback.useUi().theme;
|
|
@@ -2750,7 +2853,7 @@ var PAD_V = 12;
|
|
|
2750
2853
|
var GAP = 4;
|
|
2751
2854
|
var MARK_GAP = 12;
|
|
2752
2855
|
var LINE_GAP = 8;
|
|
2753
|
-
var
|
|
2856
|
+
var styles25 = reactNative.StyleSheet.create({
|
|
2754
2857
|
row: {
|
|
2755
2858
|
flexDirection: "row",
|
|
2756
2859
|
alignItems: "center",
|
|
@@ -2774,7 +2877,7 @@ function focusTarget(event) {
|
|
|
2774
2877
|
}
|
|
2775
2878
|
function slot(node, color, strong) {
|
|
2776
2879
|
if (typeof node !== "string") return node;
|
|
2777
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
2880
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles25.shrink, strong ? styles25.strong : null, { color }], children: node });
|
|
2778
2881
|
}
|
|
2779
2882
|
var ListRow = ({
|
|
2780
2883
|
title,
|
|
@@ -2791,9 +2894,9 @@ var ListRow = ({
|
|
|
2791
2894
|
}) => {
|
|
2792
2895
|
const palette = useRowPalette();
|
|
2793
2896
|
const { colors } = uiFeedback.useUi().theme;
|
|
2794
|
-
const [focused, setFocused] =
|
|
2897
|
+
const [focused, setFocused] = React14.useState(false);
|
|
2795
2898
|
const rest = resolveRowLook(selectedStyle, { selected, hovered: false, pressed: false, focused }, palette);
|
|
2796
|
-
const tone =
|
|
2899
|
+
const tone = React14.useMemo(() => ({ textColor: rest.textColor, inverse: rest.inverse }), [rest.textColor, rest.inverse]);
|
|
2797
2900
|
const checkTestId = testID === void 0 ? void 0 : `${testID}-check`;
|
|
2798
2901
|
return /* @__PURE__ */ jsxRuntime.jsxs(ListRowToneContext.Provider, { value: tone, children: [
|
|
2799
2902
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2806,7 +2909,7 @@ var ListRow = ({
|
|
|
2806
2909
|
style: (state) => {
|
|
2807
2910
|
const { pressed, hovered } = state;
|
|
2808
2911
|
const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
|
|
2809
|
-
return [
|
|
2912
|
+
return [styles25.row, { borderTopColor: colors.border }, look.container];
|
|
2810
2913
|
},
|
|
2811
2914
|
testID,
|
|
2812
2915
|
onBlur: () => {
|
|
@@ -2819,14 +2922,14 @@ var ListRow = ({
|
|
|
2819
2922
|
...pressedProps(selected),
|
|
2820
2923
|
children: [
|
|
2821
2924
|
rest.showCheck ? /* @__PURE__ */ jsxRuntime.jsx(CheckMark, { accent: palette.accent, filled: rest.checkFilled, glyphColor: palette.background, ring: palette.border, testID: checkTestId }) : null,
|
|
2822
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2823
|
-
/* @__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: [
|
|
2824
2927
|
slot(title, rest.titleColor, true),
|
|
2825
2928
|
slot(trailing, rest.textColor, true)
|
|
2826
2929
|
] }),
|
|
2827
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
2828
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
2829
|
-
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 })
|
|
2830
2933
|
] })
|
|
2831
2934
|
] })
|
|
2832
2935
|
]
|
|
@@ -2842,6 +2945,7 @@ exports.Accordion = Accordion;
|
|
|
2842
2945
|
exports.AccordionItem = AccordionItem;
|
|
2843
2946
|
exports.AppText = AppText;
|
|
2844
2947
|
exports.BUILD_INFO_PREFIX = BUILD_INFO_PREFIX;
|
|
2948
|
+
exports.BottomSheet = BottomSheet;
|
|
2845
2949
|
exports.BuildInfoFooter = BuildInfoFooter;
|
|
2846
2950
|
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
2847
2951
|
exports.ConfirmDialog = ConfirmDialog;
|