@react-stately/select 3.6.3-nightly.4552 → 3.6.3-nightly.4558

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,19 +1,6 @@
1
- import {useFormValidationState as $e17gp$useFormValidationState} from "@react-stately/form";
2
- import {useOverlayTriggerState as $e17gp$useOverlayTriggerState} from "@react-stately/overlays";
3
- import {useSingleSelectListState as $e17gp$useSingleSelectListState} from "@react-stately/list";
4
- import {useState as $e17gp$useState} from "react";
1
+ import {useSelectState as $2bc3a590c5373a4e$export$5159ec8b34d4ec12} from "./useSelectState.mjs";
5
2
 
6
3
  /*
7
- * Copyright 2020 Adobe. All rights reserved.
8
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License. You may obtain a copy
10
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software distributed under
13
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
- * OF ANY KIND, either express or implied. See the License for the specific language
15
- * governing permissions and limitations under the License.
16
- */ /*
17
4
  * Copyright 2020 Adobe. All rights reserved.
18
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -26,48 +13,5 @@ import {useState as $e17gp$useState} from "react";
26
13
  */
27
14
 
28
15
 
29
-
30
- function $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props) {
31
- let triggerState = (0, $e17gp$useOverlayTriggerState)(props);
32
- let [focusStrategy, setFocusStrategy] = (0, $e17gp$useState)(null);
33
- let listState = (0, $e17gp$useSingleSelectListState)({
34
- ...props,
35
- onSelectionChange: (key)=>{
36
- if (props.onSelectionChange != null) props.onSelectionChange(key);
37
- triggerState.close();
38
- validationState.commitValidation();
39
- }
40
- });
41
- let validationState = (0, $e17gp$useFormValidationState)({
42
- ...props,
43
- value: listState.selectedKey
44
- });
45
- let [isFocused, setFocused] = (0, $e17gp$useState)(false);
46
- return {
47
- ...validationState,
48
- ...listState,
49
- ...triggerState,
50
- focusStrategy: focusStrategy,
51
- open (focusStrategy = null) {
52
- // Don't open if the collection is empty.
53
- if (listState.collection.size !== 0) {
54
- setFocusStrategy(focusStrategy);
55
- triggerState.open();
56
- }
57
- },
58
- toggle (focusStrategy = null) {
59
- if (listState.collection.size !== 0) {
60
- setFocusStrategy(focusStrategy);
61
- triggerState.toggle();
62
- }
63
- },
64
- isFocused: isFocused,
65
- setFocused: setFocused
66
- };
67
- }
68
-
69
-
70
-
71
-
72
16
  export {$2bc3a590c5373a4e$export$5159ec8b34d4ec12 as useSelectState};
73
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,25 +1,12 @@
1
- var $aJE2N$reactstatelyform = require("@react-stately/form");
2
- var $aJE2N$reactstatelyoverlays = require("@react-stately/overlays");
3
- var $aJE2N$reactstatelylist = require("@react-stately/list");
4
- var $aJE2N$react = require("react");
1
+ var $80ebb60e77198879$exports = require("./useSelectState.main.js");
5
2
 
6
3
 
7
4
  function $parcel$export(e, n, v, s) {
8
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
6
  }
10
7
 
11
- $parcel$export(module.exports, "useSelectState", () => $80ebb60e77198879$export$5159ec8b34d4ec12);
8
+ $parcel$export(module.exports, "useSelectState", () => $80ebb60e77198879$exports.useSelectState);
12
9
  /*
13
- * Copyright 2020 Adobe. All rights reserved.
14
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
- * you may not use this file except in compliance with the License. You may obtain a copy
16
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
- *
18
- * Unless required by applicable law or agreed to in writing, software distributed under
19
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
- * OF ANY KIND, either express or implied. See the License for the specific language
21
- * governing permissions and limitations under the License.
22
- */ /*
23
10
  * Copyright 2020 Adobe. All rights reserved.
24
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -32,47 +19,4 @@ $parcel$export(module.exports, "useSelectState", () => $80ebb60e77198879$export$
32
19
  */
33
20
 
34
21
 
35
-
36
- function $80ebb60e77198879$export$5159ec8b34d4ec12(props) {
37
- let triggerState = (0, $aJE2N$reactstatelyoverlays.useOverlayTriggerState)(props);
38
- let [focusStrategy, setFocusStrategy] = (0, $aJE2N$react.useState)(null);
39
- let listState = (0, $aJE2N$reactstatelylist.useSingleSelectListState)({
40
- ...props,
41
- onSelectionChange: (key)=>{
42
- if (props.onSelectionChange != null) props.onSelectionChange(key);
43
- triggerState.close();
44
- validationState.commitValidation();
45
- }
46
- });
47
- let validationState = (0, $aJE2N$reactstatelyform.useFormValidationState)({
48
- ...props,
49
- value: listState.selectedKey
50
- });
51
- let [isFocused, setFocused] = (0, $aJE2N$react.useState)(false);
52
- return {
53
- ...validationState,
54
- ...listState,
55
- ...triggerState,
56
- focusStrategy: focusStrategy,
57
- open (focusStrategy = null) {
58
- // Don't open if the collection is empty.
59
- if (listState.collection.size !== 0) {
60
- setFocusStrategy(focusStrategy);
61
- triggerState.open();
62
- }
63
- },
64
- toggle (focusStrategy = null) {
65
- if (listState.collection.size !== 0) {
66
- setFocusStrategy(focusStrategy);
67
- triggerState.toggle();
68
- }
69
- },
70
- isFocused: isFocused,
71
- setFocused: setFocused
72
- };
73
- }
74
-
75
-
76
-
77
-
78
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAiC,KAA4B;IAC3E,IAAI,eAAe,CAAA,GAAA,kDAAqB,EAAE;IAC1C,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAChE,IAAI,YAAY,CAAA,GAAA,gDAAuB,EAAE;QACvC,GAAG,KAAK;QACR,mBAAmB,CAAC;YAClB,IAAI,MAAM,iBAAiB,IAAI,MAC7B,MAAM,iBAAiB,CAAC;YAG1B,aAAa,KAAK;YAClB,gBAAgB,gBAAgB;QAClC;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,8CAAqB,EAAE;QAC3C,GAAG,KAAK;QACR,OAAO,UAAU,WAAW;IAC9B;IAEA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEvC,OAAO;QACL,GAAG,eAAe;QAClB,GAAG,SAAS;QACZ,GAAG,YAAY;uBACf;QACA,MAAK,gBAA+B,IAAI;YACtC,yCAAyC;YACzC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,IAAI;YACnB;QACF;QACA,QAAO,gBAA+B,IAAI;YACxC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,MAAM;YACrB;QACF;mBACA;oBACA;IACF;AACF;;CD5EC","sources":["packages/@react-stately/select/src/index.ts","packages/@react-stately/select/src/useSelectState.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\nexport {useSelectState} from './useSelectState';\n\nexport type {SelectProps} from '@react-types/select';\nexport type {SelectState, SelectStateOptions} from './useSelectState';\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 {CollectionStateBase, FocusStrategy} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {SelectProps} from '@react-types/select';\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {useState} from 'react';\n\nexport interface SelectStateOptions<T> extends Omit<SelectProps<T>, 'children'>, CollectionStateBase<T> {}\n\nexport interface SelectState<T> extends SingleSelectListState<T>, OverlayTriggerState, FormValidationState {\n /** Whether the select is currently focused. */\n readonly isFocused: boolean,\n\n /** Sets whether the select is focused. */\n setFocused(isFocused: boolean): void,\n\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\n/**\n * Provides state management for a select component. Handles building a collection\n * of items from props, handles the open state for the popup menu, and manages\n * multiple selection state.\n */\nexport function useSelectState<T extends object>(props: SelectStateOptions<T>): SelectState<T> {\n let triggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let listState = useSingleSelectListState({\n ...props,\n onSelectionChange: (key) => {\n if (props.onSelectionChange != null) {\n props.onSelectionChange(key);\n }\n\n triggerState.close();\n validationState.commitValidation();\n }\n });\n\n let validationState = useFormValidationState({\n ...props,\n value: listState.selectedKey\n });\n\n let [isFocused, setFocused] = useState(false);\n\n return {\n ...validationState,\n ...listState,\n ...triggerState,\n focusStrategy,\n open(focusStrategy: FocusStrategy = null) {\n // Don't open if the collection is empty.\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.open();\n }\n },\n toggle(focusStrategy: FocusStrategy = null) {\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.toggle();\n }\n },\n isFocused,\n setFocused\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/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 */\n\nexport {useSelectState} from './useSelectState';\n\nexport type {SelectProps} from '@react-types/select';\nexport type {SelectState, SelectStateOptions} from './useSelectState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,19 +1,6 @@
1
- import {useFormValidationState as $e17gp$useFormValidationState} from "@react-stately/form";
2
- import {useOverlayTriggerState as $e17gp$useOverlayTriggerState} from "@react-stately/overlays";
3
- import {useSingleSelectListState as $e17gp$useSingleSelectListState} from "@react-stately/list";
4
- import {useState as $e17gp$useState} from "react";
1
+ import {useSelectState as $2bc3a590c5373a4e$export$5159ec8b34d4ec12} from "./useSelectState.module.js";
5
2
 
6
3
  /*
7
- * Copyright 2020 Adobe. All rights reserved.
8
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License. You may obtain a copy
10
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software distributed under
13
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
- * OF ANY KIND, either express or implied. See the License for the specific language
15
- * governing permissions and limitations under the License.
16
- */ /*
17
4
  * Copyright 2020 Adobe. All rights reserved.
18
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
19
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -26,48 +13,5 @@ import {useState as $e17gp$useState} from "react";
26
13
  */
27
14
 
28
15
 
29
-
30
- function $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props) {
31
- let triggerState = (0, $e17gp$useOverlayTriggerState)(props);
32
- let [focusStrategy, setFocusStrategy] = (0, $e17gp$useState)(null);
33
- let listState = (0, $e17gp$useSingleSelectListState)({
34
- ...props,
35
- onSelectionChange: (key)=>{
36
- if (props.onSelectionChange != null) props.onSelectionChange(key);
37
- triggerState.close();
38
- validationState.commitValidation();
39
- }
40
- });
41
- let validationState = (0, $e17gp$useFormValidationState)({
42
- ...props,
43
- value: listState.selectedKey
44
- });
45
- let [isFocused, setFocused] = (0, $e17gp$useState)(false);
46
- return {
47
- ...validationState,
48
- ...listState,
49
- ...triggerState,
50
- focusStrategy: focusStrategy,
51
- open (focusStrategy = null) {
52
- // Don't open if the collection is empty.
53
- if (listState.collection.size !== 0) {
54
- setFocusStrategy(focusStrategy);
55
- triggerState.open();
56
- }
57
- },
58
- toggle (focusStrategy = null) {
59
- if (listState.collection.size !== 0) {
60
- setFocusStrategy(focusStrategy);
61
- triggerState.toggle();
62
- }
63
- },
64
- isFocused: isFocused,
65
- setFocused: setFocused
66
- };
67
- }
68
-
69
-
70
-
71
-
72
16
  export {$2bc3a590c5373a4e$export$5159ec8b34d4ec12 as useSelectState};
73
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAiC,KAA4B;IAC3E,IAAI,eAAe,CAAA,GAAA,6BAAqB,EAAE;IAC1C,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAiB;IAChE,IAAI,YAAY,CAAA,GAAA,+BAAuB,EAAE;QACvC,GAAG,KAAK;QACR,mBAAmB,CAAC;YAClB,IAAI,MAAM,iBAAiB,IAAI,MAC7B,MAAM,iBAAiB,CAAC;YAG1B,aAAa,KAAK;YAClB,gBAAgB,gBAAgB;QAClC;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,6BAAqB,EAAE;QAC3C,GAAG,KAAK;QACR,OAAO,UAAU,WAAW;IAC9B;IAEA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,OAAO;QACL,GAAG,eAAe;QAClB,GAAG,SAAS;QACZ,GAAG,YAAY;uBACf;QACA,MAAK,gBAA+B,IAAI;YACtC,yCAAyC;YACzC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,IAAI;YACnB;QACF;QACA,QAAO,gBAA+B,IAAI;YACxC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,MAAM;YACrB;QACF;mBACA;oBACA;IACF;AACF;;CD5EC","sources":["packages/@react-stately/select/src/index.ts","packages/@react-stately/select/src/useSelectState.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\nexport {useSelectState} from './useSelectState';\n\nexport type {SelectProps} from '@react-types/select';\nexport type {SelectState, SelectStateOptions} from './useSelectState';\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 {CollectionStateBase, FocusStrategy} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {SelectProps} from '@react-types/select';\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {useState} from 'react';\n\nexport interface SelectStateOptions<T> extends Omit<SelectProps<T>, 'children'>, CollectionStateBase<T> {}\n\nexport interface SelectState<T> extends SingleSelectListState<T>, OverlayTriggerState, FormValidationState {\n /** Whether the select is currently focused. */\n readonly isFocused: boolean,\n\n /** Sets whether the select is focused. */\n setFocused(isFocused: boolean): void,\n\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\n/**\n * Provides state management for a select component. Handles building a collection\n * of items from props, handles the open state for the popup menu, and manages\n * multiple selection state.\n */\nexport function useSelectState<T extends object>(props: SelectStateOptions<T>): SelectState<T> {\n let triggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let listState = useSingleSelectListState({\n ...props,\n onSelectionChange: (key) => {\n if (props.onSelectionChange != null) {\n props.onSelectionChange(key);\n }\n\n triggerState.close();\n validationState.commitValidation();\n }\n });\n\n let validationState = useFormValidationState({\n ...props,\n value: listState.selectedKey\n });\n\n let [isFocused, setFocused] = useState(false);\n\n return {\n ...validationState,\n ...listState,\n ...triggerState,\n focusStrategy,\n open(focusStrategy: FocusStrategy = null) {\n // Don't open if the collection is empty.\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.open();\n }\n },\n toggle(focusStrategy: FocusStrategy = null) {\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.toggle();\n }\n },\n isFocused,\n setFocused\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/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 */\n\nexport {useSelectState} from './useSelectState';\n\nexport type {SelectProps} from '@react-types/select';\nexport type {SelectState, SelectStateOptions} from './useSelectState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,66 @@
1
+ var $5KJtg$reactstatelyform = require("@react-stately/form");
2
+ var $5KJtg$reactstatelyoverlays = require("@react-stately/overlays");
3
+ var $5KJtg$reactstatelylist = require("@react-stately/list");
4
+ var $5KJtg$react = require("react");
5
+
6
+
7
+ function $parcel$export(e, n, v, s) {
8
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
+ }
10
+
11
+ $parcel$export(module.exports, "useSelectState", () => $80ebb60e77198879$export$5159ec8b34d4ec12);
12
+ /*
13
+ * Copyright 2020 Adobe. All rights reserved.
14
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License. You may obtain a copy
16
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software distributed under
19
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
20
+ * OF ANY KIND, either express or implied. See the License for the specific language
21
+ * governing permissions and limitations under the License.
22
+ */
23
+
24
+
25
+
26
+ function $80ebb60e77198879$export$5159ec8b34d4ec12(props) {
27
+ let triggerState = (0, $5KJtg$reactstatelyoverlays.useOverlayTriggerState)(props);
28
+ let [focusStrategy, setFocusStrategy] = (0, $5KJtg$react.useState)(null);
29
+ let listState = (0, $5KJtg$reactstatelylist.useSingleSelectListState)({
30
+ ...props,
31
+ onSelectionChange: (key)=>{
32
+ if (props.onSelectionChange != null) props.onSelectionChange(key);
33
+ triggerState.close();
34
+ validationState.commitValidation();
35
+ }
36
+ });
37
+ let validationState = (0, $5KJtg$reactstatelyform.useFormValidationState)({
38
+ ...props,
39
+ value: listState.selectedKey
40
+ });
41
+ let [isFocused, setFocused] = (0, $5KJtg$react.useState)(false);
42
+ return {
43
+ ...validationState,
44
+ ...listState,
45
+ ...triggerState,
46
+ focusStrategy: focusStrategy,
47
+ open (focusStrategy = null) {
48
+ // Don't open if the collection is empty.
49
+ if (listState.collection.size !== 0) {
50
+ setFocusStrategy(focusStrategy);
51
+ triggerState.open();
52
+ }
53
+ },
54
+ toggle (focusStrategy = null) {
55
+ if (listState.collection.size !== 0) {
56
+ setFocusStrategy(focusStrategy);
57
+ triggerState.toggle();
58
+ }
59
+ },
60
+ isFocused: isFocused,
61
+ setFocused: setFocused
62
+ };
63
+ }
64
+
65
+
66
+ //# sourceMappingURL=useSelectState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAiC,KAA4B;IAC3E,IAAI,eAAe,CAAA,GAAA,kDAAqB,EAAE;IAC1C,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,qBAAO,EAAiB;IAChE,IAAI,YAAY,CAAA,GAAA,gDAAuB,EAAE;QACvC,GAAG,KAAK;QACR,mBAAmB,CAAC;YAClB,IAAI,MAAM,iBAAiB,IAAI,MAC7B,MAAM,iBAAiB,CAAC;YAG1B,aAAa,KAAK;YAClB,gBAAgB,gBAAgB;QAClC;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,8CAAqB,EAAE;QAC3C,GAAG,KAAK;QACR,OAAO,UAAU,WAAW;IAC9B;IAEA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,qBAAO,EAAE;IAEvC,OAAO;QACL,GAAG,eAAe;QAClB,GAAG,SAAS;QACZ,GAAG,YAAY;uBACf;QACA,MAAK,gBAA+B,IAAI;YACtC,yCAAyC;YACzC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,IAAI;YACnB;QACF;QACA,QAAO,gBAA+B,IAAI;YACxC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,MAAM;YACrB;QACF;mBACA;oBACA;IACF;AACF","sources":["packages/@react-stately/select/src/useSelectState.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 {CollectionStateBase, FocusStrategy} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {SelectProps} from '@react-types/select';\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {useState} from 'react';\n\nexport interface SelectStateOptions<T> extends Omit<SelectProps<T>, 'children'>, CollectionStateBase<T> {}\n\nexport interface SelectState<T> extends SingleSelectListState<T>, OverlayTriggerState, FormValidationState {\n /** Whether the select is currently focused. */\n readonly isFocused: boolean,\n\n /** Sets whether the select is focused. */\n setFocused(isFocused: boolean): void,\n\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\n/**\n * Provides state management for a select component. Handles building a collection\n * of items from props, handles the open state for the popup menu, and manages\n * multiple selection state.\n */\nexport function useSelectState<T extends object>(props: SelectStateOptions<T>): SelectState<T> {\n let triggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let listState = useSingleSelectListState({\n ...props,\n onSelectionChange: (key) => {\n if (props.onSelectionChange != null) {\n props.onSelectionChange(key);\n }\n\n triggerState.close();\n validationState.commitValidation();\n }\n });\n\n let validationState = useFormValidationState({\n ...props,\n value: listState.selectedKey\n });\n\n let [isFocused, setFocused] = useState(false);\n\n return {\n ...validationState,\n ...listState,\n ...triggerState,\n focusStrategy,\n open(focusStrategy: FocusStrategy = null) {\n // Don't open if the collection is empty.\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.open();\n }\n },\n toggle(focusStrategy: FocusStrategy = null) {\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.toggle();\n }\n },\n isFocused,\n setFocused\n };\n}\n"],"names":[],"version":3,"file":"useSelectState.main.js.map"}
@@ -0,0 +1,61 @@
1
+ import {useFormValidationState as $6FfNf$useFormValidationState} from "@react-stately/form";
2
+ import {useOverlayTriggerState as $6FfNf$useOverlayTriggerState} from "@react-stately/overlays";
3
+ import {useSingleSelectListState as $6FfNf$useSingleSelectListState} from "@react-stately/list";
4
+ import {useState as $6FfNf$useState} from "react";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ function $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props) {
21
+ let triggerState = (0, $6FfNf$useOverlayTriggerState)(props);
22
+ let [focusStrategy, setFocusStrategy] = (0, $6FfNf$useState)(null);
23
+ let listState = (0, $6FfNf$useSingleSelectListState)({
24
+ ...props,
25
+ onSelectionChange: (key)=>{
26
+ if (props.onSelectionChange != null) props.onSelectionChange(key);
27
+ triggerState.close();
28
+ validationState.commitValidation();
29
+ }
30
+ });
31
+ let validationState = (0, $6FfNf$useFormValidationState)({
32
+ ...props,
33
+ value: listState.selectedKey
34
+ });
35
+ let [isFocused, setFocused] = (0, $6FfNf$useState)(false);
36
+ return {
37
+ ...validationState,
38
+ ...listState,
39
+ ...triggerState,
40
+ focusStrategy: focusStrategy,
41
+ open (focusStrategy = null) {
42
+ // Don't open if the collection is empty.
43
+ if (listState.collection.size !== 0) {
44
+ setFocusStrategy(focusStrategy);
45
+ triggerState.open();
46
+ }
47
+ },
48
+ toggle (focusStrategy = null) {
49
+ if (listState.collection.size !== 0) {
50
+ setFocusStrategy(focusStrategy);
51
+ triggerState.toggle();
52
+ }
53
+ },
54
+ isFocused: isFocused,
55
+ setFocused: setFocused
56
+ };
57
+ }
58
+
59
+
60
+ export {$2bc3a590c5373a4e$export$5159ec8b34d4ec12 as useSelectState};
61
+ //# sourceMappingURL=useSelectState.mjs.map
@@ -0,0 +1,61 @@
1
+ import {useFormValidationState as $6FfNf$useFormValidationState} from "@react-stately/form";
2
+ import {useOverlayTriggerState as $6FfNf$useOverlayTriggerState} from "@react-stately/overlays";
3
+ import {useSingleSelectListState as $6FfNf$useSingleSelectListState} from "@react-stately/list";
4
+ import {useState as $6FfNf$useState} from "react";
5
+
6
+ /*
7
+ * Copyright 2020 Adobe. All rights reserved.
8
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License. You may obtain a copy
10
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software distributed under
13
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
14
+ * OF ANY KIND, either express or implied. See the License for the specific language
15
+ * governing permissions and limitations under the License.
16
+ */
17
+
18
+
19
+
20
+ function $2bc3a590c5373a4e$export$5159ec8b34d4ec12(props) {
21
+ let triggerState = (0, $6FfNf$useOverlayTriggerState)(props);
22
+ let [focusStrategy, setFocusStrategy] = (0, $6FfNf$useState)(null);
23
+ let listState = (0, $6FfNf$useSingleSelectListState)({
24
+ ...props,
25
+ onSelectionChange: (key)=>{
26
+ if (props.onSelectionChange != null) props.onSelectionChange(key);
27
+ triggerState.close();
28
+ validationState.commitValidation();
29
+ }
30
+ });
31
+ let validationState = (0, $6FfNf$useFormValidationState)({
32
+ ...props,
33
+ value: listState.selectedKey
34
+ });
35
+ let [isFocused, setFocused] = (0, $6FfNf$useState)(false);
36
+ return {
37
+ ...validationState,
38
+ ...listState,
39
+ ...triggerState,
40
+ focusStrategy: focusStrategy,
41
+ open (focusStrategy = null) {
42
+ // Don't open if the collection is empty.
43
+ if (listState.collection.size !== 0) {
44
+ setFocusStrategy(focusStrategy);
45
+ triggerState.open();
46
+ }
47
+ },
48
+ toggle (focusStrategy = null) {
49
+ if (listState.collection.size !== 0) {
50
+ setFocusStrategy(focusStrategy);
51
+ triggerState.toggle();
52
+ }
53
+ },
54
+ isFocused: isFocused,
55
+ setFocused: setFocused
56
+ };
57
+ }
58
+
59
+
60
+ export {$2bc3a590c5373a4e$export$5159ec8b34d4ec12 as useSelectState};
61
+ //# sourceMappingURL=useSelectState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAiCM,SAAS,0CAAiC,KAA4B;IAC3E,IAAI,eAAe,CAAA,GAAA,6BAAqB,EAAE;IAC1C,IAAI,CAAC,eAAe,iBAAiB,GAAG,CAAA,GAAA,eAAO,EAAiB;IAChE,IAAI,YAAY,CAAA,GAAA,+BAAuB,EAAE;QACvC,GAAG,KAAK;QACR,mBAAmB,CAAC;YAClB,IAAI,MAAM,iBAAiB,IAAI,MAC7B,MAAM,iBAAiB,CAAC;YAG1B,aAAa,KAAK;YAClB,gBAAgB,gBAAgB;QAClC;IACF;IAEA,IAAI,kBAAkB,CAAA,GAAA,6BAAqB,EAAE;QAC3C,GAAG,KAAK;QACR,OAAO,UAAU,WAAW;IAC9B;IAEA,IAAI,CAAC,WAAW,WAAW,GAAG,CAAA,GAAA,eAAO,EAAE;IAEvC,OAAO;QACL,GAAG,eAAe;QAClB,GAAG,SAAS;QACZ,GAAG,YAAY;uBACf;QACA,MAAK,gBAA+B,IAAI;YACtC,yCAAyC;YACzC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,IAAI;YACnB;QACF;QACA,QAAO,gBAA+B,IAAI;YACxC,IAAI,UAAU,UAAU,CAAC,IAAI,KAAK,GAAG;gBACnC,iBAAiB;gBACjB,aAAa,MAAM;YACrB;QACF;mBACA;oBACA;IACF;AACF","sources":["packages/@react-stately/select/src/useSelectState.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 {CollectionStateBase, FocusStrategy} from '@react-types/shared';\nimport {FormValidationState, useFormValidationState} from '@react-stately/form';\nimport {OverlayTriggerState, useOverlayTriggerState} from '@react-stately/overlays';\nimport {SelectProps} from '@react-types/select';\nimport {SingleSelectListState, useSingleSelectListState} from '@react-stately/list';\nimport {useState} from 'react';\n\nexport interface SelectStateOptions<T> extends Omit<SelectProps<T>, 'children'>, CollectionStateBase<T> {}\n\nexport interface SelectState<T> extends SingleSelectListState<T>, OverlayTriggerState, FormValidationState {\n /** Whether the select is currently focused. */\n readonly isFocused: boolean,\n\n /** Sets whether the select is focused. */\n setFocused(isFocused: boolean): void,\n\n /** Controls which item will be auto focused when the menu opens. */\n readonly focusStrategy: FocusStrategy,\n\n /** Opens the menu. */\n open(focusStrategy?: FocusStrategy | null): void,\n\n /** Toggles the menu. */\n toggle(focusStrategy?: FocusStrategy | null): void\n}\n\n/**\n * Provides state management for a select component. Handles building a collection\n * of items from props, handles the open state for the popup menu, and manages\n * multiple selection state.\n */\nexport function useSelectState<T extends object>(props: SelectStateOptions<T>): SelectState<T> {\n let triggerState = useOverlayTriggerState(props);\n let [focusStrategy, setFocusStrategy] = useState<FocusStrategy>(null);\n let listState = useSingleSelectListState({\n ...props,\n onSelectionChange: (key) => {\n if (props.onSelectionChange != null) {\n props.onSelectionChange(key);\n }\n\n triggerState.close();\n validationState.commitValidation();\n }\n });\n\n let validationState = useFormValidationState({\n ...props,\n value: listState.selectedKey\n });\n\n let [isFocused, setFocused] = useState(false);\n\n return {\n ...validationState,\n ...listState,\n ...triggerState,\n focusStrategy,\n open(focusStrategy: FocusStrategy = null) {\n // Don't open if the collection is empty.\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.open();\n }\n },\n toggle(focusStrategy: FocusStrategy = null) {\n if (listState.collection.size !== 0) {\n setFocusStrategy(focusStrategy);\n triggerState.toggle();\n }\n },\n isFocused,\n setFocused\n };\n}\n"],"names":[],"version":3,"file":"useSelectState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/select",
3
- "version": "3.6.3-nightly.4552+64ed13090",
3
+ "version": "3.6.3-nightly.4558+c5e4b3701",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,11 +22,11 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/form": "3.0.2-nightly.4552+64ed13090",
26
- "@react-stately/list": "3.10.4-nightly.4552+64ed13090",
27
- "@react-stately/overlays": "3.6.6-nightly.4552+64ed13090",
28
- "@react-types/select": "3.9.3-nightly.4552+64ed13090",
29
- "@react-types/shared": "3.0.0-nightly.2840+64ed13090",
25
+ "@react-stately/form": "3.0.2-nightly.4558+c5e4b3701",
26
+ "@react-stately/list": "3.10.4-nightly.4558+c5e4b3701",
27
+ "@react-stately/overlays": "3.6.6-nightly.4558+c5e4b3701",
28
+ "@react-types/select": "3.9.3-nightly.4558+c5e4b3701",
29
+ "@react-types/shared": "3.0.0-nightly.2846+c5e4b3701",
30
30
  "@swc/helpers": "^0.5.0"
31
31
  },
32
32
  "peerDependencies": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "64ed13090ce77cc0e4cb4cd5602e75f655bff6bb"
38
+ "gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
39
39
  }