@react-aria/select 3.14.6-nightly.4700 → 3.14.6-nightly.4704
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/HiddenSelect.main.js +2 -0
- package/dist/HiddenSelect.main.js.map +1 -1
- package/dist/HiddenSelect.mjs +2 -0
- package/dist/HiddenSelect.module.js +2 -0
- package/dist/HiddenSelect.module.js.map +1 -1
- package/dist/types.d.ts +11 -256
- package/dist/types.d.ts.map +1 -1
- package/dist/useSelect.main.js.map +1 -1
- package/dist/useSelect.module.js.map +1 -1
- package/package.json +15 -15
- package/src/HiddenSelect.tsx +16 -3
- package/src/useSelect.ts +2 -2
|
@@ -66,7 +66,9 @@ function $6eae0e0872a4cdd4$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
|
66
66
|
containerProps: {
|
|
67
67
|
...visuallyHiddenProps,
|
|
68
68
|
'aria-hidden': true,
|
|
69
|
+
// @ts-ignore
|
|
69
70
|
['data-react-aria-prevent-focus']: true,
|
|
71
|
+
// @ts-ignore
|
|
70
72
|
['data-a11y-ignore']: 'aria-hidden-focus'
|
|
71
73
|
},
|
|
72
74
|
inputProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwDM,SAAS,0CAAmB,KAA8B,EAAE,KAAqB,EAAE,UAA8C;IACtI,IAAI,OAAO,CAAA,GAAA,oCAAS,EAAE,GAAG,CAAC,UAAU,CAAC;IACrC,IAAI,gBAAC,YAAY,QAAE,OAAO,KAAK,IAAI,cAAE,aAAa,KAAK,UAAU,EAAC,GAAG;IACrE,IAAI,sBAAC,kBAAkB,cAAE,UAAU,EAAC,GAAG;IACvC,IAAI,WAAW,CAAA,GAAA,mDAAqB;IACpC,IAAI,uBAAC,mBAAmB,EAAC,GA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0CAAgB;QAAC,GAAG,KAAK;mBAAE;IAAS,GAAG,OAAO;QAoCjF;IAlCb,qFAAqF;IACrF,0FAA0F;IAC1F,+DAA+D;IAC/D,IAAI,MAAM,UAAU,CAAC,IAAI,IAAI,KAC3B,qBACE,0DAAC;QAAK,GAAG,cAAc;QAAE,eAAY;qBACnC,0DAAC,SAAU,2BACX,0DAAC,eACE,qBACD,0DAAC;QAAQ,GAAG,WAAW;QAAE,KAAK;qBAC5B,0DAAC,iBACA;WAAI,MAAM,UAAU,CAAC,OAAO;KAAG,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;QACpC,IAAI,KAAK,IAAI,KAAK,QAChB,qBACE,0DAAC;YACC,KAAK,KAAK,GAAG;YACb,OAAO,KAAK,GAAG;WACd,KAAK,SAAS;IAIvB;SAKH,IAAI,MACT,qBACE,0DAAC;QACC,MAAK;QACL,cAAc,YAAY,YAAY;QACtC,MAAM;QACN,UAAU;QACV,OAAO,CAAA,qBAAA,MAAM,WAAW,cAAjB,gCAAA,qBAAqB;;IAIlC,OAAO;AACT","sources":["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 {FocusableElement, RefObject} from '@react-types/shared';\nimport React, {ReactNode, useRef} from 'react';\nimport {selectData} from './useSelect';\nimport {SelectState} from '@react-stately/select';\nimport {useFormReset} from '@react-aria/utils';\nimport {useFormValidation} from '@react-aria/form';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface 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\nexport interface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<FocusableElement | null>\n}\n\nexport interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {\n /** A ref to the hidden `<select>` element. */\n selectRef?: RefObject<HTMLSelectElement | null>\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: React.HTMLAttributes<FocusableElement>,\n\n /** Props for the hidden input element. */\n inputProps: React.InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the hidden select element. */\n selectProps: React.SelectHTMLAttributes<HTMLSelectElement>\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: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria {\n let data = selectData.get(state) || {};\n let {autoComplete, name = data.name, isDisabled = data.isDisabled} = props;\n let {validationBehavior, isRequired} = data;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n useFormReset(props.selectRef, state.selectedKey, state.setSelectedKey);\n useFormValidation({\n validationBehavior,\n focus: () => triggerRef.current.focus()\n }, state, props.selectRef);\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 // @ts-ignore\n ['data-react-aria-prevent-focus']: true,\n // @ts-ignore\n ['data-a11y-ignore']: 'aria-hidden-focus'\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 required: validationBehavior === 'native' && isRequired,\n name,\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 selectRef = useRef(null);\n let {containerProps, inputProps, selectProps} = useHiddenSelect({...props, selectRef}, 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} data-testid=\"hidden-select-container\">\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps} ref={selectRef}>\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":[],"version":3,"file":"HiddenSelect.main.js.map"}
|
package/dist/HiddenSelect.mjs
CHANGED
|
@@ -55,7 +55,9 @@ function $bdd25dc72710631f$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
|
55
55
|
containerProps: {
|
|
56
56
|
...visuallyHiddenProps,
|
|
57
57
|
'aria-hidden': true,
|
|
58
|
+
// @ts-ignore
|
|
58
59
|
['data-react-aria-prevent-focus']: true,
|
|
60
|
+
// @ts-ignore
|
|
59
61
|
['data-a11y-ignore']: 'aria-hidden-focus'
|
|
60
62
|
},
|
|
61
63
|
inputProps: {
|
|
@@ -55,7 +55,9 @@ function $bdd25dc72710631f$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
|
55
55
|
containerProps: {
|
|
56
56
|
...visuallyHiddenProps,
|
|
57
57
|
'aria-hidden': true,
|
|
58
|
+
// @ts-ignore
|
|
58
59
|
['data-react-aria-prevent-focus']: true,
|
|
60
|
+
// @ts-ignore
|
|
59
61
|
['data-a11y-ignore']: 'aria-hidden-focus'
|
|
60
62
|
},
|
|
61
63
|
inputProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AAwDM,SAAS,0CAAmB,KAA8B,EAAE,KAAqB,EAAE,UAA8C;IACtI,IAAI,OAAO,CAAA,GAAA,yCAAS,EAAE,GAAG,CAAC,UAAU,CAAC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O,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,cAAE,UAAU,SAAE,KAAK,QAAE,IAAI,cAAE,UAAU,EAAC,GAAG;IACnD,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,IAAI,kBAAC,cAAc,cAAE,UAAU,eAAE,WAAW,EAAC,GAAG,0CAAgB;QAAC,GAAG,KAAK;mBAAE;IAAS,GAAG,OAAO;QAoCjF;IAlCb,qFAAqF;IACrF,0FAA0F;IAC1F,+DAA+D;IAC/D,IAAI,MAAM,UAAU,CAAC,IAAI,IAAI,KAC3B,qBACE,gCAAC;QAAK,GAAG,cAAc;QAAE,eAAY;qBACnC,gCAAC,SAAU,2BACX,gCAAC,eACE,qBACD,gCAAC;QAAQ,GAAG,WAAW;QAAE,KAAK;qBAC5B,gCAAC,iBACA;WAAI,MAAM,UAAU,CAAC,OAAO;KAAG,CAAC,GAAG,CAAC,CAAA;QACnC,IAAI,OAAO,MAAM,UAAU,CAAC,OAAO,CAAC;QACpC,IAAI,KAAK,IAAI,KAAK,QAChB,qBACE,gCAAC;YACC,KAAK,KAAK,GAAG;YACb,OAAO,KAAK,GAAG;WACd,KAAK,SAAS;IAIvB;SAKH,IAAI,MACT,qBACE,gCAAC;QACC,MAAK;QACL,cAAc,YAAY,YAAY;QACtC,MAAM;QACN,UAAU;QACV,OAAO,CAAA,qBAAA,MAAM,WAAW,cAAjB,gCAAA,qBAAqB;;IAIlC,OAAO;AACT","sources":["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 {FocusableElement, RefObject} from '@react-types/shared';\nimport React, {ReactNode, useRef} from 'react';\nimport {selectData} from './useSelect';\nimport {SelectState} from '@react-stately/select';\nimport {useFormReset} from '@react-aria/utils';\nimport {useFormValidation} from '@react-aria/form';\nimport {useInteractionModality} from '@react-aria/interactions';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface 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\nexport interface HiddenSelectProps<T> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<FocusableElement | null>\n}\n\nexport interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {\n /** A ref to the hidden `<select>` element. */\n selectRef?: RefObject<HTMLSelectElement | null>\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: React.HTMLAttributes<FocusableElement>,\n\n /** Props for the hidden input element. */\n inputProps: React.InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the hidden select element. */\n selectProps: React.SelectHTMLAttributes<HTMLSelectElement>\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: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria {\n let data = selectData.get(state) || {};\n let {autoComplete, name = data.name, isDisabled = data.isDisabled} = props;\n let {validationBehavior, isRequired} = data;\n let modality = useInteractionModality();\n let {visuallyHiddenProps} = useVisuallyHidden();\n\n useFormReset(props.selectRef, state.selectedKey, state.setSelectedKey);\n useFormValidation({\n validationBehavior,\n focus: () => triggerRef.current.focus()\n }, state, props.selectRef);\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 // @ts-ignore\n ['data-react-aria-prevent-focus']: true,\n // @ts-ignore\n ['data-a11y-ignore']: 'aria-hidden-focus'\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 required: validationBehavior === 'native' && isRequired,\n name,\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 selectRef = useRef(null);\n let {containerProps, inputProps, selectProps} = useHiddenSelect({...props, selectRef}, 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} data-testid=\"hidden-select-container\">\n <input {...inputProps} />\n <label>\n {label}\n <select {...selectProps} ref={selectRef}>\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":[],"version":3,"file":"HiddenSelect.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AriaButtonProps } from "@react-types/button";
|
|
2
2
|
import { AriaListBoxOptions } from "@react-aria/listbox";
|
|
3
3
|
import { AriaSelectProps } from "@react-types/select";
|
|
4
|
-
import { DOMAttributes, FocusableElement, KeyboardDelegate,
|
|
5
|
-
import React, { RefObject, ReactNode } from "react";
|
|
4
|
+
import { DOMAttributes, FocusableElement, KeyboardDelegate, RefObject, ValidationResult } from "@react-types/shared";
|
|
6
5
|
import { SelectState } from "@react-stately/select";
|
|
6
|
+
import React, { ReactNode } from "react";
|
|
7
7
|
export interface AriaSelectOptions<T> extends Omit<AriaSelectProps<T>, 'children'> {
|
|
8
8
|
/**
|
|
9
9
|
* An optional keyboard delegate implementation for type to select,
|
|
@@ -54,265 +54,20 @@ interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {
|
|
|
54
54
|
/** A ref to the hidden `<select>` element. */
|
|
55
55
|
selectRef?: RefObject<HTMLSelectElement | null>;
|
|
56
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>;
|
|
64
|
+
}
|
|
57
65
|
/**
|
|
58
66
|
* Provides the behavior and accessibility implementation for a hidden `<select>` element, which
|
|
59
67
|
* can be used in combination with `useSelect` to support browser form autofill, mobile form
|
|
60
68
|
* navigation, and native HTML form submission.
|
|
61
69
|
*/
|
|
62
|
-
export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>):
|
|
63
|
-
containerProps: {
|
|
64
|
-
'aria-hidden': boolean;
|
|
65
|
-
"data-react-aria-prevent-focus": boolean;
|
|
66
|
-
"data-a11y-ignore": string;
|
|
67
|
-
id?: string | undefined;
|
|
68
|
-
role?: React.AriaRole | undefined;
|
|
69
|
-
tabIndex?: number | undefined;
|
|
70
|
-
style?: React.CSSProperties | undefined;
|
|
71
|
-
className?: string | undefined;
|
|
72
|
-
"aria-activedescendant"?: string | undefined;
|
|
73
|
-
"aria-atomic"?: (boolean | "false" | "true") | undefined;
|
|
74
|
-
"aria-autocomplete"?: "none" | "inline" | "list" | "both" | undefined;
|
|
75
|
-
"aria-braillelabel"?: string | undefined;
|
|
76
|
-
"aria-brailleroledescription"?: string | undefined;
|
|
77
|
-
"aria-busy"?: (boolean | "false" | "true") | undefined;
|
|
78
|
-
"aria-checked"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
79
|
-
"aria-colcount"?: number | undefined;
|
|
80
|
-
"aria-colindex"?: number | undefined;
|
|
81
|
-
"aria-colindextext"?: string | undefined;
|
|
82
|
-
"aria-colspan"?: number | undefined;
|
|
83
|
-
"aria-controls"?: string | undefined;
|
|
84
|
-
"aria-current"?: boolean | "false" | "true" | "page" | "step" | "location" | "date" | "time" | undefined;
|
|
85
|
-
"aria-describedby"?: string | undefined;
|
|
86
|
-
"aria-description"?: string | undefined;
|
|
87
|
-
"aria-details"?: string | undefined;
|
|
88
|
-
"aria-disabled"?: (boolean | "false" | "true") | undefined;
|
|
89
|
-
"aria-dropeffect"?: "none" | "copy" | "execute" | "link" | "move" | "popup" | undefined;
|
|
90
|
-
"aria-errormessage"?: string | undefined;
|
|
91
|
-
"aria-expanded"?: (boolean | "false" | "true") | undefined;
|
|
92
|
-
"aria-flowto"?: string | undefined;
|
|
93
|
-
"aria-grabbed"?: (boolean | "false" | "true") | undefined;
|
|
94
|
-
"aria-haspopup"?: boolean | "false" | "true" | "menu" | "listbox" | "tree" | "grid" | "dialog" | undefined;
|
|
95
|
-
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling" | undefined;
|
|
96
|
-
"aria-keyshortcuts"?: string | undefined;
|
|
97
|
-
"aria-label"?: string | undefined;
|
|
98
|
-
"aria-labelledby"?: string | undefined;
|
|
99
|
-
"aria-level"?: number | undefined;
|
|
100
|
-
"aria-live"?: "off" | "assertive" | "polite" | undefined;
|
|
101
|
-
"aria-modal"?: (boolean | "false" | "true") | undefined;
|
|
102
|
-
"aria-multiline"?: (boolean | "false" | "true") | undefined;
|
|
103
|
-
"aria-multiselectable"?: (boolean | "false" | "true") | undefined;
|
|
104
|
-
"aria-orientation"?: "horizontal" | "vertical" | undefined;
|
|
105
|
-
"aria-owns"?: string | undefined;
|
|
106
|
-
"aria-placeholder"?: string | undefined;
|
|
107
|
-
"aria-posinset"?: number | undefined;
|
|
108
|
-
"aria-pressed"?: boolean | "false" | "mixed" | "true" | undefined;
|
|
109
|
-
"aria-readonly"?: (boolean | "false" | "true") | undefined;
|
|
110
|
-
"aria-relevant"?: "additions" | "additions removals" | "additions text" | "all" | "removals" | "removals additions" | "removals text" | "text" | "text additions" | "text removals" | undefined;
|
|
111
|
-
"aria-required"?: (boolean | "false" | "true") | undefined;
|
|
112
|
-
"aria-roledescription"?: string | undefined;
|
|
113
|
-
"aria-rowcount"?: number | undefined;
|
|
114
|
-
"aria-rowindex"?: number | undefined;
|
|
115
|
-
"aria-rowindextext"?: string | undefined;
|
|
116
|
-
"aria-rowspan"?: number | undefined;
|
|
117
|
-
"aria-selected"?: (boolean | "false" | "true") | undefined;
|
|
118
|
-
"aria-setsize"?: number | undefined;
|
|
119
|
-
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
120
|
-
"aria-valuemax"?: number | undefined;
|
|
121
|
-
"aria-valuemin"?: number | undefined;
|
|
122
|
-
"aria-valuenow"?: number | undefined;
|
|
123
|
-
"aria-valuetext"?: string | undefined;
|
|
124
|
-
children?: ReactNode | undefined;
|
|
125
|
-
dangerouslySetInnerHTML?: {
|
|
126
|
-
__html: string | TrustedHTML;
|
|
127
|
-
} | undefined;
|
|
128
|
-
onCopy?: React.ClipboardEventHandler<FocusableElement>;
|
|
129
|
-
onCopyCapture?: React.ClipboardEventHandler<FocusableElement>;
|
|
130
|
-
onCut?: React.ClipboardEventHandler<FocusableElement>;
|
|
131
|
-
onCutCapture?: React.ClipboardEventHandler<FocusableElement>;
|
|
132
|
-
onPaste?: React.ClipboardEventHandler<FocusableElement>;
|
|
133
|
-
onPasteCapture?: React.ClipboardEventHandler<FocusableElement>;
|
|
134
|
-
onCompositionEnd?: React.CompositionEventHandler<FocusableElement>;
|
|
135
|
-
onCompositionEndCapture?: React.CompositionEventHandler<FocusableElement>;
|
|
136
|
-
onCompositionStart?: React.CompositionEventHandler<FocusableElement>;
|
|
137
|
-
onCompositionStartCapture?: React.CompositionEventHandler<FocusableElement>;
|
|
138
|
-
onCompositionUpdate?: React.CompositionEventHandler<FocusableElement>;
|
|
139
|
-
onCompositionUpdateCapture?: React.CompositionEventHandler<FocusableElement>;
|
|
140
|
-
onFocus?: React.FocusEventHandler<FocusableElement>;
|
|
141
|
-
onFocusCapture?: React.FocusEventHandler<FocusableElement>;
|
|
142
|
-
onBlur?: React.FocusEventHandler<FocusableElement>;
|
|
143
|
-
onBlurCapture?: React.FocusEventHandler<FocusableElement>;
|
|
144
|
-
onChange?: React.FormEventHandler<FocusableElement>;
|
|
145
|
-
onChangeCapture?: React.FormEventHandler<FocusableElement>;
|
|
146
|
-
onBeforeInput?: React.FormEventHandler<FocusableElement>;
|
|
147
|
-
onBeforeInputCapture?: React.FormEventHandler<FocusableElement>;
|
|
148
|
-
onInput?: React.FormEventHandler<FocusableElement>;
|
|
149
|
-
onInputCapture?: React.FormEventHandler<FocusableElement>;
|
|
150
|
-
onReset?: React.FormEventHandler<FocusableElement>;
|
|
151
|
-
onResetCapture?: React.FormEventHandler<FocusableElement>;
|
|
152
|
-
onSubmit?: React.FormEventHandler<FocusableElement>;
|
|
153
|
-
onSubmitCapture?: React.FormEventHandler<FocusableElement>;
|
|
154
|
-
onInvalid?: React.FormEventHandler<FocusableElement>;
|
|
155
|
-
onInvalidCapture?: React.FormEventHandler<FocusableElement>;
|
|
156
|
-
onLoad?: React.ReactEventHandler<FocusableElement>;
|
|
157
|
-
onLoadCapture?: React.ReactEventHandler<FocusableElement>;
|
|
158
|
-
onError?: React.ReactEventHandler<FocusableElement>;
|
|
159
|
-
onErrorCapture?: React.ReactEventHandler<FocusableElement>;
|
|
160
|
-
onKeyDown?: React.KeyboardEventHandler<FocusableElement>;
|
|
161
|
-
onKeyDownCapture?: React.KeyboardEventHandler<FocusableElement>;
|
|
162
|
-
onKeyPress?: React.KeyboardEventHandler<FocusableElement>;
|
|
163
|
-
onKeyPressCapture?: React.KeyboardEventHandler<FocusableElement>;
|
|
164
|
-
onKeyUp?: React.KeyboardEventHandler<FocusableElement>;
|
|
165
|
-
onKeyUpCapture?: React.KeyboardEventHandler<FocusableElement>;
|
|
166
|
-
onAbort?: React.ReactEventHandler<FocusableElement>;
|
|
167
|
-
onAbortCapture?: React.ReactEventHandler<FocusableElement>;
|
|
168
|
-
onCanPlay?: React.ReactEventHandler<FocusableElement>;
|
|
169
|
-
onCanPlayCapture?: React.ReactEventHandler<FocusableElement>;
|
|
170
|
-
onCanPlayThrough?: React.ReactEventHandler<FocusableElement>;
|
|
171
|
-
onCanPlayThroughCapture?: React.ReactEventHandler<FocusableElement>;
|
|
172
|
-
onDurationChange?: React.ReactEventHandler<FocusableElement>;
|
|
173
|
-
onDurationChangeCapture?: React.ReactEventHandler<FocusableElement>;
|
|
174
|
-
onEmptied?: React.ReactEventHandler<FocusableElement>;
|
|
175
|
-
onEmptiedCapture?: React.ReactEventHandler<FocusableElement>;
|
|
176
|
-
onEncrypted?: React.ReactEventHandler<FocusableElement>;
|
|
177
|
-
onEncryptedCapture?: React.ReactEventHandler<FocusableElement>;
|
|
178
|
-
onEnded?: React.ReactEventHandler<FocusableElement>;
|
|
179
|
-
onEndedCapture?: React.ReactEventHandler<FocusableElement>;
|
|
180
|
-
onLoadedData?: React.ReactEventHandler<FocusableElement>;
|
|
181
|
-
onLoadedDataCapture?: React.ReactEventHandler<FocusableElement>;
|
|
182
|
-
onLoadedMetadata?: React.ReactEventHandler<FocusableElement>;
|
|
183
|
-
onLoadedMetadataCapture?: React.ReactEventHandler<FocusableElement>;
|
|
184
|
-
onLoadStart?: React.ReactEventHandler<FocusableElement>;
|
|
185
|
-
onLoadStartCapture?: React.ReactEventHandler<FocusableElement>;
|
|
186
|
-
onPause?: React.ReactEventHandler<FocusableElement>;
|
|
187
|
-
onPauseCapture?: React.ReactEventHandler<FocusableElement>;
|
|
188
|
-
onPlay?: React.ReactEventHandler<FocusableElement>;
|
|
189
|
-
onPlayCapture?: React.ReactEventHandler<FocusableElement>;
|
|
190
|
-
onPlaying?: React.ReactEventHandler<FocusableElement>;
|
|
191
|
-
onPlayingCapture?: React.ReactEventHandler<FocusableElement>;
|
|
192
|
-
onProgress?: React.ReactEventHandler<FocusableElement>;
|
|
193
|
-
onProgressCapture?: React.ReactEventHandler<FocusableElement>;
|
|
194
|
-
onRateChange?: React.ReactEventHandler<FocusableElement>;
|
|
195
|
-
onRateChangeCapture?: React.ReactEventHandler<FocusableElement>;
|
|
196
|
-
onResize?: React.ReactEventHandler<FocusableElement>;
|
|
197
|
-
onResizeCapture?: React.ReactEventHandler<FocusableElement>;
|
|
198
|
-
onSeeked?: React.ReactEventHandler<FocusableElement>;
|
|
199
|
-
onSeekedCapture?: React.ReactEventHandler<FocusableElement>;
|
|
200
|
-
onSeeking?: React.ReactEventHandler<FocusableElement>;
|
|
201
|
-
onSeekingCapture?: React.ReactEventHandler<FocusableElement>;
|
|
202
|
-
onStalled?: React.ReactEventHandler<FocusableElement>;
|
|
203
|
-
onStalledCapture?: React.ReactEventHandler<FocusableElement>;
|
|
204
|
-
onSuspend?: React.ReactEventHandler<FocusableElement>;
|
|
205
|
-
onSuspendCapture?: React.ReactEventHandler<FocusableElement>;
|
|
206
|
-
onTimeUpdate?: React.ReactEventHandler<FocusableElement>;
|
|
207
|
-
onTimeUpdateCapture?: React.ReactEventHandler<FocusableElement>;
|
|
208
|
-
onVolumeChange?: React.ReactEventHandler<FocusableElement>;
|
|
209
|
-
onVolumeChangeCapture?: React.ReactEventHandler<FocusableElement>;
|
|
210
|
-
onWaiting?: React.ReactEventHandler<FocusableElement>;
|
|
211
|
-
onWaitingCapture?: React.ReactEventHandler<FocusableElement>;
|
|
212
|
-
onAuxClick?: React.MouseEventHandler<FocusableElement>;
|
|
213
|
-
onAuxClickCapture?: React.MouseEventHandler<FocusableElement>;
|
|
214
|
-
onClick?: React.MouseEventHandler<FocusableElement>;
|
|
215
|
-
onClickCapture?: React.MouseEventHandler<FocusableElement>;
|
|
216
|
-
onContextMenu?: React.MouseEventHandler<FocusableElement>;
|
|
217
|
-
onContextMenuCapture?: React.MouseEventHandler<FocusableElement>;
|
|
218
|
-
onDoubleClick?: React.MouseEventHandler<FocusableElement>;
|
|
219
|
-
onDoubleClickCapture?: React.MouseEventHandler<FocusableElement>;
|
|
220
|
-
onDrag?: React.DragEventHandler<FocusableElement>;
|
|
221
|
-
onDragCapture?: React.DragEventHandler<FocusableElement>;
|
|
222
|
-
onDragEnd?: React.DragEventHandler<FocusableElement>;
|
|
223
|
-
onDragEndCapture?: React.DragEventHandler<FocusableElement>;
|
|
224
|
-
onDragEnter?: React.DragEventHandler<FocusableElement>;
|
|
225
|
-
onDragEnterCapture?: React.DragEventHandler<FocusableElement>;
|
|
226
|
-
onDragExit?: React.DragEventHandler<FocusableElement>;
|
|
227
|
-
onDragExitCapture?: React.DragEventHandler<FocusableElement>;
|
|
228
|
-
onDragLeave?: React.DragEventHandler<FocusableElement>;
|
|
229
|
-
onDragLeaveCapture?: React.DragEventHandler<FocusableElement>;
|
|
230
|
-
onDragOver?: React.DragEventHandler<FocusableElement>;
|
|
231
|
-
onDragOverCapture?: React.DragEventHandler<FocusableElement>;
|
|
232
|
-
onDragStart?: React.DragEventHandler<FocusableElement>;
|
|
233
|
-
onDragStartCapture?: React.DragEventHandler<FocusableElement>;
|
|
234
|
-
onDrop?: React.DragEventHandler<FocusableElement>;
|
|
235
|
-
onDropCapture?: React.DragEventHandler<FocusableElement>;
|
|
236
|
-
onMouseDown?: React.MouseEventHandler<FocusableElement>;
|
|
237
|
-
onMouseDownCapture?: React.MouseEventHandler<FocusableElement>;
|
|
238
|
-
onMouseEnter?: React.MouseEventHandler<FocusableElement>;
|
|
239
|
-
onMouseLeave?: React.MouseEventHandler<FocusableElement>;
|
|
240
|
-
onMouseMove?: React.MouseEventHandler<FocusableElement>;
|
|
241
|
-
onMouseMoveCapture?: React.MouseEventHandler<FocusableElement>;
|
|
242
|
-
onMouseOut?: React.MouseEventHandler<FocusableElement>;
|
|
243
|
-
onMouseOutCapture?: React.MouseEventHandler<FocusableElement>;
|
|
244
|
-
onMouseOver?: React.MouseEventHandler<FocusableElement>;
|
|
245
|
-
onMouseOverCapture?: React.MouseEventHandler<FocusableElement>;
|
|
246
|
-
onMouseUp?: React.MouseEventHandler<FocusableElement>;
|
|
247
|
-
onMouseUpCapture?: React.MouseEventHandler<FocusableElement>;
|
|
248
|
-
onSelect?: React.ReactEventHandler<FocusableElement>;
|
|
249
|
-
onSelectCapture?: React.ReactEventHandler<FocusableElement>;
|
|
250
|
-
onTouchCancel?: React.TouchEventHandler<FocusableElement>;
|
|
251
|
-
onTouchCancelCapture?: React.TouchEventHandler<FocusableElement>;
|
|
252
|
-
onTouchEnd?: React.TouchEventHandler<FocusableElement>;
|
|
253
|
-
onTouchEndCapture?: React.TouchEventHandler<FocusableElement>;
|
|
254
|
-
onTouchMove?: React.TouchEventHandler<FocusableElement>;
|
|
255
|
-
onTouchMoveCapture?: React.TouchEventHandler<FocusableElement>;
|
|
256
|
-
onTouchStart?: React.TouchEventHandler<FocusableElement>;
|
|
257
|
-
onTouchStartCapture?: React.TouchEventHandler<FocusableElement>;
|
|
258
|
-
onPointerDown?: React.PointerEventHandler<FocusableElement>;
|
|
259
|
-
onPointerDownCapture?: React.PointerEventHandler<FocusableElement>;
|
|
260
|
-
onPointerMove?: React.PointerEventHandler<FocusableElement>;
|
|
261
|
-
onPointerMoveCapture?: React.PointerEventHandler<FocusableElement>;
|
|
262
|
-
onPointerUp?: React.PointerEventHandler<FocusableElement>;
|
|
263
|
-
onPointerUpCapture?: React.PointerEventHandler<FocusableElement>;
|
|
264
|
-
onPointerCancel?: React.PointerEventHandler<FocusableElement>;
|
|
265
|
-
onPointerCancelCapture?: React.PointerEventHandler<FocusableElement>;
|
|
266
|
-
onPointerEnter?: React.PointerEventHandler<FocusableElement>;
|
|
267
|
-
onPointerLeave?: React.PointerEventHandler<FocusableElement>;
|
|
268
|
-
onPointerOver?: React.PointerEventHandler<FocusableElement>;
|
|
269
|
-
onPointerOverCapture?: React.PointerEventHandler<FocusableElement>;
|
|
270
|
-
onPointerOut?: React.PointerEventHandler<FocusableElement>;
|
|
271
|
-
onPointerOutCapture?: React.PointerEventHandler<FocusableElement>;
|
|
272
|
-
onGotPointerCapture?: React.PointerEventHandler<FocusableElement>;
|
|
273
|
-
onGotPointerCaptureCapture?: React.PointerEventHandler<FocusableElement>;
|
|
274
|
-
onLostPointerCapture?: React.PointerEventHandler<FocusableElement>;
|
|
275
|
-
onLostPointerCaptureCapture?: React.PointerEventHandler<FocusableElement>;
|
|
276
|
-
onScroll?: React.UIEventHandler<FocusableElement>;
|
|
277
|
-
onScrollCapture?: React.UIEventHandler<FocusableElement>;
|
|
278
|
-
onWheel?: React.WheelEventHandler<FocusableElement>;
|
|
279
|
-
onWheelCapture?: React.WheelEventHandler<FocusableElement>;
|
|
280
|
-
onAnimationStart?: React.AnimationEventHandler<FocusableElement>;
|
|
281
|
-
onAnimationStartCapture?: React.AnimationEventHandler<FocusableElement>;
|
|
282
|
-
onAnimationEnd?: React.AnimationEventHandler<FocusableElement>;
|
|
283
|
-
onAnimationEndCapture?: React.AnimationEventHandler<FocusableElement>;
|
|
284
|
-
onAnimationIteration?: React.AnimationEventHandler<FocusableElement>;
|
|
285
|
-
onAnimationIterationCapture?: React.AnimationEventHandler<FocusableElement>;
|
|
286
|
-
onToggle?: React.ToggleEventHandler<FocusableElement>;
|
|
287
|
-
onBeforeToggle?: React.ToggleEventHandler<FocusableElement>;
|
|
288
|
-
onTransitionCancel?: React.TransitionEventHandler<FocusableElement>;
|
|
289
|
-
onTransitionCancelCapture?: React.TransitionEventHandler<FocusableElement>;
|
|
290
|
-
onTransitionEnd?: React.TransitionEventHandler<FocusableElement>;
|
|
291
|
-
onTransitionEndCapture?: React.TransitionEventHandler<FocusableElement>;
|
|
292
|
-
onTransitionRun?: React.TransitionEventHandler<FocusableElement>;
|
|
293
|
-
onTransitionRunCapture?: React.TransitionEventHandler<FocusableElement>;
|
|
294
|
-
onTransitionStart?: React.TransitionEventHandler<FocusableElement>;
|
|
295
|
-
onTransitionStartCapture?: React.TransitionEventHandler<FocusableElement>;
|
|
296
|
-
};
|
|
297
|
-
inputProps: {
|
|
298
|
-
type: string;
|
|
299
|
-
tabIndex: number;
|
|
300
|
-
style: {
|
|
301
|
-
fontSize: number;
|
|
302
|
-
};
|
|
303
|
-
onFocus: () => void;
|
|
304
|
-
disabled: boolean;
|
|
305
|
-
};
|
|
306
|
-
selectProps: {
|
|
307
|
-
tabIndex: number;
|
|
308
|
-
autoComplete: string;
|
|
309
|
-
disabled: boolean;
|
|
310
|
-
required: boolean;
|
|
311
|
-
name: string;
|
|
312
|
-
value: Key;
|
|
313
|
-
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
314
|
-
};
|
|
315
|
-
};
|
|
70
|
+
export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria;
|
|
316
71
|
/**
|
|
317
72
|
* Renders a hidden native `<select>` element, which can be used to support browser
|
|
318
73
|
* form autofill, mobile form navigation, and native form submission.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;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AAK,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"}
|
|
@@ -1 +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,IAAI,CAAA,GAAA,8CAAmB,EAAE,MAAM,UAAU,EAAE,MAAM,YAAY,EAAE,MAAM,WAAW;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;KAAS;IAEnM,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,mCAAa,EAC/C;oBACE;QACA,MAAM;IACR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7B,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, ValidationResult} from '@react-types/shared';\nimport {FocusEvent, RefObject, 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"}
|
|
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,IAAI,CAAA,GAAA,8CAAmB,EAAE,MAAM,UAAU,EAAE,MAAM,YAAY,EAAE,MAAM,WAAW;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;KAAS;IAEnM,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,mCAAa,EAC/C;oBACE;QACA,MAAM;IACR,GACA,OACA;IAGF,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;gBAAa;oBAChB,+BAA+B;oBAC/B,EAAE,cAAc;oBAEhB,IAAI,MAAM,MAAM,WAAW,IAAI,OAAO,SAAS,WAAW,CAAC,MAAM,WAAW,IAAI,SAAS,WAAW;oBACpG,IAAI,KACF,MAAM,cAAc,CAAC;oBAEvB;gBACF;YACA,KAAK;gBAAc;oBACjB,+BAA+B;oBAC/B,EAAE,cAAc;oBAEhB,IAAI,MAAM,MAAM,WAAW,IAAI,OAAO,SAAS,WAAW,CAAC,MAAM,WAAW,IAAI,SAAS,WAAW;oBACpG,IAAI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Aa,EAAE,GAAG;aACpF,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;YACvB,SAAQ,CAAa;gBACnB,IAAI,MAAM,SAAS,EACjB;gBAGF,IAAI,MAAM,OAAO,EACf,MAAM,OAAO,CAAC;gBAGhB,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;YACA,QAAO,CAAa;gBAClB,IAAI,MAAM,MAAM,EACd;gBAGF,IAAI,MAAM,MAAM,EACd,MAAM,MAAM,CAAC;gBAGf,IAAI,MAAM,aAAa,EACrB,MAAM,aAAa,CAAC;gBAGtB,MAAM,UAAU,CAAC;YACnB;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,WAAW;YACT,GAAG,SAAS;YACZ,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,oBAAoB;YACpB,wBAAwB;YACxB,cAAc;YACd,QAAQ,CAAC;gBACP,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"}
|
|
@@ -1 +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,qBA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AC;YACnB;QACF;QACA,YAAY;YACV,IAAI;QACN;QACA,WAAW;YACT,GAAG,SAAS;YACZ,WAAW,MAAM,aAAa,IAAI;YAClC,uBAAuB;YACvB,oBAAoB;YACpB,wBAAwB;YACxB,cAAc;YACd,QAAQ,CAAC;gBACP,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, ValidationResult} from '@react-types/shared';\nimport {FocusEvent, RefObject, 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"}
|
|
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,UAAU,EAAE,MAAM,YAAY,EAAE,MAAM,WAAW;QAAC;QAAkB,MAAM,UAAU;QAAE,MAAM,YAAY;QAAE;KAAS;IAEnM,IAAI,oBAAC,gBAAgB,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qBAAa,EAC/C;oBACE;QACA,MAAM;IACR,GACA,OACA;IAG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Aa,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/select",
|
|
3
|
-
"version": "3.14.6-nightly.
|
|
3
|
+
"version": "3.14.6-nightly.4704+546ffa41f",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/form": "3.0.6-nightly.
|
|
26
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
27
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
28
|
-
"@react-aria/label": "3.0.0-nightly.
|
|
29
|
-
"@react-aria/listbox": "3.12.2-nightly.
|
|
30
|
-
"@react-aria/menu": "3.14.2-nightly.
|
|
31
|
-
"@react-aria/selection": "3.0.0-nightly.
|
|
32
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
33
|
-
"@react-aria/visually-hidden": "3.0.0-nightly.
|
|
34
|
-
"@react-stately/select": "3.6.5-nightly.
|
|
35
|
-
"@react-types/button": "3.9.5-nightly.
|
|
36
|
-
"@react-types/select": "3.9.5-nightly.
|
|
37
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
25
|
+
"@react-aria/form": "3.0.6-nightly.4704+546ffa41f",
|
|
26
|
+
"@react-aria/i18n": "3.0.0-nightly.2992+546ffa41f",
|
|
27
|
+
"@react-aria/interactions": "3.0.0-nightly.2992+546ffa41f",
|
|
28
|
+
"@react-aria/label": "3.0.0-nightly.2992+546ffa41f",
|
|
29
|
+
"@react-aria/listbox": "3.12.2-nightly.4704+546ffa41f",
|
|
30
|
+
"@react-aria/menu": "3.14.2-nightly.4704+546ffa41f",
|
|
31
|
+
"@react-aria/selection": "3.0.0-nightly.2992+546ffa41f",
|
|
32
|
+
"@react-aria/utils": "3.0.0-nightly.2992+546ffa41f",
|
|
33
|
+
"@react-aria/visually-hidden": "3.0.0-nightly.2992+546ffa41f",
|
|
34
|
+
"@react-stately/select": "3.6.5-nightly.4704+546ffa41f",
|
|
35
|
+
"@react-types/button": "3.9.5-nightly.4704+546ffa41f",
|
|
36
|
+
"@react-types/select": "3.9.5-nightly.4704+546ffa41f",
|
|
37
|
+
"@react-types/shared": "3.0.0-nightly.2992+546ffa41f",
|
|
38
38
|
"@swc/helpers": "^0.5.0"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "546ffa41f7d1d3a566950a14d8f46cf726891220"
|
|
48
48
|
}
|
package/src/HiddenSelect.tsx
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {FocusableElement} from '@react-types/shared';
|
|
14
|
-
import React, {ReactNode,
|
|
13
|
+
import {FocusableElement, RefObject} from '@react-types/shared';
|
|
14
|
+
import React, {ReactNode, useRef} from 'react';
|
|
15
15
|
import {selectData} from './useSelect';
|
|
16
16
|
import {SelectState} from '@react-stately/select';
|
|
17
17
|
import {useFormReset} from '@react-aria/utils';
|
|
@@ -48,12 +48,23 @@ export interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {
|
|
|
48
48
|
selectRef?: RefObject<HTMLSelectElement | null>
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
export interface HiddenSelectAria {
|
|
52
|
+
/** Props for the container element. */
|
|
53
|
+
containerProps: React.HTMLAttributes<FocusableElement>,
|
|
54
|
+
|
|
55
|
+
/** Props for the hidden input element. */
|
|
56
|
+
inputProps: React.InputHTMLAttributes<HTMLInputElement>,
|
|
57
|
+
|
|
58
|
+
/** Props for the hidden select element. */
|
|
59
|
+
selectProps: React.SelectHTMLAttributes<HTMLSelectElement>
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
/**
|
|
52
63
|
* Provides the behavior and accessibility implementation for a hidden `<select>` element, which
|
|
53
64
|
* can be used in combination with `useSelect` to support browser form autofill, mobile form
|
|
54
65
|
* navigation, and native HTML form submission.
|
|
55
66
|
*/
|
|
56
|
-
export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>) {
|
|
67
|
+
export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: SelectState<T>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria {
|
|
57
68
|
let data = selectData.get(state) || {};
|
|
58
69
|
let {autoComplete, name = data.name, isDisabled = data.isDisabled} = props;
|
|
59
70
|
let {validationBehavior, isRequired} = data;
|
|
@@ -88,7 +99,9 @@ export function useHiddenSelect<T>(props: AriaHiddenSelectOptions, state: Select
|
|
|
88
99
|
containerProps: {
|
|
89
100
|
...visuallyHiddenProps,
|
|
90
101
|
'aria-hidden': true,
|
|
102
|
+
// @ts-ignore
|
|
91
103
|
['data-react-aria-prevent-focus']: true,
|
|
104
|
+
// @ts-ignore
|
|
92
105
|
['data-a11y-ignore']: 'aria-hidden-focus'
|
|
93
106
|
},
|
|
94
107
|
inputProps: {
|
package/src/useSelect.ts
CHANGED
|
@@ -14,8 +14,8 @@ import {AriaButtonProps} from '@react-types/button';
|
|
|
14
14
|
import {AriaListBoxOptions} from '@react-aria/listbox';
|
|
15
15
|
import {AriaSelectProps} from '@react-types/select';
|
|
16
16
|
import {chain, filterDOMProps, mergeProps, useId} from '@react-aria/utils';
|
|
17
|
-
import {DOMAttributes, FocusableElement, KeyboardDelegate, ValidationResult} from '@react-types/shared';
|
|
18
|
-
import {FocusEvent,
|
|
17
|
+
import {DOMAttributes, FocusableElement, KeyboardDelegate, RefObject, ValidationResult} from '@react-types/shared';
|
|
18
|
+
import {FocusEvent, useMemo} from 'react';
|
|
19
19
|
import {ListKeyboardDelegate, useTypeSelect} from '@react-aria/selection';
|
|
20
20
|
import {SelectState} from '@react-stately/select';
|
|
21
21
|
import {setInteractionModality} from '@react-aria/interactions';
|