@react-aria/select 3.5.1-nightly.2962 → 3.5.1-nightly.2972
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/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -0
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/HiddenSelect.tsx +8 -1
package/dist/main.js
CHANGED
|
@@ -204,6 +204,7 @@ function useHiddenSelect(props, state, triggerRef) {
|
|
|
204
204
|
var _state$selectedKey;
|
|
205
205
|
|
|
206
206
|
let {
|
|
207
|
+
autoComplete,
|
|
207
208
|
name,
|
|
208
209
|
isDisabled
|
|
209
210
|
} = props;
|
|
@@ -244,6 +245,7 @@ function useHiddenSelect(props, state, triggerRef) {
|
|
|
244
245
|
},
|
|
245
246
|
selectProps: {
|
|
246
247
|
tabIndex: -1,
|
|
248
|
+
autoComplete,
|
|
247
249
|
disabled: isDisabled,
|
|
248
250
|
name,
|
|
249
251
|
size: state.collection.size,
|
|
@@ -290,6 +292,7 @@ function HiddenSelect(props) {
|
|
|
290
292
|
} else if (name) {
|
|
291
293
|
return /*#__PURE__*/_react.createElement("input", {
|
|
292
294
|
type: "hidden",
|
|
295
|
+
autoComplete: selectProps.autoComplete,
|
|
293
296
|
name: name,
|
|
294
297
|
disabled: isDisabled,
|
|
295
298
|
value: state.selectedKey
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACmDD;;;;;;AAMO,SAASG,SAAT,CAAsBC,KAAtB,EAAmDC,KAAnD,EAA0EC,GAA1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AAI,CAAC1E,IAAL,KAAc,MAAlB,EAA0B;AACxB,4BACE;AACE,UAAA,GAAG,EAAE0E,IAAI,CAACvE,GADZ;AAEE,UAAA,KAAK,EAAEuE,IAAI,CAACvE;AAFd,WAGGuE,IAAI,CAACE,SAHR,CADF;AAOD;AACF,KAXA,CAFH,CAFF,CAFF,CADF;AAuBD,GAxBD,MAwBO,IAAItB,IAAJ,EAAU;AACf,wBACE;AACE,MAAA,IAAI,EAAC,QADP;AAEE,MAAA,IAAI,EAAEA,IAFR;AAGE,MAAA,QAAQ,EAAEnE,UAHZ;AAIE,MAAA,KAAK,EAAEH,KAAK,CAACqB;AAJf,MADF;AAOD;;AAED,SAAO,IAAP;AACD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/select/src/useSelect.ts","./packages/@react-aria/select/src/HiddenSelect.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\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 {FocusEvent, HTMLAttributes, RefObject, useMemo} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\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\ninterface AriaSelectOptions<T> extends AriaSelectProps<T> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface SelectAria {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<unknown>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: HTMLAttributes<HTMLElement>\n}\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<HTMLElement>): SelectAria {\n let {\n keyboardDelegate,\n isDisabled\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(\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 {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span'\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 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 onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null,\n valueId\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 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 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 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 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 };\n}\n","/*\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 React, {ReactNode, RefObject} from 'react';\nimport {SelectState} from '@react-stately/select';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\ninterface AriaHiddenSelectProps {\n /** The text label for the select. */\n label?: ReactNode,\n\n /** HTML form input name. */\n name?: string,\n\n /** Sets the disabled state of the select and input. */\n isDisabled?: boolean\n}\n\ninterface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a hidden `<select>` element, which\n * can be used in combination with `useSelect` to support browser form autofill, mobile form\n * navigation, and native HTML form submission.\n */\nexport function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectState<T>, triggerRef: RefObject<HTMLElement>) {\n let {name, isDisabled} = props;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.\n // In Firefox, there must be a <label> to identify the <select> whereas other browsers\n // seem to identify it just by surrounding text.\n // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a\n // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>\n // non tabbable with tabIndex={-1}.\n //\n // In mobile browsers, there are next/previous buttons above the software keyboard for navigating\n // between fields in a form. These only support native form inputs that are tabbable. In order to\n // support those, an additional hidden input is used to marshall focus to the button. It is tabbable\n // except when the button is focused, so that shift tab works properly to go to the actual previous\n // input in the form. Using the <select> for this also works, but Safari on iOS briefly flashes\n // the native menu on focus, so this isn't ideal. A font-size of 16px or greater is required to\n // prevent Safari from zooming in on the input when it is focused.\n //\n // If the current interaction modality is null, then the user hasn't interacted with the page yet.\n // In this case, we set the tabIndex to -1 on the input element so that automated accessibility\n // checkers don't throw false-positives about focusable elements inside an aria-hidden parent.\n return {\n containerProps: {\n ...visuallyHiddenProps,\n 'aria-hidden': true\n },\n inputProps: {\n type: 'text',\n tabIndex: modality == null || state.isFocused || state.isOpen ? -1 : 0,\n style: {fontSize: 16},\n onFocus: () => triggerRef.current.focus(),\n disabled: isDisabled\n },\n selectProps: {\n tabIndex: -1,\n disabled: isDisabled,\n name,\n size: state.collection.size,\n value: state.selectedKey ?? '',\n onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value)\n }\n };\n}\n\n/**\n * Renders a hidden native `<select>` element, which can be used to support browser\n * form autofill, mobile form navigation, and native form submission.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>) {\n let {state, triggerRef, label, name, isDisabled} = props;\n let {containerProps, inputProps, selectProps} = useHiddenSelect(props, state, triggerRef);\n\n // If used in a <form>, use a hidden input so the value can be submitted to a server.\n // If the collection isn't too big, use a hidden <select> element for this so that browser\n // autofill will work. Otherwise, use an <input type=\"hidden\">.\n if (state.collection.size <= 300) {\n return (\n <div {...containerProps}>\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps}>\n <option />\n {[...state.collection.getKeys()].map(key => {\n let item = state.collection.getItem(key);\n if (item.type === 'item') {\n return (\n <option\n key={item.key}\n value={item.key}>\n {item.textValue}\n </option>\n );\n }\n })}\n </select>\n </label>\n </div>\n );\n } else if (name) {\n return (\n <input\n type=\"hidden\"\n name={name}\n disabled={isDisabled}\n value={state.selectedKey} />\n );\n }\n\n return null;\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useSelect","props","state","ref","keyboardDelegate","isDisabled","collator","useCollator","usage","sensitivity","delegate","useMemo","ListKeyboardDelegate","collection","disabledKeys","menuTriggerProps","menuProps","useMenuTrigger","type","onKeyDown","e","key","preventDefault","selectedKey","getKeyAbove","getFirstKey","setSelectedKey","getKeyBelow","typeSelectProps","useTypeSelect","selectionManager","onTypeSelect","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","labelElementType","onKeyDownCapture","domProps","filterDOMProps","labelable","triggerProps","mergeProps","valueId","useId","onClick","current","focus","setInteractionModality","chain","onKeyUp","id","filter","Boolean","join","onFocus","isFocused","setFocused","onBlur","isOpen","valueProps","autoFocus","focusStrategy","shouldSelectOnPressUp","shouldFocusOnHover","disallowEmptySelection","currentTarget","contains","relatedTarget","useHiddenSelect","triggerRef","name","modality","useInteractionModality","visuallyHiddenProps","useVisuallyHidden","containerProps","inputProps","tabIndex","style","fontSize","disabled","selectProps","size","value","onChange","target","HiddenSelect","label","getKeys","map","item","getItem","textValue"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAA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EAEG,CAAC,GAAGlF,KAAK,CAACW,UAAN,CAAiB8E,OAAjB,EAAJ,EAAgCC,GAAhC,CAAoCvE,GAAG,IAAI;AAC1C,UAAIwE,IAAI,GAAG3F,KAAK,CAACW,UAAN,CAAiBiF,OAAjB,CAAyBzE,GAAzB,CAAX;;AACA,UAAIwE,IAAI,CAAC3E,IAAL,KAAc,MAAlB,EAA0B;AACxB,4BACE;AACE,UAAA,GAAG,EAAE2E,IAAI,CAACxE,GADZ;AAEE,UAAA,KAAK,EAAEwE,IAAI,CAACxE;AAFd,WAGGwE,IAAI,CAACE,SAHR,CADF;AAOD;AACF,KAXA,CAFH,CAFF,CAFF,CADF;AAuBD,GAxBD,MAwBO,IAAItB,IAAJ,EAAU;AACf,wBACE;AACE,MAAA,IAAI,EAAC,QADP;AAEE,MAAA,YAAY,EAAEW,WAAW,CAACZ,YAF5B;AAGE,MAAA,IAAI,EAAEC,IAHR;AAIE,MAAA,QAAQ,EAAEpE,UAJZ;AAKE,MAAA,KAAK,EAAEH,KAAK,CAACqB;AALf,MADF;AAQD;;AAED,SAAO,IAAP;AACD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/select/src/useSelect.ts","./packages/@react-aria/select/src/HiddenSelect.tsx"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","/*\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 {FocusEvent, HTMLAttributes, RefObject, useMemo} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\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\ninterface AriaSelectOptions<T> extends AriaSelectProps<T> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface SelectAria {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<unknown>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: HTMLAttributes<HTMLElement>\n}\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<HTMLElement>): SelectAria {\n let {\n keyboardDelegate,\n isDisabled\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(\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 {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span'\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 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 onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null,\n valueId\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 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 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 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 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 };\n}\n","/*\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 React, {ReactNode, RefObject} from 'react';\nimport {SelectState} from '@react-stately/select';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\ninterface AriaHiddenSelectProps {\n /**\n * 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).\n */\n autoComplete?: string,\n\n /** The text label for the select. */\n label?: ReactNode,\n\n /** HTML form input name. */\n name?: string,\n\n /** Sets the disabled state of the select and input. */\n isDisabled?: boolean\n}\n\ninterface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a hidden `<select>` element, which\n * can be used in combination with `useSelect` to support browser form autofill, mobile form\n * navigation, and native HTML form submission.\n */\nexport function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectState<T>, triggerRef: RefObject<HTMLElement>) {\n let {autoComplete, name, isDisabled} = props;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.\n // In Firefox, there must be a <label> to identify the <select> whereas other browsers\n // seem to identify it just by surrounding text.\n // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a\n // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>\n // non tabbable with tabIndex={-1}.\n //\n // In mobile browsers, there are next/previous buttons above the software keyboard for navigating\n // between fields in a form. These only support native form inputs that are tabbable. In order to\n // support those, an additional hidden input is used to marshall focus to the button. It is tabbable\n // except when the button is focused, so that shift tab works properly to go to the actual previous\n // input in the form. Using the <select> for this also works, but Safari on iOS briefly flashes\n // the native menu on focus, so this isn't ideal. A font-size of 16px or greater is required to\n // prevent Safari from zooming in on the input when it is focused.\n //\n // If the current interaction modality is null, then the user hasn't interacted with the page yet.\n // In this case, we set the tabIndex to -1 on the input element so that automated accessibility\n // checkers don't throw false-positives about focusable elements inside an aria-hidden parent.\n return {\n containerProps: {\n ...visuallyHiddenProps,\n 'aria-hidden': true\n },\n inputProps: {\n type: 'text',\n tabIndex: modality == null || state.isFocused || state.isOpen ? -1 : 0,\n style: {fontSize: 16},\n onFocus: () => triggerRef.current.focus(),\n disabled: isDisabled\n },\n selectProps: {\n tabIndex: -1,\n autoComplete,\n disabled: isDisabled,\n name,\n size: state.collection.size,\n value: state.selectedKey ?? '',\n onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value)\n }\n };\n}\n\n/**\n * Renders a hidden native `<select>` element, which can be used to support browser\n * form autofill, mobile form navigation, and native form submission.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>) {\n let {state, triggerRef, label, name, isDisabled} = props;\n let {containerProps, inputProps, selectProps} = useHiddenSelect(props, state, triggerRef);\n\n // If used in a <form>, use a hidden input so the value can be submitted to a server.\n // If the collection isn't too big, use a hidden <select> element for this so that browser\n // autofill will work. Otherwise, use an <input type=\"hidden\">.\n if (state.collection.size <= 300) {\n return (\n <div {...containerProps}>\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps}>\n <option />\n {[...state.collection.getKeys()].map(key => {\n let item = state.collection.getItem(key);\n if (item.type === 'item') {\n return (\n <option\n key={item.key}\n value={item.key}>\n {item.textValue}\n </option>\n );\n }\n })}\n </select>\n </label>\n </div>\n );\n } else if (name) {\n return (\n <input\n type=\"hidden\"\n autoComplete={selectProps.autoComplete}\n name={name}\n disabled={isDisabled}\n value={state.selectedKey} />\n );\n }\n\n return null;\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useSelect","props","state","ref","keyboardDelegate","isDisabled","collator","useCollator","usage","sensitivity","delegate","useMemo","ListKeyboardDelegate","collection","disabledKeys","menuTriggerProps","menuProps","useMenuTrigger","type","onKeyDown","e","key","preventDefault","selectedKey","getKeyAbove","getFirstKey","setSelectedKey","getKeyBelow","typeSelectProps","useTypeSelect","selectionManager","onTypeSelect","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","labelElementType","onKeyDownCapture","domProps","filterDOMProps","labelable","triggerProps","mergeProps","valueId","useId","onClick","current","focus","setInteractionModality","chain","onKeyUp","id","filter","Boolean","join","onFocus","isFocused","setFocused","onBlur","isOpen","valueProps","autoFocus","focusStrategy","shouldSelectOnPressUp","shouldFocusOnHover","disallowEmptySelection","currentTarget","contains","relatedTarget","useHiddenSelect","triggerRef","autoComplete","name","modality","useInteractionModality","visuallyHiddenProps","useVisuallyHidden","containerProps","inputProps","tabIndex","style","fontSize","disabled","selectProps","size","value","onChange","target","HiddenSelect","label","getKeys","map","item","getItem","textValue"],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -165,6 +165,7 @@ export function useHiddenSelect(props, state, triggerRef) {
|
|
|
165
165
|
var _state$selectedKey;
|
|
166
166
|
|
|
167
167
|
let {
|
|
168
|
+
autoComplete,
|
|
168
169
|
name,
|
|
169
170
|
isDisabled
|
|
170
171
|
} = props;
|
|
@@ -205,6 +206,7 @@ export function useHiddenSelect(props, state, triggerRef) {
|
|
|
205
206
|
},
|
|
206
207
|
selectProps: {
|
|
207
208
|
tabIndex: -1,
|
|
209
|
+
autoComplete,
|
|
208
210
|
disabled: isDisabled,
|
|
209
211
|
name,
|
|
210
212
|
size: state.collection.size,
|
|
@@ -248,6 +250,7 @@ export function HiddenSelect(props) {
|
|
|
248
250
|
} else if (name) {
|
|
249
251
|
return /*#__PURE__*/_react.createElement("input", {
|
|
250
252
|
type: "hidden",
|
|
253
|
+
autoComplete: selectProps.autoComplete,
|
|
251
254
|
name: name,
|
|
252
255
|
disabled: isDisabled,
|
|
253
256
|
value: state.selectedKey
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAqDA;;;;;;OAMO,SAASA,SAAT,CAAsBC,KAAtB,EAAmDC,KAAnD,EAA0EC,GAA1E,EAAmH;AACxH,MAAI;AACFC,IAAAA,gBADE;AAEFC,IAAAA;AAFE,MAGAJ,KAHJ,CADwH,CAMxH;AACA;;AACA,MAAIK,QAAQ,GAAGC,WAAW,CAAC;AAACC,IAAAA,KAAK,EAAE,QAAR;AAAkBC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AACF,KAXA,CAFH,CAFF,CAFF,CADF;AAuBD,GAxBD,MAwBO,IAAItB,IAAJ,EAAU;AACf,wBACE;AACE,MAAA,IAAI,EAAC,QADP;AAEE,MAAA,IAAI,EAAEA,IAFR;AAGE,MAAA,QAAQ,EAAEnE,UAHZ;AAIE,MAAA,KAAK,EAAEH,KAAK,CAACqB;AAJf,MADF;AAOD;;AAED,SAAO,IAAP;AACD","sources":["./packages/@react-aria/select/src/useSelect.ts","./packages/@react-aria/select/src/HiddenSelect.tsx"],"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 {FocusEvent, HTMLAttributes, RefObject, useMemo} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\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\ninterface AriaSelectOptions<T> extends AriaSelectProps<T> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface SelectAria {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<unknown>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: HTMLAttributes<HTMLElement>\n}\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<HTMLElement>): SelectAria {\n let {\n keyboardDelegate,\n isDisabled\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(\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 {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span'\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 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 onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null,\n valueId\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 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 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 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 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 };\n}\n","/*\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 React, {ReactNode, RefObject} from 'react';\nimport {SelectState} from '@react-stately/select';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\ninterface AriaHiddenSelectProps {\n /** The text label for the select. */\n label?: ReactNode,\n\n /** HTML form input name. */\n name?: string,\n\n /** Sets the disabled state of the select and input. */\n isDisabled?: boolean\n}\n\ninterface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a hidden `<select>` element, which\n * can be used in combination with `useSelect` to support browser form autofill, mobile form\n * navigation, and native HTML form submission.\n */\nexport function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectState<T>, triggerRef: RefObject<HTMLElement>) {\n let {name, isDisabled} = props;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.\n // In Firefox, there must be a <label> to identify the <select> whereas other browsers\n // seem to identify it just by surrounding text.\n // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a\n // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>\n // non tabbable with tabIndex={-1}.\n //\n // In mobile browsers, there are next/previous buttons above the software keyboard for navigating\n // between fields in a form. These only support native form inputs that are tabbable. In order to\n // support those, an additional hidden input is used to marshall focus to the button. It is tabbable\n // except when the button is focused, so that shift tab works properly to go to the actual previous\n // input in the form. Using the <select> for this also works, but Safari on iOS briefly flashes\n // the native menu on focus, so this isn't ideal. A font-size of 16px or greater is required to\n // prevent Safari from zooming in on the input when it is focused.\n //\n // If the current interaction modality is null, then the user hasn't interacted with the page yet.\n // In this case, we set the tabIndex to -1 on the input element so that automated accessibility\n // checkers don't throw false-positives about focusable elements inside an aria-hidden parent.\n return {\n containerProps: {\n ...visuallyHiddenProps,\n 'aria-hidden': true\n },\n inputProps: {\n type: 'text',\n tabIndex: modality == null || state.isFocused || state.isOpen ? -1 : 0,\n style: {fontSize: 16},\n onFocus: () => triggerRef.current.focus(),\n disabled: isDisabled\n },\n selectProps: {\n tabIndex: -1,\n disabled: isDisabled,\n name,\n size: state.collection.size,\n value: state.selectedKey ?? '',\n onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value)\n }\n };\n}\n\n/**\n * Renders a hidden native `<select>` element, which can be used to support browser\n * form autofill, mobile form navigation, and native form submission.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>) {\n let {state, triggerRef, label, name, isDisabled} = props;\n let {containerProps, inputProps, selectProps} = useHiddenSelect(props, state, triggerRef);\n\n // If used in a <form>, use a hidden input so the value can be submitted to a server.\n // If the collection isn't too big, use a hidden <select> element for this so that browser\n // autofill will work. Otherwise, use an <input type=\"hidden\">.\n if (state.collection.size <= 300) {\n return (\n <div {...containerProps}>\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps}>\n <option />\n {[...state.collection.getKeys()].map(key => {\n let item = state.collection.getItem(key);\n if (item.type === 'item') {\n return (\n <option\n key={item.key}\n value={item.key}>\n {item.textValue}\n </option>\n );\n }\n })}\n </select>\n </label>\n </div>\n );\n } else if (name) {\n return (\n <input\n type=\"hidden\"\n name={name}\n disabled={isDisabled}\n value={state.selectedKey} />\n );\n }\n\n return null;\n}\n"],"names":["useSelect","props","state","ref","keyboardDelegate","isDisabled","collator","useCollator","usage","sensitivity","delegate","useMemo","ListKeyboardDelegate","collection","disabledKeys","menuTriggerProps","menuProps","useMenuTrigger","type","onKeyDown","e","key","preventDefault","selectedKey","getKeyAbove","getFirstKey","setSelectedKey","getKeyBelow","typeSelectProps","useTypeSelect","selectionManager","onTypeSelect","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","labelElementType","onKeyDownCapture","domProps","filterDOMProps","labelable","triggerProps","mergeProps","valueId","useId","onClick","current","focus","setInteractionModality","chain","onKeyUp","id","filter","Boolean","join","onFocus","isFocused","setFocused","onBlur","isOpen","valueProps","autoFocus","focusStrategy","shouldSelectOnPressUp","shouldFocusOnHover","disallowEmptySelection","currentTarget","contains","relatedTarget","useHiddenSelect","triggerRef","name","modality","useInteractionModality","visuallyHiddenProps","useVisuallyHidden","containerProps","inputProps","tabIndex","style","fontSize","disabled","selectProps","size","value","onChange","target","HiddenSelect","label","getKeys","map","item","getItem","textValue"],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAqDA;;;;;;OAMO,SAASA,SAAT,CAAsBC,KAAtB,EAAmDC,KAAnD,EAA0EC,GAA1E,EAAmH;AACxH,MAAI;AACFC,IAAAA,gBADE;AAEFC,IAAAA;AAFE,MAGAJ,KAHJ,CADwH,CAMxH;AACA;;AACA,MAAIK,QAAQ,GAAGC,WAAW,CAAC;AAACC,IAAAA,KAAK,EAAE,QAAR;AAAkBC,IAAAA,WAAW,EAAE;AAA/B,GAAD,CAA1B;AACA,MAAIC,QAAQ,GAAGC,OAAO,CAAC,MAAMP,gBAAgB,IAAI,IAAIQ,oBAAJ,CAAyBV,KAAK,CAACW,UAA/B,EAA2CX,KAAK,CAACY,YAAjD,EAA+D,IAA/D,EAAqER,QAArE,CAA3B,EAA2G,CAACF,gBAAD,EAAmBF,KAAK,CAACW,UAAzB,EAAqCX,KAAK,CAACY,YAA3C,EAAyDR,QAAzD,CAA3G,CAAtB;AAEA,MAAI;AAACS,IAAAA,gBAAD;AAAmBC,IAAAA;AAAnB,MAAgCC,cAAc,CAChD;AACEZ,IAAAA,UADF;AAEEa,IAAAA,IAAI,EAAE;AAFR,GADgD,EAKhDhB,KALgD,EAMhDC,GANgD,CAAlD;;AASA,MAAIgB,SAAS,GAAIC,CAAD,IAAsB;AACpC,YAAQA,CAAC,CAACC,GAAV;AACE,WAAK,W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AC6E,IAAAA,cAAD;AAAiBC,IAAAA,UAAjB;AAA6BK,IAAAA;AAA7B,MAA4Cd,eAAe,CAACrE,KAAD,EAAQC,KAAR,EAAeqE,UAAf,CAA/D,CAF2D,CAI3D;AACA;AACA;;AACA,MAAIrE,KAAK,CAACW,UAAN,CAAiBwE,IAAjB,IAAyB,GAA7B,EAAkC;AAChC,wBACE,4BAASP,cAAT,eACE,8BAAWC,UAAX,CADF,eAEE,oCACGW,KADH,eAEE,+BAAYN,WAAZ,eACE,oCADF,EAEG,CAAC,GAAGlF,KAAK,CAACW,UAAN,CAAiB8E,OAAjB,EAAJ,EAAgCC,GAAhC,CAAoCvE,GAAG,IAAI;AAC1C,UAAIwE,IAAI,GAAG3F,KAAK,CAACW,UAAN,CAAiBiF,OAAjB,CAAyBzE,GAAzB,CAAX;;AACA,UAAIwE,IAAI,CAAC3E,IAAL,KAAc,MAAlB,EAA0B;AACxB,4BACE;AACE,UAAA,GAAG,EAAE2E,IAAI,CAACxE,GADZ;AAEE,UAAA,KAAK,EAAEwE,IAAI,CAACxE;AAFd,WAGGwE,IAAI,CAACE,SAHR,CADF;AAOD;AACF,KAXA,CAFH,CAFF,CAFF,CADF;AAuBD,GAxBD,MAwBO,IAAItB,IAAJ,EAAU;AACf,wBACE;AACE,MAAA,IAAI,EAAC,QADP;AAEE,MAAA,YAAY,EAAEW,WAAW,CAACZ,YAF5B;AAGE,MAAA,IAAI,EAAEC,IAHR;AAIE,MAAA,QAAQ,EAAEpE,UAJZ;AAKE,MAAA,KAAK,EAAEH,KAAK,CAACqB;AALf,MADF;AAQD;;AAED,SAAO,IAAP;AACD","sources":["./packages/@react-aria/select/src/useSelect.ts","./packages/@react-aria/select/src/HiddenSelect.tsx"],"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 {FocusEvent, HTMLAttributes, RefObject, useMemo} from 'react';\nimport {KeyboardDelegate} from '@react-types/shared';\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\ninterface AriaSelectOptions<T> extends AriaSelectProps<T> {\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface SelectAria {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup trigger element. */\n triggerProps: AriaButtonProps,\n\n /** Props for the element representing the selected value. */\n valueProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the popup. */\n menuProps: AriaListBoxOptions<unknown>,\n\n /** Props for the select's description element, if any. */\n descriptionProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the select's error message element, if any. */\n errorMessageProps: HTMLAttributes<HTMLElement>\n}\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<HTMLElement>): SelectAria {\n let {\n keyboardDelegate,\n isDisabled\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(\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 {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n labelElementType: 'span'\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 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 onKeyDown: chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),\n onKeyUp: props.onKeyUp,\n 'aria-labelledby': [\n triggerProps['aria-labelledby'],\n triggerProps['aria-label'] && !triggerProps['aria-labelledby'] ? triggerProps.id : null,\n valueId\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 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 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 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 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 };\n}\n","/*\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 React, {ReactNode, RefObject} from 'react';\nimport {SelectState} from '@react-stately/select';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\ninterface AriaHiddenSelectProps {\n /**\n * 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).\n */\n autoComplete?: string,\n\n /** The text label for the select. */\n label?: ReactNode,\n\n /** HTML form input name. */\n name?: string,\n\n /** Sets the disabled state of the select and input. */\n isDisabled?: boolean\n}\n\ninterface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<HTMLElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a hidden `<select>` element, which\n * can be used in combination with `useSelect` to support browser form autofill, mobile form\n * navigation, and native HTML form submission.\n */\nexport function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectState<T>, triggerRef: RefObject<HTMLElement>) {\n let {autoComplete, name, isDisabled} = props;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.\n // In Firefox, there must be a <label> to identify the <select> whereas other browsers\n // seem to identify it just by surrounding text.\n // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a\n // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>\n // non tabbable with tabIndex={-1}.\n //\n // In mobile browsers, there are next/previous buttons above the software keyboard for navigating\n // between fields in a form. These only support native form inputs that are tabbable. In order to\n // support those, an additional hidden input is used to marshall focus to the button. It is tabbable\n // except when the button is focused, so that shift tab works properly to go to the actual previous\n // input in the form. Using the <select> for this also works, but Safari on iOS briefly flashes\n // the native menu on focus, so this isn't ideal. A font-size of 16px or greater is required to\n // prevent Safari from zooming in on the input when it is focused.\n //\n // If the current interaction modality is null, then the user hasn't interacted with the page yet.\n // In this case, we set the tabIndex to -1 on the input element so that automated accessibility\n // checkers don't throw false-positives about focusable elements inside an aria-hidden parent.\n return {\n containerProps: {\n ...visuallyHiddenProps,\n 'aria-hidden': true\n },\n inputProps: {\n type: 'text',\n tabIndex: modality == null || state.isFocused || state.isOpen ? -1 : 0,\n style: {fontSize: 16},\n onFocus: () => triggerRef.current.focus(),\n disabled: isDisabled\n },\n selectProps: {\n tabIndex: -1,\n autoComplete,\n disabled: isDisabled,\n name,\n size: state.collection.size,\n value: state.selectedKey ?? '',\n onChange: (e: React.ChangeEvent<HTMLSelectElement>) => state.setSelectedKey(e.target.value)\n }\n };\n}\n\n/**\n * Renders a hidden native `<select>` element, which can be used to support browser\n * form autofill, mobile form navigation, and native form submission.\n */\nexport function HiddenSelect<T>(props: HiddenSelectProps<T>) {\n let {state, triggerRef, label, name, isDisabled} = props;\n let {containerProps, inputProps, selectProps} = useHiddenSelect(props, state, triggerRef);\n\n // If used in a <form>, use a hidden input so the value can be submitted to a server.\n // If the collection isn't too big, use a hidden <select> element for this so that browser\n // autofill will work. Otherwise, use an <input type=\"hidden\">.\n if (state.collection.size <= 300) {\n return (\n <div {...containerProps}>\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps}>\n <option />\n {[...state.collection.getKeys()].map(key => {\n let item = state.collection.getItem(key);\n if (item.type === 'item') {\n return (\n <option\n key={item.key}\n value={item.key}>\n {item.textValue}\n </option>\n );\n }\n })}\n </select>\n </label>\n </div>\n );\n } else if (name) {\n return (\n <input\n type=\"hidden\"\n autoComplete={selectProps.autoComplete}\n name={name}\n disabled={isDisabled}\n value={state.selectedKey} />\n );\n }\n\n return null;\n}\n"],"names":["useSelect","props","state","ref","keyboardDelegate","isDisabled","collator","useCollator","usage","sensitivity","delegate","useMemo","ListKeyboardDelegate","collection","disabledKeys","menuTriggerProps","menuProps","useMenuTrigger","type","onKeyDown","e","key","preventDefault","selectedKey","getKeyAbove","getFirstKey","setSelectedKey","getKeyBelow","typeSelectProps","useTypeSelect","selectionManager","onTypeSelect","labelProps","fieldProps","descriptionProps","errorMessageProps","useField","labelElementType","onKeyDownCapture","domProps","filterDOMProps","labelable","triggerProps","mergeProps","valueId","useId","onClick","current","focus","setInteractionModality","chain","onKeyUp","id","filter","Boolean","join","onFocus","isFocused","setFocused","onBlur","isOpen","valueProps","autoFocus","focusStrategy","shouldSelectOnPressUp","shouldFocusOnHover","disallowEmptySelection","currentTarget","contains","relatedTarget","useHiddenSelect","triggerRef","autoComplete","name","modality","useInteractionModality","visuallyHiddenProps","useVisuallyHidden","containerProps","inputProps","tabIndex","style","fontSize","disabled","selectProps","size","value","onChange","target","HiddenSelect","label","getKeys","map","item","getItem","textValue"],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ interface SelectAria {
|
|
|
33
33
|
*/
|
|
34
34
|
export function useSelect<T>(props: AriaSelectOptions<T>, state: SelectState<T>, ref: RefObject<HTMLElement>): SelectAria;
|
|
35
35
|
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;
|
|
36
40
|
/** The text label for the select. */
|
|
37
41
|
label?: ReactNode;
|
|
38
42
|
/** HTML form input name. */
|
|
@@ -321,6 +325,7 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectSt
|
|
|
321
325
|
};
|
|
322
326
|
selectProps: {
|
|
323
327
|
tabIndex: number;
|
|
328
|
+
autoComplete: string;
|
|
324
329
|
disabled: boolean;
|
|
325
330
|
name: string;
|
|
326
331
|
size: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"A;A;A;A;A;A;AAyBA,4BAA4B,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IACvD;A;A;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AAED;IACE,mCAAmC;IACnC,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IAExC,2CAA2C;IAC3C,YAAY,EAAE,eAAe,CAAC;IAE9B,6DAA6D;IAC7D,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IAExC,2BAA2B;IAC3B,SAAS,EAAE,mBAAmB,OAAO,CAAC,CAAC;IAEvC,0DAA0D;IAC1D,gBAAgB,EAAE,eAAe,WAAW,CAAC,CAAC;IAE9C,4DAA4D;IAC5D,iBAAiB,EAAE,eAAe,WAAW,CAAC,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AAC,EAAE,UAAU,EAAE,UAAU,WAAW,CAAC;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;A;EA6CzH;AAED;A;A;GAGG;AACH,6BAA6B,CAAC,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC,eA2C1D","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"],"sourcesContent":[null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/select",
|
|
3
|
-
"version": "3.5.1-nightly.
|
|
3
|
+
"version": "3.5.1-nightly.2972+9ca62f944",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/label": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/listbox": "3.3.2-nightly.
|
|
25
|
-
"@react-aria/menu": "3.2.4-nightly.
|
|
26
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
27
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
28
|
-
"@react-aria/visually-hidden": "3.0.0-nightly.
|
|
29
|
-
"@react-stately/select": "3.1.4-nightly.
|
|
30
|
-
"@react-types/button": "3.4.2-nightly.
|
|
31
|
-
"@react-types/select": "3.4.1-nightly.
|
|
32
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
21
|
+
"@react-aria/i18n": "3.0.0-nightly.1286+9ca62f944",
|
|
22
|
+
"@react-aria/interactions": "3.0.0-nightly.1286+9ca62f944",
|
|
23
|
+
"@react-aria/label": "3.0.0-nightly.1286+9ca62f944",
|
|
24
|
+
"@react-aria/listbox": "3.3.2-nightly.2972+9ca62f944",
|
|
25
|
+
"@react-aria/menu": "3.2.4-nightly.2972+9ca62f944",
|
|
26
|
+
"@react-aria/selection": "3.0.0-nightly.1286+9ca62f944",
|
|
27
|
+
"@react-aria/utils": "3.0.0-nightly.1286+9ca62f944",
|
|
28
|
+
"@react-aria/visually-hidden": "3.0.0-nightly.1286+9ca62f944",
|
|
29
|
+
"@react-stately/select": "3.1.4-nightly.2972+9ca62f944",
|
|
30
|
+
"@react-types/button": "3.4.2-nightly.2972+9ca62f944",
|
|
31
|
+
"@react-types/select": "3.4.1-nightly.2972+9ca62f944",
|
|
32
|
+
"@react-types/shared": "3.0.0-nightly.1286+9ca62f944"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0-rc.1",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "9ca62f94405cb8b930bd155f6e44c4854f0a20f3"
|
|
42
42
|
}
|
package/src/HiddenSelect.tsx
CHANGED
|
@@ -16,6 +16,11 @@ import {useInteractionModality} from '@react-aria/interactions';
|
|
|
16
16
|
import {useVisuallyHidden} from '@react-aria/visually-hidden';
|
|
17
17
|
|
|
18
18
|
interface AriaHiddenSelectProps {
|
|
19
|
+
/**
|
|
20
|
+
* 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).
|
|
21
|
+
*/
|
|
22
|
+
autoComplete?: string,
|
|
23
|
+
|
|
19
24
|
/** The text label for the select. */
|
|
20
25
|
label?: ReactNode,
|
|
21
26
|
|
|
@@ -40,7 +45,7 @@ interface HiddenSelectProps<T> extends AriaHiddenSelectProps {
|
|
|
40
45
|
* navigation, and native HTML form submission.
|
|
41
46
|
*/
|
|
42
47
|
export function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectState<T>, triggerRef: RefObject<HTMLElement>) {
|
|
43
|
-
let {name, isDisabled} = props;
|
|
48
|
+
let {autoComplete, name, isDisabled} = props;
|
|
44
49
|
let modality = useInteractionModality();
|
|
45
50
|
let {visuallyHiddenProps} = useVisuallyHidden();
|
|
46
51
|
|
|
@@ -76,6 +81,7 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectProps, state: SelectSt
|
|
|
76
81
|
},
|
|
77
82
|
selectProps: {
|
|
78
83
|
tabIndex: -1,
|
|
84
|
+
autoComplete,
|
|
79
85
|
disabled: isDisabled,
|
|
80
86
|
name,
|
|
81
87
|
size: state.collection.size,
|
|
@@ -124,6 +130,7 @@ export function HiddenSelect<T>(props: HiddenSelectProps<T>) {
|
|
|
124
130
|
return (
|
|
125
131
|
<input
|
|
126
132
|
type="hidden"
|
|
133
|
+
autoComplete={selectProps.autoComplete}
|
|
127
134
|
name={name}
|
|
128
135
|
disabled={isDisabled}
|
|
129
136
|
value={state.selectedKey} />
|