@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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.25.0
4
+
5
+ INVOICE-3 "Invoice interface over a user-chosen folder": extracted from invoice-web.
6
+
7
+ - New `SelectField`: `Field` + `SelectControl`, its accessible name carries the selection.
8
+
9
+ ## 1.24.0
10
+
11
+ BEAD-3 "Report form: searchable pattern field": review fix.
12
+
13
+ - New `useKeepInView(trigger)`, moved from Jinx: scrolls the returned view into sight each time `trigger` takes a new value, as far as needed and no further. Web only; a no-op on native.
14
+
3
15
  ## 1.23.0
4
16
 
5
17
  BEAD-3 "Report form: searchable pattern field and shared form feedback".
package/dist/index.d.mts CHANGED
@@ -762,6 +762,16 @@ interface SelectControlProps {
762
762
  }
763
763
  declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, style, testID, }: SelectControlProps): React.ReactElement;
764
764
 
765
+ interface SelectFieldProps {
766
+ label: string;
767
+ accessibilityHint: string;
768
+ value: string;
769
+ options: readonly ControlOption[];
770
+ onChange: (value: string) => void;
771
+ testID: string;
772
+ }
773
+ declare const SelectField: ({ label, accessibilityHint, value, options, onChange, testID, }: SelectFieldProps) => React.ReactElement;
774
+
765
775
  interface FieldControlWiring {
766
776
  id?: string;
767
777
  describedById?: string;
@@ -1146,6 +1156,9 @@ type FocusableRefs<Field extends string> = Readonly<Record<Field, RefObject<Focu
1146
1156
  /** Returns a stable function that focuses the first listed field that is on screen. */
1147
1157
  declare function useFocusFirstInvalid<Field extends string>(refs: FocusableRefs<Field>): (invalid: readonly Field[]) => void;
1148
1158
 
1159
+ /** Scrolls the returned view fully into sight each time `trigger` takes a new value. */
1160
+ declare function useKeepInView(trigger: unknown): RefObject<View | null>;
1161
+
1149
1162
  /** Every string the field shows; all pre-localized. */
1150
1163
  interface UploadWithLinkLabels {
1151
1164
  title: string;
@@ -1170,4 +1183,4 @@ interface UploadWithLinkFieldProps {
1170
1183
  /** An image field: preview, an upload control, and a link input revealed on request. */
1171
1184
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1172
1185
 
1173
- 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, DateRangeControl, type DateRangeControlProps, type DateRangeValue, 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, 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, useRecentValues, useThemedInput };
1186
+ 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, DateRangeControl, type DateRangeControlProps, type DateRangeValue, 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 };
package/dist/index.d.ts CHANGED
@@ -762,6 +762,16 @@ interface SelectControlProps {
762
762
  }
763
763
  declare function SelectControl({ options, value, onChange, placeholder, accessibilityLabel, accessibilityHint, labelledById, optionHint, style, testID, }: SelectControlProps): React.ReactElement;
764
764
 
765
+ interface SelectFieldProps {
766
+ label: string;
767
+ accessibilityHint: string;
768
+ value: string;
769
+ options: readonly ControlOption[];
770
+ onChange: (value: string) => void;
771
+ testID: string;
772
+ }
773
+ declare const SelectField: ({ label, accessibilityHint, value, options, onChange, testID, }: SelectFieldProps) => React.ReactElement;
774
+
765
775
  interface FieldControlWiring {
766
776
  id?: string;
767
777
  describedById?: string;
@@ -1146,6 +1156,9 @@ type FocusableRefs<Field extends string> = Readonly<Record<Field, RefObject<Focu
1146
1156
  /** Returns a stable function that focuses the first listed field that is on screen. */
1147
1157
  declare function useFocusFirstInvalid<Field extends string>(refs: FocusableRefs<Field>): (invalid: readonly Field[]) => void;
1148
1158
 
1159
+ /** Scrolls the returned view fully into sight each time `trigger` takes a new value. */
1160
+ declare function useKeepInView(trigger: unknown): RefObject<View | null>;
1161
+
1149
1162
  /** Every string the field shows; all pre-localized. */
1150
1163
  interface UploadWithLinkLabels {
1151
1164
  title: string;
@@ -1170,4 +1183,4 @@ interface UploadWithLinkFieldProps {
1170
1183
  /** An image field: preview, an upload control, and a link input revealed on request. */
1171
1184
  declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
1172
1185
 
1173
- 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, DateRangeControl, type DateRangeControlProps, type DateRangeValue, 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, 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, useRecentValues, useThemedInput };
1186
+ 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, DateRangeControl, type DateRangeControlProps, type DateRangeValue, 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 };
package/dist/index.js CHANGED
@@ -1765,6 +1765,28 @@ function SelectControl({
1765
1765
  ) : null
1766
1766
  ] });
1767
1767
  }
1768
+ var SelectField = ({
1769
+ label,
1770
+ accessibilityHint,
1771
+ value,
1772
+ options,
1773
+ onChange,
1774
+ testID
1775
+ }) => {
1776
+ const selected = options.find((option) => option.value === value)?.label ?? "";
1777
+ return /* @__PURE__ */ jsxRuntime.jsx(Field, { label, children: ({ labelId }) => /* @__PURE__ */ jsxRuntime.jsx(
1778
+ SelectControl,
1779
+ {
1780
+ accessibilityHint,
1781
+ accessibilityLabel: `${label}: ${selected}`,
1782
+ labelledById: labelId,
1783
+ options,
1784
+ testID,
1785
+ value,
1786
+ onChange
1787
+ }
1788
+ ) });
1789
+ };
1768
1790
  var CLOSE_DELAY_MS2 = 140;
1769
1791
  function useDelayedBlurClose(open, close) {
1770
1792
  const timerRef = React2.useRef(null);
@@ -2256,6 +2278,18 @@ function useFocusFirstInvalid(refs) {
2256
2278
  first?.focus();
2257
2279
  }, []);
2258
2280
  }
2281
+ function isScrollable(node) {
2282
+ return "scrollIntoView" in Object(node);
2283
+ }
2284
+ function useKeepInView(trigger) {
2285
+ const ref = React2.useRef(null);
2286
+ React2.useEffect(() => {
2287
+ const node = ref.current;
2288
+ const hasTrigger = trigger !== void 0 && trigger !== null;
2289
+ if (hasTrigger && isScrollable(node)) node.scrollIntoView({ block: "nearest" });
2290
+ }, [trigger]);
2291
+ return ref;
2292
+ }
2259
2293
  var DEFAULT_PREVIEW_PX = 48;
2260
2294
  var PREVIEW_RADIUS = 8;
2261
2295
  var GAP = 8;
@@ -2341,6 +2375,7 @@ exports.FormSwitch = FormSwitch;
2341
2375
  exports.INLINE_FIELD_ROW_MIN_WIDTH = INLINE_FIELD_ROW_MIN_WIDTH;
2342
2376
  exports.InlineFieldRow = InlineFieldRow;
2343
2377
  exports.SelectControl = SelectControl;
2378
+ exports.SelectField = SelectField;
2344
2379
  exports.StepperNav = StepperNav;
2345
2380
  exports.StepperTabs = StepperTabs;
2346
2381
  exports.ThemedTextInput = ThemedTextInput;
@@ -2355,6 +2390,7 @@ exports.resolveStepNeighbours = resolveStepNeighbours;
2355
2390
  exports.suggestOptions = suggestOptions;
2356
2391
  exports.toggleGroupSelection = toggleGroupSelection;
2357
2392
  exports.useFocusFirstInvalid = useFocusFirstInvalid;
2393
+ exports.useKeepInView = useKeepInView;
2358
2394
  exports.useRecentValues = useRecentValues;
2359
2395
  exports.useThemedInput = useThemedInput;
2360
2396
  //# sourceMappingURL=index.js.map