# @mobly/react-mobile-picker

> An iOS like select box component for React

Latest version **0.2.3** (published 2019-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @mobly/react-mobile-picker
pnpm add @mobly/react-mobile-picker
yarn add @mobly/react-mobile-picker
bun add @mobly/react-mobile-picker
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2019-02-18 |
| First published | 2019-02-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lei Lei |
| Maintainers | andrych, mobly-dev |
| Keywords | react, react mobile picker, mobile picker, picker, react-component, react components, react ui, mobile ui |

## Links

- npm: https://www.npmjs.com/package/@mobly/react-mobile-picker
- Repository: https://github.com/mobly-nv/react-mobile-picker
- Homepage: https://github.com/mobly-nv/react-mobile-picker#readme
- Issues: https://github.com/mobly-nv/react-mobile-picker/issues
- npm.io page: https://npm.io/package/@mobly/react-mobile-picker

## Dependencies (1)

- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.2.3 (latest) — 2019-02-18
- 0.2.2 — 2019-02-14
- 0.2.1 — 2019-02-14
- 0.2.0 — 2019-02-14

## README

# React Mobile Picker

[![Travis](https://img.shields.io/travis/adcentury/react-mobile-picker.svg)](https://travis-ci.org/adcentury/react-mobile-picker) [![npm](https://img.shields.io/npm/dm/react-mobile-picker.svg)](https://www.npmjs.com/package/react-mobile-picker) [![GitHub license](https://img.shields.io/github/license/adcentury/react-mobile-picker.svg)](https://github.com/adcentury/react-mobile-picker/blob/master/LICENSE)

This is a forked package of the original (which seems no longer maintained). Updated react, cleaned up code and fixed passive event listener error for touchmove.

## TODO

- [ ] Add tests
- [ ] Update webpack and config

React Mobile Picker is a super simple component with no restriction, which means you can use it in any way you want.

![screen-capture](./examples/screen-capture.gif)

## Preview

![qr](./examples/qr.png)

Scan this Qr in you mobile.

Or visit (in mobile or mobile simulator): [http://adcentury.github.io/react-mobile-picker](http://adcentury.github.io/react-mobile-picker)

## Install

```
npm install @mobly/react-mobile-picker --save
```

## Usage

### ES6

```javascript
import Picker from '@mobly/react-mobile-picker';
```

### CommonJS

```javascript
var Picker = require('@mobly/react-mobile-picker');
```

## Props

| Property name | Type | Default | Description |
| ------------- | ---- | ------- | ----------- |
| optionGroups | Object | N/A | Key-value pairs as `{name1: options1, name2: options2}`. `options` is an array of all options for this name. |
| valueGroups | Object | N/A | Selected value pairs as `{name1: value1, name2: value2}`. |
| onChange(name, value) | Function | N/A | Callback called when user pick a new value. |
| onClick(name, value) | Function | N/A | Callback called when user click on selected value. |
| itemHeight | Number | 36 | Height of each item (that is each option). In `px`. |
| height | Number | 216 | Height of the picker. In `px`. |

## Getting Started

By design, React Mobile Picker is a [Controlled Component](https://facebook.github.io/react/docs/forms.html#controlled-components), which means the selected value of the rendered element will always reflect the `valueGroups`. Every time you want to change the selected item, just modify `valueGroups` values.

Here is an example of how to integrate React Mobile Picker:

```javascript
import React, {Component} from 'react';
import Picker from '@mobly/react-mobile-picker';

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      valueGroups: {
        title: 'Mr.',
        firstName: 'Micheal',
        secondName: 'Jordan'
      },
      optionGroups: {
        title: ['Mr.', 'Mrs.', 'Ms.', 'Dr.'],
        firstName: ['John', 'Micheal', 'Elizabeth'],
        secondName: ['Lennon', 'Jackson', 'Jordan', 'Legend', 'Taylor']
      }
    };
  }

  // Update the value in response to user picking event
  handleChange = (name, value) => {
    this.setState(({valueGroups}) => ({
      valueGroups: {
        ...valueGroups,
        [name]: value
      }
    }));
  };

  render() {
    const {optionGroups, valueGroups} = this.state;

    return (
      <Picker
        optionGroups={optionGroups}
        valueGroups={valueGroups}
        onChange={this.handleChange} />
    );
  }
}
```

## More Examples

```
git clone this repo
npm install
npm start
point your browser to http://localhost:8080
```

## License

MIT.

---
_Source: https://npm.io/package/@mobly/react-mobile-picker · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
