@json-layout/core 0.13.0 → 0.15.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 +4 -4
- package/src/compile/index.js +16 -1
- package/src/compile/serialize.js +25 -0
- package/src/compile/skeleton-node.js +3 -1
- package/src/compile/types.ts +8 -3
- package/src/state/index.js +62 -21
- package/src/state/state-node.js +6 -6
- package/src/state/types.ts +4 -8
- package/src/utils/doc-options.js +14 -5
- package/types/compile/index.d.ts.map +1 -1
- package/types/compile/serialize.d.ts.map +1 -1
- package/types/compile/skeleton-node.d.ts.map +1 -1
- package/types/compile/types.d.ts +5 -2
- package/types/compile/types.d.ts.map +1 -1
- package/types/state/index.d.ts +18 -5
- package/types/state/index.d.ts.map +1 -1
- package/types/state/state-node.d.ts +2 -2
- package/types/state/state-node.d.ts.map +1 -1
- package/types/state/types.d.ts +4 -8
- package/types/state/types.d.ts.map +1 -1
- package/types/utils/doc-options.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.15.0",
|
|
4
4
|
"description": "Compilation and state management utilities for JSON Layout.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"LICENSE"
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
|
-
"test:
|
|
38
|
+
"test:only": "node --no-experimental-fetch --test --test-only test/*.spec.js",
|
|
39
39
|
"test": "node --no-experimental-fetch --test test/*.spec.js",
|
|
40
40
|
"build": "rm -rf ./types && tsc -p tsconfig.build.json",
|
|
41
41
|
"lint": "eslint . --fix",
|
|
@@ -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.15.0",
|
|
63
63
|
"@types/markdown-it": "^13.0.1",
|
|
64
64
|
"ajv": "^8.12.0",
|
|
65
65
|
"ajv-errors": "^3.0.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/debug": "^4.1.7",
|
|
77
77
|
"@types/node-fetch": "^2.6.5",
|
|
78
|
-
"json-schema-to-typescript": "^
|
|
78
|
+
"json-schema-to-typescript": "^14.0.0",
|
|
79
79
|
"nock": "^13.3.3",
|
|
80
80
|
"node-fetch": "^2.7.0"
|
|
81
81
|
}
|
package/src/compile/index.js
CHANGED
|
@@ -11,6 +11,7 @@ import i18n from '../i18n/index.js'
|
|
|
11
11
|
import { makeSkeletonTree } from './skeleton-tree.js'
|
|
12
12
|
import { resolveRefs } from './utils/resolve-refs.js'
|
|
13
13
|
import clone from '../utils/clone.js'
|
|
14
|
+
import { standardComponents } from '@json-layout/vocabulary'
|
|
14
15
|
|
|
15
16
|
export { resolveRefs } from './utils/resolve-refs.js'
|
|
16
17
|
|
|
@@ -69,6 +70,18 @@ const fillOptions = (partialOptions) => {
|
|
|
69
70
|
const messages = { ...i18n[locale] || i18n.en }
|
|
70
71
|
if (partialOptions.messages) Object.assign(messages, partialOptions.messages)
|
|
71
72
|
|
|
73
|
+
const components = standardComponents.reduce((acc, component) => {
|
|
74
|
+
acc[component.name] = component
|
|
75
|
+
return acc
|
|
76
|
+
}, /** @type {Record<string, import('@json-layout/vocabulary').ComponentInfo>} */({}))
|
|
77
|
+
|
|
78
|
+
if (partialOptions.components) {
|
|
79
|
+
for (const componentName of Object.keys(partialOptions.components)) {
|
|
80
|
+
components[componentName] = { ...partialOptions.components[componentName], name: componentName }
|
|
81
|
+
}
|
|
82
|
+
Object.assign(components, partialOptions.components)
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
return {
|
|
73
86
|
ajv,
|
|
74
87
|
code: false,
|
|
@@ -76,7 +89,8 @@ const fillOptions = (partialOptions) => {
|
|
|
76
89
|
optionsKeys: [],
|
|
77
90
|
...partialOptions,
|
|
78
91
|
locale,
|
|
79
|
-
messages
|
|
92
|
+
messages,
|
|
93
|
+
components
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
|
|
@@ -157,6 +171,7 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
157
171
|
expressions,
|
|
158
172
|
locale: options.locale,
|
|
159
173
|
messages: options.messages,
|
|
174
|
+
components: options.components,
|
|
160
175
|
// @ts-ignore
|
|
161
176
|
localizeErrors: ajvLocalize[options.locale] || ajvLocalize.en
|
|
162
177
|
}
|
package/src/compile/serialize.js
CHANGED
|
@@ -4,6 +4,20 @@ import standaloneCode from 'ajv/dist/standalone/index.js'
|
|
|
4
4
|
import { parseModule, generateCode, builders } from 'magicast'
|
|
5
5
|
import { parse, print } from 'recast'
|
|
6
6
|
import clone from '../utils/clone.js'
|
|
7
|
+
import { isSwitchStruct } from '@json-layout/vocabulary'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @generator
|
|
11
|
+
* @param {import('./index.js').CompiledLayout} compiledLayout
|
|
12
|
+
* @yields {import('./types.js').BaseCompObject}
|
|
13
|
+
* @returns {Generator<import('@json-layout/vocabulary').BaseCompObject>}
|
|
14
|
+
*/
|
|
15
|
+
function * iterCompObject (compiledLayout) {
|
|
16
|
+
for (const normalizedLayout of Object.values(compiledLayout.normalizedLayouts)) {
|
|
17
|
+
if (isSwitchStruct(normalizedLayout)) yield * normalizedLayout.switch
|
|
18
|
+
else yield normalizedLayout
|
|
19
|
+
}
|
|
20
|
+
}
|
|
7
21
|
|
|
8
22
|
/**
|
|
9
23
|
* @param {import('./index.js').CompiledLayout} compiledLayout
|
|
@@ -51,6 +65,16 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
51
65
|
expressionsNodes.push(builders.raw(fn.id))
|
|
52
66
|
}
|
|
53
67
|
|
|
68
|
+
/** @type {Record<string, Omit<import('@json-layout/vocabulary').ComponentInfo, 'schema'>>} */
|
|
69
|
+
const components = {}
|
|
70
|
+
for (const compObject of iterCompObject(compiledLayout)) {
|
|
71
|
+
if (!components[compObject.comp]) {
|
|
72
|
+
const component = { ...compiledLayout.options.components[compObject.comp] }
|
|
73
|
+
delete component.schema
|
|
74
|
+
components[compObject.comp] = component
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
54
78
|
const ast = parseModule(code)
|
|
55
79
|
ast.exports.compiledLayout = {
|
|
56
80
|
skeletonTree: compiledLayout.skeletonTree,
|
|
@@ -60,6 +84,7 @@ export const exportLocalizeErrors = localizeErrors;\n` + code
|
|
|
60
84
|
expressions: expressionsNodes,
|
|
61
85
|
locale: compiledLayout.locale,
|
|
62
86
|
messages: compiledLayout.messages,
|
|
87
|
+
components,
|
|
63
88
|
localizeErrors: ast.exports.exportLocalizeErrors
|
|
64
89
|
}
|
|
65
90
|
delete ast.exports.exportLocalizeErrors
|
|
@@ -35,6 +35,7 @@ export function makeSkeletonNode (
|
|
|
35
35
|
const normalizationResult = normalizeLayoutFragment(
|
|
36
36
|
/** @type {import('@json-layout/vocabulary').SchemaFragment} */(schema),
|
|
37
37
|
pointer,
|
|
38
|
+
options.components,
|
|
38
39
|
options.markdown,
|
|
39
40
|
options.optionsKeys
|
|
40
41
|
)
|
|
@@ -90,7 +91,7 @@ export function makeSkeletonNode (
|
|
|
90
91
|
|
|
91
92
|
if (compObject.transformData) pushExpression(expressions, compObject.transformData)
|
|
92
93
|
|
|
93
|
-
if (isItemsLayout(compObject) && compObject.getItems) {
|
|
94
|
+
if (isItemsLayout(compObject, options.components) && compObject.getItems) {
|
|
94
95
|
if (isGetItemsExpression(compObject.getItems)) pushExpression(expressions, compObject.getItems)
|
|
95
96
|
if (isGetItemsFetch(compObject.getItems)) pushExpression(expressions, compObject.getItems.url)
|
|
96
97
|
if (compObject.getItems.itemTitle) pushExpression(expressions, compObject.getItems.itemTitle)
|
|
@@ -153,6 +154,7 @@ export function makeSkeletonNode (
|
|
|
153
154
|
const normalizationResult = normalizeLayoutFragment(
|
|
154
155
|
schema,
|
|
155
156
|
oneOfPointer,
|
|
157
|
+
options.components,
|
|
156
158
|
options.markdown,
|
|
157
159
|
options.optionsKeys,
|
|
158
160
|
'oneOf'
|
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
|
|
3
|
+
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase } 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'
|
|
@@ -10,7 +10,7 @@ export type CompiledExpression = (
|
|
|
10
10
|
options: StateNodeOptionsBase,
|
|
11
11
|
context: object,
|
|
12
12
|
display: Display,
|
|
13
|
-
layout:
|
|
13
|
+
layout: BaseCompObject,
|
|
14
14
|
rootData?: unknown,
|
|
15
15
|
parentData?: unknown
|
|
16
16
|
) => any
|
|
@@ -24,9 +24,13 @@ export interface CompileOptions {
|
|
|
24
24
|
locale: string
|
|
25
25
|
messages: LocaleMessages
|
|
26
26
|
optionsKeys: string[]
|
|
27
|
+
components: Record<string, ComponentInfo>
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
|
|
30
|
+
export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
|
|
31
|
+
messages?: Partial<LocaleMessages>
|
|
32
|
+
components?: Record<string, Omit<ComponentInfo, 'name'>>
|
|
33
|
+
}
|
|
30
34
|
|
|
31
35
|
export interface CompiledLayout {
|
|
32
36
|
options?: CompileOptions
|
|
@@ -38,6 +42,7 @@ export interface CompiledLayout {
|
|
|
38
42
|
expressions: CompiledExpression[]
|
|
39
43
|
locale: string
|
|
40
44
|
messages: LocaleMessages
|
|
45
|
+
components: Record<string, Omit<ComponentInfo, 'schema'>>
|
|
41
46
|
localizeErrors: (errors: ajvModule.ErrorObject[]) => void
|
|
42
47
|
}
|
|
43
48
|
|
package/src/state/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { produce } from 'immer'
|
|
|
5
5
|
import { evalExpression, producePatchedData } from './state-node.js'
|
|
6
6
|
import { createStateTree } from './state-tree.js'
|
|
7
7
|
import { Display } from './utils/display.js'
|
|
8
|
-
import {
|
|
8
|
+
import { isGetItemsExpression, isGetItemsFetch, isItemsLayout } from '@json-layout/vocabulary'
|
|
9
9
|
import { shallowProduceArray } from './utils/immutable.js'
|
|
10
10
|
|
|
11
11
|
export { Display } from './utils/display.js'
|
|
@@ -37,15 +37,14 @@ export { Display } from './utils/display.js'
|
|
|
37
37
|
* @typedef {import('./types.js').OneOfSelectNode} OneOfSelectNode
|
|
38
38
|
* @typedef {import('./types.js').ListNode} ListNode
|
|
39
39
|
* @typedef {import('./types.js').FileInputNode} FileInputNode
|
|
40
|
-
* @typedef {import('./types.js').MarkdownNode} MarkdownNode
|
|
41
40
|
* @typedef {import('./types.js').FileRef} FileRef
|
|
42
41
|
*/
|
|
43
42
|
|
|
44
43
|
/** @type {(node: StateNode | undefined) => node is SectionNode} */
|
|
45
44
|
export const isSection = (node) => !!node && node.layout.comp === 'section'
|
|
46
45
|
|
|
47
|
-
/** @type {(node: StateNode | undefined) => node is SelectNode | ComboboxNode | AutocompleteNode} */
|
|
48
|
-
export const isItemsNode = (node) => !!node && isItemsLayout(node.layout)
|
|
46
|
+
/** @type {(node: StateNode | undefined, components: Record<string, import('@json-layout/vocabulary').ComponentInfo>) => node is SelectNode | ComboboxNode | AutocompleteNode} */
|
|
47
|
+
export const isItemsNode = (node, components) => !!node && isItemsLayout(node.layout, components)
|
|
49
48
|
|
|
50
49
|
const logDataBinding = debug('jl:data-binding')
|
|
51
50
|
|
|
@@ -70,11 +69,12 @@ function fillOptions (partialOptions, compiledLayout) {
|
|
|
70
69
|
titleDepth: 2,
|
|
71
70
|
validateOn: 'input',
|
|
72
71
|
initialValidation: 'withData',
|
|
72
|
+
updateOn: 'input',
|
|
73
|
+
debounceInputMs: 300,
|
|
73
74
|
defaultOn: 'empty',
|
|
74
75
|
removeAdditional: 'error',
|
|
75
76
|
autofocus: false,
|
|
76
77
|
readOnlyPropertiesMode: 'show',
|
|
77
|
-
debounceInputMs: 300,
|
|
78
78
|
...partialOptions,
|
|
79
79
|
messages
|
|
80
80
|
}
|
|
@@ -173,6 +173,18 @@ export class StatefulLayout {
|
|
|
173
173
|
this.updateState()
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* @private
|
|
178
|
+
* @type {unknown}
|
|
179
|
+
*/
|
|
180
|
+
_previousData
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @private
|
|
184
|
+
* @type {boolean}
|
|
185
|
+
*/
|
|
186
|
+
_dataWaitingForBlur = false
|
|
187
|
+
|
|
176
188
|
/**
|
|
177
189
|
* @private
|
|
178
190
|
* @type {CreateStateTreeContext}
|
|
@@ -258,6 +270,19 @@ export class StatefulLayout {
|
|
|
258
270
|
}
|
|
259
271
|
logDataBinding('emit update event', this._data, this._stateTree)
|
|
260
272
|
this.events.emit('update', this)
|
|
273
|
+
this.emitData()
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* @private
|
|
278
|
+
*/
|
|
279
|
+
emitData () {
|
|
280
|
+
// emit data event only if the data has changed, as it is immutable this simple comparison should suffice
|
|
281
|
+
if (!this._dataWaitingForBlur && this._data !== this._previousData) {
|
|
282
|
+
logDataBinding('emit data event', this._data)
|
|
283
|
+
this.events.emit('data', this._data)
|
|
284
|
+
this._previousData = this._data
|
|
285
|
+
}
|
|
261
286
|
}
|
|
262
287
|
|
|
263
288
|
/**
|
|
@@ -346,14 +371,15 @@ export class StatefulLayout {
|
|
|
346
371
|
* @private
|
|
347
372
|
* @param {StateNode} node
|
|
348
373
|
* @param {unknown} data
|
|
374
|
+
* @param {boolean} [validated]
|
|
349
375
|
* @param {number} [activateKey]
|
|
350
376
|
*/
|
|
351
|
-
applyInput (node, data, activateKey) {
|
|
377
|
+
applyInput (node, data, validated, activateKey) {
|
|
352
378
|
logDataBinding('received input event from node', node, data)
|
|
353
379
|
|
|
354
380
|
const transformedData = node.layout.transformData && this.evalNodeExpression(node, node.layout.transformData, data)
|
|
355
381
|
|
|
356
|
-
if (
|
|
382
|
+
if (node.layout.comp === 'file-input') {
|
|
357
383
|
if (transformedData) {
|
|
358
384
|
// @ts-ignore
|
|
359
385
|
data.toJSON = () => transformedData
|
|
@@ -372,25 +398,23 @@ export class StatefulLayout {
|
|
|
372
398
|
data = transformedData
|
|
373
399
|
}
|
|
374
400
|
|
|
375
|
-
if (
|
|
376
|
-
(node.options.validateOn === 'input' || (node.options.validateOne === 'blur' && !editableCompNames.includes(node.layout.comp))) &&
|
|
377
|
-
!this.validationState.validatedChildren.includes(node.fullKey)
|
|
378
|
-
) {
|
|
401
|
+
if (validated && !this.validationState.validatedChildren.includes(node.fullKey)) {
|
|
379
402
|
this.validationState = { validatedChildren: this.validationState.validatedChildren.concat([node.fullKey]) }
|
|
380
403
|
}
|
|
404
|
+
|
|
381
405
|
if (activateKey !== undefined) {
|
|
382
406
|
this.activeItems = produce(this.activeItems, draft => { draft[node.fullKey] = activateKey })
|
|
383
407
|
this._autofocusTarget = node.fullKey + '/' + activateKey
|
|
384
408
|
}
|
|
385
409
|
if (node.parentFullKey === null) {
|
|
386
|
-
this.
|
|
387
|
-
this.
|
|
410
|
+
this._data = data
|
|
411
|
+
this.updateState()
|
|
388
412
|
return
|
|
389
413
|
}
|
|
390
414
|
const parentNode = this._lastCreateStateTreeContext.nodes.find(p => p.fullKey === node.parentFullKey)
|
|
391
415
|
if (!parentNode) throw new Error(`parent with key "${node.parentFullKey}" not found`)
|
|
392
416
|
const newParentValue = producePatchedData(parentNode.data ?? (typeof node.key === 'number' ? [] : {}), node, data)
|
|
393
|
-
this.applyInput(parentNode, newParentValue)
|
|
417
|
+
this.applyInput(parentNode, newParentValue, validated)
|
|
394
418
|
|
|
395
419
|
if (activateKey !== undefined) {
|
|
396
420
|
this.handleAutofocus()
|
|
@@ -399,14 +423,14 @@ export class StatefulLayout {
|
|
|
399
423
|
|
|
400
424
|
/**
|
|
401
425
|
* @private
|
|
402
|
-
* @type {null | [StateNode, unknown, number | undefined, ReturnType<typeof setTimeout>]}
|
|
426
|
+
* @type {null | [StateNode, unknown, boolean, number | undefined, ReturnType<typeof setTimeout>]}
|
|
403
427
|
*/
|
|
404
428
|
debouncedInput = null
|
|
405
429
|
|
|
406
430
|
applyDebouncedInput () {
|
|
407
431
|
if (this.debouncedInput) {
|
|
408
432
|
clearTimeout(this.debouncedInput[3])
|
|
409
|
-
this.applyInput(this.debouncedInput[0], this.debouncedInput[1], this.debouncedInput[2])
|
|
433
|
+
this.applyInput(this.debouncedInput[0], this.debouncedInput[1], this.debouncedInput[2], this.debouncedInput[3])
|
|
410
434
|
this.debouncedInput = null
|
|
411
435
|
}
|
|
412
436
|
}
|
|
@@ -420,14 +444,23 @@ export class StatefulLayout {
|
|
|
420
444
|
// debounced data from the same node is cancelled if a new input is received
|
|
421
445
|
// debounced data from another node is applied immediately
|
|
422
446
|
if (this.debouncedInput) {
|
|
423
|
-
if (this.debouncedInput[0] === node) clearTimeout(this.debouncedInput[
|
|
447
|
+
if (this.debouncedInput[0] === node) clearTimeout(this.debouncedInput[4])
|
|
424
448
|
else this.applyDebouncedInput()
|
|
425
449
|
}
|
|
426
450
|
|
|
427
|
-
|
|
428
|
-
|
|
451
|
+
const emitsBlur = this.compiledLayout.components[node.layout.comp]?.emitsBlur
|
|
452
|
+
|
|
453
|
+
if (node.options.updateOn === 'blur' && emitsBlur) {
|
|
454
|
+
this._dataWaitingForBlur = true
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const validated = node.options.validateOn === 'input' || (node.options.validateOn === 'blur' && !emitsBlur)
|
|
458
|
+
|
|
459
|
+
const shouldDebounce = this.compiledLayout.components[node.layout.comp]?.shouldDebounce
|
|
460
|
+
if (shouldDebounce && node.options.debounceInputMs) {
|
|
461
|
+
this.debouncedInput = [node, data, validated, activateKey, setTimeout(() => this.applyDebouncedInput(), node.options.debounceInputMs)]
|
|
429
462
|
} else {
|
|
430
|
-
this.applyInput(node, data, activateKey)
|
|
463
|
+
this.applyInput(node, data, validated, activateKey)
|
|
431
464
|
}
|
|
432
465
|
}
|
|
433
466
|
|
|
@@ -445,6 +478,12 @@ export class StatefulLayout {
|
|
|
445
478
|
) {
|
|
446
479
|
this.validationState = { validatedChildren: this.validationState.validatedChildren.concat([node.fullKey]) }
|
|
447
480
|
}
|
|
481
|
+
|
|
482
|
+
// in case of updateOn=blur option
|
|
483
|
+
if (this._dataWaitingForBlur) {
|
|
484
|
+
this._dataWaitingForBlur = false
|
|
485
|
+
this.emitData()
|
|
486
|
+
}
|
|
448
487
|
}
|
|
449
488
|
|
|
450
489
|
/**
|
|
@@ -466,7 +505,9 @@ export class StatefulLayout {
|
|
|
466
505
|
* @returns {Promise<[import('@json-layout/vocabulary').SelectItems, boolean]>}
|
|
467
506
|
*/
|
|
468
507
|
async getSourceItems (node, q = '') {
|
|
469
|
-
if (!isItemsNode(node))
|
|
508
|
+
if (!isItemsNode(node, this._compiledLayout.components)) {
|
|
509
|
+
throw new Error('node is not a component with an items list')
|
|
510
|
+
}
|
|
470
511
|
|
|
471
512
|
if (node.layout.items) return [node.layout.items, false]
|
|
472
513
|
|
package/src/state/state-node.js
CHANGED
|
@@ -16,7 +16,7 @@ const isDataEmpty = (data) => {
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @param {unknown} data
|
|
19
|
-
* @param {import('@json-layout/vocabulary').
|
|
19
|
+
* @param {import('@json-layout/vocabulary').BaseCompObject} layout
|
|
20
20
|
* @param {import('./types.js').StateNodeOptions} options
|
|
21
21
|
* @returns {boolean}
|
|
22
22
|
*/
|
|
@@ -27,7 +27,7 @@ const useDefaultData = (data, layout, options) => {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// use Immer for efficient updating with immutability and no-op detection
|
|
30
|
-
/** @type {(draft: import('./types.js').StateNode, key: string | number, fullKey: string, parentFullKey: string | null, dataPath: string, parentDataPath: string | null, skeleton: import('../index.js').SkeletonNode, layout: import('@json-layout/vocabulary').
|
|
30
|
+
/** @type {(draft: import('./types.js').StateNode, key: string | number, fullKey: string, parentFullKey: string | null, dataPath: string, parentDataPath: string | null, skeleton: import('../index.js').SkeletonNode, layout: import('@json-layout/vocabulary').BaseCompObject, width: number, cols: number, data: unknown, error: string | undefined, validated: boolean, options: import('./types.js').StateNodeOptions, autofocus: boolean, props: import('@json-layout/vocabulary').StateNodePropsLib, children: import('../index.js').StateNode[] | undefined) => import('../index.js').StateNode} */
|
|
31
31
|
const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath, parentDataPath, skeleton, layout, width, cols, data, error, validated, options, autofocus, props, children) => {
|
|
32
32
|
draft.messages = layout.messages ? produceStateNodeMessages(draft.messages || {}, layout.messages, options) : options.messages
|
|
33
33
|
|
|
@@ -169,7 +169,7 @@ const matchChildError = (error, skeleton, dataPath, parentDataPath) => {
|
|
|
169
169
|
* @param {any} data
|
|
170
170
|
* @param {import('./types.js').StateNodeOptions} options
|
|
171
171
|
* @param {import('./utils/display.js').Display} display
|
|
172
|
-
* @param {import('@json-layout/vocabulary').
|
|
172
|
+
* @param {import('@json-layout/vocabulary').BaseCompObject} layout
|
|
173
173
|
* @param {unknown} rootData
|
|
174
174
|
* @param {unknown} parentData
|
|
175
175
|
* @returns {any}
|
|
@@ -188,7 +188,7 @@ export function evalExpression (expressions, expression, data, options, display,
|
|
|
188
188
|
* @param {unknown} data
|
|
189
189
|
* @param {unknown} rootData
|
|
190
190
|
* @param {unknown} parentData
|
|
191
|
-
* @returns {import('@json-layout/vocabulary').
|
|
191
|
+
* @returns {import('@json-layout/vocabulary').BaseCompObject}
|
|
192
192
|
*/
|
|
193
193
|
const getCompObject = (normalizedLayout, options, compiledLayout, display, data, rootData, parentData) => {
|
|
194
194
|
if (isSwitchStruct(normalizedLayout)) {
|
|
@@ -275,7 +275,7 @@ export function createStateNode (
|
|
|
275
275
|
|
|
276
276
|
/** @type {import('./types.js').StateNode[] | undefined} */
|
|
277
277
|
let children
|
|
278
|
-
if (isCompositeLayout(layout)) {
|
|
278
|
+
if (isCompositeLayout(layout, compiledLayout.components)) {
|
|
279
279
|
// TODO: make this type casting safe using prior validation
|
|
280
280
|
const objectData = /** @type {Record<string, unknown>} */(data ?? {})
|
|
281
281
|
const childrenOptions = produceCompositeChildrenOptions(options, layout)
|
|
@@ -436,7 +436,7 @@ export function createStateNode (
|
|
|
436
436
|
props = evalExpression(compiledLayout.expressions, layout.getProps, nodeData, options, display, layout, context.rootData, parentData)
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
const autofocus = isFocusableLayout(layout) && !options.readOnly && !options.summary && context.autofocusTarget === fullKey
|
|
439
|
+
const autofocus = isFocusableLayout(layout, compiledLayout.components) && !options.readOnly && !options.summary && context.autofocusTarget === fullKey
|
|
440
440
|
const node = produceStateNode(
|
|
441
441
|
reusedNode ?? /** @type {import('./types.js').StateNode} */({}),
|
|
442
442
|
key,
|
package/src/state/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ErrorObject } from 'ajv/dist/2019.js'
|
|
2
2
|
import {
|
|
3
|
-
type
|
|
3
|
+
type BaseCompObject,
|
|
4
4
|
type Cols,
|
|
5
5
|
type StateNodeOptionsBase,
|
|
6
6
|
type TextField,
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
type Stepper,
|
|
24
24
|
type List,
|
|
25
25
|
type Combobox,
|
|
26
|
-
type Markdown,
|
|
27
26
|
type FileInput,
|
|
28
27
|
type Child,
|
|
29
28
|
type StateNodePropsLib
|
|
@@ -38,7 +37,7 @@ export interface StateNode {
|
|
|
38
37
|
dataPath: string
|
|
39
38
|
parentDataPath: string | null
|
|
40
39
|
skeleton: SkeletonNode
|
|
41
|
-
layout:
|
|
40
|
+
layout: BaseCompObject
|
|
42
41
|
cols: Cols
|
|
43
42
|
data: unknown
|
|
44
43
|
error: string | undefined
|
|
@@ -98,9 +97,8 @@ export interface ValidationState {
|
|
|
98
97
|
|
|
99
98
|
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
|
|
100
99
|
export type StatefulLayoutEvents = {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'update': StatefulLayout
|
|
100
|
+
data: any
|
|
101
|
+
update: StatefulLayout
|
|
104
102
|
autofocus: string
|
|
105
103
|
}
|
|
106
104
|
|
|
@@ -155,5 +153,3 @@ export type ListNode = StateNode & { layout: List, data: any[], children: StateN
|
|
|
155
153
|
export type ComboboxNode = Omit<StateNode, 'children'> & { layout: Combobox, data: any[] }
|
|
156
154
|
|
|
157
155
|
export type FileInputNode = Omit<StateNode, 'children'> & { layout: FileInput, data: object | undefined | null }
|
|
158
|
-
|
|
159
|
-
export type MarkdownNode = Omit<StateNode, 'children'> & { layout: Markdown, data: string | undefined | null }
|
package/src/utils/doc-options.js
CHANGED
|
@@ -89,6 +89,20 @@ export const runtimeOptions = [
|
|
|
89
89
|
withData: 'Only the inputs with data at initialization are validated.'
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
|
+
{
|
|
93
|
+
key: 'updateOn',
|
|
94
|
+
description: 'Control when the new data will be emitted by the form.',
|
|
95
|
+
default: 'input',
|
|
96
|
+
values: {
|
|
97
|
+
input: 'The data will be updated in realtime when the user makes any input (except for the application of debounceInputMs).',
|
|
98
|
+
blur: 'The data will be updated only when the user interacts with a form input then leaves it.'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
key: 'debounceInputMs',
|
|
103
|
+
description: 'The debounce time for the input event of editable fields.',
|
|
104
|
+
default: 300
|
|
105
|
+
},
|
|
92
106
|
{
|
|
93
107
|
key: 'defaultOn',
|
|
94
108
|
description: 'Control the use of default values in the form.',
|
|
@@ -123,10 +137,5 @@ export const runtimeOptions = [
|
|
|
123
137
|
hide: 'Hide the readOnly properties but keep them in the data.',
|
|
124
138
|
show: 'Show the readOnly properties.'
|
|
125
139
|
}
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
key: 'debounceInputMs',
|
|
129
|
-
description: 'The debounce time for the input event of editable fields.',
|
|
130
|
-
default: 300
|
|
131
140
|
}
|
|
132
141
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AAgGA;;;;GAIG;AACH,iCAJW,MAAM,4EAEJ,cAAc,CA8E1B;;AA/ID,yGAAyG;AACzG,4CADmB,qBAAqB,cAAc,qBAAqB,KAAK,qBAAqB,CAQnG;2BAxBW,OAAO,YAAY,EAAE,YAAY;2BACjC,OAAO,YAAY,EAAE,YAAY;6BACjC,OAAO,YAAY,EAAE,cAAc;6BACnC,OAAO,YAAY,EAAE,cAAc;oCACnC,OAAO,YAAY,EAAE,qBAAqB;iCAC1C,OAAO,YAAY,EAAE,kBAAkB"}
|
|
@@ -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":"AAqBA;;;GAGG;AACH,0CAHW,OAAO,YAAY,EAAE,cAAc,GACjC,MAAM,CA+ElB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,yCAZW,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,GACL,OAAO,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,yCAZW,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,GACL,OAAO,YAAY,EAAE,YAAY,CA4N7C"}
|
package/types/compile/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type ajvModule from 'ajv/dist/2019.js';
|
|
2
2
|
import type MarkdownIt from 'markdown-it';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase } 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';
|
|
7
|
-
export type CompiledExpression = (data: any, options: StateNodeOptionsBase, context: object, display: Display, layout:
|
|
7
|
+
export type CompiledExpression = (data: any, options: StateNodeOptionsBase, context: object, display: Display, layout: BaseCompObject, rootData?: unknown, parentData?: unknown) => any;
|
|
8
8
|
export interface CompileOptions {
|
|
9
9
|
ajv: ajvModule.default;
|
|
10
10
|
ajvOptions?: ajvModule.Options;
|
|
@@ -14,9 +14,11 @@ export interface CompileOptions {
|
|
|
14
14
|
locale: string;
|
|
15
15
|
messages: LocaleMessages;
|
|
16
16
|
optionsKeys: string[];
|
|
17
|
+
components: Record<string, ComponentInfo>;
|
|
17
18
|
}
|
|
18
19
|
export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
|
|
19
20
|
messages?: Partial<LocaleMessages>;
|
|
21
|
+
components?: Record<string, Omit<ComponentInfo, 'name'>>;
|
|
20
22
|
};
|
|
21
23
|
export interface CompiledLayout {
|
|
22
24
|
options?: CompileOptions;
|
|
@@ -28,6 +30,7 @@ export interface CompiledLayout {
|
|
|
28
30
|
expressions: CompiledExpression[];
|
|
29
31
|
locale: string;
|
|
30
32
|
messages: LocaleMessages;
|
|
33
|
+
components: Record<string, Omit<ComponentInfo, 'schema'>>;
|
|
31
34
|
localizeErrors: (errors: ajvModule.ErrorObject[]) => void;
|
|
32
35
|
}
|
|
33
36
|
export interface SkeletonTree {
|
|
@@ -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,
|
|
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,o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A;IACrB,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IAC3C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;IACnD,WAAW,EAAE,kBAAkB,EAAE,CAAA;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,cAAc,CAAA;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAA;IACzD,cAAc,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,KAAK,IAAI,CAAA;CAC1D;AAID,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,YAAY,CAAA;CACnB;AAID,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAA;IACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;CAC/B"}
|
package/types/state/index.d.ts
CHANGED
|
@@ -26,13 +26,12 @@ export { Display } from "./utils/display.js";
|
|
|
26
26
|
* @typedef {import('./types.js').OneOfSelectNode} OneOfSelectNode
|
|
27
27
|
* @typedef {import('./types.js').ListNode} ListNode
|
|
28
28
|
* @typedef {import('./types.js').FileInputNode} FileInputNode
|
|
29
|
-
* @typedef {import('./types.js').MarkdownNode} MarkdownNode
|
|
30
29
|
* @typedef {import('./types.js').FileRef} FileRef
|
|
31
30
|
*/
|
|
32
31
|
/** @type {(node: StateNode | undefined) => node is SectionNode} */
|
|
33
32
|
export const isSection: (node: StateNode | undefined) => node is import("./types.js").SectionNode;
|
|
34
|
-
/** @type {(node: StateNode | undefined) => node is SelectNode | ComboboxNode | AutocompleteNode} */
|
|
35
|
-
export const isItemsNode: (node: StateNode | undefined) => node is import("./types.js").SelectNode | import("./types.js").AutocompleteNode | import("./types.js").ComboboxNode;
|
|
33
|
+
/** @type {(node: StateNode | undefined, components: Record<string, import('@json-layout/vocabulary').ComponentInfo>) => node is SelectNode | ComboboxNode | AutocompleteNode} */
|
|
34
|
+
export const isItemsNode: (node: StateNode | undefined, components: Record<string, import('@json-layout/vocabulary').ComponentInfo>) => node is import("./types.js").SelectNode | import("./types.js").AutocompleteNode | import("./types.js").ComboboxNode;
|
|
36
35
|
export class StatefulLayout {
|
|
37
36
|
/**
|
|
38
37
|
* @param {import("../index.js").CompiledLayout} compiledLayout
|
|
@@ -104,6 +103,16 @@ export class StatefulLayout {
|
|
|
104
103
|
private _data;
|
|
105
104
|
set data(arg: unknown);
|
|
106
105
|
get data(): unknown;
|
|
106
|
+
/**
|
|
107
|
+
* @private
|
|
108
|
+
* @type {unknown}
|
|
109
|
+
*/
|
|
110
|
+
private _previousData;
|
|
111
|
+
/**
|
|
112
|
+
* @private
|
|
113
|
+
* @type {boolean}
|
|
114
|
+
*/
|
|
115
|
+
private _dataWaitingForBlur;
|
|
107
116
|
/**
|
|
108
117
|
* @private
|
|
109
118
|
* @type {CreateStateTreeContext}
|
|
@@ -140,6 +149,10 @@ export class StatefulLayout {
|
|
|
140
149
|
* @private
|
|
141
150
|
*/
|
|
142
151
|
private updateState;
|
|
152
|
+
/**
|
|
153
|
+
* @private
|
|
154
|
+
*/
|
|
155
|
+
private emitData;
|
|
143
156
|
/**
|
|
144
157
|
* @private
|
|
145
158
|
* @param {boolean} rehydrate
|
|
@@ -171,12 +184,13 @@ export class StatefulLayout {
|
|
|
171
184
|
* @private
|
|
172
185
|
* @param {StateNode} node
|
|
173
186
|
* @param {unknown} data
|
|
187
|
+
* @param {boolean} [validated]
|
|
174
188
|
* @param {number} [activateKey]
|
|
175
189
|
*/
|
|
176
190
|
private applyInput;
|
|
177
191
|
/**
|
|
178
192
|
* @private
|
|
179
|
-
* @type {null | [StateNode, unknown, number | undefined, ReturnType<typeof setTimeout>]}
|
|
193
|
+
* @type {null | [StateNode, unknown, boolean, number | undefined, ReturnType<typeof setTimeout>]}
|
|
180
194
|
*/
|
|
181
195
|
private debouncedInput;
|
|
182
196
|
applyDebouncedInput(): void;
|
|
@@ -244,7 +258,6 @@ export type StepperNode = import('./types.js').StepperNode;
|
|
|
244
258
|
export type OneOfSelectNode = import('./types.js').OneOfSelectNode;
|
|
245
259
|
export type ListNode = import('./types.js').ListNode;
|
|
246
260
|
export type FileInputNode = import('./types.js').FileInputNode;
|
|
247
|
-
export type MarkdownNode = import('./types.js').MarkdownNode;
|
|
248
261
|
export type FileRef = import('./types.js').FileRef;
|
|
249
262
|
import { Display } from './utils/display.js';
|
|
250
263
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;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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AO,yBAAyB,EAAE,WAAW,CAAC,CAMlE;IAOD;;;OAGG;IACH,mBAHW,SAAS,OACT,MAAM,QAWhB;IAED;;OAEG;IACH,qBAFW,SAAS,QAKnB;IAED,wBASC;CACF;wBA1lBY,OAAO,YAAY,EAAE,SAAS;wBAC9B,OAAO,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;2BACrC,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;wBAjCjB,oBAAoB"}
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @param {any} data
|
|
5
5
|
* @param {import('./types.js').StateNodeOptions} options
|
|
6
6
|
* @param {import('./utils/display.js').Display} display
|
|
7
|
-
* @param {import('@json-layout/vocabulary').
|
|
7
|
+
* @param {import('@json-layout/vocabulary').BaseCompObject} layout
|
|
8
8
|
* @param {unknown} rootData
|
|
9
9
|
* @param {unknown} parentData
|
|
10
10
|
* @returns {any}
|
|
11
11
|
*/
|
|
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').
|
|
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, parentData: unknown): any;
|
|
13
13
|
/**
|
|
14
14
|
*
|
|
15
15
|
* @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;;;;;;;;;;GAUG;AACH,4CAVW,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,
|
|
1
|
+
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAqKA;;;;;;;;;;GAUG;AACH,4CAVW,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,YAChD,OAAO,cACP,OAAO,GACL,GAAG,CAMf;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,cACP,OAAO,mBACP,OAAO,YAAY,EAAE,eAAe,4DAElC,OAAO,YAAY,EAAE,SAAS,CA0O1C;AAED,uFAAuF;AACvF,yCADmB,GAAG,QAAQ,OAAO,YAAY,EAAE,SAAS,QAAQ,OAAO,KAAK,GAAG,CAOjF"}
|
package/types/state/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ErrorObject } from 'ajv/dist/2019.js';
|
|
2
|
-
import { type
|
|
2
|
+
import { type BaseCompObject, type Cols, type StateNodeOptionsBase, type TextField, type Textarea, type NumberField, type Slider, type Checkbox, type Switch, type DatePicker, type DateTimePicker, type TimePicker, type ColorPicker, type Section, type OneOfSelect, type Select, type Autocomplete, type Tabs, type VerticalTabs, type ExpansionPanels, type Stepper, type List, type Combobox, type FileInput, type Child, type StateNodePropsLib } from '@json-layout/vocabulary';
|
|
3
3
|
import { type SkeletonTree, type SkeletonNode, type StatefulLayout, type CompiledLayout } from '../index.js';
|
|
4
4
|
import { type LocaleMessages } from '../i18n/types.js';
|
|
5
5
|
export interface StateNode {
|
|
@@ -9,7 +9,7 @@ export interface StateNode {
|
|
|
9
9
|
dataPath: string;
|
|
10
10
|
parentDataPath: string | null;
|
|
11
11
|
skeleton: SkeletonNode;
|
|
12
|
-
layout:
|
|
12
|
+
layout: BaseCompObject;
|
|
13
13
|
cols: Cols;
|
|
14
14
|
data: unknown;
|
|
15
15
|
error: string | undefined;
|
|
@@ -61,8 +61,8 @@ export interface ValidationState {
|
|
|
61
61
|
validatedChildren: string[];
|
|
62
62
|
}
|
|
63
63
|
export type StatefulLayoutEvents = {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
data: any;
|
|
65
|
+
update: StatefulLayout;
|
|
66
66
|
autofocus: string;
|
|
67
67
|
};
|
|
68
68
|
export type StateNodeOptions = Required<StateNodeOptionsBase & {
|
|
@@ -159,8 +159,4 @@ export type FileInputNode = Omit<StateNode, 'children'> & {
|
|
|
159
159
|
layout: FileInput;
|
|
160
160
|
data: object | undefined | null;
|
|
161
161
|
};
|
|
162
|
-
export type MarkdownNode = Omit<StateNode, 'children'> & {
|
|
163
|
-
layout: Markdown;
|
|
164
|
-
data: string | undefined | null;
|
|
165
|
-
};
|
|
166
162
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,IAAI,EACT,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,IAAI,EACT,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAA;AAChC,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AS,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,SAAS,EAAE,CAAA;CAAE,CAAA;AAEhF,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAC;IAAC,QAAQ,EAAE,SAAS,EAAE,CAAC;IAAC,aAAa,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA;AAEtH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,GAAG,EAAE,CAAA;CAAE,CAAA;AAE1F,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAA;CAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc-options.d.ts","sourceRoot":"","sources":["../../src/utils/doc-options.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH,yBAAyB;AACzB,wCA8BC;AAED,yBAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"doc-options.d.ts","sourceRoot":"","sources":["../../src/utils/doc-options.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH,yBAAyB;AACzB,wCA8BC;AAED,yBAAyB;AACzB,wCAoGC;yBAzIY;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,MAAM,EAAE,GAAG,CAAC,CAAA;CAAC,EAAE"}
|