@json-layout/core 0.2.0 → 0.4.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 +1 -2
- package/src/compile/serialize.js +2 -2
- package/src/compile/skeleton-node.js +15 -11
- package/src/compile/types.ts +0 -2
- package/src/i18n/en.js +22 -1
- package/src/i18n/fr.js +22 -1
- package/src/i18n/types.ts +21 -0
- package/src/index.js +1 -0
- package/src/state/index.js +70 -6
- package/src/state/state-node.js +85 -26
- package/src/state/state-tree.js +4 -4
- package/src/state/types.ts +10 -0
- package/src/utils/clone.js +65 -0
- package/types/compile/index.d.ts.map +1 -1
- package/types/compile/skeleton-node.d.ts.map +1 -1
- package/types/compile/types.d.ts +0 -2
- package/types/compile/types.d.ts.map +1 -1
- package/types/i18n/types.d.ts +21 -0
- package/types/i18n/types.d.ts.map +1 -1
- package/types/index.d.ts +1 -0
- package/types/state/index.d.ts +22 -1
- package/types/state/index.d.ts.map +1 -1
- package/types/state/state-node.d.ts.map +1 -1
- package/types/state/state-tree.d.ts +2 -2
- package/types/state/state-tree.d.ts.map +1 -1
- package/types/state/types.d.ts +12 -1
- package/types/state/types.d.ts.map +1 -1
- package/types/utils/clone.d.ts +3 -0
- package/types/utils/clone.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@json-layout/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Compilation and state management utilities for JSON Layout.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/json-layout/json-layout#readme",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@json-layout/vocabulary": "^0.
|
|
50
|
+
"@json-layout/vocabulary": "^0.4.0",
|
|
51
51
|
"@types/markdown-it": "^13.0.1",
|
|
52
52
|
"ajv": "^8.12.0",
|
|
53
53
|
"ajv-errors": "^3.0.0",
|
|
@@ -58,8 +58,7 @@
|
|
|
58
58
|
"magicast": "^0.3.0",
|
|
59
59
|
"markdown-it": "^13.0.2",
|
|
60
60
|
"mitt": "^3.0.1",
|
|
61
|
-
"recast": "^0.23.4"
|
|
62
|
-
"rfdc": "^1.3.0"
|
|
61
|
+
"recast": "^0.23.4"
|
|
63
62
|
},
|
|
64
63
|
"devDependencies": {
|
|
65
64
|
"@types/debug": "^4.1.7",
|
package/src/compile/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// compileStatic is meant to produce a serializable result
|
|
2
2
|
|
|
3
3
|
import ajvModule from 'ajv'
|
|
4
|
-
import rfdc from 'rfdc'
|
|
5
4
|
// import { Parser as ExprEvalParser } from 'expr-eval'
|
|
6
5
|
import addFormats from 'ajv-formats'
|
|
7
6
|
import ajvErrors from 'ajv-errors'
|
|
@@ -10,6 +9,7 @@ import MarkdownIt from 'markdown-it'
|
|
|
10
9
|
import i18n from '../i18n/index.js'
|
|
11
10
|
import { makeSkeletonTree } from './skeleton-tree.js'
|
|
12
11
|
import { resolveRefs } from './utils/resolve-refs.js'
|
|
12
|
+
import clone from '../utils/clone.js'
|
|
13
13
|
|
|
14
14
|
export { resolveRefs } from './utils/resolve-refs.js'
|
|
15
15
|
|
|
@@ -29,7 +29,6 @@ const ajvLocalize = /** @type {typeof ajvLocalizeModule.default} */ (ajvLocalize
|
|
|
29
29
|
|
|
30
30
|
const expressionsParams = ['data', 'options', 'context', 'display']
|
|
31
31
|
|
|
32
|
-
const clone = rfdc()
|
|
33
32
|
// const exprEvalParser = new ExprEvalParser()
|
|
34
33
|
|
|
35
34
|
/**
|
package/src/compile/serialize.js
CHANGED
|
@@ -29,8 +29,8 @@ export function serialize (compiledLayout) {
|
|
|
29
29
|
// some internal imports to ajv are not translated to esm, we do it here
|
|
30
30
|
// cf https://github.com/ajv-validator/ajv-formats/pull/73
|
|
31
31
|
if (code.includes('require("ajv-formats/dist/formats")')) {
|
|
32
|
-
code = 'import
|
|
33
|
-
code = code.replace(/require\("ajv-formats\/dist\/formats"\)\.fullFormats/g, 'fullFormats')
|
|
32
|
+
code = 'import ajvFormats from "ajv-formats/dist/formats.js";\n' + code
|
|
33
|
+
code = code.replace(/require\("ajv-formats\/dist\/formats"\)\.fullFormats/g, 'ajvFormats.fullFormats')
|
|
34
34
|
}
|
|
35
35
|
if (code.includes('require("ajv/dist/runtime/ucs2length")')) {
|
|
36
36
|
code = 'import ucs2length from "ajv/dist/runtime/ucs2length.js";\n' + code
|
|
@@ -55,10 +55,24 @@ export function makeSkeletonNode (
|
|
|
55
55
|
}
|
|
56
56
|
const normalizedLayout = normalizedLayouts[pointer]
|
|
57
57
|
|
|
58
|
+
let defaultData
|
|
59
|
+
if ('default' in schema) defaultData = schema.default
|
|
60
|
+
else if (required) {
|
|
61
|
+
if (schema.type === 'object') defaultData = {}
|
|
62
|
+
if (schema.type === 'array') defaultData = []
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
const compObjects = isSwitchStruct(normalizedLayout) ? normalizedLayout.switch : [normalizedLayout]
|
|
59
66
|
for (const compObject of compObjects) {
|
|
60
67
|
if (schema.description && !compObject.help) compObject.help = schema.description
|
|
61
68
|
if (compObject.if) pushExpression(expressions, compObject.if)
|
|
69
|
+
|
|
70
|
+
if ('const' in schema) compObject.constData = { type: 'js-eval', expr: JSON.stringify(schema.const) }
|
|
71
|
+
if (compObject.constData) pushExpression(expressions, compObject.constData)
|
|
72
|
+
|
|
73
|
+
if (defaultData && !compObject.defaultData) compObject.defaultData = { type: 'js-eval', expr: JSON.stringify(defaultData) }
|
|
74
|
+
if (compObject.defaultData) pushExpression(expressions, compObject.defaultData)
|
|
75
|
+
|
|
62
76
|
if (isItemsLayout(compObject) && compObject.getItems) {
|
|
63
77
|
if (isGetItemsExpression(compObject.getItems)) pushExpression(expressions, compObject.getItems)
|
|
64
78
|
if (isGetItemsFetch(compObject.getItems)) pushExpression(expressions, compObject.getItems.url)
|
|
@@ -70,18 +84,8 @@ export function makeSkeletonNode (
|
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
86
|
|
|
73
|
-
let defaultData
|
|
74
|
-
if (schema.const) defaultData = schema.const
|
|
75
|
-
else if (schema.default) defaultData = schema.default
|
|
76
|
-
if (required) {
|
|
77
|
-
if (schema.type === 'object') defaultData = {} // TODO: this is only true if property is required ?
|
|
78
|
-
if (schema.type === 'array') defaultData = []
|
|
79
|
-
if (schema.type === 'string' && !schema.format) defaultData = ''
|
|
80
|
-
}
|
|
81
|
-
|
|
82
87
|
/** @type {import('./types.js').SkeletonNode} */
|
|
83
|
-
const node = { key: key ?? '', pointer, parentPointer
|
|
84
|
-
if (schema.const) node.const = schema.const
|
|
88
|
+
const node = { key: key ?? '', pointer, parentPointer }
|
|
85
89
|
if (schema.type === 'object') {
|
|
86
90
|
if (schema.properties) {
|
|
87
91
|
node.children = node.children ?? []
|
package/src/compile/types.ts
CHANGED
|
@@ -44,8 +44,6 @@ export interface SkeletonNode {
|
|
|
44
44
|
key: string | number
|
|
45
45
|
pointer: string
|
|
46
46
|
parentPointer: string | null
|
|
47
|
-
defaultData?: unknown
|
|
48
|
-
const?: unknown
|
|
49
47
|
children?: SkeletonNode[] // optional children in the case of arrays and object nodes
|
|
50
48
|
childrenTrees?: SkeletonTree[] // other trees that can be instantiated with separate validation (for example in the case of new array items of oneOfs, etc)
|
|
51
49
|
}
|
package/src/i18n/en.js
CHANGED
|
@@ -7,5 +7,26 @@ export default {
|
|
|
7
7
|
edit: 'Edit',
|
|
8
8
|
duplicate: 'Duplicate',
|
|
9
9
|
sort: 'Sort',
|
|
10
|
-
|
|
10
|
+
up: 'Move up',
|
|
11
|
+
down: 'Move down',
|
|
12
|
+
showHelp: 'Show a help message',
|
|
13
|
+
mdeLink1: '[Link title',
|
|
14
|
+
mdeLink2: '](link url)',
|
|
15
|
+
mdeImg1: '',
|
|
17
|
+
mdeTable1: '',
|
|
18
|
+
mdeTable2: '\n\n| Column 1 | Column 2 | ColoColumnnne 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n',
|
|
19
|
+
bold: 'Bold',
|
|
20
|
+
italic: 'Italic',
|
|
21
|
+
heading: 'Title',
|
|
22
|
+
quote: 'Quote',
|
|
23
|
+
unorderedList: 'Unordered list',
|
|
24
|
+
orderedList: 'Ordered list',
|
|
25
|
+
createLink: 'Create a link',
|
|
26
|
+
insertImage: 'Insert an image',
|
|
27
|
+
createTable: 'Create a table',
|
|
28
|
+
preview: 'Aperçu du rendu',
|
|
29
|
+
mdeGuide: 'Documentation de la syntaxe',
|
|
30
|
+
undo: 'Undo',
|
|
31
|
+
redo: 'Redo'
|
|
11
32
|
}
|
package/src/i18n/fr.js
CHANGED
|
@@ -7,5 +7,26 @@ export default {
|
|
|
7
7
|
edit: 'Éditer',
|
|
8
8
|
duplicate: 'Dupliquer',
|
|
9
9
|
sort: 'Trier',
|
|
10
|
-
|
|
10
|
+
up: 'Décaler vers le haut',
|
|
11
|
+
down: 'Décaler vers le bas',
|
|
12
|
+
showHelp: 'Afficher un message d\'aide',
|
|
13
|
+
mdeLink1: '[titre du lien',
|
|
14
|
+
mdeLink2: '](adresse du lien)',
|
|
15
|
+
mdeImg1: '',
|
|
17
|
+
mdeTable1: '',
|
|
18
|
+
mdeTable2: '\n\n| Colonne 1 | Colonne 2 | Colonne 3 |\n| -------- | -------- | -------- |\n| Texte | Texte | Texte |\n\n',
|
|
19
|
+
bold: 'Gras',
|
|
20
|
+
italic: 'Italique',
|
|
21
|
+
heading: 'Titre',
|
|
22
|
+
quote: 'Citation',
|
|
23
|
+
unorderedList: 'Liste à puce',
|
|
24
|
+
orderedList: 'Liste numérotée',
|
|
25
|
+
createLink: 'Créer un lien',
|
|
26
|
+
insertImage: 'Insérer une image',
|
|
27
|
+
createTable: 'Créer un tableau',
|
|
28
|
+
preview: 'Preview',
|
|
29
|
+
mdeGuide: 'Syntax documentation',
|
|
30
|
+
undo: 'Défaire',
|
|
31
|
+
redo: 'Refaire'
|
|
11
32
|
}
|
package/src/i18n/types.ts
CHANGED
|
@@ -9,7 +9,28 @@ export interface StateOptionsMessages {
|
|
|
9
9
|
edit: string
|
|
10
10
|
duplicate: string
|
|
11
11
|
sort: string
|
|
12
|
+
up: string
|
|
13
|
+
down: string
|
|
12
14
|
showHelp: string
|
|
15
|
+
mdeLink1: string
|
|
16
|
+
mdeLink2: string
|
|
17
|
+
mdeImg1: string
|
|
18
|
+
mdeImg2: string
|
|
19
|
+
mdeTable1: string
|
|
20
|
+
mdeTable2: string
|
|
21
|
+
bold: string
|
|
22
|
+
italic: string
|
|
23
|
+
heading: string
|
|
24
|
+
quote: string
|
|
25
|
+
unorderedList: string
|
|
26
|
+
orderedList: string
|
|
27
|
+
createLink: string
|
|
28
|
+
insertImage: string
|
|
29
|
+
createTable: string
|
|
30
|
+
preview: string
|
|
31
|
+
mdeGuide: string
|
|
32
|
+
undo: string
|
|
33
|
+
redo: string
|
|
13
34
|
}
|
|
14
35
|
|
|
15
36
|
export type LocaleMessages = CompileOptionsMessages & StateOptionsMessages
|
package/src/index.js
CHANGED
package/src/state/index.js
CHANGED
|
@@ -31,6 +31,7 @@ export { Display } from './utils/display.js'
|
|
|
31
31
|
* @typedef {import('./types.js').ExpansionPanelsNode} ExpansionPanelsNode
|
|
32
32
|
* @typedef {import('./types.js').TabsNode} TabsNode
|
|
33
33
|
* @typedef {import('./types.js').VerticalTabsNode} VerticalTabsNode
|
|
34
|
+
* @typedef {import('./types.js').StepperNode} StepperNode
|
|
34
35
|
* @typedef {import('./types.js').OneOfSelectNode} OneOfSelectNode
|
|
35
36
|
* @typedef {import('./types.js').ListNode} ListNode
|
|
36
37
|
*/
|
|
@@ -63,6 +64,8 @@ function fillOptions (partialOptions, compiledLayout) {
|
|
|
63
64
|
titleDepth: 2,
|
|
64
65
|
validateOn: 'input',
|
|
65
66
|
initialValidation: 'withData',
|
|
67
|
+
defaultOn: 'empty',
|
|
68
|
+
autofocus: false,
|
|
66
69
|
...partialOptions,
|
|
67
70
|
messages
|
|
68
71
|
}
|
|
@@ -168,22 +171,36 @@ export class StatefulLayout {
|
|
|
168
171
|
// @ts-ignore
|
|
169
172
|
_lastCreateStateTreeContext
|
|
170
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @private
|
|
176
|
+
* @type {string | null}
|
|
177
|
+
*/
|
|
178
|
+
_autofocusTarget
|
|
179
|
+
/**
|
|
180
|
+
* @private
|
|
181
|
+
* @type {string | null}
|
|
182
|
+
*/
|
|
183
|
+
_previousAutofocusTarget
|
|
184
|
+
|
|
171
185
|
/**
|
|
172
186
|
* @param {import("../index.js").CompiledLayout} compiledLayout
|
|
173
187
|
* @param {import("../index.js").SkeletonTree} skeletonTree
|
|
174
188
|
* @param {Partial<StatefulLayoutOptions>} options
|
|
175
|
-
* @param {unknown} data
|
|
189
|
+
* @param {unknown} [data]
|
|
176
190
|
*/
|
|
177
|
-
constructor (compiledLayout, skeletonTree, options, data
|
|
191
|
+
constructor (compiledLayout, skeletonTree, options, data) {
|
|
178
192
|
this._compiledLayout = compiledLayout
|
|
179
193
|
this.skeletonTree = skeletonTree
|
|
180
194
|
/** @type {import('mitt').Emitter<StatefulLayoutEvents>} */
|
|
181
195
|
this.events = mitt()
|
|
182
196
|
this.prepareOptions(options)
|
|
197
|
+
this._autofocusTarget = this.options.autofocus ? '' : null
|
|
198
|
+
this._previousAutofocusTarget = null
|
|
183
199
|
this._data = data
|
|
184
200
|
this.initValidationState()
|
|
185
201
|
this.activeItems = {}
|
|
186
202
|
this.updateState()
|
|
203
|
+
this.handleAutofocus()
|
|
187
204
|
}
|
|
188
205
|
|
|
189
206
|
/**
|
|
@@ -212,10 +229,11 @@ export class StatefulLayout {
|
|
|
212
229
|
*/
|
|
213
230
|
updateState () {
|
|
214
231
|
this.createStateTree()
|
|
215
|
-
if (this._data !== this._stateTree.root.data) {
|
|
232
|
+
if (this._data !== this._stateTree.root.data || this._autofocusTarget !== this._lastCreateStateTreeContext.autofocusTarget) {
|
|
216
233
|
logDataBinding('hydrating state tree changed the data, do it again', this._data, this._stateTree.root.data)
|
|
217
234
|
// this is necessary because a first hydration can add default values and change validity, etc
|
|
218
235
|
this._data = this._stateTree.root.data
|
|
236
|
+
this._autofocusTarget = this._lastCreateStateTreeContext.autofocusTarget
|
|
219
237
|
this.createStateTree()
|
|
220
238
|
}
|
|
221
239
|
logDataBinding('emit update event', this._data, this._stateTree)
|
|
@@ -227,7 +245,12 @@ export class StatefulLayout {
|
|
|
227
245
|
*/
|
|
228
246
|
createStateTree () {
|
|
229
247
|
/** @type {CreateStateTreeContext} */
|
|
230
|
-
const createStateTreeContext = {
|
|
248
|
+
const createStateTreeContext = {
|
|
249
|
+
nodes: [],
|
|
250
|
+
activeItems: this.activeItems,
|
|
251
|
+
autofocusTarget: this._autofocusTarget,
|
|
252
|
+
initial: !this._lastCreateStateTreeContext
|
|
253
|
+
}
|
|
231
254
|
this._stateTree = createStateTree(
|
|
232
255
|
createStateTreeContext,
|
|
233
256
|
this._options,
|
|
@@ -240,7 +263,11 @@ export class StatefulLayout {
|
|
|
240
263
|
)
|
|
241
264
|
this._lastCreateStateTreeContext = createStateTreeContext
|
|
242
265
|
if (!this.validationState.initialized) {
|
|
243
|
-
this.
|
|
266
|
+
this._validationState = {
|
|
267
|
+
initialized: true,
|
|
268
|
+
validatedForm: this._validationState.validatedForm,
|
|
269
|
+
validatedChildren: createStateTreeContext.nodes.filter(n => n.validated).map(n => n.fullKey)
|
|
270
|
+
}
|
|
244
271
|
}
|
|
245
272
|
}
|
|
246
273
|
|
|
@@ -260,6 +287,13 @@ export class StatefulLayout {
|
|
|
260
287
|
return this.stateTree.valid
|
|
261
288
|
}
|
|
262
289
|
|
|
290
|
+
/**
|
|
291
|
+
* @returns {string[]}
|
|
292
|
+
*/
|
|
293
|
+
get errors () {
|
|
294
|
+
return this._lastCreateStateTreeContext.nodes.filter(n => !!n.error).map(n => /** @type {string} */(n.error))
|
|
295
|
+
}
|
|
296
|
+
|
|
263
297
|
/**
|
|
264
298
|
* @returns {boolean}
|
|
265
299
|
*/
|
|
@@ -279,6 +313,7 @@ export class StatefulLayout {
|
|
|
279
313
|
}
|
|
280
314
|
if (activateKey !== undefined) {
|
|
281
315
|
this.activeItems[node.fullKey] = activateKey
|
|
316
|
+
this._autofocusTarget = node.fullKey + '/' + activateKey
|
|
282
317
|
}
|
|
283
318
|
if (node.parentFullKey === null) {
|
|
284
319
|
this.data = data
|
|
@@ -289,6 +324,10 @@ export class StatefulLayout {
|
|
|
289
324
|
if (!parentNode) throw new Error(`parent with key "${node.parentFullKey}" not found`)
|
|
290
325
|
const newParentValue = producePatchedData(parentNode.data ?? {}, node, data)
|
|
291
326
|
this.input(parentNode, newParentValue)
|
|
327
|
+
|
|
328
|
+
if (activateKey !== undefined) {
|
|
329
|
+
this.handleAutofocus()
|
|
330
|
+
}
|
|
292
331
|
}
|
|
293
332
|
|
|
294
333
|
/**
|
|
@@ -304,6 +343,18 @@ export class StatefulLayout {
|
|
|
304
343
|
}
|
|
305
344
|
}
|
|
306
345
|
|
|
346
|
+
/**
|
|
347
|
+
* @param {StateNode} node
|
|
348
|
+
*/
|
|
349
|
+
validateNodeRecurse (node) {
|
|
350
|
+
this.validationState = { validatedChildren: this.validationState.validatedChildren.concat([node.fullKey]) }
|
|
351
|
+
if (node.children) {
|
|
352
|
+
for (const child of node.children) {
|
|
353
|
+
this.validateNodeRecurse(child)
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
307
358
|
/**
|
|
308
359
|
* @private
|
|
309
360
|
* @param {StateNode} node
|
|
@@ -393,11 +444,13 @@ export class StatefulLayout {
|
|
|
393
444
|
*/
|
|
394
445
|
activateItem (node, key) {
|
|
395
446
|
this.activeItems[node.fullKey] = key
|
|
447
|
+
this._autofocusTarget = node.fullKey + '/' + key
|
|
396
448
|
if (node.key === '$oneOf') {
|
|
397
|
-
this.input(node,
|
|
449
|
+
this.input(node, undefined)
|
|
398
450
|
} else {
|
|
399
451
|
this.updateState()
|
|
400
452
|
}
|
|
453
|
+
this.handleAutofocus()
|
|
401
454
|
}
|
|
402
455
|
|
|
403
456
|
/**
|
|
@@ -407,4 +460,15 @@ export class StatefulLayout {
|
|
|
407
460
|
delete this.activeItems[node.fullKey]
|
|
408
461
|
this.updateState()
|
|
409
462
|
}
|
|
463
|
+
|
|
464
|
+
handleAutofocus () {
|
|
465
|
+
const autofocusTarget = this._autofocusTarget
|
|
466
|
+
if (autofocusTarget !== null && this._autofocusTarget !== this._previousAutofocusTarget) {
|
|
467
|
+
this._previousAutofocusTarget = autofocusTarget
|
|
468
|
+
setTimeout(() => {
|
|
469
|
+
logDataBinding('emit autofocus event', autofocusTarget)
|
|
470
|
+
this.events.emit('autofocus', autofocusTarget)
|
|
471
|
+
})
|
|
472
|
+
}
|
|
473
|
+
}
|
|
410
474
|
}
|
package/src/state/state-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSwitchStruct, childIsCompObject, isCompositeLayout } from '@json-layout/vocabulary'
|
|
1
|
+
import { isSwitchStruct, childIsCompObject, isCompositeLayout, isFocusableLayout } from '@json-layout/vocabulary'
|
|
2
2
|
import { produce } from 'immer'
|
|
3
3
|
import { getChildDisplay } from './utils/display.js'
|
|
4
4
|
import { shallowCompareArrays } from './utils/immutable.js'
|
|
@@ -10,18 +10,25 @@ import { shallowCompareArrays } from './utils/immutable.js'
|
|
|
10
10
|
const isDataEmpty = (data) => {
|
|
11
11
|
if (data === '' || data === undefined) return true
|
|
12
12
|
if (Array.isArray(data) && !data.length) return true
|
|
13
|
-
if (typeof data === 'object' && !Array.isArray(data) && !!data && Object.values(data).findIndex(prop =>
|
|
13
|
+
if (typeof data === 'object' && !Array.isArray(data) && !!data && Object.values(data).findIndex(prop => prop !== undefined) === -1) return true
|
|
14
14
|
return false
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @param {unknown} data
|
|
19
|
+
* @param {import('@json-layout/vocabulary').CompObject} layout
|
|
20
|
+
* @param {import('./types.js').StatefulLayoutOptions} options
|
|
21
|
+
* @returns {boolean}
|
|
22
|
+
*/
|
|
23
|
+
const useDefaultData = (data, layout, options) => {
|
|
24
|
+
if (options.defaultOn === 'missing' && data === undefined) return true
|
|
25
|
+
if (options.defaultOn === 'empty' && isDataEmpty(data)) return true
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
24
28
|
|
|
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').CompObject, cols: number, data: unknown, error: string | undefined, validated: boolean, options: import('./types.js').StatefulLayoutOptions, autofocus: boolean, children: import('../index.js').StateNode[] | undefined) => import('../index.js').StateNode} */
|
|
31
|
+
const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath, parentDataPath, skeleton, layout, cols, data, error, validated, options, autofocus, children) => {
|
|
25
32
|
draft.messages = layout.messages ? produceStateNodeMessages(draft.messages || {}, layout.messages, options) : options.messages
|
|
26
33
|
|
|
27
34
|
draft.key = key
|
|
@@ -37,6 +44,16 @@ const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath,
|
|
|
37
44
|
draft.error = error
|
|
38
45
|
draft.childError = children && (children.findIndex(c => c.error || c.childError) !== -1)
|
|
39
46
|
draft.validated = validated
|
|
47
|
+
if (autofocus) {
|
|
48
|
+
draft.autofocus = true
|
|
49
|
+
delete draft.autofocusChild
|
|
50
|
+
} else {
|
|
51
|
+
delete draft.autofocus
|
|
52
|
+
const autofocusChild = children?.find(c => c.autofocus)
|
|
53
|
+
if (autofocusChild) draft.autofocusChild = autofocusChild.key
|
|
54
|
+
else delete draft.autofocusChild
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
draft.children = children
|
|
41
58
|
})
|
|
42
59
|
|
|
@@ -196,32 +213,43 @@ export function createStateNode (
|
|
|
196
213
|
display.width
|
|
197
214
|
)
|
|
198
215
|
|
|
216
|
+
if (context.initial && parentOptions.autofocus && layout.autofocus) {
|
|
217
|
+
context.autofocusTarget = fullKey
|
|
218
|
+
}
|
|
219
|
+
|
|
199
220
|
/** @type {import('./types.js').StateNode[] | undefined} */
|
|
200
221
|
let children
|
|
201
222
|
if (isCompositeLayout(layout)) {
|
|
202
223
|
// TODO: make this type casting safe using prior validation
|
|
203
224
|
const objectData = /** @type {Record<string, unknown>} */(data ?? {})
|
|
204
225
|
const childrenOptions = produceCompositeChildrenOptions(options, layout)
|
|
205
|
-
children =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
226
|
+
children = []
|
|
227
|
+
let focusChild = context.autofocusTarget === fullKey
|
|
228
|
+
for (let i = 0; i < layout.children.length; i++) {
|
|
229
|
+
const childLayout = layout.children[i]
|
|
230
|
+
const childSkeleton = skeleton.children?.find(c => c.key === childLayout.key) ?? skeleton
|
|
231
|
+
const isSameData = typeof childLayout.key === 'string' && childLayout.key.startsWith('$')
|
|
232
|
+
const childFullKey = `${fullKey}/${childLayout.key}`
|
|
233
|
+
if (focusChild) context.autofocusTarget = childFullKey
|
|
234
|
+
const child = createStateNode(
|
|
209
235
|
context,
|
|
210
236
|
childrenOptions,
|
|
211
237
|
compiledLayout,
|
|
212
|
-
|
|
213
|
-
|
|
238
|
+
childLayout.key,
|
|
239
|
+
childFullKey,
|
|
214
240
|
fullKey,
|
|
215
|
-
isSameData ? dataPath : `${dataPath}/${
|
|
241
|
+
isSameData ? dataPath : `${dataPath}/${childLayout.key}`,
|
|
216
242
|
dataPath,
|
|
217
243
|
childSkeleton,
|
|
218
|
-
|
|
244
|
+
childLayout,
|
|
219
245
|
display,
|
|
220
|
-
isSameData ? objectData : objectData[
|
|
246
|
+
isSameData ? objectData : objectData[childLayout.key],
|
|
221
247
|
validationState,
|
|
222
248
|
reusedNode?.children?.[i]
|
|
223
249
|
)
|
|
224
|
-
|
|
250
|
+
if (child.autofocus || child.autofocusChild !== undefined) focusChild = false
|
|
251
|
+
children.push(child)
|
|
252
|
+
}
|
|
225
253
|
}
|
|
226
254
|
|
|
227
255
|
if (key === '$oneOf' && skeleton.childrenTrees) {
|
|
@@ -230,6 +258,8 @@ export function createStateNode (
|
|
|
230
258
|
const activeChildTreeIndex = fullKey in context.activeItems ? context.activeItems[fullKey] : skeleton.childrenTrees?.findIndex((childTree) => compiledLayout.validates[childTree.root.pointer](data))
|
|
231
259
|
if (activeChildTreeIndex !== -1) {
|
|
232
260
|
context.activeItems[fullKey] = activeChildTreeIndex
|
|
261
|
+
const activeChildKey = `${fullKey}/${activeChildTreeIndex}`
|
|
262
|
+
if (context.autofocusTarget === fullKey) context.autofocusTarget = activeChildKey
|
|
233
263
|
const activeChildTree = skeleton.childrenTrees[activeChildTreeIndex]
|
|
234
264
|
children = [
|
|
235
265
|
createStateNode(
|
|
@@ -237,7 +267,7 @@ export function createStateNode (
|
|
|
237
267
|
options,
|
|
238
268
|
compiledLayout,
|
|
239
269
|
activeChildTreeIndex,
|
|
240
|
-
|
|
270
|
+
activeChildKey,
|
|
241
271
|
fullKey,
|
|
242
272
|
dataPath,
|
|
243
273
|
dataPath,
|
|
@@ -256,9 +286,13 @@ export function createStateNode (
|
|
|
256
286
|
const arrayData = /** @type {unknown[]} */(data ?? [])
|
|
257
287
|
const childSkeleton = /** @type {import('../index.js').SkeletonNode} */(skeleton?.childrenTrees?.[0]?.root)
|
|
258
288
|
const listItemOptions = layout.listEditMode === 'inline' ? options : produceReadonlyArrayItemOptions(options)
|
|
259
|
-
children =
|
|
289
|
+
children = []
|
|
290
|
+
let focusChild = context.autofocusTarget === fullKey
|
|
291
|
+
for (let i = 0; i < arrayData.length; i++) {
|
|
292
|
+
const itemData = arrayData[i]
|
|
260
293
|
const childFullKey = `${fullKey}/${i}`
|
|
261
|
-
|
|
294
|
+
if (focusChild) context.autofocusTarget = childFullKey
|
|
295
|
+
const child = createStateNode(
|
|
262
296
|
context,
|
|
263
297
|
(layout.listEditMode === 'inline-single' && context.activeItems[fullKey] === i) ? options : listItemOptions,
|
|
264
298
|
compiledLayout,
|
|
@@ -274,7 +308,9 @@ export function createStateNode (
|
|
|
274
308
|
validationState,
|
|
275
309
|
reusedNode?.children?.[0]
|
|
276
310
|
)
|
|
277
|
-
|
|
311
|
+
if (child.autofocus || child.autofocusChild !== undefined) focusChild = false
|
|
312
|
+
children.push(child)
|
|
313
|
+
}
|
|
278
314
|
}
|
|
279
315
|
|
|
280
316
|
const error = context.errors?.find(error => matchError(error, skeleton, dataPath, parentDataPath)) ?? context.errors?.find(error => matchChildError(error, skeleton, dataPath))
|
|
@@ -287,6 +323,29 @@ export function createStateNode (
|
|
|
287
323
|
(validationState.initialized === false && options.initialValidation === 'always') ||
|
|
288
324
|
(validationState.initialized === false && options.initialValidation === 'withData' && !isDataEmpty(data))
|
|
289
325
|
|
|
326
|
+
let nodeData = children ? produceStateNodeData(/** @type {Record<string, unknown>} */(data ?? {}), dataPath, children) : data
|
|
327
|
+
if (layout.constData) {
|
|
328
|
+
nodeData = evalExpression(compiledLayout.expressions, layout.constData, nodeData, options, display)
|
|
329
|
+
} else {
|
|
330
|
+
if (layout.defaultData && useDefaultData(nodeData, layout, options)) {
|
|
331
|
+
nodeData = evalExpression(compiledLayout.expressions, layout.defaultData, nodeData, options, display)
|
|
332
|
+
} else {
|
|
333
|
+
if (isDataEmpty(nodeData)) {
|
|
334
|
+
if (layout.nullable) {
|
|
335
|
+
// if a property is nullable empty values are converted to null
|
|
336
|
+
// except for undefined if we need to distinguish between empty and missing data
|
|
337
|
+
if (options.defaultOn !== 'missing' || nodeData !== undefined) {
|
|
338
|
+
nodeData = null
|
|
339
|
+
}
|
|
340
|
+
} else if (options.defaultOn !== 'missing') {
|
|
341
|
+
// remove empty data, except if we need to distinguish between empty and missing data
|
|
342
|
+
nodeData = undefined
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const autofocus = isFocusableLayout(layout) && !options.readOnly && !options.summary && context.autofocusTarget === fullKey
|
|
290
349
|
const node = produceStateNode(
|
|
291
350
|
reusedNode ?? /** @type {import('./types.js').StateNode} */({}),
|
|
292
351
|
key,
|
|
@@ -297,10 +356,11 @@ export function createStateNode (
|
|
|
297
356
|
skeleton,
|
|
298
357
|
layout,
|
|
299
358
|
cols,
|
|
300
|
-
|
|
359
|
+
nodeData,
|
|
301
360
|
error?.message,
|
|
302
361
|
validated,
|
|
303
362
|
options,
|
|
363
|
+
autofocus,
|
|
304
364
|
children && shallowCompareArrays(reusedNode?.children, children)
|
|
305
365
|
)
|
|
306
366
|
context.nodes.push(node)
|
|
@@ -314,5 +374,4 @@ export const producePatchedData = produce((draft, node, data) => {
|
|
|
314
374
|
} else {
|
|
315
375
|
draft[node.key] = data
|
|
316
376
|
}
|
|
317
|
-
}
|
|
318
|
-
)
|
|
377
|
+
})
|
package/src/state/state-tree.js
CHANGED
|
@@ -15,7 +15,7 @@ const produceStateTree = produce(
|
|
|
15
15
|
* @param {import('../index.js').CompiledLayout} compiledLayout
|
|
16
16
|
* @param {import('../index.js').SkeletonTree} skeleton
|
|
17
17
|
* @param {import('./utils/display.js').Display} display
|
|
18
|
-
* @param {unknown}
|
|
18
|
+
* @param {unknown} data
|
|
19
19
|
* @param {import('./types.js').ValidationState} validationState
|
|
20
20
|
* @param {import('./types.js').StateTree} [reusedStateTree]
|
|
21
21
|
* @returns {import('./types.js').StateTree}
|
|
@@ -26,12 +26,12 @@ export function createStateTree (
|
|
|
26
26
|
compiledLayout,
|
|
27
27
|
skeleton,
|
|
28
28
|
display,
|
|
29
|
-
|
|
29
|
+
data,
|
|
30
30
|
validationState,
|
|
31
31
|
reusedStateTree
|
|
32
32
|
) {
|
|
33
33
|
const validate = compiledLayout.validates[skeleton.root.pointer]
|
|
34
|
-
const valid = validate(
|
|
34
|
+
const valid = validate(data)
|
|
35
35
|
if (validate.errors) {
|
|
36
36
|
for (const error of validate.errors) {
|
|
37
37
|
if (error.keyword !== 'errorMessage') compiledLayout.localizeErrors([error])
|
|
@@ -50,7 +50,7 @@ export function createStateTree (
|
|
|
50
50
|
skeleton.root,
|
|
51
51
|
null,
|
|
52
52
|
display,
|
|
53
|
-
|
|
53
|
+
data,
|
|
54
54
|
validationState,
|
|
55
55
|
reusedStateTree?.root
|
|
56
56
|
)
|
package/src/state/types.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type Tabs,
|
|
21
21
|
type VerticalTabs,
|
|
22
22
|
type ExpansionPanels,
|
|
23
|
+
type Stepper,
|
|
23
24
|
type List,
|
|
24
25
|
type Combobox
|
|
25
26
|
} from '@json-layout/vocabulary'
|
|
@@ -41,6 +42,8 @@ export interface StateNode {
|
|
|
41
42
|
validated: boolean
|
|
42
43
|
options: StatefulLayoutOptions
|
|
43
44
|
messages: LocaleMessages
|
|
45
|
+
autofocus?: boolean
|
|
46
|
+
autofocusChild?: string | number
|
|
44
47
|
children?: StateNode[]
|
|
45
48
|
}
|
|
46
49
|
|
|
@@ -54,6 +57,8 @@ export interface CreateStateTreeContext {
|
|
|
54
57
|
errors?: ErrorObject[]
|
|
55
58
|
nodes: StateNode[]
|
|
56
59
|
activeItems: Record<string, number>
|
|
60
|
+
autofocusTarget: string | null
|
|
61
|
+
initial: boolean
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
export interface ValidationState {
|
|
@@ -67,6 +72,7 @@ export type StatefulLayoutEvents = {
|
|
|
67
72
|
// input: { value: unknown, child: { pointer: string, dataPointer: string, value: unknown } }
|
|
68
73
|
input: unknown
|
|
69
74
|
'update': StatefulLayout
|
|
75
|
+
autofocus: string
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
export type StatefulLayoutOptions = Required<StateNodeOptions> & {
|
|
@@ -74,7 +80,9 @@ export type StatefulLayoutOptions = Required<StateNodeOptions> & {
|
|
|
74
80
|
width: number
|
|
75
81
|
validateOn: 'input' | 'blur' | 'submit'
|
|
76
82
|
initialValidation: 'never' | 'always' | 'withData'
|
|
83
|
+
defaultOn: 'missing' | 'empty' | 'never'
|
|
77
84
|
messages: LocaleMessages
|
|
85
|
+
autofocus: boolean
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
export type TextFieldNode = Omit<StateNode, 'children'> & { layout: TextField, data: string | undefined | null }
|
|
@@ -111,6 +119,8 @@ export type VerticalTabsNode = StateNode & { layout: VerticalTabs, children: Sta
|
|
|
111
119
|
|
|
112
120
|
export type ExpansionPanelsNode = StateNode & { layout: ExpansionPanels, children: StateNode[] }
|
|
113
121
|
|
|
122
|
+
export type StepperNode = StateNode & { layout: Stepper, children: StateNode[] }
|
|
123
|
+
|
|
114
124
|
export type ListNode = StateNode & { layout: List, data: any[], children: StateNode[], childrenTrees: SkeletonTree[] }
|
|
115
125
|
|
|
116
126
|
export type ComboboxNode = Omit<StateNode, 'children'> & { layout: Combobox, data: any[] }
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* eslint-disable jsdoc/require-jsdoc */
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
|
|
4
|
+
// a copy of https://github.com/davidmarkclements/rfdc/blob/master/index.js
|
|
5
|
+
// but lighter and with ESM export
|
|
6
|
+
|
|
7
|
+
function copyBuffer (cur) {
|
|
8
|
+
if (cur instanceof Buffer) {
|
|
9
|
+
return Buffer.from(cur)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return new cur.constructor(cur.buffer.slice(), cur.byteOffset, cur.length)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function rfdc () {
|
|
16
|
+
return clone
|
|
17
|
+
|
|
18
|
+
function cloneArray (a, fn) {
|
|
19
|
+
const keys = Object.keys(a)
|
|
20
|
+
const a2 = new Array(keys.length)
|
|
21
|
+
for (let i = 0; i < keys.length; i++) {
|
|
22
|
+
const k = keys[i]
|
|
23
|
+
const cur = a[k]
|
|
24
|
+
if (typeof cur !== 'object' || cur === null) {
|
|
25
|
+
a2[k] = cur
|
|
26
|
+
} else if (cur instanceof Date) {
|
|
27
|
+
a2[k] = new Date(cur)
|
|
28
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
29
|
+
a2[k] = copyBuffer(cur)
|
|
30
|
+
} else {
|
|
31
|
+
a2[k] = fn(cur)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return a2
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function clone (o) {
|
|
38
|
+
if (typeof o !== 'object' || o === null) return o
|
|
39
|
+
if (o instanceof Date) return new Date(o)
|
|
40
|
+
if (Array.isArray(o)) return cloneArray(o, clone)
|
|
41
|
+
if (o instanceof Map) return new Map(cloneArray(Array.from(o), clone))
|
|
42
|
+
if (o instanceof Set) return new Set(cloneArray(Array.from(o), clone))
|
|
43
|
+
const o2 = {}
|
|
44
|
+
for (const k in o) {
|
|
45
|
+
if (Object.hasOwnProperty.call(o, k) === false) continue
|
|
46
|
+
const cur = o[k]
|
|
47
|
+
if (typeof cur !== 'object' || cur === null) {
|
|
48
|
+
o2[k] = cur
|
|
49
|
+
} else if (cur instanceof Date) {
|
|
50
|
+
o2[k] = new Date(cur)
|
|
51
|
+
} else if (cur instanceof Map) {
|
|
52
|
+
o2[k] = new Map(cloneArray(Array.from(cur), clone))
|
|
53
|
+
} else if (cur instanceof Set) {
|
|
54
|
+
o2[k] = new Set(cloneArray(Array.from(cur), clone))
|
|
55
|
+
} else if (ArrayBuffer.isView(cur)) {
|
|
56
|
+
o2[k] = copyBuffer(cur)
|
|
57
|
+
} else {
|
|
58
|
+
o2[k] = clone(cur)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return o2
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default rfdc()
|
|
@@ -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":"AAqEA;;;;GAIG;AACH,iCAJW,MAAM,4EAEJ,cAAc,CA0E1B;;2BAlIY,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":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;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":"AAkBA;;;;;;;;;;;;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,M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E,CAAA;IACzB,aAAa,CAAC,EAAE,YAAY,EAAE,CAAA;CAC/B"}
|
package/types/i18n/types.d.ts
CHANGED
|
@@ -8,7 +8,28 @@ export interface StateOptionsMessages {
|
|
|
8
8
|
edit: string;
|
|
9
9
|
duplicate: string;
|
|
10
10
|
sort: string;
|
|
11
|
+
up: string;
|
|
12
|
+
down: string;
|
|
11
13
|
showHelp: string;
|
|
14
|
+
mdeLink1: string;
|
|
15
|
+
mdeLink2: string;
|
|
16
|
+
mdeImg1: string;
|
|
17
|
+
mdeImg2: string;
|
|
18
|
+
mdeTable1: string;
|
|
19
|
+
mdeTable2: string;
|
|
20
|
+
bold: string;
|
|
21
|
+
italic: string;
|
|
22
|
+
heading: string;
|
|
23
|
+
quote: string;
|
|
24
|
+
unorderedList: string;
|
|
25
|
+
orderedList: string;
|
|
26
|
+
createLink: string;
|
|
27
|
+
insertImage: string;
|
|
28
|
+
createTable: string;
|
|
29
|
+
preview: string;
|
|
30
|
+
mdeGuide: string;
|
|
31
|
+
undo: string;
|
|
32
|
+
redo: string;
|
|
12
33
|
}
|
|
13
34
|
export type LocaleMessages = CompileOptionsMessages & StateOptionsMessages;
|
|
14
35
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i18n/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,MAAM,cAAc,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
|
package/types/index.d.ts
CHANGED
package/types/state/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export { Display } from "./utils/display.js";
|
|
|
22
22
|
* @typedef {import('./types.js').ExpansionPanelsNode} ExpansionPanelsNode
|
|
23
23
|
* @typedef {import('./types.js').TabsNode} TabsNode
|
|
24
24
|
* @typedef {import('./types.js').VerticalTabsNode} VerticalTabsNode
|
|
25
|
+
* @typedef {import('./types.js').StepperNode} StepperNode
|
|
25
26
|
* @typedef {import('./types.js').OneOfSelectNode} OneOfSelectNode
|
|
26
27
|
* @typedef {import('./types.js').ListNode} ListNode
|
|
27
28
|
*/
|
|
@@ -34,7 +35,7 @@ export class StatefulLayout {
|
|
|
34
35
|
* @param {import("../index.js").CompiledLayout} compiledLayout
|
|
35
36
|
* @param {import("../index.js").SkeletonTree} skeletonTree
|
|
36
37
|
* @param {Partial<StatefulLayoutOptions>} options
|
|
37
|
-
* @param {unknown} data
|
|
38
|
+
* @param {unknown} [data]
|
|
38
39
|
*/
|
|
39
40
|
constructor(compiledLayout: import("../index.js").CompiledLayout, skeletonTree: import("../index.js").SkeletonTree, options: Partial<StatefulLayoutOptions>, data?: unknown);
|
|
40
41
|
/**
|
|
@@ -105,6 +106,16 @@ export class StatefulLayout {
|
|
|
105
106
|
* @type {CreateStateTreeContext}
|
|
106
107
|
*/
|
|
107
108
|
private _lastCreateStateTreeContext;
|
|
109
|
+
/**
|
|
110
|
+
* @private
|
|
111
|
+
* @type {string | null}
|
|
112
|
+
*/
|
|
113
|
+
private _autofocusTarget;
|
|
114
|
+
/**
|
|
115
|
+
* @private
|
|
116
|
+
* @type {string | null}
|
|
117
|
+
*/
|
|
118
|
+
private _previousAutofocusTarget;
|
|
108
119
|
/**
|
|
109
120
|
* @type {Record<string, number>}
|
|
110
121
|
*/
|
|
@@ -132,6 +143,10 @@ export class StatefulLayout {
|
|
|
132
143
|
* @returns {boolean}
|
|
133
144
|
*/
|
|
134
145
|
get valid(): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* @returns {string[]}
|
|
148
|
+
*/
|
|
149
|
+
get errors(): string[];
|
|
135
150
|
/**
|
|
136
151
|
* @returns {boolean}
|
|
137
152
|
*/
|
|
@@ -146,6 +161,10 @@ export class StatefulLayout {
|
|
|
146
161
|
* @param {StateNode} node
|
|
147
162
|
*/
|
|
148
163
|
blur(node: StateNode): void;
|
|
164
|
+
/**
|
|
165
|
+
* @param {StateNode} node
|
|
166
|
+
*/
|
|
167
|
+
validateNodeRecurse(node: StateNode): void;
|
|
149
168
|
/**
|
|
150
169
|
* @private
|
|
151
170
|
* @param {StateNode} node
|
|
@@ -168,6 +187,7 @@ export class StatefulLayout {
|
|
|
168
187
|
* @param {StateNode} node
|
|
169
188
|
*/
|
|
170
189
|
deactivateItem(node: StateNode): void;
|
|
190
|
+
handleAutofocus(): void;
|
|
171
191
|
}
|
|
172
192
|
export type StateNode = import('./types.js').StateNode;
|
|
173
193
|
export type StateTree = import('./types.js').StateTree;
|
|
@@ -191,6 +211,7 @@ export type TimePickerNode = import('./types.js').TimePickerNode;
|
|
|
191
211
|
export type ExpansionPanelsNode = import('./types.js').ExpansionPanelsNode;
|
|
192
212
|
export type TabsNode = import('./types.js').TabsNode;
|
|
193
213
|
export type VerticalTabsNode = import('./types.js').VerticalTabsNode;
|
|
214
|
+
export type StepperNode = import('./types.js').StepperNode;
|
|
194
215
|
export type OneOfSelectNode = import('./types.js').OneOfSelectNode;
|
|
195
216
|
export type ListNode = import('./types.js').ListNode;
|
|
196
217
|
import { Display } from './utils/display.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAUA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,mEAAmE;AACnE,+BADkB,SAAS,GAAG,SAAS,8CACoC;AAE3E,oGAAoG;AACpG,iCADkB,SAAS,GAAG,SAAS,yHACkC;AA+BzE;IA+GE;;;;;OAKG;IACH,4BALW,OAAO,aAAa,EAAE,cAAc,gBACpC,OAAO,aAAa,EAAE,YAAY,WAClC,QAAQ,qBAAqB,CAAC,SAC9B,OAAO,EAejB;IAjID;;;OAGG;IACH,iBAFU,OAAO,MAAM,EAAE,OAAO,CAA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AAO,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;wBA9BlB,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAoIA;;;;;;;GAOG;AACH,4CAPW,OAAO,aAAa,EAAE,kBAAkB,EAAE,cAC1C,OAAO,yBAAyB,EAAE,UAAU,QAC5C,GAAG,WACH,OAAO,YAAY,EAAE,qBAAqB,WAC1C,OAAO,oBAAoB,EAAE,OAAO,GAClC,GAAG,CAOf;AAuBD;;;;;;;;;;;;;;;;;GAiBG;AACH,yCAhBW,OAAO,YAAY,EAAE,sBAAsB,iBAC3C,OAAO,YAAY,EAAE,qBAAqB,kBAC1C,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,mBACP,OAAO,YAAY,EAAE,eAAe,4DAElC,OAAO,YAAY,EAAE,SAAS,CAuL1C;AAED,uFAAuF;AACvF,yCADmB,GAAG,QAAQ,OAAO,YAAY,EAAE,SAAS,QAAQ,OAAO,KAAK,GAAG,CAOjF"}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* @param {import('../index.js').CompiledLayout} compiledLayout
|
|
5
5
|
* @param {import('../index.js').SkeletonTree} skeleton
|
|
6
6
|
* @param {import('./utils/display.js').Display} display
|
|
7
|
-
* @param {unknown}
|
|
7
|
+
* @param {unknown} data
|
|
8
8
|
* @param {import('./types.js').ValidationState} validationState
|
|
9
9
|
* @param {import('./types.js').StateTree} [reusedStateTree]
|
|
10
10
|
* @returns {import('./types.js').StateTree}
|
|
11
11
|
*/
|
|
12
|
-
export function createStateTree(context: import('./types.js').CreateStateTreeContext, options: import('./types.js').StatefulLayoutOptions, compiledLayout: import('../index.js').CompiledLayout, skeleton: import('../index.js').SkeletonTree, display: import('./utils/display.js').Display,
|
|
12
|
+
export function createStateTree(context: import('./types.js').CreateStateTreeContext, options: import('./types.js').StatefulLayoutOptions, compiledLayout: import('../index.js').CompiledLayout, skeleton: import('../index.js').SkeletonTree, display: import('./utils/display.js').Display, data: unknown, validationState: import('./types.js').ValidationState, reusedStateTree?: import("./types.js").StateTree | undefined): import('./types.js').StateTree;
|
|
13
13
|
//# sourceMappingURL=state-tree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-tree.d.ts","sourceRoot":"","sources":["../../src/state/state-tree.js"],"names":[],"mappings":"AAWA;;;;;;;;;;GAUG;AACH,yCAVW,OAAO,YAAY,EAAE,sBAAsB,WAC3C,OAAO,YAAY,EAAE,qBAAqB,kBAC1C,OAAO,aAAa,EAAE,cAAc,YACpC,OAAO,aAAa,EAAE,YAAY,WAClC,OAAO,oBAAoB,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"state-tree.d.ts","sourceRoot":"","sources":["../../src/state/state-tree.js"],"names":[],"mappings":"AAWA;;;;;;;;;;GAUG;AACH,yCAVW,OAAO,YAAY,EAAE,sBAAsB,WAC3C,OAAO,YAAY,EAAE,qBAAqB,kBAC1C,OAAO,aAAa,EAAE,cAAc,YACpC,OAAO,aAAa,EAAE,YAAY,WAClC,OAAO,oBAAoB,EAAE,OAAO,QACpC,OAAO,mBACP,OAAO,YAAY,EAAE,eAAe,iEAElC,OAAO,YAAY,EAAE,SAAS,CAsC1C"}
|
package/types/state/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ErrorObject } from 'ajv';
|
|
2
|
-
import { type CompObject, type Cols, type StateNodeOptions, 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 List, type Combobox } from '@json-layout/vocabulary';
|
|
2
|
+
import { type CompObject, type Cols, type StateNodeOptions, 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 } from '@json-layout/vocabulary';
|
|
3
3
|
import { type SkeletonTree, type SkeletonNode, type StatefulLayout } from '../index.js';
|
|
4
4
|
import { type LocaleMessages } from '../i18n/types.js';
|
|
5
5
|
export interface StateNode {
|
|
@@ -17,6 +17,8 @@ export interface StateNode {
|
|
|
17
17
|
validated: boolean;
|
|
18
18
|
options: StatefulLayoutOptions;
|
|
19
19
|
messages: LocaleMessages;
|
|
20
|
+
autofocus?: boolean;
|
|
21
|
+
autofocusChild?: string | number;
|
|
20
22
|
children?: StateNode[];
|
|
21
23
|
}
|
|
22
24
|
export interface StateTree {
|
|
@@ -28,6 +30,8 @@ export interface CreateStateTreeContext {
|
|
|
28
30
|
errors?: ErrorObject[];
|
|
29
31
|
nodes: StateNode[];
|
|
30
32
|
activeItems: Record<string, number>;
|
|
33
|
+
autofocusTarget: string | null;
|
|
34
|
+
initial: boolean;
|
|
31
35
|
}
|
|
32
36
|
export interface ValidationState {
|
|
33
37
|
initialized: boolean;
|
|
@@ -37,13 +41,16 @@ export interface ValidationState {
|
|
|
37
41
|
export type StatefulLayoutEvents = {
|
|
38
42
|
input: unknown;
|
|
39
43
|
'update': StatefulLayout;
|
|
44
|
+
autofocus: string;
|
|
40
45
|
};
|
|
41
46
|
export type StatefulLayoutOptions = Required<StateNodeOptions> & {
|
|
42
47
|
context: Record<string, any>;
|
|
43
48
|
width: number;
|
|
44
49
|
validateOn: 'input' | 'blur' | 'submit';
|
|
45
50
|
initialValidation: 'never' | 'always' | 'withData';
|
|
51
|
+
defaultOn: 'missing' | 'empty' | 'never';
|
|
46
52
|
messages: LocaleMessages;
|
|
53
|
+
autofocus: boolean;
|
|
47
54
|
};
|
|
48
55
|
export type TextFieldNode = Omit<StateNode, 'children'> & {
|
|
49
56
|
layout: TextField;
|
|
@@ -114,6 +121,10 @@ export type ExpansionPanelsNode = StateNode & {
|
|
|
114
121
|
layout: ExpansionPanels;
|
|
115
122
|
children: StateNode[];
|
|
116
123
|
};
|
|
124
|
+
export type StepperNode = StateNode & {
|
|
125
|
+
layout: Stepper;
|
|
126
|
+
children: StateNode[];
|
|
127
|
+
};
|
|
117
128
|
export type ListNode = StateNode & {
|
|
118
129
|
layout: List;
|
|
119
130
|
data: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts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