@projectcaluma/ember-form-builder 11.0.0-beta.30 → 11.0.0-beta.32
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.
- package/addon/components/cfb-code-editor.hbs +1 -0
- package/addon/components/cfb-code-editor.js +2 -1
- package/addon/validations/question.js +3 -0
- package/addon/validators/jexl.js +49 -0
- package/blueprints/@projectcaluma/ember-form-builder/index.js +1 -1
- package/package.json +8 -8
- package/addon/modifiers/pikaday.js +0 -2
|
@@ -7,6 +7,8 @@ import json from "highlight.js/lib/languages/json";
|
|
|
7
7
|
import markdown from "highlight.js/lib/languages/markdown";
|
|
8
8
|
import jexl from "highlightjs-jexl/src/languages/jexl";
|
|
9
9
|
|
|
10
|
+
hljs.configure({ ignoreUnescapedHTML: true });
|
|
11
|
+
|
|
10
12
|
hljs.registerLanguage("json", json);
|
|
11
13
|
hljs.registerLanguage("markdown", markdown);
|
|
12
14
|
hljs.registerLanguage("jexl", jexl);
|
|
@@ -42,7 +44,6 @@ export default class CfbCodeEditorComponent extends Component {
|
|
|
42
44
|
|
|
43
45
|
this._lastValue = value;
|
|
44
46
|
this.args.update(value);
|
|
45
|
-
this.args.setDirty();
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
@action
|
|
@@ -9,6 +9,7 @@ import validateOptions from "../validators/options";
|
|
|
9
9
|
|
|
10
10
|
import and from "@projectcaluma/ember-form-builder/utils/and";
|
|
11
11
|
import or from "@projectcaluma/ember-form-builder/utils/or";
|
|
12
|
+
import validateJexl from "@projectcaluma/ember-form-builder/validators/jexl";
|
|
12
13
|
import validateSlug from "@projectcaluma/ember-form-builder/validators/slug";
|
|
13
14
|
import validateType from "@projectcaluma/ember-form-builder/validators/type";
|
|
14
15
|
|
|
@@ -82,4 +83,6 @@ export default {
|
|
|
82
83
|
validateType("FormQuestion", false),
|
|
83
84
|
validatePresence(true)
|
|
84
85
|
),
|
|
86
|
+
isHidden: validateJexl(),
|
|
87
|
+
isRequired: validateJexl(),
|
|
85
88
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import jexl from "jexl";
|
|
2
|
+
|
|
3
|
+
const TRANSFORMS = [
|
|
4
|
+
"answer",
|
|
5
|
+
"mapby",
|
|
6
|
+
"debug",
|
|
7
|
+
"min",
|
|
8
|
+
"max",
|
|
9
|
+
"round",
|
|
10
|
+
"ceil",
|
|
11
|
+
"floor",
|
|
12
|
+
"sum",
|
|
13
|
+
"avg",
|
|
14
|
+
"stringify",
|
|
15
|
+
];
|
|
16
|
+
const BINARY_OPS = ["intersects"];
|
|
17
|
+
|
|
18
|
+
const documentJexl = new jexl.Jexl();
|
|
19
|
+
|
|
20
|
+
const noop = () => {};
|
|
21
|
+
|
|
22
|
+
TRANSFORMS.forEach((transform) => documentJexl.addTransform(transform, noop));
|
|
23
|
+
BINARY_OPS.forEach((binaryOp) => documentJexl.addBinaryOp(binaryOp, 0, noop));
|
|
24
|
+
|
|
25
|
+
function parseError(error) {
|
|
26
|
+
const str = String(error)
|
|
27
|
+
.replace(/^Error:/, "") // Remove "Error:" prefix
|
|
28
|
+
.replace(/(of expression):.*$/, (_, match) => match) // Remove everything after "of expression"
|
|
29
|
+
.replace(/in expression:.*$/, "") // Remove "in expression: [expression]"
|
|
30
|
+
.replace(/\.$/g, "") // Remove trailing dot
|
|
31
|
+
.replace(/\s\s+/g, " ") // Remove double whitespace chars
|
|
32
|
+
.trim();
|
|
33
|
+
|
|
34
|
+
return str;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default function validateJexl() {
|
|
38
|
+
return (key, newValue) => {
|
|
39
|
+
try {
|
|
40
|
+
if (newValue) {
|
|
41
|
+
documentJexl.evalSync(newValue);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return true;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return parseError(error);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.32",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"homepage": "https://docs.caluma.io/ember-caluma",
|
|
11
11
|
"repository": "github:projectcaluma/ember-caluma",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "npm-run-all test
|
|
13
|
+
"test": "npm-run-all --print-name \"lint\" \"test:*\"",
|
|
14
14
|
"test:ember": "ember test",
|
|
15
15
|
"test:ember-compatibility": "ember try:each"
|
|
16
16
|
},
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@embroider/macros": "^1.9.0",
|
|
25
25
|
"@glimmer/component": "^1.1.2",
|
|
26
26
|
"@glimmer/tracking": "^1.1.2",
|
|
27
|
-
"@projectcaluma/ember-core": "^11.0.0-beta.
|
|
28
|
-
"@projectcaluma/ember-form": "^11.0.0-beta.
|
|
27
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.32",
|
|
28
|
+
"@projectcaluma/ember-form": "^11.0.0-beta.32",
|
|
29
29
|
"codejar": "^3.6.0",
|
|
30
30
|
"ember-apollo-client": "~4.0.2",
|
|
31
31
|
"ember-auto-import": "^2.4.3",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"ember-concurrency": "^2.3.7",
|
|
38
38
|
"ember-engines-router-service": "^0.3.0",
|
|
39
39
|
"ember-fetch": "^8.1.2",
|
|
40
|
+
"ember-flatpickr": "^3.2.3",
|
|
40
41
|
"ember-intl": "^5.7.2",
|
|
41
42
|
"ember-math-helpers": "^2.18.2",
|
|
42
|
-
"ember-pikaday": "^4.0.0",
|
|
43
43
|
"ember-power-select": "^6.0.1",
|
|
44
44
|
"ember-resources": "^5.4.0",
|
|
45
45
|
"ember-test-selectors": "^6.0.0",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"@ember/test-helpers": "2.7.0",
|
|
63
63
|
"@embroider/test-setup": "1.8.3",
|
|
64
64
|
"@faker-js/faker": "7.6.0",
|
|
65
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
|
65
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.32",
|
|
66
66
|
"broccoli-asset-rev": "3.0.0",
|
|
67
67
|
"ember-autoresize-modifier": "^0.6.0",
|
|
68
|
-
"ember-cli": "4.
|
|
68
|
+
"ember-cli": "4.8.0",
|
|
69
69
|
"ember-cli-code-coverage": "1.0.3",
|
|
70
70
|
"ember-cli-dependency-checker": "3.3.1",
|
|
71
71
|
"ember-cli-inject-live-reload": "2.1.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"webpack": "5.74.0"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
|
-
"node": "14.* || >=
|
|
92
|
+
"node": "14.* || 16.* || >= 18"
|
|
93
93
|
},
|
|
94
94
|
"ember": {
|
|
95
95
|
"edition": "octane"
|