@react-stately/toggle 3.0.0-nightly.1371 → 3.0.0-nightly.1378

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
@@ -25,23 +25,15 @@ $parcel$export($e78ebe726193d711$exports, "useToggleState", () => $e78ebe726193d
25
25
 
26
26
  function $e78ebe726193d711$export$8042c6c013fd5226(props = {
27
27
  }) {
28
- let { isReadOnly: isReadOnly , onChange: onChange } = props;
28
+ let { isReadOnly: isReadOnly } = props;
29
29
  // have to provide an empty function so useControlledState doesn't throw a fit
30
30
  // can't use useControlledState's prop calling because we need the event object from the change
31
- let [isSelected, setSelected] = $1Apn0$reactstatelyutils.useControlledState(props.isSelected, props.defaultSelected || false, ()=>{
32
- });
31
+ let [isSelected, setSelected] = $1Apn0$reactstatelyutils.useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);
33
32
  function updateSelected(value) {
34
- if (!isReadOnly) {
35
- setSelected(value);
36
- if (onChange) onChange(value);
37
- }
33
+ if (!isReadOnly) setSelected(value);
38
34
  }
39
35
  function toggleState() {
40
- if (!isReadOnly) setSelected((prev)=>{
41
- let newVal = !prev;
42
- if (onChange) onChange(newVal);
43
- return newVal;
44
- });
36
+ if (!isReadOnly) setSelected(!isSelected);
45
37
  }
46
38
  return {
47
39
  isSelected: isSelected,
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;SC6BgB,yCAAc,CAAC,KAAkB,GAAG,CAAC;AAAA,CAAC,EAAe,CAAC;IACpE,GAAG,CAAC,CAAC,aAAA,UAAU,aAAE,QAAQ,EAAA,CAAC,GAAG,KAAK;IAElC,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,MAAQ,CAAC;IAAA,CAAC;aAEpG,cAAc,CAAC,KAAK,EAAE,CAAC;QAC9B,EAAE,GAAG,UAAU,EAAE,CAAC;YAChB,WAAW,CAAC,KAAK;YACjB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,KAAK;QAElB,CAAC;IACH,CAAC;aAEQ,WAAW,GAAG,CAAC;QACtB,EAAE,GAAG,UAAU,EACb,WAAW,EAAC,IAAI,GAAI,CAAC;YACnB,GAAG,CAAC,MAAM,IAAI,IAAI;YAClB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,MAAM;YAEjB,MAAM,CAAC,MAAM;QACf,CAAC;IAEL,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, 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":[],"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
@@ -9,23 +9,15 @@ $parcel$export($9e25f3a27544e6e8$exports, "useToggleState", () => $9e25f3a27544e
9
9
 
10
10
  function $9e25f3a27544e6e8$export$8042c6c013fd5226(props = {
11
11
  }) {
12
- let { isReadOnly: isReadOnly , onChange: onChange } = props;
12
+ let { isReadOnly: isReadOnly } = props;
13
13
  // have to provide an empty function so useControlledState doesn't throw a fit
14
14
  // can't use useControlledState's prop calling because we need the event object from the change
15
- let [isSelected, setSelected] = $1TkUk$useControlledState(props.isSelected, props.defaultSelected || false, ()=>{
16
- });
15
+ let [isSelected, setSelected] = $1TkUk$useControlledState(props.isSelected, props.defaultSelected || false, props.onChange);
17
16
  function updateSelected(value) {
18
- if (!isReadOnly) {
19
- setSelected(value);
20
- if (onChange) onChange(value);
21
- }
17
+ if (!isReadOnly) setSelected(value);
22
18
  }
23
19
  function toggleState() {
24
- if (!isReadOnly) setSelected((prev)=>{
25
- let newVal = !prev;
26
- if (onChange) onChange(newVal);
27
- return newVal;
28
- });
20
+ if (!isReadOnly) setSelected(!isSelected);
29
21
  }
30
22
  return {
31
23
  isSelected: isSelected,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;SC6BgB,yCAAc,CAAC,KAAkB,GAAG,CAAC;AAAA,CAAC,EAAe,CAAC;IACpE,GAAG,CAAC,CAAC,aAAA,UAAU,aAAE,QAAQ,EAAA,CAAC,GAAG,KAAK;IAElC,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,MAAQ,CAAC;IAAA,CAAC;aAEpG,cAAc,CAAC,KAAK,EAAE,CAAC;QAC9B,EAAE,GAAG,UAAU,EAAE,CAAC;YAChB,WAAW,CAAC,KAAK;YACjB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,KAAK;QAElB,CAAC;IACH,CAAC;aAEQ,WAAW,GAAG,CAAC;QACtB,EAAE,GAAG,UAAU,EACb,WAAW,EAAC,IAAI,GAAI,CAAC;YACnB,GAAG,CAAC,MAAM,IAAI,IAAI;YAClB,EAAE,EAAE,QAAQ,EACV,QAAQ,CAAC,MAAM;YAEjB,MAAM,CAAC,MAAM;QACf,CAAC;IAEL,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, 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":[],"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":";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,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","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"}
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.0.0-nightly.1371+d764bb057",
3
+ "version": "3.0.0-nightly.1378+c8381816b",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,9 +18,9 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-stately/utils": "3.0.0-nightly.1371+d764bb057",
22
- "@react-types/checkbox": "3.0.0-nightly.1371+d764bb057",
23
- "@react-types/shared": "3.0.0-nightly.1371+d764bb057"
21
+ "@react-stately/utils": "3.0.0-nightly.1378+c8381816b",
22
+ "@react-types/checkbox": "3.0.0-nightly.1378+c8381816b",
23
+ "@react-types/shared": "3.0.0-nightly.1378+c8381816b"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -28,5 +28,5 @@
28
28
  "publishConfig": {
29
29
  "access": "public"
30
30
  },
31
- "gitHead": "d764bb0570b011bca731b7da1e8f87e2f34b6e32"
31
+ "gitHead": "c8381816b644e0a495106e3404637bc9e8aad084"
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