@react-native-aria/button 0.2.4 → 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.
@@ -29,11 +29,9 @@ function useButton(props) {
29
29
  isDisabled
30
30
  });
31
31
  const mergedProps = (0, _utils.mergeProps)(pressProps, rest, {
32
- accessibilityState: {
33
- disabled: isDisabled
34
- },
35
- accessibilityRole: 'button',
36
- disabled: isDisabled
32
+ 'aria-disabled': isDisabled,
33
+ 'role': 'button',
34
+ 'disabled': isDisabled
37
35
  });
38
36
  return {
39
37
  isPressed,
@@ -1 +1 @@
1
- {"version":3,"sources":["useButton.ts"],"names":["useButton","props","isDisabled","onPress","onPressStart","onPressEnd","onPressChange","rest","pressProps","isPressed","mergedProps","accessibilityState","disabled","accessibilityRole","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/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 } 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 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"]}
@@ -22,9 +22,7 @@ function useToggleButton(props, state) {
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","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityState","selected"],"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;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 { 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 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"]}
@@ -39,10 +39,7 @@ function useToggleButton(props, state) {
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","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;AACA,sBAAgBF,UAFmB;AAInC;AACA,8BAAwBA;AALW,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 } 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 // 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"]}
@@ -20,11 +20,9 @@ export function useButton(props) {
20
20
  isDisabled
21
21
  });
22
22
  const mergedProps = mergeProps(pressProps, rest, {
23
- accessibilityState: {
24
- disabled: isDisabled
25
- },
26
- accessibilityRole: 'button',
27
- disabled: isDisabled
23
+ 'aria-disabled': isDisabled,
24
+ 'role': 'button',
25
+ 'disabled': isDisabled
28
26
  });
29
27
  return {
30
28
  isPressed,
@@ -1 +1 @@
1
- {"version":3,"sources":["useButton.ts"],"names":["usePress","mergeProps","useButton","props","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,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/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 } 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 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"]}
@@ -13,9 +13,7 @@ export function useToggleButton(props, state) {
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","isSelected","isPressed","buttonProps","onPress","toggle","accessibilityState","selected"],"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;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 { 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 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"]}
@@ -31,10 +31,7 @@ export function useToggleButton(props, state) {
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","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;AACA,sBAAgBF,UAFmB;AAInC;AACA,8BAAwBA;AALW,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 } 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 // 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-aria/button",
3
- "version": "0.2.4",
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",
package/src/useButton.ts CHANGED
@@ -38,11 +38,9 @@ export function useButton(props: RNAriaButtonProps): ButtonAria {
38
38
  });
39
39
 
40
40
  const mergedProps = mergeProps(pressProps, rest, {
41
- accessibilityState: {
42
- disabled: isDisabled,
43
- },
44
- accessibilityRole: 'button',
45
- disabled: isDisabled,
41
+ 'aria-disabled': isDisabled,
42
+ 'role': 'button',
43
+ 'disabled': isDisabled,
46
44
  });
47
45
 
48
46
  return {
@@ -31,9 +31,7 @@ export function useToggleButton(
31
31
  return {
32
32
  isPressed,
33
33
  buttonProps: mergeProps(buttonProps, {
34
- accessibilityState: {
35
- selected: isSelected,
36
- },
34
+ 'aria-selected': isSelected,
37
35
  }),
38
36
  };
39
37
  }
@@ -35,11 +35,7 @@ export function useToggleButton(
35
35
  return {
36
36
  isPressed,
37
37
  buttonProps: mergeProps(buttonProps, {
38
- // For v0.14+
39
38
  'aria-pressed': isSelected,
40
-
41
- // For v0.15+
42
- 'accessibilityPressed': isSelected,
43
39
  }),
44
40
  };
45
41
  }
package/.DS_Store DELETED
Binary file