šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

semantic-ui-calendar-react

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semantic-ui-calendar-react

date/time picker built from semantic-ui elements

0.8.0
Source
npm
Version published
Weekly downloads
8.9K
12.46%
Maintainers
1
Weekly downloads
Ā 
Created
Source

:tada: Starting with version 0.8.0 it's css free.

:warning: not fully compatible with semantic-ui-react version >= 0.81.0

semantic-ui-calendar-react

Datepicker react component based on semantic-ui-react components

My intention was to create something that looks like this https://github.com/mdehoog/Semantic-UI-Calendar.

Here you can find a live example https://arfedulov.ru/examples/semantic-ui-calendar-react.

installation

npm i semantic-ui-calendar-react

usage

Let's create a form that needs date-related input fields.

Import input components:

import {
  DateInput,
  TimeInput,
  DateTimeInput,
  DatesRangeInput
} from 'semantic-ui-calendar-react';

Then build a form:

class DateTimeForm extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      date: '',
      time: '',
      dateTime: '',
      datesRange: ''
    };
  }

  handleChange = (event, {name, value}) => {
    if (this.state.hasOwnProperty(name)) {
      this.setState({ [name]: value });
    }
  }

  render() {
    return (
      <Form>
        <DateInput
          name="date"
          placeholder="Date"
          value={this.state.date}
          iconPosition="left"
          onChange={this.handleChange} />
        <TimeInput
          name="time"
          placeholder="Time"
          value={this.state.time}
          iconPosition="left"
          onChange={this.handleChange} />
        <DateTimeInput
          name="dateTime"
          placeholder="Date Time"
          value={this.state.dateTime}
          iconPosition="left"
          onChange={this.handleChange} />
        <DatesRangeInput
          name="datesRange"
          placeholder="From - To"
          value={this.state.datesRange}
          iconPosition="left"
          onChange={this.handleChange} />
      </Form>
    );
  }
}

Also you can build a form with inline pickers as inputs. Just set inline prop on input element and it will be displayed as inline picker:

class DateTimeFormInline extends React.Component {
 handleChange = (event, {name, value}) => {
    if (this.state.hasOwnProperty(name)) {
      this.setState({ [name]: value });
    }
  }

  render() {
    return (
      <Form>
        <DateInput
          inline
          name="date"
          value={this.state.date}
          onChange={this.handleDateChange} />
      </Form>
    );
  }
}

Locales support

Since semantic-ui-calendar-react uses moment.js it has complete locales support. To change locale you need to set moment's locale in a scope that contains semantic-ui-calendar-react components:


moment.locale('ru')

// code that uses ``semantic-ui-calendar-react`` components

Supported elements

DateInput

PropDescription
all that can be used with SUIR Form.Input
dateFormat{string} Date formatting string. You can use here anything that can be passed to moment().format. Default: DD-MM-YYYY
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
startMode{string} Display mode to start. One of ['year', 'month', 'day']. Default: day
closable{bool} If true, popup closes after selecting a date
initialDate{string|moment|Date} Date to display initially when no date is selected
disable{string|moment|string[]|moment[]} Date or list of dates that are displayed as disabled
maxDate{string|moment} Maximum date that can be selected
minDate{string|moment} Minimum date that can be selected
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

TimeInput

PropDescription
all that can be used with SUIR Form.Input
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
closable{bool} If true, popup closes after selecting a time
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

DateTimeInput

PropDescription
all that can be used with SUIR Form.Input
dateFormat{string} Date formatting string. You can use here anything that can be passed to moment().format. Default: DD-MM-YYYY
divider{string} Date and time divider. Default:
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
startMode{string} Display mode to start. One of ['year', 'month', 'day']. Default: day
closable{bool} If true, popup closes after selecting a date-time
initialDate{string|moment|Date} Date to display initially when no date is selected
disable{string|moment|string[]|moment[]} Date or list of dates that are displayed as disabled
maxDate{string|moment} Maximum date that can be selected
minDate{string|moment} Minimum date that can be selected
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

DatesRangeInput

PropDescription
all that can be used with SUIR Form.Input
dateFormat{string} Date formatting string. You can use here anything that can be passed to moment().format. Default: DD.MM.YY
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
closable{bool} If true, popup closes after selecting a dates range
initialDate{string|moment|Date} Open a calendar on this date
maxDate{string|moment} Maximum date that can be selected
minDate{string|moment} Minimum date that can be selected
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

YearInput

PropDescription
all that can be used with SUIR Form.Input
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
closable{bool} If true, popup closes after selecting a year
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

MonthInput

PropDescription
all that can be used with SUIR Form.Input
popupPosition{string} One of ['top left', 'top right', 'bottom left', 'bottom right', 'right center', 'left center', 'top center', 'bottom center']. Default: top left
inline{bool} If true inline picker displayed. Default: false
closable{bool} If true, popup closes after selecting a month
inlineLabel{bool} A field can have its label next to instead of above it.
closeOnMouseLeave{bool} Should close when cursor leaves calendar popup. Default: true

Keywords

semantic

FAQs

Package last updated on 04 Aug 2018

Did you know?

Socket

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