@sealcode/jdd-editor 0.1.0
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/.arcconfig +12 -0
- package/.arclint +18 -0
- package/.eslintrc.js +37 -0
- package/.mocharc.js +6 -0
- package/.nycrc +6 -0
- package/.prettierrc +14 -0
- package/@types/component-preview-actions.d.ts +43 -0
- package/@types/components.sreact.d.ts +48 -0
- package/@types/controllers/autogrow-textarea.stimulus.d.ts +5 -0
- package/@types/controllers/component-debugger.stimulus.d.ts +28 -0
- package/@types/controllers/exportable-textarea.stimulus.d.ts +7 -0
- package/@types/controllers/input-image-preview.stimulus.d.ts +5 -0
- package/@types/controllers/jdd-table-paste.stimulus.d.ts +8 -0
- package/@types/controllers/json-editor.stimulus.d.ts +9 -0
- package/@types/controllers/markdown-textarea.stimulus.d.ts +20 -0
- package/@types/controllers/refresh-on-ts-changes.stimulus.d.ts +6 -0
- package/@types/controllers/refresh-styles.stimulus.d.ts +6 -0
- package/@types/controllers/submit-on-input.stimulus.d.ts +7 -0
- package/@types/controllers/toast.stimulus.d.ts +4 -0
- package/@types/edit-jdd-field.d.ts +22 -0
- package/@types/index.d.ts +2 -0
- package/@types/inputs/component-input-enum.d.ts +8 -0
- package/@types/inputs/component-input-image.d.ts +15 -0
- package/@types/inputs/component-input-list.d.ts +15 -0
- package/@types/inputs/component-input-single-reference.d.ts +11 -0
- package/@types/inputs/component-input-structured.d.ts +15 -0
- package/@types/inputs/component-input-table.d.ts +15 -0
- package/@types/inputs/component-input.d.ts +16 -0
- package/@types/inputs/print-arg-path.d.ts +1 -0
- package/@types/jdd-creator.d.ts +49 -0
- package/@types/jdd-page.d.ts +85 -0
- package/assets/icons/table-add-column-right.svg +1 -0
- package/assets/icons/table-add-row-below.svg +1 -0
- package/assets/icons/table-add-row-header-below.svg +1 -0
- package/assets/icons/table-delete-column.svg +1 -0
- package/assets/icons/table-delete-row.svg +1 -0
- package/assets/icons/table-move-column-right.svg +1 -0
- package/assets/icons/table-move-row-down.svg +1 -0
- package/assets/icons/table-move-row-up.svg +1 -0
- package/assets/styles/component-admin-table.jdd-page.css +11 -0
- package/assets/styles/component-debugger.jdd-page.css +71 -0
- package/assets/styles/components.jdd-page.css +286 -0
- package/assets/styles/grow-wrap.css +33 -0
- package/assets/styles/markdown-editor.css +42 -0
- package/dist/src/autogrow-textarea.stimulus.js +13 -0
- package/dist/src/autogrow-textarea.stimulus.js.map +7 -0
- package/dist/src/component-debugger.stimulus.js +190 -0
- package/dist/src/component-debugger.stimulus.js.map +7 -0
- package/dist/src/component-preview-actions.js +439 -0
- package/dist/src/component-preview-actions.js.map +7 -0
- package/dist/src/components.sreact.js +93 -0
- package/dist/src/components.sreact.js.map +7 -0
- package/dist/src/controllers/autogrow-textarea.stimulus.js +13 -0
- package/dist/src/controllers/autogrow-textarea.stimulus.js.map +7 -0
- package/dist/src/controllers/component-debugger.stimulus.js +193 -0
- package/dist/src/controllers/component-debugger.stimulus.js.map +7 -0
- package/dist/src/controllers/exportable-textarea.stimulus.js +71 -0
- package/dist/src/controllers/exportable-textarea.stimulus.js.map +7 -0
- package/dist/src/controllers/input-image-preview.stimulus.js +30 -0
- package/dist/src/controllers/input-image-preview.stimulus.js.map +7 -0
- package/dist/src/controllers/jdd-table-paste.stimulus.js +78 -0
- package/dist/src/controllers/jdd-table-paste.stimulus.js.map +7 -0
- package/dist/src/controllers/json-editor.stimulus.js +114 -0
- package/dist/src/controllers/json-editor.stimulus.js.map +7 -0
- package/dist/src/controllers/markdown-textarea.stimulus.js +174 -0
- package/dist/src/controllers/markdown-textarea.stimulus.js.map +7 -0
- package/dist/src/controllers/refresh-on-ts-changes.stimulus.js +90 -0
- package/dist/src/controllers/refresh-on-ts-changes.stimulus.js.map +7 -0
- package/dist/src/controllers/refresh-styles.stimulus.js +67 -0
- package/dist/src/controllers/refresh-styles.stimulus.js.map +7 -0
- package/dist/src/controllers/submit-on-input.stimulus.js +55 -0
- package/dist/src/controllers/submit-on-input.stimulus.js.map +7 -0
- package/dist/src/controllers/toast.stimulus.js +19 -0
- package/dist/src/controllers/toast.stimulus.js.map +7 -0
- package/dist/src/edit-jdd-field.js +94 -0
- package/dist/src/edit-jdd-field.js.map +7 -0
- package/dist/src/exportable-textarea.stimulus.js +71 -0
- package/dist/src/exportable-textarea.stimulus.js.map +7 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/input-image-preview.stimulus.js +30 -0
- package/dist/src/input-image-preview.stimulus.js.map +7 -0
- package/dist/src/inputs/component-input-enum.js +30 -0
- package/dist/src/inputs/component-input-enum.js.map +7 -0
- package/dist/src/inputs/component-input-image.js +58 -0
- package/dist/src/inputs/component-input-image.js.map +7 -0
- package/dist/src/inputs/component-input-list.js +74 -0
- package/dist/src/inputs/component-input-list.js.map +7 -0
- package/dist/src/inputs/component-input-single-reference.js +31 -0
- package/dist/src/inputs/component-input-single-reference.js.map +7 -0
- package/dist/src/inputs/component-input-structured.js +36 -0
- package/dist/src/inputs/component-input-structured.js.map +7 -0
- package/dist/src/inputs/component-input-table.js +228 -0
- package/dist/src/inputs/component-input-table.js.map +7 -0
- package/dist/src/inputs/component-input.js +129 -0
- package/dist/src/inputs/component-input.js.map +7 -0
- package/dist/src/inputs/print-arg-path.js +7 -0
- package/dist/src/inputs/print-arg-path.js.map +7 -0
- package/dist/src/jdd-creator.js +131 -0
- package/dist/src/jdd-creator.js.map +7 -0
- package/dist/src/jdd-page.js +339 -0
- package/dist/src/jdd-page.js.map +7 -0
- package/dist/src/jdd-table-paste.stimulus.js +78 -0
- package/dist/src/jdd-table-paste.stimulus.js.map +7 -0
- package/dist/src/json-editor.stimulus.js +114 -0
- package/dist/src/json-editor.stimulus.js.map +7 -0
- package/dist/src/markdown-textarea.stimulus.js +174 -0
- package/dist/src/markdown-textarea.stimulus.js.map +7 -0
- package/dist/src/submit-on-input.stimulus.js +55 -0
- package/dist/src/submit-on-input.stimulus.js.map +7 -0
- package/dist/src/toast.stimulus.js +19 -0
- package/dist/src/toast.stimulus.js.map +7 -0
- package/esbuild.cjs +20 -0
- package/esbuild.js +23 -0
- package/jenkins.sanity.sh +3 -0
- package/lib/component-preview-actions.js +286 -0
- package/lib/component-preview-actions.js.map +1 -0
- package/lib/components.sreact.js +102 -0
- package/lib/components.sreact.js.map +1 -0
- package/lib/controllers/autogrow-textarea.stimulus.js +15 -0
- package/lib/controllers/autogrow-textarea.stimulus.js.map +1 -0
- package/lib/controllers/component-debugger.stimulus.js +188 -0
- package/lib/controllers/component-debugger.stimulus.js.map +1 -0
- package/lib/controllers/exportable-textarea.stimulus.js +79 -0
- package/lib/controllers/exportable-textarea.stimulus.js.map +1 -0
- package/lib/controllers/input-image-preview.stimulus.js +28 -0
- package/lib/controllers/input-image-preview.stimulus.js.map +1 -0
- package/lib/controllers/jdd-table-paste.stimulus.js +84 -0
- package/lib/controllers/jdd-table-paste.stimulus.js.map +1 -0
- package/lib/controllers/json-editor.stimulus.js +134 -0
- package/lib/controllers/json-editor.stimulus.js.map +1 -0
- package/lib/controllers/markdown-textarea.stimulus.js +186 -0
- package/lib/controllers/markdown-textarea.stimulus.js.map +1 -0
- package/lib/controllers/refresh-on-ts-changes.stimulus.js +123 -0
- package/lib/controllers/refresh-on-ts-changes.stimulus.js.map +1 -0
- package/lib/controllers/refresh-styles.stimulus.js +66 -0
- package/lib/controllers/refresh-styles.stimulus.js.map +1 -0
- package/lib/controllers/submit-on-input.stimulus.js +48 -0
- package/lib/controllers/submit-on-input.stimulus.js.map +1 -0
- package/lib/controllers/toast.stimulus.js +16 -0
- package/lib/controllers/toast.stimulus.js.map +1 -0
- package/lib/edit-jdd-field.js +102 -0
- package/lib/edit-jdd-field.js.map +1 -0
- package/lib/index.js +19 -0
- package/lib/index.js.map +1 -0
- package/lib/inputs/component-input-enum.js +25 -0
- package/lib/inputs/component-input-enum.js.map +1 -0
- package/lib/inputs/component-input-image.js +47 -0
- package/lib/inputs/component-input-image.js.map +1 -0
- package/lib/inputs/component-input-list.js +61 -0
- package/lib/inputs/component-input-list.js.map +1 -0
- package/lib/inputs/component-input-single-reference.js +36 -0
- package/lib/inputs/component-input-single-reference.js.map +1 -0
- package/lib/inputs/component-input-structured.js +42 -0
- package/lib/inputs/component-input-structured.js.map +1 -0
- package/lib/inputs/component-input-table.js +184 -0
- package/lib/inputs/component-input-table.js.map +1 -0
- package/lib/inputs/component-input.js +133 -0
- package/lib/inputs/component-input.js.map +1 -0
- package/lib/inputs/print-arg-path.js +7 -0
- package/lib/inputs/print-arg-path.js.map +1 -0
- package/lib/jdd-creator.js +113 -0
- package/lib/jdd-creator.js.map +1 -0
- package/lib/jdd-page.js +310 -0
- package/lib/jdd-page.js.map +1 -0
- package/package.json +61 -0
- package/src/component-preview-actions.ts +520 -0
- package/src/components.sreact.ts +100 -0
- package/src/controllers/autogrow-textarea.stimulus.ts +13 -0
- package/src/controllers/component-debugger.stimulus.ts +247 -0
- package/src/controllers/exportable-textarea.stimulus.ts +77 -0
- package/src/controllers/input-image-preview.stimulus.ts +29 -0
- package/src/controllers/jdd-table-paste.stimulus.ts +89 -0
- package/src/controllers/json-editor.stimulus.ts +127 -0
- package/src/controllers/markdown-textarea.stimulus.ts +198 -0
- package/src/controllers/refresh-on-ts-changes.stimulus.ts +112 -0
- package/src/controllers/refresh-styles.stimulus.ts +70 -0
- package/src/controllers/submit-on-input.stimulus.ts +66 -0
- package/src/controllers/toast.stimulus.ts +15 -0
- package/src/edit-jdd-field.ts +127 -0
- package/src/index.ts +2 -0
- package/src/inputs/component-input-enum.ts +36 -0
- package/src/inputs/component-input-image.ts +70 -0
- package/src/inputs/component-input-list.ts +91 -0
- package/src/inputs/component-input-single-reference.ts +45 -0
- package/src/inputs/component-input-structured.ts +51 -0
- package/src/inputs/component-input-table.ts +262 -0
- package/src/inputs/component-input.ts +158 -0
- package/src/inputs/print-arg-path.ts +3 -0
- package/src/jdd-creator.ts +151 -0
- package/src/jdd-page.ts +439 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/inputs/component-input-table.ts"],
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport type { JDDContext, Table, TableData } from \"@sealcode/jdd\";\nimport { Markdown } from \"@sealcode/jdd\";\nimport { isTableHeader } from \"@sealcode/jdd\";\nimport type { StatefulPage } from \"@sealcode/sealgen\";\nimport type { Context } from \"koa\";\nimport { tempstream } from \"tempstream\";\nimport { ComponentInput } from \"./component-input.js\";\nimport type { ComponentPreviewActions } from \"../component-preview-actions.js\";\nimport type { JDDPageState } from \"../jdd-page.js\";\n\nexport async function ComponentInputTable<\n\tState extends JDDPageState,\n\tCellType,\n\tHeaderType\n>({\n\tstate,\n\targ_path,\n\tctx,\n\targ,\n\tvalue,\n\tpage,\n\tmakeJDDContext,\n\tmakeAssetURL,\n}: {\n\tstate: State;\n\tctx: Context;\n\targ_path: string[];\n\targ: Table<CellType, HeaderType>;\n\tvalue: TableData<CellType, HeaderType>;\n\tpage: StatefulPage<JDDPageState, typeof ComponentPreviewActions>;\n\tmakeJDDContext: (ctx: Context) => JDDContext;\n\tmakeAssetURL: (asset: string) => string;\n}): Promise<string> {\n\tif (!value) {\n\t\tvalue = await arg.getEmptyValue(makeJDDContext(ctx));\n\t}\n\n\tconst show_paste =\n\t\targ.cell_type instanceof Markdown &&\n\t\targ.header_type instanceof Markdown;\n\n\treturn tempstream/* HTML */ `<fieldset>\n\t\t<legend>${arg_path.at(-1)!}</legend>\n\t\t<div>\n\t\t\t${show_paste\n\t\t\t\t? /* HTML */ `<input\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvalue=\"paste\"\n\t\t\t\t\t\tplaceholder=\"paste table here\"\n\t\t\t\t\t\tdata-jdd-table-paste-argpath-value=\"${arg_path.join(\n\t\t\t\t\t\t\t\".\"\n\t\t\t\t\t\t)}\"\n\t\t\t\t\t\tdata-controller=\"jdd-table-paste\"\n\t\t\t\t />`\n\t\t\t\t: \"\"}\n\t\t\t<table\n\t\t\t\tclass=\"jdd-component-input--table\"\n\t\t\t\tstyle=\"position: relative; /* necessary for sticky th*/\"\n\t\t\t>\n\t\t\t\t<tbody>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td></td>\n\t\t\t\t\t\t${[...Array(arg.getColumnsCount(value)).keys()]\n\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t(column_index) => /* HTML */ `<th\n\t\t\t\t\t\t\t\t\tclass=\"sticky sticky--top subdued\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\taction: \"remove_table_column\",\n\t\t\t\t\t\t\t\t\t\t\tlabel: \"Remove column\",\n\t\t\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"icons/table-delete-column.svg\"\n\t\t\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\t\t\tcolumn_index\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t${column_index >=\n\t\t\t\t\t\t\t\t\targ.getColumnsCount(value) - 1\n\t\t\t\t\t\t\t\t\t\t? \"\"\n\t\t\t\t\t\t\t\t\t\t: page.makeActionButton(\n\t\t\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: \"move_table_column_right\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Move column to the right\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"icons/table-move-column-right.svg\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\t\t\t\t\tcolumn_index\n\t\t\t\t\t\t\t\t\t\t )}\n\t\t\t\t\t\t\t\t</th>`\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.join(\"\")}\n\t\t\t\t\t</tr>\n\t\t\t\t\t${value.rows.map(\n\t\t\t\t\t\t(row, row_index) => tempstream/* HTML */ `<tr>\n\t\t\t\t\t\t\t<td class=\"sticky sticky--left subdued\">\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tstyle=\"display: flex; flex-flow: column; row-gap: 5px;\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\taction: \"remove_table_row\",\n\t\t\t\t\t\t\t\t\t\t\tlabel: \"Remove row\",\n\t\t\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"icons/table-delete-row.svg\"\n\t\t\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\t\t\trow_index\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\taction: \"move_table_row_down\",\n\t\t\t\t\t\t\t\t\t\t\tlabel: \"Move this row down\",\n\t\t\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"icons/table-move-row-down.svg\"\n\t\t\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\t\t\trow_index\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t${isTableHeader(row)\n\t\t\t\t\t\t\t\t? /* HTML */ tempstream`<th\n\t\t\t\t\t\t\t\t\t\tcolspan=\"${arg.getColumnsCount(value).toString()}\"\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t\t\t\t\t${ComponentInput({\n\t\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\t\targ_path: [\n\t\t\t\t\t\t\t\t\t\t\t\t...arg_path,\n\t\t\t\t\t\t\t\t\t\t\t\t\"rows\",\n\t\t\t\t\t\t\t\t\t\t\t\trow_index.toString(),\n\t\t\t\t\t\t\t\t\t\t\t\t\"header_content\",\n\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\targ: arg.header_type,\n\t\t\t\t\t\t\t\t\t\t\tvalue: row.header_content,\n\t\t\t\t\t\t\t\t\t\t\tpage,\n\t\t\t\t\t\t\t\t\t\t\tmakeJDDContext,\n\t\t\t\t\t\t\t\t\t\t\tmakeAssetURL,\n\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t </th>`\n\t\t\t\t\t\t\t\t: row.cells.map(\n\t\t\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\t\t\tcell,\n\t\t\t\t\t\t\t\t\t\t\tcell_index\n\t\t\t\t\t\t\t\t\t\t) => tempstream/* HTML */ `<td>\n\t\t\t\t\t\t\t\t\t\t\t${ComponentInput({\n\t\t\t\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t\t\targ_path: [\n\t\t\t\t\t\t\t\t\t\t\t\t\t...arg_path,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"rows\",\n\t\t\t\t\t\t\t\t\t\t\t\t\trow_index.toString(),\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"cells\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tcell_index.toString(),\n\t\t\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\t\t\targ: arg.cell_type,\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: cell,\n\t\t\t\t\t\t\t\t\t\t\t\tpage,\n\t\t\t\t\t\t\t\t\t\t\t\tmakeJDDContext,\n\t\t\t\t\t\t\t\t\t\t\t\tmakeAssetURL,\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t</td>`\n\t\t\t\t\t\t\t\t )}\n\t\t\t\t\t\t\t${row_index == 0\n\t\t\t\t\t\t\t\t? /* HTML */ `<td\n\t\t\t\t\t\t\t\t\t\tclass=\"subdued\"\n\t\t\t\t\t\t\t\t\t\trowspan=\"${value.rows.length.toString()}\"\n\t\t\t\t\t\t\t\t >\n\t\t\t\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\taction: \"add_table_column\",\n\t\t\t\t\t\t\t\t\t\t\t\tlabel: \"Add column\",\n\t\t\t\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"icons/table-add-column-right.svg\"\n\t\t\t\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\targ_path\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t </td>`\n\t\t\t\t\t\t\t\t: \"\"}\n\t\t\t\t\t\t</tr>`\n\t\t\t\t\t)}\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td\n\t\t\t\t\t\t\tclass=\"subdued\"\n\t\t\t\t\t\t\tcolspan=\"{(arg.getColumnsCount(value)\"\n\t\t\t\t\t\t\t+\n\t\t\t\t\t\t\t1).toString()}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\taction: \"add_table_row\",\n\t\t\t\t\t\t\t\t\tlabel: \"Add table row\",\n\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\"icons/table-add-row-below.svg\"\n\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\targ.getColumnsCount(value),\n\t\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t${page.makeActionButton(\n\t\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\taction: \"add_table_row\",\n\t\t\t\t\t\t\t\t\tlabel: \"Add table header\",\n\t\t\t\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\t\t\t\tsrc=\"${makeAssetURL(\n\t\t\t\t\t\t\t\t\t\t\t\"icons/table-add-column-header-below.svg\"\n\t\t\t\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t\t\t\t/>`,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\targ_path,\n\t\t\t\t\t\t\t\targ.getColumnsCount(value),\n\t\t\t\t\t\t\t\t\"header\"\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</tbody>\n\t\t\t</table>\n\t\t</div>\n\t</fieldset>`;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAG9B,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAI/B,eAAsB,oBAIpB;AAAA,EACD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GASoB;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;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA,IAAI,gBAAgB,KAAK;AAAA,IACzB;AAAA,EACD;AAAA,SACE,KAAK;AAAA,IACN;AAAA,IACA;AAAA,MACC,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,SAAoB;AAAA;AAAA;AAAA,iBAGZ;AAAA,QACN;AAAA,MACD;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA,IAAI,gBAAgB,KAAK;AAAA,IACzB;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOP;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { printArgPath } from "./print-arg-path.js";
|
|
2
|
+
import { SingleReference } from "@sealcode/jdd";
|
|
3
|
+
import {
|
|
4
|
+
ComponentArguments,
|
|
5
|
+
Enum,
|
|
6
|
+
Image,
|
|
7
|
+
List,
|
|
8
|
+
Structured,
|
|
9
|
+
Table
|
|
10
|
+
} from "@sealcode/jdd";
|
|
11
|
+
import { ComponentInputStructured } from "./component-input-structured.js";
|
|
12
|
+
import { ComponentInputList } from "./component-input-list.js";
|
|
13
|
+
import { ComponentInputEnum } from "./component-input-enum.js";
|
|
14
|
+
import { ComponentInputImage } from "./component-input-image.js";
|
|
15
|
+
import { ComponentInputTable } from "./component-input-table.js";
|
|
16
|
+
import { ComponentInputSingleReference } from "./component-input-single-reference.js";
|
|
17
|
+
import { is, predicates } from "@sealcode/ts-predicates";
|
|
18
|
+
const actionName = "Components";
|
|
19
|
+
const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
|
|
20
|
+
async function ComponentInput({
|
|
21
|
+
ctx,
|
|
22
|
+
state,
|
|
23
|
+
arg_path,
|
|
24
|
+
arg,
|
|
25
|
+
value,
|
|
26
|
+
page,
|
|
27
|
+
makeJDDContext,
|
|
28
|
+
makeAssetURL
|
|
29
|
+
}) {
|
|
30
|
+
if (value === void 0) {
|
|
31
|
+
value = await arg.getEmptyValue(makeJDDContext(ctx));
|
|
32
|
+
}
|
|
33
|
+
if (arg instanceof List) {
|
|
34
|
+
return ComponentInputList({
|
|
35
|
+
ctx,
|
|
36
|
+
state,
|
|
37
|
+
arg_path,
|
|
38
|
+
arg,
|
|
39
|
+
value,
|
|
40
|
+
page,
|
|
41
|
+
makeJDDContext,
|
|
42
|
+
makeAssetURL
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const argType = arg.getTypeName();
|
|
46
|
+
const isUrlAbsolute = arg instanceof ComponentArguments.URL && arg.urlType === "absolute";
|
|
47
|
+
const inputType = isUrlAbsolute ? "url" : "text";
|
|
48
|
+
if (arg instanceof Structured) {
|
|
49
|
+
return ComponentInputStructured({
|
|
50
|
+
ctx,
|
|
51
|
+
state,
|
|
52
|
+
arg_path,
|
|
53
|
+
arg,
|
|
54
|
+
value,
|
|
55
|
+
page,
|
|
56
|
+
makeJDDContext,
|
|
57
|
+
makeAssetURL
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (arg instanceof SingleReference) {
|
|
61
|
+
return ComponentInputSingleReference({
|
|
62
|
+
ctx,
|
|
63
|
+
state,
|
|
64
|
+
arg_path,
|
|
65
|
+
arg,
|
|
66
|
+
value,
|
|
67
|
+
onchange: page.rerender(),
|
|
68
|
+
makeJDDContext
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
if (arg instanceof Enum) {
|
|
72
|
+
return ComponentInputEnum({
|
|
73
|
+
state,
|
|
74
|
+
arg_path,
|
|
75
|
+
arg,
|
|
76
|
+
value,
|
|
77
|
+
onchange: page.rerender()
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (arg instanceof Image) {
|
|
81
|
+
return ComponentInputImage({
|
|
82
|
+
ctx,
|
|
83
|
+
state,
|
|
84
|
+
arg_path,
|
|
85
|
+
arg,
|
|
86
|
+
value,
|
|
87
|
+
page,
|
|
88
|
+
makeJDDContext
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (arg instanceof Table) {
|
|
92
|
+
return ComponentInputTable({
|
|
93
|
+
ctx,
|
|
94
|
+
state,
|
|
95
|
+
arg_path,
|
|
96
|
+
arg,
|
|
97
|
+
value,
|
|
98
|
+
page,
|
|
99
|
+
makeJDDContext,
|
|
100
|
+
makeAssetURL
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return `<div>
|
|
104
|
+
<label>
|
|
105
|
+
${arg_path.at(-1) || ""}
|
|
106
|
+
${argType == "markdown" ? `<div class="grow-wrap">
|
|
107
|
+
<textarea
|
|
108
|
+
name="${`$${printArgPath(arg_path)}`}"
|
|
109
|
+
onblur="${page.rerender()}"
|
|
110
|
+
cols="40"
|
|
111
|
+
data-controller="markdown-textarea submit-on-input"
|
|
112
|
+
data-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"
|
|
113
|
+
autocomplete="off"
|
|
114
|
+
>
|
|
115
|
+
${is(value, predicates.string) ? value : ""}
|
|
116
|
+
</textarea
|
|
117
|
+
>
|
|
118
|
+
</div>` : `<input type="${inputType}"
|
|
119
|
+
name="${`$${printArgPath(arg_path)}`}"
|
|
120
|
+
value="${is(value, predicates.string) ? value : ""}" size="40"
|
|
121
|
+
${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}" />`}
|
|
122
|
+
</label>
|
|
123
|
+
</div>`;
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
ComponentInput,
|
|
127
|
+
actionName
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=component-input.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/inputs/component-input.ts"],
|
|
4
|
+
"sourcesContent": ["import { printArgPath } from \"./print-arg-path.js\";\nimport type { Context } from \"koa\";\nimport type { ComponentArgument, JDDContext, TableData } from \"@sealcode/jdd\";\nimport { SingleReference } from \"@sealcode/jdd\";\nimport {\n\tComponentArguments,\n\tEnum,\n\tImage,\n\tList,\n\tStructured,\n\tTable,\n} from \"@sealcode/jdd\";\nimport { ComponentInputStructured } from \"./component-input-structured.js\";\nimport type { StatefulPage } from \"@sealcode/sealgen\";\nimport type { ComponentPreviewActions } from \"../component-preview-actions.js\";\nimport { ComponentInputList } from \"./component-input-list.js\";\nimport type { JDDPageState } from \"../jdd-page.js\";\nimport { ComponentInputEnum } from \"./component-input-enum.js\";\nimport { ComponentInputImage } from \"./component-input-image.js\";\nimport { ComponentInputTable } from \"./component-input-table.js\";\nimport type { FilePointer } from \"@sealcode/file-manager\";\nimport { ComponentInputSingleReference } from \"./component-input-single-reference.js\";\nimport { is, predicates } from \"@sealcode/ts-predicates\";\n\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 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) {\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});\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\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\t\t\t\t\t\t\t${is(value, predicates.string) ? value : \"\"}\n\t\t\t\t\t\t</textarea\n\t\t\t\t\t\t>\n\t\t\t\t </div>`\n\t\t\t\t: /* HTML */ `<input type=\"${inputType}\"\n\t\t\t\t name=\"${`$${printArgPath(arg_path)}`}\"\n\t\t\t\t value=\"${is(value, predicates.string) ? value : \"\"}\" size=\"40\"\n\t\t\t\t ${isUrlAbsolute ? `pattern=\"${absoluteUrlPattern}\"` : \"\"}\" />`}\n\t\t</label>\n\t</div>`;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,oBAAoB;AAG7B,SAAS,uBAAuB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,gCAAgC;AAGzC,SAAS,0BAA0B;AAEnC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AAEpC,SAAS,qCAAqC;AAC9C,SAAS,IAAI,kBAAkB;AAExB,MAAM,aAAa;AAC1B,MAAM,qBAAqB;AAE3B,eAAsB,eAA8C;AAAA,EACnE;AAAA,EACA;AAAA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AEA,SAAkB;AAAA;AAAA,KAEd,SAAS,GAAG,EAAE,KAAK;AAAA,KACnB,WAAW,aACC;AAAA;AAAA,eAEF,IAAI,aAAa,QAAQ;AAAA,iBACvB,KAAK,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAMtB,GAAG,OAAO,WAAW,MAAM,IAAI,QAAQ;AAAA;AAAA;AAAA,gBAI/B,gBAAgB;AAAA,cACnB,IAAI,aAAa,QAAQ;AAAA,eACxB,GAAG,OAAO,WAAW,MAAM,IAAI,QAAQ;AAAA,QAC9C,gBAAgB,YAAY,wBAAwB;AAAA;AAAA;AAG5D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/inputs/print-arg-path.ts"],
|
|
4
|
+
"sourcesContent": ["export function printArgPath(path: string[]): string {\n\treturn path.map((e) => `[${e}]`).join(\"\");\n}\n"],
|
|
5
|
+
"mappings": "AAAO,SAAS,aAAa,MAAwB;AACpD,SAAO,KAAK,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,EAAE;AACzC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ComponentPreviewActions } from "./component-preview-actions.js";
|
|
2
|
+
import JDDPage from "./jdd-page.js";
|
|
3
|
+
import { htmlEscape } from "escape-goat";
|
|
4
|
+
import { tempstream } from "tempstream";
|
|
5
|
+
class JDDCreator extends JDDPage {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.actions = ComponentPreviewActions;
|
|
9
|
+
}
|
|
10
|
+
getAllowedComponents() {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
getRegistryComponents() {
|
|
14
|
+
const all_components = super.getRegistryComponents();
|
|
15
|
+
const allowed_components = this.getAllowedComponents();
|
|
16
|
+
if (allowed_components.length > 0) {
|
|
17
|
+
return Object.fromEntries(
|
|
18
|
+
Object.entries(all_components).filter(
|
|
19
|
+
([name]) => allowed_components.includes(name)
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
return all_components;
|
|
24
|
+
}
|
|
25
|
+
renderParameterButtons(state) {
|
|
26
|
+
{
|
|
27
|
+
}
|
|
28
|
+
return `<div class="jdd-editor__toolbar">
|
|
29
|
+
<input type="submit" value="Preview" />
|
|
30
|
+
<select name="component">
|
|
31
|
+
${Object.keys(this.getRegistryComponents()).map((cmp) => `<option value="${cmp}">${cmp}</option>`).join("")}
|
|
32
|
+
</select>
|
|
33
|
+
${this.makeActionButton(state, {
|
|
34
|
+
action: "add_component",
|
|
35
|
+
label: "Add component"
|
|
36
|
+
})}
|
|
37
|
+
</div>`;
|
|
38
|
+
}
|
|
39
|
+
renderComponentBlock(ctx, state, component_data, component_index) {
|
|
40
|
+
const component = this.getRegistryComponents()[component_data.component_name];
|
|
41
|
+
const checkbox_id = `component_${component_index}_open`;
|
|
42
|
+
return tempstream`<div
|
|
43
|
+
class="jdd-editor__component-block jdd-editor__component-block--number-${component_index}"
|
|
44
|
+
id="${`jdd-editor__component-block--${component_data.component_name}-${component_index}`}"
|
|
45
|
+
data-component-debugger-target="componentBlock"
|
|
46
|
+
data-component-index="${component_index.toString()}"
|
|
47
|
+
>
|
|
48
|
+
<summary class="jdd-editor__component-block__top_bar">
|
|
49
|
+
${this.makeActionButton(
|
|
50
|
+
state,
|
|
51
|
+
{ action: "remove_component", label: "\u274C" },
|
|
52
|
+
component_index
|
|
53
|
+
)}
|
|
54
|
+
${this.makeActionButton(
|
|
55
|
+
state,
|
|
56
|
+
{
|
|
57
|
+
action: "move_component_up",
|
|
58
|
+
label: "Move this row up",
|
|
59
|
+
content: `<img
|
|
60
|
+
width="20"
|
|
61
|
+
height="20"
|
|
62
|
+
src="${this.makeAssetURL(
|
|
63
|
+
"icons/table-move-row-up.svg"
|
|
64
|
+
)}"
|
|
65
|
+
/>`
|
|
66
|
+
},
|
|
67
|
+
component_index
|
|
68
|
+
)}
|
|
69
|
+
${this.makeActionButton(
|
|
70
|
+
state,
|
|
71
|
+
{
|
|
72
|
+
action: "move_component_down",
|
|
73
|
+
label: "Move this row down",
|
|
74
|
+
content: `<img
|
|
75
|
+
width="20"
|
|
76
|
+
height="20"
|
|
77
|
+
src="${this.makeAssetURL(
|
|
78
|
+
"icons/table-move-row-down.svg"
|
|
79
|
+
)}"
|
|
80
|
+
/>`
|
|
81
|
+
},
|
|
82
|
+
component_index
|
|
83
|
+
)}
|
|
84
|
+
<span class="jdd-editor__component-block__title">
|
|
85
|
+
<div class="jdd-editor__component-block__title__main">
|
|
86
|
+
${htmlEscape(
|
|
87
|
+
(component == null ? void 0 : component.getTitle(
|
|
88
|
+
this.makeJDDContext(ctx),
|
|
89
|
+
component_data.args
|
|
90
|
+
)) || ""
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
<div class="jdd-editor__component-block__title__secondary">
|
|
94
|
+
${component_data.component_name}
|
|
95
|
+
</div>
|
|
96
|
+
</span>
|
|
97
|
+
<label
|
|
98
|
+
class="component-block__handle"
|
|
99
|
+
for="${checkbox_id}"
|
|
100
|
+
style="flex-grow: 1"
|
|
101
|
+
data-action="click->component-debugger#labelClicked"
|
|
102
|
+
>
|
|
103
|
+
<span class="jdd-editor__component-block__chevron">
|
|
104
|
+
${" "} >${" "}
|
|
105
|
+
</span>
|
|
106
|
+
</label>
|
|
107
|
+
</summary>
|
|
108
|
+
<input
|
|
109
|
+
type="checkbox"
|
|
110
|
+
class="component-collapse-toggle"
|
|
111
|
+
name="${`$[components][${component_index}][open]`}"
|
|
112
|
+
data-turbo-permanent
|
|
113
|
+
id="${checkbox_id}"
|
|
114
|
+
style="display:none"
|
|
115
|
+
data-component-debugger-target="checkbox"
|
|
116
|
+
/>
|
|
117
|
+
<div class="jdd-editor__component-block__inner">
|
|
118
|
+
${super.renderComponentBlock(
|
|
119
|
+
ctx,
|
|
120
|
+
state,
|
|
121
|
+
component_data,
|
|
122
|
+
component_index
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
</div>`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export {
|
|
129
|
+
JDDCreator as default
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=jdd-creator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/jdd-creator.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Context } from \"koa\";\nimport { ComponentPreviewActions } from \"./component-preview-actions.js\";\nimport type { JDDPageState } from \"./jdd-page.js\";\nimport JDDPage from \"./jdd-page.js\";\nimport { htmlEscape } from \"escape-goat\";\nimport { tempstream } from \"tempstream\";\n\nexport default abstract class JDDCreator extends JDDPage {\n\tactions = ComponentPreviewActions;\n\n\t/**\n\t * This method returns list of components allowed in JDD Editor instance.\n\t * If list is empty it will allow all of the components in registry,\n\t * if you overide this function you can decide on what components should\n\t * available.\n\t */\n\tgetAllowedComponents(): string[] {\n\t\treturn [];\n\t}\n\n\tgetRegistryComponents() {\n\t\tconst all_components = super.getRegistryComponents();\n\t\tconst allowed_components = this.getAllowedComponents();\n\n\t\tif (allowed_components.length > 0) {\n\t\t\treturn Object.fromEntries(\n\t\t\t\tObject.entries(all_components).filter(([name]) =>\n\t\t\t\t\tallowed_components.includes(name)\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\n\t\treturn all_components;\n\t}\n\n\trenderParameterButtons(state: JDDPageState) {\n\t\t{\n\t\t\t/*The below button has to be here in order for it to be the default behavior */\n\t\t}\n\t\treturn `<div class=\"jdd-editor__toolbar\">\n\t\t\t\t<input type=\"submit\" value=\"Preview\" />\n\t\t\t\t<select name=\"component\">\n\t\t\t\t\t${Object.keys(this.getRegistryComponents())\n\t\t\t\t\t\t.map((cmp) => `<option value=\"${cmp}\">${cmp}</option>`)\n\t\t\t\t\t\t.join(\"\")}\n\t\t\t\t</select>\n\t\t\t\t${this.makeActionButton(state, {\n\t\t\t\t\taction: \"add_component\",\n\t\t\t\t\tlabel: \"Add component\",\n\t\t\t\t})}\n\t\t\t</div>`;\n\t}\n\n\trenderComponentBlock(\n\t\tctx: Context,\n\t\tstate: JDDPageState,\n\t\tcomponent_data: {\n\t\t\tcomponent_name: string;\n\t\t\targs: Record<string, unknown>;\n\t\t},\n\t\tcomponent_index: number\n\t) {\n\t\tconst component =\n\t\t\tthis.getRegistryComponents()[component_data.component_name];\n\t\tconst checkbox_id = `component_${component_index}_open`;\n\t\treturn tempstream/* HTML */ `<div\n\t\t\tclass=\"jdd-editor__component-block jdd-editor__component-block--number-${component_index}\"\n\t\t\tid=\"${`jdd-editor__component-block--${component_data.component_name}-${component_index}`}\"\n\t\t\tdata-component-debugger-target=\"componentBlock\"\n\t\t\tdata-component-index=\"${component_index.toString()}\"\n\t\t>\n\t\t\t<summary class=\"jdd-editor__component-block__top_bar\">\n\t\t\t\t${this.makeActionButton(\n\t\t\t\t\tstate,\n\t\t\t\t\t{ action: \"remove_component\", label: \"\u274C\" },\n\t\t\t\t\tcomponent_index\n\t\t\t\t)}\n\t\t\t\t${this.makeActionButton(\n\t\t\t\t\tstate,\n\t\t\t\t\t{\n\t\t\t\t\t\taction: \"move_component_up\",\n\t\t\t\t\t\tlabel: \"Move this row up\",\n\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\tsrc=\"${this.makeAssetURL(\n\t\t\t\t\t\t\t\t\"icons/table-move-row-up.svg\"\n\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t/>`,\n\t\t\t\t\t},\n\t\t\t\t\tcomponent_index\n\t\t\t\t)}\n\t\t\t\t${this.makeActionButton(\n\t\t\t\t\tstate,\n\t\t\t\t\t{\n\t\t\t\t\t\taction: \"move_component_down\",\n\t\t\t\t\t\tlabel: \"Move this row down\",\n\t\t\t\t\t\tcontent: /* HTML */ `<img\n\t\t\t\t\t\t\twidth=\"20\"\n\t\t\t\t\t\t\theight=\"20\"\n\t\t\t\t\t\t\tsrc=\"${this.makeAssetURL(\n\t\t\t\t\t\t\t\t\"icons/table-move-row-down.svg\"\n\t\t\t\t\t\t\t)}\"\n\t\t\t\t\t\t/>`,\n\t\t\t\t\t},\n\t\t\t\t\tcomponent_index\n\t\t\t\t)}\n\t\t\t\t<span class=\"jdd-editor__component-block__title\">\n\t\t\t\t\t<div class=\"jdd-editor__component-block__title__main\">\n\t\t\t\t\t\t${htmlEscape(\n\t\t\t\t\t\t\tcomponent?.getTitle(\n\t\t\t\t\t\t\t\tthis.makeJDDContext(ctx),\n\t\t\t\t\t\t\t\tcomponent_data.args\n\t\t\t\t\t\t\t) || \"\"\n\t\t\t\t\t\t)}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"jdd-editor__component-block__title__secondary\">\n\t\t\t\t\t\t${component_data.component_name}\n\t\t\t\t\t</div>\n\t\t\t\t</span>\n\t\t\t\t<label\n\t\t\t\t\tclass=\"component-block__handle\"\n\t\t\t\t\tfor=\"${checkbox_id}\"\n\t\t\t\t\tstyle=\"flex-grow: 1\"\n\t\t\t\t\tdata-action=\"click->component-debugger#labelClicked\"\n\t\t\t\t>\n\t\t\t\t\t<span class=\"jdd-editor__component-block__chevron\">\n\t\t\t\t\t\t${\" \"} >${\" \"}\n\t\t\t\t\t</span>\n\t\t\t\t</label>\n\t\t\t</summary>\n\t\t\t<input\n\t\t\t\ttype=\"checkbox\"\n\t\t\t\tclass=\"component-collapse-toggle\"\n\t\t\t\tname=\"${`$[components][${component_index}][open]`}\"\n\t\t\t\tdata-turbo-permanent\n\t\t\t\tid=\"${checkbox_id}\"\n\t\t\t\tstyle=\"display:none\"\n\t\t\t\tdata-component-debugger-target=\"checkbox\"\n\t\t\t/>\n\t\t\t<div class=\"jdd-editor__component-block__inner\">\n\t\t\t\t${super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