@projectcaluma/ember-form 11.0.0 → 11.0.1

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,52 @@
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
+ FLATPICKR_DATE_FORMAT_DEFAULT = "m/d/Y",
25
+ } = this.config["ember-caluma"] || {};
26
+
27
+ return FLATPICKR_DATE_FORMAT[this.locale] ?? FLATPICKR_DATE_FORMAT_DEFAULT;
28
+ }
29
+
30
+ @action
31
+ onReady(_selectedDates, _dateStr, flatpickrRef) {
32
+ this.flatpickrRef = flatpickrRef;
33
+ }
34
+
35
+ @action
36
+ clearCalendar(e) {
37
+ e.stopPropagation();
38
+ this.flatpickrRef.clear();
39
+ }
40
+
13
41
  @action
14
42
  onChange([date]) {
15
43
  // Change Javascript date to ISO string if not null.
16
44
  this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
17
45
  }
18
46
 
47
+ // flatpickr doesnt call onChange after manual input and clicking outside.
19
48
  @action
20
- formatDate(date) {
21
- return this.intl.formatDate(date, {
22
- day: "2-digit",
23
- month: "2-digit",
24
- year: "numeric",
25
- });
49
+ onClose(dates) {
50
+ this.onChange(dates);
26
51
  }
27
52
  }
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.1",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -19,7 +19,7 @@
19
19
  "@embroider/util": "^1.9.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.1",
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.1",
52
+ "@projectcaluma/ember-workflow": "^11.0.1",
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.1",
77
77
  "ember-source": "^3.28.0 || ^4.0.0"
78
78
  },
79
79
  "peerDependenciesMeta": {