@react-aria/toggle 3.10.2 → 3.10.3

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 CHANGED
@@ -1,18 +1,6 @@
1
- import {mergeProps as $7CUUz$mergeProps, filterDOMProps as $7CUUz$filterDOMProps, useFormReset as $7CUUz$useFormReset} from "@react-aria/utils";
2
- import {useFocusable as $7CUUz$useFocusable} from "@react-aria/focus";
3
- import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
1
+ import {useToggle as $d2c8e2b0480f3f34$export$cbe85ee05b554577} from "./useToggle.mjs";
4
2
 
5
3
  /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */ /*
16
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,62 +13,5 @@ import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
25
13
  */
26
14
 
27
15
 
28
- function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
29
- let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
30
- let onChange = (e)=>{
31
- // since we spread props on label, onChange will end up there as well as in here.
32
- // so we have to stop propagation at the lowest level that we care about
33
- e.stopPropagation();
34
- state.setSelected(e.target.checked);
35
- };
36
- let hasChildren = children != null;
37
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
38
- if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
39
- // This handles focusing the input on pointer down, which Safari does not do by default.
40
- let { pressProps: pressProps, isPressed: isPressed } = (0, $7CUUz$usePress)({
41
- isDisabled: isDisabled
42
- });
43
- // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
44
- let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $7CUUz$usePress)({
45
- isDisabled: isDisabled || isReadOnly,
46
- onPress () {
47
- state.toggle();
48
- }
49
- });
50
- let { focusableProps: focusableProps } = (0, $7CUUz$useFocusable)(props, ref);
51
- let interactions = (0, $7CUUz$mergeProps)(pressProps, focusableProps);
52
- let domProps = (0, $7CUUz$filterDOMProps)(props, {
53
- labelable: true
54
- });
55
- (0, $7CUUz$useFormReset)(ref, state.isSelected, state.setSelected);
56
- return {
57
- labelProps: (0, $7CUUz$mergeProps)(labelProps, {
58
- onClick: (e)=>e.preventDefault()
59
- }),
60
- inputProps: (0, $7CUUz$mergeProps)(domProps, {
61
- "aria-invalid": isInvalid || validationState === "invalid" || undefined,
62
- "aria-errormessage": props["aria-errormessage"],
63
- "aria-controls": props["aria-controls"],
64
- "aria-readonly": isReadOnly || undefined,
65
- onChange: onChange,
66
- disabled: isDisabled,
67
- ...value == null ? {} : {
68
- value: value
69
- },
70
- name: name,
71
- type: "checkbox",
72
- ...interactions
73
- }),
74
- isSelected: state.isSelected,
75
- isPressed: isPressed || isLabelPressed,
76
- isDisabled: isDisabled,
77
- isReadOnly: isReadOnly,
78
- isInvalid: isInvalid || validationState === "invalid"
79
- };
80
- }
81
-
82
-
83
-
84
-
85
16
  export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
86
17
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,24 +1,12 @@
1
- var $7WOm2$reactariautils = require("@react-aria/utils");
2
- var $7WOm2$reactariafocus = require("@react-aria/focus");
3
- var $7WOm2$reactariainteractions = require("@react-aria/interactions");
1
+ var $ee1b638d33c90dcc$exports = require("./useToggle.main.js");
4
2
 
5
3
 
6
4
  function $parcel$export(e, n, v, s) {
7
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
6
  }
9
7
 
10
- $parcel$export(module.exports, "useToggle", () => $ee1b638d33c90dcc$export$cbe85ee05b554577);
8
+ $parcel$export(module.exports, "useToggle", () => $ee1b638d33c90dcc$exports.useToggle);
11
9
  /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */ /*
22
10
  * Copyright 2020 Adobe. All rights reserved.
23
11
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
24
12
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -31,61 +19,4 @@ $parcel$export(module.exports, "useToggle", () => $ee1b638d33c90dcc$export$cbe85
31
19
  */
32
20
 
33
21
 
34
- function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) {
35
- let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
36
- let onChange = (e)=>{
37
- // since we spread props on label, onChange will end up there as well as in here.
38
- // so we have to stop propagation at the lowest level that we care about
39
- e.stopPropagation();
40
- state.setSelected(e.target.checked);
41
- };
42
- let hasChildren = children != null;
43
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
44
- if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
45
- // This handles focusing the input on pointer down, which Safari does not do by default.
46
- let { pressProps: pressProps, isPressed: isPressed } = (0, $7WOm2$reactariainteractions.usePress)({
47
- isDisabled: isDisabled
48
- });
49
- // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
50
- let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $7WOm2$reactariainteractions.usePress)({
51
- isDisabled: isDisabled || isReadOnly,
52
- onPress () {
53
- state.toggle();
54
- }
55
- });
56
- let { focusableProps: focusableProps } = (0, $7WOm2$reactariafocus.useFocusable)(props, ref);
57
- let interactions = (0, $7WOm2$reactariautils.mergeProps)(pressProps, focusableProps);
58
- let domProps = (0, $7WOm2$reactariautils.filterDOMProps)(props, {
59
- labelable: true
60
- });
61
- (0, $7WOm2$reactariautils.useFormReset)(ref, state.isSelected, state.setSelected);
62
- return {
63
- labelProps: (0, $7WOm2$reactariautils.mergeProps)(labelProps, {
64
- onClick: (e)=>e.preventDefault()
65
- }),
66
- inputProps: (0, $7WOm2$reactariautils.mergeProps)(domProps, {
67
- "aria-invalid": isInvalid || validationState === "invalid" || undefined,
68
- "aria-errormessage": props["aria-errormessage"],
69
- "aria-controls": props["aria-controls"],
70
- "aria-readonly": isReadOnly || undefined,
71
- onChange: onChange,
72
- disabled: isDisabled,
73
- ...value == null ? {} : {
74
- value: value
75
- },
76
- name: name,
77
- type: "checkbox",
78
- ...interactions
79
- }),
80
- isSelected: state.isSelected,
81
- isPressed: isPressed || isLabelPressed,
82
- isDisabled: isDisabled,
83
- isReadOnly: isReadOnly,
84
- isInvalid: isInvalid || validationState === "invalid"
85
- };
86
- }
87
-
88
-
89
-
90
-
91
22
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC;IACpG,IAAI,cACF,aAAa,mBACb,aAAa,cACb,KAAK,QACL,IAAI,YACJ,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,mBACjC,kBAAkB,oBAClB,SAAS,EACV,GAAG;IAEJ,IAAI,WAAW,CAAC;QACd,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACrC;IACF;IAEA,kGAAkG;IAClG,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QACjE,YAAY,cAAc;QAC1B;YACE,MAAM,MAAM;QACd;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,OAAO;IAC3C,IAAI,eAAe,CAAA,GAAA,gCAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,CAAA,GAAA,kCAAW,EAAE,KAAK,MAAM,UAAU,EAAE,MAAM,WAAW;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC/B,gBAAgB,aAAa,oBAAoB,aAAa;YAC9D,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,OAAO,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;QACA,YAAY,MAAM,UAAU;QAC5B,WAAW,aAAa;oBACxB;oBACA;QACA,WAAW,aAAa,oBAAoB;IAC9C;AACF;;CD9FC","sources":["packages/@react-aria/toggle/src/index.ts","packages/@react-aria/toggle/src/useToggle.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 */\n\nexport {useToggle} from './useToggle';\nexport type {AriaToggleProps} from '@react-types/checkbox';\nexport type {ToggleAria} from './useToggle';\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 {AriaToggleProps} from '@react-types/checkbox';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface ToggleAria {\n /** Props to be spread on the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to be spread on the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the toggle is selected. */\n isSelected: boolean,\n /** Whether the toggle is in a pressed state. */\n isPressed: boolean,\n /** Whether the toggle is disabled. */\n isDisabled: boolean,\n /** Whether the toggle is read only. */\n isReadOnly: boolean,\n /** Whether the toggle is invalid. */\n isInvalid: boolean\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLInputElement>): ToggleAria {\n let {\n isDisabled = false,\n isReadOnly = false,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid',\n isInvalid\n } = props;\n\n let onChange = (e) => {\n // since we spread props on label, onChange will end up there as well as in here.\n // so we have to stop propagation at the lowest level that we care about\n e.stopPropagation();\n state.setSelected(e.target.checked);\n };\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n // This handles focusing the input on pointer down, which Safari does not do by default.\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n state.toggle();\n }\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n useFormReset(ref, state.isSelected, state.setSelected);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n 'aria-invalid': isInvalid || validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n onChange,\n disabled: isDisabled,\n ...(value == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n }),\n isSelected: state.isSelected,\n isPressed: isPressed || isLabelPressed,\n isDisabled,\n isReadOnly,\n isInvalid: isInvalid || validationState === 'invalid'\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/toggle/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 */\n\nexport {useToggle} from './useToggle';\nexport type {AriaToggleProps} from '@react-types/checkbox';\nexport type {ToggleAria} from './useToggle';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,18 +1,6 @@
1
- import {mergeProps as $7CUUz$mergeProps, filterDOMProps as $7CUUz$filterDOMProps, useFormReset as $7CUUz$useFormReset} from "@react-aria/utils";
2
- import {useFocusable as $7CUUz$useFocusable} from "@react-aria/focus";
3
- import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
1
+ import {useToggle as $d2c8e2b0480f3f34$export$cbe85ee05b554577} from "./useToggle.module.js";
4
2
 
5
3
  /*
6
- * Copyright 2020 Adobe. All rights reserved.
7
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License. You may obtain a copy
9
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software distributed under
12
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
- * OF ANY KIND, either express or implied. See the License for the specific language
14
- * governing permissions and limitations under the License.
15
- */ /*
16
4
  * Copyright 2020 Adobe. All rights reserved.
17
5
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
6
  * you may not use this file except in compliance with the License. You may obtain a copy
@@ -25,62 +13,5 @@ import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
25
13
  */
26
14
 
27
15
 
28
- function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
29
- let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
30
- let onChange = (e)=>{
31
- // since we spread props on label, onChange will end up there as well as in here.
32
- // so we have to stop propagation at the lowest level that we care about
33
- e.stopPropagation();
34
- state.setSelected(e.target.checked);
35
- };
36
- let hasChildren = children != null;
37
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
38
- if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
39
- // This handles focusing the input on pointer down, which Safari does not do by default.
40
- let { pressProps: pressProps, isPressed: isPressed } = (0, $7CUUz$usePress)({
41
- isDisabled: isDisabled
42
- });
43
- // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
44
- let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $7CUUz$usePress)({
45
- isDisabled: isDisabled || isReadOnly,
46
- onPress () {
47
- state.toggle();
48
- }
49
- });
50
- let { focusableProps: focusableProps } = (0, $7CUUz$useFocusable)(props, ref);
51
- let interactions = (0, $7CUUz$mergeProps)(pressProps, focusableProps);
52
- let domProps = (0, $7CUUz$filterDOMProps)(props, {
53
- labelable: true
54
- });
55
- (0, $7CUUz$useFormReset)(ref, state.isSelected, state.setSelected);
56
- return {
57
- labelProps: (0, $7CUUz$mergeProps)(labelProps, {
58
- onClick: (e)=>e.preventDefault()
59
- }),
60
- inputProps: (0, $7CUUz$mergeProps)(domProps, {
61
- "aria-invalid": isInvalid || validationState === "invalid" || undefined,
62
- "aria-errormessage": props["aria-errormessage"],
63
- "aria-controls": props["aria-controls"],
64
- "aria-readonly": isReadOnly || undefined,
65
- onChange: onChange,
66
- disabled: isDisabled,
67
- ...value == null ? {} : {
68
- value: value
69
- },
70
- name: name,
71
- type: "checkbox",
72
- ...interactions
73
- }),
74
- isSelected: state.isSelected,
75
- isPressed: isPressed || isLabelPressed,
76
- isDisabled: isDisabled,
77
- isReadOnly: isReadOnly,
78
- isInvalid: isInvalid || validationState === "invalid"
79
- };
80
- }
81
-
82
-
83
-
84
-
85
16
  export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
86
17
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC;IACpG,IAAI,cACF,aAAa,mBACb,aAAa,cACb,KAAK,QACL,IAAI,YACJ,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,mBACjC,kBAAkB,oBAClB,SAAS,EACV,GAAG;IAEJ,IAAI,WAAW,CAAC;QACd,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBACrC;IACF;IAEA,kGAAkG;IAClG,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACjE,YAAY,cAAc;QAC1B;YACE,MAAM,MAAM;QACd;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,OAAO;IAC3C,IAAI,eAAe,CAAA,GAAA,iBAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,CAAA,GAAA,mBAAW,EAAE,KAAK,MAAM,UAAU,EAAE,MAAM,WAAW;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,gBAAgB,aAAa,oBAAoB,aAAa;YAC9D,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,OAAO,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;QACA,YAAY,MAAM,UAAU;QAC5B,WAAW,aAAa;oBACxB;oBACA;QACA,WAAW,aAAa,oBAAoB;IAC9C;AACF;;CD9FC","sources":["packages/@react-aria/toggle/src/index.ts","packages/@react-aria/toggle/src/useToggle.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 */\n\nexport {useToggle} from './useToggle';\nexport type {AriaToggleProps} from '@react-types/checkbox';\nexport type {ToggleAria} from './useToggle';\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 {AriaToggleProps} from '@react-types/checkbox';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface ToggleAria {\n /** Props to be spread on the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to be spread on the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the toggle is selected. */\n isSelected: boolean,\n /** Whether the toggle is in a pressed state. */\n isPressed: boolean,\n /** Whether the toggle is disabled. */\n isDisabled: boolean,\n /** Whether the toggle is read only. */\n isReadOnly: boolean,\n /** Whether the toggle is invalid. */\n isInvalid: boolean\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLInputElement>): ToggleAria {\n let {\n isDisabled = false,\n isReadOnly = false,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid',\n isInvalid\n } = props;\n\n let onChange = (e) => {\n // since we spread props on label, onChange will end up there as well as in here.\n // so we have to stop propagation at the lowest level that we care about\n e.stopPropagation();\n state.setSelected(e.target.checked);\n };\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n // This handles focusing the input on pointer down, which Safari does not do by default.\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n state.toggle();\n }\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n useFormReset(ref, state.isSelected, state.setSelected);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n 'aria-invalid': isInvalid || validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n onChange,\n disabled: isDisabled,\n ...(value == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n }),\n isSelected: state.isSelected,\n isPressed: isPressed || isLabelPressed,\n isDisabled,\n isReadOnly,\n isInvalid: isInvalid || validationState === 'invalid'\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/toggle/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 */\n\nexport {useToggle} from './useToggle';\nexport type {AriaToggleProps} from '@react-types/checkbox';\nexport type {ToggleAria} from './useToggle';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,79 @@
1
+ var $2jyrz$reactariautils = require("@react-aria/utils");
2
+ var $2jyrz$reactariafocus = require("@react-aria/focus");
3
+ var $2jyrz$reactariainteractions = require("@react-aria/interactions");
4
+
5
+
6
+ function $parcel$export(e, n, v, s) {
7
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
8
+ }
9
+
10
+ $parcel$export(module.exports, "useToggle", () => $ee1b638d33c90dcc$export$cbe85ee05b554577);
11
+ /*
12
+ * Copyright 2020 Adobe. All rights reserved.
13
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License. You may obtain a copy
15
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software distributed under
18
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
+ * OF ANY KIND, either express or implied. See the License for the specific language
20
+ * governing permissions and limitations under the License.
21
+ */
22
+
23
+
24
+ function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) {
25
+ let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
26
+ let onChange = (e)=>{
27
+ // since we spread props on label, onChange will end up there as well as in here.
28
+ // so we have to stop propagation at the lowest level that we care about
29
+ e.stopPropagation();
30
+ state.setSelected(e.target.checked);
31
+ };
32
+ let hasChildren = children != null;
33
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
34
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
35
+ // This handles focusing the input on pointer down, which Safari does not do by default.
36
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $2jyrz$reactariainteractions.usePress)({
37
+ isDisabled: isDisabled
38
+ });
39
+ // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
40
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $2jyrz$reactariainteractions.usePress)({
41
+ isDisabled: isDisabled || isReadOnly,
42
+ onPress () {
43
+ state.toggle();
44
+ }
45
+ });
46
+ let { focusableProps: focusableProps } = (0, $2jyrz$reactariafocus.useFocusable)(props, ref);
47
+ let interactions = (0, $2jyrz$reactariautils.mergeProps)(pressProps, focusableProps);
48
+ let domProps = (0, $2jyrz$reactariautils.filterDOMProps)(props, {
49
+ labelable: true
50
+ });
51
+ (0, $2jyrz$reactariautils.useFormReset)(ref, state.isSelected, state.setSelected);
52
+ return {
53
+ labelProps: (0, $2jyrz$reactariautils.mergeProps)(labelProps, {
54
+ onClick: (e)=>e.preventDefault()
55
+ }),
56
+ inputProps: (0, $2jyrz$reactariautils.mergeProps)(domProps, {
57
+ "aria-invalid": isInvalid || validationState === "invalid" || undefined,
58
+ "aria-errormessage": props["aria-errormessage"],
59
+ "aria-controls": props["aria-controls"],
60
+ "aria-readonly": isReadOnly || undefined,
61
+ onChange: onChange,
62
+ disabled: isDisabled,
63
+ ...value == null ? {} : {
64
+ value: value
65
+ },
66
+ name: name,
67
+ type: "checkbox",
68
+ ...interactions
69
+ }),
70
+ isSelected: state.isSelected,
71
+ isPressed: isPressed || isLabelPressed,
72
+ isDisabled: isDisabled,
73
+ isReadOnly: isReadOnly,
74
+ isInvalid: isInvalid || validationState === "invalid"
75
+ };
76
+ }
77
+
78
+
79
+ //# sourceMappingURL=useToggle.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC;IACpG,IAAI,cACF,aAAa,mBACb,aAAa,cACb,KAAK,QACL,IAAI,YACJ,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,mBACjC,kBAAkB,oBAClB,SAAS,EACV,GAAG;IAEJ,IAAI,WAAW,CAAC;QACd,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;oBACrC;IACF;IAEA,kGAAkG;IAClG,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QACjE,YAAY,cAAc;QAC1B;YACE,MAAM,MAAM;QACd;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW,EAAE,OAAO;IAC3C,IAAI,eAAe,CAAA,GAAA,gCAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,CAAA,GAAA,kCAAW,EAAE,KAAK,MAAM,UAAU,EAAE,MAAM,WAAW;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,gCAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,gCAAS,EAAE,UAAU;YAC/B,gBAAgB,aAAa,oBAAoB,aAAa;YAC9D,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,OAAO,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;QACA,YAAY,MAAM,UAAU;QAC5B,WAAW,aAAa;oBACxB;oBACA;QACA,WAAW,aAAa,oBAAoB;IAC9C;AACF","sources":["packages/@react-aria/toggle/src/useToggle.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 */\n\nimport {AriaToggleProps} from '@react-types/checkbox';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface ToggleAria {\n /** Props to be spread on the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to be spread on the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the toggle is selected. */\n isSelected: boolean,\n /** Whether the toggle is in a pressed state. */\n isPressed: boolean,\n /** Whether the toggle is disabled. */\n isDisabled: boolean,\n /** Whether the toggle is read only. */\n isReadOnly: boolean,\n /** Whether the toggle is invalid. */\n isInvalid: boolean\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLInputElement>): ToggleAria {\n let {\n isDisabled = false,\n isReadOnly = false,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid',\n isInvalid\n } = props;\n\n let onChange = (e) => {\n // since we spread props on label, onChange will end up there as well as in here.\n // so we have to stop propagation at the lowest level that we care about\n e.stopPropagation();\n state.setSelected(e.target.checked);\n };\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n // This handles focusing the input on pointer down, which Safari does not do by default.\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n state.toggle();\n }\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n useFormReset(ref, state.isSelected, state.setSelected);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n 'aria-invalid': isInvalid || validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n onChange,\n disabled: isDisabled,\n ...(value == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n }),\n isSelected: state.isSelected,\n isPressed: isPressed || isLabelPressed,\n isDisabled,\n isReadOnly,\n isInvalid: isInvalid || validationState === 'invalid'\n };\n}\n"],"names":[],"version":3,"file":"useToggle.main.js.map"}
@@ -0,0 +1,74 @@
1
+ import {mergeProps as $bvdLj$mergeProps, filterDOMProps as $bvdLj$filterDOMProps, useFormReset as $bvdLj$useFormReset} from "@react-aria/utils";
2
+ import {useFocusable as $bvdLj$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $bvdLj$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
19
+ let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
20
+ let onChange = (e)=>{
21
+ // since we spread props on label, onChange will end up there as well as in here.
22
+ // so we have to stop propagation at the lowest level that we care about
23
+ e.stopPropagation();
24
+ state.setSelected(e.target.checked);
25
+ };
26
+ let hasChildren = children != null;
27
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
28
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
29
+ // This handles focusing the input on pointer down, which Safari does not do by default.
30
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $bvdLj$usePress)({
31
+ isDisabled: isDisabled
32
+ });
33
+ // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
34
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $bvdLj$usePress)({
35
+ isDisabled: isDisabled || isReadOnly,
36
+ onPress () {
37
+ state.toggle();
38
+ }
39
+ });
40
+ let { focusableProps: focusableProps } = (0, $bvdLj$useFocusable)(props, ref);
41
+ let interactions = (0, $bvdLj$mergeProps)(pressProps, focusableProps);
42
+ let domProps = (0, $bvdLj$filterDOMProps)(props, {
43
+ labelable: true
44
+ });
45
+ (0, $bvdLj$useFormReset)(ref, state.isSelected, state.setSelected);
46
+ return {
47
+ labelProps: (0, $bvdLj$mergeProps)(labelProps, {
48
+ onClick: (e)=>e.preventDefault()
49
+ }),
50
+ inputProps: (0, $bvdLj$mergeProps)(domProps, {
51
+ "aria-invalid": isInvalid || validationState === "invalid" || undefined,
52
+ "aria-errormessage": props["aria-errormessage"],
53
+ "aria-controls": props["aria-controls"],
54
+ "aria-readonly": isReadOnly || undefined,
55
+ onChange: onChange,
56
+ disabled: isDisabled,
57
+ ...value == null ? {} : {
58
+ value: value
59
+ },
60
+ name: name,
61
+ type: "checkbox",
62
+ ...interactions
63
+ }),
64
+ isSelected: state.isSelected,
65
+ isPressed: isPressed || isLabelPressed,
66
+ isDisabled: isDisabled,
67
+ isReadOnly: isReadOnly,
68
+ isInvalid: isInvalid || validationState === "invalid"
69
+ };
70
+ }
71
+
72
+
73
+ export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
74
+ //# sourceMappingURL=useToggle.mjs.map
@@ -0,0 +1,74 @@
1
+ import {mergeProps as $bvdLj$mergeProps, filterDOMProps as $bvdLj$filterDOMProps, useFormReset as $bvdLj$useFormReset} from "@react-aria/utils";
2
+ import {useFocusable as $bvdLj$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $bvdLj$usePress} from "@react-aria/interactions";
4
+
5
+ /*
6
+ * Copyright 2020 Adobe. All rights reserved.
7
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License. You may obtain a copy
9
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software distributed under
12
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
13
+ * OF ANY KIND, either express or implied. See the License for the specific language
14
+ * governing permissions and limitations under the License.
15
+ */
16
+
17
+
18
+ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
19
+ let { isDisabled: isDisabled = false, isReadOnly: isReadOnly = false, value: value, name: name, children: children, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, validationState: validationState = "valid", isInvalid: isInvalid } = props;
20
+ let onChange = (e)=>{
21
+ // since we spread props on label, onChange will end up there as well as in here.
22
+ // so we have to stop propagation at the lowest level that we care about
23
+ e.stopPropagation();
24
+ state.setSelected(e.target.checked);
25
+ };
26
+ let hasChildren = children != null;
27
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
28
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
29
+ // This handles focusing the input on pointer down, which Safari does not do by default.
30
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $bvdLj$usePress)({
31
+ isDisabled: isDisabled
32
+ });
33
+ // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.
34
+ let { pressProps: labelProps, isPressed: isLabelPressed } = (0, $bvdLj$usePress)({
35
+ isDisabled: isDisabled || isReadOnly,
36
+ onPress () {
37
+ state.toggle();
38
+ }
39
+ });
40
+ let { focusableProps: focusableProps } = (0, $bvdLj$useFocusable)(props, ref);
41
+ let interactions = (0, $bvdLj$mergeProps)(pressProps, focusableProps);
42
+ let domProps = (0, $bvdLj$filterDOMProps)(props, {
43
+ labelable: true
44
+ });
45
+ (0, $bvdLj$useFormReset)(ref, state.isSelected, state.setSelected);
46
+ return {
47
+ labelProps: (0, $bvdLj$mergeProps)(labelProps, {
48
+ onClick: (e)=>e.preventDefault()
49
+ }),
50
+ inputProps: (0, $bvdLj$mergeProps)(domProps, {
51
+ "aria-invalid": isInvalid || validationState === "invalid" || undefined,
52
+ "aria-errormessage": props["aria-errormessage"],
53
+ "aria-controls": props["aria-controls"],
54
+ "aria-readonly": isReadOnly || undefined,
55
+ onChange: onChange,
56
+ disabled: isDisabled,
57
+ ...value == null ? {} : {
58
+ value: value
59
+ },
60
+ name: name,
61
+ type: "checkbox",
62
+ ...interactions
63
+ }),
64
+ isSelected: state.isSelected,
65
+ isPressed: isPressed || isLabelPressed,
66
+ isDisabled: isDisabled,
67
+ isReadOnly: isReadOnly,
68
+ isInvalid: isInvalid || validationState === "invalid"
69
+ };
70
+ }
71
+
72
+
73
+ export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
74
+ //# sourceMappingURL=useToggle.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AA6BM,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC;IACpG,IAAI,cACF,aAAa,mBACb,aAAa,cACb,KAAK,QACL,IAAI,YACJ,QAAQ,EACR,cAAc,SAAS,EACvB,mBAAmB,cAAc,mBACjC,kBAAkB,oBAClB,SAAS,EACV,GAAG;IAEJ,IAAI,WAAW,CAAC;QACd,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY;IAC9B,IAAI,eAAe,aAAa,QAAQ,kBAAkB;IAC1D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,UAAU,aAAE,SAAS,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;oBACrC;IACF;IAEA,kGAAkG;IAClG,IAAI,EAAC,YAAY,UAAU,EAAE,WAAW,cAAc,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QACjE,YAAY,cAAc;QAC1B;YACE,MAAM,MAAM;QACd;IACF;IAEA,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE,OAAO;IAC3C,IAAI,eAAe,CAAA,GAAA,iBAAS,EAAE,YAAY;IAC1C,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IAErD,CAAA,GAAA,mBAAW,EAAE,KAAK,MAAM,UAAU,EAAE,MAAM,WAAW;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,iBAAS,EAAE,YAAY;YAAC,SAAS,CAAA,IAAK,EAAE,cAAc;QAAE;QACpE,YAAY,CAAA,GAAA,iBAAS,EAAE,UAAU;YAC/B,gBAAgB,aAAa,oBAAoB,aAAa;YAC9D,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,OAAO,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;QACA,YAAY,MAAM,UAAU;QAC5B,WAAW,aAAa;oBACxB;oBACA;QACA,WAAW,aAAa,oBAAoB;IAC9C;AACF","sources":["packages/@react-aria/toggle/src/useToggle.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 */\n\nimport {AriaToggleProps} from '@react-types/checkbox';\nimport {filterDOMProps, mergeProps, useFormReset} from '@react-aria/utils';\nimport {InputHTMLAttributes, LabelHTMLAttributes, RefObject} from 'react';\nimport {ToggleState} from '@react-stately/toggle';\nimport {useFocusable} from '@react-aria/focus';\nimport {usePress} from '@react-aria/interactions';\n\nexport interface ToggleAria {\n /** Props to be spread on the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n /** Props to be spread on the input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n /** Whether the toggle is selected. */\n isSelected: boolean,\n /** Whether the toggle is in a pressed state. */\n isPressed: boolean,\n /** Whether the toggle is disabled. */\n isDisabled: boolean,\n /** Whether the toggle is read only. */\n isReadOnly: boolean,\n /** Whether the toggle is invalid. */\n isInvalid: boolean\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLInputElement>): ToggleAria {\n let {\n isDisabled = false,\n isReadOnly = false,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid',\n isInvalid\n } = props;\n\n let onChange = (e) => {\n // since we spread props on label, onChange will end up there as well as in here.\n // so we have to stop propagation at the lowest level that we care about\n e.stopPropagation();\n state.setSelected(e.target.checked);\n };\n\n let hasChildren = children != null;\n let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;\n if (!hasChildren && !hasAriaLabel) {\n console.warn('If you do not provide children, you must specify an aria-label for accessibility');\n }\n\n // This handles focusing the input on pointer down, which Safari does not do by default.\n let {pressProps, isPressed} = usePress({\n isDisabled\n });\n\n // iOS does not toggle checkboxes if you drag off and back onto the label, so handle it ourselves.\n let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({\n isDisabled: isDisabled || isReadOnly,\n onPress() {\n state.toggle();\n }\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n useFormReset(ref, state.isSelected, state.setSelected);\n\n return {\n labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),\n inputProps: mergeProps(domProps, {\n 'aria-invalid': isInvalid || validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n onChange,\n disabled: isDisabled,\n ...(value == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n }),\n isSelected: state.isSelected,\n isPressed: isPressed || isLabelPressed,\n isDisabled,\n isReadOnly,\n isInvalid: isInvalid || validationState === 'invalid'\n };\n}\n"],"names":[],"version":3,"file":"useToggle.module.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/toggle",
3
- "version": "3.10.2",
3
+ "version": "3.10.3",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,11 +22,11 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-aria/focus": "^3.16.2",
26
- "@react-aria/interactions": "^3.21.1",
27
- "@react-aria/utils": "^3.23.2",
28
- "@react-stately/toggle": "^3.7.2",
29
- "@react-types/checkbox": "^3.7.1",
25
+ "@react-aria/focus": "^3.17.0",
26
+ "@react-aria/interactions": "^3.21.2",
27
+ "@react-aria/utils": "^3.24.0",
28
+ "@react-stately/toggle": "^3.7.3",
29
+ "@react-types/checkbox": "^3.8.0",
30
30
  "@swc/helpers": "^0.5.0"
31
31
  },
32
32
  "peerDependencies": {
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
38
+ "gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
39
39
  }