@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,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.EditJDDField = void 0;
|
|
16
|
+
const jdd_1 = require("@sealcode/jdd");
|
|
17
|
+
const jdd_creator_js_1 = __importDefault(require("./jdd-creator.js"));
|
|
18
|
+
const tempstream_1 = require("tempstream");
|
|
19
|
+
class EditJDDField extends jdd_creator_js_1.default {
|
|
20
|
+
getID(ctx) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions, @typescript-eslint/no-unsafe-member-access
|
|
23
|
+
const id = ctx.params["id"];
|
|
24
|
+
if (!id) {
|
|
25
|
+
throw new Error("Missing URL parameter: " + "id");
|
|
26
|
+
}
|
|
27
|
+
return id;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
getItem(ctx) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const { items: [item], } = yield this.getCollection(ctx)
|
|
33
|
+
.list(ctx.$context)
|
|
34
|
+
.ids([yield this.getID(ctx)])
|
|
35
|
+
.fetch();
|
|
36
|
+
if (!item) {
|
|
37
|
+
throw new Error("Couldn't get item of id " + (yield this.getID(ctx)));
|
|
38
|
+
}
|
|
39
|
+
return item;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
mount(router, path) {
|
|
43
|
+
super.mount(router, path);
|
|
44
|
+
router.post(path + "save/", (ctx) => __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const { state } = yield this.extractState(ctx);
|
|
46
|
+
const item = yield this.getItem(ctx);
|
|
47
|
+
item.set(this.getJDDFieldName(), (yield (0, jdd_1.documentToStorage)(this.registry, this.makeJDDContext(ctx), {
|
|
48
|
+
value: state.components,
|
|
49
|
+
})).value);
|
|
50
|
+
yield item.save(ctx.$context);
|
|
51
|
+
ctx.type = "html";
|
|
52
|
+
ctx.status = 422;
|
|
53
|
+
if (!state.messages) {
|
|
54
|
+
state.messages = [];
|
|
55
|
+
}
|
|
56
|
+
state.messages.push("Saved!");
|
|
57
|
+
ctx.body = this.render(ctx, state);
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
renderHeader(_ctx, _item) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
return /* HTML */ `<h1>Edit JDD</h1>`;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
renderPreParameterButtons(ctx) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const item = yield this.getItem(ctx);
|
|
68
|
+
return (0, tempstream_1.tempstream) `<div>${this.renderHeader(ctx, item)}</div>`;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
renderParameterButtons(state) {
|
|
72
|
+
{
|
|
73
|
+
/*The below button has to be here in order for it to be the default behavior */
|
|
74
|
+
}
|
|
75
|
+
return `<div class="jdd-editor__toolbar">
|
|
76
|
+
<input type="submit" value="Preview" />
|
|
77
|
+
<select name="component">
|
|
78
|
+
${Object.keys(this.getRegistryComponents())
|
|
79
|
+
.map((cmp) => `<option value="${cmp}">${cmp}</option>`)
|
|
80
|
+
.join("")}
|
|
81
|
+
</select>
|
|
82
|
+
${this.makeActionButton(state, {
|
|
83
|
+
action: "add_component",
|
|
84
|
+
label: "Add component",
|
|
85
|
+
})}
|
|
86
|
+
<input type="submit" formaction="./save/" value="zapisz" />
|
|
87
|
+
</div>`;
|
|
88
|
+
}
|
|
89
|
+
getInitialState(ctx) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const article = yield this.getItem(ctx);
|
|
92
|
+
const parsed_document = yield (0, jdd_1.documentToParsed)(this.registry, this.makeJDDContext(ctx), (0, jdd_1.documentContainerFromStorage)(
|
|
93
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
94
|
+
article.get(this.getJDDFieldName()) || []));
|
|
95
|
+
return {
|
|
96
|
+
components: parsed_document.value.map((e) => (Object.assign(Object.assign({}, e), { open: true }))),
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.EditJDDField = EditJDDField;
|
|
102
|
+
//# sourceMappingURL=edit-jdd-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit-jdd-field.js","sourceRoot":"","sources":["../src/edit-jdd-field.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,uCAIuB;AAGvB,sEAA0C;AAE1C,2CAAwC;AAExC,MAAsB,YAAmC,SAAQ,wBAAU;IACpE,KAAK,CAAC,GAAY;;YACvB,qHAAqH;YACrH,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAW,CAAC;YACtC,IAAI,CAAC,EAAE,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;YACpD,CAAC;YACD,OAAO,EAAE,CAAC;QACX,CAAC;KAAA;IAIK,OAAO,CAAC,GAAY;;YACzB,MAAM,EACL,KAAK,EAAE,CAAC,IA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OAAO;gBACN,UAAU,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACzC,CAAC,KACJ,IAAI,EAAE,IAAI,IACT,CAAC;aACH,CAAC;QACH,CAAC;KAAA;CAMD;AA7GD,oCA6GC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./edit-jdd-field.js"), exports);
|
|
18
|
+
__exportStar(require("./components.sreact.js"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,yDAAuC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentInputEnum = ComponentInputEnum;
|
|
4
|
+
const print_arg_path_js_1 = require("./print-arg-path.js");
|
|
5
|
+
function ComponentInputEnum({ arg_path, arg, value, onchange, }) {
|
|
6
|
+
return /* HTML */ `<div id=${`component-input-enum-${arg_path.join("-")}`}>
|
|
7
|
+
<label>
|
|
8
|
+
${arg_path.at(-1) || ""}
|
|
9
|
+
<select
|
|
10
|
+
name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}`}"
|
|
11
|
+
onchange="${onchange || ""}"
|
|
12
|
+
>
|
|
13
|
+
${arg.values
|
|
14
|
+
.map((v) => /* HTML */ `<option
|
|
15
|
+
value="${v}"
|
|
16
|
+
${value == v ? "selected" : ""}
|
|
17
|
+
>
|
|
18
|
+
${v}
|
|
19
|
+
</option>`)
|
|
20
|
+
.join("")}
|
|
21
|
+
</select>
|
|
22
|
+
</label>
|
|
23
|
+
</div>`;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=component-input-enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-enum.js","sourceRoot":"","sources":["../../src/inputs/component-input-enum.ts"],"names":[],"mappings":";;AAGA,gDAgCC;AAlCD,2DAAmD;AAEnD,SAAgB,kBAAkB,CAA6C,EAC9E,QAAQ,EACR,GAAG,EACH,KAAK,EACL,QAAQ,GAOR;IACA,OAAO,UAAU,CAAC,WAAW,wBAAwB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;;KAErE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;;YAEd,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,EAAE;gBACxB,QAAQ,IAAI,EAAE;;MAExB,GAAG,CAAC,MAAM;SACV,GAAG,CACH,CAAC,CAAI,EAAE,EAAE,CAAC,UAAU,CAAC;gBACX,CAAC;SACR,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;;SAE5B,CAAC;gBACM,CACV;SACA,IAAI,CAAC,EAAE,CAAC;;;QAGN,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentInputImage = ComponentInputImage;
|
|
4
|
+
const tempstream_1 = require("tempstream");
|
|
5
|
+
const print_arg_path_js_1 = require("./print-arg-path.js");
|
|
6
|
+
function ComponentInputImage({ arg_path, arg, value, ctx, page, state, makeJDDContext, }) {
|
|
7
|
+
const jdd_context = makeJDDContext(ctx);
|
|
8
|
+
return (0, tempstream_1.tempstream /* HTML */) `<div style="margin-bottom: 10px">
|
|
9
|
+
<label
|
|
10
|
+
style="display: flex; align-items: center; column-gap: 10px;"
|
|
11
|
+
data-controller="input-image-preview"
|
|
12
|
+
>
|
|
13
|
+
${arg_path.at(-1) || ""}
|
|
14
|
+
<div class="image-preview-container">
|
|
15
|
+
${value &&
|
|
16
|
+
jdd_context.render_image(value, {
|
|
17
|
+
container: {
|
|
18
|
+
width: 40,
|
|
19
|
+
height: 40,
|
|
20
|
+
objectFit: "cover",
|
|
21
|
+
},
|
|
22
|
+
crop: { width: 40, height: 40 },
|
|
23
|
+
style: "height: 40px; width: 40px;",
|
|
24
|
+
alt: "",
|
|
25
|
+
})}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<input
|
|
29
|
+
type="file"
|
|
30
|
+
name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}.new`}"
|
|
31
|
+
value=""
|
|
32
|
+
autocomplete="off"
|
|
33
|
+
data-action="change->input-image-preview#handleChange"
|
|
34
|
+
${arg.hasParent("list") ? "multiple" : ""}
|
|
35
|
+
/>
|
|
36
|
+
</label>
|
|
37
|
+
<div>
|
|
38
|
+
<input type="hidden" name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}.old`}"
|
|
39
|
+
value={value?.token || ""} autocomplete="off" />
|
|
40
|
+
</div>
|
|
41
|
+
${page.makeActionButton(state, {
|
|
42
|
+
action: "remove_file",
|
|
43
|
+
label: "❌",
|
|
44
|
+
}, arg_path)}
|
|
45
|
+
</div>`;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=component-input-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-image.js","sourceRoot":"","sources":["../../src/inputs/component-input-image.ts"],"names":[],"mappings":";;AASA,kDA4DC;AA/DD,2CAAwC;AACxC,2DAAmD;AAEnD,SAAgB,mBAAmB,CAA6B,EAC/D,QAAQ,EACR,GAAG,EACH,KAAK,EACL,GAAG,EACH,IAAI,EACJ,KAAK,EACL,cAAc,GASd;IACA,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO,IAAA,uBAAU,CAAA,UAAU,EAAC;;;;;KAKxB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;;MAEpB,KAAK;QACP,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE;YAC/B,SAAS,EAAE;gBACV,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,OAAO;aAClB;YACD,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC/B,KAAK,EAAE,4BAA4B;YACnC,GAAG,EAAE,EAAE;SACP,CAAC;;;;;YAKM,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,MAAM;;;;MAItC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;;;;gCAIb,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,MAAM;;;IAG5D,IAAI,CAAC,gBAAgB,CACtB,KAAK,EACL;QACC,MAAM,EAAE,aAAa;QACrB,KAAK,EAAE,GAAG;KACV,EACD,QAAQ,CACR;QACK,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.ComponentInputList = ComponentInputList;
|
|
24
|
+
const component_input_js_1 = require("./component-input.js");
|
|
25
|
+
const tempstream_1 = require("tempstream");
|
|
26
|
+
function ComponentInputList(_a) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
var { state, ctx, arg_path, arg, value, page, makeJDDContext } = _a, rest = __rest(_a, ["state", "ctx", "arg_path", "arg", "value", "page", "makeJDDContext"]);
|
|
29
|
+
if (!value) {
|
|
30
|
+
value = [];
|
|
31
|
+
}
|
|
32
|
+
return (0, tempstream_1.tempstream /* HTML */) `<fieldset
|
|
33
|
+
id="${`component-input-list-${arg_path.join("-")}`}"
|
|
34
|
+
>
|
|
35
|
+
<legend>${arg_path.at(-1)}</legend>
|
|
36
|
+
${value.map((value, i, all_values) => (0, tempstream_1.tempstream) `<div style="display: flex">
|
|
37
|
+
${(0, component_input_js_1.ComponentInput)(Object.assign(Object.assign({}, rest), { ctx,
|
|
38
|
+
state, arg_path: [...arg_path, i.toString()], arg: arg.item_type, value,
|
|
39
|
+
page,
|
|
40
|
+
makeJDDContext }))}
|
|
41
|
+
${page.makeActionButton(state, {
|
|
42
|
+
action: "move_array_item_down",
|
|
43
|
+
label: "↓",
|
|
44
|
+
disabled: i == all_values.length - 1,
|
|
45
|
+
}, arg_path, i)}
|
|
46
|
+
${page.makeActionButton(state, {
|
|
47
|
+
action: "move_array_item_up",
|
|
48
|
+
label: "↑",
|
|
49
|
+
disabled: i == 0,
|
|
50
|
+
}, arg_path, i)}
|
|
51
|
+
|
|
52
|
+
${page.makeActionButton(state, { action: "remove_array_item", label: "❌" }, arg_path, i)}
|
|
53
|
+
</div>`)}
|
|
54
|
+
${page.makeActionButton(state, {
|
|
55
|
+
action: "add_array_item",
|
|
56
|
+
label: "➕",
|
|
57
|
+
}, arg_path)}
|
|
58
|
+
</fieldset>`;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=component-input-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-list.js","sourceRoot":"","sources":["../../src/inputs/component-input-list.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AASA,gDAiFC;AArFD,6DAAsD;AAEtD,2CAAwC;AAExC,SAAsB,kBAAkB,CAGtC,EAmBD;;YAnBC,EACD,KAAK,EACL,GAAG,EACH,QAAQ,EACR,GAAG,EACH,KAAK,EACL,IAAI,EACJ,cAAc,OAYd,EAXG,IAAI,cARN,sEASD,CADO;QAYP,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,K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3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ComponentInputSingleReference = ComponentInputSingleReference;
|
|
13
|
+
const print_arg_path_js_1 = require("./print-arg-path.js");
|
|
14
|
+
function ComponentInputSingleReference(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ ctx, arg_path, arg, value, onchange, makeJDDContext, }) {
|
|
16
|
+
const values = yield arg.getValues(makeJDDContext(ctx));
|
|
17
|
+
const ret = `<div>
|
|
18
|
+
<label>
|
|
19
|
+
${arg_path.at(-1) || ""}
|
|
20
|
+
<select name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}`}" onchange="${onchange}">
|
|
21
|
+
${values
|
|
22
|
+
.sort((v1, v2) => (v1.label > v2.label ? 1 : -1))
|
|
23
|
+
.map((v) => /* HTML */ `<option
|
|
24
|
+
value="${v.value}"
|
|
25
|
+
${value == v.value ? "selected" : ""}
|
|
26
|
+
>
|
|
27
|
+
${v.label}
|
|
28
|
+
</option>`)
|
|
29
|
+
.join("")}
|
|
30
|
+
</select>
|
|
31
|
+
</label>
|
|
32
|
+
</div>`;
|
|
33
|
+
return ret;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=component-input-single-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-single-reference.js","sourceRoot":"","sources":["../../src/inputs/component-input-single-reference.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,sEAwCC;AA1CD,2DAAmD;AAEnD,SAAsB,6BAA6B;yDAIjD,EACD,GAAG,EACH,QAAQ,EACR,GAAG,EACH,KAAK,EACL,QAAQ,EACR,cAAc,GASd;QACA,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACxD,MAAM,GAAG,GAAG;;MAEP,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;oBACP,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,EAAE,eAAe,QAAQ;OAChE,MAAM;aACN,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CACH,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC;iBACR,CAAC,CAAC,KAAK;UACd,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE;;UAElC,CAAC,CAAC,KAAK;iBACA,CACV;aACA,IAAI,CAAC,EAAE,CAAC;;;SAGN,CAAC;QACT,OAAO,GAAG,CAAC;IACZ,CAAC;CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.ComponentInputStructured = ComponentInputStructured;
|
|
24
|
+
const component_input_js_1 = require("./component-input.js");
|
|
25
|
+
function ComponentInputStructured(_a) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
var { state, ctx, arg_path, arg, value, page } = _a, rest = __rest(_a, ["state", "ctx", "arg_path", "arg", "value", "page"]);
|
|
28
|
+
return /* HTML */ `<fieldset
|
|
29
|
+
id="${`component-input-structured-${arg_path.join("-")}`}"
|
|
30
|
+
>
|
|
31
|
+
<legend>{arg_path.at(-1)}</legend>
|
|
32
|
+
${(yield Promise.all(Object.entries(arg.structure).map((_a) => __awaiter(this, [_a], void 0, function* ([arg_name, arg]) {
|
|
33
|
+
const ret = `<div>
|
|
34
|
+
${yield (0, component_input_js_1.ComponentInput)(Object.assign({ ctx,
|
|
35
|
+
state, arg_path: [...arg_path, arg_name], arg, value: value[arg_name], page }, rest))}
|
|
36
|
+
</div>`;
|
|
37
|
+
return ret;
|
|
38
|
+
})))).join("")}
|
|
39
|
+
</fieldset>`;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=component-input-structured.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-structured.js","sourceRoot":"","sources":["../../src/inputs/component-input-structured.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAOA,4DA2CC;AA/CD,6DAAsD;AAItD,SAAsB,wBAAwB,CAE5C,EAiBD;;YAjBC,EACD,KAAK,EACL,GAAG,EACH,QAAQ,EACR,GAAG,EACH,KAAK,EACL,IAAI,OAWJ,EAVG,IAAI,cAPN,oDAQD,CADO;QAWP,OAAO,UAAU,CAAC;QACX,8BAA8B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;;;IAGtD,CACD,MAAM,OAAO,CAAC,GAAG,CAChB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,KAAwB,EAAE,0CAAnB,CAAC,QAAQ,EAAE,GAAG,CAAC;YACvD,MAAM,GAAG,GAAG;QACT,MAAM,IAAA,mCAAc,kBACrB,GAAG;gBACH,KAAK,EACL,QAAQ,EAAE,CAAC,GAAG,QAAQ,EAAE,QAAQ,CAAC,EACjC,GAAG,EACH,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,EACtB,IAAI,IACD,IAAI,EACN;YACI,CAAC;YACR,OAAO,GAAG,CAAC;QACZ,CAAC,CAAA,CAAC,CACF,CACD,CAAC,IAAI,CAAC,EAAE,CAAC;aACC,CAAC;IACd,CAAC;CAAA"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ComponentInputTable = ComponentInputTable;
|
|
13
|
+
const jdd_1 = require("@sealcode/jdd");
|
|
14
|
+
const jdd_2 = require("@sealcode/jdd");
|
|
15
|
+
const tempstream_1 = require("tempstream");
|
|
16
|
+
const component_input_js_1 = require("./component-input.js");
|
|
17
|
+
function ComponentInputTable(_a) {
|
|
18
|
+
return __awaiter(this, arguments, void 0, function* ({ state, arg_path, ctx, arg, value, page, makeJDDContext, makeAssetURL, }) {
|
|
19
|
+
if (!value) {
|
|
20
|
+
value = yield arg.getEmptyValue(makeJDDContext(ctx));
|
|
21
|
+
}
|
|
22
|
+
const show_paste = arg.cell_type instanceof jdd_1.Markdown &&
|
|
23
|
+
arg.header_type instanceof jdd_1.Markdown;
|
|
24
|
+
return (0, tempstream_1.tempstream /* HTML */) `<fieldset>
|
|
25
|
+
<legend>${arg_path.at(-1)}</legend>
|
|
26
|
+
<div>
|
|
27
|
+
${show_paste
|
|
28
|
+
? /* HTML */ `<input
|
|
29
|
+
type="button"
|
|
30
|
+
value="paste"
|
|
31
|
+
placeholder="paste table here"
|
|
32
|
+
data-jdd-table-paste-argpath-value="${arg_path.join(".")}"
|
|
33
|
+
data-controller="jdd-table-paste"
|
|
34
|
+
/>`
|
|
35
|
+
: ""}
|
|
36
|
+
<table
|
|
37
|
+
class="jdd-component-input--table"
|
|
38
|
+
style="position: relative; /* necessary for sticky th*/"
|
|
39
|
+
>
|
|
40
|
+
<tbody>
|
|
41
|
+
<tr>
|
|
42
|
+
<td></td>
|
|
43
|
+
${[...Array(arg.getColumnsCount(value)).keys()]
|
|
44
|
+
.map((column_index) => /* HTML */ `<th
|
|
45
|
+
class="sticky sticky--top subdued"
|
|
46
|
+
>
|
|
47
|
+
${page.makeActionButton(state, {
|
|
48
|
+
action: "remove_table_column",
|
|
49
|
+
label: "Remove column",
|
|
50
|
+
content: /* HTML */ `<img
|
|
51
|
+
width="20"
|
|
52
|
+
height="20"
|
|
53
|
+
src="${makeAssetURL("icons/table-delete-column.svg")}"
|
|
54
|
+
/>`,
|
|
55
|
+
}, arg_path, column_index)}
|
|
56
|
+
${column_index >=
|
|
57
|
+
arg.getColumnsCount(value) - 1
|
|
58
|
+
? ""
|
|
59
|
+
: page.makeActionButton(state, {
|
|
60
|
+
action: "move_table_column_right",
|
|
61
|
+
label: "Move column to the right",
|
|
62
|
+
content: /* HTML */ `<img
|
|
63
|
+
width="20"
|
|
64
|
+
height="20"
|
|
65
|
+
src="${makeAssetURL("icons/table-move-column-right.svg")}"
|
|
66
|
+
/>`,
|
|
67
|
+
}, arg_path, column_index)}
|
|
68
|
+
</th>`)
|
|
69
|
+
.join("")}
|
|
70
|
+
</tr>
|
|
71
|
+
${value.rows.map((row, row_index) => (0, tempstream_1.tempstream /* HTML */) `<tr>
|
|
72
|
+
<td class="sticky sticky--left subdued">
|
|
73
|
+
<div
|
|
74
|
+
style="display: flex; flex-flow: column; row-gap: 5px;"
|
|
75
|
+
>
|
|
76
|
+
${page.makeActionButton(state, {
|
|
77
|
+
action: "remove_table_row",
|
|
78
|
+
label: "Remove row",
|
|
79
|
+
content: /* HTML */ `<img
|
|
80
|
+
width="20"
|
|
81
|
+
height="20"
|
|
82
|
+
src="${makeAssetURL("icons/table-delete-row.svg")}"
|
|
83
|
+
/>`,
|
|
84
|
+
}, arg_path, row_index)}
|
|
85
|
+
${page.makeActionButton(state, {
|
|
86
|
+
action: "move_table_row_down",
|
|
87
|
+
label: "Move this row down",
|
|
88
|
+
content: /* HTML */ `<img
|
|
89
|
+
width="20"
|
|
90
|
+
height="20"
|
|
91
|
+
src="${makeAssetURL("icons/table-move-row-down.svg")}"
|
|
92
|
+
/>`,
|
|
93
|
+
}, arg_path, row_index)}
|
|
94
|
+
</div>
|
|
95
|
+
</td>
|
|
96
|
+
${(0, jdd_2.isTableHeader)(row)
|
|
97
|
+
? /* HTML */ (0, tempstream_1.tempstream) `<th
|
|
98
|
+
colspan="${arg.getColumnsCount(value).toString()}"
|
|
99
|
+
>
|
|
100
|
+
${(0, component_input_js_1.ComponentInput)({
|
|
101
|
+
state,
|
|
102
|
+
ctx,
|
|
103
|
+
arg_path: [
|
|
104
|
+
...arg_path,
|
|
105
|
+
"rows",
|
|
106
|
+
row_index.toString(),
|
|
107
|
+
"header_content",
|
|
108
|
+
],
|
|
109
|
+
arg: arg.header_type,
|
|
110
|
+
value: row.header_content,
|
|
111
|
+
page,
|
|
112
|
+
makeJDDContext,
|
|
113
|
+
makeAssetURL,
|
|
114
|
+
})}
|
|
115
|
+
</th>`
|
|
116
|
+
: row.cells.map((cell, cell_index) => (0, tempstream_1.tempstream /* HTML */) `<td>
|
|
117
|
+
${(0, component_input_js_1.ComponentInput)({
|
|
118
|
+
ctx,
|
|
119
|
+
state,
|
|
120
|
+
arg_path: [
|
|
121
|
+
...arg_path,
|
|
122
|
+
"rows",
|
|
123
|
+
row_index.toString(),
|
|
124
|
+
"cells",
|
|
125
|
+
cell_index.toString(),
|
|
126
|
+
],
|
|
127
|
+
arg: arg.cell_type,
|
|
128
|
+
value: cell,
|
|
129
|
+
page,
|
|
130
|
+
makeJDDContext,
|
|
131
|
+
makeAssetURL,
|
|
132
|
+
})}
|
|
133
|
+
</td>`)}
|
|
134
|
+
${row_index == 0
|
|
135
|
+
? /* HTML */ `<td
|
|
136
|
+
class="subdued"
|
|
137
|
+
rowspan="${value.rows.length.toString()}"
|
|
138
|
+
>
|
|
139
|
+
${page.makeActionButton(state, {
|
|
140
|
+
action: "add_table_column",
|
|
141
|
+
label: "Add column",
|
|
142
|
+
content: /* HTML */ `<img
|
|
143
|
+
width="20"
|
|
144
|
+
height="20"
|
|
145
|
+
src="${makeAssetURL("icons/table-add-column-right.svg")}"
|
|
146
|
+
/>`,
|
|
147
|
+
}, arg_path)}
|
|
148
|
+
</td>`
|
|
149
|
+
: ""}
|
|
150
|
+
</tr>`)}
|
|
151
|
+
<tr>
|
|
152
|
+
<td
|
|
153
|
+
class="subdued"
|
|
154
|
+
colspan="{(arg.getColumnsCount(value)"
|
|
155
|
+
+
|
|
156
|
+
1).toString()}
|
|
157
|
+
>
|
|
158
|
+
${page.makeActionButton(state, {
|
|
159
|
+
action: "add_table_row",
|
|
160
|
+
label: "Add table row",
|
|
161
|
+
content: /* HTML */ `<img
|
|
162
|
+
width="20"
|
|
163
|
+
height="20"
|
|
164
|
+
src="${makeAssetURL("icons/table-add-row-below.svg")}"
|
|
165
|
+
/>`,
|
|
166
|
+
}, arg_path, arg.getColumnsCount(value), undefined)}
|
|
167
|
+
${page.makeActionButton(state, {
|
|
168
|
+
action: "add_table_row",
|
|
169
|
+
label: "Add table header",
|
|
170
|
+
content: /* HTML */ `<img
|
|
171
|
+
width="20"
|
|
172
|
+
height="20"
|
|
173
|
+
src="${makeAssetURL("icons/table-add-column-header-below.svg")}"
|
|
174
|
+
/>`,
|
|
175
|
+
}, arg_path, arg.getColumnsCount(value), "header")}
|
|
176
|
+
</td>
|
|
177
|
+
</tr>
|
|
178
|
+
</tbody>
|
|
179
|
+
</table>
|
|
180
|
+
</div>
|
|
181
|
+
</fieldset>`;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=component-input-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-input-table.js","sourceRoot":"","sources":["../../src/inputs/component-input-table.ts"],"names":[],"mappings":";;;;;;;;;;;AAWA,kDA0PC;AAnQD,uCAAyC;AACzC,uCAA8C;AAG9C,2CAAwC;AACxC,6DAAsD;AAItD,SAAsB,mBAAmB;yDAIvC,EACD,KAAK,EACL,QAAQ,EACR,GAAG,EACH,GAAG,EACH,KAAK,EACL,IAAI,EACJ,cAAc,EACd,YAAY,GAUZ;QAC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