@react-aria/checkbox 3.7.0 → 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.
@@ -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/dist/main.js CHANGED
@@ -11,13 +11,33 @@ function $parcel$export(e, n, v, s) {
11
11
  $parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$export$e375f10ce42261c5);
12
12
  $parcel$export(module.exports, "useCheckboxGroup", () => $253685172d17db7d$export$49ff6f28c54f1cbe);
13
13
  $parcel$export(module.exports, "useCheckboxGroupItem", () => $07e03121d6ac83c8$export$353b32fc6898d37d);
14
-
14
+ /*
15
+ * Copyright 2020 Adobe. All rights reserved.
16
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
17
+ * you may not use this file except in compliance with the License. You may obtain a copy
18
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software distributed under
21
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
22
+ * OF ANY KIND, either express or implied. See the License for the specific language
23
+ * governing permissions and limitations under the License.
24
+ */ /*
25
+ * Copyright 2020 Adobe. All rights reserved.
26
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
27
+ * you may not use this file except in compliance with the License. You may obtain a copy
28
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
29
+ *
30
+ * Unless required by applicable law or agreed to in writing, software distributed under
31
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
32
+ * OF ANY KIND, either express or implied. See the License for the specific language
33
+ * governing permissions and limitations under the License.
34
+ */
15
35
 
16
36
  function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
17
- let { inputProps: inputProps } = $k0DcK$reactariatoggle.useToggle(props, state, inputRef);
37
+ let { inputProps: inputProps } = (0, $k0DcK$reactariatoggle.useToggle)(props, state, inputRef);
18
38
  let { isSelected: isSelected } = state;
19
39
  let { isIndeterminate: isIndeterminate } = props;
20
- $k0DcK$react.useEffect(()=>{
40
+ (0, $k0DcK$react.useEffect)(()=>{
21
41
  // indeterminate is a property, but it can only be set via javascript
22
42
  // https://css-tricks.com/indeterminate-checkboxes/
23
43
  if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;
@@ -31,7 +51,27 @@ function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
31
51
  }
32
52
 
33
53
 
34
- const $64fc3370e682155f$export$31440636951aa68c = new WeakMap();
54
+ /*
55
+ * Copyright 2020 Adobe. All rights reserved.
56
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
57
+ * you may not use this file except in compliance with the License. You may obtain a copy
58
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
59
+ *
60
+ * Unless required by applicable law or agreed to in writing, software distributed under
61
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
62
+ * OF ANY KIND, either express or implied. See the License for the specific language
63
+ * governing permissions and limitations under the License.
64
+ */ /*
65
+ * Copyright 2020 Adobe. All rights reserved.
66
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
67
+ * you may not use this file except in compliance with the License. You may obtain a copy
68
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
69
+ *
70
+ * Unless required by applicable law or agreed to in writing, software distributed under
71
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
72
+ * OF ANY KIND, either express or implied. See the License for the specific language
73
+ * governing permissions and limitations under the License.
74
+ */ const $64fc3370e682155f$export$31440636951aa68c = new WeakMap();
35
75
  const $64fc3370e682155f$export$a3077e9c93f7360f = new WeakMap();
36
76
  const $64fc3370e682155f$export$d5679492e2864181 = new WeakMap();
37
77
 
@@ -40,23 +80,23 @@ const $64fc3370e682155f$export$d5679492e2864181 = new WeakMap();
40
80
 
41
81
  function $253685172d17db7d$export$49ff6f28c54f1cbe(props, state) {
42
82
  let { isDisabled: isDisabled , name: name } = props;
43
- let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $k0DcK$reactarialabel.useField({
83
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $k0DcK$reactarialabel.useField)({
44
84
  ...props,
45
85
  // Checkbox group is not an HTML input element so it
46
86
  // shouldn't be labeled by a <label> element.
47
- labelElementType: 'span'
87
+ labelElementType: "span"
48
88
  });
49
- $64fc3370e682155f$export$a3077e9c93f7360f.set(state, descriptionProps.id);
50
- $64fc3370e682155f$export$d5679492e2864181.set(state, errorMessageProps.id);
51
- let domProps = $k0DcK$reactariautils.filterDOMProps(props, {
89
+ (0, $64fc3370e682155f$export$a3077e9c93f7360f).set(state, descriptionProps.id);
90
+ (0, $64fc3370e682155f$export$d5679492e2864181).set(state, errorMessageProps.id);
91
+ let domProps = (0, $k0DcK$reactariautils.filterDOMProps)(props, {
52
92
  labelable: true
53
93
  });
54
94
  // Pass name prop from group to all items by attaching to the state.
55
- $64fc3370e682155f$export$31440636951aa68c.set(state, name);
95
+ (0, $64fc3370e682155f$export$31440636951aa68c).set(state, name);
56
96
  return {
57
- groupProps: $k0DcK$reactariautils.mergeProps(domProps, {
58
- role: 'group',
59
- 'aria-disabled': isDisabled || undefined,
97
+ groupProps: (0, $k0DcK$reactariautils.mergeProps)(domProps, {
98
+ role: "group",
99
+ "aria-disabled": isDisabled || undefined,
60
100
  ...fieldProps
61
101
  }),
62
102
  labelProps: labelProps,
@@ -66,11 +106,21 @@ function $253685172d17db7d$export$49ff6f28c54f1cbe(props, state) {
66
106
  }
67
107
 
68
108
 
69
-
109
+ /*
110
+ * Copyright 2020 Adobe. All rights reserved.
111
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
112
+ * you may not use this file except in compliance with the License. You may obtain a copy
113
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
114
+ *
115
+ * Unless required by applicable law or agreed to in writing, software distributed under
116
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
117
+ * OF ANY KIND, either express or implied. See the License for the specific language
118
+ * governing permissions and limitations under the License.
119
+ */
70
120
 
71
121
 
72
122
  function $07e03121d6ac83c8$export$353b32fc6898d37d(props, state, inputRef) {
73
- const toggleState = $k0DcK$reactstatelytoggle.useToggleState({
123
+ const toggleState = (0, $k0DcK$reactstatelytoggle.useToggleState)({
74
124
  isReadOnly: props.isReadOnly || state.isReadOnly,
75
125
  isSelected: state.isSelected(props.value),
76
126
  onChange (isSelected) {
@@ -79,19 +129,19 @@ function $07e03121d6ac83c8$export$353b32fc6898d37d(props, state, inputRef) {
79
129
  if (props.onChange) props.onChange(isSelected);
80
130
  }
81
131
  });
82
- let { inputProps: inputProps } = $468c774d7db917b7$export$e375f10ce42261c5({
132
+ let { inputProps: inputProps } = (0, $468c774d7db917b7$export$e375f10ce42261c5)({
83
133
  ...props,
84
134
  isReadOnly: props.isReadOnly || state.isReadOnly,
85
135
  isDisabled: props.isDisabled || state.isDisabled,
86
- name: props.name || $64fc3370e682155f$export$31440636951aa68c.get(state)
136
+ name: props.name || (0, $64fc3370e682155f$export$31440636951aa68c).get(state)
87
137
  }, toggleState, inputRef);
88
138
  return {
89
139
  inputProps: {
90
140
  ...inputProps,
91
- 'aria-describedby': [
92
- state.validationState === 'invalid' ? $64fc3370e682155f$export$d5679492e2864181.get(state) : null,
93
- $64fc3370e682155f$export$a3077e9c93f7360f.get(state)
94
- ].filter(Boolean).join(' ') || undefined
141
+ "aria-describedby": [
142
+ state.validationState === "invalid" ? (0, $64fc3370e682155f$export$d5679492e2864181).get(state) : null,
143
+ (0, $64fc3370e682155f$export$a3077e9c93f7360f).get(state)
144
+ ].filter(Boolean).join(" ") || undefined
95
145
  }
96
146
  };
97
147
  }
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;SC8BgB,yCAAW,CAAC,KAAwB,EAAE,KAAkB,EAAE,QAAqC,EAAgB,CAAC;IAC9H,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,gCAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ;IACnD,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAExB,GAAG,CAAC,CAAC,kBAAA,eAAe,EAAA,CAAC,GAAG,KAAK;IAC7B,sBAAS,KAAO,CAAC;QACf,EAAqE,AAArE,mEAAqE;QACrE,EAAmD,AAAnD,iDAAmD;QACnD,EAAE,EAAE,QAAQ,CAAC,OAAO,EAClB,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,eAAe;IAEpD,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,CAAC;eACR,UAAU;YACb,OAAO,EAAE,UAAU;QACrB,CAAC;IACH,CAAC;AACH,CAAC;;;AEnCM,KAAK,CAAC,yCAAkB,GAAG,GAAG,CAAC,OAAO;AACtC,KAAK,CAAC,yCAA2B,GAAG,GAAG,CAAC,OAAO;AAC/C,KAAK,CAAC,yCAA4B,GAAG,GAAG,CAAC,OAAO;;;;;SDoBvC,yCAAgB,CAAC,KAA6B,EAAE,KAAyB,EAAqB,CAAC;IAC7G,GAAG,CAAC,CAAC,aAAA,UAAU,SAAE,IAAI,EAAA,CAAC,GAAG,KAAK;IAE9B,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,qBAAE,gBAAgB,sBAAE,iBAAiB,EAAA,CAAC,GAAG,8BAAQ,CAAC,CAAC;WACzE,KAAK;QACR,EAAoD,AAApD,kDAAoD;QACpD,EAA6C,AAA7C,2CAA6C;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,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;QAChD,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,yCAAkB,CAAC,GAAG,CAAC,KAAK;IAClD,CAAC,EAAE,WAAW,EAAE,QAAQ;IAExB,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,CAAC;eACR,UAAU;YACb,CAAkB,mBAAE,CAAC;gBACnB,KAAK,CAAC,eAAe,KAAK,CAAS,WAAG,yCAA4B,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI;gBACpF,yCAA2B,CAAC,GAAG,CAAC,KAAK;YACvC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAG,OAAK,SAAS;QAC1C,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/useCheckboxGroupItem.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 */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n let {inputProps} = useToggle(props, state, inputRef);\n let {isSelected} = state;\n\n let {isIndeterminate} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = isIndeterminate;\n }\n });\n\n return {\n inputProps: {\n ...inputProps,\n checked: isSelected\n }\n };\n}\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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\n\nexport interface CheckboxGroupAria {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name} = props;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n checkboxGroupDescriptionIds.set(state, descriptionProps.id);\n checkboxGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // Pass name prop from group to all items by attaching to the state.\n checkboxGroupNames.set(state, name);\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\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 {CheckboxGroupState} from '@react-stately/checkbox';\n\nexport const checkboxGroupNames = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupDescriptionIds = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupErrorMessageIds = new WeakMap<CheckboxGroupState, string>();\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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {RefObject} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {inputProps} = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || checkboxGroupNames.get(state)\n }, toggleState, inputRef);\n\n return {\n inputProps: {\n ...inputProps,\n 'aria-describedby': [\n state.validationState === 'invalid' ? checkboxGroupErrorMessageIds.get(state) : null,\n checkboxGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;AAkBO,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAAqC,EAAgB;IAC7H,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,gCAAS,AAAD,EAAE,OAAO,OAAO;IAC3C,IAAI,cAAC,WAAU,EAAC,GAAG;IAEnB,IAAI,mBAAC,gBAAe,EAAC,GAAG;IACxB,CAAA,GAAA,sBAAS,AAAD,EAAE,IAAM;QACd,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG;IAErC;IAEA,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,SAAS;QACX;IACF;AACF;;CDvCC,GACD;AEXA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAqB,IAAI;AAC/B,MAAM,4CAA8B,IAAI;AACxC,MAAM,4CAA+B,IAAI;;CDN/C,GAED;;;AAwBO,SAAS,0CAAiB,KAA6B,EAAE,KAAyB,EAAqB;IAC5G,IAAI,cAAC,WAAU,QAAE,KAAI,EAAC,GAAG;IAEzB,IAAI,cAAC,WAAU,cAAE,WAAU,oBAAE,iBAAgB,qBAAE,kBAAiB,EAAC,GAAG,CAAA,GAAA,8BAAO,EAAE;QAC3E,GAAG,KAAK;QACR,oDAAoD;QACpD,6CAA6C;QAC7C,kBAAkB;IACpB;IACA,CAAA,GAAA,yCAA0B,EAAE,GAAG,CAAC,OAAO,iBAAiB,EAAE;IAC1D,CAAA,GAAA,y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F;AACF;;","sources":["packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/useCheckboxGroupItem.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 */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n let {inputProps} = useToggle(props, state, inputRef);\n let {isSelected} = state;\n\n let {isIndeterminate} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = isIndeterminate;\n }\n });\n\n return {\n inputProps: {\n ...inputProps,\n checked: isSelected\n }\n };\n}\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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\n\nexport interface CheckboxGroupAria {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name} = props;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n checkboxGroupDescriptionIds.set(state, descriptionProps.id);\n checkboxGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // Pass name prop from group to all items by attaching to the state.\n checkboxGroupNames.set(state, name);\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\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 {CheckboxGroupState} from '@react-stately/checkbox';\n\nexport const checkboxGroupNames = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupDescriptionIds = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupErrorMessageIds = new WeakMap<CheckboxGroupState, string>();\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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {RefObject} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {inputProps} = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || checkboxGroupNames.get(state)\n }, toggleState, inputRef);\n\n return {\n inputProps: {\n ...inputProps,\n 'aria-describedby': [\n state.validationState === 'invalid' ? checkboxGroupErrorMessageIds.get(state) : null,\n checkboxGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -4,13 +4,33 @@ import {filterDOMProps as $cKEhs$filterDOMProps, mergeProps as $cKEhs$mergeProps
4
4
  import {useField as $cKEhs$useField} from "@react-aria/label";
5
5
  import {useToggleState as $cKEhs$useToggleState} from "@react-stately/toggle";
6
6
 
7
-
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
+ */
8
28
 
9
29
  function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
10
- let { inputProps: inputProps } = $cKEhs$useToggle(props, state, inputRef);
30
+ let { inputProps: inputProps } = (0, $cKEhs$useToggle)(props, state, inputRef);
11
31
  let { isSelected: isSelected } = state;
12
32
  let { isIndeterminate: isIndeterminate } = props;
13
- $cKEhs$useEffect(()=>{
33
+ (0, $cKEhs$useEffect)(()=>{
14
34
  // indeterminate is a property, but it can only be set via javascript
15
35
  // https://css-tricks.com/indeterminate-checkboxes/
16
36
  if (inputRef.current) inputRef.current.indeterminate = isIndeterminate;
@@ -24,7 +44,27 @@ function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
24
44
  }
25
45
 
26
46
 
27
- const $1ae600c947479353$export$31440636951aa68c = new WeakMap();
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();
28
68
  const $1ae600c947479353$export$a3077e9c93f7360f = new WeakMap();
29
69
  const $1ae600c947479353$export$d5679492e2864181 = new WeakMap();
30
70
 
@@ -33,23 +73,23 @@ const $1ae600c947479353$export$d5679492e2864181 = new WeakMap();
33
73
 
34
74
  function $1e9fce0cfacc738b$export$49ff6f28c54f1cbe(props, state) {
35
75
  let { isDisabled: isDisabled , name: name } = props;
36
- let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = $cKEhs$useField({
76
+ let { labelProps: labelProps , fieldProps: fieldProps , descriptionProps: descriptionProps , errorMessageProps: errorMessageProps } = (0, $cKEhs$useField)({
37
77
  ...props,
38
78
  // Checkbox group is not an HTML input element so it
39
79
  // shouldn't be labeled by a <label> element.
40
- labelElementType: 'span'
80
+ labelElementType: "span"
41
81
  });
42
- $1ae600c947479353$export$a3077e9c93f7360f.set(state, descriptionProps.id);
43
- $1ae600c947479353$export$d5679492e2864181.set(state, errorMessageProps.id);
44
- let domProps = $cKEhs$filterDOMProps(props, {
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, {
45
85
  labelable: true
46
86
  });
47
87
  // Pass name prop from group to all items by attaching to the state.
48
- $1ae600c947479353$export$31440636951aa68c.set(state, name);
88
+ (0, $1ae600c947479353$export$31440636951aa68c).set(state, name);
49
89
  return {
50
- groupProps: $cKEhs$mergeProps(domProps, {
51
- role: 'group',
52
- 'aria-disabled': isDisabled || undefined,
90
+ groupProps: (0, $cKEhs$mergeProps)(domProps, {
91
+ role: "group",
92
+ "aria-disabled": isDisabled || undefined,
53
93
  ...fieldProps
54
94
  }),
55
95
  labelProps: labelProps,
@@ -59,11 +99,21 @@ function $1e9fce0cfacc738b$export$49ff6f28c54f1cbe(props, state) {
59
99
  }
60
100
 
61
101
 
62
-
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
+ */
63
113
 
64
114
 
65
115
  function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
66
- const toggleState = $cKEhs$useToggleState({
116
+ const toggleState = (0, $cKEhs$useToggleState)({
67
117
  isReadOnly: props.isReadOnly || state.isReadOnly,
68
118
  isSelected: state.isSelected(props.value),
69
119
  onChange (isSelected) {
@@ -72,19 +122,19 @@ function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
72
122
  if (props.onChange) props.onChange(isSelected);
73
123
  }
74
124
  });
75
- let { inputProps: inputProps } = $406796ff087fe49b$export$e375f10ce42261c5({
125
+ let { inputProps: inputProps } = (0, $406796ff087fe49b$export$e375f10ce42261c5)({
76
126
  ...props,
77
127
  isReadOnly: props.isReadOnly || state.isReadOnly,
78
128
  isDisabled: props.isDisabled || state.isDisabled,
79
- name: props.name || $1ae600c947479353$export$31440636951aa68c.get(state)
129
+ name: props.name || (0, $1ae600c947479353$export$31440636951aa68c).get(state)
80
130
  }, toggleState, inputRef);
81
131
  return {
82
132
  inputProps: {
83
133
  ...inputProps,
84
- 'aria-describedby': [
85
- state.validationState === 'invalid' ? $1ae600c947479353$export$d5679492e2864181.get(state) : null,
86
- $1ae600c947479353$export$a3077e9c93f7360f.get(state)
87
- ].filter(Boolean).join(' ') || undefined
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
88
138
  }
89
139
  };
90
140
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;SC8BgB,yCAAW,CAAC,KAAwB,EAAE,KAAkB,EAAE,QAAqC,EAAgB,CAAC;IAC9H,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,gBAAS,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ;IACnD,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,KAAK;IAExB,GAAG,CAAC,CAAC,kBAAA,eAAe,EAAA,CAAC,GAAG,KAAK;IAC7B,gBAAS,KAAO,CAAC;QACf,EAAqE,AAArE,mEAAqE;QACrE,EAAmD,AAAnD,iDAAmD;QACnD,EAAE,EAAE,QAAQ,CAAC,OAAO,EAClB,QAAQ,CAAC,OAAO,CAAC,aAAa,GAAG,eAAe;IAEpD,CAAC;IAED,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,CAAC;eACR,UAAU;YACb,OAAO,EAAE,UAAU;QACrB,CAAC;IACH,CAAC;AACH,CAAC;;;AEnCM,KAAK,CAAC,yCAAkB,GAAG,GAA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C,KAAK,CAAC,KAAK;QACxC,QAAQ,EAAC,UAAU,EAAE,CAAC;YACpB,EAAE,EAAE,UAAU,EACZ,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK;iBAE1B,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK;YAG/B,EAAE,EAAE,KAAK,CAAC,QAAQ,EAChB,KAAK,CAAC,QAAQ,CAAC,UAAU;QAE7B,CAAC;IACH,CAAC;IAED,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,yCAAW,CAAC,CAAC;WAC3B,KAAK;QACR,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;QAChD,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,UAAU;QAChD,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,yCAAkB,CAAC,GAAG,CAAC,KAAK;IAClD,CAAC,EAAE,WAAW,EAAE,QAAQ;IAExB,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,CAAC;eACR,UAAU;YACb,CAAkB,mBAAE,CAAC;gBACnB,KAAK,CAAC,eAAe,KAAK,CAAS,WAAG,yCAA4B,CAAC,GAAG,CAAC,KAAK,IAAI,IAAI;gBACpF,yCAA2B,CAAC,GAAG,CAAC,KAAK;YACvC,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAG,OAAK,SAAS;QAC1C,CAAC;IACH,CAAC;AACH,CAAC;","sources":["packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/useCheckboxGroupItem.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 */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n let {inputProps} = useToggle(props, state, inputRef);\n let {isSelected} = state;\n\n let {isIndeterminate} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = isIndeterminate;\n }\n });\n\n return {\n inputProps: {\n ...inputProps,\n checked: isSelected\n }\n };\n}\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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\n\nexport interface CheckboxGroupAria {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name} = props;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n checkboxGroupDescriptionIds.set(state, descriptionProps.id);\n checkboxGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // Pass name prop from group to all items by attaching to the state.\n checkboxGroupNames.set(state, name);\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\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 {CheckboxGroupState} from '@react-stately/checkbox';\n\nexport const checkboxGroupNames = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupDescriptionIds = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupErrorMessageIds = new WeakMap<CheckboxGroupState, string>();\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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {RefObject} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {inputProps} = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || checkboxGroupNames.get(state)\n }, toggleState, inputRef);\n\n return {\n inputProps: {\n ...inputProps,\n 'aria-describedby': [\n state.validationState === 'invalid' ? checkboxGroupErrorMessageIds.get(state) : null,\n checkboxGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;AAkBO,SAAS,0CAAY,KAAwB,EAAE,KAAkB,EAAE,QAAqC,EAAgB;IAC7H,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,gBAAS,AAAD,EAAE,OAAO,OAAO;IAC3C,IAAI,cAAC,WAAU,EAAC,GAAG;IAEnB,IAAI,mBAAC,gBAAe,EAAC,GAAG;IACxB,CAAA,GAAA,gBAAS,AAAD,EAAE,IAAM;QACd,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,SAAS,OAAO,EAClB,SAAS,OAAO,CAAC,aAAa,GAAG;IAErC;IAEA,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,SAAS;QACX;IACF;AACF;;CDvCC,GACD;AEXA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED,AAEO,MAAM,4CAAqB,IAAI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AAG,KAAK;QACR,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;QAChD,YAAY,MAAM,UAAU,IAAI,MAAM,UAAU;QAChD,MAAM,MAAM,IAAI,IAAI,CAAA,GAAA,yCAAiB,EAAE,GAAG,CAAC;IAC7C,GAAG,aAAa;IAEhB,OAAO;QACL,YAAY;YACV,GAAG,UAAU;YACb,oBAAoB;gBAClB,MAAM,eAAe,KAAK,YAAY,CAAA,GAAA,yCAA4B,AAAD,EAAE,GAAG,CAAC,SAAS,IAAI;gBACpF,CAAA,GAAA,yCAA0B,EAAE,GAAG,CAAC;aACjC,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,QAAQ;QACjC;IACF;AACF;;","sources":["packages/@react-aria/checkbox/src/index.ts","packages/@react-aria/checkbox/src/useCheckbox.ts","packages/@react-aria/checkbox/src/useCheckboxGroup.ts","packages/@react-aria/checkbox/src/utils.ts","packages/@react-aria/checkbox/src/useCheckboxGroupItem.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 */\nexport type {CheckboxAria} from './useCheckbox';\nexport {useCheckbox} from './useCheckbox';\nexport {useCheckboxGroup} from './useCheckboxGroup';\nexport {useCheckboxGroupItem} from './useCheckboxGroupItem';\nexport type {AriaCheckboxGroupItemProps, AriaCheckboxGroupProps, AriaCheckboxProps} from '@react-types/checkbox';\nexport type {CheckboxGroupAria} from './useCheckboxGroup';\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 {AriaCheckboxProps} from '@react-types/checkbox';\nimport {InputHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useToggle} from '@react-aria/toggle';\n\nexport interface CheckboxAria {\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component.\n * Checkboxes allow users to select multiple items from a list of individual items, or\n * to mark one individual item as selected.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useToggleState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckbox(props: AriaCheckboxProps, state: ToggleState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n let {inputProps} = useToggle(props, state, inputRef);\n let {isSelected} = state;\n\n let {isIndeterminate} = props;\n useEffect(() => {\n // indeterminate is a property, but it can only be set via javascript\n // https://css-tricks.com/indeterminate-checkboxes/\n if (inputRef.current) {\n inputRef.current.indeterminate = isIndeterminate;\n }\n });\n\n return {\n inputProps: {\n ...inputProps,\n checked: isSelected\n }\n };\n}\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 {AriaCheckboxGroupProps} from '@react-types/checkbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\n\nexport interface CheckboxGroupAria {\n /** Props for the checkbox group wrapper element. */\n groupProps: DOMAttributes,\n /** Props for the checkbox group's visible label (if any). */\n labelProps: DOMAttributes,\n /** Props for the checkbox group description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the checkbox group error message element, if any. */\n errorMessageProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox group component.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox group.\n * @param state - State for the checkbox group, as returned by `useCheckboxGroupState`.\n */\nexport function useCheckboxGroup(props: AriaCheckboxGroupProps, state: CheckboxGroupState): CheckboxGroupAria {\n let {isDisabled, name} = props;\n\n let {labelProps, fieldProps, descriptionProps, errorMessageProps} = useField({\n ...props,\n // Checkbox group is not an HTML input element so it\n // shouldn't be labeled by a <label> element.\n labelElementType: 'span'\n });\n checkboxGroupDescriptionIds.set(state, descriptionProps.id);\n checkboxGroupErrorMessageIds.set(state, errorMessageProps.id);\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n // Pass name prop from group to all items by attaching to the state.\n checkboxGroupNames.set(state, name);\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps\n };\n}\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 {CheckboxGroupState} from '@react-stately/checkbox';\n\nexport const checkboxGroupNames = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupDescriptionIds = new WeakMap<CheckboxGroupState, string>();\nexport const checkboxGroupErrorMessageIds = new WeakMap<CheckboxGroupState, string>();\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 {AriaCheckboxGroupItemProps} from '@react-types/checkbox';\nimport {CheckboxAria, useCheckbox} from './useCheckbox';\nimport {checkboxGroupDescriptionIds, checkboxGroupErrorMessageIds, checkboxGroupNames} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {RefObject} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a checkbox component contained within a checkbox group.\n * Checkbox groups allow users to select multiple items from a list of options.\n * @param props - Props for the checkbox.\n * @param state - State for the checkbox, as returned by `useCheckboxGroupState`.\n * @param inputRef - A ref for the HTML input element.\n */\nexport function useCheckboxGroupItem(props: AriaCheckboxGroupItemProps, state: CheckboxGroupState, inputRef: RefObject<HTMLInputElement>): CheckboxAria {\n const toggleState = useToggleState({\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isSelected: state.isSelected(props.value),\n onChange(isSelected) {\n if (isSelected) {\n state.addValue(props.value);\n } else {\n state.removeValue(props.value);\n }\n\n if (props.onChange) {\n props.onChange(isSelected);\n }\n }\n });\n\n let {inputProps} = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || checkboxGroupNames.get(state)\n }, toggleState, inputRef);\n\n return {\n inputProps: {\n ...inputProps,\n 'aria-describedby': [\n state.validationState === 'invalid' ? checkboxGroupErrorMessageIds.get(state) : null,\n checkboxGroupDescriptionIds.get(state)\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/checkbox",
3
- "version": "3.7.0",
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,14 +22,14 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/label": "^3.4.3",
22
- "@react-aria/toggle": "^3.4.1",
23
- "@react-aria/utils": "^3.14.1",
24
- "@react-stately/checkbox": "^3.3.1",
25
- "@react-stately/toggle": "^3.4.3",
26
- "@react-types/checkbox": "^3.4.1",
27
- "@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",
32
+ "@swc/helpers": "^0.4.14"
28
33
  },
29
34
  "peerDependencies": {
30
35
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -32,5 +37,5 @@
32
37
  "publishConfig": {
33
38
  "access": "public"
34
39
  },
35
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
40
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
36
41
  }