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 🙏

© 2026 – Pkg Stats / Ryan Hefner

better-datepicker

v0.2.3

Published

better-datepicker

Readme

Better-datepicker

A PC Datepicker with only 9KB

code-test install size

Doc

https://jumodada.github.io/better-datepicker/

CDN

https://cdn.jsdelivr.net/npm/[email protected]/

Installing

Using npm:

$ npm i better-datepicker

Using yarn:

$ yarn add better-datepicker

Usage

es5

import  {createDatePicker} from 'better-datepicker'
import 'better-datepicker/dist/index.css'

CommonJS

const {createDatePicker} = require('better-datepicker').default
require('better-datepicker/dist/index.css')

Example

<input type="text" id="input">
  const input = document.querySelector('#input')
  createDatePicker(input,{
    placement: 'bottom',
    type: 'date',
    zIndex: 2000,
    format: 'yyyy/MM/dd'
  })

you can also

  <div id="wrapper">
     <span>Including children, find the first inputElement</span>
     <input type="text">
  </div>
  <script >
    const input = document.querySelector('#wrapper')
    createDatePicker(input,{
      placement: 'bottom',
      type: 'date',
      zIndex: 2000,
      format: 'yyyy/MM/dd'
    })
  </script>

todo: support virtual dom

Options Validator

If the format is illegal, it will use default value

Options

| Options | Description | Type | Accepted Values | Default | |---------|------------ |---------- |------------- |-------- | | placeholder | To set placeholder | string | - | - | | type | Type of datepicker | string | date/date-range/month/month-range/year/year-range/week | date | | format | To set the date format | string | - | yyyy/MM/dd | | classes | To set the picker wrapper classes(It will have a logo prefix: better-datepicker) | string[] | - | - | | zIndex | z-index of Picker | number | - | 2000 | style | To set the picker wrapper style(zIndex Priority is lower than above) | Object | - | - | | placement | Placement of datepicker | string | top/bottom/right/left | bottom | | disabledDate | Specifies the date that cannot be selected | function | - | - | | offset | Distance between Picker and inputElement | number | - | 12 | | insertTo | Name of the node inserted | string | body/parent | body | | binding | Bind the value of the inputElement | boolean | - | true | | themeColor | Theme color(selected、hover、range-start、range-end), like #2ECC71 | string | - | - | rangeBgColor | The backgroundColor that element is in range ,It's usually lighter than the themeColor | string | - | - | tdColor | Td text color | string | - | - | thColor | Th text color | string | - | -

Default Options

global config

  import {defaultOptions} from "better-datepicker"
  defaultOptions({
    placement: 'bottom',
    type: 'date',
    zIndex: 2000,
    format: 'yyyy/MM/dd'
  })

Theme

you can use defaultOptions

  import {defaultOptions} from "better-datepicker"
  defaultOptions({
    themeColor: '#1890ff',
    rangeBgColor: '#e6f7ff',
    tdColor: '#5f5f5f',
    thColor: '#5f5f5f'
  })

or

only changes theme of the current instance

     const input = document.querySelector('#wrapper')
     const instance = createDatePicker(input,{
         themeColor: '#1890ff',
         rangeBgColor: '#e6f7ff',
         tdColor: '#5f5f5f',
         thColor: '#5f5f5f'
     })

Locale

global config

  import {locale} from "better-datepicker"
  import zhCn from 'better-datepicker/dist/locale_es/zh-cn'    // es
  //require('better-datepicker/dist/locale_umd/zh-cn') // cjs
  locale(zhCn)

| Locale/Language | Abbreviation/Link | | ----------------- | -------------------------------- | | Afghanistan | af | | Brazil | br |
| English | en | | Australia | en-au | | Canada | en-au | | England | en-gb | | Ireland | en-ie | | Spain | es |
| Finland | fi | | Angola | fo |
| Faroe Islands | fr |
| Croatia | hr |
| Haiti | ht | | Italy | it |
| Japan | ja | | Korea(South) | ko | | Kuwait | ku | | Lebanon | lb | | Laos | lo | | Ukraine | uk | | Uzbekistan | uz | | Chinese | zh | | Simplified Chinese | zh-cn | | Hong Kong China | zh-hk | | Taiwan China | zh-tw |

or configure your own region

  import {locale} from "better-datepicker"
  const CubaLocale =  {
    name: 'Cuba',
    weekStart: 6,  //Saturday is set as the first day of the week
    months: ["کانونی دووەم", "شوبات", "ئازار", "نیسان", "ئایار", "حوزەیران", "تەمموز", "ئاب", "ئەیلوول", "تشرینی یەكەم", "تشرینی دووەم", "كانونی یەکەم"],
    weekdays: ["ی", "د", "س", "چ", "پ", "ه", "ش"], //short for week
    weekFormat: 'yyyy-ww'
  }
  locale(CubaLocale)

Instance methods

| name | Description | params | |---------|------------ |------------ | | destroyed | destroyed the datepicker,clear InputElement value| - | onChange | called callback when date has changed |(callback) | update | Update configuration, remove old datepicker | (options) | getCurrentDate | get current date | - | open | open the datepicker | - | close | close the datepicker | - | clear | clear the date | -

DESTROY

  import {destroy} from "better-datepicker"

  const picker1 = createDatePicker('#input1')
  
  // picker1.destroyed()

  const picker1 = createDatePickerc('#input2')
  destroy([picker1,picker2]) // destroyed picker1 and picker 2
  destroy() //destroyed all 

USE IN VUE

Reactive updates have been supported since version 0.2.2

When a property of props is changed, the datepicker is also updated

<template>
  <el-input ref='input'></el-input>
</template>

<script lang='ts'>
import '../../../assets/svg/svg'
import { defineComponent, toRefs } from 'vue'

import { createDatePicker } from '../../../../../src'

export default defineComponent({
  name: 'datepicker',
  data() {
    return {
      datepicker: null,
    }
  },
  mounted() {
    const input = this.$refs.input
    this.datepicker = createDatePicker(input.$el, this.$props)
  }
})
</script>

TODO LIST

| versions | Description| |---------|------------ | | 0.5.0 | support unlinkPanels、zIndex、readonly、default-value、className、style、size .... | | 0.7.0 | support extends plugins | | 0.9.0 | support time picker |

Browser support

todo

License

MIT