@dloizides/ui-layout 1.30.0 → 1.31.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/dist/index.d.mts CHANGED
@@ -248,6 +248,12 @@ interface DropdownOption<T> {
248
248
  readonly value: T;
249
249
  }
250
250
 
251
+ /** How a dropdown option row marks the currently selected value. */
252
+ declare enum SelectedMarker {
253
+ Bold = "bold",
254
+ AccentCheck = "accent-check"
255
+ }
256
+
251
257
  /**
252
258
  * ModalDropdown — generic dropdown selector (any value type via generics).
253
259
  *
@@ -322,8 +328,10 @@ interface ModalDropdownProps<T> {
322
328
  showHamburger?: boolean;
323
329
  /** Visible, non-focusable heading at the top of the open menu; it also names the menu. */
324
330
  menuHeading?: string;
331
+ /** How the selected option is marked; `AccentCheck` = accent left bar + check. */
332
+ selectedMarker?: SelectedMarker;
325
333
  }
326
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, menuHeading, }: ModalDropdownProps<T>) => React.ReactElement;
334
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, menuHeading, selectedMarker, }: ModalDropdownProps<T>) => React.ReactElement;
327
335
 
328
336
  /**
329
337
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -892,4 +900,4 @@ declare const MIN_TARGET_PX = 44;
892
900
  */
893
901
  declare function isWideWebViewport(width: number, platformOS: string, breakpoint?: number): boolean;
894
902
 
895
- export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
903
+ export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
package/dist/index.d.ts CHANGED
@@ -248,6 +248,12 @@ interface DropdownOption<T> {
248
248
  readonly value: T;
249
249
  }
250
250
 
251
+ /** How a dropdown option row marks the currently selected value. */
252
+ declare enum SelectedMarker {
253
+ Bold = "bold",
254
+ AccentCheck = "accent-check"
255
+ }
256
+
251
257
  /**
252
258
  * ModalDropdown — generic dropdown selector (any value type via generics).
253
259
  *
@@ -322,8 +328,10 @@ interface ModalDropdownProps<T> {
322
328
  showHamburger?: boolean;
323
329
  /** Visible, non-focusable heading at the top of the open menu; it also names the menu. */
324
330
  menuHeading?: string;
331
+ /** How the selected option is marked; `AccentCheck` = accent left bar + check. */
332
+ selectedMarker?: SelectedMarker;
325
333
  }
326
- declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, menuHeading, }: ModalDropdownProps<T>) => React.ReactElement;
334
+ declare const ModalDropdown: <T extends string | number>({ testID, accessibilityLabel, accessibilityHint, value, options, onChange, variant, renderTrigger, optionTestID, menuMinWidth, showCaret, showHamburger, menuHeading, selectedMarker, }: ModalDropdownProps<T>) => React.ReactElement;
327
335
 
328
336
  /**
329
337
  * ModalShell — a slide-up full-screen modal with a themed header (title + close button)
@@ -892,4 +900,4 @@ declare const MIN_TARGET_PX = 44;
892
900
  */
893
901
  declare function isWideWebViewport(width: number, platformOS: string, breakpoint?: number): boolean;
894
902
 
895
- export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, StatusBadge, type StatusBadgeProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
903
+ export { API_COMMIT_SEPARATOR, Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionVariant, BUILD_INFO_PREFIX, BuildInfoFooter, type BuildInfoFooterProps, COPY_FEEDBACK_MS, ConfirmDialog, type ConfirmDialogProps, CopyStatus, type CopyToClipboard, CopyableId, type CopyableIdProps, DEFAULT_BILLING_ROUTE, type DropdownOption, type DropdownTriggerState, DropdownVariant, ELLIPSIS, Heading, type HeadingLevel, type HeadingProps, LAYOUT_COLLAPSE_BREAKPOINT, LAYOUT_I18N, LAYOUT_TEST_IDS, MIN_TARGET_PX, Modal, ModalDropdown, type ModalDropdownProps, type ModalProps, ModalShell, type ModalShellProps, type ModalSize, Section, type SectionProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SelectedMarker, StatusBadge, type StatusBadgeProps, TYPE_SCALE_BREAKPOINT, type TabDescriptor, Tabs, TabsCollapsedTrigger, type TabsProps, TruncatedText, type TruncatedTextProps, UpgradePrompt, type UpgradePromptProps, type VersionResponse, copyText, formatBuildInfo, formatUrlForDisplay, isWideWebViewport, shortenCommit, trimTrailingSlash, truncateMiddle, useApiCommit, useCopyToClipboard, useFocusTrap };
package/dist/index.js CHANGED
@@ -414,11 +414,21 @@ var MenuHeading = ({ testID, text }) => {
414
414
  }
415
415
  );
416
416
  };
417
+
418
+ // src/ModalDropdown/SelectedMarker.ts
419
+ var SelectedMarker = /* @__PURE__ */ ((SelectedMarker2) => {
420
+ SelectedMarker2["Bold"] = "bold";
421
+ SelectedMarker2["AccentCheck"] = "accent-check";
422
+ return SelectedMarker2;
423
+ })(SelectedMarker || {});
417
424
  var OPTION_BORDER_RADIUS = 4;
418
425
  var BODY_FONT_SIZE = 14;
419
426
  var SELECTED_FONT_WEIGHT = "600";
420
427
  var OPTION_PADDING_H = 16;
421
428
  var OPTION_PADDING_V = 12;
429
+ var ACCENT_BAR_WIDTH = 3;
430
+ var CHECK_GAP = 8;
431
+ var CHECK_GLYPH = "\u2713";
422
432
  var styles6 = reactNative.StyleSheet.create({
423
433
  option: {
424
434
  paddingHorizontal: OPTION_PADDING_H,
@@ -428,35 +438,63 @@ var styles6 = reactNative.StyleSheet.create({
428
438
  borderRadius: OPTION_BORDER_RADIUS
429
439
  },
430
440
  optionText: { fontSize: BODY_FONT_SIZE },
431
- selectedText: { fontWeight: SELECTED_FONT_WEIGHT }
441
+ selectedText: { fontWeight: SELECTED_FONT_WEIGHT },
442
+ markedRow: {
443
+ flexDirection: "row",
444
+ alignItems: "center",
445
+ justifyContent: "space-between",
446
+ columnGap: CHECK_GAP,
447
+ borderLeftWidth: ACCENT_BAR_WIDTH,
448
+ borderLeftColor: "transparent",
449
+ paddingLeft: OPTION_PADDING_H - ACCENT_BAR_WIDTH
450
+ },
451
+ markedText: { flexShrink: 1 }
432
452
  });
433
453
  var OptionRow = ({
434
454
  testID,
435
455
  label,
436
456
  isSelected,
437
457
  isHighlighted = false,
438
- onSelect
458
+ onSelect,
459
+ selectedMarker = "bold" /* Bold */,
460
+ asMenuItem = false
439
461
  }) => {
440
462
  const { theme, t } = uiFeedback.useUi();
441
463
  const { colors } = theme;
442
464
  const handlePress = React10.useCallback(() => {
443
465
  onSelect();
444
466
  }, [onSelect]);
467
+ const accentColor = theme.palette.primary["500"];
468
+ const isMarked = selectedMarker === "accent-check" /* AccentCheck */;
445
469
  const isActive = isSelected || isHighlighted;
446
- const rowStyle = [styles6.option, isActive ? { backgroundColor: colors.surfaceElevated } : null];
447
- const textStyle = [styles6.optionText, { color: colors.text }, isSelected ? styles6.selectedText : null];
448
- return /* @__PURE__ */ jsxRuntime.jsx(
470
+ const rowStyle = [
471
+ styles6.option,
472
+ isMarked ? styles6.markedRow : null,
473
+ isActive ? { backgroundColor: colors.surfaceElevated } : null,
474
+ isMarked && isSelected ? { borderLeftColor: accentColor } : null
475
+ ];
476
+ const textStyle = [
477
+ styles6.optionText,
478
+ { color: colors.text },
479
+ isSelected ? styles6.selectedText : null,
480
+ isMarked ? styles6.markedText : null
481
+ ];
482
+ const selectionProps = asMenuItem ? { "aria-current": isSelected ? "true" : void 0 } : { "aria-selected": isSelected };
483
+ return /* @__PURE__ */ jsxRuntime.jsxs(
449
484
  reactNative.TouchableOpacity,
450
485
  {
451
486
  accessible: true,
452
487
  accessibilityHint: t(LAYOUT_I18N.selectOptionHint),
453
488
  accessibilityLabel: label,
454
- accessibilityRole: "button",
455
- "aria-selected": isSelected,
489
+ accessibilityRole: asMenuItem ? "menuitem" : "button",
490
+ ...selectionProps,
456
491
  style: rowStyle,
457
492
  testID,
458
493
  onPress: handlePress,
459
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label })
494
+ children: [
495
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: textStyle, children: label }),
496
+ isMarked && isSelected ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { "aria-hidden": true, testID: `${testID}-check`, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles6.selectedText, { color: accentColor }], children: CHECK_GLYPH }) }) : null
497
+ ]
460
498
  }
461
499
  );
462
500
  };
@@ -650,6 +688,7 @@ var InlineMenu = ({
650
688
  menuMinWidth = 0,
651
689
  menuHeading,
652
690
  animatedStyle,
691
+ selectedMarker,
653
692
  onSelect,
654
693
  onClose
655
694
  }) => {
@@ -720,9 +759,11 @@ var InlineMenu = ({
720
759
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.ScrollView, { style: styles7.scroll, keyboardShouldPersistTaps: "handled", children: options.map((option, index) => /* @__PURE__ */ jsxRuntime.jsx(
721
760
  OptionRow,
722
761
  {
762
+ asMenuItem: true,
723
763
  isHighlighted: index === highlightedIndex,
724
764
  isSelected: option.value === value,
725
765
  label: option.label,
766
+ selectedMarker,
726
767
  testID: optionTestID !== void 0 ? optionTestID(option.value) : `${testID}-option-${String(option.value)}`,
727
768
  onSelect: () => handleSelect(option.value)
728
769
  },
@@ -834,7 +875,8 @@ var ModalDropdown = ({
834
875
  menuMinWidth,
835
876
  showCaret = false,
836
877
  showHamburger = false,
837
- menuHeading
878
+ menuHeading,
879
+ selectedMarker
838
880
  }) => {
839
881
  const { theme, t } = uiFeedback.useUi();
840
882
  const { colors } = theme;
@@ -849,6 +891,8 @@ var ModalDropdown = ({
849
891
  testID
850
892
  });
851
893
  const anchorRef = React10.useRef(null);
894
+ const triggerRef = React10.useRef(null);
895
+ const popupProps = { "aria-haspopup": isMenu ? "menu" : "dialog" };
852
896
  const dialogRef = React10.useRef(null);
853
897
  useFocusTrap(dialogRef, isOpen && !isMenu);
854
898
  const menuAnim = uiMotion.useEnterExit({
@@ -875,6 +919,7 @@ var ModalDropdown = ({
875
919
  (optionValue) => {
876
920
  onChange(optionValue);
877
921
  setIsOpen(false);
922
+ triggerRef.current?.focus();
878
923
  },
879
924
  [onChange]
880
925
  );
@@ -917,15 +962,16 @@ var ModalDropdown = ({
917
962
  {
918
963
  isSelected: item.value === value,
919
964
  label: item.label,
965
+ selectedMarker,
920
966
  testID: optionTestIDFor(item.value),
921
967
  onSelect: () => handleSelect(item.value)
922
968
  }
923
969
  ),
924
- [handleSelect, optionTestIDFor, value]
970
+ [handleSelect, optionTestIDFor, selectedMarker, value]
925
971
  );
926
972
  const keyExtractor = React10.useCallback((item) => String(item.value), []);
927
973
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: anchorStyle, children: [
928
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, style: containerStyle, onPress: handleToggle, children: [
974
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.TouchableOpacity, { ...a11yProps, ...popupProps, ref: triggerRef, style: containerStyle, onPress: handleToggle, children: [
929
975
  renderTrigger !== void 0 ? renderTrigger({ label: selectedLabel, isOpen }) : isHamburger ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
930
976
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: hamburgerStyle, children: HAMBURGER_GLYPH }),
931
977
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { numberOfLines: 1, style: [styles8.selectedText, styles8.selectedTextMenu, { color: colors.text }], children: selectedLabel })
@@ -946,6 +992,7 @@ var ModalDropdown = ({
946
992
  menuMinWidth,
947
993
  optionTestID: optionTestIDFor,
948
994
  options,
995
+ selectedMarker,
949
996
  testID,
950
997
  value,
951
998
  onClose: handleClose,
@@ -2184,6 +2231,7 @@ exports.ModalDropdown = ModalDropdown;
2184
2231
  exports.ModalShell = ModalShell;
2185
2232
  exports.Section = Section;
2186
2233
  exports.SegmentedControl = SegmentedControl;
2234
+ exports.SelectedMarker = SelectedMarker;
2187
2235
  exports.StatusBadge = StatusBadge;
2188
2236
  exports.TYPE_SCALE_BREAKPOINT = TYPE_SCALE_BREAKPOINT;
2189
2237
  exports.Tabs = Tabs;