@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.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React10, { createContext, useMemo, useRef, useEffect, useState, useCallback, useContext, useLayoutEffect } from 'react';
|
|
2
2
|
import { StyleSheet, Platform, View, Text, Pressable, TouchableOpacity, Modal, FlatList, ScrollView, Animated, Easing, useWindowDimensions, LayoutAnimation, UIManager } 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
5
|
import { useA11y } from '@dloizides/a11y';
|
|
6
6
|
import { createPortal } from 'react-dom';
|
|
7
7
|
import { SvgIcon } from '@dloizides/ui-icons';
|
|
8
|
+
import { IconButton, Button } from '@dloizides/ui-buttons';
|
|
8
9
|
import { useReducedMotion, prefersReducedMotion } from '@dloizides/rn-web-hooks';
|
|
9
10
|
|
|
10
11
|
// src/Section/Section.tsx
|
|
@@ -17,7 +18,7 @@ var styles = StyleSheet.create({
|
|
|
17
18
|
});
|
|
18
19
|
var Section = ({ children, style }) => {
|
|
19
20
|
const { theme } = useUi();
|
|
20
|
-
const containerStyle =
|
|
21
|
+
const containerStyle = React10.useMemo(
|
|
21
22
|
() => [styles.card, { borderColor: theme.colors.border, backgroundColor: theme.colors.surface }, style],
|
|
22
23
|
[theme.colors.border, theme.colors.surface, style]
|
|
23
24
|
);
|
|
@@ -33,6 +34,10 @@ var LAYOUT_TEST_IDS = {
|
|
|
33
34
|
upgradePromptDismiss: "upgrade-prompt-dismiss",
|
|
34
35
|
modalShell: "template-modal",
|
|
35
36
|
modalShellClose: "cancel-button",
|
|
37
|
+
/** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
|
|
38
|
+
modal: "modal",
|
|
39
|
+
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
40
|
+
confirmDialog: "confirm-dialog",
|
|
36
41
|
accordion: "accordion"
|
|
37
42
|
};
|
|
38
43
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
@@ -61,6 +66,14 @@ var LAYOUT_I18N = {
|
|
|
61
66
|
close: "quizTemplates.cancel",
|
|
62
67
|
/** `ModalShell`: heading fallback when no title is supplied. */
|
|
63
68
|
closeHeading: "close",
|
|
69
|
+
/** `Modal`: accessible name + web tooltip of the top-right ✕ close button. */
|
|
70
|
+
dialogClose: "common.close",
|
|
71
|
+
/** `ConfirmDialog`: default Confirm button label (overridable via `confirmLabel`) + its hint. */
|
|
72
|
+
confirm: "common.confirm",
|
|
73
|
+
confirmHint: "common.confirmHint",
|
|
74
|
+
/** `ConfirmDialog`: default Cancel button label (overridable via `cancelLabel`) + its hint. */
|
|
75
|
+
cancel: "common.cancel",
|
|
76
|
+
cancelHint: "common.cancelHint",
|
|
64
77
|
upgradePromptTitle: "settings.billing.upgradePrompt.title",
|
|
65
78
|
/** Body copy, parameterised: "…requires {{p1}}, you are on {{p2}}." */
|
|
66
79
|
upgradePromptMessage: "settings.billing.upgradePrompt.message",
|
|
@@ -96,7 +109,7 @@ var Heading = ({
|
|
|
96
109
|
testID
|
|
97
110
|
}) => {
|
|
98
111
|
const { theme } = useUi();
|
|
99
|
-
const headingStyle =
|
|
112
|
+
const headingStyle = React10.useMemo(
|
|
100
113
|
() => [styles2.heading, { color: theme.colors.text }, style],
|
|
101
114
|
[theme.colors.text, style]
|
|
102
115
|
);
|
|
@@ -230,6 +243,13 @@ function SegmentedControl({
|
|
|
230
243
|
}
|
|
231
244
|
);
|
|
232
245
|
}
|
|
246
|
+
|
|
247
|
+
// src/Tabs/TabsCollapsedTrigger.ts
|
|
248
|
+
var TabsCollapsedTrigger = /* @__PURE__ */ ((TabsCollapsedTrigger2) => {
|
|
249
|
+
TabsCollapsedTrigger2["Caret"] = "caret";
|
|
250
|
+
TabsCollapsedTrigger2["Hamburger"] = "hamburger";
|
|
251
|
+
return TabsCollapsedTrigger2;
|
|
252
|
+
})(TabsCollapsedTrigger || {});
|
|
233
253
|
var FOCUSABLE_SELECTOR = [
|
|
234
254
|
"a[href]",
|
|
235
255
|
"button:not([disabled])",
|
|
@@ -638,6 +658,8 @@ var MIN_TOUCH_TARGET = 44;
|
|
|
638
658
|
var CARET_FONT_SIZE = 12;
|
|
639
659
|
var CARET_GAP = 8;
|
|
640
660
|
var CARET_GLYPH = "\u25BE";
|
|
661
|
+
var HAMBURGER_GLYPH = "\u2630";
|
|
662
|
+
var HAMBURGER_FONT_SIZE = 18;
|
|
641
663
|
var CARET_OPEN_ROTATION = "180deg";
|
|
642
664
|
var CARET_CLOSED_ROTATION = "0deg";
|
|
643
665
|
var styles7 = StyleSheet.create({
|
|
@@ -658,10 +680,20 @@ var styles7 = StyleSheet.create({
|
|
|
658
680
|
justifyContent: "space-between",
|
|
659
681
|
columnGap: CARET_GAP
|
|
660
682
|
},
|
|
683
|
+
// Hamburger variant: the ☰ glyph LEADS the label (icon-first, like a phone nav button), so the
|
|
684
|
+
// row packs to the start rather than pushing a trailing caret to the far edge. Same tap target.
|
|
685
|
+
containerHamburger: {
|
|
686
|
+
minHeight: MIN_TOUCH_TARGET,
|
|
687
|
+
flexDirection: "row",
|
|
688
|
+
alignItems: "center",
|
|
689
|
+
justifyContent: "flex-start",
|
|
690
|
+
columnGap: CARET_GAP
|
|
691
|
+
},
|
|
661
692
|
selectedText: { fontSize: BODY_FONT_SIZE2 },
|
|
662
|
-
// The label may shrink/ellipsize; the caret never does.
|
|
693
|
+
// The label may shrink/ellipsize; the caret / hamburger glyph never does.
|
|
663
694
|
selectedTextMenu: { flexShrink: 1 },
|
|
664
695
|
caret: { fontSize: CARET_FONT_SIZE, flexShrink: 0 },
|
|
696
|
+
hamburger: { fontSize: HAMBURGER_FONT_SIZE, flexShrink: 0 },
|
|
665
697
|
modalOverlay: {
|
|
666
698
|
flex: 1,
|
|
667
699
|
justifyContent: "center",
|
|
@@ -686,7 +718,8 @@ var ModalDropdown = ({
|
|
|
686
718
|
renderTrigger,
|
|
687
719
|
optionTestID,
|
|
688
720
|
menuMinWidth,
|
|
689
|
-
showCaret = false
|
|
721
|
+
showCaret = false,
|
|
722
|
+
showHamburger = false
|
|
690
723
|
}) => {
|
|
691
724
|
const { theme, t } = useUi();
|
|
692
725
|
const { colors } = theme;
|
|
@@ -720,13 +753,19 @@ var ModalDropdown = ({
|
|
|
720
753
|
},
|
|
721
754
|
[onChange]
|
|
722
755
|
);
|
|
756
|
+
const isHamburger = showHamburger;
|
|
757
|
+
const isCaret = showCaret && !isHamburger;
|
|
723
758
|
const containerStyle = useMemo(
|
|
724
759
|
() => renderTrigger !== void 0 ? void 0 : [
|
|
725
760
|
styles7.container,
|
|
726
|
-
|
|
761
|
+
isHamburger ? styles7.containerHamburger : isCaret ? styles7.containerMenu : null,
|
|
727
762
|
{ borderColor: colors.border, backgroundColor: colors.surface }
|
|
728
763
|
],
|
|
729
|
-
[colors.border, colors.surface, renderTrigger,
|
|
764
|
+
[colors.border, colors.surface, renderTrigger, isHamburger, isCaret]
|
|
765
|
+
);
|
|
766
|
+
const hamburgerStyle = useMemo(
|
|
767
|
+
() => [styles7.hamburger, { color: colors.textSecondary }],
|
|
768
|
+
[colors.textSecondary]
|
|
730
769
|
);
|
|
731
770
|
const caretStyle = useMemo(
|
|
732
771
|
() => [
|
|
@@ -762,7 +801,10 @@ var ModalDropdown = ({
|
|
|
762
801
|
const keyExtractor = useCallback((item) => String(item.value), []);
|
|
763
802
|
return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: anchorStyle, children: [
|
|
764
803
|
/* @__PURE__ */ jsxs(TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
|
|
765
|
-
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) :
|
|
804
|
+
renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
805
|
+
/* @__PURE__ */ jsx(Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
|
|
806
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel })
|
|
807
|
+
] }) : isCaret ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
766
808
|
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [styles7.selectedText, styles7.selectedTextMenu, { color: colors.text }], children: selectedLabel }),
|
|
767
809
|
/* @__PURE__ */ jsx(Text, { style: caretStyle, children: CARET_GLYPH })
|
|
768
810
|
] }) : /* @__PURE__ */ jsx(Text, { style: [styles7.selectedText, { color: colors.text }], children: selectedLabel }),
|
|
@@ -816,7 +858,8 @@ var TabsMenu = ({
|
|
|
816
858
|
onChange,
|
|
817
859
|
accessibilityLabel,
|
|
818
860
|
idPrefix,
|
|
819
|
-
testID
|
|
861
|
+
testID,
|
|
862
|
+
collapsedTrigger = "caret" /* Caret */
|
|
820
863
|
}) => {
|
|
821
864
|
const { t } = useUi();
|
|
822
865
|
const options = useMemo(
|
|
@@ -830,6 +873,7 @@ var TabsMenu = ({
|
|
|
830
873
|
},
|
|
831
874
|
[tabs, idPrefix]
|
|
832
875
|
);
|
|
876
|
+
const isHamburger = collapsedTrigger === "hamburger" /* Hamburger */;
|
|
833
877
|
return /* @__PURE__ */ jsx(
|
|
834
878
|
ModalDropdown,
|
|
835
879
|
{
|
|
@@ -837,7 +881,8 @@ var TabsMenu = ({
|
|
|
837
881
|
accessibilityLabel,
|
|
838
882
|
optionTestID,
|
|
839
883
|
options,
|
|
840
|
-
showCaret:
|
|
884
|
+
showCaret: !isHamburger,
|
|
885
|
+
showHamburger: isHamburger,
|
|
841
886
|
testID,
|
|
842
887
|
value: activeKey,
|
|
843
888
|
onChange
|
|
@@ -950,6 +995,7 @@ var Tabs = ({
|
|
|
950
995
|
children,
|
|
951
996
|
idPrefix = "tabs",
|
|
952
997
|
collapseBelow = TABS_COLLAPSE_BREAKPOINT,
|
|
998
|
+
collapsedTrigger = "caret" /* Caret */,
|
|
953
999
|
style,
|
|
954
1000
|
stripStyle,
|
|
955
1001
|
panelStyle,
|
|
@@ -967,6 +1013,7 @@ var Tabs = ({
|
|
|
967
1013
|
{
|
|
968
1014
|
accessibilityLabel,
|
|
969
1015
|
activeKey,
|
|
1016
|
+
collapsedTrigger,
|
|
970
1017
|
idPrefix,
|
|
971
1018
|
tabs,
|
|
972
1019
|
testID: `${idPrefix}-menu`,
|
|
@@ -1088,7 +1135,7 @@ var ModalShell = ({
|
|
|
1088
1135
|
showClose = true
|
|
1089
1136
|
}) => {
|
|
1090
1137
|
const { theme, t } = useUi();
|
|
1091
|
-
const containerStyle =
|
|
1138
|
+
const containerStyle = React10.useMemo(
|
|
1092
1139
|
() => [styles10.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1093
1140
|
[theme.colors.background, contentStyle]
|
|
1094
1141
|
);
|
|
@@ -1131,6 +1178,195 @@ var ModalShell = ({
|
|
|
1131
1178
|
}
|
|
1132
1179
|
);
|
|
1133
1180
|
};
|
|
1181
|
+
function useEscapeKey(enabled, onClose) {
|
|
1182
|
+
useEffect(() => {
|
|
1183
|
+
if (Platform.OS !== "web" || !enabled) return;
|
|
1184
|
+
const onKeyDown = (event) => {
|
|
1185
|
+
if (event.key === "Escape") onClose();
|
|
1186
|
+
};
|
|
1187
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1188
|
+
return () => {
|
|
1189
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1190
|
+
};
|
|
1191
|
+
}, [enabled, onClose]);
|
|
1192
|
+
}
|
|
1193
|
+
function useScrollLock(enabled) {
|
|
1194
|
+
useEffect(() => {
|
|
1195
|
+
if (Platform.OS !== "web" || !enabled) return;
|
|
1196
|
+
const { body } = document;
|
|
1197
|
+
const previousOverflow = body.style.overflow;
|
|
1198
|
+
body.style.overflow = "hidden";
|
|
1199
|
+
return () => {
|
|
1200
|
+
body.style.overflow = previousOverflow;
|
|
1201
|
+
};
|
|
1202
|
+
}, [enabled]);
|
|
1203
|
+
}
|
|
1204
|
+
var OVERLAY_PADDING = 16;
|
|
1205
|
+
var DIALOG_RADIUS = 12;
|
|
1206
|
+
var DIALOG_PADDING = 16;
|
|
1207
|
+
var HEADER_GAP = 12;
|
|
1208
|
+
var FOOTER_MARGIN = 16;
|
|
1209
|
+
var HEADER_MARGIN = 12;
|
|
1210
|
+
var DIALOG_MAX_HEIGHT = "90%";
|
|
1211
|
+
var SIZE_MAX_WIDTH = { sm: 360, md: 480, lg: 640 };
|
|
1212
|
+
var styles11 = StyleSheet.create({
|
|
1213
|
+
overlay: {
|
|
1214
|
+
flex: 1,
|
|
1215
|
+
justifyContent: "center",
|
|
1216
|
+
alignItems: "center",
|
|
1217
|
+
padding: OVERLAY_PADDING,
|
|
1218
|
+
backgroundColor: MODAL_OVERLAY_COLOR
|
|
1219
|
+
},
|
|
1220
|
+
dialog: {
|
|
1221
|
+
width: "100%",
|
|
1222
|
+
borderRadius: DIALOG_RADIUS,
|
|
1223
|
+
padding: DIALOG_PADDING,
|
|
1224
|
+
maxHeight: DIALOG_MAX_HEIGHT
|
|
1225
|
+
},
|
|
1226
|
+
headerRow: {
|
|
1227
|
+
flexDirection: "row",
|
|
1228
|
+
alignItems: "flex-start",
|
|
1229
|
+
justifyContent: "space-between",
|
|
1230
|
+
columnGap: HEADER_GAP,
|
|
1231
|
+
marginBottom: HEADER_MARGIN
|
|
1232
|
+
},
|
|
1233
|
+
// Occupies the header's leading space so the ✕ pins to the trailing edge even without a title.
|
|
1234
|
+
titleWrap: { flex: 1 },
|
|
1235
|
+
footer: { marginTop: FOOTER_MARGIN }
|
|
1236
|
+
});
|
|
1237
|
+
var Modal3 = ({
|
|
1238
|
+
visible,
|
|
1239
|
+
onClose,
|
|
1240
|
+
title,
|
|
1241
|
+
children,
|
|
1242
|
+
footer,
|
|
1243
|
+
size = "md",
|
|
1244
|
+
showClose = true,
|
|
1245
|
+
testID = LAYOUT_TEST_IDS.modal,
|
|
1246
|
+
accessibilityLabel
|
|
1247
|
+
}) => {
|
|
1248
|
+
const { theme, t } = useUi();
|
|
1249
|
+
const dialogRef = useRef(null);
|
|
1250
|
+
useFocusTrap(dialogRef, visible);
|
|
1251
|
+
useEscapeKey(visible, onClose);
|
|
1252
|
+
useScrollLock(visible);
|
|
1253
|
+
const accessibleName = accessibilityLabel ?? title ?? t(LAYOUT_I18N.dialog);
|
|
1254
|
+
const closeLabel = t(LAYOUT_I18N.dialogClose);
|
|
1255
|
+
const dialogStyle = useMemo(
|
|
1256
|
+
() => [styles11.dialog, { backgroundColor: theme.colors.surface, maxWidth: SIZE_MAX_WIDTH[size] }],
|
|
1257
|
+
[theme.colors.surface, size]
|
|
1258
|
+
);
|
|
1259
|
+
const hasHeader = title !== void 0 || showClose;
|
|
1260
|
+
return /* @__PURE__ */ jsx(Modal, { transparent: true, animationType: "fade", visible, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles11.overlay, children: [
|
|
1261
|
+
/* @__PURE__ */ jsx(
|
|
1262
|
+
TouchableOpacity,
|
|
1263
|
+
{
|
|
1264
|
+
accessible: true,
|
|
1265
|
+
accessibilityHint: t(LAYOUT_I18N.dismissDropdownHint),
|
|
1266
|
+
accessibilityLabel: t(LAYOUT_I18N.dismissDropdown),
|
|
1267
|
+
accessibilityRole: "button",
|
|
1268
|
+
activeOpacity: 1,
|
|
1269
|
+
style: StyleSheet.absoluteFill,
|
|
1270
|
+
testID: `${testID}-backdrop`,
|
|
1271
|
+
onPress: onClose
|
|
1272
|
+
}
|
|
1273
|
+
),
|
|
1274
|
+
/* @__PURE__ */ jsxs(
|
|
1275
|
+
View,
|
|
1276
|
+
{
|
|
1277
|
+
ref: dialogRef,
|
|
1278
|
+
accessibilityViewIsModal: true,
|
|
1279
|
+
"aria-label": accessibleName,
|
|
1280
|
+
role: "dialog",
|
|
1281
|
+
style: dialogStyle,
|
|
1282
|
+
testID,
|
|
1283
|
+
children: [
|
|
1284
|
+
hasHeader ? /* @__PURE__ */ jsxs(View, { style: styles11.headerRow, children: [
|
|
1285
|
+
/* @__PURE__ */ jsx(View, { style: styles11.titleWrap, children: title !== void 0 ? /* @__PURE__ */ jsx(Heading, { children: title }) : null }),
|
|
1286
|
+
showClose ? /* @__PURE__ */ jsx(
|
|
1287
|
+
IconButton,
|
|
1288
|
+
{
|
|
1289
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1290
|
+
accessibilityLabel: closeLabel,
|
|
1291
|
+
appearance: "ghost",
|
|
1292
|
+
renderIcon: (color, iconSize) => /* @__PURE__ */ jsx(SvgIcon, { color, name: "close", size: iconSize }),
|
|
1293
|
+
size: "md",
|
|
1294
|
+
testID: `${testID}-close`,
|
|
1295
|
+
tooltip: closeLabel,
|
|
1296
|
+
variant: "ghost",
|
|
1297
|
+
onPress: onClose
|
|
1298
|
+
}
|
|
1299
|
+
) : null
|
|
1300
|
+
] }) : null,
|
|
1301
|
+
/* @__PURE__ */ jsx(ScrollView, { children }),
|
|
1302
|
+
footer !== void 0 ? /* @__PURE__ */ jsx(View, { style: styles11.footer, children: footer }) : null
|
|
1303
|
+
]
|
|
1304
|
+
}
|
|
1305
|
+
)
|
|
1306
|
+
] }) });
|
|
1307
|
+
};
|
|
1308
|
+
var MESSAGE_FONT_SIZE2 = 14;
|
|
1309
|
+
var MESSAGE_LINE_HEIGHT = 20;
|
|
1310
|
+
var BUTTON_GAP = 12;
|
|
1311
|
+
var styles12 = StyleSheet.create({
|
|
1312
|
+
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1313
|
+
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1314
|
+
});
|
|
1315
|
+
var ConfirmDialog = ({
|
|
1316
|
+
visible,
|
|
1317
|
+
title,
|
|
1318
|
+
message,
|
|
1319
|
+
confirmLabel,
|
|
1320
|
+
cancelLabel,
|
|
1321
|
+
destructive = false,
|
|
1322
|
+
onConfirm,
|
|
1323
|
+
onCancel,
|
|
1324
|
+
busy = false,
|
|
1325
|
+
testID = LAYOUT_TEST_IDS.confirmDialog
|
|
1326
|
+
}) => {
|
|
1327
|
+
const { theme, t } = useUi();
|
|
1328
|
+
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1329
|
+
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1330
|
+
const footer = /* @__PURE__ */ jsxs(View, { style: styles12.footer, children: [
|
|
1331
|
+
/* @__PURE__ */ jsx(
|
|
1332
|
+
Button,
|
|
1333
|
+
{
|
|
1334
|
+
accessibilityHint: t(LAYOUT_I18N.cancelHint),
|
|
1335
|
+
accessibilityLabel: resolvedCancel,
|
|
1336
|
+
disabled: busy,
|
|
1337
|
+
label: resolvedCancel,
|
|
1338
|
+
testID: `${testID}-cancel`,
|
|
1339
|
+
variant: "secondary",
|
|
1340
|
+
onPress: onCancel
|
|
1341
|
+
}
|
|
1342
|
+
),
|
|
1343
|
+
/* @__PURE__ */ jsx(
|
|
1344
|
+
Button,
|
|
1345
|
+
{
|
|
1346
|
+
accessibilityHint: t(LAYOUT_I18N.confirmHint),
|
|
1347
|
+
accessibilityLabel: resolvedConfirm,
|
|
1348
|
+
label: resolvedConfirm,
|
|
1349
|
+
loading: busy,
|
|
1350
|
+
testID: `${testID}-confirm`,
|
|
1351
|
+
variant: destructive ? "danger" : "primary",
|
|
1352
|
+
onPress: onConfirm
|
|
1353
|
+
}
|
|
1354
|
+
)
|
|
1355
|
+
] });
|
|
1356
|
+
return /* @__PURE__ */ jsx(
|
|
1357
|
+
Modal3,
|
|
1358
|
+
{
|
|
1359
|
+
footer,
|
|
1360
|
+
showClose: false,
|
|
1361
|
+
size: "sm",
|
|
1362
|
+
testID,
|
|
1363
|
+
title,
|
|
1364
|
+
visible,
|
|
1365
|
+
onClose: onCancel,
|
|
1366
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles12.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1367
|
+
}
|
|
1368
|
+
);
|
|
1369
|
+
};
|
|
1134
1370
|
var AccordionContext = createContext(null);
|
|
1135
1371
|
function useAccordionContext() {
|
|
1136
1372
|
const value = useContext(AccordionContext);
|
|
@@ -1160,14 +1396,14 @@ function animateNextLayout() {
|
|
|
1160
1396
|
}
|
|
1161
1397
|
}
|
|
1162
1398
|
var BOXED_GAP = 12;
|
|
1163
|
-
var
|
|
1399
|
+
var styles13 = StyleSheet.create({
|
|
1164
1400
|
container: { alignSelf: "stretch" },
|
|
1165
1401
|
boxed: { gap: BOXED_GAP }
|
|
1166
1402
|
});
|
|
1167
1403
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1168
1404
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1169
|
-
|
|
1170
|
-
if (!
|
|
1405
|
+
React10.Children.forEach(children, (child) => {
|
|
1406
|
+
if (!React10.isValidElement(child)) return;
|
|
1171
1407
|
const props = child.props;
|
|
1172
1408
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1173
1409
|
ids.add(props.id);
|
|
@@ -1218,7 +1454,7 @@ var Accordion = ({
|
|
|
1218
1454
|
[openSet, toggle, allowMultiple, variant]
|
|
1219
1455
|
);
|
|
1220
1456
|
const containerStyle = useMemo(() => {
|
|
1221
|
-
const base = variant === "boxed" ? [
|
|
1457
|
+
const base = variant === "boxed" ? [styles13.container, styles13.boxed] : [styles13.container];
|
|
1222
1458
|
if (style === void 0) return base;
|
|
1223
1459
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
1224
1460
|
}, [style, variant]);
|
|
@@ -1228,7 +1464,7 @@ var HEADER_PADDING_H = 16;
|
|
|
1228
1464
|
var HEADER_PADDING_V = 12;
|
|
1229
1465
|
var BODY_PADDING_H = 16;
|
|
1230
1466
|
var BODY_PADDING_V = 12;
|
|
1231
|
-
var
|
|
1467
|
+
var HEADER_GAP2 = 8;
|
|
1232
1468
|
var TITLE_FONT_SIZE2 = 15;
|
|
1233
1469
|
var TITLE_FONT_WEIGHT = "600";
|
|
1234
1470
|
var CHEVRON_SIZE = 18;
|
|
@@ -1250,7 +1486,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
1250
1486
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
1251
1487
|
var BOX_MARKER_GAP = 6;
|
|
1252
1488
|
var BOX_MARKER = "\u25B8";
|
|
1253
|
-
var
|
|
1489
|
+
var styles14 = StyleSheet.create({
|
|
1254
1490
|
item: { borderTopWidth: StyleSheet.hairlineWidth },
|
|
1255
1491
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
1256
1492
|
header: {
|
|
@@ -1263,10 +1499,10 @@ var styles12 = StyleSheet.create({
|
|
|
1263
1499
|
boxHeader: { paddingHorizontal: 0, paddingVertical: BOX_HEADER_PADDING_V },
|
|
1264
1500
|
headerLeft: { flexShrink: 1, flexGrow: 1 },
|
|
1265
1501
|
headerLeftRow: { flexDirection: "row", alignItems: "center" },
|
|
1266
|
-
headerRight: { flexDirection: "row", alignItems: "center", marginLeft:
|
|
1502
|
+
headerRight: { flexDirection: "row", alignItems: "center", marginLeft: HEADER_GAP2 },
|
|
1267
1503
|
title: { fontSize: TITLE_FONT_SIZE2, fontWeight: TITLE_FONT_WEIGHT },
|
|
1268
1504
|
boxTitle: { fontSize: BOX_TITLE_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1269
|
-
chevron: { marginLeft:
|
|
1505
|
+
chevron: { marginLeft: HEADER_GAP2 },
|
|
1270
1506
|
marker: { marginRight: BOX_MARKER_GAP },
|
|
1271
1507
|
markerText: { fontSize: BOX_MARKER_FONT_SIZE, fontWeight: TITLE_FONT_WEIGHT },
|
|
1272
1508
|
body: { paddingHorizontal: BODY_PADDING_H, paddingBottom: BODY_PADDING_V },
|
|
@@ -1324,19 +1560,19 @@ var AccordionItem = ({
|
|
|
1324
1560
|
);
|
|
1325
1561
|
const keyboardProps = Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
1326
1562
|
const itemStyle = useMemo(
|
|
1327
|
-
() => boxed ? [
|
|
1563
|
+
() => boxed ? [styles14.boxItem, { borderColor: colors.border }] : [styles14.item, { borderTopColor: colors.border }],
|
|
1328
1564
|
[boxed, colors.border]
|
|
1329
1565
|
);
|
|
1330
1566
|
const headerStyle = useMemo(
|
|
1331
1567
|
() => [
|
|
1332
|
-
|
|
1333
|
-
...boxed ? [
|
|
1568
|
+
styles14.header,
|
|
1569
|
+
...boxed ? [styles14.boxHeader] : [],
|
|
1334
1570
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
1335
1571
|
],
|
|
1336
1572
|
[boxed, disabled]
|
|
1337
1573
|
);
|
|
1338
1574
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
1339
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsx(Text, { style: [boxed ?
|
|
1575
|
+
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsx(Text, { style: [boxed ? styles14.boxTitle : styles14.title, { color: boxed ? colors.textSecondary : colors.text }], children: title }) : title;
|
|
1340
1576
|
return /* @__PURE__ */ jsxs(View, { style: itemStyle, children: [
|
|
1341
1577
|
/* @__PURE__ */ jsxs(
|
|
1342
1578
|
Pressable,
|
|
@@ -1353,7 +1589,7 @@ var AccordionItem = ({
|
|
|
1353
1589
|
onPress: handlePress,
|
|
1354
1590
|
...keyboardProps,
|
|
1355
1591
|
children: [
|
|
1356
|
-
/* @__PURE__ */ jsxs(View, { style: [
|
|
1592
|
+
/* @__PURE__ */ jsxs(View, { style: [styles14.headerLeft, boxed ? styles14.headerLeftRow : null], children: [
|
|
1357
1593
|
boxed ? (
|
|
1358
1594
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
1359
1595
|
/* @__PURE__ */ jsx(
|
|
@@ -1362,15 +1598,15 @@ var AccordionItem = ({
|
|
|
1362
1598
|
accessibilityElementsHidden: true,
|
|
1363
1599
|
"aria-hidden": true,
|
|
1364
1600
|
importantForAccessibility: "no-hide-descendants",
|
|
1365
|
-
style: [
|
|
1601
|
+
style: [styles14.marker, { transform: [{ rotate }] }],
|
|
1366
1602
|
testID: chevronTestID,
|
|
1367
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1603
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles14.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
1368
1604
|
}
|
|
1369
1605
|
)
|
|
1370
1606
|
) : null,
|
|
1371
1607
|
titleNode
|
|
1372
1608
|
] }),
|
|
1373
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1609
|
+
/* @__PURE__ */ jsxs(View, { style: styles14.headerRight, children: [
|
|
1374
1610
|
right,
|
|
1375
1611
|
boxed ? null : /* @__PURE__ */ jsx(
|
|
1376
1612
|
Animated.View,
|
|
@@ -1378,7 +1614,7 @@ var AccordionItem = ({
|
|
|
1378
1614
|
accessibilityElementsHidden: true,
|
|
1379
1615
|
"aria-hidden": true,
|
|
1380
1616
|
importantForAccessibility: "no-hide-descendants",
|
|
1381
|
-
style: [
|
|
1617
|
+
style: [styles14.chevron, { transform: [{ rotate }] }],
|
|
1382
1618
|
children: /* @__PURE__ */ jsx(SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
1383
1619
|
}
|
|
1384
1620
|
)
|
|
@@ -1392,7 +1628,7 @@ var AccordionItem = ({
|
|
|
1392
1628
|
accessibilityLabel: resolvedLabel,
|
|
1393
1629
|
nativeID: bodyTestID,
|
|
1394
1630
|
role: ROLE_REGION,
|
|
1395
|
-
style: boxed ?
|
|
1631
|
+
style: boxed ? styles14.boxBody : styles14.body,
|
|
1396
1632
|
testID: bodyTestID,
|
|
1397
1633
|
children
|
|
1398
1634
|
}
|
|
@@ -1455,7 +1691,7 @@ function useAvailableWidth() {
|
|
|
1455
1691
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
1456
1692
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
1457
1693
|
var UNMEASURED2 = 0;
|
|
1458
|
-
var
|
|
1694
|
+
var styles15 = StyleSheet.create({
|
|
1459
1695
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
1460
1696
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
1461
1697
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -1486,7 +1722,7 @@ var TruncatedText = ({
|
|
|
1486
1722
|
[value, measureRef]
|
|
1487
1723
|
);
|
|
1488
1724
|
const flatStyle = useMemo(
|
|
1489
|
-
() => StyleSheet.flatten([
|
|
1725
|
+
() => StyleSheet.flatten([styles15.base, style]),
|
|
1490
1726
|
[style]
|
|
1491
1727
|
);
|
|
1492
1728
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
@@ -1501,7 +1737,7 @@ var TruncatedText = ({
|
|
|
1501
1737
|
ref: attachRef,
|
|
1502
1738
|
onLayout,
|
|
1503
1739
|
numberOfLines: 1,
|
|
1504
|
-
style: [
|
|
1740
|
+
style: [styles15.base, styles15.fill, style],
|
|
1505
1741
|
testID,
|
|
1506
1742
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
1507
1743
|
accessibilityLabel,
|
|
@@ -1604,7 +1840,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
1604
1840
|
var ACTION_PADDING_H = 6;
|
|
1605
1841
|
var ACTION_PADDING_V = 2;
|
|
1606
1842
|
var ACTION_RADIUS = 6;
|
|
1607
|
-
var
|
|
1843
|
+
var styles16 = StyleSheet.create({
|
|
1608
1844
|
cell: { gap: CELL_GAP },
|
|
1609
1845
|
label: {
|
|
1610
1846
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -1663,14 +1899,14 @@ var CopyableId = ({
|
|
|
1663
1899
|
const { colors } = theme;
|
|
1664
1900
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
1665
1901
|
const action = useActionState(status);
|
|
1666
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
1667
|
-
label !== void 0 && /* @__PURE__ */ jsx(Text, { style: [
|
|
1668
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
1669
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
1902
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles16.cell, style], testID, children: [
|
|
1903
|
+
label !== void 0 && /* @__PURE__ */ jsx(Text, { style: [styles16.label, { color: colors.textSecondary }], children: label }),
|
|
1904
|
+
/* @__PURE__ */ jsxs(View, { style: styles16.row, children: [
|
|
1905
|
+
/* @__PURE__ */ jsx(View, { style: styles16.valueWrap, children: /* @__PURE__ */ jsx(
|
|
1670
1906
|
TruncatedText,
|
|
1671
1907
|
{
|
|
1672
1908
|
value,
|
|
1673
|
-
style: [
|
|
1909
|
+
style: [styles16.value, { color: colors.text }],
|
|
1674
1910
|
testID: `${testID}-value`,
|
|
1675
1911
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
1676
1912
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -1684,7 +1920,7 @@ var CopyableId = ({
|
|
|
1684
1920
|
accessibilityLabel: t(action.key),
|
|
1685
1921
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
1686
1922
|
testID: `${testID}-copy`,
|
|
1687
|
-
style: [
|
|
1923
|
+
style: [styles16.action, { color: action.color }],
|
|
1688
1924
|
children: t(action.key)
|
|
1689
1925
|
}
|
|
1690
1926
|
)
|
|
@@ -1692,6 +1928,6 @@ var CopyableId = ({
|
|
|
1692
1928
|
] });
|
|
1693
1929
|
};
|
|
1694
1930
|
|
|
1695
|
-
export { Accordion, AccordionItem, COPY_FEEDBACK_MS, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_I18N, LAYOUT_TEST_IDS, ModalDropdown, ModalShell, Section, SegmentedControl, StatusBadge, Tabs, TruncatedText, UpgradePrompt, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
|
|
1931
|
+
export { Accordion, AccordionItem, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_I18N, LAYOUT_TEST_IDS, Modal3 as Modal, ModalDropdown, ModalShell, Section, SegmentedControl, StatusBadge, Tabs, TabsCollapsedTrigger, TruncatedText, UpgradePrompt, copyText, formatUrlForDisplay, truncateMiddle, useCopyToClipboard, useFocusTrap };
|
|
1696
1932
|
//# sourceMappingURL=index.mjs.map
|
|
1697
1933
|
//# sourceMappingURL=index.mjs.map
|