@ember-eui/pikaday 4.0.3 → 4.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,26 @@
20
20
  @disabled={{@disabled}}
21
21
  @isInvalid={{@isInvalid}}
22
22
  ...attributes
23
- {{did-insert this.didInsertInput}}
23
+ {{pikaday
24
+ @options
25
+ value=this.value
26
+ onSelect=this.onSelect
27
+ setDefaultDate=true
28
+ defaultDate=@defaultDate
29
+ onOpen=@onOpen
30
+ onDraw=this.onDraw
31
+ onClose=this.onClose
32
+ format=this.format
33
+ minDate=@minDate
34
+ maxDate=@maxDate
35
+ theme=@theme
36
+ yearRange=this.yearRange
37
+ i18n=this.i18n
38
+ firstDay=this.firstDay
39
+ container=@container
40
+ bound=@bound
41
+ }}
42
+ {{on 'change' this.didChange}}
24
43
  >
25
44
  <:prepend as |classes|>
26
45
  {{yield classes to="prepend"}}
@@ -0,0 +1,80 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+
4
+ export default class EuiPikadayComponent extends Component {
5
+ get format() {
6
+ return this.args.format || 'DD.MM.YYYY';
7
+ }
8
+
9
+ get value() {
10
+ return this.args.value;
11
+ }
12
+
13
+ get yearRange() {
14
+ const yearRange = this.args.yearRange;
15
+ if (!yearRange) {
16
+ return 10;
17
+ }
18
+ if (yearRange.indexOf(',') > -1) {
19
+ const yearArray = yearRange.split(',');
20
+ if (yearArray[1] === 'currentYear') {
21
+ yearArray[1] = new Date().getFullYear();
22
+ }
23
+ return yearArray;
24
+ } else {
25
+ return yearRange;
26
+ }
27
+ }
28
+
29
+ get i18n() {
30
+ let i18n = this.args.i18n;
31
+ if (!i18n) {
32
+ return undefined;
33
+ }
34
+ if (!i18n.t) {
35
+ return i18n;
36
+ }
37
+ return {
38
+ previousMonth: i18n.t('previousMonth').toString(),
39
+ nextMonth: i18n.t('nextMonth').toString(),
40
+ months: i18n.t('months').toString().split(','),
41
+ weekdays: i18n.t('weekdays').toString().split(','),
42
+ weekdaysShort: i18n.t('weekdaysShort').toString().split(',')
43
+ };
44
+ }
45
+
46
+ get firstDay() {
47
+ return this.args.firstDay == null ? 1 : parseInt(this.args.firstDay, 10);
48
+ }
49
+
50
+ @action
51
+ onClose() {
52
+ if (this.isDestroying) {
53
+ return;
54
+ }
55
+ if (!this.#heardValue) {
56
+ this.onSelect(null);
57
+ }
58
+ this.args.onClose?.();
59
+ }
60
+
61
+ #heardValue;
62
+
63
+ @action
64
+ onDraw() {
65
+ // this is here because apparently the classic behavior is to pass no
66
+ // arguments to the onDraw callback, but Pikaday's own ownDraw has an
67
+ // argument.
68
+ this.args.onDraw?.();
69
+ }
70
+
71
+ @action
72
+ didChange(event) {
73
+ this.#heardValue = event.target.value;
74
+ }
75
+
76
+ @action
77
+ onSelect(date) {
78
+ this.args.onSelection?.(date);
79
+ }
80
+ }
@@ -2,4 +2,6 @@
2
2
 
3
3
  `ember-pikaday` for `@ember-eui/core`
4
4
 
5
- 1. `ember install @ember-eui/pikaday`
5
+ 1. `ember install @ember-eui/pikaday`
6
+
7
+ In order to have styles for pikaday, please refer to [styles section on their documentation](https://github.com/adopted-ember-addons/ember-pikaday#styles)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ember-eui/pikaday",
3
- "version": "4.0.3",
3
+ "version": "4.0.4",
4
4
  "description": "ember-pikaday integration with @ember-eui/core",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -31,13 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@ember-decorators/component": "^6.1.0",
34
- "@ember-eui/core": "^4.0.3",
34
+ "@ember-eui/core": "^4.0.4",
35
35
  "@types/ember": "^3.16.4",
36
+ "ember-auto-import": "^2.4.0",
36
37
  "ember-cli-babel": "^7.26.11",
37
38
  "ember-cli-htmlbars": "^6.0.1",
38
39
  "ember-cli-typescript": "4.2.1",
39
40
  "ember-named-blocks-polyfill": "^0.2.3",
40
- "ember-pikaday": "^3.0.0",
41
+ "ember-pikaday": "^4.0.0",
41
42
  "ember-svg-jar": "^2.3.4"
42
43
  },
43
44
  "devDependencies": {
@@ -70,7 +71,6 @@
70
71
  "@types/rsvp": "^4.0.4",
71
72
  "babel-eslint": "^8.0.0",
72
73
  "broccoli-asset-rev": "^3.0.0",
73
- "ember-auto-import": "^2.2.4",
74
74
  "ember-cli": "~4.1.1",
75
75
  "ember-cli-dependency-checker": "^3.2.0",
76
76
  "ember-cli-inject-live-reload": "^2.1.0",
@@ -117,5 +117,5 @@
117
117
  "volta": {
118
118
  "extends": "../../package.json"
119
119
  },
120
- "gitHead": "62474e13f2a8273b9a9b58285b9aa30086b5071a"
120
+ "gitHead": "d0007138cff1b49a85ad28a59bc4080d57042990"
121
121
  }
@@ -1,87 +0,0 @@
1
- import Component from '@ember/component';
2
- // eslint-disable-next-line
3
- import PikadayMixin from 'ember-pikaday/mixins/pikaday';
4
- import { isEmpty } from '@ember/utils';
5
- import { action } from '@ember/object';
6
- import { tagName, layout } from '@ember-decorators/component';
7
- import template from '../templates/components/eui-pikaday';
8
-
9
- const defaultFormat = 'YYYY-MM-DD';
10
-
11
- @tagName('')
12
- @layout(template)
13
- export default class EuiPikaday extends Component.extend(PikadayMixin) {
14
- useUtc = false;
15
- yearRange = '1930,currentYear';
16
- useISODate = false;
17
- format = defaultFormat;
18
-
19
- init() {
20
- this.set('format', this.getDateFormat());
21
- super.init(...arguments);
22
- }
23
-
24
- getDateFormat() {
25
- return this.format || defaultFormat;
26
- }
27
-
28
- @action
29
- didInsertInput(input) {
30
- if (this.isDestroyed) {
31
- return;
32
- }
33
- this.set('field', input);
34
- this.setupPikaday();
35
- }
36
-
37
- /*
38
- destroy component and set the field to null
39
- */
40
- willDestroyElement() {
41
- if (this.isDestroyed) {
42
- return;
43
- }
44
- super.willDestroyElement(...arguments);
45
- this.pikaday.destroy();
46
- this.set('field', null);
47
- }
48
-
49
- /*
50
- We convert selected date to correct format
51
- */
52
- getSelectedDate() {
53
- var selectedDate = this.pikaday.getDate();
54
-
55
- if (this.useUTC) {
56
- selectedDate = this.moment
57
- .utc([
58
- selectedDate.getFullYear(),
59
- selectedDate.getMonth(),
60
- selectedDate.getDate()
61
- ])
62
- .toDate();
63
- }
64
- return selectedDate;
65
- }
66
-
67
- userSelectedDate() {
68
- let selectedDate = this.getSelectedDate();
69
- this.onSelection?.(selectedDate);
70
- }
71
-
72
- onPikadayOpen() {
73
- this.onOpen();
74
- }
75
-
76
- onPikadayClose() {
77
- if (this.isDestroyed || this.isDestroying) {
78
- return;
79
- }
80
-
81
- if (this.pikaday.getDate() === null || isEmpty(this.field.value)) {
82
- this.onSelection(null);
83
- }
84
-
85
- this.onClose();
86
- }
87
- }