@draftbit/core 44.1.7 → 44.1.9-222859.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/lib/commonjs/components/ActionSheet/ActionSheetItem.js.map +1 -1
  2. package/lib/commonjs/components/DeprecatedFAB.js +4 -20
  3. package/lib/commonjs/components/Picker/Picker.js +254 -27
  4. package/lib/commonjs/components/Picker/Picker.js.map +1 -1
  5. package/lib/commonjs/components/StepIndicator.js.map +1 -1
  6. package/lib/commonjs/components/Stepper.js.map +1 -1
  7. package/lib/commonjs/hooks.js.map +1 -1
  8. package/lib/commonjs/mappings/MapCallout.js +1 -0
  9. package/lib/commonjs/mappings/MapCallout.js.map +1 -1
  10. package/lib/commonjs/mappings/Picker.js +3 -1
  11. package/lib/commonjs/mappings/Picker.js.map +1 -1
  12. package/lib/commonjs/mappings/ScrollView.js.map +1 -1
  13. package/lib/commonjs/mappings/WebView.js.map +1 -1
  14. package/lib/module/components/HeaderLarge.js.map +1 -1
  15. package/lib/module/components/Picker/Picker.js +241 -29
  16. package/lib/module/components/Picker/Picker.js.map +1 -1
  17. package/lib/module/mappings/AudioPlayer.js.map +1 -1
  18. package/lib/module/mappings/MapCallout.js +2 -1
  19. package/lib/module/mappings/MapCallout.js.map +1 -1
  20. package/lib/module/mappings/Picker.js +4 -2
  21. package/lib/module/mappings/Picker.js.map +1 -1
  22. package/lib/typescript/src/components/Picker/Picker.d.ts +28 -4
  23. package/lib/typescript/src/mappings/MapCallout.d.ts +1 -0
  24. package/lib/typescript/src/mappings/Picker.d.ts +21 -0
  25. package/package.json +2 -2
  26. package/src/components/Picker/Picker.js +188 -18
  27. package/src/components/Picker/Picker.tsx +364 -35
  28. package/src/mappings/MapCallout.js +2 -1
  29. package/src/mappings/MapCallout.ts +2 -0
  30. package/src/mappings/Picker.js +3 -1
  31. package/src/mappings/Picker.ts +4 -0
  32. package/lib/commonjs/components/Picker/PickerComponent.android.js +0 -135
  33. package/lib/commonjs/components/Picker/PickerComponent.android.js.map +0 -1
  34. package/lib/commonjs/components/Picker/PickerComponent.ios.js +0 -161
  35. package/lib/commonjs/components/Picker/PickerComponent.ios.js.map +0 -1
  36. package/lib/commonjs/components/Picker/PickerComponent.web.js +0 -136
  37. package/lib/commonjs/components/Picker/PickerComponent.web.js.map +0 -1
  38. package/lib/commonjs/components/Picker/PickerTypes.js +0 -6
  39. package/lib/commonjs/components/Picker/PickerTypes.js.map +0 -1
  40. package/lib/module/components/Picker/PickerComponent.android.js +0 -112
  41. package/lib/module/components/Picker/PickerComponent.android.js.map +0 -1
  42. package/lib/module/components/Picker/PickerComponent.ios.js +0 -135
  43. package/lib/module/components/Picker/PickerComponent.ios.js.map +0 -1
  44. package/lib/module/components/Picker/PickerComponent.web.js +0 -113
  45. package/lib/module/components/Picker/PickerComponent.web.js.map +0 -1
  46. package/lib/module/components/Picker/PickerTypes.js +0 -2
  47. package/lib/module/components/Picker/PickerTypes.js.map +0 -1
  48. package/lib/typescript/src/components/Picker/PickerComponent.android.d.ts +0 -6
  49. package/lib/typescript/src/components/Picker/PickerComponent.ios.d.ts +0 -7
  50. package/lib/typescript/src/components/Picker/PickerComponent.web.d.ts +0 -6
  51. package/lib/typescript/src/components/Picker/PickerTypes.d.ts +0 -18
  52. package/src/components/Picker/PickerComponent.android.js +0 -68
  53. package/src/components/Picker/PickerComponent.android.tsx +0 -116
  54. package/src/components/Picker/PickerComponent.ios.js +0 -78
  55. package/src/components/Picker/PickerComponent.ios.tsx +0 -142
  56. package/src/components/Picker/PickerComponent.web.js +0 -69
  57. package/src/components/Picker/PickerComponent.web.tsx +0 -117
  58. package/src/components/Picker/PickerTypes.js +0 -1
  59. package/src/components/Picker/PickerTypes.ts +0 -18
@@ -1,31 +1,72 @@
1
1
  import * as React from "react";
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ Text,
6
+ Platform,
7
+ ViewStyle,
8
+ StyleProp,
9
+ Dimensions,
10
+ } from "react-native";
11
+ import { omit, pick, pickBy, identity } from "lodash";
12
+ import { SafeAreaView } from "react-native-safe-area-context";
13
+ import { Picker as NativePicker } from "@react-native-picker/picker";
14
+
2
15
  import { withTheme } from "../../theming";
3
- //@ts-ignore
4
- import PickerComponent from "./PickerComponent"; //unable to find file due to using .android/.web/.ios
5
- import { PickerComponentProps, PickerOption } from "./PickerTypes";
16
+ import Portal from "../Portal/Portal";
17
+ import Button from "../DeprecatedButton";
18
+ import Touchable from "../Touchable";
19
+ import type { Theme } from "../../styles/DefaultTheme";
20
+ import type { IconSlot } from "../../interfaces/Icon";
21
+ import { extractStyles } from "../../utilities";
22
+
23
+ export interface PickerOption {
24
+ value: string;
25
+ label: string;
26
+ }
6
27
 
7
- type Props = PickerComponentProps & {
28
+ export type PickerProps = {
29
+ error?: any;
8
30
  placeholder?: string;
31
+ disabled?: boolean;
32
+ style?: StyleProp<ViewStyle> & { height?: number };
9
33
  value?: string;
10
34
  options: PickerOption[] | string[];
35
+ onValueChange: (value: string, index: number) => void;
36
+ defaultValue?: string;
37
+ assistiveText?: string;
38
+ label?: string;
39
+ iconColor?: string;
40
+ iconSize?: number;
41
+ leftIconMode?: "inset" | "outset";
42
+ leftIconName?: string;
43
+ placeholderTextColor?: string;
44
+ rightIconName?: string;
45
+ type?: "solid" | "underline";
46
+ theme: Theme;
47
+ Icon: IconSlot["Icon"];
11
48
  };
12
49
 
13
- function normalizeOptions(options: Props["options"]): PickerOption[] {
50
+ function normalizeOptions(options: PickerProps["options"]): PickerOption[] {
14
51
  if (options.length === 0) {
15
52
  return [];
16
53
  }
17
54
 
18
- if (typeof options[0] === "string") {
55
+ if (typeof options[0] === ("string" || "number")) {
19
56
  return (options as string[]).map((option) => ({
20
- label: option,
57
+ label: String(option),
21
58
  value: String(option),
22
59
  }));
23
60
  }
24
61
 
25
- if (options[0].label && options[0].value) {
26
- return options.map((option) => {
62
+ if (
63
+ typeof options[0] === "object" &&
64
+ options[0].value !== null &&
65
+ options[0].label !== null
66
+ ) {
67
+ return (options as PickerOption[]).map((option) => {
27
68
  return {
28
- label: option.label,
69
+ label: String(option.label),
29
70
  value: String(option.value),
30
71
  };
31
72
  });
@@ -36,18 +77,40 @@ function normalizeOptions(options: Props["options"]): PickerOption[] {
36
77
  );
37
78
  }
38
79
 
39
- const Picker: React.FC<Props> = ({
80
+ const unstyledColor = "rgba(165, 173, 183, 1)";
81
+ const disabledColor = "rgb(240, 240, 240)";
82
+ const errorColor = "rgba(255, 69, 100, 1)";
83
+
84
+ const Picker: React.FC<PickerProps> = ({
85
+ error,
40
86
  options = [],
87
+ onValueChange,
88
+ defaultValue,
89
+ Icon,
90
+ style,
41
91
  placeholder,
42
- onValueChange: onValueChangeOverride,
43
92
  value,
44
- defaultValue,
45
- ...props
93
+ disabled = false,
94
+ theme,
95
+ assistiveText,
96
+ label,
97
+ iconColor = unstyledColor,
98
+ iconSize = 24,
99
+ leftIconMode = "inset",
100
+ leftIconName,
101
+ placeholderTextColor = unstyledColor,
102
+ rightIconName,
103
+ type = "solid",
46
104
  }) => {
47
105
  const [internalValue, setInternalValue] = React.useState<string | undefined>(
48
106
  value || defaultValue
49
107
  );
50
108
 
109
+ const [pickerVisible, togglePickerVisible] = React.useReducer(
110
+ (state) => !state,
111
+ false
112
+ );
113
+
51
114
  React.useEffect(() => {
52
115
  if (value != null) {
53
116
  setInternalValue(value);
@@ -60,39 +123,305 @@ const Picker: React.FC<Props> = ({
60
123
  }
61
124
  }, [defaultValue]);
62
125
 
63
- const onValueChange = React.useCallback(
64
- (itemValue: string, itemIndex: number) => {
65
- if (placeholder && itemIndex === 0) {
66
- return;
67
- }
68
- onValueChangeOverride &&
69
- onValueChangeOverride(String(itemValue), itemIndex);
70
- },
71
- [placeholder, onValueChangeOverride]
72
- );
73
-
74
126
  const normalizedOptions = normalizeOptions(options);
75
127
 
76
128
  const pickerOptions = placeholder
77
129
  ? [{ value: placeholder, label: placeholder }, ...normalizedOptions]
78
130
  : normalizedOptions;
79
131
 
132
+ const { viewStyles, textStyles } = extractStyles(style);
133
+
134
+ const { colors } = theme;
135
+
136
+ const borders = [
137
+ "borderRadius",
138
+ "borderTopLeftRadius",
139
+ "borderTopRightRadius",
140
+ "borderBottomRightRadius",
141
+ "borderBottomLeftRadius",
142
+ "borderTopWidth",
143
+ "borderRightWidth",
144
+ "borderBottomWidth",
145
+ "borderLeftWidth",
146
+ "borderColor",
147
+ "borderStyle",
148
+ "backgroundColor",
149
+ ];
150
+
151
+ const borderStyles = {
152
+ ...{
153
+ ...(type === "solid"
154
+ ? {
155
+ borderTopLeftRadius: 5,
156
+ borderTopRightRadius: 5,
157
+ borderBottomRightRadius: 5,
158
+ borderBottomLeftRadius: 5,
159
+ borderTopWidth: 1,
160
+ borderRightWidth: 1,
161
+ borderLeftWidth: 1,
162
+ }
163
+ : {}),
164
+ borderBottomWidth: 1,
165
+ borderColor: unstyledColor,
166
+ borderStyle: "solid",
167
+ },
168
+ ...pick(viewStyles, borders),
169
+ ...(error ? { borderColor: errorColor } : {}),
170
+ ...(disabled
171
+ ? { borderColor: "transparent", backgroundColor: disabledColor }
172
+ : {}),
173
+ };
174
+
175
+ const margins = ["marginLeft", "marginRight", "marginTop", "marginBottom"];
176
+
177
+ const marginStyles = pick(viewStyles, margins);
178
+
179
+ const maxHeight =
180
+ viewStyles?.maxHeight && viewStyles.maxHeight !== "100%"
181
+ ? viewStyles.maxHeight
182
+ : Dimensions.get("window").height;
183
+
184
+ const stylesWithoutBordersAndMargins = {
185
+ ...{
186
+ height: 60,
187
+ width: "100%",
188
+ },
189
+ ...omit(viewStyles, [...borders, ...margins]),
190
+ ...{ maxHeight },
191
+ };
192
+
193
+ const selectedLabel =
194
+ internalValue &&
195
+ ((pickerOptions as unknown as PickerOption[]).find(
196
+ (option) => option.value === internalValue
197
+ )?.label ??
198
+ internalValue);
199
+
200
+ const labelText = label ? (
201
+ <Text
202
+ style={{
203
+ textAlign: textStyles.textAlign,
204
+ color: unstyledColor,
205
+ fontSize: 12,
206
+ paddingBottom: 4,
207
+ }}
208
+ >
209
+ {label}
210
+ </Text>
211
+ ) : null;
212
+
213
+ const leftIconOutset = leftIconMode === "outset";
214
+
215
+ const leftIcon = leftIconName ? (
216
+ <Icon
217
+ name={leftIconName}
218
+ color={disabled ? unstyledColor : iconColor}
219
+ size={iconSize}
220
+ style={{
221
+ marginRight: 4,
222
+ marginLeft: 4,
223
+ }}
224
+ />
225
+ ) : null;
226
+
227
+ const rightIcon = rightIconName ? (
228
+ <Icon
229
+ name={rightIconName}
230
+ color={disabled ? unstyledColor : iconColor}
231
+ size={iconSize}
232
+ style={{
233
+ marginRight: -10,
234
+ marginLeft: 8,
235
+ }}
236
+ />
237
+ ) : null;
238
+
239
+ const width = stylesWithoutBordersAndMargins?.width ?? undefined;
240
+
241
+ const textAlign = textStyles?.textAlign;
242
+
243
+ const paddingLeft =
244
+ leftIconOutset &&
245
+ (!textAlign || textAlign === "left" || textAlign === "justify")
246
+ ? iconSize + 4
247
+ : 0;
248
+
249
+ const assistiveTextLabel = assistiveText ? (
250
+ <Text
251
+ style={{
252
+ textAlign,
253
+ width,
254
+ paddingLeft,
255
+ color: unstyledColor,
256
+ fontSize: 12,
257
+ paddingTop: 4,
258
+ }}
259
+ >
260
+ {assistiveText}
261
+ </Text>
262
+ ) : null;
263
+
264
+ const primaryTextStyle = {
265
+ color: unstyledColor,
266
+ fontSize: 14,
267
+ ...pickBy(textStyles, identity),
268
+ ...(placeholder === internalValue ? { color: placeholderTextColor } : {}),
269
+ ...(disabled ? { color: unstyledColor } : {}),
270
+ };
271
+
80
272
  const handleValueChange = (newValue: string, itemIndex: number) => {
81
- setInternalValue(newValue);
82
- if (onValueChange) {
83
- onValueChange(newValue, itemIndex);
273
+ if (!placeholder || itemIndex > 0) {
274
+ onValueChange?.(newValue, itemIndex);
84
275
  }
276
+ setInternalValue(newValue);
85
277
  };
86
278
 
87
279
  return (
88
- <PickerComponent
89
- {...props}
90
- selectedValue={String(internalValue)}
91
- placeholder={placeholder}
92
- options={pickerOptions}
93
- onValueChange={handleValueChange}
94
- />
280
+ /* marginsContainer */
281
+ <View style={[styles.marginsContainer, marginStyles]}>
282
+ {/* touchableContainer */}
283
+ <Touchable
284
+ disabled={disabled}
285
+ onPress={togglePickerVisible}
286
+ style={styles.touchableContainer}
287
+ >
288
+ {/* outsetContainer */}
289
+ <View
290
+ pointerEvents="none"
291
+ style={[
292
+ styles.outsetContainer,
293
+ stylesWithoutBordersAndMargins,
294
+ // @ts-expect-error ... rejects border-related { key: undefined }
295
+ !leftIconOutset && borderStyles, // set border if Icon is inset
296
+ ]}
297
+ >
298
+ {leftIcon}
299
+
300
+ {/* insetContainer */}
301
+ <View
302
+ style={[
303
+ styles.insetContainer,
304
+ // @ts-expect-error ... rejects border-related { key: undefined }
305
+ leftIconOutset && borderStyles, // set border if Icon is outset
306
+ ]}
307
+ >
308
+ {/* primaryTextContainer */}
309
+ <View style={styles.primaryTextContainer}>
310
+ {labelText}
311
+
312
+ <Text style={primaryTextStyle}>
313
+ {String(selectedLabel ?? placeholder)}
314
+ </Text>
315
+ </View>
316
+
317
+ {rightIcon}
318
+ </View>
319
+ </View>
320
+ {assistiveTextLabel}
321
+ </Touchable>
322
+
323
+ {/* iosPicker */}
324
+ {Platform.OS === "ios" && pickerVisible ? (
325
+ <Portal>
326
+ <View
327
+ style={[
328
+ styles.iosPicker,
329
+ {
330
+ backgroundColor: colors.divider,
331
+ },
332
+ ]}
333
+ >
334
+ <SafeAreaView style={styles.iosSafeArea}>
335
+ <Button
336
+ Icon={Icon}
337
+ type="text"
338
+ onPress={togglePickerVisible}
339
+ style={styles.iosButton}
340
+ >
341
+ {"Close"}
342
+ </Button>
343
+
344
+ <NativePicker
345
+ style={styles.iosNativePicker}
346
+ selectedValue={internalValue}
347
+ onValueChange={handleValueChange}
348
+ >
349
+ {(pickerOptions as unknown as PickerOption[]).map((option) => (
350
+ <NativePicker.Item
351
+ label={option.label}
352
+ value={option.value}
353
+ key={option.value}
354
+ />
355
+ ))}
356
+ </NativePicker>
357
+ </SafeAreaView>
358
+ </View>
359
+ </Portal>
360
+ ) : null}
361
+
362
+ {/* nonIosPicker */}
363
+ {Platform.OS !== "ios" ? (
364
+ <NativePicker
365
+ enabled={!disabled}
366
+ selectedValue={internalValue}
367
+ onValueChange={handleValueChange}
368
+ style={styles.nonIosPicker}
369
+ >
370
+ {(pickerOptions as unknown as PickerOption[]).map((option) => (
371
+ <NativePicker.Item
372
+ label={option.label}
373
+ value={option.value}
374
+ key={option.value}
375
+ />
376
+ ))}
377
+ </NativePicker>
378
+ ) : null}
379
+ </View>
95
380
  );
96
381
  };
97
382
 
98
383
  export default withTheme(Picker);
384
+
385
+ const styles = StyleSheet.create({
386
+ marginsContainer: { alignSelf: "stretch" },
387
+ touchableContainer: { alignSelf: "stretch", alignItems: "center" },
388
+ outsetContainer: {
389
+ flexDirection: "row",
390
+ alignItems: "center",
391
+ justifyContent: "space-between",
392
+ },
393
+ insetContainer: {
394
+ flex: 1,
395
+ height: "100%",
396
+ flexDirection: "row",
397
+ alignItems: "center",
398
+ justifyContent: "space-between",
399
+ paddingLeft: 12,
400
+ paddingRight: 12,
401
+ },
402
+ primaryTextContainer: { flex: 1 },
403
+ iosPicker: {
404
+ position: "absolute",
405
+ bottom: 0,
406
+ left: 0,
407
+ right: 0,
408
+ flexDirection: "row",
409
+ justifyContent: "center",
410
+ },
411
+ iosSafeArea: {
412
+ backgroundColor: "white",
413
+ flexDirection: "column",
414
+ width: "100%",
415
+ },
416
+ iosButton: { alignSelf: "flex-end" },
417
+ iosNativePicker: { backgroundColor: "white" },
418
+ nonIosPicker: {
419
+ opacity: 0,
420
+ position: "absolute",
421
+ top: 0,
422
+ left: 0,
423
+ right: 0,
424
+ bottom: 0,
425
+ width: "100%",
426
+ },
427
+ });
@@ -1,10 +1,11 @@
1
- import { COMPONENT_TYPES, createActionProp, createBoolProp, GROUPS, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, createActionProp, createBoolProp, GROUPS, Triggers, } from "@draftbit/types";
2
2
  export const SEED_DATA = {
3
3
  name: "Map Callout",
4
4
  tag: "MapCallout",
5
5
  packageName: "@draftbit/maps",
6
6
  description: "An info window to display on top of a marker when it is clicked",
7
7
  category: COMPONENT_TYPES.media,
8
+ triggers: [Triggers.OnPress],
8
9
  layout: {},
9
10
  props: {
10
11
  onPress: createActionProp({
@@ -3,6 +3,7 @@ import {
3
3
  createActionProp,
4
4
  createBoolProp,
5
5
  GROUPS,
6
+ Triggers,
6
7
  } from "@draftbit/types";
7
8
 
8
9
  export const SEED_DATA = {
@@ -12,6 +13,7 @@ export const SEED_DATA = {
12
13
  description:
13
14
  "An info window to display on top of a marker when it is clicked",
14
15
  category: COMPONENT_TYPES.media,
16
+ triggers: [Triggers.OnPress],
15
17
  layout: {},
16
18
  props: {
17
19
  onPress: createActionProp({
@@ -1,4 +1,4 @@
1
- import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, } from "@draftbit/types";
1
+ import { COMPONENT_TYPES, Triggers, GROUPS, FORM_TYPES, PROP_TYPES, FIELD_NAME, createIconSizeProp, createColorProp, } from "@draftbit/types";
2
2
  const SEED_DATA_PROPS = {
3
3
  label: {
4
4
  group: GROUPS.data,
@@ -131,6 +131,8 @@ export const SEED_DATA = [
131
131
  required: true,
132
132
  group: GROUPS.basic,
133
133
  },
134
+ iconSize: createIconSizeProp(),
135
+ iconColor: createColorProp(),
134
136
  },
135
137
  layout: {},
136
138
  },
@@ -5,6 +5,8 @@ import {
5
5
  FORM_TYPES,
6
6
  PROP_TYPES,
7
7
  FIELD_NAME,
8
+ createIconSizeProp,
9
+ createColorProp,
8
10
  } from "@draftbit/types";
9
11
 
10
12
  const SEED_DATA_PROPS = {
@@ -143,6 +145,8 @@ export const SEED_DATA = [
143
145
  required: true,
144
146
  group: GROUPS.basic,
145
147
  },
148
+ iconSize: createIconSizeProp(),
149
+ iconColor: createColorProp(),
146
150
  },
147
151
  layout: {},
148
152
  },
@@ -1,135 +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 _reactNative = require("react-native");
11
-
12
- var _lodash = _interopRequireDefault(require("lodash.omit"));
13
-
14
- var _theming = require("../../theming");
15
-
16
- var _picker = require("@react-native-picker/picker");
17
-
18
- var _utilities = require("../../utilities");
19
-
20
- var _TextField = _interopRequireDefault(require("../TextField"));
21
-
22
- var _Touchable = _interopRequireDefault(require("../Touchable"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- 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); }
27
-
28
- 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; }
29
-
30
- 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); }
31
-
32
- const Picker = _ref => {
33
- var _options$find$label, _options$find;
34
-
35
- let {
36
- style,
37
- options,
38
- placeholder,
39
- selectedValue,
40
- disabled = false,
41
- onValueChange: onValueChangeOverride = () => {},
42
- ...props
43
- } = _ref;
44
- const {
45
- viewStyles: {
46
- borderRadius,
47
- // eslint-disable-line @typescript-eslint/no-unused-vars
48
- borderWidth,
49
- // eslint-disable-line @typescript-eslint/no-unused-vars
50
- borderTopWidth,
51
- // eslint-disable-line @typescript-eslint/no-unused-vars
52
- borderRightWidth,
53
- // eslint-disable-line @typescript-eslint/no-unused-vars
54
- borderBottomWidth,
55
- // eslint-disable-line @typescript-eslint/no-unused-vars
56
- borderLeftWidth,
57
- // eslint-disable-line @typescript-eslint/no-unused-vars
58
- borderColor,
59
- // eslint-disable-line @typescript-eslint/no-unused-vars
60
- backgroundColor,
61
- // eslint-disable-line @typescript-eslint/no-unused-vars
62
- padding,
63
- // eslint-disable-line @typescript-eslint/no-unused-vars
64
- paddingTop,
65
- // eslint-disable-line @typescript-eslint/no-unused-vars
66
- paddingRight,
67
- // eslint-disable-line @typescript-eslint/no-unused-vars
68
- paddingBottom,
69
- // eslint-disable-line @typescript-eslint/no-unused-vars
70
- paddingLeft,
71
- // eslint-disable-line @typescript-eslint/no-unused-vars
72
- ...viewStyles
73
- }
74
- } = (0, _utilities.extractStyles)(style);
75
- const textField = React.useRef(undefined);
76
-
77
- const onValueChange = (itemValue, itemIndex) => {
78
- toggleFocus();
79
- onValueChangeOverride(itemValue, itemIndex);
80
- };
81
-
82
- const toggleFocus = () => {
83
- if (!disabled) {
84
- // @ts-ignore
85
- textField.current.toggleFocus(); // cannot determine if method exists due to component being wrapped in a withTheme()
86
- }
87
- };
88
-
89
- const stylesWithoutMargin = style && (0, _lodash.default)(_reactNative.StyleSheet.flatten(style), ["margin", "marginTop", "marginRight", "marginBottom", "marginLeft"]);
90
- 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);
91
- return /*#__PURE__*/React.createElement(_Touchable.default, {
92
- disabled: disabled,
93
- onPress: toggleFocus,
94
- style: [styles.container, viewStyles]
95
- }, /*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_picker.Picker, {
96
- enabled: !disabled,
97
- selectedValue: selectedValue,
98
- onValueChange: onValueChange,
99
- style: {
100
- opacity: 0,
101
- position: "absolute",
102
- top: 0,
103
- left: 0,
104
- right: 0,
105
- bottom: 0,
106
- width: "100%"
107
- }
108
- }, options.map(o => /*#__PURE__*/React.createElement(_picker.Picker.Item, {
109
- label: o.label,
110
- value: o.value,
111
- key: o.value
112
- }))), /*#__PURE__*/React.createElement(_reactNative.View, {
113
- pointerEvents: "none"
114
- }, /*#__PURE__*/React.createElement(_TextField.default, _extends({}, props, {
115
- value: selectedLabel,
116
- placeholder: placeholder // @ts-ignore
117
- ,
118
- ref: textField // cannot determine if ref is of correct type due to component being wrapped in a withTheme()
119
- ,
120
- disabled: disabled // @ts-expect-error
121
- ,
122
- style: stylesWithoutMargin
123
- })))));
124
- };
125
-
126
- const styles = _reactNative.StyleSheet.create({
127
- container: {
128
- alignSelf: "stretch"
129
- }
130
- });
131
-
132
- var _default = (0, _theming.withTheme)(Picker);
133
-
134
- exports.default = _default;
135
- //# sourceMappingURL=PickerComponent.android.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["PickerComponent.android.tsx"],"names":["Picker","style","options","placeholder","selectedValue","disabled","onValueChange","onValueChangeOverride","props","viewStyles","borderRadius","borderWidth","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderColor","backgroundColor","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","textField","React","useRef","undefined","itemValue","itemIndex","toggleFocus","current","stylesWithoutMargin","StyleSheet","flatten","selectedLabel","find","o","value","label","styles","container","opacity","position","top","left","right","bottom","width","map","create","alignSelf"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;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K,EAAE0B;AART,KADF,CAnBF,CALF,CADF;AAwCD,CAhGD;;AAkGA,MAAMQ,MAAM,GAAGP,wBAAWiB,MAAX,CAAkB;AAC/BT,EAAAA,SAAS,EAAE;AACTU,IAAAA,SAAS,EAAE;AADF;AADoB,CAAlB,CAAf;;eAMe,wBAAUlD,MAAV,C","sourcesContent":["import * as React from \"react\";\nimport { View, StyleSheet } from \"react-native\";\nimport omit from \"lodash.omit\";\nimport { withTheme } from \"../../theming\";\nimport { Picker as NativePicker } from \"@react-native-picker/picker\";\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 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"]}