@react-aria/select 3.6.1-nightly.3100 → 3.6.2
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 +37 -36
- package/dist/main.js.map +1 -1
- package/dist/module.js +36 -35
- package/dist/module.js.map +1 -1
- package/package.json +14 -14
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
7
|
-
var $
|
|
8
|
-
var $
|
|
1
|
+
var $3wXCD$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $3wXCD$react = require("react");
|
|
3
|
+
var $3wXCD$reactariaselection = require("@react-aria/selection");
|
|
4
|
+
var $3wXCD$reactariainteractions = require("@react-aria/interactions");
|
|
5
|
+
var $3wXCD$reactariai18n = require("@react-aria/i18n");
|
|
6
|
+
var $3wXCD$reactarialabel = require("@react-aria/label");
|
|
7
|
+
var $3wXCD$reactariamenu = require("@react-aria/menu");
|
|
8
|
+
var $3wXCD$reactariavisuallyhidden = require("@react-aria/visually-hidden");
|
|
9
9
|
|
|
10
10
|
function $parcel$exportWildcard(dest, source) {
|
|
11
11
|
Object.keys(source).forEach(function(key) {
|
|
@@ -29,9 +29,9 @@ function $parcel$export(e, n, v, s) {
|
|
|
29
29
|
function $parcel$interopDefault(a) {
|
|
30
30
|
return a && a.__esModule ? a.default : a;
|
|
31
31
|
}
|
|
32
|
-
var $
|
|
32
|
+
var $40757cfef767e356$exports = {};
|
|
33
33
|
|
|
34
|
-
$parcel$export($
|
|
34
|
+
$parcel$export($40757cfef767e356$exports, "useSelect", () => $40757cfef767e356$export$e64b2f635402ca43);
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -39,22 +39,22 @@ $parcel$export($4298c6daa5cb9767$exports, "useSelect", () => $4298c6daa5cb9767$e
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
function $
|
|
42
|
+
function $40757cfef767e356$export$e64b2f635402ca43(props, state, ref) {
|
|
43
43
|
let { keyboardDelegate: keyboardDelegate , isDisabled: isDisabled } = props;
|
|
44
44
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
45
45
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
46
|
-
let collator = $
|
|
46
|
+
let collator = $3wXCD$reactariai18n.useCollator({
|
|
47
47
|
usage: 'search',
|
|
48
48
|
sensitivity: 'base'
|
|
49
49
|
});
|
|
50
|
-
let delegate = $
|
|
50
|
+
let delegate = $3wXCD$react.useMemo(()=>keyboardDelegate || new $3wXCD$reactariaselection.ListKeyboardDelegate(state.collection, state.disabledKeys, null, collator)
|
|
51
51
|
, [
|
|
52
52
|
keyboardDelegate,
|
|
53
53
|
state.collection,
|
|
54
54
|
state.disabledKeys,
|
|
55
55
|
collator
|
|
56
56
|
]);
|
|
57
|
-
let { menuTriggerProps: menuTriggerProps , menuProps: menuProps } = $
|
|
57
|
+
let { menuTriggerProps: menuTriggerProps , menuProps: menuProps } = $3wXCD$reactariamenu.useMenuTrigger({
|
|
58
58
|
isDisabled: isDisabled,
|
|
59
59
|
type: 'listbox'
|
|
60
60
|
}, state, ref);
|
|
@@ -78,24 +78,24 @@ function $4298c6daa5cb9767$export$e64b2f635402ca43(props, state, ref) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
let { typeSelectProps: typeSelectProps } = $
|
|
81
|
+
let { typeSelectProps: typeSelectProps } = $3wXCD$reactariaselection.useTypeSelect({
|
|
82
82
|
keyboardDelegate: delegate,
|
|
83
83
|
selectionManager: state.selectionManager,
|
|
84
84
|
onTypeSelect (key) {
|
|
85
85
|
state.setSelectedKey(key);
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $
|
|
88
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $3wXCD$reactarialabel.useField({
|
|
89
89
|
...props,
|
|
90
90
|
labelElementType: 'span'
|
|
91
91
|
});
|
|
92
92
|
typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
|
|
93
93
|
delete typeSelectProps.onKeyDownCapture;
|
|
94
|
-
let domProps = $
|
|
94
|
+
let domProps = $3wXCD$reactariautils.filterDOMProps(props, {
|
|
95
95
|
labelable: true
|
|
96
96
|
});
|
|
97
|
-
let triggerProps = $
|
|
98
|
-
let valueId = $
|
|
97
|
+
let triggerProps = $3wXCD$reactariautils.mergeProps(typeSelectProps, menuTriggerProps, fieldProps);
|
|
98
|
+
let valueId = $3wXCD$reactariautils.useId();
|
|
99
99
|
return {
|
|
100
100
|
labelProps: {
|
|
101
101
|
...labelProps,
|
|
@@ -103,13 +103,13 @@ function $4298c6daa5cb9767$export$e64b2f635402ca43(props, state, ref) {
|
|
|
103
103
|
if (!props.isDisabled) {
|
|
104
104
|
ref.current.focus();
|
|
105
105
|
// Show the focus ring so the user knows where focus went
|
|
106
|
-
$
|
|
106
|
+
$3wXCD$reactariainteractions.setInteractionModality('keyboard');
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
},
|
|
110
|
-
triggerProps: $
|
|
110
|
+
triggerProps: $3wXCD$reactariautils.mergeProps(domProps, {
|
|
111
111
|
...triggerProps,
|
|
112
|
-
onKeyDown: $
|
|
112
|
+
onKeyDown: $3wXCD$reactariautils.chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
|
|
113
113
|
onKeyUp: props.onKeyUp,
|
|
114
114
|
'aria-labelledby': [
|
|
115
115
|
triggerProps['aria-labelledby'],
|
|
@@ -152,17 +152,18 @@ function $4298c6daa5cb9767$export$e64b2f635402ca43(props, state, ref) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
var $
|
|
155
|
+
var $237cbb6003c1c52b$exports = {};
|
|
156
156
|
|
|
157
|
-
$parcel$export($
|
|
158
|
-
$parcel$export($
|
|
157
|
+
$parcel$export($237cbb6003c1c52b$exports, "useHiddenSelect", () => $237cbb6003c1c52b$export$f809e80f58e251d1);
|
|
158
|
+
$parcel$export($237cbb6003c1c52b$exports, "HiddenSelect", () => $237cbb6003c1c52b$export$cbd84cdb2e668835);
|
|
159
159
|
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
function $
|
|
162
|
+
function $237cbb6003c1c52b$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
163
163
|
let { autoComplete: autoComplete , name: name , isDisabled: isDisabled } = props;
|
|
164
|
-
let modality = $
|
|
165
|
-
let { visuallyHiddenProps: visuallyHiddenProps } = $
|
|
164
|
+
let modality = $3wXCD$reactariainteractions.useInteractionModality();
|
|
165
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = $3wXCD$reactariavisuallyhidden.useVisuallyHidden();
|
|
166
|
+
var _selectedKey;
|
|
166
167
|
// In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.
|
|
167
168
|
// In Firefox, there must be a <label> to identify the <select> whereas other browsers
|
|
168
169
|
// seem to identify it just by surrounding text.
|
|
@@ -202,27 +203,27 @@ function $e5f0755e372eaf29$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
|
202
203
|
disabled: isDisabled,
|
|
203
204
|
name: name,
|
|
204
205
|
size: state.collection.size,
|
|
205
|
-
value: state.selectedKey
|
|
206
|
+
value: (_selectedKey = state.selectedKey) !== null && _selectedKey !== void 0 ? _selectedKey : '',
|
|
206
207
|
onChange: (e)=>state.setSelectedKey(e.target.value)
|
|
207
208
|
}
|
|
208
209
|
};
|
|
209
210
|
}
|
|
210
|
-
function $
|
|
211
|
+
function $237cbb6003c1c52b$export$cbd84cdb2e668835(props) {
|
|
211
212
|
let { state: state , triggerRef: triggerRef , label: label , name: name , isDisabled: isDisabled } = props;
|
|
212
|
-
let { containerProps: containerProps , inputProps: inputProps , selectProps: selectProps } = $
|
|
213
|
+
let { containerProps: containerProps , inputProps: inputProps , selectProps: selectProps } = $237cbb6003c1c52b$export$f809e80f58e251d1(props, state, triggerRef);
|
|
213
214
|
// If used in a <form>, use a hidden input so the value can be submitted to a server.
|
|
214
215
|
// If the collection isn't too big, use a hidden <select> element for this so that browser
|
|
215
216
|
// autofill will work. Otherwise, use an <input type="hidden">.
|
|
216
|
-
if (state.collection.size <= 300) return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
217
|
+
if (state.collection.size <= 300) return(/*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("div", containerProps, /*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("input", inputProps), /*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("label", null, label, /*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("select", selectProps, /*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("option", null), [
|
|
217
218
|
...state.collection.getKeys()
|
|
218
219
|
].map((key)=>{
|
|
219
220
|
let item = state.collection.getItem(key);
|
|
220
|
-
if (item.type === 'item') return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
221
|
+
if (item.type === 'item') return(/*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("option", {
|
|
221
222
|
key: item.key,
|
|
222
223
|
value: item.key
|
|
223
224
|
}, item.textValue));
|
|
224
225
|
})))));
|
|
225
|
-
else if (name) return(/*#__PURE__*/ ($parcel$interopDefault($
|
|
226
|
+
else if (name) return(/*#__PURE__*/ ($parcel$interopDefault($3wXCD$react)).createElement("input", {
|
|
226
227
|
type: "hidden",
|
|
227
228
|
autoComplete: selectProps.autoComplete,
|
|
228
229
|
name: name,
|
|
@@ -233,8 +234,8 @@ function $e5f0755e372eaf29$export$cbd84cdb2e668835(props) {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
|
|
236
|
-
$parcel$exportWildcard(module.exports, $
|
|
237
|
-
$parcel$exportWildcard(module.exports, $
|
|
237
|
+
$parcel$exportWildcard(module.exports, $40757cfef767e356$exports);
|
|
238
|
+
$parcel$exportWildcard(module.exports, $237cbb6003c1c52b$exports);
|
|
238
239
|
|
|
239
240
|
|
|
240
241
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SC2DgB,yCAAS,CAAI,KAA2B,EAAE,KAAqB,EAAE,GAA2B,EAAc,CAAC;IACzH,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,EACZ,CAAC,GAAG,KAAK;IAET,EAA0H,AAA1H,wHAA0H;IAC1H,EAAqF,AAArF,mFAAqF;IACrF,GAAG,CAAC,QAAQ,GAAG,gCAAW,CAAC,CAAC;QAAA,KAAK,EAAE,CAAQ;QAAE,WAAW,EAAE,CAAM;IAAA,CAAC;IACjE,GAAG,CAAC,QAAQ,GAAG,oBAAO,KAAO,gBAAgB,IAAI,GAAG,CAAC,8CAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,QAAQ;MAAG,CAAC;QAAA,gBAAgB;QAAE,KAAK,CAAC,UAAU;QAAE,KAAK,CAAC,YAAY;QAAE,QAAQ;IAAA,CAAC;IAEnM,GAAG,CAAC,CAAC,mBAAA,gBAAgB,cAAE,SAAS,EAAA,CAAC,GAAG,mCAAc,CAChD,CAAC;oBACC,UAAU;QACV,IAAI,EAAE,CAAS;IACjB,CAAC,EACD,KAAK,EACL,GAAG;IAGL,GAAG,CAAC,SAAS,IAAI,CAAgB,GAAK,CAAC;QACrC,MAAM,CAAE,CAAC,CAAC,GAAG;YACX,IAAI,CAAC,CAAW;gBAAE,CAAC;oBACjB,EAA+B,AAA/B,6BAA+B;oBAC/B,CAAC,CAAC,cAAc;oBAEhB,GAAG,CAAC,GAAG,GAA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AAU,CAAC,IAAI,IAAI,GAAG,EAC9B,MAAM,oEACH,CAAG,MAAK,cAAc,qEACpB,CAAK,QAAK,UAAU,sEACpB,CAAK,cACH,KAAK,qEACL,CAAM,SAAK,WAAW,qEACpB,CAAM,gBACN,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC,CAAC,GAAG,EAAC,GAAG,GAAI,CAAC;QAC3C,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QACvC,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAM,OACtB,MAAM,oEACH,CAAM;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,GAAG;WACd,IAAI,CAAC,SAAS;IAIvB,CAAC;SAKJ,EAAE,EAAE,IAAI,EACb,MAAM,oEACH,CAAK;QACJ,IAAI,EAAC,CAAQ;QACb,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,KAAK,CAAC,WAAW;;IAI9B,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-aria/select/src/index.ts","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\nexport * from './useSelect';\nexport * from './HiddenSelect';\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":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SC2DgB,yCAAS,CAAI,KAA2B,EAAE,KAAqB,EAAE,GAA2B,EAAc,CAAC;IACzH,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,EACZ,CAAC,GAAG,KAAK;IAET,EAA0H,AAA1H,wHAA0H;IAC1H,EAAqF,AAArF,mFAAqF;IACrF,GAAG,CAAC,QAAQ,GAAG,gCAAW,CAAC,CAAC;QAAA,KAAK,EAAE,CAAQ;QAAE,WAAW,EAAE,CAAM;IAAA,CAAC;IACjE,GAAG,CAAC,QAAQ,GAAG,oBAAO,KAAO,gBAAgB,IAAI,GAAG,CAAC,8CAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC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KAAK,CAAC,WAAW;;IAI9B,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-aria/select/src/index.ts","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\nexport * from './useSelect';\nexport * from './HiddenSelect';\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":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {filterDOMProps as $
|
|
2
|
-
import $
|
|
3
|
-
import {ListKeyboardDelegate as $
|
|
4
|
-
import {setInteractionModality as $
|
|
5
|
-
import {useCollator as $
|
|
6
|
-
import {useField as $
|
|
7
|
-
import {useMenuTrigger as $
|
|
8
|
-
import {useVisuallyHidden as $
|
|
1
|
+
import {filterDOMProps as $9GmRZ$filterDOMProps, mergeProps as $9GmRZ$mergeProps, useId as $9GmRZ$useId, chain as $9GmRZ$chain} from "@react-aria/utils";
|
|
2
|
+
import $9GmRZ$react, {useMemo as $9GmRZ$useMemo} from "react";
|
|
3
|
+
import {ListKeyboardDelegate as $9GmRZ$ListKeyboardDelegate, useTypeSelect as $9GmRZ$useTypeSelect} from "@react-aria/selection";
|
|
4
|
+
import {setInteractionModality as $9GmRZ$setInteractionModality, useInteractionModality as $9GmRZ$useInteractionModality} from "@react-aria/interactions";
|
|
5
|
+
import {useCollator as $9GmRZ$useCollator} from "@react-aria/i18n";
|
|
6
|
+
import {useField as $9GmRZ$useField} from "@react-aria/label";
|
|
7
|
+
import {useMenuTrigger as $9GmRZ$useMenuTrigger} from "@react-aria/menu";
|
|
8
|
+
import {useVisuallyHidden as $9GmRZ$useVisuallyHidden} from "@react-aria/visually-hidden";
|
|
9
9
|
|
|
10
10
|
function $parcel$export(e, n, v, s) {
|
|
11
11
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
12
|
}
|
|
13
|
-
var $
|
|
13
|
+
var $36b2c435d5f32f05$exports = {};
|
|
14
14
|
|
|
15
|
-
$parcel$export($
|
|
15
|
+
$parcel$export($36b2c435d5f32f05$exports, "useSelect", () => $36b2c435d5f32f05$export$e64b2f635402ca43);
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
@@ -20,22 +20,22 @@ $parcel$export($de64f201c7565162$exports, "useSelect", () => $de64f201c7565162$e
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
function $
|
|
23
|
+
function $36b2c435d5f32f05$export$e64b2f635402ca43(props, state, ref) {
|
|
24
24
|
let { keyboardDelegate: keyboardDelegate , isDisabled: isDisabled } = props;
|
|
25
25
|
// By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
|
|
26
26
|
// When virtualized, the layout object will be passed in as a prop and override this.
|
|
27
|
-
let collator = $
|
|
27
|
+
let collator = $9GmRZ$useCollator({
|
|
28
28
|
usage: 'search',
|
|
29
29
|
sensitivity: 'base'
|
|
30
30
|
});
|
|
31
|
-
let delegate = $
|
|
31
|
+
let delegate = $9GmRZ$useMemo(()=>keyboardDelegate || new $9GmRZ$ListKeyboardDelegate(state.collection, state.disabledKeys, null, collator)
|
|
32
32
|
, [
|
|
33
33
|
keyboardDelegate,
|
|
34
34
|
state.collection,
|
|
35
35
|
state.disabledKeys,
|
|
36
36
|
collator
|
|
37
37
|
]);
|
|
38
|
-
let { menuTriggerProps: menuTriggerProps , menuProps: menuProps } = $
|
|
38
|
+
let { menuTriggerProps: menuTriggerProps , menuProps: menuProps } = $9GmRZ$useMenuTrigger({
|
|
39
39
|
isDisabled: isDisabled,
|
|
40
40
|
type: 'listbox'
|
|
41
41
|
}, state, ref);
|
|
@@ -59,24 +59,24 @@ function $de64f201c7565162$export$e64b2f635402ca43(props, state, ref) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
let { typeSelectProps: typeSelectProps } = $
|
|
62
|
+
let { typeSelectProps: typeSelectProps } = $9GmRZ$useTypeSelect({
|
|
63
63
|
keyboardDelegate: delegate,
|
|
64
64
|
selectionManager: state.selectionManager,
|
|
65
65
|
onTypeSelect (key) {
|
|
66
66
|
state.setSelectedKey(key);
|
|
67
67
|
}
|
|
68
68
|
});
|
|
69
|
-
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $
|
|
69
|
+
let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $9GmRZ$useField({
|
|
70
70
|
...props,
|
|
71
71
|
labelElementType: 'span'
|
|
72
72
|
});
|
|
73
73
|
typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
|
|
74
74
|
delete typeSelectProps.onKeyDownCapture;
|
|
75
|
-
let domProps = $
|
|
75
|
+
let domProps = $9GmRZ$filterDOMProps(props, {
|
|
76
76
|
labelable: true
|
|
77
77
|
});
|
|
78
|
-
let triggerProps = $
|
|
79
|
-
let valueId = $
|
|
78
|
+
let triggerProps = $9GmRZ$mergeProps(typeSelectProps, menuTriggerProps, fieldProps);
|
|
79
|
+
let valueId = $9GmRZ$useId();
|
|
80
80
|
return {
|
|
81
81
|
labelProps: {
|
|
82
82
|
...labelProps,
|
|
@@ -84,13 +84,13 @@ function $de64f201c7565162$export$e64b2f635402ca43(props, state, ref) {
|
|
|
84
84
|
if (!props.isDisabled) {
|
|
85
85
|
ref.current.focus();
|
|
86
86
|
// Show the focus ring so the user knows where focus went
|
|
87
|
-
$
|
|
87
|
+
$9GmRZ$setInteractionModality('keyboard');
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
},
|
|
91
|
-
triggerProps: $
|
|
91
|
+
triggerProps: $9GmRZ$mergeProps(domProps, {
|
|
92
92
|
...triggerProps,
|
|
93
|
-
onKeyDown: $
|
|
93
|
+
onKeyDown: $9GmRZ$chain(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
|
|
94
94
|
onKeyUp: props.onKeyUp,
|
|
95
95
|
'aria-labelledby': [
|
|
96
96
|
triggerProps['aria-labelledby'],
|
|
@@ -133,17 +133,18 @@ function $de64f201c7565162$export$e64b2f635402ca43(props, state, ref) {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
|
|
136
|
-
var $
|
|
136
|
+
var $b6311686a239550d$exports = {};
|
|
137
137
|
|
|
138
|
-
$parcel$export($
|
|
139
|
-
$parcel$export($
|
|
138
|
+
$parcel$export($b6311686a239550d$exports, "useHiddenSelect", () => $b6311686a239550d$export$f809e80f58e251d1);
|
|
139
|
+
$parcel$export($b6311686a239550d$exports, "HiddenSelect", () => $b6311686a239550d$export$cbd84cdb2e668835);
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
|
|
143
|
-
function $
|
|
143
|
+
function $b6311686a239550d$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
144
144
|
let { autoComplete: autoComplete , name: name , isDisabled: isDisabled } = props;
|
|
145
|
-
let modality = $
|
|
146
|
-
let { visuallyHiddenProps: visuallyHiddenProps } = $
|
|
145
|
+
let modality = $9GmRZ$useInteractionModality();
|
|
146
|
+
let { visuallyHiddenProps: visuallyHiddenProps } = $9GmRZ$useVisuallyHidden();
|
|
147
|
+
var _selectedKey;
|
|
147
148
|
// In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.
|
|
148
149
|
// In Firefox, there must be a <label> to identify the <select> whereas other browsers
|
|
149
150
|
// seem to identify it just by surrounding text.
|
|
@@ -183,27 +184,27 @@ function $6154129a2f2e20c7$export$f809e80f58e251d1(props, state, triggerRef) {
|
|
|
183
184
|
disabled: isDisabled,
|
|
184
185
|
name: name,
|
|
185
186
|
size: state.collection.size,
|
|
186
|
-
value: state.selectedKey
|
|
187
|
+
value: (_selectedKey = state.selectedKey) !== null && _selectedKey !== void 0 ? _selectedKey : '',
|
|
187
188
|
onChange: (e)=>state.setSelectedKey(e.target.value)
|
|
188
189
|
}
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
|
-
function $
|
|
192
|
+
function $b6311686a239550d$export$cbd84cdb2e668835(props) {
|
|
192
193
|
let { state: state , triggerRef: triggerRef , label: label , name: name , isDisabled: isDisabled } = props;
|
|
193
|
-
let { containerProps: containerProps , inputProps: inputProps , selectProps: selectProps } = $
|
|
194
|
+
let { containerProps: containerProps , inputProps: inputProps , selectProps: selectProps } = $b6311686a239550d$export$f809e80f58e251d1(props, state, triggerRef);
|
|
194
195
|
// If used in a <form>, use a hidden input so the value can be submitted to a server.
|
|
195
196
|
// If the collection isn't too big, use a hidden <select> element for this so that browser
|
|
196
197
|
// autofill will work. Otherwise, use an <input type="hidden">.
|
|
197
|
-
if (state.collection.size <= 300) return(/*#__PURE__*/ $
|
|
198
|
+
if (state.collection.size <= 300) return(/*#__PURE__*/ $9GmRZ$react.createElement("div", containerProps, /*#__PURE__*/ $9GmRZ$react.createElement("input", inputProps), /*#__PURE__*/ $9GmRZ$react.createElement("label", null, label, /*#__PURE__*/ $9GmRZ$react.createElement("select", selectProps, /*#__PURE__*/ $9GmRZ$react.createElement("option", null), [
|
|
198
199
|
...state.collection.getKeys()
|
|
199
200
|
].map((key)=>{
|
|
200
201
|
let item = state.collection.getItem(key);
|
|
201
|
-
if (item.type === 'item') return(/*#__PURE__*/ $
|
|
202
|
+
if (item.type === 'item') return(/*#__PURE__*/ $9GmRZ$react.createElement("option", {
|
|
202
203
|
key: item.key,
|
|
203
204
|
value: item.key
|
|
204
205
|
}, item.textValue));
|
|
205
206
|
})))));
|
|
206
|
-
else if (name) return(/*#__PURE__*/ $
|
|
207
|
+
else if (name) return(/*#__PURE__*/ $9GmRZ$react.createElement("input", {
|
|
207
208
|
type: "hidden",
|
|
208
209
|
autoComplete: selectProps.autoComplete,
|
|
209
210
|
name: name,
|
|
@@ -216,5 +217,5 @@ function $6154129a2f2e20c7$export$cbd84cdb2e668835(props) {
|
|
|
216
217
|
|
|
217
218
|
|
|
218
219
|
|
|
219
|
-
export {$
|
|
220
|
+
export {$36b2c435d5f32f05$export$e64b2f635402ca43 as useSelect, $b6311686a239550d$export$f809e80f58e251d1 as useHiddenSelect, $b6311686a239550d$export$cbd84cdb2e668835 as HiddenSelect};
|
|
220
221
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;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AK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QACvC,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAM,OACtB,MAAM,0CACH,CAAM;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,GAAG;WACd,IAAI,CAAC,SAAS;IAIvB,CAAC;SAKJ,EAAE,EAAE,IAAI,EACb,MAAM,0CACH,CAAK;QACJ,IAAI,EAAC,CAAQ;QACb,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,KAAK,CAAC,WAAW;;IAI9B,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-aria/select/src/index.ts","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\nexport * from './useSelect';\nexport * from './HiddenSelect';\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":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;SC2DgB,yCAAS,CAAI,KAA2B,EAAE,KAAqB,EAAE,GAA2B,EAAc,CAAC;IACzH,GAAG,CAAC,CAAC,mBACH,gBAAgB,eAChB,UAAU,EACZ,CAAC,GAAG,KAAK;IAET,EAA0H,AAA1H,wHAA0H;IAC1H,EAAqF,AAArF,mFAAqF;IACrF,GAAG,CAAC,QAAQ,GAAG,kBAAW,CAAC,CAAC;QAAA,KAAK,EAAE,CAAQ;QAAE,WAAW,EAAE,CAAM;IAAA,CAAC;IACjE,GAAG,CAAC,QAAQ,GAAG,cAAO,KAAO,gBAAgB,IAAI,GAAG,CAAC,2BAAoB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,QAAQ;MAAG,CAAC;QAAA,gBAAgB;QAAE,KAAK,CAAC,UAAU;QAAE,KAAK,CAAC,YAAY;QAAE,QAAQ;IAAA,CAAC;IAEnM,GAAG,CAAC,CAAC,mBAAA,gBAAgB,cAAE,SAAS,EAAA,CAAC,GAAG,qBAAc,CAChD,CAAC;oBACC,UAAU;QACV,IAAI,EAAE,CAAS;IACjB,CAAC,EACD,KAAK,EACL,GAAG;IAGL,GAAG,CAA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AK;IACxD,GAAG,CAAC,CAAC,iBAAA,cAAc,eAAE,UAAU,gBAAE,WAAW,EAAA,CAAC,GAAG,yCAAe,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU;IAExF,EAAqF,AAArF,mFAAqF;IACrF,EAA0F,AAA1F,wFAA0F;IAC1F,EAA+D,AAA/D,6DAA+D;IAC/D,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC,IAAI,IAAI,GAAG,EAC9B,MAAM,0CACH,CAAG,MAAK,cAAc,2CACpB,CAAK,QAAK,UAAU,4CACpB,CAAK,cACH,KAAK,2CACL,CAAM,SAAK,WAAW,2CACpB,CAAM,gBACN,CAAC;WAAG,KAAK,CAAC,UAAU,CAAC,OAAO;IAAE,CAAC,CAAC,GAAG,EAAC,GAAG,GAAI,CAAC;QAC3C,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG;QACvC,EAAE,EAAE,IAAI,CAAC,IAAI,KAAK,CAAM,OACtB,MAAM,0CACH,CAAM;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,KAAK,EAAE,IAAI,CAAC,GAAG;WACd,IAAI,CAAC,SAAS;IAIvB,CAAC;SAKJ,EAAE,EAAE,IAAI,EACb,MAAM,0CACH,CAAK;QACJ,IAAI,EAAC,CAAQ;QACb,YAAY,EAAE,WAAW,CAAC,YAAY;QACtC,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,UAAU;QACpB,KAAK,EAAE,KAAK,CAAC,WAAW;;IAI9B,MAAM,CAAC,IAAI;AACb,CAAC;;","sources":["packages/@react-aria/select/src/index.ts","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\nexport * from './useSelect';\nexport * from './HiddenSelect';\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":[],"version":3,"file":"module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/select",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
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.
|
|
22
|
-
"@react-aria/interactions": "3.
|
|
23
|
-
"@react-aria/label": "3.
|
|
24
|
-
"@react-aria/listbox": "3.4.
|
|
25
|
-
"@react-aria/menu": "3.
|
|
26
|
-
"@react-aria/selection": "3.
|
|
27
|
-
"@react-aria/utils": "3.
|
|
28
|
-
"@react-aria/visually-hidden": "3.
|
|
29
|
-
"@react-stately/select": "3.1.
|
|
30
|
-
"@react-types/button": "3.4.
|
|
31
|
-
"@react-types/select": "3.5.
|
|
32
|
-
"@react-types/shared": "3.
|
|
21
|
+
"@react-aria/i18n": "^3.3.6",
|
|
22
|
+
"@react-aria/interactions": "^3.8.1",
|
|
23
|
+
"@react-aria/label": "^3.2.3",
|
|
24
|
+
"@react-aria/listbox": "^3.4.2",
|
|
25
|
+
"@react-aria/menu": "^3.4.1",
|
|
26
|
+
"@react-aria/selection": "^3.7.3",
|
|
27
|
+
"@react-aria/utils": "^3.11.2",
|
|
28
|
+
"@react-aria/visually-hidden": "^3.2.5",
|
|
29
|
+
"@react-stately/select": "^3.1.5",
|
|
30
|
+
"@react-types/button": "^3.4.3",
|
|
31
|
+
"@react-types/select": "^3.5.3",
|
|
32
|
+
"@react-types/shared": "^3.11.1"
|
|
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": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
|
|
42
42
|
}
|