npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rfcalendar

v0.1.7

Published

基于react封装的全日历组件

Downloads

2

Readme

react 全日历组件

基于react开发的一个非常漂亮的全日历组件 预览地址:https://onpure.github.io/rfcalendar/index.html

从NPM下载包

npm i rfcalendar

使用实例

引入包

import React, { Component } from 'react';
import { render } from 'react-dom';
import moment from 'moment';
import { Calendar, CalendarControls } from 'rfcalendar';

class Index extends Component{
  constructor(props){
    super(props);
    const today = moment();
    this.state = {
      year: today.year(),
      selectedDay: [],
      selectedRange: [today, moment(today).add(15, 'day')],
      showDaysOfWeek: true,
      showTodayBtn: true,
      showWeekSeparators: true,
      selectRange: false,
      firstDayOfWeek: 0, // sunday
      customCSSclasses: [today],
      customClassesError: false,
    };
  }

  /**
   * 切换到前一年
   */
  onPrevYear() {
    this.setState(prevState => {
      return{
        year: prevState.year - 1
      }
    });
  }

  /**
   * 切换到下一年
   */
  onNextYear() {
    this.setState(prevState => {
      return{
        year: prevState.year + 1
      }
    });
  }

  /**
   * 日期单项选择
   * @param  {[type]} date    [description]
   * @param  {[type]} classes [description]
   * @return {[type]}         [description]
   */
  datePicked(date, classes) {
    if (!date) {
      // clicked on prev or next month
      return;
    }
    let flag = 0, type = 1;
    let selectedDay = this.state.selectedDay;
    if(selectedDay.length !== 0) {
      selectedDay.forEach((item, index) => {
        ++flag;
        if (moment(item).format("YYYY-MM-DD") == moment(date).format("YYYY-MM-DD")) {
          type = 2;
          selectedDay.splice(index, 1);
        }
      });
    }else{
      selectedDay.push(date);
    }
    type === 1 && flag == selectedDay.length ?
      selectedDay.push(date) : '';
    this.setState({
      selectedDay: selectedDay,
    })
  }

  /**
   * 日期范围选择
   * @param  {[type]} start [description]
   * @param  {[type]} end   [description]
   * @return {[type]}       [description]
   */
  rangePicked(start, end) {
    this.setState({
      selectedRange: [start, end],
      selectedDay: start
    });
  }

  render(){
    const {
      year,
      showTodayBtn,
      selectedDay,
      showDaysOfWeek,
      // forceFullWeeks,
      showWeekSeparators,
      firstDayOfWeek,
      selectRange,
      selectedRange,
      customCSSclasses
    } = this.state;
    return (
      <div id="calendar">
        <CalendarControls
            year={year}
            showTodayButton={showTodayBtn}
            onPrevYear={() => this.onPrevYear()}
            onNextYear={() => this.onNextYear()}
            goToToday={() => this.goToToday()}
          />
        <Calendar
          year={year}
          selectedDay={selectedDay}
          showDaysOfWeek={showDaysOfWeek}
          showWeekSeparators={showWeekSeparators}
          firstDayOfWeek={firstDayOfWeek}
          selectRange={selectRange}
          selectedRange={selectedRange}
          onPickDate={(date, classes) => this.datePicked(date, classes)}
          onPickRange={(start, end) => this.rangePicked(start, end)}
          customClasses={customCSSclasses}
        />
      </div>
    )
  }
}

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

自定义样式

编写样式覆盖即可

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

# run unit tests
npm run unit

# run all tests
npm test