@react-stately/toggle 3.7.1 → 3.7.3

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,16 +1,6 @@
1
- import {useControlledState as $bOkae$useControlledState} from "@react-stately/utils";
1
+ import {useToggleState as $3017fa7ffdddec74$export$8042c6c013fd5226} from "./useToggleState.mjs";
2
2
 
3
3
  /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */ /*
14
4
  * Copyright 2020 Adobe. All rights reserved.
15
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -21,25 +11,6 @@ import {useControlledState as $bOkae$useControlledState} from "@react-stately/ut
21
11
  * OF ANY KIND, either express or implied. See the License for the specific language
22
12
  * governing permissions and limitations under the License.
23
13
  */
24
- function $3017fa7ffdddec74$export$8042c6c013fd5226(props = {}) {
25
- let { isReadOnly: isReadOnly } = props;
26
- // have to provide an empty function so useControlledState doesn't throw a fit
27
- // can't use useControlledState's prop calling because we need the event object from the change
28
- let [isSelected, setSelected] = (0, $bOkae$useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
29
- function updateSelected(value) {
30
- if (!isReadOnly) setSelected(value);
31
- }
32
- function toggleState() {
33
- if (!isReadOnly) setSelected(!isSelected);
34
- }
35
- return {
36
- isSelected: isSelected,
37
- setSelected: updateSelected,
38
- toggle: toggleState
39
- };
40
- }
41
-
42
-
43
14
 
44
15
 
45
16
  export {$3017fa7ffdddec74$export$8042c6c013fd5226 as useToggleState};
package/dist/main.js CHANGED
@@ -1,22 +1,12 @@
1
- var $2JeFo$reactstatelyutils = require("@react-stately/utils");
1
+ var $d84f98b140466b44$exports = require("./useToggleState.main.js");
2
2
 
3
3
 
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
7
 
8
- $parcel$export(module.exports, "useToggleState", () => $d84f98b140466b44$export$8042c6c013fd5226);
8
+ $parcel$export(module.exports, "useToggleState", () => $d84f98b140466b44$exports.useToggleState);
9
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
10
  * Copyright 2020 Adobe. All rights reserved.
21
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
22
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -27,25 +17,6 @@ $parcel$export(module.exports, "useToggleState", () => $d84f98b140466b44$export$
27
17
  * OF ANY KIND, either express or implied. See the License for the specific language
28
18
  * governing permissions and limitations under the License.
29
19
  */
30
- function $d84f98b140466b44$export$8042c6c013fd5226(props = {}) {
31
- let { isReadOnly: isReadOnly } = props;
32
- // have to provide an empty function so useControlledState doesn't throw a fit
33
- // can't use useControlledState's prop calling because we need the event object from the change
34
- let [isSelected, setSelected] = (0, $2JeFo$reactstatelyutils.useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
35
- function updateSelected(value) {
36
- if (!isReadOnly) setSelected(value);
37
- }
38
- function toggleState() {
39
- if (!isReadOnly) setSelected(!isSelected);
40
- }
41
- return {
42
- isSelected: isSelected,
43
- setSelected: updateSelected,
44
- toggle: toggleState
45
- };
46
- }
47
-
48
-
49
20
 
50
21
 
51
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAqBM,SAAS,0CAAe,QAA4B,CAAC,CAAC;IAC3D,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,8EAA8E;IAC9E,+FAA+F;IAC/F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,UAAU,EAAE,MAAM,eAAe,IAAI,OAAO,MAAM,QAAQ;IAEnH,SAAS,eAAe,KAAK;QAC3B,IAAI,CAAC,YACH,YAAY;IAEhB;IAEA,SAAS;QACP,IAAI,CAAC,YACH,YAAY,CAAC;IAEjB;IAEA,OAAO;oBACL;QACA,aAAa;QACb,QAAQ;IACV;AACF;;CD7CC","sources":["packages/@react-stately/toggle/src/index.ts","packages/@react-stately/toggle/src/useToggleState.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 {useToggleState} from './useToggleState';\n\nexport type {ToggleProps} from '@react-types/checkbox';\nexport type {ToggleState, ToggleStateOptions} from './useToggleState';\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 {ToggleProps} from '@react-types/checkbox';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ToggleStateOptions extends Omit<ToggleProps, 'children'> {}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: boolean,\n\n /** Updates selection state. */\n setSelected(isSelected: boolean): void,\n\n /** Toggle the selection state. */\n toggle(): void\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function useToggleState(props: ToggleStateOptions = {}): ToggleState {\n let {isReadOnly} = props;\n\n // have to provide an empty function so useControlledState doesn't throw a fit\n // can't use useControlledState's prop calling because we need the event object from the change\n let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(!isSelected);\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/toggle/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 {useToggleState} from './useToggleState';\n\nexport type {ToggleProps} from '@react-types/checkbox';\nexport type {ToggleState, ToggleStateOptions} from './useToggleState';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,16 +1,6 @@
1
- import {useControlledState as $bOkae$useControlledState} from "@react-stately/utils";
1
+ import {useToggleState as $3017fa7ffdddec74$export$8042c6c013fd5226} from "./useToggleState.module.js";
2
2
 
3
3
  /*
4
- * Copyright 2020 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */ /*
14
4
  * Copyright 2020 Adobe. All rights reserved.
15
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -21,25 +11,6 @@ import {useControlledState as $bOkae$useControlledState} from "@react-stately/ut
21
11
  * OF ANY KIND, either express or implied. See the License for the specific language
22
12
  * governing permissions and limitations under the License.
23
13
  */
24
- function $3017fa7ffdddec74$export$8042c6c013fd5226(props = {}) {
25
- let { isReadOnly: isReadOnly } = props;
26
- // have to provide an empty function so useControlledState doesn't throw a fit
27
- // can't use useControlledState's prop calling because we need the event object from the change
28
- let [isSelected, setSelected] = (0, $bOkae$useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
29
- function updateSelected(value) {
30
- if (!isReadOnly) setSelected(value);
31
- }
32
- function toggleState() {
33
- if (!isReadOnly) setSelected(!isSelected);
34
- }
35
- return {
36
- isSelected: isSelected,
37
- setSelected: updateSelected,
38
- toggle: toggleState
39
- };
40
- }
41
-
42
-
43
14
 
44
15
 
45
16
  export {$3017fa7ffdddec74$export$8042c6c013fd5226 as useToggleState};
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;AAqBM,SAAS,0CAAe,QAA4B,CAAC,CAAC;IAC3D,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,8EAA8E;IAC9E,+FAA+F;IAC/F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,UAAU,EAAE,MAAM,eAAe,IAAI,OAAO,MAAM,QAAQ;IAEnH,SAAS,eAAe,KAAK;QAC3B,IAAI,CAAC,YACH,YAAY;IAEhB;IAEA,SAAS;QACP,IAAI,CAAC,YACH,YAAY,CAAC;IAEjB;IAEA,OAAO;oBACL;QACA,aAAa;QACb,QAAQ;IACV;AACF;;CD7CC","sources":["packages/@react-stately/toggle/src/index.ts","packages/@react-stately/toggle/src/useToggleState.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 {useToggleState} from './useToggleState';\n\nexport type {ToggleProps} from '@react-types/checkbox';\nexport type {ToggleState, ToggleStateOptions} from './useToggleState';\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 {ToggleProps} from '@react-types/checkbox';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ToggleStateOptions extends Omit<ToggleProps, 'children'> {}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: boolean,\n\n /** Updates selection state. */\n setSelected(isSelected: boolean): void,\n\n /** Toggle the selection state. */\n toggle(): void\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function useToggleState(props: ToggleStateOptions = {}): ToggleState {\n let {isReadOnly} = props;\n\n // have to provide an empty function so useControlledState doesn't throw a fit\n // can't use useControlledState's prop calling because we need the event object from the change\n let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(!isSelected);\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-stately/toggle/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 {useToggleState} from './useToggleState';\n\nexport type {ToggleProps} from '@react-types/checkbox';\nexport type {ToggleState, ToggleStateOptions} from './useToggleState';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,39 @@
1
+ var $g7qpO$reactstatelyutils = require("@react-stately/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useToggleState", () => $d84f98b140466b44$export$8042c6c013fd5226);
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
+ function $d84f98b140466b44$export$8042c6c013fd5226(props = {}) {
21
+ let { isReadOnly: isReadOnly } = props;
22
+ // have to provide an empty function so useControlledState doesn't throw a fit
23
+ // can't use useControlledState's prop calling because we need the event object from the change
24
+ let [isSelected, setSelected] = (0, $g7qpO$reactstatelyutils.useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
25
+ function updateSelected(value) {
26
+ if (!isReadOnly) setSelected(value);
27
+ }
28
+ function toggleState() {
29
+ if (!isReadOnly) setSelected(!isSelected);
30
+ }
31
+ return {
32
+ isSelected: isSelected,
33
+ setSelected: updateSelected,
34
+ toggle: toggleState
35
+ };
36
+ }
37
+
38
+
39
+ //# sourceMappingURL=useToggleState.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAqBM,SAAS,0CAAe,QAA4B,CAAC,CAAC;IAC3D,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,8EAA8E;IAC9E,+FAA+F;IAC/F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,2CAAiB,EAAE,MAAM,UAAU,EAAE,MAAM,eAAe,IAAI,OAAO,MAAM,QAAQ;IAEnH,SAAS,eAAe,KAAK;QAC3B,IAAI,CAAC,YACH,YAAY;IAEhB;IAEA,SAAS;QACP,IAAI,CAAC,YACH,YAAY,CAAC;IAEjB;IAEA,OAAO;oBACL;QACA,aAAa;QACb,QAAQ;IACV;AACF","sources":["packages/@react-stately/toggle/src/useToggleState.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 {ToggleProps} from '@react-types/checkbox';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ToggleStateOptions extends Omit<ToggleProps, 'children'> {}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: boolean,\n\n /** Updates selection state. */\n setSelected(isSelected: boolean): void,\n\n /** Toggle the selection state. */\n toggle(): void\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function useToggleState(props: ToggleStateOptions = {}): ToggleState {\n let {isReadOnly} = props;\n\n // have to provide an empty function so useControlledState doesn't throw a fit\n // can't use useControlledState's prop calling because we need the event object from the change\n let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(!isSelected);\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":[],"version":3,"file":"useToggleState.main.js.map"}
@@ -0,0 +1,34 @@
1
+ import {useControlledState as $d8rik$useControlledState} from "@react-stately/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $3017fa7ffdddec74$export$8042c6c013fd5226(props = {}) {
15
+ let { isReadOnly: isReadOnly } = props;
16
+ // have to provide an empty function so useControlledState doesn't throw a fit
17
+ // can't use useControlledState's prop calling because we need the event object from the change
18
+ let [isSelected, setSelected] = (0, $d8rik$useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
19
+ function updateSelected(value) {
20
+ if (!isReadOnly) setSelected(value);
21
+ }
22
+ function toggleState() {
23
+ if (!isReadOnly) setSelected(!isSelected);
24
+ }
25
+ return {
26
+ isSelected: isSelected,
27
+ setSelected: updateSelected,
28
+ toggle: toggleState
29
+ };
30
+ }
31
+
32
+
33
+ export {$3017fa7ffdddec74$export$8042c6c013fd5226 as useToggleState};
34
+ //# sourceMappingURL=useToggleState.mjs.map
@@ -0,0 +1,34 @@
1
+ import {useControlledState as $d8rik$useControlledState} from "@react-stately/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $3017fa7ffdddec74$export$8042c6c013fd5226(props = {}) {
15
+ let { isReadOnly: isReadOnly } = props;
16
+ // have to provide an empty function so useControlledState doesn't throw a fit
17
+ // can't use useControlledState's prop calling because we need the event object from the change
18
+ let [isSelected, setSelected] = (0, $d8rik$useControlledState)(props.isSelected, props.defaultSelected || false, props.onChange);
19
+ function updateSelected(value) {
20
+ if (!isReadOnly) setSelected(value);
21
+ }
22
+ function toggleState() {
23
+ if (!isReadOnly) setSelected(!isSelected);
24
+ }
25
+ return {
26
+ isSelected: isSelected,
27
+ setSelected: updateSelected,
28
+ toggle: toggleState
29
+ };
30
+ }
31
+
32
+
33
+ export {$3017fa7ffdddec74$export$8042c6c013fd5226 as useToggleState};
34
+ //# sourceMappingURL=useToggleState.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAqBM,SAAS,0CAAe,QAA4B,CAAC,CAAC;IAC3D,IAAI,cAAC,UAAU,EAAC,GAAG;IAEnB,8EAA8E;IAC9E,+FAA+F;IAC/F,IAAI,CAAC,YAAY,YAAY,GAAG,CAAA,GAAA,yBAAiB,EAAE,MAAM,UAAU,EAAE,MAAM,eAAe,IAAI,OAAO,MAAM,QAAQ;IAEnH,SAAS,eAAe,KAAK;QAC3B,IAAI,CAAC,YACH,YAAY;IAEhB;IAEA,SAAS;QACP,IAAI,CAAC,YACH,YAAY,CAAC;IAEjB;IAEA,OAAO;oBACL;QACA,aAAa;QACb,QAAQ;IACV;AACF","sources":["packages/@react-stately/toggle/src/useToggleState.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 {ToggleProps} from '@react-types/checkbox';\nimport {useControlledState} from '@react-stately/utils';\n\nexport interface ToggleStateOptions extends Omit<ToggleProps, 'children'> {}\n\nexport interface ToggleState {\n /** Whether the toggle is selected. */\n readonly isSelected: boolean,\n\n /** Updates selection state. */\n setSelected(isSelected: boolean): void,\n\n /** Toggle the selection state. */\n toggle(): void\n}\n\n/**\n * Provides state management for toggle components like checkboxes and switches.\n */\nexport function useToggleState(props: ToggleStateOptions = {}): ToggleState {\n let {isReadOnly} = props;\n\n // have to provide an empty function so useControlledState doesn't throw a fit\n // can't use useControlledState's prop calling because we need the event object from the change\n let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(!isSelected);\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":[],"version":3,"file":"useToggleState.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/toggle",
3
- "version": "3.7.1",
3
+ "version": "3.7.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,8 +22,8 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/utils": "^3.9.0",
26
- "@react-types/checkbox": "^3.7.0",
25
+ "@react-stately/utils": "^3.10.0",
26
+ "@react-types/checkbox": "^3.8.0",
27
27
  "@swc/helpers": "^0.5.0"
28
28
  },
29
29
  "peerDependencies": {
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "f040ff62678e6a31375b96c05396df0bae660350"
35
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
36
36
  }