@bettercms-ai/kit 3.1.7 → 3.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controls/choice.js +2 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/code.js +1 -1
- package/dist/controls/code.js.map +1 -1
- package/dist/controls/color.js +1 -1
- package/dist/controls/color.js.map +1 -1
- package/dist/controls/icon.js +1 -1
- package/dist/controls/icon.js.map +1 -1
- package/dist/controls/location.js +1 -1
- package/dist/controls/location.js.map +1 -1
- package/dist/controls/number.js +4 -4
- package/dist/controls/number.js.map +1 -1
- package/dist/controls/reference.js +3 -3
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/editor.d.ts +0 -2
- package/dist/controls/rich-text/editor.js +4 -11
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/table/table-editor.js +1 -1
- package/dist/controls/table/table-editor.js.map +1 -1
- package/dist/engine/array.d.ts +11 -0
- package/dist/engine/array.js +24 -4
- package/dist/engine/array.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/lib/validate.d.ts +2 -0
- package/dist/lib/validate.js +4 -2
- package/dist/lib/validate.js.map +1 -1
- package/dist/library/entries/advanced.entries.js +4 -0
- package/dist/library/entries/advanced.entries.js.map +1 -1
- package/dist/library/kit-catalog.json +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +0 -3
- package/dist/tokens.css +6 -12
- package/dist/ui/controls.js +9 -9
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/path-crumbs.js +2 -1
- package/dist/ui/path-crumbs.js.map +1 -1
- package/package.json +2 -2
package/dist/lib/validate.js.map
CHANGED
|
@@ -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;\n/** A colour as a stylesheet takes it: hex (#RGB · #RRGGBB · #RRGGBBAA), a colour function, or a custom property (BL-567). */\nconst COLOUR = /^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\\([^()]*\\)|var\\(--[\\w-]+\\))$/i;\nexport const isColour = (v: string): boolean => COLOUR.test(v.trim());\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 // BL-567: a required button with a link and no words is a blank button on the page.\n if (r.required && f.type === \"button\" && isObj(v) && !String(v.label ?? \"\").trim())\n return { level: \"error\", kind: \"required\", message: `Add a label for ${label.toLowerCase()}` };\n if (f.type === \"color\" && typeof v === \"string\" && !isColour(v)) return { level: \"error\", kind: \"rule\", message: \"Use a hex colour, like #1a73e8\" };\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.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;;AAEvD,IAAM,SAAS;AACf,IAAa,YAAY,MAAuB,OAAO,KAAK,EAAE,KAAK,CAAC;AACpE,IAAM,WAAW,MAAmB,EAAE,SAAS,YAAY,EAAE,SAAS,UAAU,EAAE,SAAS;;AAG3F,SAAgB,cAA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
|
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\n/** One wording for a list under its minimum: the rule (error, once touched) and the at-rest warning (OBS-01). */\nexport const minItemsMessage = (min: number) => `Add at least ${min} ${min === 1 ? \"item\" : \"items\"}`;\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;\n/** A colour as a stylesheet takes it: hex (#RGB · #RRGGBB · #RRGGBBAA), a colour function, or a custom property (BL-567). */\nconst COLOUR = /^(?:#(?:[0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\\([^()]*\\)|var\\(--[\\w-]+\\))$/i;\nexport const isColour = (v: string): boolean => COLOUR.test(v.trim());\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 // BL-567: a required button with a link and no words is a blank button on the page.\n if (r.required && f.type === \"button\" && isObj(v) && !String(v.label ?? \"\").trim())\n return { level: \"error\", kind: \"required\", message: `Add a label for ${label.toLowerCase()}` };\n if (f.type === \"color\" && typeof v === \"string\" && !isColour(v)) return { level: \"error\", kind: \"rule\", message: \"Use a hex colour, like #1a73e8\" };\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: minItemsMessage(r.min) };\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.variants?.[0]?.id });\n if (f.slotSettings && isObj(it)) collectIssues(f.slotSettings, it._settings, [...p, i, \"_settings\"], resolveSchema, out);\n });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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"}
|
|
@@ -1732,6 +1732,7 @@ var ENTRIES = [
|
|
|
1732
1732
|
title: "Offer terms",
|
|
1733
1733
|
type: "string",
|
|
1734
1734
|
group: "global",
|
|
1735
|
+
synced: { from: "Announcement bar" },
|
|
1735
1736
|
access: { edit: "schema.manage" },
|
|
1736
1737
|
lockReason: "Set in the global block. Pages can't override offer terms.",
|
|
1737
1738
|
validation: { max: 120 }
|
|
@@ -1741,6 +1742,7 @@ var ENTRIES = [
|
|
|
1741
1742
|
title: "Show from",
|
|
1742
1743
|
type: "datetime",
|
|
1743
1744
|
group: "global",
|
|
1745
|
+
synced: { from: "Announcement bar" },
|
|
1744
1746
|
access: { edit: "schema.manage" },
|
|
1745
1747
|
lockReason: "The schedule is the same on every page."
|
|
1746
1748
|
},
|
|
@@ -1749,6 +1751,7 @@ var ENTRIES = [
|
|
|
1749
1751
|
title: "Hide after",
|
|
1750
1752
|
type: "datetime",
|
|
1751
1753
|
group: "global",
|
|
1754
|
+
synced: { from: "Announcement bar" },
|
|
1752
1755
|
access: { edit: "schema.manage" },
|
|
1753
1756
|
lockReason: "The schedule is the same on every page."
|
|
1754
1757
|
},
|
|
@@ -1757,6 +1760,7 @@ var ENTRIES = [
|
|
|
1757
1760
|
title: "Visitors can close it",
|
|
1758
1761
|
type: "boolean",
|
|
1759
1762
|
group: "global",
|
|
1763
|
+
synced: { from: "Announcement bar" },
|
|
1760
1764
|
access: { edit: "schema.manage" },
|
|
1761
1765
|
lockReason: "Set in the global block.",
|
|
1762
1766
|
description: "Remembers the close for 7 days."
|