🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

amos-datepicker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amos-datepicker

datepicker ui component for amos ui

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

amos-datepicker

TimeView

Clock

example

import React, { Component } from 'react';
import { render } from 'react-dom';
import PropTypes from 'prop-types';
import moment from 'moment';

import { TimeView, Clock } from 'amos-datepicker';

import 'amos-datepicker/assets/TimeView.scss';
import 'amos-datepicker/assets/Clock.scss';

const _locale = {
  hours: '时',
  minutes: '分',
  seconds: '秒'
};

class Demo extends Component {
  static propTypes = {
    dateFormat: PropTypes.string
  };

  static defaultProps = {
    dateFormat: 'HH:mm:ss'
  };

  constructor(props) {
    super(props);
    this.state = {
      value: null
    };
  }

  onClickOutside = () => {};

  onClockChange = v => {
    this.setState({ value: v });
    console.log('selected time:', v);
  };

  getTime = () => {
    const { dateFormat } = this.props;
    const { value } = this.state;
    let timeDate = value || new Date();
    let time = {};
    if (/(H|h)/.test(dateFormat)) {
      time.hours = timeDate.getHours();
    }
    if (/m/.test(dateFormat)) {
      time.minutes = timeDate.getMinutes();
    }
    if (/s/.test(dateFormat)) {
      time.seconds = timeDate.getSeconds();
    }
    return time;
  };

  render() {
    return (
      <div className="demo">
        <TimeView timeFormat="HH:mm:ss" selectedDate={moment()} handleClickOutside={this.onClickOutside} />
        <Clock time={this.getTime()} locale={_locale} onChange={this.onClockChange} />
        <Clock locale={_locale} onChange={this.onClockChange} />
      </div>
    );
  }
}

render(<Demo />, document.getElementById('app'));

Keywords

react

FAQs

Package last updated on 29 Jun 2021

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