@dloizides/ui-layout 1.21.0 → 1.22.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/CHANGELOG.md +41 -0
- package/README.md +35 -0
- package/dist/index.d.mts +113 -1
- package/dist/index.d.ts +113 -1
- package/dist/index.js +302 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +242 -35
- 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
|
{
|
|
@@ -280,8 +293,8 @@ function handleKeyDown(domNode, event) {
|
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
295
|
function useFocusTrap(containerRef, enabled) {
|
|
283
|
-
const previousFocusRef =
|
|
284
|
-
|
|
296
|
+
const previousFocusRef = React10.useRef(null);
|
|
297
|
+
React10.useEffect(() => {
|
|
285
298
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
286
299
|
const domNode = containerRef.current;
|
|
287
300
|
if (!domNode) return;
|
|
@@ -366,7 +379,7 @@ var OptionRow = ({
|
|
|
366
379
|
}) => {
|
|
367
380
|
const { theme, t } = uiFeedback.useUi();
|
|
368
381
|
const { colors } = theme;
|
|
369
|
-
const handlePress =
|
|
382
|
+
const handlePress = React10.useCallback(() => {
|
|
370
383
|
onSelect();
|
|
371
384
|
}, [onSelect]);
|
|
372
385
|
const isActive = isSelected || isHighlighted;
|
|
@@ -435,8 +448,8 @@ function observeLayout(node, onChange) {
|
|
|
435
448
|
return observer;
|
|
436
449
|
}
|
|
437
450
|
function useAnchorTracking(containerRef, onOutOfView) {
|
|
438
|
-
const [rect, setRect] =
|
|
439
|
-
|
|
451
|
+
const [rect, setRect] = React10.useState(() => readAnchorRect(containerRef));
|
|
452
|
+
React10.useLayoutEffect(() => {
|
|
440
453
|
if (!IS_WEB) return void 0;
|
|
441
454
|
let frame = null;
|
|
442
455
|
let isDisposed = false;
|
|
@@ -515,7 +528,7 @@ function buildKeyHandler(params) {
|
|
|
515
528
|
}
|
|
516
529
|
function useMenuKeyboard(params) {
|
|
517
530
|
const { containerRef, menuRef, enabled, onClose } = params;
|
|
518
|
-
|
|
531
|
+
React10.useEffect(() => {
|
|
519
532
|
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
520
533
|
const onKeyDown = buildKeyHandler(params);
|
|
521
534
|
const onMouseDown = (event) => {
|
|
@@ -566,21 +579,21 @@ var InlineMenu = ({
|
|
|
566
579
|
}) => {
|
|
567
580
|
const { theme } = uiFeedback.useUi();
|
|
568
581
|
const { colors } = theme;
|
|
569
|
-
const menuRef =
|
|
582
|
+
const menuRef = React10.useRef(null);
|
|
570
583
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
571
|
-
const selectedIndex =
|
|
584
|
+
const selectedIndex = React10.useMemo(
|
|
572
585
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
573
586
|
[options, value]
|
|
574
587
|
);
|
|
575
|
-
const [highlightedIndex, setHighlightedIndex] =
|
|
576
|
-
const selectAt =
|
|
588
|
+
const [highlightedIndex, setHighlightedIndex] = React10.useState(() => selectedIndex);
|
|
589
|
+
const selectAt = React10.useCallback(
|
|
577
590
|
(index) => {
|
|
578
591
|
const option = options[index];
|
|
579
592
|
if (option !== void 0) onSelect(option.value);
|
|
580
593
|
},
|
|
581
594
|
[options, onSelect]
|
|
582
595
|
);
|
|
583
|
-
const selectHighlighted =
|
|
596
|
+
const selectHighlighted = React10.useCallback(
|
|
584
597
|
() => {
|
|
585
598
|
selectAt(highlightedIndex);
|
|
586
599
|
},
|
|
@@ -595,7 +608,7 @@ var InlineMenu = ({
|
|
|
595
608
|
onSelectHighlighted: selectHighlighted,
|
|
596
609
|
onClose
|
|
597
610
|
});
|
|
598
|
-
const popoverStyle =
|
|
611
|
+
const popoverStyle = React10.useMemo(() => {
|
|
599
612
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
600
613
|
if (IS_WEB2)
|
|
601
614
|
return [
|
|
@@ -661,7 +674,12 @@ var styles7 = reactNative.StyleSheet.create({
|
|
|
661
674
|
borderWidth: BORDER_WIDTH4,
|
|
662
675
|
borderRadius: BORDER_RADIUS3,
|
|
663
676
|
paddingHorizontal: CONTAINER_PADDING_H,
|
|
664
|
-
paddingVertical: CONTAINER_PADDING_V
|
|
677
|
+
paddingVertical: CONTAINER_PADDING_V,
|
|
678
|
+
// Match the shared control height used by @dloizides/ui-forms inputs (same MIN_TOUCH_TARGET_PX
|
|
679
|
+
// floor from @dloizides/a11y), so a select trigger and a text/typeahead field sitting side by
|
|
680
|
+
// side in a filter bar are exactly the same height. Centre the label within that floor.
|
|
681
|
+
minHeight: a11y.MIN_TOUCH_TARGET_PX,
|
|
682
|
+
justifyContent: "center"
|
|
665
683
|
},
|
|
666
684
|
// Caret variant: a row with the label leading and the caret pinned to the trailing edge, at a
|
|
667
685
|
// phone-friendly minimum height. Only applied when `showCaret` is set, so field dropdowns are
|
|
@@ -718,7 +736,7 @@ var ModalDropdown = ({
|
|
|
718
736
|
const { colors } = theme;
|
|
719
737
|
const resolvedVariant = useResolvedDropdownVariant(variant);
|
|
720
738
|
const isMenu = resolvedVariant === "menu" /* Menu */;
|
|
721
|
-
const [isOpen, setIsOpen] =
|
|
739
|
+
const [isOpen, setIsOpen] = React10.useState(false);
|
|
722
740
|
const { a11yProps, hintNode } = a11y.useA11y({
|
|
723
741
|
label: accessibilityLabel,
|
|
724
742
|
hint: accessibilityHint,
|
|
@@ -726,20 +744,20 @@ var ModalDropdown = ({
|
|
|
726
744
|
state: { expanded: isOpen },
|
|
727
745
|
testID
|
|
728
746
|
});
|
|
729
|
-
const anchorRef =
|
|
730
|
-
const dialogRef =
|
|
747
|
+
const anchorRef = React10.useRef(null);
|
|
748
|
+
const dialogRef = React10.useRef(null);
|
|
731
749
|
useFocusTrap(dialogRef, isOpen && !isMenu);
|
|
732
|
-
const selectedLabel =
|
|
750
|
+
const selectedLabel = React10.useMemo(() => {
|
|
733
751
|
const found = options.find((opt) => opt.value === value);
|
|
734
752
|
return found?.label ?? t(LAYOUT_I18N.selectPlaceholder);
|
|
735
753
|
}, [options, value, t]);
|
|
736
|
-
const handleToggle =
|
|
754
|
+
const handleToggle = React10.useCallback(() => {
|
|
737
755
|
setIsOpen((prev) => !prev);
|
|
738
756
|
}, []);
|
|
739
|
-
const handleClose =
|
|
757
|
+
const handleClose = React10.useCallback(() => {
|
|
740
758
|
setIsOpen(false);
|
|
741
759
|
}, []);
|
|
742
|
-
const handleSelect =
|
|
760
|
+
const handleSelect = React10.useCallback(
|
|
743
761
|
(optionValue) => {
|
|
744
762
|
onChange(optionValue);
|
|
745
763
|
setIsOpen(false);
|
|
@@ -748,7 +766,7 @@ var ModalDropdown = ({
|
|
|
748
766
|
);
|
|
749
767
|
const isHamburger = showHamburger;
|
|
750
768
|
const isCaret = showCaret && !isHamburger;
|
|
751
|
-
const containerStyle =
|
|
769
|
+
const containerStyle = React10.useMemo(
|
|
752
770
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
753
771
|
styles7.container,
|
|
754
772
|
isHamburger ? styles7.containerHamburger : isCaret ? styles7.containerMenu : null,
|
|
@@ -756,30 +774,30 @@ var ModalDropdown = ({
|
|
|
756
774
|
],
|
|
757
775
|
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
758
776
|
);
|
|
759
|
-
const hamburgerStyle =
|
|
777
|
+
const hamburgerStyle = React10.useMemo(
|
|
760
778
|
() => [styles7.hamburger, { color: colors.textSecondary }],
|
|
761
779
|
[colors.textSecondary]
|
|
762
780
|
);
|
|
763
|
-
const caretStyle =
|
|
781
|
+
const caretStyle = React10.useMemo(
|
|
764
782
|
() => [
|
|
765
783
|
styles7.caret,
|
|
766
784
|
{ color: colors.textSecondary, transform: [{ rotate: isOpen ? CARET_OPEN_ROTATION : CARET_CLOSED_ROTATION }] }
|
|
767
785
|
],
|
|
768
786
|
[colors.textSecondary, isOpen]
|
|
769
787
|
);
|
|
770
|
-
const optionTestIDFor =
|
|
788
|
+
const optionTestIDFor = React10.useCallback(
|
|
771
789
|
(optionValue) => optionTestID !== void 0 ? optionTestID(optionValue) : `${testID}-option-${String(optionValue)}`,
|
|
772
790
|
[optionTestID, testID]
|
|
773
791
|
);
|
|
774
|
-
const anchorStyle =
|
|
792
|
+
const anchorStyle = React10.useMemo(
|
|
775
793
|
() => [styles7.anchor, buildAnchorStackStyle(isMenu && isOpen)],
|
|
776
794
|
[isMenu, isOpen]
|
|
777
795
|
);
|
|
778
|
-
const modalContentStyle =
|
|
796
|
+
const modalContentStyle = React10.useMemo(
|
|
779
797
|
() => [styles7.modalContent, { backgroundColor: colors.surface }],
|
|
780
798
|
[colors.surface]
|
|
781
799
|
);
|
|
782
|
-
const renderModalOption =
|
|
800
|
+
const renderModalOption = React10.useCallback(
|
|
783
801
|
({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
784
802
|
OptionRow,
|
|
785
803
|
{
|
|
@@ -791,7 +809,7 @@ var ModalDropdown = ({
|
|
|
791
809
|
),
|
|
792
810
|
[handleSelect, optionTestIDFor, value]
|
|
793
811
|
);
|
|
794
|
-
const keyExtractor =
|
|
812
|
+
const keyExtractor = React10.useCallback((item) => String(item.value), []);
|
|
795
813
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
|
|
796
814
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
797
815
|
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
@@ -855,11 +873,11 @@ var TabsMenu = ({
|
|
|
855
873
|
collapsedTrigger = "caret" /* Caret */
|
|
856
874
|
}) => {
|
|
857
875
|
const { t } = uiFeedback.useUi();
|
|
858
|
-
const options =
|
|
876
|
+
const options = React10.useMemo(
|
|
859
877
|
() => tabs.map((tab) => ({ label: tab.label, value: tab.key })),
|
|
860
878
|
[tabs]
|
|
861
879
|
);
|
|
862
|
-
const optionTestID =
|
|
880
|
+
const optionTestID = React10.useCallback(
|
|
863
881
|
(key) => {
|
|
864
882
|
const found = tabs.find((tab) => tab.key === key);
|
|
865
883
|
return found?.testID ?? `${idPrefix}-tab-${key}`;
|
|
@@ -1128,7 +1146,7 @@ var ModalShell = ({
|
|
|
1128
1146
|
showClose = true
|
|
1129
1147
|
}) => {
|
|
1130
1148
|
const { theme, t } = uiFeedback.useUi();
|
|
1131
|
-
const containerStyle =
|
|
1149
|
+
const containerStyle = React10__default.default.useMemo(
|
|
1132
1150
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1133
1151
|
[theme.colors.background, contentStyle]
|
|
1134
1152
|
);
|
|
@@ -1171,9 +1189,198 @@ var ModalShell = ({
|
|
|
1171
1189
|
}
|
|
1172
1190
|
);
|
|
1173
1191
|
};
|
|
1174
|
-
|
|
1192
|
+
function useEscapeKey(enabled, onClose) {
|
|
1193
|
+
React10.useEffect(() => {
|
|
1194
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1195
|
+
const onKeyDown = (event) => {
|
|
1196
|
+
if (event.key === "Escape") onClose();
|
|
1197
|
+
};
|
|
1198
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1199
|
+
return () => {
|
|
1200
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1201
|
+
};
|
|
1202
|
+
}, [enabled, onClose]);
|
|
1203
|
+
}
|
|
1204
|
+
function useScrollLock(enabled) {
|
|
1205
|
+
React10.useEffect(() => {
|
|
1206
|
+
if (reactNative.Platform.OS !== "web" || !enabled) return;
|
|
1207
|
+
const { body } = document;
|
|
1208
|
+
const previousOverflow = body.style.overflow;
|
|
1209
|
+
body.style.overflow = "hidden";
|
|
1210
|
+
return () => {
|
|
1211
|
+
body.style.overflow = previousOverflow;
|
|
1212
|
+
};
|
|
1213
|
+
}, [enabled]);
|
|
1214
|
+
}
|
|
1215
|
+
var OVERLAY_PADDING = 16;
|
|
1216
|
+
var DIALOG_RADIUS = 12;
|
|
1217
|
+
var DIALOG_PADDING = 16;
|
|
1218
|
+
var HEADER_GAP = 12;
|
|
1219
|
+
var FOOTER_MARGIN = 16;
|
|
1220
|
+
var HEADER_MARGIN = 12;
|
|
1221
|
+
var DIALOG_MAX_HEIGHT = "90%";
|
|
1222
|
+
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640 };
|
|
1223
|
+
var styles11 = reactNative.StyleSheet.create({
|
|
1224
|
+
overlay: {
|
|
1225
|
+
flex: 1,
|
|
1226
|
+
justifyContent: "center",
|
|
1227
|
+
alignItems: "center",
|
|
1228
|
+
padding: OVERLAY_PADDING,
|
|
1229
|
+
backgroundColor: uiFeedback.MODAL_OVERLAY_COLOR
|
|
1230
|
+
},
|
|
1231
|
+
dialog: {
|
|
1232
|
+
width: "100%",
|
|
1233
|
+
borderRadius: DIALOG_RADIUS,
|
|
1234
|
+
padding: DIALOG_PADDING,
|
|
1235
|
+
maxHeight: DIALOG_MAX_HEIGHT
|
|
1236
|
+
},
|
|
1237
|
+
headerRow: {
|
|
1238
|
+
flexDirection: "row",
|
|
1239
|
+
alignItems: "flex-start",
|
|
1240
|
+
justifyContent: "space-between",
|
|
1241
|
+
columnGap: HEADER_GAP,
|
|
1242
|
+
marginBottom: HEADER_MARGIN
|
|
1243
|
+
},
|
|
1244
|
+
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
1245
|
+
titleWrap: { flex: 1 },
|
|
1246
|
+
footer: { marginTop: FOOTER_MARGIN }
|
|
1247
|
+
});
|
|
1248
|
+
var Modal3 = ({
|
|
1249
|
+
visible,
|
|
1250
|
+
onClose,
|
|
1251
|
+
title,
|
|
1252
|
+
children,
|
|
1253
|
+
footer,
|
|
1254
|
+
size = "md",
|
|
1255
|
+
showClose = true,
|
|
1256
|
+
testID = LAYOUT_TEST_IDS.modal,
|
|
1257
|
+
accessibilityLabel
|
|
1258
|
+
}) => {
|
|
1259
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1260
|
+
const dialogRef = React10.useRef(null);
|
|
1261
|
+
useFocusTrap(dialogRef, visible);
|
|
1262
|
+
useEscapeKey(visible, onClose);
|
|
1263
|
+
useScrollLock(visible);
|
|
1264
|
+
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
1265
|
+
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
1266
|
+
const dialogStyle = React10.useMemo(
|
|
1267
|
+
() => [styles11.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
1268
|
+
[theme.colors.surface, size]
|
|
1269
|
+
);
|
|
1270
|
+
const hasHeader = title !== void 0 || showClose;
|
|
1271
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { transparent: true, animationType: "fade", visible, onRequestClose: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.overlay, children: [
|
|
1272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1273
|
+
reactNative.TouchableOpacity,
|
|
1274
|
+
{
|
|
1275
|
+
accessible: true,
|
|
1276
|
+
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
1277
|
+
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
1278
|
+
accessibilityRole: "button",
|
|
1279
|
+
activeOpacity: 1,
|
|
1280
|
+
style: reactNative.StyleSheet.absoluteFill,
|
|
1281
|
+
testID: `${testID}-backdrop`,
|
|
1282
|
+
onPress: onClose
|
|
1283
|
+
}
|
|
1284
|
+
),
|
|
1285
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1286
|
+
reactNative.View,
|
|
1287
|
+
{
|
|
1288
|
+
ref: dialogRef,
|
|
1289
|
+
accessibilityViewIsModal: true,
|
|
1290
|
+
"aria-label": accessibleName,
|
|
1291
|
+
role: "dialog",
|
|
1292
|
+
style: dialogStyle,
|
|
1293
|
+
testID,
|
|
1294
|
+
children: [
|
|
1295
|
+
hasHeader ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles11.headerRow, children: [
|
|
1296
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Heading, { children: title }) : null }),
|
|
1297
|
+
showClose ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1298
|
+
uiButtons.IconButton,
|
|
1299
|
+
{
|
|
1300
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1301
|
+
accessibilityLabel: closeLabel,
|
|
1302
|
+
appearance: "ghost",
|
|
1303
|
+
renderIcon: (color, iconSize) => /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color, name: "close", size: iconSize }),
|
|
1304
|
+
size: "md",
|
|
1305
|
+
testID: `${testID}-close`,
|
|
1306
|
+
tooltip: closeLabel,
|
|
1307
|
+
variant: "ghost",
|
|
1308
|
+
onPress: onClose
|
|
1309
|
+
}
|
|
1310
|
+
) : null
|
|
1311
|
+
] }) : null,
|
|
1312
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { children }),
|
|
1313
|
+
footer !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles11.footer, children: footer }) : null
|
|
1314
|
+
]
|
|
1315
|
+
}
|
|
1316
|
+
)
|
|
1317
|
+
] }) });
|
|
1318
|
+
};
|
|
1319
|
+
var MESSAGE_FONT_SIZE2 = 14;
|
|
1320
|
+
var MESSAGE_LINE_HEIGHT = 20;
|
|
1321
|
+
var BUTTON_GAP = 12;
|
|
1322
|
+
var styles12 = reactNative.StyleSheet.create({
|
|
1323
|
+
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1324
|
+
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1325
|
+
});
|
|
1326
|
+
var ConfirmDialog = ({
|
|
1327
|
+
visible,
|
|
1328
|
+
title,
|
|
1329
|
+
message,
|
|
1330
|
+
confirmLabel,
|
|
1331
|
+
cancelLabel,
|
|
1332
|
+
destructive = false,
|
|
1333
|
+
onConfirm,
|
|
1334
|
+
onCancel,
|
|
1335
|
+
busy = false,
|
|
1336
|
+
testID = LAYOUT_TEST_IDS.confirmDialog
|
|
1337
|
+
}) => {
|
|
1338
|
+
const { theme, t } = uiFeedback.useUi();
|
|
1339
|
+
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1340
|
+
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1341
|
+
const footer = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles12.footer, children: [
|
|
1342
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1343
|
+
uiButtons.Button,
|
|
1344
|
+
{
|
|
1345
|
+
accessibilityHint: t(LAYOUT_I18N.cancelHint),
|
|
1346
|
+
accessibilityLabel: resolvedCancel,
|
|
1347
|
+
disabled: busy,
|
|
1348
|
+
label: resolvedCancel,
|
|
1349
|
+
testID: `${testID}-cancel`,
|
|
1350
|
+
variant: "secondary",
|
|
1351
|
+
onPress: onCancel
|
|
1352
|
+
}
|
|
1353
|
+
),
|
|
1354
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1355
|
+
uiButtons.Button,
|
|
1356
|
+
{
|
|
1357
|
+
accessibilityHint: t(LAYOUT_I18N.confirmHint),
|
|
1358
|
+
accessibilityLabel: resolvedConfirm,
|
|
1359
|
+
label: resolvedConfirm,
|
|
1360
|
+
loading: busy,
|
|
1361
|
+
testID: `${testID}-confirm`,
|
|
1362
|
+
variant: destructive ? "danger" : "primary",
|
|
1363
|
+
onPress: onConfirm
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
] });
|
|
1367
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1368
|
+
Modal3,
|
|
1369
|
+
{
|
|
1370
|
+
footer,
|
|
1371
|
+
showClose: false,
|
|
1372
|
+
size: "sm",
|
|
1373
|
+
testID,
|
|
1374
|
+
title,
|
|
1375
|
+
visible,
|
|
1376
|
+
onClose: onCancel,
|
|
1377
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles12.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1378
|
+
}
|
|
1379
|
+
);
|
|
1380
|
+
};
|
|
1381
|
+
var AccordionContext = React10.createContext(null);
|
|
1175
1382
|
function useAccordionContext() {
|
|
1176
|
-
const value =
|
|
1383
|
+
const value = React10.useContext(AccordionContext);
|
|
1177
1384
|
if (value === null) {
|
|
1178
1385
|
throw new Error("AccordionItem must be rendered inside an <Accordion>.");
|
|
1179
1386
|
}
|
|
@@ -1200,14 +1407,14 @@ function animateNextLayout() {
|
|
|
1200
1407
|
}
|
|
1201
1408
|
}
|
|
1202
1409
|
var BOXED_GAP = 12;
|
|
1203
|
-
var
|
|
1410
|
+
var styles13 = reactNative.StyleSheet.create({
|
|
1204
1411
|
container: { alignSelf: "stretch" },
|
|
1205
1412
|
boxed: { gap: BOXED_GAP }
|
|
1206
1413
|
});
|
|
1207
1414
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1208
1415
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1209
|
-
|
|
1210
|
-
if (!
|
|
1416
|
+
React10__default.default.Children.forEach(children, (child) => {
|
|
1417
|
+
if (!React10__default.default.isValidElement(child)) return;
|
|
1211
1418
|
const props = child.props;
|
|
1212
1419
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1213
1420
|
ids.add(props.id);
|
|
@@ -1230,14 +1437,14 @@ var Accordion = ({
|
|
|
1230
1437
|
style
|
|
1231
1438
|
}) => {
|
|
1232
1439
|
const isControlled = openIds !== void 0;
|
|
1233
|
-
const [internalOpen, setInternalOpen] =
|
|
1440
|
+
const [internalOpen, setInternalOpen] = React10.useState(
|
|
1234
1441
|
() => computeInitialOpen(children, defaultOpenIds, allowMultiple)
|
|
1235
1442
|
);
|
|
1236
|
-
const openSet =
|
|
1443
|
+
const openSet = React10.useMemo(
|
|
1237
1444
|
() => isControlled ? new Set(openIds) : internalOpen,
|
|
1238
1445
|
[isControlled, openIds, internalOpen]
|
|
1239
1446
|
);
|
|
1240
|
-
const toggle =
|
|
1447
|
+
const toggle = React10.useCallback(
|
|
1241
1448
|
(id) => {
|
|
1242
1449
|
animateNextLayout();
|
|
1243
1450
|
const next = new Set(openSet);
|
|
@@ -1253,12 +1460,12 @@ var Accordion = ({
|
|
|
1253
1460
|
},
|
|
1254
1461
|
[allowMultiple, isControlled, onOpenChange, openSet]
|
|
1255
1462
|
);
|
|
1256
|
-
const contextValue =
|
|
1463
|
+
const contextValue = React10.useMemo(
|
|
1257
1464
|
() => ({ openIds: openSet, toggle, allowMultiple, variant }),
|
|
1258
1465
|
[openSet, toggle, allowMultiple, variant]
|
|
1259
1466
|
);
|
|
1260
|
-
const containerStyle =
|
|
1261
|
-
const base = variant === "boxed" ? [
|
|
1467
|
+
const containerStyle = React10.useMemo(() => {
|
|
1468
|
+
const base = variant === "boxed" ? [styles13.container, styles13.boxed] : [styles13.container];
|
|
1262
1469
|
if (style === void 0) return base;
|
|
1263
1470
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
1264
1471
|
}, [style, variant]);
|
|
@@ -1268,7 +1475,7 @@ var HEADER_PADDING_H = 16;
|
|
|
1268
1475
|
var HEADER_PADDING_V = 12;
|
|
1269
1476
|
var BODY_PADDING_H = 16;
|
|
1270
1477
|
var BODY_PADDING_V = 12;
|
|
1271
|
-
var
|
|
1478
|
+
var HEADER_GAP2 = 8;
|
|
1272
1479
|
var TITLE_FONT_SIZE2 = 15;
|
|
1273
1480
|
var TITLE_FONT_WEIGHT = "600";
|
|
1274
1481
|
var CHEVRON_SIZE = 18;
|
|
@@ -1290,7 +1497,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
1290
1497
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
1291
1498
|
var BOX_MARKER_GAP = 6;
|
|
1292
1499
|
var BOX_MARKER = "\u25B8";
|
|
1293
|
-
var
|
|
1500
|
+
var styles14 = reactNative.StyleSheet.create({
|
|
1294
1501
|
item: { borderTopWidth: reactNative.StyleSheet.hairlineWidth },
|
|
1295
1502
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
1296
1503
|
header: {
|
|
@@ -1303,10 +1510,10 @@ var styles12 = reactNative.StyleSheet.create({
|
|
|
1303
1510
|
boxHeader: { paddingHorizontal: 0, paddingVertical: BOX_HEADER_PADDING_V },
|
|
1304
1511
|
headerLeft: { flexShrink: 1, flexGrow: 1 },
|
|
1305
1512
|
headerLeftRow: { flexDirection: "row", alignItems: "center" },
|
|
1306
|
-
headerRight: { flexDirection: "row", alignItems: "center", marginLeft:
|
|
1513
|
+
headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP2 },
|
|
1307
1514
|
title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
|
|
1308
1515
|
boxTitle: { fontSize: BOX_TITLE_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1309
|
-
chevron: { marginLeft:
|
|
1516
|
+
chevron: { marginLeft: HEADER_GAP2 },
|
|
1310
1517
|
marker: { marginRight: BOX_MARKER_GAP },
|
|
1311
1518
|
markerText: { fontSize: BOX_MARKER_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1312
1519
|
body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V },
|
|
@@ -1334,9 +1541,9 @@ var AccordionItem = ({
|
|
|
1334
1541
|
const headerTestID = testID ?? `accordion-item-${id}`;
|
|
1335
1542
|
const bodyTestID = `${headerTestID}-body`;
|
|
1336
1543
|
const chevronTestID = `${headerTestID}-chevron`;
|
|
1337
|
-
const [rotation] =
|
|
1544
|
+
const [rotation] = React10.useState(() => new reactNative.Animated.Value(expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED));
|
|
1338
1545
|
const reducedMotion = rnWebHooks.useReducedMotion();
|
|
1339
|
-
|
|
1546
|
+
React10.useEffect(() => {
|
|
1340
1547
|
reactNative.Animated.timing(rotation, {
|
|
1341
1548
|
toValue: expanded ? ROTATE_EXPANDED : ROTATE_COLLAPSED,
|
|
1342
1549
|
duration: reducedMotion ? INSTANT_DURATION_MS : ROTATE_DURATION_MS,
|
|
@@ -1348,10 +1555,10 @@ var AccordionItem = ({
|
|
|
1348
1555
|
inputRange: [ROTATE_COLLAPSED, ROTATE_EXPANDED],
|
|
1349
1556
|
outputRange: [COLLAPSED_DEG, boxed ? BOXED_EXPANDED_DEG : PLAIN_EXPANDED_DEG]
|
|
1350
1557
|
});
|
|
1351
|
-
const handlePress =
|
|
1558
|
+
const handlePress = React10.useCallback(() => {
|
|
1352
1559
|
if (!disabled) toggle(id);
|
|
1353
1560
|
}, [disabled, id, toggle]);
|
|
1354
|
-
const handleKeyDown2 =
|
|
1561
|
+
const handleKeyDown2 = React10.useCallback(
|
|
1355
1562
|
(event) => {
|
|
1356
1563
|
if (disabled) return;
|
|
1357
1564
|
const key = event.key ?? "";
|
|
@@ -1363,20 +1570,20 @@ var AccordionItem = ({
|
|
|
1363
1570
|
[disabled, id, toggle]
|
|
1364
1571
|
);
|
|
1365
1572
|
const keyboardProps = reactNative.Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1366
|
-
const itemStyle =
|
|
1367
|
-
() => boxed ? [
|
|
1573
|
+
const itemStyle = React10.useMemo(
|
|
1574
|
+
() => boxed ? [styles14.boxItem, { borderColor: colors.border }] : [styles14.item, { borderTopColor: colors.border }],
|
|
1368
1575
|
[boxed, colors.border]
|
|
1369
1576
|
);
|
|
1370
|
-
const headerStyle =
|
|
1577
|
+
const headerStyle = React10.useMemo(
|
|
1371
1578
|
() => [
|
|
1372
|
-
|
|
1373
|
-
...boxed ? [
|
|
1579
|
+
styles14.header,
|
|
1580
|
+
...boxed ? [styles14.boxHeader] : [],
|
|
1374
1581
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
1375
1582
|
],
|
|
1376
1583
|
[boxed, disabled]
|
|
1377
1584
|
);
|
|
1378
1585
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
1379
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [boxed ?
|
|
1586
|
+
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;
|
|
1380
1587
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: itemStyle, children: [
|
|
1381
1588
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1382
1589
|
reactNative.Pressable,
|
|
@@ -1393,7 +1600,7 @@ var AccordionItem = ({
|
|
|
1393
1600
|
onPress: handlePress,
|
|
1394
1601
|
...keyboardProps,
|
|
1395
1602
|
children: [
|
|
1396
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1603
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles14.headerLeft, boxed ? styles14.headerLeftRow : null], children: [
|
|
1397
1604
|
boxed ? (
|
|
1398
1605
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
1399
1606
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1402,15 +1609,15 @@ var AccordionItem = ({
|
|
|
1402
1609
|
accessibilityElementsHidden: true,
|
|
1403
1610
|
"aria-hidden": true,
|
|
1404
1611
|
importantForAccessibility: "no-hide-descendants",
|
|
1405
|
-
style: [
|
|
1612
|
+
style: [styles14.marker, { transform: [{ rotate }] }],
|
|
1406
1613
|
testID: chevronTestID,
|
|
1407
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1614
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles14.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
1408
1615
|
}
|
|
1409
1616
|
)
|
|
1410
1617
|
) : null,
|
|
1411
1618
|
titleNode
|
|
1412
1619
|
] }),
|
|
1413
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1620
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles14.headerRight, children: [
|
|
1414
1621
|
right,
|
|
1415
1622
|
boxed ? null : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1416
1623
|
reactNative.Animated.View,
|
|
@@ -1418,7 +1625,7 @@ var AccordionItem = ({
|
|
|
1418
1625
|
accessibilityElementsHidden: true,
|
|
1419
1626
|
"aria-hidden": true,
|
|
1420
1627
|
importantForAccessibility: "no-hide-descendants",
|
|
1421
|
-
style: [
|
|
1628
|
+
style: [styles14.chevron, { transform: [{ rotate }] }],
|
|
1422
1629
|
children: /* @__PURE__ */ jsxRuntime.jsx(uiIcons.SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
1423
1630
|
}
|
|
1424
1631
|
)
|
|
@@ -1432,7 +1639,7 @@ var AccordionItem = ({
|
|
|
1432
1639
|
accessibilityLabel: resolvedLabel,
|
|
1433
1640
|
nativeID: bodyTestID,
|
|
1434
1641
|
role: ROLE_REGION,
|
|
1435
|
-
style: boxed ?
|
|
1642
|
+
style: boxed ? styles14.boxBody : styles14.body,
|
|
1436
1643
|
testID: bodyTestID,
|
|
1437
1644
|
children
|
|
1438
1645
|
}
|
|
@@ -1470,14 +1677,14 @@ function measureParentInnerWidth(node) {
|
|
|
1470
1677
|
return Math.max(UNMEASURED, parent.clientWidth - padding);
|
|
1471
1678
|
}
|
|
1472
1679
|
function useAvailableWidth() {
|
|
1473
|
-
const [width, setWidth] =
|
|
1474
|
-
const nodeRef =
|
|
1475
|
-
const measureRef =
|
|
1680
|
+
const [width, setWidth] = React10.useState(UNMEASURED);
|
|
1681
|
+
const nodeRef = React10.useRef(null);
|
|
1682
|
+
const measureRef = React10.useCallback((node) => {
|
|
1476
1683
|
if (!IS_WEB3) return;
|
|
1477
1684
|
nodeRef.current = node;
|
|
1478
1685
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
1479
1686
|
}, []);
|
|
1480
|
-
|
|
1687
|
+
React10.useEffect(() => {
|
|
1481
1688
|
if (!IS_WEB3) return void 0;
|
|
1482
1689
|
const remeasure = () => {
|
|
1483
1690
|
const node = nodeRef.current;
|
|
@@ -1486,7 +1693,7 @@ function useAvailableWidth() {
|
|
|
1486
1693
|
window.addEventListener("resize", remeasure);
|
|
1487
1694
|
return () => window.removeEventListener("resize", remeasure);
|
|
1488
1695
|
}, []);
|
|
1489
|
-
const onLayout =
|
|
1696
|
+
const onLayout = React10.useCallback((event) => {
|
|
1490
1697
|
if (IS_WEB3) return;
|
|
1491
1698
|
setWidth(event.nativeEvent.layout.width);
|
|
1492
1699
|
}, []);
|
|
@@ -1495,7 +1702,7 @@ function useAvailableWidth() {
|
|
|
1495
1702
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
1496
1703
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
1497
1704
|
var UNMEASURED2 = 0;
|
|
1498
|
-
var
|
|
1705
|
+
var styles15 = reactNative.StyleSheet.create({
|
|
1499
1706
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
1500
1707
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
1501
1708
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -1515,8 +1722,8 @@ var TruncatedText = ({
|
|
|
1515
1722
|
accessibilityHint
|
|
1516
1723
|
}) => {
|
|
1517
1724
|
const { width, measureRef, onLayout } = useAvailableWidth();
|
|
1518
|
-
const hostRef =
|
|
1519
|
-
const attachRef =
|
|
1725
|
+
const hostRef = React10.useRef(null);
|
|
1726
|
+
const attachRef = React10.useCallback(
|
|
1520
1727
|
(node) => {
|
|
1521
1728
|
hostRef.current = node;
|
|
1522
1729
|
measureRef(node);
|
|
@@ -1525,12 +1732,12 @@ var TruncatedText = ({
|
|
|
1525
1732
|
},
|
|
1526
1733
|
[value, measureRef]
|
|
1527
1734
|
);
|
|
1528
|
-
const flatStyle =
|
|
1529
|
-
() => reactNative.StyleSheet.flatten([
|
|
1735
|
+
const flatStyle = React10.useMemo(
|
|
1736
|
+
() => reactNative.StyleSheet.flatten([styles15.base, style]),
|
|
1530
1737
|
[style]
|
|
1531
1738
|
);
|
|
1532
1739
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
1533
|
-
const display =
|
|
1740
|
+
const display = React10.useMemo(() => {
|
|
1534
1741
|
const source = isUrl ? formatUrlForDisplay(value) : value;
|
|
1535
1742
|
const budget = charBudget(width, fontSize);
|
|
1536
1743
|
return budget === UNMEASURED2 ? source : truncateMiddle(source, budget);
|
|
@@ -1541,7 +1748,7 @@ var TruncatedText = ({
|
|
|
1541
1748
|
ref: attachRef,
|
|
1542
1749
|
onLayout,
|
|
1543
1750
|
numberOfLines: 1,
|
|
1544
|
-
style: [
|
|
1751
|
+
style: [styles15.base, styles15.fill, style],
|
|
1545
1752
|
testID,
|
|
1546
1753
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
1547
1754
|
accessibilityLabel,
|
|
@@ -1612,17 +1819,17 @@ async function copyText(value, writer) {
|
|
|
1612
1819
|
// src/CopyableId/useCopyToClipboard.ts
|
|
1613
1820
|
var COPY_FEEDBACK_MS = 2e3;
|
|
1614
1821
|
function useCopyToClipboard(value, writer) {
|
|
1615
|
-
const [status, setStatus] =
|
|
1616
|
-
const timerRef =
|
|
1617
|
-
const mountedRef =
|
|
1618
|
-
|
|
1822
|
+
const [status, setStatus] = React10.useState("idle" /* Idle */);
|
|
1823
|
+
const timerRef = React10.useRef(null);
|
|
1824
|
+
const mountedRef = React10.useRef(true);
|
|
1825
|
+
React10.useEffect(() => {
|
|
1619
1826
|
mountedRef.current = true;
|
|
1620
1827
|
return () => {
|
|
1621
1828
|
mountedRef.current = false;
|
|
1622
1829
|
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
1623
1830
|
};
|
|
1624
1831
|
}, []);
|
|
1625
|
-
const copy =
|
|
1832
|
+
const copy = React10.useCallback(() => {
|
|
1626
1833
|
void (async () => {
|
|
1627
1834
|
const ok = await copyText(value, writer);
|
|
1628
1835
|
if (!mountedRef.current) return;
|
|
@@ -1644,7 +1851,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
1644
1851
|
var ACTION_PADDING_H = 6;
|
|
1645
1852
|
var ACTION_PADDING_V = 2;
|
|
1646
1853
|
var ACTION_RADIUS = 6;
|
|
1647
|
-
var
|
|
1854
|
+
var styles16 = reactNative.StyleSheet.create({
|
|
1648
1855
|
cell: { gap: CELL_GAP },
|
|
1649
1856
|
label: {
|
|
1650
1857
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -1680,7 +1887,7 @@ var styles14 = reactNative.StyleSheet.create({
|
|
|
1680
1887
|
var TONE_STEP = "500";
|
|
1681
1888
|
function useActionState(status) {
|
|
1682
1889
|
const { theme } = uiFeedback.useUi();
|
|
1683
|
-
return
|
|
1890
|
+
return React10.useMemo(() => {
|
|
1684
1891
|
const primary = theme.palette.primary[TONE_STEP];
|
|
1685
1892
|
if (status === "copied" /* Copied */) {
|
|
1686
1893
|
return { key: LAYOUT_I18N.copied, color: theme.semantic.success?.[TONE_STEP] ?? primary };
|
|
@@ -1703,14 +1910,14 @@ var CopyableId = ({
|
|
|
1703
1910
|
const { colors } = theme;
|
|
1704
1911
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
1705
1912
|
const action = useActionState(status);
|
|
1706
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
|
|
1707
|
-
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
|
|
1708
|
-
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style:
|
|
1709
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style:
|
|
1913
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles16.cell, style], testID, children: [
|
|
1914
|
+
label !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles16.label, { color: colors.textSecondary }], children: label }),
|
|
1915
|
+
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles16.row, children: [
|
|
1916
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles16.valueWrap, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1710
1917
|
TruncatedText,
|
|
1711
1918
|
{
|
|
1712
1919
|
value,
|
|
1713
|
-
style: [
|
|
1920
|
+
style: [styles16.value, { color: colors.text }],
|
|
1714
1921
|
testID: `${testID}-value`,
|
|
1715
1922
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
1716
1923
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -1724,7 +1931,7 @@ var CopyableId = ({
|
|
|
1724
1931
|
accessibilityLabel: t(action.key),
|
|
1725
1932
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
1726
1933
|
testID: `${testID}-copy`,
|
|
1727
|
-
style: [
|
|
1934
|
+
style: [styles16.action, { color: action.color }],
|
|
1728
1935
|
children: t(action.key)
|
|
1729
1936
|
}
|
|
1730
1937
|
)
|
|
@@ -1735,6 +1942,7 @@ var CopyableId = ({
|
|
|
1735
1942
|
exports.Accordion = Accordion;
|
|
1736
1943
|
exports.AccordionItem = AccordionItem;
|
|
1737
1944
|
exports.COPY_FEEDBACK_MS = COPY_FEEDBACK_MS;
|
|
1945
|
+
exports.ConfirmDialog = ConfirmDialog;
|
|
1738
1946
|
exports.CopyStatus = CopyStatus;
|
|
1739
1947
|
exports.CopyableId = CopyableId;
|
|
1740
1948
|
exports.DEFAULT_BILLING_ROUTE = DEFAULT_BILLING_ROUTE;
|
|
@@ -1743,6 +1951,7 @@ exports.ELLIPSIS = ELLIPSIS;
|
|
|
1743
1951
|
exports.Heading = Heading;
|
|
1744
1952
|
exports.LAYOUT_I18N = LAYOUT_I18N;
|
|
1745
1953
|
exports.LAYOUT_TEST_IDS = LAYOUT_TEST_IDS;
|
|
1954
|
+
exports.Modal = Modal3;
|
|
1746
1955
|
exports.ModalDropdown = ModalDropdown;
|
|
1747
1956
|
exports.ModalShell = ModalShell;
|
|
1748
1957
|
exports.Section = Section;
|