@projectcaluma/ember-form 11.0.0 → 11.0.2

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.
@@ -1,12 +1,25 @@
1
- <EmberFlatpickr
2
- id={{@field.pk}}
3
- name={{@field.pk}}
4
- class="uk-input {{if @disabled 'uk-disabled'}}"
5
- readonly={{@disabled}}
6
- @disabled={{@disabled}}
7
- @locale={{this.locale}}
8
- @date={{or @field.answer.value null}}
9
- @formatDate={{this.formatDate}}
10
- @allowInput={{true}}
11
- @onChange={{this.onChange}}
12
- />
1
+ <div class="uk-inline uk-width-1-1">
2
+ <a
3
+ class="uk-form-icon uk-form-icon-flip"
4
+ uk-tooltip={{t "caluma.form.delete"}}
5
+ href="#"
6
+ {{on "click" this.clearCalendar}}
7
+ >
8
+ <UkIcon @icon="close" />
9
+ </a>
10
+ <EmberFlatpickr
11
+ id={{@field.pk}}
12
+ name={{@field.pk}}
13
+ class="uk-input {{if @disabled 'uk-disabled'}}"
14
+ readonly={{@disabled}}
15
+ @disabled={{@disabled}}
16
+ @locale={{this.locale}}
17
+ @date={{or @field.answer.value null}}
18
+ @altFormat={{this.dateFormat}}
19
+ @altInput={{true}}
20
+ @allowInput={{true}}
21
+ @onChange={{this.onChange}}
22
+ @onReady={{this.onReady}}
23
+ @onClose={{this.onClose}}
24
+ />
25
+ </div>
@@ -1,27 +1,56 @@
1
+ import { getOwner } from "@ember/application";
1
2
  import { action } from "@ember/object";
2
3
  import { inject as service } from "@ember/service";
3
4
  import Component from "@glimmer/component";
5
+ import { tracked } from "@glimmer/tracking";
4
6
  import { DateTime } from "luxon";
5
7
 
6
8
  export default class CfFieldInputDateComponent extends Component {
7
9
  @service intl;
8
10
 
11
+ @tracked flatpickrRef = null;
12
+
9
13
  get locale() {
10
14
  return this.intl.primaryLocale.split("-")[0];
11
15
  }
12
16
 
17
+ get config() {
18
+ return getOwner(this).resolveRegistration("config:environment");
19
+ }
20
+
21
+ get dateFormat() {
22
+ const {
23
+ FLATPICKR_DATE_FORMAT = {
24
+ de: "d.m.Y",
25
+ fr: "d.m.Y",
26
+ en: "m/d/Y",
27
+ },
28
+ FLATPICKR_DATE_FORMAT_DEFAULT = "m/d/Y",
29
+ } = this.config["ember-caluma"] || {};
30
+
31
+ return FLATPICKR_DATE_FORMAT[this.locale] ?? FLATPICKR_DATE_FORMAT_DEFAULT;
32
+ }
33
+
34
+ @action
35
+ onReady(_selectedDates, _dateStr, flatpickrRef) {
36
+ this.flatpickrRef = flatpickrRef;
37
+ }
38
+
39
+ @action
40
+ clearCalendar(e) {
41
+ e.stopPropagation();
42
+ this.flatpickrRef.clear();
43
+ }
44
+
13
45
  @action
14
46
  onChange([date]) {
15
47
  // Change Javascript date to ISO string if not null.
16
48
  this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
17
49
  }
18
50
 
51
+ // flatpickr doesnt call onChange after manual input and clicking outside.
19
52
  @action
20
- formatDate(date) {
21
- return this.intl.formatDate(date, {
22
- day: "2-digit",
23
- month: "2-digit",
24
- year: "numeric",
25
- });
53
+ onClose(dates) {
54
+ this.onChange(dates);
26
55
  }
27
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "11.0.0",
3
+ "version": "11.0.2",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -16,10 +16,10 @@
16
16
  "dependencies": {
17
17
  "@ember/string": "^3.0.1",
18
18
  "@embroider/macros": "^1.10.0",
19
- "@embroider/util": "^1.9.0",
19
+ "@embroider/util": "^1.10.0",
20
20
  "@glimmer/component": "^1.1.2",
21
21
  "@glimmer/tracking": "^1.1.2",
22
- "@projectcaluma/ember-core": "^11.0.0",
22
+ "@projectcaluma/ember-core": "^11.0.2",
23
23
  "ember-apollo-client": "~4.0.2",
24
24
  "ember-auto-import": "^2.6.0",
25
25
  "ember-autoresize-modifier": "^0.7.0",
@@ -48,8 +48,8 @@
48
48
  "@ember/test-helpers": "2.7.0",
49
49
  "@embroider/test-setup": "2.1.1",
50
50
  "@faker-js/faker": "7.6.0",
51
- "@projectcaluma/ember-testing": "11.0.0",
52
- "@projectcaluma/ember-workflow": "^11.0.0",
51
+ "@projectcaluma/ember-testing": "11.0.2",
52
+ "@projectcaluma/ember-workflow": "^11.0.2",
53
53
  "broccoli-asset-rev": "3.0.0",
54
54
  "concurrently": "7.6.0",
55
55
  "ember-cli": "4.9.2",
@@ -73,7 +73,7 @@
73
73
  "webpack": "5.75.0"
74
74
  },
75
75
  "peerDependencies": {
76
- "@projectcaluma/ember-workflow": "^11.0.0",
76
+ "@projectcaluma/ember-workflow": "^11.0.2",
77
77
  "ember-source": "^3.28.0 || ^4.0.0"
78
78
  },
79
79
  "peerDependenciesMeta": {