@json-layout/core
Advanced tools
Comparing version 0.35.0 to 1.0.0
{ | ||
"name": "@json-layout/core", | ||
"version": "0.35.0", | ||
"version": "1.0.0", | ||
"description": "Compilation and state management utilities for JSON Layout.", | ||
@@ -62,3 +62,3 @@ "type": "module", | ||
"dependencies": { | ||
"@json-layout/vocabulary": "^0.23.2", | ||
"@json-layout/vocabulary": "^1.0.0", | ||
"ajv": "^8.12.0", | ||
@@ -65,0 +65,0 @@ "ajv-errors": "^3.0.0", |
// import Debug from 'debug' | ||
import { normalizeLayoutFragment, isSwitchStruct, isGetItemsExpression, isGetItemsFetch, isItemsLayout, getSchemaFragmentType, isCompositeLayout } from '@json-layout/vocabulary' | ||
import { normalizeLayoutFragment, isSwitchStruct, isGetItemsExpression, isGetItemsFetch, isItemsLayout, getSchemaFragmentType, isCompositeLayout, childIsCompObject } from '@json-layout/vocabulary' | ||
import { makeSkeletonTree } from './skeleton-tree.js' | ||
@@ -95,5 +95,19 @@ import { partialResolveRefs } from './utils/resolve-refs.js' | ||
/** | ||
* @param {import('@json-layout/vocabulary').Child} child | ||
*/ | ||
const prepareLayoutChild = (child) => { | ||
if (child.if) pushExpression(expressions, child.if) | ||
if (childIsCompObject(child)) { | ||
for (const grandChild of child.children) prepareLayoutChild(grandChild) | ||
} | ||
} | ||
const compObjects = isSwitchStruct(normalizedLayout) ? normalizedLayout.switch : [normalizedLayout] | ||
for (const compObject of compObjects) { | ||
if (compObject.if) pushExpression(expressions, compObject.if) | ||
if (isCompositeLayout(compObject, options.components)) { | ||
for (const child of compObject.children) prepareLayoutChild(child) | ||
} | ||
@@ -100,0 +114,0 @@ if (schema.const !== undefined && compObject.constData === undefined) compObject.constData = schema.const |
@@ -245,2 +245,3 @@ import { isSwitchStruct, childIsCompObject, isCompositeLayout, isFocusableLayout, isItemsLayout, isGetItemsExpression, isGetItemsFetch, isListLayout } from '@json-layout/vocabulary' | ||
* @param {import('@json-layout/vocabulary').NormalizedLayout} normalizedLayout | ||
* @param {import('@json-layout/vocabulary').Child | null} childDefinition | ||
* @param {import('./types.js').StateNodeOptions} options | ||
@@ -254,3 +255,3 @@ * @param {import('../index.js').CompiledLayout} compiledLayout | ||
*/ | ||
const getCompObject = (normalizedLayout, options, compiledLayout, display, data, rootData, parentContext) => { | ||
const getCompObject = (normalizedLayout, childDefinition, options, compiledLayout, display, data, rootData, parentContext) => { | ||
if (isSwitchStruct(normalizedLayout)) { | ||
@@ -263,9 +264,9 @@ for (const compObject of normalizedLayout.switch) { | ||
} else { | ||
if (normalizedLayout.if) { | ||
if (evalExpression(compiledLayout.expressions, normalizedLayout.if, data, options, display, normalizedLayout, compiledLayout.validates, rootData, parentContext)) { | ||
return normalizedLayout | ||
} | ||
} else { | ||
return normalizedLayout | ||
if (childDefinition?.if && !evalExpression(compiledLayout.expressions, childDefinition.if, data, options, display, normalizedLayout, compiledLayout.validates, rootData, parentContext)) { | ||
return { comp: 'none' } | ||
} | ||
if (normalizedLayout.if && !evalExpression(compiledLayout.expressions, normalizedLayout.if, data, options, display, normalizedLayout, compiledLayout.validates, rootData, parentContext)) { | ||
return { comp: 'none' } | ||
} | ||
return normalizedLayout | ||
} | ||
@@ -353,3 +354,3 @@ return { comp: 'none' } | ||
: compiledLayout.normalizedLayouts[skeleton.pointer] | ||
const layout = getCompObject(normalizedLayout, parentOptions, compiledLayout, parentDisplay, data, context.rootData, parentContext) | ||
const layout = getCompObject(normalizedLayout, childDefinition, parentOptions, compiledLayout, parentDisplay, data, context.rootData, parentContext) | ||
const [display, cols] = getChildDisplay(parentDisplay, childDefinition?.cols ?? layout.cols) | ||
@@ -356,0 +357,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
177943
3991
0
+ Added@json-layout/vocabulary@1.3.0(transitive)
- Removed@json-layout/vocabulary@0.23.3(transitive)