@json-layout/core 0.18.0 → 0.19.0
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 +3 -4
- package/src/compile/index.js +2 -2
- package/src/compile/serialize.js +6 -4
- package/src/compile/skeleton-node.js +93 -7
- package/src/compile/types.ts +3 -1
- package/src/state/index.js +1 -2
- package/src/state/state-node.js +15 -9
- package/types/compile/serialize.d.ts.map +1 -1
- package/types/compile/skeleton-node.d.ts +4 -1
- package/types/compile/skeleton-node.d.ts.map +1 -1
- package/types/compile/types.d.ts +3 -2
- package/types/compile/types.d.ts.map +1 -1
- package/types/state/index.d.ts +1 -2
- package/types/state/index.d.ts.map +1 -1
- package/types/state/state-node.d.ts +2 -1
- package/types/state/state-node.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-layout/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Compilation and state management utilities for JSON Layout.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://github.com/json-layout/json-layout#readme",
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@json-layout/vocabulary": "^0.
|
|
62
|
+
"@json-layout/vocabulary": "^0.18.0",
|
|
63
63
|
"@types/markdown-it": "^13.0.1",
|
|
64
64
|
"ajv": "^8.12.0",
|
|
65
65
|
"ajv-errors": "^3.0.0",
|
|
@@ -69,8 +69,7 @@
|
|
|
69
69
|
"immer": "^10.0.3",
|
|
70
70
|
"magicast": "^0.3.3",
|
|
71
71
|
"markdown-it": "^13.0.2",
|
|
72
|
-
"mitt": "^3.0.1"
|
|
73
|
-
"recast": "^0.23.4"
|
|
72
|
+
"mitt": "^3.0.1"
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
75
|
"@types/debug": "^4.1.7",
|
package/src/compile/index.js
CHANGED
|
@@ -142,8 +142,8 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
142
142
|
|
|
143
143
|
for (const expression of expressionsDefinitions) {
|
|
144
144
|
const expressionsParams = expression.pure
|
|
145
|
-
? ['data', 'options', 'context', 'display', 'layout']
|
|
146
|
-
: ['data', 'options', 'context', 'display', 'layout', 'rootData', 'parent']
|
|
145
|
+
? ['data', 'options', 'context', 'display', 'layout', 'validates']
|
|
146
|
+
: ['data', 'options', 'context', 'display', 'layout', 'validates', 'rootData', 'parent']
|
|
147
147
|
/* if (expression.type === 'expr-eval') {
|
|
148
148
|
expressions.push(exprEvalParser.parse(expression.expr).toJSFunction(expressionsParams.join(',')))
|
|
149
149
|
} */
|
package/src/compile/serialize.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { ok } from 'assert/strict'
|
|
3
3
|
import standaloneCode from 'ajv/dist/standalone/index.js'
|
|
4
4
|
import { parseModule, generateCode, builders } from 'magicast'
|
|
5
|
-
import { parse, print } from 'recast'
|
|
6
5
|
import clone from '../utils/clone.js'
|
|
7
6
|
import { isSwitchStruct } from '@json-layout/vocabulary'
|
|
8
7
|
|
|
@@ -59,10 +58,13 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
59
58
|
i = 0
|
|
60
59
|
const expressionsNodes = []
|
|
61
60
|
for (const expression of compiledLayout.expressions) {
|
|
61
|
+
const id = `expression${i++}`
|
|
62
|
+
code += expression.toString().replace('function anonymous', `function ${id}`)
|
|
63
|
+
/* Previous code based on recast/esprima, suffered syntax limitations
|
|
62
64
|
const fn = parse(expression.toString()).program.body[0]
|
|
63
|
-
fn.id =
|
|
64
|
-
code += `\n${print(fn)}\n`
|
|
65
|
-
expressionsNodes.push(builders.raw(
|
|
65
|
+
fn.id = id
|
|
66
|
+
code += `\n${print(fn)}\n` */
|
|
67
|
+
expressionsNodes.push(builders.raw(id))
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/** @type {Record<string, Omit<import('@json-layout/vocabulary').ComponentInfo, 'schema'>>} */
|
|
@@ -13,6 +13,9 @@ import { makeSkeletonTree } from './skeleton-tree.js'
|
|
|
13
13
|
* @param {string} pointer
|
|
14
14
|
* @param {string | null} parentPointer
|
|
15
15
|
* @param {boolean} required
|
|
16
|
+
* @param {string} [condition]
|
|
17
|
+
* @param {boolean} [dependent]
|
|
18
|
+
* @param {string} [knownType]
|
|
16
19
|
* @returns {import('./types.js').SkeletonNode}
|
|
17
20
|
*/
|
|
18
21
|
export function makeSkeletonNode (
|
|
@@ -25,9 +28,12 @@ export function makeSkeletonNode (
|
|
|
25
28
|
key,
|
|
26
29
|
pointer,
|
|
27
30
|
parentPointer,
|
|
28
|
-
required
|
|
31
|
+
required,
|
|
32
|
+
condition,
|
|
33
|
+
dependent,
|
|
34
|
+
knownType
|
|
29
35
|
) {
|
|
30
|
-
const { type, nullable } = getSchemaFragmentType(schema)
|
|
36
|
+
const { type, nullable } = knownType ? { type: knownType, nullable: false } : getSchemaFragmentType(schema)
|
|
31
37
|
|
|
32
38
|
// improve on ajv error messages based on ajv-errors (https://ajv.js.org/packages/ajv-errors.html)
|
|
33
39
|
schema.errorMessage = schema.errorMessage ?? {}
|
|
@@ -37,7 +43,10 @@ export function makeSkeletonNode (
|
|
|
37
43
|
pointer,
|
|
38
44
|
options.components,
|
|
39
45
|
options.markdown,
|
|
40
|
-
options.optionsKeys
|
|
46
|
+
options.optionsKeys,
|
|
47
|
+
undefined,
|
|
48
|
+
type,
|
|
49
|
+
nullable
|
|
41
50
|
)
|
|
42
51
|
normalizedLayouts[pointer] = normalizationResult.layout
|
|
43
52
|
if (normalizationResult.errors.length) {
|
|
@@ -54,7 +63,7 @@ export function makeSkeletonNode (
|
|
|
54
63
|
else if (type === 'array') defaultData = []
|
|
55
64
|
}
|
|
56
65
|
|
|
57
|
-
let pure =
|
|
66
|
+
let pure = !dependent
|
|
58
67
|
/**
|
|
59
68
|
* @param {import('@json-layout/vocabulary').Expression[]} expressions
|
|
60
69
|
* @param {import('@json-layout/vocabulary').Expression} expression
|
|
@@ -104,12 +113,20 @@ export function makeSkeletonNode (
|
|
|
104
113
|
|
|
105
114
|
/** @type {import('./types.js').SkeletonNode} */
|
|
106
115
|
const node = { key: key ?? '', pointer, parentPointer, pure, propertyKeys: [], roPropertyKeys: [] }
|
|
116
|
+
|
|
117
|
+
if (condition) {
|
|
118
|
+
if (isSwitchStruct(normalizedLayout)) throw new Error('Switch struct not allowed in conditional schema')
|
|
119
|
+
node.condition = { type: 'js-eval', expr: condition, pure: true }
|
|
120
|
+
pushExpression(expressions, node.condition)
|
|
121
|
+
}
|
|
122
|
+
|
|
107
123
|
if (type === 'object') {
|
|
108
124
|
if (schema.properties) {
|
|
109
125
|
node.children = node.children ?? []
|
|
110
126
|
for (const propertyKey of Object.keys(schema.properties)) {
|
|
111
127
|
node.propertyKeys.push(propertyKey)
|
|
112
128
|
if (schema.properties[propertyKey].readOnly) node.roPropertyKeys.push(propertyKey)
|
|
129
|
+
const dependent = schema.dependentRequired && Object.values(schema.dependentRequired).some(dependentProperties => dependentProperties.includes(propertyKey))
|
|
113
130
|
node.children.push(makeSkeletonNode(
|
|
114
131
|
schema.properties[propertyKey],
|
|
115
132
|
options,
|
|
@@ -120,12 +137,37 @@ export function makeSkeletonNode (
|
|
|
120
137
|
propertyKey,
|
|
121
138
|
`${pointer}/properties/${propertyKey}`,
|
|
122
139
|
pointer,
|
|
123
|
-
schema.required?.includes(propertyKey)
|
|
140
|
+
schema.required?.includes(propertyKey),
|
|
141
|
+
undefined,
|
|
142
|
+
dependent
|
|
124
143
|
))
|
|
125
144
|
if (schema?.required?.includes(propertyKey)) {
|
|
126
145
|
schema.errorMessage.required = schema.errorMessage.required ?? {}
|
|
127
146
|
schema.errorMessage.required[propertyKey] = options.messages.errorRequired
|
|
128
147
|
}
|
|
148
|
+
if (schema.dependentRequired && Object.keys(schema.dependentRequired).includes(propertyKey)) {
|
|
149
|
+
schema.errorMessage.dependentRequired = options.messages.errorRequired
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (schema.dependentSchemas?.[propertyKey] || (schema.dependencies?.[propertyKey] && !Array.isArray(schema.dependencies[propertyKey]))) {
|
|
153
|
+
const dependentSchema = schema.dependentSchemas?.[propertyKey] ?? schema.dependencies[propertyKey]
|
|
154
|
+
const dependentPointer = schema.dependentSchemas?.[propertyKey] ? `${pointer}/dependentSchemas/${propertyKey}` : `${pointer}/dependencies/${propertyKey}`
|
|
155
|
+
node.children.push(makeSkeletonNode(
|
|
156
|
+
dependentSchema,
|
|
157
|
+
options,
|
|
158
|
+
validates,
|
|
159
|
+
validationErrors,
|
|
160
|
+
normalizedLayouts,
|
|
161
|
+
expressions,
|
|
162
|
+
`$deps-${propertyKey}`,
|
|
163
|
+
dependentPointer,
|
|
164
|
+
pointer,
|
|
165
|
+
false,
|
|
166
|
+
`"${propertyKey}" in data`,
|
|
167
|
+
undefined,
|
|
168
|
+
'object'
|
|
169
|
+
))
|
|
170
|
+
}
|
|
129
171
|
}
|
|
130
172
|
}
|
|
131
173
|
if (schema.allOf) {
|
|
@@ -141,7 +183,10 @@ export function makeSkeletonNode (
|
|
|
141
183
|
`$allOf-${i}`,
|
|
142
184
|
`${pointer}/allOf/${i}`,
|
|
143
185
|
pointer,
|
|
144
|
-
false
|
|
186
|
+
false,
|
|
187
|
+
undefined,
|
|
188
|
+
undefined,
|
|
189
|
+
'object'
|
|
145
190
|
)
|
|
146
191
|
node.propertyKeys = node.propertyKeys.concat(allOfNode.propertyKeys)
|
|
147
192
|
node.roPropertyKeys = node.roPropertyKeys.concat(allOfNode.roPropertyKeys)
|
|
@@ -157,7 +202,9 @@ export function makeSkeletonNode (
|
|
|
157
202
|
options.components,
|
|
158
203
|
options.markdown,
|
|
159
204
|
options.optionsKeys,
|
|
160
|
-
'oneOf'
|
|
205
|
+
'oneOf',
|
|
206
|
+
type,
|
|
207
|
+
nullable
|
|
161
208
|
)
|
|
162
209
|
normalizedLayouts[oneOfPointer] = normalizationResult.layout
|
|
163
210
|
if (normalizationResult.errors.length) {
|
|
@@ -195,6 +242,45 @@ export function makeSkeletonNode (
|
|
|
195
242
|
|
|
196
243
|
schema.errorMessage.oneOf = options.messages.errorOneOf
|
|
197
244
|
}
|
|
245
|
+
if (schema.if) {
|
|
246
|
+
validates.push(`${pointer}/if`)
|
|
247
|
+
if (schema.then) {
|
|
248
|
+
node.children = node.children ?? []
|
|
249
|
+
node.children.push(makeSkeletonNode(
|
|
250
|
+
schema.then,
|
|
251
|
+
options,
|
|
252
|
+
validates,
|
|
253
|
+
validationErrors,
|
|
254
|
+
normalizedLayouts,
|
|
255
|
+
expressions,
|
|
256
|
+
'$then',
|
|
257
|
+
`${pointer}/then`,
|
|
258
|
+
pointer,
|
|
259
|
+
false,
|
|
260
|
+
`validates["${pointer}/if"](data)`,
|
|
261
|
+
undefined,
|
|
262
|
+
'object'
|
|
263
|
+
))
|
|
264
|
+
}
|
|
265
|
+
if (schema.else) {
|
|
266
|
+
node.children = node.children ?? []
|
|
267
|
+
node.children.push(makeSkeletonNode(
|
|
268
|
+
schema.else,
|
|
269
|
+
options,
|
|
270
|
+
validates,
|
|
271
|
+
validationErrors,
|
|
272
|
+
normalizedLayouts,
|
|
273
|
+
expressions,
|
|
274
|
+
'$else',
|
|
275
|
+
`${pointer}/else`,
|
|
276
|
+
pointer,
|
|
277
|
+
false,
|
|
278
|
+
`!validates["${pointer}/if"](data)`,
|
|
279
|
+
undefined,
|
|
280
|
+
'object'
|
|
281
|
+
))
|
|
282
|
+
}
|
|
283
|
+
}
|
|
198
284
|
}
|
|
199
285
|
|
|
200
286
|
if (type === 'array' && schema.items) {
|
package/src/compile/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ajvModule from 'ajv/dist/2019.js'
|
|
2
2
|
import type MarkdownIt from 'markdown-it'
|
|
3
|
-
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase } from '@json-layout/vocabulary'
|
|
3
|
+
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase, type Expression } from '@json-layout/vocabulary'
|
|
4
4
|
import { type ValidateFunction, type SchemaObject, type ErrorObject } from 'ajv/dist/2019.js'
|
|
5
5
|
import { type Display } from '../state/utils/display.js'
|
|
6
6
|
import { type LocaleMessages } from '../i18n/types.js'
|
|
@@ -16,6 +16,7 @@ export type CompiledExpression = (
|
|
|
16
16
|
context: object,
|
|
17
17
|
display: Display,
|
|
18
18
|
layout: BaseCompObject,
|
|
19
|
+
validates: Record<string, ValidateFunction>,
|
|
19
20
|
rootData?: unknown,
|
|
20
21
|
parent?: ParentContextExpression | null
|
|
21
22
|
) => any
|
|
@@ -67,6 +68,7 @@ export interface SkeletonNode {
|
|
|
67
68
|
pure: boolean
|
|
68
69
|
propertyKeys: string[]
|
|
69
70
|
roPropertyKeys: string[]
|
|
71
|
+
condition?: Expression
|
|
70
72
|
children?: SkeletonNode[] // optional children in the case of arrays and object nodes
|
|
71
73
|
childrenTrees?: SkeletonTree[] // other trees that can be instantiated with separate validation (for example in the case of new array items of oneOfs, etc)
|
|
72
74
|
}
|
package/src/state/index.js
CHANGED
|
@@ -371,14 +371,13 @@ export class StatefulLayout {
|
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
/**
|
|
374
|
-
* @private
|
|
375
374
|
* @param {StateNode} node
|
|
376
375
|
* @param {import('@json-layout/vocabulary').Expression} expression
|
|
377
376
|
* @param {any} data
|
|
378
377
|
* @returns {any}
|
|
379
378
|
*/
|
|
380
379
|
evalNodeExpression (node, expression, data) {
|
|
381
|
-
return evalExpression(this.compiledLayout.expressions, expression, data, node.options, new Display(node.width), node.layout, this._data, this.getParentContextExpression(node))
|
|
380
|
+
return evalExpression(this.compiledLayout.expressions, expression, data, node.options, new Display(node.width), node.layout, this.compiledLayout.validates, this._data, this.getParentContextExpression(node))
|
|
382
381
|
}
|
|
383
382
|
|
|
384
383
|
/**
|
package/src/state/state-node.js
CHANGED
|
@@ -170,16 +170,17 @@ const matchChildError = (error, skeleton, dataPath, parentDataPath) => {
|
|
|
170
170
|
* @param {import('./types.js').StateNodeOptions} options
|
|
171
171
|
* @param {import('./utils/display.js').Display} display
|
|
172
172
|
* @param {import('@json-layout/vocabulary').BaseCompObject} layout
|
|
173
|
+
* @param {Record<string, import('ajv').ValidateFunction>} validates
|
|
173
174
|
* @param {unknown} rootData
|
|
174
175
|
* @param {import('../compile/types.js').ParentContextExpression | null} parentContext
|
|
175
176
|
* @returns {any}
|
|
176
177
|
*/
|
|
177
|
-
export function evalExpression (expressions, expression, data, options, display, layout, rootData, parentContext) {
|
|
178
|
+
export function evalExpression (expressions, expression, data, options, display, layout, validates, rootData, parentContext) {
|
|
178
179
|
if (expression.ref === undefined) throw new Error('expression was not compiled : ' + JSON.stringify(expression))
|
|
179
180
|
const compiledExpression = expressions[expression.ref]
|
|
180
181
|
return expression.pure
|
|
181
|
-
? compiledExpression(data, options, options.context, display, layout)
|
|
182
|
-
: compiledExpression(data, options, options.context, display, layout, rootData, parentContext)
|
|
182
|
+
? compiledExpression(data, options, options.context, display, layout, validates)
|
|
183
|
+
: compiledExpression(data, options, options.context, display, layout, validates, rootData, parentContext)
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
/**
|
|
@@ -195,13 +196,13 @@ export function evalExpression (expressions, expression, data, options, display,
|
|
|
195
196
|
const getCompObject = (normalizedLayout, options, compiledLayout, display, data, rootData, parentContext) => {
|
|
196
197
|
if (isSwitchStruct(normalizedLayout)) {
|
|
197
198
|
for (const compObject of normalizedLayout.switch) {
|
|
198
|
-
if (!compObject.if || !!evalExpression(compiledLayout.expressions, compObject.if, data, options, display, compObject, rootData, parentContext)) {
|
|
199
|
+
if (!compObject.if || !!evalExpression(compiledLayout.expressions, compObject.if, data, options, display, compObject, compiledLayout.validates, rootData, parentContext)) {
|
|
199
200
|
return compObject
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
} else {
|
|
203
204
|
if (normalizedLayout.if) {
|
|
204
|
-
if (evalExpression(compiledLayout.expressions, normalizedLayout.if, data, options, display, normalizedLayout, rootData, parentContext)) {
|
|
205
|
+
if (evalExpression(compiledLayout.expressions, normalizedLayout.if, data, options, display, normalizedLayout, compiledLayout.validates, rootData, parentContext)) {
|
|
205
206
|
return normalizedLayout
|
|
206
207
|
}
|
|
207
208
|
} else {
|
|
@@ -269,7 +270,7 @@ export function createStateNode (
|
|
|
269
270
|
? produceNodeOptions(
|
|
270
271
|
reusedNode?.options ?? /** @type {import('./types.js').StateNodeOptions} */({}),
|
|
271
272
|
parentOptions,
|
|
272
|
-
evalExpression(compiledLayout.expressions, layout.getOptions, data, parentOptions, display, layout, context.rootData, parentContext)
|
|
273
|
+
evalExpression(compiledLayout.expressions, layout.getOptions, data, parentOptions, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
273
274
|
)
|
|
274
275
|
: parentOptions
|
|
275
276
|
|
|
@@ -292,6 +293,11 @@ export function createStateNode (
|
|
|
292
293
|
skeleton.roPropertyKeys?.includes(/** @type {string} */(childLayout.key))
|
|
293
294
|
) continue
|
|
294
295
|
const childSkeleton = skeleton.children?.find(c => c.key === childLayout.key) ?? skeleton
|
|
296
|
+
if (childSkeleton.condition) {
|
|
297
|
+
if (!evalExpression(compiledLayout.expressions, childSkeleton.condition, objectData, parentOptions, display, layout, compiledLayout.validates, context.rootData, parentContext)) {
|
|
298
|
+
continue
|
|
299
|
+
}
|
|
300
|
+
}
|
|
295
301
|
const isSameData = typeof childLayout.key === 'string' && childLayout.key.startsWith('$')
|
|
296
302
|
const childFullKey = `${fullKey}/${childLayout.key}`
|
|
297
303
|
if (focusChild) context.autofocusTarget = childFullKey
|
|
@@ -427,12 +433,12 @@ export function createStateNode (
|
|
|
427
433
|
|
|
428
434
|
if (layout.getConstData) {
|
|
429
435
|
if (!context.rehydrate) {
|
|
430
|
-
nodeData = evalExpression(compiledLayout.expressions, layout.getConstData, nodeData, options, display, layout, context.rootData, parentContext)
|
|
436
|
+
nodeData = evalExpression(compiledLayout.expressions, layout.getConstData, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
431
437
|
}
|
|
432
438
|
} else {
|
|
433
439
|
if (layout.getDefaultData && useDefaultData(nodeData, layout, options)) {
|
|
434
440
|
if (!context.rehydrate) {
|
|
435
|
-
nodeData = evalExpression(compiledLayout.expressions, layout.getDefaultData, nodeData, options, display, layout, context.rootData, parentContext)
|
|
441
|
+
nodeData = evalExpression(compiledLayout.expressions, layout.getDefaultData, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
436
442
|
}
|
|
437
443
|
} else {
|
|
438
444
|
if (isDataEmpty(nodeData)) {
|
|
@@ -452,7 +458,7 @@ export function createStateNode (
|
|
|
452
458
|
|
|
453
459
|
let props
|
|
454
460
|
if (layout.getProps) {
|
|
455
|
-
props = evalExpression(compiledLayout.expressions, layout.getProps, nodeData, options, display, layout, context.rootData, parentContext)
|
|
461
|
+
props = evalExpression(compiledLayout.expressions, layout.getProps, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
456
462
|
}
|
|
457
463
|
|
|
458
464
|
const autofocus = isFocusableLayout(layout, compiledLayout.components) && !options.readOnly && !options.summary && context.autofocusTarget === fullKey
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/compile/serialize.js"],"names":[],"mappings":"AAoBA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CAkFlB"}
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
* @param {string} pointer
|
|
10
10
|
* @param {string | null} parentPointer
|
|
11
11
|
* @param {boolean} required
|
|
12
|
+
* @param {string} [condition]
|
|
13
|
+
* @param {boolean} [dependent]
|
|
14
|
+
* @param {string} [knownType]
|
|
12
15
|
* @returns {import('./types.js').SkeletonNode}
|
|
13
16
|
*/
|
|
14
|
-
export function makeSkeletonNode(schema: any, options: import('./index.js').CompileOptions, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], key: string | number, pointer: string, parentPointer: string | null, required: boolean): import('./types.js').SkeletonNode;
|
|
17
|
+
export function makeSkeletonNode(schema: any, options: import('./index.js').CompileOptions, validates: string[], validationErrors: Record<string, string[]>, normalizedLayouts: Record<string, import('@json-layout/vocabulary').NormalizedLayout>, expressions: import('@json-layout/vocabulary').Expression[], key: string | number, pointer: string, parentPointer: string | null, required: boolean, condition?: string | undefined, dependent?: boolean | undefined, knownType?: string | undefined): import('./types.js').SkeletonNode;
|
|
15
18
|
//# sourceMappingURL=skeleton-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;GAeG;AACH,yCAfW,GAAG,WACH,OAAO,YAAY,EAAE,cAAc,aACnC,MAAM,EAAE,oBACR,OAAO,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,WACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,OAAO,oGAIL,OAAO,YAAY,EAAE,YAAY,CA+S7C"}
|
package/types/compile/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ajvModule from 'ajv/dist/2019.js';
|
|
2
2
|
import type MarkdownIt from 'markdown-it';
|
|
3
|
-
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase } from '@json-layout/vocabulary';
|
|
3
|
+
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase, type Expression } from '@json-layout/vocabulary';
|
|
4
4
|
import { type ValidateFunction, type SchemaObject } from 'ajv/dist/2019.js';
|
|
5
5
|
import { type Display } from '../state/utils/display.js';
|
|
6
6
|
import { type LocaleMessages } from '../i18n/types.js';
|
|
@@ -8,7 +8,7 @@ export interface ParentContextExpression {
|
|
|
8
8
|
data: unknown;
|
|
9
9
|
parent: ParentContextExpression | undefined | null;
|
|
10
10
|
}
|
|
11
|
-
export type CompiledExpression = (data: any, options: StateNodeOptionsBase, context: object, display: Display, layout: BaseCompObject, rootData?: unknown, parent?: ParentContextExpression | null) => any;
|
|
11
|
+
export type CompiledExpression = (data: any, options: StateNodeOptionsBase, context: object, display: Display, layout: BaseCompObject, validates: Record<string, ValidateFunction>, rootData?: unknown, parent?: ParentContextExpression | null) => any;
|
|
12
12
|
export interface CompileOptions {
|
|
13
13
|
ajv: ajvModule.default;
|
|
14
14
|
ajvOptions?: ajvModule.Options;
|
|
@@ -48,6 +48,7 @@ export interface SkeletonNode {
|
|
|
48
48
|
pure: boolean;
|
|
49
49
|
propertyKeys: string[];
|
|
50
50
|
roPropertyKeys: string[];
|
|
51
|
+
condition?: Expression;
|
|
51
52
|
children?: SkeletonNode[];
|
|
52
53
|
childrenTrees?: SkeletonTree[];
|
|
53
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,UAAU,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,oBAA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,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;CAC/B"}
|
package/types/state/index.d.ts
CHANGED
|
@@ -182,13 +182,12 @@ export class StatefulLayout {
|
|
|
182
182
|
*/
|
|
183
183
|
private getParentContextExpression;
|
|
184
184
|
/**
|
|
185
|
-
* @private
|
|
186
185
|
* @param {StateNode} node
|
|
187
186
|
* @param {import('@json-layout/vocabulary').Expression} expression
|
|
188
187
|
* @param {any} data
|
|
189
188
|
* @returns {any}
|
|
190
189
|
*/
|
|
191
|
-
|
|
190
|
+
evalNodeExpression(node: StateNode, expression: import('@json-layout/vocabulary').Expression, data: any): any;
|
|
192
191
|
/**
|
|
193
192
|
* @private
|
|
194
193
|
* @param {StateNode} node
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,mEAAmE;AACnE,+BADkB,SAAS,GAAG,SAAS,8CACoC;AAE3E,iLAAiL;AACjL,iCADkB,SAAS,GAAG,SAAS,cAAc,OAAO,MAAM,EAAE,OAAO,yBAAyB,EAAE,aAAa,CAAC,yHACnB;AAoCjG;IAgIE;;;;;OAKG;IACH,4BALW,OAAO,aAAa,EAAE,cAAc,gBACpC,OAAO,aAAa,EAAE,YAAY,WAClC,QAAQ,qBAAqB,CAAC,SAC9B,OAAO,EAejB;IAlJD;;;OAGG;IACH,iBAFU,OAAO,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAEhD;IAEN;;;;OAIG;IACH,iCAAe;IACf,mEAAqD;IAErD;;;OAGG;IAEH,mBAAU;IACV,gDAA2C;IAE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,YAAY,EAAE,SAAS;oCAC9B,OAAO,YAAY,EAAE,qBAAqB;mCAC1C,OAAO,YAAY,EAAE,oBAAoB;qCACzC,OAAO,YAAY,EAAE,sBAAsB;4BAC3C,OAAO,YAAY,EAAE,aAAa;2BAClC,OAAO,YAAY,EAAE,YAAY;8BACjC,OAAO,YAAY,EAAE,eAAe;yBACpC,OAAO,YAAY,EAAE,UAAU;0BAC/B,OAAO,YAAY,EAAE,WAAW;yBAChC,OAAO,YAAY,EAAE,UAAU;+BAC/B,OAAO,YAAY,EAAE,gBAAgB;6BACrC,OAAO,YAAY,EAAE,cAAc;gCACnC,OAAO,YAAY,EAAE,iBAAiB;8BACtC,OAAO,YAAY,EAAE,eAAe;2BACpC,OAAO,YAAY,EAAE,YAAY;2BACjC,OAAO,YAAY,EAAE,YAAY;yBACjC,OAAO,YAAY,EAAE,UAAU;8BAC/B,OAAO,YAAY,EAAE,eAAe;6BACpC,OAAO,YAAY,EAAE,cAAc;iCACnC,OAAO,YAAY,EAAE,kBAAkB;6BACvC,OAAO,YAAY,EAAE,cAAc;kCACnC,OAAO,YAAY,EAAE,mBAAmB;uBACxC,OAAO,YAAY,EAAE,QAAQ;+BAC7B,OAAO,YAAY,EAAE,gBAAgB;0BACrC,OAAO,YAAY,EAAE,WAAW;8BAChC,OAAO,YAAY,EAAE,eAAe;uBACpC,OAAO,YAAY,EAAE,QAAQ;4BAC7B,OAAO,YAAY,EAAE,aAAa;sBAClC,OAAO,YAAY,EAAE,OAAO;wBApCjB,oBAAoB"}
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
* @param {import('./types.js').StateNodeOptions} options
|
|
6
6
|
* @param {import('./utils/display.js').Display} display
|
|
7
7
|
* @param {import('@json-layout/vocabulary').BaseCompObject} layout
|
|
8
|
+
* @param {Record<string, import('ajv').ValidateFunction>} validates
|
|
8
9
|
* @param {unknown} rootData
|
|
9
10
|
* @param {import('../compile/types.js').ParentContextExpression | null} parentContext
|
|
10
11
|
* @returns {any}
|
|
11
12
|
*/
|
|
12
|
-
export function evalExpression(expressions: import('../index.js').CompiledExpression[], expression: import('@json-layout/vocabulary').Expression, data: any, options: import('./types.js').StateNodeOptions, display: import('./utils/display.js').Display, layout: import('@json-layout/vocabulary').BaseCompObject, rootData: unknown, parentContext: import('../compile/types.js').ParentContextExpression | null): any;
|
|
13
|
+
export function evalExpression(expressions: import('../index.js').CompiledExpression[], expression: import('@json-layout/vocabulary').Expression, data: any, options: import('./types.js').StateNodeOptions, display: import('./utils/display.js').Display, layout: import('@json-layout/vocabulary').BaseCompObject, validates: Record<string, import('ajv').ValidateFunction>, rootData: unknown, parentContext: import('../compile/types.js').ParentContextExpression | null): any;
|
|
13
14
|
/**
|
|
14
15
|
*
|
|
15
16
|
* @param {import('./types.js').CreateStateTreeContext} context
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAqKA
|
|
1
|
+
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAqKA;;;;;;;;;;;GAWG;AACH,4CAXW,OAAO,aAAa,EAAE,kBAAkB,EAAE,cAC1C,OAAO,yBAAyB,EAAE,UAAU,QAC5C,GAAG,WACH,OAAO,YAAY,EAAE,gBAAgB,WACrC,OAAO,oBAAoB,EAAE,OAAO,UACpC,OAAO,yBAAyB,EAAE,cAAc,aAChD,OAAO,MAAM,EAAE,OAAO,KAAK,EAAE,gBAAgB,CAAC,YAC9C,OAAO,iBACP,OAAO,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAC1D,GAAG,CAQf;AA+BD;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAjBW,OAAO,YAAY,EAAE,sBAAsB,iBAC3C,OAAO,YAAY,EAAE,gBAAgB,kBACrC,OAAO,aAAa,EAAE,cAAc,OACpC,MAAM,GAAG,MAAM,WACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,MAAM,kBACN,MAAM,GAAG,IAAI,YACb,OAAO,aAAa,EAAE,YAAY,mBAClC,OAAO,yBAAyB,EAAE,KAAK,GAAG,IAAI,iBAC9C,OAAO,oBAAoB,EAAE,OAAO,QACpC,OAAO,iBACP,OAAO,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,mBAC5D,OAAO,YAAY,EAAE,eAAe,4DAElC,OAAO,YAAY,EAAE,SAAS,CAgQ1C;AAED,uFAAuF;AACvF,yCADmB,GAAG,QAAQ,OAAO,YAAY,EAAE,SAAS,QAAQ,OAAO,KAAK,GAAG,CAOjF"}
|