@draftbit/core 43.4.5-d442fc.1 → 43.4.6-5320f5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Checkbox/CheckboxGroup.js +17 -5
- package/lib/commonjs/components/Checkbox/CheckboxGroup.js.map +1 -1
- package/lib/commonjs/components/DeprecatedCardWrapper.js +14 -2
- package/lib/commonjs/components/DeprecatedCardWrapper.js.map +1 -1
- package/lib/commonjs/components/Elevation.js +3 -14
- package/lib/commonjs/components/Elevation.js.map +1 -1
- package/lib/commonjs/components/FAB.js +19 -5
- package/lib/commonjs/components/FAB.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +30 -10
- package/lib/commonjs/components/Picker/PickerComponent.ios.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 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/CheckboxRow.js +1 -1
- package/lib/commonjs/mappings/CheckboxRow.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
- package/lib/commonjs/mappings/Slider.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 +28 -17
- 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/CheckboxRow.js +1 -1
- package/lib/module/mappings/CheckboxRow.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 -4
- 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/mappings/CheckboxRow.js +1 -1
- package/src/mappings/CheckboxRow.ts +1 -1
- package/src/utilities.js +12 -0
- package/src/utilities.ts +11 -0
- package/lib/commonjs/components/TabView/TabView.js +0 -103
- package/lib/commonjs/components/TabView/TabView.js.map +0 -1
- package/lib/commonjs/components/TabView/TabViewItem.js +0 -27
- package/lib/commonjs/components/TabView/TabViewItem.js.map +0 -1
- package/lib/commonjs/components/TabView/index.js +0 -24
- package/lib/commonjs/components/TabView/index.js.map +0 -1
- package/lib/commonjs/mappings/TabView.js +0 -80
- package/lib/commonjs/mappings/TabView.js.map +0 -1
- package/lib/module/components/TabView/TabView.js +0 -88
- package/lib/module/components/TabView/TabView.js.map +0 -1
- package/lib/module/components/TabView/TabViewItem.js +0 -19
- package/lib/module/components/TabView/TabViewItem.js.map +0 -1
- package/lib/module/components/TabView/index.js +0 -3
- package/lib/module/components/TabView/index.js.map +0 -1
- package/lib/module/mappings/TabView.js +0 -71
- package/lib/module/mappings/TabView.js.map +0 -1
- package/lib/typescript/src/components/TabView/TabView.d.ts +0 -19
- package/lib/typescript/src/components/TabView/TabViewItem.d.ts +0 -10
- package/lib/typescript/src/components/TabView/index.d.ts +0 -2
- package/lib/typescript/src/mappings/TabView.d.ts +0 -111
- package/src/components/TabView/TabView.js +0 -33
- package/src/components/TabView/TabView.tsx +0 -97
- package/src/components/TabView/TabViewItem.js +0 -5
- package/src/components/TabView/TabViewItem.tsx +0 -21
- package/src/components/TabView/index.js +0 -2
- package/src/components/TabView/index.ts +0 -2
- package/src/mappings/TabView.js +0 -73
- package/src/mappings/TabView.ts +0 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CheckboxRow.ts"],"names":["createTextProp","createTextStyle","createRowDirectionProp","createFieldNameProp","COMPONENT_TYPES","Triggers","createColorProp","SEED_DATA","name","tag","category","input","layout","minHeight","triggers","OnPress","props","label","description","required","defaultValue","labelStyle","editable","direction","fieldName","valuePropName","handlerPropName","color","uncheckedColor"],"mappings":"AAAA,SACEA,cADF,EAEEC,eAFF,EAGEC,sBAHF,EAIEC,mBAJF,EAKEC,eALF,EAMEC,QANF,EAOEC,eAPF,QAQO,iBARP;AAUA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,cADiB;AAEvBC,EAAAA,GAAG,EAAE,aAFkB;AAGvBC,EAAAA,QAAQ,EAAEN,eAAe,CAACO,KAHH;AAIvBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,SAAS,EAAE;AADL,GAJe;AAOvBC,EAAAA,QAAQ,EAAE,CAACT,QAAQ,CAACU,OAAV,CAPa;AAQvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAEjB,cAAc,CAAC;AACpBiB,MAAAA,KAAK,EAAE,OADa;AAEpBC,MAAAA,WAAW,EAAE,iCAFO;AAGpBC,MAAAA,QAAQ,EAAE,IAHU;AAIpBC,MAAAA,YAAY,EAAE;AAJM,KAAD,CADhB;AAOLC,IAAAA,UAAU,EAAEpB,eAAe,CAAC;AAC1BgB,MAAAA,KAAK,EAAE,aADmB;AAE1BC,MAAAA,WAAW,EAAE,gCAFa;AAG1BC,MAAAA,QAAQ,EAAE,KAHgB;AAI1BG,MAAAA,QAAQ,EAAE;AAJgB,KAAD,CAPtB;AAaLC,IAAAA,SAAS,EAAErB,sBAAsB,EAb5B;AAcLsB,IAAAA,SAAS,EAAErB,mBAAmB,CAAC;AAC7BiB,MAAAA,YAAY,EAAE,
|
|
1
|
+
{"version":3,"sources":["CheckboxRow.ts"],"names":["createTextProp","createTextStyle","createRowDirectionProp","createFieldNameProp","COMPONENT_TYPES","Triggers","createColorProp","SEED_DATA","name","tag","category","input","layout","minHeight","triggers","OnPress","props","label","description","required","defaultValue","labelStyle","editable","direction","fieldName","valuePropName","handlerPropName","color","uncheckedColor"],"mappings":"AAAA,SACEA,cADF,EAEEC,eAFF,EAGEC,sBAHF,EAIEC,mBAJF,EAKEC,eALF,EAMEC,QANF,EAOEC,eAPF,QAQO,iBARP;AAUA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,cADiB;AAEvBC,EAAAA,GAAG,EAAE,aAFkB;AAGvBC,EAAAA,QAAQ,EAAEN,eAAe,CAACO,KAHH;AAIvBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,SAAS,EAAE;AADL,GAJe;AAOvBC,EAAAA,QAAQ,EAAE,CAACT,QAAQ,CAACU,OAAV,CAPa;AAQvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,KAAK,EAAEjB,cAAc,CAAC;AACpBiB,MAAAA,KAAK,EAAE,OADa;AAEpBC,MAAAA,WAAW,EAAE,iCAFO;AAGpBC,MAAAA,QAAQ,EAAE,IAHU;AAIpBC,MAAAA,YAAY,EAAE;AAJM,KAAD,CADhB;AAOLC,IAAAA,UAAU,EAAEpB,eAAe,CAAC;AAC1BgB,MAAAA,KAAK,EAAE,aADmB;AAE1BC,MAAAA,WAAW,EAAE,gCAFa;AAG1BC,MAAAA,QAAQ,EAAE,KAHgB;AAI1BG,MAAAA,QAAQ,EAAE;AAJgB,KAAD,CAPtB;AAaLC,IAAAA,SAAS,EAAErB,sBAAsB,EAb5B;AAcLsB,IAAAA,SAAS,EAAErB,mBAAmB,CAAC;AAC7BiB,MAAAA,YAAY,EAAE,kBADe;AAE7BK,MAAAA,aAAa,EAAE,OAFc;AAG7BC,MAAAA,eAAe,EAAE;AAHY,KAAD,CAdzB;AAmBLC,IAAAA,KAAK,EAAErB,eAAe,CAAC;AACrBY,MAAAA,WAAW,EAAE;AADQ,KAAD,CAnBjB;AAsBLU,IAAAA,cAAc,EAAEtB,eAAe,CAAC;AAC9BW,MAAAA,KAAK,EAAE,kBADuB;AAE9BC,MAAAA,WAAW,EAAE;AAFiB,KAAD;AAtB1B;AARgB,CAAlB","sourcesContent":["import {\n createTextProp,\n createTextStyle,\n createRowDirectionProp,\n createFieldNameProp,\n COMPONENT_TYPES,\n Triggers,\n createColorProp,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Checkbox Row\",\n tag: \"CheckboxRow\",\n category: COMPONENT_TYPES.input,\n layout: {\n minHeight: 50,\n },\n triggers: [Triggers.OnPress],\n props: {\n label: createTextProp({\n label: \"Label\",\n description: \"Label to show with the checkbox\",\n required: true,\n defaultValue: \"First Option\",\n }),\n labelStyle: createTextStyle({\n label: \"Label Style\",\n description: \"Change the styles of the label\",\n required: false,\n editable: false,\n }),\n direction: createRowDirectionProp(),\n fieldName: createFieldNameProp({\n defaultValue: \"checkboxRowValue\",\n valuePropName: \"value\",\n handlerPropName: \"onPress\",\n }),\n color: createColorProp({\n description: \"Color for the button (used when the checkbox is checked)\",\n }),\n uncheckedColor: createColorProp({\n label: \"Unselected Color\",\n description: \"Color for the button when the checkbox is unchecked\",\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>;
|
|
@@ -27,7 +27,6 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
27
27
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
28
28
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
29
29
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
30
|
-
export { TabView, TabViewItem } from "./components/TabView";
|
|
31
30
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
32
31
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
33
32
|
export { default as Button } from "./components/DeprecatedButton";
|
|
@@ -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.
|
|
3
|
+
"version": "43.4.6-5320f5.0+5320f59e",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -54,8 +54,6 @@
|
|
|
54
54
|
"lodash.omit": "^4.5.0",
|
|
55
55
|
"lodash.tonumber": "^4.0.3",
|
|
56
56
|
"react-native-modal-datetime-picker": "^13.0.0",
|
|
57
|
-
"react-native-pager-view": "^5.4.9",
|
|
58
|
-
"react-native-tab-view": "^3.1.1",
|
|
59
57
|
"react-native-typography": "^1.4.1",
|
|
60
58
|
"react-native-web-swiper": "^2.2.1"
|
|
61
59
|
},
|
|
@@ -82,5 +80,5 @@
|
|
|
82
80
|
]
|
|
83
81
|
]
|
|
84
82
|
},
|
|
85
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "5320f59e438f243322330aff344115c2e9eab3b9"
|
|
86
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: {
|
|
@@ -13,7 +13,7 @@ import { useRadioButtonGroupContext } from "./context";
|
|
|
13
13
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
14
14
|
import { Direction as GroupDirection } from "./context";
|
|
15
15
|
import Touchable from "../Touchable";
|
|
16
|
-
import { extractStyles } from "../../utilities";
|
|
16
|
+
import { extractStyles, getValueForRadioButton } from "../../utilities";
|
|
17
17
|
|
|
18
18
|
export enum Direction {
|
|
19
19
|
Row = "row",
|
|
@@ -22,7 +22,7 @@ export enum Direction {
|
|
|
22
22
|
|
|
23
23
|
export interface RadioButtonRowProps extends Omit<RadioButtonProps, "onPress"> {
|
|
24
24
|
label: string | React.ReactNode;
|
|
25
|
-
value: string; // A string that this radio button row represents when selected
|
|
25
|
+
value: string | number; // A string (or number that will be parsed String(number)) that this radio button row represents when selected
|
|
26
26
|
color?: string;
|
|
27
27
|
unselectedColor?: string;
|
|
28
28
|
labelContainerStyle: StyleProp<ViewStyle>;
|
|
@@ -60,10 +60,10 @@ const renderLabel = (
|
|
|
60
60
|
const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
61
61
|
Icon,
|
|
62
62
|
label,
|
|
63
|
-
value,
|
|
63
|
+
value = "",
|
|
64
64
|
color,
|
|
65
65
|
unselectedColor,
|
|
66
|
-
onPress
|
|
66
|
+
onPress,
|
|
67
67
|
labelContainerStyle,
|
|
68
68
|
labelStyle,
|
|
69
69
|
radioButtonStyle,
|
|
@@ -79,9 +79,13 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
|
79
79
|
direction: parentDirection,
|
|
80
80
|
} = useRadioButtonGroupContext();
|
|
81
81
|
|
|
82
|
+
const realValue = getValueForRadioButton(value);
|
|
83
|
+
const realContextValue = getValueForRadioButton(contextValue);
|
|
84
|
+
const isSelected = selected ?? realContextValue === realValue;
|
|
85
|
+
|
|
82
86
|
const handlePress = () => {
|
|
83
|
-
onPress(
|
|
84
|
-
onValueChange
|
|
87
|
+
onPress?.(realValue);
|
|
88
|
+
onValueChange?.(realValue);
|
|
85
89
|
};
|
|
86
90
|
|
|
87
91
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
@@ -112,12 +116,10 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
|
112
116
|
>
|
|
113
117
|
<RadioButton
|
|
114
118
|
Icon={Icon}
|
|
115
|
-
selected={
|
|
116
|
-
|
|
117
|
-
}
|
|
119
|
+
selected={isSelected}
|
|
120
|
+
value={realValue}
|
|
118
121
|
color={color}
|
|
119
122
|
unselectedColor={unselectedColor}
|
|
120
|
-
onPress={handlePress}
|
|
121
123
|
style={radioButtonStyle}
|
|
122
124
|
/>
|
|
123
125
|
</View>
|
package/src/index.js
CHANGED
|
@@ -27,7 +27,6 @@ export { default as Touchable } from "./components/Touchable";
|
|
|
27
27
|
export { AccordionGroup, AccordionItem } from "./components/Accordion";
|
|
28
28
|
export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/ActionSheet";
|
|
29
29
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
30
|
-
export { TabView, TabViewItem } from "./components/TabView";
|
|
31
30
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
32
31
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
33
32
|
/* Deprecated: Fix or Delete! */
|
package/src/index.tsx
CHANGED
package/src/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 { color, fontFamily, fontWeight, fontSize, lineHeight, letterSpacing, textTransform, textAlign, textDecorationLine, textDecorationColor, textDecorationStyle, ...viewStyles } = StyleSheet.flatten(style || {});
|
|
4
5
|
const textStyles = {
|
|
@@ -40,3 +41,14 @@ export function applyStyles(baseStyles, stylesToApply) {
|
|
|
40
41
|
}
|
|
41
42
|
return flattenedStyles;
|
|
42
43
|
}
|
|
44
|
+
export function getValueForRadioButton(value) {
|
|
45
|
+
if (isString(value)) {
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
else if (isNumber(value)) {
|
|
49
|
+
return String(value);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
throw new Error(`Invalid value: ${value}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/utilities.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StyleSheet, StyleProp, TextStyle } from "react-native";
|
|
2
|
+
import { isString, isNumber } from "lodash";
|
|
2
3
|
|
|
3
4
|
export function extractStyles(style: StyleProp<any>) {
|
|
4
5
|
const {
|
|
@@ -63,3 +64,13 @@ export function applyStyles(
|
|
|
63
64
|
|
|
64
65
|
return flattenedStyles;
|
|
65
66
|
}
|
|
67
|
+
|
|
68
|
+
export function getValueForRadioButton(value: string | number) {
|
|
69
|
+
if (isString(value)) {
|
|
70
|
+
return value;
|
|
71
|
+
} else if (isNumber(value)) {
|
|
72
|
+
return String(value);
|
|
73
|
+
} else {
|
|
74
|
+
throw new Error(`Invalid value: ${value}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var React = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _reactNativeTabView = require("react-native-tab-view");
|
|
11
|
-
|
|
12
|
-
var _TabViewItem = _interopRequireDefault(require("./TabViewItem"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
21
|
-
|
|
22
|
-
const TabViewComponent = _ref => {
|
|
23
|
-
let {
|
|
24
|
-
Icon,
|
|
25
|
-
tabBarPosition,
|
|
26
|
-
keyboardDismissMode,
|
|
27
|
-
swipeEnabled,
|
|
28
|
-
scrollEnabled,
|
|
29
|
-
activeColor,
|
|
30
|
-
inactiveColor,
|
|
31
|
-
pressColor,
|
|
32
|
-
indicatorColor,
|
|
33
|
-
style,
|
|
34
|
-
children
|
|
35
|
-
} = _ref;
|
|
36
|
-
const [index, setIndex] = React.useState(0);
|
|
37
|
-
const [routes, setRoutes] = React.useState([]);
|
|
38
|
-
const [tabScenes, setTabScenes] = React.useState({});
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
const newRoutes = [];
|
|
41
|
-
const scenes = {};
|
|
42
|
-
React.Children.toArray(children).filter(child => child.type === _TabViewItem.default).forEach(child => {
|
|
43
|
-
var _child$props;
|
|
44
|
-
|
|
45
|
-
if (child !== null && child !== void 0 && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.id) {
|
|
46
|
-
var _child$props2, _child$props3;
|
|
47
|
-
|
|
48
|
-
newRoutes.push({
|
|
49
|
-
key: child === null || child === void 0 ? void 0 : (_child$props2 = child.props) === null || _child$props2 === void 0 ? void 0 : _child$props2.id,
|
|
50
|
-
...(child === null || child === void 0 ? void 0 : child.props)
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
scenes[child === null || child === void 0 ? void 0 : (_child$props3 = child.props) === null || _child$props3 === void 0 ? void 0 : _child$props3.id] = () => child;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
setRoutes(newRoutes);
|
|
57
|
-
setTabScenes(scenes);
|
|
58
|
-
}, [children]);
|
|
59
|
-
|
|
60
|
-
const indexChangeHandler = i => setIndex(i);
|
|
61
|
-
|
|
62
|
-
const renderTabBar = props => {
|
|
63
|
-
console.log(props);
|
|
64
|
-
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabBar, _extends({}, props, {
|
|
65
|
-
activeColor: activeColor,
|
|
66
|
-
inactiveColor: inactiveColor,
|
|
67
|
-
pressColor: pressColor,
|
|
68
|
-
scrollEnabled: scrollEnabled,
|
|
69
|
-
indicatorStyle: {
|
|
70
|
-
backgroundColor: indicatorColor
|
|
71
|
-
},
|
|
72
|
-
renderIcon: _ref2 => {
|
|
73
|
-
let {
|
|
74
|
-
route,
|
|
75
|
-
color
|
|
76
|
-
} = _ref2;
|
|
77
|
-
return route !== null && route !== void 0 && route.icon ? /*#__PURE__*/React.createElement(Icon, {
|
|
78
|
-
name: route.icon,
|
|
79
|
-
color: color,
|
|
80
|
-
size: 36
|
|
81
|
-
}) : null;
|
|
82
|
-
},
|
|
83
|
-
style: style
|
|
84
|
-
}));
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return /*#__PURE__*/React.createElement(_reactNativeTabView.TabView, {
|
|
88
|
-
navigationState: {
|
|
89
|
-
index,
|
|
90
|
-
routes
|
|
91
|
-
},
|
|
92
|
-
renderScene: (0, _reactNativeTabView.SceneMap)(tabScenes),
|
|
93
|
-
renderTabBar: renderTabBar,
|
|
94
|
-
onIndexChange: indexChangeHandler,
|
|
95
|
-
tabBarPosition: tabBarPosition,
|
|
96
|
-
keyboardDismissMode: keyboardDismissMode,
|
|
97
|
-
swipeEnabled: swipeEnabled
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
var _default = TabViewComponent;
|
|
102
|
-
exports.default = _default;
|
|
103
|
-
//# sourceMappingURL=TabView.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["TabView.tsx"],"names":["TabViewComponent","Icon","tabBarPosition","keyboardDismissMode","swipeEnabled","scrollEnabled","activeColor","inactiveColor","pressColor","indicatorColor","style","children","index","setIndex","React","useState","routes","setRoutes","tabScenes","setTabScenes","useEffect","newRoutes","scenes","Children","toArray","filter","child","type","TabViewItem","forEach","props","id","push","key","indexChangeHandler","i","renderTabBar","console","log","backgroundColor","route","color","icon"],"mappings":"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","sourcesContent":["import * as React from \"react\";\nimport { StyleProp, TextStyle, ViewStyle } from \"react-native\";\nimport { TabView, TabBar, SceneMap } from \"react-native-tab-view\";\n\n// import { withTheme } from \"../../theming\";\nimport TabViewItem from \"./TabViewItem\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\ntype TabBarPosition = \"top\" | \"bottom\";\ntype KeyboardDismissMode = \"none\" | \"auto\" | \"on-drag\";\n\ntype TabViewProps = {\n tabBarPosition?: TabBarPosition;\n keyboardDismissMode?: KeyboardDismissMode;\n swipeEnabled?: boolean;\n scrollEnabled?: boolean;\n activeColor?: string;\n inactiveColor?: string;\n pressColor?: string;\n indicatorColor?: string;\n style?: StyleProp<TextStyle | ViewStyle>;\n children: React.ReactNode;\n} & IconSlot;\n\nconst TabViewComponent = ({\n Icon,\n tabBarPosition,\n keyboardDismissMode,\n swipeEnabled,\n scrollEnabled,\n activeColor,\n inactiveColor,\n pressColor,\n indicatorColor,\n style,\n children,\n}: TabViewProps) => {\n const [index, setIndex] = React.useState(0);\n const [routes, setRoutes] = React.useState([]);\n const [tabScenes, setTabScenes] = React.useState({});\n\n React.useEffect(() => {\n const newRoutes: any = [];\n const scenes: any = {};\n\n React.Children.toArray(children)\n .filter((child: any) => child.type === TabViewItem)\n .forEach((child: any) => {\n if (child?.props?.id) {\n newRoutes.push({\n key: child?.props?.id,\n ...child?.props,\n });\n scenes[child?.props?.id] = () => child;\n }\n });\n\n setRoutes(newRoutes);\n setTabScenes(scenes);\n }, [children]);\n\n const indexChangeHandler = (i: any) => setIndex(i);\n\n const renderTabBar = (props: any) => {\n console.log(props);\n return (\n <TabBar\n {...props}\n activeColor={activeColor}\n inactiveColor={inactiveColor}\n pressColor={pressColor}\n scrollEnabled={scrollEnabled}\n indicatorStyle={{ backgroundColor: indicatorColor }}\n renderIcon={({ route, color }) =>\n route?.icon ? (\n <Icon name={route.icon} color={color} size={36} />\n ) : null\n }\n style={style}\n />\n );\n };\n\n return (\n <TabView\n navigationState={{ index, routes }}\n renderScene={SceneMap(tabScenes)}\n renderTabBar={renderTabBar}\n onIndexChange={indexChangeHandler}\n tabBarPosition={tabBarPosition}\n keyboardDismissMode={keyboardDismissMode}\n swipeEnabled={swipeEnabled}\n />\n );\n};\n\nexport default TabViewComponent;\n"]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
const TabViewItem = _ref => {
|
|
9
|
-
let {
|
|
10
|
-
title,
|
|
11
|
-
id,
|
|
12
|
-
icon,
|
|
13
|
-
children,
|
|
14
|
-
accessibilityLabel
|
|
15
|
-
} = _ref;
|
|
16
|
-
console.log({
|
|
17
|
-
title,
|
|
18
|
-
id,
|
|
19
|
-
icon,
|
|
20
|
-
accessibilityLabel
|
|
21
|
-
});
|
|
22
|
-
return children;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var _default = TabViewItem;
|
|
26
|
-
exports.default = _default;
|
|
27
|
-
//# sourceMappingURL=TabViewItem.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["TabViewItem.tsx"],"names":["TabViewItem","title","id","icon","children","accessibilityLabel","console","log"],"mappings":";;;;;;;AASA,MAAMA,WAAW,GAAG,QAMI;AAAA,MANH;AACnBC,IAAAA,KADmB;AAEnBC,IAAAA,EAFmB;AAGnBC,IAAAA,IAHmB;AAInBC,IAAAA,QAJmB;AAKnBC,IAAAA;AALmB,GAMG;AACtBC,EAAAA,OAAO,CAACC,GAAR,CAAY;AAAEN,IAAAA,KAAF;AAASC,IAAAA,EAAT;AAAaC,IAAAA,IAAb;AAAmBE,IAAAA;AAAnB,GAAZ;AACA,SAAOD,QAAP;AACD,CATD;;eAWeJ,W","sourcesContent":["import React from \"react\";\ninterface TabViewItemProps {\n title: string;\n id: string;\n icon: string;\n accessibilityLabel: string;\n children: React.ReactNode;\n}\n\nconst TabViewItem = ({\n title,\n id,\n icon,\n children,\n accessibilityLabel,\n}: TabViewItemProps) => {\n console.log({ title, id, icon, accessibilityLabel });\n return children;\n};\n\nexport default TabViewItem;\n"]}
|