@dloizides/ui-layout 1.38.2 → 1.39.2
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 +7 -0
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +267 -148
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +179 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React13, { createContext, useMemo, useState, useRef, useEffect, useCallback, useContext, useLayoutEffect } from 'react';
|
|
2
2
|
import { StyleSheet, Platform, View, Text, useWindowDimensions, Modal as Modal$1, Animated, TouchableOpacity, ScrollView, Pressable, FlatList, Easing } from 'react-native';
|
|
3
3
|
import { MODAL_OVERLAY_COLOR, useUi } from '@dloizides/ui-feedback';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -38,7 +38,7 @@ var Section = ({
|
|
|
38
38
|
const { theme } = useUi();
|
|
39
39
|
const isCard = variant === "card" /* Card */;
|
|
40
40
|
const fill = isCard ? theme.colors.background : theme.colors.surface;
|
|
41
|
-
const containerStyle =
|
|
41
|
+
const containerStyle = React13.useMemo(
|
|
42
42
|
() => [styles.card, isCard ? styles.raised : null, { borderColor: theme.colors.border, backgroundColor: fill }, style],
|
|
43
43
|
[theme.colors.border, fill, isCard, style]
|
|
44
44
|
);
|
|
@@ -99,6 +99,7 @@ var LAYOUT_TEST_IDS = {
|
|
|
99
99
|
modalShellClose: "cancel-button",
|
|
100
100
|
/** Default base testID for the centered `Modal`; ✕ is `modal-close`, backdrop `modal-backdrop`. */
|
|
101
101
|
modal: "modal",
|
|
102
|
+
sideSheet: "side-sheet",
|
|
102
103
|
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
103
104
|
confirmDialog: "confirm-dialog",
|
|
104
105
|
accordion: "accordion",
|
|
@@ -206,7 +207,7 @@ var Heading = ({
|
|
|
206
207
|
testID
|
|
207
208
|
}) => {
|
|
208
209
|
const { theme } = useUi();
|
|
209
|
-
const headingStyle =
|
|
210
|
+
const headingStyle = React13.useMemo(
|
|
210
211
|
() => [styles3.heading, { color: theme.colors.text }, style],
|
|
211
212
|
[theme.colors.text, style]
|
|
212
213
|
);
|
|
@@ -765,6 +766,9 @@ var BORDER_RADIUS = 8;
|
|
|
765
766
|
var BORDER_WIDTH2 = 1;
|
|
766
767
|
var MENU_PADDING = 4;
|
|
767
768
|
var MENU_SCROLL_MAX_HEIGHT = MENU_MAX_HEIGHT - (BORDER_WIDTH2 + MENU_PADDING) * 2;
|
|
769
|
+
function menuScrollMaxHeight(popoverMaxHeight) {
|
|
770
|
+
return Math.max(0, popoverMaxHeight - (BORDER_WIDTH2 + MENU_PADDING) * 2);
|
|
771
|
+
}
|
|
768
772
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
769
773
|
var MENU_VIEWPORT_MARGIN = 8;
|
|
770
774
|
var COMPACT_TRIGGER_MENU_MIN_WIDTH = 160;
|
|
@@ -772,7 +776,18 @@ function resolveMenuMinWidth(menuMinWidth, hasCustomTrigger) {
|
|
|
772
776
|
if (menuMinWidth !== void 0) return menuMinWidth;
|
|
773
777
|
return hasCustomTrigger ? COMPACT_TRIGGER_MENU_MIN_WIDTH : void 0;
|
|
774
778
|
}
|
|
775
|
-
function
|
|
779
|
+
function resolveMenuPlacement(rect, viewportHeight, menuHeight) {
|
|
780
|
+
if (viewportHeight <= 0) return { top: rect.bottom + MENU_TOP_GAP, maxHeight: MENU_MAX_HEIGHT };
|
|
781
|
+
const top = Math.max(MENU_VIEWPORT_MARGIN, rect.bottom + MENU_TOP_GAP);
|
|
782
|
+
const bottom = Math.max(MENU_VIEWPORT_MARGIN, viewportHeight - rect.top + MENU_TOP_GAP);
|
|
783
|
+
const roomBelow = viewportHeight - top - MENU_VIEWPORT_MARGIN;
|
|
784
|
+
const roomAbove = viewportHeight - bottom - MENU_VIEWPORT_MARGIN;
|
|
785
|
+
const fitsBelow = roomBelow >= Math.min(menuHeight, MENU_MAX_HEIGHT);
|
|
786
|
+
const cap = (room) => Math.max(0, Math.min(MENU_MAX_HEIGHT, room));
|
|
787
|
+
if (!fitsBelow && roomAbove > roomBelow) return { bottom, maxHeight: cap(roomAbove) };
|
|
788
|
+
return { top, maxHeight: cap(roomBelow) };
|
|
789
|
+
}
|
|
790
|
+
function buildPortalPopoverStyle(rect, minWidth = 0, viewportWidth = 0, placement = resolveMenuPlacement(rect, 0, MENU_MAX_HEIGHT)) {
|
|
776
791
|
const width = Math.max(rect.width, minWidth);
|
|
777
792
|
let left = rect.left;
|
|
778
793
|
if (viewportWidth > 0) {
|
|
@@ -783,14 +798,13 @@ function buildPortalPopoverStyle(rect, minWidth = 0, viewportWidth = 0) {
|
|
|
783
798
|
// RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
|
|
784
799
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
|
|
785
800
|
position: "fixed",
|
|
786
|
-
|
|
801
|
+
...placement,
|
|
787
802
|
left,
|
|
788
803
|
width,
|
|
789
804
|
zIndex: MENU_Z_INDEX,
|
|
790
805
|
borderWidth: BORDER_WIDTH2,
|
|
791
806
|
borderRadius: BORDER_RADIUS,
|
|
792
807
|
padding: MENU_PADDING,
|
|
793
|
-
maxHeight: MENU_MAX_HEIGHT,
|
|
794
808
|
boxShadow: MENU_BOX_SHADOW,
|
|
795
809
|
elevation: MENU_ELEVATION
|
|
796
810
|
};
|
|
@@ -1069,6 +1083,29 @@ function useMenuKeyboard(params) {
|
|
|
1069
1083
|
}, [containerRef, menuRef, enabled, onClose, params]);
|
|
1070
1084
|
}
|
|
1071
1085
|
var IS_WEB2 = Platform.OS === "web";
|
|
1086
|
+
var UNMEASURED_RECT = { top: 0, bottom: 0 };
|
|
1087
|
+
function readViewportHeight() {
|
|
1088
|
+
return IS_WEB2 && typeof window !== "undefined" ? window.innerHeight : 0;
|
|
1089
|
+
}
|
|
1090
|
+
function useMenuPlacement(rect, menuRef, itemCount) {
|
|
1091
|
+
const [menuHeight, setMenuHeight] = useState(MENU_MAX_HEIGHT);
|
|
1092
|
+
const [viewportHeight, setViewportHeight] = useState(readViewportHeight);
|
|
1093
|
+
useLayoutEffect(() => {
|
|
1094
|
+
const measured = toDomNode(menuRef)?.offsetHeight ?? 0;
|
|
1095
|
+
if (measured > 0) setMenuHeight(measured);
|
|
1096
|
+
}, [menuRef, itemCount]);
|
|
1097
|
+
useLayoutEffect(() => {
|
|
1098
|
+
if (!IS_WEB2) return void 0;
|
|
1099
|
+
const onResize = () => setViewportHeight(readViewportHeight());
|
|
1100
|
+
window.addEventListener("resize", onResize);
|
|
1101
|
+
return () => window.removeEventListener("resize", onResize);
|
|
1102
|
+
}, []);
|
|
1103
|
+
return useMemo(
|
|
1104
|
+
() => resolveMenuPlacement(rect ?? UNMEASURED_RECT, viewportHeight, menuHeight),
|
|
1105
|
+
[rect, viewportHeight, menuHeight]
|
|
1106
|
+
);
|
|
1107
|
+
}
|
|
1108
|
+
var IS_WEB3 = Platform.OS === "web";
|
|
1072
1109
|
var BORDER_RADIUS2 = 8;
|
|
1073
1110
|
var BORDER_WIDTH3 = 1;
|
|
1074
1111
|
var MENU_PADDING2 = 4;
|
|
@@ -1091,7 +1128,8 @@ var styles11 = StyleSheet.create({
|
|
|
1091
1128
|
// The enter/exit fade+scale lives on an INNER wrapper so the outer popover keeps its raw DOM
|
|
1092
1129
|
// node (the `menuRef` outside-click / keyboard logic and the web portal target depend on it).
|
|
1093
1130
|
// `transformOrigin: 'top'` makes the scale grow downward FROM the anchor rather than the centre.
|
|
1094
|
-
animated: { transformOrigin: "top" },
|
|
1131
|
+
animated: { transformOrigin: "top", flexShrink: 1 },
|
|
1132
|
+
animatedAbove: { transformOrigin: "bottom" },
|
|
1095
1133
|
// Exit fade only: the dying popover must not receive the next click. See the file header.
|
|
1096
1134
|
inert: { pointerEvents: "none" },
|
|
1097
1135
|
// Bound the scroll viewport so a list longer than the popover scrolls (with a scrollbar) instead of
|
|
@@ -1117,6 +1155,8 @@ var InlineMenu = ({
|
|
|
1117
1155
|
const { colors } = theme;
|
|
1118
1156
|
const menuRef = useRef(null);
|
|
1119
1157
|
const rect = useAnchorTracking(containerRef, onClose);
|
|
1158
|
+
const placement = useMenuPlacement(rect, menuRef, options.length);
|
|
1159
|
+
const opensAbove = placement.bottom !== void 0;
|
|
1120
1160
|
const selectedIndex = useMemo(
|
|
1121
1161
|
() => Math.max(0, options.findIndex((opt) => opt.value === value)),
|
|
1122
1162
|
[options, value]
|
|
@@ -1152,15 +1192,16 @@ var InlineMenu = ({
|
|
|
1152
1192
|
});
|
|
1153
1193
|
const popoverStyle = useMemo(() => {
|
|
1154
1194
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
1155
|
-
if (
|
|
1195
|
+
if (IS_WEB3) {
|
|
1156
1196
|
const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 0;
|
|
1157
1197
|
return [
|
|
1158
|
-
buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth, viewportWidth),
|
|
1198
|
+
buildPortalPopoverStyle(rect ?? { top: 0, left: 0, width: 0, bottom: 0 }, menuMinWidth, viewportWidth, placement),
|
|
1159
1199
|
themed
|
|
1160
1200
|
];
|
|
1161
1201
|
}
|
|
1162
1202
|
return [styles11.popover, { minWidth: menuMinWidth }, themed];
|
|
1163
|
-
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
1203
|
+
}, [colors.border, colors.surface, menuMinWidth, placement, rect]);
|
|
1204
|
+
const scrollStyle = IS_WEB3 ? { maxHeight: menuScrollMaxHeight(placement.maxHeight) } : styles11.scroll;
|
|
1164
1205
|
const menu = /* @__PURE__ */ jsx(
|
|
1165
1206
|
View,
|
|
1166
1207
|
{
|
|
@@ -1174,10 +1215,10 @@ var InlineMenu = ({
|
|
|
1174
1215
|
Animated.View,
|
|
1175
1216
|
{
|
|
1176
1217
|
pointerEvents: isOpen ? "auto" : "none",
|
|
1177
|
-
style: [styles11.animated, animatedStyle, isOpen ? null : styles11.inert],
|
|
1218
|
+
style: [styles11.animated, opensAbove ? styles11.animatedAbove : null, animatedStyle, isOpen ? null : styles11.inert],
|
|
1178
1219
|
children: [
|
|
1179
1220
|
menuHeading !== void 0 ? /* @__PURE__ */ jsx(MenuHeading, { testID, text: menuHeading }) : null,
|
|
1180
|
-
/* @__PURE__ */ jsx(ScrollView, { style:
|
|
1221
|
+
/* @__PURE__ */ jsx(ScrollView, { style: scrollStyle, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
1181
1222
|
OptionRow,
|
|
1182
1223
|
{
|
|
1183
1224
|
asMenuItem: true,
|
|
@@ -1195,7 +1236,7 @@ var InlineMenu = ({
|
|
|
1195
1236
|
)
|
|
1196
1237
|
}
|
|
1197
1238
|
);
|
|
1198
|
-
if (
|
|
1239
|
+
if (IS_WEB3) return createPortal(menu, document.body);
|
|
1199
1240
|
return menu;
|
|
1200
1241
|
};
|
|
1201
1242
|
var MENU_BREAKPOINT = LAYOUT_COLLAPSE_BREAKPOINT;
|
|
@@ -1739,7 +1780,7 @@ var ModalShell = ({
|
|
|
1739
1780
|
}) => {
|
|
1740
1781
|
const { theme, t } = useUi();
|
|
1741
1782
|
const { style: sheetStyle, mounted } = useEnterExit({ visible, fromScale: PANEL_ENTER_SCALE2 });
|
|
1742
|
-
const containerStyle =
|
|
1783
|
+
const containerStyle = React13.useMemo(
|
|
1743
1784
|
() => [styles15.container, { backgroundColor: theme.colors.background }, contentStyle],
|
|
1744
1785
|
[theme.colors.background, contentStyle]
|
|
1745
1786
|
);
|
|
@@ -1782,10 +1823,87 @@ var ModalShell = ({
|
|
|
1782
1823
|
}
|
|
1783
1824
|
);
|
|
1784
1825
|
};
|
|
1826
|
+
var SHEET_WIDTH = 560;
|
|
1827
|
+
var PHONE_CORNER = 16;
|
|
1828
|
+
var PHONE_ENTER_OFFSET = 24;
|
|
1829
|
+
var styles16 = StyleSheet.create({
|
|
1830
|
+
root: { flex: 1 },
|
|
1831
|
+
scrim: { backgroundColor: MODAL_OVERLAY_COLOR, pointerEvents: "none" },
|
|
1832
|
+
sheet: { position: "absolute", bottom: 0, overflow: "hidden" },
|
|
1833
|
+
wide: { top: 0, right: 0, width: SHEET_WIDTH, maxWidth: "100%", borderLeftWidth: 1 },
|
|
1834
|
+
phone: {
|
|
1835
|
+
top: MIN_TARGET_PX,
|
|
1836
|
+
left: 0,
|
|
1837
|
+
right: 0,
|
|
1838
|
+
borderTopLeftRadius: PHONE_CORNER,
|
|
1839
|
+
borderTopRightRadius: PHONE_CORNER
|
|
1840
|
+
},
|
|
1841
|
+
title: { paddingHorizontal: 16, paddingTop: 16 },
|
|
1842
|
+
scroll: { flex: 1 },
|
|
1843
|
+
content: { padding: 16, gap: 12 },
|
|
1844
|
+
bar: { flexDirection: "row", justifyContent: "flex-end", gap: 8, padding: 16, borderTopWidth: 1 }
|
|
1845
|
+
});
|
|
1846
|
+
var SideSheet = ({
|
|
1847
|
+
visible,
|
|
1848
|
+
onClose,
|
|
1849
|
+
title,
|
|
1850
|
+
children,
|
|
1851
|
+
footer,
|
|
1852
|
+
testID = LAYOUT_TEST_IDS.sideSheet,
|
|
1853
|
+
accessibilityLabel,
|
|
1854
|
+
initialFocusTestID
|
|
1855
|
+
}) => {
|
|
1856
|
+
const { theme, t } = useUi();
|
|
1857
|
+
const isWide = useIsWideViewport();
|
|
1858
|
+
const sheetRef = useRef(null);
|
|
1859
|
+
const backdrop = useEnterExit({ visible });
|
|
1860
|
+
const panel = useEnterExit({ visible, translateY: isWide ? 0 : PHONE_ENTER_OFFSET });
|
|
1861
|
+
const edges = { borderColor: theme.colors.border };
|
|
1862
|
+
useFocusTrap(sheetRef, visible && panel.mounted, initialFocusTestID);
|
|
1863
|
+
useEscapeKey(visible, onClose);
|
|
1864
|
+
useScrollLock(visible);
|
|
1865
|
+
return /* @__PURE__ */ jsx(Modal$1, { transparent: true, visible: panel.mounted || backdrop.mounted, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { style: styles16.root, children: [
|
|
1866
|
+
/* @__PURE__ */ jsx(Animated.View, { style: [StyleSheet.absoluteFill, styles16.scrim, { opacity: backdrop.style.opacity }] }),
|
|
1867
|
+
/* @__PURE__ */ jsx(
|
|
1868
|
+
Pressable,
|
|
1869
|
+
{
|
|
1870
|
+
accessibilityHint: t(LAYOUT_I18N.closeDialogHint),
|
|
1871
|
+
accessibilityLabel: t(LAYOUT_I18N.dialogClose),
|
|
1872
|
+
accessibilityRole: "button",
|
|
1873
|
+
style: StyleSheet.absoluteFill,
|
|
1874
|
+
testID: `${testID}-scrim`,
|
|
1875
|
+
onPress: onClose
|
|
1876
|
+
}
|
|
1877
|
+
),
|
|
1878
|
+
/* @__PURE__ */ jsxs(
|
|
1879
|
+
Animated.View,
|
|
1880
|
+
{
|
|
1881
|
+
ref: sheetRef,
|
|
1882
|
+
accessibilityViewIsModal: true,
|
|
1883
|
+
"aria-modal": true,
|
|
1884
|
+
"aria-label": accessibilityLabel ?? title,
|
|
1885
|
+
role: "dialog",
|
|
1886
|
+
style: [
|
|
1887
|
+
styles16.sheet,
|
|
1888
|
+
isWide ? styles16.wide : styles16.phone,
|
|
1889
|
+
edges,
|
|
1890
|
+
{ backgroundColor: theme.colors.surface },
|
|
1891
|
+
panel.style
|
|
1892
|
+
],
|
|
1893
|
+
testID,
|
|
1894
|
+
children: [
|
|
1895
|
+
/* @__PURE__ */ jsx(View, { style: styles16.title, children: /* @__PURE__ */ jsx(AppText, { kind: "title" /* Title */, children: title }) }),
|
|
1896
|
+
/* @__PURE__ */ jsx(ScrollView, { contentContainerStyle: styles16.content, style: styles16.scroll, children }),
|
|
1897
|
+
/* @__PURE__ */ jsx(View, { style: [styles16.bar, edges], children: footer })
|
|
1898
|
+
]
|
|
1899
|
+
}
|
|
1900
|
+
)
|
|
1901
|
+
] }) });
|
|
1902
|
+
};
|
|
1785
1903
|
var MESSAGE_FONT_SIZE2 = 14;
|
|
1786
1904
|
var MESSAGE_LINE_HEIGHT = 20;
|
|
1787
1905
|
var BUTTON_GAP = 12;
|
|
1788
|
-
var
|
|
1906
|
+
var styles17 = StyleSheet.create({
|
|
1789
1907
|
message: { fontSize: MESSAGE_FONT_SIZE2, lineHeight: MESSAGE_LINE_HEIGHT },
|
|
1790
1908
|
footer: { flexDirection: "row", justifyContent: "flex-end", columnGap: BUTTON_GAP }
|
|
1791
1909
|
});
|
|
@@ -1804,7 +1922,7 @@ var ConfirmDialog = ({
|
|
|
1804
1922
|
const { theme, t } = useUi();
|
|
1805
1923
|
const resolvedConfirm = confirmLabel ?? t(LAYOUT_I18N.confirm);
|
|
1806
1924
|
const resolvedCancel = cancelLabel ?? t(LAYOUT_I18N.cancel);
|
|
1807
|
-
const footer = /* @__PURE__ */ jsxs(View, { style:
|
|
1925
|
+
const footer = /* @__PURE__ */ jsxs(View, { style: styles17.footer, children: [
|
|
1808
1926
|
/* @__PURE__ */ jsx(
|
|
1809
1927
|
Button,
|
|
1810
1928
|
{
|
|
@@ -1840,7 +1958,7 @@ var ConfirmDialog = ({
|
|
|
1840
1958
|
title,
|
|
1841
1959
|
visible,
|
|
1842
1960
|
onClose: onCancel,
|
|
1843
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
1961
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles17.message, { color: theme.colors.text }], testID: `${testID}-message`, children: message })
|
|
1844
1962
|
}
|
|
1845
1963
|
);
|
|
1846
1964
|
};
|
|
@@ -1853,14 +1971,14 @@ function useAccordionContext() {
|
|
|
1853
1971
|
return value;
|
|
1854
1972
|
}
|
|
1855
1973
|
var BOXED_GAP = 12;
|
|
1856
|
-
var
|
|
1974
|
+
var styles18 = StyleSheet.create({
|
|
1857
1975
|
container: { alignSelf: "stretch" },
|
|
1858
1976
|
boxed: { gap: BOXED_GAP }
|
|
1859
1977
|
});
|
|
1860
1978
|
function computeInitialOpen(children, defaultOpenIds, allowMultiple) {
|
|
1861
1979
|
const ids = new Set(defaultOpenIds ?? []);
|
|
1862
|
-
|
|
1863
|
-
if (!
|
|
1980
|
+
React13.Children.forEach(children, (child) => {
|
|
1981
|
+
if (!React13.isValidElement(child)) return;
|
|
1864
1982
|
const props = child.props;
|
|
1865
1983
|
if (props.defaultOpen === true && typeof props.id === "string") {
|
|
1866
1984
|
ids.add(props.id);
|
|
@@ -1910,7 +2028,7 @@ var Accordion = ({
|
|
|
1910
2028
|
[openSet, toggle, allowMultiple, variant]
|
|
1911
2029
|
);
|
|
1912
2030
|
const containerStyle = useMemo(() => {
|
|
1913
|
-
const base = variant === "boxed" ? [
|
|
2031
|
+
const base = variant === "boxed" ? [styles18.container, styles18.boxed] : [styles18.container];
|
|
1914
2032
|
if (style === void 0) return base;
|
|
1915
2033
|
return [...base, ...Array.isArray(style) ? style : [style]];
|
|
1916
2034
|
}, [style, variant]);
|
|
@@ -1942,7 +2060,7 @@ var BOX_TITLE_FONT_SIZE = 14;
|
|
|
1942
2060
|
var BOX_MARKER_FONT_SIZE = 13;
|
|
1943
2061
|
var BOX_MARKER_GAP = 6;
|
|
1944
2062
|
var BOX_MARKER = "\u25B8";
|
|
1945
|
-
var
|
|
2063
|
+
var styles19 = StyleSheet.create({
|
|
1946
2064
|
item: { borderTopWidth: StyleSheet.hairlineWidth },
|
|
1947
2065
|
boxItem: { borderWidth: 1, borderRadius: BOX_BORDER_RADIUS, paddingHorizontal: BOX_PADDING_H },
|
|
1948
2066
|
header: {
|
|
@@ -2018,19 +2136,19 @@ var AccordionItem = ({
|
|
|
2018
2136
|
);
|
|
2019
2137
|
const keyboardProps = Platform.OS === "web" ? { onKeyDown: handleKeyDown2 } : {};
|
|
2020
2138
|
const itemStyle = useMemo(
|
|
2021
|
-
() => boxed ? [
|
|
2139
|
+
() => boxed ? [styles19.boxItem, { borderColor: colors.border }] : [styles19.item, { borderTopColor: colors.border }],
|
|
2022
2140
|
[boxed, colors.border]
|
|
2023
2141
|
);
|
|
2024
2142
|
const headerStyle = useMemo(
|
|
2025
2143
|
() => [
|
|
2026
|
-
|
|
2027
|
-
...boxed ? [
|
|
2144
|
+
styles19.header,
|
|
2145
|
+
...boxed ? [styles19.boxHeader] : [],
|
|
2028
2146
|
{ opacity: disabled ? DISABLED_OPACITY : FULL_OPACITY }
|
|
2029
2147
|
],
|
|
2030
2148
|
[boxed, disabled]
|
|
2031
2149
|
);
|
|
2032
2150
|
const resolvedLabel = accessibilityLabel ?? (typeof title === "string" ? title : void 0);
|
|
2033
|
-
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsx(Text, { style: [boxed ?
|
|
2151
|
+
const titleNode = typeof title === "string" ? /* @__PURE__ */ jsx(Text, { style: [boxed ? styles19.boxTitle : styles19.title, { color: boxed ? colors.textSecondary : colors.text }], children: title }) : title;
|
|
2034
2152
|
return /* @__PURE__ */ jsxs(View, { style: itemStyle, children: [
|
|
2035
2153
|
/* @__PURE__ */ jsxs(
|
|
2036
2154
|
Pressable,
|
|
@@ -2047,7 +2165,7 @@ var AccordionItem = ({
|
|
|
2047
2165
|
onPress: handlePress,
|
|
2048
2166
|
...keyboardProps,
|
|
2049
2167
|
children: [
|
|
2050
|
-
/* @__PURE__ */ jsxs(View, { style: [
|
|
2168
|
+
/* @__PURE__ */ jsxs(View, { style: [styles19.headerLeft, boxed ? styles19.headerLeftRow : null], children: [
|
|
2051
2169
|
boxed ? (
|
|
2052
2170
|
// Decorative — the open/closed state is already conveyed by aria-expanded on the header.
|
|
2053
2171
|
/* @__PURE__ */ jsx(
|
|
@@ -2056,15 +2174,15 @@ var AccordionItem = ({
|
|
|
2056
2174
|
accessibilityElementsHidden: true,
|
|
2057
2175
|
"aria-hidden": true,
|
|
2058
2176
|
importantForAccessibility: "no-hide-descendants",
|
|
2059
|
-
style: [
|
|
2177
|
+
style: [styles19.marker, { transform: [{ rotate }] }],
|
|
2060
2178
|
testID: chevronTestID,
|
|
2061
|
-
children: /* @__PURE__ */ jsx(Text, { style: [
|
|
2179
|
+
children: /* @__PURE__ */ jsx(Text, { style: [styles19.markerText, { color: colors.textSecondary }], children: BOX_MARKER })
|
|
2062
2180
|
}
|
|
2063
2181
|
)
|
|
2064
2182
|
) : null,
|
|
2065
2183
|
titleNode
|
|
2066
2184
|
] }),
|
|
2067
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2185
|
+
/* @__PURE__ */ jsxs(View, { style: styles19.headerRight, children: [
|
|
2068
2186
|
right,
|
|
2069
2187
|
boxed ? null : /* @__PURE__ */ jsx(
|
|
2070
2188
|
Animated.View,
|
|
@@ -2072,7 +2190,7 @@ var AccordionItem = ({
|
|
|
2072
2190
|
accessibilityElementsHidden: true,
|
|
2073
2191
|
"aria-hidden": true,
|
|
2074
2192
|
importantForAccessibility: "no-hide-descendants",
|
|
2075
|
-
style: [
|
|
2193
|
+
style: [styles19.chevron, { transform: [{ rotate }] }],
|
|
2076
2194
|
children: /* @__PURE__ */ jsx(SvgIcon, { color: colors.textSecondary, name: "chevronDown", size: CHEVRON_SIZE, testID: chevronTestID })
|
|
2077
2195
|
}
|
|
2078
2196
|
)
|
|
@@ -2086,7 +2204,7 @@ var AccordionItem = ({
|
|
|
2086
2204
|
accessibilityLabel: resolvedLabel,
|
|
2087
2205
|
nativeID: bodyTestID,
|
|
2088
2206
|
role: ROLE_REGION,
|
|
2089
|
-
style: boxed ?
|
|
2207
|
+
style: boxed ? styles19.boxBody : styles19.body,
|
|
2090
2208
|
testID: bodyTestID,
|
|
2091
2209
|
children
|
|
2092
2210
|
}
|
|
@@ -2115,7 +2233,7 @@ function formatUrlForDisplay(value) {
|
|
|
2115
2233
|
return trimmed.length > 0 ? trimmed : value;
|
|
2116
2234
|
}
|
|
2117
2235
|
var UNMEASURED = 0;
|
|
2118
|
-
var
|
|
2236
|
+
var IS_WEB4 = Platform.OS === "web";
|
|
2119
2237
|
function measureParentInnerWidth(node) {
|
|
2120
2238
|
const parent = node.parentElement;
|
|
2121
2239
|
if (parent === null) return UNMEASURED;
|
|
@@ -2127,12 +2245,12 @@ function useAvailableWidth() {
|
|
|
2127
2245
|
const [width, setWidth] = useState(UNMEASURED);
|
|
2128
2246
|
const nodeRef = useRef(null);
|
|
2129
2247
|
const measureRef = useCallback((node) => {
|
|
2130
|
-
if (!
|
|
2248
|
+
if (!IS_WEB4) return;
|
|
2131
2249
|
nodeRef.current = node;
|
|
2132
2250
|
if (nodeRef.current !== null) setWidth(measureParentInnerWidth(nodeRef.current));
|
|
2133
2251
|
}, []);
|
|
2134
2252
|
useEffect(() => {
|
|
2135
|
-
if (!
|
|
2253
|
+
if (!IS_WEB4) return void 0;
|
|
2136
2254
|
const remeasure = () => {
|
|
2137
2255
|
const node = nodeRef.current;
|
|
2138
2256
|
if (node !== null) setWidth(measureParentInnerWidth(node));
|
|
@@ -2141,7 +2259,7 @@ function useAvailableWidth() {
|
|
|
2141
2259
|
return () => window.removeEventListener("resize", remeasure);
|
|
2142
2260
|
}, []);
|
|
2143
2261
|
const onLayout = useCallback((event) => {
|
|
2144
|
-
if (
|
|
2262
|
+
if (IS_WEB4) return;
|
|
2145
2263
|
setWidth(event.nativeEvent.layout.width);
|
|
2146
2264
|
}, []);
|
|
2147
2265
|
return { width, measureRef, onLayout };
|
|
@@ -2149,7 +2267,7 @@ function useAvailableWidth() {
|
|
|
2149
2267
|
var AVG_CHAR_WIDTH_RATIO = 0.58;
|
|
2150
2268
|
var DEFAULT_FONT_SIZE2 = 13;
|
|
2151
2269
|
var UNMEASURED2 = 0;
|
|
2152
|
-
var
|
|
2270
|
+
var styles20 = StyleSheet.create({
|
|
2153
2271
|
base: { fontSize: DEFAULT_FONT_SIZE2 },
|
|
2154
2272
|
/** `minWidth: 0` lets the text shrink inside a flex row instead of forcing the row wider. */
|
|
2155
2273
|
fill: { flexShrink: 1, minWidth: 0 }
|
|
@@ -2180,7 +2298,7 @@ var TruncatedText = ({
|
|
|
2180
2298
|
[value, measureRef]
|
|
2181
2299
|
);
|
|
2182
2300
|
const flatStyle = useMemo(
|
|
2183
|
-
() => StyleSheet.flatten([
|
|
2301
|
+
() => StyleSheet.flatten([styles20.base, style]),
|
|
2184
2302
|
[style]
|
|
2185
2303
|
);
|
|
2186
2304
|
const fontSize = flatStyle.fontSize ?? DEFAULT_FONT_SIZE2;
|
|
@@ -2195,7 +2313,7 @@ var TruncatedText = ({
|
|
|
2195
2313
|
ref: attachRef,
|
|
2196
2314
|
onLayout,
|
|
2197
2315
|
numberOfLines: 1,
|
|
2198
|
-
style: [
|
|
2316
|
+
style: [styles20.base, styles20.fill, style],
|
|
2199
2317
|
testID,
|
|
2200
2318
|
accessibilityRole: onPress !== void 0 || href !== void 0 ? "link" : "text",
|
|
2201
2319
|
accessibilityLabel,
|
|
@@ -2298,7 +2416,7 @@ var LABEL_LETTER_SPACING = 0.4;
|
|
|
2298
2416
|
var ACTION_PADDING_H = 6;
|
|
2299
2417
|
var ACTION_PADDING_V = 2;
|
|
2300
2418
|
var ACTION_RADIUS = 6;
|
|
2301
|
-
var
|
|
2419
|
+
var styles21 = StyleSheet.create({
|
|
2302
2420
|
cell: { gap: CELL_GAP },
|
|
2303
2421
|
label: {
|
|
2304
2422
|
fontSize: LABEL_FONT_SIZE,
|
|
@@ -2363,14 +2481,14 @@ var CopyableId = ({
|
|
|
2363
2481
|
const { colors } = theme;
|
|
2364
2482
|
const { status, copy } = useCopyToClipboard(value, writer);
|
|
2365
2483
|
const action = useActionState(status);
|
|
2366
|
-
return /* @__PURE__ */ jsxs(View, { style: [
|
|
2367
|
-
label !== void 0 && /* @__PURE__ */ jsx(Text, { style: [
|
|
2368
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2369
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
2484
|
+
return /* @__PURE__ */ jsxs(View, { style: [styles21.cell, style], testID, children: [
|
|
2485
|
+
label !== void 0 && /* @__PURE__ */ jsx(Text, { style: [styles21.label, { color: colors.textSecondary }], children: label }),
|
|
2486
|
+
/* @__PURE__ */ jsxs(View, { style: styles21.row, children: [
|
|
2487
|
+
/* @__PURE__ */ jsx(View, { style: styles21.valueWrap, children: /* @__PURE__ */ jsx(
|
|
2370
2488
|
TruncatedText,
|
|
2371
2489
|
{
|
|
2372
2490
|
value,
|
|
2373
|
-
style: [
|
|
2491
|
+
style: [styles21.value, { color: colors.text }],
|
|
2374
2492
|
testID: `${testID}-value`,
|
|
2375
2493
|
accessibilityLabel: accessibilityLabel ?? value,
|
|
2376
2494
|
accessibilityHint: t(LAYOUT_I18N.copyableIdHint)
|
|
@@ -2384,7 +2502,7 @@ var CopyableId = ({
|
|
|
2384
2502
|
accessibilityLabel: t(action.key),
|
|
2385
2503
|
accessibilityHint: t(LAYOUT_I18N.copyHint),
|
|
2386
2504
|
testID: `${testID}-copy`,
|
|
2387
|
-
style: [
|
|
2505
|
+
style: [styles21.action, { color: action.color }],
|
|
2388
2506
|
children: t(action.key)
|
|
2389
2507
|
}
|
|
2390
2508
|
)
|
|
@@ -2439,7 +2557,7 @@ var FOOTER_PADDING_V = 6;
|
|
|
2439
2557
|
var FOOTER_PADDING_H = 12;
|
|
2440
2558
|
var FOOTER_FONT_SIZE = 11;
|
|
2441
2559
|
var FOOTER_OPACITY = 0.75;
|
|
2442
|
-
var
|
|
2560
|
+
var styles22 = StyleSheet.create({
|
|
2443
2561
|
footer: {
|
|
2444
2562
|
paddingVertical: FOOTER_PADDING_V,
|
|
2445
2563
|
paddingHorizontal: FOOTER_PADDING_H,
|
|
@@ -2465,7 +2583,7 @@ var BuildInfoFooter = ({
|
|
|
2465
2583
|
const commit = apiCommit ?? fetchedCommit;
|
|
2466
2584
|
const label = formatBuildInfo(buildVersion, commit);
|
|
2467
2585
|
const textStyle = useMemo(
|
|
2468
|
-
() => [
|
|
2586
|
+
() => [styles22.text, { color: theme.colors.textSecondary }],
|
|
2469
2587
|
[theme.colors.textSecondary]
|
|
2470
2588
|
);
|
|
2471
2589
|
return /* @__PURE__ */ jsx(
|
|
@@ -2473,7 +2591,7 @@ var BuildInfoFooter = ({
|
|
|
2473
2591
|
{
|
|
2474
2592
|
accessibilityLabel: accessibilityLabel ?? label,
|
|
2475
2593
|
accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
|
|
2476
|
-
style: [
|
|
2594
|
+
style: [styles22.footer, style],
|
|
2477
2595
|
testID,
|
|
2478
2596
|
children: /* @__PURE__ */ jsx(Text, { style: textStyle, children: label })
|
|
2479
2597
|
}
|
|
@@ -2484,7 +2602,7 @@ var BORDER = 2;
|
|
|
2484
2602
|
var GLYPH_SIZE = 14;
|
|
2485
2603
|
var GLYPH_LINE = 16;
|
|
2486
2604
|
var TICK = "\u2713";
|
|
2487
|
-
var
|
|
2605
|
+
var styles23 = StyleSheet.create({
|
|
2488
2606
|
circle: {
|
|
2489
2607
|
width: SIZE,
|
|
2490
2608
|
height: SIZE,
|
|
@@ -2501,9 +2619,9 @@ var CheckMark = ({ filled, accent, ring, glyphColor, testID }) => /* @__PURE__ *
|
|
|
2501
2619
|
"aria-hidden": true,
|
|
2502
2620
|
accessibilityElementsHidden: true,
|
|
2503
2621
|
importantForAccessibility: "no-hide-descendants",
|
|
2504
|
-
style: [
|
|
2622
|
+
style: [styles23.circle, { borderColor: filled ? accent : ring, backgroundColor: filled ? accent : void 0 }],
|
|
2505
2623
|
testID,
|
|
2506
|
-
children: filled ? /* @__PURE__ */ jsx(Text, { style: [
|
|
2624
|
+
children: filled ? /* @__PURE__ */ jsx(Text, { style: [styles23.glyph, { color: glyphColor }], children: TICK }) : null
|
|
2507
2625
|
}
|
|
2508
2626
|
);
|
|
2509
2627
|
var ListRowToneContext = createContext(null);
|
|
@@ -2626,7 +2744,7 @@ var PAD_V = 12;
|
|
|
2626
2744
|
var GAP = 4;
|
|
2627
2745
|
var MARK_GAP = 12;
|
|
2628
2746
|
var LINE_GAP = 8;
|
|
2629
|
-
var
|
|
2747
|
+
var styles24 = StyleSheet.create({
|
|
2630
2748
|
row: {
|
|
2631
2749
|
flexDirection: "row",
|
|
2632
2750
|
alignItems: "center",
|
|
@@ -2650,7 +2768,7 @@ function focusTarget(event) {
|
|
|
2650
2768
|
}
|
|
2651
2769
|
function slot(node, color, strong) {
|
|
2652
2770
|
if (typeof node !== "string") return node;
|
|
2653
|
-
return /* @__PURE__ */ jsx(Text, { style: [
|
|
2771
|
+
return /* @__PURE__ */ jsx(Text, { style: [styles24.shrink, strong ? styles24.strong : null, { color }], children: node });
|
|
2654
2772
|
}
|
|
2655
2773
|
var ListRow = ({
|
|
2656
2774
|
title,
|
|
@@ -2682,7 +2800,7 @@ var ListRow = ({
|
|
|
2682
2800
|
style: (state) => {
|
|
2683
2801
|
const { pressed, hovered } = state;
|
|
2684
2802
|
const look = resolveRowLook(selectedStyle, { selected, pressed, focused, hovered: hovered === true }, palette);
|
|
2685
|
-
return [
|
|
2803
|
+
return [styles24.row, { borderTopColor: colors.border }, look.container];
|
|
2686
2804
|
},
|
|
2687
2805
|
testID,
|
|
2688
2806
|
onBlur: () => {
|
|
@@ -2695,14 +2813,14 @@ var ListRow = ({
|
|
|
2695
2813
|
...pressedProps(selected),
|
|
2696
2814
|
children: [
|
|
2697
2815
|
rest.showCheck ? /* @__PURE__ */ jsx(CheckMark, { accent: palette.accent, filled: rest.checkFilled, glyphColor: palette.background, ring: palette.border, testID: checkTestId }) : null,
|
|
2698
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2699
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2816
|
+
/* @__PURE__ */ jsxs(View, { style: styles24.body, children: [
|
|
2817
|
+
/* @__PURE__ */ jsxs(View, { style: styles24.line, children: [
|
|
2700
2818
|
slot(title, rest.titleColor, true),
|
|
2701
2819
|
slot(trailing, rest.textColor, true)
|
|
2702
2820
|
] }),
|
|
2703
|
-
/* @__PURE__ */ jsxs(View, { style:
|
|
2704
|
-
/* @__PURE__ */ jsx(View, { style:
|
|
2705
|
-
badges === void 0 ? null : /* @__PURE__ */ jsx(View, { style:
|
|
2821
|
+
/* @__PURE__ */ jsxs(View, { style: styles24.line, children: [
|
|
2822
|
+
/* @__PURE__ */ jsx(View, { style: styles24.shrink, children: slot(meta, rest.textColor, false) }),
|
|
2823
|
+
badges === void 0 ? null : /* @__PURE__ */ jsx(View, { style: styles24.badges, children: badges })
|
|
2706
2824
|
] })
|
|
2707
2825
|
] })
|
|
2708
2826
|
]
|
|
@@ -2712,6 +2830,6 @@ var ListRow = ({
|
|
|
2712
2830
|
] });
|
|
2713
2831
|
};
|
|
2714
2832
|
|
|
2715
|
-
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, Modal, ModalDropdown, ModalShell, PageFrame, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
2833
|
+
export { A4_PAGE, API_COMMIT_SEPARATOR, Accordion, AccordionItem, AppText, BUILD_INFO_PREFIX, BuildInfoFooter, COPY_FEEDBACK_MS, ConfirmDialog, CopyStatus, CopyableId, DEFAULT_BILLING_ROUTE, DropdownVariant, ELLIPSIS, Heading, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, ListRow, MIN_TARGET_PX, Modal, ModalDropdown, ModalShell, PageFrame, RowSelectedStyle, ScreenColumn, Section, SectionVariant, SegmentedControl, SelectedMarker, SideSheet, StatusBadge, StickyPreview, TYPE_SCALE_BREAKPOINT, Tabs, TabsCollapsedTrigger, TextKind, TruncatedText, UpgradePrompt, copyText, formatBuildInfo, formatUrlForDisplay, isKeyboardOpen, isWideWebViewport, pageScale, resolveRowLook, scaledFrame, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap, useIsWideViewport, useListRowTone, useVisibleViewport };
|
|
2716
2834
|
//# sourceMappingURL=index.mjs.map
|
|
2717
2835
|
//# sourceMappingURL=index.mjs.map
|