@dloizides/ui-forms 1.27.0 → 1.28.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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.28.1
4
+
5
+ INVOICE-FU-22 "To and Cc dropdown of saved people".
6
+
7
+ - Every `SelectControl` trigger sets `aria-haspopup="listbox"`, which `useEscapeKey` in `ui-layout` reads to give Escape to the open menu.
8
+
9
+ ## 1.28.0
10
+
11
+ INVOICE-FU-22 "To and Cc dropdown of saved people", D-FU22-5 "Review findings are fixed in the packages".
12
+
13
+ - `SelectControl` gains `menuAnchor` (`listboxLabel`, `anchorRef`): the menu stays on screen, focus stays on the trigger, arrows, Enter and Space work from it, and the trigger is a combobox with `aria-activedescendant`. Callers without it are unchanged.
14
+ - `AnchoredMenu` gains `placement`; `AnchoredMenuListbox.highlightedValue` is optional.
15
+ - `nextHighlight` is exported.
16
+
3
17
  ## 1.27.0
4
18
 
5
19
  DATE-INPUT-1 "Every date or date-time field uses the shared input".
package/dist/index.d.mts CHANGED
@@ -730,6 +730,11 @@ interface DateRangeValue {
730
730
  * `{{p1}}` from one component.
731
731
  */
732
732
 
733
+ /** Opts in to a menu that stays on screen with focus on the trigger, for screen edges and focus-trapped sheets. */
734
+ interface SelectMenuAnchor {
735
+ listboxLabel: string;
736
+ anchorRef?: React.RefObject<View | null>;
737
+ }
733
738
  interface SelectControlProps {
734
739
  options: readonly ControlOption[];
735
740
  /** The selected option's `value`. `''` (or any unmatched value) renders the placeholder. */
@@ -757,12 +762,16 @@ interface SelectControlProps {
757
762
  labelledById?: string;
758
763
  /** PRE-LOCALIZED accessibility hint applied to every option in the menu. */
759
764
  optionHint?: string;
765
+ menuAnchor?: SelectMenuAnchor;
760
766
  /** Merged LAST onto the anchor wrapper — the consumer always wins over the shared style. */
761
767
  style?: StyleProp<ViewStyle>;
762
768
  /** Trigger is `${testID}-trigger`, menu `${testID}-menu`, options `${testID}-option-${value}`. */
763
769
  testID: string;
764
770
  }
765
- declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, style, testID, }: SelectControlProps): React.ReactElement;
771
+ declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, menuAnchor, style, testID, }: SelectControlProps): React.ReactElement;
772
+
773
+ /** The row index an arrow key moves to: wraps at both ends, -1 when there are no rows. */
774
+ declare function nextHighlight(current: number, count: number, delta: number): number;
766
775
 
767
776
  interface SelectFieldProps {
768
777
  label: string;
@@ -925,9 +934,13 @@ interface AnchoredMenuColors {
925
934
  brand: string;
926
935
  }
927
936
  interface AnchoredMenuListbox {
928
- highlightedValue: string;
937
+ highlightedValue?: string;
929
938
  statusText?: string;
930
939
  }
940
+ /** Web: keeps the portalled menu on screen, lined up with positionRef when given, else with anchorRef. */
941
+ interface AnchoredMenuPlacement {
942
+ positionRef?: React.RefObject<View | null>;
943
+ }
931
944
  interface AnchoredMenuProps {
932
945
  options: readonly ControlOption[];
933
946
  /** The currently-selected value, highlighted in the list ('' = none). */
@@ -961,8 +974,9 @@ interface AnchoredMenuProps {
961
974
  */
962
975
  usePortal?: boolean;
963
976
  listbox?: AnchoredMenuListbox;
977
+ placement?: AnchoredMenuPlacement;
964
978
  }
965
- declare function AnchoredMenu({ options, selectedValue, onSelect, onDismiss, colors, optionHint, accessibilityLabel, testID, anchorRef, usePortal, listbox, }: AnchoredMenuProps): React.ReactElement;
979
+ declare function AnchoredMenu({ options, selectedValue, onSelect, onDismiss, colors, optionHint, accessibilityLabel, testID, anchorRef, usePortal, listbox, placement, }: AnchoredMenuProps): React.ReactElement;
966
980
 
967
981
  declare const controlStyles: {
968
982
  /**
@@ -1210,4 +1224,4 @@ interface UploadWithLinkFieldProps {
1210
1224
  /** An image field: preview, an upload control, and a link input revealed on request. */
1211
1225
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1212
1226
 
1213
- export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
1227
+ export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuPlacement, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type SelectMenuAnchor, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, nextHighlight, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
package/dist/index.d.ts CHANGED
@@ -730,6 +730,11 @@ interface DateRangeValue {
730
730
  * `{{p1}}` from one component.
731
731
  */
732
732
 
733
+ /** Opts in to a menu that stays on screen with focus on the trigger, for screen edges and focus-trapped sheets. */
734
+ interface SelectMenuAnchor {
735
+ listboxLabel: string;
736
+ anchorRef?: React.RefObject<View | null>;
737
+ }
733
738
  interface SelectControlProps {
734
739
  options: readonly ControlOption[];
735
740
  /** The selected option's `value`. `''` (or any unmatched value) renders the placeholder. */
@@ -757,12 +762,16 @@ interface SelectControlProps {
757
762
  labelledById?: string;
758
763
  /** PRE-LOCALIZED accessibility hint applied to every option in the menu. */
759
764
  optionHint?: string;
765
+ menuAnchor?: SelectMenuAnchor;
760
766
  /** Merged LAST onto the anchor wrapper — the consumer always wins over the shared style. */
761
767
  style?: StyleProp<ViewStyle>;
762
768
  /** Trigger is `${testID}-trigger`, menu `${testID}-menu`, options `${testID}-option-${value}`. */
763
769
  testID: string;
764
770
  }
765
- declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, style, testID, }: SelectControlProps): React.ReactElement;
771
+ declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, menuAnchor, style, testID, }: SelectControlProps): React.ReactElement;
772
+
773
+ /** The row index an arrow key moves to: wraps at both ends, -1 when there are no rows. */
774
+ declare function nextHighlight(current: number, count: number, delta: number): number;
766
775
 
767
776
  interface SelectFieldProps {
768
777
  label: string;
@@ -925,9 +934,13 @@ interface AnchoredMenuColors {
925
934
  brand: string;
926
935
  }
927
936
  interface AnchoredMenuListbox {
928
- highlightedValue: string;
937
+ highlightedValue?: string;
929
938
  statusText?: string;
930
939
  }
940
+ /** Web: keeps the portalled menu on screen, lined up with positionRef when given, else with anchorRef. */
941
+ interface AnchoredMenuPlacement {
942
+ positionRef?: React.RefObject<View | null>;
943
+ }
931
944
  interface AnchoredMenuProps {
932
945
  options: readonly ControlOption[];
933
946
  /** The currently-selected value, highlighted in the list ('' = none). */
@@ -961,8 +974,9 @@ interface AnchoredMenuProps {
961
974
  */
962
975
  usePortal?: boolean;
963
976
  listbox?: AnchoredMenuListbox;
977
+ placement?: AnchoredMenuPlacement;
964
978
  }
965
- declare function AnchoredMenu({ options, selectedValue, onSelect, onDismiss, colors, optionHint, accessibilityLabel, testID, anchorRef, usePortal, listbox, }: AnchoredMenuProps): React.ReactElement;
979
+ declare function AnchoredMenu({ options, selectedValue, onSelect, onDismiss, colors, optionHint, accessibilityLabel, testID, anchorRef, usePortal, listbox, placement, }: AnchoredMenuProps): React.ReactElement;
966
980
 
967
981
  declare const controlStyles: {
968
982
  /**
@@ -1210,4 +1224,4 @@ interface UploadWithLinkFieldProps {
1210
1224
  /** An image field: preview, an upload control, and a link input revealed on request. */
1211
1225
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1212
1226
 
1213
- export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
1227
+ export { AlignToControl, type AlignToControlProps, AnchoredMenu, type AnchoredMenuColors, type AnchoredMenuListbox, type AnchoredMenuPlacement, type AnchoredMenuProps, type ChipOption, ChipSelector, type ChipSelectorProps, type ChipSingleSelectRole, type ChipVariant, type ControlOption, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, type DateFieldProps, DateRangeControl, type DateRangeControlProps, type DateRangeValue, DateTimeField, type DateTimeFieldProps, Field, type FieldChildContext, type FieldChildren, type FieldLabelVariant, type FieldMarker, type FieldProps, type FieldSpacing, type Focusable, type FocusableRefs, FormActions, type FormActionsProps, FormCell, type FormCellProps, FormCheckbox, type FormCheckboxProps, FormField, type FormFieldProps, FormGrid, type FormGridProps, FormSection, type FormSectionProps, FormStatusLine, type FormStatusLineProps, FormSwitch, type FormSwitchProps, type GroupSelection, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, type InlineFieldRowLayout, type InlineFieldRowProps, type RecentValues, SelectControl, type SelectControlProps, SelectField, type SelectFieldProps, type SelectMenuAnchor, type StepNeighbours, StepperNav, type StepperNavLabels, type StepperNavProps, type StepperStep, StepperTabs, type StepperTabsProps, type ThemedInput, ThemedTextInput, type ThemedTextInputProps, TypeaheadControl, type TypeaheadControlProps, type TypeaheadSearch, type TypeaheadSearchProps, UploadWithLinkField, type UploadWithLinkFieldProps, type UploadWithLinkLabels, type UseThemedInputOptions, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, nextHighlight, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
package/dist/index.js CHANGED
@@ -615,18 +615,23 @@ function readAnchorRect(ref) {
615
615
  const r = node.getBoundingClientRect();
616
616
  return { top: r.top, left: r.left, width: r.width, bottom: r.bottom };
617
617
  }
618
- function buildPortalPopoverStyle(rect, viewportBottom) {
618
+ function buildPortalPopoverStyle(rect, viewportBottom, viewportWidth) {
619
619
  return {
620
620
  ...viewportBottom !== void 0 ? { maxHeight: menuMaxHeight(rect.bottom, viewportBottom) } : null,
621
621
  // RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
622
622
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
623
623
  position: "fixed",
624
624
  top: rect.bottom + MENU_TOP_GAP2,
625
- left: rect.left,
626
- width: rect.width,
625
+ ...horizontalPlacement(rect, viewportWidth),
627
626
  zIndex: MENU_PORTAL_Z_INDEX
628
627
  };
629
628
  }
629
+ function horizontalPlacement(rect, viewportWidth) {
630
+ if (viewportWidth === void 0) return { left: rect.left, width: rect.width };
631
+ const width = Math.min(Math.max(rect.width, MENU_MIN_WIDTH), viewportWidth - 2 * VIEWPORT_MARGIN);
632
+ const left = Math.max(VIEWPORT_MARGIN, Math.min(rect.left, viewportWidth - VIEWPORT_MARGIN - width));
633
+ return { left, width };
634
+ }
630
635
  function useAnchorRect(ref, enabled) {
631
636
  const [rect, setRect] = React2.useState(null);
632
637
  React2.useLayoutEffect(() => {
@@ -761,15 +766,16 @@ function AnchoredMenu({
761
766
  testID,
762
767
  anchorRef,
763
768
  usePortal = true,
764
- listbox
769
+ listbox,
770
+ placement
765
771
  }) {
766
772
  const menuRef = React2__default.default.useRef(null);
767
773
  useDismiss(anchorRef, menuRef, onDismiss);
768
774
  useKeepHighlightInView(testID, listbox?.highlightedValue);
769
- const rect = useAnchorRect(anchorRef, usePortal);
775
+ const rect = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
770
776
  const viewportBottom = useVisualViewportBottom(usePortal);
771
- const portalStyle = rect !== null ? buildPortalPopoverStyle(rect, viewportBottom ?? void 0) : null;
772
777
  const { width: windowWidth } = reactNative.useWindowDimensions();
778
+ const portalStyle = rect !== null ? buildPortalPopoverStyle(rect, viewportBottom ?? void 0, placement !== void 0 ? windowWidth : void 0) : null;
773
779
  const menuWidth = rect?.width ?? windowWidth;
774
780
  const isListbox = listbox !== void 0;
775
781
  const statusText = listbox?.statusText;
@@ -1697,8 +1703,47 @@ var FormCheckbox = ({
1697
1703
  }
1698
1704
  );
1699
1705
  };
1706
+
1707
+ // src/controls/nextHighlight.ts
1708
+ var NO_HIGHLIGHT = -1;
1709
+ function nextHighlight(current, count, delta) {
1710
+ if (count === 0) return NO_HIGHLIGHT;
1711
+ if (current === NO_HIGHLIGHT) return delta > 0 ? 0 : count - 1;
1712
+ return (current + delta + count) % count;
1713
+ }
1714
+
1715
+ // src/SelectControl/useSelectListbox.ts
1716
+ var FORWARD = 1;
1717
+ var BACKWARD = -1;
1718
+ function useSelectListbox({ options, isOpen, open, toggle, select }) {
1719
+ const [row, setRow] = React2.useState(NO_HIGHLIGHT);
1720
+ const highlighted = isOpen ? options[row] : void 0;
1721
+ React2.useEffect(() => {
1722
+ if (!isOpen) setRow(NO_HIGHLIGHT);
1723
+ }, [isOpen]);
1724
+ const onKeyDown = (event) => {
1725
+ const { key } = event;
1726
+ const isArrow = key === "ArrowDown" || key === "ArrowUp";
1727
+ if (!isArrow && key !== "Enter" && key !== " ") return;
1728
+ event.preventDefault();
1729
+ event.stopPropagation();
1730
+ if (isArrow) {
1731
+ open();
1732
+ setRow((current) => nextHighlight(current, options.length, key === "ArrowDown" ? FORWARD : BACKWARD));
1733
+ } else if (highlighted !== void 0) select(highlighted.value);
1734
+ else toggle();
1735
+ };
1736
+ return { highlighted, onKeyDown };
1737
+ }
1700
1738
  var CHEVRON_DOWN = "\u25BE";
1701
1739
  var CHEVRON_UP = "\u25B4";
1740
+ function listboxTriggerAria(testID, hasList, highlighted) {
1741
+ return {
1742
+ role: "combobox",
1743
+ "aria-controls": hasList ? listboxDomId(testID) : void 0,
1744
+ "aria-activedescendant": highlighted !== void 0 ? optionDomId(testID, highlighted.value) : void 0
1745
+ };
1746
+ }
1702
1747
  function SelectControl({
1703
1748
  options,
1704
1749
  value,
@@ -1708,6 +1753,7 @@ function SelectControl({
1708
1753
  accessibilityHint,
1709
1754
  labelledById,
1710
1755
  optionHint = "",
1756
+ menuAnchor,
1711
1757
  style,
1712
1758
  testID
1713
1759
  }) {
@@ -1722,6 +1768,9 @@ function SelectControl({
1722
1768
  const close = React2.useCallback(() => {
1723
1769
  setIsOpen(false);
1724
1770
  }, []);
1771
+ const open = React2.useCallback(() => {
1772
+ setIsOpen(true);
1773
+ }, []);
1725
1774
  const toggle = React2.useCallback(() => {
1726
1775
  setIsOpen((prev) => !prev);
1727
1776
  }, []);
@@ -1732,16 +1781,23 @@ function SelectControl({
1732
1781
  },
1733
1782
  [onChange]
1734
1783
  );
1735
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: [controlStyles.anchor, style], children: [
1784
+ const listbox = useSelectListbox({ options, isOpen, open, toggle, select });
1785
+ const isListbox = menuAnchor !== void 0;
1786
+ const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
1787
+ const triggerAria = isListbox ? listboxTriggerAria(testID, isOpen && options.length > 0, listbox.highlighted) : {};
1788
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: [controlStyles.anchor, style], ...captureKeys, children: [
1736
1789
  /* @__PURE__ */ jsxRuntime.jsxs(
1737
1790
  reactNative.Pressable,
1738
1791
  {
1739
- accessibilityRole: "button",
1792
+ ...triggerAria,
1793
+ accessibilityRole: isListbox ? void 0 : "button",
1740
1794
  accessibilityLabel,
1741
1795
  accessibilityHint,
1742
1796
  accessibilityState: { expanded: isOpen },
1743
1797
  "aria-expanded": isOpen,
1798
+ "aria-haspopup": "listbox",
1744
1799
  "aria-labelledby": labelledById,
1800
+ onBlur: isListbox ? close : void 0,
1745
1801
  onPress: toggle,
1746
1802
  style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
1747
1803
  testID: `${testID}-trigger`,
@@ -1758,10 +1814,13 @@ function SelectControl({
1758
1814
  selectedValue: value,
1759
1815
  onSelect: select,
1760
1816
  onDismiss: close,
1761
- colors: { text: colors.text, border: colors.border, surface: colors.surface, brand: palette.primary["500"] },
1817
+ colors: { text: colors.text, ...isListbox ? { textSecondary: colors.textSecondary } : null, border: colors.border, surface: colors.surface, brand: palette.primary["500"] },
1762
1818
  optionHint,
1763
1819
  testID,
1764
- anchorRef
1820
+ anchorRef,
1821
+ accessibilityLabel: menuAnchor?.listboxLabel,
1822
+ listbox: isListbox ? { highlightedValue: listbox.highlighted?.value } : void 0,
1823
+ placement: isListbox ? { positionRef: menuAnchor.anchorRef } : void 0
1765
1824
  }
1766
1825
  ) : null
1767
1826
  ] });
@@ -1869,15 +1928,9 @@ function useTypeaheadSearch(load, query, enabled, debounceMs) {
1869
1928
  }
1870
1929
 
1871
1930
  // src/TypeaheadControl/hooks/useTypeaheadState.ts
1872
- var NO_HIGHLIGHT = -1;
1873
- var FORWARD = 1;
1874
- var BACKWARD = -1;
1931
+ var FORWARD2 = 1;
1932
+ var BACKWARD2 = -1;
1875
1933
  var NO_ROWS = [];
1876
- function nextHighlight(current, count, delta) {
1877
- if (count === 0) return NO_HIGHLIGHT;
1878
- if (current === NO_HIGHLIGHT) return delta > 0 ? 0 : count - 1;
1879
- return (current + delta + count) % count;
1880
- }
1881
1934
  function searchStatusText(found, search) {
1882
1935
  if (found.hasFailed) return search.errorText;
1883
1936
  if (found.results.length > 0) return void 0;
@@ -1959,7 +2012,7 @@ function useTypeaheadKeys(input) {
1959
2012
  if (key === "ArrowDown" || key === "ArrowUp") {
1960
2013
  event.preventDefault();
1961
2014
  setIsOpen(true);
1962
- setHighlightIndex((current) => nextHighlight(current, rowCount, key === "ArrowDown" ? FORWARD : BACKWARD));
2015
+ setHighlightIndex((current) => nextHighlight(current, rowCount, key === "ArrowDown" ? FORWARD2 : BACKWARD2));
1963
2016
  } else if (key === "Escape" && isOpen) {
1964
2017
  event.preventDefault();
1965
2018
  close();
@@ -2468,6 +2521,7 @@ exports.controlStyles = controlStyles;
2468
2521
  exports.groupAriaChecked = groupAriaChecked;
2469
2522
  exports.inlineFieldRowLayout = inlineFieldRowLayout;
2470
2523
  exports.isUnmatched = isUnmatched;
2524
+ exports.nextHighlight = nextHighlight;
2471
2525
  exports.resolveGroupSelection = resolveGroupSelection;
2472
2526
  exports.resolveStepNeighbours = resolveStepNeighbours;
2473
2527
  exports.suggestOptions = suggestOptions;