@koumoul/vjsf 3.0.0-beta.16 → 3.0.0-beta.17
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/package.json +1 -1
- package/src/compat/v2.js +21 -2
package/package.json
CHANGED
package/src/compat/v2.js
CHANGED
|
@@ -6,6 +6,25 @@ import { isPartialGetItemsObj } from '@json-layout/vocabulary'
|
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const Ajv = /** @type {typeof ajvModule.default} */ (ajvModule)
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {string} expression
|
|
12
|
+
* @returns {{expr: string, pure: boolean}}
|
|
13
|
+
*/
|
|
14
|
+
const fiexEvalExpression = (expression) => {
|
|
15
|
+
let expr = expression
|
|
16
|
+
let pure = true
|
|
17
|
+
if (expr.includes('rootData')) {
|
|
18
|
+
pure = false
|
|
19
|
+
}
|
|
20
|
+
if (expr.includes('parent.value')) {
|
|
21
|
+
pure = false
|
|
22
|
+
expr = expr.replace(/parent\.value/g, 'parentData')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return { type: 'js-eval', expr, pure }
|
|
26
|
+
}
|
|
27
|
+
|
|
9
28
|
const processFragment = (/** @type {import("ajv").SchemaObject} */schema) => {
|
|
10
29
|
if (!schema.layout) {
|
|
11
30
|
/** @type import('@json-layout/vocabulary').PartialCompObject */
|
|
@@ -39,12 +58,12 @@ const processFragment = (/** @type {import("ajv").SchemaObject} */schema) => {
|
|
|
39
58
|
|
|
40
59
|
if (schema['x-fromData']) {
|
|
41
60
|
layout.comp = 'select'
|
|
42
|
-
layout.getItems =
|
|
61
|
+
layout.getItems = fiexEvalExpression(schema['x-fromData'])
|
|
43
62
|
delete schema['x-fromData']
|
|
44
63
|
}
|
|
45
64
|
|
|
46
65
|
if (schema['x-if']) {
|
|
47
|
-
layout.if = schema['x-if']
|
|
66
|
+
layout.if = fiexEvalExpression(schema['x-if'])
|
|
48
67
|
delete schema['x-if']
|
|
49
68
|
}
|
|
50
69
|
|