@react-aria/select 3.0.0-alpha.1 → 3.0.0-nightly-641446f65-240905

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/types.d.ts CHANGED
@@ -1,18 +1,78 @@
1
- import { HTMLAttributes, RefObject } from "react";
2
- import { KeyboardDelegate } from "@react-types/shared";
3
- import { PressProps } from "@react-aria/interactions";
1
+ import { AriaButtonProps } from "@react-types/button";
2
+ import { AriaListBoxOptions } from "@react-aria/listbox";
3
+ import { AriaSelectProps } from "@react-types/select";
4
+ import { DOMAttributes, FocusableElement, KeyboardDelegate, RefObject, ValidationResult } from "@react-types/shared";
4
5
  import { SelectState } from "@react-stately/select";
5
- interface SelectProps {
6
- triggerRef: RefObject<HTMLElement>;
6
+ import React, { ReactNode } from "react";
7
+ export interface AriaSelectOptions<T> extends Omit<AriaSelectProps<T>, 'children'> {
8
+ /**
9
+ * An optional keyboard delegate implementation for type to select,
10
+ * to override the default.
11
+ */
12
+ keyboardDelegate?: KeyboardDelegate;
13
+ }
14
+ export interface SelectAria<T> extends ValidationResult {
15
+ /** Props for the label element. */
16
+ labelProps: DOMAttributes;
17
+ /** Props for the popup trigger element. */
18
+ triggerProps: AriaButtonProps;
19
+ /** Props for the element representing the selected value. */
20
+ valueProps: DOMAttributes;
21
+ /** Props for the popup. */
22
+ menuProps: AriaListBoxOptions<T>;
23
+ /** Props for the select's description element, if any. */
24
+ descriptionProps: DOMAttributes;
25
+ /** Props for the select's error message element, if any. */
26
+ errorMessageProps: DOMAttributes;
27
+ }
28
+ /**
29
+ * Provides the behavior and accessibility implementation for a select component.
30
+ * A select displays a collapsible list of options and allows a user to select one of them.
31
+ * @param props - Props for the select.
32
+ * @param state - State for the select, as returned by `useListState`.
33
+ */
34
+ export function useSelect<T>(props: AriaSelectOptions<T>, state: SelectState<T>, ref: RefObject<FocusableElement | null>): SelectAria<T>;
35
+ export interface AriaHiddenSelectProps {
36
+ /**
37
+ * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).
38
+ */
39
+ autoComplete?: string;
40
+ /** The text label for the select. */
41
+ label?: ReactNode;
42
+ /** HTML form input name. */
43
+ name?: string;
44
+ /** Sets the disabled state of the select and input. */
7
45
  isDisabled?: boolean;
8
- keyboardDelegate: KeyboardDelegate;
9
46
  }
10
- interface SelectAria {
11
- labelProps: HTMLAttributes<HTMLElement>;
12
- triggerProps: HTMLAttributes<HTMLElement> & PressProps;
13
- valueProps: HTMLAttributes<HTMLElement>;
14
- menuProps: HTMLAttributes<HTMLElement>;
47
+ export interface HiddenSelectProps<T> extends AriaHiddenSelectProps {
48
+ /** State for the select. */
49
+ state: SelectState<T>;
50
+ /** A ref to the trigger element. */
51
+ triggerRef: RefObject<FocusableElement | null>;
52
+ }
53
+ interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {
54
+ /** A ref to the hidden `<select>` element. */
55
+ selectRef?: RefObject<HTMLSelectElement | null>;
56
+ }
57
+ interface HiddenSelectAria {
58
+ /** Props for the container element. */
59
+ containerProps: React.HTMLAttributes<FocusableElement>;
60
+ /** Props for the hidden input element. */
61
+ inputProps: React.InputHTMLAttributes<HTMLInputElement>;
62
+ /** Props for the hidden select element. */
63
+ selectProps: React.SelectHTMLAttributes<HTMLSelectElement>;
15
64
  }
16
- export function useSelect<T>(props: SelectProps, state: SelectState<T>): SelectAria;
65
+ /**
66
+ * Provides the behavior and accessibility implementation for a hidden `<select>` element, which
67
+ * can be used in combination with `useSelect` to support browser form autofill, mobile form
68
+ * navigation, and native HTML form submission.
69
+ */
70
+ export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria;
71
+ /**
72
+ * Renders a hidden native `<select>` element, which can be used to support browser
73
+ * form autofill, mobile form navigation, and native form submission.
74
+ */
75
+ export function HiddenSelect<T>(props: HiddenSelectProps<T>): React.JSX.Element;
76
+ export type { AriaSelectProps } from '@react-types/select';
17
77
 
18
78
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/govett/dev/react-spectrum/packages/@react-aria/select/src/packages/@react-aria/select/src/useSelect.ts"],"names":[],"mappings":";;;;AAqBA;IACE,UAAU,EAAE,UAAU,WAAW,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,EAAE,gBAAgB,CAAA;CACnC;AAED;IACE,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IACxC,YAAY,EAAE,eAAe,WAAW,CAAC,GAAG,UAAU,CAAC;IACvD,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IACxC,SAAS,EAAE,eAAe,WAAW,CAAC,CAAA;CACvC;AAED,0BAA0B,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,GAAG,UAAU,CAmDlF","file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;AAyBA,mCAAmC,CAAC,CAAE,SAAQ,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,UAAU,CAAC;IAChF;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED,4BAA4B,CAAC,CAAE,SAAQ,gBAAgB;IACrD,mCAAmC;IACnC,UAAU,EAAE,aAAa,CAAC;IAE1B,2CAA2C;IAC3C,YAAY,EAAE,eAAe,CAAC;IAE9B,6DAA6D;IAC7D,UAAU,EAAE,aAAa,CAAC;IAE1B,2BAA2B;IAC3B,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAEjC,0DAA0D;IAC1D,gBAAgB,EAAE,aAAa,CAAC;IAEhC,4DAA4D;IAC5D,iBAAiB,EAAE,aAAa,CAAA;CACjC;AAWD;;;;;GAKG;AACH,0BAA0B,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAwKvI;ACvND;IACE;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qCAAqC;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,mCAAmC,CAAC,CAAE,SAAQ,qBAAqB;IACjE,4BAA4B;IAC5B,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IAEtB,oCAAoC;IACpC,UAAU,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,CAAA;CAC/C;AAED,iCAAyC,SAAQ,qBAAqB;IACpE,8CAA8C;IAC9C,SAAS,CAAC,EAAE,UAAU,iBAAiB,GAAG,IAAI,CAAC,CAAA;CAChD;AAED;IACE,uCAAuC;IACvC,cAAc,EAAE,MAAM,cAAc,CAAC,gBAAgB,CAAC,CAAC;IAEvD,0CAA0C;IAC1C,UAAU,EAAE,MAAM,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAExD,2CAA2C;IAC3C,WAAW,EAAE,MAAM,oBAAoB,CAAC,iBAAiB,CAAC,CAAA;CAC3D;AAED;;;;GAIG;AACH,gCAAgC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,gBAAgB,CAyD1J;AAED;;;GAGG;AACH,6BAA6B,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,qBA4C1D;AC9JD,YAAY,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC","sources":["packages/@react-aria/select/src/packages/@react-aria/select/src/useSelect.ts","packages/@react-aria/select/src/packages/@react-aria/select/src/HiddenSelect.tsx","packages/@react-aria/select/src/packages/@react-aria/select/src/index.ts","packages/@react-aria/select/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSelect} from './useSelect';\nexport {useHiddenSelect, HiddenSelect} from './HiddenSelect';\nexport type {AriaSelectOptions, SelectAria} from './useSelect';\nexport type {AriaHiddenSelectProps, HiddenSelectProps} from './HiddenSelect';\nexport type {AriaSelectProps} from '@react-types/select';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -0,0 +1,163 @@
1
+ var $63cuq$reactariautils = require("@react-aria/utils");
2
+ var $63cuq$react = require("react");
3
+ var $63cuq$reactariaselection = require("@react-aria/selection");
4
+ var $63cuq$reactariainteractions = require("@react-aria/interactions");
5
+ var $63cuq$reactariai18n = require("@react-aria/i18n");
6
+ var $63cuq$reactarialabel = require("@react-aria/label");
7
+ var $63cuq$reactariamenu = require("@react-aria/menu");
8
+
9
+
10
+ function $parcel$export(e, n, v, s) {
11
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
12
+ }
13
+
14
+ $parcel$export(module.exports, "selectData", () => $23a1e93dc7fa8653$export$703601b7e90536f8);
15
+ $parcel$export(module.exports, "useSelect", () => $23a1e93dc7fa8653$export$e64b2f635402ca43);
16
+ /*
17
+ * Copyright 2020 Adobe. All rights reserved.
18
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
+ * you may not use this file except in compliance with the License. You may obtain a copy
20
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
21
+ *
22
+ * Unless required by applicable law or agreed to in writing, software distributed under
23
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
24
+ * OF ANY KIND, either express or implied. See the License for the specific language
25
+ * governing permissions and limitations under the License.
26
+ */
27
+
28
+
29
+
30
+
31
+
32
+
33
+ const $23a1e93dc7fa8653$export$703601b7e90536f8 = new WeakMap();
34
+ function $23a1e93dc7fa8653$export$e64b2f635402ca43(props, state, ref) {
35
+ let { keyboardDelegate: keyboardDelegate, isDisabled: isDisabled, isRequired: isRequired, name: name, validationBehavior: validationBehavior = 'aria' } = props;
36
+ // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
37
+ // When virtualized, the layout object will be passed in as a prop and override this.
38
+ let collator = (0, $63cuq$reactariai18n.useCollator)({
39
+ usage: 'search',
40
+ sensitivity: 'base'
41
+ });
42
+ let delegate = (0, $63cuq$react.useMemo)(()=>keyboardDelegate || new (0, $63cuq$reactariaselection.ListKeyboardDelegate)(state.collection, state.disabledKeys, null, collator), [
43
+ keyboardDelegate,
44
+ state.collection,
45
+ state.disabledKeys,
46
+ collator
47
+ ]);
48
+ let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $63cuq$reactariamenu.useMenuTrigger)({
49
+ isDisabled: isDisabled,
50
+ type: 'listbox'
51
+ }, state, ref);
52
+ let onKeyDown = (e)=>{
53
+ switch(e.key){
54
+ case 'ArrowLeft':
55
+ {
56
+ // prevent scrolling containers
57
+ e.preventDefault();
58
+ let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
59
+ if (key) state.setSelectedKey(key);
60
+ break;
61
+ }
62
+ case 'ArrowRight':
63
+ {
64
+ // prevent scrolling containers
65
+ e.preventDefault();
66
+ let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
67
+ if (key) state.setSelectedKey(key);
68
+ break;
69
+ }
70
+ }
71
+ };
72
+ let { typeSelectProps: typeSelectProps } = (0, $63cuq$reactariaselection.useTypeSelect)({
73
+ keyboardDelegate: delegate,
74
+ selectionManager: state.selectionManager,
75
+ onTypeSelect (key) {
76
+ state.setSelectedKey(key);
77
+ }
78
+ });
79
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
80
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $63cuq$reactarialabel.useField)({
81
+ ...props,
82
+ labelElementType: 'span',
83
+ isInvalid: isInvalid,
84
+ errorMessage: props.errorMessage || validationErrors
85
+ });
86
+ typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
87
+ delete typeSelectProps.onKeyDownCapture;
88
+ let domProps = (0, $63cuq$reactariautils.filterDOMProps)(props, {
89
+ labelable: true
90
+ });
91
+ let triggerProps = (0, $63cuq$reactariautils.mergeProps)(typeSelectProps, menuTriggerProps, fieldProps);
92
+ let valueId = (0, $63cuq$reactariautils.useId)();
93
+ $23a1e93dc7fa8653$export$703601b7e90536f8.set(state, {
94
+ isDisabled: isDisabled,
95
+ isRequired: isRequired,
96
+ name: name,
97
+ validationBehavior: validationBehavior
98
+ });
99
+ return {
100
+ labelProps: {
101
+ ...labelProps,
102
+ onClick: ()=>{
103
+ if (!props.isDisabled) {
104
+ ref.current.focus();
105
+ // Show the focus ring so the user knows where focus went
106
+ (0, $63cuq$reactariainteractions.setInteractionModality)('keyboard');
107
+ }
108
+ }
109
+ },
110
+ triggerProps: (0, $63cuq$reactariautils.mergeProps)(domProps, {
111
+ ...triggerProps,
112
+ isDisabled: isDisabled,
113
+ onKeyDown: (0, $63cuq$reactariautils.chain)(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
114
+ onKeyUp: props.onKeyUp,
115
+ 'aria-labelledby': [
116
+ valueId,
117
+ triggerProps['aria-labelledby'],
118
+ triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null
119
+ ].filter(Boolean).join(' '),
120
+ onFocus (e) {
121
+ if (state.isFocused) return;
122
+ if (props.onFocus) props.onFocus(e);
123
+ if (props.onFocusChange) props.onFocusChange(true);
124
+ state.setFocused(true);
125
+ },
126
+ onBlur (e) {
127
+ if (state.isOpen) return;
128
+ if (props.onBlur) props.onBlur(e);
129
+ if (props.onFocusChange) props.onFocusChange(false);
130
+ state.setFocused(false);
131
+ }
132
+ }),
133
+ valueProps: {
134
+ id: valueId
135
+ },
136
+ menuProps: {
137
+ ...menuProps,
138
+ autoFocus: state.focusStrategy || true,
139
+ shouldSelectOnPressUp: true,
140
+ shouldFocusOnHover: true,
141
+ disallowEmptySelection: true,
142
+ linkBehavior: 'selection',
143
+ onBlur: (e)=>{
144
+ if (e.currentTarget.contains(e.relatedTarget)) return;
145
+ if (props.onBlur) props.onBlur(e);
146
+ if (props.onFocusChange) props.onFocusChange(false);
147
+ state.setFocused(false);
148
+ },
149
+ 'aria-labelledby': [
150
+ fieldProps['aria-labelledby'],
151
+ triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null
152
+ ].filter(Boolean).join(' ')
153
+ },
154
+ descriptionProps: descriptionProps,
155
+ errorMessageProps: errorMessageProps,
156
+ isInvalid: isInvalid,
157
+ validationErrors: validationErrors,
158
+ validationDetails: validationDetails
159
+ };
160
+ }
161
+
162
+
163
+ //# sourceMappingURL=useSelect.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAkDM,MAAM,4CAAa,IAAI;AAQvB,SAAS,0CAAa,KAA2B,EAAE,KAAqB,EAAE,GAAuC;IACtH,IAAI,oBACF,gBAAgB,cAChB,UAAU,cACV,UAAU,QACV,IAAI,sBACJ,qBAAqB,QACtB,GAAG;IAEJ,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,gCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,WAAW,CAAA,GAAA,oBAAM,EAAE,IAAM,oBAAoB,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ACP,IAAI,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,aAAa,GAC1C;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QACzB;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/select/src/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSelectProps} from '@react-types/select';\nimport {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, KeyboardDelegate, RefObject, ValidationResult} from '@react-types/shared';\nimport {FocusEvent, useMemo} from 'react';\nimport {ListKeyboardDelegate, useTypeSelect} from '@react-aria/selection';\nimport {SelectState} from '@react-stately/select';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useCollator} from '@react-aria/i18n';\nimport {useField} from '@react-aria/label';\nimport {useMenuTrigger} from '@react-aria/menu';\n\nexport interface AriaSelectOptions<T> extends Omit<AriaSelectProps<T>, 'children'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface SelectAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\ninterface SelectData {\n isDisabled?: boolean,\n isRequired?: boolean,\n name?: string,\n validationBehavior?: 'aria' | 'native'\n}\n\nexport const selectData = new WeakMap<SelectState<any>, SelectData>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T>(props: AriaSelectOptions<T>, state: SelectState<T>, ref: RefObject<FocusableElement | null>): SelectAria<T> {\n let {\n keyboardDelegate,\n isDisabled,\n isRequired,\n name,\n validationBehavior = 'aria'\n } = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(() => keyboardDelegate || new ListKeyboardDelegate(state.collection, state.disabledKeys, null, collator), [keyboardDelegate, state.collection, state.disabledKeys, collator]);\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();\n if (key) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();\n if (key) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;\n delete typeSelectProps.onKeyDownCapture;\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ].filter(Boolean).join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: (e) => {\n if (e.currentTarget.contains(e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ].filter(Boolean).join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useSelect.main.js.map"}
@@ -0,0 +1,157 @@
1
+ import {filterDOMProps as $aUnai$filterDOMProps, mergeProps as $aUnai$mergeProps, useId as $aUnai$useId, chain as $aUnai$chain} from "@react-aria/utils";
2
+ import {useMemo as $aUnai$useMemo} from "react";
3
+ import {ListKeyboardDelegate as $aUnai$ListKeyboardDelegate, useTypeSelect as $aUnai$useTypeSelect} from "@react-aria/selection";
4
+ import {setInteractionModality as $aUnai$setInteractionModality} from "@react-aria/interactions";
5
+ import {useCollator as $aUnai$useCollator} from "@react-aria/i18n";
6
+ import {useField as $aUnai$useField} from "@react-aria/label";
7
+ import {useMenuTrigger as $aUnai$useMenuTrigger} from "@react-aria/menu";
8
+
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ const $58aed456727eb0f3$export$703601b7e90536f8 = new WeakMap();
27
+ function $58aed456727eb0f3$export$e64b2f635402ca43(props, state, ref) {
28
+ let { keyboardDelegate: keyboardDelegate, isDisabled: isDisabled, isRequired: isRequired, name: name, validationBehavior: validationBehavior = 'aria' } = props;
29
+ // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
30
+ // When virtualized, the layout object will be passed in as a prop and override this.
31
+ let collator = (0, $aUnai$useCollator)({
32
+ usage: 'search',
33
+ sensitivity: 'base'
34
+ });
35
+ let delegate = (0, $aUnai$useMemo)(()=>keyboardDelegate || new (0, $aUnai$ListKeyboardDelegate)(state.collection, state.disabledKeys, null, collator), [
36
+ keyboardDelegate,
37
+ state.collection,
38
+ state.disabledKeys,
39
+ collator
40
+ ]);
41
+ let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $aUnai$useMenuTrigger)({
42
+ isDisabled: isDisabled,
43
+ type: 'listbox'
44
+ }, state, ref);
45
+ let onKeyDown = (e)=>{
46
+ switch(e.key){
47
+ case 'ArrowLeft':
48
+ {
49
+ // prevent scrolling containers
50
+ e.preventDefault();
51
+ let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
52
+ if (key) state.setSelectedKey(key);
53
+ break;
54
+ }
55
+ case 'ArrowRight':
56
+ {
57
+ // prevent scrolling containers
58
+ e.preventDefault();
59
+ let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
60
+ if (key) state.setSelectedKey(key);
61
+ break;
62
+ }
63
+ }
64
+ };
65
+ let { typeSelectProps: typeSelectProps } = (0, $aUnai$useTypeSelect)({
66
+ keyboardDelegate: delegate,
67
+ selectionManager: state.selectionManager,
68
+ onTypeSelect (key) {
69
+ state.setSelectedKey(key);
70
+ }
71
+ });
72
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
73
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $aUnai$useField)({
74
+ ...props,
75
+ labelElementType: 'span',
76
+ isInvalid: isInvalid,
77
+ errorMessage: props.errorMessage || validationErrors
78
+ });
79
+ typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
80
+ delete typeSelectProps.onKeyDownCapture;
81
+ let domProps = (0, $aUnai$filterDOMProps)(props, {
82
+ labelable: true
83
+ });
84
+ let triggerProps = (0, $aUnai$mergeProps)(typeSelectProps, menuTriggerProps, fieldProps);
85
+ let valueId = (0, $aUnai$useId)();
86
+ $58aed456727eb0f3$export$703601b7e90536f8.set(state, {
87
+ isDisabled: isDisabled,
88
+ isRequired: isRequired,
89
+ name: name,
90
+ validationBehavior: validationBehavior
91
+ });
92
+ return {
93
+ labelProps: {
94
+ ...labelProps,
95
+ onClick: ()=>{
96
+ if (!props.isDisabled) {
97
+ ref.current.focus();
98
+ // Show the focus ring so the user knows where focus went
99
+ (0, $aUnai$setInteractionModality)('keyboard');
100
+ }
101
+ }
102
+ },
103
+ triggerProps: (0, $aUnai$mergeProps)(domProps, {
104
+ ...triggerProps,
105
+ isDisabled: isDisabled,
106
+ onKeyDown: (0, $aUnai$chain)(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
107
+ onKeyUp: props.onKeyUp,
108
+ 'aria-labelledby': [
109
+ valueId,
110
+ triggerProps['aria-labelledby'],
111
+ triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null
112
+ ].filter(Boolean).join(' '),
113
+ onFocus (e) {
114
+ if (state.isFocused) return;
115
+ if (props.onFocus) props.onFocus(e);
116
+ if (props.onFocusChange) props.onFocusChange(true);
117
+ state.setFocused(true);
118
+ },
119
+ onBlur (e) {
120
+ if (state.isOpen) return;
121
+ if (props.onBlur) props.onBlur(e);
122
+ if (props.onFocusChange) props.onFocusChange(false);
123
+ state.setFocused(false);
124
+ }
125
+ }),
126
+ valueProps: {
127
+ id: valueId
128
+ },
129
+ menuProps: {
130
+ ...menuProps,
131
+ autoFocus: state.focusStrategy || true,
132
+ shouldSelectOnPressUp: true,
133
+ shouldFocusOnHover: true,
134
+ disallowEmptySelection: true,
135
+ linkBehavior: 'selection',
136
+ onBlur: (e)=>{
137
+ if (e.currentTarget.contains(e.relatedTarget)) return;
138
+ if (props.onBlur) props.onBlur(e);
139
+ if (props.onFocusChange) props.onFocusChange(false);
140
+ state.setFocused(false);
141
+ },
142
+ 'aria-labelledby': [
143
+ fieldProps['aria-labelledby'],
144
+ triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null
145
+ ].filter(Boolean).join(' ')
146
+ },
147
+ descriptionProps: descriptionProps,
148
+ errorMessageProps: errorMessageProps,
149
+ isInvalid: isInvalid,
150
+ validationErrors: validationErrors,
151
+ validationDetails: validationDetails
152
+ };
153
+ }
154
+
155
+
156
+ export {$58aed456727eb0f3$export$703601b7e90536f8 as selectData, $58aed456727eb0f3$export$e64b2f635402ca43 as useSelect};
157
+ //# sourceMappingURL=useSelect.module.js.map
@@ -0,0 +1,157 @@
1
+ import {filterDOMProps as $aUnai$filterDOMProps, mergeProps as $aUnai$mergeProps, useId as $aUnai$useId, chain as $aUnai$chain} from "@react-aria/utils";
2
+ import {useMemo as $aUnai$useMemo} from "react";
3
+ import {ListKeyboardDelegate as $aUnai$ListKeyboardDelegate, useTypeSelect as $aUnai$useTypeSelect} from "@react-aria/selection";
4
+ import {setInteractionModality as $aUnai$setInteractionModality} from "@react-aria/interactions";
5
+ import {useCollator as $aUnai$useCollator} from "@react-aria/i18n";
6
+ import {useField as $aUnai$useField} from "@react-aria/label";
7
+ import {useMenuTrigger as $aUnai$useMenuTrigger} from "@react-aria/menu";
8
+
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ const $58aed456727eb0f3$export$703601b7e90536f8 = new WeakMap();
27
+ function $58aed456727eb0f3$export$e64b2f635402ca43(props, state, ref) {
28
+ let { keyboardDelegate: keyboardDelegate, isDisabled: isDisabled, isRequired: isRequired, name: name, validationBehavior: validationBehavior = 'aria' } = props;
29
+ // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
30
+ // When virtualized, the layout object will be passed in as a prop and override this.
31
+ let collator = (0, $aUnai$useCollator)({
32
+ usage: 'search',
33
+ sensitivity: 'base'
34
+ });
35
+ let delegate = (0, $aUnai$useMemo)(()=>keyboardDelegate || new (0, $aUnai$ListKeyboardDelegate)(state.collection, state.disabledKeys, null, collator), [
36
+ keyboardDelegate,
37
+ state.collection,
38
+ state.disabledKeys,
39
+ collator
40
+ ]);
41
+ let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $aUnai$useMenuTrigger)({
42
+ isDisabled: isDisabled,
43
+ type: 'listbox'
44
+ }, state, ref);
45
+ let onKeyDown = (e)=>{
46
+ switch(e.key){
47
+ case 'ArrowLeft':
48
+ {
49
+ // prevent scrolling containers
50
+ e.preventDefault();
51
+ let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
52
+ if (key) state.setSelectedKey(key);
53
+ break;
54
+ }
55
+ case 'ArrowRight':
56
+ {
57
+ // prevent scrolling containers
58
+ e.preventDefault();
59
+ let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
60
+ if (key) state.setSelectedKey(key);
61
+ break;
62
+ }
63
+ }
64
+ };
65
+ let { typeSelectProps: typeSelectProps } = (0, $aUnai$useTypeSelect)({
66
+ keyboardDelegate: delegate,
67
+ selectionManager: state.selectionManager,
68
+ onTypeSelect (key) {
69
+ state.setSelectedKey(key);
70
+ }
71
+ });
72
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
73
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $aUnai$useField)({
74
+ ...props,
75
+ labelElementType: 'span',
76
+ isInvalid: isInvalid,
77
+ errorMessage: props.errorMessage || validationErrors
78
+ });
79
+ typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
80
+ delete typeSelectProps.onKeyDownCapture;
81
+ let domProps = (0, $aUnai$filterDOMProps)(props, {
82
+ labelable: true
83
+ });
84
+ let triggerProps = (0, $aUnai$mergeProps)(typeSelectProps, menuTriggerProps, fieldProps);
85
+ let valueId = (0, $aUnai$useId)();
86
+ $58aed456727eb0f3$export$703601b7e90536f8.set(state, {
87
+ isDisabled: isDisabled,
88
+ isRequired: isRequired,
89
+ name: name,
90
+ validationBehavior: validationBehavior
91
+ });
92
+ return {
93
+ labelProps: {
94
+ ...labelProps,
95
+ onClick: ()=>{
96
+ if (!props.isDisabled) {
97
+ ref.current.focus();
98
+ // Show the focus ring so the user knows where focus went
99
+ (0, $aUnai$setInteractionModality)('keyboard');
100
+ }
101
+ }
102
+ },
103
+ triggerProps: (0, $aUnai$mergeProps)(domProps, {
104
+ ...triggerProps,
105
+ isDisabled: isDisabled,
106
+ onKeyDown: (0, $aUnai$chain)(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
107
+ onKeyUp: props.onKeyUp,
108
+ 'aria-labelledby': [
109
+ valueId,
110
+ triggerProps['aria-labelledby'],
111
+ triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null
112
+ ].filter(Boolean).join(' '),
113
+ onFocus (e) {
114
+ if (state.isFocused) return;
115
+ if (props.onFocus) props.onFocus(e);
116
+ if (props.onFocusChange) props.onFocusChange(true);
117
+ state.setFocused(true);
118
+ },
119
+ onBlur (e) {
120
+ if (state.isOpen) return;
121
+ if (props.onBlur) props.onBlur(e);
122
+ if (props.onFocusChange) props.onFocusChange(false);
123
+ state.setFocused(false);
124
+ }
125
+ }),
126
+ valueProps: {
127
+ id: valueId
128
+ },
129
+ menuProps: {
130
+ ...menuProps,
131
+ autoFocus: state.focusStrategy || true,
132
+ shouldSelectOnPressUp: true,
133
+ shouldFocusOnHover: true,
134
+ disallowEmptySelection: true,
135
+ linkBehavior: 'selection',
136
+ onBlur: (e)=>{
137
+ if (e.currentTarget.contains(e.relatedTarget)) return;
138
+ if (props.onBlur) props.onBlur(e);
139
+ if (props.onFocusChange) props.onFocusChange(false);
140
+ state.setFocused(false);
141
+ },
142
+ 'aria-labelledby': [
143
+ fieldProps['aria-labelledby'],
144
+ triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null
145
+ ].filter(Boolean).join(' ')
146
+ },
147
+ descriptionProps: descriptionProps,
148
+ errorMessageProps: errorMessageProps,
149
+ isInvalid: isInvalid,
150
+ validationErrors: validationErrors,
151
+ validationDetails: validationDetails
152
+ };
153
+ }
154
+
155
+
156
+ export {$58aed456727eb0f3$export$703601b7e90536f8 as selectData, $58aed456727eb0f3$export$e64b2f635402ca43 as useSelect};
157
+ //# sourceMappingURL=useSelect.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAkDM,MAAM,4CAAa,IAAI;AAQvB,SAAS,0CAAa,KAA2B,EAAE,KAAqB,EAAE,GAAuC;IACtH,IAAI,oBACF,gBAAgB,cAChB,UAAU,cACV,UAAU,QACV,IAAI,sBACJ,qBAAqB,QACtB,GAAG;IAEJ,0HAA0H;IAC1H,qFAAqF;IACrF,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,WAAW,CAAA,GAAA,cAAM,EAAE,IAAM,oBAAoB,IAAI,CAAA,GAAA,2BAAmB,EAAE,MAAM,U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AE,aAAa,GAC1C;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,mBAAmB;gBACjB,UAAU,CAAC,kBAAkB;gBAC7B,YAAY,CAAC,aAAa,IAAI,CAAC,UAAU,CAAC,kBAAkB,GAAG,aAAa,EAAE,GAAG;aAClF,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QACzB;0BACA;2BACA;mBACA;0BACA;2BACA;IACF;AACF","sources":["packages/@react-aria/select/src/useSelect.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaListBoxOptions} from '@react-aria/listbox';\nimport {AriaSelectProps} from '@react-types/select';\nimport {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';\nimport {DOMAttributes, FocusableElement, KeyboardDelegate, RefObject, ValidationResult} from '@react-types/shared';\nimport {FocusEvent, useMemo} from 'react';\nimport {ListKeyboardDelegate, useTypeSelect} from '@react-aria/selection';\nimport {SelectState} from '@react-stately/select';\nimport {setInteractionModality} from '@react-aria/interactions';\nimport {useCollator} from '@react-aria/i18n';\nimport {useField} from '@react-aria/label';\nimport {useMenuTrigger} from '@react-aria/menu';\n\nexport interface AriaSelectOptions<T> extends Omit<AriaSelectProps<T>, 'children'> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\nexport interface SelectAria<T> extends ValidationResult {\n /** Props for the label element. */\n labelProps: DOMAttributes,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: DOMAttributes,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<T>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: DOMAttributes,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\ninterface SelectData {\n isDisabled?: boolean,\n isRequired?: boolean,\n name?: string,\n validationBehavior?: 'aria' | 'native'\n}\n\nexport const selectData = new WeakMap<SelectState<any>, SelectData>();\n\n/**\n * Provides the behavior and accessibility implementation for a select component.\n * A select displays a collapsible list of options and allows a user to select one of them.\n * @param props - Props for the select.\n * @param state - State for the select, as returned by `useListState`.\n */\nexport function useSelect<T>(props: AriaSelectOptions<T>, state: SelectState<T>, ref: RefObject<FocusableElement | null>): SelectAria<T> {\n let {\n keyboardDelegate,\n isDisabled,\n isRequired,\n name,\n validationBehavior = 'aria'\n } = props;\n\n // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).\n // When virtualized, the layout object will be passed in as a prop and override this.\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let delegate = useMemo(() => keyboardDelegate || new ListKeyboardDelegate(state.collection, state.disabledKeys, null, collator), [keyboardDelegate, state.collection, state.disabledKeys, collator]);\n\n let {menuTriggerProps, menuProps} = useMenuTrigger<T>(\n {\n isDisabled,\n type: 'listbox'\n },\n state,\n ref\n );\n\n let onKeyDown = (e: KeyboardEvent) => {\n switch (e.key) {\n case 'ArrowLeft': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();\n if (key) {\n state.setSelectedKey(key);\n }\n break;\n }\n case 'ArrowRight': {\n // prevent scrolling containers\n e.preventDefault();\n\n let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();\n if (key) {\n state.setSelectedKey(key);\n }\n break;\n }\n }\n };\n\n let {typeSelectProps} = useTypeSelect({\n keyboardDelegate: delegate,\n selectionManager: state.selectionManager,\n onTypeSelect(key) {\n state.setSelectedKey(key);\n }\n });\n\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span',\n isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;\n delete typeSelectProps.onKeyDownCapture;\n\n let domProps = filterDOMProps(props, {labelable: true});\n let triggerProps = mergeProps(typeSelectProps, menuTriggerProps, fieldProps);\n\n let valueId = useId();\n\n selectData.set(state, {\n isDisabled,\n isRequired,\n name,\n validationBehavior\n });\n\n return {\n labelProps: {\n ...labelProps,\n onClick: () => {\n if (!props.isDisabled) {\n ref.current.focus();\n\n // Show the focus ring so the user knows where focus went\n setInteractionModality('keyboard');\n }\n }\n },\n triggerProps: mergeProps(domProps, {\n ...triggerProps,\n isDisabled,\n onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n valueId,\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null\n ].filter(Boolean).join(' '),\n onFocus(e: FocusEvent) {\n if (state.isFocused) {\n return;\n }\n\n if (props.onFocus) {\n props.onFocus(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(true);\n }\n\n state.setFocused(true);\n },\n onBlur(e: FocusEvent) {\n if (state.isOpen) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n }\n }),\n valueProps: {\n id: valueId\n },\n menuProps: {\n ...menuProps,\n autoFocus: state.focusStrategy || true,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n disallowEmptySelection: true,\n linkBehavior: 'selection',\n onBlur: (e) => {\n if (e.currentTarget.contains(e.relatedTarget as Node)) {\n return;\n }\n\n if (props.onBlur) {\n props.onBlur(e);\n }\n\n if (props.onFocusChange) {\n props.onFocusChange(false);\n }\n\n state.setFocused(false);\n },\n 'aria-labelledby': [\n fieldProps['aria-labelledby'],\n triggerProps['aria-label'] && !fieldProps['aria-labelledby'] ? triggerProps.id : null\n ].filter(Boolean).join(' ')\n },\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\n };\n}\n"],"names":[],"version":3,"file":"useSelect.module.js.map"}