@projectcaluma/ember-form 11.0.0-beta.30 → 11.0.0-beta.32
Sign up to get free protection for your applications and to get access to all the features.
- package/addon/components/cf-field/input/date.hbs +12 -30
- package/addon/components/cf-field/input/date.js +6 -28
- package/addon/lib/field.js +4 -2
- package/app/styles/@projectcaluma/ember-form.scss +2 -0
- package/app/styles/_flatpickr.scss +47 -0
- package/blueprints/@projectcaluma/ember-form/index.js +1 -1
- package/index.js +12 -0
- package/package.json +9 -9
- package/translations/de.yaml +0 -4
- package/translations/en.yaml +0 -4
- package/translations/fr.yaml +0 -4
@@ -1,30 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
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
|
-
|
14
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
}
|
package/addon/lib/field.js
CHANGED
@@ -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
|
793
|
+
return this.answer.value
|
794
|
+
? value.map((value) => this._validateOption(value))
|
795
|
+
: true;
|
794
796
|
}
|
795
797
|
|
796
798
|
_validateOption(value, allowBlank = false) {
|
@@ -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-
|
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.
|
3
|
+
"version": "11.0.0-beta.32",
|
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.
|
22
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.32",
|
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.
|
52
|
-
"@projectcaluma/ember-workflow": "^11.0.0-beta.
|
51
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.32",
|
52
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.32",
|
53
53
|
"broccoli-asset-rev": "3.0.0",
|
54
|
-
"ember-cli": "4.
|
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.
|
77
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.32"
|
78
78
|
},
|
79
79
|
"peerDependenciesMeta": {
|
80
80
|
"@projectcaluma/ember-workflow": {
|
@@ -82,7 +82,7 @@
|
|
82
82
|
}
|
83
83
|
},
|
84
84
|
"engines": {
|
85
|
-
"node": "14.* || >=
|
85
|
+
"node": "14.* || 16.* || >= 18"
|
86
86
|
},
|
87
87
|
"ember": {
|
88
88
|
"edition": "octane"
|
package/translations/de.yaml
CHANGED
package/translations/en.yaml
CHANGED
package/translations/fr.yaml
CHANGED