Code Monkey home page Code Monkey logo

material-ui-next-pickers's Introduction

Material UI Next Pickers

Description

This repository act as a sample of creating a datepicker or timepicker in Material UI Next or it can be imported as a datepicker or timepicker component.

Prerequisite

npm install material-ui-next-pickers --save

Screenshot

Image of Material UI DatePicker Image of Material UI TimePicker

Options

Datepicker

name: string
label?: string
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement>) => void
anchorOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
transformOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
disabled?: boolean
error?: string
min?: Date
max?: Date
dateFormat?: string | ((date:Date) => string)
fullWidth?: boolean
dialog?: boolean
okToConfirm?: boolean
endIcon?: Node
className?: string
InputLabelProps?: InputLabelProps
InputProps?: InputProps
FormHelperTextProps?: FormHelperTextProps
CalendarProps?: CalendarProps

Calendar

action: (actions:any) => void // only resize event
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement>) => void
closeCalendar: () => void
min?: Date
max?: Date
okToConfirm?: boolean
classes?: {
  root?: string
  selectedDay?: string
  selectedDayText?: string
  selectedYear?: string
  selectedYearText?: string
}

Timepicker

name: string
label?: string
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>) => void
selectableMinutesInterval?: number
anchorOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
transformOrigin?: {
  vertical: 'top' | 'center' | 'bottom'
  horizontal: 'left' | 'center' | 'right'
}
disabled?: boolean
error?: string
fullWidth?: boolean
dialog?: boolean
okToConfirm?: boolean
endIcon?: Node
className?: string
InputLabelProps?: InputLabelProps
InputProps?: InputProps
FormHelperTextProps?: FormHelperTextProps
ClockProps?: ClockProps

Clock

action: (actions:any) => void // only resize event
value: Date
onChange: (value:Date, event?:React.MouseEvent<HTMLElement> | React.TouchEvent<HTMLElement>) => void
closeClock: () => void
selectableMinutesInterval?: number
okToConfirm?: boolean
classes?: {
  root?: string
  digitalContainer?: string
  clockBackground?: string
  hand?: string
  textSelected?: string
  minuteDotSelected?: string
}

Basic setup

  1. Make sure you installed Material UI Next.
  2. Install this package via npm.
  3. Import this package and use like the following:
import {DateFormatInput, TimeFormatInput} from 'material-ui-next-pickers'

class YourComponent extends React.Component<{}, YourComponentState> {
  onChangeDate = (date:Date) => {
    console.log('Date: ', date)
    this.setState({date})
  } 
  onChangeTime = (time:Date) => {
    console.log('Time: ', time)
    this.setState({time})
  } 
  render() {
    const {date, time} = this.state
    return (
      <div>
        <DateFormatInput name='date-input' value={date} onChange={this.onChangeDate}/>
        <TimeFormatInput name='time-input' value={time} onChange={this.onChangeTime}/>
      </div>
    )
  } 
}
interface YourComponentState {
  date: Date
  time: Date
}

material-ui-next-pickers's People

Contributors

chingyawhao avatar matth-porch avatar yhching avatar

Watchers

 avatar  avatar

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.