@react-stately/toggle 3.4.4 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/import.mjs +46 -0
  2. package/package.json +10 -5
@@ -0,0 +1,46 @@
1
+ import {useControlledState as $bOkae$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
+ * Copyright 2020 Adobe. All rights reserved.
15
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
16
+ * you may not use this file except in compliance with the License. You may obtain a copy
17
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software distributed under
20
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
21
+ * OF ANY KIND, either express or implied. See the License for the specific language
22
+ * governing permissions and limitations under the License.
23
+ */
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
+
44
+
45
+ export {$3017fa7ffdddec74$export$8042c6c013fd5226 as useToggleState};
46
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-stately/toggle",
3
- "version": "3.4.4",
3
+ "version": "3.5.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,9 +22,9 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-stately/utils": "^3.5.2",
21
- "@react-types/checkbox": "^3.4.1",
22
- "@react-types/shared": "^3.16.0",
25
+ "@react-stately/utils": "^3.6.0",
26
+ "@react-types/checkbox": "^3.4.2",
27
+ "@react-types/shared": "^3.17.0",
23
28
  "@swc/helpers": "^0.4.14"
24
29
  },
25
30
  "peerDependencies": {
@@ -28,5 +33,5 @@
28
33
  "publishConfig": {
29
34
  "access": "public"
30
35
  },
31
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
36
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
32
37
  }