@react-aria/checkbox 3.7.1 → 3.8.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 +146 -0
  2. package/package.json +14 -9
@@ -0,0 +1,146 @@
1
+ import {useEffect as $cKEhs$useEffect} from "react";
2
+ import {useToggle as $cKEhs$useToggle} from "@react-aria/toggle";
3
+ import {filterDOMProps as $cKEhs$filterDOMProps, mergeProps as $cKEhs$mergeProps} from "@react-aria/utils";
4
+ import {useField as $cKEhs$useField} from "@react-aria/label";
5
+ import {useToggleState as $cKEhs$useToggleState} from "@react-stately/toggle";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */ /*
18
+ * Copyright 2020 Adobe. All rights reserved.
19
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License. You may obtain a copy
21
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software distributed under
24
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
25
+ * OF ANY KIND, either express or implied. See the License for the specific language
26
+ * governing permissions and limitations under the License.
27
+ */
28
+
29
+ function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
30
+ let { inputProps: inputProps } = (0, $cKEhs$useToggle)(props, state, inputRef);
31
+ let { isSelected: isSelected } = state;
32
+ let { isIndeterminate: isIndeterminate } = props;
33
+ (0, $cKEhs$useEffect)(()=>{
34
+ // indeterminate is a property, but it can only be set via javascript
35
+ // https://css-tricks.com/indeterminate-checkboxes/
36
+ if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;
37
+ });
38
+ return {
39
+ inputProps: {
40
+ ...inputProps,
41
+ checked: isSelected
42
+ }
43
+ };
44
+ }
45
+
46
+
47
+ /*
48
+ * Copyright 2020 Adobe. All rights reserved.
49
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
50
+ * you may not use this file except in compliance with the License. You may obtain a copy
51
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
52
+ *
53
+ * Unless required by applicable law or agreed to in writing, software distributed under
54
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
55
+ * OF ANY KIND, either express or implied. See the License for the specific language
56
+ * governing permissions and limitations under the License.
57
+ */ /*
58
+ * Copyright 2020 Adobe. All rights reserved.
59
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
60
+ * you may not use this file except in compliance with the License. You may obtain a copy
61
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
62
+ *
63
+ * Unless required by applicable law or agreed to in writing, software distributed under
64
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
65
+ * OF ANY KIND, either express or implied. See the License for the specific language
66
+ * governing permissions and limitations under the License.
67
+ */ const $1ae600c947479353$export$31440636951aa68c = new WeakMap();
68
+ const $1ae600c947479353$export$a3077e9c93f7360f = new WeakMap();
69
+ const $1ae600c947479353$export$d5679492e2864181 = new WeakMap();
70
+
71
+
72
+
73
+
74
+ function $1e9fce0cfacc738b$export$49ff6f28c54f1cbe(props, state) {
75
+ let { isDisabled: isDisabled , name: name } = props;
76
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $cKEhs$useField)({
77
+ ...props,
78
+ // Checkbox group is not an HTML input element so it
79
+ // shouldn't be labeled by a <label> element.
80
+ labelElementType: "span"
81
+ });
82
+ (0, $1ae600c947479353$export$a3077e9c93f7360f).set(state, descriptionProps.id);
83
+ (0, $1ae600c947479353$export$d5679492e2864181).set(state, errorMessageProps.id);
84
+ let domProps = (0, $cKEhs$filterDOMProps)(props, {
85
+ labelable: true
86
+ });
87
+ // Pass name prop from group to all items by attaching to the state.
88
+ (0, $1ae600c947479353$export$31440636951aa68c).set(state, name);
89
+ return {
90
+ groupProps: (0, $cKEhs$mergeProps)(domProps, {
91
+ role: "group",
92
+ "aria-disabled": isDisabled || undefined,
93
+ ...fieldProps
94
+ }),
95
+ labelProps: labelProps,
96
+ descriptionProps: descriptionProps,
97
+ errorMessageProps: errorMessageProps
98
+ };
99
+ }
100
+
101
+
102
+ /*
103
+ * Copyright 2020 Adobe. All rights reserved.
104
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
105
+ * you may not use this file except in compliance with the License. You may obtain a copy
106
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
107
+ *
108
+ * Unless required by applicable law or agreed to in writing, software distributed under
109
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
110
+ * OF ANY KIND, either express or implied. See the License for the specific language
111
+ * governing permissions and limitations under the License.
112
+ */
113
+
114
+
115
+ function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
116
+ const toggleState = (0, $cKEhs$useToggleState)({
117
+ isReadOnly: props.isReadOnly || state.isReadOnly,
118
+ isSelected: state.isSelected(props.value),
119
+ onChange (isSelected) {
120
+ if (isSelected) state.addValue(props.value);
121
+ else state.removeValue(props.value);
122
+ if (props.onChange) props.onChange(isSelected);
123
+ }
124
+ });
125
+ let { inputProps: inputProps } = (0, $406796ff087fe49b$export$e375f10ce42261c5)({
126
+ ...props,
127
+ isReadOnly: props.isReadOnly || state.isReadOnly,
128
+ isDisabled: props.isDisabled || state.isDisabled,
129
+ name: props.name || (0, $1ae600c947479353$export$31440636951aa68c).get(state)
130
+ }, toggleState, inputRef);
131
+ return {
132
+ inputProps: {
133
+ ...inputProps,
134
+ "aria-describedby": [
135
+ state.validationState === "invalid" ? (0, $1ae600c947479353$export$d5679492e2864181).get(state) : null,
136
+ (0, $1ae600c947479353$export$a3077e9c93f7360f).get(state)
137
+ ].filter(Boolean).join(" ") || undefined
138
+ }
139
+ };
140
+ }
141
+
142
+
143
+
144
+
145
+ export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox, $1e9fce0cfacc738b$export$49ff6f28c54f1cbe as useCheckboxGroup, $fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
146
+ //# sourceMappingURL=module.js.map
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/checkbox",
3
- "version": "3.7.1",
3
+ "version": "3.8.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/label": "^3.4.4",
21
- "@react-aria/toggle": "^3.4.2",
22
- "@react-aria/utils": "^3.14.2",
23
- "@react-stately/checkbox": "^3.3.2",
24
- "@react-stately/toggle": "^3.4.4",
25
- "@react-types/checkbox": "^3.4.1",
26
- "@react-types/shared": "^3.16.0",
25
+ "@react-aria/label": "^3.5.0",
26
+ "@react-aria/toggle": "^3.5.0",
27
+ "@react-aria/utils": "^3.15.0",
28
+ "@react-stately/checkbox": "^3.4.0",
29
+ "@react-stately/toggle": "^3.5.0",
30
+ "@react-types/checkbox": "^3.4.2",
31
+ "@react-types/shared": "^3.17.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
  }