@draftbit/core 43.4.4-03ab3e.0 → 43.4.5-958f08.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 +9 -6
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +18 -8
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +14 -9
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/StarRating.js +5 -4
- package/lib/commonjs/components/StarRating.js.map +1 -1
- package/lib/commonjs/components/Touchable.js +3 -16
- package/lib/commonjs/components/Touchable.js.map +1 -1
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/mappings/Accordion.js.map +1 -1
- package/lib/commonjs/mappings/LinearGradient.js +2 -2
- package/lib/commonjs/mappings/LinearGradient.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageIcon.js.map +1 -1
- package/lib/commonjs/utilities.js +16 -0
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +8 -6
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +17 -8
- package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +15 -10
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/Swiper/Swiper.js.map +1 -1
- package/lib/module/mappings/FAB.js.map +1 -1
- package/lib/module/mappings/LinearGradient.js +2 -2
- package/lib/module/mappings/LinearGradient.js.map +1 -1
- package/lib/module/utilities.js +14 -0
- 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/utilities.d.ts +1 -0
- package/package.json +2 -2
- package/src/components/RadioButton/RadioButton.js +9 -5
- package/src/components/RadioButton/RadioButton.tsx +12 -9
- package/src/components/RadioButton/RadioButtonGroup.js +14 -8
- package/src/components/RadioButton/RadioButtonGroup.tsx +21 -12
- package/src/components/RadioButton/RadioButtonRow.js +15 -9
- package/src/components/RadioButton/RadioButtonRow.tsx +19 -13
- package/src/mappings/LinearGradient.js +2 -2
- package/src/mappings/LinearGradient.ts +2 -2
- package/src/utilities.js +12 -0
- package/src/utilities.ts +13 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","useRadioButtonGroupContext","RadioButton","Icon","disabled","color","value","selected","unselectedColor","onPress","size","radioButtonSize","selectedIcon","unselectedIcon","style","rest","contextValue","onValueChange","
|
|
1
|
+
{"version":3,"sources":["RadioButton.tsx"],"names":["React","Config","IconButton","getRealValue","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;AAGA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,UAAP,MAAuB,eAAvB;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,0BAAT,QAA2C,WAA3C;;AAiBA,MAAMC,WAAuC,GAAG,QAa1C;AAAA,MAb2C;AAC/CC,IAAAA,IAD+C;AAE/CC,IAAAA,QAAQ,GAAG,KAFoC;AAG/CC,IAAAA,KAH+C;AAI/CC,IAAAA,KAJ+C;AAK/CC,IAAAA,QAL+C;AAM/CC,IAAAA,eAN+C;AAO/CC,IAAAA,OAP+C;AAQ/CC,IAAAA,IAAI,GAAGZ,MAAM,CAACa,eARiC;AAS/CC,IAAAA,YAAY,GAAG,oCATgC;AAU/CC,IAAAA,cAAc,GAAG,sCAV8B;AAW/CC,IAAAA,KAX+C;AAY/C,OAAGC;AAZ4C,GAa3C;AACJ,QAAM;AAAET,IAAAA,KAAK,EAAEU,YAAT;AAAuBC,IAAAA;AAAvB,MAAyChB,0BAA0B,EAAzE;AAEA,QAAMiB,SAAS,GAAGlB,YAAY,CAACM,KAAD,CAA9B;AACA,QAAMa,gBAAgB,GAAGnB,YAAY,CAACgB,YAAD,CAArC;AACA,QAAMI,UAAU,GACdb,QADc,aACdA,QADc,cACdA,QADc,GAEbY,gBAAgB,IAAID,SAApB,IAAiCC,gBAAgB,KAAKD,SAFzD;;AAIA,QAAMG,WAAW,GAAG,MAAM;AACxB,QAAIH,SAAJ,EAAe;AACbT,MAAAA,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAGS,SAAH,CAAP;AACAD,MAAAA,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGC,SAAH,CAAb;AACD;AACF,GALD;;AAOA,sBACE,oBAAC,UAAD;AACE,IAAA,IAAI,EAAEf,IADR;AAEE,IAAA,IAAI,EAAEiB,UAAU,GAAGR,YAAH,GAAkBC,cAFpC;AAGE,IAAA,KAAK,EAAEO,UAAU,GAAGf,KAAH,GAAWG,eAH9B;AAIE,IAAA,QAAQ,EAAEJ,QAJZ;AAKE,IAAA,OAAO,EAAEiB,WALX;AAME,IAAA,IAAI,EAAEX,IANR;AAOE,IAAA,KAAK,EAAEI;AAPT,KAQMC,IARN,EADF;AAYD,CAzCD;;AA2CA,eAAeb,WAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, ViewStyle } from \"react-native\";\n\nimport Config from \"../Config\";\nimport IconButton from \"../IconButton\";\nimport { getRealValue } 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;\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 = getRealValue(value);\n const realContextValue = getRealValue(contextValue);\n const isSelected =\n selected ??\n (realContextValue && realValue && realContextValue === realValue);\n\n const handlePress = () => {\n if (realValue) {\n onPress?.(realValue);\n onValueChange?.(realValue);\n }\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,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 { getRealValue } from "../../utilities";
|
|
5
6
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
6
7
|
const {
|
|
7
8
|
Provider
|
|
@@ -11,27 +12,35 @@ const RadioButtonGroup = _ref => {
|
|
|
11
12
|
let {
|
|
12
13
|
direction = Direction.Vertical,
|
|
13
14
|
value,
|
|
14
|
-
onValueChange
|
|
15
|
+
onValueChange,
|
|
15
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
|
-
|
|
23
|
+
const realValue = getRealValue(value);
|
|
24
|
+
|
|
25
|
+
if (realValue) {
|
|
26
|
+
setInternalValue(realValue);
|
|
24
27
|
}
|
|
25
28
|
}, [value]);
|
|
26
29
|
React.useEffect(() => {
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
const realDefaultValue = getRealValue(defaultValue);
|
|
31
|
+
|
|
32
|
+
if (realDefaultValue) {
|
|
33
|
+
setInternalValue(realDefaultValue);
|
|
29
34
|
}
|
|
30
35
|
}, [defaultValue]);
|
|
31
36
|
|
|
32
37
|
const handleValueChange = newValue => {
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
const realNewValue = getRealValue(newValue);
|
|
39
|
+
|
|
40
|
+
if (realNewValue) {
|
|
41
|
+
setInternalValue(newValue);
|
|
42
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(newValue);
|
|
43
|
+
}
|
|
35
44
|
};
|
|
36
45
|
|
|
37
46
|
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,KAFyD;AAGzDC,IAAAA,
|
|
1
|
+
{"version":3,"sources":["RadioButtonGroup.tsx"],"names":["React","View","getRealValue","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,YAAT,QAA6B,iBAA7B;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,KAFyD;AAGzDC,IAAAA,aAHyD;AAIzDC,IAAAA,YAJyD;AAKzDC,IAAAA,KALyD;AAMzDC,IAAAA,QANyD;AAOzD,OAAGC;AAPsD,GAQrD;AACJ,QAAM,CAACC,aAAD,EAAgBC,gBAAhB,IAAoChB,KAAK,CAACiB,QAAN,EAA1C;AAIAjB,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAMC,SAAS,GAAGjB,YAAY,CAACO,KAAD,CAA9B;;AAEA,QAAIU,SAAJ,EAAe;AACbH,MAAAA,gBAAgB,CAACG,SAAD,CAAhB;AACD;AACF,GAND,EAMG,CAACV,KAAD,CANH;AAQAT,EAAAA,KAAK,CAACkB,SAAN,CAAgB,MAAM;AACpB,UAAME,gBAAgB,GAAGlB,YAAY,CAACS,YAAD,CAArC;;AAEA,QAAIS,gBAAJ,EAAsB;AACpBJ,MAAAA,gBAAgB,CAACI,gBAAD,CAAhB;AACD;AACF,GAND,EAMG,CAACT,YAAD,CANH;;AAQA,QAAMU,iBAAiB,GAAIC,QAAD,IAAmB;AAC3C,UAAMC,YAAY,GAAGrB,YAAY,CAACoB,QAAD,CAAjC;;AAEA,QAAIC,YAAJ,EAAkB;AAChBP,MAAAA,gBAAgB,CAACM,QAAD,CAAhB;AACAZ,MAAAA,aAAa,SAAb,IAAAA,aAAa,WAAb,YAAAA,aAAa,CAAGY,QAAH,CAAb;AACD;AACF,GAPD;;AASA,QAAME,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,CA/DD;;AAiEA,eAAeP,gBAAf","sourcesContent":["import * as React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport type { Theme } from \"../../styles/DefaultTheme\";\nimport { getRealValue } 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<\n string | undefined\n >();\n\n React.useEffect(() => {\n const realValue = getRealValue(value);\n\n if (realValue) {\n setInternalValue(realValue);\n }\n }, [value]);\n\n React.useEffect(() => {\n const realDefaultValue = getRealValue(defaultValue);\n\n if (realDefaultValue) {\n setInternalValue(realDefaultValue);\n }\n }, [defaultValue]);\n\n const handleValueChange = (newValue: any) => {\n const realNewValue = getRealValue(newValue);\n\n if (realNewValue) {\n setInternalValue(newValue);\n onValueChange?.(newValue);\n }\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, getRealValue } from "../../utilities";
|
|
11
11
|
export let Direction;
|
|
12
12
|
|
|
13
13
|
(function (Direction) {
|
|
@@ -25,13 +25,13 @@ const getRadioButtonAlignment = (parentDirection, direction) => {
|
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const renderLabel = (
|
|
29
|
-
if (typeof
|
|
28
|
+
const renderLabel = (label, labelStyle, textStyle) => {
|
|
29
|
+
if (typeof label === "string") {
|
|
30
30
|
return /*#__PURE__*/React.createElement(Text, {
|
|
31
31
|
style: [labelStyle, textStyle]
|
|
32
|
-
},
|
|
32
|
+
}, label);
|
|
33
33
|
} else {
|
|
34
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
34
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, label);
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -42,7 +42,7 @@ const RadioButtonRow = _ref => {
|
|
|
42
42
|
value,
|
|
43
43
|
color,
|
|
44
44
|
unselectedColor,
|
|
45
|
-
onPress
|
|
45
|
+
onPress,
|
|
46
46
|
labelContainerStyle,
|
|
47
47
|
labelStyle,
|
|
48
48
|
radioButtonStyle,
|
|
@@ -57,10 +57,15 @@ const RadioButtonRow = _ref => {
|
|
|
57
57
|
onValueChange,
|
|
58
58
|
direction: parentDirection
|
|
59
59
|
} = useRadioButtonGroupContext();
|
|
60
|
+
const realValue = getRealValue(value);
|
|
61
|
+
const realContextValue = getRealValue(contextValue);
|
|
62
|
+
const isSelected = selected !== null && selected !== void 0 ? selected : realContextValue && realValue && realContextValue === realValue;
|
|
60
63
|
|
|
61
64
|
const handlePress = () => {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
if (realValue) {
|
|
66
|
+
onPress === null || onPress === void 0 ? void 0 : onPress(realValue);
|
|
67
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange(realValue);
|
|
68
|
+
}
|
|
64
69
|
};
|
|
65
70
|
|
|
66
71
|
const {
|
|
@@ -84,10 +89,10 @@ const RadioButtonRow = _ref => {
|
|
|
84
89
|
}
|
|
85
90
|
}, /*#__PURE__*/React.createElement(RadioButton, {
|
|
86
91
|
Icon: Icon,
|
|
87
|
-
selected:
|
|
92
|
+
selected: isSelected ? true : false,
|
|
93
|
+
value: realValue,
|
|
88
94
|
color: color,
|
|
89
95
|
unselectedColor: unselectedColor,
|
|
90
|
-
onPress: handlePress,
|
|
91
96
|
style: radioButtonStyle
|
|
92
97
|
})));
|
|
93
98
|
};
|
|
@@ -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","
|
|
1
|
+
{"version":3,"sources":["RadioButtonRow.tsx"],"names":["React","StyleSheet","View","Platform","RadioButton","Text","useRadioButtonGroupContext","Direction","GroupDirection","Touchable","extractStyles","getRealValue","getRadioButtonAlignment","parentDirection","direction","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","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,YAAxB,QAA4C,iBAA5C;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;AA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IVC,IAAAA,SAAS,EAAE,EAJD;AAKVC,IAAAA,UAAU,EAAE,EALF;AAMVL,IAAAA,IAAI,EAAE,CANI;AAOV,OAAG3C,QAAQ,CAACiD,MAAT,CAAgB;AACjBC,MAAAA,GAAG,EAAE;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,UAAU,EAAE;AAFT;AADY,KAAhB;AAPO,GADmB;AAe/BpC,EAAAA,KAAK,EAAE;AACL2B,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, getRealValue } 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; // 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 = getRealValue(value);\n const realContextValue = getRealValue(contextValue);\n const isSelected =\n selected ??\n (realContextValue && realValue && realContextValue === realValue);\n\n const handlePress = () => {\n if (realValue) {\n onPress?.(realValue);\n onValueChange?.(realValue);\n }\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":["Swiper.
|
|
1
|
+
{"version":3,"sources":["Swiper.tsx"],"names":["React","View","SwiperComponent","Swiper","vertical","loop","timeout","from","prevTitle","nextTitle","prevTitleColor","nextTitleColor","dotsTouchable","dotColor","dotActiveColor","children","style","prevTitleStyle","color","nextTitleStyle","dotProps","badgeStyle","backgroundColor","dotActiveStyle"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,IAAT,QAA2C,cAA3C;AACA,OAAOC,eAAP,MAA4B,yBAA5B;;AAkBA,MAAMC,MAAM,GAAG;AAAA,MAAC;AACdC,IAAAA,QAAQ,GAAG,KADG;AAEdC,IAAAA,IAAI,GAAG,KAFO;AAGdC,IAAAA,OAAO,GAAG,CAHI;AAIdC,IAAAA,IAAI,GAAG,CAJO;AAKdC,IAAAA,SAAS,GAAG,EALE;AAMdC,IAAAA,SAAS,GAAG,EANE;AAOdC,IAAAA,cAPc;AAQdC,IAAAA,cARc;AASdC,IAAAA,aAAa,GAAG,IATF;AAUdC,IAAAA,QAVc;AAWdC,IAAAA,cAXc;AAYdC,IAAAA,QAZc;AAadC,IAAAA;AAbc,GAAD;AAAA,sBAeb,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEA;AAAb,kBACE,oBAAC,eAAD;AACE,IAAA,IAAI,EAAET,IADR;AAEE,IAAA,IAAI,EAAEF,IAFR;AAGE,IAAA,OAAO,EAAEC,OAHX;AAIE,IAAA,QAAQ,EAAEF,QAJZ;AAKE,IAAA,aAAa,EAAE;AACbI,MAAAA,SADa;AAEbC,MAAAA,SAFa;AAGbQ,MAAAA,cAAc,EAAE;AAAEC,QAAAA,KAAK,EAAER;AAAT,OAHH;AAIbS,MAAAA,cAAc,EAAE;AAAED,QAAAA,KAAK,EAAEP;AAAT,OAJH;AAKbC,MAAAA,aALa;AAMb,UAAIC,QAAQ,GACR;AAAEO,QAAAA,QAAQ,EAAE;AAAEC,UAAAA,UAAU,EAAE;AAAEC,YAAAA,eAAe,EAAET;AAAnB;AAAd;AAAZ,OADQ,GAER,EAFJ,CANa;AASb,UAAIC,cAAc,GACd;AAAES,QAAAA,cAAc,EAAE;AAAED,UAAAA,eAAe,EAAER;AAAnB;AAAlB,OADc,GAEd,EAFJ;AATa;AALjB,KAmBGC,QAnBH,CADF,CAfa;AAAA,CAAf;;AAwCA,eAAeZ,MAAf","sourcesContent":["import React from \"react\";\nimport { View, StyleProp, ViewStyle } from \"react-native\";\nimport SwiperComponent from \"react-native-web-swiper\";\n\nexport interface SwiperProps {\n vertical?: boolean;\n loop?: boolean;\n from?: number;\n timeout?: number;\n prevTitle?: string;\n nextTitle?: string;\n prevTitleColor?: string;\n nextTitleColor?: string;\n dotsTouchable?: boolean;\n dotColor?: string;\n dotActiveColor?: string;\n children: React.ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nconst Swiper = ({\n vertical = false,\n loop = false,\n timeout = 0,\n from = 0,\n prevTitle = \"\",\n nextTitle = \"\",\n prevTitleColor,\n nextTitleColor,\n dotsTouchable = true,\n dotColor,\n dotActiveColor,\n children,\n style,\n}: SwiperProps) => (\n <View style={style}>\n <SwiperComponent\n from={from}\n loop={loop}\n timeout={timeout}\n vertical={vertical}\n controlsProps={{\n prevTitle,\n nextTitle,\n prevTitleStyle: { color: prevTitleColor },\n nextTitleStyle: { color: nextTitleColor },\n dotsTouchable,\n ...(dotColor\n ? { dotProps: { badgeStyle: { backgroundColor: dotColor } } }\n : {}),\n ...(dotActiveColor\n ? { dotActiveStyle: { backgroundColor: dotActiveColor } }\n : {}),\n }}\n >\n {children}\n </SwiperComponent>\n </View>\n);\n\nexport default Swiper;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["FAB.
|
|
1
|
+
{"version":3,"sources":["FAB.ts"],"names":["COMPONENT_TYPES","createIconProp","createColorProp","GROUPS","createBoolProp","createIconSizeProp","createActionProp","Triggers","SEED_DATA","name","tag","category","button","description","layout","triggers","OnPress","props","onPress","disabled","label","group","basic","loading","iconName","defaultValue","iconColor","bgColor","size"],"mappings":"AAAA,SACEA,eADF,EAEEC,cAFF,EAGEC,eAHF,EAIEC,MAJ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zBnB;AAPgB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n createIconProp,\n createColorProp,\n GROUPS,\n createBoolProp,\n createIconSizeProp,\n createActionProp,\n Triggers,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"FAB\",\n tag: \"FAB\",\n category: COMPONENT_TYPES.button,\n description: \"A mini round icon FAB\",\n layout: {},\n triggers: [Triggers.OnPress],\n props: {\n onPress: createActionProp(),\n disabled: createBoolProp({\n label: \"Disabled\",\n group: GROUPS.basic,\n }),\n loading: createBoolProp({\n label: \"Loading\",\n group: GROUPS.basic,\n }),\n iconName: createIconProp({\n label: \"Icon\",\n defaultValue: null,\n group: GROUPS.basic,\n }),\n iconColor: createColorProp({\n label: \"Icon color\",\n defaultValue: null,\n group: GROUPS.basic,\n }),\n bgColor: createColorProp({\n label: \"Background color\",\n defaultValue: null,\n group: GROUPS.basic,\n }),\n size: createIconSizeProp(),\n },\n};\n"]}
|
|
@@ -70,11 +70,11 @@ export const SEED_DATA = {
|
|
|
70
70
|
}),
|
|
71
71
|
color2: createColorProp({
|
|
72
72
|
label: "Color 2",
|
|
73
|
-
defaultValue: "
|
|
73
|
+
defaultValue: "secondary"
|
|
74
74
|
}),
|
|
75
75
|
color1: createColorProp({
|
|
76
76
|
label: "Color 1",
|
|
77
|
-
defaultValue: "
|
|
77
|
+
defaultValue: "primary"
|
|
78
78
|
})
|
|
79
79
|
}
|
|
80
80
|
};
|
|
@@ -1 +1 @@
|
|
|
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,IAA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Content":["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: \"
|
|
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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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
|
@@ -60,4 +60,18 @@ export function applyStyles(baseStyles, stylesToApply) {
|
|
|
60
60
|
|
|
61
61
|
return flattenedStyles;
|
|
62
62
|
}
|
|
63
|
+
export function getRealValue(value) {
|
|
64
|
+
// console.log("getRealValue typeof", typeof value);
|
|
65
|
+
// console.log("getRealValue value", value);
|
|
66
|
+
switch (typeof value) {
|
|
67
|
+
case "string":
|
|
68
|
+
return value;
|
|
69
|
+
|
|
70
|
+
case "number":
|
|
71
|
+
return String(value);
|
|
72
|
+
|
|
73
|
+
default:
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
63
77
|
//# 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,MAaFd,UAAU,CAACe,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,GAAGpB,UAAU,CAACe,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","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\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"]}
|
|
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","getRealValue","String","undefined"],"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,MAaFd,UAAU,CAACe,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,GAAGpB,UAAU,CAACe,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,YAAT,CAAsBH,KAAtB,EAAkC;AACvC;AACA;AACA,UAAQ,OAAOA,KAAf;AACE,SAAK,QAAL;AACE,aAAOA,KAAP;;AACF,SAAK,QAAL;AACE,aAAOI,MAAM,CAACJ,KAAD,CAAb;;AACF;AACE,aAAOK,SAAP;AANJ;AAQD","sourcesContent":["import { StyleSheet, StyleProp, TextStyle } from \"react-native\";\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 getRealValue(value: any) {\n // console.log(\"getRealValue typeof\", typeof value);\n // console.log(\"getRealValue value\", value);\n switch (typeof value) {\n case \"string\":\n return value;\n case \"number\":\n return String(value);\n default:\n return undefined;\n }\n}\n"]}
|
|
@@ -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 getRealValue(value: any): string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "43.4.
|
|
3
|
+
"version": "43.4.5-958f08.1+958f0845",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
]
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "958f08459dc0f48d20fb89fa7b9607837796c151"
|
|
84
84
|
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import Config from "../Config";
|
|
3
3
|
import IconButton from "../IconButton";
|
|
4
|
+
import { getRealValue } 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 = getRealValue(value);
|
|
9
|
+
const realContextValue = getRealValue(contextValue);
|
|
10
|
+
const isSelected = selected ??
|
|
11
|
+
(realContextValue && realValue && realContextValue === realValue);
|
|
7
12
|
const handlePress = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
onValueChange(
|
|
13
|
+
if (realValue) {
|
|
14
|
+
onPress?.(realValue);
|
|
15
|
+
onValueChange?.(realValue);
|
|
11
16
|
}
|
|
12
17
|
};
|
|
13
|
-
const isSelected = selected || (contextValue != null && contextValue === value);
|
|
14
18
|
return (React.createElement(IconButton, { Icon: Icon, icon: isSelected ? selectedIcon : unselectedIcon, color: isSelected ? color : unselectedColor, disabled: disabled, onPress: handlePress, size: size, style: style, ...rest }));
|
|
15
19
|
};
|
|
16
20
|
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 { getRealValue } from "../../utilities";
|
|
6
7
|
import { useRadioButtonGroupContext } from "./context";
|
|
7
8
|
|
|
8
9
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -13,7 +14,7 @@ export type RadioButtonProps = {
|
|
|
13
14
|
color?: string;
|
|
14
15
|
value?: string;
|
|
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;
|
|
@@ -27,7 +28,7 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
27
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,19 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
36
37
|
}) => {
|
|
37
38
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
38
39
|
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const realValue = getRealValue(value);
|
|
41
|
+
const realContextValue = getRealValue(contextValue);
|
|
42
|
+
const isSelected =
|
|
43
|
+
selected ??
|
|
44
|
+
(realContextValue && realValue && realContextValue === realValue);
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
const handlePress = () => {
|
|
47
|
+
if (realValue) {
|
|
48
|
+
onPress?.(realValue);
|
|
49
|
+
onValueChange?.(realValue);
|
|
44
50
|
}
|
|
45
51
|
};
|
|
46
52
|
|
|
47
|
-
const isSelected =
|
|
48
|
-
selected || (contextValue != null && contextValue === value);
|
|
49
|
-
|
|
50
53
|
return (
|
|
51
54
|
<IconButton
|
|
52
55
|
Icon={Icon}
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
+
import { getRealValue } from "../../utilities";
|
|
3
4
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
4
5
|
const { Provider } = radioButtonGroupContext;
|
|
5
|
-
const RadioButtonGroup = ({ direction = Direction.Vertical, value, onValueChange
|
|
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
|
-
|
|
9
|
+
const realValue = getRealValue(value);
|
|
10
|
+
if (realValue) {
|
|
11
|
+
setInternalValue(realValue);
|
|
10
12
|
}
|
|
11
13
|
}, [value]);
|
|
12
14
|
React.useEffect(() => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const realDefaultValue = getRealValue(defaultValue);
|
|
16
|
+
if (realDefaultValue) {
|
|
17
|
+
setInternalValue(realDefaultValue);
|
|
15
18
|
}
|
|
16
19
|
}, [defaultValue]);
|
|
17
20
|
const handleValueChange = (newValue) => {
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
const realNewValue = getRealValue(newValue);
|
|
22
|
+
if (realNewValue) {
|
|
23
|
+
setInternalValue(newValue);
|
|
24
|
+
onValueChange?.(newValue);
|
|
25
|
+
}
|
|
20
26
|
};
|
|
21
27
|
const _containerStyle = [
|
|
22
28
|
{
|
|
@@ -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 { getRealValue } from "../../utilities";
|
|
4
5
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
5
6
|
export interface RadioButtonGroupProps {
|
|
6
7
|
direction?: Direction;
|
|
7
8
|
style?: StyleProp<ViewStyle>;
|
|
8
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
|
}
|
|
@@ -17,31 +18,39 @@ const { Provider } = radioButtonGroupContext;
|
|
|
17
18
|
const RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({
|
|
18
19
|
direction = Direction.Vertical,
|
|
19
20
|
value,
|
|
20
|
-
onValueChange
|
|
21
|
+
onValueChange,
|
|
21
22
|
defaultValue,
|
|
22
23
|
style,
|
|
23
24
|
children,
|
|
24
25
|
...rest
|
|
25
26
|
}) => {
|
|
26
|
-
const [internalValue, setInternalValue] = React.useState<
|
|
27
|
-
|
|
28
|
-
);
|
|
27
|
+
const [internalValue, setInternalValue] = React.useState<
|
|
28
|
+
string | undefined
|
|
29
|
+
>();
|
|
29
30
|
|
|
30
31
|
React.useEffect(() => {
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const realValue = getRealValue(value);
|
|
33
|
+
|
|
34
|
+
if (realValue) {
|
|
35
|
+
setInternalValue(realValue);
|
|
33
36
|
}
|
|
34
37
|
}, [value]);
|
|
35
38
|
|
|
36
39
|
React.useEffect(() => {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
const realDefaultValue = getRealValue(defaultValue);
|
|
41
|
+
|
|
42
|
+
if (realDefaultValue) {
|
|
43
|
+
setInternalValue(realDefaultValue);
|
|
39
44
|
}
|
|
40
45
|
}, [defaultValue]);
|
|
41
46
|
|
|
42
|
-
const handleValueChange = (newValue:
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
const handleValueChange = (newValue: any) => {
|
|
48
|
+
const realNewValue = getRealValue(newValue);
|
|
49
|
+
|
|
50
|
+
if (realNewValue) {
|
|
51
|
+
setInternalValue(newValue);
|
|
52
|
+
onValueChange?.(newValue);
|
|
53
|
+
}
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
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, getRealValue } from "../../utilities";
|
|
9
9
|
export var Direction;
|
|
10
10
|
(function (Direction) {
|
|
11
11
|
Direction["Row"] = "row";
|
|
@@ -22,19 +22,25 @@ const getRadioButtonAlignment = (parentDirection, direction) => {
|
|
|
22
22
|
return "flex-end";
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
const renderLabel = (
|
|
26
|
-
if (typeof
|
|
27
|
-
return React.createElement(Text, { style: [labelStyle, textStyle] },
|
|
25
|
+
const renderLabel = (label, labelStyle, textStyle) => {
|
|
26
|
+
if (typeof label === "string") {
|
|
27
|
+
return React.createElement(Text, { style: [labelStyle, textStyle] }, label);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
return React.createElement(React.Fragment, null,
|
|
30
|
+
return React.createElement(React.Fragment, null, label);
|
|
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 = getRealValue(value);
|
|
36
|
+
const realContextValue = getRealValue(contextValue);
|
|
37
|
+
const isSelected = selected ??
|
|
38
|
+
(realContextValue && realValue && realContextValue === realValue);
|
|
35
39
|
const handlePress = () => {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
if (realValue) {
|
|
41
|
+
onPress?.(realValue);
|
|
42
|
+
onValueChange?.(realValue);
|
|
43
|
+
}
|
|
38
44
|
};
|
|
39
45
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
40
46
|
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
@@ -49,7 +55,7 @@ const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress =
|
|
|
49
55
|
flex: 1,
|
|
50
56
|
alignItems: getRadioButtonAlignment(parentDirection, direction),
|
|
51
57
|
} },
|
|
52
|
-
React.createElement(RadioButton, { Icon: Icon, selected:
|
|
58
|
+
React.createElement(RadioButton, { Icon: Icon, selected: isSelected ? true : false, value: realValue, color: color, unselectedColor: unselectedColor, style: radioButtonStyle }))));
|
|
53
59
|
};
|
|
54
60
|
const styles = StyleSheet.create({
|
|
55
61
|
mainParent: {
|