@react-aria/select 3.17.3 → 3.18.0

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/import.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import {useSelect as $58aed456727eb0f3$export$e64b2f635402ca43} from "./useSelect.mjs";
2
- import {HiddenSelect as $bdd25dc72710631f$export$cbd84cdb2e668835, useHiddenSelect as $bdd25dc72710631f$export$f809e80f58e251d1} from "./HiddenSelect.mjs";
1
+ import {useSelect as $da6d22b4ec279f7c$re_export$useSelect, useHiddenSelect as $da6d22b4ec279f7c$re_export$useHiddenSelect, HiddenSelect as $da6d22b4ec279f7c$re_export$HiddenSelect} from "react-aria/useSelect";
3
2
 
4
3
  /*
5
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,6 +13,5 @@ import {HiddenSelect as $bdd25dc72710631f$export$cbd84cdb2e668835, useHiddenSele
14
13
  */
15
14
 
16
15
 
17
-
18
- export {$58aed456727eb0f3$export$e64b2f635402ca43 as useSelect, $bdd25dc72710631f$export$f809e80f58e251d1 as useHiddenSelect, $bdd25dc72710631f$export$cbd84cdb2e668835 as HiddenSelect};
16
+ export {$da6d22b4ec279f7c$re_export$useSelect as useSelect, $da6d22b4ec279f7c$re_export$useHiddenSelect as useHiddenSelect, $da6d22b4ec279f7c$re_export$HiddenSelect as HiddenSelect};
19
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,14 +1,13 @@
1
- var $23a1e93dc7fa8653$exports = require("./useSelect.main.js");
2
- var $6eae0e0872a4cdd4$exports = require("./HiddenSelect.main.js");
1
+ var $88DxE$reactariauseSelect = require("react-aria/useSelect");
3
2
 
4
3
 
5
4
  function $parcel$export(e, n, v, s) {
6
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
6
  }
8
7
 
9
- $parcel$export(module.exports, "useSelect", () => $23a1e93dc7fa8653$exports.useSelect);
10
- $parcel$export(module.exports, "useHiddenSelect", () => $6eae0e0872a4cdd4$exports.useHiddenSelect);
11
- $parcel$export(module.exports, "HiddenSelect", () => $6eae0e0872a4cdd4$exports.HiddenSelect);
8
+ $parcel$export(module.exports, "useSelect", function () { return $88DxE$reactariauseSelect.useSelect; });
9
+ $parcel$export(module.exports, "useHiddenSelect", function () { return $88DxE$reactariauseSelect.useHiddenSelect; });
10
+ $parcel$export(module.exports, "HiddenSelect", function () { return $88DxE$reactariauseSelect.HiddenSelect; });
12
11
  /*
13
12
  * Copyright 2020 Adobe. All rights reserved.
14
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -22,5 +21,4 @@ $parcel$export(module.exports, "HiddenSelect", () => $6eae0e0872a4cdd4$exports.H
22
21
  */
23
22
 
24
23
 
25
-
26
24
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/select/src/index.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 */\nexport {useSelect} from './useSelect';\nexport {useHiddenSelect, HiddenSelect} from './HiddenSelect';\nexport type {AriaSelectOptions, SelectAria} from './useSelect';\nexport type {AriaHiddenSelectProps, HiddenSelectProps} from './HiddenSelect';\nexport type {AriaSelectProps} from '@react-types/select';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/select/src/index.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 */\nexport {useSelect, useHiddenSelect, HiddenSelect} from 'react-aria/useSelect';\n\nexport type {AriaSelectProps, AriaSelectOptions, SelectAria, AriaHiddenSelectProps, AriaHiddenSelectOptions, HiddenSelectProps, HiddenSelectAria} from 'react-aria/useSelect';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,5 +1,4 @@
1
- import {useSelect as $58aed456727eb0f3$export$e64b2f635402ca43} from "./useSelect.module.js";
2
- import {HiddenSelect as $bdd25dc72710631f$export$cbd84cdb2e668835, useHiddenSelect as $bdd25dc72710631f$export$f809e80f58e251d1} from "./HiddenSelect.module.js";
1
+ import {useSelect as $da6d22b4ec279f7c$re_export$useSelect, useHiddenSelect as $da6d22b4ec279f7c$re_export$useHiddenSelect, HiddenSelect as $da6d22b4ec279f7c$re_export$HiddenSelect} from "react-aria/useSelect";
3
2
 
4
3
  /*
5
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,6 +13,5 @@ import {HiddenSelect as $bdd25dc72710631f$export$cbd84cdb2e668835, useHiddenSele
14
13
  */
15
14
 
16
15
 
17
-
18
- export {$58aed456727eb0f3$export$e64b2f635402ca43 as useSelect, $bdd25dc72710631f$export$f809e80f58e251d1 as useHiddenSelect, $bdd25dc72710631f$export$cbd84cdb2e668835 as HiddenSelect};
16
+ export {$da6d22b4ec279f7c$re_export$useSelect as useSelect, $da6d22b4ec279f7c$re_export$useHiddenSelect as useHiddenSelect, $da6d22b4ec279f7c$re_export$HiddenSelect as HiddenSelect};
19
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/select/src/index.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 */\nexport {useSelect} from './useSelect';\nexport {useHiddenSelect, HiddenSelect} from './HiddenSelect';\nexport type {AriaSelectOptions, SelectAria} from './useSelect';\nexport type {AriaHiddenSelectProps, HiddenSelectProps} from './HiddenSelect';\nexport type {AriaSelectProps} from '@react-types/select';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/select/src/index.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 */\nexport {useSelect, useHiddenSelect, HiddenSelect} from 'react-aria/useSelect';\n\nexport type {AriaSelectProps, AriaSelectOptions, SelectAria, AriaHiddenSelectProps, AriaHiddenSelectOptions, HiddenSelectProps, HiddenSelectAria} from 'react-aria/useSelect';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,2 @@
1
+ export { useSelect, useHiddenSelect, HiddenSelect } from 'react-aria/useSelect';
2
+ export type { AriaSelectProps, AriaSelectOptions, SelectAria, AriaHiddenSelectProps, AriaHiddenSelectOptions, HiddenSelectProps, HiddenSelectAria } from 'react-aria/useSelect';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-aria/select",
3
- "version": "3.17.3",
3
+ "version": "3.18.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -26,20 +26,8 @@
26
26
  "url": "https://github.com/adobe/react-spectrum"
27
27
  },
28
28
  "dependencies": {
29
- "@react-aria/form": "^3.1.5",
30
- "@react-aria/i18n": "^3.12.16",
31
- "@react-aria/interactions": "^3.27.1",
32
- "@react-aria/label": "^3.7.25",
33
- "@react-aria/listbox": "^3.15.3",
34
- "@react-aria/menu": "^3.21.0",
35
- "@react-aria/selection": "^3.27.2",
36
- "@react-aria/utils": "^3.33.1",
37
- "@react-aria/visually-hidden": "^3.8.31",
38
- "@react-stately/select": "^3.9.2",
39
- "@react-types/button": "^3.15.1",
40
- "@react-types/select": "^3.12.2",
41
- "@react-types/shared": "^3.33.1",
42
- "@swc/helpers": "^0.5.0"
29
+ "@swc/helpers": "^0.5.0",
30
+ "react-aria": "3.48.0"
43
31
  },
44
32
  "peerDependencies": {
45
33
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
@@ -48,5 +36,8 @@
48
36
  "publishConfig": {
49
37
  "access": "public"
50
38
  },
51
- "gitHead": "8df187370053aa35f553cb388ad670f65e1ab371"
39
+ "targets": {
40
+ "types": false
41
+ },
42
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
52
43
  }
package/src/index.ts CHANGED
@@ -9,8 +9,6 @@
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
- export {useSelect} from './useSelect';
13
- export {useHiddenSelect, HiddenSelect} from './HiddenSelect';
14
- export type {AriaSelectOptions, SelectAria} from './useSelect';
15
- export type {AriaHiddenSelectProps, HiddenSelectProps} from './HiddenSelect';
16
- export type {AriaSelectProps} from '@react-types/select';
12
+ export {useSelect, useHiddenSelect, HiddenSelect} from 'react-aria/useSelect';
13
+
14
+ export type {AriaSelectProps, AriaSelectOptions, SelectAria, AriaHiddenSelectProps, AriaHiddenSelectOptions, HiddenSelectProps, HiddenSelectAria} from 'react-aria/useSelect';
@@ -1,169 +0,0 @@
1
- var $23a1e93dc7fa8653$exports = require("./useSelect.main.js");
2
- var $ccxQv$reactariautils = require("@react-aria/utils");
3
- var $ccxQv$react = require("react");
4
- var $ccxQv$reactariaform = require("@react-aria/form");
5
- var $ccxQv$reactariavisuallyhidden = require("@react-aria/visually-hidden");
6
-
7
-
8
- function $parcel$interopDefault(a) {
9
- return a && a.__esModule ? a.default : a;
10
- }
11
-
12
- function $parcel$export(e, n, v, s) {
13
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
- }
15
-
16
- $parcel$export(module.exports, "useHiddenSelect", () => $6eae0e0872a4cdd4$export$f809e80f58e251d1);
17
- $parcel$export(module.exports, "HiddenSelect", () => $6eae0e0872a4cdd4$export$cbd84cdb2e668835);
18
- /*
19
- * Copyright 2020 Adobe. All rights reserved.
20
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License. You may obtain a copy
22
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
23
- *
24
- * Unless required by applicable law or agreed to in writing, software distributed under
25
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
26
- * OF ANY KIND, either express or implied. See the License for the specific language
27
- * governing permissions and limitations under the License.
28
- */
29
-
30
-
31
-
32
-
33
- function $6eae0e0872a4cdd4$export$f809e80f58e251d1(props, state, triggerRef) {
34
- let data = (0, $23a1e93dc7fa8653$exports.selectData).get(state) || {};
35
- let { autoComplete: autoComplete, name: name = data.name, form: form = data.form, isDisabled: isDisabled = data.isDisabled } = props;
36
- let { validationBehavior: validationBehavior, isRequired: isRequired } = data;
37
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $ccxQv$reactariavisuallyhidden.useVisuallyHidden)({
38
- style: {
39
- // Prevent page scrolling.
40
- position: 'fixed',
41
- top: 0,
42
- left: 0
43
- }
44
- });
45
- (0, $ccxQv$reactariautils.useFormReset)(props.selectRef, state.defaultValue, state.setValue);
46
- (0, $ccxQv$reactariaform.useFormValidation)({
47
- validationBehavior: validationBehavior,
48
- focus: ()=>{
49
- var _triggerRef_current;
50
- return (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
51
- }
52
- }, state, props.selectRef);
53
- let setValue = state.setValue;
54
- let onChange = (0, $ccxQv$react.useCallback)((e)=>{
55
- let eventTarget = (0, $ccxQv$reactariautils.getEventTarget)(e);
56
- if (eventTarget.multiple) setValue(Array.from(eventTarget.selectedOptions, (option)=>option.value));
57
- else setValue(e.currentTarget.value);
58
- }, [
59
- setValue
60
- ]);
61
- var _state_value;
62
- // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.
63
- // In Firefox, there must be a <label> to identify the <select> whereas other browsers
64
- // seem to identify it just by surrounding text.
65
- // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a
66
- // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>
67
- // non tabbable with tabIndex={-1}.
68
- return {
69
- containerProps: {
70
- ...visuallyHiddenProps,
71
- 'aria-hidden': true,
72
- // @ts-ignore
73
- ['data-react-aria-prevent-focus']: true,
74
- // @ts-ignore
75
- ['data-a11y-ignore']: 'aria-hidden-focus'
76
- },
77
- inputProps: {
78
- style: {
79
- display: 'none'
80
- }
81
- },
82
- selectProps: {
83
- tabIndex: -1,
84
- autoComplete: autoComplete,
85
- disabled: isDisabled,
86
- multiple: state.selectionManager.selectionMode === 'multiple',
87
- required: validationBehavior === 'native' && isRequired,
88
- name: name,
89
- form: form,
90
- value: (_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : '',
91
- onChange: onChange,
92
- onInput: onChange
93
- }
94
- };
95
- }
96
- function $6eae0e0872a4cdd4$export$cbd84cdb2e668835(props) {
97
- let { state: state, triggerRef: triggerRef, label: label, name: name, form: form, isDisabled: isDisabled } = props;
98
- let selectRef = (0, $ccxQv$react.useRef)(null);
99
- let inputRef = (0, $ccxQv$react.useRef)(null);
100
- let { containerProps: containerProps, selectProps: selectProps } = $6eae0e0872a4cdd4$export$f809e80f58e251d1({
101
- ...props,
102
- selectRef: state.collection.size <= 300 ? selectRef : inputRef
103
- }, state, triggerRef);
104
- let values = Array.isArray(state.value) ? state.value : [
105
- state.value
106
- ];
107
- // If used in a <form>, use a hidden input so the value can be submitted to a server.
108
- // If the collection isn't too big, use a hidden <select> element for this so that browser
109
- // autofill will work. Otherwise, use an <input type="hidden">.
110
- if (state.collection.size <= 300) return /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("div", {
111
- ...containerProps,
112
- "data-testid": "hidden-select-container"
113
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("label", null, label, /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("select", {
114
- ...selectProps,
115
- ref: selectRef
116
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("option", null), [
117
- ...state.collection.getKeys()
118
- ].map((key)=>{
119
- let item = state.collection.getItem(key);
120
- if (item && item.type === 'item') return /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("option", {
121
- key: item.key,
122
- value: item.key
123
- }, item.textValue);
124
- }), state.collection.size === 0 && name && values.map((value, i)=>/*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("option", {
125
- key: i,
126
- value: value !== null && value !== void 0 ? value : ''
127
- })))));
128
- else if (name) {
129
- let data = (0, $23a1e93dc7fa8653$exports.selectData).get(state) || {};
130
- let { validationBehavior: validationBehavior } = data;
131
- // Always render at least one hidden input to ensure required form submission.
132
- if (values.length === 0) values = [
133
- null
134
- ];
135
- let res = values.map((value, i)=>{
136
- let inputProps = {
137
- type: 'hidden',
138
- autoComplete: selectProps.autoComplete,
139
- name: name,
140
- form: form,
141
- disabled: isDisabled,
142
- value: value !== null && value !== void 0 ? value : ''
143
- };
144
- if (validationBehavior === 'native') // Use a hidden <input type="text"> rather than <input type="hidden">
145
- // so that an empty value blocks HTML form submission when the field is required.
146
- return /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("input", {
147
- key: i,
148
- ...inputProps,
149
- ref: i === 0 ? inputRef : null,
150
- style: {
151
- display: 'none'
152
- },
153
- type: "text",
154
- required: i === 0 ? selectProps.required : false,
155
- onChange: ()=>{}
156
- });
157
- return /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement("input", {
158
- key: i,
159
- ...inputProps,
160
- ref: i === 0 ? inputRef : null
161
- });
162
- });
163
- return /*#__PURE__*/ (0, ($parcel$interopDefault($ccxQv$react))).createElement((0, ($parcel$interopDefault($ccxQv$react))).Fragment, null, res);
164
- }
165
- return null;
166
- }
167
-
168
-
169
- //# sourceMappingURL=HiddenSelect.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA+DM,SAAS,0CAAuD,KAA8B,EAAE,KAAwB,EAAE,UAA8C;IAC7K,IAAI,OAAO,CAAA,GAAA,oCAAS,EAAE,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AAC;QACrC,IAAI,sBAAC,kBAAkB,EAAC,GAAG;QAE3B,8EAA8E;QAC9E,IAAI,OAAO,MAAM,KAAK,GACpB,SAAS;YAAC;SAAK;QAGjB,IAAI,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO;YAC3B,IAAI,aAAoD;gBACtD,MAAM;gBACN,cAAc,YAAY,YAAY;sBACtC;sBACA;gBACA,UAAU;gBACV,OAAO,kBAAA,mBAAA,QAAS;YAClB;YAEA,IAAI,uBAAuB,UACzB,qEAAqE;YACrE,iFAAiF;YACjF,qBACE,0DAAC;gBACC,KAAK;gBACJ,GAAG,UAAU;gBACd,KAAK,MAAM,IAAI,WAAW;gBAC1B,OAAO;oBAAC,SAAS;gBAAM;gBACvB,MAAK;gBACL,UAAU,MAAM,IAAI,YAAY,QAAQ,GAAG;gBAC3C,UAAU,KAAmC;;YAInD,qBACE,0DAAC;gBAAM,KAAK;gBAAI,GAAG,UAAU;gBAAE,KAAK,MAAM,IAAI,WAAW;;QAE7D;QAEA,qBAAO,sHAAG;IACZ;IAEA,OAAO;AACT","sources":["packages/@react-aria/select/src/HiddenSelect.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FocusableElement, Key, RefObject} from '@react-types/shared';\nimport {getEventTarget, useFormReset} from '@react-aria/utils';\nimport React, {InputHTMLAttributes, JSX, ReactNode, useCallback, useRef} from 'react';\nimport {selectData} from './useSelect';\nimport {SelectionMode} from '@react-types/select';\nimport {SelectState} from '@react-stately/select';\nimport {useFormValidation} from '@react-aria/form';\nimport {useVisuallyHidden} from '@react-aria/visually-hidden';\n\nexport interface AriaHiddenSelectProps {\n /**\n * Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete).\n */\n autoComplete?: string,\n\n /** The text label for the select. */\n label?: ReactNode,\n\n /** HTML form input name. */\n name?: string,\n\n /**\n * The `<form>` element to associate the input with.\n * The value of this attribute must be the id of a `<form>` in the same document.\n * See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#form).\n */\n form?: string,\n\n /** Sets the disabled state of the select and input. */\n isDisabled?: boolean\n}\n\nexport interface HiddenSelectProps<T, M extends SelectionMode = 'single'> extends AriaHiddenSelectProps {\n /** State for the select. */\n state: SelectState<T, M>,\n\n /** A ref to the trigger element. */\n triggerRef: RefObject<FocusableElement | null>\n}\n\nexport interface AriaHiddenSelectOptions extends AriaHiddenSelectProps {\n /** A ref to the hidden `<select>` element. */\n selectRef?: RefObject<HTMLSelectElement | HTMLInputElement | null>\n}\n\nexport interface HiddenSelectAria {\n /** Props for the container element. */\n containerProps: React.HTMLAttributes<FocusableElement>,\n\n /** Props for the hidden input element. */\n inputProps: React.InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the hidden select element. */\n selectProps: React.SelectHTMLAttributes<HTMLSelectElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a hidden `<select>` element, which\n * can be used in combination with `useSelect` to support browser form autofill, mobile form\n * navigation, and native HTML form submission.\n */\nexport function useHiddenSelect<T, M extends SelectionMode = 'single'>(props: AriaHiddenSelectOptions, state: SelectState<T, M>, triggerRef: RefObject<FocusableElement | null>): HiddenSelectAria {\n let data = selectData.get(state) || {};\n let {autoComplete, name = data.name, form = data.form, isDisabled = data.isDisabled} = props;\n let {validationBehavior, isRequired} = data;\n let {visuallyHiddenProps} = useVisuallyHidden({\n style: {\n // Prevent page scrolling.\n position: 'fixed',\n top: 0,\n left: 0\n }\n });\n\n useFormReset(props.selectRef, state.defaultValue, state.setValue);\n useFormValidation({\n validationBehavior,\n focus: () => triggerRef.current?.focus()\n }, state, props.selectRef);\n\n let setValue = state.setValue;\n let onChange = useCallback((e: React.ChangeEvent<HTMLSelectElement>) => {\n let eventTarget = getEventTarget(e);\n if (eventTarget.multiple) {\n setValue(Array.from(\n eventTarget.selectedOptions,\n (option) => option.value\n ) as any);\n } else {\n setValue(e.currentTarget.value as any);\n }\n }, [setValue]);\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 return {\n containerProps: {\n ...visuallyHiddenProps,\n 'aria-hidden': true,\n // @ts-ignore\n ['data-react-aria-prevent-focus']: true,\n // @ts-ignore\n ['data-a11y-ignore']: 'aria-hidden-focus'\n },\n inputProps: {\n style: {display: 'none'}\n },\n selectProps: {\n tabIndex: -1,\n autoComplete,\n disabled: isDisabled,\n multiple: state.selectionManager.selectionMode === 'multiple',\n required: validationBehavior === 'native' && isRequired,\n name,\n form,\n value: (state.value as string | string[]) ?? '',\n onChange,\n onInput: onChange\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, M extends SelectionMode = 'single'>(props: HiddenSelectProps<T, M>): JSX.Element | null {\n let {state, triggerRef, label, name, form, isDisabled} = props;\n let selectRef = useRef(null);\n let inputRef = useRef(null);\n let {containerProps, selectProps} = useHiddenSelect({...props, selectRef: state.collection.size <= 300 ? selectRef : inputRef}, state, triggerRef);\n\n let values: (Key | null)[] = Array.isArray(state.value) ? state.value : [state.value];\n\n // If used in a <form>, use a hidden input so the value can be submitted to a server.\n // If the collection isn't too big, use a hidden <select> element for this so that browser\n // autofill will work. Otherwise, use an <input type=\"hidden\">.\n if (state.collection.size <= 300) {\n return (\n <div {...containerProps} data-testid=\"hidden-select-container\">\n <label>\n {label}\n <select {...selectProps} ref={selectRef}>\n <option />\n {[...state.collection.getKeys()].map(key => {\n let item = state.collection.getItem(key);\n if (item && item.type === 'item') {\n return (\n <option\n key={item.key}\n value={item.key}>\n {item.textValue}\n </option>\n );\n }\n })}\n {/* The collection may be empty during the initial render. */}\n {/* Rendering options for the current values ensures the select has a value immediately, */}\n {/* making FormData reads consistent. */}\n {state.collection.size === 0 && name && values.map((value, i) => <option key={i} value={value ?? ''} />)}\n </select>\n </label>\n </div>\n );\n } else if (name) {\n let data = selectData.get(state) || {};\n let {validationBehavior} = data;\n\n // Always render at least one hidden input to ensure required form submission.\n if (values.length === 0) {\n values = [null];\n }\n\n let res = values.map((value, i) => {\n let inputProps: InputHTMLAttributes<HTMLInputElement> = {\n type: 'hidden',\n autoComplete: selectProps.autoComplete,\n name,\n form,\n disabled: isDisabled,\n value: value ?? ''\n };\n\n if (validationBehavior === 'native') {\n // Use a hidden <input type=\"text\"> rather than <input type=\"hidden\">\n // so that an empty value blocks HTML form submission when the field is required.\n return (\n <input\n key={i}\n {...inputProps}\n ref={i === 0 ? inputRef : null}\n style={{display: 'none'}}\n type=\"text\"\n required={i === 0 ? selectProps.required : false}\n onChange={() => {/** Ignore react warning. */}} />\n );\n }\n\n return (\n <input key={i} {...inputProps} ref={i === 0 ? inputRef : null} />\n );\n });\n\n return <>{res}</>;\n }\n\n return null;\n}\n"],"names":[],"version":3,"file":"HiddenSelect.main.js.map"}
@@ -1,159 +0,0 @@
1
- import {selectData as $58aed456727eb0f3$export$703601b7e90536f8} from "./useSelect.mjs";
2
- import {useFormReset as $8BE50$useFormReset, getEventTarget as $8BE50$getEventTarget} from "@react-aria/utils";
3
- import $8BE50$react, {useCallback as $8BE50$useCallback, useRef as $8BE50$useRef} from "react";
4
- import {useFormValidation as $8BE50$useFormValidation} from "@react-aria/form";
5
- import {useVisuallyHidden as $8BE50$useVisuallyHidden} from "@react-aria/visually-hidden";
6
-
7
- /*
8
- * Copyright 2020 Adobe. All rights reserved.
9
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License. You may obtain a copy
11
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software distributed under
14
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
- * OF ANY KIND, either express or implied. See the License for the specific language
16
- * governing permissions and limitations under the License.
17
- */
18
-
19
-
20
-
21
-
22
- function $bdd25dc72710631f$export$f809e80f58e251d1(props, state, triggerRef) {
23
- let data = (0, $58aed456727eb0f3$export$703601b7e90536f8).get(state) || {};
24
- let { autoComplete: autoComplete, name: name = data.name, form: form = data.form, isDisabled: isDisabled = data.isDisabled } = props;
25
- let { validationBehavior: validationBehavior, isRequired: isRequired } = data;
26
- let { visuallyHiddenProps: visuallyHiddenProps } = (0, $8BE50$useVisuallyHidden)({
27
- style: {
28
- // Prevent page scrolling.
29
- position: 'fixed',
30
- top: 0,
31
- left: 0
32
- }
33
- });
34
- (0, $8BE50$useFormReset)(props.selectRef, state.defaultValue, state.setValue);
35
- (0, $8BE50$useFormValidation)({
36
- validationBehavior: validationBehavior,
37
- focus: ()=>{
38
- var _triggerRef_current;
39
- return (_triggerRef_current = triggerRef.current) === null || _triggerRef_current === void 0 ? void 0 : _triggerRef_current.focus();
40
- }
41
- }, state, props.selectRef);
42
- let setValue = state.setValue;
43
- let onChange = (0, $8BE50$useCallback)((e)=>{
44
- let eventTarget = (0, $8BE50$getEventTarget)(e);
45
- if (eventTarget.multiple) setValue(Array.from(eventTarget.selectedOptions, (option)=>option.value));
46
- else setValue(e.currentTarget.value);
47
- }, [
48
- setValue
49
- ]);
50
- var _state_value;
51
- // In Safari, the <select> cannot have `display: none` or `hidden` for autofill to work.
52
- // In Firefox, there must be a <label> to identify the <select> whereas other browsers
53
- // seem to identify it just by surrounding text.
54
- // The solution is to use <VisuallyHidden> to hide the elements, which clips the elements to a
55
- // 1px rectangle. In addition, we hide from screen readers with aria-hidden, and make the <select>
56
- // non tabbable with tabIndex={-1}.
57
- return {
58
- containerProps: {
59
- ...visuallyHiddenProps,
60
- 'aria-hidden': true,
61
- // @ts-ignore
62
- ['data-react-aria-prevent-focus']: true,
63
- // @ts-ignore
64
- ['data-a11y-ignore']: 'aria-hidden-focus'
65
- },
66
- inputProps: {
67
- style: {
68
- display: 'none'
69
- }
70
- },
71
- selectProps: {
72
- tabIndex: -1,
73
- autoComplete: autoComplete,
74
- disabled: isDisabled,
75
- multiple: state.selectionManager.selectionMode === 'multiple',
76
- required: validationBehavior === 'native' && isRequired,
77
- name: name,
78
- form: form,
79
- value: (_state_value = state.value) !== null && _state_value !== void 0 ? _state_value : '',
80
- onChange: onChange,
81
- onInput: onChange
82
- }
83
- };
84
- }
85
- function $bdd25dc72710631f$export$cbd84cdb2e668835(props) {
86
- let { state: state, triggerRef: triggerRef, label: label, name: name, form: form, isDisabled: isDisabled } = props;
87
- let selectRef = (0, $8BE50$useRef)(null);
88
- let inputRef = (0, $8BE50$useRef)(null);
89
- let { containerProps: containerProps, selectProps: selectProps } = $bdd25dc72710631f$export$f809e80f58e251d1({
90
- ...props,
91
- selectRef: state.collection.size <= 300 ? selectRef : inputRef
92
- }, state, triggerRef);
93
- let values = Array.isArray(state.value) ? state.value : [
94
- state.value
95
- ];
96
- // If used in a <form>, use a hidden input so the value can be submitted to a server.
97
- // If the collection isn't too big, use a hidden <select> element for this so that browser
98
- // autofill will work. Otherwise, use an <input type="hidden">.
99
- if (state.collection.size <= 300) return /*#__PURE__*/ (0, $8BE50$react).createElement("div", {
100
- ...containerProps,
101
- "data-testid": "hidden-select-container"
102
- }, /*#__PURE__*/ (0, $8BE50$react).createElement("label", null, label, /*#__PURE__*/ (0, $8BE50$react).createElement("select", {
103
- ...selectProps,
104
- ref: selectRef
105
- }, /*#__PURE__*/ (0, $8BE50$react).createElement("option", null), [
106
- ...state.collection.getKeys()
107
- ].map((key)=>{
108
- let item = state.collection.getItem(key);
109
- if (item && item.type === 'item') return /*#__PURE__*/ (0, $8BE50$react).createElement("option", {
110
- key: item.key,
111
- value: item.key
112
- }, item.textValue);
113
- }), state.collection.size === 0 && name && values.map((value, i)=>/*#__PURE__*/ (0, $8BE50$react).createElement("option", {
114
- key: i,
115
- value: value !== null && value !== void 0 ? value : ''
116
- })))));
117
- else if (name) {
118
- let data = (0, $58aed456727eb0f3$export$703601b7e90536f8).get(state) || {};
119
- let { validationBehavior: validationBehavior } = data;
120
- // Always render at least one hidden input to ensure required form submission.
121
- if (values.length === 0) values = [
122
- null
123
- ];
124
- let res = values.map((value, i)=>{
125
- let inputProps = {
126
- type: 'hidden',
127
- autoComplete: selectProps.autoComplete,
128
- name: name,
129
- form: form,
130
- disabled: isDisabled,
131
- value: value !== null && value !== void 0 ? value : ''
132
- };
133
- if (validationBehavior === 'native') // Use a hidden <input type="text"> rather than <input type="hidden">
134
- // so that an empty value blocks HTML form submission when the field is required.
135
- return /*#__PURE__*/ (0, $8BE50$react).createElement("input", {
136
- key: i,
137
- ...inputProps,
138
- ref: i === 0 ? inputRef : null,
139
- style: {
140
- display: 'none'
141
- },
142
- type: "text",
143
- required: i === 0 ? selectProps.required : false,
144
- onChange: ()=>{}
145
- });
146
- return /*#__PURE__*/ (0, $8BE50$react).createElement("input", {
147
- key: i,
148
- ...inputProps,
149
- ref: i === 0 ? inputRef : null
150
- });
151
- });
152
- return /*#__PURE__*/ (0, $8BE50$react).createElement((0, $8BE50$react).Fragment, null, res);
153
- }
154
- return null;
155
- }
156
-
157
-
158
- export {$bdd25dc72710631f$export$f809e80f58e251d1 as useHiddenSelect, $bdd25dc72710631f$export$cbd84cdb2e668835 as HiddenSelect};
159
- //# sourceMappingURL=HiddenSelect.module.js.map