@dloizides/ui-layout 1.37.0 → 1.38.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 +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +302 -265
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -267
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React12, { createContext, useMemo, useState, useRef, useEffect, useCallback, useContext, useLayoutEffect } from 'react';
|
|
2
|
-
import { StyleSheet, Platform, View, Text, useWindowDimensions,
|
|
2
|
+
import { StyleSheet, Platform, View, Text, useWindowDimensions, Modal as Modal$1, Animated, TouchableOpacity, ScrollView, Pressable, FlatList, Easing } from 'react-native';
|
|
3
3
|
import { MODAL_OVERLAY_COLOR, useUi } from '@dloizides/ui-feedback';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import {
|
|
5
|
+
import { IconButton, Button } from '@dloizides/ui-buttons';
|
|
6
|
+
import { SvgIcon } from '@dloizides/ui-icons';
|
|
6
7
|
import { useEnterExit, Collapse } from '@dloizides/ui-motion';
|
|
8
|
+
import { MIN_TOUCH_TARGET_PX, useA11y } from '@dloizides/a11y';
|
|
7
9
|
import { createPortal } from 'react-dom';
|
|
8
10
|
import { Z_INDEX } from '@dloizides/design-tokens';
|
|
9
|
-
import { SvgIcon } from '@dloizides/ui-icons';
|
|
10
|
-
import { IconButton, Button } from '@dloizides/ui-buttons';
|
|
11
11
|
import { useReducedMotion } from '@dloizides/rn-web-hooks';
|
|
12
12
|
|
|
13
13
|
// src/Section/Section.tsx
|
|
@@ -133,6 +133,9 @@ var LAYOUT_I18N = {
|
|
|
133
133
|
closeHeading: "close",
|
|
134
134
|
/** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
|
|
135
135
|
dialogClose: "common.close",
|
|
136
|
+
/** `PageFrame` (`enlargeable`): accessible name + hint of the preview that opens the full-size page. */
|
|
137
|
+
pageEnlarge: "common.pageEnlarge",
|
|
138
|
+
pageEnlargeHint: "common.pageEnlargeHint",
|
|
136
139
|
/** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
|
|
137
140
|
confirm: "common.confirm",
|
|
138
141
|
confirmHint: "common.confirmHint",
|
|
@@ -371,6 +374,223 @@ var StickyPreview = ({
|
|
|
371
374
|
)
|
|
372
375
|
] });
|
|
373
376
|
};
|
|
377
|
+
function useEscapeKey(enabled, onClose) {
|
|
378
|
+
useEffect(() => {
|
|
379
|
+
if (Platform.OS !== "web" || !enabled) return;
|
|
380
|
+
const onKeyDown = (event) => {
|
|
381
|
+
if (event.key === "Escape") onClose();
|
|
382
|
+
};
|
|
383
|
+
document.addEventListener("keydown", onKeyDown);
|
|
384
|
+
return () => {
|
|
385
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
386
|
+
};
|
|
387
|
+
}, [enabled, onClose]);
|
|
388
|
+
}
|
|
389
|
+
var FOCUSABLE_SELECTOR = [
|
|
390
|
+
"a[href]",
|
|
391
|
+
"button:not([disabled])",
|
|
392
|
+
"input:not([disabled])",
|
|
393
|
+
"select:not([disabled])",
|
|
394
|
+
"textarea:not([disabled])",
|
|
395
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
396
|
+
].join(", ");
|
|
397
|
+
function getFocusableElements(container) {
|
|
398
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
399
|
+
}
|
|
400
|
+
function savePreviousFocus() {
|
|
401
|
+
return document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
402
|
+
}
|
|
403
|
+
function focusInitial(domNode, initialFocusTestID) {
|
|
404
|
+
const named = initialFocusTestID === void 0 ? null : domNode.querySelector(`[data-testid="${initialFocusTestID}"]`);
|
|
405
|
+
if (named) {
|
|
406
|
+
named.focus();
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (domNode.contains(document.activeElement)) return;
|
|
410
|
+
getFocusableElements(domNode)[0]?.focus();
|
|
411
|
+
}
|
|
412
|
+
function handleKeyDown(domNode, event) {
|
|
413
|
+
if (event.key !== "Tab") return;
|
|
414
|
+
const focusable = getFocusableElements(domNode);
|
|
415
|
+
if (focusable.length === 0) {
|
|
416
|
+
event.preventDefault();
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const first = focusable[0];
|
|
420
|
+
const last = focusable[focusable.length - 1];
|
|
421
|
+
if (!first || !last) {
|
|
422
|
+
event.preventDefault();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const active = document.activeElement;
|
|
426
|
+
if (event.shiftKey && active === first) {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
last.focus();
|
|
429
|
+
} else if (!event.shiftKey && active === last) {
|
|
430
|
+
event.preventDefault();
|
|
431
|
+
first.focus();
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
435
|
+
const previousFocusRef = useRef(null);
|
|
436
|
+
useEffect(() => {
|
|
437
|
+
if (Platform.OS !== "web" || !enabled) return;
|
|
438
|
+
const domNode = containerRef.current;
|
|
439
|
+
if (!domNode) return;
|
|
440
|
+
const previous = savePreviousFocus();
|
|
441
|
+
previousFocusRef.current = previous !== null && domNode.contains(previous) ? null : previous;
|
|
442
|
+
queueMicrotask(() => focusInitial(domNode, initialFocusTestID));
|
|
443
|
+
const listener = (e) => handleKeyDown(domNode, e);
|
|
444
|
+
domNode.addEventListener("keydown", listener);
|
|
445
|
+
return () => {
|
|
446
|
+
domNode.removeEventListener("keydown", listener);
|
|
447
|
+
previousFocusRef.current?.focus();
|
|
448
|
+
previousFocusRef.current = null;
|
|
449
|
+
};
|
|
450
|
+
}, [containerRef, enabled, initialFocusTestID]);
|
|
451
|
+
}
|
|
452
|
+
function useScrollLock(enabled) {
|
|
453
|
+
useEffect(() => {
|
|
454
|
+
if (Platform.OS !== "web" || !enabled) return;
|
|
455
|
+
const { body } = document;
|
|
456
|
+
const previousOverflow = body.style.overflow;
|
|
457
|
+
body.style.overflow = "hidden";
|
|
458
|
+
return () => {
|
|
459
|
+
body.style.overflow = previousOverflow;
|
|
460
|
+
};
|
|
461
|
+
}, [enabled]);
|
|
462
|
+
}
|
|
463
|
+
var OVERLAY_PADDING = 16;
|
|
464
|
+
var DIALOG_RADIUS = 12;
|
|
465
|
+
var DIALOG_PADDING = 16;
|
|
466
|
+
var HEADER_GAP = 12;
|
|
467
|
+
var FOOTER_MARGIN = 16;
|
|
468
|
+
var HEADER_MARGIN = 12;
|
|
469
|
+
var DIALOG_MAX_HEIGHT = "90%";
|
|
470
|
+
var PANEL_ENTER_SCALE = 0.96;
|
|
471
|
+
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640, xl: 880 };
|
|
472
|
+
var styles6 = StyleSheet.create({
|
|
473
|
+
overlay: {
|
|
474
|
+
flex: 1,
|
|
475
|
+
justifyContent: "center",
|
|
476
|
+
alignItems: "center",
|
|
477
|
+
padding: OVERLAY_PADDING
|
|
478
|
+
},
|
|
479
|
+
// The scrim is its OWN animated layer (behind the tap-catcher and the panel) so its opacity
|
|
480
|
+
// can fade independently of the panel's fade+scale. `animationType` is a native-only no-op on
|
|
481
|
+
// react-native-web, which is why the fade is driven by `Animated` instead. `pointerEvents` lives
|
|
482
|
+
// in style (not the deprecated prop) so taps fall through to the sibling tap-catcher below.
|
|
483
|
+
scrim: { backgroundColor: MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
484
|
+
dialog: {
|
|
485
|
+
width: "100%",
|
|
486
|
+
borderRadius: DIALOG_RADIUS,
|
|
487
|
+
padding: DIALOG_PADDING,
|
|
488
|
+
maxHeight: DIALOG_MAX_HEIGHT
|
|
489
|
+
},
|
|
490
|
+
headerRow: {
|
|
491
|
+
flexDirection: "row",
|
|
492
|
+
alignItems: "flex-start",
|
|
493
|
+
justifyContent: "space-between",
|
|
494
|
+
columnGap: HEADER_GAP,
|
|
495
|
+
marginBottom: HEADER_MARGIN
|
|
496
|
+
},
|
|
497
|
+
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
498
|
+
titleWrap: { flex: 1 },
|
|
499
|
+
footer: { marginTop: FOOTER_MARGIN }
|
|
500
|
+
});
|
|
501
|
+
var Modal = ({
|
|
502
|
+
visible,
|
|
503
|
+
onClose,
|
|
504
|
+
title,
|
|
505
|
+
children,
|
|
506
|
+
footer,
|
|
507
|
+
size = "md",
|
|
508
|
+
showClose = true,
|
|
509
|
+
testID = LAYOUT_TEST_IDS.modal,
|
|
510
|
+
accessibilityLabel,
|
|
511
|
+
initialFocusTestID
|
|
512
|
+
}) => {
|
|
513
|
+
const { theme, t } = useUi();
|
|
514
|
+
const dialogRef = useRef(null);
|
|
515
|
+
const backdrop = useEnterExit({ visible });
|
|
516
|
+
const panel = useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE });
|
|
517
|
+
const mounted = panel.mounted || backdrop.mounted;
|
|
518
|
+
useFocusTrap(dialogRef, visible, initialFocusTestID);
|
|
519
|
+
useEscapeKey(visible, onClose);
|
|
520
|
+
useScrollLock(visible);
|
|
521
|
+
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
522
|
+
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
523
|
+
const dialogStyle = useMemo(
|
|
524
|
+
() => [styles6.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
525
|
+
[theme.colors.surface, size]
|
|
526
|
+
);
|
|
527
|
+
const hasHeader = title !== void 0 || showClose;
|
|
528
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles6.overlay, children: [
|
|
529
|
+
/* @__PURE__ */ jsx(
|
|
530
|
+
Animated.View,
|
|
531
|
+
{
|
|
532
|
+
style: [StyleSheet.absoluteFill, styles6.scrim, { opacity: backdrop.style.opacity }]
|
|
533
|
+
}
|
|
534
|
+
),
|
|
535
|
+
/* @__PURE__ */ jsx(
|
|
536
|
+
TouchableOpacity,
|
|
537
|
+
{
|
|
538
|
+
accessible: true,
|
|
539
|
+
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
540
|
+
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
541
|
+
accessibilityRole: "button",
|
|
542
|
+
activeOpacity: 1,
|
|
543
|
+
style: StyleSheet.absoluteFill,
|
|
544
|
+
testID: `${testID}-backdrop`,
|
|
545
|
+
onPress: onClose
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
/* @__PURE__ */ jsxs(
|
|
549
|
+
Animated.View,
|
|
550
|
+
{
|
|
551
|
+
ref: dialogRef,
|
|
552
|
+
accessibilityViewIsModal: true,
|
|
553
|
+
"aria-label": accessibleName,
|
|
554
|
+
role: "dialog",
|
|
555
|
+
style: [dialogStyle, panel.style],
|
|
556
|
+
testID,
|
|
557
|
+
children: [
|
|
558
|
+
hasHeader ? /* @__PURE__ */ jsxs(View, { style: styles6.headerRow, children: [
|
|
559
|
+
/* @__PURE__ */ jsx(View, { style: styles6.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsx(Heading, { children: title }) : null }),
|
|
560
|
+
showClose ? /* @__PURE__ */ jsx(
|
|
561
|
+
IconButton,
|
|
562
|
+
{
|
|
563
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
564
|
+
accessibilityLabel: closeLabel,
|
|
565
|
+
appearance: "ghost",
|
|
566
|
+
renderIcon: (color, iconSize) => /* @__PURE__ */ jsx(SvgIcon, { color, name: "close", size: iconSize }),
|
|
567
|
+
size: "md",
|
|
568
|
+
testID: `${testID}-close`,
|
|
569
|
+
tooltip: closeLabel,
|
|
570
|
+
variant: "ghost",
|
|
571
|
+
onPress: onClose
|
|
572
|
+
}
|
|
573
|
+
) : null
|
|
574
|
+
] }) : null,
|
|
575
|
+
/* @__PURE__ */ jsx(ScrollView, { children }),
|
|
576
|
+
footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: styles6.footer, children: footer }) : null
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
] }) });
|
|
581
|
+
};
|
|
582
|
+
var CENTRED_ROW = { flexGrow: 1, justifyContent: "center" };
|
|
583
|
+
var PageOverlay = ({ children, pageSize, visible, onClose, testID }) => {
|
|
584
|
+
const { t } = useUi();
|
|
585
|
+
return /* @__PURE__ */ jsx(Modal, { accessibilityLabel: t(LAYOUT_I18N.pageEnlarge), size: "xl", testID, visible, onClose, children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, contentContainerStyle: CENTRED_ROW, children: /* @__PURE__ */ jsx(
|
|
586
|
+
View,
|
|
587
|
+
{
|
|
588
|
+
style: { width: pageSize.width, minWidth: pageSize.width, height: pageSize.height, flexShrink: 0 },
|
|
589
|
+
testID: `${testID}-page`,
|
|
590
|
+
children
|
|
591
|
+
}
|
|
592
|
+
) }) });
|
|
593
|
+
};
|
|
374
594
|
|
|
375
595
|
// src/PageFrame/utils/pageScale.ts
|
|
376
596
|
var HALF = 2;
|
|
@@ -388,25 +608,31 @@ var scaledFrame = (containerWidth, page) => {
|
|
|
388
608
|
offsetY: (scale - 1) * page.height / HALF
|
|
389
609
|
};
|
|
390
610
|
};
|
|
391
|
-
var
|
|
611
|
+
var styles7 = StyleSheet.create({
|
|
392
612
|
outer: { width: "100%", overflow: "hidden" },
|
|
393
|
-
page: { position: "absolute", top: 0, left: 0 }
|
|
613
|
+
page: { position: "absolute", top: 0, left: 0 },
|
|
614
|
+
trigger: { width: "100%", cursor: "pointer" }
|
|
394
615
|
});
|
|
395
616
|
var PageFrame = ({
|
|
396
617
|
children,
|
|
397
618
|
pageSize = A4_PAGE,
|
|
398
|
-
testID = LAYOUT_TEST_IDS.pageFrame
|
|
619
|
+
testID = LAYOUT_TEST_IDS.pageFrame,
|
|
620
|
+
enlargeable = false
|
|
399
621
|
}) => {
|
|
622
|
+
const { t } = useUi();
|
|
400
623
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
624
|
+
const [enlarged, setEnlarged] = useState(false);
|
|
401
625
|
const onLayout = useCallback((event) => {
|
|
402
626
|
setContainerWidth(event.nativeEvent.layout.width);
|
|
403
627
|
}, []);
|
|
628
|
+
const open = useCallback(() => setEnlarged(true), []);
|
|
629
|
+
const close = useCallback(() => setEnlarged(false), []);
|
|
404
630
|
const frame = scaledFrame(containerWidth, pageSize);
|
|
405
|
-
|
|
631
|
+
const preview = /* @__PURE__ */ jsx(View, { style: [styles7.outer, { height: frame.height }], testID, onLayout, children: /* @__PURE__ */ jsx(
|
|
406
632
|
View,
|
|
407
633
|
{
|
|
408
634
|
style: [
|
|
409
|
-
|
|
635
|
+
styles7.page,
|
|
410
636
|
{
|
|
411
637
|
width: pageSize.width,
|
|
412
638
|
height: pageSize.height,
|
|
@@ -416,6 +642,22 @@ var PageFrame = ({
|
|
|
416
642
|
children
|
|
417
643
|
}
|
|
418
644
|
) });
|
|
645
|
+
if (!enlargeable) return preview;
|
|
646
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
647
|
+
/* @__PURE__ */ jsx(
|
|
648
|
+
Pressable,
|
|
649
|
+
{
|
|
650
|
+
accessibilityHint: t(LAYOUT_I18N.pageEnlargeHint),
|
|
651
|
+
accessibilityLabel: t(LAYOUT_I18N.pageEnlarge),
|
|
652
|
+
accessibilityRole: "button",
|
|
653
|
+
style: styles7.trigger,
|
|
654
|
+
testID: `${testID}-enlarge`,
|
|
655
|
+
onPress: open,
|
|
656
|
+
children: preview
|
|
657
|
+
}
|
|
658
|
+
),
|
|
659
|
+
/* @__PURE__ */ jsx(PageOverlay, { pageSize, testID: `${testID}-overlay`, visible: enlarged, onClose: close, children })
|
|
660
|
+
] });
|
|
419
661
|
};
|
|
420
662
|
var TRACK_PADDING = 3;
|
|
421
663
|
var TRACK_RADIUS = 999;
|
|
@@ -428,7 +670,7 @@ var BORDER_WIDTH = 1;
|
|
|
428
670
|
var SEGMENT_BOX_SHADOW = "0px 1px 3px rgba(20, 30, 50, 0.1)";
|
|
429
671
|
var SHADOW_ELEVATION = 2;
|
|
430
672
|
var TRANSPARENT = "transparent";
|
|
431
|
-
var
|
|
673
|
+
var styles8 = StyleSheet.create({
|
|
432
674
|
track: {
|
|
433
675
|
flexDirection: "row",
|
|
434
676
|
alignSelf: "flex-start",
|
|
@@ -473,7 +715,7 @@ function SegmentedControl({
|
|
|
473
715
|
{
|
|
474
716
|
accessibilityRole: "tablist",
|
|
475
717
|
"aria-label": accessibilityLabel,
|
|
476
|
-
style: [
|
|
718
|
+
style: [styles8.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
|
|
477
719
|
testID,
|
|
478
720
|
children: options.map((opt) => {
|
|
479
721
|
const selected = opt.value === value;
|
|
@@ -486,13 +728,13 @@ function SegmentedControl({
|
|
|
486
728
|
accessibilityHint: opt.accessibilityHint,
|
|
487
729
|
onPress: () => onChange(opt.value),
|
|
488
730
|
style: [
|
|
489
|
-
|
|
490
|
-
selected ?
|
|
731
|
+
styles8.segment,
|
|
732
|
+
selected ? styles8.segmentSelected : null,
|
|
491
733
|
{ backgroundColor: selected ? colors.surface : TRANSPARENT }
|
|
492
734
|
],
|
|
493
735
|
testID: opt.testID,
|
|
494
736
|
...ariaSelectedProps(selected),
|
|
495
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
737
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles8.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
|
|
496
738
|
},
|
|
497
739
|
opt.value
|
|
498
740
|
);
|
|
@@ -507,69 +749,6 @@ var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
|
507
749
|
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
508
750
|
return TabsCollapsedTrigger2;
|
|
509
751
|
})(TabsCollapsedTrigger || {});
|
|
510
|
-
var FOCUSABLE_SELECTOR = [
|
|
511
|
-
"a[href]",
|
|
512
|
-
"button:not([disabled])",
|
|
513
|
-
"input:not([disabled])",
|
|
514
|
-
"select:not([disabled])",
|
|
515
|
-
"textarea:not([disabled])",
|
|
516
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
517
|
-
].join(", ");
|
|
518
|
-
function getFocusableElements(container) {
|
|
519
|
-
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
520
|
-
}
|
|
521
|
-
function savePreviousFocus() {
|
|
522
|
-
return document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
523
|
-
}
|
|
524
|
-
function focusInitial(domNode, initialFocusTestID) {
|
|
525
|
-
const named = initialFocusTestID === void 0 ? null : domNode.querySelector(`[data-testid="${initialFocusTestID}"]`);
|
|
526
|
-
if (named) {
|
|
527
|
-
named.focus();
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
if (domNode.contains(document.activeElement)) return;
|
|
531
|
-
getFocusableElements(domNode)[0]?.focus();
|
|
532
|
-
}
|
|
533
|
-
function handleKeyDown(domNode, event) {
|
|
534
|
-
if (event.key !== "Tab") return;
|
|
535
|
-
const focusable = getFocusableElements(domNode);
|
|
536
|
-
if (focusable.length === 0) {
|
|
537
|
-
event.preventDefault();
|
|
538
|
-
return;
|
|
539
|
-
}
|
|
540
|
-
const first = focusable[0];
|
|
541
|
-
const last = focusable[focusable.length - 1];
|
|
542
|
-
if (!first || !last) {
|
|
543
|
-
event.preventDefault();
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const active = document.activeElement;
|
|
547
|
-
if (event.shiftKey && active === first) {
|
|
548
|
-
event.preventDefault();
|
|
549
|
-
last.focus();
|
|
550
|
-
} else if (!event.shiftKey && active === last) {
|
|
551
|
-
event.preventDefault();
|
|
552
|
-
first.focus();
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
556
|
-
const previousFocusRef = useRef(null);
|
|
557
|
-
useEffect(() => {
|
|
558
|
-
if (Platform.OS !== "web" || !enabled) return;
|
|
559
|
-
const domNode = containerRef.current;
|
|
560
|
-
if (!domNode) return;
|
|
561
|
-
const previous = savePreviousFocus();
|
|
562
|
-
previousFocusRef.current = previous !== null && domNode.contains(previous) ? null : previous;
|
|
563
|
-
queueMicrotask(() => focusInitial(domNode, initialFocusTestID));
|
|
564
|
-
const listener = (e) => handleKeyDown(domNode, e);
|
|
565
|
-
domNode.addEventListener("keydown", listener);
|
|
566
|
-
return () => {
|
|
567
|
-
domNode.removeEventListener("keydown", listener);
|
|
568
|
-
previousFocusRef.current?.focus();
|
|
569
|
-
previousFocusRef.current = null;
|
|
570
|
-
};
|
|
571
|
-
}, [containerRef, enabled, initialFocusTestID]);
|
|
572
|
-
}
|
|
573
752
|
|
|
574
753
|
// src/ModalDropdown/DropdownVariant.ts
|
|
575
754
|
var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
|
|
@@ -629,7 +808,7 @@ var HEADING_PADDING_H = 16;
|
|
|
629
808
|
var HEADING_PADDING_TOP = 8;
|
|
630
809
|
var HEADING_PADDING_BOTTOM = 4;
|
|
631
810
|
var HEADING_LETTER_SPACING = 0.5;
|
|
632
|
-
var
|
|
811
|
+
var styles9 = StyleSheet.create({
|
|
633
812
|
heading: {
|
|
634
813
|
fontSize: HEADING_FONT_SIZE,
|
|
635
814
|
fontWeight: HEADING_FONT_WEIGHT,
|
|
@@ -645,7 +824,7 @@ var MenuHeading = ({ testID, text }) => {
|
|
|
645
824
|
Text,
|
|
646
825
|
{
|
|
647
826
|
accessibilityRole: "header",
|
|
648
|
-
style: [
|
|
827
|
+
style: [styles9.heading, { color: theme.colors.textSecondary }],
|
|
649
828
|
testID: `${testID}-menu-heading`,
|
|
650
829
|
children: text
|
|
651
830
|
}
|
|
@@ -666,7 +845,7 @@ var OPTION_PADDING_V = 12;
|
|
|
666
845
|
var ACCENT_BAR_WIDTH = 3;
|
|
667
846
|
var CHECK_GAP = 8;
|
|
668
847
|
var CHECK_GLYPH = "\u2713";
|
|
669
|
-
var
|
|
848
|
+
var styles10 = StyleSheet.create({
|
|
670
849
|
option: {
|
|
671
850
|
paddingHorizontal: OPTION_PADDING_H,
|
|
672
851
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -705,16 +884,16 @@ var OptionRow = ({
|
|
|
705
884
|
const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
|
|
706
885
|
const isActive = isSelected || isHighlighted;
|
|
707
886
|
const rowStyle = [
|
|
708
|
-
|
|
709
|
-
isMarked ?
|
|
887
|
+
styles10.option,
|
|
888
|
+
isMarked ? styles10.markedRow : null,
|
|
710
889
|
isActive ? { backgroundColor: colors.surfaceElevated } : null,
|
|
711
890
|
isMarked && isSelected ? { borderLeftColor: accentColor } : null
|
|
712
891
|
];
|
|
713
892
|
const textStyle = [
|
|
714
|
-
|
|
893
|
+
styles10.optionText,
|
|
715
894
|
{ color: colors.text },
|
|
716
|
-
isSelected ?
|
|
717
|
-
isMarked ?
|
|
895
|
+
isSelected ? styles10.selectedText : null,
|
|
896
|
+
isMarked ? styles10.markedText : null
|
|
718
897
|
];
|
|
719
898
|
const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
|
|
720
899
|
return /* @__PURE__ */ jsxs(
|
|
@@ -730,7 +909,7 @@ var OptionRow = ({
|
|
|
730
909
|
onPress: handlePress,
|
|
731
910
|
children: [
|
|
732
911
|
/* @__PURE__ */ jsx(Text, { style: textStyle, children: label }),
|
|
733
|
-
isMarked && isSelected ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsx(Text, { style: [
|
|
912
|
+
isMarked && isSelected ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsx(Text, { style: [styles10.selectedText, { color: accentColor }], children: CHECK_GLYPH }) }) : null
|
|
734
913
|
]
|
|
735
914
|
}
|
|
736
915
|
);
|
|
@@ -888,7 +1067,7 @@ var IS_WEB2 = Platform.OS === "web";
|
|
|
888
1067
|
var BORDER_RADIUS2 = 8;
|
|
889
1068
|
var BORDER_WIDTH3 = 1;
|
|
890
1069
|
var MENU_PADDING2 = 4;
|
|
891
|
-
var
|
|
1070
|
+
var styles11 = StyleSheet.create({
|
|
892
1071
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
893
1072
|
popover: {
|
|
894
1073
|
position: "absolute",
|
|
@@ -975,7 +1154,7 @@ var InlineMenu = ({
|
|
|
975
1154
|
themed
|
|
976
1155
|
];
|
|
977
1156
|
}
|
|
978
|
-
return [
|
|
1157
|
+
return [styles11.popover, { minWidth: menuMinWidth }, themed];
|
|
979
1158
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
980
1159
|
const menu = /* @__PURE__ */ jsx(
|
|
981
1160
|
View,
|
|
@@ -990,10 +1169,10 @@ var InlineMenu = ({
|
|
|
990
1169
|
Animated.View,
|
|
991
1170
|
{
|
|
992
1171
|
pointerEvents: isOpen ? "auto" : "none",
|
|
993
|
-
style: [
|
|
1172
|
+
style: [styles11.animated, animatedStyle, isOpen ? null : styles11.inert],
|
|
994
1173
|
children: [
|
|
995
1174
|
menuHeading !== void 0 ? /* @__PURE__ */ jsx(MenuHeading, { testID, text: menuHeading }) : null,
|
|
996
|
-
/* @__PURE__ */ jsx(ScrollView, { style:
|
|
1175
|
+
/* @__PURE__ */ jsx(ScrollView, { style: styles11.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
997
1176
|
OptionRow,
|
|
998
1177
|
{
|
|
999
1178
|
asMenuItem: true,
|
|
@@ -1041,7 +1220,7 @@ var CARET_OPEN_ROTATION = "180deg";
|
|
|
1041
1220
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
1042
1221
|
var POPOVER_ENTER_SCALE = 0.96;
|
|
1043
1222
|
var POPOVER_MOTION_MS = 120;
|
|
1044
|
-
var
|
|
1223
|
+
var styles12 = StyleSheet.create({
|
|
1045
1224
|
anchor: { position: "relative" },
|
|
1046
1225
|
container: {
|
|
1047
1226
|
borderWidth: BORDER_WIDTH4,
|
|
@@ -1156,19 +1335,19 @@ var ModalDropdown = ({
|
|
|
1156
1335
|
const isCaret = showCaret && !isHamburger;
|
|
1157
1336
|
const containerStyle = useMemo(
|
|
1158
1337
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
1159
|
-
|
|
1160
|
-
isHamburger ?
|
|
1338
|
+
styles12.container,
|
|
1339
|
+
isHamburger ? styles12.containerHamburger : isCaret ? styles12.containerMenu : null,
|
|
1161
1340
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
1162
1341
|
],
|
|
1163
1342
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
1164
1343
|
);
|
|
1165
1344
|
const hamburgerStyle = useMemo(
|
|
1166
|
-
() => [
|
|
1345
|
+
() => [styles12.hamburger, { color: colors.textSecondary }],
|
|
1167
1346
|
[colors.textSecondary]
|
|
1168
1347
|
);
|
|
1169
1348
|
const caretStyle = useMemo(
|
|
1170
1349
|
() => [
|
|
1171
|
-
|
|
1350
|
+
styles12.caret,
|
|
1172
1351
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
1173
1352
|
],
|
|
1174
1353
|
[colors.textSecondary, isOpen]
|
|
@@ -1178,11 +1357,11 @@ var ModalDropdown = ({
|
|
|
1178
1357
|
[optionTestID, testID]
|
|
1179
1358
|
);
|
|
1180
1359
|
const anchorStyle = useMemo(
|
|
1181
|
-
() => [
|
|
1360
|
+
() => [styles12.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
1182
1361
|
[isMenu, isOpen]
|
|
1183
1362
|
);
|
|
1184
1363
|
const modalContentStyle = useMemo(
|
|
1185
|
-
() => [
|
|
1364
|
+
() => [styles12.modalContent, { backgroundColor: colors.surface }],
|
|
1186
1365
|
[colors.surface]
|
|
1187
1366
|
);
|
|
1188
1367
|
const renderModalOption = useCallback(
|
|
@@ -1203,11 +1382,11 @@ var ModalDropdown = ({
|
|
|
1203
1382
|
/* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
|
|
1204
1383
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1205
1384
|
/* @__PURE__ */ jsx(Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
1206
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [
|
|
1385
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
1207
1386
|
] }) : isCaret ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1208
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [
|
|
1387
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
1209
1388
|
/* @__PURE__ */ jsx(Text, { style: caretStyle, children: CARET_GLYPH })
|
|
1210
|
-
] }) : /* @__PURE__ */ jsx(Text, { style: [
|
|
1389
|
+
] }) : /* @__PURE__ */ jsx(Text, { style: [styles12.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
1211
1390
|
hintNode
|
|
1212
1391
|
] }),
|
|
1213
1392
|
isMenu && menuAnim.mounted ? /* @__PURE__ */ jsx(
|
|
@@ -1228,7 +1407,7 @@ var ModalDropdown = ({
|
|
|
1228
1407
|
onSelect: handleSelect
|
|
1229
1408
|
}
|
|
1230
1409
|
) : null,
|
|
1231
|
-
!isMenu ? /* @__PURE__ */ jsx(Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style:
|
|
1410
|
+
!isMenu ? /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style: styles12.modalOverlay, children: [
|
|
1232
1411
|
/* @__PURE__ */ jsx(
|
|
1233
1412
|
TouchableOpacity,
|
|
1234
1413
|
{
|
|
@@ -1321,7 +1500,7 @@ var ROW_PAD_V = 8;
|
|
|
1321
1500
|
var PANEL_PAD_TOP = 16;
|
|
1322
1501
|
var BORDER_WIDTH5 = 1;
|
|
1323
1502
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
1324
|
-
var
|
|
1503
|
+
var styles13 = StyleSheet.create({
|
|
1325
1504
|
root: {
|
|
1326
1505
|
width: "100%"
|
|
1327
1506
|
},
|
|
@@ -1375,7 +1554,7 @@ var WideTabStrip = ({
|
|
|
1375
1554
|
textSecondary,
|
|
1376
1555
|
surfaceElevated,
|
|
1377
1556
|
stripStyle
|
|
1378
|
-
}) => /* @__PURE__ */ jsx(View, { style: [
|
|
1557
|
+
}) => /* @__PURE__ */ jsx(View, { style: [styles13.stripOuter, { borderBottomColor: borderColor }], children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsx(View, { accessibilityRole: "tablist", "aria-label": accessibilityLabel, style: [styles13.strip, stripStyle], children: tabs.map((tab) => {
|
|
1379
1558
|
const selected = tab.key === activeKey;
|
|
1380
1559
|
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
1381
1560
|
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
@@ -1389,10 +1568,10 @@ var WideTabStrip = ({
|
|
|
1389
1568
|
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
1390
1569
|
accessibilityHint: tab.accessibilityHint,
|
|
1391
1570
|
onPress: () => onChange(tab.key),
|
|
1392
|
-
style: [
|
|
1571
|
+
style: [styles13.pill, { backgroundColor: pillColor }],
|
|
1393
1572
|
testID: tab.testID,
|
|
1394
1573
|
...ariaTabProps(selected, panelId, tabId),
|
|
1395
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1574
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles13.pillText, { color: textColor }], children: tab.label })
|
|
1396
1575
|
},
|
|
1397
1576
|
tab.key
|
|
1398
1577
|
);
|
|
@@ -1417,7 +1596,7 @@ var Tabs = ({
|
|
|
1417
1596
|
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
1418
1597
|
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
1419
1598
|
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
1420
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
1599
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles13.root, style], testID, children: [
|
|
1421
1600
|
collapsed ? /* @__PURE__ */ jsx(
|
|
1422
1601
|
TabsMenu,
|
|
1423
1602
|
{
|
|
@@ -1444,7 +1623,7 @@ var Tabs = ({
|
|
|
1444
1623
|
onChange
|
|
1445
1624
|
}
|
|
1446
1625
|
),
|
|
1447
|
-
/* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [
|
|
1626
|
+
/* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [styles13.panel, panelStyle], ...panelAria, children })
|
|
1448
1627
|
] });
|
|
1449
1628
|
};
|
|
1450
1629
|
var PROMPT_PADDING = 20;
|
|
@@ -1459,7 +1638,7 @@ var DISMISS_FONT_SIZE = 13;
|
|
|
1459
1638
|
var TITLE_MARGIN_BOTTOM = 8;
|
|
1460
1639
|
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
1461
1640
|
var CTA_MARGIN_BOTTOM = 8;
|
|
1462
|
-
var
|
|
1641
|
+
var styles14 = StyleSheet.create({
|
|
1463
1642
|
container: {
|
|
1464
1643
|
padding: PROMPT_PADDING,
|
|
1465
1644
|
borderRadius: PROMPT_BORDER_RADIUS,
|
|
@@ -1494,21 +1673,21 @@ var UpgradePrompt = ({
|
|
|
1494
1673
|
return /* @__PURE__ */ jsxs(
|
|
1495
1674
|
View,
|
|
1496
1675
|
{
|
|
1497
|
-
style: [
|
|
1676
|
+
style: [styles14.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1498
1677
|
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1499
1678
|
children: [
|
|
1500
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1501
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1679
|
+
/* @__PURE__ */ jsx(Text, { style: [styles14.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1680
|
+
/* @__PURE__ */ jsx(Text, { style: [styles14.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1502
1681
|
/* @__PURE__ */ jsx(
|
|
1503
1682
|
TouchableOpacity,
|
|
1504
1683
|
{
|
|
1505
1684
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1506
1685
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1507
1686
|
accessibilityRole: "button",
|
|
1508
|
-
style: [
|
|
1687
|
+
style: [styles14.cta, { backgroundColor: primary }],
|
|
1509
1688
|
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1510
1689
|
onPress: handleUpgradePress,
|
|
1511
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1690
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles14.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1512
1691
|
}
|
|
1513
1692
|
),
|
|
1514
1693
|
onDismiss ? /* @__PURE__ */ jsx(
|
|
@@ -1517,10 +1696,10 @@ var UpgradePrompt = ({
|
|
|
1517
1696
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1518
1697
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1519
1698
|
accessibilityRole: "button",
|
|
1520
|
-
style:
|
|
1699
|
+
style: styles14.dismiss,
|
|
1521
1700
|
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1522
1701
|
onPress: onDismiss,
|
|
1523
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1702
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles14.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1524
1703
|
}
|
|
1525
1704
|
) : null
|
|
1526
1705
|
]
|
|
@@ -1528,8 +1707,8 @@ var UpgradePrompt = ({
|
|
|
1528
1707
|
);
|
|
1529
1708
|
};
|
|
1530
1709
|
var CLOSE_ICON_SIZE = 18;
|
|
1531
|
-
var
|
|
1532
|
-
var
|
|
1710
|
+
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1711
|
+
var styles15 = StyleSheet.create({
|
|
1533
1712
|
animatedFill: { flex: 1 },
|
|
1534
1713
|
container: {
|
|
1535
1714
|
flex: 1,
|
|
@@ -1554,21 +1733,21 @@ var ModalShell = ({
|
|
|
1554
1733
|
showClose = true
|
|
1555
1734
|
}) => {
|
|
1556
1735
|
const { theme, t } = useUi();
|
|
1557
|
-
const { style: sheetStyle, mounted } = useEnterExit({ visible, fromScale:
|
|
1736
|
+
const { style: sheetStyle, mounted } = useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1558
1737
|
const containerStyle = React12.useMemo(
|
|
1559
|
-
() => [
|
|
1738
|
+
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1560
1739
|
[theme.colors.background, contentStyle]
|
|
1561
1740
|
);
|
|
1562
1741
|
const closeA11yLabel = t(LAYOUT_I18N.close);
|
|
1563
1742
|
const accessibleTitle = typeof title === "string" ? title : t(LAYOUT_I18N.dialog);
|
|
1564
1743
|
return /* @__PURE__ */ jsx(
|
|
1565
|
-
Modal,
|
|
1744
|
+
Modal$1,
|
|
1566
1745
|
{
|
|
1567
1746
|
transparent: true,
|
|
1568
1747
|
testID: LAYOUT_TEST_IDS.modalShell,
|
|
1569
1748
|
visible: mounted,
|
|
1570
1749
|
onRequestClose: onCancel,
|
|
1571
|
-
children: /* @__PURE__ */ jsx(Animated.View, { style: [
|
|
1750
|
+
children: /* @__PURE__ */ jsx(Animated.View, { style: [styles15.animatedFill, sheetStyle], children: /* @__PURE__ */ jsxs(
|
|
1572
1751
|
ScrollView,
|
|
1573
1752
|
{
|
|
1574
1753
|
accessibilityViewIsModal: true,
|
|
@@ -1576,7 +1755,7 @@ var ModalShell = ({
|
|
|
1576
1755
|
role: "dialog",
|
|
1577
1756
|
style: containerStyle,
|
|
1578
1757
|
children: [
|
|
1579
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1758
|
+
/* @__PURE__ */ jsxs(View, { style: styles15.headerRow, children: [
|
|
1580
1759
|
/* @__PURE__ */ jsx(Heading, { children: title ?? t(LAYOUT_I18N.closeHeading) }),
|
|
1581
1760
|
showClose ? /* @__PURE__ */ jsx(
|
|
1582
1761
|
TouchableOpacity,
|
|
@@ -1584,7 +1763,7 @@ var ModalShell = ({
|
|
|
1584
1763
|
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1585
1764
|
accessibilityLabel: closeA11yLabel,
|
|
1586
1765
|
accessibilityRole: "button",
|
|
1587
|
-
style:
|
|
1766
|
+
style: styles15.closeButton,
|
|
1588
1767
|
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
1589
1768
|
onPress: onCancel,
|
|
1590
1769
|
children: /* @__PURE__ */ jsx(SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
@@ -1598,148 +1777,6 @@ var ModalShell = ({
|
|
|
1598
1777
|
}
|
|
1599
1778
|
);
|
|
1600
1779
|
};
|
|
1601
|
-
function useEscapeKey(enabled, onClose) {
|
|
1602
|
-
useEffect(() => {
|
|
1603
|
-
if (Platform.OS !== "web" || !enabled) return;
|
|
1604
|
-
const onKeyDown = (event) => {
|
|
1605
|
-
if (event.key === "Escape") onClose();
|
|
1606
|
-
};
|
|
1607
|
-
document.addEventListener("keydown", onKeyDown);
|
|
1608
|
-
return () => {
|
|
1609
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
1610
|
-
};
|
|
1611
|
-
}, [enabled, onClose]);
|
|
1612
|
-
}
|
|
1613
|
-
function useScrollLock(enabled) {
|
|
1614
|
-
useEffect(() => {
|
|
1615
|
-
if (Platform.OS !== "web" || !enabled) return;
|
|
1616
|
-
const { body } = document;
|
|
1617
|
-
const previousOverflow = body.style.overflow;
|
|
1618
|
-
body.style.overflow = "hidden";
|
|
1619
|
-
return () => {
|
|
1620
|
-
body.style.overflow = previousOverflow;
|
|
1621
|
-
};
|
|
1622
|
-
}, [enabled]);
|
|
1623
|
-
}
|
|
1624
|
-
var OVERLAY_PADDING = 16;
|
|
1625
|
-
var DIALOG_RADIUS = 12;
|
|
1626
|
-
var DIALOG_PADDING = 16;
|
|
1627
|
-
var HEADER_GAP = 12;
|
|
1628
|
-
var FOOTER_MARGIN = 16;
|
|
1629
|
-
var HEADER_MARGIN = 12;
|
|
1630
|
-
var DIALOG_MAX_HEIGHT = "90%";
|
|
1631
|
-
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1632
|
-
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640 };
|
|
1633
|
-
var styles15 = StyleSheet.create({
|
|
1634
|
-
overlay: {
|
|
1635
|
-
flex: 1,
|
|
1636
|
-
justifyContent: "center",
|
|
1637
|
-
alignItems: "center",
|
|
1638
|
-
padding: OVERLAY_PADDING
|
|
1639
|
-
},
|
|
1640
|
-
// The scrim is its OWN animated layer (behind the tap-catcher and the panel) so its opacity
|
|
1641
|
-
// can fade independently of the panel's fade+scale. `animationType` is a native-only no-op on
|
|
1642
|
-
// react-native-web, which is why the fade is driven by `Animated` instead. `pointerEvents` lives
|
|
1643
|
-
// in style (not the deprecated prop) so taps fall through to the sibling tap-catcher below.
|
|
1644
|
-
scrim: { backgroundColor: MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
1645
|
-
dialog: {
|
|
1646
|
-
width: "100%",
|
|
1647
|
-
borderRadius: DIALOG_RADIUS,
|
|
1648
|
-
padding: DIALOG_PADDING,
|
|
1649
|
-
maxHeight: DIALOG_MAX_HEIGHT
|
|
1650
|
-
},
|
|
1651
|
-
headerRow: {
|
|
1652
|
-
flexDirection: "row",
|
|
1653
|
-
alignItems: "flex-start",
|
|
1654
|
-
justifyContent: "space-between",
|
|
1655
|
-
columnGap: HEADER_GAP,
|
|
1656
|
-
marginBottom: HEADER_MARGIN
|
|
1657
|
-
},
|
|
1658
|
-
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
1659
|
-
titleWrap: { flex: 1 },
|
|
1660
|
-
footer: { marginTop: FOOTER_MARGIN }
|
|
1661
|
-
});
|
|
1662
|
-
var Modal3 = ({
|
|
1663
|
-
visible,
|
|
1664
|
-
onClose,
|
|
1665
|
-
title,
|
|
1666
|
-
children,
|
|
1667
|
-
footer,
|
|
1668
|
-
size = "md",
|
|
1669
|
-
showClose = true,
|
|
1670
|
-
testID = LAYOUT_TEST_IDS.modal,
|
|
1671
|
-
accessibilityLabel,
|
|
1672
|
-
initialFocusTestID
|
|
1673
|
-
}) => {
|
|
1674
|
-
const { theme, t } = useUi();
|
|
1675
|
-
const dialogRef = useRef(null);
|
|
1676
|
-
const backdrop = useEnterExit({ visible });
|
|
1677
|
-
const panel = useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1678
|
-
const mounted = panel.mounted || backdrop.mounted;
|
|
1679
|
-
useFocusTrap(dialogRef, visible, initialFocusTestID);
|
|
1680
|
-
useEscapeKey(visible, onClose);
|
|
1681
|
-
useScrollLock(visible);
|
|
1682
|
-
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
1683
|
-
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
1684
|
-
const dialogStyle = useMemo(
|
|
1685
|
-
() => [styles15.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
1686
|
-
[theme.colors.surface, size]
|
|
1687
|
-
);
|
|
1688
|
-
const hasHeader = title !== void 0 || showClose;
|
|
1689
|
-
return /* @__PURE__ */ jsx(Modal, { transparent: true, visible: mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles15.overlay, children: [
|
|
1690
|
-
/* @__PURE__ */ jsx(
|
|
1691
|
-
Animated.View,
|
|
1692
|
-
{
|
|
1693
|
-
style: [StyleSheet.absoluteFill, styles15.scrim, { opacity: backdrop.style.opacity }]
|
|
1694
|
-
}
|
|
1695
|
-
),
|
|
1696
|
-
/* @__PURE__ */ jsx(
|
|
1697
|
-
TouchableOpacity,
|
|
1698
|
-
{
|
|
1699
|
-
accessible: true,
|
|
1700
|
-
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
1701
|
-
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
1702
|
-
accessibilityRole: "button",
|
|
1703
|
-
activeOpacity: 1,
|
|
1704
|
-
style: StyleSheet.absoluteFill,
|
|
1705
|
-
testID: `${testID}-backdrop`,
|
|
1706
|
-
onPress: onClose
|
|
1707
|
-
}
|
|
1708
|
-
),
|
|
1709
|
-
/* @__PURE__ */ jsxs(
|
|
1710
|
-
Animated.View,
|
|
1711
|
-
{
|
|
1712
|
-
ref: dialogRef,
|
|
1713
|
-
accessibilityViewIsModal: true,
|
|
1714
|
-
"aria-label": accessibleName,
|
|
1715
|
-
role: "dialog",
|
|
1716
|
-
style: [dialogStyle, panel.style],
|
|
1717
|
-
testID,
|
|
1718
|
-
children: [
|
|
1719
|
-
hasHeader ? /* @__PURE__ */ jsxs(View, { style: styles15.headerRow, children: [
|
|
1720
|
-
/* @__PURE__ */ jsx(View, { style: styles15.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsx(Heading, { children: title }) : null }),
|
|
1721
|
-
showClose ? /* @__PURE__ */ jsx(
|
|
1722
|
-
IconButton,
|
|
1723
|
-
{
|
|
1724
|
-
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1725
|
-
accessibilityLabel: closeLabel,
|
|
1726
|
-
appearance: "ghost",
|
|
1727
|
-
renderIcon: (color, iconSize) => /* @__PURE__ */ jsx(SvgIcon, { color, name: "close", size: iconSize }),
|
|
1728
|
-
size: "md",
|
|
1729
|
-
testID: `${testID}-close`,
|
|
1730
|
-
tooltip: closeLabel,
|
|
1731
|
-
variant: "ghost",
|
|
1732
|
-
onPress: onClose
|
|
1733
|
-
}
|
|
1734
|
-
) : null
|
|
1735
|
-
] }) : null,
|
|
1736
|
-
/* @__PURE__ */ jsx(ScrollView, { children }),
|
|
1737
|
-
footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: styles15.footer, children: footer }) : null
|
|
1738
|
-
]
|
|
1739
|
-
}
|
|
1740
|
-
)
|
|
1741
|
-
] }) });
|
|
1742
|
-
};
|
|
1743
1780
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1744
1781
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1745
1782
|
var BUTTON_GAP = 12;
|
|
@@ -1789,7 +1826,7 @@ var ConfirmDialog = ({
|
|
|
1789
1826
|
)
|
|
1790
1827
|
] });
|
|
1791
1828
|
return /* @__PURE__ */ jsx(
|
|
1792
|
-
|
|
1829
|
+
Modal,
|
|
1793
1830
|
{
|
|
1794
1831
|
footer,
|
|
1795
1832
|
showClose: false,
|
|
@@ -2670,6 +2707,6 @@ var ListRow = ({
|
|
|
2670
2707
|
] });
|
|
2671
2708
|
};
|
|
2672
2709
|
|
|
2673
|
-
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX,
|
|
2710
|
+
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, Modal, ModalDropdown, ModalShell, PageFrame, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
2674
2711
|
//# sourceMappingURL=index.mjs.map
|
|
2675
2712
|
//# sourceMappingURL=index.mjs.map
|