Support for default values in jdd args

This commit is contained in:
Kuba Orlik 2026-08-15 16:06:02 +02:00
parent 4210e52e7e
commit a364cc97a3
13 changed files with 61 additions and 61 deletions

46
package-lock.json generated
View File

@ -14,8 +14,8 @@
"@koa/router": "^12.0.1", "@koa/router": "^12.0.1",
"@sealcode/add-to-head": "^1.0.0", "@sealcode/add-to-head": "^1.0.0",
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/jdd": "^0.8.11", "@sealcode/jdd": "^0.8.13",
"@sealcode/jdd-editor": "^0.2.36", "@sealcode/jdd-editor": "^0.2.37",
"@sealcode/monaco-wrapper": "^0.0.12", "@sealcode/monaco-wrapper": "^0.0.12",
"@sealcode/sealgen": "^0.19.23", "@sealcode/sealgen": "^0.19.23",
"@sealcode/show-first-row": "^0.1.0", "@sealcode/show-first-row": "^0.1.0",
@ -39,7 +39,7 @@
"js-convert-case": "^4.2.0", "js-convert-case": "^4.2.0",
"koa-mount": "^4.2.0", "koa-mount": "^4.2.0",
"koa-qs": "^3.0.0", "koa-qs": "^3.0.0",
"koa-responsive-image-router": "^0.2.40", "koa-responsive-image-router": "^0.2.41",
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"locreq": "^3.0.0", "locreq": "^3.0.0",
"meilisearch": "^0.41.0", "meilisearch": "^0.41.0",
@ -1361,9 +1361,9 @@
} }
}, },
"node_modules/@sealcode/jdd": { "node_modules/@sealcode/jdd": {
"version": "0.8.11", "version": "0.8.13",
"resolved": "https://registry.npmjs.org/@sealcode/jdd/-/jdd-0.8.11.tgz", "resolved": "https://registry.npmjs.org/@sealcode/jdd/-/jdd-0.8.13.tgz",
"integrity": "sha512-2OVNyxoKt/C1k+of6+t+tYrZUrf7DhrVf7nlYTSZ3+e4JMtZQl5dO3fJdPy5MasjkLcDTdQ0I9aHVeBK2cGr8w==", "integrity": "sha512-5vzKIk0Z/wpayvTfpoB5e6TI4cko99NuxjKUtQIpEam4lMXXgg8jD1++TK6JXrVakMjQmhW7Yg1EKz5kr+DTNQ==",
"dependencies": { "dependencies": {
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/ts-predicates": "^0.5.3", "@sealcode/ts-predicates": "^0.5.3",
@ -1384,12 +1384,12 @@
} }
}, },
"node_modules/@sealcode/jdd-editor": { "node_modules/@sealcode/jdd-editor": {
"version": "0.2.36", "version": "0.2.37",
"resolved": "https://registry.npmjs.org/@sealcode/jdd-editor/-/jdd-editor-0.2.36.tgz", "resolved": "https://registry.npmjs.org/@sealcode/jdd-editor/-/jdd-editor-0.2.37.tgz",
"integrity": "sha512-nr4xbV+0Y6/6XSKViP6CZn/+UJUU+nUcodn8izRyJPq9s8SS5jcnVgT7jwKMGL/c3Ahcso46VQV1djcZJG07Zw==", "integrity": "sha512-H2Qo4pQnLJkh6yfs18/6dw/DQxjat4Dxj+6R2gjKqGa8+eEj26DTuR/QYbsEIlbAg7HI3uEMUyw/YoqaKSXDaQ==",
"dependencies": { "dependencies": {
"@koa/router": "^13.1.0", "@koa/router": "^13.1.0",
"@sealcode/jdd": "^0.8.11", "@sealcode/jdd": "^0.8.13",
"@sealcode/monaco-wrapper": "^0.0.12", "@sealcode/monaco-wrapper": "^0.0.12",
"@sealcode/sealcodemirror": "^5.70.0-beta6", "@sealcode/sealcodemirror": "^5.70.0-beta6",
"@sealcode/sealgen": "^0.19.23", "@sealcode/sealgen": "^0.19.23",
@ -8127,9 +8127,9 @@
} }
}, },
"node_modules/koa-responsive-image-router": { "node_modules/koa-responsive-image-router": {
"version": "0.2.40", "version": "0.2.41",
"resolved": "https://registry.npmjs.org/koa-responsive-image-router/-/koa-responsive-image-router-0.2.40.tgz", "resolved": "https://registry.npmjs.org/koa-responsive-image-router/-/koa-responsive-image-router-0.2.41.tgz",
"integrity": "sha512-N9TFYGXc8904bzxgKWb7+ZUmu/lpIlfAyxZaODGS/RmQPzOAqfUS0MVuS2L+HetiGMVIPtEaBE4qY/9+Eb2pYQ==", "integrity": "sha512-nRwiVtJcHludR4cUrYdqjZQruVcpnOtNRmxW7pQiZrD9B4tQwYYXNjvPP12FLoZP4FyRmY7Acmyvqhj4HG+sDw==",
"dependencies": { "dependencies": {
"@koa/router": "^10.0.0", "@koa/router": "^10.0.0",
"@sealcode/ts-predicates": "^0.5.3", "@sealcode/ts-predicates": "^0.5.3",
@ -16011,9 +16011,9 @@
} }
}, },
"@sealcode/jdd": { "@sealcode/jdd": {
"version": "0.8.11", "version": "0.8.13",
"resolved": "https://registry.npmjs.org/@sealcode/jdd/-/jdd-0.8.11.tgz", "resolved": "https://registry.npmjs.org/@sealcode/jdd/-/jdd-0.8.13.tgz",
"integrity": "sha512-2OVNyxoKt/C1k+of6+t+tYrZUrf7DhrVf7nlYTSZ3+e4JMtZQl5dO3fJdPy5MasjkLcDTdQ0I9aHVeBK2cGr8w==", "integrity": "sha512-5vzKIk0Z/wpayvTfpoB5e6TI4cko99NuxjKUtQIpEam4lMXXgg8jD1++TK6JXrVakMjQmhW7Yg1EKz5kr+DTNQ==",
"requires": { "requires": {
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/ts-predicates": "^0.5.3", "@sealcode/ts-predicates": "^0.5.3",
@ -16043,12 +16043,12 @@
} }
}, },
"@sealcode/jdd-editor": { "@sealcode/jdd-editor": {
"version": "0.2.36", "version": "0.2.37",
"resolved": "https://registry.npmjs.org/@sealcode/jdd-editor/-/jdd-editor-0.2.36.tgz", "resolved": "https://registry.npmjs.org/@sealcode/jdd-editor/-/jdd-editor-0.2.37.tgz",
"integrity": "sha512-nr4xbV+0Y6/6XSKViP6CZn/+UJUU+nUcodn8izRyJPq9s8SS5jcnVgT7jwKMGL/c3Ahcso46VQV1djcZJG07Zw==", "integrity": "sha512-H2Qo4pQnLJkh6yfs18/6dw/DQxjat4Dxj+6R2gjKqGa8+eEj26DTuR/QYbsEIlbAg7HI3uEMUyw/YoqaKSXDaQ==",
"requires": { "requires": {
"@koa/router": "^13.1.0", "@koa/router": "^13.1.0",
"@sealcode/jdd": "^0.8.11", "@sealcode/jdd": "^0.8.13",
"@sealcode/monaco-wrapper": "^0.0.12", "@sealcode/monaco-wrapper": "^0.0.12",
"@sealcode/sealcodemirror": "^5.70.0-beta6", "@sealcode/sealcodemirror": "^5.70.0-beta6",
"@sealcode/sealgen": "^0.19.23", "@sealcode/sealgen": "^0.19.23",
@ -21072,9 +21072,9 @@
} }
}, },
"koa-responsive-image-router": { "koa-responsive-image-router": {
"version": "0.2.40", "version": "0.2.41",
"resolved": "https://registry.npmjs.org/koa-responsive-image-router/-/koa-responsive-image-router-0.2.40.tgz", "resolved": "https://registry.npmjs.org/koa-responsive-image-router/-/koa-responsive-image-router-0.2.41.tgz",
"integrity": "sha512-N9TFYGXc8904bzxgKWb7+ZUmu/lpIlfAyxZaODGS/RmQPzOAqfUS0MVuS2L+HetiGMVIPtEaBE4qY/9+Eb2pYQ==", "integrity": "sha512-nRwiVtJcHludR4cUrYdqjZQruVcpnOtNRmxW7pQiZrD9B4tQwYYXNjvPP12FLoZP4FyRmY7Acmyvqhj4HG+sDw==",
"requires": { "requires": {
"@koa/router": "^10.0.0", "@koa/router": "^10.0.0",
"@sealcode/ts-predicates": "^0.5.3", "@sealcode/ts-predicates": "^0.5.3",

View File

@ -97,8 +97,8 @@
"@koa/router": "^12.0.1", "@koa/router": "^12.0.1",
"@sealcode/add-to-head": "^1.0.0", "@sealcode/add-to-head": "^1.0.0",
"@sealcode/file-manager": "^1.0.2", "@sealcode/file-manager": "^1.0.2",
"@sealcode/jdd": "^0.8.11", "@sealcode/jdd": "^0.8.13",
"@sealcode/jdd-editor": "^0.2.36", "@sealcode/jdd-editor": "^0.2.37",
"@sealcode/monaco-wrapper": "^0.0.12", "@sealcode/monaco-wrapper": "^0.0.12",
"@sealcode/sealgen": "^0.19.23", "@sealcode/sealgen": "^0.19.23",
"@sealcode/show-first-row": "^0.1.0", "@sealcode/show-first-row": "^0.1.0",
@ -122,7 +122,7 @@
"js-convert-case": "^4.2.0", "js-convert-case": "^4.2.0",
"koa-mount": "^4.2.0", "koa-mount": "^4.2.0",
"koa-qs": "^3.0.0", "koa-qs": "^3.0.0",
"koa-responsive-image-router": "^0.2.40", "koa-responsive-image-router": "^0.2.41",
"koa-static": "^5.0.0", "koa-static": "^5.0.0",
"locreq": "^3.0.0", "locreq": "^3.0.0",
"meilisearch": "^0.41.0", "meilisearch": "^0.41.0",

View File

@ -24,14 +24,14 @@ images.getExampleCount = () => {
const component_arguments = { const component_arguments = {
title: new ComponentArguments.ShortText(), title: new ComponentArguments.ShortText(),
imagesPerPage: new ComponentArguments.ShortText().setExampleValues(["6"]), imagesPerPage: new ComponentArguments.ShortText().setDefaultValue("6"),
background_mode: new ComponentArguments.Enum([ background_mode: new ComponentArguments.Enum([
"transparent", "transparent",
"white", "white",
"white-square", "white-square",
]), ]),
speed: new ComponentArguments.ShortText().setExampleValues(["5"]), speed: new ComponentArguments.ShortText().setDefaultValue("5"),
desktop_interval: new ComponentArguments.ShortText().setExampleValues(["5"]), desktop_interval: new ComponentArguments.ShortText().setDefaultValue("5"),
endless: new ComponentArguments.Enum(["true", "false"]), endless: new ComponentArguments.Enum(["true", "false"]),
images, images,
} as const; } as const;

View File

@ -8,7 +8,7 @@ import { Component, ComponentArguments } from "@sealcode/jdd";
import { calculateDifference } from "./difference.js"; import { calculateDifference } from "./difference.js";
const component_arguments = { const component_arguments = {
date: new ComponentArguments.ShortText().setExampleValues(["2025-08-05"]), date: new ComponentArguments.ShortText().setDefaultValue("2028-08-05"),
} as const; } as const;
function renderBlock({ function renderBlock({

View File

@ -7,7 +7,9 @@ const component_arguments = {
title: new ComponentArguments.ShortText(), title: new ComponentArguments.ShortText(),
content: new ComponentArguments.Structured({ content: new ComponentArguments.Structured({
text: new ComponentArguments.Markdown(), text: new ComponentArguments.Markdown(),
color: new ComponentArguments.Enum(["normal", "accent"]), color: new ComponentArguments.Enum(["normal", "accent"]).setDefaultValue(
"normal"
),
}), }),
accordion_color: new ComponentArguments.Enum(["accent", "accent2"]), accordion_color: new ComponentArguments.Enum(["accent", "accent2"]),
faq: new ComponentArguments.List( faq: new ComponentArguments.List(

View File

@ -8,9 +8,9 @@ import { Component, ComponentArguments } from "@sealcode/jdd";
const component_arguments = { const component_arguments = {
title: new ComponentArguments.ShortText(), title: new ComponentArguments.ShortText(),
level: new ComponentArguments.Enum(["1", "2", "3", "4", "5", "6"]).setExampleValues([ level: new ComponentArguments.Enum(["1", "2", "3", "4", "5", "6"]).setDefaultValue(
"2", "2"
]), ),
blur_backdrop: new ComponentArguments.Enum(["true", "false"]), blur_backdrop: new ComponentArguments.Enum(["true", "false"]),
font_family: new ComponentArguments.Enum([ font_family: new ComponentArguments.Enum([
"industrial", "industrial",

View File

@ -10,16 +10,16 @@ const component_arguments = {
"h4", "h4",
"h5", "h5",
"h6", "h6",
]).setExampleValues(["h2"]), ]).setDefaultValue("h2"),
font_size: new ComponentArguments.Enum([ font_size: new ComponentArguments.Enum([
"tiny", "tiny",
"small", "small",
"medium", "medium",
"large", "large",
"extra_large", "extra_large",
]).setExampleValues(["medium"]), ]).setDefaultValue("medium"),
color: new ComponentArguments.Enum(["normal", "accent1", "accent2"]).setExampleValues( color: new ComponentArguments.Enum(["normal", "accent1", "accent2"]).setDefaultValue(
["normal"] "normal"
), ),
title: new ComponentArguments.ShortText(), title: new ComponentArguments.ShortText(),
} as const; } as const;

View File

@ -13,7 +13,7 @@ const component_arguments = {
icon: new Args.Enum(async () => [ icon: new Args.Enum(async () => [
"none", "none",
...(await getAllIconNames()), ...(await getAllIconNames()),
]).setExampleValues(["none"]), ]).setDefaultValue("none"),
color: new Args.Enum(async () => color: new Args.Enum(async () =>
getColorVariables().filter( getColorVariables().filter(
(e) => !e.includes("text") && !e.includes("link") (e) => !e.includes("text") && !e.includes("link")

View File

@ -24,7 +24,7 @@ const component_arguments = {
href: new ComponentArguments.ShortText(), href: new ComponentArguments.ShortText(),
}), }),
header_mode: new ComponentArguments.Enum(["below", "above"]), header_mode: new ComponentArguments.Enum(["below", "above"]),
starting_index: new ComponentArguments.ShortText().setExampleValues(["1"]), starting_index: new ComponentArguments.ShortText().setDefaultValue("1"),
} as const; } as const;
export class OrderedBlocks extends Component<typeof component_arguments> { export class OrderedBlocks extends Component<typeof component_arguments> {

View File

@ -7,14 +7,12 @@ import type {
import { Component, ComponentArguments } from "@sealcode/jdd"; import { Component, ComponentArguments } from "@sealcode/jdd";
const component_arguments = { const component_arguments = {
bleed_left: new ComponentArguments.Enum(["none", "bleed", "screen"]).setExampleValues( bleed_left: new ComponentArguments.Enum(["none", "bleed", "screen"]).setDefaultValue(
["none"] "none"
),
bleed_right: new ComponentArguments.Enum(["none", "bleed", "screen"]).setDefaultValue(
"none"
), ),
bleed_right: new ComponentArguments.Enum([
"none",
"bleed",
"screen",
]).setExampleValues(["none"]),
column_gap: new ComponentArguments.Boolean(), column_gap: new ComponentArguments.Boolean(),
row_gap: new ComponentArguments.Boolean(), row_gap: new ComponentArguments.Boolean(),
component1: new ComponentArguments.NestedComponent(), component1: new ComponentArguments.NestedComponent(),

View File

@ -9,22 +9,22 @@ import { horizontalScroller } from "src/back/routes/common/horizontal-scroller/h
import { getColorVariables, getFgColorVariable } from "src/back/colors.js"; import { getColorVariables, getFgColorVariable } from "src/back/colors.js";
const component_arguments = { const component_arguments = {
mode: new ComponentArguments.Enum(["column", "horizontal-scroller"]).setExampleValues( mode: new ComponentArguments.Enum(["column", "horizontal-scroller"]).setDefaultValue(
["column"] "column"
), ),
scroller_mode_item_width: new ComponentArguments.Number().setExampleValues([320]), scroller_mode_item_width: new ComponentArguments.Number().setDefaultValue(320),
scroller_mode_arrows_color: new ComponentArguments.Enum( scroller_mode_arrows_color: new ComponentArguments.Enum(
getColorVariables() getColorVariables()
).setExampleValues(["--color-brand-accent"]), ).setDefaultValue("--color-brand-accent"),
bleed: new ComponentArguments.Enum(["none", "bleed", "screen"]).setExampleValues([ bleed: new ComponentArguments.Enum(["none", "bleed", "screen"]).setDefaultValue(
"none", "none"
]), ),
gap: new ComponentArguments.Enum([ gap: new ComponentArguments.Enum([
"none", "none",
"narrow", "narrow",
"medium", "medium",
"wide", "wide",
]).setExampleValues(["medium"]), ]).setDefaultValue("medium"),
padding_vertical: new ComponentArguments.Enum([ padding_vertical: new ComponentArguments.Enum([
"none", "none",
"narrow", "narrow",
@ -32,7 +32,7 @@ const component_arguments = {
"wide", "wide",
"extra-wide", "extra-wide",
"super-wide", "super-wide",
]).setExampleValues(["medium"]), ]).setDefaultValue("medium"),
components: new ComponentArguments.List(new ComponentArguments.NestedComponent()), components: new ComponentArguments.List(new ComponentArguments.NestedComponent()),
} as const; } as const;

View File

@ -13,10 +13,10 @@ const component_arguments = {
"normal", "normal",
"accent", "accent",
"accent2", "accent2",
]).setExampleValues(["normal"]), ]).setDefaultValue("normal"),
size: new ComponentArguments.Enum(["small", "normal", "large"]).setExampleValues([ size: new ComponentArguments.Enum(["small", "normal", "large"]).setDefaultValue(
"normal", "normal"
]), ),
content: new ComponentArguments.Markdown(), content: new ComponentArguments.Markdown(),
side_content: new ComponentArguments.NestedComponent(), side_content: new ComponentArguments.NestedComponent(),
} as const; } as const;

View File

@ -9,7 +9,7 @@ import { registry } from "./jdd-components/registry.js";
export function makeJDDContext(ctx: Context): JDDContext { export function makeJDDContext(ctx: Context): JDDContext {
return { return {
language: "pl", language: "pl",
...makeSimpleJDDContext(TheFileManager, registry), ...makeSimpleJDDContext(TheFileManager, registry, "empty"),
render_image: async (image: string | FilePointer | null, args) => { render_image: async (image: string | FilePointer | null, args) => {
if (!image) { if (!image) {
return ""; return "";