@draftbit/core 44.1.14 → 44.1.15

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.
Files changed (31) hide show
  1. package/lib/commonjs/components/Picker/Picker.js +27 -266
  2. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  3. package/lib/commonjs/components/Picker/PickerComponent.android.js +110 -34
  4. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -1
  5. package/lib/commonjs/components/Picker/PickerComponent.ios.js +113 -44
  6. package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +1 -1
  7. package/lib/commonjs/components/Picker/PickerComponent.web.js +111 -34
  8. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -1
  9. package/lib/commonjs/components/Picker/PickerTypes.js +6 -0
  10. package/lib/commonjs/components/Picker/PickerTypes.js.map +1 -0
  11. package/lib/module/components/Picker/Picker.js +28 -260
  12. package/lib/module/components/Picker/Picker.js.map +1 -1
  13. package/lib/module/components/Picker/PickerComponent.android.js +103 -32
  14. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -1
  15. package/lib/module/components/Picker/PickerComponent.ios.js +108 -42
  16. package/lib/module/components/Picker/PickerComponent.ios.js.map +1 -1
  17. package/lib/module/components/Picker/PickerComponent.web.js +104 -32
  18. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -1
  19. package/lib/module/components/Picker/PickerTypes.js +2 -0
  20. package/lib/module/components/Picker/PickerTypes.js.map +1 -0
  21. package/lib/typescript/src/components/Picker/Picker.d.ts +4 -28
  22. package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +5 -12
  23. package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +5 -11
  24. package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +5 -12
  25. package/lib/typescript/src/components/Picker/PickerTypes.d.ts +18 -0
  26. package/package.json +2 -2
  27. package/src/components/Picker/Picker.tsx +34 -434
  28. package/src/components/Picker/PickerComponent.android.tsx +101 -44
  29. package/src/components/Picker/PickerComponent.ios.tsx +116 -63
  30. package/src/components/Picker/PickerComponent.web.tsx +102 -44
  31. package/src/components/Picker/PickerTypes.ts +18 -0
@@ -1,69 +1,135 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  import * as React from "react";
2
- import { View, StyleSheet, Dimensions } from "react-native";
4
+ import { View, StyleSheet } from "react-native";
3
5
  import { SafeAreaView } from "react-native-safe-area-context";
6
+ import omit from "lodash.omit";
4
7
  import { Picker as NativePicker } from "@react-native-picker/picker";
8
+ import { withTheme } from "../../theming";
5
9
  import Portal from "../Portal/Portal";
6
10
  import Button from "../DeprecatedButton";
7
- const {
8
- width: deviceWidth,
9
- height: deviceHeight
10
- } = Dimensions.get("screen");
11
- export const PickerComponent = _ref => {
11
+ import TextField from "../TextField";
12
+ import Touchable from "../Touchable";
13
+ import { extractStyles } from "../../utilities";
14
+
15
+ const Picker = _ref => {
16
+ var _options$find$label, _options$find;
17
+
12
18
  let {
13
19
  Icon,
14
- togglePickerVisible,
15
- pickerOptions,
16
- internalValue,
17
- handleValueChange
20
+ style,
21
+ options,
22
+ placeholder,
23
+ selectedValue,
24
+ disabled = false,
25
+ onValueChange = () => {},
26
+ theme: {
27
+ colors
28
+ },
29
+ ...props
18
30
  } = _ref;
19
- return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(View, {
20
- style: styles.iosPicker
31
+ const {
32
+ viewStyles: {
33
+ borderRadius,
34
+ // eslint-disable-line @typescript-eslint/no-unused-vars
35
+ borderWidth,
36
+ // eslint-disable-line @typescript-eslint/no-unused-vars
37
+ borderTopWidth,
38
+ // eslint-disable-line @typescript-eslint/no-unused-vars
39
+ borderRightWidth,
40
+ // eslint-disable-line @typescript-eslint/no-unused-vars
41
+ borderBottomWidth,
42
+ // eslint-disable-line @typescript-eslint/no-unused-vars
43
+ borderLeftWidth,
44
+ // eslint-disable-line @typescript-eslint/no-unused-vars
45
+ borderColor,
46
+ // eslint-disable-line @typescript-eslint/no-unused-vars
47
+ backgroundColor,
48
+ // eslint-disable-line @typescript-eslint/no-unused-vars
49
+ padding,
50
+ // eslint-disable-line @typescript-eslint/no-unused-vars
51
+ paddingTop,
52
+ // eslint-disable-line @typescript-eslint/no-unused-vars
53
+ paddingRight,
54
+ // eslint-disable-line @typescript-eslint/no-unused-vars
55
+ paddingBottom,
56
+ // eslint-disable-line @typescript-eslint/no-unused-vars
57
+ paddingLeft,
58
+ // eslint-disable-line @typescript-eslint/no-unused-vars
59
+ ...viewStyles
60
+ }
61
+ } = extractStyles(style);
62
+ const textField = React.useRef(undefined);
63
+ const [pickerVisible, setIsPickerVisible] = React.useState(false);
64
+
65
+ const toggleVisibility = () => {
66
+ setIsPickerVisible(!pickerVisible); // @ts-ignore
67
+
68
+ textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
69
+ };
70
+
71
+ const stylesWithoutMargin = style && omit(StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
72
+ const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(o => o.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
73
+ return /*#__PURE__*/React.createElement(View, {
74
+ style: [styles.container, viewStyles]
75
+ }, /*#__PURE__*/React.createElement(Touchable, {
76
+ disabled: disabled,
77
+ onPress: toggleVisibility
78
+ }, /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
79
+ value: String(selectedLabel),
80
+ placeholder: placeholder // @ts-ignore
81
+ ,
82
+ ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
83
+ ,
84
+ disabled: disabled,
85
+ pointerEvents: "none" // @ts-expect-error
86
+ ,
87
+ style: stylesWithoutMargin,
88
+ Icon: Icon
89
+ }))), pickerVisible && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(View, {
90
+ style: [styles.picker, {
91
+ backgroundColor: colors.divider
92
+ }]
21
93
  }, /*#__PURE__*/React.createElement(SafeAreaView, {
22
- style: styles.iosSafeArea
94
+ style: styles.pickerContainer
23
95
  }, /*#__PURE__*/React.createElement(Button, {
24
96
  Icon: Icon,
25
97
  type: "text",
26
- onPress: togglePickerVisible,
27
- style: styles.iosButton
98
+ onPress: toggleVisibility,
99
+ style: styles.closeButton
28
100
  }, "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
- }))))));
101
+ style: {
102
+ backgroundColor: "white"
103
+ },
104
+ selectedValue: selectedValue,
105
+ onValueChange: onValueChange
106
+ }, options.map(o => /*#__PURE__*/React.createElement(NativePicker.Item, {
107
+ label: o.label,
108
+ value: o.value,
109
+ key: o.value
110
+ })))))));
37
111
  };
112
+
38
113
  const styles = StyleSheet.create({
39
- iosPicker: {
114
+ container: {
115
+ alignSelf: "stretch"
116
+ },
117
+ picker: {
40
118
  position: "absolute",
41
119
  bottom: 0,
42
120
  left: 0,
43
121
  right: 0,
44
122
  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
-
123
+ justifyContent: "center"
53
124
  },
54
- iosSafeArea: {
55
- backgroundColor: "yellow",
56
- // backgroundColor: "white",// TODO
125
+ pickerContainer: {
126
+ backgroundColor: "white",
57
127
  flexDirection: "column",
58
- width: deviceWidth,
59
- maxWidth: deviceWidth
128
+ width: "100%"
60
129
  },
61
- iosButton: {
130
+ closeButton: {
62
131
  alignSelf: "flex-end"
63
- },
64
- iosNativePicker: {
65
- //backgroundColor: "white",// TODO
66
- backgroundColor: "red"
67
132
  }
68
133
  });
134
+ export default withTheme(Picker);
69
135
  //# sourceMappingURL=PickerComponent.ios.js.map
@@ -1 +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,MAF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Bc,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"]}
1
+ {"version":3,"sources":["PickerComponent.ios.tsx"],"names":["React","View","StyleSheet","SafeAreaView","omit","Picker","NativePicker","withTheme","Portal","Button","TextField","Touchable","extractStyles","Icon","style","options","placeholder","selectedValue","disabled","onValueChange","theme","colors","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","pickerVisible","setIsPickerVisible","useState","toggleVisibility","current","toggleFocus","stylesWithoutMargin","flatten","selectedLabel","find","o","value","label","styles","container","String","picker","divider","pickerContainer","closeButton","map","create","alignSelf","position","bottom","left","right","flexDirection","justifyContent","width"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AACA,SAASC,YAAT,QAA6B,gCAA7B;AACA,OAAOC,IAAP,MAAiB,aAAjB;AAEA,SAASC,MAAM,IAAIC,YAAnB,QAAuC,6BAAvC;AAEA,SAASC,SAAT,QAA0B,eAA1B;AAEA,OAAOC,MAAP,MAAmB,kBAAnB;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,SAAP,MAAsB,cAAtB;AAEA,SAASC,aAAT,QAA8B,iBAA9B;;AAGA,MAAMP,MAAiD,GAAG,QAUpD;AAAA;;AAAA,MAVqD;AACzDQ,IAAAA,IADyD;AAEzDC,IAAAA,KAFyD;AAGzDC,IAAAA,OAHyD;AAIzDC,IAAAA,WAJyD;AAKzDC,IAAAA,aALyD;AAMzDC,IAAAA,QAAQ,GAAG,KAN8C;AAOzDC,IAAAA,aAAa,GAAG,MAAM,CAAE,CAPiC;AAQzDC,IAAAA,KAAK,EAAE;AAAEC,MAAAA;AAAF,KARkD;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AGnD,UAAU,CAAC2D,MAAX,CAAkB;AAC/BP,EAAAA,SAAS,EAAE;AACTQ,IAAAA,SAAS,EAAE;AADF,GADoB;AAI/BN,EAAAA,MAAM,EAAE;AACNO,IAAAA,QAAQ,EAAE,UADJ;AAENC,IAAAA,MAAM,EAAE,CAFF;AAGNC,IAAAA,IAAI,EAAE,CAHA;AAINC,IAAAA,KAAK,EAAE,CAJD;AAKNC,IAAAA,aAAa,EAAE,KALT;AAMNC,IAAAA,cAAc,EAAE;AANV,GAJuB;AAY/BV,EAAAA,eAAe,EAAE;AACf3B,IAAAA,eAAe,EAAE,OADF;AAEfoC,IAAAA,aAAa,EAAE,QAFA;AAGfE,IAAAA,KAAK,EAAE;AAHQ,GAZc;AAiB/BV,EAAAA,WAAW,EAAE;AACXG,IAAAA,SAAS,EAAE;AADA;AAjBkB,CAAlB,CAAf;AAsBA,eAAevD,SAAS,CAACF,MAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport { SafeAreaView } from \"react-native-safe-area-context\";\nimport omit from \"lodash.omit\";\n\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\n\nimport { withTheme } from \"../../theming\";\n\nimport Portal from \"../Portal/Portal\";\nimport Button from \"../DeprecatedButton\";\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\nimport { extractStyles } from \"../../utilities\";\nimport type { IconSlot } from \"../../interfaces/Icon\";\n\nconst Picker: React.FC<PickerComponentProps & IconSlot> = ({\n Icon,\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange = () => {},\n theme: { colors },\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n const [pickerVisible, setIsPickerVisible] = React.useState(false);\n\n const toggleVisibility = () => {\n setIsPickerVisible(!pickerVisible);\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);\n\n return (\n <View style={[styles.container, viewStyles]}>\n <Touchable disabled={disabled} onPress={toggleVisibility}>\n <TextField\n {...props}\n value={String(selectedLabel)}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n pointerEvents=\"none\"\n // @ts-expect-error\n style={stylesWithoutMargin}\n Icon={Icon}\n />\n </Touchable>\n {pickerVisible && (\n <Portal>\n <View style={[styles.picker, { backgroundColor: colors.divider }]}>\n <SafeAreaView style={styles.pickerContainer}>\n <Button\n Icon={Icon}\n type=\"text\"\n onPress={toggleVisibility}\n style={styles.closeButton}\n >\n Close\n </Button>\n <NativePicker\n style={{ backgroundColor: \"white\" }}\n selectedValue={selectedValue}\n onValueChange={onValueChange}\n >\n {options.map((o: any) => (\n <NativePicker.Item\n label={o.label}\n value={o.value}\n key={o.value}\n />\n ))}\n </NativePicker>\n </SafeAreaView>\n </View>\n </Portal>\n )}\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n picker: {\n position: \"absolute\",\n bottom: 0,\n left: 0,\n right: 0,\n flexDirection: \"row\",\n justifyContent: \"center\",\n },\n pickerContainer: {\n backgroundColor: \"white\",\n flexDirection: \"column\",\n width: \"100%\",\n },\n closeButton: {\n alignSelf: \"flex-end\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
@@ -1,41 +1,113 @@
1
+ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
+
1
3
  import * as React from "react";
2
- import { StyleSheet, Dimensions } from "react-native";
4
+ import { View, StyleSheet } from "react-native";
3
5
  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 => {
6
+ import omit from "lodash.omit";
7
+ import { withTheme } from "../../theming";
8
+ import { extractStyles } from "../../utilities";
9
+ import TextField from "../TextField";
10
+ import Touchable from "../Touchable";
11
+
12
+ const Picker = _ref => {
13
+ var _options$find$label, _options$find;
14
+
9
15
  let {
10
- androidPickerRef,
11
- togglePickerVisible,
12
- pickerOptions,
13
- internalValue,
14
- handleValueChange
16
+ style,
17
+ options,
18
+ placeholder,
19
+ selectedValue,
20
+ disabled = false,
21
+ onValueChange: onValueChangeOverride = () => {},
22
+ ...props
15
23
  } = _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
- })));
24
+ const {
25
+ viewStyles: {
26
+ borderRadius,
27
+ // eslint-disable-line @typescript-eslint/no-unused-vars
28
+ borderWidth,
29
+ // eslint-disable-line @typescript-eslint/no-unused-vars
30
+ borderTopWidth,
31
+ // eslint-disable-line @typescript-eslint/no-unused-vars
32
+ borderRightWidth,
33
+ // eslint-disable-line @typescript-eslint/no-unused-vars
34
+ borderBottomWidth,
35
+ // eslint-disable-line @typescript-eslint/no-unused-vars
36
+ borderLeftWidth,
37
+ // eslint-disable-line @typescript-eslint/no-unused-vars
38
+ borderColor,
39
+ // eslint-disable-line @typescript-eslint/no-unused-vars
40
+ backgroundColor,
41
+ // eslint-disable-line @typescript-eslint/no-unused-vars
42
+ padding,
43
+ // eslint-disable-line @typescript-eslint/no-unused-vars
44
+ paddingTop,
45
+ // eslint-disable-line @typescript-eslint/no-unused-vars
46
+ paddingRight,
47
+ // eslint-disable-line @typescript-eslint/no-unused-vars
48
+ paddingBottom,
49
+ // eslint-disable-line @typescript-eslint/no-unused-vars
50
+ paddingLeft,
51
+ // eslint-disable-line @typescript-eslint/no-unused-vars
52
+ ...viewStyles
53
+ }
54
+ } = extractStyles(style);
55
+ const textField = React.useRef(undefined);
56
+
57
+ const onValueChange = (itemValue, itemIndex) => {
58
+ toggleFocus();
59
+ onValueChangeOverride(itemValue, itemIndex);
60
+ };
61
+
62
+ const toggleFocus = () => {
63
+ if (!disabled) {
64
+ // @ts-ignore
65
+ textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
66
+ }
67
+ };
68
+
69
+ const stylesWithoutMargin = style && omit(StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
70
+ const selectedLabel = selectedValue && ((_options$find$label = (_options$find = options.find(o => o.value === selectedValue)) === null || _options$find === void 0 ? void 0 : _options$find.label) !== null && _options$find$label !== void 0 ? _options$find$label : selectedValue);
71
+ return /*#__PURE__*/React.createElement(Touchable, {
72
+ disabled: disabled,
73
+ onPress: toggleFocus,
74
+ style: [styles.container, viewStyles]
75
+ }, /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(NativePicker, {
76
+ enabled: !disabled,
77
+ selectedValue: selectedValue,
78
+ onValueChange: onValueChange,
79
+ style: {
80
+ flex: 1,
81
+ opacity: 0,
82
+ position: "absolute",
83
+ top: 0,
84
+ left: 0,
85
+ right: 0,
86
+ bottom: 0,
87
+ width: "100%"
88
+ }
89
+ }, options.map(o => /*#__PURE__*/React.createElement(NativePicker.Item, {
90
+ label: o.label,
91
+ value: o.value,
92
+ key: o.value
93
+ }))), /*#__PURE__*/React.createElement(View, {
94
+ pointerEvents: "none"
95
+ }, /*#__PURE__*/React.createElement(TextField, _extends({}, props, {
96
+ value: selectedLabel,
97
+ placeholder: placeholder // @ts-ignore
98
+ ,
99
+ ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
100
+ ,
101
+ disabled: disabled // @ts-expect-error
102
+ ,
103
+ style: stylesWithoutMargin
104
+ })))));
27
105
  };
106
+
28
107
  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
108
+ container: {
109
+ alignSelf: "stretch"
39
110
  }
40
111
  });
112
+ export default withTheme(Picker);
41
113
  //# sourceMappingURL=PickerComponent.web.js.map
@@ -1 +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;AAC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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
+ {"version":3,"sources":["PickerComponent.web.tsx"],"names":["React","View","StyleSheet","Picker","NativePicker","omit","withTheme","extractStyles","TextField","Touchable","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","flatten","selectedLabel","find","o","value","label","styles","container","flex","opacity","position","top","left","right","bottom","width","map","create","alignSelf"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA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1D,IADD,CAfH,CADF,eAoBE,oBAAC,IAAD;AAAM,IAAA,aAAa,EAAC;AAApB,kBACE,oBAAC,SAAD,eACM3B,KADN;AAEE,IAAA,KAAK,EAAEwB,aAFT;AAGE,IAAA,WAAW,EAAE7B,WAHf,CAIE;AAJF;AAKE,IAAA,GAAG,EAAEoB,SALP,CAKkB;AALlB;AAME,IAAA,QAAQ,EAAElB,QANZ,CAOE;AAPF;AAQE,IAAA,KAAK,EAAEyB;AART,KADF,CApBF,CALF,CADF;AAyCD,CAjGD;;AAmGA,MAAMO,MAAM,GAAG5C,UAAU,CAACuD,MAAX,CAAkB;AAC/BV,EAAAA,SAAS,EAAE;AACTW,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;AAMA,eAAepD,SAAS,CAACH,MAAD,CAAxB","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { extractStyles } from \"../../utilities\";\n\nimport TextField from \"../TextField\";\nimport Touchable from \"../Touchable\";\nimport { PickerComponentProps } from \"./PickerTypes\";\n\nconst Picker: React.FC<PickerComponentProps> = ({\n style,\n options,\n placeholder,\n selectedValue,\n disabled = false,\n onValueChange: onValueChangeOverride = () => {},\n ...props\n}) => {\n const {\n viewStyles: {\n borderRadius, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderTopWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderRightWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderBottomWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderLeftWidth, // eslint-disable-line @typescript-eslint/no-unused-vars\n borderColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n backgroundColor, // eslint-disable-line @typescript-eslint/no-unused-vars\n padding, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingTop, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingRight, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingBottom, // eslint-disable-line @typescript-eslint/no-unused-vars\n paddingLeft, // eslint-disable-line @typescript-eslint/no-unused-vars\n ...viewStyles\n },\n } = extractStyles(style);\n\n const textField = React.useRef<typeof TextField | undefined>(undefined);\n\n const onValueChange = (itemValue: string, itemIndex: number) => {\n toggleFocus();\n onValueChangeOverride(itemValue, itemIndex);\n };\n\n const toggleFocus = () => {\n if (!disabled) {\n // @ts-ignore\n textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()\n }\n };\n\n const stylesWithoutMargin =\n style &&\n omit(StyleSheet.flatten(style), [\n \"margin\",\n \"marginTop\",\n \"marginRight\",\n \"marginBottom\",\n \"marginLeft\",\n ]);\n\n const selectedLabel =\n selectedValue &&\n (options.find((o) => o.value === selectedValue)?.label ?? selectedValue);\n\n return (\n <Touchable\n disabled={disabled}\n onPress={toggleFocus}\n style={[styles.container, viewStyles]}\n >\n <View>\n <NativePicker\n enabled={!disabled}\n selectedValue={selectedValue}\n onValueChange={onValueChange}\n style={{\n flex: 1,\n opacity: 0,\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n width: \"100%\",\n }}\n >\n {options.map((o) => (\n <NativePicker.Item label={o.label} value={o.value} key={o.value} />\n ))}\n </NativePicker>\n <View pointerEvents=\"none\">\n <TextField\n {...props}\n value={selectedLabel}\n placeholder={placeholder}\n // @ts-ignore\n ref={textField} // cannot determine if ref is of correct type due to component being wrapped in a withTheme()\n disabled={disabled}\n // @ts-expect-error\n style={stylesWithoutMargin}\n />\n </View>\n </View>\n </Touchable>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n alignSelf: \"stretch\",\n },\n});\n\nexport default withTheme(Picker);\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PickerTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -1,35 +1,11 @@
1
1
  import * as React from "react";
2
- import { ViewStyle, StyleProp } from "react-native";
3
- import type { Theme } from "../../styles/DefaultTheme";
4
- import type { IconSlot } from "../../interfaces/Icon";
5
- export interface PickerOption {
6
- value: string;
7
- label: string;
8
- }
9
- export declare type PickerProps = {
10
- error?: any;
2
+ import { PickerComponentProps, PickerOption } from "./PickerTypes";
3
+ declare type Props = PickerComponentProps & {
11
4
  placeholder?: string;
12
- disabled?: boolean;
13
- style?: StyleProp<ViewStyle> & {
14
- height?: number;
15
- };
16
5
  value?: string;
17
6
  options: PickerOption[] | string[];
18
- onValueChange: (value: string, index: number) => void;
19
- defaultValue?: string;
20
- assistiveText?: string;
21
- label?: string;
22
- iconColor?: string;
23
- iconSize?: number;
24
- leftIconMode?: "inset" | "outset";
25
- leftIconName?: string;
26
- placeholderTextColor?: string;
27
- rightIconName?: string;
28
- type?: "solid" | "underline";
29
- theme: Theme;
30
- Icon: IconSlot["Icon"];
31
7
  };
32
- declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PickerProps, "theme"> & {
8
+ declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<Props, "theme"> & {
33
9
  theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
34
- }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<PickerProps> & React.FC<PickerProps>, {}>;
10
+ }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<Props> & React.FC<Props>, {}>;
35
11
  export default _default;
@@ -1,13 +1,6 @@
1
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 {};
2
+ import { PickerComponentProps } from "./PickerTypes";
3
+ declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PickerComponentProps, "theme"> & {
4
+ theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
5
+ }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<PickerComponentProps> & React.FC<PickerComponentProps>, {}>;
6
+ export default _default;
@@ -1,13 +1,7 @@
1
1
  import * as React from "react";
2
+ import { PickerComponentProps } from "./PickerTypes";
2
3
  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 {};
4
+ declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PickerComponentProps & IconSlot, "theme"> & {
5
+ theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
6
+ }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<PickerComponentProps & IconSlot> & React.FC<PickerComponentProps & IconSlot>, {}>;
7
+ export default _default;
@@ -1,13 +1,6 @@
1
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 {};
2
+ import { PickerComponentProps } from "./PickerTypes";
3
+ declare const _default: React.ComponentType<import("@draftbit/react-theme-provider").$Without<PickerComponentProps, "theme"> & {
4
+ theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
5
+ }> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<PickerComponentProps> & React.FC<PickerComponentProps>, {}>;
6
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import { ViewStyle } from "react-native";
2
+ import { StyleProp } from "react-native";
3
+ import { Props as TextFieldProps } from "../TextField";
4
+ export interface PickerOption {
5
+ value: string;
6
+ label: string;
7
+ }
8
+ export interface PickerComponentProps extends TextFieldProps {
9
+ style?: StyleProp<ViewStyle> & {
10
+ height?: number;
11
+ };
12
+ options: PickerOption[];
13
+ placeholder?: string;
14
+ selectedValue: string;
15
+ disabled?: boolean;
16
+ onValueChange?: (value: string, index: number) => void;
17
+ defaultValue?: string;
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@draftbit/core",
3
- "version": "44.1.14",
3
+ "version": "44.1.15",
4
4
  "description": "Core (non-native) Components",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -79,5 +79,5 @@
79
79
  ]
80
80
  ]
81
81
  },
82
- "gitHead": "5d730f7f97002f5c0bdd0ad810d44422b3176900"
82
+ "gitHead": "826fabffa6a3250ff29a7018cc6048de9a4eb2e3"
83
83
  }