@react-aria/toggle 3.1.5 → 3.2.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/main.js CHANGED
@@ -1,80 +1,71 @@
1
- var {
2
- usePress
3
- } = require("@react-aria/interactions");
1
+ var $7WOm2$reactariautils = require("@react-aria/utils");
2
+ var $7WOm2$reactariafocus = require("@react-aria/focus");
3
+ var $7WOm2$reactariainteractions = require("@react-aria/interactions");
4
4
 
5
- var {
6
- useFocusable
7
- } = require("@react-aria/focus");
5
+ function $parcel$exportWildcard(dest, source) {
6
+ Object.keys(source).forEach(function(key) {
7
+ if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
8
+ return;
9
+ }
8
10
 
9
- var {
10
- filterDOMProps,
11
- mergeProps
12
- } = require("@react-aria/utils");
13
-
14
- var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
11
+ Object.defineProperty(dest, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return source[key];
15
+ }
16
+ });
17
+ });
15
18
 
16
- function $parcel$interopDefault(a) {
17
- return a && a.__esModule ? a.default : a;
19
+ return dest;
18
20
  }
21
+ function $parcel$export(e, n, v, s) {
22
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
23
+ }
24
+ var $ee1b638d33c90dcc$exports = {};
25
+
26
+ $parcel$export($ee1b638d33c90dcc$exports, "useToggle", () => $ee1b638d33c90dcc$export$cbe85ee05b554577);
19
27
 
20
- /**
21
- * Handles interactions for toggle elements, e.g. Checkboxes and Switches.
22
- */
23
- function useToggle(props, state, ref) {
24
- let {
25
- isDisabled = false,
26
- isRequired,
27
- isReadOnly,
28
- value,
29
- name,
30
- children,
31
- 'aria-label': ariaLabel,
32
- 'aria-labelledby': ariaLabelledby,
33
- validationState = 'valid'
34
- } = props;
35
28
 
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
29
 
43
- let hasChildren = children != null;
44
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
30
+ function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) {
31
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby , validationState: validationState = 'valid' } = props;
32
+ let onChange = (e)=>{
33
+ // since we spread props on label, onChange will end up there as well as in here.
34
+ // so we have to stop propagation at the lowest level that we care about
35
+ e.stopPropagation();
36
+ state.setSelected(e.target.checked);
37
+ };
38
+ let hasChildren = children != null;
39
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
40
+ if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
41
+ // This handles focusing the input on pointer down, which Safari does not do by default.
42
+ let { pressProps: pressProps } = $7WOm2$reactariainteractions.usePress({
43
+ isDisabled: isDisabled
44
+ });
45
+ let { focusableProps: focusableProps } = $7WOm2$reactariafocus.useFocusable(props, ref);
46
+ let interactions = $7WOm2$reactariautils.mergeProps(pressProps, focusableProps);
47
+ let domProps = $7WOm2$reactariautils.filterDOMProps(props, {
48
+ labelable: true
49
+ });
50
+ return {
51
+ inputProps: $7WOm2$reactariautils.mergeProps(domProps, {
52
+ 'aria-invalid': validationState === 'invalid' || undefined,
53
+ 'aria-errormessage': props['aria-errormessage'],
54
+ 'aria-controls': props['aria-controls'],
55
+ 'aria-readonly': isReadOnly || undefined,
56
+ 'aria-required': isRequired || undefined,
57
+ onChange: onChange,
58
+ disabled: isDisabled,
59
+ value: value,
60
+ name: name,
61
+ type: 'checkbox',
62
+ ...interactions
63
+ })
64
+ };
65
+ }
45
66
 
46
- if (!hasChildren && !hasAriaLabel) {
47
- console.warn('If you do not provide children, you must specify an aria-label for accessibility');
48
- } // This handles focusing the input on pointer down, which Safari does not do by default.
49
67
 
68
+ $parcel$exportWildcard(module.exports, $ee1b638d33c90dcc$exports);
50
69
 
51
- let {
52
- pressProps
53
- } = usePress({
54
- isDisabled
55
- });
56
- let {
57
- focusableProps
58
- } = useFocusable(props, ref);
59
- let interactions = mergeProps(pressProps, focusableProps);
60
- let domProps = filterDOMProps(props, {
61
- labelable: true
62
- });
63
- return {
64
- inputProps: mergeProps(domProps, _babelRuntimeHelpersExtends({
65
- 'aria-invalid': validationState === 'invalid' || undefined,
66
- 'aria-errormessage': props['aria-errormessage'],
67
- 'aria-controls': props['aria-controls'],
68
- 'aria-readonly': isReadOnly || undefined,
69
- 'aria-required': isRequired || undefined,
70
- onChange,
71
- disabled: isDisabled,
72
- value,
73
- name,
74
- type: 'checkbox'
75
- }, interactions))
76
- };
77
- }
78
70
 
79
- exports.useToggle = useToggle;
80
71
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACwBD;;;AAGO,SAASG,SAAT,CAAmBC,KAAnB,EAA2CC,KAA3C,EAA+DC,GAA/D,EAAwG;AAC7G,MAAI;AACFC,IAAAA,UAAU,GAAG,KADX;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,UAHE;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,IALE;AAMFC,IAAAA,QANE;AAOF,kBAAcC,SAPZ;AAQF,uBAAmBC,cARjB;AASFC,IAAAA,eAAe,GAAG;AAThB,MAUAX,KAVJ;;AAYA,MAAIY,QAAQ,GAAIC,CAAD,IAAO;AACpB;AACA;AACAA,IAAAA,CAAC,CAACC,eAAF;AACAb,IAAAA,KAAK,CAACc,WAAN,CAAkBF,CAAC,CAACG,MAAF,CAASC,OAA3B;AACD,GALD;;AAOA,MAAIC,WAAW,GAAGV,QAAQ,IAAI,IAA9B;AACA,MAAIW,YAAY,GAAGV,SAAS,IAAI,IAAb,IAAqBC,cAAc,IAAI,IAA1D;;AACA,MAAI,CAACQ,WAAD,IAAgB,CAACC,YAArB,EAAmC;AACjCC,IAAAA,OAAO,CAACC,IAAR,CAAa,kFAAb;AACD,GAxB4G,CA0B7G;;;AACA,MAAI;AAACC,IAAAA;AAAD,MAAeC,QAAQ,CAAC;AAC1BpB,IAAAA;AAD0B,GAAD,CAA3B;AAIA,MAAI;AAACqB,IAAAA;AAAD,MAAmBC,YAAY,CAACzB,KAAD,EAAQE,GAAR,CAAnC;AACA,MAAIwB,YAAY,GAAGC,UAAU,CAACL,UAAD,EAAaE,cAAb,CAA7B;AACA,MAAII,QAAQ,GAAGC,cAAc,CAAC7B,KAAD,EAAQ;AAAC8B,IAAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;AAEA,SAAO;AACLC,IAAAA,UAAU,EAAEJ,UAAU,CAACC,QAAD;AACpB,sBAAgBjB,eAAe,KAAK,SAApB,IAAiCqB,SAD7B;AAEpB,2BAAqBhC,KAAK,CAAC,mBAAD,CAFN;AAGpB,uBAAiBA,KAAK,CAAC,eAAD,CAHF;AAIpB,uBAAiBK,UAAU,IAAI2B,SAJX;AAKpB,uBAAiB5B,UAAU,IAAI4B,SALX;AAMpBpB,MAAAA,QANoB;AAOpBqB,MAAAA,QAAQ,EAAE9B,UAPU;AAQpBG,MAAAA,KARoB;AASpBC,MAAAA,IAToB;AAUpB2B,MAAAA,IAAI,EAAE;AAVc,OAWjBR,YAXiB;AADjB,GAAP;AAeD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/toggle/src/useToggle.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\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 {AriaToggleProps} from '@react-types/checkbox';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {InputHTMLAttributes, 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 /**\n * Props to be spread on the input element.\n */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLElement>): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid'\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n return {\n inputProps: mergeProps(domProps, {\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onChange,\n disabled: isDisabled,\n value,\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","useToggle","props","state","ref","isDisabled","isRequired","isReadOnly","value","name","children","ariaLabel","ariaLabelledby","validationState","onChange","e","stopPropagation","setSelected","target","checked","hasChildren","hasAriaLabel","console","warn","pressProps","usePress","focusableProps","useFocusable","interactions","mergeProps","domProps","filterDOMProps","labelable","inputProps","undefined","disabled","type"],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,KAAkB,EAAE,GAA2B,EAAc,CAAC;IAC9G,GAAG,CAAC,CAAC,aACH,UAAU,GAAG,KAAK,eAClB,UAAU,eACV,UAAU,UACV,KAAK,SACL,IAAI,aACJ,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,oBACjC,eAAe,GAAG,CAAO,QAC3B,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAK,CAAC;QACrB,EAAiF,AAAjF,+EAAiF;QACjF,EAAwE,AAAxE,sEAAwE;QACxE,CAAC,CAAC,eAAe;QACjB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO;IACpC,CAAC;IAED,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IAAI;IAClC,GAAG,CAAC,YAAY,GAAG,SAAS,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI;IAC9D,EAAE,GAAG,WAAW,KAAK,YAAY,EAC/B,OAAO,CAAC,IAAI,CAAC,CAAkF;IAGjG,EAAwF,AAAxF,sFAAwF;IACxF,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,qCAAQ,CAAC,CAAC;oBAC3B,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,kCAAY,CAAC,KAAK,EAAE,GAAG;IAC9C,GAAG,CAAC,YAAY,GAAG,gCAAU,CAAC,UAAU,EAAE,cAAc;IACxD,GAAG,CAAC,QAAQ,GAAG,oCAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,gCAAU,CAAC,QAAQ,EAAE,CAAC;YAChC,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;sBACxC,QAAQ;YACR,QAAQ,EAAE,UAAU;mBACpB,KAAK;kBACL,IAAI;YACJ,IAAI,EAAE,CAAU;eACb,YAAY;QACjB,CAAC;IACH,CAAC;AACH,CAAC","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 * 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} from '@react-aria/utils';\nimport {InputHTMLAttributes, 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 /**\n * Props to be spread on the input element.\n */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLElement>): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid'\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n return {\n inputProps: mergeProps(domProps, {\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onChange,\n disabled: isDisabled,\n value,\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,64 +1,55 @@
1
- import { usePress } from "@react-aria/interactions";
2
- import { useFocusable } from "@react-aria/focus";
3
- import { filterDOMProps, mergeProps } from "@react-aria/utils";
4
- import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends";
1
+ import {mergeProps as $7CUUz$mergeProps, filterDOMProps as $7CUUz$filterDOMProps} from "@react-aria/utils";
2
+ import {useFocusable as $7CUUz$useFocusable} from "@react-aria/focus";
3
+ import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
5
4
 
6
- /**
7
- * Handles interactions for toggle elements, e.g. Checkboxes and Switches.
8
- */
9
- export function useToggle(props, state, ref) {
10
- let {
11
- isDisabled = false,
12
- isRequired,
13
- isReadOnly,
14
- value,
15
- name,
16
- children,
17
- 'aria-label': ariaLabel,
18
- 'aria-labelledby': ariaLabelledby,
19
- validationState = 'valid'
20
- } = props;
21
-
22
- let onChange = e => {
23
- // since we spread props on label, onChange will end up there as well as in here.
24
- // so we have to stop propagation at the lowest level that we care about
25
- e.stopPropagation();
26
- state.setSelected(e.target.checked);
27
- };
5
+ function $parcel$export(e, n, v, s) {
6
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
+ }
8
+ var $d2c8e2b0480f3f34$exports = {};
28
9
 
29
- let hasChildren = children != null;
30
- let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
10
+ $parcel$export($d2c8e2b0480f3f34$exports, "useToggle", () => $d2c8e2b0480f3f34$export$cbe85ee05b554577);
31
11
 
32
- if (!hasChildren && !hasAriaLabel) {
33
- console.warn('If you do not provide children, you must specify an aria-label for accessibility');
34
- } // This handles focusing the input on pointer down, which Safari does not do by default.
35
12
 
36
13
 
37
- let {
38
- pressProps
39
- } = usePress({
40
- isDisabled
41
- });
42
- let {
43
- focusableProps
44
- } = useFocusable(props, ref);
45
- let interactions = mergeProps(pressProps, focusableProps);
46
- let domProps = filterDOMProps(props, {
47
- labelable: true
48
- });
49
- return {
50
- inputProps: mergeProps(domProps, _babelRuntimeHelpersEsmExtends({
51
- 'aria-invalid': validationState === 'invalid' || undefined,
52
- 'aria-errormessage': props['aria-errormessage'],
53
- 'aria-controls': props['aria-controls'],
54
- 'aria-readonly': isReadOnly || undefined,
55
- 'aria-required': isRequired || undefined,
56
- onChange,
57
- disabled: isDisabled,
58
- value,
59
- name,
60
- type: 'checkbox'
61
- }, interactions))
62
- };
14
+ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
15
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby , validationState: validationState = 'valid' } = props;
16
+ let onChange = (e)=>{
17
+ // since we spread props on label, onChange will end up there as well as in here.
18
+ // so we have to stop propagation at the lowest level that we care about
19
+ e.stopPropagation();
20
+ state.setSelected(e.target.checked);
21
+ };
22
+ let hasChildren = children != null;
23
+ let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
24
+ if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
25
+ // This handles focusing the input on pointer down, which Safari does not do by default.
26
+ let { pressProps: pressProps } = $7CUUz$usePress({
27
+ isDisabled: isDisabled
28
+ });
29
+ let { focusableProps: focusableProps } = $7CUUz$useFocusable(props, ref);
30
+ let interactions = $7CUUz$mergeProps(pressProps, focusableProps);
31
+ let domProps = $7CUUz$filterDOMProps(props, {
32
+ labelable: true
33
+ });
34
+ return {
35
+ inputProps: $7CUUz$mergeProps(domProps, {
36
+ 'aria-invalid': validationState === 'invalid' || undefined,
37
+ 'aria-errormessage': props['aria-errormessage'],
38
+ 'aria-controls': props['aria-controls'],
39
+ 'aria-readonly': isReadOnly || undefined,
40
+ 'aria-required': isRequired || undefined,
41
+ onChange: onChange,
42
+ disabled: isDisabled,
43
+ value: value,
44
+ name: name,
45
+ type: 'checkbox',
46
+ ...interactions
47
+ })
48
+ };
63
49
  }
50
+
51
+
52
+
53
+
54
+ export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
64
55
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;;;AA0BA;;;OAGO,SAASA,SAAT,CAAmBC,KAAnB,EAA2CC,KAA3C,EAA+DC,GAA/D,EAAwG;AAC7G,MAAI;AACFC,IAAAA,UAAU,GAAG,KADX;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,UAHE;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,IALE;AAMFC,IAAAA,QANE;AAOF,kBAAcC,SAPZ;AAQF,uBAAmBC,cARjB;AASFC,IAAAA,eAAe,GAAG;AAThB,MAUAX,KAVJ;;AAYA,MAAIY,QAAQ,GAAIC,CAAD,IAAO;AACpB;AACA;AACAA,IAAAA,CAAC,CAACC,eAAF;AACAb,IAAAA,KAAK,CAACc,WAAN,CAAkBF,CAAC,CAACG,MAAF,CAASC,OAA3B;AACD,GALD;;AAOA,MAAIC,WAAW,GAAGV,QAAQ,IAAI,IAA9B;AACA,MAAIW,YAAY,GAAGV,SAAS,IAAI,IAAb,IAAqBC,cAAc,IAAI,IAA1D;;AACA,MAAI,CAACQ,WAAD,IAAgB,CAACC,YAArB,EAAmC;AACjCC,IAAAA,OAAO,CAACC,IAAR,CAAa,kFAAb;AACD,GAxB4G,CA0B7G;;;AACA,MAAI;AAACC,IAAAA;AAAD,MAAeC,QAAQ,CAAC;AAC1BpB,IAAAA;AAD0B,GAAD,CAA3B;AAIA,MAAI;AAACqB,IAAAA;AAAD,MAAmBC,YAAY,CAACzB,KAAD,EAAQE,GAAR,CAAnC;AACA,MAAIwB,YAAY,GAAGC,UAAU,CAACL,UAAD,EAAaE,cAAb,CAA7B;AACA,MAAII,QAAQ,GAAGC,cAAc,CAAC7B,KAAD,EAAQ;AAAC8B,IAAAA,SAAS,EAAE;AAAZ,GAAR,CAA7B;AAEA,SAAO;AACLC,IAAAA,UAAU,EAAEJ,UAAU,CAACC,QAAD;AACpB,sBAAgBjB,eAAe,KAAK,SAApB,IAAiCqB,SAD7B;AAEpB,2BAAqBhC,KAAK,CAAC,mBAAD,CAFN;AAGpB,uBAAiBA,KAAK,CAAC,eAAD,CAHF;AAIpB,uBAAiBK,UAAU,IAAI2B,SAJX;AAKpB,uBAAiB5B,UAAU,IAAI4B,SALX;AAMpBpB,MAAAA,QANoB;AAOpBqB,MAAAA,QAAQ,EAAE9B,UAPU;AAQpBG,MAAAA,KARoB;AASpBC,MAAAA,IAToB;AAUpB2B,MAAAA,IAAI,EAAE;AAVc,OAWjBR,YAXiB;AADjB,GAAP;AAeD","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} from '@react-aria/utils';\nimport {InputHTMLAttributes, 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 /**\n * Props to be spread on the input element.\n */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLElement>): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid'\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n return {\n inputProps: mergeProps(domProps, {\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onChange,\n disabled: isDisabled,\n value,\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":["useToggle","props","state","ref","isDisabled","isRequired","isReadOnly","value","name","children","ariaLabel","ariaLabelledby","validationState","onChange","e","stopPropagation","setSelected","target","checked","hasChildren","hasAriaLabel","console","warn","pressProps","usePress","focusableProps","useFocusable","interactions","mergeProps","domProps","filterDOMProps","labelable","inputProps","undefined","disabled","type"],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,KAAkB,EAAE,GAA2B,EAAc,CAAC;IAC9G,GAAG,CAAC,CAAC,aACH,UAAU,GAAG,KAAK,eAClB,UAAU,eACV,UAAU,UACV,KAAK,SACL,IAAI,aACJ,QAAQ,GACR,CAAY,aAAE,SAAS,GACvB,CAAiB,kBAAE,cAAc,oBACjC,eAAe,GAAG,CAAO,QAC3B,CAAC,GAAG,KAAK;IAET,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAK,CAAC;QACrB,EAAiF,AAAjF,+EAAiF;QACjF,EAAwE,AAAxE,sEAAwE;QACxE,CAAC,CAAC,eAAe;QACjB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO;IACpC,CAAC;IAED,GAAG,CAAC,WAAW,GAAG,QAAQ,IAAI,IAAI;IAClC,GAAG,CAAC,YAAY,GAAG,SAAS,IAAI,IAAI,IAAI,cAAc,IAAI,IAAI;IAC9D,EAAE,GAAG,WAAW,KAAK,YAAY,EAC/B,OAAO,CAAC,IAAI,CAAC,CAAkF;IAGjG,EAAwF,AAAxF,sFAAwF;IACxF,GAAG,CAAC,CAAC,aAAA,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,CAAC;oBAC3B,UAAU;IACZ,CAAC;IAED,GAAG,CAAC,CAAC,iBAAA,cAAc,EAAA,CAAC,GAAG,mBAAY,CAAC,KAAK,EAAE,GAAG;IAC9C,GAAG,CAAC,YAAY,GAAG,iBAAU,CAAC,UAAU,EAAE,cAAc;IACxD,GAAG,CAAC,QAAQ,GAAG,qBAAc,CAAC,KAAK,EAAE,CAAC;QAAA,SAAS,EAAE,IAAI;IAAA,CAAC;IAEtD,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,iBAAU,CAAC,QAAQ,EAAE,CAAC;YAChC,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,KAAK,CAAC,CAAmB;YAC9C,CAAe,gBAAE,KAAK,CAAC,CAAe;YACtC,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAe,gBAAE,UAAU,IAAI,SAAS;sBACxC,QAAQ;YACR,QAAQ,EAAE,UAAU;mBACpB,KAAK;kBACL,IAAI;YACJ,IAAI,EAAE,CAAU;eACb,YAAY;QACjB,CAAC;IACH,CAAC;AACH,CAAC","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 * 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} from '@react-aria/utils';\nimport {InputHTMLAttributes, 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 /**\n * Props to be spread on the input element.\n */\n inputProps: InputHTMLAttributes<HTMLInputElement>\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefObject<HTMLElement>): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n children,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledby,\n validationState = 'valid'\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} = usePress({\n isDisabled\n });\n\n let {focusableProps} = useFocusable(props, ref);\n let interactions = mergeProps(pressProps, focusableProps);\n let domProps = filterDOMProps(props, {labelable: true});\n\n return {\n inputProps: mergeProps(domProps, {\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': props['aria-errormessage'],\n 'aria-controls': props['aria-controls'],\n 'aria-readonly': isReadOnly || undefined,\n 'aria-required': isRequired || undefined,\n onChange,\n disabled: isDisabled,\n value,\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -1 +1 @@
1
- {"mappings":"A;A;A;AAmBA;IACE;A;OAEG;IACH,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAA;CAClD;AAED;A;GAEG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,UAAU,CAkD7G","sources":["./packages/@react-aria/toggle/src/packages/@react-aria/toggle/src/useToggle.ts","./packages/@react-aria/toggle/src/packages/@react-aria/toggle/src/index.ts"],"sourcesContent":[null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;AAmBA;IACE;;OAEG;IACH,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAA;CAClD;AAED;;GAEG;AACH,0BAA0B,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,UAAU,WAAW,CAAC,GAAG,UAAU,CAkD7G","sources":["packages/@react-aria/toggle/src/packages/@react-aria/toggle/src/useToggle.ts","packages/@react-aria/toggle/src/packages/@react-aria/toggle/src/index.ts","packages/@react-aria/toggle/src/index.ts"],"sourcesContent":[null,null,"/*\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 * from './useToggle';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-aria/toggle",
3
- "version": "3.1.5",
3
+ "version": "3.2.2",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -18,13 +18,13 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.4.1",
22
- "@react-aria/interactions": "^3.7.0",
23
- "@react-aria/utils": "^3.10.0",
24
- "@react-stately/toggle": "^3.2.3",
25
- "@react-types/checkbox": "^3.2.3",
26
- "@react-types/shared": "^3.10.0",
27
- "@react-types/switch": "^3.1.2"
21
+ "@react-aria/focus": "^3.5.3",
22
+ "@react-aria/interactions": "^3.8.2",
23
+ "@react-aria/utils": "^3.11.3",
24
+ "@react-stately/toggle": "^3.2.6",
25
+ "@react-types/checkbox": "^3.2.6",
26
+ "@react-types/shared": "^3.11.2",
27
+ "@react-types/switch": "^3.1.5"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "^16.8.0 || ^17.0.0-rc.1"
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "896eabe5521a0349a675c4773ed7629addd4b8c4"
35
+ "gitHead": "ed8d8d984c2f7f2c31e8b18795b97858a95e4729"
36
36
  }