@react-aria/toggle 3.4.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,71 @@
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";
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
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
26
+
27
+
28
+ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
29
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby , validationState: validationState = "valid" } = 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 } = (0, $7CUUz$usePress)({
41
+ isDisabled: isDisabled
42
+ });
43
+ let { focusableProps: focusableProps } = (0, $7CUUz$useFocusable)(props, ref);
44
+ let interactions = (0, $7CUUz$mergeProps)(pressProps, focusableProps);
45
+ let domProps = (0, $7CUUz$filterDOMProps)(props, {
46
+ labelable: true
47
+ });
48
+ return {
49
+ inputProps: (0, $7CUUz$mergeProps)(domProps, {
50
+ "aria-invalid": validationState === "invalid" || undefined,
51
+ "aria-errormessage": props["aria-errormessage"],
52
+ "aria-controls": props["aria-controls"],
53
+ "aria-readonly": isReadOnly || undefined,
54
+ "aria-required": isRequired || undefined,
55
+ onChange: onChange,
56
+ disabled: isDisabled,
57
+ ...value == null ? {} : {
58
+ value: value
59
+ },
60
+ name: name,
61
+ type: "checkbox",
62
+ ...interactions
63
+ })
64
+ };
65
+ }
66
+
67
+
68
+
69
+
70
+ export {$d2c8e2b0480f3f34$export$cbe85ee05b554577 as useToggle};
71
+ //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -7,11 +7,31 @@ function $parcel$export(e, n, v, s) {
7
7
  }
8
8
 
9
9
  $parcel$export(module.exports, "useToggle", () => $ee1b638d33c90dcc$export$cbe85ee05b554577);
10
-
10
+ /*
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
+ * Copyright 2020 Adobe. All rights reserved.
22
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
23
+ * you may not use this file except in compliance with the License. You may obtain a copy
24
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software distributed under
27
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
28
+ * OF ANY KIND, either express or implied. See the License for the specific language
29
+ * governing permissions and limitations under the License.
30
+ */
11
31
 
12
32
 
13
33
  function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) {
14
- let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby , validationState: validationState = 'valid' } = props;
34
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby , validationState: validationState = "valid" } = props;
15
35
  let onChange = (e)=>{
16
36
  // since we spread props on label, onChange will end up there as well as in here.
17
37
  // so we have to stop propagation at the lowest level that we care about
@@ -20,31 +40,30 @@ function $ee1b638d33c90dcc$export$cbe85ee05b554577(props, state, ref) {
20
40
  };
21
41
  let hasChildren = children != null;
22
42
  let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
23
- if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
43
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
24
44
  // This handles focusing the input on pointer down, which Safari does not do by default.
25
- let { pressProps: pressProps } = $7WOm2$reactariainteractions.usePress({
45
+ let { pressProps: pressProps } = (0, $7WOm2$reactariainteractions.usePress)({
26
46
  isDisabled: isDisabled
27
47
  });
28
- let { focusableProps: focusableProps } = $7WOm2$reactariafocus.useFocusable(props, ref);
29
- let interactions = $7WOm2$reactariautils.mergeProps(pressProps, focusableProps);
30
- let domProps = $7WOm2$reactariautils.filterDOMProps(props, {
48
+ let { focusableProps: focusableProps } = (0, $7WOm2$reactariafocus.useFocusable)(props, ref);
49
+ let interactions = (0, $7WOm2$reactariautils.mergeProps)(pressProps, focusableProps);
50
+ let domProps = (0, $7WOm2$reactariautils.filterDOMProps)(props, {
31
51
  labelable: true
32
52
  });
33
53
  return {
34
- inputProps: $7WOm2$reactariautils.mergeProps(domProps, {
35
- 'aria-invalid': validationState === 'invalid' || undefined,
36
- 'aria-errormessage': props['aria-errormessage'],
37
- 'aria-controls': props['aria-controls'],
38
- 'aria-readonly': isReadOnly || undefined,
39
- 'aria-required': isRequired || undefined,
54
+ inputProps: (0, $7WOm2$reactariautils.mergeProps)(domProps, {
55
+ "aria-invalid": validationState === "invalid" || undefined,
56
+ "aria-errormessage": props["aria-errormessage"],
57
+ "aria-controls": props["aria-controls"],
58
+ "aria-readonly": isReadOnly || undefined,
59
+ "aria-required": isRequired || undefined,
40
60
  onChange: onChange,
41
61
  disabled: isDisabled,
42
- ...value == null ? {
43
- } : {
62
+ ...value == null ? {} : {
44
63
  value: value
45
64
  },
46
65
  name: name,
47
- type: 'checkbox',
66
+ type: "checkbox",
48
67
  ...interactions
49
68
  })
50
69
  };
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,KAAkB,EAAE,GAAgC,EAAc,CAAC;IACnH,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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*\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} 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<HTMLInputElement>): 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 == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AAiBO,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC,EAAc;IAClH,IAAI,cACF,aAAa,KAAK,eAClB,WAAU,cACV,WAAU,SACV,MAAK,QACL,KAAI,YACJ,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,mBACjC,kBAAkB,UACnB,GAAG;IAEJ,IAAI,WAAW,CAAC,IAAM;QACpB,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY,IAAI;IAClC,IAAI,eAAe,aAAa,IAAI,IAAI,kBAAkB,IAAI;IAC9D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,qCAAQ,AAAD,EAAE;oBAC1B;IACF;IAEA,IAAI,kBAAC,eAAc,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;IAAA;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,gCAAU,AAAD,EAAE,UAAU;YAC/B,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,IAAI,GAAG,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;IACF;AACF;;CDrEC,GAED","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} 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<HTMLInputElement>): 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 == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -2,11 +2,31 @@ import {mergeProps as $7CUUz$mergeProps, filterDOMProps as $7CUUz$filterDOMProps
2
2
  import {useFocusable as $7CUUz$useFocusable} from "@react-aria/focus";
3
3
  import {usePress as $7CUUz$usePress} from "@react-aria/interactions";
4
4
 
5
-
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
+ * Copyright 2020 Adobe. All rights reserved.
17
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
+ * you may not use this file except in compliance with the License. You may obtain a copy
19
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
+ *
21
+ * Unless required by applicable law or agreed to in writing, software distributed under
22
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
+ * OF ANY KIND, either express or implied. See the License for the specific language
24
+ * governing permissions and limitations under the License.
25
+ */
6
26
 
7
27
 
8
28
  function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
9
- let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , 'aria-label': ariaLabel , 'aria-labelledby': ariaLabelledby , validationState: validationState = 'valid' } = props;
29
+ let { isDisabled: isDisabled = false , isRequired: isRequired , isReadOnly: isReadOnly , value: value , name: name , children: children , "aria-label": ariaLabel , "aria-labelledby": ariaLabelledby , validationState: validationState = "valid" } = props;
10
30
  let onChange = (e)=>{
11
31
  // since we spread props on label, onChange will end up there as well as in here.
12
32
  // so we have to stop propagation at the lowest level that we care about
@@ -15,31 +35,30 @@ function $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref) {
15
35
  };
16
36
  let hasChildren = children != null;
17
37
  let hasAriaLabel = ariaLabel != null || ariaLabelledby != null;
18
- if (!hasChildren && !hasAriaLabel) console.warn('If you do not provide children, you must specify an aria-label for accessibility');
38
+ if (!hasChildren && !hasAriaLabel) console.warn("If you do not provide children, you must specify an aria-label for accessibility");
19
39
  // This handles focusing the input on pointer down, which Safari does not do by default.
20
- let { pressProps: pressProps } = $7CUUz$usePress({
40
+ let { pressProps: pressProps } = (0, $7CUUz$usePress)({
21
41
  isDisabled: isDisabled
22
42
  });
23
- let { focusableProps: focusableProps } = $7CUUz$useFocusable(props, ref);
24
- let interactions = $7CUUz$mergeProps(pressProps, focusableProps);
25
- let domProps = $7CUUz$filterDOMProps(props, {
43
+ let { focusableProps: focusableProps } = (0, $7CUUz$useFocusable)(props, ref);
44
+ let interactions = (0, $7CUUz$mergeProps)(pressProps, focusableProps);
45
+ let domProps = (0, $7CUUz$filterDOMProps)(props, {
26
46
  labelable: true
27
47
  });
28
48
  return {
29
- inputProps: $7CUUz$mergeProps(domProps, {
30
- 'aria-invalid': validationState === 'invalid' || undefined,
31
- 'aria-errormessage': props['aria-errormessage'],
32
- 'aria-controls': props['aria-controls'],
33
- 'aria-readonly': isReadOnly || undefined,
34
- 'aria-required': isRequired || undefined,
49
+ inputProps: (0, $7CUUz$mergeProps)(domProps, {
50
+ "aria-invalid": validationState === "invalid" || undefined,
51
+ "aria-errormessage": props["aria-errormessage"],
52
+ "aria-controls": props["aria-controls"],
53
+ "aria-readonly": isReadOnly || undefined,
54
+ "aria-required": isRequired || undefined,
35
55
  onChange: onChange,
36
56
  disabled: isDisabled,
37
- ...value == null ? {
38
- } : {
57
+ ...value == null ? {} : {
39
58
  value: value
40
59
  },
41
60
  name: name,
42
- type: 'checkbox',
61
+ type: "checkbox",
43
62
  ...interactions
44
63
  })
45
64
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;SC6BgB,yCAAS,CAAC,KAAsB,EAAE,KAAkB,EAAE,GAAgC,EAAc,CAAC;IACnH,GAAG,CAAC,CAAC,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sBACxC,QAAQ;YACR,QAAQ,EAAE,UAAU;eAChB,KAAK,IAAI,IAAI,GAAG,CAAC;YAAA,CAAC,GAAG,CAAC;uBAAA,KAAK;YAAA,CAAC;kBAChC,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 {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} 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<HTMLInputElement>): 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 == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;;;AAiBO,SAAS,0CAAU,KAAsB,EAAE,KAAkB,EAAE,GAAgC,EAAc;IAClH,IAAI,cACF,aAAa,KAAK,eAClB,WAAU,cACV,WAAU,SACV,MAAK,QACL,KAAI,YACJ,SAAQ,EACR,cAAc,UAAS,EACvB,mBAAmB,eAAc,mBACjC,kBAAkB,UACnB,GAAG;IAEJ,IAAI,WAAW,CAAC,IAAM;QACpB,iFAAiF;QACjF,wEAAwE;QACxE,EAAE,eAAe;QACjB,MAAM,WAAW,CAAC,EAAE,MAAM,CAAC,OAAO;IACpC;IAEA,IAAI,cAAc,YAAY,IAAI;IAClC,IAAI,eAAe,aAAa,IAAI,IAAI,kBAAkB,IAAI;IAC9D,IAAI,CAAC,eAAe,CAAC,cACnB,QAAQ,IAAI,CAAC;IAGf,wFAAwF;IACxF,IAAI,cAAC,WAAU,EAAC,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAE;oBAC1B;IACF;IAEA,IAAI,kBAAC,eAAc,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;IAAA;IAErD,OAAO;QACL,YAAY,CAAA,GAAA,iBAAU,AAAD,EAAE,UAAU;YAC/B,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,KAAK,CAAC,oBAAoB;YAC/C,iBAAiB,KAAK,CAAC,gBAAgB;YACvC,iBAAiB,cAAc;YAC/B,iBAAiB,cAAc;sBAC/B;YACA,UAAU;YACV,GAAI,SAAS,IAAI,GAAG,CAAC,IAAI;uBAAC;YAAK,CAAC;kBAChC;YACA,MAAM;YACN,GAAG,YAAY;QACjB;IACF;AACF;;CDrEC,GAED","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} 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<HTMLInputElement>): 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 == null ? {} : {value}),\n name,\n type: 'checkbox',\n ...interactions\n })\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-aria/toggle",
3
- "version": "3.4.1",
3
+ "version": "3.5.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -17,14 +22,14 @@
17
22
  "url": "https://github.com/adobe/react-spectrum"
18
23
  },
19
24
  "dependencies": {
20
- "@babel/runtime": "^7.6.2",
21
- "@react-aria/focus": "^3.10.0",
22
- "@react-aria/interactions": "^3.13.0",
23
- "@react-aria/utils": "^3.14.1",
24
- "@react-stately/toggle": "^3.4.3",
25
- "@react-types/checkbox": "^3.4.1",
26
- "@react-types/shared": "^3.16.0",
27
- "@react-types/switch": "^3.2.5"
25
+ "@react-aria/focus": "^3.11.0",
26
+ "@react-aria/interactions": "^3.14.0",
27
+ "@react-aria/utils": "^3.15.0",
28
+ "@react-stately/toggle": "^3.5.0",
29
+ "@react-types/checkbox": "^3.4.2",
30
+ "@react-types/shared": "^3.17.0",
31
+ "@react-types/switch": "^3.3.0",
32
+ "@swc/helpers": "^0.4.14"
28
33
  },
29
34
  "peerDependencies": {
30
35
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
@@ -32,5 +37,5 @@
32
37
  "publishConfig": {
33
38
  "access": "public"
34
39
  },
35
- "gitHead": "2954307ddbefe149241685440c81f80ece6b2c83"
40
+ "gitHead": "a0efee84aa178cb1a202951dfd6d8de02b292307"
36
41
  }