@json-layout/core 0.25.0 → 0.26.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@json-layout/core",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "description": "Compilation and state management utilities for JSON Layout.",
5
5
  "type": "module",
6
6
  "exports": {
package/src/i18n/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import en from './en.js'
2
2
  import fr from './fr.js'
3
+ import nl from './nl.js'
3
4
 
4
5
  /** @type {Record<string, import('./types.js').LocaleMessages>} */
5
6
  export default {
6
7
  en,
7
- fr
8
+ fr,
9
+ nl
8
10
  }
package/src/i18n/nl.js ADDED
@@ -0,0 +1,33 @@
1
+ /** @type {import('./types.js').LocaleMessages} */
2
+ export default {
3
+ errorOneOf: 'Kies er een',
4
+ errorRequired: 'benodigde informatie',
5
+ addItem: 'Item toevoegen',
6
+ delete: 'Verwijderen',
7
+ edit: 'Bewerken',
8
+ close: 'Sluiten',
9
+ duplicate: 'Verveelvoudigen',
10
+ sort: 'Sorteren',
11
+ up: 'Omhoog verplaatsen',
12
+ down: 'Omlaag verplaatsen',
13
+ showHelp: 'Toon helpbericht',
14
+ mdeLink1: '[Link titel',
15
+ mdeLink2: '](link url)',
16
+ mdeImg1: '![](',
17
+ mdeImg2: 'afbeelding url)',
18
+ mdeTable1: '',
19
+ mdeTable2: '\n\n| Kolom 1 | Kolom 2 | Kolom 3 |\n| -------- | -------- | -------- |\n| Tekst | Tekst | Tekst |\n\n',
20
+ bold: 'Vet',
21
+ italic: 'Cursief',
22
+ heading: 'Titel',
23
+ quote: 'Citaat',
24
+ unorderedList: 'Ongeordende lijst',
25
+ orderedList: 'Geordende lijst',
26
+ createLink: 'Maak een koppeling',
27
+ insertImage: 'Afbeelding invoegen',
28
+ createTable: 'Tabel aanmaken',
29
+ preview: 'Voorbeeld',
30
+ mdeGuide: 'Documentatie over syntaxis',
31
+ undo: 'Ongedaan maken',
32
+ redo: 'Opnieuw'
33
+ }
@@ -295,6 +295,10 @@ export class StatefulLayout {
295
295
  files: [],
296
296
  nodes: []
297
297
  }
298
+
299
+ // @ts-ignore
300
+ if (this._options._debugCache) createStateTreeContext._debugCache = this._lastCreateStateTreeContext?._debugCache ?? {}
301
+
298
302
  this._stateTree = createStateTree(
299
303
  createStateTreeContext,
300
304
  this._options,
@@ -270,11 +270,20 @@ export function createStateNode (
270
270
 
271
271
  // NOTE we have to exclude nodes with errors from the cache, because context.errors is unpurely modified
272
272
  // TODO: implement a cleaner way to filter context.errors while being able to reuse nodes with errors
273
- if (skeleton.pure && reusedNode && !reusedNode.error && !reusedNode.childError) {
274
- cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.activatedItems, context.initial, data]
275
- if (context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) {
273
+ if (skeleton.pure && !reusedNode?.error && !reusedNode?.childError) {
274
+ const validatedCacheKey = validationState.validatedForm || validationState.validatedChildren.includes(fullKey)
275
+ cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validatedCacheKey, context.activatedItems, context.initial, data]
276
+ if (reusedNode && context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) {
277
+ // @ts-ignore
278
+ if (context._debugCache) context._debugCache[fullKey] = (context._debugCache[fullKey] ?? []).concat(['hit'])
276
279
  return reusedNode
280
+ } else {
281
+ // @ts-ignore
282
+ if (context._debugCache) context._debugCache[fullKey] = (context._debugCache[fullKey] ?? []).concat(['miss'])
277
283
  }
284
+ } else {
285
+ // @ts-ignore
286
+ if (context._debugCache) context._debugCache[fullKey] = (context._debugCache[fullKey] ?? []).concat(['skip'])
278
287
  }
279
288
 
280
289
  const normalizedLayout = childDefinition && childIsCompObject(childDefinition)
@@ -428,19 +437,19 @@ export function createStateNode (
428
437
  })
429
438
  }
430
439
  }
431
- const validated = validationState.validatedForm ||
432
- validationState.validatedChildren.includes(fullKey) ||
433
- (validationState.initialized === false && options.initialValidation === 'always') ||
434
- (validationState.initialized === false && options.initialValidation === 'withData' && !isDataEmpty(data))
435
440
 
436
441
  let nodeData = data
437
-
438
442
  if (nodeData === null && !layout.nullable) nodeData = undefined
439
443
 
444
+ const validated = validationState.validatedForm ||
445
+ validationState.validatedChildren.includes(fullKey) ||
446
+ (validationState.initialized === false && options.initialValidation === 'always') ||
447
+ (validationState.initialized === false && options.initialValidation === 'withData' && !isDataEmpty(nodeData))
448
+
440
449
  /** @type {unknown} */
441
- if (typeof nodeData === 'object' && !(nodeData instanceof File)) {
450
+ if ((typeof nodeData === 'object' || (nodeData === undefined && children?.length)) && !(nodeData instanceof File)) {
442
451
  nodeData = produceStateNodeData(
443
- /** @type {Record<string, unknown>} */(nodeData ?? {}),
452
+ /** @type {Record<string, unknown>} */(nodeData ?? (typeof children?.[0]?.key === 'number' ? [] : {})),
444
453
  dataPath,
445
454
  children,
446
455
  context.additionalPropertiesErrors,
@@ -76,7 +76,7 @@ export interface FileRef {
76
76
  dataPath: string
77
77
  }
78
78
 
79
- // [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validationState, activatedItems, initial, data]
79
+ // [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentWidth, validated, activatedItems, initial, data]
80
80
  export type StateNodeCacheKey = [
81
81
  StateNodeOptions,
82
82
  CompiledLayout,
@@ -84,7 +84,7 @@ export type StateNodeCacheKey = [
84
84
  SkeletonNode,
85
85
  Child | null,
86
86
  number,
87
- ValidationState,
87
+ boolean,
88
88
  Record<string, number>,
89
89
  boolean,
90
90
  unknown
@@ -124,11 +124,6 @@ export const runtimeOptions = [
124
124
  false: 'Never remove additional properties (alias "none").'
125
125
  }
126
126
  },
127
- {
128
- key: 'autofocus',
129
- description: 'Activate autofocus. The focus will be given to the first input of the form.',
130
- default: false
131
- },
132
127
  {
133
128
  key: 'readOnlyPropertiesMode',
134
129
  description: 'Control the way readOnly properties from the schema are managed.',
@@ -138,5 +133,10 @@ export const runtimeOptions = [
138
133
  hide: 'Hide the readOnly properties but keep them in the data.',
139
134
  show: 'Show the readOnly properties.'
140
135
  }
136
+ },
137
+ {
138
+ key: 'autofocus',
139
+ description: 'Activate autofocus. The focus will be given to the first input of the form.',
140
+ default: false
141
141
  }
142
142
  ]