@projectcaluma/ember-form 11.0.0-beta.30 → 11.0.0-beta.31

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,30 +1,12 @@
1
- {{#if @disabled}}
2
- <input
3
- class="uk-input uk-disabled"
4
- type="text"
5
- name={{@field.pk}}
6
- id={{@field.pk}}
7
- value={{format-date
8
- @field.answer.value
9
- day="2-digit"
10
- month="2-digit"
11
- year="numeric"
12
- }}
13
- readonly
14
- />
15
- {{else}}
16
- <input
17
- class="uk-input"
18
- type="text"
19
- name={{@field.pk}}
20
- id={{@field.pk}}
21
- {{pikaday
22
- firstDay=1
23
- toString=this.formatDate
24
- i18n=this.pikadayTranslations
25
- value=@field.answer.value
26
- onSelect=this.onChange
27
- parse=this.parseDate
28
- }}
29
- />
30
- {{/if}}
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,28 +1,19 @@
1
1
  import { action } from "@ember/object";
2
2
  import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
- import { DateTime, Info } from "luxon";
5
- import { cached } from "tracked-toolbox";
6
-
7
- // put the last element to the front of the array
8
- const shift = (array) => [...array.slice(-1), ...array.slice(0, -1)];
4
+ import { DateTime } from "luxon";
9
5
 
10
6
  export default class CfFieldInputDateComponent extends Component {
11
7
  @service intl;
12
8
 
13
- @action
14
- onChange(date) {
15
- // Change Javascript date to ISO string if not null.
16
- this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
9
+ get locale() {
10
+ return this.intl.primaryLocale.split("-")[0];
17
11
  }
18
12
 
19
13
  @action
20
- parseDate(value) {
21
- const date = DateTime.fromFormat(value, "D", {
22
- locale: this.intl.primaryLocale,
23
- });
24
-
25
- return date.isValid ? date.toJSDate() : null;
14
+ onChange([date]) {
15
+ // Change Javascript date to ISO string if not null.
16
+ this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
26
17
  }
27
18
 
28
19
  @action
@@ -33,17 +24,4 @@ export default class CfFieldInputDateComponent extends Component {
33
24
  year: "numeric",
34
25
  });
35
26
  }
36
-
37
- @cached
38
- get pikadayTranslations() {
39
- const locale = this.intl.primaryLocale;
40
-
41
- return {
42
- previousMonth: this.intl.t("caluma.form.pikaday.month-previous"),
43
- nextMonth: this.intl.t("caluma.form.pikaday.month-next"),
44
- months: Info.months("long", { locale }),
45
- weekdays: shift(Info.weekdays("long", { locale })),
46
- weekdaysShort: shift(Info.weekdays("short", { locale })),
47
- };
48
- }
49
27
  }
@@ -770,7 +770,7 @@ export default class Field extends Base {
770
770
  async _validateDynamicChoiceQuestion() {
771
771
  await this.question.dynamicOptions;
772
772
 
773
- return this._validateOption(this.answer.value);
773
+ return this._validateOption(this.answer.value, true);
774
774
  }
775
775
 
776
776
  /**
@@ -790,7 +790,9 @@ export default class Field extends Base {
790
790
 
791
791
  await this.question.dynamicOptions;
792
792
 
793
- return value.map((value) => this._validateOption(value));
793
+ return this.answer.value
794
+ ? value.map((value) => this._validateOption(value))
795
+ : true;
794
796
  }
795
797
 
796
798
  _validateOption(value, allowBlank = false) {
@@ -3,6 +3,8 @@
3
3
  @import "../cf-field";
4
4
  @import "../cf-navigation";
5
5
 
6
+ @import "../flatpickr";
7
+
6
8
  @import "../uikit-overwrites";
7
9
 
8
10
  .table-controls > .uk-icon {
@@ -0,0 +1,47 @@
1
+ $flatpickr-today-color: $global-warning-background;
2
+ $flatpickr-selected-color: $global-primary-background;
3
+
4
+ span.flatpickr-day {
5
+ font-weight: $base-body-font-weight;
6
+
7
+ &.today:not(.selected) {
8
+ border-bottom-color: $flatpickr-today-color;
9
+
10
+ &:hover {
11
+ background: $flatpickr-today-color;
12
+ border-color: $flatpickr-today-color;
13
+ }
14
+ }
15
+
16
+ &.selected {
17
+ background: $flatpickr-selected-color;
18
+ border-color: $flatpickr-selected-color;
19
+ font-weight: 700;
20
+
21
+ &:hover {
22
+ background: darken($flatpickr-selected-color, 10%);
23
+ border-color: darken($flatpickr-selected-color, 10%);
24
+ }
25
+ }
26
+ }
27
+
28
+ .flatpickr-months {
29
+ .flatpickr-prev-month:hover,
30
+ .flatpickr-next-month:hover {
31
+ color: $flatpickr-today-color;
32
+ }
33
+ }
34
+
35
+ span.flatpickr-weekday {
36
+ font-size: $global-small-font-size;
37
+ font-weight: $base-body-font-weight;
38
+ }
39
+
40
+ .flatpickr-current-month {
41
+ font-size: $global-font-size;
42
+ font-weight: $base-body-font-weight;
43
+
44
+ .flatpickr-monthDropdown-months {
45
+ font-weight: $base-body-font-weight;
46
+ }
47
+ }
@@ -10,7 +10,7 @@ module.exports = {
10
10
  { name: "ember-cli-showdown" },
11
11
  { name: "ember-composable-helpers" },
12
12
  { name: "ember-math-helpers" },
13
- { name: "ember-pikaday" },
13
+ { name: "ember-flatpickr" },
14
14
  { name: "ember-power-select" },
15
15
  { name: "ember-autoresize-modifier" },
16
16
  ],
package/index.js CHANGED
@@ -2,4 +2,16 @@
2
2
 
3
3
  module.exports = {
4
4
  name: require("./package").name,
5
+
6
+ included(...args) {
7
+ const app = this._findHost(this);
8
+
9
+ app.options.flatpickr = {
10
+ locales: ["de", "fr"],
11
+ theme: "airbnb",
12
+ ...(app.options.flatpickr ?? {}),
13
+ };
14
+
15
+ this._super.included.apply(this, args);
16
+ },
5
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "11.0.0-beta.30",
3
+ "version": "11.0.0-beta.31",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -9,7 +9,7 @@
9
9
  "homepage": "https://docs.caluma.io/ember-caluma",
10
10
  "repository": "github:projectcaluma/ember-caluma",
11
11
  "scripts": {
12
- "test": "npm-run-all test:*",
12
+ "test": "npm-run-all --print-name \"lint\" \"test:*\"",
13
13
  "test:ember": "ember test",
14
14
  "test:ember-compatibility": "ember try:each"
15
15
  },
@@ -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-beta.30",
22
+ "@projectcaluma/ember-core": "^11.0.0-beta.31",
23
23
  "ember-apollo-client": "~4.0.2",
24
24
  "ember-auto-import": "^2.4.3",
25
25
  "ember-autoresize-modifier": "^0.6.0",
@@ -29,10 +29,10 @@
29
29
  "ember-composable-helpers": "^5.0.0",
30
30
  "ember-concurrency": "^2.3.7",
31
31
  "ember-fetch": "^8.1.2",
32
+ "ember-flatpickr": "^3.2.3",
32
33
  "ember-in-viewport": "^4.0.2",
33
34
  "ember-intl": "^5.7.2",
34
35
  "ember-math-helpers": "^2.18.2",
35
- "ember-pikaday": "^4.0.0",
36
36
  "ember-power-select": "^6.0.1",
37
37
  "ember-resources": "^5.4.0",
38
38
  "ember-uikit": "^6.1.0",
@@ -48,10 +48,10 @@
48
48
  "@ember/test-helpers": "2.7.0",
49
49
  "@embroider/test-setup": "1.8.3",
50
50
  "@faker-js/faker": "7.6.0",
51
- "@projectcaluma/ember-testing": "11.0.0-beta.30",
52
- "@projectcaluma/ember-workflow": "^11.0.0-beta.30",
51
+ "@projectcaluma/ember-testing": "11.0.0-beta.31",
52
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.31",
53
53
  "broccoli-asset-rev": "3.0.0",
54
- "ember-cli": "4.7.0",
54
+ "ember-cli": "4.8.0",
55
55
  "ember-cli-code-coverage": "1.0.3",
56
56
  "ember-cli-dependency-checker": "3.3.1",
57
57
  "ember-cli-inject-live-reload": "2.1.0",
@@ -74,7 +74,7 @@
74
74
  "webpack": "5.74.0"
75
75
  },
76
76
  "peerDependencies": {
77
- "@projectcaluma/ember-workflow": "^11.0.0-beta.30"
77
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.31"
78
78
  },
79
79
  "peerDependenciesMeta": {
80
80
  "@projectcaluma/ember-workflow": {
@@ -82,7 +82,7 @@
82
82
  }
83
83
  },
84
84
  "engines": {
85
- "node": "14.* || >= 16"
85
+ "node": "14.* || 16.* || >= 18"
86
86
  },
87
87
  "ember": {
88
88
  "edition": "octane"
@@ -51,7 +51,3 @@ caluma:
51
51
  uploadFailed: "Beim Hochladen ist ein Fehler aufgetreten."
52
52
  format: "{errorMsg}"
53
53
  table: "Mindestens eine Zeile der Tabelle wurde nicht korrekt ausgefüllt"
54
-
55
- pikaday:
56
- month-previous: "Vorheriger Monat"
57
- month-next: "Nächster Monat"
@@ -51,7 +51,3 @@ caluma:
51
51
  uploadFailed: "An error occured during upload."
52
52
  format: "{errorMsg}"
53
53
  table: "At least one row of the table was not filled in correctly"
54
-
55
- pikaday:
56
- month-previous: "Previous month"
57
- month-next: "Next month"
@@ -51,7 +51,3 @@ caluma:
51
51
  uploadFailed: "Une erreur s'est produite pendant le téléchargement."
52
52
  format: "{errorMsg}"
53
53
  table: "Au moins une ligne du tableau n'a pas été remplie correctement"
54
-
55
- pikaday:
56
- month-previous: "Mois précédent"
57
- month-next: "Mois suivant"