Skip to content

Picker - export RenderCustomModalProps and PickerItemsListProps #2961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions demo/src/screens/componentScreens/PickerScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
PanningProvider,
Typography,
PickerProps,
RenderCustomModalProps,
PickerMethods,
Button
} from 'react-native-ui-lib'; //eslint-disable-line
Expand Down Expand Up @@ -73,15 +74,15 @@ export default class PickerScreen extends Component {
contact: 0
};

renderDialog: PickerProps['renderCustomModal'] = modalProps => {
renderDialog: PickerProps['renderCustomModal'] = (modalProps: RenderCustomModalProps) => {
const {visible, children, toggleModal, onDone} = modalProps;

return (
<Incubator.Dialog
visible={visible}
onDismiss={() => {
onDone();
toggleModal(false);
toggleModal();
}}
width="100%"
height="45%"
Expand Down
14 changes: 13 additions & 1 deletion src/components/picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import {
PickerModes,
PickerFieldTypes,
PickerSearchStyle,
RenderCustomModalProps,
PickerItemsListProps,
PickerMethods
} from './types';

Expand Down Expand Up @@ -344,6 +346,16 @@ Picker.fieldTypes = PickerFieldTypes;
// @ts-expect-error
Picker.extractPickerItems = extractPickerItems;

export {PickerProps, PickerItemProps, PickerValue, PickerModes, PickerFieldTypes, PickerSearchStyle, PickerMethods};
export {
PickerProps,
PickerItemProps,
PickerValue,
PickerModes,
PickerFieldTypes,
PickerSearchStyle,
RenderCustomModalProps,
PickerItemsListProps,
PickerMethods
};
export {Picker}; // For tests
export default Picker as typeof Picker & PickerStatics;
4 changes: 2 additions & 2 deletions src/components/picker/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ type RenderPickerOverloads<ValueType> = ValueType extends PickerValue
: never;
type RenderPicker = RenderPickerOverloads<PickerValue>;

type RenderCustomModalProps = {
export type RenderCustomModalProps = {
visible: boolean;
toggleModal: (show: boolean) => void;
toggleModal: () => void;
onSearchChange: (searchValue: string) => void;
children: ReactNode;
// onDone is relevant to multi mode only
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export {
PickerModes,
PickerFieldTypes,
PickerSearchStyle,
RenderCustomModalProps,
PickerItemsListProps,
PickerMethods
} from './components/picker';
export {default as ProgressBar, ProgressBarProps} from './components/progressBar';
Expand Down
15 changes: 12 additions & 3 deletions webDemo/src/examples/Picker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import React, {useState} from 'react';
import {ScrollView} from 'react-native-gesture-handler';
import {Picker, Colors, View, Text, Incubator, PickerProps, PanningProvider} from 'react-native-ui-lib';
import {
Picker,
Colors,
View,
Text,
Incubator,
PickerProps,
RenderCustomModalProps,
PanningProvider
} from 'react-native-ui-lib';

const options = [
{label: 'JavaScript', value: 'js'},
Expand Down Expand Up @@ -29,15 +38,15 @@ const PickerWrapper = () => {
const [language, setLanguage] = useState(undefined);
const [filter, setFilter] = useState(undefined);
const [customModalValues, setCustomModalValues] = useState(undefined);
const renderDialog: PickerProps['renderCustomModal'] = (modalProps: any) => {
const renderDialog: PickerProps['renderCustomModal'] = (modalProps: RenderCustomModalProps) => {
const {visible, children, toggleModal, onDone} = modalProps;

return (
<Incubator.Dialog
visible={visible}
onDismiss={() => {
onDone();
toggleModal(false);
toggleModal();
}}
width="40%"
height="45%"
Expand Down