@dloizides/ui-layout 1.37.0 → 1.38.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 +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +294 -265
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +296 -267
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,12 +4,12 @@ var React12 = 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');
|
|
7
|
-
var
|
|
7
|
+
var uiButtons = require('@dloizides/ui-buttons');
|
|
8
|
+
var uiIcons = require('@dloizides/ui-icons');
|
|
8
9
|
var uiMotion = require('@dloizides/ui-motion');
|
|
10
|
+
var a11y = require('@dloizides/a11y');
|
|
9
11
|
var reactDom = require('react-dom');
|
|
10
12
|
var designTokens = require('@dloizides/design-tokens');
|
|
11
|
-
var uiIcons = require('@dloizides/ui-icons');
|
|
12
|
-
var uiButtons = require('@dloizides/ui-buttons');
|
|
13
13
|
var rnWebHooks = require('@dloizides/rn-web-hooks');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -139,6 +139,9 @@ var LAYOUT_I18N = {
|
|
|
139
139
|
closeHeading: "close",
|
|
140
140
|
/** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
|
|
141
141
|
dialogClose: "common.close",
|
|
142
|
+
/** `PageFrame` (`enlargeable`): accessible name + hint of the preview that opens the full-size page. */
|
|
143
|
+
pageEnlarge: "common.pageEnlarge",
|
|
144
|
+
pageEnlargeHint: "common.pageEnlargeHint",
|
|
142
145
|
/** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
|
|
143
146
|
confirm: "common.confirm",
|
|
144
147
|
confirmHint: "common.confirmHint",
|
|
@@ -377,6 +380,215 @@ var StickyPreview = ({
|
|
|
377
380
|
)
|
|
378
381
|
] });
|
|
379
382
|
};
|
|
383
|
+
function useEscapeKey(enabled, onClose) {
|
|
384
|
+
React12.useEffect(() => {
|
|
385
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
386
|
+
const onKeyDown = (event) => {
|
|
387
|
+
if (event.key === "Escape") onClose();
|
|
388
|
+
};
|
|
389
|
+
document.addEventListener("keydown", onKeyDown);
|
|
390
|
+
return () => {
|
|
391
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
392
|
+
};
|
|
393
|
+
}, [enabled, onClose]);
|
|
394
|
+
}
|
|
395
|
+
var FOCUSABLE_SELECTOR = [
|
|
396
|
+
"a[href]",
|
|
397
|
+
"button:not([disabled])",
|
|
398
|
+
"input:not([disabled])",
|
|
399
|
+
"select:not([disabled])",
|
|
400
|
+
"textarea:not([disabled])",
|
|
401
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
402
|
+
].join(", ");
|
|
403
|
+
function getFocusableElements(container) {
|
|
404
|
+
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
405
|
+
}
|
|
406
|
+
function savePreviousFocus() {
|
|
407
|
+
return document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
408
|
+
}
|
|
409
|
+
function focusInitial(domNode, initialFocusTestID) {
|
|
410
|
+
const named = initialFocusTestID === void 0 ? null : domNode.querySelector(`[data-testid="${initialFocusTestID}"]`);
|
|
411
|
+
if (named) {
|
|
412
|
+
named.focus();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (domNode.contains(document.activeElement)) return;
|
|
416
|
+
getFocusableElements(domNode)[0]?.focus();
|
|
417
|
+
}
|
|
418
|
+
function handleKeyDown(domNode, event) {
|
|
419
|
+
if (event.key !== "Tab") return;
|
|
420
|
+
const focusable = getFocusableElements(domNode);
|
|
421
|
+
if (focusable.length === 0) {
|
|
422
|
+
event.preventDefault();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const first = focusable[0];
|
|
426
|
+
const last = focusable[focusable.length - 1];
|
|
427
|
+
if (!first || !last) {
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
const active = document.activeElement;
|
|
432
|
+
if (event.shiftKey && active === first) {
|
|
433
|
+
event.preventDefault();
|
|
434
|
+
last.focus();
|
|
435
|
+
} else if (!event.shiftKey && active === last) {
|
|
436
|
+
event.preventDefault();
|
|
437
|
+
first.focus();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
441
|
+
const previousFocusRef = React12.useRef(null);
|
|
442
|
+
React12.useEffect(() => {
|
|
443
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
444
|
+
const domNode = containerRef.current;
|
|
445
|
+
if (!domNode) return;
|
|
446
|
+
const previous = savePreviousFocus();
|
|
447
|
+
previousFocusRef.current = previous !== null && domNode.contains(previous) ? null : previous;
|
|
448
|
+
queueMicrotask(() => focusInitial(domNode, initialFocusTestID));
|
|
449
|
+
const listener = (e) => handleKeyDown(domNode, e);
|
|
450
|
+
domNode.addEventListener("keydown", listener);
|
|
451
|
+
return () => {
|
|
452
|
+
domNode.removeEventListener("keydown", listener);
|
|
453
|
+
previousFocusRef.current?.focus();
|
|
454
|
+
previousFocusRef.current = null;
|
|
455
|
+
};
|
|
456
|
+
}, [containerRef, enabled, initialFocusTestID]);
|
|
457
|
+
}
|
|
458
|
+
function useScrollLock(enabled) {
|
|
459
|
+
React12.useEffect(() => {
|
|
460
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
461
|
+
const { body } = document;
|
|
462
|
+
const previousOverflow = body.style.overflow;
|
|
463
|
+
body.style.overflow = "hidden";
|
|
464
|
+
return () => {
|
|
465
|
+
body.style.overflow = previousOverflow;
|
|
466
|
+
};
|
|
467
|
+
}, [enabled]);
|
|
468
|
+
}
|
|
469
|
+
var OVERLAY_PADDING = 16;
|
|
470
|
+
var DIALOG_RADIUS = 12;
|
|
471
|
+
var DIALOG_PADDING = 16;
|
|
472
|
+
var HEADER_GAP = 12;
|
|
473
|
+
var FOOTER_MARGIN = 16;
|
|
474
|
+
var HEADER_MARGIN = 12;
|
|
475
|
+
var DIALOG_MAX_HEIGHT = "90%";
|
|
476
|
+
var PANEL_ENTER_SCALE = 0.96;
|
|
477
|
+
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640, xl: 880 };
|
|
478
|
+
var styles6 = reactNative.StyleSheet.create({
|
|
479
|
+
overlay: {
|
|
480
|
+
flex: 1,
|
|
481
|
+
justifyContent: "center",
|
|
482
|
+
alignItems: "center",
|
|
483
|
+
padding: OVERLAY_PADDING
|
|
484
|
+
},
|
|
485
|
+
// The scrim is its OWN animated layer (behind the tap-catcher and the panel) so its opacity
|
|
486
|
+
// can fade independently of the panel's fade+scale. `animationType` is a native-only no-op on
|
|
487
|
+
// react-native-web, which is why the fade is driven by `Animated` instead. `pointerEvents` lives
|
|
488
|
+
// in style (not the deprecated prop) so taps fall through to the sibling tap-catcher below.
|
|
489
|
+
scrim: { backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
490
|
+
dialog: {
|
|
491
|
+
width: "100%",
|
|
492
|
+
borderRadius: DIALOG_RADIUS,
|
|
493
|
+
padding: DIALOG_PADDING,
|
|
494
|
+
maxHeight: DIALOG_MAX_HEIGHT
|
|
495
|
+
},
|
|
496
|
+
headerRow: {
|
|
497
|
+
flexDirection: "row",
|
|
498
|
+
alignItems: "flex-start",
|
|
499
|
+
justifyContent: "space-between",
|
|
500
|
+
columnGap: HEADER_GAP,
|
|
501
|
+
marginBottom: HEADER_MARGIN
|
|
502
|
+
},
|
|
503
|
+
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
504
|
+
titleWrap: { flex: 1 },
|
|
505
|
+
footer: { marginTop: FOOTER_MARGIN }
|
|
506
|
+
});
|
|
507
|
+
var Modal = ({
|
|
508
|
+
visible,
|
|
509
|
+
onClose,
|
|
510
|
+
title,
|
|
511
|
+
children,
|
|
512
|
+
footer,
|
|
513
|
+
size = "md",
|
|
514
|
+
showClose = true,
|
|
515
|
+
testID = LAYOUT_TEST_IDS.modal,
|
|
516
|
+
accessibilityLabel,
|
|
517
|
+
initialFocusTestID
|
|
518
|
+
}) => {
|
|
519
|
+
const { theme, t } = uiFeedback.useUi();
|
|
520
|
+
const dialogRef = React12.useRef(null);
|
|
521
|
+
const backdrop = uiMotion.useEnterExit({ visible });
|
|
522
|
+
const panel = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE });
|
|
523
|
+
const mounted = panel.mounted || backdrop.mounted;
|
|
524
|
+
useFocusTrap(dialogRef, visible, initialFocusTestID);
|
|
525
|
+
useEscapeKey(visible, onClose);
|
|
526
|
+
useScrollLock(visible);
|
|
527
|
+
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
528
|
+
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
529
|
+
const dialogStyle = React12.useMemo(
|
|
530
|
+
() => [styles6.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
531
|
+
[theme.colors.surface, size]
|
|
532
|
+
);
|
|
533
|
+
const hasHeader = title !== void 0 || showClose;
|
|
534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.overlay, children: [
|
|
535
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
536
|
+
reactNative.Animated.View,
|
|
537
|
+
{
|
|
538
|
+
style: [reactNative.StyleSheet.absoluteFill, styles6.scrim, { opacity: backdrop.style.opacity }]
|
|
539
|
+
}
|
|
540
|
+
),
|
|
541
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
542
|
+
reactNative.TouchableOpacity,
|
|
543
|
+
{
|
|
544
|
+
accessible: true,
|
|
545
|
+
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
546
|
+
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
547
|
+
accessibilityRole: "button",
|
|
548
|
+
activeOpacity: 1,
|
|
549
|
+
style: reactNative.StyleSheet.absoluteFill,
|
|
550
|
+
testID: `${testID}-backdrop`,
|
|
551
|
+
onPress: onClose
|
|
552
|
+
}
|
|
553
|
+
),
|
|
554
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
555
|
+
reactNative.Animated.View,
|
|
556
|
+
{
|
|
557
|
+
ref: dialogRef,
|
|
558
|
+
accessibilityViewIsModal: true,
|
|
559
|
+
"aria-label": accessibleName,
|
|
560
|
+
role: "dialog",
|
|
561
|
+
style: [dialogStyle, panel.style],
|
|
562
|
+
testID,
|
|
563
|
+
children: [
|
|
564
|
+
hasHeader ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles6.headerRow, children: [
|
|
565
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles6.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title }) : null }),
|
|
566
|
+
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
567
|
+
uiButtons.IconButton,
|
|
568
|
+
{
|
|
569
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
570
|
+
accessibilityLabel: closeLabel,
|
|
571
|
+
appearance: "ghost",
|
|
572
|
+
renderIcon: (color, iconSize) => /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color, name: "close", size: iconSize }),
|
|
573
|
+
size: "md",
|
|
574
|
+
testID: `${testID}-close`,
|
|
575
|
+
tooltip: closeLabel,
|
|
576
|
+
variant: "ghost",
|
|
577
|
+
onPress: onClose
|
|
578
|
+
}
|
|
579
|
+
) : null
|
|
580
|
+
] }) : null,
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { children }),
|
|
582
|
+
footer !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles6.footer, children: footer }) : null
|
|
583
|
+
]
|
|
584
|
+
}
|
|
585
|
+
)
|
|
586
|
+
] }) });
|
|
587
|
+
};
|
|
588
|
+
var PageOverlay = ({ children, pageSize, visible, onClose, testID }) => {
|
|
589
|
+
const { t } = uiFeedback.useUi();
|
|
590
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Modal, { accessibilityLabel: t(LAYOUT_I18N.pageEnlarge), size: "xl", testID, visible, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { width: pageSize.width, height: pageSize.height }, testID: `${testID}-page`, children }) }) });
|
|
591
|
+
};
|
|
380
592
|
|
|
381
593
|
// src/PageFrame/utils/pageScale.ts
|
|
382
594
|
var HALF = 2;
|
|
@@ -394,25 +606,31 @@ var scaledFrame = (containerWidth, page) => {
|
|
|
394
606
|
offsetY: (scale - 1) * page.height / HALF
|
|
395
607
|
};
|
|
396
608
|
};
|
|
397
|
-
var
|
|
609
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
398
610
|
outer: { width: "100%", overflow: "hidden" },
|
|
399
|
-
page: { position: "absolute", top: 0, left: 0 }
|
|
611
|
+
page: { position: "absolute", top: 0, left: 0 },
|
|
612
|
+
trigger: { width: "100%", cursor: "pointer" }
|
|
400
613
|
});
|
|
401
614
|
var PageFrame = ({
|
|
402
615
|
children,
|
|
403
616
|
pageSize = A4_PAGE,
|
|
404
|
-
testID = LAYOUT_TEST_IDS.pageFrame
|
|
617
|
+
testID = LAYOUT_TEST_IDS.pageFrame,
|
|
618
|
+
enlargeable = false
|
|
405
619
|
}) => {
|
|
620
|
+
const { t } = uiFeedback.useUi();
|
|
406
621
|
const [containerWidth, setContainerWidth] = React12.useState(0);
|
|
622
|
+
const [enlarged, setEnlarged] = React12.useState(false);
|
|
407
623
|
const onLayout = React12.useCallback((event) => {
|
|
408
624
|
setContainerWidth(event.nativeEvent.layout.width);
|
|
409
625
|
}, []);
|
|
626
|
+
const open = React12.useCallback(() => setEnlarged(true), []);
|
|
627
|
+
const close = React12.useCallback(() => setEnlarged(false), []);
|
|
410
628
|
const frame = scaledFrame(containerWidth, pageSize);
|
|
411
|
-
|
|
629
|
+
const preview = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles7.outer, { height: frame.height }], testID, onLayout, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
412
630
|
reactNative.View,
|
|
413
631
|
{
|
|
414
632
|
style: [
|
|
415
|
-
|
|
633
|
+
styles7.page,
|
|
416
634
|
{
|
|
417
635
|
width: pageSize.width,
|
|
418
636
|
height: pageSize.height,
|
|
@@ -422,6 +640,22 @@ var PageFrame = ({
|
|
|
422
640
|
children
|
|
423
641
|
}
|
|
424
642
|
) });
|
|
643
|
+
if (!enlargeable) return preview;
|
|
644
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
645
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
646
|
+
reactNative.Pressable,
|
|
647
|
+
{
|
|
648
|
+
accessibilityHint: t(LAYOUT_I18N.pageEnlargeHint),
|
|
649
|
+
accessibilityLabel: t(LAYOUT_I18N.pageEnlarge),
|
|
650
|
+
accessibilityRole: "button",
|
|
651
|
+
style: styles7.trigger,
|
|
652
|
+
testID: `${testID}-enlarge`,
|
|
653
|
+
onPress: open,
|
|
654
|
+
children: preview
|
|
655
|
+
}
|
|
656
|
+
),
|
|
657
|
+
/* @__PURE__ */ jsxRuntime.jsx(PageOverlay, { pageSize, testID: `${testID}-overlay`, visible: enlarged, onClose: close, children })
|
|
658
|
+
] });
|
|
425
659
|
};
|
|
426
660
|
var TRACK_PADDING = 3;
|
|
427
661
|
var TRACK_RADIUS = 999;
|
|
@@ -434,7 +668,7 @@ var BORDER_WIDTH = 1;
|
|
|
434
668
|
var SEGMENT_BOX_SHADOW = "0px 1px 3px rgba(20, 30, 50, 0.1)";
|
|
435
669
|
var SHADOW_ELEVATION = 2;
|
|
436
670
|
var TRANSPARENT = "transparent";
|
|
437
|
-
var
|
|
671
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
438
672
|
track: {
|
|
439
673
|
flexDirection: "row",
|
|
440
674
|
alignSelf: "flex-start",
|
|
@@ -479,7 +713,7 @@ function SegmentedControl({
|
|
|
479
713
|
{
|
|
480
714
|
accessibilityRole: "tablist",
|
|
481
715
|
"aria-label": accessibilityLabel,
|
|
482
|
-
style: [
|
|
716
|
+
style: [styles8.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
|
|
483
717
|
testID,
|
|
484
718
|
children: options.map((opt) => {
|
|
485
719
|
const selected = opt.value === value;
|
|
@@ -492,13 +726,13 @@ function SegmentedControl({
|
|
|
492
726
|
accessibilityHint: opt.accessibilityHint,
|
|
493
727
|
onPress: () => onChange(opt.value),
|
|
494
728
|
style: [
|
|
495
|
-
|
|
496
|
-
selected ?
|
|
729
|
+
styles8.segment,
|
|
730
|
+
selected ? styles8.segmentSelected : null,
|
|
497
731
|
{ backgroundColor: selected ? colors.surface : TRANSPARENT }
|
|
498
732
|
],
|
|
499
733
|
testID: opt.testID,
|
|
500
734
|
...ariaSelectedProps(selected),
|
|
501
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
735
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
|
|
502
736
|
},
|
|
503
737
|
opt.value
|
|
504
738
|
);
|
|
@@ -513,69 +747,6 @@ var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
|
513
747
|
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
514
748
|
return TabsCollapsedTrigger2;
|
|
515
749
|
})(TabsCollapsedTrigger || {});
|
|
516
|
-
var FOCUSABLE_SELECTOR = [
|
|
517
|
-
"a[href]",
|
|
518
|
-
"button:not([disabled])",
|
|
519
|
-
"input:not([disabled])",
|
|
520
|
-
"select:not([disabled])",
|
|
521
|
-
"textarea:not([disabled])",
|
|
522
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
523
|
-
].join(", ");
|
|
524
|
-
function getFocusableElements(container) {
|
|
525
|
-
return Array.from(container.querySelectorAll(FOCUSABLE_SELECTOR));
|
|
526
|
-
}
|
|
527
|
-
function savePreviousFocus() {
|
|
528
|
-
return document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
529
|
-
}
|
|
530
|
-
function focusInitial(domNode, initialFocusTestID) {
|
|
531
|
-
const named = initialFocusTestID === void 0 ? null : domNode.querySelector(`[data-testid="${initialFocusTestID}"]`);
|
|
532
|
-
if (named) {
|
|
533
|
-
named.focus();
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
if (domNode.contains(document.activeElement)) return;
|
|
537
|
-
getFocusableElements(domNode)[0]?.focus();
|
|
538
|
-
}
|
|
539
|
-
function handleKeyDown(domNode, event) {
|
|
540
|
-
if (event.key !== "Tab") return;
|
|
541
|
-
const focusable = getFocusableElements(domNode);
|
|
542
|
-
if (focusable.length === 0) {
|
|
543
|
-
event.preventDefault();
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const first = focusable[0];
|
|
547
|
-
const last = focusable[focusable.length - 1];
|
|
548
|
-
if (!first || !last) {
|
|
549
|
-
event.preventDefault();
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
const active = document.activeElement;
|
|
553
|
-
if (event.shiftKey && active === first) {
|
|
554
|
-
event.preventDefault();
|
|
555
|
-
last.focus();
|
|
556
|
-
} else if (!event.shiftKey && active === last) {
|
|
557
|
-
event.preventDefault();
|
|
558
|
-
first.focus();
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function useFocusTrap(containerRef, enabled, initialFocusTestID) {
|
|
562
|
-
const previousFocusRef = React12.useRef(null);
|
|
563
|
-
React12.useEffect(() => {
|
|
564
|
-
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
565
|
-
const domNode = containerRef.current;
|
|
566
|
-
if (!domNode) return;
|
|
567
|
-
const previous = savePreviousFocus();
|
|
568
|
-
previousFocusRef.current = previous !== null && domNode.contains(previous) ? null : previous;
|
|
569
|
-
queueMicrotask(() => focusInitial(domNode, initialFocusTestID));
|
|
570
|
-
const listener = (e) => handleKeyDown(domNode, e);
|
|
571
|
-
domNode.addEventListener("keydown", listener);
|
|
572
|
-
return () => {
|
|
573
|
-
domNode.removeEventListener("keydown", listener);
|
|
574
|
-
previousFocusRef.current?.focus();
|
|
575
|
-
previousFocusRef.current = null;
|
|
576
|
-
};
|
|
577
|
-
}, [containerRef, enabled, initialFocusTestID]);
|
|
578
|
-
}
|
|
579
750
|
|
|
580
751
|
// src/ModalDropdown/DropdownVariant.ts
|
|
581
752
|
var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
|
|
@@ -635,7 +806,7 @@ var HEADING_PADDING_H = 16;
|
|
|
635
806
|
var HEADING_PADDING_TOP = 8;
|
|
636
807
|
var HEADING_PADDING_BOTTOM = 4;
|
|
637
808
|
var HEADING_LETTER_SPACING = 0.5;
|
|
638
|
-
var
|
|
809
|
+
var styles9 = reactNative.StyleSheet.create({
|
|
639
810
|
heading: {
|
|
640
811
|
fontSize: HEADING_FONT_SIZE,
|
|
641
812
|
fontWeight: HEADING_FONT_WEIGHT,
|
|
@@ -651,7 +822,7 @@ var MenuHeading = ({ testID, text }) => {
|
|
|
651
822
|
reactNative.Text,
|
|
652
823
|
{
|
|
653
824
|
accessibilityRole: "header",
|
|
654
|
-
style: [
|
|
825
|
+
style: [styles9.heading, { color: theme.colors.textSecondary }],
|
|
655
826
|
testID: `${testID}-menu-heading`,
|
|
656
827
|
children: text
|
|
657
828
|
}
|
|
@@ -672,7 +843,7 @@ var OPTION_PADDING_V = 12;
|
|
|
672
843
|
var ACCENT_BAR_WIDTH = 3;
|
|
673
844
|
var CHECK_GAP = 8;
|
|
674
845
|
var CHECK_GLYPH = "\u2713";
|
|
675
|
-
var
|
|
846
|
+
var styles10 = reactNative.StyleSheet.create({
|
|
676
847
|
option: {
|
|
677
848
|
paddingHorizontal: OPTION_PADDING_H,
|
|
678
849
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -711,16 +882,16 @@ var OptionRow = ({
|
|
|
711
882
|
const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
|
|
712
883
|
const isActive = isSelected || isHighlighted;
|
|
713
884
|
const rowStyle = [
|
|
714
|
-
|
|
715
|
-
isMarked ?
|
|
885
|
+
styles10.option,
|
|
886
|
+
isMarked ? styles10.markedRow : null,
|
|
716
887
|
isActive ? { backgroundColor: colors.surfaceElevated } : null,
|
|
717
888
|
isMarked && isSelected ? { borderLeftColor: accentColor } : null
|
|
718
889
|
];
|
|
719
890
|
const textStyle = [
|
|
720
|
-
|
|
891
|
+
styles10.optionText,
|
|
721
892
|
{ color: colors.text },
|
|
722
|
-
isSelected ?
|
|
723
|
-
isMarked ?
|
|
893
|
+
isSelected ? styles10.selectedText : null,
|
|
894
|
+
isMarked ? styles10.markedText : null
|
|
724
895
|
];
|
|
725
896
|
const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
|
|
726
897
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -736,7 +907,7 @@ var OptionRow = ({
|
|
|
736
907
|
onPress: handlePress,
|
|
737
908
|
children: [
|
|
738
909
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label }),
|
|
739
|
-
isMarked && isSelected ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
910
|
+
isMarked && isSelected ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles10.selectedText, { color: accentColor }], children: CHECK_GLYPH }) }) : null
|
|
740
911
|
]
|
|
741
912
|
}
|
|
742
913
|
);
|
|
@@ -894,7 +1065,7 @@ var IS_WEB2 = reactNative.Platform.OS === "web";
|
|
|
894
1065
|
var BORDER_RADIUS2 = 8;
|
|
895
1066
|
var BORDER_WIDTH3 = 1;
|
|
896
1067
|
var MENU_PADDING2 = 4;
|
|
897
|
-
var
|
|
1068
|
+
var styles11 = reactNative.StyleSheet.create({
|
|
898
1069
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
899
1070
|
popover: {
|
|
900
1071
|
position: "absolute",
|
|
@@ -981,7 +1152,7 @@ var InlineMenu = ({
|
|
|
981
1152
|
themed
|
|
982
1153
|
];
|
|
983
1154
|
}
|
|
984
|
-
return [
|
|
1155
|
+
return [styles11.popover, { minWidth: menuMinWidth }, themed];
|
|
985
1156
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
986
1157
|
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
987
1158
|
reactNative.View,
|
|
@@ -996,10 +1167,10 @@ var InlineMenu = ({
|
|
|
996
1167
|
reactNative.Animated.View,
|
|
997
1168
|
{
|
|
998
1169
|
pointerEvents: isOpen ? "auto" : "none",
|
|
999
|
-
style: [
|
|
1170
|
+
style: [styles11.animated, animatedStyle, isOpen ? null : styles11.inert],
|
|
1000
1171
|
children: [
|
|
1001
1172
|
menuHeading !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(MenuHeading, { testID, text: menuHeading }) : null,
|
|
1002
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style:
|
|
1173
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style: styles11.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1003
1174
|
OptionRow,
|
|
1004
1175
|
{
|
|
1005
1176
|
asMenuItem: true,
|
|
@@ -1047,7 +1218,7 @@ var CARET_OPEN_ROTATION = "180deg";
|
|
|
1047
1218
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
1048
1219
|
var POPOVER_ENTER_SCALE = 0.96;
|
|
1049
1220
|
var POPOVER_MOTION_MS = 120;
|
|
1050
|
-
var
|
|
1221
|
+
var styles12 = reactNative.StyleSheet.create({
|
|
1051
1222
|
anchor: { position: "relative" },
|
|
1052
1223
|
container: {
|
|
1053
1224
|
borderWidth: BORDER_WIDTH4,
|
|
@@ -1162,19 +1333,19 @@ var ModalDropdown = ({
|
|
|
1162
1333
|
const isCaret = showCaret && !isHamburger;
|
|
1163
1334
|
const containerStyle = React12.useMemo(
|
|
1164
1335
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
1165
|
-
|
|
1166
|
-
isHamburger ?
|
|
1336
|
+
styles12.container,
|
|
1337
|
+
isHamburger ? styles12.containerHamburger : isCaret ? styles12.containerMenu : null,
|
|
1167
1338
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
1168
1339
|
],
|
|
1169
1340
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
1170
1341
|
);
|
|
1171
1342
|
const hamburgerStyle = React12.useMemo(
|
|
1172
|
-
() => [
|
|
1343
|
+
() => [styles12.hamburger, { color: colors.textSecondary }],
|
|
1173
1344
|
[colors.textSecondary]
|
|
1174
1345
|
);
|
|
1175
1346
|
const caretStyle = React12.useMemo(
|
|
1176
1347
|
() => [
|
|
1177
|
-
|
|
1348
|
+
styles12.caret,
|
|
1178
1349
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
1179
1350
|
],
|
|
1180
1351
|
[colors.textSecondary, isOpen]
|
|
@@ -1184,11 +1355,11 @@ var ModalDropdown = ({
|
|
|
1184
1355
|
[optionTestID, testID]
|
|
1185
1356
|
);
|
|
1186
1357
|
const anchorStyle = React12.useMemo(
|
|
1187
|
-
() => [
|
|
1358
|
+
() => [styles12.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
1188
1359
|
[isMenu, isOpen]
|
|
1189
1360
|
);
|
|
1190
1361
|
const modalContentStyle = React12.useMemo(
|
|
1191
|
-
() => [
|
|
1362
|
+
() => [styles12.modalContent, { backgroundColor: colors.surface }],
|
|
1192
1363
|
[colors.surface]
|
|
1193
1364
|
);
|
|
1194
1365
|
const renderModalOption = React12.useCallback(
|
|
@@ -1209,11 +1380,11 @@ var ModalDropdown = ({
|
|
|
1209
1380
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
|
|
1210
1381
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1211
1382
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
1212
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
1383
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
1213
1384
|
] }) : isCaret ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1214
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
1385
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
1215
1386
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: caretStyle, children: CARET_GLYPH })
|
|
1216
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1387
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles12.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
1217
1388
|
hintNode
|
|
1218
1389
|
] }),
|
|
1219
1390
|
isMenu && menuAnim.mounted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1234,7 +1405,7 @@ var ModalDropdown = ({
|
|
|
1234
1405
|
onSelect: handleSelect
|
|
1235
1406
|
}
|
|
1236
1407
|
) : null,
|
|
1237
|
-
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1408
|
+
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.modalOverlay, children: [
|
|
1238
1409
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1239
1410
|
reactNative.TouchableOpacity,
|
|
1240
1411
|
{
|
|
@@ -1327,7 +1498,7 @@ var ROW_PAD_V = 8;
|
|
|
1327
1498
|
var PANEL_PAD_TOP = 16;
|
|
1328
1499
|
var BORDER_WIDTH5 = 1;
|
|
1329
1500
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
1330
|
-
var
|
|
1501
|
+
var styles13 = reactNative.StyleSheet.create({
|
|
1331
1502
|
root: {
|
|
1332
1503
|
width: "100%"
|
|
1333
1504
|
},
|
|
@@ -1381,7 +1552,7 @@ var WideTabStrip = ({
|
|
|
1381
1552
|
textSecondary,
|
|
1382
1553
|
surfaceElevated,
|
|
1383
1554
|
stripStyle
|
|
1384
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
1555
|
+
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles13.stripOuter, { borderBottomColor: borderColor }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "tablist", "aria-label": accessibilityLabel, style: [styles13.strip, stripStyle], children: tabs.map((tab) => {
|
|
1385
1556
|
const selected = tab.key === activeKey;
|
|
1386
1557
|
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
1387
1558
|
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
@@ -1395,10 +1566,10 @@ var WideTabStrip = ({
|
|
|
1395
1566
|
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
1396
1567
|
accessibilityHint: tab.accessibilityHint,
|
|
1397
1568
|
onPress: () => onChange(tab.key),
|
|
1398
|
-
style: [
|
|
1569
|
+
style: [styles13.pill, { backgroundColor: pillColor }],
|
|
1399
1570
|
testID: tab.testID,
|
|
1400
1571
|
...ariaTabProps(selected, panelId, tabId),
|
|
1401
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1572
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles13.pillText, { color: textColor }], children: tab.label })
|
|
1402
1573
|
},
|
|
1403
1574
|
tab.key
|
|
1404
1575
|
);
|
|
@@ -1423,7 +1594,7 @@ var Tabs = ({
|
|
|
1423
1594
|
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
1424
1595
|
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
1425
1596
|
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
1426
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1597
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles13.root, style], testID, children: [
|
|
1427
1598
|
collapsed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1428
1599
|
TabsMenu,
|
|
1429
1600
|
{
|
|
@@ -1450,7 +1621,7 @@ var Tabs = ({
|
|
|
1450
1621
|
onChange
|
|
1451
1622
|
}
|
|
1452
1623
|
),
|
|
1453
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [
|
|
1624
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles13.panel, panelStyle], ...panelAria, children })
|
|
1454
1625
|
] });
|
|
1455
1626
|
};
|
|
1456
1627
|
var PROMPT_PADDING = 20;
|
|
@@ -1465,7 +1636,7 @@ var DISMISS_FONT_SIZE = 13;
|
|
|
1465
1636
|
var TITLE_MARGIN_BOTTOM = 8;
|
|
1466
1637
|
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
1467
1638
|
var CTA_MARGIN_BOTTOM = 8;
|
|
1468
|
-
var
|
|
1639
|
+
var styles14 = reactNative.StyleSheet.create({
|
|
1469
1640
|
container: {
|
|
1470
1641
|
padding: PROMPT_PADDING,
|
|
1471
1642
|
borderRadius: PROMPT_BORDER_RADIUS,
|
|
@@ -1500,21 +1671,21 @@ var UpgradePrompt = ({
|
|
|
1500
1671
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1501
1672
|
reactNative.View,
|
|
1502
1673
|
{
|
|
1503
|
-
style: [
|
|
1674
|
+
style: [styles14.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1504
1675
|
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1505
1676
|
children: [
|
|
1506
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1507
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1677
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1678
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1508
1679
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1509
1680
|
reactNative.TouchableOpacity,
|
|
1510
1681
|
{
|
|
1511
1682
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1512
1683
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1513
1684
|
accessibilityRole: "button",
|
|
1514
|
-
style: [
|
|
1685
|
+
style: [styles14.cta, { backgroundColor: primary }],
|
|
1515
1686
|
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1516
1687
|
onPress: handleUpgradePress,
|
|
1517
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1688
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1518
1689
|
}
|
|
1519
1690
|
),
|
|
1520
1691
|
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1523,10 +1694,10 @@ var UpgradePrompt = ({
|
|
|
1523
1694
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1524
1695
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1525
1696
|
accessibilityRole: "button",
|
|
1526
|
-
style:
|
|
1697
|
+
style: styles14.dismiss,
|
|
1527
1698
|
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1528
1699
|
onPress: onDismiss,
|
|
1529
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1700
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1530
1701
|
}
|
|
1531
1702
|
) : null
|
|
1532
1703
|
]
|
|
@@ -1534,8 +1705,8 @@ var UpgradePrompt = ({
|
|
|
1534
1705
|
);
|
|
1535
1706
|
};
|
|
1536
1707
|
var CLOSE_ICON_SIZE = 18;
|
|
1537
|
-
var
|
|
1538
|
-
var
|
|
1708
|
+
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1709
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1539
1710
|
animatedFill: { flex: 1 },
|
|
1540
1711
|
container: {
|
|
1541
1712
|
flex: 1,
|
|
@@ -1560,9 +1731,9 @@ var ModalShell = ({
|
|
|
1560
1731
|
showClose = true
|
|
1561
1732
|
}) => {
|
|
1562
1733
|
const { theme, t } = uiFeedback.useUi();
|
|
1563
|
-
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale:
|
|
1734
|
+
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1564
1735
|
const containerStyle = React12__default.default.useMemo(
|
|
1565
|
-
() => [
|
|
1736
|
+
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1566
1737
|
[theme.colors.background, contentStyle]
|
|
1567
1738
|
);
|
|
1568
1739
|
const closeA11yLabel = t(LAYOUT_I18N.close);
|
|
@@ -1574,7 +1745,7 @@ var ModalShell = ({
|
|
|
1574
1745
|
testID: LAYOUT_TEST_IDS.modalShell,
|
|
1575
1746
|
visible: mounted,
|
|
1576
1747
|
onRequestClose: onCancel,
|
|
1577
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [
|
|
1748
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles15.animatedFill, sheetStyle], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1578
1749
|
reactNative.ScrollView,
|
|
1579
1750
|
{
|
|
1580
1751
|
accessibilityViewIsModal: true,
|
|
@@ -1582,7 +1753,7 @@ var ModalShell = ({
|
|
|
1582
1753
|
role: "dialog",
|
|
1583
1754
|
style: containerStyle,
|
|
1584
1755
|
children: [
|
|
1585
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1756
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles15.headerRow, children: [
|
|
1586
1757
|
/* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t(LAYOUT_I18N.closeHeading) }),
|
|
1587
1758
|
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1588
1759
|
reactNative.TouchableOpacity,
|
|
@@ -1590,7 +1761,7 @@ var ModalShell = ({
|
|
|
1590
1761
|
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1591
1762
|
accessibilityLabel: closeA11yLabel,
|
|
1592
1763
|
accessibilityRole: "button",
|
|
1593
|
-
style:
|
|
1764
|
+
style: styles15.closeButton,
|
|
1594
1765
|
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
1595
1766
|
onPress: onCancel,
|
|
1596
1767
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
@@ -1604,148 +1775,6 @@ var ModalShell = ({
|
|
|
1604
1775
|
}
|
|
1605
1776
|
);
|
|
1606
1777
|
};
|
|
1607
|
-
function useEscapeKey(enabled, onClose) {
|
|
1608
|
-
React12.useEffect(() => {
|
|
1609
|
-
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1610
|
-
const onKeyDown = (event) => {
|
|
1611
|
-
if (event.key === "Escape") onClose();
|
|
1612
|
-
};
|
|
1613
|
-
document.addEventListener("keydown", onKeyDown);
|
|
1614
|
-
return () => {
|
|
1615
|
-
document.removeEventListener("keydown", onKeyDown);
|
|
1616
|
-
};
|
|
1617
|
-
}, [enabled, onClose]);
|
|
1618
|
-
}
|
|
1619
|
-
function useScrollLock(enabled) {
|
|
1620
|
-
React12.useEffect(() => {
|
|
1621
|
-
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1622
|
-
const { body } = document;
|
|
1623
|
-
const previousOverflow = body.style.overflow;
|
|
1624
|
-
body.style.overflow = "hidden";
|
|
1625
|
-
return () => {
|
|
1626
|
-
body.style.overflow = previousOverflow;
|
|
1627
|
-
};
|
|
1628
|
-
}, [enabled]);
|
|
1629
|
-
}
|
|
1630
|
-
var OVERLAY_PADDING = 16;
|
|
1631
|
-
var DIALOG_RADIUS = 12;
|
|
1632
|
-
var DIALOG_PADDING = 16;
|
|
1633
|
-
var HEADER_GAP = 12;
|
|
1634
|
-
var FOOTER_MARGIN = 16;
|
|
1635
|
-
var HEADER_MARGIN = 12;
|
|
1636
|
-
var DIALOG_MAX_HEIGHT = "90%";
|
|
1637
|
-
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1638
|
-
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640 };
|
|
1639
|
-
var styles15 = reactNative.StyleSheet.create({
|
|
1640
|
-
overlay: {
|
|
1641
|
-
flex: 1,
|
|
1642
|
-
justifyContent: "center",
|
|
1643
|
-
alignItems: "center",
|
|
1644
|
-
padding: OVERLAY_PADDING
|
|
1645
|
-
},
|
|
1646
|
-
// The scrim is its OWN animated layer (behind the tap-catcher and the panel) so its opacity
|
|
1647
|
-
// can fade independently of the panel's fade+scale. `animationType` is a native-only no-op on
|
|
1648
|
-
// react-native-web, which is why the fade is driven by `Animated` instead. `pointerEvents` lives
|
|
1649
|
-
// in style (not the deprecated prop) so taps fall through to the sibling tap-catcher below.
|
|
1650
|
-
scrim: { backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
1651
|
-
dialog: {
|
|
1652
|
-
width: "100%",
|
|
1653
|
-
borderRadius: DIALOG_RADIUS,
|
|
1654
|
-
padding: DIALOG_PADDING,
|
|
1655
|
-
maxHeight: DIALOG_MAX_HEIGHT
|
|
1656
|
-
},
|
|
1657
|
-
headerRow: {
|
|
1658
|
-
flexDirection: "row",
|
|
1659
|
-
alignItems: "flex-start",
|
|
1660
|
-
justifyContent: "space-between",
|
|
1661
|
-
columnGap: HEADER_GAP,
|
|
1662
|
-
marginBottom: HEADER_MARGIN
|
|
1663
|
-
},
|
|
1664
|
-
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
1665
|
-
titleWrap: { flex: 1 },
|
|
1666
|
-
footer: { marginTop: FOOTER_MARGIN }
|
|
1667
|
-
});
|
|
1668
|
-
var Modal3 = ({
|
|
1669
|
-
visible,
|
|
1670
|
-
onClose,
|
|
1671
|
-
title,
|
|
1672
|
-
children,
|
|
1673
|
-
footer,
|
|
1674
|
-
size = "md",
|
|
1675
|
-
showClose = true,
|
|
1676
|
-
testID = LAYOUT_TEST_IDS.modal,
|
|
1677
|
-
accessibilityLabel,
|
|
1678
|
-
initialFocusTestID
|
|
1679
|
-
}) => {
|
|
1680
|
-
const { theme, t } = uiFeedback.useUi();
|
|
1681
|
-
const dialogRef = React12.useRef(null);
|
|
1682
|
-
const backdrop = uiMotion.useEnterExit({ visible });
|
|
1683
|
-
const panel = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1684
|
-
const mounted = panel.mounted || backdrop.mounted;
|
|
1685
|
-
useFocusTrap(dialogRef, visible, initialFocusTestID);
|
|
1686
|
-
useEscapeKey(visible, onClose);
|
|
1687
|
-
useScrollLock(visible);
|
|
1688
|
-
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
1689
|
-
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
1690
|
-
const dialogStyle = React12.useMemo(
|
|
1691
|
-
() => [styles15.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
1692
|
-
[theme.colors.surface, size]
|
|
1693
|
-
);
|
|
1694
|
-
const hasHeader = title !== void 0 || showClose;
|
|
1695
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles15.overlay, children: [
|
|
1696
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1697
|
-
reactNative.Animated.View,
|
|
1698
|
-
{
|
|
1699
|
-
style: [reactNative.StyleSheet.absoluteFill, styles15.scrim, { opacity: backdrop.style.opacity }]
|
|
1700
|
-
}
|
|
1701
|
-
),
|
|
1702
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1703
|
-
reactNative.TouchableOpacity,
|
|
1704
|
-
{
|
|
1705
|
-
accessible: true,
|
|
1706
|
-
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
1707
|
-
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
1708
|
-
accessibilityRole: "button",
|
|
1709
|
-
activeOpacity: 1,
|
|
1710
|
-
style: reactNative.StyleSheet.absoluteFill,
|
|
1711
|
-
testID: `${testID}-backdrop`,
|
|
1712
|
-
onPress: onClose
|
|
1713
|
-
}
|
|
1714
|
-
),
|
|
1715
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1716
|
-
reactNative.Animated.View,
|
|
1717
|
-
{
|
|
1718
|
-
ref: dialogRef,
|
|
1719
|
-
accessibilityViewIsModal: true,
|
|
1720
|
-
"aria-label": accessibleName,
|
|
1721
|
-
role: "dialog",
|
|
1722
|
-
style: [dialogStyle, panel.style],
|
|
1723
|
-
testID,
|
|
1724
|
-
children: [
|
|
1725
|
-
hasHeader ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles15.headerRow, children: [
|
|
1726
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles15.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title }) : null }),
|
|
1727
|
-
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1728
|
-
uiButtons.IconButton,
|
|
1729
|
-
{
|
|
1730
|
-
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1731
|
-
accessibilityLabel: closeLabel,
|
|
1732
|
-
appearance: "ghost",
|
|
1733
|
-
renderIcon: (color, iconSize) => /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color, name: "close", size: iconSize }),
|
|
1734
|
-
size: "md",
|
|
1735
|
-
testID: `${testID}-close`,
|
|
1736
|
-
tooltip: closeLabel,
|
|
1737
|
-
variant: "ghost",
|
|
1738
|
-
onPress: onClose
|
|
1739
|
-
}
|
|
1740
|
-
) : null
|
|
1741
|
-
] }) : null,
|
|
1742
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { children }),
|
|
1743
|
-
footer !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles15.footer, children: footer }) : null
|
|
1744
|
-
]
|
|
1745
|
-
}
|
|
1746
|
-
)
|
|
1747
|
-
] }) });
|
|
1748
|
-
};
|
|
1749
1778
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1750
1779
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1751
1780
|
var BUTTON_GAP = 12;
|
|
@@ -1795,7 +1824,7 @@ var ConfirmDialog = ({
|
|
|
1795
1824
|
)
|
|
1796
1825
|
] });
|
|
1797
1826
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1798
|
-
|
|
1827
|
+
Modal,
|
|
1799
1828
|
{
|
|
1800
1829
|
footer,
|
|
1801
1830
|
showClose: false,
|
|
@@ -2696,7 +2725,7 @@ exports.LAYOUT_I18N = LAYOUT_I18N;
|
|
|
2696
2725
|
exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
2697
2726
|
exports.ListRow = ListRow;
|
|
2698
2727
|
exports.MIN_TARGET_PX = MIN_TARGET_PX;
|
|
2699
|
-
exports.Modal =
|
|
2728
|
+
exports.Modal = Modal;
|
|
2700
2729
|
exports.ModalDropdown = ModalDropdown;
|
|
2701
2730
|
exports.ModalShell = ModalShell;
|
|
2702
2731
|
exports.PageFrame = PageFrame;
|