@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.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,215 @@ 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 PageOverlay = ({ children, pageSize, visible, onClose, testID }) => {
|
|
583
|
+
const { t } = useUi();
|
|
584
|
+
return /* @__PURE__ */ jsx(Modal, { accessibilityLabel: t(LAYOUT_I18N.pageEnlarge), size: "xl", testID, visible, onClose, children: /* @__PURE__ */ jsx(ScrollView, { horizontal: true, children: /* @__PURE__ */ jsx(View, { style: { width: pageSize.width, height: pageSize.height }, testID: `${testID}-page`, children }) }) });
|
|
585
|
+
};
|
|
374
586
|
|
|
375
587
|
// src/PageFrame/utils/pageScale.ts
|
|
376
588
|
var HALF = 2;
|
|
@@ -388,25 +600,31 @@ var scaledFrame = (containerWidth, page) => {
|
|
|
388
600
|
offsetY: (scale - 1) * page.height / HALF
|
|
389
601
|
};
|
|
390
602
|
};
|
|
391
|
-
var
|
|
603
|
+
var styles7 = StyleSheet.create({
|
|
392
604
|
outer: { width: "100%", overflow: "hidden" },
|
|
393
|
-
page: { position: "absolute", top: 0, left: 0 }
|
|
605
|
+
page: { position: "absolute", top: 0, left: 0 },
|
|
606
|
+
trigger: { width: "100%", cursor: "pointer" }
|
|
394
607
|
});
|
|
395
608
|
var PageFrame = ({
|
|
396
609
|
children,
|
|
397
610
|
pageSize = A4_PAGE,
|
|
398
|
-
testID = LAYOUT_TEST_IDS.pageFrame
|
|
611
|
+
testID = LAYOUT_TEST_IDS.pageFrame,
|
|
612
|
+
enlargeable = false
|
|
399
613
|
}) => {
|
|
614
|
+
const { t } = useUi();
|
|
400
615
|
const [containerWidth, setContainerWidth] = useState(0);
|
|
616
|
+
const [enlarged, setEnlarged] = useState(false);
|
|
401
617
|
const onLayout = useCallback((event) => {
|
|
402
618
|
setContainerWidth(event.nativeEvent.layout.width);
|
|
403
619
|
}, []);
|
|
620
|
+
const open = useCallback(() => setEnlarged(true), []);
|
|
621
|
+
const close = useCallback(() => setEnlarged(false), []);
|
|
404
622
|
const frame = scaledFrame(containerWidth, pageSize);
|
|
405
|
-
|
|
623
|
+
const preview = /* @__PURE__ */ jsx(View, { style: [styles7.outer, { height: frame.height }], testID, onLayout, children: /* @__PURE__ */ jsx(
|
|
406
624
|
View,
|
|
407
625
|
{
|
|
408
626
|
style: [
|
|
409
|
-
|
|
627
|
+
styles7.page,
|
|
410
628
|
{
|
|
411
629
|
width: pageSize.width,
|
|
412
630
|
height: pageSize.height,
|
|
@@ -416,6 +634,22 @@ var PageFrame = ({
|
|
|
416
634
|
children
|
|
417
635
|
}
|
|
418
636
|
) });
|
|
637
|
+
if (!enlargeable) return preview;
|
|
638
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
639
|
+
/* @__PURE__ */ jsx(
|
|
640
|
+
Pressable,
|
|
641
|
+
{
|
|
642
|
+
accessibilityHint: t(LAYOUT_I18N.pageEnlargeHint),
|
|
643
|
+
accessibilityLabel: t(LAYOUT_I18N.pageEnlarge),
|
|
644
|
+
accessibilityRole: "button",
|
|
645
|
+
style: styles7.trigger,
|
|
646
|
+
testID: `${testID}-enlarge`,
|
|
647
|
+
onPress: open,
|
|
648
|
+
children: preview
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
/* @__PURE__ */ jsx(PageOverlay, { pageSize, testID: `${testID}-overlay`, visible: enlarged, onClose: close, children })
|
|
652
|
+
] });
|
|
419
653
|
};
|
|
420
654
|
var TRACK_PADDING = 3;
|
|
421
655
|
var TRACK_RADIUS = 999;
|
|
@@ -428,7 +662,7 @@ var BORDER_WIDTH = 1;
|
|
|
428
662
|
var SEGMENT_BOX_SHADOW = "0px 1px 3px rgba(20, 30, 50, 0.1)";
|
|
429
663
|
var SHADOW_ELEVATION = 2;
|
|
430
664
|
var TRANSPARENT = "transparent";
|
|
431
|
-
var
|
|
665
|
+
var styles8 = StyleSheet.create({
|
|
432
666
|
track: {
|
|
433
667
|
flexDirection: "row",
|
|
434
668
|
alignSelf: "flex-start",
|
|
@@ -473,7 +707,7 @@ function SegmentedControl({
|
|
|
473
707
|
{
|
|
474
708
|
accessibilityRole: "tablist",
|
|
475
709
|
"aria-label": accessibilityLabel,
|
|
476
|
-
style: [
|
|
710
|
+
style: [styles8.track, { backgroundColor: colors.background, borderColor: colors.border }, style],
|
|
477
711
|
testID,
|
|
478
712
|
children: options.map((opt) => {
|
|
479
713
|
const selected = opt.value === value;
|
|
@@ -486,13 +720,13 @@ function SegmentedControl({
|
|
|
486
720
|
accessibilityHint: opt.accessibilityHint,
|
|
487
721
|
onPress: () => onChange(opt.value),
|
|
488
722
|
style: [
|
|
489
|
-
|
|
490
|
-
selected ?
|
|
723
|
+
styles8.segment,
|
|
724
|
+
selected ? styles8.segmentSelected : null,
|
|
491
725
|
{ backgroundColor: selected ? colors.surface : TRANSPARENT }
|
|
492
726
|
],
|
|
493
727
|
testID: opt.testID,
|
|
494
728
|
...ariaSelectedProps(selected),
|
|
495
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
729
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles8.label, { color: selected ? colors.text : colors.textSecondary }], children: opt.label })
|
|
496
730
|
},
|
|
497
731
|
opt.value
|
|
498
732
|
);
|
|
@@ -507,69 +741,6 @@ var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
|
507
741
|
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
508
742
|
return TabsCollapsedTrigger2;
|
|
509
743
|
})(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
744
|
|
|
574
745
|
// src/ModalDropdown/DropdownVariant.ts
|
|
575
746
|
var DropdownVariant = /* @__PURE__ */ ((DropdownVariant2) => {
|
|
@@ -629,7 +800,7 @@ var HEADING_PADDING_H = 16;
|
|
|
629
800
|
var HEADING_PADDING_TOP = 8;
|
|
630
801
|
var HEADING_PADDING_BOTTOM = 4;
|
|
631
802
|
var HEADING_LETTER_SPACING = 0.5;
|
|
632
|
-
var
|
|
803
|
+
var styles9 = StyleSheet.create({
|
|
633
804
|
heading: {
|
|
634
805
|
fontSize: HEADING_FONT_SIZE,
|
|
635
806
|
fontWeight: HEADING_FONT_WEIGHT,
|
|
@@ -645,7 +816,7 @@ var MenuHeading = ({ testID, text }) => {
|
|
|
645
816
|
Text,
|
|
646
817
|
{
|
|
647
818
|
accessibilityRole: "header",
|
|
648
|
-
style: [
|
|
819
|
+
style: [styles9.heading, { color: theme.colors.textSecondary }],
|
|
649
820
|
testID: `${testID}-menu-heading`,
|
|
650
821
|
children: text
|
|
651
822
|
}
|
|
@@ -666,7 +837,7 @@ var OPTION_PADDING_V = 12;
|
|
|
666
837
|
var ACCENT_BAR_WIDTH = 3;
|
|
667
838
|
var CHECK_GAP = 8;
|
|
668
839
|
var CHECK_GLYPH = "\u2713";
|
|
669
|
-
var
|
|
840
|
+
var styles10 = StyleSheet.create({
|
|
670
841
|
option: {
|
|
671
842
|
paddingHorizontal: OPTION_PADDING_H,
|
|
672
843
|
paddingVertical: OPTION_PADDING_V,
|
|
@@ -705,16 +876,16 @@ var OptionRow = ({
|
|
|
705
876
|
const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
|
|
706
877
|
const isActive = isSelected || isHighlighted;
|
|
707
878
|
const rowStyle = [
|
|
708
|
-
|
|
709
|
-
isMarked ?
|
|
879
|
+
styles10.option,
|
|
880
|
+
isMarked ? styles10.markedRow : null,
|
|
710
881
|
isActive ? { backgroundColor: colors.surfaceElevated } : null,
|
|
711
882
|
isMarked && isSelected ? { borderLeftColor: accentColor } : null
|
|
712
883
|
];
|
|
713
884
|
const textStyle = [
|
|
714
|
-
|
|
885
|
+
styles10.optionText,
|
|
715
886
|
{ color: colors.text },
|
|
716
|
-
isSelected ?
|
|
717
|
-
isMarked ?
|
|
887
|
+
isSelected ? styles10.selectedText : null,
|
|
888
|
+
isMarked ? styles10.markedText : null
|
|
718
889
|
];
|
|
719
890
|
const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
|
|
720
891
|
return /* @__PURE__ */ jsxs(
|
|
@@ -730,7 +901,7 @@ var OptionRow = ({
|
|
|
730
901
|
onPress: handlePress,
|
|
731
902
|
children: [
|
|
732
903
|
/* @__PURE__ */ jsx(Text, { style: textStyle, children: label }),
|
|
733
|
-
isMarked && isSelected ? /* @__PURE__ */ jsx(View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsx(Text, { style: [
|
|
904
|
+
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
905
|
]
|
|
735
906
|
}
|
|
736
907
|
);
|
|
@@ -888,7 +1059,7 @@ var IS_WEB2 = Platform.OS === "web";
|
|
|
888
1059
|
var BORDER_RADIUS2 = 8;
|
|
889
1060
|
var BORDER_WIDTH3 = 1;
|
|
890
1061
|
var MENU_PADDING2 = 4;
|
|
891
|
-
var
|
|
1062
|
+
var styles11 = StyleSheet.create({
|
|
892
1063
|
/** Native (in-tree) popover — anchored absolutely just under the trigger. */
|
|
893
1064
|
popover: {
|
|
894
1065
|
position: "absolute",
|
|
@@ -975,7 +1146,7 @@ var InlineMenu = ({
|
|
|
975
1146
|
themed
|
|
976
1147
|
];
|
|
977
1148
|
}
|
|
978
|
-
return [
|
|
1149
|
+
return [styles11.popover, { minWidth: menuMinWidth }, themed];
|
|
979
1150
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
980
1151
|
const menu = /* @__PURE__ */ jsx(
|
|
981
1152
|
View,
|
|
@@ -990,10 +1161,10 @@ var InlineMenu = ({
|
|
|
990
1161
|
Animated.View,
|
|
991
1162
|
{
|
|
992
1163
|
pointerEvents: isOpen ? "auto" : "none",
|
|
993
|
-
style: [
|
|
1164
|
+
style: [styles11.animated, animatedStyle, isOpen ? null : styles11.inert],
|
|
994
1165
|
children: [
|
|
995
1166
|
menuHeading !== void 0 ? /* @__PURE__ */ jsx(MenuHeading, { testID, text: menuHeading }) : null,
|
|
996
|
-
/* @__PURE__ */ jsx(ScrollView, { style:
|
|
1167
|
+
/* @__PURE__ */ jsx(ScrollView, { style: styles11.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
997
1168
|
OptionRow,
|
|
998
1169
|
{
|
|
999
1170
|
asMenuItem: true,
|
|
@@ -1041,7 +1212,7 @@ var CARET_OPEN_ROTATION = "180deg";
|
|
|
1041
1212
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
1042
1213
|
var POPOVER_ENTER_SCALE = 0.96;
|
|
1043
1214
|
var POPOVER_MOTION_MS = 120;
|
|
1044
|
-
var
|
|
1215
|
+
var styles12 = StyleSheet.create({
|
|
1045
1216
|
anchor: { position: "relative" },
|
|
1046
1217
|
container: {
|
|
1047
1218
|
borderWidth: BORDER_WIDTH4,
|
|
@@ -1156,19 +1327,19 @@ var ModalDropdown = ({
|
|
|
1156
1327
|
const isCaret = showCaret && !isHamburger;
|
|
1157
1328
|
const containerStyle = useMemo(
|
|
1158
1329
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
1159
|
-
|
|
1160
|
-
isHamburger ?
|
|
1330
|
+
styles12.container,
|
|
1331
|
+
isHamburger ? styles12.containerHamburger : isCaret ? styles12.containerMenu : null,
|
|
1161
1332
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
1162
1333
|
],
|
|
1163
1334
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
1164
1335
|
);
|
|
1165
1336
|
const hamburgerStyle = useMemo(
|
|
1166
|
-
() => [
|
|
1337
|
+
() => [styles12.hamburger, { color: colors.textSecondary }],
|
|
1167
1338
|
[colors.textSecondary]
|
|
1168
1339
|
);
|
|
1169
1340
|
const caretStyle = useMemo(
|
|
1170
1341
|
() => [
|
|
1171
|
-
|
|
1342
|
+
styles12.caret,
|
|
1172
1343
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
1173
1344
|
],
|
|
1174
1345
|
[colors.textSecondary, isOpen]
|
|
@@ -1178,11 +1349,11 @@ var ModalDropdown = ({
|
|
|
1178
1349
|
[optionTestID, testID]
|
|
1179
1350
|
);
|
|
1180
1351
|
const anchorStyle = useMemo(
|
|
1181
|
-
() => [
|
|
1352
|
+
() => [styles12.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
1182
1353
|
[isMenu, isOpen]
|
|
1183
1354
|
);
|
|
1184
1355
|
const modalContentStyle = useMemo(
|
|
1185
|
-
() => [
|
|
1356
|
+
() => [styles12.modalContent, { backgroundColor: colors.surface }],
|
|
1186
1357
|
[colors.surface]
|
|
1187
1358
|
);
|
|
1188
1359
|
const renderModalOption = useCallback(
|
|
@@ -1203,11 +1374,11 @@ var ModalDropdown = ({
|
|
|
1203
1374
|
/* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
|
|
1204
1375
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1205
1376
|
/* @__PURE__ */ jsx(Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
1206
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [
|
|
1377
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
1207
1378
|
] }) : isCaret ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1208
|
-
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [
|
|
1379
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles12.selectedText, styles12.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
1209
1380
|
/* @__PURE__ */ jsx(Text, { style: caretStyle, children: CARET_GLYPH })
|
|
1210
|
-
] }) : /* @__PURE__ */ jsx(Text, { style: [
|
|
1381
|
+
] }) : /* @__PURE__ */ jsx(Text, { style: [styles12.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
1211
1382
|
hintNode
|
|
1212
1383
|
] }),
|
|
1213
1384
|
isMenu && menuAnim.mounted ? /* @__PURE__ */ jsx(
|
|
@@ -1228,7 +1399,7 @@ var ModalDropdown = ({
|
|
|
1228
1399
|
onSelect: handleSelect
|
|
1229
1400
|
}
|
|
1230
1401
|
) : null,
|
|
1231
|
-
!isMenu ? /* @__PURE__ */ jsx(Modal, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style:
|
|
1402
|
+
!isMenu ? /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: modalAnim.mounted, onRequestClose: handleClose, children: /* @__PURE__ */ jsxs(View, { style: styles12.modalOverlay, children: [
|
|
1232
1403
|
/* @__PURE__ */ jsx(
|
|
1233
1404
|
TouchableOpacity,
|
|
1234
1405
|
{
|
|
@@ -1321,7 +1492,7 @@ var ROW_PAD_V = 8;
|
|
|
1321
1492
|
var PANEL_PAD_TOP = 16;
|
|
1322
1493
|
var BORDER_WIDTH5 = 1;
|
|
1323
1494
|
var TEXT_ON_PRIMARY = "#ffffff";
|
|
1324
|
-
var
|
|
1495
|
+
var styles13 = StyleSheet.create({
|
|
1325
1496
|
root: {
|
|
1326
1497
|
width: "100%"
|
|
1327
1498
|
},
|
|
@@ -1375,7 +1546,7 @@ var WideTabStrip = ({
|
|
|
1375
1546
|
textSecondary,
|
|
1376
1547
|
surfaceElevated,
|
|
1377
1548
|
stripStyle
|
|
1378
|
-
}) => /* @__PURE__ */ jsx(View, { style: [
|
|
1549
|
+
}) => /* @__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
1550
|
const selected = tab.key === activeKey;
|
|
1380
1551
|
const textColor = selected ? TEXT_ON_PRIMARY : textSecondary;
|
|
1381
1552
|
const pillColor = selected ? primaryColor : surfaceElevated;
|
|
@@ -1389,10 +1560,10 @@ var WideTabStrip = ({
|
|
|
1389
1560
|
accessibilityLabel: tab.accessibilityLabel ?? tab.label,
|
|
1390
1561
|
accessibilityHint: tab.accessibilityHint,
|
|
1391
1562
|
onPress: () => onChange(tab.key),
|
|
1392
|
-
style: [
|
|
1563
|
+
style: [styles13.pill, { backgroundColor: pillColor }],
|
|
1393
1564
|
testID: tab.testID,
|
|
1394
1565
|
...ariaTabProps(selected, panelId, tabId),
|
|
1395
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1566
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles13.pillText, { color: textColor }], children: tab.label })
|
|
1396
1567
|
},
|
|
1397
1568
|
tab.key
|
|
1398
1569
|
);
|
|
@@ -1417,7 +1588,7 @@ var Tabs = ({
|
|
|
1417
1588
|
const activePanelId = `${idPrefix}-panel-${activeKey}`;
|
|
1418
1589
|
const activeTabId = `${idPrefix}-tab-${activeKey}`;
|
|
1419
1590
|
const panelAria = { "aria-labelledby": activeTabId, id: activePanelId };
|
|
1420
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
1591
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles13.root, style], testID, children: [
|
|
1421
1592
|
collapsed ? /* @__PURE__ */ jsx(
|
|
1422
1593
|
TabsMenu,
|
|
1423
1594
|
{
|
|
@@ -1444,7 +1615,7 @@ var Tabs = ({
|
|
|
1444
1615
|
onChange
|
|
1445
1616
|
}
|
|
1446
1617
|
),
|
|
1447
|
-
/* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [
|
|
1618
|
+
/* @__PURE__ */ jsx(View, { accessibilityRole: "none", style: [styles13.panel, panelStyle], ...panelAria, children })
|
|
1448
1619
|
] });
|
|
1449
1620
|
};
|
|
1450
1621
|
var PROMPT_PADDING = 20;
|
|
@@ -1459,7 +1630,7 @@ var DISMISS_FONT_SIZE = 13;
|
|
|
1459
1630
|
var TITLE_MARGIN_BOTTOM = 8;
|
|
1460
1631
|
var MESSAGE_MARGIN_BOTTOM = 16;
|
|
1461
1632
|
var CTA_MARGIN_BOTTOM = 8;
|
|
1462
|
-
var
|
|
1633
|
+
var styles14 = StyleSheet.create({
|
|
1463
1634
|
container: {
|
|
1464
1635
|
padding: PROMPT_PADDING,
|
|
1465
1636
|
borderRadius: PROMPT_BORDER_RADIUS,
|
|
@@ -1494,21 +1665,21 @@ var UpgradePrompt = ({
|
|
|
1494
1665
|
return /* @__PURE__ */ jsxs(
|
|
1495
1666
|
View,
|
|
1496
1667
|
{
|
|
1497
|
-
style: [
|
|
1668
|
+
style: [styles14.container, { borderColor: primary, backgroundColor: colors.surface }],
|
|
1498
1669
|
testID: LAYOUT_TEST_IDS.upgradePrompt,
|
|
1499
1670
|
children: [
|
|
1500
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1501
|
-
/* @__PURE__ */ jsx(Text, { style: [
|
|
1671
|
+
/* @__PURE__ */ jsx(Text, { style: [styles14.title, { color: colors.text }], children: t(LAYOUT_I18N.upgradePromptTitle) }),
|
|
1672
|
+
/* @__PURE__ */ jsx(Text, { style: [styles14.message, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptMessage, requiredTier, currentTier) }),
|
|
1502
1673
|
/* @__PURE__ */ jsx(
|
|
1503
1674
|
TouchableOpacity,
|
|
1504
1675
|
{
|
|
1505
1676
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptCtaHint),
|
|
1506
1677
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptCta),
|
|
1507
1678
|
accessibilityRole: "button",
|
|
1508
|
-
style: [
|
|
1679
|
+
style: [styles14.cta, { backgroundColor: primary }],
|
|
1509
1680
|
testID: LAYOUT_TEST_IDS.upgradePromptCta,
|
|
1510
1681
|
onPress: handleUpgradePress,
|
|
1511
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1682
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles14.ctaText, { color: colors.surface }], children: t(LAYOUT_I18N.upgradePromptCta) })
|
|
1512
1683
|
}
|
|
1513
1684
|
),
|
|
1514
1685
|
onDismiss ? /* @__PURE__ */ jsx(
|
|
@@ -1517,10 +1688,10 @@ var UpgradePrompt = ({
|
|
|
1517
1688
|
accessibilityHint: t(LAYOUT_I18N.upgradePromptDismissHint),
|
|
1518
1689
|
accessibilityLabel: t(LAYOUT_I18N.upgradePromptDismiss),
|
|
1519
1690
|
accessibilityRole: "button",
|
|
1520
|
-
style:
|
|
1691
|
+
style: styles14.dismiss,
|
|
1521
1692
|
testID: LAYOUT_TEST_IDS.upgradePromptDismiss,
|
|
1522
1693
|
onPress: onDismiss,
|
|
1523
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1694
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles14.dismissText, { color: colors.textSecondary }], children: t(LAYOUT_I18N.upgradePromptDismiss) })
|
|
1524
1695
|
}
|
|
1525
1696
|
) : null
|
|
1526
1697
|
]
|
|
@@ -1528,8 +1699,8 @@ var UpgradePrompt = ({
|
|
|
1528
1699
|
);
|
|
1529
1700
|
};
|
|
1530
1701
|
var CLOSE_ICON_SIZE = 18;
|
|
1531
|
-
var
|
|
1532
|
-
var
|
|
1702
|
+
var PANEL_ENTER_SCALE2 = 0.96;
|
|
1703
|
+
var styles15 = StyleSheet.create({
|
|
1533
1704
|
animatedFill: { flex: 1 },
|
|
1534
1705
|
container: {
|
|
1535
1706
|
flex: 1,
|
|
@@ -1554,21 +1725,21 @@ var ModalShell = ({
|
|
|
1554
1725
|
showClose = true
|
|
1555
1726
|
}) => {
|
|
1556
1727
|
const { theme, t } = useUi();
|
|
1557
|
-
const { style: sheetStyle, mounted } = useEnterExit({ visible, fromScale:
|
|
1728
|
+
const { style: sheetStyle, mounted } = useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1558
1729
|
const containerStyle = React12.useMemo(
|
|
1559
|
-
() => [
|
|
1730
|
+
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1560
1731
|
[theme.colors.background, contentStyle]
|
|
1561
1732
|
);
|
|
1562
1733
|
const closeA11yLabel = t(LAYOUT_I18N.close);
|
|
1563
1734
|
const accessibleTitle = typeof title === "string" ? title : t(LAYOUT_I18N.dialog);
|
|
1564
1735
|
return /* @__PURE__ */ jsx(
|
|
1565
|
-
Modal,
|
|
1736
|
+
Modal$1,
|
|
1566
1737
|
{
|
|
1567
1738
|
transparent: true,
|
|
1568
1739
|
testID: LAYOUT_TEST_IDS.modalShell,
|
|
1569
1740
|
visible: mounted,
|
|
1570
1741
|
onRequestClose: onCancel,
|
|
1571
|
-
children: /* @__PURE__ */ jsx(Animated.View, { style: [
|
|
1742
|
+
children: /* @__PURE__ */ jsx(Animated.View, { style: [styles15.animatedFill, sheetStyle], children: /* @__PURE__ */ jsxs(
|
|
1572
1743
|
ScrollView,
|
|
1573
1744
|
{
|
|
1574
1745
|
accessibilityViewIsModal: true,
|
|
@@ -1576,7 +1747,7 @@ var ModalShell = ({
|
|
|
1576
1747
|
role: "dialog",
|
|
1577
1748
|
style: containerStyle,
|
|
1578
1749
|
children: [
|
|
1579
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1750
|
+
/* @__PURE__ */ jsxs(View, { style: styles15.headerRow, children: [
|
|
1580
1751
|
/* @__PURE__ */ jsx(Heading, { children: title ?? t(LAYOUT_I18N.closeHeading) }),
|
|
1581
1752
|
showClose ? /* @__PURE__ */ jsx(
|
|
1582
1753
|
TouchableOpacity,
|
|
@@ -1584,7 +1755,7 @@ var ModalShell = ({
|
|
|
1584
1755
|
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1585
1756
|
accessibilityLabel: closeA11yLabel,
|
|
1586
1757
|
accessibilityRole: "button",
|
|
1587
|
-
style:
|
|
1758
|
+
style: styles15.closeButton,
|
|
1588
1759
|
testID: LAYOUT_TEST_IDS.modalShellClose,
|
|
1589
1760
|
onPress: onCancel,
|
|
1590
1761
|
children: /* @__PURE__ */ jsx(SvgIcon, { color: theme.colors.textSecondary, name: "close", size: CLOSE_ICON_SIZE })
|
|
@@ -1598,148 +1769,6 @@ var ModalShell = ({
|
|
|
1598
1769
|
}
|
|
1599
1770
|
);
|
|
1600
1771
|
};
|
|
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
1772
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1744
1773
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1745
1774
|
var BUTTON_GAP = 12;
|
|
@@ -1789,7 +1818,7 @@ var ConfirmDialog = ({
|
|
|
1789
1818
|
)
|
|
1790
1819
|
] });
|
|
1791
1820
|
return /* @__PURE__ */ jsx(
|
|
1792
|
-
|
|
1821
|
+
Modal,
|
|
1793
1822
|
{
|
|
1794
1823
|
footer,
|
|
1795
1824
|
showClose: false,
|
|
@@ -2670,6 +2699,6 @@ var ListRow = ({
|
|
|
2670
2699
|
] });
|
|
2671
2700
|
};
|
|
2672
2701
|
|
|
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,
|
|
2702
|
+
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
2703
|
//# sourceMappingURL=index.mjs.map
|
|
2675
2704
|
//# sourceMappingURL=index.mjs.map
|