@dloizides/ui-forms 1.26.0 → 1.28.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 +14 -0
- package/dist/index.d.mts +43 -4
- package/dist/index.d.ts +43 -4
- package/dist/index.js +155 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.28.0
|
|
4
|
+
|
|
5
|
+
INVOICE-FU-22 "To and Cc dropdown of saved people", D-FU22-5 "Review findings are fixed in the packages".
|
|
6
|
+
|
|
7
|
+
- `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.
|
|
8
|
+
- `AnchoredMenu` gains `placement`; `AnchoredMenuListbox.highlightedValue` is optional.
|
|
9
|
+
- `nextHighlight` is exported.
|
|
10
|
+
|
|
11
|
+
## 1.27.0
|
|
12
|
+
|
|
13
|
+
DATE-INPUT-1 "Every date or date-time field uses the shared input".
|
|
14
|
+
|
|
15
|
+
- New `DateField` (`YYYY-MM-DD`) and `DateTimeField` (`YYYY-MM-DDTHH:mm`), rendered through `Field`; a real `<input type>` on web.
|
|
16
|
+
|
|
3
17
|
## 1.26.0
|
|
4
18
|
|
|
5
19
|
INVOICE-3 "Invoice interface over a user-chosen folder": owner picks.
|
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;
|
|
@@ -871,6 +880,31 @@ interface DateRangeControlProps {
|
|
|
871
880
|
}
|
|
872
881
|
declare function DateRangeControl({ value, onChange, onSubmit, fromLabel, toLabel, fromPlaceholder, toPlaceholder, accessibilityHint, style, testID, }: DateRangeControlProps): React.ReactElement;
|
|
873
882
|
|
|
883
|
+
interface DateFieldProps {
|
|
884
|
+
/** PRE-LOCALIZED label; also the accessible name. */
|
|
885
|
+
label: string;
|
|
886
|
+
/** `YYYY-MM-DD` for `DateField`, `YYYY-MM-DDTHH:mm` for `DateTimeField`; empty is `''`. */
|
|
887
|
+
value: string;
|
|
888
|
+
onChange: (value: string) => void;
|
|
889
|
+
/** Runs on Enter. */
|
|
890
|
+
onSubmit?: () => void;
|
|
891
|
+
accessibilityHint: string;
|
|
892
|
+
testID: string;
|
|
893
|
+
required?: boolean;
|
|
894
|
+
hint?: string;
|
|
895
|
+
error?: string;
|
|
896
|
+
disabled?: boolean;
|
|
897
|
+
min?: string;
|
|
898
|
+
max?: string;
|
|
899
|
+
}
|
|
900
|
+
type DateTimeFieldProps = DateFieldProps;
|
|
901
|
+
|
|
902
|
+
/** A labelled calendar date: takes and emits `YYYY-MM-DD`, empty is `''`. */
|
|
903
|
+
declare function DateField(props: DateFieldProps): React.ReactElement;
|
|
904
|
+
|
|
905
|
+
/** A labelled local date and time: takes and emits `YYYY-MM-DDTHH:mm`, empty is `''`. */
|
|
906
|
+
declare function DateTimeField(props: DateTimeFieldProps): React.ReactElement;
|
|
907
|
+
|
|
874
908
|
/**
|
|
875
909
|
* `AnchoredMenu` — the floating option list shared by `SelectControl` and `TypeaheadControl`.
|
|
876
910
|
*
|
|
@@ -900,9 +934,13 @@ interface AnchoredMenuColors {
|
|
|
900
934
|
brand: string;
|
|
901
935
|
}
|
|
902
936
|
interface AnchoredMenuListbox {
|
|
903
|
-
highlightedValue
|
|
937
|
+
highlightedValue?: string;
|
|
904
938
|
statusText?: string;
|
|
905
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
|
+
}
|
|
906
944
|
interface AnchoredMenuProps {
|
|
907
945
|
options: readonly ControlOption[];
|
|
908
946
|
/** The currently-selected value, highlighted in the list ('' = none). */
|
|
@@ -936,8 +974,9 @@ interface AnchoredMenuProps {
|
|
|
936
974
|
*/
|
|
937
975
|
usePortal?: boolean;
|
|
938
976
|
listbox?: AnchoredMenuListbox;
|
|
977
|
+
placement?: AnchoredMenuPlacement;
|
|
939
978
|
}
|
|
940
|
-
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;
|
|
941
980
|
|
|
942
981
|
declare const controlStyles: {
|
|
943
982
|
/**
|
|
@@ -1185,4 +1224,4 @@ interface UploadWithLinkFieldProps {
|
|
|
1185
1224
|
/** An image field: preview, an upload control, and a link input revealed on request. */
|
|
1186
1225
|
declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
|
|
1187
1226
|
|
|
1188
|
-
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 };
|
|
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;
|
|
@@ -871,6 +880,31 @@ interface DateRangeControlProps {
|
|
|
871
880
|
}
|
|
872
881
|
declare function DateRangeControl({ value, onChange, onSubmit, fromLabel, toLabel, fromPlaceholder, toPlaceholder, accessibilityHint, style, testID, }: DateRangeControlProps): React.ReactElement;
|
|
873
882
|
|
|
883
|
+
interface DateFieldProps {
|
|
884
|
+
/** PRE-LOCALIZED label; also the accessible name. */
|
|
885
|
+
label: string;
|
|
886
|
+
/** `YYYY-MM-DD` for `DateField`, `YYYY-MM-DDTHH:mm` for `DateTimeField`; empty is `''`. */
|
|
887
|
+
value: string;
|
|
888
|
+
onChange: (value: string) => void;
|
|
889
|
+
/** Runs on Enter. */
|
|
890
|
+
onSubmit?: () => void;
|
|
891
|
+
accessibilityHint: string;
|
|
892
|
+
testID: string;
|
|
893
|
+
required?: boolean;
|
|
894
|
+
hint?: string;
|
|
895
|
+
error?: string;
|
|
896
|
+
disabled?: boolean;
|
|
897
|
+
min?: string;
|
|
898
|
+
max?: string;
|
|
899
|
+
}
|
|
900
|
+
type DateTimeFieldProps = DateFieldProps;
|
|
901
|
+
|
|
902
|
+
/** A labelled calendar date: takes and emits `YYYY-MM-DD`, empty is `''`. */
|
|
903
|
+
declare function DateField(props: DateFieldProps): React.ReactElement;
|
|
904
|
+
|
|
905
|
+
/** A labelled local date and time: takes and emits `YYYY-MM-DDTHH:mm`, empty is `''`. */
|
|
906
|
+
declare function DateTimeField(props: DateTimeFieldProps): React.ReactElement;
|
|
907
|
+
|
|
874
908
|
/**
|
|
875
909
|
* `AnchoredMenu` — the floating option list shared by `SelectControl` and `TypeaheadControl`.
|
|
876
910
|
*
|
|
@@ -900,9 +934,13 @@ interface AnchoredMenuColors {
|
|
|
900
934
|
brand: string;
|
|
901
935
|
}
|
|
902
936
|
interface AnchoredMenuListbox {
|
|
903
|
-
highlightedValue
|
|
937
|
+
highlightedValue?: string;
|
|
904
938
|
statusText?: string;
|
|
905
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
|
+
}
|
|
906
944
|
interface AnchoredMenuProps {
|
|
907
945
|
options: readonly ControlOption[];
|
|
908
946
|
/** The currently-selected value, highlighted in the list ('' = none). */
|
|
@@ -936,8 +974,9 @@ interface AnchoredMenuProps {
|
|
|
936
974
|
*/
|
|
937
975
|
usePortal?: boolean;
|
|
938
976
|
listbox?: AnchoredMenuListbox;
|
|
977
|
+
placement?: AnchoredMenuPlacement;
|
|
939
978
|
}
|
|
940
|
-
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;
|
|
941
980
|
|
|
942
981
|
declare const controlStyles: {
|
|
943
982
|
/**
|
|
@@ -1185,4 +1224,4 @@ interface UploadWithLinkFieldProps {
|
|
|
1185
1224
|
/** An image field: preview, an upload control, and a link input revealed on request. */
|
|
1186
1225
|
declare const UploadWithLinkField: ({ value, onChange, labels, uploadControl, testID, disabled, previewSize, }: UploadWithLinkFieldProps) => React.ReactElement;
|
|
1187
1226
|
|
|
1188
|
-
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 };
|
|
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
|
-
|
|
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,48 @@ 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-haspopup": "listbox",
|
|
1744
|
+
"aria-controls": hasList ? listboxDomId(testID) : void 0,
|
|
1745
|
+
"aria-activedescendant": highlighted !== void 0 ? optionDomId(testID, highlighted.value) : void 0
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1702
1748
|
function SelectControl({
|
|
1703
1749
|
options,
|
|
1704
1750
|
value,
|
|
@@ -1708,6 +1754,7 @@ function SelectControl({
|
|
|
1708
1754
|
accessibilityHint,
|
|
1709
1755
|
labelledById,
|
|
1710
1756
|
optionHint = "",
|
|
1757
|
+
menuAnchor,
|
|
1711
1758
|
style,
|
|
1712
1759
|
testID
|
|
1713
1760
|
}) {
|
|
@@ -1722,6 +1769,9 @@ function SelectControl({
|
|
|
1722
1769
|
const close = React2.useCallback(() => {
|
|
1723
1770
|
setIsOpen(false);
|
|
1724
1771
|
}, []);
|
|
1772
|
+
const open = React2.useCallback(() => {
|
|
1773
|
+
setIsOpen(true);
|
|
1774
|
+
}, []);
|
|
1725
1775
|
const toggle = React2.useCallback(() => {
|
|
1726
1776
|
setIsOpen((prev) => !prev);
|
|
1727
1777
|
}, []);
|
|
@@ -1732,16 +1782,22 @@ function SelectControl({
|
|
|
1732
1782
|
},
|
|
1733
1783
|
[onChange]
|
|
1734
1784
|
);
|
|
1735
|
-
|
|
1785
|
+
const listbox = useSelectListbox({ options, isOpen, open, toggle, select });
|
|
1786
|
+
const isListbox = menuAnchor !== void 0;
|
|
1787
|
+
const captureKeys = isListbox ? { onKeyDownCapture: listbox.onKeyDown } : {};
|
|
1788
|
+
const triggerAria = isListbox ? listboxTriggerAria(testID, isOpen && options.length > 0, listbox.highlighted) : {};
|
|
1789
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { ref: anchorRef, style: [controlStyles.anchor, style], ...captureKeys, children: [
|
|
1736
1790
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1737
1791
|
reactNative.Pressable,
|
|
1738
1792
|
{
|
|
1739
|
-
|
|
1793
|
+
...triggerAria,
|
|
1794
|
+
accessibilityRole: isListbox ? void 0 : "button",
|
|
1740
1795
|
accessibilityLabel,
|
|
1741
1796
|
accessibilityHint,
|
|
1742
1797
|
accessibilityState: { expanded: isOpen },
|
|
1743
1798
|
"aria-expanded": isOpen,
|
|
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
|
|
1873
|
-
var
|
|
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" ?
|
|
2015
|
+
setHighlightIndex((current) => nextHighlight(current, rowCount, key === "ArrowDown" ? FORWARD2 : BACKWARD2));
|
|
1963
2016
|
} else if (key === "Escape" && isOpen) {
|
|
1964
2017
|
event.preventDefault();
|
|
1965
2018
|
close();
|
|
@@ -2116,6 +2169,86 @@ function DateRangeControl({
|
|
|
2116
2169
|
)
|
|
2117
2170
|
] });
|
|
2118
2171
|
}
|
|
2172
|
+
var NATIVE_INPUT_BOX = {
|
|
2173
|
+
borderStyle: "solid",
|
|
2174
|
+
boxSizing: "border-box",
|
|
2175
|
+
fontFamily: "inherit",
|
|
2176
|
+
width: "100%"
|
|
2177
|
+
};
|
|
2178
|
+
function buildNativeInputStyle(themed) {
|
|
2179
|
+
const { paddingHorizontal, paddingVertical, ...box } = reactNative.StyleSheet.flatten(controlStyles.input);
|
|
2180
|
+
return {
|
|
2181
|
+
...box,
|
|
2182
|
+
...themed,
|
|
2183
|
+
...NATIVE_INPUT_BOX,
|
|
2184
|
+
paddingBlock: paddingVertical,
|
|
2185
|
+
paddingInline: paddingHorizontal
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
function WebDateInput({ fieldProps, context, webInputType }) {
|
|
2189
|
+
const { label, value, onChange, onSubmit, accessibilityHint, testID, required, disabled = false, min, max } = fieldProps;
|
|
2190
|
+
const { style, focusBind, hoverBind } = useThemedInput({ hasError: context.hasError, editable: !disabled });
|
|
2191
|
+
const webA11y = webFieldA11y({
|
|
2192
|
+
describedById: context.describedById,
|
|
2193
|
+
hasError: context.hasError,
|
|
2194
|
+
required
|
|
2195
|
+
});
|
|
2196
|
+
const handleChange = (event) => onChange(event.target.value);
|
|
2197
|
+
const handleKeyDown = (event) => {
|
|
2198
|
+
if (event.key !== "Enter" || onSubmit === void 0) return;
|
|
2199
|
+
event.preventDefault();
|
|
2200
|
+
onSubmit();
|
|
2201
|
+
};
|
|
2202
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2203
|
+
"input",
|
|
2204
|
+
{
|
|
2205
|
+
...webA11y,
|
|
2206
|
+
...hoverBind,
|
|
2207
|
+
...focusBind,
|
|
2208
|
+
"aria-label": label,
|
|
2209
|
+
"data-testid": testID,
|
|
2210
|
+
disabled,
|
|
2211
|
+
id: context.controlId,
|
|
2212
|
+
max,
|
|
2213
|
+
min,
|
|
2214
|
+
style: buildNativeInputStyle(style),
|
|
2215
|
+
title: accessibilityHint,
|
|
2216
|
+
type: webInputType,
|
|
2217
|
+
value,
|
|
2218
|
+
onChange: handleChange,
|
|
2219
|
+
onKeyDown: handleKeyDown
|
|
2220
|
+
}
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
var IS_WEB7 = reactNative.Platform.OS === "web";
|
|
2224
|
+
function renderNativeInput(fieldProps, context) {
|
|
2225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2226
|
+
ThemedTextInput,
|
|
2227
|
+
{
|
|
2228
|
+
accessibilityHint: fieldProps.accessibilityHint,
|
|
2229
|
+
accessibilityLabel: fieldProps.label,
|
|
2230
|
+
describedById: context.describedById,
|
|
2231
|
+
editable: fieldProps.disabled !== true,
|
|
2232
|
+
hasError: context.hasError,
|
|
2233
|
+
id: context.controlId,
|
|
2234
|
+
requiredField: fieldProps.required,
|
|
2235
|
+
testID: fieldProps.testID,
|
|
2236
|
+
value: fieldProps.value,
|
|
2237
|
+
onChangeText: fieldProps.onChange,
|
|
2238
|
+
onSubmitEditing: fieldProps.onSubmit
|
|
2239
|
+
}
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2242
|
+
function TemporalField({ fieldProps, webInputType }) {
|
|
2243
|
+
const { label, required, hint, error } = fieldProps;
|
|
2244
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Field, { error, hint, label, required, children: (context) => IS_WEB7 ? /* @__PURE__ */ jsxRuntime.jsx(WebDateInput, { context, fieldProps, webInputType }) : renderNativeInput(fieldProps, context) });
|
|
2245
|
+
}
|
|
2246
|
+
function DateField(props) {
|
|
2247
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "date" });
|
|
2248
|
+
}
|
|
2249
|
+
function DateTimeField(props) {
|
|
2250
|
+
return /* @__PURE__ */ jsxRuntime.jsx(TemporalField, { fieldProps: props, webInputType: "datetime-local" });
|
|
2251
|
+
}
|
|
2119
2252
|
|
|
2120
2253
|
// src/groupSelection/groupSelection.ts
|
|
2121
2254
|
var NONE = 0;
|
|
@@ -2363,7 +2496,9 @@ exports.DEFAULT_MAX_RECENTS = DEFAULT_MAX_RECENTS;
|
|
|
2363
2496
|
exports.DEFAULT_OPTIONAL_LABEL = DEFAULT_OPTIONAL_LABEL;
|
|
2364
2497
|
exports.DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS = DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS;
|
|
2365
2498
|
exports.DEFAULT_TYPEAHEAD_MIN_CHARS = DEFAULT_TYPEAHEAD_MIN_CHARS;
|
|
2499
|
+
exports.DateField = DateField;
|
|
2366
2500
|
exports.DateRangeControl = DateRangeControl;
|
|
2501
|
+
exports.DateTimeField = DateTimeField;
|
|
2367
2502
|
exports.Field = Field;
|
|
2368
2503
|
exports.FormActions = FormActions;
|
|
2369
2504
|
exports.FormCell = FormCell;
|
|
@@ -2386,6 +2521,7 @@ exports.controlStyles = controlStyles;
|
|
|
2386
2521
|
exports.groupAriaChecked = groupAriaChecked;
|
|
2387
2522
|
exports.inlineFieldRowLayout = inlineFieldRowLayout;
|
|
2388
2523
|
exports.isUnmatched = isUnmatched;
|
|
2524
|
+
exports.nextHighlight = nextHighlight;
|
|
2389
2525
|
exports.resolveGroupSelection = resolveGroupSelection;
|
|
2390
2526
|
exports.resolveStepNeighbours = resolveStepNeighbours;
|
|
2391
2527
|
exports.suggestOptions = suggestOptions;
|