@dloizides/ui-layout 1.24.0 → 1.26.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 +20 -0
- package/dist/index.d.mts +67 -1
- package/dist/index.d.ts +67 -1
- package/dist/index.js +107 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -39,7 +39,9 @@ var LAYOUT_TEST_IDS = {
|
|
|
39
39
|
modal: "modal",
|
|
40
40
|
/** Default base testID for `ConfirmDialog`; Confirm/Cancel are `confirm-dialog-{confirm,cancel}`. */
|
|
41
41
|
confirmDialog: "confirm-dialog",
|
|
42
|
-
accordion: "accordion"
|
|
42
|
+
accordion: "accordion",
|
|
43
|
+
/** Default testID for the `BuildInfoFooter` caption (`v<version>`). */
|
|
44
|
+
buildInfoFooter: "build-info-footer"
|
|
43
45
|
};
|
|
44
46
|
var DEFAULT_BILLING_ROUTE = "/settings/billing";
|
|
45
47
|
var LAYOUT_I18N = {
|
|
@@ -93,7 +95,9 @@ var LAYOUT_I18N = {
|
|
|
93
95
|
*/
|
|
94
96
|
copyFailed: "common.copyFailed",
|
|
95
97
|
/** `CopyableId`: hint on the value itself, explaining it is shortened for display. */
|
|
96
|
-
copyableIdHint: "common.copyableIdHint"
|
|
98
|
+
copyableIdHint: "common.copyableIdHint",
|
|
99
|
+
/** `BuildInfoFooter`: accessible hint on the version caption (the visible `v<version>` is the label). */
|
|
100
|
+
buildInfoHint: "common.buildInfoHint"
|
|
97
101
|
};
|
|
98
102
|
var styles2 = StyleSheet.create({
|
|
99
103
|
heading: {
|
|
@@ -321,6 +325,7 @@ var MENU_MAX_HEIGHT = 300;
|
|
|
321
325
|
var BORDER_RADIUS = 8;
|
|
322
326
|
var BORDER_WIDTH2 = 1;
|
|
323
327
|
var MENU_PADDING = 4;
|
|
328
|
+
var MENU_SCROLL_MAX_HEIGHT = MENU_MAX_HEIGHT - (BORDER_WIDTH2 + MENU_PADDING) * 2;
|
|
324
329
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
325
330
|
var MENU_VIEWPORT_MARGIN = 8;
|
|
326
331
|
function buildPortalPopoverStyle(rect, minWidth = 0, viewportWidth = 0) {
|
|
@@ -570,7 +575,10 @@ var styles6 = StyleSheet.create({
|
|
|
570
575
|
// The enter/exit fade+scale lives on an INNER wrapper so the outer popover keeps its raw DOM
|
|
571
576
|
// node (the `menuRef` outside-click / keyboard logic and the web portal target depend on it).
|
|
572
577
|
// `transformOrigin: 'top'` makes the scale grow downward FROM the anchor rather than the centre.
|
|
573
|
-
animated: { transformOrigin: "top" }
|
|
578
|
+
animated: { transformOrigin: "top" },
|
|
579
|
+
// Bound the scroll viewport so a list longer than the popover scrolls (with a scrollbar) instead of
|
|
580
|
+
// overflowing the frame — the popover's own maxHeight cannot do this (see MENU_SCROLL_MAX_HEIGHT).
|
|
581
|
+
scroll: { maxHeight: MENU_SCROLL_MAX_HEIGHT }
|
|
574
582
|
});
|
|
575
583
|
var InlineMenu = ({
|
|
576
584
|
testID,
|
|
@@ -634,7 +642,7 @@ var InlineMenu = ({
|
|
|
634
642
|
"aria-label": accessibilityLabel,
|
|
635
643
|
style: popoverStyle,
|
|
636
644
|
testID: `${testID}-menu`,
|
|
637
|
-
children: /* @__PURE__ */ jsx(Animated.View, { style: [styles6.animated, animatedStyle], children: /* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
645
|
+
children: /* @__PURE__ */ jsx(Animated.View, { style: [styles6.animated, animatedStyle], children: /* @__PURE__ */ jsx(ScrollView, { style: styles6.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsx(
|
|
638
646
|
OptionRow,
|
|
639
647
|
{
|
|
640
648
|
isHighlighted: index === highlightedIndex,
|
|
@@ -1957,6 +1965,94 @@ var CopyableId = ({
|
|
|
1957
1965
|
] });
|
|
1958
1966
|
};
|
|
1959
1967
|
|
|
1960
|
-
|
|
1968
|
+
// src/BuildInfoFooter/formatBuildInfo.ts
|
|
1969
|
+
var BUILD_INFO_PREFIX = "v";
|
|
1970
|
+
var API_COMMIT_SEPARATOR = " \xB7 api ";
|
|
1971
|
+
var SHORT_COMMIT_LENGTH = 7;
|
|
1972
|
+
function shortenCommit(commit) {
|
|
1973
|
+
return commit.trim().slice(0, SHORT_COMMIT_LENGTH);
|
|
1974
|
+
}
|
|
1975
|
+
function trimTrailingSlash(url) {
|
|
1976
|
+
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
1977
|
+
}
|
|
1978
|
+
function formatBuildInfo(buildVersion, apiCommit) {
|
|
1979
|
+
const base = `${BUILD_INFO_PREFIX}${buildVersion.trim()}`;
|
|
1980
|
+
const commit = apiCommit?.trim();
|
|
1981
|
+
if (commit === void 0 || commit === "") return base;
|
|
1982
|
+
return `${base}${API_COMMIT_SEPARATOR}${shortenCommit(commit)}`;
|
|
1983
|
+
}
|
|
1984
|
+
function useApiCommit(apiBaseUrl, fetchImpl) {
|
|
1985
|
+
const [commit, setCommit] = useState(void 0);
|
|
1986
|
+
const mountedRef = useRef(true);
|
|
1987
|
+
useEffect(() => {
|
|
1988
|
+
mountedRef.current = true;
|
|
1989
|
+
return () => {
|
|
1990
|
+
mountedRef.current = false;
|
|
1991
|
+
};
|
|
1992
|
+
}, []);
|
|
1993
|
+
useEffect(() => {
|
|
1994
|
+
if (apiBaseUrl === void 0 || apiBaseUrl === "") return;
|
|
1995
|
+
const doFetch = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
1996
|
+
if (doFetch === void 0) return;
|
|
1997
|
+
void (async () => {
|
|
1998
|
+
try {
|
|
1999
|
+
const res = await doFetch(`${trimTrailingSlash(apiBaseUrl)}/version`);
|
|
2000
|
+
if (!res.ok) return;
|
|
2001
|
+
const body = await res.json();
|
|
2002
|
+
const value = body.commit;
|
|
2003
|
+
if (mountedRef.current && value !== void 0 && value !== "") setCommit(value);
|
|
2004
|
+
} catch {
|
|
2005
|
+
return;
|
|
2006
|
+
}
|
|
2007
|
+
})();
|
|
2008
|
+
}, [apiBaseUrl, fetchImpl]);
|
|
2009
|
+
return commit;
|
|
2010
|
+
}
|
|
2011
|
+
var FOOTER_PADDING_V = 6;
|
|
2012
|
+
var FOOTER_PADDING_H = 12;
|
|
2013
|
+
var FOOTER_FONT_SIZE = 11;
|
|
2014
|
+
var FOOTER_OPACITY = 0.75;
|
|
2015
|
+
var styles17 = StyleSheet.create({
|
|
2016
|
+
footer: {
|
|
2017
|
+
paddingVertical: FOOTER_PADDING_V,
|
|
2018
|
+
paddingHorizontal: FOOTER_PADDING_H,
|
|
2019
|
+
alignItems: "center"
|
|
2020
|
+
},
|
|
2021
|
+
text: {
|
|
2022
|
+
fontSize: FOOTER_FONT_SIZE,
|
|
2023
|
+
opacity: FOOTER_OPACITY
|
|
2024
|
+
}
|
|
2025
|
+
});
|
|
2026
|
+
var BuildInfoFooter = ({
|
|
2027
|
+
buildVersion,
|
|
2028
|
+
apiBaseUrl,
|
|
2029
|
+
apiCommit,
|
|
2030
|
+
fetchImpl,
|
|
2031
|
+
testID = LAYOUT_TEST_IDS.buildInfoFooter,
|
|
2032
|
+
accessibilityLabel,
|
|
2033
|
+
accessibilityHint,
|
|
2034
|
+
style
|
|
2035
|
+
}) => {
|
|
2036
|
+
const { theme, t } = useUi();
|
|
2037
|
+
const fetchedCommit = useApiCommit(apiCommit === void 0 ? apiBaseUrl : void 0, fetchImpl);
|
|
2038
|
+
const commit = apiCommit ?? fetchedCommit;
|
|
2039
|
+
const label = formatBuildInfo(buildVersion, commit);
|
|
2040
|
+
const textStyle = useMemo(
|
|
2041
|
+
() => [styles17.text, { color: theme.colors.textSecondary }],
|
|
2042
|
+
[theme.colors.textSecondary]
|
|
2043
|
+
);
|
|
2044
|
+
return /* @__PURE__ */ jsx(
|
|
2045
|
+
View,
|
|
2046
|
+
{
|
|
2047
|
+
accessibilityLabel: accessibilityLabel ?? label,
|
|
2048
|
+
accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
|
|
2049
|
+
style: [styles17.footer, style],
|
|
2050
|
+
testID,
|
|
2051
|
+
children: /* @__PURE__ */ jsx(Text, { style: textStyle, children: label })
|
|
2052
|
+
}
|
|
2053
|
+
);
|
|
2054
|
+
};
|
|
2055
|
+
|
|
2056
|
+
export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, BUILD_INFO_PREFIX, BuildInfoFooter, 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, formatBuildInfo, formatUrlForDisplay, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
|
|
1961
2057
|
//# sourceMappingURL=index.mjs.map
|
|
1962
2058
|
//# sourceMappingURL=index.mjs.map
|