@react-native-aria/button 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/useButton.js +3 -5
- package/lib/commonjs/useButton.js.map +1 -1
- package/lib/commonjs/useToggleButton.js +1 -3
- package/lib/commonjs/useToggleButton.js.map +1 -1
- package/lib/commonjs/useToggleButton.web.js +1 -4
- package/lib/commonjs/useToggleButton.web.js.map +1 -1
- package/lib/module/useButton.js +3 -5
- package/lib/module/useButton.js.map +1 -1
- package/lib/module/useToggleButton.js +1 -3
- package/lib/module/useToggleButton.js.map +1 -1
- package/lib/module/useToggleButton.web.js +1 -4
- package/lib/module/useToggleButton.web.js.map +1 -1
- package/package.json +2 -2
- package/src/useButton.ts +3 -5
- package/src/useToggleButton.ts +1 -3
- package/src/useToggleButton.web.ts +0 -4
- package/.DS_Store +0 -0
@@ -29,11 +29,9 @@ function useButton(props) {
|
|
29
29
|
isDisabled
|
30
30
|
});
|
31
31
|
const mergedProps = (0, _utils.mergeProps)(pressProps, rest, {
|
32
|
-
|
33
|
-
|
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","
|
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"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useToggleButton.ts"],"names":["useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"
|
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
|
-
|
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
|
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"]}
|
package/lib/module/useButton.js
CHANGED
@@ -20,11 +20,9 @@ export function useButton(props) {
|
|
20
20
|
isDisabled
|
21
21
|
});
|
22
22
|
const mergedProps = mergeProps(pressProps, rest, {
|
23
|
-
|
24
|
-
|
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","
|
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 +1 @@
|
|
1
|
-
{"version":3,"sources":["useToggleButton.ts"],"names":["useButton","chain","mergeProps","useToggleButton","props","state","isSelected","isPressed","buttonProps","onPress","toggle"
|
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
|
-
|
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
|
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.
|
3
|
+
"version": "0.2.5",
|
4
4
|
"description": "mono repo setup with bob",
|
5
5
|
"main": "lib/commonjs/index",
|
6
6
|
"module": "lib/module/index",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
},
|
49
49
|
"dependencies": {
|
50
50
|
"@react-aria/utils": "^3.6.0",
|
51
|
-
"@react-native-aria/interactions": "^0.2.
|
51
|
+
"@react-native-aria/interactions": "^0.2.11",
|
52
52
|
"@react-stately/toggle": "^3.2.1",
|
53
53
|
"@react-types/checkbox": "^3.2.1"
|
54
54
|
},
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
accessibilityRole: 'button',
|
45
|
-
disabled: isDisabled,
|
41
|
+
'aria-disabled': isDisabled,
|
42
|
+
'role': 'button',
|
43
|
+
'disabled': isDisabled,
|
46
44
|
});
|
47
45
|
|
48
46
|
return {
|
package/src/useToggleButton.ts
CHANGED
package/.DS_Store
DELETED
Binary file
|