@draftbit/core 43.4.5-958f08.1 → 43.4.5-c7a710.1
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/components/Accordion/index.js.map +1 -1
- package/lib/commonjs/components/DatePicker/DatePickerComponent.js.map +1 -1
- package/lib/commonjs/components/Portal/PortalConsumer.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js +6 -8
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +11 -20
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +6 -8
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
- package/lib/commonjs/utilities.js +10 -13
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.web.js +17 -3
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +7 -9
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +12 -21
- package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +7 -9
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/mappings/BlurView.js.map +1 -1
- package/lib/module/mappings/CardContainerShortImage.js.map +1 -1
- package/lib/module/utilities.js +8 -12
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButtonRow.d.ts +1 -1
- package/lib/typescript/src/utilities.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/RadioButton/RadioButton.js +7 -10
- package/src/components/RadioButton/RadioButton.tsx +8 -12
- package/src/components/RadioButton/RadioButtonGroup.js +11 -17
- package/src/components/RadioButton/RadioButtonGroup.tsx +14 -22
- package/src/components/RadioButton/RadioButtonRow.js +7 -10
- package/src/components/RadioButton/RadioButtonRow.tsx +8 -12
- package/src/utilities.js +10 -10
- package/src/utilities.ts +8 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { default as AccordionGroup } from \"./AccordionGroup\";\nexport { default as AccordionItem } from \"./AccordionItem\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatePickerComponent.
|
|
1
|
+
{"version":3,"sources":["DatePickerComponent.tsx"],"names":["DatePickerComponent","value","onChange","mode","toggleVisibility","Platform","OS","console","log","data"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAGA,MAAMA,mBAAoC,GAAG,QAKvC;AAAA,MALwC;AAC5CC,IAAAA,KAD4C;AAE5CC,IAAAA,QAF4C;AAG5CC,IAAAA,IAH4C;AAI5CC,IAAAA;AAJ4C,GAKxC;AACJ,SAAOC,sBAASC,EAAT,KAAgB,KAAhB,IAAyBD,sBAASC,EAAT,KAAgB,SAAzC,gBACL,6BAAC,uCAAD;AACE,IAAA,IAAI,EAAEL,KADR;AAEE,IAAA,IAAI,EAAEE,IAFR;AAGE,IAAA,SAAS,EAAE,IAHb;AAIE,IAAA,OAAO,EAAEE,sBAASC,EAAT,KAAgB,KAAhB,GAAwB,SAAxB,GAAoC,SAJ/C;AAKE,IAAA,QAAQ,EAAE,MAAM;AACdC,MAAAA,OAAO,CAACC,GAAR,CAAY,6CAAZ;AACAJ,MAAAA,gBAAgB;AACjB,KARH;AASE,IAAA,SAAS,EAAGK,IAAD,IAAU;AACnBP,MAAAA,QAAQ,CAAC,IAAD,EAAOO,IAAP,CAAR;AACD;AAXH,IADK,gBAeL,6BAAC,uBAAD;AACE,IAAA,KAAK,EAAER,KADT;AAEE,IAAA,IAAI,EAAEE,IAFR;AAGE,IAAA,QAAQ,EAAED,QAHZ;AAIE,IAAA,OAAO,EAAE;AAJX,IAfF;AAsBD,CA5BD;;eA8BeF,mB","sourcesContent":["import React from \"react\";\nimport { Platform } from \"react-native\";\nimport DateTimePicker from \"@react-native-community/datetimepicker\";\nimport DateTimePickerModal from \"react-native-modal-datetime-picker\";\nimport { DatePickerComponentProps as Props } from \"./DatePickerComponentType\";\n\nconst DatePickerComponent: React.FC<Props> = ({\n value,\n onChange,\n mode,\n toggleVisibility,\n}) => {\n return Platform.OS === \"ios\" || Platform.OS === \"android\" ? (\n <DateTimePickerModal\n date={value}\n mode={mode}\n isVisible={true}\n display={Platform.OS === \"ios\" ? \"spinner\" : \"default\"}\n onCancel={() => {\n console.log(\"Picker cancelled before selecting anything.\");\n toggleVisibility();\n }}\n onConfirm={(data) => {\n onChange(null, data);\n }}\n />\n ) : (\n <DateTimePicker\n value={value}\n mode={mode}\n onChange={onChange}\n display={\"default\"}\n />\n );\n};\n\nexport default DatePickerComponent;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PortalConsumer.
|
|
1
|
+
{"version":3,"sources":["PortalConsumer.tsx"],"names":["PortalConsumer","React","Component","componentDidMount","checkManager","Promise","resolve","key","props","manager","mount","children","componentDidUpdate","update","componentWillUnmount","unmount","Error","render"],"mappings":";;;;;;;AAAA;;;;;;;;AAQe,MAAMA,cAAN,SAA6BC,KAAK,CAACC,SAAnC,CAAoD;AAAA;AAAA;;AAAA;AAAA;;AAC1C,QAAjBC,iBAAiB,GAAG;AACxB,SAAKC,YAAL,GADwB,CAGxB;;AACA,UAAMC,OAAO,CAACC,OAAR,EAAN;AAEA,SAAKC,GAAL,GAAW,KAAKC,KAAL,CAAWC,OAAX,CAAmBC,KAAnB,CAAyB,KAAKF,KAAL,CAAWG,QAApC,CAAX;AACD;;AAEDC,EAAAA,kBAAkB,GAAG;AACnB,SAAKR,YAAL;AAEA,SAAKI,KAAL,CAAWC,OAAX,CAAmBI,MAAnB,CAA0B,KAAKN,GAA/B,EAAoC,KAAKC,KAAL,CAAWG,QAA/C;AACD;;AAEDG,EAAAA,oBAAoB,GAAG;AACrB,SAAKV,YAAL;AAEA,SAAKI,KAAL,CAAWC,OAAX,CAAmBM,OAAnB,CAA2B,KAAKR,GAAhC;AACD;;AAIOH,EAAAA,YAAY,GAAG;AACrB,QAAI,CAAC,KAAKI,KAAL,CAAWC,OAAhB,EAAyB;AACvB,YAAM,IAAIO,KAAJ,CACJ,+GACE,iGADF,GAEE,qEAHE,CAAN;AAKD;AACF;;AAEDC,EAAAA,MAAM,GAAG;AACP,WAAO,IAAP;AACD;;AApCgE","sourcesContent":["import * as React from \"react\";\nimport { PortalMethods } from \"./PortalHost\";\n\ntype Props = {\n manager: PortalMethods;\n children: React.ReactNode;\n};\n\nexport default class PortalConsumer extends React.Component<Props> {\n async componentDidMount() {\n this.checkManager();\n\n // Delay updating to prevent React from going to infinite loop\n await Promise.resolve();\n\n this.key = this.props.manager.mount(this.props.children);\n }\n\n componentDidUpdate() {\n this.checkManager();\n\n this.props.manager.update(this.key, this.props.children);\n }\n\n componentWillUnmount() {\n this.checkManager();\n\n this.props.manager.unmount(this.key);\n }\n\n private key: any;\n\n private checkManager() {\n if (!this.props.manager) {\n throw new Error(\n \"Looks like you forgot to wrap your root component with `Provider` component from `react-native-paper`.\\n\\n\" +\n \"Please read our getting-started guide and make sure you've followed all the required steps.\\n\\n\" +\n \"https://callstack.github.io/react-native-paper/getting-started.html\"\n );\n }\n }\n\n render() {\n return null;\n }\n}\n"]}
|
|
@@ -28,7 +28,7 @@ const RadioButton = _ref => {
|
|
|
28
28
|
Icon,
|
|
29
29
|
disabled = false,
|
|
30
30
|
color,
|
|
31
|
-
value,
|
|
31
|
+
value = "",
|
|
32
32
|
selected,
|
|
33
33
|
unselectedColor,
|
|
34
34
|
onPress,
|
|
@@ -42,15 +42,13 @@ const RadioButton = _ref => {
|
|
|
42
42
|
value: contextValue,
|
|
43
43
|
onValueChange
|
|
44
44
|
} = (0, _context.useRadioButtonGroupContext)();
|
|
45
|
-
const realValue = (0, _utilities.
|
|
46
|
-
const realContextValue = (0, _utilities.
|
|
47
|
-
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue
|
|
45
|
+
const realValue = (0, _utilities.getValueForRadioButton)(value);
|
|
46
|
+
const realContextValue = (0, _utilities.getValueForRadioButton)(contextValue);
|
|
47
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
48
48
|
|
|
49
49
|
const handlePress = () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
53
|
-
}
|
|
50
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
51
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
return /*#__PURE__*/React.createElement(_IconButton.default, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButton.tsx"],"names":["RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","Config","radioButtonSize","selectedIcon","unselectedIcon","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress"],"mappings":";;;;;;;AAAA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAiBA,MAAMA,WAAuC,GAAG,QAa1C;AAAA,MAb2C;AAC/CC,IAAAA,IAD+C;AAE/CC,IAAAA,QAAQ,GAAG,KAFoC;AAG/CC,IAAAA,KAH+C;AAI/CC,IAAAA,
|
|
1
|
+
{"version":3,"sources":["RadioButton.tsx"],"names":["RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","Config","radioButtonSize","selectedIcon","unselectedIcon","style","rest","context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,IANR;AAOE,IAAA,KAAK,EAAEK;AAPT,KAQMC,IARN,EADF;AAYD,CArCD;;eAuCed,W","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\nimport Config from \"../Config\";\nimport IconButton from \"../IconButton\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { useRadioButtonGroupContext } from \"./context\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nexport type RadioButtonProps = {\n selected?: boolean;\n disabled?: boolean;\n color?: string;\n value: string | number;\n unselectedColor?: string;\n onPress?: (value: string) => void;\n style?: StyleProp<ViewStyle>;\n size?: number;\n selectedIcon?: string;\n unselectedIcon?: string;\n} & IconSlot;\n\nconst RadioButton: React.FC<RadioButtonProps> = ({\n Icon,\n disabled = false,\n color,\n value = \"\",\n selected,\n unselectedColor,\n onPress,\n size = Config.radioButtonSize,\n selectedIcon = \"MaterialIcons/radio-button-checked\",\n unselectedIcon = \"MaterialIcons/radio-button-unchecked\",\n style,\n ...rest\n}) => {\n const { value: contextValue, onValueChange } = useRadioButtonGroupContext();\n\n const realValue = getValueForRadioButton(value);\n const realContextValue = getValueForRadioButton(contextValue);\n const isSelected = selected ?? realContextValue === realValue;\n\n const handlePress = () => {\n onPress?.(realValue);\n onValueChange?.(realValue);\n };\n\n return (\n <IconButton\n Icon={Icon}\n icon={isSelected ? selectedIcon : unselectedIcon}\n color={isSelected ? color : unselectedColor}\n disabled={disabled}\n onPress={handlePress}\n size={size}\n style={style}\n {...rest}\n />\n );\n};\n\nexport default RadioButton;\n"]}
|
|
@@ -26,36 +26,27 @@ const {
|
|
|
26
26
|
const RadioButtonGroup = _ref => {
|
|
27
27
|
let {
|
|
28
28
|
direction = _context.Direction.Vertical,
|
|
29
|
-
value,
|
|
29
|
+
value = "",
|
|
30
30
|
onValueChange,
|
|
31
|
-
defaultValue,
|
|
31
|
+
defaultValue = "",
|
|
32
32
|
style,
|
|
33
33
|
children,
|
|
34
34
|
...rest
|
|
35
35
|
} = _ref;
|
|
36
|
-
const [internalValue, setInternalValue] = React.useState();
|
|
36
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
37
37
|
React.useEffect(() => {
|
|
38
|
-
const realValue = (0, _utilities.
|
|
39
|
-
|
|
40
|
-
if (realValue) {
|
|
41
|
-
setInternalValue(realValue);
|
|
42
|
-
}
|
|
38
|
+
const realValue = (0, _utilities.getValueForRadioButton)(value);
|
|
39
|
+
setInternalValue(realValue);
|
|
43
40
|
}, [value]);
|
|
44
41
|
React.useEffect(() => {
|
|
45
|
-
const realDefaultValue = (0, _utilities.
|
|
46
|
-
|
|
47
|
-
if (realDefaultValue) {
|
|
48
|
-
setInternalValue(realDefaultValue);
|
|
49
|
-
}
|
|
42
|
+
const realDefaultValue = (0, _utilities.getValueForRadioButton)(defaultValue);
|
|
43
|
+
setInternalValue(realDefaultValue);
|
|
50
44
|
}, [defaultValue]);
|
|
51
45
|
|
|
52
46
|
const handleValueChange = newValue => {
|
|
53
|
-
const realNewValue = (0, _utilities.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
setInternalValue(newValue);
|
|
57
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
58
|
-
}
|
|
47
|
+
const realNewValue = (0, _utilities.getValueForRadioButton)(newValue);
|
|
48
|
+
setInternalValue(realNewValue);
|
|
49
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
|
|
59
50
|
};
|
|
60
51
|
|
|
61
52
|
const _containerStyle = [{
|
|
@@ -74,7 +65,7 @@ const RadioButtonGroup = _ref => {
|
|
|
74
65
|
}, style]
|
|
75
66
|
}, rest), /*#__PURE__*/React.createElement(Provider, {
|
|
76
67
|
value: {
|
|
77
|
-
value: internalValue
|
|
68
|
+
value: internalValue !== null && internalValue !== void 0 ? internalValue : "",
|
|
78
69
|
onValueChange: handleValueChange,
|
|
79
70
|
direction
|
|
80
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["Provider","radioButtonGroupContext","RadioButtonGroup","direction","Direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","React","useState","useEffect","realValue","realDefaultValue","handleValueChange","newValue","realNewValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAeC,gCAArB;;AAEA,MAAMC,gBAAiD,GAAG,QAQpD;AAAA,MARqD;AACzDC,IAAAA,SAAS,GAAGC,mBAAUC,QADmC;AAEzDC,IAAAA,
|
|
1
|
+
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["Provider","radioButtonGroupContext","RadioButtonGroup","direction","Direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","React","useState","useEffect","realValue","realDefaultValue","handleValueChange","newValue","realNewValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;;;AAWA,MAAM;AAAEA,EAAAA;AAAF,IAAeC,gCAArB;;AAEA,MAAMC,gBAAiD,GAAG,QAQpD;AAAA,MARqD;AACzDC,IAAAA,SAAS,GAAGC,mBAAUC,QADmC;AAEzDC,IAAAA,KAAK,GAAG,EAFiD;AAGzDC,IAAAA,aAHyD;AAIzDC,IAAAA,YAAY,GAAG,EAJ0C;AAKzDC,IAAAA,KALyD;AAMzDC,IAAAA,QANyD;AAOzD,OAAGC;AAPsD,GAQrD;AACJ,QAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoCC,KAAK,CAACC,QAAN,CAAuB,EAAvB,CAA1C;AAEAD,EAAAA,KAAK,CAACE,SAAN,CAAgB,MAAM;AACpB,UAAMC,SAAS,GAAG,uCAAuBX,KAAvB,CAAlB;AAEAO,IAAAA,gBAAgB,CAACI,SAAD,CAAhB;AACD,GAJD,EAIG,CAACX,KAAD,CAJH;AAMAQ,EAAAA,KAAK,CAACE,SAAN,CAAgB,MAAM;AACpB,UAAME,gBAAgB,GAAG,uCAAuBV,YAAvB,CAAzB;AAEAK,IAAAA,gBAAgB,CAACK,gBAAD,CAAhB;AACD,GAJD,EAIG,CAACV,YAAD,CAJH;;AAMA,QAAMW,iBAAiB,GAAIC,QAAD,IAA+B;AACvD,UAAMC,YAAY,GAAG,uCAAuBD,QAAvB,CAArB;AAEAP,IAAAA,gBAAgB,CAACQ,YAAD,CAAhB;AACAd,IAAAA,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGc,YAAH,CAAb;AACD,GALD;;AAOA,QAAMC,eAAqC,GAAG,CAC5C;AACEC,IAAAA,aAAa,EAAEpB,SAAS,KAAKC,mBAAUoB,UAAxB,GAAqC,KAArC,GAA6C;AAD9D,GAD4C,CAA9C;;AAMA,MAAIrB,SAAS,KAAKC,mBAAUC,QAA5B,EAAsC;AACpCiB,IAAAA,eAAe,CAACG,IAAhB,CAAqB;AACnBC,MAAAA,UAAU,EAAE;AADO,KAArB;AAGD;;AAED,sBACE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAE,CAAC;AAAEC,MAAAA,SAAS,EAAE;AAAb,KAAD,EAAoBlB,KAApB;AAAb,KAA6CE,IAA7C,gBACE,oBAAC,QAAD;AACE,IAAA,KAAK,EAAE;AACLL,MAAAA,KAAK,EAAEM,aAAF,aAAEA,aAAF,cAAEA,aAAF,GAAmB,EADnB;AAELL,MAAAA,aAAa,EAAEY,iBAFV;AAGLhB,MAAAA;AAHK;AADT,kBAOE,oBAAC,iBAAD;AAAM,IAAA,KAAK,EAAEmB;AAAb,KAA+BZ,QAA/B,CAPF,CADF,CADF;AAaD,CAvDD;;eAyDeR,gB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport type { Theme } from \"../../styles/DefaultTheme\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { radioButtonGroupContext, Direction } from \"./context\";\nexport interface RadioButtonGroupProps {\n direction?: Direction;\n style?: StyleProp<ViewStyle>;\n value: string;\n onValueChange?: (value: string) => void;\n defaultValue?: string | number;\n theme: Theme;\n children: React.ReactNode;\n}\n\nconst { Provider } = radioButtonGroupContext;\n\nconst RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({\n direction = Direction.Vertical,\n value = \"\",\n onValueChange,\n defaultValue = \"\",\n style,\n children,\n ...rest\n}) => {\n const [internalValue, setInternalValue] = React.useState<string>(\"\");\n\n React.useEffect(() => {\n const realValue = getValueForRadioButton(value);\n\n setInternalValue(realValue);\n }, [value]);\n\n React.useEffect(() => {\n const realDefaultValue = getValueForRadioButton(defaultValue);\n\n setInternalValue(realDefaultValue);\n }, [defaultValue]);\n\n const handleValueChange = (newValue: string | number) => {\n const realNewValue = getValueForRadioButton(newValue);\n\n setInternalValue(realNewValue);\n onValueChange?.(realNewValue);\n };\n\n const _containerStyle: StyleProp<ViewStyle> = [\n {\n flexDirection: direction === Direction.Horizontal ? \"row\" : \"column\",\n },\n ];\n\n if (direction !== Direction.Vertical) {\n _containerStyle.push({\n alignItems: \"center\",\n });\n }\n\n return (\n <View style={[{ minHeight: 40 }, style]} {...rest}>\n <Provider\n value={{\n value: internalValue ?? \"\",\n onValueChange: handleValueChange,\n direction,\n }}\n >\n <View style={_containerStyle}>{children}</View>\n </Provider>\n </View>\n );\n};\n\nexport default RadioButtonGroup;\n"]}
|
|
@@ -59,7 +59,7 @@ const RadioButtonRow = _ref => {
|
|
|
59
59
|
let {
|
|
60
60
|
Icon,
|
|
61
61
|
label,
|
|
62
|
-
value,
|
|
62
|
+
value = "",
|
|
63
63
|
color,
|
|
64
64
|
unselectedColor,
|
|
65
65
|
onPress,
|
|
@@ -77,15 +77,13 @@ const RadioButtonRow = _ref => {
|
|
|
77
77
|
onValueChange,
|
|
78
78
|
direction: parentDirection
|
|
79
79
|
} = (0, _context.useRadioButtonGroupContext)();
|
|
80
|
-
const realValue = (0, _utilities.
|
|
81
|
-
const realContextValue = (0, _utilities.
|
|
82
|
-
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue
|
|
80
|
+
const realValue = (0, _utilities.getValueForRadioButton)(value);
|
|
81
|
+
const realContextValue = (0, _utilities.getValueForRadioButton)(contextValue);
|
|
82
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
83
83
|
|
|
84
84
|
const handlePress = () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
88
|
-
}
|
|
85
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
86
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
89
87
|
};
|
|
90
88
|
|
|
91
89
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["Direction","getRadioButtonAlignment","parentDirection","direction","GroupDirection","Horizontal","Row","RowReverse","renderLabel","label","labelStyle","textStyle","RadioButtonRow","Icon","value","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAiBZ,MAAMC,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIH,SAAS,KAAKH,SAAS,CAACO,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADkB,EAElBC,UAFkB,EAGlBC,SAHkB,KAIf;AACH,MAAI,OAAOF,KAAP,KAAiB,QAArB,EAA+B;AAC7B,wBAAO,oBAAC,aAAD;AAAM,MAAA,KAAK,EAAE,CAACC,UAAD,EAAaC,SAAb;AAAb,OAAuCF,KAAvC,CAAP;AACD,GAFD,MAEO;AACL,wBAAO,0CAAGA,KAAH,CAAP;AACD;AACF,CAVD;;AAYA,MAAMG,cAAwD,GAAG,QAe3D;AAAA,MAf4D;AAChEC,IAAAA,IADgE;AAEhEJ,IAAAA,KAFgE;AAGhEK,IAAAA,
|
|
1
|
+
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["Direction","getRadioButtonAlignment","parentDirection","direction","GroupDirection","Horizontal","Row","RowReverse","renderLabel","label","labelStyle","textStyle","RadioButtonRow","Icon","value","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","StyleSheet","create","justifyContent","paddingStart","minHeight","paddingEnd","Platform","select","web","cursor","userSelect"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AACA;;AAGA;;AACA;;;;;;;;;;IAEYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;AAiBZ,MAAMC,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKE,mBAAeC,UAAvC,EAAmD;AACjD,WAAOF,SAAS,KAAKH,SAAS,CAACM,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIH,SAAS,KAAKH,SAAS,CAACO,UAA5B,EAAw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;AAMVN,IAAAA,IAAI,EAAE,CANI;AAOV,OAAGO,sBAASC,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,UAAU,EAAE;AAFT;AADY,KAAhB;AAPO,GADmB;AAe/BtC,EAAAA,KAAK,EAAE;AACL2B,IAAAA,IAAI,EAAE;AADD;AAfwB,CAAlB,CAAf;;eAoBexB,c","sourcesContent":["import * as React from \"react\";\nimport {\n StyleProp,\n ViewStyle,\n StyleSheet,\n TextStyle,\n View,\n Platform,\n} from \"react-native\";\nimport RadioButton, { RadioButtonProps } from \"./RadioButton\";\nimport Text from \"../Text\";\nimport { useRadioButtonGroupContext } from \"./context\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport { Direction as GroupDirection } from \"./context\";\nimport Touchable from \"../Touchable\";\nimport { extractStyles, getValueForRadioButton } from \"../../utilities\";\n\nexport enum Direction {\n Row = \"row\",\n RowReverse = \"row-reverse\",\n}\n\nexport interface RadioButtonRowProps extends Omit<RadioButtonProps, \"onPress\"> {\n label: string | React.ReactNode;\n value: string | number; // A string (or number that will be parsed String(number)) that this radio button row represents when selected\n color?: string;\n unselectedColor?: string;\n labelContainerStyle: StyleProp<ViewStyle>;\n radioButtonStyle?: StyleProp<ViewStyle>;\n labelStyle?: StyleProp<TextStyle>;\n onPress?: (value: string) => void;\n direction?: Direction;\n}\n\nconst getRadioButtonAlignment = (\n parentDirection: GroupDirection | undefined,\n direction: Direction\n) => {\n if (parentDirection === GroupDirection.Horizontal) {\n return direction === Direction.Row ? \"flex-start\" : \"flex-end\";\n } else if (direction === Direction.RowReverse) {\n return \"flex-start\";\n } else {\n return \"flex-end\";\n }\n};\n\nconst renderLabel = (\n label: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof label === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{label}</Text>;\n } else {\n return <>{label}</>;\n }\n};\n\nconst RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({\n Icon,\n label,\n value = \"\",\n color,\n unselectedColor,\n onPress,\n labelContainerStyle,\n labelStyle,\n radioButtonStyle,\n direction = Direction.Row,\n selected,\n disabled,\n style,\n ...rest\n}) => {\n const {\n value: contextValue,\n onValueChange,\n direction: parentDirection,\n } = useRadioButtonGroupContext();\n\n const realValue = getValueForRadioButton(value);\n const realContextValue = getValueForRadioButton(contextValue);\n const isSelected = selected ?? realContextValue === realValue;\n\n const handlePress = () => {\n onPress?.(realValue);\n onValueChange?.(realValue);\n };\n\n const { textStyles, viewStyles } = extractStyles(style);\n\n return (\n <Touchable\n onPress={handlePress}\n style={[styles.mainParent, { flexDirection: direction }, viewStyles]}\n disabled={disabled}\n {...rest}\n >\n <View\n style={[\n styles.label,\n {\n alignItems: direction === Direction.Row ? \"flex-start\" : \"flex-end\",\n },\n labelContainerStyle,\n ]}\n >\n {renderLabel(label, labelStyle, textStyles)}\n </View>\n <View\n style={{\n flex: 1,\n alignItems: getRadioButtonAlignment(parentDirection, direction),\n }}\n >\n <RadioButton\n Icon={Icon}\n selected={isSelected ? true : false}\n value={realValue}\n color={color}\n unselectedColor={unselectedColor}\n style={radioButtonStyle}\n />\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n mainParent: {\n alignItems: \"center\",\n justifyContent: \"space-around\",\n paddingStart: 20,\n minHeight: 50,\n paddingEnd: 20,\n flex: 1,\n ...Platform.select({\n web: {\n cursor: \"pointer\",\n userSelect: \"none\",\n },\n }),\n },\n label: {\n flex: 3,\n },\n});\n\nexport default RadioButtonRow;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RowHeadlineImageIcon.
|
|
1
|
+
{"version":3,"sources":["RowHeadlineImageIcon.js"],"names":["SEED_DATA_PROPS","title","label","description","icon","defaultValue","IMAGE_PROP","MULTILINE_PROP","editable","SUBTITLE_PROP","SEED_DATA","name","tag","category","COMPONEN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IAAAA,QAAQ,EAAE,2BAAe;AACrBjB,MAAAA,KAAK,EAAE,UADc;AAErBC,MAAAA,WAAW,EAAE,0BAFQ;AAGrBE,MAAAA,YAAY,EAAE;AAHO,KAAf;AAJP;AANX,CA7DqB,CAAlB","sourcesContent":["import { COMPONENT_TYPES, createIconProp, createTextProp, createImageProp, createStaticBoolProp, } from \"@draftbit/types\";\nconst SEED_DATA_PROPS = {\n title: createTextProp({\n label: \"Title\",\n description: \"Headline text to display\",\n }),\n icon: createIconProp({\n defaultValue: null,\n }),\n};\nconst IMAGE_PROP = createImageProp();\nconst MULTILINE_PROP = createStaticBoolProp({\n defaultValue: true,\n editable: false,\n});\nconst SUBTITLE_PROP = createTextProp({\n label: \"Subtitle\",\n description: \"Subtitle text to display\",\n defaultValue: \"San Diego\",\n});\nexport const SEED_DATA = [\n {\n name: \"Row Single Line Headline Icon\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned headline text and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n },\n },\n {\n name: \"Row Single Line Headline Icon Image\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned image and headline text and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n image: IMAGE_PROP,\n },\n },\n {\n name: \"Row Double Line Headline Icon\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned headline text and subtitle text and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n subtitle: SUBTITLE_PROP,\n },\n },\n {\n name: \"Row Double Line Headline Image Icon\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned headline text and subtitle text and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n image: IMAGE_PROP,\n subtitle: SUBTITLE_PROP,\n },\n },\n {\n name: \"Row Multiline Headline Icon\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned headline text and multiline subtitle text and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n multilineSubtitle: MULTILINE_PROP,\n subtitle: createTextProp({\n label: \"Subtitle\",\n description: \"Subtitle text to display\",\n defaultValue: \"San Diego is a city on the Pacific coast of California known for its beaches, parks and warm climate\",\n }),\n },\n },\n {\n name: \"Row Multiline Headline Image Icon\",\n tag: \"RowHeadlineImageIcon\",\n description: \"A row with left aligned image, headline text, and multiline subtitle text, and a right aligned icon\",\n category: COMPONENT_TYPES.row,\n layout: {},\n props: {\n ...SEED_DATA_PROPS,\n image: IMAGE_PROP,\n multilineSubtitle: MULTILINE_PROP,\n subtitle: createTextProp({\n label: \"Subtitle\",\n description: \"Subtitle text to display\",\n defaultValue: \"San Diego is a city on the Pacific coast of California known for its beaches, parks and warm climate\",\n }),\n },\n },\n];\n"]}
|
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.applyStyles = applyStyles;
|
|
7
7
|
exports.extractStyles = extractStyles;
|
|
8
|
-
exports.
|
|
8
|
+
exports.getValueForRadioButton = getValueForRadioButton;
|
|
9
9
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
|
|
12
|
+
var _lodash = require("lodash");
|
|
13
|
+
|
|
12
14
|
function extractStyles(style) {
|
|
13
15
|
const {
|
|
14
16
|
color,
|
|
@@ -73,18 +75,13 @@ function applyStyles(baseStyles, stylesToApply) {
|
|
|
73
75
|
return flattenedStyles;
|
|
74
76
|
}
|
|
75
77
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
case "number":
|
|
84
|
-
return String(value);
|
|
85
|
-
|
|
86
|
-
default:
|
|
87
|
-
return undefined;
|
|
78
|
+
function getValueForRadioButton(value) {
|
|
79
|
+
if ((0, _lodash.isString)(value)) {
|
|
80
|
+
return value;
|
|
81
|
+
} else if ((0, _lodash.isNumber)(value)) {
|
|
82
|
+
return String(value);
|
|
83
|
+
} else {
|
|
84
|
+
throw new Error(`Invalid value: ${value}`);
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utilities.ts"],"names":["extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","StyleSheet","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","
|
|
1
|
+
{"version":3,"sources":["utilities.ts"],"names":["extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","StyleSheet","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":";;;;;;;;;AAAA;;AACA;;AAEO,SAASA,aAAT,CAAuBC,KAAvB,EAA8C;AACnD,QAAM;AACJC,IAAAA,KADI;AAEJC,IAAAA,UAFI;AAGJC,IAAAA,UAHI;AAIJC,IAAAA,QAJI;AAKJC,IAAAA,UALI;AAMJC,IAAAA,aANI;AAOJC,IAAAA,aAPI;AAQJC,IAAAA,SARI;AASJC,IAAAA,kBATI;AAUJC,IAAAA,mBAVI;AAWJC,IAAAA,mBAXI;AAYJ,OAAGC;AAZC,MAaFC,wBAAWC,OAAX,CAAmBd,KAAK,IAAI,EAA5B,CAbJ;;AAeA,QAAMe,UAAqB,GAAG;AAC5Bd,IAAAA,KAD4B;AAE5BC,IAAAA,UAF4B;AAG5BC,IAAAA,UAH4B;AAI5BC,IAAAA,QAJ4B;AAK5BC,IAAAA,UAL4B;AAM5BC,IAAAA,aAN4B;AAO5BC,IAAAA,aAP4B;AAQ5BC,IAAAA,SAR4B;AAS5BC,IAAAA,kBAT4B;AAU5BC,IAAAA,mBAV4B;AAW5BC,IAAAA;AAX4B,GAA9B;AAcA,SAAO;AAAEC,IAAAA,UAAF;AAAcG,IAAAA;AAAd,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,WAAT,CACLC,UADK,EAELC,aAFK,EAGL;AACA,MAAI,CAACA,aAAL,EAAoB;AAClB;AACD;;AAED,QAAMC,eAAe,GAAGN,wBAAWC,OAAX,CAAmBG,UAAnB,CAAxB;;AAEA,OAAK,MAAM,CAACG,GAAD,EAAMC,KAAN,CAAX,IAA2BC,MAAM,CAACC,OAAP,CAAeL,aAAf,CAA3B,EAA0D;AACxD,QAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBF,MAAAA,eAAe,CAACC,GAAD,CAAf,GAAuBC,KAAvB;AACD;AACF;;AAED,SAAOF,eAAP;AACD;;AAEM,SAASK,sBAAT,CAAgCH,KAAhC,EAAwD;AAC7D,MAAI,sBAASA,KAAT,CAAJ,EAAqB;AACnB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAI,sBAASA,KAAT,CAAJ,EAAqB;AAC1B,WAAOI,MAAM,CAACJ,KAAD,CAAb;AACD,GAFM,MAEA;AACL,UAAM,IAAIK,KAAJ,CAAW,kBAAiBL,KAAM,EAAlC,CAAN;AACD;AACF","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\nimport { isString, isNumber } from \"lodash\";\n\nexport function extractStyles(style: StyleProp<any>) {\n const {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n ...viewStyles\n } = StyleSheet.flatten(style || {});\n\n const textStyles: TextStyle = {\n color,\n fontFamily,\n fontWeight,\n fontSize,\n lineHeight,\n letterSpacing,\n textTransform,\n textAlign,\n textDecorationLine,\n textDecorationColor,\n textDecorationStyle,\n };\n\n return { viewStyles, textStyles };\n}\n\n/**\n * Merges a style object on top of another style object. In React Native,\n * keys with undefined values in a style object will still override styles\n * that appear earlier in a sequence. This avoids that problem.\n *\n * This lets us avoid the `...(something ? { something } : {})` pattern.\n * There doesn't seem to be a better way to do this. These all seem to not\n * work (i.e. they all result in `{ color: undefined }`:\n * `const mergedStyles = [{ color: \"red\" }, { color: undefined }]`\n * `const mergedStyles = StyleSheet.compose({ color: \"red\" }, { color: undefined })`\n * `const mergedStyles = StyleSheet.flatten([{ color: \"red\" }, { color: undefined }])`\n */\nexport function applyStyles(\n baseStyles: Array<StyleProp<any>>,\n stylesToApply: StyleProp<any> | undefined\n) {\n if (!stylesToApply) {\n return;\n }\n\n const flattenedStyles = StyleSheet.flatten(baseStyles);\n\n for (const [key, value] of Object.entries(stylesToApply)) {\n if (value != null) {\n flattenedStyles[key] = value;\n }\n }\n\n return flattenedStyles;\n}\n\nexport function getValueForRadioButton(value: string | number) {\n if (isString(value)) {\n return value;\n } else if (isNumber(value)) {\n return String(value);\n } else {\n throw new Error(`Invalid value: ${value}`);\n }\n}\n"]}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import * as React from "react";
|
|
4
2
|
import { View, StyleSheet } from "react-native";
|
|
5
3
|
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
@@ -92,8 +90,24 @@ const Picker = _ref => {
|
|
|
92
90
|
key: o.value
|
|
93
91
|
}))), /*#__PURE__*/React.createElement(View, {
|
|
94
92
|
pointerEvents: "none"
|
|
95
|
-
}, /*#__PURE__*/React.createElement(TextField,
|
|
93
|
+
}, /*#__PURE__*/React.createElement(TextField, { ...props,
|
|
96
94
|
value: selectedLabel,
|
|
95
|
+
placeholder: placeholder,
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
ref: textField,
|
|
98
|
+
disabled: disabled,
|
|
99
|
+
// @ts-expect-error
|
|
100
|
+
style: stylesWithoutMargin
|
|
101
|
+
}))));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const styles = StyleSheet.create({
|
|
105
|
+
container: {
|
|
106
|
+
alignSelf: "stretch"
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
export default withTheme(Picker);
|
|
110
|
+
//# sourceMappingURL=PickerComponent.web.js.mapbel,
|
|
97
111
|
placeholder: placeholder // @ts-ignore
|
|
98
112
|
,
|
|
99
113
|
ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PickerComponent.web.
|
|
1
|
+
{"version":3,"sources":["PickerComponent.web.js"],"names":["React","View","StyleSheet","Picker","NativePicker","omit","withTheme","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","selectedLabel","find","o","value","label","createElement","onPress","styles","container","enabled","flex","opacity","position","top","left","right","bottom","width","map","Item","key","pointerEvents","ref","create","alignSelf"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,SAASC,MAAM,IAAIC,YAAnB,QAAuC,6BAAvC;AACA,OAAOC,IAAP,MAAiB,aAAjB;AACA,SAASC,SAAT,QAA0B,eAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,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AzC,GAAvC,CAApB,CATT,CADJ,eAWI5C,KAAK,CAAC8C,aAAN,CAAoB7C,IAApB,EAA0B;AAAE6D,IAAAA,aAAa,EAAE;AAAjB,GAA1B,eACI9D,KAAK,CAAC8C,aAAN,CAAoBtC,SAApB,EAA+B,EAAE,GAAGS,KAAL;AAAY2B,IAAAA,KAAK,EAAEH,aAAnB;AAAkC7B,IAAAA,WAAW,EAAEA,WAA/C;AAC3B;AACAmD,IAAAA,GAAG,EAAE/B,SAFsB;AAEXlB,IAAAA,QAAQ,EAAEA,QAFC;AAG3B;AACAJ,IAAAA,KAAK,EAAE6B;AAJoB,GAA/B,CADJ,CAXJ,CADI,CAAR;AAkBH,CAtDD;;AAuDA,MAAMS,MAAM,GAAG9C,UAAU,CAAC8D,MAAX,CAAkB;AAC7Bf,EAAAA,SAAS,EAAE;AACPgB,IAAAA,SAAS,EAAE;AADJ;AADkB,CAAlB,CAAf;AAKA,eAAe3D,SAAS,CAACH,MAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { extractStyles } from \"../../utilities\";\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nconst Picker = ({ style, options, placeholder, selectedValue, disabled = false, onValueChange: onValueChangeOverride = () => { }, ...props }) => {\n const { viewStyles: { borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles }, } = extractStyles(style);\n const textField = React.useRef(undefined);\n const onValueChange = (itemValue, itemIndex) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n const stylesWithoutMargin = style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n const selectedLabel = selectedValue &&\n (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);\n return (React.createElement(Touchable, { disabled: disabled, onPress: toggleFocus, style: [styles.container, viewStyles] },\n React.createElement(View, null,\n React.createElement(NativePicker, { enabled: !disabled, selectedValue: selectedValue, onValueChange: onValueChange, style: {\n flex: 1,\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: \"100%\",\n } }, options.map((o) => (React.createElement(NativePicker.Item, { label: o.label, value: o.value, key: o.value })))),\n React.createElement(View, { pointerEvents: \"none\" },\n React.createElement(TextField, { ...props, value: selectedLabel, placeholder: placeholder, \n // @ts-ignore\n ref: textField, disabled: disabled, \n // @ts-expect-error\n style: stylesWithoutMargin })))));\n};\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\nexport default withTheme(Picker);\n"]}
|
|
@@ -3,7 +3,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import Config from "../Config";
|
|
5
5
|
import IconButton from "../IconButton";
|
|
6
|
-
import {
|
|
6
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
7
7
|
import { useRadioButtonGroupContext } from "./context";
|
|
8
8
|
|
|
9
9
|
const RadioButton = _ref => {
|
|
@@ -11,7 +11,7 @@ const RadioButton = _ref => {
|
|
|
11
11
|
Icon,
|
|
12
12
|
disabled = false,
|
|
13
13
|
color,
|
|
14
|
-
value,
|
|
14
|
+
value = "",
|
|
15
15
|
selected,
|
|
16
16
|
unselectedColor,
|
|
17
17
|
onPress,
|
|
@@ -25,15 +25,13 @@ const RadioButton = _ref => {
|
|
|
25
25
|
value: contextValue,
|
|
26
26
|
onValueChange
|
|
27
27
|
} = useRadioButtonGroupContext();
|
|
28
|
-
const realValue =
|
|
29
|
-
const realContextValue =
|
|
30
|
-
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue
|
|
28
|
+
const realValue = getValueForRadioButton(value);
|
|
29
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
30
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
31
31
|
|
|
32
32
|
const handlePress = () => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
36
|
-
}
|
|
33
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
34
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
return /*#__PURE__*/React.createElement(IconButton, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","
|
|
1
|
+
{"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","getValueForRadioButton","useRadioButtonGroupContext","RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","radioButtonSize","selectedIcon","unselectedIcon","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB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EJ,QAJZ;AAKE,IAAA,OAAO,EAAEiB,WALX;AAME,IAAA,IAAI,EAAEX,IANR;AAOE,IAAA,KAAK,EAAEI;AAPT,KAQMC,IARN,EADF;AAYD,CArCD;;AAuCA,eAAeb,WAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\nimport Config from \"../Config\";\nimport IconButton from \"../IconButton\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { useRadioButtonGroupContext } from \"./context\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nexport type RadioButtonProps = {\n selected?: boolean;\n disabled?: boolean;\n color?: string;\n value: string | number;\n unselectedColor?: string;\n onPress?: (value: string) => void;\n style?: StyleProp<ViewStyle>;\n size?: number;\n selectedIcon?: string;\n unselectedIcon?: string;\n} & IconSlot;\n\nconst RadioButton: React.FC<RadioButtonProps> = ({\n Icon,\n disabled = false,\n color,\n value = \"\",\n selected,\n unselectedColor,\n onPress,\n size = Config.radioButtonSize,\n selectedIcon = \"MaterialIcons/radio-button-checked\",\n unselectedIcon = \"MaterialIcons/radio-button-unchecked\",\n style,\n ...rest\n}) => {\n const { value: contextValue, onValueChange } = useRadioButtonGroupContext();\n\n const realValue = getValueForRadioButton(value);\n const realContextValue = getValueForRadioButton(contextValue);\n const isSelected = selected ?? realContextValue === realValue;\n\n const handlePress = () => {\n onPress?.(realValue);\n onValueChange?.(realValue);\n };\n\n return (\n <IconButton\n Icon={Icon}\n icon={isSelected ? selectedIcon : unselectedIcon}\n color={isSelected ? color : unselectedColor}\n disabled={disabled}\n onPress={handlePress}\n size={size}\n style={style}\n {...rest}\n />\n );\n};\n\nexport default RadioButton;\n"]}
|
|
@@ -2,7 +2,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { View } from "react-native";
|
|
5
|
-
import {
|
|
5
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
6
6
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
7
7
|
const {
|
|
8
8
|
Provider
|
|
@@ -11,36 +11,27 @@ const {
|
|
|
11
11
|
const RadioButtonGroup = _ref => {
|
|
12
12
|
let {
|
|
13
13
|
direction = Direction.Vertical,
|
|
14
|
-
value,
|
|
14
|
+
value = "",
|
|
15
15
|
onValueChange,
|
|
16
|
-
defaultValue,
|
|
16
|
+
defaultValue = "",
|
|
17
17
|
style,
|
|
18
18
|
children,
|
|
19
19
|
...rest
|
|
20
20
|
} = _ref;
|
|
21
|
-
const [internalValue, setInternalValue] = React.useState();
|
|
21
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
22
22
|
React.useEffect(() => {
|
|
23
|
-
const realValue =
|
|
24
|
-
|
|
25
|
-
if (realValue) {
|
|
26
|
-
setInternalValue(realValue);
|
|
27
|
-
}
|
|
23
|
+
const realValue = getValueForRadioButton(value);
|
|
24
|
+
setInternalValue(realValue);
|
|
28
25
|
}, [value]);
|
|
29
26
|
React.useEffect(() => {
|
|
30
|
-
const realDefaultValue =
|
|
31
|
-
|
|
32
|
-
if (realDefaultValue) {
|
|
33
|
-
setInternalValue(realDefaultValue);
|
|
34
|
-
}
|
|
27
|
+
const realDefaultValue = getValueForRadioButton(defaultValue);
|
|
28
|
+
setInternalValue(realDefaultValue);
|
|
35
29
|
}, [defaultValue]);
|
|
36
30
|
|
|
37
31
|
const handleValueChange = newValue => {
|
|
38
|
-
const realNewValue =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
setInternalValue(newValue);
|
|
42
|
-
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
43
|
-
}
|
|
32
|
+
const realNewValue = getValueForRadioButton(newValue);
|
|
33
|
+
setInternalValue(realNewValue);
|
|
34
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
|
|
44
35
|
};
|
|
45
36
|
|
|
46
37
|
const _containerStyle = [{
|
|
@@ -59,7 +50,7 @@ const RadioButtonGroup = _ref => {
|
|
|
59
50
|
}, style]
|
|
60
51
|
}, rest), /*#__PURE__*/React.createElement(Provider, {
|
|
61
52
|
value: {
|
|
62
|
-
value: internalValue
|
|
53
|
+
value: internalValue !== null && internalValue !== void 0 ? internalValue : "",
|
|
63
54
|
onValueChange: handleValueChange,
|
|
64
55
|
direction
|
|
65
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","
|
|
1
|
+
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","getValueForRadioButton","radioButtonGroupContext","Direction","Provider","RadioButtonGroup","direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","useState","useEffect","realValue","realDefaultValue","handleValueChange","newValue","realNewValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAA2C,cAA3C;AAEA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,uBAAT,EAAkCC,SAAlC,QAAmD,WAAnD;AAWA,MAAM;AAAEC,EAAAA;AAAF,IAAeF,uBAArB;;AAEA,MAAMG,gBAAiD,GAAG,QAQpD;AAAA,MARqD;AACzDC,IAAAA,SAAS,GAAGH,SAAS,CAACI,QADmC;AAEzDC,IAAAA,KAAK,GAAG,EAFiD;AAGzDC,IAAAA,aAHyD;AAIzDC,IAAAA,YAAY,GAAG,EAJ0C;AAKzDC,IAAAA,KALyD;AAMzDC,IAAAA,QANyD;AAOzD,OAAGC;AAPsD,GAQrD;AACJ,QAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoChB,KAAK,CAACiB,QAAN,CAAuB,EAAvB,CAA1C;AAEAjB,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAMC,SAAS,GAAGjB,sBAAsB,CAACO,KAAD,CAAxC;AAEAO,IAAAA,gBAAgB,CAACG,SAAD,CAAhB;AACD,GAJD,EAIG,CAACV,KAAD,CAJH;AAMAT,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAME,gBAAgB,GAAGlB,sBAAsB,CAACS,YAAD,CAA/C;AAEAK,IAAAA,gBAAgB,CAACI,gBAAD,CAAhB;AACD,GAJD,EAIG,CAACT,YAAD,CAJH;;AAMA,QAAMU,iBAAiB,GAAIC,QAAD,IAA+B;AACvD,UAAMC,YAAY,GAAGrB,sBAAsB,CAACoB,QAAD,CAA3C;AAEAN,IAAAA,gBAAgB,CAACO,YAAD,CAAhB;AACAb,IAAAA,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGa,YAAH,CAAb;AACD,GALD;;AAOA,QAAMC,eAAqC,GAAG,CAC5C;AACEC,IAAAA,aAAa,EAAElB,SAAS,KAAKH,SAAS,CAACsB,UAAxB,GAAqC,KAArC,GAA6C;AAD9D,GAD4C,CAA9C;;AAMA,MAAInB,SAAS,KAAKH,SAAS,CAACI,QAA5B,EAAsC;AACpCgB,IAAAA,eAAe,CAACG,IAAhB,CAAqB;AACnBC,MAAAA,UAAU,EAAE;AADO,KAArB;AAGD;;AAED,sBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAE,CAAC;AAAEC,MAAAA,SAAS,EAAE;AAAb,KAAD,EAAoBjB,KAApB;AAAb,KAA6CE,IAA7C,gBACE,oBAAC,QAAD;AACE,IAAA,KAAK,EAAE;AACLL,MAAAA,KAAK,EAAEM,aAAF,aAAEA,aAAF,cAAEA,aAAF,GAAmB,EADnB;AAELL,MAAAA,aAAa,EAAEW,iBAFV;AAGLd,MAAAA;AAHK;AADT,kBAOE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEiB;AAAb,KAA+BX,QAA/B,CAPF,CADF,CADF;AAaD,CAvDD;;AAyDA,eAAeP,gBAAf","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport type { Theme } from \"../../styles/DefaultTheme\";\nimport { getValueForRadioButton } from \"../../utilities\";\nimport { radioButtonGroupContext, Direction } from \"./context\";\nexport interface RadioButtonGroupProps {\n direction?: Direction;\n style?: StyleProp<ViewStyle>;\n value: string;\n onValueChange?: (value: string) => void;\n defaultValue?: string | number;\n theme: Theme;\n children: React.ReactNode;\n}\n\nconst { Provider } = radioButtonGroupContext;\n\nconst RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({\n direction = Direction.Vertical,\n value = \"\",\n onValueChange,\n defaultValue = \"\",\n style,\n children,\n ...rest\n}) => {\n const [internalValue, setInternalValue] = React.useState<string>(\"\");\n\n React.useEffect(() => {\n const realValue = getValueForRadioButton(value);\n\n setInternalValue(realValue);\n }, [value]);\n\n React.useEffect(() => {\n const realDefaultValue = getValueForRadioButton(defaultValue);\n\n setInternalValue(realDefaultValue);\n }, [defaultValue]);\n\n const handleValueChange = (newValue: string | number) => {\n const realNewValue = getValueForRadioButton(newValue);\n\n setInternalValue(realNewValue);\n onValueChange?.(realNewValue);\n };\n\n const _containerStyle: StyleProp<ViewStyle> = [\n {\n flexDirection: direction === Direction.Horizontal ? \"row\" : \"column\",\n },\n ];\n\n if (direction !== Direction.Vertical) {\n _containerStyle.push({\n alignItems: \"center\",\n });\n }\n\n return (\n <View style={[{ minHeight: 40 }, style]} {...rest}>\n <Provider\n value={{\n value: internalValue ?? \"\",\n onValueChange: handleValueChange,\n direction,\n }}\n >\n <View style={_containerStyle}>{children}</View>\n </Provider>\n </View>\n );\n};\n\nexport default RadioButtonGroup;\n"]}
|