@draftbit/core 44.1.12 → 44.1.13-6f194c.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.
Files changed (30) hide show
  1. package/lib/commonjs/components/Accordion/index.js.map +1 -1
  2. package/lib/commonjs/components/Picker/Picker.js +23 -47
  3. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  4. package/lib/commonjs/components/Picker/PickerComponent.android.js +34 -0
  5. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +1 -0
  6. package/lib/commonjs/components/Picker/PickerComponent.js +253 -0
  7. package/lib/commonjs/components/Picker/PickerComponent.js.map +1 -0
  8. package/lib/commonjs/components/Picker/PickerComponent.web.js +34 -0
  9. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +1 -0
  10. package/lib/module/components/Picker/Picker.js +26 -47
  11. package/lib/module/components/Picker/Picker.js.map +1 -1
  12. package/lib/module/components/Picker/PickerComponent.android.js +21 -0
  13. package/lib/module/components/Picker/PickerComponent.android.js.map +1 -0
  14. package/lib/module/components/Picker/PickerComponent.js +231 -0
  15. package/lib/module/components/Picker/PickerComponent.js.map +1 -0
  16. package/lib/module/components/Picker/PickerComponent.web.js +21 -0
  17. package/lib/module/components/Picker/PickerComponent.web.js.map +1 -0
  18. package/lib/module/components/StepIndicator.js.map +1 -1
  19. package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +13 -0
  20. package/lib/typescript/src/components/Picker/PickerComponent.d.ts +4501 -0
  21. package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +13 -0
  22. package/package.json +2 -2
  23. package/src/components/Picker/Picker.js +21 -19
  24. package/src/components/Picker/Picker.tsx +30 -12
  25. package/src/components/Picker/PickerComponent.android.js +18 -0
  26. package/src/components/Picker/PickerComponent.android.tsx +37 -0
  27. package/src/components/Picker/PickerComponent.js +185 -0
  28. package/src/components/Picker/PickerComponent.tsx +321 -0
  29. package/src/components/Picker/PickerComponent.web.js +18 -0
  30. package/src/components/Picker/PickerComponent.web.tsx +37 -0
@@ -0,0 +1,321 @@
1
+ import * as React from "react";
2
+ import { View, /* StyleSheet, */ Text, Platform } from "react-native";
3
+ import { SafeAreaView } from "react-native-safe-area-context";
4
+ import { omit, pick, pickBy, identity } from "lodash";
5
+ import { Picker as NativePicker } from "@react-native-picker/picker";
6
+
7
+ import { withTheme } from "../../theming";
8
+ import Portal from "../Portal/Portal";
9
+ import Button from "../DeprecatedButton";
10
+ import Touchable from "../Touchable";
11
+ import { PickerProps, PickerOption } from "./Picker";
12
+ import { extractStyles } from "../../utilities";
13
+ import type { IconSlot } from "../../interfaces/Icon";
14
+ import type { Theme } from "../../styles/DefaultTheme";
15
+
16
+ const Picker: React.FC<PickerProps & IconSlot & Theme> = ({
17
+ Icon,
18
+ style,
19
+ options = [],
20
+ placeholder = "",
21
+ value: selectedValue = "",
22
+ disabled = false,
23
+ onValueChange = () => {},
24
+ theme,
25
+ assistiveText,
26
+ label,
27
+ leftIconMode = "inset",
28
+ leftIconName,
29
+ placeholderTextColor,
30
+ rightIconName,
31
+ type,
32
+ }) => {
33
+ const [pickerVisible, setIsPickerVisible] = React.useState(false);
34
+
35
+ const { viewStyles, textStyles } = extractStyles(style);
36
+
37
+ const { colors } = theme;
38
+
39
+ console.log({
40
+ // viewStyles,
41
+ // textStyles,
42
+ // options,
43
+ // placeholder,
44
+ // selectedValue,
45
+ // theme,
46
+ // disabled,
47
+ // onValueChange,
48
+ // colors,
49
+ // assistiveText,
50
+ // label,
51
+ // leftIconMode,
52
+ // leftIconName,
53
+ // placeholderTextColor,
54
+ // rightIconName,
55
+ // type,
56
+ });
57
+
58
+ const borders = [
59
+ "borderRadius",
60
+ "borderTopLeftRadius",
61
+ "borderTopRightRadius",
62
+ "borderBottomRightRadius",
63
+ "borderBottomLeftRadius",
64
+ "borderTopWidth",
65
+ "borderRightWidth",
66
+ "borderBottomWidth",
67
+ "borderLeftWidth",
68
+ "borderColor",
69
+ "borderStyle",
70
+ ];
71
+
72
+ const borderStyles = {
73
+ ...{
74
+ ...(type === "solid"
75
+ ? {
76
+ borderTopLeftRadius: 5,
77
+ borderTopRightRadius: 5,
78
+ borderBottomRightRadius: 5,
79
+ borderBottomLeftRadius: 5,
80
+ borderTopWidth: 1,
81
+ borderRightWidth: 1,
82
+ borderLeftWidth: 1,
83
+ }
84
+ : {}),
85
+ borderBottomWidth: 1,
86
+ borderColor: colors.light,
87
+ borderStyle: "solid",
88
+ },
89
+ ...pick(viewStyles, borders),
90
+ };
91
+
92
+ const margins = ["marginLeft", "marginRight", "marginTop", "marginBottom"];
93
+
94
+ const marginStyles = pick(viewStyles, margins);
95
+
96
+ const stylesWithoutBordersAndMargins = {
97
+ ...{
98
+ height: 60,
99
+ width: "100%",
100
+ },
101
+ ...omit(viewStyles, [...borders, ...margins]),
102
+ };
103
+
104
+ const selectedLabel =
105
+ selectedValue &&
106
+ ((options as unknown as PickerOption[]).find(
107
+ (o) => o.value === selectedValue
108
+ )?.label ??
109
+ selectedValue);
110
+
111
+ const labelText = label ? (
112
+ <Text
113
+ style={{
114
+ textAlign: textStyles.textAlign,
115
+ color: colors.light,
116
+ fontSize: 12,
117
+ paddingBottom: 4,
118
+ }}
119
+ >
120
+ {label}
121
+ </Text>
122
+ ) : null;
123
+
124
+ const leftIconOutset = leftIconMode === "outset";
125
+
126
+ const leftIcon = leftIconName ? (
127
+ <Icon
128
+ name={leftIconName}
129
+ size={24}
130
+ style={{
131
+ marginRight: 8,
132
+ marginLeft: -6,
133
+ }}
134
+ />
135
+ ) : null;
136
+
137
+ const rightIcon = rightIconName ? (
138
+ <Icon
139
+ name={rightIconName}
140
+ size={24}
141
+ style={{
142
+ marginRight: -6,
143
+ marginLeft: 8,
144
+ }}
145
+ />
146
+ ) : null;
147
+
148
+ // @ts-ignore
149
+ const width = stylesWithoutBordersAndMargins?.width ?? undefined;
150
+
151
+ const textAlign = textStyles?.textAlign;
152
+
153
+ const paddingLeft =
154
+ leftIconOutset &&
155
+ (!textAlign || textAlign === "left" || textAlign === "justify")
156
+ ? 28 // icon size + 4
157
+ : 0;
158
+
159
+ const assistiveTextLabel = assistiveText ? (
160
+ <Text
161
+ style={{
162
+ textAlign,
163
+ width,
164
+ paddingLeft,
165
+ color: colors.light,
166
+ fontSize: 12,
167
+ paddingTop: 4,
168
+ }}
169
+ >
170
+ {assistiveText}
171
+ </Text>
172
+ ) : null;
173
+
174
+ const primaryTextStyle = {
175
+ color: colors.light,
176
+ fontSize: 14,
177
+ ...pickBy(textStyles, identity),
178
+ ...(placeholder === selectedValue
179
+ ? { color: placeholderTextColor ?? colors.light }
180
+ : {}),
181
+ };
182
+
183
+ const toggleVisibility = () => setIsPickerVisible(!pickerVisible);
184
+
185
+ return (
186
+ <View
187
+ style={[
188
+ {
189
+ alignSelf: "stretch",
190
+ },
191
+ marginStyles,
192
+ ]}
193
+ >
194
+ <Touchable
195
+ disabled={disabled}
196
+ onPress={toggleVisibility}
197
+ style={{ alignSelf: "stretch", alignItems: "center" }}
198
+ >
199
+ <View
200
+ pointerEvents="none"
201
+ style={[
202
+ {
203
+ //alignSelf: "stretch",
204
+ flexDirection: "row",
205
+ alignItems: "center",
206
+ justifyContent: "space-between",
207
+ },
208
+ stylesWithoutBordersAndMargins,
209
+ // @ts-ignore
210
+ !leftIconOutset && borderStyles,
211
+ ]}
212
+ >
213
+ {leftIcon}
214
+
215
+ <View
216
+ style={[
217
+ {
218
+ flex: 1,
219
+ height: "100%",
220
+ flexDirection: "row",
221
+ alignItems: "center",
222
+ justifyContent: "space-between",
223
+ paddingLeft: 12,
224
+ paddingRight: 12,
225
+ },
226
+ // @ts-ignore
227
+ leftIconOutset && borderStyles,
228
+ ]}
229
+ >
230
+ <View
231
+ style={{
232
+ flex: 1,
233
+ // paddingTop: 0,
234
+ // paddingRight: 0, // add inner text paddding settings
235
+ // paddingLeft: 0,
236
+ // paddingBottom: 0,
237
+ }}
238
+ >
239
+ {labelText}
240
+
241
+ <Text style={primaryTextStyle}>
242
+ {String(selectedLabel ?? placeholder)}
243
+ </Text>
244
+ </View>
245
+
246
+ {rightIcon}
247
+ </View>
248
+ </View>
249
+ {assistiveTextLabel}
250
+ </Touchable>
251
+
252
+ {Platform.OS === "ios" && pickerVisible ? (
253
+ <Portal>
254
+ <View
255
+ style={{
256
+ position: "absolute",
257
+ bottom: 0,
258
+ left: 0,
259
+ right: 0,
260
+ flexDirection: "row",
261
+ justifyContent: "center",
262
+ backgroundColor: colors.divider,
263
+ }}
264
+ >
265
+ <SafeAreaView
266
+ style={{
267
+ backgroundColor: "white",
268
+ flexDirection: "column",
269
+ width: "100%",
270
+ }}
271
+ >
272
+ <Button
273
+ Icon={Icon}
274
+ type="text"
275
+ onPress={toggleVisibility}
276
+ style={{ alignSelf: "flex-end" }}
277
+ >
278
+ {"Close"}
279
+ </Button>
280
+
281
+ <NativePicker
282
+ style={{ backgroundColor: "white" }}
283
+ selectedValue={selectedValue}
284
+ onValueChange={onValueChange}
285
+ >
286
+ {(options as unknown as PickerOption[]).map((o) => (
287
+ <NativePicker.Item
288
+ label={o.label}
289
+ value={o.value}
290
+ key={o.value}
291
+ />
292
+ ))}
293
+ </NativePicker>
294
+ </SafeAreaView>
295
+ </View>
296
+ </Portal>
297
+ ) : (
298
+ <NativePicker
299
+ enabled={pickerVisible}
300
+ selectedValue={selectedValue}
301
+ onValueChange={onValueChange}
302
+ style={{
303
+ opacity: 0,
304
+ position: "absolute",
305
+ top: 0,
306
+ left: 0,
307
+ right: 0,
308
+ bottom: 0,
309
+ width: "100%",
310
+ }}
311
+ >
312
+ {(options as unknown as PickerOption[]).map((o) => (
313
+ <NativePicker.Item label={o.label} value={o.value} key={o.value} />
314
+ ))}
315
+ </NativePicker>
316
+ )}
317
+ </View>
318
+ );
319
+ };
320
+
321
+ export default withTheme(Picker);
@@ -0,0 +1,18 @@
1
+ import * as React from "react";
2
+ import { /* StyleSheet, Dimensions, */ Text } from "react-native";
3
+ export const PickerComponent = () => {
4
+ return React.createElement(Text, null, "web");
5
+ };
6
+ // const styles = StyleSheet.create({
7
+ // nonIosPicker: {
8
+ // opacity: 0,
9
+ // position: "absolute",
10
+ // top: 0,
11
+ // left: 0,
12
+ // right: 0,
13
+ // bottom: 0,
14
+ // width: "100%",
15
+ // maxWidth: deviceWidth,
16
+ // maxHeight: deviceHeight,
17
+ // },
18
+ // });
@@ -0,0 +1,37 @@
1
+ import * as React from "react";
2
+ import { /* StyleSheet, Dimensions, */ Text } from "react-native";
3
+
4
+ // import { Picker as NativePicker } from "@react-native-picker/picker";
5
+
6
+ import type { IconSlot } from "../../interfaces/Icon";
7
+
8
+ import { PickerOption } from "./Picker";
9
+
10
+ // const { width: deviceWidth, height: deviceHeight } = Dimensions.get("screen");
11
+
12
+ interface PickerComponentProps {
13
+ Icon: IconSlot["Icon"];
14
+ androidPickerRef: React.RefObject<any>;
15
+ togglePickerVisible: () => void;
16
+ pickerOptions: PickerOption[];
17
+ internalValue: string | undefined;
18
+ handleValueChange: (newValue: string, itemIndex: number) => void;
19
+ }
20
+
21
+ export const PickerComponent: React.FC<PickerComponentProps> = () => {
22
+ return <Text>web</Text>;
23
+ };
24
+
25
+ // const styles = StyleSheet.create({
26
+ // nonIosPicker: {
27
+ // opacity: 0,
28
+ // position: "absolute",
29
+ // top: 0,
30
+ // left: 0,
31
+ // right: 0,
32
+ // bottom: 0,
33
+ // width: "100%",
34
+ // maxWidth: deviceWidth,
35
+ // maxHeight: deviceHeight,
36
+ // },
37
+ // });