@dloizides/ui-layout 1.25.0 → 1.26.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/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: {
@@ -582,6 +586,7 @@ var InlineMenu = ({
582
586
  value,
583
587
  options,
584
588
  containerRef,
589
+ isOpen,
585
590
  optionTestID,
586
591
  menuMinWidth = 0,
587
592
  animatedStyle,
@@ -613,7 +618,7 @@ var InlineMenu = ({
613
618
  useMenuKeyboard({
614
619
  containerRef,
615
620
  menuRef,
616
- enabled: true,
621
+ enabled: isOpen,
617
622
  itemCount: options.length,
618
623
  onHighlightChange: setHighlightedIndex,
619
624
  onSelectHighlighted: selectHighlighted,
@@ -852,6 +857,7 @@ var ModalDropdown = ({
852
857
  accessibilityLabel,
853
858
  animatedStyle: menuAnim.style,
854
859
  containerRef: anchorRef,
860
+ isOpen,
855
861
  menuMinWidth,
856
862
  optionTestID: optionTestIDFor,
857
863
  options,
@@ -1961,6 +1967,94 @@ var CopyableId = ({
1961
1967
  ] });
1962
1968
  };
1963
1969
 
1964
- 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 };
1970
+ // src/BuildInfoFooter/formatBuildInfo.ts
1971
+ var BUILD_INFO_PREFIX = "v";
1972
+ var API_COMMIT_SEPARATOR = " \xB7 api ";
1973
+ var SHORT_COMMIT_LENGTH = 7;
1974
+ function shortenCommit(commit) {
1975
+ return commit.trim().slice(0, SHORT_COMMIT_LENGTH);
1976
+ }
1977
+ function trimTrailingSlash(url) {
1978
+ return url.endsWith("/") ? url.slice(0, -1) : url;
1979
+ }
1980
+ function formatBuildInfo(buildVersion, apiCommit) {
1981
+ const base = `${BUILD_INFO_PREFIX}${buildVersion.trim()}`;
1982
+ const commit = apiCommit?.trim();
1983
+ if (commit === void 0 || commit === "") return base;
1984
+ return `${base}${API_COMMIT_SEPARATOR}${shortenCommit(commit)}`;
1985
+ }
1986
+ function useApiCommit(apiBaseUrl, fetchImpl) {
1987
+ const [commit, setCommit] = useState(void 0);
1988
+ const mountedRef = useRef(true);
1989
+ useEffect(() => {
1990
+ mountedRef.current = true;
1991
+ return () => {
1992
+ mountedRef.current = false;
1993
+ };
1994
+ }, []);
1995
+ useEffect(() => {
1996
+ if (apiBaseUrl === void 0 || apiBaseUrl === "") return;
1997
+ const doFetch = fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
1998
+ if (doFetch === void 0) return;
1999
+ void (async () => {
2000
+ try {
2001
+ const res = await doFetch(`${trimTrailingSlash(apiBaseUrl)}/version`);
2002
+ if (!res.ok) return;
2003
+ const body = await res.json();
2004
+ const value = body.commit;
2005
+ if (mountedRef.current && value !== void 0 && value !== "") setCommit(value);
2006
+ } catch {
2007
+ return;
2008
+ }
2009
+ })();
2010
+ }, [apiBaseUrl, fetchImpl]);
2011
+ return commit;
2012
+ }
2013
+ var FOOTER_PADDING_V = 6;
2014
+ var FOOTER_PADDING_H = 12;
2015
+ var FOOTER_FONT_SIZE = 11;
2016
+ var FOOTER_OPACITY = 0.75;
2017
+ var styles17 = StyleSheet.create({
2018
+ footer: {
2019
+ paddingVertical: FOOTER_PADDING_V,
2020
+ paddingHorizontal: FOOTER_PADDING_H,
2021
+ alignItems: "center"
2022
+ },
2023
+ text: {
2024
+ fontSize: FOOTER_FONT_SIZE,
2025
+ opacity: FOOTER_OPACITY
2026
+ }
2027
+ });
2028
+ var BuildInfoFooter = ({
2029
+ buildVersion,
2030
+ apiBaseUrl,
2031
+ apiCommit,
2032
+ fetchImpl,
2033
+ testID = LAYOUT_TEST_IDS.buildInfoFooter,
2034
+ accessibilityLabel,
2035
+ accessibilityHint,
2036
+ style
2037
+ }) => {
2038
+ const { theme, t } = useUi();
2039
+ const fetchedCommit = useApiCommit(apiCommit === void 0 ? apiBaseUrl : void 0, fetchImpl);
2040
+ const commit = apiCommit ?? fetchedCommit;
2041
+ const label = formatBuildInfo(buildVersion, commit);
2042
+ const textStyle = useMemo(
2043
+ () => [styles17.text, { color: theme.colors.textSecondary }],
2044
+ [theme.colors.textSecondary]
2045
+ );
2046
+ return /* @__PURE__ */ jsx(
2047
+ View,
2048
+ {
2049
+ accessibilityLabel: accessibilityLabel ?? label,
2050
+ accessibilityHint: accessibilityHint ?? t(LAYOUT_I18N.buildInfoHint),
2051
+ style: [styles17.footer, style],
2052
+ testID,
2053
+ children: /* @__PURE__ */ jsx(Text, { style: textStyle, children: label })
2054
+ }
2055
+ );
2056
+ };
2057
+
2058
+ 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 };
1965
2059
  //# sourceMappingURL=index.mjs.map
1966
2060
  //# sourceMappingURL=index.mjs.map