@dloizides/ui-forms 1.23.1 → 1.25.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.mjs CHANGED
@@ -1759,6 +1759,28 @@ function SelectControl({
1759
1759
  ) : null
1760
1760
  ] });
1761
1761
  }
1762
+ var SelectField = ({
1763
+ label,
1764
+ accessibilityHint,
1765
+ value,
1766
+ options,
1767
+ onChange,
1768
+ testID
1769
+ }) => {
1770
+ const selected = options.find((option) => option.value === value)?.label ?? "";
1771
+ return /* @__PURE__ */ jsx(Field, { label, children: ({ labelId }) => /* @__PURE__ */ jsx(
1772
+ SelectControl,
1773
+ {
1774
+ accessibilityHint,
1775
+ accessibilityLabel: `${label}: ${selected}`,
1776
+ labelledById: labelId,
1777
+ options,
1778
+ testID,
1779
+ value,
1780
+ onChange
1781
+ }
1782
+ ) });
1783
+ };
1762
1784
  var CLOSE_DELAY_MS2 = 140;
1763
1785
  function useDelayedBlurClose(open, close) {
1764
1786
  const timerRef = useRef(null);
@@ -2250,6 +2272,18 @@ function useFocusFirstInvalid(refs) {
2250
2272
  first?.focus();
2251
2273
  }, []);
2252
2274
  }
2275
+ function isScrollable(node) {
2276
+ return "scrollIntoView" in Object(node);
2277
+ }
2278
+ function useKeepInView(trigger) {
2279
+ const ref = useRef(null);
2280
+ useEffect(() => {
2281
+ const node = ref.current;
2282
+ const hasTrigger = trigger !== void 0 && trigger !== null;
2283
+ if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
2284
+ }, [trigger]);
2285
+ return ref;
2286
+ }
2253
2287
  var DEFAULT_PREVIEW_PX = 48;
2254
2288
  var PREVIEW_RADIUS = 8;
2255
2289
  var GAP = 8;
@@ -2315,6 +2349,6 @@ var UploadWithLinkField = ({
2315
2349
  ] });
2316
2350
  };
2317
2351
 
2318
- export { AlignToControl, AnchoredMenu, ChipSelector, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, Field, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStatusLine, FormSwitch, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, SelectControl, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useRecentValues, useThemedInput };
2352
+ export { AlignToControl, AnchoredMenu, ChipSelector, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateRangeControl, Field, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStatusLine, FormSwitch, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, SelectControl, SelectField, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
2319
2353
  //# sourceMappingURL=index.mjs.map
2320
2354
  //# sourceMappingURL=index.mjs.map