@react-aria/checkbox 3.14.1 → 3.14.2
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/import.mjs +3 -202
- package/dist/main.js +6 -205
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -202
- package/dist/module.js.map +1 -1
- package/dist/useCheckbox.main.js +63 -0
- package/dist/useCheckbox.main.js.map +1 -0
- package/dist/useCheckbox.mjs +58 -0
- package/dist/useCheckbox.module.js +58 -0
- package/dist/useCheckbox.module.js.map +1 -0
- package/dist/useCheckboxGroup.main.js +68 -0
- package/dist/useCheckboxGroup.main.js.map +1 -0
- package/dist/useCheckboxGroup.mjs +63 -0
- package/dist/useCheckboxGroup.module.js +63 -0
- package/dist/useCheckboxGroup.module.js.map +1 -0
- package/dist/useCheckboxGroupItem.main.js +91 -0
- package/dist/useCheckboxGroupItem.main.js.map +1 -0
- package/dist/useCheckboxGroupItem.mjs +86 -0
- package/dist/useCheckboxGroupItem.module.js +86 -0
- package/dist/useCheckboxGroupItem.module.js.map +1 -0
- package/dist/utils.main.js +20 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +15 -0
- package/dist/utils.module.js +15 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +12 -12
package/dist/import.mjs
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {useToggle as $cKEhs$useToggle} from "@react-aria/toggle";
|
|
5
|
-
import {filterDOMProps as $cKEhs$filterDOMProps, mergeProps as $cKEhs$mergeProps} from "@react-aria/utils";
|
|
6
|
-
import {useField as $cKEhs$useField} from "@react-aria/label";
|
|
7
|
-
import {useFocusWithin as $cKEhs$useFocusWithin} from "@react-aria/interactions";
|
|
8
|
-
import {useToggleState as $cKEhs$useToggleState} from "@react-stately/toggle";
|
|
1
|
+
import {useCheckbox as $406796ff087fe49b$export$e375f10ce42261c5} from "./useCheckbox.mjs";
|
|
2
|
+
import {useCheckboxGroup as $1e9fce0cfacc738b$export$49ff6f28c54f1cbe} from "./useCheckboxGroup.mjs";
|
|
3
|
+
import {useCheckboxGroupItem as $fba3e38d5ca8983f$export$353b32fc6898d37d} from "./useCheckboxGroupItem.mjs";
|
|
9
4
|
|
|
10
5
|
/*
|
|
11
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
-
* governing permissions and limitations under the License.
|
|
20
|
-
*/ /*
|
|
21
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
22
7
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
23
8
|
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
@@ -31,190 +16,6 @@ import {useToggleState as $cKEhs$useToggleState} from "@react-stately/toggle";
|
|
|
31
16
|
|
|
32
17
|
|
|
33
18
|
|
|
34
|
-
function $406796ff087fe49b$export$e375f10ce42261c5(props, state, inputRef) {
|
|
35
|
-
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
36
|
-
let validationState = (0, $cKEhs$useFormValidationState)({
|
|
37
|
-
...props,
|
|
38
|
-
value: state.isSelected
|
|
39
|
-
});
|
|
40
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
|
|
41
|
-
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $cKEhs$useToggle)({
|
|
42
|
-
...props,
|
|
43
|
-
isInvalid: isInvalid
|
|
44
|
-
}, state, inputRef);
|
|
45
|
-
(0, $cKEhs$useFormValidation)(props, validationState, inputRef);
|
|
46
|
-
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = "aria" } = props;
|
|
47
|
-
(0, $cKEhs$useEffect)(()=>{
|
|
48
|
-
// indeterminate is a property, but it can only be set via javascript
|
|
49
|
-
// https://css-tricks.com/indeterminate-checkboxes/
|
|
50
|
-
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
labelProps: labelProps,
|
|
54
|
-
inputProps: {
|
|
55
|
-
...inputProps,
|
|
56
|
-
checked: isSelected,
|
|
57
|
-
"aria-required": isRequired && validationBehavior === "aria" || undefined,
|
|
58
|
-
required: isRequired && validationBehavior === "native"
|
|
59
|
-
},
|
|
60
|
-
isSelected: isSelected,
|
|
61
|
-
isPressed: isPressed,
|
|
62
|
-
isDisabled: isDisabled,
|
|
63
|
-
isReadOnly: isReadOnly,
|
|
64
|
-
isInvalid: isInvalid,
|
|
65
|
-
validationErrors: validationErrors,
|
|
66
|
-
validationDetails: validationDetails
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
73
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
74
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
75
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
76
|
-
*
|
|
77
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
78
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
79
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
80
|
-
* governing permissions and limitations under the License.
|
|
81
|
-
*/ /*
|
|
82
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
83
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
84
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
85
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
86
|
-
*
|
|
87
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
88
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
89
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
90
|
-
* governing permissions and limitations under the License.
|
|
91
|
-
*/ const $1ae600c947479353$export$ec98120685d4f57d = new WeakMap();
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
function $1e9fce0cfacc738b$export$49ff6f28c54f1cbe(props, state) {
|
|
98
|
-
let { isDisabled: isDisabled, name: name, validationBehavior: validationBehavior = "aria" } = props;
|
|
99
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
100
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $cKEhs$useField)({
|
|
101
|
-
...props,
|
|
102
|
-
// Checkbox group is not an HTML input element so it
|
|
103
|
-
// shouldn't be labeled by a <label> element.
|
|
104
|
-
labelElementType: "span",
|
|
105
|
-
isInvalid: isInvalid,
|
|
106
|
-
errorMessage: props.errorMessage || validationErrors
|
|
107
|
-
});
|
|
108
|
-
(0, $1ae600c947479353$export$ec98120685d4f57d).set(state, {
|
|
109
|
-
name: name,
|
|
110
|
-
descriptionId: descriptionProps.id,
|
|
111
|
-
errorMessageId: errorMessageProps.id,
|
|
112
|
-
validationBehavior: validationBehavior
|
|
113
|
-
});
|
|
114
|
-
let domProps = (0, $cKEhs$filterDOMProps)(props, {
|
|
115
|
-
labelable: true
|
|
116
|
-
});
|
|
117
|
-
let { focusWithinProps: focusWithinProps } = (0, $cKEhs$useFocusWithin)({
|
|
118
|
-
onBlurWithin: props.onBlur,
|
|
119
|
-
onFocusWithin: props.onFocus,
|
|
120
|
-
onFocusWithinChange: props.onFocusChange
|
|
121
|
-
});
|
|
122
|
-
return {
|
|
123
|
-
groupProps: (0, $cKEhs$mergeProps)(domProps, {
|
|
124
|
-
role: "group",
|
|
125
|
-
"aria-disabled": isDisabled || undefined,
|
|
126
|
-
...fieldProps,
|
|
127
|
-
...focusWithinProps
|
|
128
|
-
}),
|
|
129
|
-
labelProps: labelProps,
|
|
130
|
-
descriptionProps: descriptionProps,
|
|
131
|
-
errorMessageProps: errorMessageProps,
|
|
132
|
-
isInvalid: isInvalid,
|
|
133
|
-
validationErrors: validationErrors,
|
|
134
|
-
validationDetails: validationDetails
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
/*
|
|
140
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
141
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
142
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
143
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
144
|
-
*
|
|
145
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
146
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
147
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
148
|
-
* governing permissions and limitations under the License.
|
|
149
|
-
*/
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
function $fba3e38d5ca8983f$export$353b32fc6898d37d(props, state, inputRef) {
|
|
155
|
-
const toggleState = (0, $cKEhs$useToggleState)({
|
|
156
|
-
isReadOnly: props.isReadOnly || state.isReadOnly,
|
|
157
|
-
isSelected: state.isSelected(props.value),
|
|
158
|
-
onChange (isSelected) {
|
|
159
|
-
if (isSelected) state.addValue(props.value);
|
|
160
|
-
else state.removeValue(props.value);
|
|
161
|
-
if (props.onChange) props.onChange(isSelected);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $1ae600c947479353$export$ec98120685d4f57d).get(state);
|
|
165
|
-
var _props_validationBehavior;
|
|
166
|
-
validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
|
|
167
|
-
// Local validation for this checkbox.
|
|
168
|
-
let { realtimeValidation: realtimeValidation } = (0, $cKEhs$useFormValidationState)({
|
|
169
|
-
...props,
|
|
170
|
-
value: toggleState.isSelected,
|
|
171
|
-
// Server validation is handled at the group level.
|
|
172
|
-
name: undefined,
|
|
173
|
-
validationBehavior: "aria"
|
|
174
|
-
});
|
|
175
|
-
// Update the checkbox group state when realtime validation changes.
|
|
176
|
-
let nativeValidation = (0, $cKEhs$useRef)((0, $cKEhs$DEFAULT_VALIDATION_RESULT));
|
|
177
|
-
let updateValidation = ()=>{
|
|
178
|
-
state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
|
|
179
|
-
};
|
|
180
|
-
(0, $cKEhs$useEffect)(updateValidation);
|
|
181
|
-
// Combine group and checkbox level validation.
|
|
182
|
-
let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
|
|
183
|
-
let displayValidation = validationBehavior === "native" ? state.displayValidation : combinedRealtimeValidation;
|
|
184
|
-
var _props_isRequired;
|
|
185
|
-
let res = (0, $406796ff087fe49b$export$e375f10ce42261c5)({
|
|
186
|
-
...props,
|
|
187
|
-
isReadOnly: props.isReadOnly || state.isReadOnly,
|
|
188
|
-
isDisabled: props.isDisabled || state.isDisabled,
|
|
189
|
-
name: props.name || name,
|
|
190
|
-
isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
|
|
191
|
-
validationBehavior: validationBehavior,
|
|
192
|
-
[(0, $cKEhs$privateValidationStateProp)]: {
|
|
193
|
-
realtimeValidation: combinedRealtimeValidation,
|
|
194
|
-
displayValidation: displayValidation,
|
|
195
|
-
resetValidation: state.resetValidation,
|
|
196
|
-
commitValidation: state.commitValidation,
|
|
197
|
-
updateValidation (v) {
|
|
198
|
-
nativeValidation.current = v;
|
|
199
|
-
updateValidation();
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}, toggleState, inputRef);
|
|
203
|
-
return {
|
|
204
|
-
...res,
|
|
205
|
-
inputProps: {
|
|
206
|
-
...res.inputProps,
|
|
207
|
-
"aria-describedby": [
|
|
208
|
-
props["aria-describedby"],
|
|
209
|
-
state.isInvalid ? errorMessageId : null,
|
|
210
|
-
descriptionId
|
|
211
|
-
].filter(Boolean).join(" ") || undefined
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
19
|
|
|
219
20
|
export {$406796ff087fe49b$export$e375f10ce42261c5 as useCheckbox, $1e9fce0cfacc738b$export$49ff6f28c54f1cbe as useCheckboxGroup, $fba3e38d5ca8983f$export$353b32fc6898d37d as useCheckboxGroupItem};
|
|
220
21
|
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,149 +1,15 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $k0DcK$reactariatoggle = require("@react-aria/toggle");
|
|
5
|
-
var $k0DcK$reactariautils = require("@react-aria/utils");
|
|
6
|
-
var $k0DcK$reactarialabel = require("@react-aria/label");
|
|
7
|
-
var $k0DcK$reactariainteractions = require("@react-aria/interactions");
|
|
8
|
-
var $k0DcK$reactstatelytoggle = require("@react-stately/toggle");
|
|
1
|
+
var $468c774d7db917b7$exports = require("./useCheckbox.main.js");
|
|
2
|
+
var $253685172d17db7d$exports = require("./useCheckboxGroup.main.js");
|
|
3
|
+
var $07e03121d6ac83c8$exports = require("./useCheckboxGroupItem.main.js");
|
|
9
4
|
|
|
10
5
|
|
|
11
6
|
function $parcel$export(e, n, v, s) {
|
|
12
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
13
8
|
}
|
|
14
9
|
|
|
15
|
-
$parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$
|
|
16
|
-
$parcel$export(module.exports, "useCheckboxGroup", () => $253685172d17db7d$
|
|
17
|
-
$parcel$export(module.exports, "useCheckboxGroupItem", () => $07e03121d6ac83c8$
|
|
18
|
-
/*
|
|
19
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
20
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
21
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
22
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
-
*
|
|
24
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
25
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
26
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
27
|
-
* governing permissions and limitations under the License.
|
|
28
|
-
*/ /*
|
|
29
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
-
*
|
|
34
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
-
* governing permissions and limitations under the License.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
function $468c774d7db917b7$export$e375f10ce42261c5(props, state, inputRef) {
|
|
43
|
-
// Create validation state here because it doesn't make sense to add to general useToggleState.
|
|
44
|
-
let validationState = (0, $k0DcK$reactstatelyform.useFormValidationState)({
|
|
45
|
-
...props,
|
|
46
|
-
value: state.isSelected
|
|
47
|
-
});
|
|
48
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = validationState.displayValidation;
|
|
49
|
-
let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isPressed: isPressed, isDisabled: isDisabled, isReadOnly: isReadOnly } = (0, $k0DcK$reactariatoggle.useToggle)({
|
|
50
|
-
...props,
|
|
51
|
-
isInvalid: isInvalid
|
|
52
|
-
}, state, inputRef);
|
|
53
|
-
(0, $k0DcK$reactariaform.useFormValidation)(props, validationState, inputRef);
|
|
54
|
-
let { isIndeterminate: isIndeterminate, isRequired: isRequired, validationBehavior: validationBehavior = "aria" } = props;
|
|
55
|
-
(0, $k0DcK$react.useEffect)(()=>{
|
|
56
|
-
// indeterminate is a property, but it can only be set via javascript
|
|
57
|
-
// https://css-tricks.com/indeterminate-checkboxes/
|
|
58
|
-
if (inputRef.current) inputRef.current.indeterminate = !!isIndeterminate;
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
labelProps: labelProps,
|
|
62
|
-
inputProps: {
|
|
63
|
-
...inputProps,
|
|
64
|
-
checked: isSelected,
|
|
65
|
-
"aria-required": isRequired && validationBehavior === "aria" || undefined,
|
|
66
|
-
required: isRequired && validationBehavior === "native"
|
|
67
|
-
},
|
|
68
|
-
isSelected: isSelected,
|
|
69
|
-
isPressed: isPressed,
|
|
70
|
-
isDisabled: isDisabled,
|
|
71
|
-
isReadOnly: isReadOnly,
|
|
72
|
-
isInvalid: isInvalid,
|
|
73
|
-
validationErrors: validationErrors,
|
|
74
|
-
validationDetails: validationDetails
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
/*
|
|
80
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
81
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
82
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
83
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
84
|
-
*
|
|
85
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
86
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
87
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
88
|
-
* governing permissions and limitations under the License.
|
|
89
|
-
*/ /*
|
|
90
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
91
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
92
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
93
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
94
|
-
*
|
|
95
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
96
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
97
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
98
|
-
* governing permissions and limitations under the License.
|
|
99
|
-
*/ const $64fc3370e682155f$export$ec98120685d4f57d = new WeakMap();
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
function $253685172d17db7d$export$49ff6f28c54f1cbe(props, state) {
|
|
106
|
-
let { isDisabled: isDisabled, name: name, validationBehavior: validationBehavior = "aria" } = props;
|
|
107
|
-
let { isInvalid: isInvalid, validationErrors: validationErrors, validationDetails: validationDetails } = state.displayValidation;
|
|
108
|
-
let { labelProps: labelProps, fieldProps: fieldProps, descriptionProps: descriptionProps, errorMessageProps: errorMessageProps } = (0, $k0DcK$reactarialabel.useField)({
|
|
109
|
-
...props,
|
|
110
|
-
// Checkbox group is not an HTML input element so it
|
|
111
|
-
// shouldn't be labeled by a <label> element.
|
|
112
|
-
labelElementType: "span",
|
|
113
|
-
isInvalid: isInvalid,
|
|
114
|
-
errorMessage: props.errorMessage || validationErrors
|
|
115
|
-
});
|
|
116
|
-
(0, $64fc3370e682155f$export$ec98120685d4f57d).set(state, {
|
|
117
|
-
name: name,
|
|
118
|
-
descriptionId: descriptionProps.id,
|
|
119
|
-
errorMessageId: errorMessageProps.id,
|
|
120
|
-
validationBehavior: validationBehavior
|
|
121
|
-
});
|
|
122
|
-
let domProps = (0, $k0DcK$reactariautils.filterDOMProps)(props, {
|
|
123
|
-
labelable: true
|
|
124
|
-
});
|
|
125
|
-
let { focusWithinProps: focusWithinProps } = (0, $k0DcK$reactariainteractions.useFocusWithin)({
|
|
126
|
-
onBlurWithin: props.onBlur,
|
|
127
|
-
onFocusWithin: props.onFocus,
|
|
128
|
-
onFocusWithinChange: props.onFocusChange
|
|
129
|
-
});
|
|
130
|
-
return {
|
|
131
|
-
groupProps: (0, $k0DcK$reactariautils.mergeProps)(domProps, {
|
|
132
|
-
role: "group",
|
|
133
|
-
"aria-disabled": isDisabled || undefined,
|
|
134
|
-
...fieldProps,
|
|
135
|
-
...focusWithinProps
|
|
136
|
-
}),
|
|
137
|
-
labelProps: labelProps,
|
|
138
|
-
descriptionProps: descriptionProps,
|
|
139
|
-
errorMessageProps: errorMessageProps,
|
|
140
|
-
isInvalid: isInvalid,
|
|
141
|
-
validationErrors: validationErrors,
|
|
142
|
-
validationDetails: validationDetails
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
10
|
+
$parcel$export(module.exports, "useCheckbox", () => $468c774d7db917b7$exports.useCheckbox);
|
|
11
|
+
$parcel$export(module.exports, "useCheckboxGroup", () => $253685172d17db7d$exports.useCheckboxGroup);
|
|
12
|
+
$parcel$export(module.exports, "useCheckboxGroupItem", () => $07e03121d6ac83c8$exports.useCheckboxGroupItem);
|
|
147
13
|
/*
|
|
148
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
149
15
|
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
@@ -159,69 +25,4 @@ function $253685172d17db7d$export$49ff6f28c54f1cbe(props, state) {
|
|
|
159
25
|
|
|
160
26
|
|
|
161
27
|
|
|
162
|
-
function $07e03121d6ac83c8$export$353b32fc6898d37d(props, state, inputRef) {
|
|
163
|
-
const toggleState = (0, $k0DcK$reactstatelytoggle.useToggleState)({
|
|
164
|
-
isReadOnly: props.isReadOnly || state.isReadOnly,
|
|
165
|
-
isSelected: state.isSelected(props.value),
|
|
166
|
-
onChange (isSelected) {
|
|
167
|
-
if (isSelected) state.addValue(props.value);
|
|
168
|
-
else state.removeValue(props.value);
|
|
169
|
-
if (props.onChange) props.onChange(isSelected);
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
let { name: name, descriptionId: descriptionId, errorMessageId: errorMessageId, validationBehavior: validationBehavior } = (0, $64fc3370e682155f$export$ec98120685d4f57d).get(state);
|
|
173
|
-
var _props_validationBehavior;
|
|
174
|
-
validationBehavior = (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : validationBehavior;
|
|
175
|
-
// Local validation for this checkbox.
|
|
176
|
-
let { realtimeValidation: realtimeValidation } = (0, $k0DcK$reactstatelyform.useFormValidationState)({
|
|
177
|
-
...props,
|
|
178
|
-
value: toggleState.isSelected,
|
|
179
|
-
// Server validation is handled at the group level.
|
|
180
|
-
name: undefined,
|
|
181
|
-
validationBehavior: "aria"
|
|
182
|
-
});
|
|
183
|
-
// Update the checkbox group state when realtime validation changes.
|
|
184
|
-
let nativeValidation = (0, $k0DcK$react.useRef)((0, $k0DcK$reactstatelyform.DEFAULT_VALIDATION_RESULT));
|
|
185
|
-
let updateValidation = ()=>{
|
|
186
|
-
state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);
|
|
187
|
-
};
|
|
188
|
-
(0, $k0DcK$react.useEffect)(updateValidation);
|
|
189
|
-
// Combine group and checkbox level validation.
|
|
190
|
-
let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;
|
|
191
|
-
let displayValidation = validationBehavior === "native" ? state.displayValidation : combinedRealtimeValidation;
|
|
192
|
-
var _props_isRequired;
|
|
193
|
-
let res = (0, $468c774d7db917b7$export$e375f10ce42261c5)({
|
|
194
|
-
...props,
|
|
195
|
-
isReadOnly: props.isReadOnly || state.isReadOnly,
|
|
196
|
-
isDisabled: props.isDisabled || state.isDisabled,
|
|
197
|
-
name: props.name || name,
|
|
198
|
-
isRequired: (_props_isRequired = props.isRequired) !== null && _props_isRequired !== void 0 ? _props_isRequired : state.isRequired,
|
|
199
|
-
validationBehavior: validationBehavior,
|
|
200
|
-
[(0, $k0DcK$reactstatelyform.privateValidationStateProp)]: {
|
|
201
|
-
realtimeValidation: combinedRealtimeValidation,
|
|
202
|
-
displayValidation: displayValidation,
|
|
203
|
-
resetValidation: state.resetValidation,
|
|
204
|
-
commitValidation: state.commitValidation,
|
|
205
|
-
updateValidation (v) {
|
|
206
|
-
nativeValidation.current = v;
|
|
207
|
-
updateValidation();
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}, toggleState, inputRef);
|
|
211
|
-
return {
|
|
212
|
-
...res,
|
|
213
|
-
inputProps: {
|
|
214
|
-
...res.inputProps,
|
|
215
|
-
"aria-describedby": [
|
|
216
|
-
props["aria-describedby"],
|
|
217
|
-
state.isInvalid ? errorMessageId : null,
|
|
218
|
-
descriptionId
|
|
219
|
-
].filter(Boolean).join(" ") || undefined
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
28
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"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","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, LabelHTMLAttributes, RefObject, useEffect} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFormValidation} from '@react-aria/form';\nimport {useFormValidationState} from '@react-stately/form';\nimport {useToggle} from '@react-aria/toggle';\nimport {ValidationResult} from '@react-types/shared';\n\nexport interface CheckboxAria extends ValidationResult {\n /** Props for the label wrapper element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props for the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the checkbox is selected. */\n isSelected: boolean,\n /** Whether the checkbox is in a pressed state. */\n isPressed: boolean,\n /** Whether the checkbox is disabled. */\n isDisabled: boolean,\n /** Whether the checkbox is read only. */\n isReadOnly: boolean\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 // Create validation state here because it doesn't make sense to add to general useToggleState.\n let validationState = useFormValidationState({...props, value: state.isSelected});\n let {isInvalid, validationErrors, validationDetails} = validationState.displayValidation;\n let {labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly} = useToggle({\n ...props,\n isInvalid\n }, state, inputRef);\n\n useFormValidation(props, validationState, inputRef);\n\n let {isIndeterminate, isRequired, validationBehavior = 'aria'} = 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 labelProps,\n inputProps: {\n ...inputProps,\n checked: isSelected,\n 'aria-required': (isRequired && validationBehavior === 'aria') || undefined,\n required: isRequired && validationBehavior === 'native'\n },\n isSelected,\n isPressed,\n isDisabled,\n isReadOnly,\n isInvalid,\n validationErrors,\n validationDetails\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 {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DOMAttributes, ValidationResult} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {useField} from '@react-aria/label';\nimport {useFocusWithin} from '@react-aria/interactions';\n\nexport interface CheckboxGroupAria extends ValidationResult {\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, validationBehavior = 'aria'} = props;\n let {isInvalid, validationErrors, validationDetails} = state.displayValidation;\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 isInvalid,\n errorMessage: props.errorMessage || validationErrors\n });\n\n checkboxGroupData.set(state, {\n name,\n descriptionId: descriptionProps.id,\n errorMessageId: errorMessageProps.id,\n validationBehavior\n });\n\n let domProps = filterDOMProps(props, {labelable: true});\n\n let {focusWithinProps} = useFocusWithin({\n onBlurWithin: props.onBlur,\n onFocusWithin: props.onFocus,\n onFocusWithinChange: props.onFocusChange\n });\n\n return {\n groupProps: mergeProps(domProps, {\n role: 'group',\n 'aria-disabled': isDisabled || undefined,\n ...fieldProps,\n ...focusWithinProps\n }),\n labelProps,\n descriptionProps,\n errorMessageProps,\n isInvalid,\n validationErrors,\n validationDetails\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\ninterface CheckboxGroupData {\n name?: string,\n descriptionId?: string,\n errorMessageId?: string,\n validationBehavior: 'aria' | 'native'\n}\n\nexport const checkboxGroupData = new WeakMap<CheckboxGroupState, CheckboxGroupData>();\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 {checkboxGroupData} from './utils';\nimport {CheckboxGroupState} from '@react-stately/checkbox';\nimport {DEFAULT_VALIDATION_RESULT, privateValidationStateProp, useFormValidationState} from '@react-stately/form';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useToggleState} from '@react-stately/toggle';\nimport {ValidationResult} from '@react-types/shared';\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 {name, descriptionId, errorMessageId, validationBehavior} = checkboxGroupData.get(state)!;\n validationBehavior = props.validationBehavior ?? validationBehavior;\n\n // Local validation for this checkbox.\n let {realtimeValidation} = useFormValidationState({\n ...props,\n value: toggleState.isSelected,\n // Server validation is handled at the group level.\n name: undefined,\n validationBehavior: 'aria'\n });\n\n // Update the checkbox group state when realtime validation changes.\n let nativeValidation = useRef(DEFAULT_VALIDATION_RESULT);\n let updateValidation = () => {\n state.setInvalid(props.value, realtimeValidation.isInvalid ? realtimeValidation : nativeValidation.current);\n };\n\n useEffect(updateValidation);\n\n // Combine group and checkbox level validation.\n let combinedRealtimeValidation = state.realtimeValidation.isInvalid ? state.realtimeValidation : realtimeValidation;\n let displayValidation = validationBehavior === 'native' ? state.displayValidation : combinedRealtimeValidation;\n\n let res = useCheckbox({\n ...props,\n isReadOnly: props.isReadOnly || state.isReadOnly,\n isDisabled: props.isDisabled || state.isDisabled,\n name: props.name || name,\n isRequired: props.isRequired ?? state.isRequired,\n validationBehavior,\n [privateValidationStateProp]: {\n realtimeValidation: combinedRealtimeValidation,\n displayValidation,\n resetValidation: state.resetValidation,\n commitValidation: state.commitValidation,\n updateValidation(v: ValidationResult) {\n nativeValidation.current = v;\n updateValidation();\n }\n }\n }, toggleState, inputRef);\n\n return {\n ...res,\n inputProps: {\n ...res.inputProps,\n 'aria-describedby': [\n props['aria-describedby'],\n state.isInvalid ? errorMessageId : null,\n descriptionId\n ].filter(Boolean).join(' ') || undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/checkbox/src/index.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"],"names":[],"version":3,"file":"main.js.map"}
|