@json-layout/core 0.20.0 → 0.21.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 +2 -2
- package/src/compile/skeleton-node.js +1 -1
- package/src/i18n/en.js +1 -0
- package/src/i18n/fr.js +1 -0
- package/src/i18n/types.ts +1 -0
- package/src/state/index.js +71 -41
- package/src/state/state-node.js +41 -7
- package/src/state/types.ts +1 -0
- package/src/utils/doc-options.js +5 -4
- package/types/compile/index.d.ts +16 -0
- package/types/compile/index.d.ts.map +1 -0
- package/types/compile/serialize.d.ts +6 -0
- package/types/compile/serialize.d.ts.map +1 -0
- package/types/compile/skeleton-node.d.ts +18 -0
- package/types/compile/skeleton-node.d.ts.map +1 -0
- package/types/compile/skeleton-tree.d.ts +13 -0
- package/types/compile/skeleton-tree.d.ts.map +1 -0
- package/types/compile/types.d.ts +57 -0
- package/types/compile/types.d.ts.map +1 -0
- package/types/compile/utils/resolve-refs.d.ts +9 -0
- package/types/compile/utils/resolve-refs.d.ts.map +1 -0
- package/types/i18n/en.d.ts +3 -0
- package/types/i18n/en.d.ts.map +1 -0
- package/types/i18n/fr.d.ts +3 -0
- package/types/i18n/fr.d.ts.map +1 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/i18n/index.d.ts.map +1 -0
- package/types/i18n/types.d.ts +36 -0
- package/types/i18n/types.d.ts.map +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.d.ts.map +1 -0
- package/types/state/index.d.ts +285 -0
- package/types/state/index.d.ts.map +1 -0
- package/types/state/state-node.d.ts +36 -0
- package/types/state/state-node.d.ts.map +1 -0
- package/types/state/state-tree.d.ts +13 -0
- package/types/state/state-tree.d.ts.map +1 -0
- package/types/state/types.d.ts +175 -0
- package/types/state/types.d.ts.map +1 -0
- package/types/state/utils/display.d.ts +51 -0
- package/types/state/utils/display.d.ts.map +1 -0
- package/types/state/utils/immutable.d.ts +21 -0
- package/types/state/utils/immutable.d.ts.map +1 -0
- package/types/utils/build.d.ts +5 -0
- package/types/utils/build.d.ts.map +1 -0
- package/types/utils/clone.d.ts +3 -0
- package/types/utils/clone.d.ts.map +1 -0
- package/types/utils/doc-options.d.ts +14 -0
- package/types/utils/doc-options.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.21.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.19.0",
|
|
63
63
|
"@types/markdown-it": "^13.0.1",
|
|
64
64
|
"ajv": "^8.12.0",
|
|
65
65
|
"ajv-errors": "^3.0.0",
|
package/src/i18n/en.js
CHANGED
package/src/i18n/fr.js
CHANGED
package/src/i18n/types.ts
CHANGED
package/src/state/index.js
CHANGED
|
@@ -259,7 +259,7 @@ export class StatefulLayout {
|
|
|
259
259
|
updateState () {
|
|
260
260
|
this.createStateTree()
|
|
261
261
|
let nbIter = 0
|
|
262
|
-
while (this._data !== this._stateTree.root.data || this._autofocusTarget !== this._lastCreateStateTreeContext.autofocusTarget) {
|
|
262
|
+
while (this._data !== (this._stateTree.root.data ?? null) || this._autofocusTarget !== this._lastCreateStateTreeContext.autofocusTarget) {
|
|
263
263
|
nbIter += 1
|
|
264
264
|
if (nbIter > 100) {
|
|
265
265
|
console.error('too many iterations in updateState, the data is probably not stable', this._data, this._stateTree.root.data)
|
|
@@ -267,7 +267,7 @@ export class StatefulLayout {
|
|
|
267
267
|
}
|
|
268
268
|
logDataBinding('hydrating state tree changed the data, do it again', this._data, this._stateTree.root.data)
|
|
269
269
|
// this is necessary because a first hydration can add default values and change validity, etc
|
|
270
|
-
this._data = this._stateTree.root.data
|
|
270
|
+
this._data = this._stateTree.root.data ?? null
|
|
271
271
|
this._autofocusTarget = this._lastCreateStateTreeContext.autofocusTarget
|
|
272
272
|
this.createStateTree(true)
|
|
273
273
|
}
|
|
@@ -515,26 +515,32 @@ export class StatefulLayout {
|
|
|
515
515
|
}
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
+
/**
|
|
519
|
+
* @private
|
|
520
|
+
* @type {Record<string, {key: any, appliedQ: boolean, items: import('@json-layout/vocabulary').SelectItems}>}
|
|
521
|
+
*/
|
|
522
|
+
_itemsCache = {}
|
|
523
|
+
|
|
518
524
|
/**
|
|
519
525
|
* @private
|
|
520
526
|
* @param {StateNode} node
|
|
521
527
|
* @param {string} q
|
|
522
|
-
* @returns {Promise<
|
|
528
|
+
* @returns {Promise<{appliedQ: boolean, items: import('@json-layout/vocabulary').SelectItems}>}
|
|
523
529
|
*/
|
|
524
|
-
async
|
|
530
|
+
async getItemsWithoutCache (node, q = '') {
|
|
525
531
|
if (!isItemsNode(node, this._compiledLayout.components)) {
|
|
526
532
|
throw new Error('node is not a component with an items list')
|
|
527
533
|
}
|
|
528
534
|
|
|
529
|
-
if (node.
|
|
535
|
+
if (node.itemsCacheKey === null) return { appliedQ: false, items: [] }
|
|
530
536
|
|
|
531
|
-
let rawItems
|
|
532
537
|
let appliedQ = false
|
|
533
|
-
|
|
534
|
-
|
|
538
|
+
let rawItems
|
|
539
|
+
if (node.layout.items || (node.layout.getItems && isGetItemsExpression(node.layout.getItems))) {
|
|
540
|
+
rawItems = node.itemsCacheKey
|
|
535
541
|
}
|
|
536
542
|
if (node.layout.getItems && isGetItemsFetch(node.layout.getItems)) {
|
|
537
|
-
const url = new URL(
|
|
543
|
+
const url = new URL(node.itemsCacheKey)
|
|
538
544
|
let qSearchParam = node.layout.getItems.qSearchParam
|
|
539
545
|
if (!qSearchParam) {
|
|
540
546
|
for (const searchParam of url.searchParams.entries()) {
|
|
@@ -549,36 +555,21 @@ export class StatefulLayout {
|
|
|
549
555
|
rawItems = await (await fetch(url)).json()
|
|
550
556
|
}
|
|
551
557
|
|
|
552
|
-
if (rawItems) {
|
|
553
|
-
|
|
554
|
-
rawItems = this.evalNodeExpression(node, node.layout.getItems.itemsResults, rawItems)
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
if (!Array.isArray(rawItems)) throw new Error(`getItems didn't return an array for node ${node.fullKey}, you can define itemsResults to extract the array`)
|
|
558
|
-
|
|
559
|
-
/** @type {import('@json-layout/vocabulary').SelectItems} */
|
|
560
|
-
const items = rawItems.map((/** @type {any} */ rawItem) => {
|
|
561
|
-
/** @type {Partial<import('@json-layout/vocabulary').SelectItem>} */
|
|
562
|
-
const item = {}
|
|
563
|
-
if (typeof rawItem === 'object') {
|
|
564
|
-
item.value = node.layout.getItems?.itemValue ? this.evalNodeExpression(node, node.layout.getItems.itemValue, rawItem) : (node.layout.getItems?.returnObjects ? rawItem : rawItem.value)
|
|
565
|
-
item.key = node.layout.getItems?.itemKey ? this.evalNodeExpression(node, node.layout.getItems.itemKey, rawItem) : rawItem.key
|
|
566
|
-
item.title = node.layout.getItems?.itemTitle ? this.evalNodeExpression(node, node.layout.getItems.itemTitle, rawItem) : rawItem.title
|
|
567
|
-
item.value = item.value ?? item.key
|
|
568
|
-
item.key = item.key ?? item.value + ''
|
|
569
|
-
item.title = item.title ?? item.key
|
|
570
|
-
if (!item.icon && rawItem.icon) item.icon = rawItem.icon
|
|
571
|
-
} else {
|
|
572
|
-
item.value = node.layout.getItems?.itemValue ? this.evalNodeExpression(node, node.layout.getItems.itemValue, rawItem) : rawItem
|
|
573
|
-
item.key = node.layout.getItems?.itemKey ? this.evalNodeExpression(node, node.layout.getItems.itemKey, rawItem) : item.value
|
|
574
|
-
item.title = node.layout.getItems?.itemTitle ? this.evalNodeExpression(node, node.layout.getItems.itemTitle, rawItem) : item.value
|
|
575
|
-
}
|
|
576
|
-
if (node.layout.getItems?.itemIcon) item.icon = this.evalNodeExpression(node, node.layout.getItems?.itemIcon, rawItem)
|
|
577
|
-
return /** @type {import('@json-layout/vocabulary').SelectItem} */(item)
|
|
578
|
-
})
|
|
579
|
-
return [items, appliedQ]
|
|
558
|
+
if (!rawItems) {
|
|
559
|
+
throw new Error(`node ${node.fullKey} is missing items or getItems parameters`)
|
|
580
560
|
}
|
|
581
|
-
|
|
561
|
+
if (node.layout.getItems?.itemsResults) {
|
|
562
|
+
rawItems = this.evalNodeExpression(node, node.layout.getItems.itemsResults, rawItems)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
if (!Array.isArray(rawItems)) throw new Error(`getItems didn't return an array for node ${node.fullKey}, you can define itemsResults to extract the array`)
|
|
566
|
+
|
|
567
|
+
/** @type {import('@json-layout/vocabulary').SelectItems} */
|
|
568
|
+
const items = rawItems.map((/** @type {any} */ rawItem) => {
|
|
569
|
+
return this.prepareSelectItem(node, rawItem)
|
|
570
|
+
})
|
|
571
|
+
|
|
572
|
+
return { appliedQ, items }
|
|
582
573
|
}
|
|
583
574
|
|
|
584
575
|
/**
|
|
@@ -587,9 +578,48 @@ export class StatefulLayout {
|
|
|
587
578
|
* @returns {Promise<import('@json-layout/vocabulary').SelectItems>}
|
|
588
579
|
*/
|
|
589
580
|
async getItems (node, q = '') {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
581
|
+
/** @type {{appliedQ: boolean, items: import('@json-layout/vocabulary').SelectItems}} */
|
|
582
|
+
let itemsResult
|
|
583
|
+
if (
|
|
584
|
+
this._itemsCache[node.fullKey] &&
|
|
585
|
+
this._itemsCache[node.fullKey].key === node.itemsCacheKey &&
|
|
586
|
+
(!q || !this._itemsCache[node.fullKey].appliedQ)
|
|
587
|
+
) {
|
|
588
|
+
itemsResult = this._itemsCache[node.fullKey]
|
|
589
|
+
} else {
|
|
590
|
+
itemsResult = await this.getItemsWithoutCache(node, q)
|
|
591
|
+
if (!q || !itemsResult.appliedQ) {
|
|
592
|
+
this._itemsCache[node.fullKey] = { key: node.itemsCacheKey, ...itemsResult }
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
if (q && !itemsResult.appliedQ) return itemsResult.items.filter(item => item.title.toLowerCase().includes(q.toLowerCase()))
|
|
597
|
+
return itemsResult.items
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* @param {StateNode} node
|
|
602
|
+
* @param {any} rawItem
|
|
603
|
+
* @returns {import('@json-layout/vocabulary').SelectItem}
|
|
604
|
+
*/
|
|
605
|
+
prepareSelectItem (node, rawItem) {
|
|
606
|
+
/** @type {Partial<import('@json-layout/vocabulary').SelectItem>} */
|
|
607
|
+
const item = {}
|
|
608
|
+
if (typeof rawItem === 'object') {
|
|
609
|
+
item.value = node.layout.getItems?.itemValue ? this.evalNodeExpression(node, node.layout.getItems.itemValue, rawItem) : (node.layout.getItems?.returnObjects ? rawItem : rawItem.value)
|
|
610
|
+
item.key = node.layout.getItems?.itemKey ? this.evalNodeExpression(node, node.layout.getItems.itemKey, rawItem) : rawItem.key
|
|
611
|
+
item.title = node.layout.getItems?.itemTitle ? this.evalNodeExpression(node, node.layout.getItems.itemTitle, rawItem) : rawItem.title
|
|
612
|
+
item.value = item.value ?? item.key
|
|
613
|
+
item.key = item.key ?? item.value + ''
|
|
614
|
+
item.title = item.title ?? item.key
|
|
615
|
+
if (!item.icon && rawItem.icon) item.icon = rawItem.icon
|
|
616
|
+
} else {
|
|
617
|
+
item.value = node.layout.getItems?.itemValue ? this.evalNodeExpression(node, node.layout.getItems.itemValue, rawItem) : rawItem
|
|
618
|
+
item.key = node.layout.getItems?.itemKey ? this.evalNodeExpression(node, node.layout.getItems.itemKey, rawItem) : item.value
|
|
619
|
+
item.title = node.layout.getItems?.itemTitle ? this.evalNodeExpression(node, node.layout.getItems.itemTitle, rawItem) : item.value
|
|
620
|
+
}
|
|
621
|
+
if (node.layout.getItems?.itemIcon) item.icon = this.evalNodeExpression(node, node.layout.getItems?.itemIcon, rawItem)
|
|
622
|
+
return /** @type {import('@json-layout/vocabulary').SelectItem} */(item)
|
|
593
623
|
}
|
|
594
624
|
|
|
595
625
|
/**
|
package/src/state/state-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isSwitchStruct, childIsCompObject, isCompositeLayout, isFocusableLayout } from '@json-layout/vocabulary'
|
|
1
|
+
import { isSwitchStruct, childIsCompObject, isCompositeLayout, isFocusableLayout, isItemsLayout, isGetItemsExpression, isGetItemsFetch } from '@json-layout/vocabulary'
|
|
2
2
|
import { produce } from 'immer'
|
|
3
3
|
import { getChildDisplay } from './utils/display.js'
|
|
4
4
|
import { shallowEqualArray, shallowProduceArray, shallowProduceObject } from './utils/immutable.js'
|
|
@@ -27,8 +27,8 @@ 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').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
|
-
const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath, parentDataPath, skeleton, layout, width, cols, data, error, validated, options, autofocus, props, children) => {
|
|
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, itemsCacheKey: any, children: import('../index.js').StateNode[] | undefined) => import('../index.js').StateNode} */
|
|
31
|
+
const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath, parentDataPath, skeleton, layout, width, cols, data, error, validated, options, autofocus, props, itemsCacheKey, children) => {
|
|
32
32
|
draft.messages = layout.messages ? produceStateNodeMessages(draft.messages || {}, layout.messages, options) : options.messages
|
|
33
33
|
|
|
34
34
|
draft.key = key
|
|
@@ -43,6 +43,7 @@ const produceStateNode = produce((draft, key, fullKey, parentFullKey, dataPath,
|
|
|
43
43
|
draft.cols = cols
|
|
44
44
|
draft.data = data
|
|
45
45
|
draft.error = error
|
|
46
|
+
draft.itemsCacheKey = itemsCacheKey
|
|
46
47
|
draft.childError = children && (children.findIndex(c => c.error || c.childError) !== -1)
|
|
47
48
|
draft.validated = validated
|
|
48
49
|
if (autofocus) {
|
|
@@ -178,9 +179,16 @@ const matchChildError = (error, skeleton, dataPath, parentDataPath) => {
|
|
|
178
179
|
export function evalExpression (expressions, expression, data, options, display, layout, validates, rootData, parentContext) {
|
|
179
180
|
if (expression.ref === undefined) throw new Error('expression was not compiled : ' + JSON.stringify(expression))
|
|
180
181
|
const compiledExpression = expressions[expression.ref]
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
try {
|
|
183
|
+
if (expression.pure) {
|
|
184
|
+
return compiledExpression(data, options, options.context, display, layout, validates)
|
|
185
|
+
} else {
|
|
186
|
+
return compiledExpression(data, options, options.context, display, layout, validates, rootData, parentContext)
|
|
187
|
+
}
|
|
188
|
+
} catch (err) {
|
|
189
|
+
console.warn('json-layout: failed to evaluate expression', err, { expression, data, context: options.context, display, rootData, parent: parentContext })
|
|
190
|
+
throw new Error('json-layout: failed to evaluate expression')
|
|
191
|
+
}
|
|
184
192
|
}
|
|
185
193
|
|
|
186
194
|
/**
|
|
@@ -316,7 +324,7 @@ export function createStateNode (
|
|
|
316
324
|
isSameData ? objectData : objectData[childLayout.key],
|
|
317
325
|
{ parent: parentContext, data: objectData },
|
|
318
326
|
validationState,
|
|
319
|
-
reusedNode?.children?.
|
|
327
|
+
reusedNode?.children?.find(c => c.fullKey === childFullKey)
|
|
320
328
|
)
|
|
321
329
|
if (child.autofocus || child.autofocusChild !== undefined) focusChild = false
|
|
322
330
|
children.push(child)
|
|
@@ -461,6 +469,31 @@ export function createStateNode (
|
|
|
461
469
|
props = evalExpression(compiledLayout.expressions, layout.getProps, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
462
470
|
}
|
|
463
471
|
|
|
472
|
+
/** @type {any} */
|
|
473
|
+
let itemsCacheKey
|
|
474
|
+
if (isItemsLayout(layout, compiledLayout.components)) {
|
|
475
|
+
// prefetch items or preresolve url and store a key whose changes can be monitored to re-trigger actual fetch
|
|
476
|
+
if (layout.items) itemsCacheKey = layout.items
|
|
477
|
+
else if (layout.getItems?.immutable && reusedNode?.itemsCacheKey) itemsCacheKey = reusedNode.itemsCacheKey
|
|
478
|
+
else if (layout.getItems && isGetItemsExpression(layout.getItems)) {
|
|
479
|
+
if (layout.getItems.immutable && reusedNode?.itemsCacheKey) {
|
|
480
|
+
itemsCacheKey = reusedNode.itemsCacheKey
|
|
481
|
+
} else {
|
|
482
|
+
try {
|
|
483
|
+
itemsCacheKey = evalExpression(compiledLayout.expressions, layout.getItems, nodeData, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
484
|
+
} catch (err) {
|
|
485
|
+
itemsCacheKey = null
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
} else if (layout.getItems && isGetItemsFetch(layout.getItems)) {
|
|
489
|
+
try {
|
|
490
|
+
itemsCacheKey = evalExpression(compiledLayout.expressions, layout.getItems.url, null, options, display, layout, compiledLayout.validates, context.rootData, parentContext)
|
|
491
|
+
} catch (err) {
|
|
492
|
+
itemsCacheKey = null
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
464
497
|
const autofocus = isFocusableLayout(layout, compiledLayout.components) && !options.readOnly && !options.summary && context.autofocusTarget === fullKey
|
|
465
498
|
const node = produceStateNode(
|
|
466
499
|
reusedNode ?? /** @type {import('./types.js').StateNode} */({}),
|
|
@@ -479,6 +512,7 @@ export function createStateNode (
|
|
|
479
512
|
options,
|
|
480
513
|
autofocus,
|
|
481
514
|
props,
|
|
515
|
+
itemsCacheKey,
|
|
482
516
|
children && shallowProduceArray(reusedNode?.children, children)
|
|
483
517
|
)
|
|
484
518
|
|
package/src/state/types.ts
CHANGED
package/src/utils/doc-options.js
CHANGED
|
@@ -32,8 +32,9 @@ export const compileOptions = [
|
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
key: 'messages',
|
|
35
|
-
description: 'The locale messages. You
|
|
36
|
-
default:
|
|
35
|
+
description: 'The locale messages. You can overwrite only the keys you want to change.',
|
|
36
|
+
default: {},
|
|
37
|
+
values: en
|
|
37
38
|
}
|
|
38
39
|
]
|
|
39
40
|
|
|
@@ -109,8 +110,8 @@ export const runtimeOptions = [
|
|
|
109
110
|
default: 'empty',
|
|
110
111
|
values: {
|
|
111
112
|
never: 'Never use the default data.',
|
|
112
|
-
missing: 'The default data is used when the property
|
|
113
|
-
empty: 'The default data is used when the property is either undefined
|
|
113
|
+
missing: 'The default data is used when the property is not defined in the data.',
|
|
114
|
+
empty: 'The default data is used when the property is either undefined or empty (empty string, empty object, etc.).'
|
|
114
115
|
}
|
|
115
116
|
},
|
|
116
117
|
{
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {object} _schema
|
|
3
|
+
* @param {PartialCompileOptions} [partialOptions]
|
|
4
|
+
* @returns {CompiledLayout}
|
|
5
|
+
*/
|
|
6
|
+
export function compile(_schema: object, partialOptions?: import("./types.js").PartialCompileOptions | undefined): CompiledLayout;
|
|
7
|
+
export { resolveRefs } from "./utils/resolve-refs.js";
|
|
8
|
+
/** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
|
|
9
|
+
export const produceCompileOptions: (draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions;
|
|
10
|
+
export type SkeletonTree = import('./types.js').SkeletonTree;
|
|
11
|
+
export type SkeletonNode = import('./types.js').SkeletonNode;
|
|
12
|
+
export type CompiledLayout = import('./types.js').CompiledLayout;
|
|
13
|
+
export type CompileOptions = import('./types.js').CompileOptions;
|
|
14
|
+
export type PartialCompileOptions = import('./types.js').PartialCompileOptions;
|
|
15
|
+
export type CompiledExpression = import('./types.js').CompiledExpression;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AAgGA;;;;GAIG;AACH,iCAJW,MAAM,4EAEJ,cAAc,CAkF1B;;AAnJD,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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} schema
|
|
3
|
+
* @param {import('./index.js').CompileOptions} options
|
|
4
|
+
* @param {string[]} validates
|
|
5
|
+
* @param {Record<string, string[]>} validationErrors
|
|
6
|
+
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
7
|
+
* @param {import('@json-layout/vocabulary').Expression[]} expressions
|
|
8
|
+
* @param {string | number} key
|
|
9
|
+
* @param {string} pointer
|
|
10
|
+
* @param {string | null} parentPointer
|
|
11
|
+
* @param {boolean} required
|
|
12
|
+
* @param {string} [condition]
|
|
13
|
+
* @param {boolean} [dependent]
|
|
14
|
+
* @param {string} [knownType]
|
|
15
|
+
* @returns {import('./types.js').SkeletonNode}
|
|
16
|
+
*/
|
|
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;
|
|
18
|
+
//# sourceMappingURL=skeleton-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAwT7C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} schema
|
|
3
|
+
* @param {import('./index.js').CompileOptions} options
|
|
4
|
+
* @param {string[]} validates
|
|
5
|
+
* @param {Record<string, string[]>} validationErrors
|
|
6
|
+
* @param {Record<string, import('@json-layout/vocabulary').NormalizedLayout>} normalizedLayouts
|
|
7
|
+
* @param {import('@json-layout/vocabulary').Expression[]} expressions
|
|
8
|
+
* @param {string} pointer
|
|
9
|
+
* @param {string} title
|
|
10
|
+
* @returns {import('./types.js').SkeletonTree}
|
|
11
|
+
*/
|
|
12
|
+
export function makeSkeletonTree(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[], pointer: string, title: string): import('./types.js').SkeletonTree;
|
|
13
|
+
//# sourceMappingURL=skeleton-tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton-tree.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-tree.js"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,yCAVW,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,WAC9C,MAAM,SACN,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CAe7C"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type ajvModule from 'ajv/dist/2019.js';
|
|
2
|
+
import type MarkdownIt from 'markdown-it';
|
|
3
|
+
import { type ComponentInfo, type BaseCompObject, type NormalizedLayout, type StateNodeOptionsBase, type Expression } from '@json-layout/vocabulary';
|
|
4
|
+
import { type ValidateFunction, type SchemaObject } from 'ajv/dist/2019.js';
|
|
5
|
+
import { type Display } from '../state/utils/display.js';
|
|
6
|
+
import { type LocaleMessages } from '../i18n/types.js';
|
|
7
|
+
export interface ParentContextExpression {
|
|
8
|
+
data: unknown;
|
|
9
|
+
parent: ParentContextExpression | undefined | null;
|
|
10
|
+
}
|
|
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
|
+
export interface CompileOptions {
|
|
13
|
+
ajv: ajvModule.default;
|
|
14
|
+
ajvOptions?: ajvModule.Options;
|
|
15
|
+
code: boolean;
|
|
16
|
+
markdown: (text: string) => string;
|
|
17
|
+
markdownItOptions?: MarkdownIt.Options;
|
|
18
|
+
locale: string;
|
|
19
|
+
messages: LocaleMessages;
|
|
20
|
+
optionsKeys: string[];
|
|
21
|
+
components: Record<string, ComponentInfo>;
|
|
22
|
+
}
|
|
23
|
+
export type PartialCompileOptions = Partial<Omit<CompileOptions, 'messages'>> & {
|
|
24
|
+
messages?: Partial<LocaleMessages>;
|
|
25
|
+
components?: Record<string, Omit<ComponentInfo, 'name'>>;
|
|
26
|
+
};
|
|
27
|
+
export interface CompiledLayout {
|
|
28
|
+
options?: CompileOptions;
|
|
29
|
+
schema?: SchemaObject;
|
|
30
|
+
skeletonTree: SkeletonTree;
|
|
31
|
+
validates: Record<string, ValidateFunction>;
|
|
32
|
+
validationErrors: Record<string, string[]>;
|
|
33
|
+
normalizedLayouts: Record<string, NormalizedLayout>;
|
|
34
|
+
expressions: CompiledExpression[];
|
|
35
|
+
locale: string;
|
|
36
|
+
messages: LocaleMessages;
|
|
37
|
+
components: Record<string, Omit<ComponentInfo, 'schema'>>;
|
|
38
|
+
localizeErrors: (errors: ajvModule.ErrorObject[]) => void;
|
|
39
|
+
}
|
|
40
|
+
export interface SkeletonTree {
|
|
41
|
+
title: string;
|
|
42
|
+
root: SkeletonNode;
|
|
43
|
+
}
|
|
44
|
+
export interface SkeletonNode {
|
|
45
|
+
key: string | number;
|
|
46
|
+
pointer: string;
|
|
47
|
+
parentPointer: string | null;
|
|
48
|
+
pure: boolean;
|
|
49
|
+
propertyKeys: string[];
|
|
50
|
+
roPropertyKeys: string[];
|
|
51
|
+
condition?: Expression;
|
|
52
|
+
children?: SkeletonNode[];
|
|
53
|
+
childrenTrees?: SkeletonTree[];
|
|
54
|
+
required?: boolean;
|
|
55
|
+
nullable?: boolean;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/compile/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('ajv').SchemaObject} schema
|
|
3
|
+
* @param {ajvModule.default} ajv
|
|
4
|
+
* @param {string} locale
|
|
5
|
+
* @returns {import('ajv').SchemaObject}
|
|
6
|
+
*/
|
|
7
|
+
export function resolveRefs(schema: import('ajv').SchemaObject, ajv: ajvModule.default, locale?: string): import('ajv').SchemaObject;
|
|
8
|
+
import ajvModule from 'ajv/dist/2019.js';
|
|
9
|
+
//# sourceMappingURL=resolve-refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-refs.d.ts","sourceRoot":"","sources":["../../../src/compile/utils/resolve-refs.js"],"names":[],"mappings":"AA2DA;;;;;GAKG;AACH,oCALW,OAAO,KAAK,EAAE,YAAY,OAC1B,UAAU,OAAO,WACjB,MAAM,GACJ,OAAO,KAAK,EAAE,YAAY,CAKtC;sBApEqB,kBAAkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/i18n/en.js"],"names":[],"mappings":"wBAAW,OAAO,YAAY,EAAE,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr.d.ts","sourceRoot":"","sources":["../../src/i18n/fr.js"],"names":[],"mappings":"wBAAW,OAAO,YAAY,EAAE,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/i18n/index.js"],"names":[],"mappings":"wBAGW,OAAO,MAAM,EAAE,OAAO,YAAY,EAAE,cAAc,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface CompileOptionsMessages {
|
|
2
|
+
errorOneOf: string;
|
|
3
|
+
errorRequired: string;
|
|
4
|
+
}
|
|
5
|
+
export interface StateOptionsMessages {
|
|
6
|
+
addItem: string;
|
|
7
|
+
delete: string;
|
|
8
|
+
edit: string;
|
|
9
|
+
close: string;
|
|
10
|
+
duplicate: string;
|
|
11
|
+
sort: string;
|
|
12
|
+
up: string;
|
|
13
|
+
down: string;
|
|
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;
|
|
34
|
+
}
|
|
35
|
+
export type LocaleMessages = CompileOptionsMessages & StateOptionsMessages;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,KAAK,EAAE,MAAM,CAAA;IACb,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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
|