@json-layout/vocabulary
Advanced tools
Comparing version 1.2.1 to 1.3.0
{ | ||
"name": "@json-layout/vocabulary", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Main JSON Layout vocabulary as JSON schemas and Typescript types. Also contains some small utility functions to validate and normalize annotations.", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -32,2 +32,5 @@ /** | ||
{ | ||
name: 'slot' | ||
}, | ||
{ | ||
name: 'section', | ||
@@ -34,0 +37,0 @@ composite: true |
@@ -22,2 +22,12 @@ import type { | ||
}); | ||
export type Slot = { | ||
comp?: "slot"; | ||
[k: string]: unknown; | ||
} & BaseCompObject & | ||
(BaseCompObject & { | ||
comp: string; | ||
label?: string; | ||
hint?: string | null; | ||
[k: string]: unknown; | ||
}); | ||
export type Section = { | ||
@@ -24,0 +34,0 @@ comp?: "section"; |
@@ -10,2 +10,3 @@ import schema from './schema.js' | ||
* @typedef {import('./types.js').PartialChildComposite} PartialChildComposite | ||
* @typedef {import('./types.js').PartialChildSlot} PartialChildSlot | ||
* @typedef {import('./types.js').PartialSwitch} PartialSwitch | ||
@@ -18,2 +19,4 @@ * @typedef {import('./types.js').PartialCompObject} PartialCompObject | ||
* @typedef {import('./types.js').PartialSlotMarkdown} PartialSlotMarkdown | ||
* @typedef {import('./types.js').PartialSlotText} PartialSlotText | ||
* @typedef {import('./types.js').PartialSlotName} PartialSlotName | ||
* @typedef {import('./types.js').PartialSlot} PartialSlot | ||
@@ -45,5 +48,10 @@ * @typedef {import('./types.js').PartialSelectItem} PartialSelectItem | ||
export function isPartialChildComposite (partialChild) { | ||
return typeof partialChild !== 'string' && "children" in partialChild | ||
return typeof partialChild !== 'string' && 'children' in partialChild | ||
} | ||
/** @type {(partialChild: PartialChild) => partialChild is PartialChildSlot} */ | ||
export function isPartialChildSlot (partialChild) { | ||
return typeof partialChild !== 'string' && ('text' in partialChild || 'markdown' in partialChild || 'name' in partialChild) | ||
} | ||
/** @type {(layoutKeyword: LayoutKeyword) => layoutKeyword is PartialCompObject} */ | ||
@@ -72,2 +80,12 @@ export function isPartialCompObject (layoutKeyword) { | ||
return typeof partialSlot == 'object' && !!/** @type {PartialSlotMarkdown} */(partialSlot).markdown | ||
} | ||
/** @type {(partialSlot: PartialSlot) => partialSlot is PartialSlotText} */ | ||
export function isPartialSlotText (partialSlot) { | ||
return typeof partialSlot == 'object' && !!/** @type {PartialSlotText} */(partialSlot).text | ||
} | ||
/** @type {(partialSlot: PartialSlot) => partialSlot is PartialSlotName} */ | ||
export function isPartialSlotName (partialSlot) { | ||
return typeof partialSlot == 'object' && !!/** @type {PartialSlotName} */(partialSlot).name | ||
} |
@@ -179,2 +179,10 @@ | ||
"$ref": "#/$defs/partial-expression" | ||
}, | ||
"slots": { | ||
"type": "object", | ||
"patternProperties": { | ||
".*": { | ||
"$ref": "#/$defs/partial-slot" | ||
} | ||
} | ||
} | ||
@@ -212,5 +220,35 @@ } | ||
"$ref": "#/$defs/partial-expression" | ||
}, | ||
"slots": { | ||
"type": "object", | ||
"patternProperties": { | ||
".*": { | ||
"$ref": "#/$defs/partial-slot" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"partial-child-slot": { | ||
"type": "object", | ||
"properties": { | ||
"cols": { | ||
"$ref": "#/$defs/partial-cols" | ||
}, | ||
"if": { | ||
"$ref": "#/$defs/partial-expression" | ||
} | ||
}, | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/$defs/partial-slot-text" | ||
}, | ||
{ | ||
"$ref": "#/$defs/partial-slot-markdown" | ||
}, | ||
{ | ||
"$ref": "#/$defs/partial-slot-name" | ||
} | ||
] | ||
}, | ||
"partial-child": { | ||
@@ -222,2 +260,8 @@ "anyOf": [ | ||
{ | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/$defs/partial-child" | ||
} | ||
}, | ||
{ | ||
"$ref": "#/$defs/partial-child-ref" | ||
@@ -227,2 +271,5 @@ }, | ||
"$ref": "#/$defs/partial-child-composite" | ||
}, | ||
{ | ||
"$ref": "#/$defs/partial-child-slot" | ||
} | ||
@@ -229,0 +276,0 @@ ] |
@@ -76,3 +76,9 @@ { | ||
"cols": {"$ref": "#/$defs/partial-cols"}, | ||
"if": {"$ref": "#/$defs/partial-expression"} | ||
"if": {"$ref": "#/$defs/partial-expression"}, | ||
"slots": { | ||
"type": "object", | ||
"patternProperties": { | ||
".*": {"$ref": "#/$defs/partial-slot"} | ||
} | ||
} | ||
} | ||
@@ -89,10 +95,30 @@ }, | ||
"cols": {"$ref": "#/$defs/partial-cols"}, | ||
"if": {"$ref": "#/$defs/partial-expression"} | ||
"if": {"$ref": "#/$defs/partial-expression"}, | ||
"slots": { | ||
"type": "object", | ||
"patternProperties": { | ||
".*": {"$ref": "#/$defs/partial-slot"} | ||
} | ||
} | ||
} | ||
}, | ||
"partial-child-slot": { | ||
"type": "object", | ||
"properties": { | ||
"cols": {"$ref": "#/$defs/partial-cols"}, | ||
"if": {"$ref": "#/$defs/partial-expression"} | ||
}, | ||
"oneOf": [ | ||
{"$ref": "#/$defs/partial-slot-text"}, | ||
{"$ref": "#/$defs/partial-slot-markdown"}, | ||
{"$ref": "#/$defs/partial-slot-name"} | ||
] | ||
}, | ||
"partial-child": { | ||
"anyOf": [ | ||
{"type": "string"}, | ||
{"type": "array", "items": {"$ref": "#/$defs/partial-child"}}, | ||
{"$ref": "#/$defs/partial-child-ref"}, | ||
{"$ref": "#/$defs/partial-child-composite"} | ||
{"$ref": "#/$defs/partial-child-composite"}, | ||
{"$ref": "#/$defs/partial-child-slot"} | ||
] | ||
@@ -99,0 +125,0 @@ }, |
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
export type PartialChild = string | PartialChildRef | PartialChildComposite; | ||
export type PartialChild = string | PartialChild[] | PartialChildRef | PartialChildComposite | PartialChildSlot; | ||
/** | ||
@@ -33,3 +33,27 @@ * This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot". | ||
*/ | ||
export type PartialSlot = string | PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
export type PartialChildSlot = { | ||
cols?: PartialCols; | ||
if?: PartialExpression; | ||
[k: string]: unknown; | ||
} & PartialChildSlot1; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-child-slot". | ||
*/ | ||
export type PartialChildSlot1 = PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-children". | ||
@@ -73,10 +97,2 @@ */ | ||
); | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot". | ||
*/ | ||
export type PartialSlot = string | PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
@@ -94,2 +110,5 @@ export interface HttpsJsonLayoutGithubIoLayoutKeyword { | ||
if?: PartialExpression; | ||
slots?: { | ||
[k: string]: PartialSlot; | ||
}; | ||
} | ||
@@ -119,2 +138,23 @@ /** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-text". | ||
*/ | ||
export interface PartialSlotText { | ||
text: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-markdown". | ||
*/ | ||
export interface PartialSlotMarkdown { | ||
markdown: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-name". | ||
*/ | ||
export interface PartialSlotName { | ||
name: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-child-composite". | ||
@@ -129,2 +169,5 @@ */ | ||
if?: PartialExpression; | ||
slots?: { | ||
[k: string]: PartialSlot; | ||
}; | ||
[k: string]: unknown; | ||
@@ -184,23 +227,2 @@ } | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-text". | ||
*/ | ||
export interface PartialSlotText { | ||
text: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-markdown". | ||
*/ | ||
export interface PartialSlotMarkdown { | ||
markdown: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-name". | ||
*/ | ||
export interface PartialSlotName { | ||
name: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-switch". | ||
@@ -207,0 +229,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
import { validateLayoutKeyword, isComponentName, isPartialCompObject, isPartialChildren, isPartialSwitch, isPartialGetItemsExpr, isPartialGetItemsObj, isPartialSlotMarkdown, isPartialGetItemsFetch, isPartialChildComposite } from './layout-keyword/index.js' | ||
import { validateLayoutKeyword, isComponentName, isPartialCompObject, isPartialChildren, isPartialSwitch, isPartialGetItemsExpr, isPartialGetItemsObj, isPartialSlotMarkdown, isPartialGetItemsFetch, isPartialChildComposite, isPartialChildSlot, isPartialSlotText, isPartialSlotName } from './layout-keyword/index.js' | ||
import { validateNormalizedLayout } from './normalized-layout/index.js' | ||
@@ -69,8 +69,10 @@ import { getComponentValidate } from './validate.js' | ||
* @param {Children} defaultChildren | ||
* @param {PartialChildren} [partialChildren] | ||
* @param {PartialChildren | undefined} partialChildren | ||
* @param {(text: string) => string} markdown | ||
* @returns {Children} | ||
*/ | ||
function getChildren (defaultChildren, partialChildren) { | ||
function getChildren (defaultChildren, partialChildren, markdown) { | ||
if (!partialChildren) return defaultChildren | ||
let compI = 0 | ||
let slotI = 0 | ||
return partialChildren.map(partialChild => { | ||
@@ -81,3 +83,14 @@ if (typeof partialChild === 'string') { // simple string/key referencing a known child | ||
return matchingDefaultChild | ||
} else if (Array.isArray(partialChild)) { | ||
compI++ | ||
return { | ||
comp: 'section', | ||
key: `$comp-${compI}`, | ||
children: getChildren(defaultChildren, partialChild, markdown) | ||
} | ||
} else { | ||
if ('slots' in partialChild && !isPartialChildSlot(partialChild)) { | ||
partialChild.slots = normalizePartialSlots(partialChild.slots, markdown) | ||
} | ||
if ('cols' in partialChild) partialChild.cols = normalizePartialCols(partialChild.cols) | ||
if (partialChild.if) partialChild.if = normalizeExpression(partialChild.if) | ||
@@ -90,12 +103,22 @@ if (typeof partialChild.cols === 'number') partialChild.cols = { sm: partialChild.cols } | ||
return /** @type {Child} */ (partialChild) | ||
} else { // a composite component definition, not directly related to a known child | ||
} else if (isPartialChildSlot(partialChild)) { // a slot defined as a child | ||
/** @type {Child} */ | ||
slotI++ | ||
return { | ||
key: `$slot-${slotI}`, | ||
comp: 'slot', | ||
cols: normalizePartialCols(partialChild.cols), | ||
slots: normalizePartialSlots({ component: partialChild }, markdown) | ||
} | ||
} else { | ||
const child = partialChild | ||
if (isPartialChildComposite(child)) { | ||
// a composite component definition, not directly related to a known child | ||
if (!child.comp) child.comp = 'section' | ||
child.children = getChildren(defaultChildren, child.children) | ||
child.children = getChildren(defaultChildren, child.children, markdown) | ||
if (!('key' in partialChild)) { | ||
compI++ | ||
child.key = `$comp-${compI}` | ||
} | ||
} | ||
if (!('key' in partialChild)) { | ||
child.key = `$comp-${compI}` | ||
compI++ | ||
} | ||
return /** @type {Child} */ (child) | ||
@@ -115,2 +138,3 @@ } | ||
function getDefaultComp (partial, schemaFragment, type, schemaChild) { | ||
if (partial.slots?.component) return 'slot' | ||
const hasSimpleType = type && ['string', 'integer', 'number'].includes(type) | ||
@@ -199,2 +223,42 @@ if (schemaChild === 'oneOf') return 'one-of-select' | ||
/** | ||
* @param {PartialCompObject['slots']} partialSlots | ||
* @param {(text: string) => string} markdown | ||
* @returns {import('./normalized-layout/types.js').Slots | undefined} | ||
*/ | ||
function normalizePartialSlots (partialSlots, markdown) { | ||
if (!partialSlots) return | ||
/** @type {import('./normalized-layout/types.js').Slots} */ | ||
const slots = {} | ||
for (const [name, slot] of Object.entries(partialSlots)) { | ||
if (typeof slot === 'string') { | ||
if (['before', 'after'].includes(name)) { | ||
slots[name] = { markdown: markdown(slot).trim() } | ||
} else { | ||
slots[name] = { name: slot } | ||
} | ||
} else if (isPartialSlotText(slot)) { | ||
slots[name] = { text: slot.text } | ||
} else if (isPartialSlotName(slot)) { | ||
slots[name] = { name: slot.name } | ||
} else if (isPartialSlotMarkdown(slot)) { | ||
slots[name] = { markdown: markdown(slot.markdown).trim() } | ||
} | ||
} | ||
return slots | ||
} | ||
/** | ||
* @param {PartialCompObject['cols']} partialCols | ||
* @returns {import('./normalized-layout/types.js').ColsObj | undefined} | ||
*/ | ||
function normalizePartialCols (partialCols) { | ||
if (typeof partialCols === 'number') { | ||
return { xs: 12, sm: partialCols } | ||
} | ||
if (typeof partialCols === 'object') { | ||
return { xs: 12, ...partialCols } | ||
} | ||
} | ||
/** | ||
* @param {SchemaFragment} schemaFragment | ||
@@ -307,3 +371,3 @@ * @returns {import('./index.js').PartialSelectItem[] | null} | ||
if (component.composite) { | ||
const children = getChildren(getDefaultChildren(schemaFragment, type), partial.children) | ||
const children = getChildren(getDefaultChildren(schemaFragment, type), partial.children, markdown) | ||
partial.children = children | ||
@@ -320,3 +384,3 @@ if (!('title' in partial)) { | ||
if (!('title' in partial)) { | ||
const children = getChildren(getDefaultChildren(schemaFragment, type), partial.children) | ||
const children = getChildren(getDefaultChildren(schemaFragment, type), partial.children, markdown) | ||
if (children.length === 1 && children[0].key === '$patternProperties') { | ||
@@ -340,3 +404,3 @@ partial.title = schemaFragment.title ?? null | ||
} | ||
} else { | ||
} else if (partial.comp !== 'slot') { | ||
if (!('label' in partial) && !schemaChild) { | ||
@@ -453,17 +517,3 @@ partial.label = schemaFragment.title ?? ('' + key) | ||
if (partial.slots) { | ||
for (const [name, slot] of Object.entries(partial.slots)) { | ||
if (typeof slot === 'string') { | ||
if (['before', 'after'].includes(name)) { | ||
partial.slots[name] = { markdown: slot } | ||
} else { | ||
partial.slots[name] = { name: slot } | ||
} | ||
} | ||
const slotObj = partial.slots[name] | ||
if (isPartialSlotMarkdown(slotObj)) { | ||
slotObj.markdown = markdown(slotObj.markdown).trim() | ||
} | ||
} | ||
} | ||
if (partial.slots) partial.slots = normalizePartialSlots(partial.slots, markdown) | ||
@@ -488,4 +538,3 @@ if (schemaFragment.description) { | ||
if (typeof partial.cols === 'number') partial.cols = { xs: partial.cols } | ||
if (typeof partial.cols === 'object' && partial.cols.xs === undefined) partial.cols.xs = 12 | ||
if ('cols' in partial) partial.cols = normalizePartialCols(partial.cols) | ||
@@ -492,0 +541,0 @@ const validateComponent = getComponentValidate(component) |
@@ -13,3 +13,5 @@ import schema from './schema.js' | ||
* @typedef {import('./types.js').Children} Children | ||
* @typedef {import('./types.js').ChildSlot} ChildSlot | ||
* @typedef {import('./types.js').CompositeCompObject} CompositeCompObject | ||
* @typedef {import('./types.js').SlotCompObject} SlotCompObject | ||
* @typedef {import('./types.js').ItemsBasedCompObject} ItemsBasedCompObject | ||
@@ -24,2 +26,3 @@ * @typedef {import('./types.js').FocusableCompObject} FocusableCompObject | ||
* @typedef {import('./types.js').Slot} Slot | ||
* @typedef {import('./types.js').Slots} Slots | ||
* @typedef {{ errors: any, (layoutKeyword: any): layoutKeyword is NormalizedLayout }} ValidateNormalizedLayout | ||
@@ -43,6 +46,11 @@ */ | ||
/** @type {(child: Child) => child is Child & CompositeCompObject} */ | ||
export function childIsCompObject (child) { | ||
return 'comp' in child | ||
export function childIsCompositeCompObject (child) { | ||
return 'comp' in child && 'children' in child | ||
} | ||
/** @type {(child: Child) => child is Child & SlotCompObject} */ | ||
export function childIsSlotCompObject (child) { | ||
return 'comp' in child && child.comp === 'slot' | ||
} | ||
/** @type {(layout: BaseCompObject, components: Record<string, import('../types.js').ComponentInfo>) => layout is CompositeCompObject} */ | ||
@@ -49,0 +57,0 @@ export function isCompositeLayout (layout, components) { |
@@ -79,21 +79,3 @@ | ||
"slots": { | ||
"type": "object", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/$defs/state-node-slots-lib" | ||
}, | ||
{ | ||
"properties": { | ||
"before": { | ||
"$ref": "#/$defs/slot" | ||
}, | ||
"after": { | ||
"$ref": "#/$defs/slot" | ||
}, | ||
"component": { | ||
"$ref": "#/$defs/slot" | ||
} | ||
} | ||
} | ||
] | ||
"$ref": "#/$defs/slots" | ||
} | ||
@@ -136,2 +118,22 @@ } | ||
}, | ||
"slot-comp-object": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/$defs/base-comp-object" | ||
}, | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"comp", | ||
"slots" | ||
], | ||
"properties": { | ||
"comp": { | ||
"type": "string", | ||
"const": "slot" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"simple-comp-object": { | ||
@@ -251,2 +253,5 @@ "allOf": [ | ||
"$ref": "#/$defs/expression" | ||
}, | ||
"slots": { | ||
"$ref": "#/$defs/slots" | ||
} | ||
@@ -286,5 +291,37 @@ } | ||
"$ref": "#/$defs/expression" | ||
}, | ||
"slots": { | ||
"$ref": "#/$defs/slots" | ||
} | ||
} | ||
}, | ||
"child-slot": { | ||
"type": "object", | ||
"required": [ | ||
"key", | ||
"comp", | ||
"slots" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"key": { | ||
"type": [ | ||
"string", | ||
"integer" | ||
] | ||
}, | ||
"cols": { | ||
"$ref": "#/$defs/cols-obj" | ||
}, | ||
"comp": { | ||
"const": "slot" | ||
}, | ||
"if": { | ||
"$ref": "#/$defs/expression" | ||
}, | ||
"slots": { | ||
"$ref": "#/$defs/slots" | ||
} | ||
} | ||
}, | ||
"child": { | ||
@@ -299,2 +336,5 @@ "title": "Child", | ||
"$ref": "#/$defs/child-composite" | ||
}, | ||
{ | ||
"$ref": "#/$defs/child-slot" | ||
} | ||
@@ -503,2 +543,23 @@ ] | ||
}, | ||
"slots": { | ||
"type": "object", | ||
"allOf": [ | ||
{ | ||
"$ref": "#/$defs/state-node-slots-lib" | ||
}, | ||
{ | ||
"properties": { | ||
"before": { | ||
"$ref": "#/$defs/slot" | ||
}, | ||
"after": { | ||
"$ref": "#/$defs/slot" | ||
}, | ||
"component": { | ||
"$ref": "#/$defs/slot" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"state-node-options-base": { | ||
@@ -505,0 +566,0 @@ "type": "object", |
@@ -42,15 +42,3 @@ { | ||
"getProps": {"$ref": "#/$defs/expression"}, | ||
"slots": { | ||
"type": "object", | ||
"allOf": [ | ||
{"$ref": "#/$defs/state-node-slots-lib"}, | ||
{ | ||
"properties": { | ||
"before": {"$ref": "#/$defs/slot"}, | ||
"after": {"$ref": "#/$defs/slot"}, | ||
"component": {"$ref": "#/$defs/slot"} | ||
} | ||
} | ||
] | ||
} | ||
"slots": {"$ref": "#/$defs/slots"} | ||
} | ||
@@ -73,2 +61,14 @@ }, | ||
}, | ||
"slot-comp-object": { | ||
"allOf": [ | ||
{"$ref": "#/$defs/base-comp-object"}, | ||
{ | ||
"type": "object", | ||
"required": ["comp", "slots"], | ||
"properties": { | ||
"comp": {"type": "string", "const": "slot"} | ||
} | ||
} | ||
] | ||
}, | ||
"simple-comp-object": { | ||
@@ -136,3 +136,4 @@ "allOf": [ | ||
"cols": {"$ref": "#/$defs/cols-obj"}, | ||
"if": {"$ref": "#/$defs/expression"} | ||
"if": {"$ref": "#/$defs/expression"}, | ||
"slots": {"$ref": "#/$defs/slots"} | ||
} | ||
@@ -151,5 +152,18 @@ }, | ||
"children": {"$ref": "#/$defs/children"}, | ||
"if": {"$ref": "#/$defs/expression"} | ||
"if": {"$ref": "#/$defs/expression"}, | ||
"slots": {"$ref": "#/$defs/slots"} | ||
} | ||
}, | ||
"child-slot": { | ||
"type": "object", | ||
"required": ["key", "comp", "slots"], | ||
"additionalProperties": false, | ||
"properties": { | ||
"key": {"type": ["string", "integer"]}, | ||
"cols": {"$ref": "#/$defs/cols-obj"}, | ||
"comp": {"const": "slot"}, | ||
"if": {"$ref": "#/$defs/expression"}, | ||
"slots": {"$ref": "#/$defs/slots"} | ||
} | ||
}, | ||
"child": { | ||
@@ -159,8 +173,5 @@ "title": "Child", | ||
"oneOf": [ | ||
{ | ||
"$ref": "#/$defs/child-ref" | ||
}, | ||
{ | ||
"$ref": "#/$defs/child-composite" | ||
} | ||
{"$ref": "#/$defs/child-ref"}, | ||
{"$ref": "#/$defs/child-composite"}, | ||
{"$ref": "#/$defs/child-slot"} | ||
] | ||
@@ -289,2 +300,15 @@ }, | ||
}, | ||
"slots": { | ||
"type": "object", | ||
"allOf": [ | ||
{"$ref": "#/$defs/state-node-slots-lib"}, | ||
{ | ||
"properties": { | ||
"before": {"$ref": "#/$defs/slot"}, | ||
"after": {"$ref": "#/$defs/slot"}, | ||
"component": {"$ref": "#/$defs/slot"} | ||
} | ||
} | ||
] | ||
}, | ||
"state-node-options-base": { | ||
@@ -291,0 +315,0 @@ "type": "object", |
@@ -35,2 +35,12 @@ /** | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "slots". | ||
*/ | ||
export type Slots = StateNodeSlotsLib & { | ||
before?: Slot; | ||
after?: Slot; | ||
component?: Slot; | ||
[k: string]: unknown; | ||
}; | ||
/** | ||
* This interface was referenced by `StateNodeSlotsLib`'s JSON-Schema definition | ||
@@ -67,3 +77,3 @@ * via the `patternProperty` ".*". | ||
*/ | ||
export type Child = ChildRef | ChildComposite; | ||
export type Child = ChildRef | ChildComposite | ChildSlot; | ||
/** | ||
@@ -76,2 +86,10 @@ * This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "slot-comp-object". | ||
*/ | ||
export type SlotCompObject = BaseCompObject & { | ||
comp: "slot"; | ||
[k: string]: unknown; | ||
}; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "simple-comp-object". | ||
@@ -163,8 +181,3 @@ */ | ||
getProps?: Expression; | ||
slots?: StateNodeSlotsLib & { | ||
before?: Slot; | ||
after?: Slot; | ||
component?: Slot; | ||
[k: string]: unknown; | ||
}; | ||
slots?: Slots; | ||
[k: string]: unknown; | ||
@@ -236,2 +249,3 @@ } | ||
if?: Expression; | ||
slots?: Slots; | ||
} | ||
@@ -250,5 +264,17 @@ /** | ||
if?: Expression; | ||
slots?: Slots; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "child-slot". | ||
*/ | ||
export interface ChildSlot { | ||
key: string | number; | ||
cols?: ColsObj; | ||
comp: "slot"; | ||
if?: Expression; | ||
slots: Slots; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "select-item". | ||
@@ -255,0 +281,0 @@ */ |
@@ -11,2 +11,11 @@ import type { BaseCompObject, Expression, Children, GetItems, SelectItems } from '../normalized-layout/types.js'; | ||
}); | ||
export type Slot = { | ||
comp?: "slot"; | ||
[k: string]: unknown; | ||
} & BaseCompObject & (BaseCompObject & { | ||
comp: string; | ||
label?: string; | ||
hint?: string | null; | ||
[k: string]: unknown; | ||
}); | ||
export type Section = { | ||
@@ -13,0 +22,0 @@ comp?: "section"; |
@@ -5,2 +5,3 @@ export function isComponentName(layoutKeyword: LayoutKeyword): layoutKeyword is string; | ||
export function isPartialChildComposite(partialChild: PartialChild): partialChild is import("./types.js").PartialChildComposite; | ||
export function isPartialChildSlot(partialChild: PartialChild): partialChild is import("./types.js").PartialChildSlot; | ||
export function isPartialCompObject(layoutKeyword: LayoutKeyword): layoutKeyword is import("./types.js").PartialCompObject; | ||
@@ -11,2 +12,4 @@ export function isPartialGetItemsExpr(getItems: PartialGetItems): getItems is import("./types.js").PartialExpression; | ||
export function isPartialSlotMarkdown(partialSlot: PartialSlot): partialSlot is import("./types.js").PartialSlotMarkdown; | ||
export function isPartialSlotText(partialSlot: PartialSlot): partialSlot is import("./types.js").PartialSlotText; | ||
export function isPartialSlotName(partialSlot: PartialSlot): partialSlot is import("./types.js").PartialSlotName; | ||
/** | ||
@@ -18,2 +21,3 @@ * @typedef {import('./types.js').LayoutKeyword} LayoutKeyword | ||
* @typedef {import('./types.js').PartialChildComposite} PartialChildComposite | ||
* @typedef {import('./types.js').PartialChildSlot} PartialChildSlot | ||
* @typedef {import('./types.js').PartialSwitch} PartialSwitch | ||
@@ -26,2 +30,4 @@ * @typedef {import('./types.js').PartialCompObject} PartialCompObject | ||
* @typedef {import('./types.js').PartialSlotMarkdown} PartialSlotMarkdown | ||
* @typedef {import('./types.js').PartialSlotText} PartialSlotText | ||
* @typedef {import('./types.js').PartialSlotName} PartialSlotName | ||
* @typedef {import('./types.js').PartialSlot} PartialSlot | ||
@@ -38,2 +44,3 @@ * @typedef {import('./types.js').PartialSelectItem} PartialSelectItem | ||
export type PartialChildComposite = import('./types.js').PartialChildComposite; | ||
export type PartialChildSlot = import('./types.js').PartialChildSlot; | ||
export type PartialSwitch = import('./types.js').PartialSwitch; | ||
@@ -46,2 +53,4 @@ export type PartialCompObject = import('./types.js').PartialCompObject; | ||
export type PartialSlotMarkdown = import('./types.js').PartialSlotMarkdown; | ||
export type PartialSlotText = import('./types.js').PartialSlotText; | ||
export type PartialSlotName = import('./types.js').PartialSlotName; | ||
export type PartialSlot = import('./types.js').PartialSlot; | ||
@@ -48,0 +57,0 @@ export type PartialSelectItem = import('./types.js').PartialSelectItem; |
@@ -140,2 +140,10 @@ declare namespace _default { | ||
}; | ||
slots: { | ||
type: string; | ||
patternProperties: { | ||
".*": { | ||
$ref: string; | ||
}; | ||
}; | ||
}; | ||
}; | ||
@@ -165,11 +173,41 @@ }; | ||
}; | ||
slots: { | ||
type: string; | ||
patternProperties: { | ||
".*": { | ||
$ref: string; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
"partial-child-slot": { | ||
type: string; | ||
properties: { | ||
cols: { | ||
$ref: string; | ||
}; | ||
if: { | ||
$ref: string; | ||
}; | ||
}; | ||
oneOf: { | ||
$ref: string; | ||
}[]; | ||
}; | ||
"partial-child": { | ||
anyOf: ({ | ||
type: string; | ||
items?: undefined; | ||
$ref?: undefined; | ||
} | { | ||
type: string; | ||
items: { | ||
$ref: string; | ||
}; | ||
$ref?: undefined; | ||
} | { | ||
$ref: string; | ||
type?: undefined; | ||
items?: undefined; | ||
})[]; | ||
@@ -176,0 +214,0 @@ }; |
@@ -15,3 +15,3 @@ /** | ||
*/ | ||
export type PartialChild = string | PartialChildRef | PartialChildComposite; | ||
export type PartialChild = string | PartialChild[] | PartialChildRef | PartialChildComposite | PartialChildSlot; | ||
/** | ||
@@ -33,3 +33,27 @@ * This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot". | ||
*/ | ||
export type PartialSlot = string | PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
export type PartialChildSlot = { | ||
cols?: PartialCols; | ||
if?: PartialExpression; | ||
[k: string]: unknown; | ||
} & PartialChildSlot1; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-child-slot". | ||
*/ | ||
export type PartialChildSlot1 = PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-children". | ||
@@ -67,10 +91,2 @@ */ | ||
} | PartialExpressionObj | PartialGetItemsFetch); | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` ".*". | ||
* | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot". | ||
*/ | ||
export type PartialSlot = string | PartialSlotText | PartialSlotMarkdown | PartialSlotName; | ||
export interface HttpsJsonLayoutGithubIoLayoutKeyword { | ||
@@ -87,2 +103,5 @@ [k: string]: unknown; | ||
if?: PartialExpression; | ||
slots?: { | ||
[k: string]: PartialSlot; | ||
}; | ||
} | ||
@@ -112,2 +131,23 @@ /** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-text". | ||
*/ | ||
export interface PartialSlotText { | ||
text: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-markdown". | ||
*/ | ||
export interface PartialSlotMarkdown { | ||
markdown: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-name". | ||
*/ | ||
export interface PartialSlotName { | ||
name: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-child-composite". | ||
@@ -122,2 +162,5 @@ */ | ||
if?: PartialExpression; | ||
slots?: { | ||
[k: string]: PartialSlot; | ||
}; | ||
[k: string]: unknown; | ||
@@ -177,23 +220,2 @@ } | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-text". | ||
*/ | ||
export interface PartialSlotText { | ||
text: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-markdown". | ||
*/ | ||
export interface PartialSlotMarkdown { | ||
markdown: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-slot-name". | ||
*/ | ||
export interface PartialSlotName { | ||
name: string; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "partial-switch". | ||
@@ -200,0 +222,0 @@ */ |
export function isSwitchStruct(layout: NormalizedLayout): layout is import("./types.js").SwitchStruct; | ||
export function isCompObject(layout: NormalizedLayout): layout is import("./types.js").BaseCompObject; | ||
export function childIsCompObject(child: Child): child is import("./types.js").Child & import("./types.js").BaseCompObject & { | ||
export function childIsCompositeCompObject(child: Child): child is import("./types.js").Child & import("./types.js").BaseCompObject & { | ||
[k: string]: unknown; | ||
@@ -10,2 +10,6 @@ comp: string; | ||
}; | ||
export function childIsSlotCompObject(child: Child): child is import("./types.js").Child & import("./types.js").BaseCompObject & { | ||
[k: string]: unknown; | ||
comp: "slot"; | ||
}; | ||
export function isCompositeLayout(layout: BaseCompObject, components: Record<string, import('../types.js').ComponentInfo>): layout is import("./types.js").CompositeCompObject; | ||
@@ -35,3 +39,5 @@ export function isListLayout(layout: BaseCompObject): layout is import("../components/types.js").List; | ||
* @typedef {import('./types.js').Children} Children | ||
* @typedef {import('./types.js').ChildSlot} ChildSlot | ||
* @typedef {import('./types.js').CompositeCompObject} CompositeCompObject | ||
* @typedef {import('./types.js').SlotCompObject} SlotCompObject | ||
* @typedef {import('./types.js').ItemsBasedCompObject} ItemsBasedCompObject | ||
@@ -46,2 +52,3 @@ * @typedef {import('./types.js').FocusableCompObject} FocusableCompObject | ||
* @typedef {import('./types.js').Slot} Slot | ||
* @typedef {import('./types.js').Slots} Slots | ||
* @typedef {{ errors: any, (layoutKeyword: any): layoutKeyword is NormalizedLayout }} ValidateNormalizedLayout | ||
@@ -59,3 +66,5 @@ */ | ||
export type Children = import('./types.js').Children; | ||
export type ChildSlot = import('./types.js').ChildSlot; | ||
export type CompositeCompObject = import('./types.js').CompositeCompObject; | ||
export type SlotCompObject = import('./types.js').SlotCompObject; | ||
export type ItemsBasedCompObject = import('./types.js').ItemsBasedCompObject; | ||
@@ -70,2 +79,3 @@ export type FocusableCompObject = import('./types.js').FocusableCompObject; | ||
export type Slot = import('./types.js').Slot; | ||
export type Slots = import('./types.js').Slots; | ||
export type ValidateNormalizedLayout = { | ||
@@ -72,0 +82,0 @@ (layoutKeyword: any): layoutKeyword is import("./types.js").NormalizedLayout; |
@@ -68,20 +68,3 @@ declare namespace _default { | ||
slots: { | ||
type: string; | ||
allOf: ({ | ||
$ref: string; | ||
properties?: undefined; | ||
} | { | ||
properties: { | ||
before: { | ||
$ref: string; | ||
}; | ||
after: { | ||
$ref: string; | ||
}; | ||
component: { | ||
$ref: string; | ||
}; | ||
}; | ||
$ref?: undefined; | ||
})[]; | ||
$ref: string; | ||
}; | ||
@@ -116,2 +99,20 @@ }; | ||
}; | ||
"slot-comp-object": { | ||
allOf: ({ | ||
$ref: string; | ||
type?: undefined; | ||
required?: undefined; | ||
properties?: undefined; | ||
} | { | ||
type: string; | ||
required: string[]; | ||
properties: { | ||
comp: { | ||
type: string; | ||
const: string; | ||
}; | ||
}; | ||
$ref?: undefined; | ||
})[]; | ||
}; | ||
"simple-comp-object": { | ||
@@ -220,2 +221,5 @@ allOf: ({ | ||
}; | ||
slots: { | ||
$ref: string; | ||
}; | ||
}; | ||
@@ -249,4 +253,29 @@ }; | ||
}; | ||
slots: { | ||
$ref: string; | ||
}; | ||
}; | ||
}; | ||
"child-slot": { | ||
type: string; | ||
required: string[]; | ||
additionalProperties: boolean; | ||
properties: { | ||
key: { | ||
type: string[]; | ||
}; | ||
cols: { | ||
$ref: string; | ||
}; | ||
comp: { | ||
const: string; | ||
}; | ||
if: { | ||
$ref: string; | ||
}; | ||
slots: { | ||
$ref: string; | ||
}; | ||
}; | ||
}; | ||
child: { | ||
@@ -432,2 +461,22 @@ title: string; | ||
}; | ||
slots: { | ||
type: string; | ||
allOf: ({ | ||
$ref: string; | ||
properties?: undefined; | ||
} | { | ||
properties: { | ||
before: { | ||
$ref: string; | ||
}; | ||
after: { | ||
$ref: string; | ||
}; | ||
component: { | ||
$ref: string; | ||
}; | ||
}; | ||
$ref?: undefined; | ||
})[]; | ||
}; | ||
"state-node-options-base": { | ||
@@ -434,0 +483,0 @@ type: string; |
@@ -35,2 +35,12 @@ /** | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "slots". | ||
*/ | ||
export type Slots = StateNodeSlotsLib & { | ||
before?: Slot; | ||
after?: Slot; | ||
component?: Slot; | ||
[k: string]: unknown; | ||
}; | ||
/** | ||
* This interface was referenced by `StateNodeSlotsLib`'s JSON-Schema definition | ||
@@ -64,3 +74,3 @@ * via the `patternProperty` ".*". | ||
*/ | ||
export type Child = ChildRef | ChildComposite; | ||
export type Child = ChildRef | ChildComposite | ChildSlot; | ||
/** | ||
@@ -73,2 +83,10 @@ * This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "slot-comp-object". | ||
*/ | ||
export type SlotCompObject = BaseCompObject & { | ||
comp: "slot"; | ||
[k: string]: unknown; | ||
}; | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "simple-comp-object". | ||
@@ -159,8 +177,3 @@ */ | ||
getProps?: Expression; | ||
slots?: StateNodeSlotsLib & { | ||
before?: Slot; | ||
after?: Slot; | ||
component?: Slot; | ||
[k: string]: unknown; | ||
}; | ||
slots?: Slots; | ||
[k: string]: unknown; | ||
@@ -232,2 +245,3 @@ } | ||
if?: Expression; | ||
slots?: Slots; | ||
} | ||
@@ -246,5 +260,17 @@ /** | ||
if?: Expression; | ||
slots?: Slots; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "child-slot". | ||
*/ | ||
export interface ChildSlot { | ||
key: string | number; | ||
cols?: ColsObj; | ||
comp: "slot"; | ||
if?: Expression; | ||
slots: Slots; | ||
} | ||
/** | ||
* This interface was referenced by `HttpsJsonLayoutGithubIoNormalizedLayoutKeyword`'s JSON-Schema | ||
* via the `definition` "select-item". | ||
@@ -251,0 +277,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
215096
6160