Gathering detailed insights and metrics for ember-pikaday
Gathering detailed insights and metrics for ember-pikaday
Gathering detailed insights and metrics for ember-pikaday
Gathering detailed insights and metrics for ember-pikaday
@ember-eui/pikaday
ember-pikaday integration with @ember-eui/core
pikaday
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS
@types/pikaday
TypeScript definitions for pikaday
@handsontable/pikaday
A refreshing JavaScript Datepicker — lightweight, no dependencies, modular CSS
npm install ember-pikaday
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
158 Stars
551 Commits
169 Forks
12 Watching
9 Branches
85 Contributors
Updated on 28 Nov 2024
JavaScript (90.15%)
Handlebars (5.85%)
HTML (3.94%)
CSS (0.06%)
Cumulative downloads
Total Downloads
Last day
-26.5%
903
Compared to previous day
Last week
-6.6%
5,876
Compared to previous week
Last month
-10.5%
26,606
Compared to previous month
Last year
-9.4%
397,393
Compared to previous year
2
3
46
ember-pikaday provides a datepicker modifier & components for Ember using the Pikaday library.
This addon is fully integration tested, and it provides test helpers to interact with the datepicker in your own tests.
Prerequisites:
Optional prerequisites:
<PikadayInput>
or <PikadayInputless>
components, your app must depend on either moment
or moment-timezone
and you should remember to configure your locale and timezone requirements. See Using Moment.js in Ember Apps & Addons.<input {{pikaday}} />
modifier, moment
or moment-timezone
are optional. Pikaday itself uses them if they present, but doesn't require them.Anti-prerequisites:
In order to give apps control over styling, the default CSS does not load unless you tell it to. The recommended way to load the CSS is to create this file:
1// app/modifiers/pikaday.js 2 3/* Opt-in to using pikaday's default CSS */ 4import 'ember-pikaday/pikaday.css'; 5export { default } from 'ember-pikaday/modifiers/pikaday';
This guarantees that the CSS will load whenever your app uses the {{pikaday}}
modifier (and the {{pikaday}}
modifier is used internally by all the other provided components, so this covers them too).
The {{pikaday}}
modifier invokes new Pikaday()
with your element as Pikaday's field
option:
1<input 2 {{pikaday 3 format='DD.MM.YYYY' 4 value=this.startDate 5 onSelect=this.setStartDate 6 }} 7/>
The optional value
argument can be used to synchronize external changes into Pikaday. Internally, we do this using Pikaday's setDate
.
All other named arguments are passed directly to Pikaday, so see Pikaday's configuration docs.
The only behaviors this modifier adds to the stock Pikaday are:
<input>
element's disabled
attribute we will close Pikaday if it had been open.While the input shows a formatted date to the user, the value
attribute can be any valid JavaScript date including Date
object. If the application sets the attribute without a user interaction the datepicker updates accordingly.
1<label> 2 Start date: 3 <PikadayInput @onSelection={{action 'doSomethingWithSelectedValue'}} /> 4</label>
You can also pass in other closure actions to handle onOpen
, onClose
and onDraw
events.
1<label> 2 Start date: 3 <PikadayInput 4 @onOpen={{action 'doSomethingOnOpen'}} 5 @onClose={{action 'doSomethingOnClose'}} 6 @onDraw={{action 'doSomethingOnDraw'}} 7 /> 8</label>
You can also change the default format from DD.MM.YYYY
to any format string supported by Moment.js.
1<label> 2 Start date: 3 <PikadayInput @format={{'MM/DD/YYYY'}} /> 4</label>
You can define a theme which will be a CSS class that can be used as a hook for styling different themes.
1<label> 2 Start date: 3 <PikadayInput @theme={{'dark-theme'}} /> 4</label>
You can change the yearRange
. It defaults to 10. the yearRange
can be a
single number or two comma separated years.
1<label> 2 Start date: 3 <PikadayInput @yearRange={{'4'}} /> 4</label>
1<label> 2 Start date: 3 <PikadayInput @yearRange={{'2004,2008'}} /> 4</label>
If the second year of the comma separated years is set to currentYear
, it sets
the maximum selectable year to the current year.
1<label> 2 Start date: 3 <PikadayInput @yearRange={{'2004,currentYear'}} /> 4</label>
The readonly
attribute is supported as binding so you can make the input readonly for mobile or other use cases.
1<label> 2 Start date: 3 <PikadayInput @readonly={{'readonly'}} /> 4</label>
The placeholder
attribute is supported as binding so you can improve the user experience of your interface.
1<label> 2 Due date: 3 <PikadayInput @placeholder={{'Due date of invoice'}} /> 4</label>
The disabled
attribute is supported as binding so you can disabled the datepicker entirely.
If the datepicker is shown to the user and it gets disabled it will close the datepicker itself.
1<label> 2 Due date: 3 <PikadayInput @disabled={{isDisabled}} /> 4</label>
The firstDay
attribute is supported as a binding so you can set the first day of the calendar week.
Defaults to Monday.
1<label> 2 Due date: 3 <PikadayInput @firstDay={{0}} /> 4</label>
The minDate
attribute is supported as a binding so you can set the earliest date that can be selected.
1<label> 2 Due Date: 3 <PikadayInput @minDate={{minDate}} /> 4</label>
The maxDate
attribute is supported as a binding so you can set the latest date that can be selected.
1<label> 2 Due Date: 3 <PikadayInput @maxDate={{maxDate}} /> 4</label>
The date returned by ember-pikaday is in your local time zone due to the JavaScript default behavior of new Date()
. This can lead to problems when your application converts the date to UTC. In additive time zones (e.g. +0010) the resulting converted date could be yesterdays date. You can force the component to return a date with the UTC time zone by passing useUTC=true
to it.
1<label> 2 Start date: 3 <PikadayInput @useUTC={{true}} /> 4</label>
ember-pikaday will not automatically convert the date to UTC if your application is setting the datepicker value directly!
You can pass any custom pikaday option through the component like this
1<label> 2 <PikadayInput 3 @options={{hash 4 numberOfMonths=2 5 disableWeekends=true 6 disableDayFn=(action 'someAction') 7 }} 8 /> 9</label>
Please refer to pikaday configuration
If you don't want to show an input field, you can use the <PikadayInputless/>
component instead of <PikadayInput/>
. It has the same API, but doesn't support onOpen
and onClose
. When disabled=true
on a pikaday-inputless
, the datepicker gets hidden.
Localizing the datepicker is possible in two steps. To localize the output of the datepicker, this is the formatted string visible in the input field, you simply include all the locales by following the ember-cli-moment-shim instructions and include the following in your ember-cli-build.js
1app.import('node_modules/moment/locale/de.js');
To localize the datepicker itself, this is the popup you see after clicking the input, a little more work is necessary. The preferred way to do this is to implement a custom component that extends the PikadayInput
component and customizes the i18n
attribute. The following example uses the translations provided by Moment.js - naturally you can use your own localized strings instead.
1// app/components/pikaday-input.js 2 3import PikadayInput from "ember-pikaday/components/pikaday-input"; 4import moment from "moment"; 5 6export default PikadayInput.extend({ 7 init(...args) { 8 this._super(args); 9 this.i18n = { 10 previousMonth: 'Vorheriger Monat', 11 nextMonth: 'Nächster Monat', 12 months: moment.localeData()._months, 13 weekdays: moment.localeData()._weekdays, 14 weekdaysShort: moment.localeData()._weekdaysShort, 15 }; 16 }, 17});
ember-pikaday
when clicking on a button1<button {{action 'togglePika'}}>Show Pika</button> 2{{#if showPika}} 3 <PikadayInputless @value={{'2017-07-07'}} /> 4{{/if}}
1// app/controller/index.js 2import Ember from 'ember'; 3export default Ember.Controller.extend({ 4 actions: { 5 togglePika() { 6 this.toggleProperty('showPika'); 7 }, 8 }, 9});
ember-pikaday
when hovering over a div1<div 2 {{action 'showPika' on='mouseEnter'}} 3 {{action 'hidePika' on='mouseLeave'}} 4> 5 Hover me to pika 6 {{#if showPika}} 7 <PikadayInputless @value={{'2017-07-07'}} /> 8 {{/if}} 9</div>
1// app/controller/index.js 2 3import Controller from '@ember/controller'; 4export default Controller.extend({ 5 actions: { 6 showPika() { 7 this.set('showPika', true); 8 }, 9 hidePika() { 10 this.set('showPika', false); 11 }, 12 }, 13});
The test helpers provided by ember-pikaday
allow you to interact with the datepicker in your integration and acceptance tests.
To open the datepicker use click
from the @ember/test-helpers
package:
1import { click } from '@ember/test-helpers'; 2 3await click('.my-pikaday-input');
Pikaday can be closed with the provided close
helper:
1import { close as closePikaday } from 'ember-pikaday/test-support'; 2 3await closePikaday('.my-pikaday-input');
An Interactor
, like a page object, provides helpers for getting and setting dates in a date picker:
1import { click } from '@ember/test-helpers'; 2import { Interactor as Pikaday } from 'ember-pikaday/test-support'; 3 4await click('#my-datepicker'); 5await Pikaday.selectDate(new Date(1989, 3, 28));
There are also methods available to check if a specific day, month or year is selected:
1await Interactor.selectDate(new Date(1989, 3, 28));
2
3assert.equal(Interactor.selectedYear(), 1989);
4assert.equal(Interactor.selectedMonth(), 3);
5assert.equal(Interactor.selectedDay(), 28);
For usage in gts
or gjs
files, modifier and components are exported from the index:
1import { pikaday, PikadayInput, PikadayInputless } from 'ember-pikaday'; 2 3function doSomethingWithSelectedValue(selectedDate) { 4 alert(selectedDate); 5} 6 7<template> 8 <input 9 Start date: 10 {{pikaday 11 format='DD.MM.YYYY' 12 value=this.startDate 13 onSelect=this.setStartDate 14 }} 15 /> 16 <label> 17 End date: 18 <PikadayInput 19 @format="DD.MM.YYYY" 20 @onSelection={{doSomethingWithSelectedValue}} 21 /> 22 </label> 23 <label> 24 Due date: 25 <PikadayInputless 26 @format="DD.MM.YYYY" 27 @onSelection={{doSomethingWithSelectedValue}} 28 /> 29 </label> 30</template>
No vulnerabilities found.
Reason
15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
packaging workflow detected
Details
Reason
Found 2/6 approved changesets -- score normalized to 3
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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