@dloizides/ui-layout 1.20.0 → 1.22.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/CHANGELOG.md +69 -0
- package/README.md +38 -2
- package/dist/index.d.mts +157 -3
- package/dist/index.d.ts +157 -3
- package/dist/index.js +337 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +276 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React10 = 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
7
|
var a11y = require('@dloizides/a11y');
|
|
8
8
|
var reactDom = require('react-dom');
|
|
9
9
|
var uiIcons = require('@dloizides/ui-icons');
|
|
10
|
+
var uiButtons = require('@dloizides/ui-buttons');
|
|
10
11
|
var rnWebHooks = require('@dloizides/rn-web-hooks');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
14
|
|
|
14
|
-
var
|
|
15
|
+
var React10__default = /*#__PURE__*/_interopDefault(React10);
|
|
15
16
|
|
|
16
17
|
// src/Section/Section.tsx
|
|
17
18
|
var styles = reactNative.StyleSheet.create({
|
|
@@ -23,7 +24,7 @@ var styles = reactNative.StyleSheet.create({
|
|
|
23
24
|
});
|
|
24
25
|
var Section = ({ children, style }) => {
|
|
25
26
|
const { theme } = uiFeedback.useUi();
|
|
26
|
-
const containerStyle =
|
|
27
|
+
const containerStyle = React10__default.default.useMemo(
|
|
27
28
|
() => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
|
|
28
29
|
[theme.colors.border, theme.colors.surface, style]
|
|
29
30
|
);
|
|
@@ -39,6 +40,10 @@ var LAYOUT_TEST_IDS = {
|
|
|
39
40
|
upgradePromptDismiss: "upgrade-prompt-dismiss",
|
|
40
41
|
modalShell: "template-modal",
|
|
41
42
|
modalShellClose: "cancel-button",
|
|
43
|
+
/** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
|
|
44
|
+
modal: "modal",
|
|
45
|
+
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
46
|
+
confirmDialog: "confirm-dialog",
|
|
42
47
|
accordion: "accordion"
|
|
43
48
|
};
|
|
44
49
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
@@ -67,6 +72,14 @@ var LAYOUT_I18N = {
|
|
|
67
72
|
close: "quizTemplates.cancel",
|
|
68
73
|
/** `ModalShell`: heading fallback when no title is supplied. */
|
|
69
74
|
closeHeading: "close",
|
|
75
|
+
/** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
|
|
76
|
+
dialogClose: "common.close",
|
|
77
|
+
/** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
|
|
78
|
+
confirm: "common.confirm",
|
|
79
|
+
confirmHint: "common.confirmHint",
|
|
80
|
+
/** `ConfirmDialog`: default Cancel button label (overridable via `cancelLabel`) + its hint. */
|
|
81
|
+
cancel: "common.cancel",
|
|
82
|
+
cancelHint: "common.cancelHint",
|
|
70
83
|
upgradePromptTitle: "settings.billing.upgradePrompt.title",
|
|
71
84
|
/** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
|
|
72
85
|
upgradePromptMessage: "settings.billing.upgradePrompt.message",
|
|
@@ -102,7 +115,7 @@ var Heading = ({
|
|
|
102
115
|
testID
|
|
103
116
|
}) => {
|
|
104
117
|
const { theme } = uiFeedback.useUi();
|
|
105
|
-
const headingStyle =
|
|
118
|
+
const headingStyle = React10__default.default.useMemo(
|
|
106
119
|
() => [styles2.heading, { color: theme.colors.text }, style],
|
|
107
120
|
[theme.colors.text, style]
|
|
108
121
|
);
|
|
@@ -142,8 +155,8 @@ var StatusBadge = ({
|
|
|
142
155
|
accessibilityHint
|
|
143
156
|
}) => {
|
|
144
157
|
const { t } = uiFeedback.useUi();
|
|
145
|
-
const dynamicBadge =
|
|
146
|
-
const dynamicText =
|
|
158
|
+
const dynamicBadge = React10.useMemo(() => ({ backgroundColor }), [backgroundColor]);
|
|
159
|
+
const dynamicText = React10.useMemo(() => ({ color }), [color]);
|
|
147
160
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
148
161
|
reactNative.View,
|
|
149
162
|
{
|
|
@@ -236,6 +249,13 @@ function SegmentedControl({
|
|
|
236
249
|
}
|
|
237
250
|
);
|
|
238
251
|
}
|
|
252
|
+
|
|
253
|
+
// src/Tabs/TabsCollapsedTrigger.ts
|
|
254
|
+
var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
255
|
+
TabsCollapsedTrigger2["Caret"] = "caret";
|
|
256
|
+
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
257
|
+
return TabsCollapsedTrigger2;
|
|
258
|
+
})(TabsCollapsedTrigger || {});
|
|
239
259
|
var FOCUSABLE_SELECTOR = [
|
|
240
260
|
"a[href]",
|
|
241
261
|
"button:not([disabled])",
|
|
@@ -273,8 +293,8 @@ function handleKeyDown(domNode, event) {
|
|
|
273
293
|
}
|
|
274
294
|
}
|
|
275
295
|
function useFocusTrap(containerRef, enabled) {
|
|
276
|
-
const previousFocusRef =
|
|
277
|
-
|
|
296
|
+
const previousFocusRef = React10.useRef(null);
|
|
297
|
+
React10.useEffect(() => {
|
|
278
298
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
279
299
|
const domNode = containerRef.current;
|
|
280
300
|
if (!domNode) return;
|
|
@@ -359,7 +379,7 @@ var OptionRow = ({
|
|
|
359
379
|
}) => {
|
|
360
380
|
const { theme, t } = uiFeedback.useUi();
|
|
361
381
|
const { colors } = theme;
|
|
362
|
-
const handlePress =
|
|
382
|
+
const handlePress = React10.useCallback(() => {
|
|
363
383
|
onSelect();
|
|
364
384
|
}, [onSelect]);
|
|
365
385
|
const isActive = isSelected || isHighlighted;
|
|
@@ -428,8 +448,8 @@ function observeLayout(node, onChange) {
|
|
|
428
448
|
return observer;
|
|
429
449
|
}
|
|
430
450
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
431
|
-
const [rect, setRect] =
|
|
432
|
-
|
|
451
|
+
const [rect, setRect] = React10.useState(() => readAnchorRect(containerRef));
|
|
452
|
+
React10.useLayoutEffect(() => {
|
|
433
453
|
if (!IS_WEB) return void 0;
|
|
434
454
|
let frame = null;
|
|
435
455
|
let isDisposed = false;
|
|
@@ -508,7 +528,7 @@ function buildKeyHandler(params) {
|
|
|
508
528
|
}
|
|
509
529
|
function useMenuKeyboard(params) {
|
|
510
530
|
const { containerRef, menuRef, enabled, onClose } = params;
|
|
511
|
-
|
|
531
|
+
React10.useEffect(() => {
|
|
512
532
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
513
533
|
const onKeyDown = buildKeyHandler(params);
|
|
514
534
|
const onMouseDown = (event) => {
|
|
@@ -559,21 +579,21 @@ var InlineMenu = ({
|
|
|
559
579
|
}) => {
|
|
560
580
|
const { theme } = uiFeedback.useUi();
|
|
561
581
|
const { colors } = theme;
|
|
562
|
-
const menuRef =
|
|
582
|
+
const menuRef = React10.useRef(null);
|
|
563
583
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
564
|
-
const selectedIndex =
|
|
584
|
+
const selectedIndex = React10.useMemo(
|
|
565
585
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
566
586
|
[options, value]
|
|
567
587
|
);
|
|
568
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
569
|
-
const selectAt =
|
|
588
|
+
const [highlightedIndex, setHighlightedIndex] = React10.useState(() => selectedIndex);
|
|
589
|
+
const selectAt = React10.useCallback(
|
|
570
590
|
(index) => {
|
|
571
591
|
const option = options[index];
|
|
572
592
|
if (option !== void 0) onSelect(option.value);
|
|
573
593
|
},
|
|
574
594
|
[options, onSelect]
|
|
575
595
|
);
|
|
576
|
-
const selectHighlighted =
|
|
596
|
+
const selectHighlighted = React10.useCallback(
|
|
577
597
|
() => {
|
|
578
598
|
selectAt(highlightedIndex);
|
|
579
599
|
},
|
|
@@ -588,7 +608,7 @@ var InlineMenu = ({
|
|
|
588
608
|
onSelectHighlighted: selectHighlighted,
|
|
589
609
|
onClose
|
|
590
610
|
});
|
|
591
|
-
const popoverStyle =
|
|
611
|
+
const popoverStyle = React10.useMemo(() => {
|
|
592
612
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
593
613
|
if (IS_WEB2)
|
|
594
614
|
return [
|
|
@@ -644,6 +664,8 @@ var MIN_TOUCH_TARGET = 44;
|
|
|
644
664
|
var CARET_FONT_SIZE = 12;
|
|
645
665
|
var CARET_GAP = 8;
|
|
646
666
|
var CARET_GLYPH = "\u25BE";
|
|
667
|
+
var HAMBURGER_GLYPH = "\u2630";
|
|
668
|
+
var HAMBURGER_FONT_SIZE = 18;
|
|
647
669
|
var CARET_OPEN_ROTATION = "180deg";
|
|
648
670
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
649
671
|
var styles7 = reactNative.StyleSheet.create({
|
|
@@ -664,10 +686,20 @@ var styles7 = reactNative.StyleSheet.create({
|
|
|
664
686
|
justifyContent: "space-between",
|
|
665
687
|
columnGap: CARET_GAP
|
|
666
688
|
},
|
|
689
|
+
// Hamburger variant: the ☰ glyph LEADS the label (icon-first, like a phone nav button), so the
|
|
690
|
+
// row packs to the start rather than pushing a trailing caret to the far edge. Same tap target.
|
|
691
|
+
containerHamburger: {
|
|
692
|
+
minHeight: MIN_TOUCH_TARGET,
|
|
693
|
+
flexDirection: "row",
|
|
694
|
+
alignItems: "center",
|
|
695
|
+
justifyContent: "flex-start",
|
|
696
|
+
columnGap: CARET_GAP
|
|
697
|
+
},
|
|
667
698
|
selectedText: { fontSize: BODY_FONT_SIZE2 },
|
|
668
|
-
// The label may shrink/ellipsize; the caret never does.
|
|
699
|
+
// The label may shrink/ellipsize; the caret / hamburger glyph never does.
|
|
669
700
|
selectedTextMenu: { flexShrink: 1 },
|
|
670
701
|
caret: { fontSize: CARET_FONT_SIZE, flexShrink: 0 },
|
|
702
|
+
hamburger: { fontSize: HAMBURGER_FONT_SIZE, flexShrink: 0 },
|
|
671
703
|
modalOverlay: {
|
|
672
704
|
flex: 1,
|
|
673
705
|
justifyContent: "center",
|
|
@@ -692,13 +724,14 @@ var ModalDropdown = ({
|
|
|
692
724
|
renderTrigger,
|
|
693
725
|
optionTestID,
|
|
694
726
|
menuMinWidth,
|
|
695
|
-
showCaret = false
|
|
727
|
+
showCaret = false,
|
|
728
|
+
showHamburger = false
|
|
696
729
|
}) => {
|
|
697
730
|
const { theme, t } = uiFeedback.useUi();
|
|
698
731
|
const { colors } = theme;
|
|
699
732
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
700
733
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
701
|
-
const [isOpen, setIsOpen] =
|
|
734
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
702
735
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
703
736
|
label: accessibilityLabel,
|
|
704
737
|
hint: accessibilityHint,
|
|
@@ -706,54 +739,60 @@ var ModalDropdown = ({
|
|
|
706
739
|
state: { expanded: isOpen },
|
|
707
740
|
testID
|
|
708
741
|
});
|
|
709
|
-
const anchorRef =
|
|
710
|
-
const dialogRef =
|
|
742
|
+
const anchorRef = React10.useRef(null);
|
|
743
|
+
const dialogRef = React10.useRef(null);
|
|
711
744
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
712
|
-
const selectedLabel =
|
|
745
|
+
const selectedLabel = React10.useMemo(() => {
|
|
713
746
|
const found = options.find((opt) => opt.value === value);
|
|
714
747
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
715
748
|
}, [options, value, t]);
|
|
716
|
-
const handleToggle =
|
|
749
|
+
const handleToggle = React10.useCallback(() => {
|
|
717
750
|
setIsOpen((prev) => !prev);
|
|
718
751
|
}, []);
|
|
719
|
-
const handleClose =
|
|
752
|
+
const handleClose = React10.useCallback(() => {
|
|
720
753
|
setIsOpen(false);
|
|
721
754
|
}, []);
|
|
722
|
-
const handleSelect =
|
|
755
|
+
const handleSelect = React10.useCallback(
|
|
723
756
|
(optionValue) => {
|
|
724
757
|
onChange(optionValue);
|
|
725
758
|
setIsOpen(false);
|
|
726
759
|
},
|
|
727
760
|
[onChange]
|
|
728
761
|
);
|
|
729
|
-
const
|
|
762
|
+
const isHamburger = showHamburger;
|
|
763
|
+
const isCaret = showCaret && !isHamburger;
|
|
764
|
+
const containerStyle = React10.useMemo(
|
|
730
765
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
731
766
|
styles7.container,
|
|
732
|
-
|
|
767
|
+
isHamburger ? styles7.containerHamburger : isCaret ? styles7.containerMenu : null,
|
|
733
768
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
734
769
|
],
|
|
735
|
-
[colors.border, colors.surface, renderTrigger,
|
|
770
|
+
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
771
|
+
);
|
|
772
|
+
const hamburgerStyle = React10.useMemo(
|
|
773
|
+
() => [styles7.hamburger, { color: colors.textSecondary }],
|
|
774
|
+
[colors.textSecondary]
|
|
736
775
|
);
|
|
737
|
-
const caretStyle =
|
|
776
|
+
const caretStyle = React10.useMemo(
|
|
738
777
|
() => [
|
|
739
778
|
styles7.caret,
|
|
740
779
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
741
780
|
],
|
|
742
781
|
[colors.textSecondary, isOpen]
|
|
743
782
|
);
|
|
744
|
-
const optionTestIDFor =
|
|
783
|
+
const optionTestIDFor = React10.useCallback(
|
|
745
784
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
746
785
|
[optionTestID, testID]
|
|
747
786
|
);
|
|
748
|
-
const anchorStyle =
|
|
787
|
+
const anchorStyle = React10.useMemo(
|
|
749
788
|
() => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
750
789
|
[isMenu, isOpen]
|
|
751
790
|
);
|
|
752
|
-
const modalContentStyle =
|
|
791
|
+
const modalContentStyle = React10.useMemo(
|
|
753
792
|
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
754
793
|
[colors.surface]
|
|
755
794
|
);
|
|
756
|
-
const renderModalOption =
|
|
795
|
+
const renderModalOption = React10.useCallback(
|
|
757
796
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
758
797
|
OptionRow,
|
|
759
798
|
{
|
|
@@ -765,10 +804,13 @@ var ModalDropdown = ({
|
|
|
765
804
|
),
|
|
766
805
|
[handleSelect, optionTestIDFor, value]
|
|
767
806
|
);
|
|
768
|
-
const keyExtractor =
|
|
807
|
+
const keyExtractor = React10.useCallback((item) => String(item.value), []);
|
|
769
808
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
770
809
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
771
|
-
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) :
|
|
810
|
+
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
811
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
812
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
813
|
+
] }) : isCaret ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
772
814
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
773
815
|
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: caretStyle, children: CARET_GLYPH })
|
|
774
816
|
] }) : /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
@@ -822,20 +864,22 @@ var TabsMenu = ({
|
|
|
822
864
|
onChange,
|
|
823
865
|
accessibilityLabel,
|
|
824
866
|
idPrefix,
|
|
825
|
-
testID
|
|
867
|
+
testID,
|
|
868
|
+
collapsedTrigger = "caret" /* Caret */
|
|
826
869
|
}) => {
|
|
827
870
|
const { t } = uiFeedback.useUi();
|
|
828
|
-
const options =
|
|
871
|
+
const options = React10.useMemo(
|
|
829
872
|
() => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
|
|
830
873
|
[tabs]
|
|
831
874
|
);
|
|
832
|
-
const optionTestID =
|
|
875
|
+
const optionTestID = React10.useCallback(
|
|
833
876
|
(key) => {
|
|
834
877
|
const found = tabs.find((tab) => tab.key === key);
|
|
835
878
|
return found?.testID ?? `${idPrefix}-tab-${key}`;
|
|
836
879
|
},
|
|
837
880
|
[tabs, idPrefix]
|
|
838
881
|
);
|
|
882
|
+
const isHamburger = collapsedTrigger === "hamburger" /* Hamburger */;
|
|
839
883
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
840
884
|
ModalDropdown,
|
|
841
885
|
{
|
|
@@ -843,7 +887,8 @@ var TabsMenu = ({
|
|
|
843
887
|
accessibilityLabel,
|
|
844
888
|
optionTestID,
|
|
845
889
|
options,
|
|
846
|
-
showCaret:
|
|
890
|
+
showCaret: !isHamburger,
|
|
891
|
+
showHamburger: isHamburger,
|
|
847
892
|
testID,
|
|
848
893
|
value: activeKey,
|
|
849
894
|
onChange
|
|
@@ -956,6 +1001,7 @@ var Tabs = ({
|
|
|
956
1001
|
children,
|
|
957
1002
|
idPrefix = "tabs",
|
|
958
1003
|
collapseBelow = TABS_COLLAPSE_BREAKPOINT,
|
|
1004
|
+
collapsedTrigger = "caret" /* Caret */,
|
|
959
1005
|
style,
|
|
960
1006
|
stripStyle,
|
|
961
1007
|
panelStyle,
|
|
@@ -973,6 +1019,7 @@ var Tabs = ({
|
|
|
973
1019
|
{
|
|
974
1020
|
accessibilityLabel,
|
|
975
1021
|
activeKey,
|
|
1022
|
+
collapsedTrigger,
|
|
976
1023
|
idPrefix,
|
|
977
1024
|
tabs,
|
|
978
1025
|
testID: `${idPrefix}-menu`,
|
|
@@ -1094,7 +1141,7 @@ var ModalShell = ({
|
|
|
1094
1141
|
showClose = true
|
|
1095
1142
|
}) => {
|
|
1096
1143
|
const { theme, t } = uiFeedback.useUi();
|
|
1097
|
-
const containerStyle =
|
|
1144
|
+
const containerStyle = React10__default.default.useMemo(
|
|
1098
1145
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1099
1146
|
[theme.colors.background, contentStyle]
|
|
1100
1147
|
);
|
|
@@ -1137,9 +1184,198 @@ var ModalShell = ({
|
|
|
1137
1184
|
}
|
|
1138
1185
|
);
|
|
1139
1186
|
};
|
|
1140
|
-
|
|
1187
|
+
function useEscapeKey(enabled, onClose) {
|
|
1188
|
+
React10.useEffect(() => {
|
|
1189
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1190
|
+
const onKeyDown = (event) => {
|
|
1191
|
+
if (event.key === "Escape") onClose();
|
|
1192
|
+
};
|
|
1193
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1194
|
+
return () => {
|
|
1195
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1196
|
+
};
|
|
1197
|
+
}, [enabled, onClose]);
|
|
1198
|
+
}
|
|
1199
|
+
function useScrollLock(enabled) {
|
|
1200
|
+
React10.useEffect(() => {
|
|
1201
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1202
|
+
const { body } = document;
|
|
1203
|
+
const previousOverflow = body.style.overflow;
|
|
1204
|
+
body.style.overflow = "hidden";
|
|
1205
|
+
return () => {
|
|
1206
|
+
body.style.overflow = previousOverflow;
|
|
1207
|
+
};
|
|
1208
|
+
}, [enabled]);
|
|
1209
|
+
}
|
|
1210
|
+
var OVERLAY_PADDING = 16;
|
|
1211
|
+
var DIALOG_RADIUS = 12;
|
|
1212
|
+
var DIALOG_PADDING = 16;
|
|
1213
|
+
var HEADER_GAP = 12;
|
|
1214
|
+
var FOOTER_MARGIN = 16;
|
|
1215
|
+
var HEADER_MARGIN = 12;
|
|
1216
|
+
var DIALOG_MAX_HEIGHT = "90%";
|
|
1217
|
+
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640 };
|
|
1218
|
+
var styles11 = reactNative.StyleSheet.create({
|
|
1219
|
+
overlay: {
|
|
1220
|
+
flex: 1,
|
|
1221
|
+
justifyContent: "center",
|
|
1222
|
+
alignItems: "center",
|
|
1223
|
+
padding: OVERLAY_PADDING,
|
|
1224
|
+
backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR
|
|
1225
|
+
},
|
|
1226
|
+
dialog: {
|
|
1227
|
+
width: "100%",
|
|
1228
|
+
borderRadius: DIALOG_RADIUS,
|
|
1229
|
+
padding: DIALOG_PADDING,
|
|
1230
|
+
maxHeight: DIALOG_MAX_HEIGHT
|
|
1231
|
+
},
|
|
1232
|
+
headerRow: {
|
|
1233
|
+
flexDirection: "row",
|
|
1234
|
+
alignItems: "flex-start",
|
|
1235
|
+
justifyContent: "space-between",
|
|
1236
|
+
columnGap: HEADER_GAP,
|
|
1237
|
+
marginBottom: HEADER_MARGIN
|
|
1238
|
+
},
|
|
1239
|
+
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
1240
|
+
titleWrap: { flex: 1 },
|
|
1241
|
+
footer: { marginTop: FOOTER_MARGIN }
|
|
1242
|
+
});
|
|
1243
|
+
var Modal3 = ({
|
|
1244
|
+
visible,
|
|
1245
|
+
onClose,
|
|
1246
|
+
title,
|
|
1247
|
+
children,
|
|
1248
|
+
footer,
|
|
1249
|
+
size = "md",
|
|
1250
|
+
showClose = true,
|
|
1251
|
+
testID = LAYOUT_TEST_IDS.modal,
|
|
1252
|
+
accessibilityLabel
|
|
1253
|
+
}) => {
|
|
1254
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1255
|
+
const dialogRef = React10.useRef(null);
|
|
1256
|
+
useFocusTrap(dialogRef, visible);
|
|
1257
|
+
useEscapeKey(visible, onClose);
|
|
1258
|
+
useScrollLock(visible);
|
|
1259
|
+
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
1260
|
+
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
1261
|
+
const dialogStyle = React10.useMemo(
|
|
1262
|
+
() => [styles11.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
1263
|
+
[theme.colors.surface, size]
|
|
1264
|
+
);
|
|
1265
|
+
const hasHeader = title !== void 0 || showClose;
|
|
1266
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.overlay, children: [
|
|
1267
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1268
|
+
reactNative.TouchableOpacity,
|
|
1269
|
+
{
|
|
1270
|
+
accessible: true,
|
|
1271
|
+
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
1272
|
+
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
1273
|
+
accessibilityRole: "button",
|
|
1274
|
+
activeOpacity: 1,
|
|
1275
|
+
style: reactNative.StyleSheet.absoluteFill,
|
|
1276
|
+
testID: `${testID}-backdrop`,
|
|
1277
|
+
onPress: onClose
|
|
1278
|
+
}
|
|
1279
|
+
),
|
|
1280
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1281
|
+
reactNative.View,
|
|
1282
|
+
{
|
|
1283
|
+
ref: dialogRef,
|
|
1284
|
+
accessibilityViewIsModal: true,
|
|
1285
|
+
"aria-label": accessibleName,
|
|
1286
|
+
role: "dialog",
|
|
1287
|
+
style: dialogStyle,
|
|
1288
|
+
testID,
|
|
1289
|
+
children: [
|
|
1290
|
+
hasHeader ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.headerRow, children: [
|
|
1291
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title }) : null }),
|
|
1292
|
+
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1293
|
+
uiButtons.IconButton,
|
|
1294
|
+
{
|
|
1295
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1296
|
+
accessibilityLabel: closeLabel,
|
|
1297
|
+
appearance: "ghost",
|
|
1298
|
+
renderIcon: (color, iconSize) => /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color, name: "close", size: iconSize }),
|
|
1299
|
+
size: "md",
|
|
1300
|
+
testID: `${testID}-close`,
|
|
1301
|
+
tooltip: closeLabel,
|
|
1302
|
+
variant: "ghost",
|
|
1303
|
+
onPress: onClose
|
|
1304
|
+
}
|
|
1305
|
+
) : null
|
|
1306
|
+
] }) : null,
|
|
1307
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { children }),
|
|
1308
|
+
footer !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.footer, children: footer }) : null
|
|
1309
|
+
]
|
|
1310
|
+
}
|
|
1311
|
+
)
|
|
1312
|
+
] }) });
|
|
1313
|
+
};
|
|
1314
|
+
var MESSAGE_FONT_SIZE2 = 14;
|
|
1315
|
+
var MESSAGE_LINE_HEIGHT = 20;
|
|
1316
|
+
var BUTTON_GAP = 12;
|
|
1317
|
+
var styles12 = reactNative.StyleSheet.create({
|
|
1318
|
+
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1319
|
+
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1320
|
+
});
|
|
1321
|
+
var ConfirmDialog = ({
|
|
1322
|
+
visible,
|
|
1323
|
+
title,
|
|
1324
|
+
message,
|
|
1325
|
+
confirmLabel,
|
|
1326
|
+
cancelLabel,
|
|
1327
|
+
destructive = false,
|
|
1328
|
+
onConfirm,
|
|
1329
|
+
onCancel,
|
|
1330
|
+
busy = false,
|
|
1331
|
+
testID = LAYOUT_TEST_IDS.confirmDialog
|
|
1332
|
+
}) => {
|
|
1333
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1334
|
+
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1335
|
+
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1336
|
+
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.footer, children: [
|
|
1337
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1338
|
+
uiButtons.Button,
|
|
1339
|
+
{
|
|
1340
|
+
accessibilityHint: t(LAYOUT_I18N.cancelHint),
|
|
1341
|
+
accessibilityLabel: resolvedCancel,
|
|
1342
|
+
disabled: busy,
|
|
1343
|
+
label: resolvedCancel,
|
|
1344
|
+
testID: `${testID}-cancel`,
|
|
1345
|
+
variant: "secondary",
|
|
1346
|
+
onPress: onCancel
|
|
1347
|
+
}
|
|
1348
|
+
),
|
|
1349
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1350
|
+
uiButtons.Button,
|
|
1351
|
+
{
|
|
1352
|
+
accessibilityHint: t(LAYOUT_I18N.confirmHint),
|
|
1353
|
+
accessibilityLabel: resolvedConfirm,
|
|
1354
|
+
label: resolvedConfirm,
|
|
1355
|
+
loading: busy,
|
|
1356
|
+
testID: `${testID}-confirm`,
|
|
1357
|
+
variant: destructive ? "danger" : "primary",
|
|
1358
|
+
onPress: onConfirm
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
] });
|
|
1362
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1363
|
+
Modal3,
|
|
1364
|
+
{
|
|
1365
|
+
footer,
|
|
1366
|
+
showClose: false,
|
|
1367
|
+
size: "sm",
|
|
1368
|
+
testID,
|
|
1369
|
+
title,
|
|
1370
|
+
visible,
|
|
1371
|
+
onClose: onCancel,
|
|
1372
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles12.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1373
|
+
}
|
|
1374
|
+
);
|
|
1375
|
+
};
|
|
1376
|
+
var AccordionContext = React10.createContext(null);
|
|
1141
1377
|
function useAccordionContext() {
|
|
1142
|
-
const value =
|
|
1378
|
+
const value = React10.useContext(AccordionContext);
|
|
1143
1379
|
if (value === null) {
|
|
1144
1380
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1145
1381
|
}
|
|
@@ -1166,14 +1402,14 @@ function animateNextLayout() {
|
|
|
1166
1402
|
}
|
|
1167
1403
|
}
|
|
1168
1404
|
var BOXED_GAP = 12;
|
|
1169
|
-
var
|
|
1405
|
+
var styles13 = reactNative.StyleSheet.create({
|
|
1170
1406
|
container: { alignSelf: "stretch" },
|
|
1171
1407
|
boxed: { gap: BOXED_GAP }
|
|
1172
1408
|
});
|
|
1173
1409
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1174
1410
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1175
|
-
|
|
1176
|
-
if (!
|
|
1411
|
+
React10__default.default.Children.forEach(children, (child) => {
|
|
1412
|
+
if (!React10__default.default.isValidElement(child)) return;
|
|
1177
1413
|
const props = child.props;
|
|
1178
1414
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1179
1415
|
ids.add(props.id);
|
|
@@ -1196,14 +1432,14 @@ var Accordion = ({
|
|
|
1196
1432
|
style
|
|
1197
1433
|
}) => {
|
|
1198
1434
|
const isControlled = openIds !== void 0;
|
|
1199
|
-
const [internalOpen, setInternalOpen] =
|
|
1435
|
+
const [internalOpen, setInternalOpen] = React10.useState(
|
|
1200
1436
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
1201
1437
|
);
|
|
1202
|
-
const openSet =
|
|
1438
|
+
const openSet = React10.useMemo(
|
|
1203
1439
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1204
1440
|
[isControlled, openIds, internalOpen]
|
|
1205
1441
|
);
|
|
1206
|
-
const toggle =
|
|
1442
|
+
const toggle = React10.useCallback(
|
|
1207
1443
|
(id) => {
|
|
1208
1444
|
animateNextLayout();
|
|
1209
1445
|
const next = new Set(openSet);
|
|
@@ -1219,12 +1455,12 @@ var Accordion = ({
|
|
|
1219
1455
|
},
|
|
1220
1456
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
1221
1457
|
);
|
|
1222
|
-
const contextValue =
|
|
1458
|
+
const contextValue = React10.useMemo(
|
|
1223
1459
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
1224
1460
|
[openSet, toggle, allowMultiple, variant]
|
|
1225
1461
|
);
|
|
1226
|
-
const containerStyle =
|
|
1227
|
-
const base = variant === "boxed" ? [
|
|
1462
|
+
const containerStyle = React10.useMemo(() => {
|
|
1463
|
+
const base = variant === "boxed" ? [styles13.container, styles13.boxed] : [styles13.container];
|
|
1228
1464
|
if (style === void 0) return base;
|
|
1229
1465
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
1230
1466
|
}, [style, variant]);
|
|
@@ -1234,7 +1470,7 @@ var HEADER_PADDING_H = 16;
|
|
|
1234
1470
|
var HEADER_PADDING_V = 12;
|
|
1235
1471
|
var BODY_PADDING_H = 16;
|
|
1236
1472
|
var BODY_PADDING_V = 12;
|
|
1237
|
-
var
|
|
1473
|
+
var HEADER_GAP2 = 8;
|
|
1238
1474
|
var TITLE_FONT_SIZE2 = 15;
|
|
1239
1475
|
var TITLE_FONT_WEIGHT = "600";
|
|
1240
1476
|
var CHEVRON_SIZE = 18;
|
|
@@ -1256,7 +1492,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
1256
1492
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
1257
1493
|
var BOX_MARKER_GAP = 6;
|
|
1258
1494
|
var BOX_MARKER = "\u25B8";
|
|
1259
|
-
var
|
|
1495
|
+
var styles14 = reactNative.StyleSheet.create({
|
|
1260
1496
|
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
1261
1497
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
1262
1498
|
header: {
|
|
@@ -1269,10 +1505,10 @@ var styles12 = reactNative.StyleSheet.create({
|
|
|
1269
1505
|
boxHeader: { paddingHorizontal: 0, paddingVertical: BOX_HEADER_PADDING_V },
|
|
1270
1506
|
headerLeft: { flexShrink: 1, flexGrow: 1 },
|
|
1271
1507
|
headerLeftRow: { flexDirection: "row", alignItems: "center" },
|
|
1272
|
-
headerRight: { flexDirection: "row", alignItems: "center", marginLeft:
|
|
1508
|
+
headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP2 },
|
|
1273
1509
|
title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
|
|
1274
1510
|
boxTitle: { fontSize: BOX_TITLE_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1275
|
-
chevron: { marginLeft:
|
|
1511
|
+
chevron: { marginLeft: HEADER_GAP2 },
|
|
1276
1512
|
marker: { marginRight: BOX_MARKER_GAP },
|
|
1277
1513
|
markerText: { fontSize: BOX_MARKER_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1278
1514
|
body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V },
|
|
@@ -1300,9 +1536,9 @@ var AccordionItem = ({
|
|
|
1300
1536
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
1301
1537
|
const bodyTestID = `${headerTestID}-body`;
|
|
1302
1538
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1303
|
-
const [rotation] =
|
|
1539
|
+
const [rotation] = React10.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1304
1540
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1305
|
-
|
|
1541
|
+
React10.useEffect(() => {
|
|
1306
1542
|
reactNative.Animated.timing(rotation, {
|
|
1307
1543
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1308
1544
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -1314,10 +1550,10 @@ var AccordionItem = ({
|
|
|
1314
1550
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1315
1551
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
1316
1552
|
});
|
|
1317
|
-
const handlePress =
|
|
1553
|
+
const handlePress = React10.useCallback(() => {
|
|
1318
1554
|
if (!disabled) toggle(id);
|
|
1319
1555
|
}, [disabled, id, toggle]);
|
|
1320
|
-
const handleKeyDown2 =
|
|
1556
|
+
const handleKeyDown2 = React10.useCallback(
|
|
1321
1557
|
(event) => {
|
|
1322
1558
|
if (disabled) return;
|
|
1323
1559
|
const key = event.key ?? "";
|
|
@@ -1329,20 +1565,20 @@ var AccordionItem = ({
|
|
|
1329
1565
|
[disabled, id, toggle]
|
|
1330
1566
|
);
|
|
1331
1567
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1332
|
-
const itemStyle =
|
|
1333
|
-
() => boxed ? [
|
|
1568
|
+
const itemStyle = React10.useMemo(
|
|
1569
|
+
() => boxed ? [styles14.boxItem, { borderColor: colors.border }] : [styles14.item, { borderTopColor: colors.border }],
|
|
1334
1570
|
[boxed, colors.border]
|
|
1335
1571
|
);
|
|
1336
|
-
const headerStyle =
|
|
1572
|
+
const headerStyle = React10.useMemo(
|
|
1337
1573
|
() => [
|
|
1338
|
-
|
|
1339
|
-
...boxed ? [
|
|
1574
|
+
styles14.header,
|
|
1575
|
+
...boxed ? [styles14.boxHeader] : [],
|
|
1340
1576
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
1341
1577
|
],
|
|
1342
1578
|
[boxed, disabled]
|
|
1343
1579
|
);
|
|
1344
1580
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
1345
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ?
|
|
1581
|
+
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ? styles14.boxTitle : styles14.title, { color: boxed ? colors.textSecondary : colors.text }], children: title }) : title;
|
|
1346
1582
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
1347
1583
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1348
1584
|
reactNative.Pressable,
|
|
@@ -1359,7 +1595,7 @@ var AccordionItem = ({
|
|
|
1359
1595
|
onPress: handlePress,
|
|
1360
1596
|
...keyboardProps,
|
|
1361
1597
|
children: [
|
|
1362
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1598
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles14.headerLeft, boxed ? styles14.headerLeftRow : null], children: [
|
|
1363
1599
|
boxed ? (
|
|
1364
1600
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
1365
1601
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1368,15 +1604,15 @@ var AccordionItem = ({
|
|
|
1368
1604
|
accessibilityElementsHidden: true,
|
|
1369
1605
|
"aria-hidden": true,
|
|
1370
1606
|
importantForAccessibility: "no-hide-descendants",
|
|
1371
|
-
style: [
|
|
1607
|
+
style: [styles14.marker, { transform: [{ rotate }] }],
|
|
1372
1608
|
testID: chevronTestID,
|
|
1373
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1609
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
1374
1610
|
}
|
|
1375
1611
|
)
|
|
1376
1612
|
) : null,
|
|
1377
1613
|
titleNode
|
|
1378
1614
|
] }),
|
|
1379
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1615
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles14.headerRight, children: [
|
|
1380
1616
|
right,
|
|
1381
1617
|
boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1382
1618
|
reactNative.Animated.View,
|
|
@@ -1384,7 +1620,7 @@ var AccordionItem = ({
|
|
|
1384
1620
|
accessibilityElementsHidden: true,
|
|
1385
1621
|
"aria-hidden": true,
|
|
1386
1622
|
importantForAccessibility: "no-hide-descendants",
|
|
1387
|
-
style: [
|
|
1623
|
+
style: [styles14.chevron, { transform: [{ rotate }] }],
|
|
1388
1624
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
1389
1625
|
}
|
|
1390
1626
|
)
|
|
@@ -1398,7 +1634,7 @@ var AccordionItem = ({
|
|
|
1398
1634
|
accessibilityLabel: resolvedLabel,
|
|
1399
1635
|
nativeID: bodyTestID,
|
|
1400
1636
|
role: ROLE_REGION,
|
|
1401
|
-
style: boxed ?
|
|
1637
|
+
style: boxed ? styles14.boxBody : styles14.body,
|
|
1402
1638
|
testID: bodyTestID,
|
|
1403
1639
|
children
|
|
1404
1640
|
}
|
|
@@ -1436,14 +1672,14 @@ function measureParentInnerWidth(node) {
|
|
|
1436
1672
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
1437
1673
|
}
|
|
1438
1674
|
function useAvailableWidth() {
|
|
1439
|
-
const [width, setWidth] =
|
|
1440
|
-
const nodeRef =
|
|
1441
|
-
const measureRef =
|
|
1675
|
+
const [width, setWidth] = React10.useState(UNMEASURED);
|
|
1676
|
+
const nodeRef = React10.useRef(null);
|
|
1677
|
+
const measureRef = React10.useCallback((node) => {
|
|
1442
1678
|
if (!IS_WEB3) return;
|
|
1443
1679
|
nodeRef.current = node;
|
|
1444
1680
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1445
1681
|
}, []);
|
|
1446
|
-
|
|
1682
|
+
React10.useEffect(() => {
|
|
1447
1683
|
if (!IS_WEB3) return void 0;
|
|
1448
1684
|
const remeasure = () => {
|
|
1449
1685
|
const node = nodeRef.current;
|
|
@@ -1452,7 +1688,7 @@ function useAvailableWidth() {
|
|
|
1452
1688
|
window.addEventListener("resize", remeasure);
|
|
1453
1689
|
return () => window.removeEventListener("resize", remeasure);
|
|
1454
1690
|
}, []);
|
|
1455
|
-
const onLayout =
|
|
1691
|
+
const onLayout = React10.useCallback((event) => {
|
|
1456
1692
|
if (IS_WEB3) return;
|
|
1457
1693
|
setWidth(event.nativeEvent.layout.width);
|
|
1458
1694
|
}, []);
|
|
@@ -1461,7 +1697,7 @@ function useAvailableWidth() {
|
|
|
1461
1697
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
1462
1698
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
1463
1699
|
var UNMEASURED2 = 0;
|
|
1464
|
-
var
|
|
1700
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1465
1701
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
1466
1702
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
1467
1703
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -1481,8 +1717,8 @@ var TruncatedText = ({
|
|
|
1481
1717
|
accessibilityHint
|
|
1482
1718
|
}) => {
|
|
1483
1719
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
1484
|
-
const hostRef =
|
|
1485
|
-
const attachRef =
|
|
1720
|
+
const hostRef = React10.useRef(null);
|
|
1721
|
+
const attachRef = React10.useCallback(
|
|
1486
1722
|
(node) => {
|
|
1487
1723
|
hostRef.current = node;
|
|
1488
1724
|
measureRef(node);
|
|
@@ -1491,12 +1727,12 @@ var TruncatedText = ({
|
|
|
1491
1727
|
},
|
|
1492
1728
|
[value, measureRef]
|
|
1493
1729
|
);
|
|
1494
|
-
const flatStyle =
|
|
1495
|
-
() => reactNative.StyleSheet.flatten([
|
|
1730
|
+
const flatStyle = React10.useMemo(
|
|
1731
|
+
() => reactNative.StyleSheet.flatten([styles15.base, style]),
|
|
1496
1732
|
[style]
|
|
1497
1733
|
);
|
|
1498
1734
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
1499
|
-
const display =
|
|
1735
|
+
const display = React10.useMemo(() => {
|
|
1500
1736
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
1501
1737
|
const budget = charBudget(width, fontSize);
|
|
1502
1738
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -1507,7 +1743,7 @@ var TruncatedText = ({
|
|
|
1507
1743
|
ref: attachRef,
|
|
1508
1744
|
onLayout,
|
|
1509
1745
|
numberOfLines: 1,
|
|
1510
|
-
style: [
|
|
1746
|
+
style: [styles15.base, styles15.fill, style],
|
|
1511
1747
|
testID,
|
|
1512
1748
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
1513
1749
|
accessibilityLabel,
|
|
@@ -1578,17 +1814,17 @@ async function copyText(value, writer) {
|
|
|
1578
1814
|
// src/CopyableId/useCopyToClipboard.ts
|
|
1579
1815
|
var COPY_FEEDBACK_MS = 2e3;
|
|
1580
1816
|
function useCopyToClipboard(value, writer) {
|
|
1581
|
-
const [status, setStatus] =
|
|
1582
|
-
const timerRef =
|
|
1583
|
-
const mountedRef =
|
|
1584
|
-
|
|
1817
|
+
const [status, setStatus] = React10.useState("idle" /* Idle */);
|
|
1818
|
+
const timerRef = React10.useRef(null);
|
|
1819
|
+
const mountedRef = React10.useRef(true);
|
|
1820
|
+
React10.useEffect(() => {
|
|
1585
1821
|
mountedRef.current = true;
|
|
1586
1822
|
return () => {
|
|
1587
1823
|
mountedRef.current = false;
|
|
1588
1824
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1589
1825
|
};
|
|
1590
1826
|
}, []);
|
|
1591
|
-
const copy =
|
|
1827
|
+
const copy = React10.useCallback(() => {
|
|
1592
1828
|
void (async () => {
|
|
1593
1829
|
const ok = await copyText(value, writer);
|
|
1594
1830
|
if (!mountedRef.current) return;
|
|
@@ -1610,7 +1846,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
1610
1846
|
var ACTION_PADDING_H = 6;
|
|
1611
1847
|
var ACTION_PADDING_V = 2;
|
|
1612
1848
|
var ACTION_RADIUS = 6;
|
|
1613
|
-
var
|
|
1849
|
+
var styles16 = reactNative.StyleSheet.create({
|
|
1614
1850
|
cell: { gap: CELL_GAP },
|
|
1615
1851
|
label: {
|
|
1616
1852
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -1646,7 +1882,7 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1646
1882
|
var TONE_STEP = "500";
|
|
1647
1883
|
function useActionState(status) {
|
|
1648
1884
|
const { theme } = uiFeedback.useUi();
|
|
1649
|
-
return
|
|
1885
|
+
return React10.useMemo(() => {
|
|
1650
1886
|
const primary = theme.palette.primary[TONE_STEP];
|
|
1651
1887
|
if (status === "copied" /* Copied */) {
|
|
1652
1888
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
@@ -1669,14 +1905,14 @@ var CopyableId = ({
|
|
|
1669
1905
|
const { colors } = theme;
|
|
1670
1906
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
1671
1907
|
const action = useActionState(status);
|
|
1672
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1673
|
-
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1674
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1675
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
1908
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles16.cell, style], testID, children: [
|
|
1909
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.label, { color: colors.textSecondary }], children: label }),
|
|
1910
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.row, children: [
|
|
1911
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles16.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1676
1912
|
TruncatedText,
|
|
1677
1913
|
{
|
|
1678
1914
|
value,
|
|
1679
|
-
style: [
|
|
1915
|
+
style: [styles16.value, { color: colors.text }],
|
|
1680
1916
|
testID: `${testID}-value`,
|
|
1681
1917
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
1682
1918
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -1690,7 +1926,7 @@ var CopyableId = ({
|
|
|
1690
1926
|
accessibilityLabel: t(action.key),
|
|
1691
1927
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
1692
1928
|
testID: `${testID}-copy`,
|
|
1693
|
-
style: [
|
|
1929
|
+
style: [styles16.action, { color: action.color }],
|
|
1694
1930
|
children: t(action.key)
|
|
1695
1931
|
}
|
|
1696
1932
|
)
|
|
@@ -1701,6 +1937,7 @@ var CopyableId = ({
|
|
|
1701
1937
|
exports.Accordion = Accordion;
|
|
1702
1938
|
exports.AccordionItem = AccordionItem;
|
|
1703
1939
|
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
1940
|
+
exports.ConfirmDialog = ConfirmDialog;
|
|
1704
1941
|
exports.CopyStatus = CopyStatus;
|
|
1705
1942
|
exports.CopyableId = CopyableId;
|
|
1706
1943
|
exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
|
|
@@ -1709,12 +1946,14 @@ exports.ELLIPSIS = ELLIPSIS;
|
|
|
1709
1946
|
exports.Heading = Heading;
|
|
1710
1947
|
exports.LAYOUT_I18N = LAYOUT_I18N;
|
|
1711
1948
|
exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
1949
|
+
exports.Modal = Modal3;
|
|
1712
1950
|
exports.ModalDropdown = ModalDropdown;
|
|
1713
1951
|
exports.ModalShell = ModalShell;
|
|
1714
1952
|
exports.Section = Section;
|
|
1715
1953
|
exports.SegmentedControl = SegmentedControl;
|
|
1716
1954
|
exports.StatusBadge = StatusBadge;
|
|
1717
1955
|
exports.Tabs = Tabs;
|
|
1956
|
+
exports.TabsCollapsedTrigger = TabsCollapsedTrigger;
|
|
1718
1957
|
exports.TruncatedText = TruncatedText;
|
|
1719
1958
|
exports.UpgradePrompt = UpgradePrompt;
|
|
1720
1959
|
exports.copyText = copyText;
|