@react-stately/toggle 3.2.0 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,53 +1,49 @@
1
- var {
2
- useControlledState
3
- } = require("@react-stately/utils");
4
-
5
- /**
6
- * Provides state management for toggle components like checkboxes and switches.
7
- */
8
- function useToggleState(props) {
9
- if (props === void 0) {
10
- props = {};
11
- }
12
-
13
- let {
14
- isReadOnly,
15
- onChange
16
- } = props; // 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
-
19
- let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, () => {});
20
-
21
- function updateSelected(value) {
22
- if (!isReadOnly) {
23
- setSelected(value);
24
-
25
- if (onChange) {
26
- onChange(value);
27
- }
28
- }
29
- }
1
+ var $55Cch$reactstatelyutils = require("@react-stately/utils");
30
2
 
31
- function toggleState() {
32
- if (!isReadOnly) {
33
- setSelected(prev => {
34
- let newVal = !prev;
3
+ function $parcel$exportWildcard(dest, source) {
4
+ Object.keys(source).forEach(function(key) {
5
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
6
+ return;
7
+ }
35
8
 
36
- if (onChange) {
37
- onChange(newVal);
38
- }
9
+ Object.defineProperty(dest, key, {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return source[key];
13
+ }
14
+ });
15
+ });
39
16
 
40
- return newVal;
41
- });
17
+ return dest;
18
+ }
19
+ function $parcel$export(e, n, v, s) {
20
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
21
+ }
22
+ var $311639b6a2ed1075$exports = {};
23
+
24
+ $parcel$export($311639b6a2ed1075$exports, "useToggleState", () => $311639b6a2ed1075$export$8042c6c013fd5226);
25
+
26
+ function $311639b6a2ed1075$export$8042c6c013fd5226(props = {
27
+ }) {
28
+ let { isReadOnly: isReadOnly } = props;
29
+ // have to provide an empty function so useControlledState doesn't throw a fit
30
+ // can't use useControlledState's prop calling because we need the event object from the change
31
+ let [isSelected, setSelected] = $55Cch$reactstatelyutils.useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);
32
+ function updateSelected(value) {
33
+ if (!isReadOnly) setSelected(value);
42
34
  }
43
- }
44
-
45
- return {
46
- isSelected,
47
- setSelected: updateSelected,
48
- toggle: toggleState
49
- };
35
+ function toggleState() {
36
+ if (!isReadOnly) setSelected(!isSelected);
37
+ }
38
+ return {
39
+ isSelected: isSelected,
40
+ setSelected: updateSelected,
41
+ toggle: toggleState
42
+ };
50
43
  }
51
44
 
52
- exports.useToggleState = useToggleState;
45
+
46
+ $parcel$exportWildcard(module.exports, $311639b6a2ed1075$exports);
47
+
48
+
53
49
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;AA0BA;;;AAGO,SAASA,cAAT,CAAwBC,KAAxB,EAA8D;AAAA,MAAtCA,KAAsC;AAAtCA,IAAAA,KAAsC,GAAjB,EAAiB;AAAA;;AACnE,MAAI;AAACC,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAAyBF,KAA7B,CADmE,CAGnE;AACA;;AACA,MAAI,CAACG,UAAD,EAAaC,WAAb,IAA4BC,kBAAkB,CAACL,KAAK,CAACG,UAAP,EAAmBH,KAAK,CAACM,eAAN,IAAyB,KAA5C,EAAmD,MAAM,CAAE,CAA3D,CAAlD;;AAEA,WAASC,cAAT,CAAwBC,KAAxB,EAA+B;AAC7B,QAAI,CAACP,UAAL,EAAiB;AACfG,MAAAA,WAAW,CAACI,KAAD,CAAX;;AACA,UAAIN,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAACM,KAAD,CAAR;AACD;AACF;AACF;;AAED,WAASC,WAAT,GAAuB;AACrB,QAAI,CAACR,UAAL,EAAiB;AACfG,MAAAA,WAAW,CAACM,IAAI,IAAI;AAClB,YAAIC,MAAM,GAAG,CAACD,IAAd;;AACA,YAAIR,QAAJ,EAAc;AACZA,UAAAA,QAAQ,CAACS,MAAD,CAAR;AACD;;AACD,eAAOA,MAAP;AACD,OANU,CAAX;AAOD;AACF;;AAED,SAAO;AACLR,IAAAA,UADK;AAELC,IAAAA,WAAW,EAAEG,cAFR;AAGLK,IAAAA,MAAM,EAAEH;AAHH,GAAP;AAKD","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 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: ToggleProps = {}): ToggleState {\n let {isReadOnly, onChange} = 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, () => {});\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n if (onChange) {\n onChange(value);\n }\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(prev => {\n let newVal = !prev;\n if (onChange) {\n onChange(newVal);\n }\n return newVal;\n });\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":["useToggleState","props","isReadOnly","onChange","isSelected","setSelected","useControlledState","defaultSelected","updateSelected","value","toggleState","prev","newVal","toggle"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;SC6BgB,yCAAc,CAAC,KAAkB,GAAG,CAAC;AAAA,CAAC,EAAe,CAAC;IACpE,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAExB,EAA8E,AAA9E,4EAA8E;IAC9E,EAA+F,AAA/F,6FAA+F;IAC/F,GAAG,EAAE,UAAU,EAAE,WAAW,IAAI,2CAAkB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,eAAe,IAAI,KAAK,EAAE,KAAK,CAAC,QAAQ;aAE1G,cAAc,CAAC,KAAK,EAAE,CAAC;QAC9B,EAAE,GAAG,UAAU,EACb,WAAW,CAAC,KAAK;IAErB,CAAC;aAEQ,WAAW,GAAG,CAAC;QACtB,EAAE,GAAG,UAAU,EACb,WAAW,EAAE,UAAU;IAE3B,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,WAAW,EAAE,cAAc;QAC3B,MAAM,EAAE,WAAW;IACrB,CAAC;AACH,CAAC","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 * 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 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: ToggleProps = {}): 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"}
package/dist/module.js CHANGED
@@ -1,49 +1,33 @@
1
- import { useControlledState } from "@react-stately/utils";
1
+ import {useControlledState as $cWY0e$useControlledState} from "@react-stately/utils";
2
2
 
3
- /**
4
- * Provides state management for toggle components like checkboxes and switches.
5
- */
6
- export function useToggleState(props) {
7
- if (props === void 0) {
8
- props = {};
9
- }
10
-
11
- let {
12
- isReadOnly,
13
- onChange
14
- } = props; // have to provide an empty function so useControlledState doesn't throw a fit
15
- // can't use useControlledState's prop calling because we need the event object from the change
16
-
17
- let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, () => {});
18
-
19
- function updateSelected(value) {
20
- if (!isReadOnly) {
21
- setSelected(value);
22
-
23
- if (onChange) {
24
- onChange(value);
25
- }
3
+ function $parcel$export(e, n, v, s) {
4
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
+ }
6
+ var $f47e43bfabc9ba47$exports = {};
7
+
8
+ $parcel$export($f47e43bfabc9ba47$exports, "useToggleState", () => $f47e43bfabc9ba47$export$8042c6c013fd5226);
9
+
10
+ function $f47e43bfabc9ba47$export$8042c6c013fd5226(props = {
11
+ }) {
12
+ let { isReadOnly: isReadOnly } = props;
13
+ // have to provide an empty function so useControlledState doesn't throw a fit
14
+ // can't use useControlledState's prop calling because we need the event object from the change
15
+ let [isSelected, setSelected] = $cWY0e$useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);
16
+ function updateSelected(value) {
17
+ if (!isReadOnly) setSelected(value);
26
18
  }
27
- }
19
+ function toggleState() {
20
+ if (!isReadOnly) setSelected(!isSelected);
21
+ }
22
+ return {
23
+ isSelected: isSelected,
24
+ setSelected: updateSelected,
25
+ toggle: toggleState
26
+ };
27
+ }
28
28
 
29
- function toggleState() {
30
- if (!isReadOnly) {
31
- setSelected(prev => {
32
- let newVal = !prev;
33
29
 
34
- if (onChange) {
35
- onChange(newVal);
36
- }
37
30
 
38
- return newVal;
39
- });
40
- }
41
- }
42
31
 
43
- return {
44
- isSelected,
45
- setSelected: updateSelected,
46
- toggle: toggleState
47
- };
48
- }
32
+ export {$f47e43bfabc9ba47$export$8042c6c013fd5226 as useToggleState};
49
33
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;AA0BA;;;OAGO,SAASA,cAAT,CAAwBC,KAAxB,EAA8D;AAAA,MAAtCA,KAAsC;AAAtCA,IAAAA,KAAsC,GAAjB,EAAiB;AAAA;;AACnE,MAAI;AAACC,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAAyBF,KAA7B,CADmE,CAGnE;AACA;;AACA,MAAI,CAACG,UAAD,EAAaC,WAAb,IAA4BC,kBAAkB,CAACL,KAAK,CAACG,UAAP,EAAmBH,KAAK,CAACM,eAAN,IAAyB,KAA5C,EAAmD,MAAM,CAAE,CAA3D,CAAlD;;AAEA,WAASC,cAAT,CAAwBC,KAAxB,EAA+B;AAC7B,QAAI,CAACP,UAAL,EAAiB;AACfG,MAAAA,WAAW,CAACI,KAAD,CAAX;;AACA,UAAIN,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAACM,KAAD,CAAR;AACD;AACF;AACF;;AAED,WAASC,WAAT,GAAuB;AACrB,QAAI,CAACR,UAAL,EAAiB;AACfG,MAAAA,WAAW,CAACM,IAAI,IAAI;AAClB,YAAIC,MAAM,GAAG,CAACD,IAAd;;AACA,YAAIR,QAAJ,EAAc;AACZA,UAAAA,QAAQ,CAACS,MAAD,CAAR;AACD;;AACD,eAAOA,MAAP;AACD,OANU,CAAX;AAOD;AACF;;AAED,SAAO;AACLR,IAAAA,UADK;AAELC,IAAAA,WAAW,EAAEG,cAFR;AAGLK,IAAAA,MAAM,EAAEH;AAHH,GAAP;AAKD","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 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: ToggleProps = {}): ToggleState {\n let {isReadOnly, onChange} = 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, () => {});\n\n function updateSelected(value) {\n if (!isReadOnly) {\n setSelected(value);\n if (onChange) {\n onChange(value);\n }\n }\n }\n\n function toggleState() {\n if (!isReadOnly) {\n setSelected(prev => {\n let newVal = !prev;\n if (onChange) {\n onChange(newVal);\n }\n return newVal;\n });\n }\n }\n\n return {\n isSelected,\n setSelected: updateSelected,\n toggle: toggleState\n };\n}\n"],"names":["useToggleState","props","isReadOnly","onChange","isSelected","setSelected","useControlledState","defaultSelected","updateSelected","value","toggleState","prev","newVal","toggle"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;SC6BgB,yCAAc,CAAC,KAAkB,GAAG,CAAC;AAAA,CAAC,EAAe,CAAC;IACpE,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAExB,EAA8E,AAA9E,4EAA8E;IAC9E,EAA+F,AAA/F,6FAA+F;IAC/F,GAAG,EAAE,UAAU,EAAE,WAAW,IAAI,yBAAkB,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,eAAe,IAAI,KAAK,EAAE,KAAK,CAAC,QAAQ;aAE1G,cAAc,CAAC,KAAK,EAAE,CAAC;QAC9B,EAAE,GAAG,UAAU,EACb,WAAW,CAAC,KAAK;IAErB,CAAC;aAEQ,WAAW,GAAG,CAAC;QACtB,EAAE,GAAG,UAAU,EACb,WAAW,EAAE,UAAU;IAE3B,CAAC;IAED,MAAM,CAAC,CAAC;oBACN,UAAU;QACV,WAAW,EAAE,cAAc;QAC3B,MAAM,EAAE,WAAW;IACrB,CAAC;AACH,CAAC","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 * 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 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: ToggleProps = {}): 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 +1 @@
1
- {"mappings":"A;AAeA;IACE,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,+BAA+B;IAC/B,WAAW,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvC,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAA;CACf;AAED;A;GAEG;AACH,+BAA+B,KAAK,GAAE,WAAgB,GAAG,WAAW,CAiCnE","sources":["./packages/@react-stately/toggle/src/packages/@react-stately/toggle/src/useToggleState.ts","./packages/@react-stately/toggle/src/packages/@react-stately/toggle/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";AAeA;IACE,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,+BAA+B;IAC/B,WAAW,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvC,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAA;CACf;AAED;;GAEG;AACH,+BAA+B,KAAK,GAAE,WAAgB,GAAG,WAAW,CAwBnE","sources":["packages/@react-stately/toggle/src/packages/@react-stately/toggle/src/useToggleState.ts","packages/@react-stately/toggle/src/packages/@react-stately/toggle/src/index.ts","packages/@react-stately/toggle/src/index.ts"],"sourcesContent":[null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport * from './useToggleState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/toggle",
3
- "version": "3.2.0",
3
+ "version": "3.2.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,15 +18,15 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/utils": "^3.1.0",
22
- "@react-types/checkbox": "^3.1.0",
23
- "@react-types/shared": "^3.2.0"
21
+ "@react-stately/utils": "^3.4.0",
22
+ "@react-types/checkbox": "^3.2.4",
23
+ "@react-types/shared": "^3.11.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "react": "^16.8.0"
26
+ "react": "^16.8.0 || ^17.0.0-rc.1"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "661f0f2e3b8648a75aae83043267954700059fe0"
31
+ "gitHead": "54c2366c4f31bd4bf619126131cd583c12972acc"
32
32
  }
@@ -19,7 +19,7 @@ export interface ToggleState {
19
19
 
20
20
  /** Updates selection state. */
21
21
  setSelected(isSelected: boolean): void,
22
-
22
+
23
23
  /** Toggle the selection state. */
24
24
  toggle(): void
25
25
  }
@@ -28,30 +28,21 @@ export interface ToggleState {
28
28
  * Provides state management for toggle components like checkboxes and switches.
29
29
  */
30
30
  export function useToggleState(props: ToggleProps = {}): ToggleState {
31
- let {isReadOnly, onChange} = props;
31
+ let {isReadOnly} = props;
32
32
 
33
33
  // have to provide an empty function so useControlledState doesn't throw a fit
34
34
  // can't use useControlledState's prop calling because we need the event object from the change
35
- let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, () => {});
35
+ let [isSelected, setSelected] = useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);
36
36
 
37
37
  function updateSelected(value) {
38
38
  if (!isReadOnly) {
39
39
  setSelected(value);
40
- if (onChange) {
41
- onChange(value);
42
- }
43
40
  }
44
41
  }
45
42
 
46
43
  function toggleState() {
47
44
  if (!isReadOnly) {
48
- setSelected(prev => {
49
- let newVal = !prev;
50
- if (onChange) {
51
- onChange(newVal);
52
- }
53
- return newVal;
54
- });
45
+ setSelected(!isSelected);
55
46
  }
56
47
  }
57
48