Giter VIP home page Giter VIP logo

ng-data-picker's Introduction

No time for maintenance - welcome to send a useful PR :)

ng-data-picker Version Badge

๐Ÿ„๐Ÿพ A Data Picker for Angular 4+

npm package travis build NPM downloads gzip size CircleCI

NPM Description

Let's more easily select some data on the touch screen device, such as time / city / gender / seat number / product / ...

Examples

See branch gh-pages for all code of extant examples and environment.

Demo Level Code
gender โ˜… gender.component.ts
product โ˜…โ˜… product.component.ts
date-time โ˜…โ˜…โ˜… date-time.component.ts

Take a look

Screen shot

โš ๏ธ Below gif is a temporary used from vue version of this picker. will be updated soon.

Screen record

Install

yarn add ng-data-picker

or

npm i -S ng-data-picker

Usage

Quick look

app.module.ts

import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core'
import { DataPickerComponent } from 'ng-data-picker'

@NgModule({
  ...
  declarations: [
    DataPickerComponent
  ],
  schemas: [
    NO_ERRORS_SCHEMA // for third party component
  ],
  ...
})

app.component.ts

export class AppComponent {
  data = [
    {
      list: ['sun', 'earth', 'moon']
    }
  ]

  change ({ gIndex, iIndex }) {
    console.log(gIndex, iIndex)
  }
}

app.component.html

<ng-data-picker [data]="data" (change)="change($event)"></ng-data-picker>

โš™๏ธ Props

name type default explain
change Function ({gIndex,iIndex})=>{} Callback after which group's current index changed, pass two arguments, group index gIndex and item index iIndex
data Array [] Picker initial data
data[i].currentIndex Number 0 Current index of this group's list
data[i].weight Number 1 Group weights in parent width 1..12
data[i].list Array - List of the group
data[i].list[j] String or Object - Item in the list of group, use value key when it is a object item
data[i].onClick Function - Click event on the middle layer of this group, pass two arguments that group index gIndex and selected index iIndex of this group
data[i].textAlign String - start center end justify left right nowrap wrap
data[i].className String - Your custom class name for this group
data[i].divider Boolean false If it is true, then onClick list currentIndex will not be used
data[i].text String - Just use this text when divider is true

๐Ÿ”จ Instance methods

name type explain
setGroupData Function (gIndex,gData)=>void Dynamically set a group data with two arguments (gIndex, gData), group index and group data (see props data[i])
getCurrentIndexList Function ()=>[] Return a Array of the groups current index list (has divider current index, and it is default to 0)
getGroupsRectList Function ()=>void Get some info for gesture, you can call this function when the component displayed if the component is hidden when it's initialization

Development

npm start # development
npm run build:prod # build for production
npm run prepare # build for third party

Any problem?

Please let me know.

Is it useful?

๐ŸŒš Donate A github star โŸ

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.