@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.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,223 @@ 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 CENTRED_ROW = { flexGrow: 1, justifyContent: "center" };
|
|
589
|
+
var PageOverlay = ({ children, pageSize, visible, onClose, testID }) => {
|
|
590
|
+
const { t } = uiFeedback.useUi();
|
|
591
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Modal, { accessibilityLabel: t(LAYOUT_I18N.pageEnlarge), size: "xl", testID, visible, onClose, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { horizontal: true, contentContainerStyle: CENTRED_ROW, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
+
reactNative.View,
|
|
593
|
+
{
|
|
594
|
+
style: { width: pageSize.width, minWidth: pageSize.width, height: pageSize.height, flexShrink: 0 },
|
|
595
|
+
testID: `${testID}-page`,
|
|
596
|
+
children
|
|
597
|
+
}
|
|
598
|
+
) }) });
|
|
599
|
+
};
|
|
380
600
|
|
|
381
601
|
// src/PageFrame/utils/pageScale.ts
|
|
382
602
|
var HALF = 2;
|
|
@@ -394,25 +614,31 @@ var scaledFrame = (containerWidth, page) => {
|
|
|
394
614
|
offsetY: (scale - 1) * page.height / HALF
|
|
395
615
|
};
|
|
396
616
|
};
|
|
397
|
-
var
|
|
617
|
+
var styles7 = reactNative.StyleSheet.create({
|
|
398
618
|
outer: { width: "100%", overflow: "hidden" },
|
|
399
|
-
page: { position: "absolute", top: 0, left: 0 }
|
|
619
|
+
page: { position: "absolute", top: 0, left: 0 },
|
|
620
|
+
trigger: { width: "100%", cursor: "pointer" }
|
|
400
621
|
});
|
|
401
622
|
var PageFrame = ({
|
|
402
623
|
children,
|
|
403
624
|
pageSize = A4_PAGE,
|
|
404
|
-
testID = LAYOUT_TEST_IDS.pageFrame
|
|
625
|
+
testID = LAYOUT_TEST_IDS.pageFrame,
|
|
626
|
+
enlargeable = false
|
|
405
627
|
}) => {
|
|
628
|
+
const { t } = uiFeedback.useUi();
|
|
406
629
|
const [containerWidth, setContainerWidth] = React12.useState(0);
|
|
630
|
+
const [enlarged, setEnlarged] = React12.useState(false);
|
|
407
631
|
const onLayout = React12.useCallback((event) => {
|
|
408
632
|
setContainerWidth(event.nativeEvent.layout.width);
|
|
409
633
|
}, []);
|
|
634
|
+
const open = React12.useCallback(() => setEnlarged(true), []);
|
|
635
|
+
const close = React12.useCallback(() => setEnlarged(false), []);
|
|
410
636
|
const frame = scaledFrame(containerWidth, pageSize);
|
|
411
|
-
|
|
637
|
+
const preview = /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles7.outer, { height: frame.height }], testID, onLayout, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
412
638
|
reactNative.View,
|
|
413
639
|
{
|
|
414
640
|
style: [
|
|
415
|
-
|
|
641
|
+
styles7.page,
|
|
416
642
|
{
|
|
417
643
|
width: pageSize.width,
|
|
418
644
|
height: pageSize.height,
|
|
@@ -422,6 +648,22 @@ var PageFrame = ({
|
|
|
422
648
|
children
|
|
423
649
|
}
|
|
424
650
|
) });
|
|
651
|
+
if (!enlargeable) return preview;
|
|
652
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
653
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
654
|
+
reactNative.Pressable,
|
|
655
|
+
{
|
|
656
|
+
accessibilityHint: t(LAYOUT_I18N.pageEnlargeHint),
|
|
657
|
+
accessibilityLabel: t(LAYOUT_I18N.pageEnlarge),
|
|
658
|
+
accessibilityRole: "button",
|
|
659
|
+
style: styles7.trigger,
|
|
660
|
+
testID: `${testID}-enlarge`,
|
|
661
|
+
onPress: open,
|
|
662
|
+
children: preview
|
|
663
|
+
}
|
|
664
|
+
),
|
|
665
|
+
/* @__PURE__ */ jsxRuntime.jsx(PageOverlay, { pageSize, testID: `${testID}-overlay`, visible: enlarged, onClose: close, children })
|
|
666
|
+
] });
|
|
425
667
|
};
|
|
426
668
|
var TRACK_PADDING = 3;
|
|
427
669
|
var TRACK_RADIUS = 999;
|
|
@@ -434,7 +676,7 @@ var BORDER_WIDTH = 1;
|
|
|
434
676
|
var SEGMENT_BOX_SHADOW = "0px 1px 3px rgba(20, 30, 50, 0.1)";
|
|
435
677
|
var SHADOW_ELEVATION = 2;
|
|
436
678
|
var TRANSPARENT = "transparent";
|
|
437
|
-
var
|
|
679
|
+
var styles8 = reactNative.StyleSheet.create({
|
|
438
680
|
track: {
|
|
439
681
|
flexDirection: "row",
|
|
440
682
|
alignSelf: "flex-start",
|
|
@@ -479,7 +721,7 @@ function SegmentedControl({
|
|
|
479
721
|
{
|
|
480
722
|
accessibilityRole: "tablist",
|
|
481
723
|
"aria-label": accessibilityLabel,
|
|
482
|
-
style: [
|
|
724
|
+
style: [styles8.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
|
|
483
725
|
testID,
|
|
484
726
|
children: options.map((opt) => {
|
|
485
727
|
const selected = opt.value === value;
|
|
@@ -492,13 +734,13 @@ function SegmentedControl({
|
|
|
492
734
|
accessibilityHint: opt.accessibilityHint,
|
|
493
735
|
onPress: () => onChange(opt.value),
|
|
494
736
|
style: [
|
|
495
|
-
|
|
496
|
-
selected ?
|
|
737
|
+
styles8.segment,
|
|
738
|
+
selected ? styles8.segmentSelected : null,
|
|
497
739
|
{ backgroundColor: selected ? colors.surface : TRANSPARENT }
|
|
498
740
|
],
|
|
499
741
|
testID: opt.testID,
|
|
500
742
|
...ariaSelectedProps(selected),
|
|
501
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
743
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles8.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
|
|
502
744
|
},
|
|
503
745
|
opt.value
|
|
504
746
|
);
|
|
@@ -513,69 +755,6 @@ var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
|
513
755
|
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
514
756
|
return TabsCollapsedTrigger2;
|
|
515
757
|
})(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
758
|
|
|
580
759
|
// src/ModalDropdown/DropdownVariant.ts
|
|
581
760
|
var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
|
|
@@ -635,7 +814,7 @@ var HEADING_PADDING_H = 16;
|
|
|
635
814
|
var HEADING_PADDING_TOP = 8;
|
|
636
815
|
var HEADING_PADDING_BOTTOM = 4;
|
|
637
816
|
var HEADING_LETTER_SPACING = 0.5;
|
|
638
|
-
var
|
|
817
|
+
var styles9 = reactNative.StyleSheet.create({
|
|
639
818
|
heading: {
|
|
640
819
|
fontSize: HEADING_FONT_SIZE,
|
|
641
820
|
fontWeight: HEADING_FONT_WEIGHT,
|
|
@@ -651,7 +830,7 @@ var MenuHeading = ({ testID, text }) => {
|
|
|
651
830
|
reactNative.Text,
|
|
652
831
|
{
|
|
653
832
|
accessibilityRole: "header",
|
|
654
|
-
style: [
|
|
833
|
+
style: [styles9.heading, { color: theme.colors.textSecondary }],
|
|
655
834
|
testID: `${testID}-menu-heading`,
|
|
656
835
|
children: text
|
|
657
836
|
}
|
|
@@ -672,7 +851,7 @@ var OPTION_PADDING_V = 12;
|
|
|
672
851
|
var ACCENT_BAR_WIDTH = 3;
|
|
673
852
|
var CHECK_GAP = 8;
|
|
674
853
|
var CHECK_GLYPH = "\u2713";
|
|
675
|
-
var
|
|
854
|
+
var styles10 = reactNative.StyleSheet.create({
|
|
676
855
|
option: {
|
|
677
856
|
paddingHorizontal: OPTION_PADDING_H,
|
|
678
857
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -711,16 +890,16 @@ var OptionRow = ({
|
|
|
711
890
|
const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
|
|
712
891
|
const isActive = isSelected || isHighlighted;
|
|
713
892
|
const rowStyle = [
|
|
714
|
-
|
|
715
|
-
isMarked ?
|
|
893
|
+
styles10.option,
|
|
894
|
+
isMarked ? styles10.markedRow : null,
|
|
716
895
|
isActive ? { backgroundColor: colors.surfaceElevated } : null,
|
|
717
896
|
isMarked && isSelected ? { borderLeftColor: accentColor } : null
|
|
718
897
|
];
|
|
719
898
|
const textStyle = [
|
|
720
|
-
|
|
899
|
+
styles10.optionText,
|
|
721
900
|
{ color: colors.text },
|
|
722
|
-
isSelected ?
|
|
723
|
-
isMarked ?
|
|
901
|
+
isSelected ? styles10.selectedText : null,
|
|
902
|
+
isMarked ? styles10.markedText : null
|
|
724
903
|
];
|
|
725
904
|
const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
|
|
726
905
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -736,7 +915,7 @@ var OptionRow = ({
|
|
|
736
915
|
onPress: handlePress,
|
|
737
916
|
children: [
|
|
738
917
|
/* @__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: [
|
|
918
|
+
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
919
|
]
|
|
741
920
|
}
|
|
742
921
|
);
|
|
@@ -894,7 +1073,7 @@ var IS_WEB2 = reactNative.Platform.OS === "web";
|
|
|
894
1073
|
var BORDER_RADIUS2 = 8;
|
|
895
1074
|
var BORDER_WIDTH3 = 1;
|
|
896
1075
|
var MENU_PADDING2 = 4;
|
|
897
|
-
var
|
|
1076
|
+
var styles11 = reactNative.StyleSheet.create({
|
|
898
1077
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
899
1078
|
popover: {
|
|
900
1079
|
position: "absolute",
|
|
@@ -981,7 +1160,7 @@ var InlineMenu = ({
|
|
|
981
1160
|
themed
|
|
982
1161
|
];
|
|
983
1162
|
}
|
|
984
|
-
return [
|
|
1163
|
+
return [styles11.popover, { minWidth: menuMinWidth }, themed];
|
|
985
1164
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
986
1165
|
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|
|
987
1166
|
reactNative.View,
|
|
@@ -996,10 +1175,10 @@ var InlineMenu = ({
|
|
|
996
1175
|
reactNative.Animated.View,
|
|
997
1176
|
{
|
|
998
1177
|
pointerEvents: isOpen ? "auto" : "none",
|
|
999
|
-
style: [
|
|
1178
|
+
style: [styles11.animated, animatedStyle, isOpen ? null : styles11.inert],
|
|
1000
1179
|
children: [
|
|
1001
1180
|
menuHeading !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(MenuHeading, { testID, text: menuHeading }) : null,
|
|
1002
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style:
|
|
1181
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style: styles11.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1003
1182
|
OptionRow,
|
|
1004
1183
|
{
|
|
1005
1184
|
asMenuItem: true,
|
|
@@ -1047,7 +1226,7 @@ var CARET_OPEN_ROTATION = "180deg";
|
|
|
1047
1226
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
1048
1227
|
var POPOVER_ENTER_SCALE = 0.96;
|
|
1049
1228
|
var POPOVER_MOTION_MS = 120;
|
|
1050
|
-
var
|
|
1229
|
+
var styles12 = reactNative.StyleSheet.create({
|
|
1051
1230
|
anchor: { position: "relative" },
|
|
1052
1231
|
container: {
|
|
1053
1232
|
borderWidth: BORDER_WIDTH4,
|
|
@@ -1162,19 +1341,19 @@ var ModalDropdown = ({
|
|
|
1162
1341
|
const isCaret = showCaret && !isHamburger;
|
|
1163
1342
|
const containerStyle = React12.useMemo(
|
|
1164
1343
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
1165
|
-
|
|
1166
|
-
isHamburger ?
|
|
1344
|
+
styles12.container,
|
|
1345
|
+
isHamburger ? styles12.containerHamburger : isCaret ? styles12.containerMenu : null,
|
|
1167
1346
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
1168
1347
|
],
|
|
1169
1348
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
1170
1349
|
);
|
|
1171
1350
|
const hamburgerStyle = React12.useMemo(
|
|
1172
|
-
() => [
|
|
1351
|
+
() => [styles12.hamburger, { color: colors.textSecondary }],
|
|
1173
1352
|
[colors.textSecondary]
|
|
1174
1353
|
);
|
|
1175
1354
|
const caretStyle = React12.useMemo(
|
|
1176
1355
|
() => [
|
|
1177
|
-
|
|
1356
|
+
styles12.caret,
|
|
1178
1357
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
1179
1358
|
],
|
|
1180
1359
|
[colors.textSecondary, isOpen]
|
|
@@ -1184,11 +1363,11 @@ var ModalDropdown = ({
|
|
|
1184
1363
|
[optionTestID, testID]
|
|
1185
1364
|
);
|
|
1186
1365
|
const anchorStyle = React12.useMemo(
|
|
1187
|
-
() => [
|
|
1366
|
+
() => [styles12.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
1188
1367
|
[isMenu, isOpen]
|
|
1189
1368
|
);
|
|
1190
1369
|
const modalContentStyle = React12.useMemo(
|
|
1191
|
-
() => [
|
|
1370
|
+
() => [styles12.modalContent, { backgroundColor: colors.surface }],
|
|
1192
1371
|
[colors.surface]
|
|
1193
1372
|
);
|
|
1194
1373
|
const renderModalOption = React12.useCallback(
|
|
@@ -1209,11 +1388,11 @@ var ModalDropdown = ({
|
|
|
1209
1388
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
|
|
1210
1389
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1211
1390
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
1212
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
1391
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
1213
1392
|
] }) : isCaret ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1214
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [
|
|
1393
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
1215
1394
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: caretStyle, children: CARET_GLYPH })
|
|
1216
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1395
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles12.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
1217
1396
|
hintNode
|
|
1218
1397
|
] }),
|
|
1219
1398
|
isMenu && menuAnim.mounted ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1234,7 +1413,7 @@ var ModalDropdown = ({
|
|
|
1234
1413
|
onSelect: handleSelect
|
|
1235
1414
|
}
|
|
1236
1415
|
) : null,
|
|
1237
|
-
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1416
|
+
!isMenu ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.modalOverlay, children: [
|
|
1238
1417
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1239
1418
|
reactNative.TouchableOpacity,
|
|
1240
1419
|
{
|
|
@@ -1327,7 +1506,7 @@ var ROW_PAD_V = 8;
|
|
|
1327
1506
|
var PANEL_PAD_TOP = 16;
|
|
1328
1507
|
var BORDER_WIDTH5 = 1;
|
|
1329
1508
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
1330
|
-
var
|
|
1509
|
+
var styles13 = reactNative.StyleSheet.create({
|
|
1331
1510
|
root: {
|
|
1332
1511
|
width: "100%"
|
|
1333
1512
|
},
|
|
@@ -1381,7 +1560,7 @@ var WideTabStrip = ({
|
|
|
1381
1560
|
textSecondary,
|
|
1382
1561
|
surfaceElevated,
|
|
1383
1562
|
stripStyle
|
|
1384
|
-
}) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
|
|
1563
|
+
}) => /* @__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
1564
|
const selected = tab.key === activeKey;
|
|
1386
1565
|
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
1387
1566
|
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
@@ -1395,10 +1574,10 @@ var WideTabStrip = ({
|
|
|
1395
1574
|
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
1396
1575
|
accessibilityHint: tab.accessibilityHint,
|
|
1397
1576
|
onPress: () => onChange(tab.key),
|
|
1398
|
-
style: [
|
|
1577
|
+
style: [styles13.pill, { backgroundColor: pillColor }],
|
|
1399
1578
|
testID: tab.testID,
|
|
1400
1579
|
...ariaTabProps(selected, panelId, tabId),
|
|
1401
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1580
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles13.pillText, { color: textColor }], children: tab.label })
|
|
1402
1581
|
},
|
|
1403
1582
|
tab.key
|
|
1404
1583
|
);
|
|
@@ -1423,7 +1602,7 @@ var Tabs = ({
|
|
|
1423
1602
|
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
1424
1603
|
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
1425
1604
|
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
1426
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1605
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles13.root, style], testID, children: [
|
|
1427
1606
|
collapsed ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1428
1607
|
TabsMenu,
|
|
1429
1608
|
{
|
|
@@ -1450,7 +1629,7 @@ var Tabs = ({
|
|
|
1450
1629
|
onChange
|
|
1451
1630
|
}
|
|
1452
1631
|
),
|
|
1453
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [
|
|
1632
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { accessibilityRole: "none", style: [styles13.panel, panelStyle], ...panelAria, children })
|
|
1454
1633
|
] });
|
|
1455
1634
|
};
|
|
1456
1635
|
var PROMPT_PADDING = 20;
|
|
@@ -1465,7 +1644,7 @@ var DISMISS_FONT_SIZE = 13;
|
|
|
1465
1644
|
var TITLE_MARGIN_BOTTOM = 8;
|
|
1466
1645
|
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
1467
1646
|
var CTA_MARGIN_BOTTOM = 8;
|
|
1468
|
-
var
|
|
1647
|
+
var styles14 = reactNative.StyleSheet.create({
|
|
1469
1648
|
container: {
|
|
1470
1649
|
padding: PROMPT_PADDING,
|
|
1471
1650
|
borderRadius: PROMPT_BORDER_RADIUS,
|
|
@@ -1500,21 +1679,21 @@ var UpgradePrompt = ({
|
|
|
1500
1679
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1501
1680
|
reactNative.View,
|
|
1502
1681
|
{
|
|
1503
|
-
style: [
|
|
1682
|
+
style: [styles14.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1504
1683
|
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1505
1684
|
children: [
|
|
1506
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1507
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1685
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1686
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1508
1687
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1509
1688
|
reactNative.TouchableOpacity,
|
|
1510
1689
|
{
|
|
1511
1690
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1512
1691
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1513
1692
|
accessibilityRole: "button",
|
|
1514
|
-
style: [
|
|
1693
|
+
style: [styles14.cta, { backgroundColor: primary }],
|
|
1515
1694
|
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1516
1695
|
onPress: handleUpgradePress,
|
|
1517
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1696
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1518
1697
|
}
|
|
1519
1698
|
),
|
|
1520
1699
|
onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1523,10 +1702,10 @@ var UpgradePrompt = ({
|
|
|
1523
1702
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1524
1703
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1525
1704
|
accessibilityRole: "button",
|
|
1526
|
-
style:
|
|
1705
|
+
style: styles14.dismiss,
|
|
1527
1706
|
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1528
1707
|
onPress: onDismiss,
|
|
1529
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1708
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1530
1709
|
}
|
|
1531
1710
|
) : null
|
|
1532
1711
|
]
|
|
@@ -1534,8 +1713,8 @@ var UpgradePrompt = ({
|
|
|
1534
1713
|
);
|
|
1535
1714
|
};
|
|
1536
1715
|
var CLOSE_ICON_SIZE = 18;
|
|
1537
|
-
var
|
|
1538
|
-
var
|
|
1716
|
+
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1717
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1539
1718
|
animatedFill: { flex: 1 },
|
|
1540
1719
|
container: {
|
|
1541
1720
|
flex: 1,
|
|
@@ -1560,9 +1739,9 @@ var ModalShell = ({
|
|
|
1560
1739
|
showClose = true
|
|
1561
1740
|
}) => {
|
|
1562
1741
|
const { theme, t } = uiFeedback.useUi();
|
|
1563
|
-
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale:
|
|
1742
|
+
const { style: sheetStyle, mounted } = uiMotion.useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1564
1743
|
const containerStyle = React12__default.default.useMemo(
|
|
1565
|
-
() => [
|
|
1744
|
+
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1566
1745
|
[theme.colors.background, contentStyle]
|
|
1567
1746
|
);
|
|
1568
1747
|
const closeA11yLabel = t(LAYOUT_I18N.close);
|
|
@@ -1574,7 +1753,7 @@ var ModalShell = ({
|
|
|
1574
1753
|
testID: LAYOUT_TEST_IDS.modalShell,
|
|
1575
1754
|
visible: mounted,
|
|
1576
1755
|
onRequestClose: onCancel,
|
|
1577
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [
|
|
1756
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Animated.View, { style: [styles15.animatedFill, sheetStyle], children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1578
1757
|
reactNative.ScrollView,
|
|
1579
1758
|
{
|
|
1580
1759
|
accessibilityViewIsModal: true,
|
|
@@ -1582,7 +1761,7 @@ var ModalShell = ({
|
|
|
1582
1761
|
role: "dialog",
|
|
1583
1762
|
style: containerStyle,
|
|
1584
1763
|
children: [
|
|
1585
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1764
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles15.headerRow, children: [
|
|
1586
1765
|
/* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title ?? t(LAYOUT_I18N.closeHeading) }),
|
|
1587
1766
|
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1588
1767
|
reactNative.TouchableOpacity,
|
|
@@ -1590,7 +1769,7 @@ var ModalShell = ({
|
|
|
1590
1769
|
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1591
1770
|
accessibilityLabel: closeA11yLabel,
|
|
1592
1771
|
accessibilityRole: "button",
|
|
1593
|
-
style:
|
|
1772
|
+
style: styles15.closeButton,
|
|
1594
1773
|
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
1595
1774
|
onPress: onCancel,
|
|
1596
1775
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
@@ -1604,148 +1783,6 @@ var ModalShell = ({
|
|
|
1604
1783
|
}
|
|
1605
1784
|
);
|
|
1606
1785
|
};
|
|
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
1786
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1750
1787
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1751
1788
|
var BUTTON_GAP = 12;
|
|
@@ -1795,7 +1832,7 @@ var ConfirmDialog = ({
|
|
|
1795
1832
|
)
|
|
1796
1833
|
] });
|
|
1797
1834
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1798
|
-
|
|
1835
|
+
Modal,
|
|
1799
1836
|
{
|
|
1800
1837
|
footer,
|
|
1801
1838
|
showClose: false,
|
|
@@ -2696,7 +2733,7 @@ exports.LAYOUT_I18N = LAYOUT_I18N;
|
|
|
2696
2733
|
exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
2697
2734
|
exports.ListRow = ListRow;
|
|
2698
2735
|
exports.MIN_TARGET_PX = MIN_TARGET_PX;
|
|
2699
|
-
exports.Modal =
|
|
2736
|
+
exports.Modal = Modal;
|
|
2700
2737
|
exports.ModalDropdown = ModalDropdown;
|
|
2701
2738
|
exports.ModalShell = ModalShell;
|
|
2702
2739
|
exports.PageFrame = PageFrame;
|