@metamask/design-system-react-native 0.7.0 → 0.9.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.
- package/CHANGELOG.md +36 -1
- package/dist/components/BadgeStatus/BadgeStatus.cjs +2 -2
- package/dist/components/BadgeStatus/BadgeStatus.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.cjs +8 -8
- package/dist/components/BadgeStatus/BadgeStatus.constants.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.cts +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.mts +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.mjs +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.constants.mjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.mjs +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.mjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.cjs.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.d.cts +5 -29
- package/dist/components/BadgeStatus/BadgeStatus.types.d.cts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.d.mts +5 -29
- package/dist/components/BadgeStatus/BadgeStatus.types.d.mts.map +1 -1
- package/dist/components/BadgeStatus/BadgeStatus.types.mjs.map +1 -1
- package/dist/components/BadgeStatus/index.cjs +4 -4
- package/dist/components/BadgeStatus/index.cjs.map +1 -1
- package/dist/components/BadgeStatus/index.d.cts +1 -1
- package/dist/components/BadgeStatus/index.d.cts.map +1 -1
- package/dist/components/BadgeStatus/index.d.mts +1 -1
- package/dist/components/BadgeStatus/index.d.mts.map +1 -1
- package/dist/components/BadgeStatus/index.mjs +1 -1
- package/dist/components/BadgeStatus/index.mjs.map +1 -1
- package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.cjs +1 -1
- package/dist/components/BottomSheetFooter/BottomSheetFooter.cjs.map +1 -0
- package/dist/components/BottomSheetFooter/BottomSheetFooter.d.cts.map +1 -0
- package/dist/components/BottomSheetFooter/BottomSheetFooter.d.mts.map +1 -0
- package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.mjs +1 -1
- package/dist/components/BottomSheetFooter/BottomSheetFooter.mjs.map +1 -0
- package/dist/components/BottomSheetFooter/BottomSheetFooter.types.cjs.map +1 -0
- package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.types.d.cts +1 -1
- package/dist/components/BottomSheetFooter/BottomSheetFooter.types.d.cts.map +1 -0
- package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.types.d.mts +1 -1
- package/dist/components/BottomSheetFooter/BottomSheetFooter.types.d.mts.map +1 -0
- package/dist/components/BottomSheetFooter/BottomSheetFooter.types.mjs.map +1 -0
- package/dist/components/BottomSheetFooter/index.cjs.map +1 -0
- package/dist/components/BottomSheetFooter/index.d.cts.map +1 -0
- package/dist/components/BottomSheetFooter/index.d.mts.map +1 -0
- package/dist/components/BottomSheetFooter/index.mjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.cjs +58 -0
- package/dist/components/RadioButton/RadioButton.cjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.constants.cjs +12 -0
- package/dist/components/RadioButton/RadioButton.constants.cjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.constants.d.cts +3 -0
- package/dist/components/RadioButton/RadioButton.constants.d.cts.map +1 -0
- package/dist/components/RadioButton/RadioButton.constants.d.mts +3 -0
- package/dist/components/RadioButton/RadioButton.constants.d.mts.map +1 -0
- package/dist/components/RadioButton/RadioButton.constants.mjs +9 -0
- package/dist/components/RadioButton/RadioButton.constants.mjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.d.cts +4 -0
- package/dist/components/RadioButton/RadioButton.d.cts.map +1 -0
- package/dist/components/RadioButton/RadioButton.d.mts +4 -0
- package/dist/components/RadioButton/RadioButton.d.mts.map +1 -0
- package/dist/components/RadioButton/RadioButton.mjs +58 -0
- package/dist/components/RadioButton/RadioButton.mjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.types.cjs +3 -0
- package/dist/components/RadioButton/RadioButton.types.cjs.map +1 -0
- package/dist/components/RadioButton/RadioButton.types.d.cts +64 -0
- package/dist/components/RadioButton/RadioButton.types.d.cts.map +1 -0
- package/dist/components/RadioButton/RadioButton.types.d.mts +64 -0
- package/dist/components/RadioButton/RadioButton.types.d.mts.map +1 -0
- package/dist/components/RadioButton/RadioButton.types.mjs +2 -0
- package/dist/components/RadioButton/RadioButton.types.mjs.map +1 -0
- package/dist/components/RadioButton/index.cjs +6 -0
- package/dist/components/RadioButton/index.cjs.map +1 -0
- package/dist/components/RadioButton/index.d.cts +3 -0
- package/dist/components/RadioButton/index.d.cts.map +1 -0
- package/dist/components/RadioButton/index.d.mts +3 -0
- package/dist/components/RadioButton/index.d.mts.map +1 -0
- package/dist/components/RadioButton/index.mjs +2 -0
- package/dist/components/RadioButton/index.mjs.map +1 -0
- package/dist/components/TextField/TextField.cjs +42 -0
- package/dist/components/TextField/TextField.cjs.map +1 -0
- package/dist/components/TextField/TextField.constants.cjs +13 -0
- package/dist/components/TextField/TextField.constants.cjs.map +1 -0
- package/dist/components/TextField/TextField.constants.d.cts +6 -0
- package/dist/components/TextField/TextField.constants.d.cts.map +1 -0
- package/dist/components/TextField/TextField.constants.d.mts +6 -0
- package/dist/components/TextField/TextField.constants.d.mts.map +1 -0
- package/dist/components/TextField/TextField.constants.mjs +10 -0
- package/dist/components/TextField/TextField.constants.mjs.map +1 -0
- package/dist/components/TextField/TextField.d.cts +12 -0
- package/dist/components/TextField/TextField.d.cts.map +1 -0
- package/dist/components/TextField/TextField.d.mts +12 -0
- package/dist/components/TextField/TextField.d.mts.map +1 -0
- package/dist/components/TextField/TextField.mjs +39 -0
- package/dist/components/TextField/TextField.mjs.map +1 -0
- package/dist/components/TextField/TextField.types.cjs +13 -0
- package/dist/components/TextField/TextField.types.cjs.map +1 -0
- package/dist/components/TextField/TextField.types.d.cts +49 -0
- package/dist/components/TextField/TextField.types.d.cts.map +1 -0
- package/dist/components/TextField/TextField.types.d.mts +49 -0
- package/dist/components/TextField/TextField.types.d.mts.map +1 -0
- package/dist/components/TextField/TextField.types.mjs +10 -0
- package/dist/components/TextField/TextField.types.mjs.map +1 -0
- package/dist/components/TextField/index.cjs +8 -0
- package/dist/components/TextField/index.cjs.map +1 -0
- package/dist/components/TextField/index.d.cts +4 -0
- package/dist/components/TextField/index.d.cts.map +1 -0
- package/dist/components/TextField/index.d.mts +4 -0
- package/dist/components/TextField/index.d.mts.map +1 -0
- package/dist/components/TextField/index.mjs +3 -0
- package/dist/components/TextField/index.mjs.map +1 -0
- package/dist/components/index.cjs +7 -2
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +6 -2
- package/dist/components/index.d.cts.map +1 -1
- package/dist/components/index.d.mts +6 -2
- package/dist/components/index.d.mts.map +1 -1
- package/dist/components/index.mjs +3 -1
- package/dist/components/index.mjs.map +1 -1
- package/dist/types/index.cjs +1 -26
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +0 -23
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.mts +0 -23
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs +0 -25
- package/dist/types/index.mjs.map +1 -1
- package/package.json +3 -3
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.cjs.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.d.cts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.d.mts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.mjs.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.types.cjs.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.types.d.cts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.types.d.mts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/BottomSheetFooter.types.mjs.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/index.cjs.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/index.d.cts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/index.d.mts.map +0 -1
- package/dist/components/BottomSheets/BottomSheetFooter/index.mjs.map +0 -1
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.d.cts +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.d.mts +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.types.cjs +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/BottomSheetFooter.types.mjs +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/index.cjs +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/index.d.cts +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/index.d.mts +0 -0
- /package/dist/components/{BottomSheets/BottomSheetFooter → BottomSheetFooter}/index.mjs +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.constants.d.cts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAG5D,eAAO,MAAM,wBAAwB,EAAE,gBAMtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.constants.d.mts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAG5D,eAAO,MAAM,wBAAwB,EAAE,gBAMtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.constants.mjs","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.constants.ts"],"names":[],"mappings":"AAEA,qCAAqC;AACrC,MAAM,CAAC,MAAM,wBAAwB,GAAqB;IACxD,KAAK,EAAE,0BAA0B;IACjC,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE,KAAK;IACjB,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,KAAK;CAChB,CAAC","sourcesContent":["import type { RadioButtonProps } from './RadioButton.types';\n\n// Sample props for stories and tests\nexport const SAMPLE_RADIOBUTTON_PROPS: RadioButtonProps = {\n label: 'Sample RadioButton Label',\n isChecked: false,\n isDisabled: false,\n isReadOnly: false,\n isDanger: false,\n};\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { RadioButtonProps } from "./RadioButton.types.cjs";
|
|
3
|
+
export declare const RadioButton: ({ onPress, label, labelProps, isChecked, isDisabled, isReadOnly, isDanger, touchableOpacityProps, radioButtonContainerProps, twClassName, style, ...props }: RadioButtonProps) => React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=RadioButton.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.d.cts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc;AAK1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAgC5D,eAAO,MAAM,WAAW,gKAarB,gBAAgB,sBA0DlB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { RadioButtonProps } from "./RadioButton.types.mjs";
|
|
3
|
+
export declare const RadioButton: ({ onPress, label, labelProps, isChecked, isDisabled, isReadOnly, isDanger, touchableOpacityProps, radioButtonContainerProps, twClassName, style, ...props }: RadioButtonProps) => React.JSX.Element;
|
|
4
|
+
//# sourceMappingURL=RadioButton.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.d.mts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc;AAK1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,gCAA4B;AAgC5D,eAAO,MAAM,WAAW,gKAarB,gBAAgB,sBA0DlB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function $importDefault(module) {
|
|
2
|
+
if (module?.__esModule) {
|
|
3
|
+
return module.default;
|
|
4
|
+
}
|
|
5
|
+
return module;
|
|
6
|
+
}
|
|
7
|
+
import { useTailwind } from "@metamask/design-system-twrnc-preset";
|
|
8
|
+
import $React from "react";
|
|
9
|
+
const React = $importDefault($React);
|
|
10
|
+
import { View, TouchableOpacity } from "react-native/index.js";
|
|
11
|
+
import { TextOrChildren } from "../temp-components/TextOrChildren/index.mjs";
|
|
12
|
+
const getRadioButtonBorderClass = (isReadOnly, isDanger, isChecked) => {
|
|
13
|
+
if (isReadOnly) {
|
|
14
|
+
return 'border-background-default';
|
|
15
|
+
}
|
|
16
|
+
if (isDanger) {
|
|
17
|
+
return 'border-error-default';
|
|
18
|
+
}
|
|
19
|
+
if (isChecked) {
|
|
20
|
+
return 'border-primary-default';
|
|
21
|
+
}
|
|
22
|
+
return 'border-default';
|
|
23
|
+
};
|
|
24
|
+
const getRadioButtonDotClass = (isReadOnly, isDanger) => {
|
|
25
|
+
if (isReadOnly) {
|
|
26
|
+
return 'bg-icon-alternative';
|
|
27
|
+
}
|
|
28
|
+
if (isDanger) {
|
|
29
|
+
return 'bg-error-default';
|
|
30
|
+
}
|
|
31
|
+
return 'bg-primary-default';
|
|
32
|
+
};
|
|
33
|
+
export const RadioButton = ({ onPress, label, labelProps, isChecked = false, isDisabled = false, isReadOnly = false, isDanger = false, touchableOpacityProps, radioButtonContainerProps, twClassName, style, ...props }) => {
|
|
34
|
+
const tw = useTailwind();
|
|
35
|
+
return (<View {...props} style={[
|
|
36
|
+
tw.style('flex-row items-center', isDisabled ? 'opacity-50' : 'opacity-100', twClassName),
|
|
37
|
+
style,
|
|
38
|
+
]}>
|
|
39
|
+
<TouchableOpacity onPress={onPress} disabled={isDisabled || isReadOnly} accessible accessibilityRole="radio" accessibilityState={{
|
|
40
|
+
checked: isChecked,
|
|
41
|
+
disabled: isDisabled,
|
|
42
|
+
}} accessibilityLabel={typeof label === 'string' ? label : undefined} {...touchableOpacityProps} style={[
|
|
43
|
+
tw.style('flex-row items-center'),
|
|
44
|
+
touchableOpacityProps?.style,
|
|
45
|
+
]}>
|
|
46
|
+
<View {...radioButtonContainerProps} style={[
|
|
47
|
+
tw.style('size-5 items-center justify-center rounded-full border-2 bg-default', getRadioButtonBorderClass(isReadOnly, isDanger, isChecked)),
|
|
48
|
+
radioButtonContainerProps?.style,
|
|
49
|
+
]}>
|
|
50
|
+
{isChecked && (<View style={tw.style('size-3 rounded-full', getRadioButtonDotClass(isReadOnly, isDanger))}/>)}
|
|
51
|
+
</View>
|
|
52
|
+
{label ? (<TextOrChildren textProps={{ ...labelProps, twClassName: 'ml-3' }}>
|
|
53
|
+
{label}
|
|
54
|
+
</TextOrChildren>) : null}
|
|
55
|
+
</TouchableOpacity>
|
|
56
|
+
</View>);
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=RadioButton.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.mjs","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.tsx"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WA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,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,CACnC,UAAU,CACV,iBAAiB,CAAC,OAAO,CACzB,kBAAkB,CAAC,CAAC;YAClB,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,UAAU;SACrB,CAAC,CACF,kBAAkB,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAClE,IAAI,qBAAqB,CAAC,CAC1B,KAAK,CAAC,CAAC;YACL,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC;YACjC,qBAAqB,EAAE,KAAK;SAC7B,CAAC,CAEF;QAAA,CAAC,IAAI,CACH,IAAI,yBAAyB,CAAC,CAC9B,KAAK,CAAC,CAAC;YACL,EAAE,CAAC,KAAK,CACN,qEAAqE,EACrE,yBAAyB,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAC3D;YACD,yBAAyB,EAAE,KAAK;SACjC,CAAC,CAEF;UAAA,CAAC,SAAS,IAAI,CACZ,CAAC,IAAI,CACH,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CACb,qBAAqB,EACrB,sBAAsB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAC7C,CAAC,EACF,CACH,CACH;QAAA,EAAE,IAAI,CACN;QAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CACP,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAChE;YAAA,CAAC,KAAK,CACR;UAAA,EAAE,cAAc,CAAC,CAClB,CAAC,CAAC,CAAC,IAAI,CACV;MAAA,EAAE,gBAAgB,CACpB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport React from 'react';\nimport { View, TouchableOpacity } from 'react-native';\n\nimport { TextOrChildren } from '../temp-components/TextOrChildren';\n\nimport type { RadioButtonProps } from './RadioButton.types';\n\nconst getRadioButtonBorderClass = (\n isReadOnly: boolean,\n isDanger: boolean,\n isChecked: boolean,\n): string => {\n if (isReadOnly) {\n return 'border-background-default';\n }\n if (isDanger) {\n return 'border-error-default';\n }\n if (isChecked) {\n return 'border-primary-default';\n }\n return 'border-default';\n};\n\nconst getRadioButtonDotClass = (\n isReadOnly: boolean,\n isDanger: boolean,\n): string => {\n if (isReadOnly) {\n return 'bg-icon-alternative';\n }\n if (isDanger) {\n return 'bg-error-default';\n }\n return 'bg-primary-default';\n};\n\nexport const RadioButton = ({\n onPress,\n label,\n labelProps,\n isChecked = false,\n isDisabled = false,\n isReadOnly = false,\n isDanger = false,\n touchableOpacityProps,\n radioButtonContainerProps,\n twClassName,\n style,\n ...props\n}: RadioButtonProps) => {\n const tw = useTailwind();\n\n return (\n <View\n {...props}\n style={[\n tw.style(\n 'flex-row items-center',\n isDisabled ? 'opacity-50' : 'opacity-100',\n twClassName,\n ),\n style,\n ]}\n >\n <TouchableOpacity\n onPress={onPress}\n disabled={isDisabled || isReadOnly}\n accessible\n accessibilityRole=\"radio\"\n accessibilityState={{\n checked: isChecked,\n disabled: isDisabled,\n }}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...touchableOpacityProps}\n style={[\n tw.style('flex-row items-center'),\n touchableOpacityProps?.style,\n ]}\n >\n <View\n {...radioButtonContainerProps}\n style={[\n tw.style(\n 'size-5 items-center justify-center rounded-full border-2 bg-default',\n getRadioButtonBorderClass(isReadOnly, isDanger, isChecked),\n ),\n radioButtonContainerProps?.style,\n ]}\n >\n {isChecked && (\n <View\n style={tw.style(\n 'size-3 rounded-full',\n getRadioButtonDotClass(isReadOnly, isDanger),\n )}\n />\n )}\n </View>\n {label ? (\n <TextOrChildren textProps={{ ...labelProps, twClassName: 'ml-3' }}>\n {label}\n </TextOrChildren>\n ) : null}\n </TouchableOpacity>\n </View>\n );\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.types.cjs","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TouchableOpacityProps, ViewProps } from 'react-native';\n\nimport type { TextProps } from '../Text';\n\n/**\n * RadioButton component props.\n *\n * Extends ViewProps so the root View inherits standard React Native\n * props such as `testID` and `accessibilityLabel`.\n */\nexport type RadioButtonProps = {\n /**\n * Optional callback triggered when the radio button is pressed.\n */\n onPress?: () => void;\n\n /**\n * Optional label displayed beside the radio button.\n */\n label?: string | React.ReactNode;\n\n /**\n * Optional props passed to the label's Text component.\n */\n labelProps?: Omit<Partial<TextProps>, 'children'>;\n\n /**\n * Optional prop to configure the checked state.\n *\n * @default false\n */\n isChecked?: boolean;\n\n /**\n * Optional prop to configure the disabled state.\n *\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Optional prop to configure the read-only state.\n *\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Optional prop to configure the danger state.\n *\n * @default false\n */\n isDanger?: boolean;\n\n /**\n * Optional props passed to the inner TouchableOpacity.\n * Use this for TouchableOpacity-specific props such as `testID`.\n */\n touchableOpacityProps?: Omit<\n Partial<TouchableOpacityProps>,\n 'children' | 'onPress' | 'disabled'\n >;\n\n /**\n * Optional props passed to the radio button circle container.\n */\n radioButtonContainerProps?: Omit<Partial<ViewProps>, 'children'>;\n\n /**\n * Optional Tailwind CSS classes for the root container.\n */\n twClassName?: string;\n\n /**\n * Optional custom styles for the root container.\n */\n style?: ViewProps['style'];\n} & Omit<ViewProps, 'children'>;\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { TouchableOpacityProps, ViewProps } from "react-native/index.js";
|
|
2
|
+
import type { TextProps } from "../Text/index.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* RadioButton component props.
|
|
5
|
+
*
|
|
6
|
+
* Extends ViewProps so the root View inherits standard React Native
|
|
7
|
+
* props such as `testID` and `accessibilityLabel`.
|
|
8
|
+
*/
|
|
9
|
+
export type RadioButtonProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Optional callback triggered when the radio button is pressed.
|
|
12
|
+
*/
|
|
13
|
+
onPress?: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Optional label displayed beside the radio button.
|
|
16
|
+
*/
|
|
17
|
+
label?: string | React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Optional props passed to the label's Text component.
|
|
20
|
+
*/
|
|
21
|
+
labelProps?: Omit<Partial<TextProps>, 'children'>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional prop to configure the checked state.
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
isChecked?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional prop to configure the disabled state.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
isDisabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional prop to configure the read-only state.
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
isReadOnly?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Optional prop to configure the danger state.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
isDanger?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional props passed to the inner TouchableOpacity.
|
|
48
|
+
* Use this for TouchableOpacity-specific props such as `testID`.
|
|
49
|
+
*/
|
|
50
|
+
touchableOpacityProps?: Omit<Partial<TouchableOpacityProps>, 'children' | 'onPress' | 'disabled'>;
|
|
51
|
+
/**
|
|
52
|
+
* Optional props passed to the radio button circle container.
|
|
53
|
+
*/
|
|
54
|
+
radioButtonContainerProps?: Omit<Partial<ViewProps>, 'children'>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional Tailwind CSS classes for the root container.
|
|
57
|
+
*/
|
|
58
|
+
twClassName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional custom styles for the root container.
|
|
61
|
+
*/
|
|
62
|
+
style?: ViewProps['style'];
|
|
63
|
+
} & Omit<ViewProps, 'children'>;
|
|
64
|
+
//# sourceMappingURL=RadioButton.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.types.d.cts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,8BAAqB;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAEjC;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IAElD;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,CAC1B,OAAO,CAAC,qBAAqB,CAAC,EAC9B,UAAU,GAAG,SAAS,GAAG,UAAU,CACpC,CAAC;IAEF;;OAEG;IACH,yBAAyB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IAEjE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { TouchableOpacityProps, ViewProps } from "react-native/index.js";
|
|
2
|
+
import type { TextProps } from "../Text/index.mjs";
|
|
3
|
+
/**
|
|
4
|
+
* RadioButton component props.
|
|
5
|
+
*
|
|
6
|
+
* Extends ViewProps so the root View inherits standard React Native
|
|
7
|
+
* props such as `testID` and `accessibilityLabel`.
|
|
8
|
+
*/
|
|
9
|
+
export type RadioButtonProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Optional callback triggered when the radio button is pressed.
|
|
12
|
+
*/
|
|
13
|
+
onPress?: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Optional label displayed beside the radio button.
|
|
16
|
+
*/
|
|
17
|
+
label?: string | React.ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Optional props passed to the label's Text component.
|
|
20
|
+
*/
|
|
21
|
+
labelProps?: Omit<Partial<TextProps>, 'children'>;
|
|
22
|
+
/**
|
|
23
|
+
* Optional prop to configure the checked state.
|
|
24
|
+
*
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
isChecked?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Optional prop to configure the disabled state.
|
|
30
|
+
*
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
isDisabled?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Optional prop to configure the read-only state.
|
|
36
|
+
*
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
isReadOnly?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Optional prop to configure the danger state.
|
|
42
|
+
*
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
isDanger?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional props passed to the inner TouchableOpacity.
|
|
48
|
+
* Use this for TouchableOpacity-specific props such as `testID`.
|
|
49
|
+
*/
|
|
50
|
+
touchableOpacityProps?: Omit<Partial<TouchableOpacityProps>, 'children' | 'onPress' | 'disabled'>;
|
|
51
|
+
/**
|
|
52
|
+
* Optional props passed to the radio button circle container.
|
|
53
|
+
*/
|
|
54
|
+
radioButtonContainerProps?: Omit<Partial<ViewProps>, 'children'>;
|
|
55
|
+
/**
|
|
56
|
+
* Optional Tailwind CSS classes for the root container.
|
|
57
|
+
*/
|
|
58
|
+
twClassName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Optional custom styles for the root container.
|
|
61
|
+
*/
|
|
62
|
+
style?: ViewProps['style'];
|
|
63
|
+
} & Omit<ViewProps, 'children'>;
|
|
64
|
+
//# sourceMappingURL=RadioButton.types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.types.d.mts","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,SAAS,EAAE,8BAAqB;AAErE,OAAO,KAAK,EAAE,SAAS,EAAE,0BAAgB;AAEzC;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC;IAEjC;;OAEG;IACH,UAAU,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IAElD;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,qBAAqB,CAAC,EAAE,IAAI,CAC1B,OAAO,CAAC,qBAAqB,CAAC,EAC9B,UAAU,GAAG,SAAS,GAAG,UAAU,CACpC,CAAC;IAEF;;OAEG;IACH,yBAAyB,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IAEjE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RadioButton.types.mjs","sourceRoot":"","sources":["../../../src/components/RadioButton/RadioButton.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TouchableOpacityProps, ViewProps } from 'react-native';\n\nimport type { TextProps } from '../Text';\n\n/**\n * RadioButton component props.\n *\n * Extends ViewProps so the root View inherits standard React Native\n * props such as `testID` and `accessibilityLabel`.\n */\nexport type RadioButtonProps = {\n /**\n * Optional callback triggered when the radio button is pressed.\n */\n onPress?: () => void;\n\n /**\n * Optional label displayed beside the radio button.\n */\n label?: string | React.ReactNode;\n\n /**\n * Optional props passed to the label's Text component.\n */\n labelProps?: Omit<Partial<TextProps>, 'children'>;\n\n /**\n * Optional prop to configure the checked state.\n *\n * @default false\n */\n isChecked?: boolean;\n\n /**\n * Optional prop to configure the disabled state.\n *\n * @default false\n */\n isDisabled?: boolean;\n\n /**\n * Optional prop to configure the read-only state.\n *\n * @default false\n */\n isReadOnly?: boolean;\n\n /**\n * Optional prop to configure the danger state.\n *\n * @default false\n */\n isDanger?: boolean;\n\n /**\n * Optional props passed to the inner TouchableOpacity.\n * Use this for TouchableOpacity-specific props such as `testID`.\n */\n touchableOpacityProps?: Omit<\n Partial<TouchableOpacityProps>,\n 'children' | 'onPress' | 'disabled'\n >;\n\n /**\n * Optional props passed to the radio button circle container.\n */\n radioButtonContainerProps?: Omit<Partial<ViewProps>, 'children'>;\n\n /**\n * Optional Tailwind CSS classes for the root container.\n */\n twClassName?: string;\n\n /**\n * Optional custom styles for the root container.\n */\n style?: ViewProps['style'];\n} & Omit<ViewProps, 'children'>;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RadioButton = void 0;
|
|
4
|
+
var RadioButton_1 = require("./RadioButton.cjs");
|
|
5
|
+
Object.defineProperty(exports, "RadioButton", { enumerable: true, get: function () { return RadioButton_1.RadioButton; } });
|
|
6
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sourceRoot":"","sources":["../../../src/components/RadioButton/index.ts"],"names":[],"mappings":";;;AAAA,iDAA4C;AAAnC,0GAAA,WAAW,OAAA","sourcesContent":["export { RadioButton } from './RadioButton';\nexport type { RadioButtonProps } from './RadioButton.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/RadioButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,YAAY,EAAE,gBAAgB,EAAE,gCAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/components/RadioButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,YAAY,EAAE,gBAAgB,EAAE,gCAA4B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/components/RadioButton/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAAsB","sourcesContent":["export { RadioButton } from './RadioButton';\nexport type { RadioButtonProps } from './RadioButton.types';\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextField = void 0;
|
|
4
|
+
const design_system_twrnc_preset_1 = require("@metamask/design-system-twrnc-preset");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_native_1 = require("react-native/index.js");
|
|
7
|
+
const types_1 = require("../../types/index.cjs");
|
|
8
|
+
const Input_1 = require("../Input/index.cjs");
|
|
9
|
+
const TextField_constants_1 = require("./TextField.constants.cjs");
|
|
10
|
+
const TextField_types_1 = require("./TextField.types.cjs");
|
|
11
|
+
exports.TextField = (0, react_1.forwardRef)(({ style, size = TextField_types_1.TextFieldSize.Md, startAccessory, endAccessory, isError = false, inputElement, isDisabled = false, autoFocus = false, twClassName, onBlur, onFocus, testID, ...props }, ref) => {
|
|
12
|
+
const [isFocused, setIsFocused] = (0, react_1.useState)(autoFocus);
|
|
13
|
+
const inputRef = (0, react_1.useRef)(null);
|
|
14
|
+
const tw = (0, design_system_twrnc_preset_1.useTailwind)();
|
|
15
|
+
(0, react_1.useImperativeHandle)(ref, () => inputRef.current, []);
|
|
16
|
+
const containerStyle = (0, react_1.useMemo)(() => tw.style('flex-row', 'items-center', 'rounded-lg', TextField_constants_1.TWCLASSMAP_TEXTFIELD_SIZE[size], 'border', 'px-4', 'bg-default', 'border-default', isError && 'border-error-default', !isDisabled && isFocused && 'border-primary-default', isDisabled && 'opacity-50', twClassName), [size, isError, isFocused, isDisabled, twClassName, tw]);
|
|
17
|
+
const onBlurHandler = (0, react_1.useCallback)((e) => {
|
|
18
|
+
if (!isDisabled) {
|
|
19
|
+
setIsFocused(false);
|
|
20
|
+
onBlur?.(e);
|
|
21
|
+
}
|
|
22
|
+
}, [isDisabled, onBlur]);
|
|
23
|
+
const onFocusHandler = (0, react_1.useCallback)((e) => {
|
|
24
|
+
if (!isDisabled) {
|
|
25
|
+
setIsFocused(true);
|
|
26
|
+
onFocus?.(e);
|
|
27
|
+
}
|
|
28
|
+
}, [isDisabled, onFocus]);
|
|
29
|
+
const onPressHandler = (0, react_1.useCallback)(() => {
|
|
30
|
+
if (!isDisabled && inputRef.current) {
|
|
31
|
+
inputRef.current.focus();
|
|
32
|
+
}
|
|
33
|
+
}, [isDisabled]);
|
|
34
|
+
return (<react_native_1.Pressable testID={testID} style={[containerStyle, style]} onPress={onPressHandler} accessible={false}>
|
|
35
|
+
{startAccessory && (<react_native_1.View style={tw.style('mr-2')}>{startAccessory}</react_native_1.View>)}
|
|
36
|
+
<react_native_1.View style={tw.style('flex-1')}>
|
|
37
|
+
{inputElement ?? (<Input_1.Input {...props} ref={inputRef} textVariant={types_1.TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled twClassName="bg-transparent border-0"/>)}
|
|
38
|
+
</react_native_1.View>
|
|
39
|
+
{endAccessory && <react_native_1.View style={tw.style('ml-2')}>{endAccessory}</react_native_1.View>}
|
|
40
|
+
</react_native_1.Pressable>);
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=TextField.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":";;;AAAA,qFAAmE;AACnE,iCAOe;AACf,wDAA0D;AAE1D,iDAA0C;AAC1C,8CAAiC;AAEjC,mEAAkE;AAClE,2DAAkD;AAGrC,QAAA,SAAS,GAAG,IAAA,kBAAU,EACjC,CACE,EACE,KAAK,EACL,IAAI,GAAG,+BAAa,CAAC,EAAE,EACvB,cAAc,EACd,YAAY,EACZ,OAAO,GAAG,KAAK,EACf,YAAY,EACZ,UAAU,GAAG,KAAK,EAClB,SAAS,GAAG,KAAK,EACjB,WAAW,EACX,MAAM,EACN,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACT,EACD,GAAG,EACH,EAAE;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,SAAS,CAAC,CAAC;IACtD,MAAM,QAAQ,GAAG,IAA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ACH,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,CAAC,wBAAS,CACR,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAC/B,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,UAAU,CAAC,CAAC,KAAK,CAAC,CAElB;QAAA,CAAC,cAAc,IAAI,CACjB,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,mBAAI,CAAC,CACvD,CACD;QAAA,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAC9B;UAAA,CAAC,YAAY,IAAI,CACf,CAAC,aAAK,CACJ,IAAI,KAAK,CAAC,CACV,GAAG,CAAC,CAAC,QAAQ,CAAC,CACd,WAAW,CAAC,CAAC,mBAAW,CAAC,MAAM,CAAC,CAChC,UAAU,CAAC,CAAC,UAAU,CAAC,CACvB,SAAS,CAAC,CAAC,SAAS,CAAC,CACrB,MAAM,CAAC,CAAC,aAAa,CAAC,CACtB,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,qBAAqB,CACrB,WAAW,CAAC,yBAAyB,EACrC,CACH,CACH;QAAA,EAAE,mBAAI,CACN;QAAA,CAAC,YAAY,IAAI,CAAC,mBAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,mBAAI,CAAC,CACvE;MAAA,EAAE,wBAAS,CAAC,CACb,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Pressable, TextInput, View } from 'react-native';\n\nimport { TextVariant } from '../../types';\nimport { Input } from '../Input';\n\nimport { TWCLASSMAP_TEXTFIELD_SIZE } from './TextField.constants';\nimport { TextFieldSize } from './TextField.types';\nimport type { TextFieldProps } from './TextField.types';\n\nexport const TextField = forwardRef<TextInput, TextFieldProps>(\n (\n {\n style,\n size = TextFieldSize.Md,\n startAccessory,\n endAccessory,\n isError = false,\n inputElement,\n isDisabled = false,\n autoFocus = false,\n twClassName,\n onBlur,\n onFocus,\n testID,\n ...props\n },\n ref,\n ) => {\n const [isFocused, setIsFocused] = useState(autoFocus);\n const inputRef = useRef<TextInput>(null);\n const tw = useTailwind();\n\n useImperativeHandle<TextInput | null, TextInput | null>(\n ref,\n () => inputRef.current,\n [],\n );\n\n const containerStyle = useMemo(\n () =>\n tw.style(\n 'flex-row',\n 'items-center',\n 'rounded-lg',\n TWCLASSMAP_TEXTFIELD_SIZE[size],\n 'border',\n 'px-4',\n 'bg-default',\n 'border-default',\n isError && 'border-error-default',\n !isDisabled && isFocused && 'border-primary-default',\n isDisabled && 'opacity-50',\n twClassName,\n ),\n [size, isError, isFocused, isDisabled, twClassName, tw],\n );\n\n const onBlurHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onBlur']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(false);\n onBlur?.(e);\n }\n },\n [isDisabled, onBlur],\n );\n\n const onFocusHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onFocus']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(true);\n onFocus?.(e);\n }\n },\n [isDisabled, onFocus],\n );\n\n const onPressHandler = useCallback(() => {\n if (!isDisabled && inputRef.current) {\n inputRef.current.focus();\n }\n }, [isDisabled]);\n\n return (\n <Pressable\n testID={testID}\n style={[containerStyle, style]}\n onPress={onPressHandler}\n accessible={false}\n >\n {startAccessory && (\n <View style={tw.style('mr-2')}>{startAccessory}</View>\n )}\n <View style={tw.style('flex-1')}>\n {inputElement ?? (\n <Input\n {...props}\n ref={inputRef}\n textVariant={TextVariant.BodyMd}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n isStateStylesDisabled\n twClassName=\"bg-transparent border-0\"\n />\n )}\n </View>\n {endAccessory && <View style={tw.style('ml-2')}>{endAccessory}</View>}\n </Pressable>\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TWCLASSMAP_TEXTFIELD_SIZE = void 0;
|
|
4
|
+
const TextField_types_1 = require("./TextField.types.cjs");
|
|
5
|
+
/**
|
|
6
|
+
* Tailwind class map for TextField sizes.
|
|
7
|
+
*/
|
|
8
|
+
exports.TWCLASSMAP_TEXTFIELD_SIZE = {
|
|
9
|
+
[TextField_types_1.TextFieldSize.Sm]: 'h-8',
|
|
10
|
+
[TextField_types_1.TextFieldSize.Md]: 'h-10',
|
|
11
|
+
[TextField_types_1.TextFieldSize.Lg]: 'h-12',
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=TextField.constants.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.constants.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.constants.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAElD;;GAEG;AACU,QAAA,yBAAyB,GAAkC;IACtE,CAAC,+BAAa,CAAC,EAAE,CAAC,EAAE,KAAK;IACzB,CAAC,+BAAa,CAAC,EAAE,CAAC,EAAE,MAAM;IAC1B,CAAC,+BAAa,CAAC,EAAE,CAAC,EAAE,MAAM;CAC3B,CAAC","sourcesContent":["import { TextFieldSize } from './TextField.types';\n\n/**\n * Tailwind class map for TextField sizes.\n */\nexport const TWCLASSMAP_TEXTFIELD_SIZE: Record<TextFieldSize, string> = {\n [TextFieldSize.Sm]: 'h-8',\n [TextFieldSize.Md]: 'h-10',\n [TextFieldSize.Lg]: 'h-12',\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.constants.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAElD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAInE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.constants.d.mts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAElD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAInE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TextFieldSize } from "./TextField.types.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* Tailwind class map for TextField sizes.
|
|
4
|
+
*/
|
|
5
|
+
export const TWCLASSMAP_TEXTFIELD_SIZE = {
|
|
6
|
+
[TextFieldSize.Sm]: 'h-8',
|
|
7
|
+
[TextFieldSize.Md]: 'h-10',
|
|
8
|
+
[TextFieldSize.Lg]: 'h-12',
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=TextField.constants.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.constants.mjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAkC;IACtE,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,KAAK;IACzB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM;IAC1B,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM;CAC3B,CAAC","sourcesContent":["import { TextFieldSize } from './TextField.types';\n\n/**\n * Tailwind class map for TextField sizes.\n */\nexport const TWCLASSMAP_TEXTFIELD_SIZE: Record<TextFieldSize, string> = {\n [TextFieldSize.Sm]: 'h-8',\n [TextFieldSize.Md]: 'h-10',\n [TextFieldSize.Lg]: 'h-12',\n};\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TextInput } from "react-native/index.js";
|
|
2
|
+
import { TextFieldSize } from "./TextField.types.cjs";
|
|
3
|
+
export declare const TextField: import("react").ForwardRefExoticComponent<Omit<import("../Input/index.cjs").InputProps, "style" | "textVariant" | "isStateStylesDisabled"> & {
|
|
4
|
+
size?: TextFieldSize | undefined;
|
|
5
|
+
startAccessory?: import("react").ReactNode;
|
|
6
|
+
endAccessory?: import("react").ReactNode;
|
|
7
|
+
isError?: boolean | undefined;
|
|
8
|
+
inputElement?: import("react").ReactNode;
|
|
9
|
+
twClassName?: string | undefined;
|
|
10
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
11
|
+
} & import("react").RefAttributes<TextInput>>;
|
|
12
|
+
//# sourceMappingURL=TextField.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;AAM1D,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAGlD,eAAO,MAAM,SAAS;;;;;;;;6CAuGrB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TextInput } from "react-native/index.js";
|
|
2
|
+
import { TextFieldSize } from "./TextField.types.mjs";
|
|
3
|
+
export declare const TextField: import("react").ForwardRefExoticComponent<Omit<import("../Input/index.mjs").InputProps, "style" | "textVariant" | "isStateStylesDisabled"> & {
|
|
4
|
+
size?: TextFieldSize | undefined;
|
|
5
|
+
startAccessory?: import("react").ReactNode;
|
|
6
|
+
endAccessory?: import("react").ReactNode;
|
|
7
|
+
isError?: boolean | undefined;
|
|
8
|
+
inputElement?: import("react").ReactNode;
|
|
9
|
+
twClassName?: string | undefined;
|
|
10
|
+
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
11
|
+
} & import("react").RefAttributes<TextInput>>;
|
|
12
|
+
//# sourceMappingURL=TextField.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.d.mts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AASA,OAAO,EAAa,SAAS,EAAQ,8BAAqB;AAM1D,OAAO,EAAE,aAAa,EAAE,8BAA0B;AAGlD,eAAO,MAAM,SAAS;;;;;;;;6CAuGrB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useTailwind } from "@metamask/design-system-twrnc-preset";
|
|
2
|
+
import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Pressable, TextInput, View } from "react-native/index.js";
|
|
4
|
+
import { TextVariant } from "../../types/index.mjs";
|
|
5
|
+
import { Input } from "../Input/index.mjs";
|
|
6
|
+
import { TWCLASSMAP_TEXTFIELD_SIZE } from "./TextField.constants.mjs";
|
|
7
|
+
import { TextFieldSize } from "./TextField.types.mjs";
|
|
8
|
+
export const TextField = forwardRef(({ style, size = TextFieldSize.Md, startAccessory, endAccessory, isError = false, inputElement, isDisabled = false, autoFocus = false, twClassName, onBlur, onFocus, testID, ...props }, ref) => {
|
|
9
|
+
const [isFocused, setIsFocused] = useState(autoFocus);
|
|
10
|
+
const inputRef = useRef(null);
|
|
11
|
+
const tw = useTailwind();
|
|
12
|
+
useImperativeHandle(ref, () => inputRef.current, []);
|
|
13
|
+
const containerStyle = useMemo(() => tw.style('flex-row', 'items-center', 'rounded-lg', TWCLASSMAP_TEXTFIELD_SIZE[size], 'border', 'px-4', 'bg-default', 'border-default', isError && 'border-error-default', !isDisabled && isFocused && 'border-primary-default', isDisabled && 'opacity-50', twClassName), [size, isError, isFocused, isDisabled, twClassName, tw]);
|
|
14
|
+
const onBlurHandler = useCallback((e) => {
|
|
15
|
+
if (!isDisabled) {
|
|
16
|
+
setIsFocused(false);
|
|
17
|
+
onBlur?.(e);
|
|
18
|
+
}
|
|
19
|
+
}, [isDisabled, onBlur]);
|
|
20
|
+
const onFocusHandler = useCallback((e) => {
|
|
21
|
+
if (!isDisabled) {
|
|
22
|
+
setIsFocused(true);
|
|
23
|
+
onFocus?.(e);
|
|
24
|
+
}
|
|
25
|
+
}, [isDisabled, onFocus]);
|
|
26
|
+
const onPressHandler = useCallback(() => {
|
|
27
|
+
if (!isDisabled && inputRef.current) {
|
|
28
|
+
inputRef.current.focus();
|
|
29
|
+
}
|
|
30
|
+
}, [isDisabled]);
|
|
31
|
+
return (<Pressable testID={testID} style={[containerStyle, style]} onPress={onPressHandler} accessible={false}>
|
|
32
|
+
{startAccessory && (<View style={tw.style('mr-2')}>{startAccessory}</View>)}
|
|
33
|
+
<View style={tw.style('flex-1')}>
|
|
34
|
+
{inputElement ?? (<Input {...props} ref={inputRef} textVariant={TextVariant.BodyMd} isDisabled={isDisabled} autoFocus={autoFocus} onBlur={onBlurHandler} onFocus={onFocusHandler} isStateStylesDisabled twClassName="bg-transparent border-0"/>)}
|
|
35
|
+
</View>
|
|
36
|
+
{endAccessory && <View style={tw.style('ml-2')}>{endAccessory}</View>}
|
|
37
|
+
</Pressable>);
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=TextField.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.mjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,6CAA6C;AACnE,OAAO,EACL,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,QAAQ,EACT,cAAc;AACf,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI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C,CAAC,SAAS,CAAC,CACrB,MAAM,CAAC,CAAC,aAAa,CAAC,CACtB,OAAO,CAAC,CAAC,cAAc,CAAC,CACxB,qBAAqB,CACrB,WAAW,CAAC,yBAAyB,EACrC,CACH,CACH;QAAA,EAAE,IAAI,CACN;QAAA,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC,CACvE;MAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { useTailwind } from '@metamask/design-system-twrnc-preset';\nimport {\n forwardRef,\n useCallback,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { Pressable, TextInput, View } from 'react-native';\n\nimport { TextVariant } from '../../types';\nimport { Input } from '../Input';\n\nimport { TWCLASSMAP_TEXTFIELD_SIZE } from './TextField.constants';\nimport { TextFieldSize } from './TextField.types';\nimport type { TextFieldProps } from './TextField.types';\n\nexport const TextField = forwardRef<TextInput, TextFieldProps>(\n (\n {\n style,\n size = TextFieldSize.Md,\n startAccessory,\n endAccessory,\n isError = false,\n inputElement,\n isDisabled = false,\n autoFocus = false,\n twClassName,\n onBlur,\n onFocus,\n testID,\n ...props\n },\n ref,\n ) => {\n const [isFocused, setIsFocused] = useState(autoFocus);\n const inputRef = useRef<TextInput>(null);\n const tw = useTailwind();\n\n useImperativeHandle<TextInput | null, TextInput | null>(\n ref,\n () => inputRef.current,\n [],\n );\n\n const containerStyle = useMemo(\n () =>\n tw.style(\n 'flex-row',\n 'items-center',\n 'rounded-lg',\n TWCLASSMAP_TEXTFIELD_SIZE[size],\n 'border',\n 'px-4',\n 'bg-default',\n 'border-default',\n isError && 'border-error-default',\n !isDisabled && isFocused && 'border-primary-default',\n isDisabled && 'opacity-50',\n twClassName,\n ),\n [size, isError, isFocused, isDisabled, twClassName, tw],\n );\n\n const onBlurHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onBlur']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(false);\n onBlur?.(e);\n }\n },\n [isDisabled, onBlur],\n );\n\n const onFocusHandler = useCallback(\n (e: Parameters<NonNullable<TextFieldProps['onFocus']>>[0]) => {\n if (!isDisabled) {\n setIsFocused(true);\n onFocus?.(e);\n }\n },\n [isDisabled, onFocus],\n );\n\n const onPressHandler = useCallback(() => {\n if (!isDisabled && inputRef.current) {\n inputRef.current.focus();\n }\n }, [isDisabled]);\n\n return (\n <Pressable\n testID={testID}\n style={[containerStyle, style]}\n onPress={onPressHandler}\n accessible={false}\n >\n {startAccessory && (\n <View style={tw.style('mr-2')}>{startAccessory}</View>\n )}\n <View style={tw.style('flex-1')}>\n {inputElement ?? (\n <Input\n {...props}\n ref={inputRef}\n textVariant={TextVariant.BodyMd}\n isDisabled={isDisabled}\n autoFocus={autoFocus}\n onBlur={onBlurHandler}\n onFocus={onFocusHandler}\n isStateStylesDisabled\n twClassName=\"bg-transparent border-0\"\n />\n )}\n </View>\n {endAccessory && <View style={tw.style('ml-2')}>{endAccessory}</View>}\n </Pressable>\n );\n },\n);\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextFieldSize = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* TextFieldSize enum.
|
|
6
|
+
*/
|
|
7
|
+
var TextFieldSize;
|
|
8
|
+
(function (TextFieldSize) {
|
|
9
|
+
TextFieldSize["Sm"] = "sm";
|
|
10
|
+
TextFieldSize["Md"] = "md";
|
|
11
|
+
TextFieldSize["Lg"] = "lg";
|
|
12
|
+
})(TextFieldSize || (exports.TextFieldSize = TextFieldSize = {}));
|
|
13
|
+
//# sourceMappingURL=TextField.types.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.types.cjs","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":";;;AAKA;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,0BAAS,CAAA;IACT,0BAAS,CAAA;IACT,0BAAS,CAAA;AACX,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB","sourcesContent":["import type { ReactNode } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport type { InputProps } from '../Input/Input.types';\n\n/**\n * TextFieldSize enum.\n */\nexport enum TextFieldSize {\n Sm = 'sm',\n Md = 'md',\n Lg = 'lg',\n}\n\n/**\n * TextField component props.\n */\nexport type TextFieldProps = Omit<\n InputProps,\n 'textVariant' | 'isStateStylesDisabled' | 'style'\n> & {\n /**\n * Optional prop for size of the TextField.\n *\n * @default TextFieldSize.Md\n */\n size?: TextFieldSize;\n /**\n * Optional content to display before the Input.\n */\n startAccessory?: ReactNode;\n /**\n * Optional content to display after the Input.\n */\n endAccessory?: ReactNode;\n /**\n * Optional boolean to show the error state.\n *\n * @default false\n */\n isError?: boolean;\n /**\n * Optional prop to replace the default Input with a custom element.\n */\n inputElement?: ReactNode;\n /**\n * Optional prop to add twrnc overriding classNames.\n */\n twClassName?: string;\n /**\n * Optional prop to customize the container style.\n */\n style?: StyleProp<ViewStyle>;\n};\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native/index.js";
|
|
3
|
+
import type { InputProps } from "../Input/Input.types.cjs";
|
|
4
|
+
/**
|
|
5
|
+
* TextFieldSize enum.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum TextFieldSize {
|
|
8
|
+
Sm = "sm",
|
|
9
|
+
Md = "md",
|
|
10
|
+
Lg = "lg"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* TextField component props.
|
|
14
|
+
*/
|
|
15
|
+
export type TextFieldProps = Omit<InputProps, 'textVariant' | 'isStateStylesDisabled' | 'style'> & {
|
|
16
|
+
/**
|
|
17
|
+
* Optional prop for size of the TextField.
|
|
18
|
+
*
|
|
19
|
+
* @default TextFieldSize.Md
|
|
20
|
+
*/
|
|
21
|
+
size?: TextFieldSize;
|
|
22
|
+
/**
|
|
23
|
+
* Optional content to display before the Input.
|
|
24
|
+
*/
|
|
25
|
+
startAccessory?: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Optional content to display after the Input.
|
|
28
|
+
*/
|
|
29
|
+
endAccessory?: ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Optional boolean to show the error state.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
isError?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Optional prop to replace the default Input with a custom element.
|
|
38
|
+
*/
|
|
39
|
+
inputElement?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Optional prop to add twrnc overriding classNames.
|
|
42
|
+
*/
|
|
43
|
+
twClassName?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Optional prop to customize the container style.
|
|
46
|
+
*/
|
|
47
|
+
style?: StyleProp<ViewStyle>;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=TextField.types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.types.d.cts","sourceRoot":"","sources":["../../../src/components/TextField/TextField.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,8BAAqB;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,iCAA6B;AAEvD;;GAEG;AACH,oBAAY,aAAa;IACvB,EAAE,OAAO;IACT,EAAE,OAAO;IACT,EAAE,OAAO;CACV;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,UAAU,EACV,aAAa,GAAG,uBAAuB,GAAG,OAAO,CAClD,GAAG;IACF;;;;OAIG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB;;OAEG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC"}
|