@react-aria/select 3.14.4-nightly.4555 → 3.14.4-nightly.4560

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.
@@ -0,0 +1,157 @@
1
+ import {filterDOMProps as $aUnai$filterDOMProps, mergeProps as $aUnai$mergeProps, useId as $aUnai$useId, chain as $aUnai$chain} from "@react-aria/utils";
2
+ import {useMemo as $aUnai$useMemo} from "react";
3
+ import {ListKeyboardDelegate as $aUnai$ListKeyboardDelegate, useTypeSelect as $aUnai$useTypeSelect} from "@react-aria/selection";
4
+ import {setInteractionModality as $aUnai$setInteractionModality} from "@react-aria/interactions";
5
+ import {useCollator as $aUnai$useCollator} from "@react-aria/i18n";
6
+ import {useField as $aUnai$useField} from "@react-aria/label";
7
+ import {useMenuTrigger as $aUnai$useMenuTrigger} from "@react-aria/menu";
8
+
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ const $58aed456727eb0f3$export$703601b7e90536f8 = new WeakMap();
27
+ function $58aed456727eb0f3$export$e64b2f635402ca43(props, state, ref) {
28
+ let { keyboardDelegate: keyboardDelegate, isDisabled: isDisabled, isRequired: isRequired, name: name, validationBehavior: validationBehavior = "aria" } = props;
29
+ // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
30
+ // When virtualized, the layout object will be passed in as a prop and override this.
31
+ let collator = (0, $aUnai$useCollator)({
32
+ usage: "search",
33
+ sensitivity: "base"
34
+ });
35
+ let delegate = (0, $aUnai$useMemo)(()=>keyboardDelegate || new (0, $aUnai$ListKeyboardDelegate)(state.collection, state.disabledKeys, null, collator), [
36
+ keyboardDelegate,
37
+ state.collection,
38
+ state.disabledKeys,
39
+ collator
40
+ ]);
41
+ let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $aUnai$useMenuTrigger)({
42
+ isDisabled: isDisabled,
43
+ type: "listbox"
44
+ }, state, ref);
45
+ let onKeyDown = (e)=>{
46
+ switch(e.key){
47
+ case "ArrowLeft":
48
+ {
49
+ // prevent scrolling containers
50
+ e.preventDefault();
51
+ let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
52
+ if (key) state.setSelectedKey(key);
53
+ break;
54
+ }
55
+ case "ArrowRight":
56
+ {
57
+ // prevent scrolling containers
58
+ e.preventDefault();
59
+ let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
60
+ if (key) state.setSelectedKey(key);
61
+ break;
62
+ }
63
+ }
64
+ };
65
+ let { typeSelectProps: typeSelectProps } = (0, $aUnai$useTypeSelect)({
66
+ keyboardDelegate: delegate,
67
+ selectionManager: state.selectionManager,
68
+ onTypeSelect (key) {
69
+ state.setSelectedKey(key);
70
+ }
71
+ });
72
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
73
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $aUnai$useField)({
74
+ ...props,
75
+ labelElementType: "span",
76
+ isInvalid: isInvalid,
77
+ errorMessage: props.errorMessage || validationErrors
78
+ });
79
+ typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
80
+ delete typeSelectProps.onKeyDownCapture;
81
+ let domProps = (0, $aUnai$filterDOMProps)(props, {
82
+ labelable: true
83
+ });
84
+ let triggerProps = (0, $aUnai$mergeProps)(typeSelectProps, menuTriggerProps, fieldProps);
85
+ let valueId = (0, $aUnai$useId)();
86
+ $58aed456727eb0f3$export$703601b7e90536f8.set(state, {
87
+ isDisabled: isDisabled,
88
+ isRequired: isRequired,
89
+ name: name,
90
+ validationBehavior: validationBehavior
91
+ });
92
+ return {
93
+ labelProps: {
94
+ ...labelProps,
95
+ onClick: ()=>{
96
+ if (!props.isDisabled) {
97
+ ref.current.focus();
98
+ // Show the focus ring so the user knows where focus went
99
+ (0, $aUnai$setInteractionModality)("keyboard");
100
+ }
101
+ }
102
+ },
103
+ triggerProps: (0, $aUnai$mergeProps)(domProps, {
104
+ ...triggerProps,
105
+ isDisabled: isDisabled,
106
+ onKeyDown: (0, $aUnai$chain)(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
107
+ onKeyUp: props.onKeyUp,
108
+ "aria-labelledby": [
109
+ valueId,
110
+ triggerProps["aria-labelledby"],
111
+ triggerProps["aria-label"] && !triggerProps["aria-labelledby"] ? triggerProps.id : null
112
+ ].filter(Boolean).join(" "),
113
+ onFocus (e) {
114
+ if (state.isFocused) return;
115
+ if (props.onFocus) props.onFocus(e);
116
+ if (props.onFocusChange) props.onFocusChange(true);
117
+ state.setFocused(true);
118
+ },
119
+ onBlur (e) {
120
+ if (state.isOpen) return;
121
+ if (props.onBlur) props.onBlur(e);
122
+ if (props.onFocusChange) props.onFocusChange(false);
123
+ state.setFocused(false);
124
+ }
125
+ }),
126
+ valueProps: {
127
+ id: valueId
128
+ },
129
+ menuProps: {
130
+ ...menuProps,
131
+ autoFocus: state.focusStrategy || true,
132
+ shouldSelectOnPressUp: true,
133
+ shouldFocusOnHover: true,
134
+ disallowEmptySelection: true,
135
+ linkBehavior: "selection",
136
+ onBlur: (e)=>{
137
+ if (e.currentTarget.contains(e.relatedTarget)) return;
138
+ if (props.onBlur) props.onBlur(e);
139
+ if (props.onFocusChange) props.onFocusChange(false);
140
+ state.setFocused(false);
141
+ },
142
+ "aria-labelledby": [
143
+ fieldProps["aria-labelledby"],
144
+ triggerProps["aria-label"] && !fieldProps["aria-labelledby"] ? triggerProps.id : null
145
+ ].filter(Boolean).join(" ")
146
+ },
147
+ descriptionProps: descriptionProps,
148
+ errorMessageProps: errorMessageProps,
149
+ isInvalid: isInvalid,
150
+ validationErrors: validationErrors,
151
+ validationDetails: validationDetails
152
+ };
153
+ }
154
+
155
+
156
+ export {$58aed456727eb0f3$export$703601b7e90536f8 as selectData, $58aed456727eb0f3$export$e64b2f635402ca43 as useSelect};
157
+ //# sourceMappingURL=useSelect.mjs.map
@@ -0,0 +1,157 @@
1
+ import {filterDOMProps as $aUnai$filterDOMProps, mergeProps as $aUnai$mergeProps, useId as $aUnai$useId, chain as $aUnai$chain} from "@react-aria/utils";
2
+ import {useMemo as $aUnai$useMemo} from "react";
3
+ import {ListKeyboardDelegate as $aUnai$ListKeyboardDelegate, useTypeSelect as $aUnai$useTypeSelect} from "@react-aria/selection";
4
+ import {setInteractionModality as $aUnai$setInteractionModality} from "@react-aria/interactions";
5
+ import {useCollator as $aUnai$useCollator} from "@react-aria/i18n";
6
+ import {useField as $aUnai$useField} from "@react-aria/label";
7
+ import {useMenuTrigger as $aUnai$useMenuTrigger} from "@react-aria/menu";
8
+
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+
21
+
22
+
23
+
24
+
25
+
26
+ const $58aed456727eb0f3$export$703601b7e90536f8 = new WeakMap();
27
+ function $58aed456727eb0f3$export$e64b2f635402ca43(props, state, ref) {
28
+ let { keyboardDelegate: keyboardDelegate, isDisabled: isDisabled, isRequired: isRequired, name: name, validationBehavior: validationBehavior = "aria" } = props;
29
+ // By default, a KeyboardDelegate is provided which uses the DOM to query layout information (e.g. for page up/page down).
30
+ // When virtualized, the layout object will be passed in as a prop and override this.
31
+ let collator = (0, $aUnai$useCollator)({
32
+ usage: "search",
33
+ sensitivity: "base"
34
+ });
35
+ let delegate = (0, $aUnai$useMemo)(()=>keyboardDelegate || new (0, $aUnai$ListKeyboardDelegate)(state.collection, state.disabledKeys, null, collator), [
36
+ keyboardDelegate,
37
+ state.collection,
38
+ state.disabledKeys,
39
+ collator
40
+ ]);
41
+ let { menuTriggerProps: menuTriggerProps, menuProps: menuProps } = (0, $aUnai$useMenuTrigger)({
42
+ isDisabled: isDisabled,
43
+ type: "listbox"
44
+ }, state, ref);
45
+ let onKeyDown = (e)=>{
46
+ switch(e.key){
47
+ case "ArrowLeft":
48
+ {
49
+ // prevent scrolling containers
50
+ e.preventDefault();
51
+ let key = state.selectedKey != null ? delegate.getKeyAbove(state.selectedKey) : delegate.getFirstKey();
52
+ if (key) state.setSelectedKey(key);
53
+ break;
54
+ }
55
+ case "ArrowRight":
56
+ {
57
+ // prevent scrolling containers
58
+ e.preventDefault();
59
+ let key = state.selectedKey != null ? delegate.getKeyBelow(state.selectedKey) : delegate.getFirstKey();
60
+ if (key) state.setSelectedKey(key);
61
+ break;
62
+ }
63
+ }
64
+ };
65
+ let { typeSelectProps: typeSelectProps } = (0, $aUnai$useTypeSelect)({
66
+ keyboardDelegate: delegate,
67
+ selectionManager: state.selectionManager,
68
+ onTypeSelect (key) {
69
+ state.setSelectedKey(key);
70
+ }
71
+ });
72
+ let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
73
+ let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $aUnai$useField)({
74
+ ...props,
75
+ labelElementType: "span",
76
+ isInvalid: isInvalid,
77
+ errorMessage: props.errorMessage || validationErrors
78
+ });
79
+ typeSelectProps.onKeyDown = typeSelectProps.onKeyDownCapture;
80
+ delete typeSelectProps.onKeyDownCapture;
81
+ let domProps = (0, $aUnai$filterDOMProps)(props, {
82
+ labelable: true
83
+ });
84
+ let triggerProps = (0, $aUnai$mergeProps)(typeSelectProps, menuTriggerProps, fieldProps);
85
+ let valueId = (0, $aUnai$useId)();
86
+ $58aed456727eb0f3$export$703601b7e90536f8.set(state, {
87
+ isDisabled: isDisabled,
88
+ isRequired: isRequired,
89
+ name: name,
90
+ validationBehavior: validationBehavior
91
+ });
92
+ return {
93
+ labelProps: {
94
+ ...labelProps,
95
+ onClick: ()=>{
96
+ if (!props.isDisabled) {
97
+ ref.current.focus();
98
+ // Show the focus ring so the user knows where focus went
99
+ (0, $aUnai$setInteractionModality)("keyboard");
100
+ }
101
+ }
102
+ },
103
+ triggerProps: (0, $aUnai$mergeProps)(domProps, {
104
+ ...triggerProps,
105
+ isDisabled: isDisabled,
106
+ onKeyDown: (0, $aUnai$chain)(triggerProps.onKeyDown, onKeyDown, props.onKeyDown),
107
+ onKeyUp: props.onKeyUp,
108
+ "aria-labelledby": [
109
+ valueId,
110
+ triggerProps["aria-labelledby"],
111
+ triggerProps["aria-label"] && !triggerProps["aria-labelledby"] ? triggerProps.id : null
112
+ ].filter(Boolean).join(" "),
113
+ onFocus (e) {
114
+ if (state.isFocused) return;
115
+ if (props.onFocus) props.onFocus(e);
116
+ if (props.onFocusChange) props.onFocusChange(true);
117
+ state.setFocused(true);
118
+ },
119
+ onBlur (e) {
120
+ if (state.isOpen) return;
121
+ if (props.onBlur) props.onBlur(e);
122
+ if (props.onFocusChange) props.onFocusChange(false);
123
+ state.setFocused(false);
124
+ }
125
+ }),
126
+ valueProps: {
127
+ id: valueId
128
+ },
129
+ menuProps: {
130
+ ...menuProps,
131
+ autoFocus: state.focusStrategy || true,
132
+ shouldSelectOnPressUp: true,
133
+ shouldFocusOnHover: true,
134
+ disallowEmptySelection: true,
135
+ linkBehavior: "selection",
136
+ onBlur: (e)=>{
137
+ if (e.currentTarget.contains(e.relatedTarget)) return;
138
+ if (props.onBlur) props.onBlur(e);
139
+ if (props.onFocusChange) props.onFocusChange(false);
140
+ state.setFocused(false);
141
+ },
142
+ "aria-labelledby": [
143
+ fieldProps["aria-labelledby"],
144
+ triggerProps["aria-label"] && !fieldProps["aria-labelledby"] ? triggerProps.id : null
145
+ ].filter(Boolean).join(" ")
146
+ },
147
+ descriptionProps: descriptionProps,
148
+ errorMessageProps: errorMessageProps,
149
+ isInvalid: isInvalid,
150
+ validationErrors: validationErrors,
151
+ validationDetails: validationDetails
152
+ };
153
+ }
154
+
155
+
156
+ export {$58aed456727eb0f3$export$703601b7e90536f8 as selectData, $58aed456727eb0f3$export$e64b2f635402ca43 as useSelect};
157
+ //# sourceMappingURL=useSelect.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAkDM,MAAM,4CAAa,IAAI;AAQvB,SAAS,0CAAa,KAA2B,EAAE,KAAqB,EAAE,GAAgC;IAC/G,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;IAGF,IAAI,YAAY,CAAC;QACf,OAAQ,EAAE,GAAG;YACX,KAAK;gBAAa;oBAChB,+BAA+B;oBAC/B,EAAE,cAAc;oBAEh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zB;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>): 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.4-nightly.4555+81162ea39",
3
+ "version": "3.14.4-nightly.4560+72775d272",
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.4-nightly.4555+81162ea39",
26
- "@react-aria/i18n": "3.0.0-nightly.2843+81162ea39",
27
- "@react-aria/interactions": "3.0.0-nightly.2843+81162ea39",
28
- "@react-aria/label": "3.0.0-nightly.2843+81162ea39",
29
- "@react-aria/listbox": "3.11.6-nightly.4555+81162ea39",
30
- "@react-aria/menu": "3.13.2-nightly.4555+81162ea39",
31
- "@react-aria/selection": "3.0.0-nightly.2843+81162ea39",
32
- "@react-aria/utils": "3.0.0-nightly.2843+81162ea39",
33
- "@react-aria/visually-hidden": "3.0.0-nightly.2843+81162ea39",
34
- "@react-stately/select": "3.6.3-nightly.4555+81162ea39",
35
- "@react-types/button": "3.9.3-nightly.4555+81162ea39",
36
- "@react-types/select": "3.9.3-nightly.4555+81162ea39",
37
- "@react-types/shared": "3.0.0-nightly.2843+81162ea39",
25
+ "@react-aria/form": "3.0.4-nightly.4560+72775d272",
26
+ "@react-aria/i18n": "3.0.0-nightly.2848+72775d272",
27
+ "@react-aria/interactions": "3.0.0-nightly.2848+72775d272",
28
+ "@react-aria/label": "3.0.0-nightly.2848+72775d272",
29
+ "@react-aria/listbox": "3.11.6-nightly.4560+72775d272",
30
+ "@react-aria/menu": "3.13.2-nightly.4560+72775d272",
31
+ "@react-aria/selection": "3.0.0-nightly.2848+72775d272",
32
+ "@react-aria/utils": "3.0.0-nightly.2848+72775d272",
33
+ "@react-aria/visually-hidden": "3.0.0-nightly.2848+72775d272",
34
+ "@react-stately/select": "3.6.3-nightly.4560+72775d272",
35
+ "@react-types/button": "3.9.3-nightly.4560+72775d272",
36
+ "@react-types/select": "3.9.3-nightly.4560+72775d272",
37
+ "@react-types/shared": "3.0.0-nightly.2848+72775d272",
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": "81162ea392926d06ec3d25c228e6f9b6b5479d59"
47
+ "gitHead": "72775d272be04cfa32d26ec821bc68513d92a72b"
48
48
  }