@bettercms-ai/kit 2.0.11 → 3.0.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.
Files changed (108) hide show
  1. package/README.md +1 -2
  2. package/dist/adapters/schema.js +45 -5
  3. package/dist/adapters/schema.js.map +1 -1
  4. package/dist/brand/logo.js.map +1 -1
  5. package/dist/context.d.ts +7 -0
  6. package/dist/context.js +6 -1
  7. package/dist/context.js.map +1 -1
  8. package/dist/controls/button.js +1 -1
  9. package/dist/controls/code.d.ts +24 -1
  10. package/dist/controls/code.js +36 -20
  11. package/dist/controls/code.js.map +1 -1
  12. package/dist/controls/icon.d.ts +28 -0
  13. package/dist/controls/icon.js +205 -61
  14. package/dist/controls/icon.js.map +1 -1
  15. package/dist/controls/index.d.ts +20 -2
  16. package/dist/controls/index.js +21 -20
  17. package/dist/controls/index.js.map +1 -1
  18. package/dist/controls/link.js +4 -4
  19. package/dist/controls/link.js.map +1 -1
  20. package/dist/controls/location.js +1 -1
  21. package/dist/controls/media.js +2 -2
  22. package/dist/controls/reference.js +3 -2
  23. package/dist/controls/reference.js.map +1 -1
  24. package/dist/controls/rich-text/blocks.js +2 -2
  25. package/dist/controls/rich-text/control.js +1 -1
  26. package/dist/controls/rich-text/editor.js +5 -5
  27. package/dist/controls/rich-text/embed.js +1 -1
  28. package/dist/controls/rich-text/toc.js +1 -1
  29. package/dist/controls/slot-register.js +1 -1
  30. package/dist/controls/table/table.js +1 -1
  31. package/dist/controls/text.js +5 -4
  32. package/dist/controls/text.js.map +1 -1
  33. package/dist/core/core.js +1 -1
  34. package/dist/engine/array.js +58 -13
  35. package/dist/engine/array.js.map +1 -1
  36. package/dist/engine/bits.js +1 -1
  37. package/dist/engine/breadcrumb.js +1 -1
  38. package/dist/engine/expand.js +1 -1
  39. package/dist/engine/field-shell.js +8 -7
  40. package/dist/engine/field-shell.js.map +1 -1
  41. package/dist/engine/frame.d.ts +1 -12
  42. package/dist/engine/frame.js +7 -149
  43. package/dist/engine/frame.js.map +1 -1
  44. package/dist/engine/group-summary.js +7 -4
  45. package/dist/engine/group-summary.js.map +1 -1
  46. package/dist/engine/grouping.js +2 -2
  47. package/dist/engine/item-list.js +2 -2
  48. package/dist/engine/kit-field.js +3 -7
  49. package/dist/engine/kit-field.js.map +1 -1
  50. package/dist/engine/schema-form.d.ts +10 -5
  51. package/dist/engine/schema-form.js +18 -10
  52. package/dist/engine/schema-form.js.map +1 -1
  53. package/dist/engine/slot.js +2 -2
  54. package/dist/index.d.ts +9 -9
  55. package/dist/index.js +32 -6
  56. package/dist/index.js.map +1 -1
  57. package/dist/kit.css +3 -11
  58. package/dist/lib/cn.js.map +1 -1
  59. package/dist/lib/frames.js +1 -1
  60. package/dist/lib/schema.d.ts +8 -1
  61. package/dist/lib/schema.js +18 -2
  62. package/dist/lib/schema.js.map +1 -1
  63. package/dist/lib/utils.d.ts +1 -4
  64. package/dist/lib/utils.js +4 -14
  65. package/dist/lib/utils.js.map +1 -1
  66. package/dist/lib/validate.d.ts +14 -1
  67. package/dist/lib/validate.js +26 -10
  68. package/dist/lib/validate.js.map +1 -1
  69. package/dist/library/coreNotes.d.ts +1 -1
  70. package/dist/library/coreNotes.js.map +1 -1
  71. package/dist/library/entries/conversion.entries.js +8 -0
  72. package/dist/library/entries/conversion.entries.js.map +1 -1
  73. package/dist/library/entries/features.entries.js +5 -0
  74. package/dist/library/entries/features.entries.js.map +1 -1
  75. package/dist/library/examples/faq.js +1 -0
  76. package/dist/library/examples/faq.js.map +1 -1
  77. package/dist/library/examples/journalStory.js +1 -2
  78. package/dist/library/examples/journalStory.js.map +1 -1
  79. package/dist/library/kit-catalog.json +4 -4
  80. package/dist/schema/adapters.js +17 -3
  81. package/dist/schema/adapters.js.map +1 -1
  82. package/dist/schema/sources.d.ts +9 -1
  83. package/dist/schema/sources.js +1 -1
  84. package/dist/schema/sources.js.map +1 -1
  85. package/dist/schema/types.d.ts +31 -3
  86. package/dist/schema/types.js.map +1 -1
  87. package/dist/styles.css +1 -1
  88. package/dist/table/table.css +1 -1
  89. package/dist/theme.css +18 -9
  90. package/dist/tokens.css +32 -60
  91. package/dist/ui/action-tray.d.ts +1 -3
  92. package/dist/ui/action-tray.js +3 -20
  93. package/dist/ui/action-tray.js.map +1 -1
  94. package/dist/ui/display.d.ts +1 -4
  95. package/dist/ui/display.js +4 -6
  96. package/dist/ui/display.js.map +1 -1
  97. package/dist/ui/index.js +3 -3
  98. package/dist/ui/overlay.d.ts +2 -5
  99. package/dist/ui/overlay.js +3 -4
  100. package/dist/ui/overlay.js.map +1 -1
  101. package/dist/ui/path-crumbs.d.ts +0 -2
  102. package/dist/ui/path-crumbs.js.map +1 -1
  103. package/dist/ui/surfaces.d.ts +2 -18
  104. package/dist/ui/surfaces.js +3 -19
  105. package/dist/ui/surfaces.js.map +1 -1
  106. package/dist/ui/toast.js +1 -1
  107. package/dist/ui/toast.js.map +1 -1
  108. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/lib/schema.ts"],"sourcesContent":["/**\n * Schema helpers — pure functions the engine uses to decide HOW a field is edited and WHAT a row shows.\n */\nimport type { Condition, FieldSchema, OpenMode, PrimitiveType, SchemaType, TypeSchema } from \"../schema/types\";\nimport { getIn, isObj, newKey } from \"./path\";\nimport { fitOf, type MediaFit } from \"./media-fit\";\nimport { cellValue, isEmptyCell, isTableValue, tableSummary } from \"../schema/table\";\n\nconst PRIMITIVES: ReadonlySet<SchemaType> = new Set<PrimitiveType>([\n \"string\", \"text\", \"richtext\", \"number\", \"boolean\", \"slug\", \"url\", \"email\", \"date\", \"datetime\", \"color\", \"select\", \"multiselect\",\n \"tags\", \"image\", \"file\", \"video\", \"icon\", \"link\", \"button\", \"reference\", \"code\", \"json\", \"geopoint\", \"rating\", \"table\",\n]);\nexport const isPrimitive = (t: SchemaType) => PRIMITIVES.has(t);\n/** Types whose value is plain text (counters, AI rewrite, copy/paste as text). */\nexport const isTextual = (t: SchemaType) => t === \"string\" || t === \"text\" || t === \"richtext\" || t === \"slug\" || t === \"url\" || t === \"email\";\n/** Types that are cheap to show inline inside a small object (no heavy surfaces). */\nconst INLINE_OK: ReadonlySet<SchemaType> = new Set([\"string\", \"number\", \"boolean\", \"select\", \"color\", \"icon\", \"url\", \"email\", \"date\", \"rating\", \"slug\"]);\n\nexport const itemSchemas = (f: FieldSchema): FieldSchema[] => (Array.isArray(f.of) ? f.of : []);\nexport const slotAllow = (f: FieldSchema): string[] | undefined => (f.of && !Array.isArray(f.of) ? f.of.allow : undefined);\nexport const itemSchemaFor = (f: FieldSchema, item: unknown): FieldSchema | undefined => {\n const of = itemSchemas(f);\n if (isObj(item) && typeof item._type === \"string\") return of.find((o) => o.name === item._type) ?? of[0];\n return of[0];\n};\n/** An array whose single item type is a primitive (tags, gallery, references, list of strings). */\nexport const primitiveItem = (f: FieldSchema): FieldSchema | undefined => {\n const of = itemSchemas(f);\n return of.length === 1 && isPrimitive(of[0].type) ? of[0] : undefined;\n};\nexport const isSmallObject = (fields: FieldSchema[] = []) => fields.length > 0 && fields.length <= 3 && fields.every((f) => INLINE_OK.has(f.type));\n\n/** How an object field / array item opens (CPO D8: inline for ≤3 primitives, else drill). */\nexport function objectOpenMode(f: FieldSchema): OpenMode {\n if (f.openMode) return f.openMode;\n return isSmallObject(f.fields) ? \"inline\" : \"drill\";\n}\n/**\n * CPO D43 — one rule for rows: an item of ≤3 simple fields (text, number, switch, select, colour, icon, url, email,\n * date, rating, slug) EXPANDS inline under its row; anything bigger, nested or rich DRILLS into its own frame.\n * `openMode` on the array still wins (developer override). Several item types → drill (they rarely share a shape).\n */\nexport function itemOpenMode(arrayField: FieldSchema): OpenMode {\n if (arrayField.openMode) return arrayField.openMode;\n const of = itemSchemas(arrayField);\n return of.length === 1 && isSmallObject(of[0].fields) ? \"inline\" : \"drill\";\n}\n\nexport function emptyFor(f: FieldSchema): unknown {\n switch (f.type) {\n case \"boolean\": return false;\n case \"number\": case \"rating\": return null;\n case \"multiselect\": case \"tags\": case \"array\": case \"slot\": return [];\n case \"object\": return objectInitial(f.fields ?? []);\n case \"image\": case \"file\": case \"video\": case \"reference\": case \"link\": case \"button\": case \"geopoint\": case \"json\": case \"table\": return null;\n default: return \"\";\n }\n}\nexport const initialFor = (f: FieldSchema) => (f.initialValue !== undefined ? structuredCloneSafe(f.initialValue) : emptyFor(f));\nexport function objectInitial(fields: FieldSchema[]): Record<string, unknown> {\n const o: Record<string, unknown> = {};\n for (const f of fields) if (f.initialValue !== undefined) o[f.name] = structuredCloneSafe(f.initialValue);\n return o;\n}\n/** A new array item for `itemSchema` (stamped with `_key` and, when the array allows several types, `_type`). */\nexport function newItem(arrayField: FieldSchema, itemSchema: FieldSchema): unknown {\n if (isPrimitive(itemSchema.type)) return initialFor(itemSchema);\n const base = itemSchema.initialValue && isObj(itemSchema.initialValue) ? structuredCloneSafe(itemSchema.initialValue) : objectInitial(itemSchema.fields ?? []);\n const multi = itemSchemas(arrayField).length > 1;\n return { _key: newKey(), ...(multi ? { _type: itemSchema.name } : {}), ...(base as object) };\n}\nexport function newBlock(block: TypeSchema, settings?: FieldSchema[]): Record<string, unknown> {\n const init = block.initialValue ? structuredCloneSafe(block.initialValue) : objectInitial(block.fields);\n const s = settings?.length ? { _settings: objectInitial(settings) } : {};\n return { _key: newKey(), _type: block.name, ...(block.variants?.[0] ? { _variant: block.variants[0].id } : {}), ...s, ...(init as object) };\n}\nexport function structuredCloneSafe<T>(v: T): T {\n try {\n return structuredClone(v);\n } catch {\n return JSON.parse(JSON.stringify(v)) as T;\n }\n}\n\n/* ── Conditions ───────────────────────────────────────────────────────── */\n/**\n * What a condition can read beyond the fields beside it (V2 kit lib/schema.ts CondCtx): the object that holds them\n * (`parent`), the top of the component or CMS item (`root`) and its variant. Callers that don't pass it get the sibling\n * rules only; a `_variant` rule that can't be read then counts as met (the field shows), never as a silent hide.\n */\nexport interface CondCtx {\n parent?: unknown;\n root?: unknown;\n /** the component's variant id, its first variant when the value has none */\n variant?: string;\n}\n/** The condition context for fields under `basePath` of a form (the nearest slot child is the component's root). V2 condCtx. */\nexport function condCtx(form: { schema: TypeSchema; getAt: (p: (string | number)[]) => unknown; resolveSchema?: (t: string) => TypeSchema | undefined }, basePath: (string | number)[]): CondCtx {\n const up = (p: (string | number)[]) => {\n const q = [...p];\n // the container may be a list item ([\"items\", 0]): the object holding it is one key further up\n while (q.length && typeof q[q.length - 1] === \"number\") q.pop();\n q.pop();\n return q;\n };\n let rootPath: (string | number)[] = [];\n let rootSchema: TypeSchema | undefined = form.schema;\n for (let i = basePath.length; i > 0; i--) {\n const v = form.getAt(basePath.slice(0, i));\n if (isObj(v) && typeof v._type === \"string\" && typeof basePath[i - 1] === \"number\") {\n rootPath = basePath.slice(0, i);\n rootSchema = form.resolveSchema?.(v._type);\n break;\n }\n }\n const root = form.getAt(rootPath);\n const own = isObj(root) && typeof root._variant === \"string\" ? root._variant : undefined;\n return { parent: basePath.length > rootPath.length ? form.getAt(up(basePath)) : undefined, root, variant: own ?? rootSchema?.variants?.[0]?.id };\n}\n\nconst num = (v: unknown) => (typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" && !Number.isNaN(Number(v)) ? Number(v) : typeof v === \"string\" && !Number.isNaN(Date.parse(v)) ? Date.parse(v) : NaN);\n/** One rule (V2 ruleHolds): true when it holds, null when it can't be read here (no context). */\nfunction ruleHolds(c: Condition, siblings: unknown, ctx: CondCtx | undefined): boolean | null {\n let v: unknown;\n if (c.field === \"_variant\" && !c.scope) {\n if (isObj(siblings) && typeof siblings._variant === \"string\") v = siblings._variant;\n else if (ctx) v = ctx.variant;\n else return null;\n } else if (c.scope) {\n if (!ctx) return null;\n const from = c.scope === \"root\" ? ctx.root : ctx.parent;\n v = c.field === \"_variant\" ? ctx.variant : isObj(from) ? from[c.field] : undefined;\n } else v = isObj(siblings) ? siblings[c.field] : undefined;\n const op = c.op ?? (c.notEmpty ? \"notEmpty\" : c.equals !== undefined ? (Array.isArray(c.equals) ? \"in\" : \"is\") : null);\n const target = c.op ? c.value : c.equals;\n const list = Array.isArray(target) ? target : [target];\n const has = (x: unknown) => list.some((y) => y === x || (Array.isArray(x) && x.includes(y as never)));\n switch (op) {\n case \"notEmpty\": return !isEmptyValue(v);\n case \"empty\": return isEmptyValue(v);\n case \"is\":\n case \"in\": return has(v);\n case \"isNot\":\n case \"notIn\": return !has(v);\n case \"gt\": return num(v) > num(target);\n case \"lt\": return num(v) < num(target);\n default: return true;\n }\n}\n\n/** `hidden: true` hides; a Condition SHOWS the field only while its rules hold (types.ts contract). A rule it can't read\n * here (a `_variant` or scoped rule with no context) holds, so the field shows. V2 isHidden. */\nexport function isHidden(f: FieldSchema, parent: unknown, ctx?: CondCtx): boolean {\n if (f.hidden === true) return true;\n if (!f.hidden) return false;\n const c = f.hidden as Condition;\n const met = [c, ...(c.also ?? [])].map((r) => ruleHolds(r, parent, ctx) ?? true);\n return !(c.match === \"any\" ? met.some(Boolean) : met.every(Boolean));\n}\n\n/* ── Values → text ────────────────────────────────────────────────────── */\n/** Portable Text blocks' text, one block per space; \"\" when the array holds no blocks (a list of items). */\nconst blocksText = (v: unknown[]): string =>\n v\n .map((b) => (isObj(b) && Array.isArray(b.children) ? b.children.map((c) => (isObj(c) && typeof c.text === \"string\" ? c.text : \"\")).join(\"\") : \"\"))\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \")\n .trim();\nconst NAMED_ENTITIES: Record<string, string> = { amp: \"&\", lt: \"<\", gt: \">\", quot: '\"', apos: \"'\", nbsp: \" \" };\n/**\n * Markup's character references as the characters they stand for, AFTER the tags are gone (so a decoded `&lt;b&gt;`\n * stays words). Named ones a rich text editor writes, and every numeric one; anything else is left as written.\n */\nconst decodeEntities = (s: string): string =>\n s.replace(/&(#x[0-9a-f]+|#\\d+|[a-z]+);/gi, (whole, ref: string) => {\n if (ref[0] !== \"#\") return NAMED_ENTITIES[ref.toLowerCase()] ?? whole;\n const code = ref[1] === \"x\" || ref[1] === \"X\" ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);\n return Number.isFinite(code) && code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;\n });\n/**\n * A value as one line of text. Stored rich text reads as its words in every shape production keeps: an html string,\n * Portable Text blocks, the component props envelope `{ content: { version, content: blocks }, html }`, and the field\n * envelope `{ format, value: blocks, html }`.\n *\n * 🔴 An html string's words are DECODED: a row titled by `<p>Advisors &amp; specialists</p>` read \"Advisors &amp;\n * specialists\" in the dock (marby-astro QA, 2026-10-22).\n */\nexport const plainText = (v: unknown): string => {\n if (typeof v === \"string\") return decodeEntities(v.replace(/<[^>]*>/g, \" \")).replace(/\\s+/g, \" \").trim();\n if (typeof v === \"number\") return String(v);\n if (Array.isArray(v)) return blocksText(v);\n if (isObj(v)) {\n if (typeof v.label === \"string\" && v.label) return v.label;\n if (typeof v.title === \"string\") return v.title;\n if (typeof v.href === \"string\") return v.href;\n if (typeof v.name === \"string\") return v.name;\n // the envelope's blocks first: their text is unescaped (the html holds `&amp;`)\n if (\"content\" in v && typeof v.content === \"object\" && v.content !== null) {\n const t = plainText(v.content);\n if (t) return t;\n }\n if (Array.isArray(v.value)) {\n const t = blocksText(v.value);\n if (t) return t;\n }\n if (typeof v.html === \"string\") return plainText(v.html);\n }\n return \"\";\n};\nexport function isEmptyValue(v: unknown): boolean {\n if (v == null) return true;\n if (typeof v === \"string\") return plainText(v) === \"\" && !/<img|<hr|<table|data-block|data-embed/.test(v);\n if (Array.isArray(v)) return v.length === 0;\n if (isTableValue(v)) return !v.caption?.trim() && v.rows.every((r) => Object.values(r.cells ?? {}).every((c) => isEmptyCell(cellValue(c))));\n if (isObj(v)) {\n if (\"url\" in v) return !v.url;\n if (\"href\" in v && !(\"label\" in v)) return !v.href;\n if (\"label\" in v && \"href\" in v) return !v.label && !v.href;\n return Object.keys(v).filter((k) => !k.startsWith(\"_\")).every((k) => isEmptyValue(v[k]));\n }\n return false;\n}\nexport const imageUrl = (v: unknown): string | undefined =>\n typeof v === \"string\" && /^(https?:|blob:|data:image|\\/)/.test(v) ? v : isObj(v) && typeof v.url === \"string\" && v.url ? v.url : undefined;\n\n/** Singular noun for an array's items: itemNoun → item title → field title minus \"s\". */\nexport function itemNoun(f: FieldSchema): string {\n if (f.itemNoun) return f.itemNoun;\n const of = itemSchemas(f);\n if (of.length === 1 && of[0].title && !isPrimitive(of[0].type)) return of[0].title.toLowerCase();\n const t = f.title.toLowerCase();\n return t.endsWith(\"ies\") ? `${t.slice(0, -3)}y` : t.endsWith(\"s\") ? t.slice(0, -1) : \"item\";\n}\n\n/* ── Previews (array rows, slot rows, crumbs) ─────────────────────────── */\nexport interface Preview {\n title: string;\n subtitle?: string;\n media?: string;\n /** fitOf for `media`, from its value and the field it came from (a logo, an icon, a stored strip shape) */\n mediaFit?: MediaFit;\n icon?: string;\n empty: boolean;\n}\n/** Display text of one field value (select → option label). */\nfunction fieldText(f: FieldSchema | undefined, v: unknown): string {\n if (f?.type === \"select\") return f.options?.find((o) => o.value === v)?.label ?? plainText(v);\n return plainText(v);\n}\nfunction firstText(fields: FieldSchema[], v: Record<string, unknown>, skip?: string) {\n for (const f of fields) {\n if (f.name === skip) continue;\n if (f.type === \"select\") {\n const t = fieldText(f, v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n if (f.type === \"string\" || f.type === \"text\" || f.type === \"richtext\" || f.type === \"number\") {\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n if (f.type === \"button\" || f.type === \"link\") {\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n }\n // no prose anywhere: a URL or address still beats \"Item 3\" (D47 — item titles use the first text value)\n for (const f of fields) {\n if (f.name === skip || (f.type !== \"url\" && f.type !== \"email\" && f.type !== \"slug\")) continue;\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n return undefined;\n}\nexport function previewOf(itemSchema: FieldSchema | TypeSchema | undefined, item: unknown, index: number, fallbackTitle?: string): Preview {\n const v = isObj(item) ? item : {};\n const fields = (itemSchema && \"fields\" in itemSchema ? itemSchema.fields : undefined) ?? [];\n const cfg = itemSchema?.preview;\n const at = (p: string) => fieldText(fields.find((f) => f.name === p), getIn(v, p.split(\".\")));\n // what the row picks for itself never comes from a hidden field (a decorative chevron or icon); a named path still reads\n const shown = fields.filter((f) => f.hidden !== true);\n let title = cfg?.title ? at(cfg.title) : \"\";\n let titleField = cfg?.title;\n if (!title) {\n const t = firstText(shown, v);\n title = t?.text ?? \"\";\n titleField = t?.name;\n }\n let subtitle = cfg?.subtitle ? at(cfg.subtitle) : \"\";\n if (!subtitle && !cfg?.subtitle) subtitle = firstText(shown, v, titleField)?.text ?? \"\";\n let media = cfg?.media ? imageUrl(getIn(v, cfg.media.split(\".\"))) : undefined;\n let mediaFit = cfg?.media && media ? fitOf(getIn(v, cfg.media.split(\".\")), fields.find((f) => f.name === cfg.media) ?? { name: cfg.media }, undefined, true) : undefined;\n if (!media && !cfg?.media) {\n const img = shown.find((f) => f.type === \"image\");\n if (img) media = imageUrl(v[img.name]);\n if (img && media) mediaFit = fitOf(v[img.name], img, undefined, true);\n }\n const empty = !title;\n const noun = fallbackTitle ?? (itemSchema?.title ?? \"Item\");\n return {\n title: title || cfg?.fallback || `${noun} ${index + 1}`,\n subtitle: subtitle ? (subtitle.length > 90 ? `${subtitle.slice(0, 88)}…` : subtitle) : undefined,\n media,\n mediaFit,\n icon: cfg?.icon ?? (itemSchema as FieldSchema | undefined)?.icon,\n empty,\n };\n}\n\n/**\n * How one slot child reads as a row (SlotField): its block's preview (the block's title while it has no text), the\n * variant chip its `_variant` names, and the line under it (block title · settings, else description, else \"Block i of n\").\n */\nexport function slotRowOf(block: TypeSchema | undefined, item: unknown, index: number, count: number, slotSettings?: FieldSchema[]): { preview: Preview; chip?: string; extra: string } {\n const pv = previewOf(block, item, index, block?.title ?? \"Block\");\n const variant = block?.variants?.find((v) => isObj(item) && v.id === item._variant)?.name;\n const settings = slotSettings && isObj(item) ? summarize(slotSettings, item._settings, 2) : \"\";\n return {\n preview: { ...pv, title: pv.empty ? (block?.title ?? \"Unknown block\") : pv.title, icon: block?.icon ?? \"box\" },\n chip: variant,\n extra: [pv.empty ? undefined : block?.title, settings].filter(Boolean).join(\" · \") || block?.description || `Block ${index + 1} of ${count}`,\n };\n}\n\n/** \"Cast iron · 4 items\" — one-line summary of an object for collapsed rows and fieldset headers. */\nexport function summarize(fields: FieldSchema[], v: unknown, max = 2): string {\n if (!isObj(v)) return \"\";\n const parts: string[] = [];\n for (const f of fields) {\n if (parts.length >= max) break;\n const x = v[f.name];\n if (isEmptyValue(x)) continue;\n if (f.type === \"reference\" || f.type === \"json\" || f.type === \"code\" || f.type === \"image\" || f.type === \"file\") continue; // ids and blobs read badly\n if (f.type === \"table\") {\n parts.push(tableSummary(x));\n continue;\n }\n if (f.type === \"rating\" && typeof x === \"number\") {\n parts.push(`${x} / 5`);\n continue;\n }\n if (Array.isArray(x)) parts.push(`${x.length} ${x.length === 1 ? itemNounSafe(f) : `${itemNounSafe(f)}s`}`);\n else if (typeof x === \"boolean\") parts.push(`${f.title}: ${x ? \"on\" : \"off\"}`);\n else {\n const t = fieldText(f, x);\n if (t) parts.push(t.length > 40 ? `${t.slice(0, 38)}…` : t);\n }\n }\n return parts.join(\" · \");\n}\nconst itemNounSafe = (f: FieldSchema) => (f.type === \"array\" || f.type === \"slot\" ? itemNoun(f) : \"item\");\n"],"mappings":";;;;AAQA,IAAM,6BAAsC,IAAI,IAAmB;CACjE;CAAU;CAAQ;CAAY;CAAU;CAAW;CAAQ;CAAO;CAAS;CAAQ;CAAY;CAAS;CAAU;CAClH;CAAQ;CAAS;CAAQ;CAAS;CAAQ;CAAQ;CAAU;CAAa;CAAQ;CAAQ;CAAY;CAAU;AACjH,CAAC;AACD,IAAa,eAAe,MAAkB,WAAW,IAAI,CAAC;;AAE9D,IAAa,aAAa,MAAkB,MAAM,YAAY,MAAM,UAAU,MAAM,cAAc,MAAM,UAAU,MAA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,QAAQ,EAAE,MAAM;CACvI;AACF;;AAGA,SAAgB,UAAU,QAAuB,GAAY,MAAM,GAAW;CAC5E,IAAI,CAAC,MAAM,CAAC,GAAG,OAAO;CACtB,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,KAAK,QAAQ;EACtB,IAAI,MAAM,UAAU,KAAK;EACzB,MAAM,IAAI,EAAE,EAAE;EACd,IAAI,aAAa,CAAC,GAAG;EACrB,IAAI,EAAE,SAAS,eAAe,EAAE,SAAS,UAAU,EAAE,SAAS,UAAU,EAAE,SAAS,WAAW,EAAE,SAAS,QAAQ;EACjH,IAAI,EAAE,SAAS,SAAS;GACtB,MAAM,KAAK,aAAa,CAAC,CAAC;GAC1B;EACF;EACA,IAAI,EAAE,SAAS,YAAY,OAAO,MAAM,UAAU;GAChD,MAAM,KAAK,GAAG,EAAE,KAAK;GACrB;EACF;EACA,IAAI,MAAM,QAAQ,CAAC,GAAG,MAAM,KAAK,GAAG,EAAE,OAAO,GAAG,EAAE,WAAW,IAAI,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,EAAE,IAAI;OACrG,IAAI,OAAO,MAAM,WAAW,MAAM,KAAK,GAAG,EAAE,MAAM,IAAI,IAAI,OAAO,OAAO;OACxE;GACH,MAAM,IAAI,UAAU,GAAG,CAAC;GACxB,IAAI,GAAG,MAAM,KAAK,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,CAAC;EAC5D;CACF;CACA,OAAO,MAAM,KAAK,KAAK;AACzB;AACA,IAAM,gBAAgB,MAAoB,EAAE,SAAS,WAAW,EAAE,SAAS,SAAS,SAAS,CAAC,IAAI"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/lib/schema.ts"],"sourcesContent":["/**\n * Schema helpers — pure functions the engine uses to decide HOW a field is edited and WHAT a row shows.\n */\nimport type { Condition, FieldSchema, OpenMode, PrimitiveType, ReferenceFilter, SchemaType, TypeSchema } from \"../schema/types\";\nimport { getIn, isObj, newKey } from \"./path\";\nimport { fitOf, type MediaFit } from \"./media-fit\";\nimport { cellValue, isEmptyCell, isTableValue, tableSummary } from \"../schema/table\";\n\nconst PRIMITIVES: ReadonlySet<SchemaType> = new Set<PrimitiveType>([\n \"string\", \"text\", \"richtext\", \"number\", \"boolean\", \"slug\", \"url\", \"email\", \"date\", \"datetime\", \"color\", \"select\", \"multiselect\",\n \"tags\", \"image\", \"file\", \"video\", \"icon\", \"link\", \"button\", \"reference\", \"code\", \"json\", \"geopoint\", \"rating\", \"table\",\n]);\nexport const isPrimitive = (t: SchemaType) => PRIMITIVES.has(t);\n/** Types whose value is plain text (counters, AI rewrite, copy/paste as text). */\nexport const isTextual = (t: SchemaType) => t === \"string\" || t === \"text\" || t === \"richtext\" || t === \"slug\" || t === \"url\" || t === \"email\";\n/** Types that are cheap to show inline inside a small object (no heavy surfaces). */\nconst INLINE_OK: ReadonlySet<SchemaType> = new Set([\"string\", \"number\", \"boolean\", \"select\", \"color\", \"icon\", \"url\", \"email\", \"date\", \"rating\", \"slug\"]);\n\nexport const itemSchemas = (f: FieldSchema): FieldSchema[] => (Array.isArray(f.of) ? f.of : []);\nexport const slotAllow = (f: FieldSchema): string[] | undefined => (f.of && !Array.isArray(f.of) ? f.of.allow : undefined);\nexport const itemSchemaFor = (f: FieldSchema, item: unknown): FieldSchema | undefined => {\n const of = itemSchemas(f);\n if (isObj(item) && typeof item._type === \"string\") return of.find((o) => o.name === item._type) ?? of[0];\n return of[0];\n};\n/** An array whose single item type is a primitive (tags, gallery, references, list of strings). */\nexport const primitiveItem = (f: FieldSchema): FieldSchema | undefined => {\n const of = itemSchemas(f);\n return of.length === 1 && isPrimitive(of[0].type) ? of[0] : undefined;\n};\nexport const isSmallObject = (fields: FieldSchema[] = []) => fields.length > 0 && fields.length <= 3 && fields.every((f) => INLINE_OK.has(f.type));\n\n/** How an object field / array item opens (CPO D8: inline for ≤3 primitives, else drill). */\nexport function objectOpenMode(f: FieldSchema): OpenMode {\n if (f.openMode) return f.openMode;\n return isSmallObject(f.fields) ? \"inline\" : \"drill\";\n}\n/**\n * CPO D43 — one rule for rows: an item of ≤3 simple fields (text, number, switch, select, colour, icon, url, email,\n * date, rating, slug) EXPANDS inline under its row; anything bigger, nested or rich DRILLS into its own frame.\n * `openMode` on the array still wins (developer override). Several item types → drill (they rarely share a shape).\n */\nexport function itemOpenMode(arrayField: FieldSchema): OpenMode {\n if (arrayField.openMode) return arrayField.openMode;\n const of = itemSchemas(arrayField);\n return of.length === 1 && isSmallObject(of[0].fields) ? \"inline\" : \"drill\";\n}\n\nexport function emptyFor(f: FieldSchema): unknown {\n switch (f.type) {\n case \"boolean\": return false;\n case \"number\": case \"rating\": return null;\n case \"multiselect\": case \"tags\": case \"array\": case \"slot\": return [];\n case \"object\": return objectInitial(f.fields ?? []);\n case \"image\": case \"file\": case \"video\": case \"reference\": case \"link\": case \"button\": case \"geopoint\": case \"json\": case \"table\": return null;\n default: return \"\";\n }\n}\nexport const initialFor = (f: FieldSchema) => (f.initialValue !== undefined ? structuredCloneSafe(f.initialValue) : emptyFor(f));\nexport function objectInitial(fields: FieldSchema[]): Record<string, unknown> {\n const o: Record<string, unknown> = {};\n for (const f of fields) if (f.initialValue !== undefined) o[f.name] = structuredCloneSafe(f.initialValue);\n return o;\n}\n/** A new array item for `itemSchema` (stamped with `_key` and, when the array allows several types, `_type`). */\nexport function newItem(arrayField: FieldSchema, itemSchema: FieldSchema): unknown {\n if (isPrimitive(itemSchema.type)) return initialFor(itemSchema);\n const base = itemSchema.initialValue && isObj(itemSchema.initialValue) ? structuredCloneSafe(itemSchema.initialValue) : objectInitial(itemSchema.fields ?? []);\n const multi = itemSchemas(arrayField).length > 1;\n return { _key: newKey(), ...(multi ? { _type: itemSchema.name } : {}), ...(base as object) };\n}\nexport function newBlock(block: TypeSchema, settings?: FieldSchema[]): Record<string, unknown> {\n const init = block.initialValue ? structuredCloneSafe(block.initialValue) : objectInitial(block.fields);\n const s = settings?.length ? { _settings: objectInitial(settings) } : {};\n return { _key: newKey(), _type: block.name, ...(block.variants?.[0] ? { _variant: block.variants[0].id } : {}), ...s, ...(init as object) };\n}\nexport function structuredCloneSafe<T>(v: T): T {\n try {\n return structuredClone(v);\n } catch {\n return JSON.parse(JSON.stringify(v)) as T;\n }\n}\n\n/* ── Conditions ───────────────────────────────────────────────────────── */\n/**\n * What a condition can read beyond the fields beside it (V2 kit lib/schema.ts CondCtx): the object that holds them\n * (`parent`), the top of the component or CMS item (`root`) and its variant. Callers that don't pass it get the sibling\n * rules only; a `_variant` rule that can't be read then counts as met (the field shows), never as a silent hide.\n */\nexport interface CondCtx {\n parent?: unknown;\n root?: unknown;\n /** the component's variant id, its first variant when the value has none */\n variant?: string;\n}\n/** The condition context for fields under `basePath` of a form (the nearest slot child is the component's root). V2 condCtx. */\nexport function condCtx(form: { schema: TypeSchema; getAt: (p: (string | number)[]) => unknown; resolveSchema?: (t: string) => TypeSchema | undefined }, basePath: (string | number)[]): CondCtx {\n const up = (p: (string | number)[]) => {\n const q = [...p];\n // the container may be a list item ([\"items\", 0]): the object holding it is one key further up\n while (q.length && typeof q[q.length - 1] === \"number\") q.pop();\n q.pop();\n return q;\n };\n let rootPath: (string | number)[] = [];\n let rootSchema: TypeSchema | undefined = form.schema;\n for (let i = basePath.length; i > 0; i--) {\n const v = form.getAt(basePath.slice(0, i));\n if (isObj(v) && typeof v._type === \"string\" && typeof basePath[i - 1] === \"number\") {\n rootPath = basePath.slice(0, i);\n rootSchema = form.resolveSchema?.(v._type);\n break;\n }\n }\n const root = form.getAt(rootPath);\n const own = isObj(root) && typeof root._variant === \"string\" ? root._variant : undefined;\n return { parent: basePath.length > rootPath.length ? form.getAt(up(basePath)) : undefined, root, variant: own ?? rootSchema?.variants?.[0]?.id };\n}\n\nconst num = (v: unknown) => (typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() !== \"\" && !Number.isNaN(Number(v)) ? Number(v) : typeof v === \"string\" && !Number.isNaN(Date.parse(v)) ? Date.parse(v) : NaN);\n/** One rule (V2 ruleHolds): true when it holds, null when it can't be read here (no context). */\nfunction ruleHolds(c: Condition, siblings: unknown, ctx: CondCtx | undefined): boolean | null {\n let v: unknown;\n if (c.field === \"_variant\" && !c.scope) {\n if (isObj(siblings) && typeof siblings._variant === \"string\") v = siblings._variant;\n else if (ctx) v = ctx.variant;\n else return null;\n } else if (c.scope) {\n if (!ctx) return null;\n const from = c.scope === \"root\" ? ctx.root : ctx.parent;\n v = c.field === \"_variant\" ? ctx.variant : isObj(from) ? from[c.field] : undefined;\n } else v = isObj(siblings) ? siblings[c.field] : undefined;\n const op = c.op ?? (c.notEmpty ? \"notEmpty\" : c.equals !== undefined ? (Array.isArray(c.equals) ? \"in\" : \"is\") : null);\n const target = c.op ? c.value : c.equals;\n const list = Array.isArray(target) ? target : [target];\n const has = (x: unknown) => list.some((y) => y === x || (Array.isArray(x) && x.includes(y as never)));\n switch (op) {\n case \"notEmpty\": return !isEmptyValue(v);\n case \"empty\": return isEmptyValue(v);\n case \"is\":\n case \"in\": return has(v);\n case \"isNot\":\n case \"notIn\": return !has(v);\n case \"gt\": return num(v) > num(target);\n case \"lt\": return num(v) < num(target);\n default: return true;\n }\n}\n\n/** `hidden: true` hides; a Condition SHOWS the field only while its rules hold (types.ts contract). A rule it can't read\n * here (a `_variant` or scoped rule with no context) holds, so the field shows. V2 isHidden. */\nexport function isHidden(f: FieldSchema, parent: unknown, ctx?: CondCtx): boolean {\n if (f.hidden === true) return true;\n if (!f.hidden) return false;\n const c = f.hidden as Condition;\n const met = [c, ...(c.also ?? [])].map((r) => ruleHolds(r, parent, ctx) ?? true);\n return !(c.match === \"any\" ? met.some(Boolean) : met.every(Boolean));\n}\n\n/** The rules of a field's condition that don't hold right now (what keeps it hidden), in order. [] when it shows. V2 D70. */\nexport function failingRules(f: FieldSchema, parent: unknown, ctx?: CondCtx): Condition[] {\n if (!f.hidden || f.hidden === true || !isHidden(f, parent, ctx)) return [];\n const c = f.hidden as Condition;\n return [c, ...(c.also ?? [])].map(({ also: _a, match: _m, ...r }) => r as Condition).filter((r) => ruleHolds(r, parent, ctx) === false);\n}\n\n/**\n * A reference filter as production stores it: the GROQ-style string as it is; the typed V2 form's field rule as\n * `field == 'value'`. `status` has no production form (the adapters report it lossy), so it is left out here.\n */\nexport function refFilterText(filter: string | ReferenceFilter | undefined): string | undefined {\n if (typeof filter === \"string\") return filter;\n if (!filter?.field || filter.equals === undefined) return undefined;\n const v = filter.equals;\n return `${filter.field} == ${typeof v === \"string\" ? `'${v.replace(/\\\\/g, \"\\\\\\\\\").replace(/'/g, \"\\\\'\")}'` : String(v)}`;\n}\n\n/* ── Values → text ────────────────────────────────────────────────────── */\n/** Portable Text blocks' text, one block per space; \"\" when the array holds no blocks (a list of items). */\nconst blocksText = (v: unknown[]): string =>\n v\n .map((b) => (isObj(b) && Array.isArray(b.children) ? b.children.map((c) => (isObj(c) && typeof c.text === \"string\" ? c.text : \"\")).join(\"\") : \"\"))\n .filter(Boolean)\n .join(\" \")\n .replace(/\\s+/g, \" \")\n .trim();\nconst NAMED_ENTITIES: Record<string, string> = { amp: \"&\", lt: \"<\", gt: \">\", quot: '\"', apos: \"'\", nbsp: \" \" };\n/**\n * Markup's character references as the characters they stand for, AFTER the tags are gone (so a decoded `&lt;b&gt;`\n * stays words). Named ones a rich text editor writes, and every numeric one; anything else is left as written.\n */\nconst decodeEntities = (s: string): string =>\n s.replace(/&(#x[0-9a-f]+|#\\d+|[a-z]+);/gi, (whole, ref: string) => {\n if (ref[0] !== \"#\") return NAMED_ENTITIES[ref.toLowerCase()] ?? whole;\n const code = ref[1] === \"x\" || ref[1] === \"X\" ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);\n return Number.isFinite(code) && code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;\n });\n/**\n * A value as one line of text. Stored rich text reads as its words in every shape production keeps: an html string,\n * Portable Text blocks, the component props envelope `{ content: { version, content: blocks }, html }`, and the field\n * envelope `{ format, value: blocks, html }`.\n *\n * 🔴 An html string's words are DECODED: a row titled by `<p>Advisors &amp; specialists</p>` read \"Advisors &amp;\n * specialists\" in the dock (marby-astro QA, 2026-10-22).\n */\nexport const plainText = (v: unknown): string => {\n if (typeof v === \"string\") return decodeEntities(v.replace(/<[^>]*>/g, \" \")).replace(/\\s+/g, \" \").trim();\n if (typeof v === \"number\") return String(v);\n if (Array.isArray(v)) return blocksText(v);\n if (isObj(v)) {\n if (typeof v.label === \"string\" && v.label) return v.label;\n if (typeof v.title === \"string\") return v.title;\n if (typeof v.href === \"string\") return v.href;\n if (typeof v.name === \"string\") return v.name;\n // the envelope's blocks first: their text is unescaped (the html holds `&amp;`)\n if (\"content\" in v && typeof v.content === \"object\" && v.content !== null) {\n const t = plainText(v.content);\n if (t) return t;\n }\n if (Array.isArray(v.value)) {\n const t = blocksText(v.value);\n if (t) return t;\n }\n if (typeof v.html === \"string\") return plainText(v.html);\n }\n return \"\";\n};\nexport function isEmptyValue(v: unknown): boolean {\n if (v == null) return true;\n if (typeof v === \"string\") return plainText(v) === \"\" && !/<img|<hr|<table|data-block|data-embed/.test(v);\n if (Array.isArray(v)) return v.length === 0;\n if (isTableValue(v)) return !v.caption?.trim() && v.rows.every((r) => Object.values(r.cells ?? {}).every((c) => isEmptyCell(cellValue(c))));\n if (isObj(v)) {\n if (\"url\" in v) return !v.url;\n if (\"href\" in v && !(\"label\" in v)) return !v.href;\n if (\"label\" in v && \"href\" in v) return !v.label && !v.href;\n return Object.keys(v).filter((k) => !k.startsWith(\"_\")).every((k) => isEmptyValue(v[k]));\n }\n return false;\n}\nexport const imageUrl = (v: unknown): string | undefined =>\n typeof v === \"string\" && /^(https?:|blob:|data:image|\\/)/.test(v) ? v : isObj(v) && typeof v.url === \"string\" && v.url ? v.url : undefined;\n\n/** Singular noun for an array's items: itemNoun → item title → field title minus \"s\". */\nexport function itemNoun(f: FieldSchema): string {\n if (f.itemNoun) return f.itemNoun;\n const of = itemSchemas(f);\n if (of.length === 1 && of[0].title && !isPrimitive(of[0].type)) return of[0].title.toLowerCase();\n const t = f.title.toLowerCase();\n return t.endsWith(\"ies\") ? `${t.slice(0, -3)}y` : t.endsWith(\"s\") ? t.slice(0, -1) : \"item\";\n}\n\n/* ── Previews (array rows, slot rows, crumbs) ─────────────────────────── */\nexport interface Preview {\n title: string;\n subtitle?: string;\n media?: string;\n /** fitOf for `media`, from its value and the field it came from (a logo, an icon, a stored strip shape) */\n mediaFit?: MediaFit;\n icon?: string;\n empty: boolean;\n}\n/** Display text of one field value (select → option label). */\nfunction fieldText(f: FieldSchema | undefined, v: unknown): string {\n if (f?.type === \"select\") return f.options?.find((o) => o.value === v)?.label ?? plainText(v);\n return plainText(v);\n}\nfunction firstText(fields: FieldSchema[], v: Record<string, unknown>, skip?: string) {\n for (const f of fields) {\n if (f.name === skip) continue;\n if (f.type === \"select\") {\n const t = fieldText(f, v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n if (f.type === \"string\" || f.type === \"text\" || f.type === \"richtext\" || f.type === \"number\") {\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n if (f.type === \"button\" || f.type === \"link\") {\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n }\n // no prose anywhere: a URL or address still beats \"Item 3\" (D47 — item titles use the first text value)\n for (const f of fields) {\n if (f.name === skip || (f.type !== \"url\" && f.type !== \"email\" && f.type !== \"slug\")) continue;\n const t = plainText(v[f.name]);\n if (t) return { name: f.name, text: t };\n }\n return undefined;\n}\nexport function previewOf(itemSchema: FieldSchema | TypeSchema | undefined, item: unknown, index: number, fallbackTitle?: string): Preview {\n const v = isObj(item) ? item : {};\n const fields = (itemSchema && \"fields\" in itemSchema ? itemSchema.fields : undefined) ?? [];\n const cfg = itemSchema?.preview;\n const at = (p: string) => fieldText(fields.find((f) => f.name === p), getIn(v, p.split(\".\")));\n // what the row picks for itself never comes from a hidden field (a decorative chevron or icon); a named path still reads\n const shown = fields.filter((f) => f.hidden !== true);\n let title = cfg?.title ? at(cfg.title) : \"\";\n let titleField = cfg?.title;\n if (!title) {\n const t = firstText(shown, v);\n title = t?.text ?? \"\";\n titleField = t?.name;\n }\n let subtitle = cfg?.subtitle ? at(cfg.subtitle) : \"\";\n if (!subtitle && !cfg?.subtitle) subtitle = firstText(shown, v, titleField)?.text ?? \"\";\n let media = cfg?.media ? imageUrl(getIn(v, cfg.media.split(\".\"))) : undefined;\n let mediaFit = cfg?.media && media ? fitOf(getIn(v, cfg.media.split(\".\")), fields.find((f) => f.name === cfg.media) ?? { name: cfg.media }, undefined, true) : undefined;\n if (!media && !cfg?.media) {\n const img = shown.find((f) => f.type === \"image\");\n if (img) media = imageUrl(v[img.name]);\n if (img && media) mediaFit = fitOf(v[img.name], img, undefined, true);\n }\n const empty = !title;\n const noun = fallbackTitle ?? (itemSchema?.title ?? \"Item\");\n return {\n title: title || cfg?.fallback || `${noun} ${index + 1}`,\n subtitle: subtitle ? (subtitle.length > 90 ? `${subtitle.slice(0, 88)}…` : subtitle) : undefined,\n media,\n mediaFit,\n icon: cfg?.icon ?? (itemSchema as FieldSchema | undefined)?.icon,\n empty,\n };\n}\n\n/**\n * How one slot child reads as a row (SlotField): its block's preview (the block's title while it has no text), the\n * variant chip its `_variant` names, and the line under it (block title · settings, else description, else \"Block i of n\").\n */\nexport function slotRowOf(block: TypeSchema | undefined, item: unknown, index: number, count: number, slotSettings?: FieldSchema[]): { preview: Preview; chip?: string; extra: string } {\n const pv = previewOf(block, item, index, block?.title ?? \"Block\");\n const variant = block?.variants?.find((v) => isObj(item) && v.id === item._variant)?.name;\n const settings = slotSettings && isObj(item) ? summarize(slotSettings, item._settings, 2) : \"\";\n return {\n preview: { ...pv, title: pv.empty ? (block?.title ?? \"Unknown block\") : pv.title, icon: block?.icon ?? \"box\" },\n chip: variant,\n extra: [pv.empty ? undefined : block?.title, settings].filter(Boolean).join(\" · \") || block?.description || `Block ${index + 1} of ${count}`,\n };\n}\n\n/** \"Cast iron · 4 items\" — one-line summary of an object for collapsed rows and fieldset headers. */\nexport function summarize(fields: FieldSchema[], v: unknown, max = 2): string {\n if (!isObj(v)) return \"\";\n const parts: string[] = [];\n for (const f of fields) {\n if (parts.length >= max) break;\n const x = v[f.name];\n if (isEmptyValue(x)) continue;\n if (f.type === \"reference\" || f.type === \"json\" || f.type === \"code\" || f.type === \"image\" || f.type === \"file\") continue; // ids and blobs read badly\n if (f.type === \"table\") {\n parts.push(tableSummary(x));\n continue;\n }\n if (f.type === \"rating\" && typeof x === \"number\") {\n parts.push(`${x} / 5`);\n continue;\n }\n if (Array.isArray(x)) parts.push(`${x.length} ${x.length === 1 ? itemNounSafe(f) : `${itemNounSafe(f)}s`}`);\n else if (typeof x === \"boolean\") parts.push(`${f.title}: ${x ? \"on\" : \"off\"}`);\n else {\n const t = fieldText(f, x);\n if (t) parts.push(t.length > 40 ? `${t.slice(0, 38)}…` : t);\n }\n }\n return parts.join(\" · \");\n}\nconst itemNounSafe = (f: FieldSchema) => (f.type === \"array\" || f.type === \"slot\" ? itemNoun(f) : \"item\");\n"],"mappings":";;;;AAQA,IAAM,6BAAsC,IAAI,IAAmB;CACjE;CAAU;CAAQ;CAAY;CAAU;CAAW;CAAQ;CAAO;CAAS;CAAQ;CAAY;CAAS;CAAU;CAClH;CAAQ;CAAS;CAAQ;CAAS;CAAQ;CAAQ;CAAU;CAAa;CAAQ;CAAQ;CAAY;CAAU;AACjH,CAAC;AACD,IAAa,eAAe,MAAkB,WAAW,IAAI,CAAC;;AAE9D,IAAa,aAAa,MAAkB,MAAM,YAAY,MAAM,UAAU,MAAM,cAAc,MAAM,UAAU,MAAM,SAAS,MAAM;;AAEvI,IAAM,4BAAqC,IAAI,IAAI;CAAC;CAAU;CAAU;CAAW;CAAU;CAAS;CAAQ;CAAO;CAAS;CAAQ;CAAU;AAAM,CAAC;AAEvJ,IAAa,eAAe,MAAmC,MAAM,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC;AAC7F,IAAa,aA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U,GAAG,CAAC;GACxB,IAAI,GAAG,MAAM,KAAK,EAAE,SAAS,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,KAAK,CAAC;EAC5D;CACF;CACA,OAAO,MAAM,KAAK,KAAK;AACzB;AACA,IAAM,gBAAgB,MAAoB,EAAE,SAAS,WAAW,EAAE,SAAS,SAAS,SAAS,CAAC,IAAI"}
@@ -1,7 +1,4 @@
1
- export declare const sleep: (ms: number) => Promise<unknown>;
2
1
  export declare const uid: (p?: string) => string;
3
- export declare function formatNumber(n: number): string;
4
- export declare function plural(n: number, one: string, many?: string): string;
5
2
  export declare function initials(name: string): string;
6
- export declare function relTime(iso: string | number | Date): string;
3
+ export declare function relTime(at: string | number | Date, now?: number): string;
7
4
  export declare const slugify: (s: string) => string;
package/dist/lib/utils.js CHANGED
@@ -1,20 +1,10 @@
1
1
  //#region src/lib/utils.ts
2
- var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
3
2
  var uid = (p = "id") => `${p}_${Math.random().toString(36).slice(2, 9)}`;
4
- function formatNumber(n) {
5
- if (n >= 1e6) return `${(n / 1e6).toFixed(n >= 1e7 ? 0 : 1)}M`;
6
- if (n >= 1e3) return `${(n / 1e3).toFixed(n >= 1e4 ? 0 : 1)}k`;
7
- return `${n}`;
8
- }
9
- function plural(n, one, many = `${one}s`) {
10
- return `${n} ${n === 1 ? one : many}`;
11
- }
12
3
  function initials(name) {
13
4
  return name.split(/\s+/).map((p) => p[0]).slice(0, 2).join("").toUpperCase();
14
5
  }
15
- function relTime(iso) {
16
- const d = new Date(iso).getTime();
17
- const s = Math.round((Date.now() - d) / 1e3);
6
+ function relTime(at, now = Date.now()) {
7
+ const s = Math.round((now - new Date(at).getTime()) / 1e3);
18
8
  if (s < 45) return "just now";
19
9
  const m = Math.round(s / 60);
20
10
  if (m < 60) return `${m}m ago`;
@@ -24,7 +14,7 @@ function relTime(iso) {
24
14
  if (days < 7) return `${days}d ago`;
25
15
  const w = Math.round(days / 7);
26
16
  if (w < 5) return `${w}w ago`;
27
- return new Date(iso).toLocaleDateString("en-US", {
17
+ return new Date(at).toLocaleDateString("en-US", {
28
18
  month: "short",
29
19
  day: "numeric",
30
20
  year: "numeric"
@@ -32,6 +22,6 @@ function relTime(iso) {
32
22
  }
33
23
  var slugify = (s) => s.toLowerCase().trim().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
34
24
  //#endregion
35
- export { formatNumber, initials, plural, relTime, sleep, slugify, uid };
25
+ export { initials, relTime, slugify, uid };
36
26
 
37
27
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../src/lib/utils.ts"],"sourcesContent":["export const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\nexport const uid = (p = \"id\") => `${p}_${Math.random().toString(36).slice(2, 9)}`;\nexport function formatNumber(n: number) {\n if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(n >= 10_000_000 ? 0 : 1)}M`;\n if (n >= 1000) return `${(n / 1000).toFixed(n >= 10000 ? 0 : 1)}k`;\n return `${n}`;\n}\nexport function plural(n: number, one: string, many = `${one}s`) {\n return `${n} ${n === 1 ? one : many}`;\n}\nexport function initials(name: string) {\n return name.split(/\\s+/).map((p) => p[0]).slice(0, 2).join(\"\").toUpperCase();\n}\nexport function relTime(iso: string | number | Date) {\n const d = new Date(iso).getTime();\n const s = Math.round((Date.now() - d) / 1000);\n if (s < 45) return \"just now\";\n const m = Math.round(s / 60); if (m < 60) return `${m}m ago`;\n const h = Math.round(m / 60); if (h < 24) return `${h}h ago`;\n const days = Math.round(h / 24); if (days < 7) return `${days}d ago`;\n const w = Math.round(days / 7); if (w < 5) return `${w}w ago`;\n return new Date(iso).toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\nexport const slugify = (s: string) => s.toLowerCase().trim().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\");\n"],"mappings":";AAAA,IAAa,SAA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,mBAAmB,SAAS;EAAE,OAAO;EAAS,KAAK;EAAW,MAAM;CAAU,CAAC;AACtG;AACA,IAAa,WAAW,MAAc,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,UAAU,EAAE"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/lib/utils.ts"],"sourcesContent":["export const uid = (p = \"id\") => `${p}_${Math.random().toString(36).slice(2, 9)}`;\nexport function initials(name: string) {\n return name.split(/\\s+/).map((p) => p[0]).slice(0, 2).join(\"\").toUpperCase();\n}\nexport function relTime(at: string | number | Date, now = Date.now()) {\n const s = Math.round((now - new Date(at).getTime()) / 1000);\n if (s < 45) return \"just now\";\n const m = Math.round(s / 60); if (m < 60) return `${m}m ago`;\n const h = Math.round(m / 60); if (h < 24) return `${h}h ago`;\n const days = Math.round(h / 24); if (days < 7) return `${days}d ago`;\n const w = Math.round(days / 7); if (w < 5) return `${w}w ago`;\n return new Date(at).toLocaleDateString(\"en-US\", { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\nexport const slugify = (s: string) => s.toLowerCase().trim().replace(/[^a-z0-9]+/g, \"-\").replace(/^-|-$/g, \"\");\n"],"mappings":";AAAA,IAAa,OAAO,IAAI,SAAS,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;AAC9E,SAAgB,SAAS,MAAc;CACrC,OAAO,KAAK,MAAM,KAAK,CAAC,CAAC,KAAK,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY;AAC7E;AACA,SAAgB,QAAQ,IAA4B,MAAM,KAAK,IAAI,GAAG;CACpE,MAAM,IAAI,KAAK,OAAO,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC,QAAQ,KAAK,GAAI;CAC1D,IAAI,IAAI,IAAI,OAAO;CACnB,MAAM,IAAI,KAAK,MAAM,IAAI,EAAE;CAAG,IAAI,IAAI,IAAI,OAAO,GAAG,EAAE;CACtD,MAAM,IAAI,KAAK,MAAM,IAAI,EAAE;CAAG,IAAI,IAAI,IAAI,OAAO,GAAG,EAAE;CACtD,MAAM,OAAO,KAAK,MAAM,IAAI,EAAE;CAAG,IAAI,OAAO,GAAG,OAAO,GAAG,KAAK;CAC9D,MAAM,IAAI,KAAK,MAAM,OAAO,CAAC;CAAG,IAAI,IAAI,GAAG,OAAO,GAAG,EAAE;CACvD,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,mBAAmB,SAAS;EAAE,OAAO;EAAS,KAAK;EAAW,MAAM;CAAU,CAAC;AACrG;AACA,IAAa,WAAW,MAAc,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAC,QAAQ,UAAU,EAAE"}
@@ -23,8 +23,21 @@ type Raw = Omit<KitIssue, "key" | "path">;
23
23
  export declare const textLength: (v: unknown) => number;
24
24
  /** Validate one value against its field (not recursing into children). */
25
25
  export declare function validateValue(f: FieldSchema, v: unknown): Raw | null;
26
+ /**
27
+ * Values other records already hold for a ROOT field with `validation.unique` (a collection's other entries). The host
28
+ * passes it; without it a root `unique` field is not checked (lists always are).
29
+ */
30
+ export type UniquePeers = (field: FieldSchema, path: FieldPath) => unknown[] | undefined;
31
+ /**
32
+ * What makes two values "the same" for `unique` (V2 uniqueKey, as the server judges a placement in backend prop-fields
33
+ * tableProblem): text trimmed and case-folded, numbers and booleans as written, a reference or link by its id. null =
34
+ * nothing to compare. A list's items compare whole (itemKey), strings case-folded, rows without their `_id` / `_key`.
35
+ */
36
+ export declare function uniqueKey(v: unknown): string | null;
26
37
  /** Walk fields under `obj` and collect every issue, recursing into objects, array items and slot blocks. */
27
38
  export declare function collectIssues(fields: FieldSchema[], obj: unknown, base: FieldPath, resolveSchema?: (t: string) => TypeSchema | undefined, out?: KitIssue[],
28
39
  /** what a `_variant` condition reads above this level (V2; the root call: the value itself) */
29
- cc?: CondCtx): KitIssue[];
40
+ cc?: CondCtx,
41
+ /** root fields with `unique`: the values the model's other records hold (the root call only) */
42
+ peers?: UniquePeers): KitIssue[];
30
43
  export {};
@@ -1,5 +1,5 @@
1
- import { tableIssues } from "../schema/table.js";
2
1
  import { isObj, pathKey } from "./path.js";
2
+ import { tableIssues } from "../schema/table.js";
3
3
  import { isEmptyValue, isHidden, itemSchemaFor, plainText, primitiveItem } from "./schema.js";
4
4
  //#region src/lib/validate.ts
5
5
  var textLength = (v) => plainText(v).length;
@@ -115,11 +115,17 @@ function validateValue(f, v) {
115
115
  return null;
116
116
  }
117
117
  /**
118
- * What makes two values "the same" for `unique`, as the server judges a placement
119
- * (backend prop-fields tableProblem): a row's field compares text trimmed and case-folded, and
120
- * numbers; a list's items compare whole, strings case-folded, rows without their `_id` / `_key`.
118
+ * What makes two values "the same" for `unique` (V2 uniqueKey, as the server judges a placement in backend prop-fields
119
+ * tableProblem): text trimmed and case-folded, numbers and booleans as written, a reference or link by its id. null =
120
+ * nothing to compare. A list's items compare whole (itemKey), strings case-folded, rows without their `_id` / `_key`.
121
121
  */
122
- var cellKey = (v) => typeof v === "number" && Number.isFinite(v) ? String(v) : typeof v === "string" && v.trim() ? v.trim().toLocaleLowerCase("und") : null;
122
+ function uniqueKey(v) {
123
+ if (typeof v === "string") return v.trim() ? v.trim().toLocaleLowerCase("und") : null;
124
+ if (typeof v === "number" && Number.isFinite(v) || typeof v === "boolean") return String(v);
125
+ if (!isObj(v)) return null;
126
+ const id = v._ref ?? v.id ?? v.value ?? v.href ?? v.url;
127
+ return typeof id === "string" || typeof id === "number" ? uniqueKey(String(id)) : null;
128
+ }
123
129
  var itemKey = (v) => {
124
130
  if (typeof v === "string") return `s:${v.trim().toLocaleLowerCase("und")}`;
125
131
  if (isObj(v)) {
@@ -141,11 +147,11 @@ function repeats(values, key) {
141
147
  return out;
142
148
  }
143
149
  var shown = (v) => {
144
- const s = typeof v === "string" ? v.trim() : String(v ?? "");
150
+ const s = typeof v === "string" ? v.trim() : isObj(v) ? String(v.title ?? v.label ?? v._ref ?? v.id ?? "") : String(v ?? "");
145
151
  return s.length > 40 ? `${s.slice(0, 39)}…` : s;
146
152
  };
147
153
  /** Walk fields under `obj` and collect every issue, recursing into objects, array items and slot blocks. */
148
- function collectIssues(fields, obj, base, resolveSchema, out = [], cc) {
154
+ function collectIssues(fields, obj, base, resolveSchema, out = [], cc, peers) {
149
155
  const v = isObj(obj) ? obj : {};
150
156
  const here = cc ?? {
151
157
  root: v,
@@ -166,6 +172,16 @@ function collectIssues(fields, obj, base, resolveSchema, out = [], cc) {
166
172
  key: pathKey(p),
167
173
  path: p
168
174
  });
175
+ else if (peers && !base.length && f.validation?.unique && f.type !== "array") {
176
+ const k = uniqueKey(val);
177
+ if (k !== null && (peers(f, p) ?? []).some((o) => uniqueKey(o) === k)) out.push({
178
+ level: "error",
179
+ kind: "rule",
180
+ message: `Another item already uses “${shown(val)}”. ${f.title} must be different on each one.`,
181
+ key: pathKey(p),
182
+ path: p
183
+ });
184
+ }
169
185
  if (f.type === "object" && f.fields) collectIssues(f.fields, val, p, resolveSchema, out, below);
170
186
  if ((f.type === "array" || f.type === "tags" || f.type === "multiselect") && Array.isArray(val) && f.validation?.unique && !raw) {
171
187
  const [r] = repeats(val, itemKey);
@@ -183,10 +199,10 @@ function collectIssues(fields, obj, base, resolveSchema, out = [], cc) {
183
199
  if (s?.fields) collectIssues(s.fields, it, [...p, i], resolveSchema, out, below);
184
200
  });
185
201
  const keys = /* @__PURE__ */ new Set();
186
- for (const it of val) for (const x of itemSchemaFor(f, it)?.fields ?? []) if (x.validation?.unique) keys.add(x.name);
202
+ for (const it of val) for (const x of itemSchemaFor(f, it)?.fields ?? []) if (x.validation?.unique || f.validation?.uniqueBy === x.name) keys.add(x.name);
187
203
  for (const k of keys) {
188
204
  const vals = val.map((it) => isObj(it) ? it[k] : void 0);
189
- for (const i of repeats(vals, cellKey)) {
205
+ for (const i of repeats(vals, uniqueKey)) {
190
206
  const fp = [
191
207
  ...p,
192
208
  i,
@@ -219,6 +235,6 @@ function collectIssues(fields, obj, base, resolveSchema, out = [], cc) {
219
235
  return out;
220
236
  }
221
237
  //#endregion
222
- export { collectIssues, textLength, validateValue };
238
+ export { collectIssues, textLength, uniqueKey, validateValue };
223
239
 
224
240
  //# sourceMappingURL=validate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate.js","names":[],"sources":["../../src/lib/validate.ts"],"sourcesContent":["/**\n * Validation — rules live in the schema (`validation`), messages state the rule in plain words.\n * Two kinds: \"required\" (shown after blur or a publish attempt) and \"rule\" (shown on blur too, never while\n * typing for the first time — the shell decides). Warnings (recommendedMax, missing alt) never block publish.\n */\nimport type { FieldPath, FieldSchema, TypeSchema } from \"../schema/types\";\nimport { isObj, pathKey } from \"./path\";\nimport { tableIssues } from \"../schema/table\";\nimport { isEmptyValue, isHidden, itemSchemaFor, plainText, primitiveItem, type CondCtx } from \"./schema\";\n\nexport interface KitIssue {\n key: string;\n path: FieldPath;\n level: \"error\" | \"warning\";\n kind: \"required\" | \"rule\";\n message: string;\n /** shown at once, even while the field is being typed in (a host's live check, e.g. the schema editor's help check) */\n live?: boolean;\n /** one fix the shell offers after the message (\"Clear help\") */\n fix?: { label: string; apply: () => void };\n}\ntype Raw = Omit<KitIssue, \"key\" | \"path\">;\n\nexport const textLength = (v: unknown) => plainText(v).length;\nconst counted = (f: FieldSchema) => f.type === \"string\" || f.type === \"text\" || f.type === \"richtext\";\n\n/** Validate one value against its field (not recursing into children). */\nexport function validateValue(f: FieldSchema, v: unknown): Raw | null {\n const r = f.validation ?? {};\n const label = f.title;\n if (r.required && isEmptyValue(v)) {\n const msg =\n f.type === \"image\" ? `Add an image for ${label.toLowerCase()}` :\n f.type === \"reference\" ? `Choose ${label.toLowerCase()}` :\n f.type === \"array\" || f.type === \"slot\" ? `Add at least one item to ${label.toLowerCase()}` :\n `${label} is required`;\n return { level: \"error\", kind: \"required\", message: msg };\n }\n if (isEmptyValue(v)) return null;\n\n if (counted(f)) {\n const n = textLength(v);\n if (r.max && n > r.max) return { level: \"error\", kind: \"rule\", message: `Keep it under ${r.max} characters (${n - r.max} over)` };\n if (r.min && n < r.min) return { level: \"error\", kind: \"rule\", message: `Use at least ${r.min} characters` };\n if (r.recommendedMax && n > r.recommendedMax)\n return { level: \"warning\", kind: \"rule\", message: `Longer than the recommended ${r.recommendedMax} characters. It may get cut off.` };\n }\n if ((f.type === \"array\" || f.type === \"slot\" || f.type === \"tags\" || f.type === \"multiselect\") && Array.isArray(v)) {\n if (r.min && v.length < r.min) return { level: \"error\", kind: \"rule\", message: `Add at least ${r.min} ${r.min === 1 ? \"item\" : \"items\"}` };\n if (r.max && v.length > r.max) return { level: \"error\", kind: \"rule\", message: `Use at most ${r.max} items` };\n }\n if (f.type === \"number\" && typeof v === \"number\") {\n const lo = r.min ?? f.numeric?.min;\n const hi = r.max ?? f.numeric?.max;\n if (lo != null && v < lo) return { level: \"error\", kind: \"rule\", message: `Use ${lo} or more` };\n if (hi != null && v > hi) return { level: \"error\", kind: \"rule\", message: `Use ${hi} or less` };\n }\n if (typeof v === \"string\") {\n if (f.type === \"email\" && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use a full email address, like hello@caldera.com\" };\n if (f.type === \"url\" && !/^(https?:\\/\\/|\\/|#|mailto:|tel:)[^\\s]*$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use a full URL, like https://example.com, or a path like /shop\" };\n if (f.type === \"url\" && /^(javascript|data):/i.test(v)) return { level: \"error\", kind: \"rule\", message: \"This kind of link isn't allowed\" };\n if (f.type === \"slug\" && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use lowercase letters, numbers and hyphens\" };\n if (f.type === \"json\") {\n try {\n JSON.parse(v);\n } catch {\n return { level: \"error\", kind: \"rule\", message: \"Invalid JSON\" };\n }\n }\n if (r.pattern && !new RegExp(r.pattern).test(v)) return { level: \"error\", kind: \"rule\", message: r.patternMessage ?? \"This doesn't match the expected format\" };\n }\n if (f.type === \"table\") {\n // caption, header labels, typed cells, row limits, markup readiness (src/schema/table.ts) — first error wins\n const issues = tableIssues(v, { ...f.table, minRows: f.table?.minRows ?? r.min, maxRows: f.table?.maxRows ?? r.max });\n const first = issues.find((i) => i.level === \"error\") ?? issues[0];\n if (first) return { level: first.level, kind: \"rule\", message: first.message };\n }\n if (f.type === \"image\" && isObj(v) && v.url && !v.alt && r.required) return { level: \"warning\", kind: \"rule\", message: \"No alt text. Describe the image for accessibility.\" };\n return null;\n}\n\n/**\n * What makes two values \"the same\" for `unique`, as the server judges a placement\n * (backend prop-fields tableProblem): a row's field compares text trimmed and case-folded, and\n * numbers; a list's items compare whole, strings case-folded, rows without their `_id` / `_key`.\n */\nconst cellKey = (v: unknown): string | null =>\n typeof v === \"number\" && Number.isFinite(v) ? String(v) : typeof v === \"string\" && v.trim() ? v.trim().toLocaleLowerCase(\"und\") : null;\nconst itemKey = (v: unknown): string => {\n if (typeof v === \"string\") return `s:${v.trim().toLocaleLowerCase(\"und\")}`;\n if (isObj(v)) {\n const { _id: _i, _key: _k, ...rest } = v;\n return `o:${JSON.stringify(Object.fromEntries(Object.entries(rest).sort(([a], [b]) => a.localeCompare(b))))}`;\n }\n return `j:${JSON.stringify(v)}`;\n};\n/** Indexes of the values whose key repeats one an earlier value already used. */\nfunction repeats(values: unknown[], key: (v: unknown) => string | null): number[] {\n const seen = new Set<string>();\n const out: number[] = [];\n values.forEach((v, i) => {\n const k = key(v);\n if (k === null) return;\n if (seen.has(k)) out.push(i);\n else seen.add(k);\n });\n return out;\n}\nconst shown = (v: unknown) => {\n const s = typeof v === \"string\" ? v.trim() : String(v ?? \"\");\n return s.length > 40 ? `${s.slice(0, 39)}…` : s;\n};\n\n/** Walk fields under `obj` and collect every issue, recursing into objects, array items and slot blocks. */\nexport function collectIssues(\n fields: FieldSchema[],\n obj: unknown,\n base: FieldPath,\n resolveSchema?: (t: string) => TypeSchema | undefined,\n out: KitIssue[] = [],\n /** what a `_variant` condition reads above this level (V2; the root call: the value itself) */\n cc?: CondCtx,\n): KitIssue[] {\n const v = isObj(obj) ? obj : {};\n const here: CondCtx = cc ?? { root: v, variant: typeof v._variant === \"string\" ? v._variant : undefined };\n const below: CondCtx = { root: here.root, parent: v, variant: here.variant };\n for (const f of fields) {\n if (isHidden(f, v, here)) continue;\n const p = [...base, f.name];\n const val = v[f.name];\n const raw = validateValue(f, val);\n if (raw) out.push({ ...raw, key: pathKey(p), path: p });\n if (f.type === \"object\" && f.fields) collectIssues(f.fields, val, p, resolveSchema, out, below);\n // A list's `unique`: no item twice (the first repeat is reported on the list).\n if ((f.type === \"array\" || f.type === \"tags\" || f.type === \"multiselect\") && Array.isArray(val) && f.validation?.unique && !raw) {\n const [r] = repeats(val, itemKey);\n if (r !== undefined) out.push({ level: \"error\", kind: \"rule\", message: typeof val[r] === \"string\" ? `“${shown(val[r])}” is in the list twice. Each item can be added once.` : `Item ${r + 1} repeats an earlier item. Each item must be different.`, key: pathKey(p), path: p });\n }\n if (f.type === \"array\" && Array.isArray(val) && !primitiveItem(f)) {\n val.forEach((it, i) => {\n const s = itemSchemaFor(f, it);\n if (s?.fields) collectIssues(s.fields, it, [...p, i], resolveSchema, out, below);\n });\n // A field inside the items with `unique`: no two items share its value.\n const keys = new Set<string>();\n for (const it of val) for (const x of itemSchemaFor(f, it)?.fields ?? []) if (x.validation?.unique) keys.add(x.name);\n for (const k of keys) {\n const vals = val.map((it) => (isObj(it) ? it[k] : undefined));\n for (const i of repeats(vals, cellKey)) {\n const fp = [...p, i, k];\n const title = itemSchemaFor(f, val[i])?.fields?.find((x) => x.name === k)?.title ?? k;\n if (!out.some((x) => x.key === pathKey(fp))) out.push({ level: \"error\", kind: \"rule\", message: `${title} must be different on each item. “${shown(vals[i])}” is already used.`, key: pathKey(fp), path: fp });\n }\n }\n }\n if (f.type === \"slot\" && Array.isArray(val) && resolveSchema) {\n val.forEach((it, i) => {\n const b = isObj(it) && typeof it._type === \"string\" ? resolveSchema(it._type) : undefined;\n if (b) collectIssues(b.fields, it, [...p, i], resolveSchema, out, { root: it, variant: isObj(it) && typeof it._variant === \"string\" ? it._variant : b.variants?.[0]?.id });\n if (f.slotSettings && isObj(it)) collectIssues(f.slotSettings, it._settings, [...p, i, \"_settings\"], resolveSchema, out);\n });\n }\n }\n return out;\n}\n"],"mappings":";;;;AAuBA,IAAa,cAAc,MAAe,UAAU,CAAC,CAAC,CAAC;AACvD,IAAM,WAAW,MAAmB,EAAE,SAAS,YAAY,EAAE,SAAS,UAAU,EAAE,SAAS;;AAG3F,SAAgB,cAAc,GAAgB,GAAwB;CACpE,MAAM,IAAI,EAAE,cAAc,CAAC;CAC3B,MAAM,QAAQ,EAAE;CAChB,IAAI,EAAE,YAAY,aAAa,CAAC,GAM9B,OAAO;EAAE,OAAO;EAAS,MAAM;EAAY,SAJzC,EAAE,SAAS,UAAU,oBAAoB,MAAM,YAAY,MAC3D,EAAE,SAAS,cAAc,UAAU,MAAM,YAAY,MACrD,EAAE,SAAS,WAAW,EAAE,SAAS,SAAS,4BAA4B,MAAM,YAAY,MACxF,GAAG,MAAM;CAC6C;CAE1D,IAAI,aAAa,CAAC,GAAG,OAAO;CAE5B,IAAI,QAAQ,CAAC,GAAG;EACd,MAAM,IAAI,WAAW,CAAC;EACtB,IAAI,EAAE,OAAO,IAAI,EAAE,KAAK,OAAO;GAAE,OAAO;GAAS,MAAM;GAAQ,SAAS,iBAAiB,EAAE,IAAI,eAAe,IAAI,EAAE,IAAI;EAAQ;EAChI,IAAI,EAAE,OAAO,IAAI,EAAE,KAAK,OAAO;GAAE,OAAO;GAAS,MAAM;GAAQ,SAAS,gBAAgB,EAAE,IAAI;EAAa;EAC3G,IAAI,EAAE,kBAAkB,IAAI,EAAE,gBAC5B,OAAO;GAAE,OAAO;GAAW,MAAM;GAAQ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SAAS,GAAG,MAAM,oCAAoC,MAAM,KAAK,EAAE,EAAE;MAAqB,KAAK,QAAQ,EAAE;MAAG,MAAM;KAAG,CAAC;IAC9M;GACF;EACF;EACA,IAAI,EAAE,SAAS,UAAU,MAAM,QAAQ,GAAG,KAAK,eAC7C,IAAI,SAAS,IAAI,MAAM;GACrB,MAAM,IAAI,MAAM,EAAE,KAAK,OAAO,GAAG,UAAU,WAAW,cAAc,GAAG,KAAK,IAAI,KAAA;GAChF,IAAI,GAAG,cAAc,EAAE,QAAQ,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,eAAe,KAAK;IAAE,MAAM;IAAI,SAAS,MAAM,EAAE,KAAK,OAAO,GAAG,aAAa,WAAW,GAAG,WAAW,EAAE,WAAW,EAAE,EAAE;GAAG,CAAC;GACzK,IAAI,EAAE,gBAAgB,MAAM,EAAE,GAAG,cAAc,EAAE,cAAc,GAAG,WAAW;IAAC,GAAG;IAAG;IAAG;GAAW,GAAG,eAAe,GAAG;EACzH,CAAC;CAEL;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"validate.js","names":[],"sources":["../../src/lib/validate.ts"],"sourcesContent":["/**\n * Validation — rules live in the schema (`validation`), messages state the rule in plain words.\n * Two kinds: \"required\" (shown after blur or a publish attempt) and \"rule\" (shown on blur too, never while\n * typing for the first time — the shell decides). Warnings (recommendedMax, missing alt) never block publish.\n */\nimport type { FieldPath, FieldSchema, TypeSchema } from \"../schema/types\";\nimport { isObj, pathKey } from \"./path\";\nimport { tableIssues } from \"../schema/table\";\nimport { isEmptyValue, isHidden, itemSchemaFor, plainText, primitiveItem, type CondCtx } from \"./schema\";\n\nexport interface KitIssue {\n key: string;\n path: FieldPath;\n level: \"error\" | \"warning\";\n kind: \"required\" | \"rule\";\n message: string;\n /** shown at once, even while the field is being typed in (a host's live check, e.g. the schema editor's help check) */\n live?: boolean;\n /** one fix the shell offers after the message (\"Clear help\") */\n fix?: { label: string; apply: () => void };\n}\ntype Raw = Omit<KitIssue, \"key\" | \"path\">;\n\nexport const textLength = (v: unknown) => plainText(v).length;\nconst counted = (f: FieldSchema) => f.type === \"string\" || f.type === \"text\" || f.type === \"richtext\";\n\n/** Validate one value against its field (not recursing into children). */\nexport function validateValue(f: FieldSchema, v: unknown): Raw | null {\n const r = f.validation ?? {};\n const label = f.title;\n if (r.required && isEmptyValue(v)) {\n const msg =\n f.type === \"image\" ? `Add an image for ${label.toLowerCase()}` :\n f.type === \"reference\" ? `Choose ${label.toLowerCase()}` :\n f.type === \"array\" || f.type === \"slot\" ? `Add at least one item to ${label.toLowerCase()}` :\n `${label} is required`;\n return { level: \"error\", kind: \"required\", message: msg };\n }\n if (isEmptyValue(v)) return null;\n\n if (counted(f)) {\n const n = textLength(v);\n if (r.max && n > r.max) return { level: \"error\", kind: \"rule\", message: `Keep it under ${r.max} characters (${n - r.max} over)` };\n if (r.min && n < r.min) return { level: \"error\", kind: \"rule\", message: `Use at least ${r.min} characters` };\n if (r.recommendedMax && n > r.recommendedMax)\n return { level: \"warning\", kind: \"rule\", message: `Longer than the recommended ${r.recommendedMax} characters. It may get cut off.` };\n }\n if ((f.type === \"array\" || f.type === \"slot\" || f.type === \"tags\" || f.type === \"multiselect\") && Array.isArray(v)) {\n if (r.min && v.length < r.min) return { level: \"error\", kind: \"rule\", message: `Add at least ${r.min} ${r.min === 1 ? \"item\" : \"items\"}` };\n if (r.max && v.length > r.max) return { level: \"error\", kind: \"rule\", message: `Use at most ${r.max} items` };\n }\n if (f.type === \"number\" && typeof v === \"number\") {\n const lo = r.min ?? f.numeric?.min;\n const hi = r.max ?? f.numeric?.max;\n if (lo != null && v < lo) return { level: \"error\", kind: \"rule\", message: `Use ${lo} or more` };\n if (hi != null && v > hi) return { level: \"error\", kind: \"rule\", message: `Use ${hi} or less` };\n }\n if (typeof v === \"string\") {\n if (f.type === \"email\" && !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use a full email address, like hello@caldera.com\" };\n if (f.type === \"url\" && !/^(https?:\\/\\/|\\/|#|mailto:|tel:)[^\\s]*$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use a full URL, like https://example.com, or a path like /shop\" };\n if (f.type === \"url\" && /^(javascript|data):/i.test(v)) return { level: \"error\", kind: \"rule\", message: \"This kind of link isn't allowed\" };\n if (f.type === \"slug\" && !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(v)) return { level: \"error\", kind: \"rule\", message: \"Use lowercase letters, numbers and hyphens\" };\n if (f.type === \"json\") {\n try {\n JSON.parse(v);\n } catch {\n return { level: \"error\", kind: \"rule\", message: \"Invalid JSON\" };\n }\n }\n if (r.pattern && !new RegExp(r.pattern).test(v)) return { level: \"error\", kind: \"rule\", message: r.patternMessage ?? \"This doesn't match the expected format\" };\n }\n if (f.type === \"table\") {\n // caption, header labels, typed cells, row limits, markup readiness (src/schema/table.ts) — first error wins\n const issues = tableIssues(v, { ...f.table, minRows: f.table?.minRows ?? r.min, maxRows: f.table?.maxRows ?? r.max });\n const first = issues.find((i) => i.level === \"error\") ?? issues[0];\n if (first) return { level: first.level, kind: \"rule\", message: first.message };\n }\n if (f.type === \"image\" && isObj(v) && v.url && !v.alt && r.required) return { level: \"warning\", kind: \"rule\", message: \"No alt text. Describe the image for accessibility.\" };\n return null;\n}\n\n/**\n * Values other records already hold for a ROOT field with `validation.unique` (a collection's other entries). The host\n * passes it; without it a root `unique` field is not checked (lists always are).\n */\nexport type UniquePeers = (field: FieldSchema, path: FieldPath) => unknown[] | undefined;\n\n/**\n * What makes two values \"the same\" for `unique` (V2 uniqueKey, as the server judges a placement in backend prop-fields\n * tableProblem): text trimmed and case-folded, numbers and booleans as written, a reference or link by its id. null =\n * nothing to compare. A list's items compare whole (itemKey), strings case-folded, rows without their `_id` / `_key`.\n */\nexport function uniqueKey(v: unknown): string | null {\n if (typeof v === \"string\") return v.trim() ? v.trim().toLocaleLowerCase(\"und\") : null;\n if ((typeof v === \"number\" && Number.isFinite(v)) || typeof v === \"boolean\") return String(v);\n if (!isObj(v)) return null;\n const id = v._ref ?? v.id ?? v.value ?? v.href ?? v.url;\n return typeof id === \"string\" || typeof id === \"number\" ? uniqueKey(String(id)) : null;\n}\nconst itemKey = (v: unknown): string => {\n if (typeof v === \"string\") return `s:${v.trim().toLocaleLowerCase(\"und\")}`;\n if (isObj(v)) {\n const { _id: _i, _key: _k, ...rest } = v;\n return `o:${JSON.stringify(Object.fromEntries(Object.entries(rest).sort(([a], [b]) => a.localeCompare(b))))}`;\n }\n return `j:${JSON.stringify(v)}`;\n};\n/** Indexes of the values whose key repeats one an earlier value already used. */\nfunction repeats(values: unknown[], key: (v: unknown) => string | null): number[] {\n const seen = new Set<string>();\n const out: number[] = [];\n values.forEach((v, i) => {\n const k = key(v);\n if (k === null) return;\n if (seen.has(k)) out.push(i);\n else seen.add(k);\n });\n return out;\n}\nconst shown = (v: unknown) => {\n const s = typeof v === \"string\" ? v.trim() : isObj(v) ? String(v.title ?? v.label ?? v._ref ?? v.id ?? \"\") : String(v ?? \"\");\n return s.length > 40 ? `${s.slice(0, 39)}…` : s;\n};\n\n/** Walk fields under `obj` and collect every issue, recursing into objects, array items and slot blocks. */\nexport function collectIssues(\n fields: FieldSchema[],\n obj: unknown,\n base: FieldPath,\n resolveSchema?: (t: string) => TypeSchema | undefined,\n out: KitIssue[] = [],\n /** what a `_variant` condition reads above this level (V2; the root call: the value itself) */\n cc?: CondCtx,\n /** root fields with `unique`: the values the model's other records hold (the root call only) */\n peers?: UniquePeers,\n): KitIssue[] {\n const v = isObj(obj) ? obj : {};\n const here: CondCtx = cc ?? { root: v, variant: typeof v._variant === \"string\" ? v._variant : undefined };\n const below: CondCtx = { root: here.root, parent: v, variant: here.variant };\n for (const f of fields) {\n if (isHidden(f, v, here)) continue;\n const p = [...base, f.name];\n const val = v[f.name];\n const raw = validateValue(f, val);\n if (raw) out.push({ ...raw, key: pathKey(p), path: p });\n else if (peers && !base.length && f.validation?.unique && f.type !== \"array\") {\n const k = uniqueKey(val);\n if (k !== null && (peers(f, p) ?? []).some((o) => uniqueKey(o) === k))\n out.push({ level: \"error\", kind: \"rule\", message: `Another item already uses “${shown(val)}”. ${f.title} must be different on each one.`, key: pathKey(p), path: p });\n }\n if (f.type === \"object\" && f.fields) collectIssues(f.fields, val, p, resolveSchema, out, below);\n // A list's `unique`: no item twice (the first repeat is reported on the list).\n if ((f.type === \"array\" || f.type === \"tags\" || f.type === \"multiselect\") && Array.isArray(val) && f.validation?.unique && !raw) {\n const [r] = repeats(val, itemKey);\n if (r !== undefined) out.push({ level: \"error\", kind: \"rule\", message: typeof val[r] === \"string\" ? `“${shown(val[r])}” is in the list twice. Each item can be added once.` : `Item ${r + 1} repeats an earlier item. Each item must be different.`, key: pathKey(p), path: p });\n }\n if (f.type === \"array\" && Array.isArray(val) && !primitiveItem(f)) {\n val.forEach((it, i) => {\n const s = itemSchemaFor(f, it);\n if (s?.fields) collectIssues(s.fields, it, [...p, i], resolveSchema, out, below);\n });\n // A field inside the items with `unique` (or the list's `uniqueBy`): no two items share its value.\n const keys = new Set<string>();\n for (const it of val) for (const x of itemSchemaFor(f, it)?.fields ?? []) if (x.validation?.unique || f.validation?.uniqueBy === x.name) keys.add(x.name);\n for (const k of keys) {\n const vals = val.map((it) => (isObj(it) ? it[k] : undefined));\n for (const i of repeats(vals, uniqueKey)) {\n const fp = [...p, i, k];\n const title = itemSchemaFor(f, val[i])?.fields?.find((x) => x.name === k)?.title ?? k;\n if (!out.some((x) => x.key === pathKey(fp))) out.push({ level: \"error\", kind: \"rule\", message: `${title} must be different on each item. “${shown(vals[i])}” is already used.`, key: pathKey(fp), path: fp });\n }\n }\n }\n if (f.type === \"slot\" && Array.isArray(val) && resolveSchema) {\n val.forEach((it, i) => {\n const b = isObj(it) && typeof it._type === \"string\" ? resolveSchema(it._type) : undefined;\n if (b) collectIssues(b.fields, it, [...p, i], resolveSchema, out, { root: it, variant: isObj(it) && typeof it._variant === \"string\" ? it._variant : b.vari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(src/kit/library/examples). They predate the entry contract, so the
2
+ * Model notes for the seven core examples (library/examples). They predate the entry contract, so the
3
3
  * catalog attaches these by example id, as it does CORE_TAGS. Every claim is sourced from the example's own schema
4
4
  * and `proves`, the backend skill's worked examples (hero, pricing, FAQ, blog entry, mega menu, tabs) and the MCP
5
5
  * playbook §2–§5 and §14. The `mcp` text is in create_component / update_layout / create_content_model terms.
@@ -1 +1 @@
1
- {"version":3,"file":"coreNotes.js","names":[],"sources":["../../src/library/coreNotes.ts"],"sourcesContent":["/**\n * Model notes for the seven core examples (src/kit/library/examples). They predate the entry contract, so the\n * catalog attaches these by example id, as it does CORE_TAGS. Every claim is sourced from the example's own schema\n * and `proves`, the backend skill's worked examples (hero, pricing, FAQ, blog entry, mega menu, tabs) and the MCP\n * playbook §2–§5 and §14. The `mcp` text is in create_component / update_layout / create_content_model terms.\n */\nimport type { KitModelNotes } from \"./types\";\n\nexport const CORE_NOTES: Record<string, KitModelNotes> = {\n faq: {\n why:\n \"Questions are same-shaped rows, so `items` is one list whose row holds a plain-string question and a rich-text answer (bold, links and lists live in answers). `source` switches between questions written here and references into a FAQs collection; each list shows only for its own choice, so the two never disagree. Search, rich results, columns and the anchor are Settings, not copy, and the anchor is locked to people who manage the schema.\",\n htmlSignals: [\n \"Repeated <details> with a <summary> holding the question (often an <h3> plus a chevron <svg>) and a body <div> holding the answer\",\n \"The first <details> carries `open`\",\n \"A hand-written <script type=\\\"application/ld+json\\\"> with \\\"@type\\\":\\\"FAQPage\\\" beside the band\",\n \"A closing line with a support link under the list (\\\"Still stuck? Talk to support\\\")\",\n ],\n mcp:\n \"create_component with sectionType 'FAQ'; each prop needs a `target` into your own blockJson (a root `section` with `style`). eyebrow/heading/intro → text props on heading/text blocks. items → ONE `table` prop: config.fields question (text, required) + answer (richtext, required), plus category (select) and open (boolean); ui { preview: { title: 'question' }, itemLabel: 'Question', icon: 'help-circle' }. source → a select with ui.control 'segmented'; give items and collection a `showIf` on source ('inline' / 'collection'), placed after source. collection → multi-reference with config.contentModelId of the FAQs model. showSearch/richResults/columns/anchor → ui.tab 'Settings'. Accordion and Two columns are two components sharing sectionType 'FAQ' with the same prop keys.\",\n pitfalls: [\n \"richResults does nothing by itself: FAQPage markup comes from update_page schemaType 'FAQPage', and the builder finds the first list whose rows have keys containing `question` and `answer`. Delete the hand-written JSON-LD.\",\n \"`open` on the first item is behaviour in the worked example and stays in the template; keep the per-item boolean only if the template reads it.\",\n \"Bind the question on the <h3>, not the <summary>, or a save erases the chevron.\",\n ],\n },\n megaMenu: {\n why:\n \"The navigation is a GLOBAL block: one copy synced across every page, edited once. Its menu is five levels deep (Navigation › menu item › column › link › badge) to prove drill-in and breadcrumb truncation. A menu item `kind` decides whether it is a plain link or opens a mega panel of columns plus a featured card, so a link row never carries panel data. Sticky, transparent and the mobile style sit in a Behaviour tab; the logo and its screen-reader text share a Brand fieldset.\",\n htmlSignals: [\n \"A <header> on every page holding <nav aria-label=\\\"Main\\\"> with a logo <a><img></a> and a <ul> of menu items\",\n \"A <button aria-expanded aria-controls> that opens a hidden panel, beside plain <a> items that just link\",\n \"Panel columns: a title <p> over a <ul> of links, each link a label <span>, an optional description <span> and an optional badge (\\\"New\\\")\",\n \"Sign-in link and a primary button at the end of the bar\",\n ],\n mcp:\n \"Site chrome is the Layout, never a page section: get_layout, then update_layout scope 'global' with `add-field` commands on the reserved `navigation` Section (ifMatch from get_layout), set-field-value for the rows, publish_layout. Read the Section's existing logo, link and button fields first and add only what is missing. If the header is a component placed with `add-component`, each prop needs a `target` into your own blockJson: items → a `table` prop (ui { itemLabel: 'Menu item', preview: { title: 'label' } }) whose rows hold label, link (a `link` value), kind (select) and ONE nested `table` of links with `column` as a text sub-field; cta → a `button` prop on a button block's `props`. logo/logoText → ui.group 'brand'; sticky/transparent/mobile → ui.tab 'Behaviour'.\",\n pitfalls: [\n \"Two list levels is the cap for a component's props and the depth chrome is proven to bind at: store menu → links and put the column title on each link row. The kit's third level (columns) and the badge object do not fit; flatten the badge to a scalar on the link row.\",\n \"A nav placed on a page as a section renders nowhere, and a page that draws its own header gets no Layout copy on top: remove page-level copies.\",\n \"The worked example keeps `sticky`, colours and height in code; expose the Behaviour props only if the template reads them.\",\n ],\n },\n tabs: {\n why:\n \"Tabs are a list (2–6), and each tab is a label, an optional icon and a SLOT of blocks, so a panel can hold text, images, features, stats, quotes, CTA cards, product cards or video in any order. The allow list keeps panels to small content blocks. Which tab opens first and whether the URL remembers it are settings; underline, pills and side tabs are layout variants.\",\n htmlSignals: [\n \"A role=\\\"tablist\\\" of <button role=\\\"tab\\\" aria-controls aria-selected>, often each with an icon <i>\",\n \"One role=\\\"tabpanel\\\" per tab, all but the first `hidden`\",\n \"Panels that hold their own rows of cards, images and stats rather than one paragraph\",\n ],\n mcp:\n \"A band one page owns can stay a `section` block holding a `tabs` block {tabs:[{id,label,children}]} (worked example 8). As a component: create_component with a sectionType naming the family (e.g. 'Tabs'); each prop needs a `target` into your own blockJson. tabs → ONE `table` prop (ui { itemLabel: 'Tab', preview: { title: 'label' }, icon: 'layout-list' }) with config.fields label (text, required), icon (`icon`) and content: a `slot` sub-field with config.multiple, maxItems 6 and config.componentIds; point the table at your tabs block the way §14's slider table targets props.slides. heading → text prop; defaultTab → number with config.min 1, max 6. Underline, Pills and Side tabs are three components sharing sectionType 'Tabs' with the same prop keys.\",\n pitfalls: [\n \"The kit's slot allow list names kit blocks, not components: config.componentIds must list published components of this project.\",\n \"Slot children are `{ componentId, overrides? }` with no `_variant`: a variant is its own component.\",\n \"Give every block, tab and instance a stable `id`; changing one orphans the edits made against it.\",\n ],\n },\n pricing: {\n why:\n \"Tiers are same-shaped rows (1–4). A tier's priceType decides what shows: a fixed tier shows the amount and billing interval, a custom tier swaps in a Contact sales button, so a tier never shows a price and 'Contact sales' at once. Features are tiny rows (label, included, tooltip) that open inline. The comparison table, currency, the monthly/yearly switch and its discount are Display settings; Three tiers, Two tiers and Comparison table are variants.\",\n htmlSignals: [\n \"A grid of plan <article>s, each with an <h3> name, a short audience line, a price, a <ul class=\\\"checks\\\"> and one CTA <a>\",\n \"One card flagged with a ribbon or modifier class (\\\"Most popular\\\")\",\n \"A price <span> with data-monthly / data-yearly next to a role=\\\"radiogroup\\\" billing toggle (\\\"Save 20%\\\")\",\n \"A price in words (\\\"Let's talk\\\") linking to contact sales instead of an amount\",\n \"A <table class=\\\"compare\\\"> with one column per plan and check / cross icons labelled by aria-label\",\n ],\n mcp:\n \"create_component with sectionType 'Pricing' and category 'conversion'; it lands as a draft, then publish_component. Each prop needs a `target` into your own blockJson: tiers → ONE `table` prop targeting props.rows of a `section` block whose children mirror one row, ui { itemLabel: 'Tier', preview: { title: 'name' }, icon: 'tiers' }; its config.fields hold name, tagline, priceType (select, ui.control 'segmented'), price (number) and interval with `showIf` priceType eq 'fixed', contactSales and cta as `button` sub-fields, featured (boolean) and features as a nested `table` of scalars. comparison → a second `table` prop, one row per feature and one key per tier. currency/toggle/discount → ui.tab 'Display'. Variants are sibling components sharing sectionType 'Pricing' and the same prop keys.\",\n pitfalls: [\n \"Store numbers, never '$24/mo'. A price in words is its own text key, shown when the numbers are empty.\",\n \"The nested features table is the deepest a prop goes: its rows take scalars only.\",\n \"A tier added to the comparison is a new sub-field, a schema change. No Offer JSON-LD is built from prices; paste it as `schema` on update_page when needed.\",\n ],\n },\n bento: {\n why:\n \"A bento is a SLOT of 3–9 cells, and each cell is any allowed block (image, stat, quote, text, CTA card, product card, video). Size (1×1, 2×1, 1×2, 2×2) and surface (light, dark, brand) belong to the cell's place in this grid, not to the block, so they are per-slot settings rather than fields on every block. The gap is a design select; four and three columns are variants.\",\n htmlSignals: [\n \"A grid section whose cells span different column/row counts (wide, tall and large tiles beside small ones)\",\n \"Cells of mixed kinds in one grid: a photo, a big number with a label, a quote, a product card, a CTA card, a video\",\n \"Some cells on a dark or brand-coloured surface while their neighbours are light\",\n ],\n mcp:\n \"create_component with a sectionType naming the family (e.g. 'Bento'); each prop needs a `target` into your own blockJson. cells → a `slot` prop with config.multiple, minItems 3, maxItems 9, config.componentIds of your published cell components, and config.slotSettings span (select 1x1/2x1/1x2/2x2, ui.control 'cards') and tone (select light/dark/brand, ui.control 'segmented'); target a container's child list (props.children on a section, props.columns.<n> on a columns block). Each child is `{ componentId, overrides? }` and its settings sit in `_settings`. eyebrow/heading → text props; gap → select with ui.control 'segmented'. 4 columns and 3 columns are two components sharing sectionType 'Bento' with the same prop keys.\",\n pitfalls: [\n \"The kit's allow list names kit blocks; config.componentIds must name this project's published components, and the renderer needs their definitions or every cell draws empty.\",\n \"A slot child has no `_variant`: a variant is its own component.\",\n \"slotSettings are leaf fields only; a cell's own copy stays in the cell component's props.\",\n ],\n },\n journalStory: {\n why:\n \"A story is an ENTRY, one of many, with its own URL: content in groups (Content, Media, Settings) and fieldsets (Byline, a collapsed Gear review, Publishing). Authors and topics are references to their own collections, not copied names; the reviewed product is a reference to commerce. The body is the one long rich-text field. Layout, accent, internal tags, related stories and developer-only custom CSS are Settings. It proves references, rich text, SEO-friendly limits (title, excerpt) and changed-since-publish.\",\n htmlSignals: [\n \"An <article> (often itemtype BlogPosting) with an <h1>, a dek <p>, a byline with <a rel=\\\"author\\\"> and <time datetime>\",\n \"A cover <figure> with <img> and <figcaption> above a prose body of <h2>, <p>, lists, figures, tables and code\",\n \"A topic link above the title and a reading time (\\\"7 min read\\\") in the byline\",\n \"One of many pages under a shared route such as /blog/<slug>\",\n ],\n mcp:\n \"Not a component: create_content_model for the stories (a collection with urlPattern '/blog/:slug' and one dynamic page), and create_content_entry per story. Find or create the author and topic entries first and reference them by id. title, slug, excerpt, cover, gallery and film are fields; body is the ONE `document` field (top level, at most one per schema); dates are ISO 8601 with their offset. Publish authors and topics, then the post, then the template page. The `component` shape below is props-shaped only for comparison; if you place a story teaser as a component, each prop needs a `target` into your own blockJson.\",\n pitfalls: [\n \"Never model SEO fields: entry meta (metaTitle, metaDescription, og, canonical) goes in update_content_entry `meta`, and BlogPosting markup is automatic for a collection with a body, a date and an author.\",\n \"Reading time is computed by the template; no field stores it today, so don't copy \\\"7 min read\\\" into readingTime.\",\n \"Bind the body wrapper as kind `document`, never `richtext`, or a save repaints the article from plain text.\",\n ],\n },\n hero: {\n why:\n \"The opening band: an eyebrow, a headline (required, 90 max, 60 recommended), supporting text, two buttons and a proof line of rating plus label. Each button is one unit, so label, link and look travel together. The proof is a small object because the stars are drawn from the number. Media (a required image, an optional background video) and Design (alignment, theme, overlay, fill-the-screen) are their own tabs, so copy, media and look never mix; split, centered and full-bleed are variants.\",\n htmlSignals: [\n \"The first <section> after the header with one <h1>, a short eyebrow <p> above it and a lede <p> below\",\n \"Two links styled as buttons (btn-primary / btn-ghost), sometimes with an arrow icon\",\n \"A <picture>/<img> beside the copy (split) or absolutely positioned behind it with a dark scrim <div> (full-bleed)\",\n \"A rating line: star glyphs with aria-label=\\\"Rated 4.8 out of 5\\\" and \\\"from 310 reviews\\\"\",\n ],\n mcp:\n \"create_component with sectionType 'Hero' and category 'hero'; root is a `section` block with `style`, content in props.children. Each prop needs a `target` into your own blockJson: eyebrow/body → text props on text blocks (props.html), heading → props.text of a level-1 heading block, primary/secondary → one `button` prop each (label, link and look in one unit) on a button block's `props`, image → an `image` prop on an image block's props.src plus a text prop on props.alt, video → a video block's props.url, proof → an `object` prop with config.fields rating (number) and label (text). Put image/video in ui.tab 'Media' and align/theme/overlay/fullHeight in ui.tab 'Design' (theme with ui.control 'segmented'). Split image, Centered and Full-bleed image are three components sharing sectionType 'Hero' with the same prop keys.\",\n pitfalls: [\n \"Overlay and height have no section token today: the scrim and spacing stay in the template's classes unless the template reads those props.\",\n \"object-position is the image's focal point (50% 35% → { x: 0.5, y: 0.35 }); store the number 4.8, never the star glyphs.\",\n \"A variant that renames a key (title vs heading) silently drops that content on a swap.\",\n ],\n },\n};\n"],"mappings":";AAQA,IAAa,aAA4C;CACvD,KAAK;EACH,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,UAAU;EACR,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,MAAM;EACJ,KACE;EACF,aAAa;GACX;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,SAAS;EACP,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,OAAO;EACL,KACE;EACF,aAAa;GACX;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,cAAc;EACZ,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,MAAM;EACJ,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;AACF"}
1
+ {"version":3,"file":"coreNotes.js","names":[],"sources":["../../src/library/coreNotes.ts"],"sourcesContent":["/**\n * Model notes for the seven core examples (library/examples). They predate the entry contract, so the\n * catalog attaches these by example id, as it does CORE_TAGS. Every claim is sourced from the example's own schema\n * and `proves`, the backend skill's worked examples (hero, pricing, FAQ, blog entry, mega menu, tabs) and the MCP\n * playbook §2–§5 and §14. The `mcp` text is in create_component / update_layout / create_content_model terms.\n */\nimport type { KitModelNotes } from \"./types\";\n\nexport const CORE_NOTES: Record<string, KitModelNotes> = {\n faq: {\n why:\n \"Questions are same-shaped rows, so `items` is one list whose row holds a plain-string question and a rich-text answer (bold, links and lists live in answers). `source` switches between questions written here and references into a FAQs collection; each list shows only for its own choice, so the two never disagree. Search, rich results, columns and the anchor are Settings, not copy, and the anchor is locked to people who manage the schema.\",\n htmlSignals: [\n \"Repeated <details> with a <summary> holding the question (often an <h3> plus a chevron <svg>) and a body <div> holding the answer\",\n \"The first <details> carries `open`\",\n \"A hand-written <script type=\\\"application/ld+json\\\"> with \\\"@type\\\":\\\"FAQPage\\\" beside the band\",\n \"A closing line with a support link under the list (\\\"Still stuck? Talk to support\\\")\",\n ],\n mcp:\n \"create_component with sectionType 'FAQ'; each prop needs a `target` into your own blockJson (a root `section` with `style`). eyebrow/heading/intro → text props on heading/text blocks. items → ONE `table` prop: config.fields question (text, required) + answer (richtext, required), plus category (select) and open (boolean); ui { preview: { title: 'question' }, itemLabel: 'Question', icon: 'help-circle' }. source → a select with ui.control 'segmented'; give items and collection a `showIf` on source ('inline' / 'collection'), placed after source. collection → multi-reference with config.contentModelId of the FAQs model. showSearch/richResults/columns/anchor → ui.tab 'Settings'. Accordion and Two columns are two components sharing sectionType 'FAQ' with the same prop keys.\",\n pitfalls: [\n \"richResults does nothing by itself: FAQPage markup comes from update_page schemaType 'FAQPage', and the builder finds the first list whose rows have keys containing `question` and `answer`. Delete the hand-written JSON-LD.\",\n \"`open` on the first item is behaviour in the worked example and stays in the template; keep the per-item boolean only if the template reads it.\",\n \"Bind the question on the <h3>, not the <summary>, or a save erases the chevron.\",\n ],\n },\n megaMenu: {\n why:\n \"The navigation is a GLOBAL block: one copy synced across every page, edited once. Its menu is five levels deep (Navigation › menu item › column › link › badge) to prove drill-in and breadcrumb truncation. A menu item `kind` decides whether it is a plain link or opens a mega panel of columns plus a featured card, so a link row never carries panel data. Sticky, transparent and the mobile style sit in a Behaviour tab; the logo and its screen-reader text share a Brand fieldset.\",\n htmlSignals: [\n \"A <header> on every page holding <nav aria-label=\\\"Main\\\"> with a logo <a><img></a> and a <ul> of menu items\",\n \"A <button aria-expanded aria-controls> that opens a hidden panel, beside plain <a> items that just link\",\n \"Panel columns: a title <p> over a <ul> of links, each link a label <span>, an optional description <span> and an optional badge (\\\"New\\\")\",\n \"Sign-in link and a primary button at the end of the bar\",\n ],\n mcp:\n \"Site chrome is the Layout, never a page section: get_layout, then update_layout scope 'global' with `add-field` commands on the reserved `navigation` Section (ifMatch from get_layout), set-field-value for the rows, publish_layout. Read the Section's existing logo, link and button fields first and add only what is missing. If the header is a component placed with `add-component`, each prop needs a `target` into your own blockJson: items → a `table` prop (ui { itemLabel: 'Menu item', preview: { title: 'label' } }) whose rows hold label, link (a `link` value), kind (select) and ONE nested `table` of links with `column` as a text sub-field; cta → a `button` prop on a button block's `props`. logo/logoText → ui.group 'brand'; sticky/transparent/mobile → ui.tab 'Behaviour'.\",\n pitfalls: [\n \"Two list levels is the cap for a component's props and the depth chrome is proven to bind at: store menu → links and put the column title on each link row. The kit's third level (columns) and the badge object do not fit; flatten the badge to a scalar on the link row.\",\n \"A nav placed on a page as a section renders nowhere, and a page that draws its own header gets no Layout copy on top: remove page-level copies.\",\n \"The worked example keeps `sticky`, colours and height in code; expose the Behaviour props only if the template reads them.\",\n ],\n },\n tabs: {\n why:\n \"Tabs are a list (2–6), and each tab is a label, an optional icon and a SLOT of blocks, so a panel can hold text, images, features, stats, quotes, CTA cards, product cards or video in any order. The allow list keeps panels to small content blocks. Which tab opens first and whether the URL remembers it are settings; underline, pills and side tabs are layout variants.\",\n htmlSignals: [\n \"A role=\\\"tablist\\\" of <button role=\\\"tab\\\" aria-controls aria-selected>, often each with an icon <i>\",\n \"One role=\\\"tabpanel\\\" per tab, all but the first `hidden`\",\n \"Panels that hold their own rows of cards, images and stats rather than one paragraph\",\n ],\n mcp:\n \"A band one page owns can stay a `section` block holding a `tabs` block {tabs:[{id,label,children}]} (worked example 8). As a component: create_component with a sectionType naming the family (e.g. 'Tabs'); each prop needs a `target` into your own blockJson. tabs → ONE `table` prop (ui { itemLabel: 'Tab', preview: { title: 'label' }, icon: 'layout-list' }) with config.fields label (text, required), icon (`icon`) and content: a `slot` sub-field with config.multiple, maxItems 6 and config.componentIds; point the table at your tabs block the way §14's slider table targets props.slides. heading → text prop; defaultTab → number with config.min 1, max 6. Underline, Pills and Side tabs are three components sharing sectionType 'Tabs' with the same prop keys.\",\n pitfalls: [\n \"The kit's slot allow list names kit blocks, not components: config.componentIds must list published components of this project.\",\n \"Slot children are `{ componentId, overrides? }` with no `_variant`: a variant is its own component.\",\n \"Give every block, tab and instance a stable `id`; changing one orphans the edits made against it.\",\n ],\n },\n pricing: {\n why:\n \"Tiers are same-shaped rows (1–4). A tier's priceType decides what shows: a fixed tier shows the amount and billing interval, a custom tier swaps in a Contact sales button, so a tier never shows a price and 'Contact sales' at once. Features are tiny rows (label, included, tooltip) that open inline. The comparison table, currency, the monthly/yearly switch and its discount are Display settings; Three tiers, Two tiers and Comparison table are variants.\",\n htmlSignals: [\n \"A grid of plan <article>s, each with an <h3> name, a short audience line, a price, a <ul class=\\\"checks\\\"> and one CTA <a>\",\n \"One card flagged with a ribbon or modifier class (\\\"Most popular\\\")\",\n \"A price <span> with data-monthly / data-yearly next to a role=\\\"radiogroup\\\" billing toggle (\\\"Save 20%\\\")\",\n \"A price in words (\\\"Let's talk\\\") linking to contact sales instead of an amount\",\n \"A <table class=\\\"compare\\\"> with one column per plan and check / cross icons labelled by aria-label\",\n ],\n mcp:\n \"create_component with sectionType 'Pricing' and category 'conversion'; it lands as a draft, then publish_component. Each prop needs a `target` into your own blockJson: tiers → ONE `table` prop targeting props.rows of a `section` block whose children mirror one row, ui { itemLabel: 'Tier', preview: { title: 'name' }, icon: 'tiers' }; its config.fields hold name, tagline, priceType (select, ui.control 'segmented'), price (number) and interval with `showIf` priceType eq 'fixed', contactSales and cta as `button` sub-fields, featured (boolean) and features as a nested `table` of scalars. comparison → a second `table` prop, one row per feature and one key per tier. currency/toggle/discount → ui.tab 'Display'. Variants are sibling components sharing sectionType 'Pricing' and the same prop keys.\",\n pitfalls: [\n \"Store numbers, never '$24/mo'. A price in words is its own text key, shown when the numbers are empty.\",\n \"The nested features table is the deepest a prop goes: its rows take scalars only.\",\n \"A tier added to the comparison is a new sub-field, a schema change. No Offer JSON-LD is built from prices; paste it as `schema` on update_page when needed.\",\n ],\n },\n bento: {\n why:\n \"A bento is a SLOT of 3–9 cells, and each cell is any allowed block (image, stat, quote, text, CTA card, product card, video). Size (1×1, 2×1, 1×2, 2×2) and surface (light, dark, brand) belong to the cell's place in this grid, not to the block, so they are per-slot settings rather than fields on every block. The gap is a design select; four and three columns are variants.\",\n htmlSignals: [\n \"A grid section whose cells span different column/row counts (wide, tall and large tiles beside small ones)\",\n \"Cells of mixed kinds in one grid: a photo, a big number with a label, a quote, a product card, a CTA card, a video\",\n \"Some cells on a dark or brand-coloured surface while their neighbours are light\",\n ],\n mcp:\n \"create_component with a sectionType naming the family (e.g. 'Bento'); each prop needs a `target` into your own blockJson. cells → a `slot` prop with config.multiple, minItems 3, maxItems 9, config.componentIds of your published cell components, and config.slotSettings span (select 1x1/2x1/1x2/2x2, ui.control 'cards') and tone (select light/dark/brand, ui.control 'segmented'); target a container's child list (props.children on a section, props.columns.<n> on a columns block). Each child is `{ componentId, overrides? }` and its settings sit in `_settings`. eyebrow/heading → text props; gap → select with ui.control 'segmented'. 4 columns and 3 columns are two components sharing sectionType 'Bento' with the same prop keys.\",\n pitfalls: [\n \"The kit's allow list names kit blocks; config.componentIds must name this project's published components, and the renderer needs their definitions or every cell draws empty.\",\n \"A slot child has no `_variant`: a variant is its own component.\",\n \"slotSettings are leaf fields only; a cell's own copy stays in the cell component's props.\",\n ],\n },\n journalStory: {\n why:\n \"A story is an ENTRY, one of many, with its own URL: content in groups (Content, Media, Settings) and fieldsets (Byline, a collapsed Gear review, Publishing). Authors and topics are references to their own collections, not copied names; the reviewed product is a reference to commerce. The body is the one long rich-text field. Layout, accent, internal tags, related stories and developer-only custom CSS are Settings. It proves references, rich text, SEO-friendly limits (title, excerpt) and changed-since-publish.\",\n htmlSignals: [\n \"An <article> (often itemtype BlogPosting) with an <h1>, a dek <p>, a byline with <a rel=\\\"author\\\"> and <time datetime>\",\n \"A cover <figure> with <img> and <figcaption> above a prose body of <h2>, <p>, lists, figures, tables and code\",\n \"A topic link above the title and a reading time (\\\"7 min read\\\") in the byline\",\n \"One of many pages under a shared route such as /blog/<slug>\",\n ],\n mcp:\n \"Not a component: create_content_model for the stories (a collection with urlPattern '/blog/:slug' and one dynamic page), and create_content_entry per story. Find or create the author and topic entries first and reference them by id. title, slug, excerpt, cover, gallery and film are fields; body is the ONE `document` field (top level, at most one per schema); dates are ISO 8601 with their offset. Publish authors and topics, then the post, then the template page. The `component` shape below is props-shaped only for comparison; if you place a story teaser as a component, each prop needs a `target` into your own blockJson.\",\n pitfalls: [\n \"Never model SEO fields: entry meta (metaTitle, metaDescription, og, canonical) goes in update_content_entry `meta`, and BlogPosting markup is automatic for a collection with a body, a date and an author.\",\n \"Reading time is computed by the template; no field stores it today, so don't copy \\\"7 min read\\\" into readingTime.\",\n \"Bind the body wrapper as kind `document`, never `richtext`, or a save repaints the article from plain text.\",\n ],\n },\n hero: {\n why:\n \"The opening band: an eyebrow, a headline (required, 90 max, 60 recommended), supporting text, two buttons and a proof line of rating plus label. Each button is one unit, so label, link and look travel together. The proof is a small object because the stars are drawn from the number. Media (a required image, an optional background video) and Design (alignment, theme, overlay, fill-the-screen) are their own tabs, so copy, media and look never mix; split, centered and full-bleed are variants.\",\n htmlSignals: [\n \"The first <section> after the header with one <h1>, a short eyebrow <p> above it and a lede <p> below\",\n \"Two links styled as buttons (btn-primary / btn-ghost), sometimes with an arrow icon\",\n \"A <picture>/<img> beside the copy (split) or absolutely positioned behind it with a dark scrim <div> (full-bleed)\",\n \"A rating line: star glyphs with aria-label=\\\"Rated 4.8 out of 5\\\" and \\\"from 310 reviews\\\"\",\n ],\n mcp:\n \"create_component with sectionType 'Hero' and category 'hero'; root is a `section` block with `style`, content in props.children. Each prop needs a `target` into your own blockJson: eyebrow/body → text props on text blocks (props.html), heading → props.text of a level-1 heading block, primary/secondary → one `button` prop each (label, link and look in one unit) on a button block's `props`, image → an `image` prop on an image block's props.src plus a text prop on props.alt, video → a video block's props.url, proof → an `object` prop with config.fields rating (number) and label (text). Put image/video in ui.tab 'Media' and align/theme/overlay/fullHeight in ui.tab 'Design' (theme with ui.control 'segmented'). Split image, Centered and Full-bleed image are three components sharing sectionType 'Hero' with the same prop keys.\",\n pitfalls: [\n \"Overlay and height have no section token today: the scrim and spacing stay in the template's classes unless the template reads those props.\",\n \"object-position is the image's focal point (50% 35% → { x: 0.5, y: 0.35 }); store the number 4.8, never the star glyphs.\",\n \"A variant that renames a key (title vs heading) silently drops that content on a swap.\",\n ],\n },\n};\n"],"mappings":";AAQA,IAAa,aAA4C;CACvD,KAAK;EACH,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,UAAU;EACR,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,MAAM;EACJ,KACE;EACF,aAAa;GACX;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,SAAS;EACP,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,OAAO;EACL,KACE;EACF,aAAa;GACX;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,cAAc;EACZ,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;CACA,MAAM;EACJ,KACE;EACF,aAAa;GACX;GACA;GACA;GACA;EACF;EACA,KACE;EACF,UAAU;GACR;GACA;GACA;EACF;CACF;AACF"}
@@ -3485,6 +3485,14 @@ var ENTRIES = [
3485
3485
  name: "icon",
3486
3486
  title: "Icon",
3487
3487
  type: "icon",
3488
+ icons: {
3489
+ sources: [
3490
+ "pack",
3491
+ "library",
3492
+ "upload"
3493
+ ],
3494
+ decorative: "ask"
3495
+ },
3488
3496
  hidden: {
3489
3497
  field: "kind",
3490
3498
  equals: [