@sealcode/jdd-editor 0.2.7 → 0.2.8
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/@types/components.sreact.d.ts +1 -1
- package/@types/inputs/component-input.d.ts +1 -1
- package/@types/jdd-creator.d.ts +2 -2
- package/dist/src/inputs/component-input-enum.js +2 -1
- package/dist/src/inputs/component-input-enum.js.map +2 -2
- package/dist/src/inputs/component-input.js +16 -13
- package/dist/src/inputs/component-input.js.map +2 -2
- package/package.json +1 -1
- package/src/inputs/component-input-enum.ts +2 -1
- package/src/inputs/component-input.ts +18 -15
|
@@ -5,7 +5,7 @@ import type { JDDPageState } from "./jdd-page.js";
|
|
|
5
5
|
import JDDPage from "./jdd-page.js";
|
|
6
6
|
export declare class JDDDebugger extends JDDPage {
|
|
7
7
|
renderParameterButtons(state: JDDPageState): Stringifiable;
|
|
8
|
-
actions: Record<string, import("
|
|
8
|
+
actions: Record<string, import("../../sealgen/@types/index.js").StatefulPageAction<JDDPageState>>;
|
|
9
9
|
getInitialState(ctx: Context): Promise<{
|
|
10
10
|
components: never[];
|
|
11
11
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Context } from "koa";
|
|
2
1
|
import type { ComponentArgument, JDDContext } from "@sealcode/jdd";
|
|
3
2
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
3
|
+
import type { Context } from "koa";
|
|
4
4
|
import type { ComponentPreviewActions } from "../component-preview-actions.js";
|
|
5
5
|
import type { JDDPageState } from "../jdd-page.js";
|
|
6
6
|
export declare const actionName = "Components";
|
package/@types/jdd-creator.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { JDDPageState } from "./jdd-page.js";
|
|
|
3
3
|
import JDDPage from "./jdd-page.js";
|
|
4
4
|
import { Stringifiable } from "tempstream/@types/stringify.js";
|
|
5
5
|
export default abstract class JDDCreator extends JDDPage {
|
|
6
|
-
actions: Record<string, import("
|
|
6
|
+
actions: Record<string, import("../../sealgen/@types/index.js").StatefulPageAction<JDDPageState>>;
|
|
7
7
|
/**
|
|
8
8
|
* This method returns list of components allowed in JDD Editor instance.
|
|
9
9
|
* If list is empty it will allow all of the components in registry,
|
|
@@ -11,7 +11,7 @@ export default abstract class JDDCreator extends JDDPage {
|
|
|
11
11
|
* available.
|
|
12
12
|
*/
|
|
13
13
|
getAllowedComponents(): string[];
|
|
14
|
-
getRegistryComponents(): Record<string, import("
|
|
14
|
+
getRegistryComponents(): Record<string, import("../../jdd/@types/component.js").Component<Record<string, import("../../jdd/@types/index.js").ComponentArgument<unknown, unknown, unknown>>>>;
|
|
15
15
|
renderParameterButtons(state: JDDPageState): string;
|
|
16
16
|
renderComponentBlock(ctx: Context, state: JDDPageState, component_data: {
|
|
17
17
|
component_name: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { printArgPath } from "./print-arg-path.js";
|
|
2
|
+
import { htmlEscape } from "escape-goat";
|
|
2
3
|
function ComponentInputEnum({
|
|
3
4
|
arg_path,
|
|
4
5
|
arg,
|
|
@@ -15,7 +16,7 @@ function ComponentInputEnum({
|
|
|
15
16
|
>
|
|
16
17
|
${arg.getValues(jdd_context).map(
|
|
17
18
|
(v) => `<option
|
|
18
|
-
value="${v}"
|
|
19
|
+
value="${htmlEscape(v)}"
|
|
19
20
|
${value == v ? "selected" : ""}
|
|
20
21
|
>
|
|
21
22
|
${v}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/component-input-enum.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Enum, JDDContext } from \"@sealcode/jdd\";\nimport { printArgPath } from \"./print-arg-path.js\";\n\nexport function ComponentInputEnum<State, S extends string, T extends Enum<S>>({\n\targ_path,\n\targ,\n\tvalue,\n\tonchange,\n\tjdd_context,\n}: {\n\tstate: State;\n\targ_path: string[];\n\targ: T;\n\tvalue: string;\n\tonchange?: string;\n\tjdd_context: JDDContext;\n}) {\n\treturn /* HTML */ `<div id=${`component-input-enum-${arg_path.join(\"-\")}`}>\n\t\t<label>\n\t\t\t${arg_path.at(-1) || \"\"}\n\t\t\t<select\n\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\tonchange=\"${onchange || \"\"}\"\n\t\t\t>\n\t\t\t\t${arg\n\t\t\t\t\t.getValues(jdd_context)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(v: S) =>\n\t\t\t\t\t\t\t/* HTML */ `<option\n\t\t\t\t\t\t\t\tvalue=\"${v}\"\n\t\t\t\t\t\t\t\t${value == v ? \"selected\" : \"\"}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t${v}\n\t\t\t\t\t\t\t</option>`\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\")}\n\t\t\t</select>\n\t\t</label>\n\t</div>`;\n}\n"],
|
|
5
|
-
"mappings": "AACA,SAAS,oBAAoB;
|
|
4
|
+
"sourcesContent": ["import type { Enum, JDDContext } from \"@sealcode/jdd\";\nimport { printArgPath } from \"./print-arg-path.js\";\nimport { htmlEscape } from \"escape-goat\";\n\nexport function ComponentInputEnum<State, S extends string, T extends Enum<S>>({\n\targ_path,\n\targ,\n\tvalue,\n\tonchange,\n\tjdd_context,\n}: {\n\tstate: State;\n\targ_path: string[];\n\targ: T;\n\tvalue: string;\n\tonchange?: string;\n\tjdd_context: JDDContext;\n}) {\n\treturn /* HTML */ `<div id=${`component-input-enum-${arg_path.join(\"-\")}`}>\n\t\t<label>\n\t\t\t${arg_path.at(-1) || \"\"}\n\t\t\t<select\n\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\tonchange=\"${onchange || \"\"}\"\n\t\t\t>\n\t\t\t\t${arg\n\t\t\t\t\t.getValues(jdd_context)\n\t\t\t\t\t.map(\n\t\t\t\t\t\t(v: S) =>\n\t\t\t\t\t\t\t/* HTML */ `<option\n\t\t\t\t\t\t\t\tvalue=\"${htmlEscape(v)}\"\n\t\t\t\t\t\t\t\t${value == v ? \"selected\" : \"\"}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t${v}\n\t\t\t\t\t\t\t</option>`\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\")}\n\t\t\t</select>\n\t\t</label>\n\t</div>`;\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,SAAS,mBAA+D;AAAA,EAC9E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAOG;AACF,SAAkB,WAAW,wBAAwB,SAAS,KAAK,GAAG;AAAA;AAAA,KAElE,SAAS,GAAG,EAAE,KAAK;AAAA;AAAA,YAEZ,IAAI,aAAa,QAAQ;AAAA,gBACrB,YAAY;AAAA;AAAA,MAEtB,IACA,UAAU,WAAW,EACrB;AAAA,IACA,CAAC,MACW;AAAA,iBACD,WAAW,CAAC;AAAA,UACnB,SAAS,IAAI,aAAa;AAAA;AAAA,UAE1B;AAAA;AAAA,EAEL,EACC,KAAK,EAAE;AAAA;AAAA;AAAA;AAIb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { printArgPath } from "./print-arg-path.js";
|
|
2
|
-
import { NestedComponent, Color, SingleReference } from "@sealcode/jdd";
|
|
3
1
|
import {
|
|
2
|
+
Code,
|
|
3
|
+
Color,
|
|
4
4
|
ComponentArguments,
|
|
5
5
|
Enum,
|
|
6
6
|
Image,
|
|
7
7
|
List,
|
|
8
|
+
NestedComponent,
|
|
9
|
+
SingleReference,
|
|
8
10
|
Structured,
|
|
9
|
-
Table
|
|
10
|
-
Code
|
|
11
|
+
Table
|
|
11
12
|
} from "@sealcode/jdd";
|
|
12
|
-
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
13
|
-
import { ComponentInputList } from "./component-input-list.js";
|
|
14
|
-
import { ComponentInputEnum } from "./component-input-enum.js";
|
|
15
|
-
import { ComponentInputImage } from "./component-input-image.js";
|
|
16
|
-
import { ComponentInputTable } from "./component-input-table.js";
|
|
17
|
-
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
18
13
|
import { is, predicates } from "@sealcode/ts-predicates";
|
|
14
|
+
import { htmlEscape } from "escape-goat";
|
|
19
15
|
import { tempstream } from "tempstream";
|
|
20
16
|
import { ComponentInputCode } from "./component-input-code.js";
|
|
21
17
|
import { ComponentInputColor } from "./component-input-color.js";
|
|
18
|
+
import { ComponentInputEnum } from "./component-input-enum.js";
|
|
19
|
+
import { ComponentInputImage } from "./component-input-image.js";
|
|
20
|
+
import { ComponentInputList } from "./component-input-list.js";
|
|
21
|
+
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
22
|
+
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
23
|
+
import { ComponentInputTable } from "./component-input-table.js";
|
|
24
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
22
25
|
const actionName = "Components";
|
|
23
26
|
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
24
27
|
async function ComponentInput({
|
|
@@ -129,7 +132,7 @@ async function ComponentInput({
|
|
|
129
132
|
return tempstream` <input
|
|
130
133
|
type="number"
|
|
131
134
|
name="${`$${printArgPath(arg_path)}`}"
|
|
132
|
-
value="${(value || "").toString()}"
|
|
135
|
+
value="${htmlEscape((value || "").toString())}"
|
|
133
136
|
min="${arg.min || ""}"
|
|
134
137
|
max="${arg.max || ""}"
|
|
135
138
|
step="${arg.step || ""}"
|
|
@@ -138,7 +141,7 @@ async function ComponentInput({
|
|
|
138
141
|
return tempstream` <input
|
|
139
142
|
type="${isUrlAbsolute ? "url" : "text"}"
|
|
140
143
|
name="${`$${printArgPath(arg_path)}`}"
|
|
141
|
-
value="${(value || "").toString()}"
|
|
144
|
+
value="${htmlEscape((value || "").toString())}"
|
|
142
145
|
size="40"
|
|
143
146
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
144
147
|
/>`;
|
|
@@ -146,7 +149,7 @@ async function ComponentInput({
|
|
|
146
149
|
return tempstream` <input
|
|
147
150
|
type="${inputType}"
|
|
148
151
|
name="${`$${printArgPath(arg_path)}`}"
|
|
149
|
-
value="${is(value, predicates.string) ? value : ""}"
|
|
152
|
+
value="${is(value, predicates.string) ? htmlEscape(value) : ""}"
|
|
150
153
|
size="40"
|
|
151
154
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
152
155
|
/>`;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/inputs/component-input.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import type { FilePointer } from \"@sealcode/file-manager\";\nimport type { ComponentArgument, JDDContext, TableData } from \"@sealcode/jdd\";\nimport {\n\tCode,\n\tColor,\n\tComponentArguments,\n\tEnum,\n\tImage,\n\tList,\n\tNestedComponent,\n\tSingleReference,\n\tStructured,\n\tTable,\n} from \"@sealcode/jdd\";\nimport type { StatefulPage } from \"@sealcode/sealgen\";\nimport { is, predicates } from \"@sealcode/ts-predicates\";\nimport { htmlEscape } from \"escape-goat\";\nimport type { Context } from \"koa\";\nimport { tempstream } from \"tempstream\";\nimport type { ComponentPreviewActions } from \"../component-preview-actions.js\";\nimport type { JDDPageState } from \"../jdd-page.js\";\nimport { ComponentInputCode } from \"./component-input-code.js\";\nimport { ComponentInputColor } from \"./component-input-color.js\";\nimport { ComponentInputEnum } from \"./component-input-enum.js\";\nimport { ComponentInputImage } from \"./component-input-image.js\";\nimport { ComponentInputList } from \"./component-input-list.js\";\nimport { ComponentInputSingleReference } from \"./component-input-single-reference.js\";\nimport { ComponentInputStructured } from \"./component-input-structured.js\";\nimport { ComponentInputTable } from \"./component-input-table.js\";\nimport { printArgPath } from \"./print-arg-path.js\";\nexport const actionName = \"Components\";\nconst absoluteUrlPattern = \"http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)\";\n\nexport async function ComponentInput<State extends JDDPageState, T>({\n\tctx,\n\tstate,\n\targ_path,\n\targ,\n\tvalue,\n\tpage,\n\tmakeJDDContext,\n\tmakeAssetURL,\n}: {\n\tstate: State;\n\tctx: Context;\n\targ_path: string[];\n\targ: ComponentArgument<T>;\n\tvalue: T;\n\tpage: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;\n\tmakeJDDContext: (ctx: Context) => JDDContext;\n\tmakeAssetURL: (asset: string) => string;\n}): Promise<string> {\n\tif (value === undefined) {\n\t\tvalue = await arg.getEmptyValue(makeJDDContext(ctx));\n\t}\n\tif (arg instanceof Color) {\n\t\treturn ComponentInputColor({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as string,\n\t\t\tpage,\n\t\t\tonchange: page.rerender(),\n\t\t\tmakeJDDContext,\n\t\t});\n\t}\n\tif (arg instanceof List) {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn ComponentInputList({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as T[],\n\t\t\tpage,\n\t\t\tmakeJDDContext,\n\t\t\tmakeAssetURL,\n\t\t});\n\t}\n\n\tconst argType = arg.getTypeName();\n\tconst isUrlAbsolute =\n\t\targ instanceof ComponentArguments.URL && arg.urlType === \"absolute\";\n\tconst inputType = isUrlAbsolute ? \"url\" : \"text\";\n\n\tif (arg instanceof Structured || arg instanceof NestedComponent) {\n\t\treturn ComponentInputStructured({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as Record<string, unknown>,\n\t\t\tpage,\n\t\t\tmakeJDDContext,\n\t\t\tmakeAssetURL,\n\t\t});\n\t}\n\n\tif (arg instanceof SingleReference) {\n\t\treturn ComponentInputSingleReference({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as string,\n\t\t\tonchange: page.rerender(),\n\t\t\tmakeJDDContext,\n\t\t});\n\t}\n\n\tif (arg instanceof Enum) {\n\t\treturn ComponentInputEnum({\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as string,\n\t\t\tonchange: page.rerender(),\n\t\t\tjdd_context: makeJDDContext(ctx),\n\t\t});\n\t}\n\n\tif (arg instanceof Image) {\n\t\treturn ComponentInputImage({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as FilePointer,\n\t\t\tpage,\n\t\t\tmakeJDDContext,\n\t\t});\n\t}\n\n\tif (arg instanceof Table) {\n\t\treturn ComponentInputTable({\n\t\t\tctx,\n\t\t\tstate,\n\t\t\targ_path,\n\t\t\targ,\n\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\tvalue: value as TableData<unknown, unknown>,\n\t\t\tpage,\n\t\t\tmakeJDDContext,\n\t\t\tmakeAssetURL,\n\t\t});\n\t}\n\n\tif (arg instanceof Code) {\n\t\treturn ComponentInputCode({\n\t\t\tlanguage: arg.language,\n\t\t\tvalue: is(value, predicates.string) ? value : \"\",\n\t\t\targ_path,\n\t\t});\n\t}\n\n\tconst inputElement = () => {\n\t\tif (arg instanceof ComponentArguments.Number) {\n\t\t\treturn tempstream /* HTML */ ` <input\n\t\t\t\ttype=\"number\"\n\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\tvalue=\"${htmlEscape((value || \"\").toString())}\"\n\t\t\t\tmin=\"${arg.min || \"\"}\"\n\t\t\t\tmax=\"${arg.max || \"\"}\"\n\t\t\t\tstep=\"${arg.step || \"\"}\"\n\t\t\t/>`;\n\t\t} else if (arg instanceof ComponentArguments.URL) {\n\t\t\treturn tempstream /* HTML */ ` <input\n\t\t\t\ttype=\"${isUrlAbsolute ? \"url\" : \"text\"}\"\n\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\tvalue=\"${htmlEscape((value || \"\").toString())}\"\n\t\t\t\tsize=\"40\"\n\t\t\t\t${isUrlAbsolute ? `pattern=\"${absoluteUrlPattern}\"` : \"\"}\n\t\t\t/>`;\n\t\t} else {\n\t\t\treturn tempstream /* HTML */ ` <input\n\t\t\t\ttype=\"${inputType}\"\n\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\tvalue=\"${is(value, predicates.string) ? htmlEscape(value) : \"\"}\"\n\t\t\t\tsize=\"40\"\n\t\t\t\t${isUrlAbsolute ? `pattern=\"${absoluteUrlPattern}\"` : \"\"}\n\t\t\t/>`;\n\t\t}\n\t};\n\n\treturn /* HTML */ `<div>\n\t\t<label>\n\t\t\t${arg_path.at(-1) || \"\"}\n\t\t\t${argType == \"markdown\"\n\t\t\t\t? /* HTML */ `<div class=\"grow-wrap\">\n\t\t\t\t\t\t<textarea\n\t\t\t\t\t\t\tname=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\t\t\t\tonblur=\"${page.rerender()}\"\n\t\t\t\t\t\t\tcols=\"40\"\n\t\t\t\t\t\t\tdata-controller=\"markdown-textarea submit-on-input\"\n\t\t\t\t\t\t\tdata-action=\"autogrow-textarea#autogrow blur->autogrow-textarea#autogrow resize->autogrow-textarea#autogrow submit-on-input#sendValues focus->submit-on-input#makePermanent blur->submit-on-input#makeNotPermanent\"\n\t\t\t\t\t\t\tautocomplete=\"off\"\n\t\t\t\t\t\t>\n${is(value, predicates.string) ? value : \"\"}</textarea\n\t\t\t\t\t\t>\n\t\t\t\t\t</div>`\n\t\t\t\t: await inputElement()}\n\t\t</label>\n\t</div>`;\n}\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Enum, JDDContext } from "@sealcode/jdd";
|
|
2
2
|
import { printArgPath } from "./print-arg-path.js";
|
|
3
|
+
import { htmlEscape } from "escape-goat";
|
|
3
4
|
|
|
4
5
|
export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
5
6
|
arg_path,
|
|
@@ -27,7 +28,7 @@ export function ComponentInputEnum<State, S extends string, T extends Enum<S>>({
|
|
|
27
28
|
.map(
|
|
28
29
|
(v: S) =>
|
|
29
30
|
/* HTML */ `<option
|
|
30
|
-
value="${v}"
|
|
31
|
+
value="${htmlEscape(v)}"
|
|
31
32
|
${value == v ? "selected" : ""}
|
|
32
33
|
>
|
|
33
34
|
${v}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Context } from "koa";
|
|
1
|
+
import type { FilePointer } from "@sealcode/file-manager";
|
|
3
2
|
import type { ComponentArgument, JDDContext, TableData } from "@sealcode/jdd";
|
|
4
|
-
import { NestedComponent, Color, SingleReference } from "@sealcode/jdd";
|
|
5
3
|
import {
|
|
4
|
+
Code,
|
|
5
|
+
Color,
|
|
6
6
|
ComponentArguments,
|
|
7
7
|
Enum,
|
|
8
8
|
Image,
|
|
9
9
|
List,
|
|
10
|
+
NestedComponent,
|
|
11
|
+
SingleReference,
|
|
10
12
|
Structured,
|
|
11
13
|
Table,
|
|
12
|
-
Code,
|
|
13
14
|
} from "@sealcode/jdd";
|
|
14
|
-
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
15
15
|
import type { StatefulPage } from "@sealcode/sealgen";
|
|
16
|
+
import { is, predicates } from "@sealcode/ts-predicates";
|
|
17
|
+
import { htmlEscape } from "escape-goat";
|
|
18
|
+
import type { Context } from "koa";
|
|
19
|
+
import { tempstream } from "tempstream";
|
|
16
20
|
import type { ComponentPreviewActions } from "../component-preview-actions.js";
|
|
17
|
-
import { ComponentInputList } from "./component-input-list.js";
|
|
18
21
|
import type { JDDPageState } from "../jdd-page.js";
|
|
22
|
+
import { ComponentInputCode } from "./component-input-code.js";
|
|
23
|
+
import { ComponentInputColor } from "./component-input-color.js";
|
|
19
24
|
import { ComponentInputEnum } from "./component-input-enum.js";
|
|
20
25
|
import { ComponentInputImage } from "./component-input-image.js";
|
|
21
|
-
import {
|
|
22
|
-
import type { FilePointer } from "@sealcode/file-manager";
|
|
26
|
+
import { ComponentInputList } from "./component-input-list.js";
|
|
23
27
|
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import { ComponentInputColor } from "./component-input-color.js";
|
|
28
|
+
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
29
|
+
import { ComponentInputTable } from "./component-input-table.js";
|
|
30
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
28
31
|
export const actionName = "Components";
|
|
29
32
|
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
30
33
|
|
|
@@ -162,7 +165,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
162
165
|
return tempstream /* HTML */ ` <input
|
|
163
166
|
type="number"
|
|
164
167
|
name="${`$${printArgPath(arg_path)}`}"
|
|
165
|
-
value="${(value || "").toString()}"
|
|
168
|
+
value="${htmlEscape((value || "").toString())}"
|
|
166
169
|
min="${arg.min || ""}"
|
|
167
170
|
max="${arg.max || ""}"
|
|
168
171
|
step="${arg.step || ""}"
|
|
@@ -171,7 +174,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
171
174
|
return tempstream /* HTML */ ` <input
|
|
172
175
|
type="${isUrlAbsolute ? "url" : "text"}"
|
|
173
176
|
name="${`$${printArgPath(arg_path)}`}"
|
|
174
|
-
value="${(value || "").toString()}"
|
|
177
|
+
value="${htmlEscape((value || "").toString())}"
|
|
175
178
|
size="40"
|
|
176
179
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
177
180
|
/>`;
|
|
@@ -179,7 +182,7 @@ export async function ComponentInput<State extends JDDPageState, T>({
|
|
|
179
182
|
return tempstream /* HTML */ ` <input
|
|
180
183
|
type="${inputType}"
|
|
181
184
|
name="${`$${printArgPath(arg_path)}`}"
|
|
182
|
-
value="${is(value, predicates.string) ? value : ""}"
|
|
185
|
+
value="${is(value, predicates.string) ? htmlEscape(value) : ""}"
|
|
183
186
|
size="40"
|
|
184
187
|
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}
|
|
185
188
|
/>`;
|