@react-native-aria/button 0.2.2 → 0.2.5-alpha.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.
@@ -9,7 +9,7 @@ var _interactions = require("@react-native-aria/interactions");
9
9
 
10
10
  var _utils = require("@react-aria/utils");
11
11
 
12
- function useButton(props, ref) {
12
+ function useButton(props) {
13
13
  let {
14
14
  isDisabled,
15
15
  onPress,
@@ -26,15 +26,12 @@ function useButton(props, ref) {
26
26
  onPressEnd,
27
27
  onPressChange,
28
28
  onPress,
29
- isDisabled,
30
- ref
29
+ isDisabled
31
30
  });
32
31
  const mergedProps = (0, _utils.mergeProps)(pressProps, rest, {
33
- accessibilityState: {
34
- disabled: isDisabled
35
- },
36
- accessibilityRole: "button",
37
- disabled: isDisabled
32
+ 'aria-disabled': isDisabled,
33
+ 'role': 'button',
34
+ 'disabled': isDisabled
38
35
  });
39
36
  return {
40
37
  isPressed,
@@ -1 +1 @@
1
- {"version":3,"sources":["useButton.ts"],"names":["useButton","props","ref","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","rest","pressProps","isPressed","mergedProps","accessibilityState","disabled","accessibilityRole","buttonProps"],"mappings":";;;;;;;AACA;;AAEA;;AAkBO,SAASA,SAAT,CACLC,KADK,EAELC,GAFK,EAGO;AACZ,MAAI;AACFC,IAAAA,UADE;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKFC,IAAAA,aALE;AAMF,OAAGC;AAND,MAOAP,KAPJ;AASA,MAAI;AAAEQ,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4B,4BAAS;AACvCL,IAAAA,YADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,aAHuC;AAIvCH,IAAAA,OAJuC;AAKvCD,IAAAA,UALuC;AAMvCD,IAAAA;AANuC,GAAT,CAAhC;AASA,QAAMS,WAAW,GAAG,uBAAWF,UAAX,EAAuBD,IAAvB,EAA6B;AAC/CI,IAAAA,kBAAkB,EAAE;AAClBC,MAAAA,QAAQ,EAAEV;AADQ,KAD2B;AAI/CW,IAAAA,iBAAiB,EAAE,QAJ4B;AAK/CD,IAAAA,QAAQ,EAAEV;AALqC,GAA7B,CAApB;AAQA,SAAO;AACLO,IAAAA,SADK;AAELK,IAAAA,WAAW,EAAEJ;AAFR,GAAP;AAID","sourcesContent":["import { ReactNode, RefObject } from \"react\";\nimport { PressEvents, usePress } from \"@react-native-aria/interactions\";\nimport { AccessibilityProps, PressableProps } from \"react-native\";\nimport { mergeProps } from \"@react-aria/utils\";\n\ninterface ButtonProps extends PressEvents {\n /** Whether the button is disabled. */\n isDisabled?: boolean;\n /** The content to display in the button. */\n children?: ReactNode;\n}\n\nexport interface RNAriaButtonProps extends AccessibilityProps, ButtonProps {}\n\nexport interface ButtonAria {\n /** Props for the button element. */\n buttonProps: PressableProps;\n /** Whether the button is currently pressed. */\n isPressed: boolean;\n}\n\nexport function useButton(\n props: RNAriaButtonProps,\n ref: RefObject<any>\n): ButtonAria {\n let {\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n ...rest\n } = props;\n\n let { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n ref,\n });\n\n const mergedProps = mergeProps(pressProps, rest, {\n accessibilityState: {\n disabled: isDisabled,\n },\n accessibilityRole: \"button\",\n disabled: isDisabled,\n });\n\n return {\n isPressed,\n buttonProps: mergedProps,\n };\n}\n"]}
1
+ {"version":3,"sources":["useButton.ts"],"names":["useButton","props","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","rest","pressProps","isPressed","mergedProps","buttonProps"],"mappings":";;;;;;;AACA;;AAEA;;AAkBO,SAASA,SAAT,CAAmBC,KAAnB,EAAyD;AAC9D,MAAI;AACFC,IAAAA,UADE;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKFC,IAAAA,aALE;AAMF,OAAGC;AAND,MAOAN,KAPJ;AASA,MAAI;AAAEO,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4B,4BAAS;AACvCL,IAAAA,YADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,aAHuC;AAIvCH,IAAAA,OAJuC;AAKvCD,IAAAA;AALuC,GAAT,CAAhC;AAQA,QAAMQ,WAAW,GAAG,uBAAWF,UAAX,EAAuBD,IAAvB,EAA6B;AAC/C,qBAAiBL,UAD8B;AAE/C,YAAQ,QAFuC;AAG/C,gBAAYA;AAHmC,GAA7B,CAApB;AAMA,SAAO;AACLO,IAAAA,SADK;AAELE,IAAAA,WAAW,EAAED;AAFR,GAAP;AAID","sourcesContent":["import { ReactNode } from 'react';\nimport { PressEvents, usePress } from '@react-native-aria/interactions';\nimport { AccessibilityProps, PressableProps } from 'react-native';\nimport { mergeProps } from '@react-aria/utils';\n\ninterface ButtonProps extends PressEvents {\n /** Whether the button is disabled. */\n isDisabled?: boolean;\n /** The content to display in the button. */\n children?: ReactNode;\n}\n\nexport interface RNAriaButtonProps extends AccessibilityProps, ButtonProps {}\n\nexport interface ButtonAria {\n /** Props for the button element. */\n buttonProps: PressableProps;\n /** Whether the button is currently pressed. */\n isPressed: boolean;\n}\n\nexport function useButton(props: RNAriaButtonProps): ButtonAria {\n let {\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n ...rest\n } = props;\n\n let { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n });\n\n const mergedProps = mergeProps(pressProps, rest, {\n 'aria-disabled': isDisabled,\n 'role': 'button',\n 'disabled': isDisabled,\n });\n\n return {\n isPressed,\n buttonProps: mergedProps,\n };\n}\n"]}
@@ -9,7 +9,7 @@ var _useButton = require("./useButton");
9
9
 
10
10
  var _utils = require("@react-aria/utils");
11
11
 
12
- function useToggleButton(props, state, ref) {
12
+ function useToggleButton(props, state) {
13
13
  const {
14
14
  isSelected
15
15
  } = state;
@@ -18,13 +18,11 @@ function useToggleButton(props, state, ref) {
18
18
  buttonProps
19
19
  } = (0, _useButton.useButton)({ ...props,
20
20
  onPress: (0, _utils.chain)(state.toggle, props.onPress)
21
- }, ref);
21
+ });
22
22
  return {
23
23
  isPressed,
24
24
  buttonProps: (0, _utils.mergeProps)(buttonProps, {
25
- accessibilityState: {
26
- selected: isSelected
27
- }
25
+ 'aria-selected': isSelected
28
26
  })
29
27
  };
30
28
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useToggleButton.ts"],"names":["useToggleButton","props","state","ref","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityState","selected"],"mappings":";;;;;;;AAAA;;AAGA;;AAkBO,SAASA,eAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIO;AACZ,QAAM;AAAEC,IAAAA;AAAF,MAAiBF,KAAvB;AACA,QAAM;AAAEG,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6B,0BACjC,EACE,GAAGL,KADL;AAEEM,IAAAA,OAAO,EAAE,kBAAML,KAAK,CAACM,MAAZ,EAAoBP,KAAK,CAACM,OAA1B;AAFX,GADiC,EAKjCJ,GALiC,CAAnC;AAQA,SAAO;AACLE,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAE,uBAAWA,WAAX,EAAwB;AACnCG,MAAAA,kBAAkB,EAAE;AAClBC,QAAAA,QAAQ,EAAEN;AADQ;AADe,KAAxB;AAFR,GAAP;AAQD","sourcesContent":["import { ButtonAria, useButton } from \"./useButton\";\nimport type { ToggleState } from \"@react-stately/toggle\";\nimport type { RefObject } from \"react\";\nimport { chain, mergeProps } from \"@react-aria/utils\";\nimport type { PressEvents } from \"@react-native-aria/interactions\";\nimport type { PressableProps } from \"react-native\";\n\nexport type AriaButtonProps = PressableProps &\n PressEvents & {\n isDisabled: boolean;\n };\n\nexport interface AriaToggleButtonProps extends AriaButtonProps {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n}\n\nexport function useToggleButton(\n props: AriaToggleButtonProps,\n state: ToggleState,\n ref: RefObject<any>\n): ButtonAria {\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton(\n {\n ...props,\n onPress: chain(state.toggle, props.onPress),\n },\n ref\n );\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n accessibilityState: {\n selected: isSelected,\n },\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["useToggleButton.ts"],"names":["useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"],"mappings":";;;;;;;AAAA;;AAEA;;AAkBO,SAASA,eAAT,CACLC,KADK,EAELC,KAFK,EAGO;AACZ,QAAM;AAAEC,IAAAA;AAAF,MAAiBD,KAAvB;AACA,QAAM;AAAEE,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6B,0BAAU,EAC3C,GAAGJ,KADwC;AAE3CK,IAAAA,OAAO,EAAE,kBAAMJ,KAAK,CAACK,MAAZ,EAAoBN,KAAK,CAACK,OAA1B;AAFkC,GAAV,CAAnC;AAKA,SAAO;AACLF,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAE,uBAAWA,WAAX,EAAwB;AACnC,uBAAiBF;AADkB,KAAxB;AAFR,GAAP;AAMD","sourcesContent":["import { ButtonAria, useButton } from './useButton';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { chain, mergeProps } from '@react-aria/utils';\nimport type { PressEvents } from '@react-native-aria/interactions';\nimport type { PressableProps } from 'react-native';\n\nexport type AriaButtonProps = PressableProps &\n PressEvents & {\n isDisabled: boolean;\n };\n\nexport interface AriaToggleButtonProps extends AriaButtonProps {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n}\n\nexport function useToggleButton(\n props: AriaToggleButtonProps,\n state: ToggleState\n): ButtonAria {\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress),\n });\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-selected': isSelected,\n }),\n };\n}\n"]}
@@ -25,7 +25,7 @@ var _utils = require("@react-aria/utils");
25
25
  * Provides the behavior and accessibility implementation for a toggle button component.
26
26
  * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
27
27
  */
28
- function useToggleButton(props, state, ref) {
28
+ function useToggleButton(props, state) {
29
29
  /* eslint-enable no-redeclare */
30
30
  const {
31
31
  isSelected
@@ -35,14 +35,11 @@ function useToggleButton(props, state, ref) {
35
35
  buttonProps
36
36
  } = (0, _useButton.useButton)({ ...props,
37
37
  onPress: (0, _utils.chain)(state.toggle, props.onPress)
38
- }, ref);
38
+ });
39
39
  return {
40
40
  isPressed,
41
41
  buttonProps: (0, _utils.mergeProps)(buttonProps, {
42
- // For v0.14+
43
- 'aria-pressed': isSelected,
44
- // For v0.15+
45
- accessibilityPressed: isSelected
42
+ 'aria-pressed': isSelected
46
43
  })
47
44
  };
48
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useToggleButton.web.ts"],"names":["useToggleButton","props","state","ref","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityPressed"],"mappings":";;;;;;;AAcA;;AACA;;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIA;AACL;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAiBF,KAAvB;AACA,QAAM;AAAEG,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6B,0BACjC,EACE,GAAGL,KADL;AAEEM,IAAAA,OAAO,EAAE,kBAAML,KAAK,CAACM,MAAZ,EAAoBP,KAAK,CAACM,OAA1B;AAFX,GADiC,EAKjCJ,GALiC,CAAnC;AAQA,SAAO;AACLE,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAE,uBAAWA,WAAX,EAAwB;AACnC;AACA,sBAAgBF,UAFmB;AAInC;AACAK,MAAAA,oBAAoB,EAAEL;AALa,KAAxB;AAFR,GAAP;AAUD","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 { ElementType, RefObject } from 'react';\nimport { AriaToggleButtonProps } from '@react-types/button';\nimport { useButton } from './useButton';\nimport { chain } from '@react-aria/utils';\nimport { mergeProps } from '@react-aria/utils';\nimport { ToggleState } from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(\n props: AriaToggleButtonProps<ElementType>,\n state: ToggleState,\n ref: RefObject<any>\n): any {\n /* eslint-enable no-redeclare */\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton(\n {\n ...props,\n onPress: chain(state.toggle, props.onPress),\n },\n ref\n );\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n // For v0.14+\n 'aria-pressed': isSelected,\n \n // For v0.15+\n accessibilityPressed: isSelected,\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["useToggleButton.web.ts"],"names":["useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"],"mappings":";;;;;;;AAcA;;AACA;;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACO,SAASA,eAAT,CACLC,KADK,EAELC,KAFK,EAGA;AACL;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAiBD,KAAvB;AACA,QAAM;AAAEE,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6B,0BAAU,EAC3C,GAAGJ,KADwC;AAE3CK,IAAAA,OAAO,EAAE,kBAAMJ,KAAK,CAACK,MAAZ,EAAoBN,KAAK,CAACK,OAA1B;AAFkC,GAAV,CAAnC;AAKA,SAAO;AACLF,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAE,uBAAWA,WAAX,EAAwB;AACnC,sBAAgBF;AADmB,KAAxB;AAFR,GAAP;AAMD","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 { ElementType } from 'react';\nimport { AriaToggleButtonProps } from '@react-types/button';\nimport { useButton } from './useButton';\nimport { chain } from '@react-aria/utils';\nimport { mergeProps } from '@react-aria/utils';\nimport { ToggleState } from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(\n props: AriaToggleButtonProps<ElementType>,\n state: ToggleState\n): any {\n /* eslint-enable no-redeclare */\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress),\n });\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected,\n }),\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { usePress } from "@react-native-aria/interactions";
2
- import { mergeProps } from "@react-aria/utils";
3
- export function useButton(props, ref) {
1
+ import { usePress } from '@react-native-aria/interactions';
2
+ import { mergeProps } from '@react-aria/utils';
3
+ export function useButton(props) {
4
4
  let {
5
5
  isDisabled,
6
6
  onPress,
@@ -17,15 +17,12 @@ export function useButton(props, ref) {
17
17
  onPressEnd,
18
18
  onPressChange,
19
19
  onPress,
20
- isDisabled,
21
- ref
20
+ isDisabled
22
21
  });
23
22
  const mergedProps = mergeProps(pressProps, rest, {
24
- accessibilityState: {
25
- disabled: isDisabled
26
- },
27
- accessibilityRole: "button",
28
- disabled: isDisabled
23
+ 'aria-disabled': isDisabled,
24
+ 'role': 'button',
25
+ 'disabled': isDisabled
29
26
  });
30
27
  return {
31
28
  isPressed,
@@ -1 +1 @@
1
- {"version":3,"sources":["useButton.ts"],"names":["usePress","mergeProps","useButton","props","ref","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","rest","pressProps","isPressed","mergedProps","accessibilityState","disabled","accessibilityRole","buttonProps"],"mappings":"AACA,SAAsBA,QAAtB,QAAsC,iCAAtC;AAEA,SAASC,UAAT,QAA2B,mBAA3B;AAkBA,OAAO,SAASC,SAAT,CACLC,KADK,EAELC,GAFK,EAGO;AACZ,MAAI;AACFC,IAAAA,UADE;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKFC,IAAAA,aALE;AAMF,OAAGC;AAND,MAOAP,KAPJ;AASA,MAAI;AAAEQ,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BZ,QAAQ,CAAC;AACvCO,IAAAA,YADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,aAHuC;AAIvCH,IAAAA,OAJuC;AAKvCD,IAAAA,UALuC;AAMvCD,IAAAA;AANuC,GAAD,CAAxC;AASA,QAAMS,WAAW,GAAGZ,UAAU,CAACU,UAAD,EAAaD,IAAb,EAAmB;AAC/CI,IAAAA,kBAAkB,EAAE;AAClBC,MAAAA,QAAQ,EAAEV;AADQ,KAD2B;AAI/CW,IAAAA,iBAAiB,EAAE,QAJ4B;AAK/CD,IAAAA,QAAQ,EAAEV;AALqC,GAAnB,CAA9B;AAQA,SAAO;AACLO,IAAAA,SADK;AAELK,IAAAA,WAAW,EAAEJ;AAFR,GAAP;AAID","sourcesContent":["import { ReactNode, RefObject } from \"react\";\nimport { PressEvents, usePress } from \"@react-native-aria/interactions\";\nimport { AccessibilityProps, PressableProps } from \"react-native\";\nimport { mergeProps } from \"@react-aria/utils\";\n\ninterface ButtonProps extends PressEvents {\n /** Whether the button is disabled. */\n isDisabled?: boolean;\n /** The content to display in the button. */\n children?: ReactNode;\n}\n\nexport interface RNAriaButtonProps extends AccessibilityProps, ButtonProps {}\n\nexport interface ButtonAria {\n /** Props for the button element. */\n buttonProps: PressableProps;\n /** Whether the button is currently pressed. */\n isPressed: boolean;\n}\n\nexport function useButton(\n props: RNAriaButtonProps,\n ref: RefObject<any>\n): ButtonAria {\n let {\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n ...rest\n } = props;\n\n let { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n ref,\n });\n\n const mergedProps = mergeProps(pressProps, rest, {\n accessibilityState: {\n disabled: isDisabled,\n },\n accessibilityRole: \"button\",\n disabled: isDisabled,\n });\n\n return {\n isPressed,\n buttonProps: mergedProps,\n };\n}\n"]}
1
+ {"version":3,"sources":["useButton.ts"],"names":["usePress","mergeProps","useButton","props","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","rest","pressProps","isPressed","mergedProps","buttonProps"],"mappings":"AACA,SAAsBA,QAAtB,QAAsC,iCAAtC;AAEA,SAASC,UAAT,QAA2B,mBAA3B;AAkBA,OAAO,SAASC,SAAT,CAAmBC,KAAnB,EAAyD;AAC9D,MAAI;AACFC,IAAAA,UADE;AAEFC,IAAAA,OAFE;AAGFC,IAAAA,YAHE;AAIFC,IAAAA,UAJE;AAKFC,IAAAA,aALE;AAMF,OAAGC;AAND,MAOAN,KAPJ;AASA,MAAI;AAAEO,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BX,QAAQ,CAAC;AACvCM,IAAAA,YADuC;AAEvCC,IAAAA,UAFuC;AAGvCC,IAAAA,aAHuC;AAIvCH,IAAAA,OAJuC;AAKvCD,IAAAA;AALuC,GAAD,CAAxC;AAQA,QAAMQ,WAAW,GAAGX,UAAU,CAACS,UAAD,EAAaD,IAAb,EAAmB;AAC/C,qBAAiBL,UAD8B;AAE/C,YAAQ,QAFuC;AAG/C,gBAAYA;AAHmC,GAAnB,CAA9B;AAMA,SAAO;AACLO,IAAAA,SADK;AAELE,IAAAA,WAAW,EAAED;AAFR,GAAP;AAID","sourcesContent":["import { ReactNode } from 'react';\nimport { PressEvents, usePress } from '@react-native-aria/interactions';\nimport { AccessibilityProps, PressableProps } from 'react-native';\nimport { mergeProps } from '@react-aria/utils';\n\ninterface ButtonProps extends PressEvents {\n /** Whether the button is disabled. */\n isDisabled?: boolean;\n /** The content to display in the button. */\n children?: ReactNode;\n}\n\nexport interface RNAriaButtonProps extends AccessibilityProps, ButtonProps {}\n\nexport interface ButtonAria {\n /** Props for the button element. */\n buttonProps: PressableProps;\n /** Whether the button is currently pressed. */\n isPressed: boolean;\n}\n\nexport function useButton(props: RNAriaButtonProps): ButtonAria {\n let {\n isDisabled,\n onPress,\n onPressStart,\n onPressEnd,\n onPressChange,\n ...rest\n } = props;\n\n let { pressProps, isPressed } = usePress({\n onPressStart,\n onPressEnd,\n onPressChange,\n onPress,\n isDisabled,\n });\n\n const mergedProps = mergeProps(pressProps, rest, {\n 'aria-disabled': isDisabled,\n 'role': 'button',\n 'disabled': isDisabled,\n });\n\n return {\n isPressed,\n buttonProps: mergedProps,\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { useButton } from "./useButton";
2
- import { chain, mergeProps } from "@react-aria/utils";
3
- export function useToggleButton(props, state, ref) {
1
+ import { useButton } from './useButton';
2
+ import { chain, mergeProps } from '@react-aria/utils';
3
+ export function useToggleButton(props, state) {
4
4
  const {
5
5
  isSelected
6
6
  } = state;
@@ -9,13 +9,11 @@ export function useToggleButton(props, state, ref) {
9
9
  buttonProps
10
10
  } = useButton({ ...props,
11
11
  onPress: chain(state.toggle, props.onPress)
12
- }, ref);
12
+ });
13
13
  return {
14
14
  isPressed,
15
15
  buttonProps: mergeProps(buttonProps, {
16
- accessibilityState: {
17
- selected: isSelected
18
- }
16
+ 'aria-selected': isSelected
19
17
  })
20
18
  };
21
19
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useToggleButton.ts"],"names":["useButton","chain","mergeProps","useToggleButton","props","state","ref","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityState","selected"],"mappings":"AAAA,SAAqBA,SAArB,QAAsC,aAAtC;AAGA,SAASC,KAAT,EAAgBC,UAAhB,QAAkC,mBAAlC;AAkBA,OAAO,SAASC,eAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIO;AACZ,QAAM;AAAEC,IAAAA;AAAF,MAAiBF,KAAvB;AACA,QAAM;AAAEG,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BT,SAAS,CAC1C,EACE,GAAGI,KADL;AAEEM,IAAAA,OAAO,EAAET,KAAK,CAACI,KAAK,CAACM,MAAP,EAAeP,KAAK,CAACM,OAArB;AAFhB,GAD0C,EAK1CJ,GAL0C,CAA5C;AAQA,SAAO;AACLE,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAEP,UAAU,CAACO,WAAD,EAAc;AACnCG,MAAAA,kBAAkB,EAAE;AAClBC,QAAAA,QAAQ,EAAEN;AADQ;AADe,KAAd;AAFlB,GAAP;AAQD","sourcesContent":["import { ButtonAria, useButton } from \"./useButton\";\nimport type { ToggleState } from \"@react-stately/toggle\";\nimport type { RefObject } from \"react\";\nimport { chain, mergeProps } from \"@react-aria/utils\";\nimport type { PressEvents } from \"@react-native-aria/interactions\";\nimport type { PressableProps } from \"react-native\";\n\nexport type AriaButtonProps = PressableProps &\n PressEvents & {\n isDisabled: boolean;\n };\n\nexport interface AriaToggleButtonProps extends AriaButtonProps {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n}\n\nexport function useToggleButton(\n props: AriaToggleButtonProps,\n state: ToggleState,\n ref: RefObject<any>\n): ButtonAria {\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton(\n {\n ...props,\n onPress: chain(state.toggle, props.onPress),\n },\n ref\n );\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n accessibilityState: {\n selected: isSelected,\n },\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["useToggleButton.ts"],"names":["useButton","chain","mergeProps","useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"],"mappings":"AAAA,SAAqBA,SAArB,QAAsC,aAAtC;AAEA,SAASC,KAAT,EAAgBC,UAAhB,QAAkC,mBAAlC;AAkBA,OAAO,SAASC,eAAT,CACLC,KADK,EAELC,KAFK,EAGO;AACZ,QAAM;AAAEC,IAAAA;AAAF,MAAiBD,KAAvB;AACA,QAAM;AAAEE,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BR,SAAS,CAAC,EAC3C,GAAGI,KADwC;AAE3CK,IAAAA,OAAO,EAAER,KAAK,CAACI,KAAK,CAACK,MAAP,EAAeN,KAAK,CAACK,OAArB;AAF6B,GAAD,CAA5C;AAKA,SAAO;AACLF,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAEN,UAAU,CAACM,WAAD,EAAc;AACnC,uBAAiBF;AADkB,KAAd;AAFlB,GAAP;AAMD","sourcesContent":["import { ButtonAria, useButton } from './useButton';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { chain, mergeProps } from '@react-aria/utils';\nimport type { PressEvents } from '@react-native-aria/interactions';\nimport type { PressableProps } from 'react-native';\n\nexport type AriaButtonProps = PressableProps &\n PressEvents & {\n isDisabled: boolean;\n };\n\nexport interface AriaToggleButtonProps extends AriaButtonProps {\n /** Whether the element should be selected (controlled). */\n isSelected?: boolean;\n /** Whether the element should be selected (uncontrolled). */\n defaultSelected?: boolean;\n /** Handler that is called when the element's selection state changes. */\n onChange?: (isSelected: boolean) => void;\n}\n\nexport function useToggleButton(\n props: AriaToggleButtonProps,\n state: ToggleState\n): ButtonAria {\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress),\n });\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-selected': isSelected,\n }),\n };\n}\n"]}
@@ -17,7 +17,7 @@ import { mergeProps } from '@react-aria/utils';
17
17
  * Provides the behavior and accessibility implementation for a toggle button component.
18
18
  * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
19
19
  */
20
- export function useToggleButton(props, state, ref) {
20
+ export function useToggleButton(props, state) {
21
21
  /* eslint-enable no-redeclare */
22
22
  const {
23
23
  isSelected
@@ -27,14 +27,11 @@ export function useToggleButton(props, state, ref) {
27
27
  buttonProps
28
28
  } = useButton({ ...props,
29
29
  onPress: chain(state.toggle, props.onPress)
30
- }, ref);
30
+ });
31
31
  return {
32
32
  isPressed,
33
33
  buttonProps: mergeProps(buttonProps, {
34
- // For v0.14+
35
- 'aria-pressed': isSelected,
36
- // For v0.15+
37
- accessibilityPressed: isSelected
34
+ 'aria-pressed': isSelected
38
35
  })
39
36
  };
40
37
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["useToggleButton.web.ts"],"names":["useButton","chain","mergeProps","useToggleButton","props","state","ref","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityPressed"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,SAASA,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,UAAT,QAA2B,mBAA3B;;AAGA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAT,CACLC,KADK,EAELC,KAFK,EAGLC,GAHK,EAIA;AACL;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAiBF,KAAvB;AACA,QAAM;AAAEG,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BT,SAAS,CAC1C,EACE,GAAGI,KADL;AAEEM,IAAAA,OAAO,EAAET,KAAK,CAACI,KAAK,CAACM,MAAP,EAAeP,KAAK,CAACM,OAArB;AAFhB,GAD0C,EAK1CJ,GAL0C,CAA5C;AAQA,SAAO;AACLE,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAEP,UAAU,CAACO,WAAD,EAAc;AACnC;AACA,sBAAgBF,UAFmB;AAInC;AACAK,MAAAA,oBAAoB,EAAEL;AALa,KAAd;AAFlB,GAAP;AAUD","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 { ElementType, RefObject } from 'react';\nimport { AriaToggleButtonProps } from '@react-types/button';\nimport { useButton } from './useButton';\nimport { chain } from '@react-aria/utils';\nimport { mergeProps } from '@react-aria/utils';\nimport { ToggleState } from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(\n props: AriaToggleButtonProps<ElementType>,\n state: ToggleState,\n ref: RefObject<any>\n): any {\n /* eslint-enable no-redeclare */\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton(\n {\n ...props,\n onPress: chain(state.toggle, props.onPress),\n },\n ref\n );\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n // For v0.14+\n 'aria-pressed': isSelected,\n \n // For v0.15+\n accessibilityPressed: isSelected,\n }),\n };\n}\n"]}
1
+ {"version":3,"sources":["useToggleButton.web.ts"],"names":["useButton","chain","mergeProps","useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,SAASA,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,UAAT,QAA2B,mBAA3B;;AAGA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAT,CACLC,KADK,EAELC,KAFK,EAGA;AACL;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAiBD,KAAvB;AACA,QAAM;AAAEE,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAA6BR,SAAS,CAAC,EAC3C,GAAGI,KADwC;AAE3CK,IAAAA,OAAO,EAAER,KAAK,CAACI,KAAK,CAACK,MAAP,EAAeN,KAAK,CAACK,OAArB;AAF6B,GAAD,CAA5C;AAKA,SAAO;AACLF,IAAAA,SADK;AAELC,IAAAA,WAAW,EAAEN,UAAU,CAACM,WAAD,EAAc;AACnC,sBAAgBF;AADmB,KAAd;AAFlB,GAAP;AAMD","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 { ElementType } from 'react';\nimport { AriaToggleButtonProps } from '@react-types/button';\nimport { useButton } from './useButton';\nimport { chain } from '@react-aria/utils';\nimport { mergeProps } from '@react-aria/utils';\nimport { ToggleState } from '@react-stately/toggle';\n\n/**\n * Provides the behavior and accessibility implementation for a toggle button component.\n * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.\n */\nexport function useToggleButton(\n props: AriaToggleButtonProps<ElementType>,\n state: ToggleState\n): any {\n /* eslint-enable no-redeclare */\n const { isSelected } = state;\n const { isPressed, buttonProps } = useButton({\n ...props,\n onPress: chain(state.toggle, props.onPress),\n });\n\n return {\n isPressed,\n buttonProps: mergeProps(buttonProps, {\n 'aria-pressed': isSelected,\n }),\n };\n}\n"]}
@@ -1,6 +1,6 @@
1
- import { ReactNode, RefObject } from "react";
2
- import { PressEvents } from "@react-native-aria/interactions";
3
- import { AccessibilityProps, PressableProps } from "react-native";
1
+ import { ReactNode } from 'react';
2
+ import { PressEvents } from '@react-native-aria/interactions';
3
+ import { AccessibilityProps, PressableProps } from 'react-native';
4
4
  interface ButtonProps extends PressEvents {
5
5
  /** Whether the button is disabled. */
6
6
  isDisabled?: boolean;
@@ -15,5 +15,5 @@ export interface ButtonAria {
15
15
  /** Whether the button is currently pressed. */
16
16
  isPressed: boolean;
17
17
  }
18
- export declare function useButton(props: RNAriaButtonProps, ref: RefObject<any>): ButtonAria;
18
+ export declare function useButton(props: RNAriaButtonProps): ButtonAria;
19
19
  export {};
@@ -1,8 +1,7 @@
1
- import { ButtonAria } from "./useButton";
2
- import type { ToggleState } from "@react-stately/toggle";
3
- import type { RefObject } from "react";
4
- import type { PressEvents } from "@react-native-aria/interactions";
5
- import type { PressableProps } from "react-native";
1
+ import { ButtonAria } from './useButton';
2
+ import type { ToggleState } from '@react-stately/toggle';
3
+ import type { PressEvents } from '@react-native-aria/interactions';
4
+ import type { PressableProps } from 'react-native';
6
5
  export declare type AriaButtonProps = PressableProps & PressEvents & {
7
6
  isDisabled: boolean;
8
7
  };
@@ -14,4 +13,4 @@ export interface AriaToggleButtonProps extends AriaButtonProps {
14
13
  /** Handler that is called when the element's selection state changes. */
15
14
  onChange?: (isSelected: boolean) => void;
16
15
  }
17
- export declare function useToggleButton(props: AriaToggleButtonProps, state: ToggleState, ref: RefObject<any>): ButtonAria;
16
+ export declare function useToggleButton(props: AriaToggleButtonProps, state: ToggleState): ButtonAria;
@@ -1,8 +1,8 @@
1
- import { ElementType, RefObject } from 'react';
1
+ import { ElementType } from 'react';
2
2
  import { AriaToggleButtonProps } from '@react-types/button';
3
3
  import { ToggleState } from '@react-stately/toggle';
4
4
  /**
5
5
  * Provides the behavior and accessibility implementation for a toggle button component.
6
6
  * ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.
7
7
  */
8
- export declare function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState, ref: RefObject<any>): any;
8
+ export declare function useToggleButton(props: AriaToggleButtonProps<ElementType>, state: ToggleState): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-aria/button",
3
- "version": "0.2.2",
3
+ "version": "0.2.5-alpha.0",
4
4
  "description": "mono repo setup with bob",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -47,8 +47,8 @@
47
47
  "registry": "https://registry.npmjs.org/"
48
48
  },
49
49
  "dependencies": {
50
- "@react-aria/utils": "^3.5.0",
51
- "@react-native-aria/interactions": "^0.2.2",
50
+ "@react-aria/utils": "^3.6.0",
51
+ "@react-native-aria/interactions": "^0.2.3",
52
52
  "@react-stately/toggle": "^3.2.1",
53
53
  "@react-types/checkbox": "^3.2.1"
54
54
  },
package/src/useButton.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { ReactNode, RefObject } from "react";
2
- import { PressEvents, usePress } from "@react-native-aria/interactions";
3
- import { AccessibilityProps, PressableProps } from "react-native";
4
- import { mergeProps } from "@react-aria/utils";
1
+ import { ReactNode } from 'react';
2
+ import { PressEvents, usePress } from '@react-native-aria/interactions';
3
+ import { AccessibilityProps, PressableProps } from 'react-native';
4
+ import { mergeProps } from '@react-aria/utils';
5
5
 
6
6
  interface ButtonProps extends PressEvents {
7
7
  /** Whether the button is disabled. */
@@ -19,10 +19,7 @@ export interface ButtonAria {
19
19
  isPressed: boolean;
20
20
  }
21
21
 
22
- export function useButton(
23
- props: RNAriaButtonProps,
24
- ref: RefObject<any>
25
- ): ButtonAria {
22
+ export function useButton(props: RNAriaButtonProps): ButtonAria {
26
23
  let {
27
24
  isDisabled,
28
25
  onPress,
@@ -38,15 +35,12 @@ export function useButton(
38
35
  onPressChange,
39
36
  onPress,
40
37
  isDisabled,
41
- ref,
42
38
  });
43
39
 
44
40
  const mergedProps = mergeProps(pressProps, rest, {
45
- accessibilityState: {
46
- disabled: isDisabled,
47
- },
48
- accessibilityRole: "button",
49
- disabled: isDisabled,
41
+ 'aria-disabled': isDisabled,
42
+ 'role': 'button',
43
+ 'disabled': isDisabled,
50
44
  });
51
45
 
52
46
  return {
@@ -1,9 +1,8 @@
1
- import { ButtonAria, useButton } from "./useButton";
2
- import type { ToggleState } from "@react-stately/toggle";
3
- import type { RefObject } from "react";
4
- import { chain, mergeProps } from "@react-aria/utils";
5
- import type { PressEvents } from "@react-native-aria/interactions";
6
- import type { PressableProps } from "react-native";
1
+ import { ButtonAria, useButton } from './useButton';
2
+ import type { ToggleState } from '@react-stately/toggle';
3
+ import { chain, mergeProps } from '@react-aria/utils';
4
+ import type { PressEvents } from '@react-native-aria/interactions';
5
+ import type { PressableProps } from 'react-native';
7
6
 
8
7
  export type AriaButtonProps = PressableProps &
9
8
  PressEvents & {
@@ -21,24 +20,18 @@ export interface AriaToggleButtonProps extends AriaButtonProps {
21
20
 
22
21
  export function useToggleButton(
23
22
  props: AriaToggleButtonProps,
24
- state: ToggleState,
25
- ref: RefObject<any>
23
+ state: ToggleState
26
24
  ): ButtonAria {
27
25
  const { isSelected } = state;
28
- const { isPressed, buttonProps } = useButton(
29
- {
30
- ...props,
31
- onPress: chain(state.toggle, props.onPress),
32
- },
33
- ref
34
- );
26
+ const { isPressed, buttonProps } = useButton({
27
+ ...props,
28
+ onPress: chain(state.toggle, props.onPress),
29
+ });
35
30
 
36
31
  return {
37
32
  isPressed,
38
33
  buttonProps: mergeProps(buttonProps, {
39
- accessibilityState: {
40
- selected: isSelected,
41
- },
34
+ 'aria-selected': isSelected,
42
35
  }),
43
36
  };
44
37
  }
@@ -10,7 +10,7 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import { ElementType, RefObject } from 'react';
13
+ import { ElementType } from 'react';
14
14
  import { AriaToggleButtonProps } from '@react-types/button';
15
15
  import { useButton } from './useButton';
16
16
  import { chain } from '@react-aria/utils';
@@ -23,27 +23,19 @@ import { ToggleState } from '@react-stately/toggle';
23
23
  */
24
24
  export function useToggleButton(
25
25
  props: AriaToggleButtonProps<ElementType>,
26
- state: ToggleState,
27
- ref: RefObject<any>
26
+ state: ToggleState
28
27
  ): any {
29
28
  /* eslint-enable no-redeclare */
30
29
  const { isSelected } = state;
31
- const { isPressed, buttonProps } = useButton(
32
- {
33
- ...props,
34
- onPress: chain(state.toggle, props.onPress),
35
- },
36
- ref
37
- );
30
+ const { isPressed, buttonProps } = useButton({
31
+ ...props,
32
+ onPress: chain(state.toggle, props.onPress),
33
+ });
38
34
 
39
35
  return {
40
36
  isPressed,
41
37
  buttonProps: mergeProps(buttonProps, {
42
- // For v0.14+
43
38
  'aria-pressed': isSelected,
44
-
45
- // For v0.15+
46
- accessibilityPressed: isSelected,
47
39
  }),
48
40
  };
49
41
  }
package/.DS_Store DELETED
Binary file