ferns-ui 0.23.0 → 0.23.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.
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
+ import { Host } from "react-native-portalize";
2
3
  import { ToastProvider } from "react-native-toast-notifications";
3
4
  import { Toast } from "./Toast";
4
5
  export function FernsProvider({ children }) {
5
- return (React.createElement(ToastProvider, { animationDuration: 250, animationType: "slide-in", duration: 50000, offset: 50, placement: "bottom", renderToast: (toastOptions) => React.createElement(Toast, Object.assign({}, toastOptions)), swipeEnabled: true }, children));
6
+ return (React.createElement(ToastProvider, { animationDuration: 250, animationType: "slide-in", duration: 50000, offset: 50, placement: "bottom", renderToast: (toastOptions) => React.createElement(Toast, Object.assign({}, toastOptions)), swipeEnabled: true },
7
+ React.createElement(Host, null, children)));
6
8
  }
7
9
  //# sourceMappingURL=FernsProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FernsProvider.js","sourceRoot":"","sources":["../src/FernsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,UAAU,aAAa,CAAC,EAAC,QAAQ,EAA8B;IACnE,OAAO,CACL,oBAAC,aAAa,IACZ,iBAAiB,EAAE,GAAG,EACtB,aAAa,EAAC,UAAU,EACxB,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,EAAE,EACV,SAAS,EAAC,QAAQ,EAClB,WAAW,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,oBAAC,KAAK,oBAAM,YAAoB,EAAI,EACnE,YAAY,UAEX,QAAQ,CACK,CACjB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"FernsProvider.js","sourceRoot":"","sources":["../src/FernsProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,IAAI,EAAC,MAAM,wBAAwB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,MAAM,UAAU,aAAa,CAAC,EAAC,QAAQ,EAA8B;IACnE,OAAO,CACL,oBAAC,aAAa,IACZ,iBAAiB,EAAE,GAAG,EACtB,aAAa,EAAC,UAAU,EACxB,QAAQ,EAAE,KAAK,EACf,MAAM,EAAE,EAAE,EACV,SAAS,EAAC,QAAQ,EAClB,WAAW,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,oBAAC,KAAK,oBAAM,YAAoB,EAAI,EACnE,YAAY;QAEZ,oBAAC,IAAI,QAAE,QAAQ,CAAQ,CACT,CACjB,CAAC;AACJ,CAAC"}
@@ -1,6 +1,5 @@
1
- import PropTypes from "prop-types";
2
- import React, { PureComponent } from "react";
3
- declare const defaultStyles: {
1
+ /// <reference types="react" />
2
+ export declare const defaultStyles: {
4
3
  viewContainer: {
5
4
  alignSelf: "stretch";
6
5
  };
@@ -81,94 +80,30 @@ declare const defaultStyles: {
81
80
  opacity: number;
82
81
  };
83
82
  };
84
- export default class RNPickerSelect extends PureComponent<any, any> {
85
- static propTypes: {
86
- onValueChange: PropTypes.Validator<(...args: any[]) => any>;
87
- items: PropTypes.Validator<(PropTypes.InferProps<{
88
- label: PropTypes.Validator<string>;
89
- value: PropTypes.Validator<any>;
90
- inputLabel: PropTypes.Requireable<string>;
91
- key: PropTypes.Requireable<React.ReactText>;
92
- color: PropTypes.Requireable<string>;
93
- }> | null | undefined)[]>;
94
- value: PropTypes.Requireable<any>;
95
- placeholder: PropTypes.Requireable<PropTypes.InferProps<{
96
- label: PropTypes.Requireable<string>;
97
- value: PropTypes.Requireable<any>;
98
- key: PropTypes.Requireable<React.ReactText>;
99
- color: PropTypes.Requireable<string>;
100
- }>>;
101
- disabled: PropTypes.Requireable<boolean>;
102
- itemKey: PropTypes.Requireable<React.ReactText>;
103
- style: PropTypes.Requireable<PropTypes.InferProps<{}>>;
104
- children: PropTypes.Requireable<any>;
105
- onOpen: PropTypes.Requireable<(...args: any[]) => any>;
106
- useNativeAndroidPickerStyle: PropTypes.Requireable<boolean>;
107
- fixAndroidTouchableBug: PropTypes.Requireable<boolean>;
108
- doneText: PropTypes.Requireable<string>;
109
- onDonePress: PropTypes.Requireable<(...args: any[]) => any>;
110
- onUpArrow: PropTypes.Requireable<(...args: any[]) => any>;
111
- onDownArrow: PropTypes.Requireable<(...args: any[]) => any>;
112
- onClose: PropTypes.Requireable<(...args: any[]) => any>;
113
- modalProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
114
- textInputProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
115
- pickerProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
116
- touchableDoneProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
117
- touchableWrapperProps: PropTypes.Requireable<PropTypes.InferProps<{}>>;
118
- Icon: PropTypes.Requireable<(...args: any[]) => any>;
119
- InputAccessoryView: PropTypes.Requireable<(...args: any[]) => any>;
120
- };
121
- static defaultProps: {
122
- value: undefined;
123
- placeholder: {
124
- label: string;
125
- value: null;
126
- color: string;
127
- };
128
- disabled: boolean;
129
- itemKey: null;
130
- style: {};
131
- children: null;
132
- useNativeAndroidPickerStyle: boolean;
133
- fixAndroidTouchableBug: boolean;
134
- doneText: string;
135
- onDonePress: null;
136
- onUpArrow: null;
137
- onDownArrow: null;
138
- onOpen: null;
139
- onClose: null;
140
- modalProps: {};
141
- textInputProps: {};
142
- pickerProps: {};
143
- touchableDoneProps: {};
144
- touchableWrapperProps: {};
145
- Icon: null;
146
- InputAccessoryView: null;
147
- };
148
- inputRef: any;
149
- static handlePlaceholder({ placeholder }: any): any[];
150
- static getSelectedItem({ items, key, value }: any): {
151
- selectedItem: any;
152
- idx: any;
153
- };
154
- constructor(props: any);
155
- componentDidUpdate(prevProps: Readonly<any>, prevState: Readonly<any>): void;
156
- onUpArrow(): void;
157
- onDownArrow(): void;
158
- onValueChange(value: any, index: any): void;
159
- onOrientationChange({ nativeEvent }: any): void;
160
- setInputRef(ref: any): void;
161
- getPlaceholderStyle(): any;
162
- triggerOpenCloseCallbacks(): void;
163
- togglePicker(animate?: boolean, postToggleCallback?: any): void;
164
- renderPickerItems(): any;
165
- renderInputAccessoryView(): JSX.Element;
166
- renderIcon(): JSX.Element | null;
167
- renderTextInputOrChildren(): JSX.Element;
168
- renderIOS(): JSX.Element;
169
- renderAndroidHeadless(): JSX.Element;
170
- renderAndroidNativePickerStyle(): JSX.Element;
171
- renderWeb(): JSX.Element;
172
- render(): JSX.Element;
83
+ interface RNPickerSelectProps {
84
+ onValueChange: (value: any, index: any) => void;
85
+ items: any[];
86
+ value?: any;
87
+ placeholder?: any;
88
+ disabled?: boolean;
89
+ itemKey?: string | number;
90
+ style?: any;
91
+ children?: any;
92
+ onOpen?: () => void;
93
+ useNativeAndroidPickerStyle?: boolean;
94
+ fixAndroidTouchableBug?: boolean;
95
+ doneText?: string;
96
+ onDonePress?: () => void;
97
+ onUpArrow?: () => void;
98
+ onDownArrow?: () => void;
99
+ onClose?: () => void;
100
+ modalProps?: any;
101
+ textInputProps?: any;
102
+ pickerProps?: any;
103
+ touchableDoneProps?: any;
104
+ touchableWrapperProps?: any;
105
+ Icon?: any;
106
+ InputAccessoryView?: any;
173
107
  }
174
- export { defaultStyles };
108
+ export declare function RNPickerSelect({ onValueChange, value, items, placeholder, disabled, itemKey, style, children, useNativeAndroidPickerStyle, fixAndroidTouchableBug, doneText, onDonePress, onUpArrow, onDownArrow, onOpen, onClose, modalProps, textInputProps, pickerProps, touchableDoneProps, touchableWrapperProps, Icon, InputAccessoryView, }: RNPickerSelectProps): JSX.Element;
109
+ export {};
@@ -19,10 +19,9 @@
19
19
  // with react-native-picker in Expo, then converted to TS.
20
20
  import { Picker } from "@react-native-picker/picker";
21
21
  import isEqual from "lodash/isEqual";
22
- import PropTypes from "prop-types";
23
- import React, { PureComponent } from "react";
22
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
24
23
  import { Keyboard, Modal, Platform, StyleSheet, Text, TextInput, TouchableOpacity, View, } from "react-native";
25
- const defaultStyles = StyleSheet.create({
24
+ export const defaultStyles = StyleSheet.create({
26
25
  viewContainer: {
27
26
  alignSelf: "stretch",
28
27
  },
@@ -91,152 +90,98 @@ const defaultStyles = StyleSheet.create({
91
90
  opacity: 0,
92
91
  },
93
92
  });
94
- export default class RNPickerSelect extends PureComponent {
95
- constructor(props) {
96
- super(props);
97
- const items = RNPickerSelect.handlePlaceholder({
98
- placeholder: props.placeholder,
99
- }).concat(props.items);
100
- const { selectedItem } = RNPickerSelect.getSelectedItem({
101
- items,
102
- key: props.itemKey,
103
- value: props.value,
104
- });
105
- this.state = {
106
- items,
107
- selectedItem,
108
- showPicker: false,
109
- animationType: undefined,
110
- orientation: "portrait",
111
- doneDepressed: false,
112
- };
113
- this.onUpArrow = this.onUpArrow.bind(this);
114
- this.onDownArrow = this.onDownArrow.bind(this);
115
- this.onValueChange = this.onValueChange.bind(this);
116
- this.onOrientationChange = this.onOrientationChange.bind(this);
117
- this.setInputRef = this.setInputRef.bind(this);
118
- this.togglePicker = this.togglePicker.bind(this);
119
- this.renderInputAccessoryView = this.renderInputAccessoryView.bind(this);
120
- }
121
- static handlePlaceholder({ placeholder }) {
93
+ export function RNPickerSelect({ onValueChange, value, items, placeholder = {
94
+ label: "Select an item...",
95
+ value: null,
96
+ color: "#9EA0A4",
97
+ }, disabled = false, itemKey, style = defaultStyles, children, useNativeAndroidPickerStyle = true, fixAndroidTouchableBug = false, doneText = "Done", onDonePress, onUpArrow, onDownArrow, onOpen, onClose, modalProps, textInputProps, pickerProps, touchableDoneProps, touchableWrapperProps, Icon, InputAccessoryView, }) {
98
+ const [selectedItem, setSelectedItem] = useState();
99
+ const [showPicker, setShowPicker] = useState(false);
100
+ const [animationType, setAnimationType] = useState(undefined);
101
+ const [orientation, setOrientation] = useState("portrait");
102
+ const [doneDepressed, setDoneDepressed] = useState(false);
103
+ const options = useMemo(() => {
122
104
  if (isEqual(placeholder, {})) {
123
- return [];
105
+ return [...items];
106
+ }
107
+ else {
108
+ return [placeholder, ...items];
124
109
  }
125
- return [placeholder];
126
- }
127
- static getSelectedItem({ items, key, value }) {
128
- let idx = items.findIndex((item) => {
110
+ }, [items, placeholder]);
111
+ const getSelectedItem = useCallback((key, val) => {
112
+ let idx = options.findIndex((item) => {
129
113
  if (item.key && key) {
130
114
  return isEqual(item.key, key);
131
115
  }
132
- return isEqual(item.value, value);
116
+ return isEqual(item.value, val);
133
117
  });
134
118
  if (idx === -1) {
135
119
  idx = 0;
136
120
  }
137
121
  return {
138
- selectedItem: items[idx] || {},
122
+ selectedItem: options[idx] || {},
139
123
  idx,
140
124
  };
141
- }
142
- componentDidUpdate(prevProps, prevState) {
143
- // update items if items or placeholder prop changes
144
- const items = RNPickerSelect.handlePlaceholder({
145
- placeholder: this.props.placeholder,
146
- }).concat(this.props.items);
147
- const itemsChanged = !isEqual(prevState.items, items);
148
- // update selectedItem if value prop is defined and differs from currently selected item
149
- const { selectedItem, idx } = RNPickerSelect.getSelectedItem({
150
- items,
151
- key: this.props.itemKey,
152
- value: this.props.value,
153
- });
154
- const selectedItemChanged = !isEqual(this.props.value, undefined) && !isEqual(prevState.selectedItem, selectedItem);
155
- if (itemsChanged || selectedItemChanged) {
156
- this.props.onValueChange(selectedItem.value, idx);
157
- this.setState(Object.assign(Object.assign({}, (itemsChanged ? { items } : {})), (selectedItemChanged ? { selectedItem } : {})));
158
- }
159
- }
160
- onUpArrow() {
161
- const { onUpArrow } = this.props;
162
- this.togglePicker(false, onUpArrow);
163
- }
164
- onDownArrow() {
165
- const { onDownArrow } = this.props;
166
- this.togglePicker(false, onDownArrow);
167
- }
168
- onValueChange(value, index) {
169
- const { onValueChange } = this.props;
170
- onValueChange(value, index);
171
- this.setState((prevState) => {
172
- return {
173
- selectedItem: prevState.items[index],
174
- };
175
- });
176
- }
177
- onOrientationChange({ nativeEvent }) {
178
- this.setState({
179
- orientation: nativeEvent.orientation,
180
- });
181
- }
182
- setInputRef(ref) {
183
- this.inputRef = ref;
184
- }
185
- getPlaceholderStyle() {
186
- const { placeholder, style } = this.props;
187
- const { selectedItem } = this.state;
188
- if (!isEqual(placeholder, {}) && selectedItem.label === placeholder.label) {
189
- return Object.assign(Object.assign({}, defaultStyles.placeholder), style.placeholder);
125
+ }, [options]);
126
+ useEffect(() => {
127
+ const item = getSelectedItem(itemKey, value);
128
+ setSelectedItem(item.selectedItem);
129
+ }, [getSelectedItem, itemKey, value]);
130
+ const onUpArrowEvent = () => {
131
+ togglePicker(false, onUpArrow);
132
+ };
133
+ const onDownArrowEvent = () => {
134
+ togglePicker(false, onDownArrow);
135
+ };
136
+ const onValueChangeEvent = (val, index) => {
137
+ const item = getSelectedItem(itemKey, val);
138
+ onValueChange(val, index);
139
+ setSelectedItem(item.selectedItem);
140
+ };
141
+ const onOrientationChange = ({ nativeEvent }) => {
142
+ setOrientation(nativeEvent.orientation);
143
+ };
144
+ const getPlaceholderStyle = () => {
145
+ if (!isEqual(placeholder, {}) && (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label) === (placeholder === null || placeholder === void 0 ? void 0 : placeholder.label)) {
146
+ return Object.assign(Object.assign({}, defaultStyles.placeholder), style === null || style === void 0 ? void 0 : style.placeholder);
190
147
  }
191
148
  return {};
192
- }
193
- triggerOpenCloseCallbacks() {
194
- const { onOpen, onClose } = this.props;
195
- const { showPicker } = this.state;
149
+ };
150
+ const triggerOpenCloseCallbacks = () => {
196
151
  if (!showPicker && onOpen) {
197
152
  onOpen();
198
153
  }
199
154
  if (showPicker && onClose) {
200
155
  onClose();
201
156
  }
202
- }
203
- togglePicker(animate = false, postToggleCallback) {
204
- const { modalProps, disabled } = this.props;
205
- const { showPicker } = this.state;
157
+ };
158
+ const togglePicker = (animate = false, postToggleCallback) => {
206
159
  if (disabled) {
207
160
  return;
208
161
  }
209
162
  if (!showPicker) {
210
163
  Keyboard.dismiss();
211
164
  }
212
- const animationType = modalProps && modalProps.animationType ? modalProps.animationType : "slide";
213
- this.triggerOpenCloseCallbacks();
214
- this.setState((prevState) => {
215
- return {
216
- animationType: animate ? animationType : undefined,
217
- showPicker: !prevState.showPicker,
218
- };
219
- }, () => {
220
- if (postToggleCallback) {
221
- postToggleCallback();
222
- }
223
- });
224
- }
225
- renderPickerItems() {
226
- const { items } = this.state;
227
- return items.map((item) => {
165
+ setAnimationType(modalProps && (modalProps === null || modalProps === void 0 ? void 0 : modalProps.animationType) ? modalProps === null || modalProps === void 0 ? void 0 : modalProps.animationType : "slide");
166
+ triggerOpenCloseCallbacks();
167
+ setAnimationType(animate ? animationType : undefined);
168
+ setShowPicker(!showPicker);
169
+ if (postToggleCallback) {
170
+ postToggleCallback();
171
+ }
172
+ };
173
+ const renderPickerItems = () => {
174
+ return options === null || options === void 0 ? void 0 : options.map((item) => {
228
175
  return (React.createElement(Picker.Item, { key: item.key || item.label, color: item.color, label: item.label, value: item.value }));
229
176
  });
230
- }
231
- renderInputAccessoryView() {
232
- const { InputAccessoryView, doneText, onUpArrow, onDownArrow, onDonePress, style, touchableDoneProps, } = this.props;
233
- const { doneDepressed } = this.state;
177
+ };
178
+ const renderInputAccessoryView = () => {
234
179
  if (InputAccessoryView) {
235
180
  return React.createElement(InputAccessoryView, { testID: "custom_input_accessory_view" });
236
181
  }
237
182
  return (React.createElement(View, { style: [defaultStyles.modalViewMiddle, style.modalViewMiddle], testID: "input_accessory_view" },
238
183
  React.createElement(View, { style: [defaultStyles.chevronContainer, style.chevronContainer] },
239
- React.createElement(TouchableOpacity, { activeOpacity: onUpArrow ? 0.5 : 1, onPress: onUpArrow ? this.onUpArrow : undefined },
184
+ React.createElement(TouchableOpacity, { activeOpacity: onUpArrow ? 0.5 : 1, onPress: onUpArrow ? onUpArrowEvent : undefined },
240
185
  React.createElement(View, { style: [
241
186
  defaultStyles.chevron,
242
187
  style.chevron,
@@ -244,7 +189,7 @@ export default class RNPickerSelect extends PureComponent {
244
189
  style.chevronUp,
245
190
  onUpArrow ? [defaultStyles.chevronActive, style.chevronActive] : {},
246
191
  ] })),
247
- React.createElement(TouchableOpacity, { activeOpacity: onDownArrow ? 0.5 : 1, onPress: onDownArrow ? this.onDownArrow : undefined },
192
+ React.createElement(TouchableOpacity, { activeOpacity: onDownArrow ? 0.5 : 1, onPress: onDownArrow ? onDownArrowEvent : undefined },
248
193
  React.createElement(View, { style: [
249
194
  defaultStyles.chevron,
250
195
  style.chevron,
@@ -253,11 +198,11 @@ export default class RNPickerSelect extends PureComponent {
253
198
  onDownArrow ? [defaultStyles.chevronActive, style.chevronActive] : {},
254
199
  ] }))),
255
200
  React.createElement(TouchableOpacity, Object.assign({ hitSlop: { top: 4, right: 4, bottom: 4, left: 4 }, testID: "done_button", onPress: () => {
256
- this.togglePicker(true, onDonePress);
201
+ togglePicker(true, onDonePress);
257
202
  }, onPressIn: () => {
258
- this.setState({ doneDepressed: true });
203
+ setDoneDepressed(true);
259
204
  }, onPressOut: () => {
260
- this.setState({ doneDepressed: false });
205
+ setDoneDepressed(false);
261
206
  } }, touchableDoneProps),
262
207
  React.createElement(View, { testID: "needed_for_touchable" },
263
208
  React.createElement(Text, { allowFontScaling: false, style: [
@@ -265,32 +210,27 @@ export default class RNPickerSelect extends PureComponent {
265
210
  style.done,
266
211
  doneDepressed ? [defaultStyles.doneDepressed, style.doneDepressed] : {},
267
212
  ], testID: "done_text" }, doneText)))));
268
- }
269
- renderIcon() {
270
- const { style, Icon } = this.props;
213
+ };
214
+ const renderIcon = () => {
271
215
  if (!Icon) {
272
216
  return null;
273
217
  }
274
218
  return (React.createElement(View, { style: [defaultStyles.iconContainer, style.iconContainer], testID: "icon_container" },
275
219
  React.createElement(Icon, { testID: "icon" })));
276
- }
277
- renderTextInputOrChildren() {
278
- const { children, style, textInputProps } = this.props;
279
- const { selectedItem } = this.state;
220
+ };
221
+ const renderTextInputOrChildren = () => {
280
222
  const containerStyle = Platform.OS === "ios" ? style.inputIOSContainer : style.inputAndroidContainer;
281
223
  if (children) {
282
224
  return (React.createElement(View, { pointerEvents: "box-only", style: containerStyle }, children));
283
225
  }
284
226
  return (React.createElement(View, { pointerEvents: "box-only", style: containerStyle },
285
- React.createElement(TextInput, Object.assign({ ref: this.setInputRef, editable: false, style: [
227
+ React.createElement(TextInput, Object.assign({ editable: false, style: [
286
228
  Platform.OS === "ios" ? style.inputIOS : style.inputAndroid,
287
- this.getPlaceholderStyle(),
288
- ], testID: "text_input", value: selectedItem.inputLabel ? selectedItem.inputLabel : selectedItem.label }, textInputProps)),
289
- this.renderIcon()));
290
- }
291
- renderIOS() {
292
- const { style, modalProps, pickerProps, touchableWrapperProps } = this.props;
293
- const { animationType, orientation, selectedItem, showPicker } = this.state;
229
+ getPlaceholderStyle(),
230
+ ], testID: "text_input", value: (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.inputLabel) ? selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.inputLabel : selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.label }, textInputProps)),
231
+ renderIcon()));
232
+ };
233
+ const renderIOS = () => {
294
234
  return (React.createElement(View, { style: [defaultStyles.viewContainer, style.viewContainer] },
295
235
  React.createElement(TouchableOpacity, Object.assign({ activeOpacity: 1, style: {
296
236
  flexDirection: "row",
@@ -299,135 +239,58 @@ export default class RNPickerSelect extends PureComponent {
299
239
  minHeight: (style === null || style === void 0 ? void 0 : style.minHeight) || 50,
300
240
  width: "100%",
301
241
  }, testID: "ios_touchable_wrapper", onPress: () => {
302
- this.togglePicker(true);
303
- } }, touchableWrapperProps), this.renderTextInputOrChildren()),
304
- React.createElement(Modal, Object.assign({ animationType: animationType, supportedOrientations: ["portrait", "landscape"], testID: "ios_modal", transparent: true, visible: showPicker, onOrientationChange: this.onOrientationChange }, modalProps),
242
+ togglePicker(true);
243
+ } }, touchableWrapperProps), renderTextInputOrChildren()),
244
+ React.createElement(Modal, Object.assign({ animationType: animationType, supportedOrientations: ["portrait", "landscape"], testID: "ios_modal", transparent: true, visible: showPicker, onOrientationChange: onOrientationChange }, modalProps),
305
245
  React.createElement(TouchableOpacity, { style: [defaultStyles.modalViewTop, style.modalViewTop], testID: "ios_modal_top", onPress: () => {
306
- this.togglePicker(true);
246
+ togglePicker(true);
307
247
  } }),
308
- this.renderInputAccessoryView(),
248
+ renderInputAccessoryView(),
309
249
  React.createElement(View, { style: [
310
250
  defaultStyles.modalViewBottom,
311
251
  { height: orientation === "portrait" ? 215 : 162 },
312
252
  style.modalViewBottom,
313
253
  ] },
314
- React.createElement(Picker, Object.assign({ selectedValue: selectedItem.value, testID: "ios_picker", onValueChange: this.onValueChange }, pickerProps), this.renderPickerItems())))));
315
- }
316
- renderAndroidHeadless() {
317
- const { disabled, Icon, style, pickerProps, onOpen, touchableWrapperProps, fixAndroidTouchableBug, } = this.props;
318
- const { selectedItem } = this.state;
254
+ React.createElement(Picker, Object.assign({ selectedValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value, testID: "ios_picker", onValueChange: onValueChangeEvent }, pickerProps), renderPickerItems())))));
255
+ };
256
+ const renderAndroidHeadless = () => {
319
257
  const Component = fixAndroidTouchableBug ? View : TouchableOpacity;
320
258
  return (React.createElement(Component, Object.assign({ activeOpacity: 1, testID: "android_touchable_wrapper", onPress: onOpen }, touchableWrapperProps),
321
259
  React.createElement(View, { style: style.headlessAndroidContainer },
322
- this.renderTextInputOrChildren(),
323
- React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem.value, style: [
260
+ renderTextInputOrChildren(),
261
+ React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value, style: [
324
262
  Icon ? { backgroundColor: "transparent" } : {},
325
263
  defaultStyles.headlessAndroidPicker,
326
264
  style.headlessAndroidPicker,
327
- ], testID: "android_picker_headless", onValueChange: this.onValueChange }, pickerProps), this.renderPickerItems()))));
328
- }
329
- renderAndroidNativePickerStyle() {
330
- const { disabled, Icon, style, pickerProps } = this.props;
331
- const { selectedItem } = this.state;
265
+ ], testID: "android_picker_headless", onValueChange: onValueChangeEvent }, pickerProps), renderPickerItems()))));
266
+ };
267
+ const renderAndroidNativePickerStyle = () => {
332
268
  return (React.createElement(View, { style: [defaultStyles.viewContainer, style.viewContainer] },
333
- React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem.value, style: [
269
+ React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value, style: [
334
270
  Icon ? { backgroundColor: "transparent" } : {},
335
271
  style.inputAndroid,
336
272
  { width: "100%" },
337
- this.getPlaceholderStyle(),
338
- ], testID: "android_picker", onValueChange: this.onValueChange }, pickerProps), this.renderPickerItems()),
339
- this.renderIcon()));
340
- }
341
- renderWeb() {
342
- const { disabled, style, pickerProps } = this.props;
343
- const { selectedItem } = this.state;
273
+ getPlaceholderStyle(),
274
+ ], testID: "android_picker", onValueChange: onValueChangeEvent }, pickerProps), renderPickerItems()),
275
+ renderIcon()));
276
+ };
277
+ const renderWeb = () => {
344
278
  return (React.createElement(View, { style: [defaultStyles.viewContainer, style.viewContainer] },
345
- React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem.value, style: [{ width: "100%", height: "100%", border: "none" }, style.inputWeb], testID: "web_picker", onValueChange: this.onValueChange }, pickerProps), this.renderPickerItems()),
346
- this.renderIcon()));
347
- }
348
- render() {
349
- const { children, useNativeAndroidPickerStyle } = this.props;
279
+ React.createElement(Picker, Object.assign({ enabled: !disabled, selectedValue: selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.value, style: [{ width: "100%", height: "100%", border: "none" }, style.inputWeb], testID: "web_picker", onValueChange: onValueChangeEvent }, pickerProps), renderPickerItems()),
280
+ renderIcon()));
281
+ };
282
+ const render = () => {
350
283
  if (Platform.OS === "ios") {
351
- return this.renderIOS();
284
+ return renderIOS();
352
285
  }
353
286
  if (Platform.OS === "web") {
354
- return this.renderWeb();
287
+ return renderWeb();
355
288
  }
356
289
  if (children || !useNativeAndroidPickerStyle) {
357
- return this.renderAndroidHeadless();
290
+ return renderAndroidHeadless();
358
291
  }
359
- return this.renderAndroidNativePickerStyle();
360
- }
292
+ return renderAndroidNativePickerStyle();
293
+ };
294
+ return render();
361
295
  }
362
- RNPickerSelect.propTypes = {
363
- onValueChange: PropTypes.func.isRequired,
364
- items: PropTypes.arrayOf(PropTypes.shape({
365
- label: PropTypes.string.isRequired,
366
- value: PropTypes.any.isRequired,
367
- inputLabel: PropTypes.string,
368
- key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
369
- color: PropTypes.string,
370
- })).isRequired,
371
- value: PropTypes.any,
372
- placeholder: PropTypes.shape({
373
- label: PropTypes.string,
374
- value: PropTypes.any,
375
- key: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
376
- color: PropTypes.string,
377
- }),
378
- disabled: PropTypes.bool,
379
- itemKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
380
- style: PropTypes.shape({}),
381
- children: PropTypes.any,
382
- onOpen: PropTypes.func,
383
- useNativeAndroidPickerStyle: PropTypes.bool,
384
- fixAndroidTouchableBug: PropTypes.bool,
385
- // Custom Modal props (iOS only)
386
- doneText: PropTypes.string,
387
- onDonePress: PropTypes.func,
388
- onUpArrow: PropTypes.func,
389
- onDownArrow: PropTypes.func,
390
- onClose: PropTypes.func,
391
- // Modal props (iOS only)
392
- modalProps: PropTypes.shape({}),
393
- // TextInput props
394
- textInputProps: PropTypes.shape({}),
395
- // Picker props
396
- pickerProps: PropTypes.shape({}),
397
- // Touchable Done props (iOS only)
398
- touchableDoneProps: PropTypes.shape({}),
399
- // Touchable wrapper props
400
- touchableWrapperProps: PropTypes.shape({}),
401
- // Custom Icon
402
- Icon: PropTypes.func,
403
- InputAccessoryView: PropTypes.func,
404
- };
405
- RNPickerSelect.defaultProps = {
406
- value: undefined,
407
- placeholder: {
408
- label: "Select an item...",
409
- value: null,
410
- color: "#9EA0A4",
411
- },
412
- disabled: false,
413
- itemKey: null,
414
- style: {},
415
- children: null,
416
- useNativeAndroidPickerStyle: true,
417
- fixAndroidTouchableBug: false,
418
- doneText: "Done",
419
- onDonePress: null,
420
- onUpArrow: null,
421
- onDownArrow: null,
422
- onOpen: null,
423
- onClose: null,
424
- modalProps: {},
425
- textInputProps: {},
426
- pickerProps: {},
427
- touchableDoneProps: {},
428
- touchableWrapperProps: {},
429
- Icon: null,
430
- InputAccessoryView: null,
431
- };
432
- export { defaultStyles };
433
296
  //# sourceMappingURL=PickerSelect.js.map