@react-native-aria/toggle 0.2.3 → 0.2.4-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.
@@ -44,16 +44,14 @@ function useToggle(props, state, _ref) {
|
|
44
44
|
});
|
45
45
|
return {
|
46
46
|
inputProps: (0, _utils.mergeProps)(props, {
|
47
|
-
disabled: isDisabled,
|
48
|
-
required: isRequired,
|
49
|
-
readOnly: isReadOnly,
|
47
|
+
'disabled': isDisabled,
|
48
|
+
'required': isRequired,
|
49
|
+
'readOnly': isReadOnly,
|
50
50
|
value,
|
51
51
|
name,
|
52
52
|
...pressProps,
|
53
|
-
|
54
|
-
|
55
|
-
disabled: isDisabled
|
56
|
-
}
|
53
|
+
'aria-label': label,
|
54
|
+
'aria-disabled': isDisabled
|
57
55
|
})
|
58
56
|
};
|
59
57
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useToggle.ts"],"names":["useToggle","props","state","_ref","isDisabled","isRequired","isReadOnly","value","name","onPress","setSelected","isSelected","hasChildren","children","label","console","warn","pressProps","inputProps"
|
1
|
+
{"version":3,"sources":["useToggle.ts"],"names":["useToggle","props","state","_ref","isDisabled","isRequired","isReadOnly","value","name","onPress","setSelected","isSelected","hasChildren","children","label","console","warn","pressProps","inputProps"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AAUA;AACA;AACA;AACO,SAASA,SAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIO;AACZ,MAAI;AACFC,IAAAA,UAAU,GAAG,KADX;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,UAHE;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,IALE,CAMF;;AANE,MAOAP,KAPJ;;AASA,MAAIQ,OAAO,GAAG,MAAM;AAClBP,IAAAA,KAAK,CAACQ,WAAN,CAAkB,CAACR,KAAK,CAACS,UAAzB;AACD,GAFD;;AAIA,MAAIC,WAAW,GAAGX,KAAK,CAACY,QAAN,IAAkB,IAApC;AAEA,QAAMC,KAAK,GAAG,sBAASb,KAAT,CAAd;;AAEA,MAAI,CAACW,WAAD,IAAgB,CAACE,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD,GAtBW,CAwBZ;;;AACA,MAAI;AAAEC,IAAAA;AAAF,MAAiB,4BAAS;AAC5Bb,IAAAA,UAD4B;AAE5BK,IAAAA;AAF4B,GAAT,CAArB;AAKA,SAAO;AACLS,IAAAA,UAAU,EAAE,uBAAWjB,KAAX,EAAkB;AAC5B,kBAAYG,UADgB;AAE5B,kBAAYC,UAFgB;AAG5B,kBAAYC,UAHgB;AAI5BC,MAAAA,KAJ4B;AAK5BC,MAAAA,IAL4B;AAM5B,SAAGS,UANyB;AAO5B,oBAAcH,KAPc;AAQ5B,uBAAiBV;AARW,KAAlB;AADP,GAAP;AAYD","sourcesContent":["import { mergeProps } from '@react-aria/utils';\nimport type { RefObject } from 'react';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { usePress } from '@react-native-aria/interactions';\nimport { getLabel } from '@react-native-aria/utils';\nimport { AriaToggleProps } from '@react-types/checkbox';\n\nexport interface ToggleAria {\n /**\n * Props to be spread on the input element.\n */\n inputProps: any;\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(\n props: AriaToggleProps,\n state: ToggleState,\n _ref: RefObject<any>\n): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n // validationState = 'valid', // No support for Invalid in RN\n } = props;\n\n let onPress = () => {\n state.setSelected(!state.isSelected);\n };\n\n let hasChildren = props.children != null;\n\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 // This handles focusing the input on pointer down, which Safari does not do by default.\n let { pressProps } = usePress({\n isDisabled,\n onPress,\n });\n\n return {\n inputProps: mergeProps(props, {\n 'disabled': isDisabled,\n 'required': isRequired,\n 'readOnly': isReadOnly,\n value,\n name,\n ...pressProps,\n 'aria-label': label,\n 'aria-disabled': isDisabled,\n }),\n };\n}\n"]}
|
package/lib/module/useToggle.js
CHANGED
@@ -35,16 +35,14 @@ export function useToggle(props, state, _ref) {
|
|
35
35
|
});
|
36
36
|
return {
|
37
37
|
inputProps: mergeProps(props, {
|
38
|
-
disabled: isDisabled,
|
39
|
-
required: isRequired,
|
40
|
-
readOnly: isReadOnly,
|
38
|
+
'disabled': isDisabled,
|
39
|
+
'required': isRequired,
|
40
|
+
'readOnly': isReadOnly,
|
41
41
|
value,
|
42
42
|
name,
|
43
43
|
...pressProps,
|
44
|
-
|
45
|
-
|
46
|
-
disabled: isDisabled
|
47
|
-
}
|
44
|
+
'aria-label': label,
|
45
|
+
'aria-disabled': isDisabled
|
48
46
|
})
|
49
47
|
};
|
50
48
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useToggle.ts"],"names":["mergeProps","usePress","getLabel","useToggle","props","state","_ref","isDisabled","isRequired","isReadOnly","value","name","onPress","setSelected","isSelected","hasChildren","children","label","console","warn","pressProps","inputProps"
|
1
|
+
{"version":3,"sources":["useToggle.ts"],"names":["mergeProps","usePress","getLabel","useToggle","props","state","_ref","isDisabled","isRequired","isReadOnly","value","name","onPress","setSelected","isSelected","hasChildren","children","label","console","warn","pressProps","inputProps"],"mappings":"AAAA,SAASA,UAAT,QAA2B,mBAA3B;AAGA,SAASC,QAAT,QAAyB,iCAAzB;AACA,SAASC,QAAT,QAAyB,0BAAzB;;AAUA;AACA;AACA;AACA,OAAO,SAASC,SAAT,CACLC,KADK,EAELC,KAFK,EAGLC,IAHK,EAIO;AACZ,MAAI;AACFC,IAAAA,UAAU,GAAG,KADX;AAEFC,IAAAA,UAFE;AAGFC,IAAAA,UAHE;AAIFC,IAAAA,KAJE;AAKFC,IAAAA,IALE,CAMF;;AANE,MAOAP,KAPJ;;AASA,MAAIQ,OAAO,GAAG,MAAM;AAClBP,IAAAA,KAAK,CAACQ,WAAN,CAAkB,CAACR,KAAK,CAACS,UAAzB;AACD,GAFD;;AAIA,MAAIC,WAAW,GAAGX,KAAK,CAACY,QAAN,IAAkB,IAApC;AAEA,QAAMC,KAAK,GAAGf,QAAQ,CAACE,KAAD,CAAtB;;AAEA,MAAI,CAACW,WAAD,IAAgB,CAACE,KAArB,EAA4B;AAC1BC,IAAAA,OAAO,CAACC,IAAR,CACE,kFADF;AAGD,GAtBW,CAwBZ;;;AACA,MAAI;AAAEC,IAAAA;AAAF,MAAiBnB,QAAQ,CAAC;AAC5BM,IAAAA,UAD4B;AAE5BK,IAAAA;AAF4B,GAAD,CAA7B;AAKA,SAAO;AACLS,IAAAA,UAAU,EAAErB,UAAU,CAACI,KAAD,EAAQ;AAC5B,kBAAYG,UADgB;AAE5B,kBAAYC,UAFgB;AAG5B,kBAAYC,UAHgB;AAI5BC,MAAAA,KAJ4B;AAK5BC,MAAAA,IAL4B;AAM5B,SAAGS,UANyB;AAO5B,oBAAcH,KAPc;AAQ5B,uBAAiBV;AARW,KAAR;AADjB,GAAP;AAYD","sourcesContent":["import { mergeProps } from '@react-aria/utils';\nimport type { RefObject } from 'react';\nimport type { ToggleState } from '@react-stately/toggle';\nimport { usePress } from '@react-native-aria/interactions';\nimport { getLabel } from '@react-native-aria/utils';\nimport { AriaToggleProps } from '@react-types/checkbox';\n\nexport interface ToggleAria {\n /**\n * Props to be spread on the input element.\n */\n inputProps: any;\n}\n\n/**\n * Handles interactions for toggle elements, e.g. Checkboxes and Switches.\n */\nexport function useToggle(\n props: AriaToggleProps,\n state: ToggleState,\n _ref: RefObject<any>\n): ToggleAria {\n let {\n isDisabled = false,\n isRequired,\n isReadOnly,\n value,\n name,\n // validationState = 'valid', // No support for Invalid in RN\n } = props;\n\n let onPress = () => {\n state.setSelected(!state.isSelected);\n };\n\n let hasChildren = props.children != null;\n\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 // This handles focusing the input on pointer down, which Safari does not do by default.\n let { pressProps } = usePress({\n isDisabled,\n onPress,\n });\n\n return {\n inputProps: mergeProps(props, {\n 'disabled': isDisabled,\n 'required': isRequired,\n 'readOnly': isReadOnly,\n value,\n name,\n ...pressProps,\n 'aria-label': label,\n 'aria-disabled': isDisabled,\n }),\n };\n}\n"]}
|
package/package.json
CHANGED
package/src/useToggle.ts
CHANGED
@@ -51,16 +51,14 @@ export function useToggle(
|
|
51
51
|
|
52
52
|
return {
|
53
53
|
inputProps: mergeProps(props, {
|
54
|
-
disabled: isDisabled,
|
55
|
-
required: isRequired,
|
56
|
-
readOnly: isReadOnly,
|
54
|
+
'disabled': isDisabled,
|
55
|
+
'required': isRequired,
|
56
|
+
'readOnly': isReadOnly,
|
57
57
|
value,
|
58
58
|
name,
|
59
59
|
...pressProps,
|
60
|
-
|
61
|
-
|
62
|
-
disabled: isDisabled,
|
63
|
-
},
|
60
|
+
'aria-label': label,
|
61
|
+
'aria-disabled': isDisabled,
|
64
62
|
}),
|
65
63
|
};
|
66
64
|
}
|