Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jobinsjp/vue3-datepicker

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jobinsjp/vue3-datepicker

A Datepicker Component For Vue3

  • 1.0.2-jobins-03
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
increased by175%
Maintainers
2
Weekly downloads
 
Created
Source

@jobinsjp/vue3-datepicker

A forked (from) and updated version for JoBins use case.

中文版

A Datepicker Component For Vue3

tests npm MIT

Demo

https://mengxiong10.github.io/vue-datepicker-next/index.html

image

Install

$ npm install @jobinsjp/vue3-datepicker --save

Usage

<script>
  import DatePicker from '@jobinsjp/vue3-datepicker';
  import '@jobinsjp/vue3-datepicker/index.css';

  export default {
    components: { DatePicker },
    data() {
      return {
        time0: null
        time1: null,
        time2: null,
        time3: null,
      };
    },
  };
</script>

<template>
  <div>
    <date-picker v-model:value="time0"></date-picker>
    <date-picker v-model:value="time1" type="datetime"></date-picker>
    <date-picker v-model:value="time2" valueType="format"></date-picker>
    <date-picker v-model:value="time3" range></date-picker>
  </div>
</template>

Theme

If your project uses SCSS, you can change the default style variables.

To create a scss file. e.g. datepicker.scss:

$namespace: 'xmx'; // change the 'mx' to 'xmx'. then <date-picker prefix-class="xmx" />

$default-color: #555;
$primary-color: #1284e7;

@import '~@jobinsjp/vue3-datepicker/scss/index.scss';

Internationalization

The default language is English. If you need other locales, you can import a locale file. Once you import a locale, it becomes the active locale.

import DatePicker from '@jobinsjp/vue3-datepicker';
import '@jobinsjp/vue3-datepicker/index.css';

import '@jobinsjp/vue3-datepicker/locale/zh-cn';

You can also override some of the default locale by lang. Full config

<script>
  export default {
    data() {
      return {
        langObject: {
          formatLocale: {
            firstDayOfWeek: 1,
          },
          monthBeforeYear: false,
        },
        langString: 'zh-cn',
      };
    },
  };
</script>

<template>
  <date-picker :lang="langObject"></date-picker>
  <date-picker :lang="langString"></date-picker>
</template>

Props

PropDescriptionTypeDefault
typeselect the type of pickerdate |datetime|year|month|time|week'date'
rangeif true, pick the range datebooleanfalse
formatto set the date format. similar to moment.jstoken'YYYY-MM-DD'
formatteruse your own formatter, such as moment.jsobject-
value-typedata type of the binding valuevalue-type'date'
default-valuedefault date of the calendarDatenew Date()
langoverride the default localestringobject
placeholderinput placeholder textstring''
editablewhether the input is editablebooleantrue
clearableif false, don't show the clear iconbooleantrue
confirmif true, need click the button to change valuebooleanfalse
confirm-textthe text of confirm buttonstring'OK'
multipleif true, multi-select datebooleanfalse
disableddisable the componentbooleanfalse
disabled-datespecify the date that cannot be selected(date: Date, currentValue?: Date[]) => boolean-
disabled-timespecify the time that cannot be selected(date: Date) => boolean-
append-to-bodyappend the popup to bodybooleantrue
input-classinput classnamestring'mx-input'
input-attrinput attrs(eg: { name: 'date', id: 'foo'})object
openopen state of pickerboolean-
default-paneldefault panel of the pickeryear|month-
popup-stylepopup styleobject
popup-classpopup classes
shortcutsset shortcuts to selectArray<{text, onClick}>-
title-formatformat of the tooltip in calendar celltoken'YYYY-MM-DD'
partial-updatewhether update date when select year or monthbooleanfalse
separatortext of range separatorstring' ~ '
show-week-numberdetermine whether show week numberbooleanfalse
hour-stepinterval between hours in time picker1 - 601
minute-stepinterval between minutes in time picker1 - 601
second-stepinterval between seconds in time picker1 - 601
hour-optionscustom hour columnArray<number>-
minute-optionscustom minute columnArray<number>-
second-optionscustom second columnArray<number>-
show-hourwhether show hour columnbooleanbase on format
show-minutewhether show minute columnbooleanbase on format
show-secondwhether show second columnbooleanbase on format
use12hwhether show ampm columnbooleanbase on format
show-time-headerwhether show header of time pickerbooleanfalse
time-title-formatformat of the time headertoken'YYYY-MM-DD'
time-picker-optionsset fixed time list to selecttime-picker-optionsnull
prefix-classset prefix classstring'mx'
scroll-durationset the duration of scroll when hour is selectednumber100

remove inline range-separator => separator; input => update:value

Token
UintTokenoutput
YearYY70 71 ... 10 11
YYYY1970 1971 ... 2010 2011
Y-1000 ...20 ... 1970 ... 9999 +10000
MonthM1 2 ... 11 12
MM01 02 ... 11 12
MMMJan Feb ... Nov Dec
MMMMJanuary February ... November December
Day of MonthD1 2 ... 30 31
DD01 02 ... 30 31
Day of Weekd0 1 ... 5 6
ddSu Mo ... Fr Sa
dddSun Mon ... Fri Sat
ddddSunday Monday ... Friday Saturday
AM/PMAAM PM
aam pm
HourH0 1 ... 22 23
HH00 01 ... 22 23
h1 2 ... 12
hh01 02 ... 12
Minutem0 1 ... 58 59
mm00 01 ... 58 59
Seconds0 1 ... 58 59
ss00 01 ... 58 59
Fractional SecondS0 1 ... 8 9
SS00 01 ... 98 99
SSS000 001 ... 998 999
Time ZoneZ-07:00 -06:00 ... +06:00 +07:00
ZZ-0700 -0600 ... +0600 +0700
Week of Yearw1 2 ... 52 53
ww01 02 ... 52 53
Unix TimestampX1360013296
Unix Millisecond Timestampx1360013296123
formatter

The formatter accepts an object to customize formatting.

<date-picker :formatter="momentFormat" />
data() {
  return {
    // Use moment.js instead of the default
    momentFormat: {
      //[optional] Date to String
      stringify: (date) => {
        return date ? moment(date).format('LL') : ''
      },
      //[optional]  String to Date
      parse: (value) => {
        return value ? moment(value, 'LL').toDate() : null
      },
      //[optional] getWeekNumber
      getWeek: (date) => {
        return // a number
      }
    }
  }
}

value-type

set the format of binding value

ValueDescription
'date'return a Date object
'timestamp'return a timestamp number
'format'returns a string formatted using pattern of format
token(MM/DD/YYYY)returns a string formatted using this pattern
shortcuts

The shortcuts for the range picker

[
  { text: 'today', onClick: () => new Date() },
  {
    text: 'Yesterday',
    onClick: () => {
      const date = new Date();
      date.setTime(date.getTime() - 3600 * 1000 * 24);
      return date;
    },
  },
];
AttributeDescription
texttitle of the shortcut
onClickcallback function , need to return a Date
time-picker-options

Set fixed time list to select;

{start: '00:00', step:'00:30' , end: '23:30', format: 'HH:mm' }
AttributeDescription
startstart time
stepstep time
endend time
formatthe default is same as prop format

Events

NameDescriptionCallback Arguments
update:valueWhen the value change(v-model:value event)date
changeWhen the value change(same as input)date, type('date'|'hour'|'minute'|'second'|'ampm')
openWhen panel openingevent
closeWhen panel closing
confirmWhen click 'confirm' buttondate
clearWhen click 'clear' button
input-errorWhen user type a invalid Datethe input text
pickwhen select date #429date
calendar-changewhen change the calendardate
panel-changewhen the calendar panel changestype('year'|'month'|'date'), oldType

Slots

NameDescription
icon-calendarcustom the calender icon
icon-clearcustom the clear icon
inputreplace input
headerpopup header
footerpopup footer
sidebarpopup sidebar

ChangeLog

CHANGELOG

One-time Donations

If you find this project useful, you can buy me a coffee

Paypal Me

donate

License

MIT

Copyright (c) 2021-present xiemengxiong

Keywords

FAQs

Package last updated on 21 Jul 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc