@draftbit/core 44.1.12-e30b54.2 → 44.1.13-2d7ff5.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/Provider.js.map +1 -1
- package/lib/commonjs/components/Accordion/AccordionItem.js +21 -5
- package/lib/commonjs/components/Accordion/AccordionItem.js.map +1 -1
- package/lib/commonjs/components/Picker/Picker.js +53 -49
- package/lib/commonjs/components/Picker/Picker.js.map +1 -1
- package/lib/commonjs/components/Picker/PickerComponent.android.js +59 -0
- package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js +92 -0
- package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js +59 -0
- package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/commonjs/components/RowHeadlineImageIcon.js.map +1 -1
- package/lib/commonjs/components/Typography.js.map +1 -1
- package/lib/commonjs/mappings/CircleImage.js.map +1 -1
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js +1 -1
- package/lib/commonjs/mappings/KeyboardAwareScrollView.js.map +1 -1
- package/lib/commonjs/mappings/RowHeadlineImageCaption.js.map +1 -1
- package/lib/commonjs/mappings/SafeAreaView.js.map +1 -1
- package/lib/commonjs/mappings/TextArea.js.map +1 -1
- package/lib/module/components/Justification.js +1 -1
- package/lib/module/components/Picker/Picker.js +55 -49
- package/lib/module/components/Picker/Picker.js.map +1 -1
- package/lib/module/components/Picker/PickerComponent.android.js +41 -0
- package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.ios.js +69 -0
- package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -0
- package/lib/module/components/Picker/PickerComponent.web.js +41 -0
- package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
- package/lib/module/constants.js.map +1 -1
- package/lib/module/mappings/Banner.js.map +1 -1
- package/lib/module/mappings/KeyboardAwareScrollView.js +1 -1
- package/lib/module/mappings/KeyboardAwareScrollView.js.map +1 -1
- package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
- package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +13 -0
- package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
- package/package.json +3 -3
- package/src/components/Picker/Picker.js +40 -20
- package/src/components/Picker/Picker.tsx +56 -18
- package/src/components/Picker/PickerComponent.android.js +20 -0
- package/src/components/Picker/PickerComponent.android.tsx +59 -0
- package/src/components/Picker/PickerComponent.ios.js +43 -0
- package/src/components/Picker/PickerComponent.ios.tsx +89 -0
- package/src/components/Picker/PickerComponent.web.js +20 -0
- package/src/components/Picker/PickerComponent.web.tsx +59 -0
- package/src/mappings/KeyboardAwareScrollView.js +1 -1
- package/src/mappings/KeyboardAwareScrollView.ts +1 -1
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { View, StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
5
|
+
import Portal from "../Portal/Portal";
|
|
6
|
+
import Button from "../DeprecatedButton";
|
|
7
|
+
const {
|
|
8
|
+
width: deviceWidth,
|
|
9
|
+
height: deviceHeight
|
|
10
|
+
} = Dimensions.get("screen");
|
|
11
|
+
export const PickerComponent = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
Icon,
|
|
14
|
+
togglePickerVisible,
|
|
15
|
+
pickerOptions,
|
|
16
|
+
internalValue,
|
|
17
|
+
handleValueChange
|
|
18
|
+
} = _ref;
|
|
19
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(View, {
|
|
20
|
+
style: styles.iosPicker
|
|
21
|
+
}, /*#__PURE__*/React.createElement(SafeAreaView, {
|
|
22
|
+
style: styles.iosSafeArea
|
|
23
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
24
|
+
Icon: Icon,
|
|
25
|
+
type: "text",
|
|
26
|
+
onPress: togglePickerVisible,
|
|
27
|
+
style: styles.iosButton
|
|
28
|
+
}, "Close"), /*#__PURE__*/React.createElement(NativePicker, {
|
|
29
|
+
style: styles.iosNativePicker,
|
|
30
|
+
selectedValue: internalValue,
|
|
31
|
+
onValueChange: handleValueChange
|
|
32
|
+
}, pickerOptions.map(option => /*#__PURE__*/React.createElement(NativePicker.Item, {
|
|
33
|
+
label: option.label,
|
|
34
|
+
value: option.value,
|
|
35
|
+
key: option.value
|
|
36
|
+
}))))));
|
|
37
|
+
};
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
iosPicker: {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
bottom: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
right: 0,
|
|
44
|
+
flexDirection: "row",
|
|
45
|
+
justifyContent: "center",
|
|
46
|
+
width: deviceWidth,
|
|
47
|
+
// TODO
|
|
48
|
+
maxWidth: deviceWidth,
|
|
49
|
+
maxHeight: deviceHeight,
|
|
50
|
+
backgroundColor: "green" // TODO
|
|
51
|
+
// backgroundColor: "rgba(255, 255, 255, 1)",
|
|
52
|
+
|
|
53
|
+
},
|
|
54
|
+
iosSafeArea: {
|
|
55
|
+
backgroundColor: "yellow",
|
|
56
|
+
// backgroundColor: "white",// TODO
|
|
57
|
+
flexDirection: "column",
|
|
58
|
+
width: deviceWidth,
|
|
59
|
+
maxWidth: deviceWidth
|
|
60
|
+
},
|
|
61
|
+
iosButton: {
|
|
62
|
+
alignSelf: "flex-end"
|
|
63
|
+
},
|
|
64
|
+
iosNativePicker: {
|
|
65
|
+
//backgroundColor: "white",// TODO
|
|
66
|
+
backgroundColor: "red"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=PickerComponent.ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PickerComponent.ios.tsx"],"names":["React","View","StyleSheet","Dimensions","SafeAreaView","Picker","NativePicker","Portal","Button","width","deviceWidth","height","deviceHeight","get","PickerComponent","Icon","togglePickerVisible","pickerOptions","internalValue","handleValueChange","styles","iosPicker","iosSafeArea","iosButton","iosNativePicker","map","option","label","value","create","position","bottom","left","right","flexDirection","justifyContent","maxWidth","maxHeight","backgroundColor","alignSelf"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,EAA2BC,UAA3B,QAA6C,cAA7C;AACA,SAASC,YAAT,QAA6B,gCAA7B;AACA,SAASC,MAAM,IAAIC,YAAnB,QAAuC,6BAAvC;AAGA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AAGA,MAAM;AAAEC,EAAAA,KAAK,EAAEC,WAAT;AAAsBC,EAAAA,MAAM,EAAEC;AAA9B,IAA+CT,UAAU,CAACU,GAAX,CAAe,QAAf,CAArD;AAWA,OAAO,MAAMC,eAA+C,GAAG,QAMzD;AAAA,MAN0D;AAC9DC,IAAAA,IAD8D;AAE9DC,IAAAA,mBAF8D;AAG9DC,IAAAA,aAH8D;AAI9DC,IAAAA,aAJ8D;AAK9DC,IAAAA;AAL8D,GAM1D;AACJ,sBACE,oBAAC,MAAD,qBACE,oBAAC,IAAD;AAAM,IAAA,KAAK,EAAEC,MAAM,CAACC;AAApB,kBACE,oBAAC,YAAD;AAAc,IAAA,KAAK,EAAED,MAAM,CAACE;AAA5B,kBACE,oBAAC,MAAD;AACE,IAAA,IAAI,EAAEP,IADR;AAEE,IAAA,IAAI,EAAC,MAFP;AAGE,IAAA,OAAO,EAAEC,mBAHX;AAIE,IAAA,KAAK,EAAEI,MAAM,CAACG;AAJhB,KAMG,OANH,CADF,eAUE,oBAAC,YAAD;AACE,IAAA,KAAK,EAAEH,MAAM,CAACI,eADhB;AAEE,IAAA,aAAa,EAAEN,aAFjB;AAGE,IAAA,aAAa,EAAEC;AAHjB,KAKIF,aAAD,CAA6CQ,GAA7C,CAAkDC,MAAD,iBAChD,oBAAC,YAAD,CAAc,IAAd;AACE,IAAA,KAAK,EAAEA,MAAM,CAACC,KADhB;AAEE,IAAA,KAAK,EAAED,MAAM,CAACE,KAFhB;AAGE,IAAA,GAAG,EAAEF,MAAM,CAACE;AAHd,IADD,CALH,CAVF,CADF,CADF,CADF;AA8BD,CArCM;AAuCP,MAAMR,MAAM,GAAGlB,UAAU,CAAC2B,MAAX,CAAkB;AAC/BR,EAAAA,SAAS,EAAE;AACTS,IAAAA,QAAQ,EAAE,UADD;AAETC,IAAAA,MAAM,EAAE,CAFC;AAGTC,IAAAA,IAAI,EAAE,CAHG;AAITC,IAAAA,KAAK,EAAE,CAJE;AAKTC,IAAAA,aAAa,EAAE,KALN;AAMTC,IAAAA,cAAc,EAAE,QANP;AAOT1B,IAAAA,KAAK,EAAEC,WAPE;AAOW;AACpB0B,IAAAA,QAAQ,EAAE1B,WARD;AAST2B,IAAAA,SAAS,EAAEzB,YATF;AAUT0B,IAAAA,eAAe,EAAE,OAVR,CAUiB;AAC1B;;AAXS,GADoB;AAc/BhB,EAAAA,WAAW,EAAE;AACXgB,IAAAA,eAAe,EAAE,QADN;AAEX;AACAJ,IAAAA,aAAa,EAAE,QAHJ;AAIXzB,IAAAA,KAAK,EAAEC,WAJI;AAKX0B,IAAAA,QAAQ,EAAE1B;AALC,GAdkB;AAqB/Ba,EAAAA,SAAS,EAAE;AACTgB,IAAAA,SAAS,EAAE;AADF,GArBoB;AAwB/Bf,EAAAA,eAAe,EAAE;AACf;AACAc,IAAAA,eAAe,EAAE;AAFF;AAxBc,CAAlB,CAAf","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet, Dimensions } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\nimport Portal from \"../Portal/Portal\";\nimport Button from \"../DeprecatedButton\";\nimport { PickerOption } from \"./Picker\";\n\nconst { width: deviceWidth, height: deviceHeight } = Dimensions.get(\"screen\");\n\ninterface PickerComponentProps {\n Icon: IconSlot[\"Icon\"];\n androidPickerRef: React.RefObject<any>;\n togglePickerVisible: () => void;\n pickerOptions: PickerOption[];\n internalValue: string | undefined;\n handleValueChange: (newValue: string, itemIndex: number) => void;\n}\n\nexport const PickerComponent: React.FC<PickerComponentProps> = ({\n Icon,\n togglePickerVisible,\n pickerOptions,\n internalValue,\n handleValueChange,\n}) => {\n return (\n <Portal>\n <View style={styles.iosPicker}>\n <SafeAreaView style={styles.iosSafeArea}>\n <Button\n Icon={Icon}\n type=\"text\"\n onPress={togglePickerVisible}\n style={styles.iosButton}\n >\n {\"Close\"}\n </Button>\n\n <NativePicker\n style={styles.iosNativePicker}\n selectedValue={internalValue}\n onValueChange={handleValueChange}\n >\n {(pickerOptions as unknown as PickerOption[]).map((option) => (\n <NativePicker.Item\n label={option.label}\n value={option.value}\n key={option.value}\n />\n ))}\n </NativePicker>\n </SafeAreaView>\n </View>\n </Portal>\n );\n};\n\nconst styles = StyleSheet.create({\n iosPicker: {\n position: \"absolute\",\n bottom: 0,\n left: 0,\n right: 0,\n flexDirection: \"row\",\n justifyContent: \"center\",\n width: deviceWidth, // TODO\n maxWidth: deviceWidth,\n maxHeight: deviceHeight,\n backgroundColor: \"green\", // TODO\n // backgroundColor: \"rgba(255, 255, 255, 1)\",\n },\n iosSafeArea: {\n backgroundColor: \"yellow\",\n // backgroundColor: \"white\",// TODO\n flexDirection: \"column\",\n width: deviceWidth,\n maxWidth: deviceWidth,\n },\n iosButton: {\n alignSelf: \"flex-end\",\n },\n iosNativePicker: {\n //backgroundColor: \"white\",// TODO\n backgroundColor: \"red\",\n },\n});\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
const {
|
|
5
|
+
width: deviceWidth,
|
|
6
|
+
height: deviceHeight
|
|
7
|
+
} = Dimensions.get("screen");
|
|
8
|
+
export const PickerComponent = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
androidPickerRef,
|
|
11
|
+
togglePickerVisible,
|
|
12
|
+
pickerOptions,
|
|
13
|
+
internalValue,
|
|
14
|
+
handleValueChange
|
|
15
|
+
} = _ref;
|
|
16
|
+
return /*#__PURE__*/React.createElement(NativePicker, {
|
|
17
|
+
selectedValue: internalValue,
|
|
18
|
+
onValueChange: handleValueChange,
|
|
19
|
+
style: styles.nonIosPicker,
|
|
20
|
+
ref: androidPickerRef,
|
|
21
|
+
onBlur: togglePickerVisible
|
|
22
|
+
}, pickerOptions.map(option => /*#__PURE__*/React.createElement(NativePicker.Item, {
|
|
23
|
+
label: option.label,
|
|
24
|
+
value: option.value,
|
|
25
|
+
key: option.value
|
|
26
|
+
})));
|
|
27
|
+
};
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
nonIosPicker: {
|
|
30
|
+
opacity: 0,
|
|
31
|
+
position: "absolute",
|
|
32
|
+
top: 0,
|
|
33
|
+
left: 0,
|
|
34
|
+
right: 0,
|
|
35
|
+
bottom: 0,
|
|
36
|
+
width: "100%",
|
|
37
|
+
maxWidth: deviceWidth,
|
|
38
|
+
maxHeight: deviceHeight
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=PickerComponent.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["PickerComponent.web.tsx"],"names":["React","StyleSheet","Dimensions","Picker","NativePicker","width","deviceWidth","height","deviceHeight","get","PickerComponent","androidPickerRef","togglePickerVisible","pickerOptions","internalValue","handleValueChange","styles","nonIosPicker","map","option","label","value","create","opacity","position","top","left","right","bottom","maxWidth","maxHeight"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,EAAqBC,UAArB,QAAuC,cAAvC;AAEA,SAASC,MAAM,IAAIC,YAAnB,QAAuC,6BAAvC;AAMA,MAAM;AAAEC,EAAAA,KAAK,EAAEC,WAAT;AAAsBC,EAAAA,MAAM,EAAEC;AAA9B,IAA+CN,UAAU,CAACO,GAAX,CAAe,QAAf,CAArD;AAWA,OAAO,MAAMC,eAA+C,GAAG,QAMzD;AAAA,MAN0D;AAC9DC,IAAAA,gBAD8D;AAE9DC,IAAAA,mBAF8D;AAG9DC,IAAAA,aAH8D;AAI9DC,IAAAA,aAJ8D;AAK9DC,IAAAA;AAL8D,GAM1D;AACJ,sBACE,oBAAC,YAAD;AACE,IAAA,aAAa,EAAED,aADjB;AAEE,IAAA,aAAa,EAAEC,iBAFjB;AAGE,IAAA,KAAK,EAAEC,MAAM,CAACC,YAHhB;AAIE,IAAA,GAAG,EAAEN,gBAJP;AAKE,IAAA,MAAM,EAAEC;AALV,KAOIC,aAAD,CAA6CK,GAA7C,CAAkDC,MAAD,iBAChD,oBAAC,YAAD,CAAc,IAAd;AACE,IAAA,KAAK,EAAEA,MAAM,CAACC,KADhB;AAEE,IAAA,KAAK,EAAED,MAAM,CAACE,KAFhB;AAGE,IAAA,GAAG,EAAEF,MAAM,CAACE;AAHd,IADD,CAPH,CADF;AAiBD,CAxBM;AA0BP,MAAML,MAAM,GAAGf,UAAU,CAACqB,MAAX,CAAkB;AAC/BL,EAAAA,YAAY,EAAE;AACZM,IAAAA,OAAO,EAAE,CADG;AAEZC,IAAAA,QAAQ,EAAE,UAFE;AAGZC,IAAAA,GAAG,EAAE,CAHO;AAIZC,IAAAA,IAAI,EAAE,CAJM;AAKZC,IAAAA,KAAK,EAAE,CALK;AAMZC,IAAAA,MAAM,EAAE,CANI;AAOZvB,IAAAA,KAAK,EAAE,MAPK;AAQZwB,IAAAA,QAAQ,EAAEvB,WARE;AASZwB,IAAAA,SAAS,EAAEtB;AATC;AADiB,CAAlB,CAAf","sourcesContent":["import * as React from \"react\";\nimport { StyleSheet, Dimensions } from \"react-native\";\n\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\n\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nimport { PickerOption } from \"./Picker\";\n\nconst { width: deviceWidth, height: deviceHeight } = Dimensions.get(\"screen\");\n\ninterface PickerComponentProps {\n Icon: IconSlot[\"Icon\"];\n androidPickerRef: React.RefObject<any>;\n togglePickerVisible: () => void;\n pickerOptions: PickerOption[];\n internalValue: string | undefined;\n handleValueChange: (newValue: string, itemIndex: number) => void;\n}\n\nexport const PickerComponent: React.FC<PickerComponentProps> = ({\n androidPickerRef,\n togglePickerVisible,\n pickerOptions,\n internalValue,\n handleValueChange,\n}) => {\n return (\n <NativePicker\n selectedValue={internalValue}\n onValueChange={handleValueChange}\n style={styles.nonIosPicker}\n ref={androidPickerRef}\n onBlur={togglePickerVisible}\n >\n {(pickerOptions as unknown as PickerOption[]).map((option) => (\n <NativePicker.Item\n label={option.label}\n value={option.value}\n key={option.value}\n />\n ))}\n </NativePicker>\n );\n};\n\nconst styles = StyleSheet.create({\n nonIosPicker: {\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: \"100%\",\n maxWidth: deviceWidth,\n maxHeight: deviceHeight,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["constants.
|
|
1
|
+
{"version":3,"sources":["constants.ts"],"names":["Platform","expo","global","__expo","DEFAULT_STATUSBAR_HEIGHT_EXPO","Constants","statusBarHeight","APPROX_STATUSBAR_HEIGHT","select","android","ios","Version"],"mappings":"AAAA,SAASA,QAAT,QAAyB,cAAzB,C,CAEA;;AACA,MAAMC,IAAI,GAAGC,MAAM,CAACC,MAApB;AAEA,MAAMC,6BAA6B,GAAGH,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEI,SAAN,GAClCJ,IAAI,CAACI,SAAL,CAAeC,eADmB,GAElC,CAFJ;AAIA,OAAO,MAAMC,uBAAuB,GAAGP,QAAQ,CAACQ,MAAT,CAAgB;AACrDC,EAAAA,OAAO,EAAEL,6BAD4C;AAErDM,EAAAA,GAAG,EAAEV,QAAQ,CAACW,OAAT,GAAmB,EAAnB,GAAwBP,6BAAxB,GAAwD;AAFR,CAAhB,CAAhC","sourcesContent":["import { Platform } from \"react-native\";\n\n// @ts-ignore\nconst expo = global.__expo;\n\nconst DEFAULT_STATUSBAR_HEIGHT_EXPO = expo?.Constants\n ? expo.Constants.statusBarHeight\n : 0;\n\nexport const APPROX_STATUSBAR_HEIGHT = Platform.select({\n android: DEFAULT_STATUSBAR_HEIGHT_EXPO,\n ios: Platform.Version < 11 ? DEFAULT_STATUSBAR_HEIGHT_EXPO : 0,\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Banner.
|
|
1
|
+
{"version":3,"sources":["Banner.ts"],"names":["COMPONENT_TYPES","createIconProp","createBoolProp","createColorProp","createTextProp","GROUPS","SEED_DATA","name","tag","category","button","props","icon","defaultValue","required","content","label","description","initiallyVisible","group","basic","dismissable","buttonColor"],"mappings":"AAAA,SACEA,eADF,EAEEC,cAFF,EAGEC,cAHF,EAIEC,eAJF,EAKEC,cALF,EAMEC,MANF,QAOO,iBAPP;AASA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,QADiB;AAEvBC,EAAAA,GAAG,EAAE,QAFkB;AAGvBC,EAAAA,QAAQ,EAAET,eAAe,CAACU,MAHH;AAIvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,IAAI,EAAEX,cAAc,CAAC;AACnBY,MAAAA,YAAY,EAAE,IADK;AAEnBC,MAAAA,QAAQ,EAAE;AAFS,KAAD,CADf;AAKLC,IAAAA,OAAO,EAAEX,cAAc,CAAC;AACtBY,MAAAA,KAAK,EAAE,SADe;AAEtBC,MAAAA,WAAW,EAAE;AAFS,KAAD,CALlB;AASLC,IAAAA,gBAAgB,EAAEhB,cAAc,CAAC;AAC/BiB,MAAAA,KAAK,EAAEd,MAAM,CAACe,KADiB;AAE/BJ,MAAAA,KAAK,EAAE,mBAFwB;AAG/BC,MAAAA,WAAW,EAAE,sCAHkB;AAI/BJ,MAAAA,YAAY,EAAE;AAJiB,KAAD,CAT3B;AAeLQ,IAAAA,WAAW,EAAEnB,cAAc,CAAC;AAC1BiB,MAAAA,KAAK,EAAEd,MAAM,CAACe,KADY;AAE1BJ,MAAAA,KAAK,EAAE,aAFmB;AAG1BC,MAAAA,WAAW,EAAE,gDAHa;AAI1BJ,MAAAA,YAAY,EAAE;AAJY,KAAD,CAftB;AAqBLS,IAAAA,WAAW,EAAEnB,eAAe,CAAC;AAC3Ba,MAAAA,KAAK,EAAE,cADoB;AAE3BH,MAAAA,YAAY,EAAE;AAFa,KAAD;AArBvB;AAJgB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n createIconProp,\n createBoolProp,\n createColorProp,\n createTextProp,\n GROUPS,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Banner\",\n tag: \"Banner\",\n category: COMPONENT_TYPES.button,\n props: {\n icon: createIconProp({\n defaultValue: null,\n required: false,\n }),\n content: createTextProp({\n label: \"Content\",\n description: \"Banner text content\",\n }),\n initiallyVisible: createBoolProp({\n group: GROUPS.basic,\n label: \"Initially visible\",\n description: \"Whether the banner should be visible\",\n defaultValue: true,\n }),\n dismissable: createBoolProp({\n group: GROUPS.basic,\n label: \"Dismissable\",\n description: \"Whether the banner should be able to be closed\",\n defaultValue: true,\n }),\n buttonColor: createColorProp({\n label: \"Button color\",\n defaultValue: \"primary\",\n }),\n },\n};\n"]}
|
|
@@ -40,7 +40,7 @@ export const SEED_DATA = {
|
|
|
40
40
|
defaultValue: true
|
|
41
41
|
}),
|
|
42
42
|
keyboardShouldPersistTaps: createTextEnumProp({
|
|
43
|
-
label: "Allow Touch Events
|
|
43
|
+
label: "Allow Touch Events",
|
|
44
44
|
description: "Allows touch events on visible components to be processed while the keyboard is open",
|
|
45
45
|
defaultValue: "never",
|
|
46
46
|
options: ["never", "always"]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["KeyboardAwareScrollView.ts"],"names":["COMPONENT_TYPES","createStaticBoolProp","createStaticNumberProp","createTextEnumProp","SEED_DATA","name","tag","description","category","layout","props","viewIsInsideTabBar","label","enableAutomaticScroll","extraHeight","extraScrollHeight","enableResetScrollToCoords","keyboardOpeningTime","enableOnAndroid","showsVerticalScrollIndicator","defaultValue","keyboardShouldPersistTaps","options"],"mappings":"AAAA,SACEA,eADF,EAEEC,oBAFF,EAGEC,sBAHF,EAIEC,kBAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,4BADiB;AAEvBC,EAAAA,GAAG,EAAE,yBAFkB;AAGvBC,EAAAA,WAAW,EACT,mEAJqB;AAKvBC,EAAAA,QAAQ,EAAER,eAAe,CAACS,MALH;AAMvBA,EAAAA,MAAM,EAAE,EANe;AAOvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAEV,oBAAoB,CAAC;AACvCW,MAAAA,KAAK,EAAE,uBADgC;AAEvCL,MAAAA,WAAW,EAAE;AAF0B,KAAD,CADnC;AAKLM,IAAAA,qBAAqB,EAAEZ,oBAAoB,CAAC;AAC1CW,MAAAA,KAAK,EAAE,yBADmC;AAE1CL,MAAAA,WAAW,EACT;AAHwC,KAAD,CALtC;AAULO,IAAAA,WAAW,EAAEZ,sBAAsB,CAAC;AAClCU,MAAAA,KAAK,EAAE,cAD2B;AAElCL,MAAAA,WAAW,EAAE;AAFqB,KAAD,CAV9B;AAcLQ,IAAAA,iBAAiB,EAAEb,sBAAsB,CAAC;AACxCU,MAAAA,KAAK,EAAE,qBADiC;AAExCL,MAAAA,WAAW,EACT;AAHsC,KAAD,CAdpC;AAmBLS,IAAAA,yBAAyB,EAAEf,oBAAoB,CAAC;AAC9CW,MAAAA,KAAK,EAAE,oCADuC;AAE9CL,MAAAA,WAAW,EACT;AAH4C,KAAD,CAnB1C;AAwBLU,IAAAA,mBAAmB,EAAEf,sBAAsB,CAAC;AAC1CU,MAAAA,KAAK,EAAE,cADmC;AAE1CL,MAAAA,WAAW,EACT;AAHwC,KAAD,CAxBtC;AA6BLW,IAAAA,eAAe,EAAEjB,oBAAoB,CAAC;AACpCW,MAAAA,KAAK,EAAE,mBAD6B;AAEpCL,MAAAA,WAAW,EAAE;AAFuB,KAAD,CA7BhC;AAiCLY,IAAAA,4BAA4B,EAAElB,oBAAoB,CAAC;AACjDW,MAAAA,KAAK,EAAE,iCAD0C;AAEjDL,MAAAA,WAAW,EAAE,4CAFoC;AAGjDa,MAAAA,YAAY,EAAE;AAHmC,KAAD,CAjC7C;AAsCLC,IAAAA,yBAAyB,EAAElB,kBAAkB,CAAC;AAC5CS,MAAAA,KAAK,EAAE,
|
|
1
|
+
{"version":3,"sources":["KeyboardAwareScrollView.ts"],"names":["COMPONENT_TYPES","createStaticBoolProp","createStaticNumberProp","createTextEnumProp","SEED_DATA","name","tag","description","category","layout","props","viewIsInsideTabBar","label","enableAutomaticScroll","extraHeight","extraScrollHeight","enableResetScrollToCoords","keyboardOpeningTime","enableOnAndroid","showsVerticalScrollIndicator","defaultValue","keyboardShouldPersistTaps","options"],"mappings":"AAAA,SACEA,eADF,EAEEC,oBAFF,EAGEC,sBAHF,EAIEC,kBAJF,QAKO,iBALP;AAOA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,4BADiB;AAEvBC,EAAAA,GAAG,EAAE,yBAFkB;AAGvBC,EAAAA,WAAW,EACT,mEAJqB;AAKvBC,EAAAA,QAAQ,EAAER,eAAe,CAACS,MALH;AAMvBA,EAAAA,MAAM,EAAE,EANe;AAOvBC,EAAAA,KAAK,EAAE;AACLC,IAAAA,kBAAkB,EAAEV,oBAAoB,CAAC;AACvCW,MAAAA,KAAK,EAAE,uBADgC;AAEvCL,MAAAA,WAAW,EAAE;AAF0B,KAAD,CADnC;AAKLM,IAAAA,qBAAqB,EAAEZ,oBAAoB,CAAC;AAC1CW,MAAAA,KAAK,EAAE,yBADmC;AAE1CL,MAAAA,WAAW,EACT;AAHwC,KAAD,CALtC;AAULO,IAAAA,WAAW,EAAEZ,sBAAsB,CAAC;AAClCU,MAAAA,KAAK,EAAE,cAD2B;AAElCL,MAAAA,WAAW,EAAE;AAFqB,KAAD,CAV9B;AAcLQ,IAAAA,iBAAiB,EAAEb,sBAAsB,CAAC;AACxCU,MAAAA,KAAK,EAAE,qBADiC;AAExCL,MAAAA,WAAW,EACT;AAHsC,KAAD,CAdpC;AAmBLS,IAAAA,yBAAyB,EAAEf,oBAAoB,CAAC;AAC9CW,MAAAA,KAAK,EAAE,oCADuC;AAE9CL,MAAAA,WAAW,EACT;AAH4C,KAAD,CAnB1C;AAwBLU,IAAAA,mBAAmB,EAAEf,sBAAsB,CAAC;AAC1CU,MAAAA,KAAK,EAAE,cADmC;AAE1CL,MAAAA,WAAW,EACT;AAHwC,KAAD,CAxBtC;AA6BLW,IAAAA,eAAe,EAAEjB,oBAAoB,CAAC;AACpCW,MAAAA,KAAK,EAAE,mBAD6B;AAEpCL,MAAAA,WAAW,EAAE;AAFuB,KAAD,CA7BhC;AAiCLY,IAAAA,4BAA4B,EAAElB,oBAAoB,CAAC;AACjDW,MAAAA,KAAK,EAAE,iCAD0C;AAEjDL,MAAAA,WAAW,EAAE,4CAFoC;AAGjDa,MAAAA,YAAY,EAAE;AAHmC,KAAD,CAjC7C;AAsCLC,IAAAA,yBAAyB,EAAElB,kBAAkB,CAAC;AAC5CS,MAAAA,KAAK,EAAE,oBADqC;AAE5CL,MAAAA,WAAW,EACT,sFAH0C;AAI5Ca,MAAAA,YAAY,EAAE,OAJ8B;AAK5CE,MAAAA,OAAO,EAAE,CAAC,OAAD,EAAU,QAAV;AALmC,KAAD;AAtCxC;AAPgB,CAAlB","sourcesContent":["import {\n COMPONENT_TYPES,\n createStaticBoolProp,\n createStaticNumberProp,\n createTextEnumProp,\n} from \"@draftbit/types\";\n\nexport const SEED_DATA = {\n name: \"Keyboard Aware Scroll View\",\n tag: \"KeyboardAwareScrollView\",\n description:\n \"View that moves pushes the content when virtual keyboard is open.\",\n category: COMPONENT_TYPES.layout,\n layout: {},\n props: {\n viewIsInsideTabBar: createStaticBoolProp({\n label: \"View Is Inside TabBar\",\n description: \"Adds an extra offset that represents the TabBarIOS height.\",\n }),\n enableAutomaticScroll: createStaticBoolProp({\n label: \"Enable Automatic Scroll\",\n description:\n \"When focus in TextInput will scroll the position, default is enabled\",\n }),\n extraHeight: createStaticNumberProp({\n label: \"Extra Height\",\n description: \"Adds an extra offset when focusing the TextInputs\",\n }),\n extraScrollHeight: createStaticNumberProp({\n label: \"Extra Scroll Height\",\n description:\n \"Adds an extra offset to the keyboard. Useful if you want to stick elements above the keyboard\",\n }),\n enableResetScrollToCoords: createStaticBoolProp({\n label: \"Enable Reset Scroll To Coordinates\",\n description:\n \"Lets the user enable or disable automatic resetScrollToCoords\",\n }),\n keyboardOpeningTime: createStaticNumberProp({\n label: \"Opening Time\",\n description:\n \"Sets the delay time before scrolling to new position after keyboard opening, default is 250\",\n }),\n enableOnAndroid: createStaticBoolProp({\n label: \"Enable On Android\",\n description: \"Enable Android Support\",\n }),\n showsVerticalScrollIndicator: createStaticBoolProp({\n label: \"Shows Vertical Scroll Indicator\",\n description: \"Show or hide the vertical scroll indicator\",\n defaultValue: true,\n }),\n keyboardShouldPersistTaps: createTextEnumProp({\n label: \"Allow Touch Events\",\n description:\n \"Allows touch events on visible components to be processed while the keyboard is open\",\n defaultValue: \"never\",\n options: [\"never\", \"always\"],\n }),\n },\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
import { PickerOption } from "./Picker";
|
|
4
|
+
interface PickerComponentProps {
|
|
5
|
+
Icon: IconSlot["Icon"];
|
|
6
|
+
androidPickerRef: React.RefObject<any>;
|
|
7
|
+
togglePickerVisible: () => void;
|
|
8
|
+
pickerOptions: PickerOption[];
|
|
9
|
+
internalValue: string | undefined;
|
|
10
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PickerComponent: React.FC<PickerComponentProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
import { PickerOption } from "./Picker";
|
|
4
|
+
interface PickerComponentProps {
|
|
5
|
+
Icon: IconSlot["Icon"];
|
|
6
|
+
androidPickerRef: React.RefObject<any>;
|
|
7
|
+
togglePickerVisible: () => void;
|
|
8
|
+
pickerOptions: PickerOption[];
|
|
9
|
+
internalValue: string | undefined;
|
|
10
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PickerComponent: React.FC<PickerComponentProps>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { IconSlot } from "../../interfaces/Icon";
|
|
3
|
+
import { PickerOption } from "./Picker";
|
|
4
|
+
interface PickerComponentProps {
|
|
5
|
+
Icon: IconSlot["Icon"];
|
|
6
|
+
androidPickerRef: React.RefObject<any>;
|
|
7
|
+
togglePickerVisible: () => void;
|
|
8
|
+
pickerOptions: PickerOption[];
|
|
9
|
+
internalValue: string | undefined;
|
|
10
|
+
handleValueChange: (newValue: string, itemIndex: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const PickerComponent: React.FC<PickerComponentProps>;
|
|
13
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@draftbit/core",
|
|
3
|
-
"version": "44.1.
|
|
3
|
+
"version": "44.1.13-2d7ff5.0+2d7ff57c",
|
|
4
4
|
"description": "Core (non-native) Components",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@date-io/date-fns": "^1.3.13",
|
|
43
43
|
"@draftbit/react-theme-provider": "^2.1.1",
|
|
44
|
-
"@draftbit/types": "^44.1.
|
|
44
|
+
"@draftbit/types": "^44.1.12",
|
|
45
45
|
"@material-ui/core": "^4.11.0",
|
|
46
46
|
"@material-ui/pickers": "^3.2.10",
|
|
47
47
|
"@react-native-community/slider": "4.1.7",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
]
|
|
80
80
|
]
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "2d7ff57cc3d8150283dcf65307dc6206b77ec077"
|
|
83
83
|
}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { View, StyleSheet, Text,
|
|
2
|
+
import { View, StyleSheet, Text, Dimensions, } from "react-native";
|
|
3
3
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
4
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
5
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
6
6
|
import { withTheme } from "../../theming";
|
|
7
|
-
import Portal from "../Portal/Portal";
|
|
8
|
-
import Button from "../DeprecatedButton";
|
|
7
|
+
// import Portal from "../Portal/Portal";
|
|
8
|
+
// import Button from "../DeprecatedButton";
|
|
9
9
|
import Touchable from "../Touchable";
|
|
10
10
|
import { extractStyles, extractBorderAndMarginStyles, borderStyleNames, marginStyleNames, } from "../../utilities";
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
import { PickerComponent } from "./PickerComponent";
|
|
11
13
|
function normalizeOptions(options) {
|
|
12
14
|
if (options.length === 0) {
|
|
13
15
|
return [];
|
|
@@ -30,12 +32,20 @@ function normalizeOptions(options) {
|
|
|
30
32
|
}
|
|
31
33
|
throw new Error('Picker options must be either an array of strings or array of { "label": string; "value": string; } objects.');
|
|
32
34
|
}
|
|
35
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
36
|
+
// const isIos = Platform.OS === "ios";
|
|
33
37
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
34
38
|
const disabledColor = "rgb(240, 240, 240)";
|
|
35
39
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
36
|
-
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
40
|
+
const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style, placeholder, value, disabled = false,
|
|
41
|
+
// theme,
|
|
42
|
+
assistiveText, label, iconColor = unstyledColor, iconSize = 24, leftIconMode = "inset", leftIconName, placeholderTextColor = unstyledColor, rightIconName, type = "solid", }) => {
|
|
43
|
+
const androidPickerRef = React.useRef(undefined);
|
|
37
44
|
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
38
|
-
const [pickerVisible,
|
|
45
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
46
|
+
const togglePickerVisible = () => {
|
|
47
|
+
setPickerVisible(!pickerVisible);
|
|
48
|
+
};
|
|
39
49
|
React.useEffect(() => {
|
|
40
50
|
if (value != null) {
|
|
41
51
|
setInternalValue(value);
|
|
@@ -46,11 +56,16 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
46
56
|
setInternalValue(defaultValue);
|
|
47
57
|
}
|
|
48
58
|
}, [defaultValue]);
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (pickerVisible && androidPickerRef.current) {
|
|
61
|
+
androidPickerRef?.current?.focus();
|
|
62
|
+
}
|
|
63
|
+
}, [pickerVisible, androidPickerRef]);
|
|
49
64
|
const normalizedOptions = normalizeOptions(options);
|
|
50
65
|
const pickerOptions = placeholder
|
|
51
66
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
52
67
|
: normalizedOptions;
|
|
53
|
-
const { colors } = theme;
|
|
68
|
+
// const { colors } = theme;
|
|
54
69
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
55
70
|
const additionalBorderStyles = ["backgroundColor"];
|
|
56
71
|
const additionalMarginStyles = [
|
|
@@ -96,7 +111,6 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
96
111
|
height: 60,
|
|
97
112
|
...extractedMarginStyles,
|
|
98
113
|
};
|
|
99
|
-
const platform = Platform.OS;
|
|
100
114
|
const stylesWithoutBordersAndMargins = omit(viewStyles, [
|
|
101
115
|
...borderStyleNames,
|
|
102
116
|
...marginStyleNames,
|
|
@@ -171,23 +185,22 @@ const Picker = ({ error, options = [], onValueChange, defaultValue, Icon, style,
|
|
|
171
185
|
React.createElement(Text, { style: primaryTextStyle }, String(selectedLabel ?? placeholder))),
|
|
172
186
|
rightIcon)),
|
|
173
187
|
assistiveTextLabel),
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
React.createElement(Button, { Icon: Icon, type: "text", onPress: togglePickerVisible, style: styles.iosButton }, "Close"),
|
|
183
|
-
React.createElement(NativePicker, { style: styles.iosNativePicker, selectedValue: internalValue, onValueChange: handleValueChange }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))))))) : null,
|
|
184
|
-
platform !== "ios" ? (React.createElement(NativePicker, { enabled: !disabled, selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value }))))) : null));
|
|
188
|
+
React.createElement(View, null, pickerVisible ? (React.createElement(PickerComponent, { ...{
|
|
189
|
+
Icon,
|
|
190
|
+
androidPickerRef,
|
|
191
|
+
togglePickerVisible,
|
|
192
|
+
pickerOptions,
|
|
193
|
+
internalValue,
|
|
194
|
+
handleValueChange,
|
|
195
|
+
} })) : null)));
|
|
185
196
|
};
|
|
186
197
|
export default withTheme(Picker);
|
|
187
198
|
const styles = StyleSheet.create({
|
|
188
199
|
marginsContainer: {
|
|
189
200
|
alignSelf: "stretch",
|
|
190
201
|
alignItems: "center",
|
|
202
|
+
width: "100%",
|
|
203
|
+
maxWidth: deviceWidth,
|
|
191
204
|
},
|
|
192
205
|
touchableContainer: {
|
|
193
206
|
flex: 1,
|
|
@@ -195,6 +208,7 @@ const styles = StyleSheet.create({
|
|
|
195
208
|
width: "100%",
|
|
196
209
|
alignSelf: "stretch",
|
|
197
210
|
alignItems: "center",
|
|
211
|
+
backgroundColor: "pink", // TODO
|
|
198
212
|
},
|
|
199
213
|
outsetContainer: {
|
|
200
214
|
flex: 1,
|
|
@@ -224,11 +238,15 @@ const styles = StyleSheet.create({
|
|
|
224
238
|
right: 0,
|
|
225
239
|
flexDirection: "row",
|
|
226
240
|
justifyContent: "center",
|
|
241
|
+
width: "100%",
|
|
242
|
+
maxWidth: deviceWidth,
|
|
243
|
+
maxHeight: deviceHeight,
|
|
227
244
|
},
|
|
228
245
|
iosSafeArea: {
|
|
229
246
|
backgroundColor: "white",
|
|
230
247
|
flexDirection: "column",
|
|
231
248
|
width: "100%",
|
|
249
|
+
maxWidth: deviceWidth,
|
|
232
250
|
},
|
|
233
251
|
iosButton: {
|
|
234
252
|
alignSelf: "flex-end",
|
|
@@ -244,5 +262,7 @@ const styles = StyleSheet.create({
|
|
|
244
262
|
right: 0,
|
|
245
263
|
bottom: 0,
|
|
246
264
|
width: "100%",
|
|
265
|
+
maxWidth: deviceWidth,
|
|
266
|
+
maxHeight: deviceHeight,
|
|
247
267
|
},
|
|
248
268
|
});
|
|
@@ -3,17 +3,18 @@ import {
|
|
|
3
3
|
View,
|
|
4
4
|
StyleSheet,
|
|
5
5
|
Text,
|
|
6
|
-
Platform,
|
|
6
|
+
// Platform,
|
|
7
7
|
ViewStyle,
|
|
8
8
|
StyleProp,
|
|
9
|
+
Dimensions,
|
|
9
10
|
} from "react-native";
|
|
10
11
|
import { omit, pickBy, identity, isObject } from "lodash";
|
|
11
|
-
import { SafeAreaView } from "react-native-safe-area-context";
|
|
12
|
-
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
12
|
+
// import { SafeAreaView } from "react-native-safe-area-context";
|
|
13
|
+
// import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
13
14
|
|
|
14
15
|
import { withTheme } from "../../theming";
|
|
15
|
-
import Portal from "../Portal/Portal";
|
|
16
|
-
import Button from "../DeprecatedButton";
|
|
16
|
+
// import Portal from "../Portal/Portal";
|
|
17
|
+
// import Button from "../DeprecatedButton";
|
|
17
18
|
import Touchable from "../Touchable";
|
|
18
19
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
19
20
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -23,6 +24,8 @@ import {
|
|
|
23
24
|
borderStyleNames,
|
|
24
25
|
marginStyleNames,
|
|
25
26
|
} from "../../utilities";
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
import { PickerComponent } from "./PickerComponent";
|
|
26
29
|
|
|
27
30
|
export interface PickerOption {
|
|
28
31
|
value: string;
|
|
@@ -81,6 +84,8 @@ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
|
|
|
81
84
|
);
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
88
|
+
// const isIos = Platform.OS === "ios";
|
|
84
89
|
const unstyledColor = "rgba(165, 173, 183, 1)";
|
|
85
90
|
const disabledColor = "rgb(240, 240, 240)";
|
|
86
91
|
const errorColor = "rgba(255, 69, 100, 1)";
|
|
@@ -95,7 +100,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
95
100
|
placeholder,
|
|
96
101
|
value,
|
|
97
102
|
disabled = false,
|
|
98
|
-
theme,
|
|
103
|
+
// theme,
|
|
99
104
|
assistiveText,
|
|
100
105
|
label,
|
|
101
106
|
iconColor = unstyledColor,
|
|
@@ -106,14 +111,17 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
106
111
|
rightIconName,
|
|
107
112
|
type = "solid",
|
|
108
113
|
}) => {
|
|
114
|
+
const androidPickerRef = React.useRef<any | undefined>(undefined);
|
|
115
|
+
|
|
109
116
|
const [internalValue, setInternalValue] = React.useState<string | undefined>(
|
|
110
117
|
value || defaultValue
|
|
111
118
|
);
|
|
112
119
|
|
|
113
|
-
const [pickerVisible,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
const [pickerVisible, setPickerVisible] = React.useState(false);
|
|
121
|
+
|
|
122
|
+
const togglePickerVisible = () => {
|
|
123
|
+
setPickerVisible(!pickerVisible);
|
|
124
|
+
};
|
|
117
125
|
|
|
118
126
|
React.useEffect(() => {
|
|
119
127
|
if (value != null) {
|
|
@@ -127,13 +135,19 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
127
135
|
}
|
|
128
136
|
}, [defaultValue]);
|
|
129
137
|
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (pickerVisible && androidPickerRef.current) {
|
|
140
|
+
androidPickerRef?.current?.focus();
|
|
141
|
+
}
|
|
142
|
+
}, [pickerVisible, androidPickerRef]);
|
|
143
|
+
|
|
130
144
|
const normalizedOptions = normalizeOptions(options);
|
|
131
145
|
|
|
132
146
|
const pickerOptions = placeholder
|
|
133
147
|
? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
|
|
134
148
|
: normalizedOptions;
|
|
135
149
|
|
|
136
|
-
const { colors } = theme;
|
|
150
|
+
// const { colors } = theme;
|
|
137
151
|
|
|
138
152
|
const { viewStyles, textStyles } = extractStyles(style);
|
|
139
153
|
|
|
@@ -193,8 +207,6 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
193
207
|
...extractedMarginStyles,
|
|
194
208
|
};
|
|
195
209
|
|
|
196
|
-
const platform = Platform.OS;
|
|
197
|
-
|
|
198
210
|
const stylesWithoutBordersAndMargins = omit(viewStyles, [
|
|
199
211
|
...borderStyleNames,
|
|
200
212
|
...marginStyleNames,
|
|
@@ -334,8 +346,23 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
334
346
|
{assistiveTextLabel}
|
|
335
347
|
</Touchable>
|
|
336
348
|
|
|
349
|
+
<View>
|
|
350
|
+
{pickerVisible ? (
|
|
351
|
+
<PickerComponent
|
|
352
|
+
{...{
|
|
353
|
+
Icon,
|
|
354
|
+
androidPickerRef,
|
|
355
|
+
togglePickerVisible,
|
|
356
|
+
pickerOptions,
|
|
357
|
+
internalValue,
|
|
358
|
+
handleValueChange,
|
|
359
|
+
}}
|
|
360
|
+
/>
|
|
361
|
+
) : null}
|
|
362
|
+
</View>
|
|
363
|
+
|
|
337
364
|
{/* iosPicker */}
|
|
338
|
-
{
|
|
365
|
+
{/* isIos && pickerVisible ? (
|
|
339
366
|
<Portal>
|
|
340
367
|
<View
|
|
341
368
|
style={[
|
|
@@ -371,15 +398,17 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
371
398
|
</SafeAreaView>
|
|
372
399
|
</View>
|
|
373
400
|
</Portal>
|
|
374
|
-
) : null}
|
|
401
|
+
) : null */}
|
|
375
402
|
|
|
376
403
|
{/* nonIosPicker */}
|
|
377
|
-
{
|
|
404
|
+
{/* !isIos && pickerVisible ? (
|
|
378
405
|
<NativePicker
|
|
379
|
-
enabled={
|
|
406
|
+
enabled={pickerVisible}
|
|
380
407
|
selectedValue={internalValue}
|
|
381
408
|
onValueChange={handleValueChange}
|
|
382
409
|
style={styles.nonIosPicker}
|
|
410
|
+
ref={androidPickerRef}
|
|
411
|
+
onBlur={() => setPickerVisible(false)}
|
|
383
412
|
>
|
|
384
413
|
{(pickerOptions as unknown as PickerOption[]).map((option) => (
|
|
385
414
|
<NativePicker.Item
|
|
@@ -389,7 +418,7 @@ const Picker: React.FC<PickerProps> = ({
|
|
|
389
418
|
/>
|
|
390
419
|
))}
|
|
391
420
|
</NativePicker>
|
|
392
|
-
) : null}
|
|
421
|
+
) : null */}
|
|
393
422
|
</View>
|
|
394
423
|
);
|
|
395
424
|
};
|
|
@@ -400,6 +429,8 @@ const styles = StyleSheet.create({
|
|
|
400
429
|
marginsContainer: {
|
|
401
430
|
alignSelf: "stretch",
|
|
402
431
|
alignItems: "center",
|
|
432
|
+
width: "100%",
|
|
433
|
+
maxWidth: deviceWidth,
|
|
403
434
|
},
|
|
404
435
|
touchableContainer: {
|
|
405
436
|
flex: 1,
|
|
@@ -407,6 +438,7 @@ const styles = StyleSheet.create({
|
|
|
407
438
|
width: "100%",
|
|
408
439
|
alignSelf: "stretch",
|
|
409
440
|
alignItems: "center",
|
|
441
|
+
backgroundColor: "pink", // TODO
|
|
410
442
|
},
|
|
411
443
|
outsetContainer: {
|
|
412
444
|
flex: 1,
|
|
@@ -436,11 +468,15 @@ const styles = StyleSheet.create({
|
|
|
436
468
|
right: 0,
|
|
437
469
|
flexDirection: "row",
|
|
438
470
|
justifyContent: "center",
|
|
471
|
+
width: "100%",
|
|
472
|
+
maxWidth: deviceWidth,
|
|
473
|
+
maxHeight: deviceHeight,
|
|
439
474
|
},
|
|
440
475
|
iosSafeArea: {
|
|
441
476
|
backgroundColor: "white",
|
|
442
477
|
flexDirection: "column",
|
|
443
478
|
width: "100%",
|
|
479
|
+
maxWidth: deviceWidth,
|
|
444
480
|
},
|
|
445
481
|
iosButton: {
|
|
446
482
|
alignSelf: "flex-end",
|
|
@@ -456,5 +492,7 @@ const styles = StyleSheet.create({
|
|
|
456
492
|
right: 0,
|
|
457
493
|
bottom: 0,
|
|
458
494
|
width: "100%",
|
|
495
|
+
maxWidth: deviceWidth,
|
|
496
|
+
maxHeight: deviceHeight,
|
|
459
497
|
},
|
|
460
498
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, Dimensions } from "react-native";
|
|
3
|
+
import { Picker as NativePicker } from "@react-native-picker/picker";
|
|
4
|
+
const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
|
|
5
|
+
export const PickerComponent = ({ androidPickerRef, togglePickerVisible, pickerOptions, internalValue, handleValueChange, }) => {
|
|
6
|
+
return (React.createElement(NativePicker, { selectedValue: internalValue, onValueChange: handleValueChange, style: styles.nonIosPicker, ref: androidPickerRef, onBlur: togglePickerVisible }, pickerOptions.map((option) => (React.createElement(NativePicker.Item, { label: option.label, value: option.value, key: option.value })))));
|
|
7
|
+
};
|
|
8
|
+
const styles = StyleSheet.create({
|
|
9
|
+
nonIosPicker: {
|
|
10
|
+
opacity: 0,
|
|
11
|
+
position: "absolute",
|
|
12
|
+
top: 0,
|
|
13
|
+
left: 0,
|
|
14
|
+
right: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
width: "100%",
|
|
17
|
+
maxWidth: deviceWidth,
|
|
18
|
+
maxHeight: deviceHeight,
|
|
19
|
+
},
|
|
20
|
+
});
|