@draftbit/core 43.4.5-e035fd.1 → 43.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Elevation.js +3 -14
- package/lib/commonjs/components/Elevation.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js +9 -8
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +13 -12
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +9 -6
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/index.js +0 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/RowBodyIcon.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
- package/lib/commonjs/utilities.js +13 -0
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +8 -8
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +12 -12
- package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +10 -7
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/mappings/LinearGradient.js.map +1 -1
- package/lib/module/utilities.js +10 -0
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +2 -2
- package/lib/typescript/src/components/RadioButton/RadioButtonRow.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/utilities.d.ts +1 -0
- package/package.json +2 -3
- package/src/components/RadioButton/RadioButton.js +7 -6
- package/src/components/RadioButton/RadioButton.tsx +11 -12
- package/src/components/RadioButton/RadioButtonGroup.js +10 -10
- package/src/components/RadioButton/RadioButtonGroup.tsx +18 -17
- package/src/components/RadioButton/RadioButtonRow.js +8 -5
- package/src/components/RadioButton/RadioButtonRow.tsx +12 -10
- package/src/index.js +0 -1
- package/src/index.tsx +0 -1
- package/src/utilities.js +12 -0
- package/src/utilities.ts +11 -0
- package/lib/commonjs/components/Markdown.js +0 -30
- package/lib/commonjs/components/Markdown.js.map +0 -1
- package/lib/commonjs/mappings/Markdown.js +0 -24
- package/lib/commonjs/mappings/Markdown.js.map +0 -1
- package/lib/module/components/Markdown.js +0 -13
- package/lib/module/components/Markdown.js.map +0 -1
- package/lib/module/mappings/Markdown.js +0 -15
- package/lib/module/mappings/Markdown.js.map +0 -1
- package/lib/typescript/src/components/Markdown.d.ts +0 -12
- package/lib/typescript/src/mappings/Markdown.d.ts +0 -9
- package/src/components/Markdown.js +0 -7
- package/src/components/Markdown.tsx +0 -14
- package/src/mappings/Markdown.js +0 -14
- package/src/mappings/Markdown.ts +0 -15
|
@@ -2,6 +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 { getValueForRadioButton } from "../../utilities";
|
|
5
6
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
6
7
|
const {
|
|
7
8
|
Provider
|
|
@@ -10,28 +11,27 @@ const {
|
|
|
10
11
|
const RadioButtonGroup = _ref => {
|
|
11
12
|
let {
|
|
12
13
|
direction = Direction.Vertical,
|
|
13
|
-
value,
|
|
14
|
-
onValueChange
|
|
15
|
-
defaultValue,
|
|
14
|
+
value = "",
|
|
15
|
+
onValueChange,
|
|
16
|
+
defaultValue = "",
|
|
16
17
|
style,
|
|
17
18
|
children,
|
|
18
19
|
...rest
|
|
19
20
|
} = _ref;
|
|
20
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
21
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
21
22
|
React.useEffect(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
23
|
+
const realValue = getValueForRadioButton(value);
|
|
24
|
+
setInternalValue(realValue);
|
|
25
25
|
}, [value]);
|
|
26
26
|
React.useEffect(() => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
27
|
+
const realDefaultValue = getValueForRadioButton(defaultValue);
|
|
28
|
+
setInternalValue(realDefaultValue);
|
|
30
29
|
}, [defaultValue]);
|
|
31
30
|
|
|
32
31
|
const handleValueChange = newValue => {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const realNewValue = getValueForRadioButton(newValue);
|
|
33
|
+
setInternalValue(realNewValue);
|
|
34
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realNewValue);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const _containerStyle = [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","radioButtonGroupContext","Direction","Provider","RadioButtonGroup","direction","Vertical","value","onValueChange","defaultValue","style","children","rest","internalValue","setInternalValue","useState","useEffect","handleValueChange","newValue","_containerStyle","flexDirection","Horizontal","push","alignItems","minHeight"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAA2C,cAA3C;AAEA,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,
|
|
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,aAAa,IAAI,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"]}
|
|
@@ -7,7 +7,7 @@ import Text from "../Text";
|
|
|
7
7
|
import { useRadioButtonGroupContext } from "./context";
|
|
8
8
|
import { Direction as GroupDirection } from "./context";
|
|
9
9
|
import Touchable from "../Touchable";
|
|
10
|
-
import { extractStyles } from "../../utilities";
|
|
10
|
+
import { extractStyles, getValueForRadioButton } from "../../utilities";
|
|
11
11
|
export let Direction;
|
|
12
12
|
|
|
13
13
|
(function (Direction) {
|
|
@@ -39,10 +39,10 @@ const RadioButtonRow = _ref => {
|
|
|
39
39
|
let {
|
|
40
40
|
Icon,
|
|
41
41
|
label,
|
|
42
|
-
value,
|
|
42
|
+
value = "",
|
|
43
43
|
color,
|
|
44
44
|
unselectedColor,
|
|
45
|
-
onPress
|
|
45
|
+
onPress,
|
|
46
46
|
labelContainerStyle,
|
|
47
47
|
labelStyle,
|
|
48
48
|
radioButtonStyle,
|
|
@@ -57,10 +57,13 @@ const RadioButtonRow = _ref => {
|
|
|
57
57
|
onValueChange,
|
|
58
58
|
direction: parentDirection
|
|
59
59
|
} = useRadioButtonGroupContext();
|
|
60
|
+
const realValue = getValueForRadioButton(value);
|
|
61
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
62
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue === realValue;
|
|
60
63
|
|
|
61
64
|
const handlePress = () => {
|
|
62
|
-
onPress(
|
|
63
|
-
onValueChange
|
|
65
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
66
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
const {
|
|
@@ -84,10 +87,10 @@ const RadioButtonRow = _ref => {
|
|
|
84
87
|
}
|
|
85
88
|
}, /*#__PURE__*/React.createElement(RadioButton, {
|
|
86
89
|
Icon: Icon,
|
|
87
|
-
selected:
|
|
90
|
+
selected: isSelected,
|
|
91
|
+
value: realValue,
|
|
88
92
|
color: color,
|
|
89
93
|
unselectedColor: unselectedColor,
|
|
90
|
-
onPress: handlePress,
|
|
91
94
|
style: radioButtonStyle
|
|
92
95
|
})));
|
|
93
96
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","Direction","GroupDirection","Touchable","extractStyles","getRadioButtonAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAOO,cAPP;AAQA,OAAOC,WAAP,MAA8C,eAA9C;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,0BAAT,QAA2C,WAA3C;AAEA,SAASC,SAAS,IAAIC,cAAtB,QAA4C,WAA5C;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,aAAT,
|
|
1
|
+
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","Direction","GroupDirection","Touchable","extractStyles","getValueForRadioButton","getRadioButtonAlignment","parentDirection","direction","Horizontal","Row","RowReverse","renderLabel","value","labelStyle","textStyle","RadioButtonRow","Icon","label","color","unselectedColor","onPress","labelContainerStyle","radioButtonStyle","selected","disabled","style","rest","contextValue","onValueChange","realValue","realContextValue","isSelected","handlePress","textStyles","viewStyles","styles","mainParent","flexDirection","alignItems","flex","create","justifyContent","paddingStart","minHeight","paddingEnd","select","web","cursor","userSelect"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAGEC,UAHF,EAKEC,IALF,EAMEC,QANF,QAOO,cAPP;AAQA,OAAOC,WAAP,MAA8C,eAA9C;AACA,OAAOC,IAAP,MAAiB,SAAjB;AACA,SAASC,0BAAT,QAA2C,WAA3C;AAEA,SAASC,SAAS,IAAIC,cAAtB,QAA4C,WAA5C;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,SAASC,aAAT,EAAwBC,sBAAxB,QAAsD,iBAAtD;AAEA,WAAYJ,SAAZ;;WAAYA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,KAAAA,S;;AAiBZ,MAAMK,uBAAuB,GAAG,CAC9BC,eAD8B,EAE9BC,SAF8B,KAG3B;AACH,MAAID,eAAe,KAAKL,cAAc,CAACO,UAAvC,EAAmD;AACjD,WAAOD,SAAS,KAAKP,SAAS,CAACS,GAAxB,GAA8B,YAA9B,GAA6C,UAApD;AACD,GAFD,MAEO,IAAIF,SAAS,KAAKP,SAAS,CAACU,UAA5B,EAAwC;AAC7C,WAAO,YAAP;AACD,GAFM,MAEA;AACL,WAAO,UAAP;AACD;AACF,CAXD;;AAaA,MAAMC,WAAW,GAAG,CAClBC,KADk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E;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,UAAU,EAAE;AAFT;AADY,KAAhB;AAPO,GADmB;AAe/B/B,EAAAA,KAAK,EAAE;AACLsB,IAAAA,IAAI,EAAE;AADD;AAfwB,CAAlB,CAAf;AAoBA,eAAexB,cAAf","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 value: string | React.ReactNode,\n labelStyle: StyleProp<TextStyle>,\n textStyle: StyleProp<TextStyle>\n) => {\n if (typeof value === \"string\") {\n return <Text style={[labelStyle, textStyle]}>{value}</Text>;\n } else {\n return <>{value}</>;\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}\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"]}
|
package/lib/module/index.js
CHANGED
|
@@ -49,5 +49,4 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
|
|
|
49
49
|
export { default as Slider } from "./components/Slider";
|
|
50
50
|
export { default as Stepper } from "./components/Stepper";
|
|
51
51
|
export { useAuthState } from "./components/useAuthState";
|
|
52
|
-
export { default as Markdown } from "./components/Markdown";
|
|
53
52
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","Center","Circle","Square","Row","Stack","Spacer","RadioButton","RadioButtonGroup","RadioButtonRow","RadioButtonFieldGroup","Button","CardBlock","CardContainer","CardContainerRating","CardInline","DatePicker","HeaderLarge","HeaderMedium","HeaderOverline","Picker","ProgressBar","ProgressCircle","RowBodyIcon","RowHeadlineImageCaption","RowHeadlineImageIcon","Slider","Stepper","useAuthState"
|
|
1
|
+
{"version":3,"sources":["index.tsx"],"names":["injectIcon","withTheme","ThemeProvider","default","Provider","DefaultTheme","Link","ButtonSolid","ButtonOutline","Avatar","AvatarEdit","Card","Carousel","Checkbox","CheckboxGroup","CheckboxRow","CircleImage","Container","Divider","FAB","FieldSearchBarFull","IconButton","Image","NumberInput","ScreenContainer","StarRating","Surface","Switch","SwitchRow","TextField","ToggleButton","Touchable","AccordionGroup","AccordionItem","ActionSheet","ActionSheetItem","ActionSheetCancel","Swiper","SwiperItem","Center","Circle","Square","Row","Stack","Spacer","RadioButton","RadioButtonGroup","RadioButtonRow","RadioButtonFieldGroup","Button","CardBlock","CardContainer","CardContainerRating","CardInline","DatePicker","HeaderLarge","HeaderMedium","HeaderOverline","Picker","ProgressBar","ProgressCircle","RowBodyIcon","RowHeadlineImageCaption","RowHeadlineImageIcon","Slider","Stepper","useAuthState"],"mappings":"AAAA,SAASA,UAAT,QAA2B,mBAA3B;AACA,SAASC,SAAT,EAAoBC,aAApB,QAAyC,WAAzC;AACA,SAASC,OAAO,IAAIC,QAApB,QAAoC,YAApC;AAC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AjB,QAAmC,qBAAnC;AAEA,SACEC,MADF,EAEEC,MAFF,EAGEC,MAHF,EAIEC,GAJF,EAKEC,KALF,EAMEC,MANF,QAOO,qBAPP;AASA,SACEC,WADF,EAEEC,gBAFF,EAGEC,cAHF,EAIEC,qBAJF,QAKO,gCALP;AAOA;;AACA,SAAS7C,OAAO,IAAI8C,MAApB,QAAkC,+BAAlC;AACA,SAAS9C,OAAO,IAAI+C,SAApB,QAAqC,wBAArC;AACA,SAAS/C,OAAO,IAAIgD,aAApB,QAAyC,4BAAzC;AACA,SAAShD,OAAO,IAAIiD,mBAApB,QAA+C,kCAA/C;AACA,SAASjD,OAAO,IAAIkD,UAApB,QAAsC,yBAAtC;AACA,SAASlD,OAAO,IAAImD,UAApB,QAAsC,oCAAtC;AACA,SAASnD,OAAO,IAAIoD,WAApB,QAAuC,0BAAvC;AACA,SAASpD,OAAO,IAAIqD,YAApB,QAAwC,2BAAxC;AACA,SAASrD,OAAO,IAAIsD,cAApB,QAA0C,6BAA1C;AACA,SAAStD,OAAO,IAAIuD,MAApB,QAAkC,4BAAlC;AACA,SAASvD,OAAO,IAAIwD,WAApB,QAAuC,0BAAvC;AACA,SAASxD,OAAO,IAAIyD,cAApB,QAA0C,6BAA1C;AACA,SAASzD,OAAO,IAAI0D,WAApB,QAAuC,0BAAvC;AACA,SAAS1D,OAAO,IAAI2D,uBAApB,QAAmD,sCAAnD;AACA,SAAS3D,OAAO,IAAI4D,oBAApB,QAAgD,mCAAhD;AACA,SAAS5D,OAAO,IAAI6D,MAApB,QAAkC,qBAAlC;AACA,SAAS7D,OAAO,IAAI8D,OAApB,QAAmC,sBAAnC;AACA,SAASC,YAAT,QAA6B,2BAA7B","sourcesContent":["export { injectIcon } from \"./interfaces/Icon\";\nexport { withTheme, ThemeProvider } from \"./theming\";\nexport { default as Provider } from \"./Provider\";\nexport { default as DefaultTheme } from \"./styles/DefaultTheme\";\n\nexport { Link } from \"./components/Text\";\nexport { ButtonSolid, ButtonOutline } from \"./components/Button\";\nexport { default as Avatar } from \"./components/CircleImage\";\nexport { default as AvatarEdit } from \"./components/AvatarEdit\";\nexport { default as Card } from \"./components/Card\";\nexport { default as Carousel } from \"./components/Carousel\";\nexport { Checkbox, CheckboxGroup, CheckboxRow } from \"./components/Checkbox\";\nexport { default as CircleImage } from \"./components/CircleImage\";\nexport { default as Container } from \"./components/Container\";\nexport { default as Divider } from \"./components/Divider\";\nexport { default as FAB } from \"./components/FAB\";\nexport { default as FieldSearchBarFull } from \"./components/FieldSearchBarFull\";\nexport { default as IconButton } from \"./components/IconButton\";\nexport { default as Image } from \"./components/Image\";\nexport { default as NumberInput } from \"./components/NumberInput\";\nexport { default as ScreenContainer } from \"./components/ScreenContainer\";\nexport { default as StarRating } from \"./components/StarRating\";\nexport { default as Surface } from \"./components/Surface\";\nexport { default as Switch, SwitchRow } from \"./components/Switch\";\nexport { default as TextField } from \"./components/TextField\";\nexport { default as ToggleButton } from \"./components/ToggleButton\";\nexport { default as Touchable } from \"./components/Touchable\";\nexport { AccordionGroup, AccordionItem } from \"./components/Accordion\";\nexport {\n ActionSheet,\n ActionSheetItem,\n ActionSheetCancel,\n} from \"./components/ActionSheet\";\nexport { Swiper, SwiperItem } from \"./components/Swiper\";\n\nexport {\n Center,\n Circle,\n Square,\n Row,\n Stack,\n Spacer,\n} from \"./components/Layout\";\n\nexport {\n RadioButton,\n RadioButtonGroup,\n RadioButtonRow,\n RadioButtonFieldGroup,\n} from \"./components/RadioButton/index\";\n\n/* Deprecated: Fix or Delete! */\nexport { default as Button } from \"./components/DeprecatedButton\";\nexport { default as CardBlock } from \"./components/CardBlock\";\nexport { default as CardContainer } from \"./components/CardContainer\";\nexport { default as CardContainerRating } from \"./components/CardContainerRating\";\nexport { default as CardInline } from \"./components/CardInline\";\nexport { default as DatePicker } from \"./components/DatePicker/DatePicker\";\nexport { default as HeaderLarge } from \"./components/HeaderLarge\";\nexport { default as HeaderMedium } from \"./components/HeaderMedium\";\nexport { default as HeaderOverline } from \"./components/HeaderOverline\";\nexport { default as Picker } from \"./components/Picker/Picker\";\nexport { default as ProgressBar } from \"./components/ProgressBar\";\nexport { default as ProgressCircle } from \"./components/ProgressCircle\";\nexport { default as RowBodyIcon } from \"./components/RowBodyIcon\";\nexport { default as RowHeadlineImageCaption } from \"./components/RowHeadlineImageCaption\";\nexport { default as RowHeadlineImageIcon } from \"./components/RowHeadlineImageIcon\";\nexport { default as Slider } from \"./components/Slider\";\nexport { default as Stepper } from \"./components/Stepper\";\nexport { useAuthState } from \"./components/useAuthState\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["LinearGradient.
|
|
1
|
+
{"version":3,"sources":["LinearGradient.ts"],"names":["createColorProp","FORM_TYPES","GROUPS","PROP_TYPES","SEED_DATA","name","tag","description","layout","width","height","props","endY","group","basic","label","editable","required","defaultValue","min","max","step","precision","formType","number","propType","NUMBER","endX","startY","startX","color3","undefined","color2","color1"],"mappings":"AAAA,SACEA,eADF,EAEEC,UAFF,EAGEC,MAHF,EAIEC,UAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,iBADiB;AAEvBC,EAAAA,GAAG,EAAE,gBAFkB;AAGvBC,EAAAA,WAAW,EAAE,2BAHU;AAIvBC,EAAAA,MAAM,EAAE;AAAEC,IAAAA,KAAK,EAAE,MAAT;AAAiBC,IAAAA,MAAM,EAAE;AAAzB,GAJe;AAKvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAE;AACJC,MAAAA,KAAK,EAAEX,MAAM,CAACY,KADV;AAEJC,MAAAA,KAAK,EAAE,OAFH;AAGJR,MAAAA,WAAW,EAAE,0BAHT;AAIJS,MAAAA,QAAQ,EAAE,IAJN;AAKJC,MAAAA,QAAQ,EAAE,KALN;AAMJC,MAAAA,YAAY,EAAE,GANV;AAOJC,MAAAA,GAAG,EAAE,CAPD;AAQJC,MAAAA,GAAG,EAAE,GARD;AASJC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;AAINS,MAAAA,QAAQ,EAAE,IAJJ;AAKNC,MAAAA,QAAQ,EAAE,KALJ;AAMNC,MAAAA,YAAY,EAAE,CANR;AAONC,MAAAA,GAAG,EAAE,CAPC;AAQNC,MAAAA,GAAG,EAAE,GARC;AASNC,MAAAA,IAAI,EAAE,CATA;AAUNC,MAAAA,SAAS,EAAE,CAVL;AAWNC,MAAAA,QAAQ,EAAEtB,UAAU,CAACuB,MAXf;AAYNC,MAAAA,QAAQ,EAAEtB,UAAU,CAACuB;AAZf,KA3CH;AAyDLI,IAAAA,MAAM,EAAE9B,eAAe,CAAC;AACtBe,MAAAA,KAAK,EAAE,SADe;AAEtBG,MAAAA,YAAY,EAAEa;AAFQ,KAAD,CAzDlB;AA6DLC,IAAAA,MAAM,EAAEhC,eAAe,CAAC;AACtBe,MAAAA,KAAK,EAAE,SADe;AAEtBG,MAAAA,YAAY,EAAE;AAFQ,KAAD,CA7DlB;AAiELe,IAAAA,MAAM,EAAEjC,eAAe,CAAC;AACtBe,MAAAA,KAAK,EAAE,SADe;AAEtBG,MAAAA,YAAY,EAAE;AAFQ,KAAD;AAjElB;AALgB,CAAlB","sourcesContent":["import {\n createColorProp,\n FORM_TYPES,\n GROUPS,\n PROP_TYPES,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Linear Gradient\",\n tag: \"LinearGradient\",\n description: \"Linear Gradient Component\",\n layout: { width: \"100%\", height: \"100%\" },\n props: {\n endY: {\n group: GROUPS.basic,\n label: \"End Y\",\n description: \"End position from Bottom\",\n editable: true,\n required: false,\n defaultValue: 100,\n min: 0,\n max: 100,\n step: 1,\n precision: 0,\n formType: FORM_TYPES.number,\n propType: PROP_TYPES.NUMBER,\n },\n endX: {\n group: GROUPS.basic,\n label: \"End X\",\n description: \"End position from Right\",\n editable: true,\n required: false,\n defaultValue: 100,\n min: 0,\n max: 100,\n step: 1,\n precision: 0,\n formType: FORM_TYPES.number,\n propType: PROP_TYPES.NUMBER,\n },\n startY: {\n group: GROUPS.basic,\n label: \"Start Y\",\n description: \"Start position from Top\",\n editable: true,\n required: false,\n defaultValue: 0,\n min: 0,\n max: 100,\n step: 1,\n precision: 0,\n formType: FORM_TYPES.number,\n propType: PROP_TYPES.NUMBER,\n },\n startX: {\n group: GROUPS.basic,\n label: \"Start X\",\n description: \"Start position from Left\",\n editable: true,\n required: false,\n defaultValue: 0,\n min: 0,\n max: 100,\n step: 1,\n precision: 0,\n formType: FORM_TYPES.number,\n propType: PROP_TYPES.NUMBER,\n },\n color3: createColorProp({\n label: \"Color 3\",\n defaultValue: undefined,\n }),\n color2: createColorProp({\n label: \"Color 2\",\n defaultValue: \"secondary\",\n }),\n color1: createColorProp({\n label: \"Color 1\",\n defaultValue: \"primary\",\n }),\n },\n};\n"]}
|
package/lib/module/utilities.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
|
+
import { isString, isNumber } from "lodash";
|
|
2
3
|
export function extractStyles(style) {
|
|
3
4
|
const {
|
|
4
5
|
color,
|
|
@@ -60,4 +61,13 @@ export function applyStyles(baseStyles, stylesToApply) {
|
|
|
60
61
|
|
|
61
62
|
return flattenedStyles;
|
|
62
63
|
}
|
|
64
|
+
export function getValueForRadioButton(value) {
|
|
65
|
+
if (isString(value)) {
|
|
66
|
+
return value;
|
|
67
|
+
} else if (isNumber(value)) {
|
|
68
|
+
return String(value);
|
|
69
|
+
} else {
|
|
70
|
+
throw new Error(`Invalid value: ${value}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
63
73
|
//# sourceMappingURL=utilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utilities.ts"],"names":["StyleSheet","extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries"],"mappings":"AAAA,SAASA,UAAT,QAAiD,cAAjD;AAEA,OAAO,SAASC,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,
|
|
1
|
+
{"version":3,"sources":["utilities.ts"],"names":["StyleSheet","isString","isNumber","extractStyles","style","color","fontFamily","fontWeight","fontSize","lineHeight","letterSpacing","textTransform","textAlign","textDecorationLine","textDecorationColor","textDecorationStyle","viewStyles","flatten","textStyles","applyStyles","baseStyles","stylesToApply","flattenedStyles","key","value","Object","entries","getValueForRadioButton","String","Error"],"mappings":"AAAA,SAASA,UAAT,QAAiD,cAAjD;AACA,SAASC,QAAT,EAAmBC,QAAnB,QAAmC,QAAnC;AAEA,OAAO,SAASC,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,MAaFhB,UAAU,CAACiB,OAAX,CAAmBb,KAAK,IAAI,EAA5B,CAbJ;AAeA,QAAMc,UAAqB,GAAG;AAC5Bb,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;AAAcE,IAAAA;AAAd,GAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,WAAT,CACLC,UADK,EAELC,aAFK,EAGL;AACA,MAAI,CAACA,aAAL,EAAoB;AAClB;AACD;;AAED,QAAMC,eAAe,GAAGtB,UAAU,CAACiB,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;AAED,OAAO,SAASK,sBAAT,CAAgCH,KAAhC,EAAwD;AAC7D,MAAIvB,QAAQ,CAACuB,KAAD,CAAZ,EAAqB;AACnB,WAAOA,KAAP;AACD,GAFD,MAEO,IAAItB,QAAQ,CAACsB,KAAD,CAAZ,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"]}
|
|
@@ -5,9 +5,9 @@ export declare type RadioButtonProps = {
|
|
|
5
5
|
selected?: boolean;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
color?: string;
|
|
8
|
-
value?: string;
|
|
8
|
+
value?: string | number;
|
|
9
9
|
unselectedColor?: string;
|
|
10
|
-
onPress?: () => void;
|
|
10
|
+
onPress?: (value?: string) => void;
|
|
11
11
|
style?: StyleProp<ViewStyle>;
|
|
12
12
|
size?: number;
|
|
13
13
|
selectedIcon?: string;
|
|
@@ -5,9 +5,9 @@ import { Direction } from "./context";
|
|
|
5
5
|
export interface RadioButtonGroupProps {
|
|
6
6
|
direction?: Direction;
|
|
7
7
|
style?: StyleProp<ViewStyle>;
|
|
8
|
-
value
|
|
8
|
+
value: string;
|
|
9
9
|
onValueChange?: (value: string) => void;
|
|
10
|
-
defaultValue?: string;
|
|
10
|
+
defaultValue?: string | number;
|
|
11
11
|
theme: Theme;
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
}
|
|
@@ -8,7 +8,7 @@ export declare enum Direction {
|
|
|
8
8
|
}
|
|
9
9
|
export interface RadioButtonRowProps extends Omit<RadioButtonProps, "onPress"> {
|
|
10
10
|
label: string | React.ReactNode;
|
|
11
|
-
value: string;
|
|
11
|
+
value: string | number;
|
|
12
12
|
color?: string;
|
|
13
13
|
unselectedColor?: string;
|
|
14
14
|
labelContainerStyle: StyleProp<ViewStyle>;
|
|
@@ -47,4 +47,3 @@ export { default as RowHeadlineImageIcon } from "./components/RowHeadlineImageIc
|
|
|
47
47
|
export { default as Slider } from "./components/Slider";
|
|
48
48
|
export { default as Stepper } from "./components/Stepper";
|
|
49
49
|
export { useAuthState } from "./components/useAuthState";
|
|
50
|
-
export { default as Markdown } from "./components/Markdown";
|
|
@@ -16,3 +16,4 @@ export declare function extractStyles(style: StyleProp<any>): {
|
|
|
16
16
|
* `const mergedStyles = StyleSheet.flatten([{ color: "red" }, { color: undefined }])`
|
|
17
17
|
*/
|
|
18
18
|
export declare function applyStyles(baseStyles: Array<StyleProp<any>>, stylesToApply: StyleProp<any> | undefined): any;
|
|
19
|
+
export declare function getValueForRadioButton(value: string | number): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "43.4.5
|
|
3
|
+
"version": "43.4.5",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -53,7 +53,6 @@
|
|
|
53
53
|
"lodash.isnumber": "^3.0.3",
|
|
54
54
|
"lodash.omit": "^4.5.0",
|
|
55
55
|
"lodash.tonumber": "^4.0.3",
|
|
56
|
-
"react-native-markdown-display": "^7.0.0-alpha.2",
|
|
57
56
|
"react-native-modal-datetime-picker": "^13.0.0",
|
|
58
57
|
"react-native-typography": "^1.4.1",
|
|
59
58
|
"react-native-web-swiper": "^2.2.1"
|
|
@@ -81,5 +80,5 @@
|
|
|
81
80
|
]
|
|
82
81
|
]
|
|
83
82
|
},
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ba3f28fcb72b7286619df898ae4068de4655c9b9"
|
|
85
84
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import Config from "../Config";
|
|
3
3
|
import IconButton from "../IconButton";
|
|
4
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
4
5
|
import { useRadioButtonGroupContext } from "./context";
|
|
5
|
-
const RadioButton = ({ Icon, disabled = false, color, value, selected, unselectedColor, onPress
|
|
6
|
+
const RadioButton = ({ Icon, disabled = false, color, value = "", selected, unselectedColor, onPress, size = Config.radioButtonSize, selectedIcon = "MaterialIcons/radio-button-checked", unselectedIcon = "MaterialIcons/radio-button-unchecked", style, ...rest }) => {
|
|
6
7
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
8
|
+
const realValue = getValueForRadioButton(value);
|
|
9
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
10
|
+
const isSelected = selected ?? realContextValue === realValue;
|
|
7
11
|
const handlePress = () => {
|
|
8
|
-
onPress
|
|
9
|
-
|
|
10
|
-
onValueChange(value);
|
|
11
|
-
}
|
|
12
|
+
onPress?.(realValue);
|
|
13
|
+
onValueChange?.(realValue);
|
|
12
14
|
};
|
|
13
|
-
const isSelected = selected || (contextValue != null && contextValue === value);
|
|
14
15
|
return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
|
|
15
16
|
};
|
|
16
17
|
export default RadioButton;
|
|
@@ -3,6 +3,7 @@ import { StyleProp, ViewStyle } from "react-native";
|
|
|
3
3
|
|
|
4
4
|
import Config from "../Config";
|
|
5
5
|
import IconButton from "../IconButton";
|
|
6
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
6
7
|
import { useRadioButtonGroupContext } from "./context";
|
|
7
8
|
|
|
8
9
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -11,9 +12,9 @@ export type RadioButtonProps = {
|
|
|
11
12
|
selected?: boolean;
|
|
12
13
|
disabled?: boolean;
|
|
13
14
|
color?: string;
|
|
14
|
-
value?: string;
|
|
15
|
+
value?: string | number;
|
|
15
16
|
unselectedColor?: string;
|
|
16
|
-
onPress?: () => void;
|
|
17
|
+
onPress?: (value?: string) => void;
|
|
17
18
|
style?: StyleProp<ViewStyle>;
|
|
18
19
|
size?: number;
|
|
19
20
|
selectedIcon?: string;
|
|
@@ -24,10 +25,10 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
24
25
|
Icon,
|
|
25
26
|
disabled = false,
|
|
26
27
|
color,
|
|
27
|
-
value,
|
|
28
|
+
value = "",
|
|
28
29
|
selected,
|
|
29
30
|
unselectedColor,
|
|
30
|
-
onPress
|
|
31
|
+
onPress,
|
|
31
32
|
size = Config.radioButtonSize,
|
|
32
33
|
selectedIcon = "MaterialIcons/radio-button-checked",
|
|
33
34
|
unselectedIcon = "MaterialIcons/radio-button-unchecked",
|
|
@@ -36,17 +37,15 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
36
37
|
}) => {
|
|
37
38
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const realValue = getValueForRadioButton(value);
|
|
41
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
42
|
+
const isSelected = selected ?? realContextValue === realValue;
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
const handlePress = () => {
|
|
45
|
+
onPress?.(realValue);
|
|
46
|
+
onValueChange?.(realValue);
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
const isSelected =
|
|
48
|
-
selected || (contextValue != null && contextValue === value);
|
|
49
|
-
|
|
50
49
|
return (
|
|
51
50
|
<IconButton
|
|
52
51
|
Icon={Icon}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
3
4
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
4
5
|
const { Provider } = radioButtonGroupContext;
|
|
5
|
-
const RadioButtonGroup = ({ direction = Direction.Vertical, value
|
|
6
|
-
const [internalValue, setInternalValue] = React.useState(
|
|
6
|
+
const RadioButtonGroup = ({ direction = Direction.Vertical, value = "", onValueChange, defaultValue = "", style, children, ...rest }) => {
|
|
7
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
7
8
|
React.useEffect(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
9
|
+
const realValue = getValueForRadioButton(value);
|
|
10
|
+
setInternalValue(realValue);
|
|
11
11
|
}, [value]);
|
|
12
12
|
React.useEffect(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
13
|
+
const realDefaultValue = getValueForRadioButton(defaultValue);
|
|
14
|
+
setInternalValue(realDefaultValue);
|
|
16
15
|
}, [defaultValue]);
|
|
17
16
|
const handleValueChange = (newValue) => {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const realNewValue = getValueForRadioButton(newValue);
|
|
18
|
+
setInternalValue(realNewValue);
|
|
19
|
+
onValueChange?.(realNewValue);
|
|
20
20
|
};
|
|
21
21
|
const _containerStyle = [
|
|
22
22
|
{
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import { getValueForRadioButton } from "../../utilities";
|
|
4
5
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
5
6
|
export interface RadioButtonGroupProps {
|
|
6
7
|
direction?: Direction;
|
|
7
8
|
style?: StyleProp<ViewStyle>;
|
|
8
|
-
value
|
|
9
|
+
value: string;
|
|
9
10
|
onValueChange?: (value: string) => void;
|
|
10
|
-
defaultValue?: string;
|
|
11
|
+
defaultValue?: string | number;
|
|
11
12
|
theme: Theme;
|
|
12
13
|
children: React.ReactNode;
|
|
13
14
|
}
|
|
@@ -16,32 +17,32 @@ const { Provider } = radioButtonGroupContext;
|
|
|
16
17
|
|
|
17
18
|
const RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({
|
|
18
19
|
direction = Direction.Vertical,
|
|
19
|
-
value,
|
|
20
|
-
onValueChange
|
|
21
|
-
defaultValue,
|
|
20
|
+
value = "",
|
|
21
|
+
onValueChange,
|
|
22
|
+
defaultValue = "",
|
|
22
23
|
style,
|
|
23
24
|
children,
|
|
24
25
|
...rest
|
|
25
26
|
}) => {
|
|
26
|
-
const [internalValue, setInternalValue] = React.useState<string
|
|
27
|
-
value || defaultValue
|
|
28
|
-
);
|
|
27
|
+
const [internalValue, setInternalValue] = React.useState<string>("");
|
|
29
28
|
|
|
30
29
|
React.useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const realValue = getValueForRadioButton(value);
|
|
31
|
+
|
|
32
|
+
setInternalValue(realValue);
|
|
34
33
|
}, [value]);
|
|
35
34
|
|
|
36
35
|
React.useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
const realDefaultValue = getValueForRadioButton(defaultValue);
|
|
37
|
+
|
|
38
|
+
setInternalValue(realDefaultValue);
|
|
40
39
|
}, [defaultValue]);
|
|
41
40
|
|
|
42
|
-
const handleValueChange = (newValue: string) => {
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const handleValueChange = (newValue: string | number) => {
|
|
42
|
+
const realNewValue = getValueForRadioButton(newValue);
|
|
43
|
+
|
|
44
|
+
setInternalValue(realNewValue);
|
|
45
|
+
onValueChange?.(realNewValue);
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
const _containerStyle: StyleProp<ViewStyle> = [
|
|
@@ -5,7 +5,7 @@ import Text from "../Text";
|
|
|
5
5
|
import { useRadioButtonGroupContext } from "./context";
|
|
6
6
|
import { Direction as GroupDirection } from "./context";
|
|
7
7
|
import Touchable from "../Touchable";
|
|
8
|
-
import { extractStyles } from "../../utilities";
|
|
8
|
+
import { extractStyles, getValueForRadioButton } from "../../utilities";
|
|
9
9
|
export var Direction;
|
|
10
10
|
(function (Direction) {
|
|
11
11
|
Direction["Row"] = "row";
|
|
@@ -30,11 +30,14 @@ const renderLabel = (value, labelStyle, textStyle) => {
|
|
|
30
30
|
return React.createElement(React.Fragment, null, value);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress
|
|
33
|
+
const RadioButtonRow = ({ Icon, label, value = "", color, unselectedColor, onPress, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
|
|
34
34
|
const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
|
|
35
|
+
const realValue = getValueForRadioButton(value);
|
|
36
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
37
|
+
const isSelected = selected ?? realContextValue === realValue;
|
|
35
38
|
const handlePress = () => {
|
|
36
|
-
onPress(
|
|
37
|
-
onValueChange
|
|
39
|
+
onPress?.(realValue);
|
|
40
|
+
onValueChange?.(realValue);
|
|
38
41
|
};
|
|
39
42
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
40
43
|
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
@@ -49,7 +52,7 @@ const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress =
|
|
|
49
52
|
flex: 1,
|
|
50
53
|
alignItems: getRadioButtonAlignment(parentDirection, direction),
|
|
51
54
|
} },
|
|
52
|
-
React.createElement(RadioButton, { Icon: Icon, selected:
|
|
55
|
+
React.createElement(RadioButton, { Icon: Icon, selected: isSelected, value: realValue, color: color, unselectedColor: unselectedColor, style: radioButtonStyle }))));
|
|
53
56
|
};
|
|
54
57
|
const styles = StyleSheet.create({
|
|
55
58
|
mainParent: {
|