Socket
Socket
Sign inDemoInstall

react-native-woodpicker

Package Overview
Dependencies
0
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-woodpicker

React Native picker and date picker for iOS and Android


Version published
Weekly downloads
1.9K
decreased by-3.95%
Maintainers
1
Install size
50.2 kB
Created
Weekly downloads
 

Readme

Source

react-native-woodpicker

Customisable picker and datePicker react-native components for Android and iOS.

Preview

Preview Preview-Android

Installation

yarn add react-native-woodpicker @react-native-community/datetimepicker @react-native-picker/picker

or

npm install react-native-woodpicker @react-native-community/datetimepicker @react-native-picker/picker --save

Expo

// add react-native-woodpicker with your package manager (yarn / npm / ...) and :
expo install @react-native-community/datetimepicker @react-native-picker/picker

Version

0.1.0

New Version 0.1.0 integrate new React-Native component DateTimePicker from @react-native-community/datetimepicker and Hooks. Don't forget to add it to your project.

0.2.0

New Version 0.2.0 integrate new React-Native component Picker from @react-native-community/picker.

0.3.0

New Version 0.3.0 use Typescript and change the picker dependency from @react-native-community/picker to @react-native-picker/picker.

Contribution

Thanks to everyone for your contribution! I try my best to review and update this repository. PR and feedback are welcomed!

Usage

Picker

You can use Picker to pick values/objects.

import type { PickerItem } from 'react-native-woodpicker'
import { Picker } from 'react-native-woodpicker'

[...]

const ExampleApp = (): JSX.Element => {
  const [pickedData, setPickedData] = useState<PickerItem>();

  const data: Array<PickerItem> = [
    { label: "DataCat", value: 1 },
    { label: "DataDog", value: 2 },
    { label: "DataSnake", value: 3 },
    { label: "DataPlatypus", value: 4 },
    { label: "DataWhale", value: 5 }
  ];

  return (
    <View>
      <Picker
        item={pickedData}
        items={data}
        onItemChange={setPickedData}
        title="Data Picker"
        placeholder="Select Data"
        isNullable={false}
      //backdropAnimation={{ opacity: 0 }}
      //mode="dropdown"
      //isNullable
      //disable
    />
    </View>
  );
}

DatePicker

You can use DatePicker to pick Dates. Unlike the Picker, you need to handle the placeholder.

import { DatePicker } from 'react-native-woodpicker'

[...]

const ExampleApp = (): JSX.Element => {
  const [pickedDate, setPickedDate] = useState<Date>();

  const handleText = (): string => pickedDate
      ? pickedDate.toDateString()
      : "No value Selected";

  return (
    <View>
      <DatePicker
        value={pickedDate}
        onDateChange={handleDateChange}
        title="Date Picker"
        text={handleText()}
        isNullable={false}
        iosDisplay="inline"
        //backdropAnimation={{ opacity: 0 }}
        //minimumDate={new Date(Date.now())}
        //maximumDate={new Date(Date.now()+2000000000)}
        //iosMode="date"
        //androidMode="countdown"
        //iosDisplay="spinner"
        //androidDisplay="spinner"
        //locale="fr"
      />
    </View>
  );
}

Props

General

NametypeRequiredDescription
titlestringfalseChange DoneBar title
doneButtonLabelstringfalseChange done button label
styleViewStylefalseConfigure the input style (View)
containerStyleViewStylefalseConfigure the input container style (View)
textInputStyleTextStylefalseConfigure the input text style (Text)
disabledbooleanfalseDisable the input
isNullablebooleanfalsePicker : Add null value on items, DatePicker: add reset button
InputComponentReact.ElementTypefalseComponent to replace input.
DoneBarComponentReact.ElementTypefalseComponent to replace iOS Picker Done Bar
onOpenfunctionfalseTriggered when the picker is opening
onClosefunctionfalseTriggered when the picker is closing
backdropAnimationObjectfalseConfigure backdrop animation property. Default: {opacity: 0.5 , duration: 1000, delay: 300}
iOSCustomPropsObjectfalseConfigure iOS props to pass to the native component (Picker or DatePicker) from react-native-community
androidCustomPropsObjectfalseConfigure Android props to pass to the native component (Picker or DatePicker) from react-native-community

Picker

NametypeRequiredDescription
itemPickerItem ({ label: string, value: any })trueConfigure the current selected item
placeholderstringfalseConfigure the picker label if no item is selected
onItemChange(item: PickerItem, index: number) => void;trueAdd listener on change event
itemsArraytrueConfigure the list of available items
mode (Android Only)"dialog" or "dropdown"falseConfigure the android picker mode
itemFontFamilystringfalseConfigure the default font family for items (each item can have a fontFamily property)
itemColorstringfalseConfigure the default color for items (each item can have a color property)

DatePicker

NametypeRequiredDescription
valueDatetrueConfigure the picker title (not the placeholder)
onDateChange(date: ?Date) => {}trueConfigure the placeholder when no value is selected
localestring (Locale IDs)falseChange the iOS picker locale
iosMode (iOS Only)"date" or "time" or "datetime"falseChange the iOS picker mode
androidMode (Android Only)"calendar" or "spinner" or "default"falseChange the Android picker mode
iosDisplay (iOS Only)"default" or "spinner" or "inline" or "compact"falseChange the iOS picker display
androidDisplay (Android Only)"default" or "spinner" or "calendar" or "clock"falseChange the Android picker display
minimumDateDatefalseRestrict date selection with a minimum date
maximumDateDatefalseRestrict date selection with a minimum date
neutralButtonLabel (Android Only)stringfalseChange "clear" button label
is24Hour (Android Only)booleanfalseChanging timepicker to 24h format
textColor (iOS Only)stringfalseChange text color on "spinner" display
textstringfalseChange picker button text
onOpen() => voidfalseAdd listener on modal open event
onClose() => voidfalseAdd listener on modal close event
minuteIntervalnumber : 1 or 2 or 3 or 4 or 5 or 6 or 10 or 12 or 15 or 20 or 30falseThe interval at which minutes can be selected
timeZoneOffsetInMinutesnumberfalseChange the timeZone of the date picker
iosCompactHiddenStyle (iOS only)ViewStylefalseChange style for the ios picker in compact mode
touchableStyleViewStylefalseChange style touchable view in the picker

ItemComponent specific

NametypeDescription
resetValue() => voidReset value to null if nullable (DatePicker only)
togglePicker(event: GestureResponderEvent) => voidClose Picker (iOS only)
textstringInput text recieved from the current element
textInputStyleStyleObjtextInputStyle props configured in the picker component
isNullablebooleanisNullable props configured in the picker component
isCompactHiddenPickerNeeded (iOS only)booleantrue if you need to use renderHiddenCompactIOSPicker
renderHiddenCompactIOSPicker (iOS only)() => JSX.ElementRender the DateTimePicker as a invisible button that overlay his parent

DoneBar Picker specific (iOS only)

NametypeDescription
titlestringtitle props configured in the picker component
doneButtonLabelstringdoneButtonLabel props configured in the picker component
onDonePress(event: GestureResponderEvent) => voidClose the picker and trigger onChange

Keywords

FAQs

Last updated on 20 Dec 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc