Gathering detailed insights and metrics for @hokify/vuejs-datepicker
Gathering detailed insights and metrics for @hokify/vuejs-datepicker
Gathering detailed insights and metrics for @hokify/vuejs-datepicker
Gathering detailed insights and metrics for @hokify/vuejs-datepicker
vuejs-datepicker
A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations
@sum.cumo/vue-datepicker
A simple, but powerful, Vue.js datepicker component. Supports disabling of dates, inline mode, translations & custom slots
vue3-datepicker
A simple Vue 3 datepicker component. Supports disabling of dates, translations. Dependent on date-fns.
react-tailwindcss-datepicker
A modern React Datepicker using Tailwind CSS 3
npm install @hokify/vuejs-datepicker
59.4
Supply Chain
97.2
Quality
75.5
Maintenance
50
Vulnerability
99.6
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
17 Stars
956 Commits
5 Forks
2 Watching
2 Branches
12 Contributors
Updated on 01 Aug 2023
Minified
Minified + Gzipped
JavaScript (50.48%)
Vue (47.06%)
CSS (2.3%)
HTML (0.17%)
Cumulative downloads
Total Downloads
Last day
11%
151
Compared to previous day
Last week
11.9%
716
Compared to previous week
Last month
9.8%
2,560
Compared to previous month
Last year
-30.6%
42,013
Compared to previous year
1
1
38
A datepicker Vue component. Compatible with Vue 2.x
this is a fork of https://github.com/charliekassel/vuejs-datepicker, which includes following breaking changes:
To view a demo online: https://codesandbox.io/s/vue-datepicker-demo-82x48
To view demo examples locally clone the repo and run npm install && npm run serve
1npm install @hokify/vuejs-datepicker
or
1yarn add @hokify/vuejs-datepicker
1import Datepicker from '@hokify/vuejs-datepicker'; 2 3export default { 4 // ... 5 components: { 6 Datepicker 7 } 8 // ... 9}
To upgrade to version 2+ check:
I've dropped the additional translations and use the moment.js directly,
therefore you need to remove all dependenices
for the "locale" imports e.g.:
import {en, es} from 'vuejs-datepicker/dist/locale'
The language property changed from an locale object to a simple string (en,de,..)! Please see Translations section how to set up your language.
change custom date formatting to moment js date formatting: https://momentjs.com/docs/#/displaying/ Examples:
Old | New (moment.js) | Displays |
---|---|---|
d MMM yyyy | D MMM YYYY | 12 Feb 2016 |
d MMMM yyyy | D MMMM YYYY | 12 February 2016 |
yyyy-MM-dd | YYYY-MM-DD | 2016-02-12 |
dsu MMM yyyy | Do MMM YYYY | 12th Feb 2016 |
D dsu MMM yyyy | ddd Do MMM YYYY | Sat 12th Feb 2016 |
As this bundle is also useable for SSR rendering, you have to take care of css yourself. (see also https://github.com/vuejs/rollup-plugin-vue/issues/266) I strongly recommend to create a custom component, that wraps the vuejs-datepicker. Then it's easy to add custom css and have a consistent style for the datepicker.
Ensure you have postcss-import up and running. (https://github.com/postcss/postcss-import) E.g.via:
<style lang="scss">
/* purgecss start ignore */
@import "@hokify/vuejs-datepicker/dist/vuejs-datepicker.css"
/* purgecss end ignore */
</style>
If you do not use purgeCSS, you can safely remove the comment lines
add inside nuxt.config:
css: [
{
src: '@hokify/vuejs-datepicker/dist/vuejs-datepicker.css',
lang: 'css'
},
I'm using this method, as I actually customized the datepicker and therefore don't need to overwrite css classes again with my style.
<style lang="scss">
.vdp-datepicker {
overflow: visible;
display: inline-block;
....
}
...
</style>
Ping me if you have any better approaches! :)
1<datepicker></datepicker>
value prop if passed should be a Date object
1<script> 2var state = { 3 date: new Date(2016, 9, 16) 4} 5</script> 6<datepicker :value="state.date"></datepicker>
support name attribute for normal html form submission
1<datepicker :value="state.date" name="uniquename"></datepicker>
Using v-model
1<datepicker v-model="state.date" name="uniquename"></datepicker>
Emits events
1<datepicker @selected="doSomethingInParentComponentFunction" @opened="datepickerOpenedFunction" @closed="datepickerClosedFunction">
Inline always open version
1<datepicker :inline="true"></datepicker>
Prop | Type | Default | Description |
---|---|---|---|
value | Date|String | Date value of the datepicker | |
name | String | Input name property | |
id | String | Input id | |
format | String|Function | DD MMM YYYY | Date formatting string or function |
full-month-name | Boolean | false | To show the full month name |
language | String | en | Translation for days and months |
disabled-dates | Object | See below for configuration | |
placeholder | String | Input placeholder text | |
inline | Boolean | To show the datepicker always open | |
calendar-class | String|Object | CSS class applied to the calendar el | |
input-class | String|Object | CSS class applied to the input el | |
wrapper-class | String|Object | CSS class applied to the outer div | |
monday-first | Boolean | false | To start the week on Monday |
clear-button | Boolean | false | Show an icon for clearing the date |
clear-button-icon | String | Use icon for button (ex: fa fa-times) | |
calendar-button | Boolean | false | Show an icon that that can be clicked |
calendar-button-icon | String | Use icon for button (ex: fa fa-calendar) | |
calendar-button-icon-content | String | Use for material-icons (ex: event) | |
day-cell-content | Function | Use to render custom content in day cell | |
bootstrap-styling | Boolean | false | Output bootstrap v4 styling classes. |
initial-view | String | minimumView | If set, open on that view |
disabled | Boolean | false | If true, disable Datepicker on screen |
required | Boolean | false | Sets html required attribute on input |
typeable | Boolean | false | If true, allow the user to type the date |
use-utc | Boolean | false | use UTC for time calculations |
open-date | Date|String | If set, open on that date | |
minimum-view | String | 'day' | If set, lower-level views won't show |
maximum-view | String | 'year' | If set, higher-level views won't show |
parse-typed-date | Function: Date | Use to parse custom date for typed input |
These events are emitted on actions in the datepicker
Event | Output | Description |
---|---|---|
opened | The picker is opened | |
closed | The picker is closed | |
selected | Date|null | A date has been selected |
selectedDisabled | Object | A disabled date has been selected |
input | Date|null | Input value has been modified |
cleared | Selected date has been cleared | |
changedMonth | Object | Month page has been changed |
changedYear | Object | Year page has been changed |
changedDecade | Object | Decade page has been changed |
Uses moment.js for date formatting. See https://momentjs.com/docs/#/displaying/ Examples:
Example | Displays |
---|---|
D MMM YYYY | 12 Feb 2016 |
D MMMM YYYY | 12 February 2016 |
YYYY-MM-DD | 2016-02-12 |
Do MMM YYYY | 12th Feb 2016 |
ddd Do MMM YYYY | Sat 12th Feb 2016 |
Token | Desc | Example | Version <2.0 |
---|---|---|---|
D | day | 1 | d |
DD | 0 prefixed day | 01 | dd |
dd | abbr day | Mon | D |
Do | date of Month | 1st 2nd ... 30th 31st | (su) |
M | month number (1 based) | 1 (for Jan) | M |
MM | 0 prefixed month | 01 | MM |
MMM | abbreviated month name | Jan | MMM |
MMMM | month name | January | MMMM |
YY | two digit year | 16 | yy |
YYYY | four digit year | 2016 | yyyy |
Delegates date formatting to provided function. Function will be called with date and it has to return formated date as a string. This allow us to use date-fns, globalize or any other library to format date.
1<script> 2 methods: { 3 customFormatter(date) { 4 return moment(date).format('MMMM Do YYYY, h:mm:ss a'); 5 } 6 } 7</script> 8<datepicker :format="customFormatter"></datepicker>
Dates can be disabled in a number of ways.
1<script> 2var state = { 3 disabledDates: { 4 to: new Date(2016, 0, 5), // Disable all dates up to specific date 5 from: new Date(2016, 0, 26), // Disable all dates after specific date 6 days: [6, 0], // Disable Saturday's and Sunday's 7 daysOfMonth: [29, 30, 31], // Disable 29th, 30th and 31st of each month 8 dates: [ // Disable an array of dates 9 new Date(2016, 9, 16), 10 new Date(2016, 9, 17), 11 new Date(2016, 9, 18) 12 ], 13 ranges: [{ // Disable dates in given ranges (exclusive). 14 from: new Date(2016, 11, 25), 15 to: new Date(2016, 11, 30) 16 }, { 17 from: new Date(2017, 1, 12), 18 to: new Date(2017, 2, 25) 19 }], 20 // a custom function that returns true if the date is disabled 21 // this can be used for wiring you own logic to disable a date if none 22 // of the above conditions serve your purpose 23 // this function should accept a date and return true if is disabled 24 customPredictor: function(date) { 25 // disables the date if it is a multiple of 5 26 if(date.getDate() % 5 == 0){ 27 return true 28 } 29 } 30 } 31} 32</script> 33<datepicker :disabledDates="state.disabledDates"></datepicker>
Dates can be highlighted (e.g. for marking an appointment) in a number of ways. Important:
By default disabled dates are ignored, to highlight disabled dates set the includeDisabled
property to true
. Note: Both to
and from
properties are required to define a range of
dates to highlight.
1<script> 2var state = { 3 highlighted: { 4 to: new Date(2016, 0, 5), // Highlight all dates up to specific date 5 from: new Date(2016, 0, 26), // Highlight all dates after specific date 6 days: [6, 0], // Highlight Saturday's and Sunday's 7 daysOfMonth: [15, 20, 31], // Highlight 15th, 20th and 31st of each month 8 dates: [ // Highlight an array of dates 9 new Date(2016, 9, 16), 10 new Date(2016, 9, 17), 11 new Date(2016, 9, 18) 12 ], 13 // a custom function that returns true of the date is highlighted 14 // this can be used for wiring you own logic to highlight a date if none 15 // of the above conditions serve your purpose 16 // this function should accept a date and return true if is highlighted 17 customPredictor: function(date) { 18 // highlights the date if it is a multiple of 4 19 if(date.getDate() % 4 == 0){ 20 return true 21 } 22 }, 23 includeDisabled: true // Highlight disabled dates 24 } 25} 26</script> 27<datepicker :highlighted="state.highlighted"></datepicker>
Slots will help you customize content. .
Sometimes you need to show custom content before the calendar header. For such cases you can use the named slot beforeCalendarHeader
.
An example would be to use bootstrap's input-group-prepend
and input-group-append
to show some custom text:
1<datepicker :bootstrap-styling="true"> 2 <div slot="beforeCalendarHeader" class="calender-header"> 3 Choose a Date 4 </div> 5</datepicker>
To implement some custom styling on DateINput, you might need to add elemnt beore the DateInput. Similar to afterDateInput, just it is before in the html DOM.
To implement some custom styling (for instance to add an animated placeholder) on DateInput, you might need to add elements as DateInput siblings. Slot named
afterDateInput
allows you to do that:
1<datepicker> 2 <span slot="afterDateInput" class="animated-placeholder"> 3 Choose a Date 4 </span> 5</datepicker>
See also https://momentjs.com/docs/#/i18n/loading-into-browser/ Especially if you use webpack!
1import 'moment/locale/de';
Browser:
1<script src="locale/de.js" charset="UTF-8"></script>
There is also a minified version including all versions:
1import 'moment/min/locales.min'
1<datepicker language="de"></datepicker>
Available languages are all that moment.js supports. See demo file or https://github.com/moment/moment/tree/develop/locale for a list of available languages and the correct language code for it.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More