@react-native-aria/radio 0.2.7 → 0.2.8
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useRadio.ts"],"names":["useRadio","props","state","_ref","value","isReadOnly","isDisabled","children","hasChildren","label","console","warn","preventChanges","checked","selectedValue","onPress","setSelectedValue","pressProps","inputProps"],"mappings":";;;;;;;AACA;;AAGA;;AAEA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIM;AAAA;;AACX,MAAI;AAAEC,IAAAA,KAAF;AAASC,IAAAA,UAAT;AAAqBC,IAAAA,UAArB;AAAiCC,IAAAA;AAAjC,MAA8CN,KAAlD;AAEA,MAAIO,WAAW,GAAGD,QAAQ,IAAI,IAA9B;AACA,QAAME,KAAK,GAAG,sBAASR,KAAT,CAAd;;AAEA,MAAI,CAACO,WAAD,IAAgB,CAACC,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;;AAED,MAAIC,cAAc,GAAGN,UAAU,IAAID,UAAnC;AACAO,EAAAA,cAAc,sBAAGA,cAAH,6DAAqB,KAAnC;AAEA,MAAIC,OAAO,GAAGX,KAAK,CAACY,aAAN,KAAwBV,KAAtC;;AAEA,MAAIW,OAAO,GAAG,MAAM;AAClBb,IAAAA,KAAK,CAACc,gBAAN,CAAuBZ,KAAvB;AACD,GAFD;;AAIA,MAAI;AAAEa,IAAAA;AAAF,MAAiB,4BAAS;AAC5BX,IAAAA,UAAU,EAAEM,cADgB;AAE5BG,IAAAA;AAF4B,GAAT,CAArB;AAKA,SAAO;AACLG,IAAAA,UAAU,EAAE,uBAAWjB,KAAX,EAAkB,EAC5B,GAAGgB,UADyB;AAE5BJ,MAAAA,OAF4B;AAG5B,kBAAYD,cAHgB;AAI5BR,MAAAA,KAJ4B;AAK5B,oBAAcK,KALc;AAM5B,cAAQ,OANoB;AAO5B,uBAAiBG,cAPW;AAQ5B,sBAAgBC;AARY,KAAlB;AADP,GAAP;AAYD","sourcesContent":["import type { AriaRadioProps } from '@react-types/radio';\nimport { mergeProps } from '@react-aria/utils';\nimport type {
|
1
|
+
{"version":3,"sources":["useRadio.ts"],"names":["useRadio","props","state","_ref","value","isReadOnly","isDisabled","children","hasChildren","label","console","warn","preventChanges","checked","selectedValue","onPress","setSelectedValue","pressProps","inputProps"],"mappings":";;;;;;;AACA;;AAGA;;AAEA;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,QAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIM;AAAA;;AACX,MAAI;AAAEC,IAAAA,KAAF;AAASC,IAAAA,UAAT;AAAqBC,IAAAA,UAArB;AAAiCC,IAAAA;AAAjC,MAA8CN,KAAlD;AAEA,MAAIO,WAAW,GAAGD,QAAQ,IAAI,IAA9B;AACA,QAAME,KAAK,GAAG,sBAASR,KAAT,CAAd;;AAEA,MAAI,CAACO,WAAD,IAAgB,CAACC,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;;AAED,MAAIC,cAAc,GAAGN,UAAU,IAAID,UAAnC;AACAO,EAAAA,cAAc,sBAAGA,cAAH,6DAAqB,KAAnC;AAEA,MAAIC,OAAO,GAAGX,KAAK,CAACY,aAAN,KAAwBV,KAAtC;;AAEA,MAAIW,OAAO,GAAG,MAAM;AAClBb,IAAAA,KAAK,CAACc,gBAAN,CAAuBZ,KAAvB;AACD,GAFD;;AAIA,MAAI;AAAEa,IAAAA;AAAF,MAAiB,4BAAS;AAC5BX,IAAAA,UAAU,EAAEM,cADgB;AAE5BG,IAAAA;AAF4B,GAAT,CAArB;AAKA,SAAO;AACLG,IAAAA,UAAU,EAAE,uBAAWjB,KAAX,EAAkB,EAC5B,GAAGgB,UADyB;AAE5BJ,MAAAA,OAF4B;AAG5B,kBAAYD,cAHgB;AAI5BR,MAAAA,KAJ4B;AAK5B,oBAAcK,KALc;AAM5B,cAAQ,OANoB;AAO5B,uBAAiBG,cAPW;AAQ5B,sBAAgBC;AARY,KAAlB;AADP,GAAP;AAYD","sourcesContent":["import type { AriaRadioProps } from '@react-types/radio';\nimport { mergeProps } from '@react-aria/utils';\nimport type { RefObject } from 'react';\nimport type { RadioGroupState } from '@react-stately/radio';\nimport { usePress } from '@react-native-aria/interactions';\nimport type { AccessibilityProps } from 'react-native';\nimport { getLabel } from '@react-native-aria/utils';\n\nexport interface RadioAriaProps extends AriaRadioProps, AccessibilityProps {\n /**\n * Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).\n */\n isRequired?: boolean;\n /**\n * Whether the Radio can be interacted with but cannot have its selection state changed.\n */\n isReadOnly?: boolean;\n}\n\nexport interface RadioAria extends AccessibilityProps {\n /** Props for the input or Pressable/Touchable element. */\n inputProps: any;\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(\n props: RadioAriaProps,\n state: RadioGroupState,\n _ref: RefObject<HTMLElement>\n): RadioAria {\n let { value, isReadOnly, isDisabled, children } = props;\n\n let hasChildren = children != null;\n const label = getLabel(props);\n\n if (!hasChildren && !label) {\n console.warn(\n 'If you do not provide children, you must specify an aria-label for accessibility'\n );\n }\n\n let preventChanges = isDisabled || isReadOnly;\n preventChanges = preventChanges ?? false;\n\n let checked = state.selectedValue === value;\n\n let onPress = () => {\n state.setSelectedValue(value);\n };\n\n let { pressProps } = usePress({\n isDisabled: preventChanges,\n onPress,\n });\n\n return {\n inputProps: mergeProps(props, {\n ...pressProps,\n checked,\n 'disabled': preventChanges,\n value,\n 'aria-label': label,\n 'role': 'radio',\n 'aria-disabled': preventChanges,\n 'aria-checked': checked,\n }),\n };\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useRadio.ts"],"names":["mergeProps","usePress","getLabel","useRadio","props","state","_ref","value","isReadOnly","isDisabled","children","hasChildren","label","console","warn","preventChanges","checked","selectedValue","onPress","setSelectedValue","pressProps","inputProps"],"mappings":"AACA,SAASA,UAAT,QAA2B,mBAA3B;AAGA,SAASC,QAAT,QAAyB,iCAAzB;AAEA,SAASC,QAAT,QAAyB,0BAAzB;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIM;AAAA;;AACX,MAAI;AAAEC,IAAAA,KAAF;AAASC,IAAAA,UAAT;AAAqBC,IAAAA,UAArB;AAAiCC,IAAAA;AAAjC,MAA8CN,KAAlD;AAEA,MAAIO,WAAW,GAAGD,QAAQ,IAAI,IAA9B;AACA,QAAME,KAAK,GAAGV,QAAQ,CAACE,KAAD,CAAtB;;AAEA,MAAI,CAACO,WAAD,IAAgB,CAACC,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;;AAED,MAAIC,cAAc,GAAGN,UAAU,IAAID,UAAnC;AACAO,EAAAA,cAAc,sBAAGA,cAAH,6DAAqB,KAAnC;AAEA,MAAIC,OAAO,GAAGX,KAAK,CAACY,aAAN,KAAwBV,KAAtC;;AAEA,MAAIW,OAAO,GAAG,MAAM;AAClBb,IAAAA,KAAK,CAACc,gBAAN,CAAuBZ,KAAvB;AACD,GAFD;;AAIA,MAAI;AAAEa,IAAAA;AAAF,MAAiBnB,QAAQ,CAAC;AAC5BQ,IAAAA,UAAU,EAAEM,cADgB;AAE5BG,IAAAA;AAF4B,GAAD,CAA7B;AAKA,SAAO;AACLG,IAAAA,UAAU,EAAErB,UAAU,CAACI,KAAD,EAAQ,EAC5B,GAAGgB,UADyB;AAE5BJ,MAAAA,OAF4B;AAG5B,kBAAYD,cAHgB;AAI5BR,MAAAA,KAJ4B;AAK5B,oBAAcK,KALc;AAM5B,cAAQ,OANoB;AAO5B,uBAAiBG,cAPW;AAQ5B,sBAAgBC;AARY,KAAR;AADjB,GAAP;AAYD","sourcesContent":["import type { AriaRadioProps } from '@react-types/radio';\nimport { mergeProps } from '@react-aria/utils';\nimport type {
|
1
|
+
{"version":3,"sources":["useRadio.ts"],"names":["mergeProps","usePress","getLabel","useRadio","props","state","_ref","value","isReadOnly","isDisabled","children","hasChildren","label","console","warn","preventChanges","checked","selectedValue","onPress","setSelectedValue","pressProps","inputProps"],"mappings":"AACA,SAASA,UAAT,QAA2B,mBAA3B;AAGA,SAASC,QAAT,QAAyB,iCAAzB;AAEA,SAASC,QAAT,QAAyB,0BAAzB;;AAkBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIM;AAAA;;AACX,MAAI;AAAEC,IAAAA,KAAF;AAASC,IAAAA,UAAT;AAAqBC,IAAAA,UAArB;AAAiCC,IAAAA;AAAjC,MAA8CN,KAAlD;AAEA,MAAIO,WAAW,GAAGD,QAAQ,IAAI,IAA9B;AACA,QAAME,KAAK,GAAGV,QAAQ,CAACE,KAAD,CAAtB;;AAEA,MAAI,CAACO,WAAD,IAAgB,CAACC,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD;;AAED,MAAIC,cAAc,GAAGN,UAAU,IAAID,UAAnC;AACAO,EAAAA,cAAc,sBAAGA,cAAH,6DAAqB,KAAnC;AAEA,MAAIC,OAAO,GAAGX,KAAK,CAACY,aAAN,KAAwBV,KAAtC;;AAEA,MAAIW,OAAO,GAAG,MAAM;AAClBb,IAAAA,KAAK,CAACc,gBAAN,CAAuBZ,KAAvB;AACD,GAFD;;AAIA,MAAI;AAAEa,IAAAA;AAAF,MAAiBnB,QAAQ,CAAC;AAC5BQ,IAAAA,UAAU,EAAEM,cADgB;AAE5BG,IAAAA;AAF4B,GAAD,CAA7B;AAKA,SAAO;AACLG,IAAAA,UAAU,EAAErB,UAAU,CAACI,KAAD,EAAQ,EAC5B,GAAGgB,UADyB;AAE5BJ,MAAAA,OAF4B;AAG5B,kBAAYD,cAHgB;AAI5BR,MAAAA,KAJ4B;AAK5B,oBAAcK,KALc;AAM5B,cAAQ,OANoB;AAO5B,uBAAiBG,cAPW;AAQ5B,sBAAgBC;AARY,KAAR;AADjB,GAAP;AAYD","sourcesContent":["import type { AriaRadioProps } from '@react-types/radio';\nimport { mergeProps } from '@react-aria/utils';\nimport type { RefObject } from 'react';\nimport type { RadioGroupState } from '@react-stately/radio';\nimport { usePress } from '@react-native-aria/interactions';\nimport type { AccessibilityProps } from 'react-native';\nimport { getLabel } from '@react-native-aria/utils';\n\nexport interface RadioAriaProps extends AriaRadioProps, AccessibilityProps {\n /**\n * Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required).\n */\n isRequired?: boolean;\n /**\n * Whether the Radio can be interacted with but cannot have its selection state changed.\n */\n isReadOnly?: boolean;\n}\n\nexport interface RadioAria extends AccessibilityProps {\n /** Props for the input or Pressable/Touchable element. */\n inputProps: any;\n}\n\n/**\n * Provides the behavior and accessibility implementation for an individual\n * radio button in a radio group.\n * @param props - Props for the radio.\n * @param state - State for the radio group, as returned by `useRadioGroupState`.\n * @param ref - Ref to the HTML input element.\n */\nexport function useRadio(\n props: RadioAriaProps,\n state: RadioGroupState,\n _ref: RefObject<HTMLElement>\n): RadioAria {\n let { value, isReadOnly, isDisabled, children } = props;\n\n let hasChildren = children != null;\n const label = getLabel(props);\n\n if (!hasChildren && !label) {\n console.warn(\n 'If you do not provide children, you must specify an aria-label for accessibility'\n );\n }\n\n let preventChanges = isDisabled || isReadOnly;\n preventChanges = preventChanges ?? false;\n\n let checked = state.selectedValue === value;\n\n let onPress = () => {\n state.setSelectedValue(value);\n };\n\n let { pressProps } = usePress({\n isDisabled: preventChanges,\n onPress,\n });\n\n return {\n inputProps: mergeProps(props, {\n ...pressProps,\n checked,\n 'disabled': preventChanges,\n value,\n 'aria-label': label,\n 'role': 'radio',\n 'aria-disabled': preventChanges,\n 'aria-checked': checked,\n }),\n };\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { AriaRadioProps } from '@react-types/radio';
|
2
|
-
import type {
|
2
|
+
import type { RefObject } from 'react';
|
3
3
|
import type { RadioGroupState } from '@react-stately/radio';
|
4
4
|
import type { AccessibilityProps } from 'react-native';
|
5
5
|
export interface RadioAriaProps extends AriaRadioProps, AccessibilityProps {
|
@@ -13,8 +13,8 @@ export interface RadioAriaProps extends AriaRadioProps, AccessibilityProps {
|
|
13
13
|
isReadOnly?: boolean;
|
14
14
|
}
|
15
15
|
export interface RadioAria extends AccessibilityProps {
|
16
|
-
/** Props for the input element. */
|
17
|
-
inputProps:
|
16
|
+
/** Props for the input or Pressable/Touchable element. */
|
17
|
+
inputProps: any;
|
18
18
|
}
|
19
19
|
/**
|
20
20
|
* Provides the behavior and accessibility implementation for an individual
|
package/package.json
CHANGED
package/src/useRadio.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { AriaRadioProps } from '@react-types/radio';
|
2
2
|
import { mergeProps } from '@react-aria/utils';
|
3
|
-
import type {
|
3
|
+
import type { RefObject } from 'react';
|
4
4
|
import type { RadioGroupState } from '@react-stately/radio';
|
5
5
|
import { usePress } from '@react-native-aria/interactions';
|
6
6
|
import type { AccessibilityProps } from 'react-native';
|
@@ -18,8 +18,8 @@ export interface RadioAriaProps extends AriaRadioProps, AccessibilityProps {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
export interface RadioAria extends AccessibilityProps {
|
21
|
-
/** Props for the input element. */
|
22
|
-
inputProps:
|
21
|
+
/** Props for the input or Pressable/Touchable element. */
|
22
|
+
inputProps: any;
|
23
23
|
}
|
24
24
|
|
25
25
|
/**
|