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

react-h5-calendar-xi

v0.1.4

Published

react的h5周 月 (多选)日期(|时间)选择器

Downloads

7

Readme

说明(请移步 https://www.npmjs.com/package/react-h5-calendar-x )

工作中碰到一个需求:h5的日历选择(react技术线),支持多选,支持快捷选择近7日、30日、工作日,支持周视图,支持手指滑动。拿来主义者我在网上搜到一个最接近的——[https://github.com/TangSY/react-hash-calendar],其功能有

  • 支持手势滑动操作
  • 上下滑动 切换 周/月 模式

    【周模式中】 左右滑动可切换 上一周/下一周 【月模式中】 左右滑动可切换 上一月/下一月

最主要的问题是不支持多选。那只好站在人家的肩膀上,做一些改造/扩展的工作:

  • 支持多选
  • 支持选择近n天且符合自定义规则的日期
  • 支持点击操作来快速左右切换月份/周

其他改动有:1)defaultDatetime可以为null,代表初始化选择的日期是无。 2)日期多选模式打开,则自动隐藏timePicker-时间选择。3)actionSlot支持函数。 4)支持顶部点击快速左右切换月份/周。

安装使用说明

npm i react-h5-calendar-x
import { ReactH5Calendar } from 'react-h5-calendar-x'

function App () {
  return (
    <div className="App">
      <ReactH5Calendar model="inline" />
    </div>
  );
}

export default App;

Demo及Api

简原版见 https://github.com/TangSY/react-hash-calendar/tree/master#readme

本库新增加[|改动](相比较于原作)有:

| 属性 | 说明 | 类型 | 默认 | | :------------------- | :----------------------------------------------------------- | :----------------------------------------------------: | :--: | | monthTitleActionSlot | truely会显示日历组件顶部控件(左右点击可切换月/周),Array则显示自定义的 类dom|文案; | boolean| undefined | Array<React.ReactNode|string> | - | | multiple | 是否多选 | boolean | - | | defaultDatetime | 指定默认时间。 | Date|undefined|null | now | | dateClickCallback | 日历被点击时调用,参数为 { date }。(返回的日期格式取决于 format 属性) | (date: Date|string, isSelected: boolean) => void | - | | checkedDateOnChange | 多选模式下,选中的日期发生变化时的回调,参数为所选中的日期数组—— 数组元素格式取决于 format 属性) | (dateArr: Array<Date | string>) => void | - |

实例新增几个方法(都是针对“多选模式”):

(1)选中临近n天(方法内部会执行checkedDateOnChange的回调)

nextSomeDayChecking = (

days = 7,

isPast?: boolean,

includeToday?: boolean

) => void

(2)选择以指定条件过滤后的本月的天(方法内部会执行checkedDateOnChange的回调,入参是选中的日期数组)

currentMonthChecking = (

onlyWorkday?: boolean,

filterFn?: (checkedDate: Date) => boolean

) => void

(3)清空所有选中日期(方法内部会执行checkedDateOnChange的回调,入参是空数组)

clearCheckedDate= () => void

Other

  • 如果有其他问题, 或者功能上不兼容的。可以邮件沟通 [email protected],或者 github 提交 issue。

打赏

如果觉得可用,那当然好了。小小打赏的二维码见作者头像。[抱拳] [祝好]