ember-pikaday is an addon that can be installed with Ember CLI. It gives you a datepicker input component that can be used in your Ember.js application. ember-cli-moment-shim is used in the background so it is added as NPM dependencies to your application.
The component provided by ember-pikaday is fully acceptance tested. It also provides test helpers to interact with the datepicker in your own acceptance tests. It works in Ember 1.13.1+ or 2.0+, including beta and canary.
cd your-project-directory
ember install ember-pikaday
This README is for the new 2.X release of ember-pikaday. You can find the 1.X README in the stable-1 branch.
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.
You can also pass in other closure actions to handle onOpen
, onClose
and onDraw
events.
You can also change the default format from DD.MM.YYYY
to any format string supported by Moment.js.
You can define a theme which will be a CSS class that can be used as a hook for styling different themes.
You can change the yearRange
. It defaults to 10. the yearRange
can be asingle number or two comma separated years.
If the second year of the comma separated years is set to currentYear
, it setsthe maximum selectable year to the current year.
The readonly
attribute is supported as binding so you can make the input readonly for mobile or other usecases.
The placeholder
attribute is supported as binding so you can improve the user experience of your interface.
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.
The firstDay
attribute is supported as a binding so you can set the first day of the calendar week.Defaults to Monday.
The minDate
attribute is supported as a binding so you can set the earliest date that can be selected.
The maxDate
attribute is supported as a binding so you can set the latest date that can be selected.
The date returned by ember-pikaday is in your local time zone due to the JavaScript default behaviour 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.
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
Please refer to pikaday configuration
If you don't want to show an input field, you can use the pikaday-inputless
component instead of pikaday-input
. 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
app.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 prefered way to do this is writting a custom initializer to inject a localized i18n
object into the datepicker component. Naturally you can use your own localized strings instead of the ones provided by Moment.js.
// app/initializers/setup-pikaday-i18n.js
import EmberObject from '@ember/object';
import moment from 'moment';
export default {
name: 'setup-pikaday-i18n',
initialize: function(application) {
let i18n = EmberObject.extend({
previousMonth: 'Vorheriger Monat',
nextMonth: 'Nächster Monat',
months: moment.localeData().months(),
weekdays: moment.localeData().weekdays(),
weekdaysShort: moment.localeData().weekdaysShort()
});
application.register('pikaday-i18n:main', i18n, { singleton: true });
application.inject('component:pikaday-input', 'i18n', 'pikaday-i18n:main');
}
};
ember-pikaday
when clicking on a button:// app/controller/index.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
togglePika() {
this.toggleProperty('showPika');
}
}
});
ember-pikaday
when hovering over a div:// app/controller/index.js
import Controller from '@ember/controller';
export default Controller.extend({
actions: {
showPika() {
this.set('showPika', true);
},
hidePika() {
this.set('showPika', false);
}
}
});
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:
import { click } from '@ember/test-helpers';
await click('.my-pikaday-input');
Pikaday can be closed with the provided close
helper:
import { close as closePikaday } from 'ember-pikaday/test-support';
await closePikaday('.my-pikaday-input');
An Interactor
, like a page object, provides helpers for getting and setting dates in a date picker:
import { click } from '@ember/test-helpers';
import { Interactor as Pikaday } from 'ember-pikaday/test-support';
await click('#my-datepicker');
await Pikaday.selectDate(new Date(1989, 3, 28));
There are also methods available to check if a specific day, month or year is selected:
await Interactor.selectDate(new Date(1989, 3, 28));
assert.equal(Interactor.selectedYear(), 1989);
assert.equal(Interactor.selectedMonth(), 3);
assert.equal(Interactor.selectedDay(), 28);
By default, ember-pikaday will load for you the needed pikaday assets.If you need to use a custom version, you can now disable auto assests importing like this:
// ember-cli-build.js
let app = new EmberApp(defaults, {
emberPikaday: {
excludePikadayAssets: true
}
});
Ember检查器是一个浏览器插件,用于调试Ember应用程序。 灰烬检查员包括以下主题 - S.No. 灰烬检查员方式和描述 1 安装Inspector 您可以安装Ember检查器来调试您的应用程序。 2 Object Inspector Ember检查器允许与Ember对象进行交互。 3 The View Tree 视图树提供应用程序的当前状态。 4 检查路由,数据选项卡和库信息 您可以看到检查
英文原文: http://emberjs.com/guides/getting-ember/index/ Ember构建 Ember的发布管理团队针对Ember和Ember Data维护了不同的发布方法。 频道 最新的Ember和Ember Data的 Release,Beta 和 Canary 构建可以在这里找到。每一个频道都提供了一个开发版、最小化版和生产版。更多关于不同频道的信息可以查看博客
ember-emojione ember-emojione is your emoji solution for Ember, based on the EmojiOne project. EmojiOne version 2 is used, which is free to use for everyone (CC BY-SA 4.0), you're only required to giv
Ember 3D Ember 3D is an Ember addon for using Three.js - an easy to use, lightweight, javascript 3D library. It is designed to: Prescribe a solid file structure to Three.js code using ES6 modules. Ena
Ember Table An addon to support large data set and a number of features around table. Ember Table canhandle over 100,000 rows without any rendering or performance issues. Ember Table 3.x supports: Emb
vscode-ember This is the VSCode extension to use the Ember Language Server. Features All features currently only work in Ember-CLI apps that use classic structure and are a rough first draft with a lo
ember-headlessui This is a work-in-progress implementation of: https://github.com/tailwindlabs/headlessui A set of completely unstyled, fully accessible UI components for Ember.js, designed to integra
Ember Popper An Ember-centric wrapper around Popper.js. Currently an alpha in active development. See the dummy app for examples Compatibility Ember.js v3.12 or above Ember CLI v2.13 or above Node.js