@react-aria/toggle 3.4.2 → 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 +71 -0
  2. package/package.json +14 -9
@@ -0,0 +1,71 @@
1
+ import {mergeProps as $7CUUz$mergeProps, filterDOMProps as $7CUUz$filterDOMProps} from "@react-aria/utils";
2
+ import {useFocusable as $7CUUz$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */ /*
16
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
29
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby , validationState: validationState = "valid" } = props;
30
+ let onChange = (e)=>{
31
+ // since we spread props on label, onChange will end up there as well as in here.
32
+ // so we have to stop propagation at the lowest level that we care about
33
+ e.stopPropagation();
34
+ state.setSelected(e.target.checked);
35
+ };
36
+ let hasChildren = children != null;
37
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
38
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
39
+ // This handles focusing the input on pointer down, which Safari does not do by default.
40
+ let { pressProps: pressProps } = (0, $7CUUz$usePress)({
41
+ isDisabled: isDisabled
42
+ });
43
+ let { focusableProps: focusableProps } = (0, $7CUUz$useFocusable)(props, ref);
44
+ let interactions = (0, $7CUUz$mergeProps)(pressProps, focusableProps);
45
+ let domProps = (0, $7CUUz$filterDOMProps)(props, {
46
+ labelable: true
47
+ });
48
+ return {
49
+ inputProps: (0, $7CUUz$mergeProps)(domProps, {
50
+ "aria-invalid": validationState === "invalid" || undefined,
51
+ "aria-errormessage": props["aria-errormessage"],
52
+ "aria-controls": props["aria-controls"],
53
+ "aria-readonly": isReadOnly || undefined,
54
+ "aria-required": isRequired || undefined,
55
+ onChange: onChange,
56
+ disabled: isDisabled,
57
+ ...value == null ? {} : {
58
+ value: value
59
+ },
60
+ name: name,
61
+ type: "checkbox",
62
+ ...interactions
63
+ })
64
+ };
65
+ }
66
+
67
+
68
+
69
+
70
+ export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
71
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/toggle",
3
- "version": "3.4.2",
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,13 +22,13 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@react-aria/focus": "^3.10.1",
21
- "@react-aria/interactions": "^3.13.1",
22
- "@react-aria/utils": "^3.14.2",
23
- "@react-stately/toggle": "^3.4.4",
24
- "@react-types/checkbox": "^3.4.1",
25
- "@react-types/shared": "^3.16.0",
26
- "@react-types/switch": "^3.2.5",
25
+ "@react-aria/focus": "^3.11.0",
26
+ "@react-aria/interactions": "^3.14.0",
27
+ "@react-aria/utils": "^3.15.0",
28
+ "@react-stately/toggle": "^3.5.0",
29
+ "@react-types/checkbox": "^3.4.2",
30
+ "@react-types/shared": "^3.17.0",
31
+ "@react-types/switch": "^3.3.0",
27
32
  "@swc/helpers": "^0.4.14"
28
33
  },
29
34
  "peerDependencies": {
@@ -32,5 +37,5 @@
32
37
  "publishConfig": {
33
38
  "access": "public"
34
39
  },
35
- "gitHead": "5480d76bd815e239366f92852c76b6831ad2a4fd"
40
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
36
41
  }