@sealcode/jdd-editor 0.1.6 → 0.1.7

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.
Files changed (114) hide show
  1. package/.nyc_output/29e7bb87-9f10-462e-84d8-ec620cfa9e6b.json +1 -0
  2. package/.nyc_output/7d7104e8-f179-427b-b4bd-30f78397e4f1.json +1 -0
  3. package/.nyc_output/9bfa248d-4f8e-4d29-9c47-d1a3961c5254.json +1 -0
  4. package/.nyc_output/processinfo/29e7bb87-9f10-462e-84d8-ec620cfa9e6b.json +1 -0
  5. package/.nyc_output/processinfo/7d7104e8-f179-427b-b4bd-30f78397e4f1.json +1 -0
  6. package/.nyc_output/processinfo/9bfa248d-4f8e-4d29-9c47-d1a3961c5254.json +1 -0
  7. package/.nyc_output/processinfo/index.json +1 -0
  8. package/.xunit +2 -0
  9. package/assets/styles/components.jdd-page.css +3 -2
  10. package/coverage/clover.xml +846 -0
  11. package/lib/src/component-preview-actions.js +439 -0
  12. package/lib/src/component-preview-actions.js.map +7 -0
  13. package/lib/src/components.sreact.js +93 -0
  14. package/lib/src/components.sreact.js.map +7 -0
  15. package/{dist/src → lib/src/controllers}/autogrow-textarea.stimulus.js.map +1 -1
  16. package/{dist/src → lib/src/controllers}/component-debugger.stimulus.js +3 -0
  17. package/lib/src/controllers/component-debugger.stimulus.js.map +7 -0
  18. package/{dist/src → lib/src/controllers}/exportable-textarea.stimulus.js.map +1 -1
  19. package/{dist/src → lib/src/controllers}/input-image-preview.stimulus.js.map +1 -1
  20. package/{dist/src → lib/src/controllers}/jdd-table-paste.stimulus.js.map +1 -1
  21. package/{dist/src → lib/src/controllers}/json-editor.stimulus.js.map +1 -1
  22. package/{dist/src → lib/src/controllers}/markdown-textarea.stimulus.js.map +1 -1
  23. package/lib/src/controllers/refresh-on-ts-changes.stimulus.js +90 -0
  24. package/lib/src/controllers/refresh-on-ts-changes.stimulus.js.map +7 -0
  25. package/lib/src/controllers/refresh-styles.stimulus.js +67 -0
  26. package/lib/src/controllers/refresh-styles.stimulus.js.map +7 -0
  27. package/{dist/src → lib/src/controllers}/submit-on-input.stimulus.js.map +1 -1
  28. package/{dist/src → lib/src/controllers}/toast.stimulus.js.map +1 -1
  29. package/lib/src/edit-jdd-field.js +94 -0
  30. package/lib/src/edit-jdd-field.js.map +7 -0
  31. package/lib/src/index.js +3 -0
  32. package/lib/src/index.js.map +7 -0
  33. package/lib/src/inputs/component-input-enum.js +30 -0
  34. package/lib/src/inputs/component-input-enum.js.map +7 -0
  35. package/lib/src/inputs/component-input-image.js +63 -0
  36. package/lib/src/inputs/component-input-image.js.map +7 -0
  37. package/lib/src/inputs/component-input-list.js +74 -0
  38. package/lib/src/inputs/component-input-list.js.map +7 -0
  39. package/lib/src/inputs/component-input-single-reference.js +31 -0
  40. package/lib/src/inputs/component-input-single-reference.js.map +7 -0
  41. package/lib/src/inputs/component-input-structured.js +36 -0
  42. package/lib/src/inputs/component-input-structured.js.map +7 -0
  43. package/lib/src/inputs/component-input-table.js +228 -0
  44. package/lib/src/inputs/component-input-table.js.map +7 -0
  45. package/lib/src/inputs/component-input.js +164 -0
  46. package/lib/src/inputs/component-input.js.map +7 -0
  47. package/lib/src/inputs/print-arg-path.js +7 -0
  48. package/lib/src/inputs/print-arg-path.js.map +7 -0
  49. package/lib/src/jdd-creator.js +131 -0
  50. package/lib/src/jdd-creator.js.map +7 -0
  51. package/lib/src/jdd-page.js +339 -0
  52. package/lib/src/jdd-page.js.map +7 -0
  53. package/lib/src/test.test.js +5 -0
  54. package/lib/src/test.test.js.map +7 -0
  55. package/package.json +1 -1
  56. package/dist/src/component-debugger.stimulus.js.map +0 -7
  57. package/lib/component-preview-actions.js +0 -286
  58. package/lib/component-preview-actions.js.map +0 -1
  59. package/lib/components.sreact.js +0 -102
  60. package/lib/components.sreact.js.map +0 -1
  61. package/lib/controllers/autogrow-textarea.stimulus.js +0 -15
  62. package/lib/controllers/autogrow-textarea.stimulus.js.map +0 -1
  63. package/lib/controllers/component-debugger.stimulus.js +0 -188
  64. package/lib/controllers/component-debugger.stimulus.js.map +0 -1
  65. package/lib/controllers/exportable-textarea.stimulus.js +0 -79
  66. package/lib/controllers/exportable-textarea.stimulus.js.map +0 -1
  67. package/lib/controllers/input-image-preview.stimulus.js +0 -28
  68. package/lib/controllers/input-image-preview.stimulus.js.map +0 -1
  69. package/lib/controllers/jdd-table-paste.stimulus.js +0 -84
  70. package/lib/controllers/jdd-table-paste.stimulus.js.map +0 -1
  71. package/lib/controllers/json-editor.stimulus.js +0 -134
  72. package/lib/controllers/json-editor.stimulus.js.map +0 -1
  73. package/lib/controllers/markdown-textarea.stimulus.js +0 -186
  74. package/lib/controllers/markdown-textarea.stimulus.js.map +0 -1
  75. package/lib/controllers/refresh-on-ts-changes.stimulus.js +0 -123
  76. package/lib/controllers/refresh-on-ts-changes.stimulus.js.map +0 -1
  77. package/lib/controllers/refresh-styles.stimulus.js +0 -66
  78. package/lib/controllers/refresh-styles.stimulus.js.map +0 -1
  79. package/lib/controllers/submit-on-input.stimulus.js +0 -48
  80. package/lib/controllers/submit-on-input.stimulus.js.map +0 -1
  81. package/lib/controllers/toast.stimulus.js +0 -16
  82. package/lib/controllers/toast.stimulus.js.map +0 -1
  83. package/lib/edit-jdd-field.js +0 -102
  84. package/lib/edit-jdd-field.js.map +0 -1
  85. package/lib/index.js +0 -19
  86. package/lib/index.js.map +0 -1
  87. package/lib/inputs/component-input-enum.js +0 -25
  88. package/lib/inputs/component-input-enum.js.map +0 -1
  89. package/lib/inputs/component-input-image.js +0 -47
  90. package/lib/inputs/component-input-image.js.map +0 -1
  91. package/lib/inputs/component-input-list.js +0 -61
  92. package/lib/inputs/component-input-list.js.map +0 -1
  93. package/lib/inputs/component-input-single-reference.js +0 -36
  94. package/lib/inputs/component-input-single-reference.js.map +0 -1
  95. package/lib/inputs/component-input-structured.js +0 -42
  96. package/lib/inputs/component-input-structured.js.map +0 -1
  97. package/lib/inputs/component-input-table.js +0 -184
  98. package/lib/inputs/component-input-table.js.map +0 -1
  99. package/lib/inputs/component-input.js +0 -133
  100. package/lib/inputs/component-input.js.map +0 -1
  101. package/lib/inputs/print-arg-path.js +0 -7
  102. package/lib/inputs/print-arg-path.js.map +0 -1
  103. package/lib/jdd-creator.js +0 -113
  104. package/lib/jdd-creator.js.map +0 -1
  105. package/lib/jdd-page.js +0 -310
  106. package/lib/jdd-page.js.map +0 -1
  107. /package/{dist/src → lib/src/controllers}/autogrow-textarea.stimulus.js +0 -0
  108. /package/{dist/src → lib/src/controllers}/exportable-textarea.stimulus.js +0 -0
  109. /package/{dist/src → lib/src/controllers}/input-image-preview.stimulus.js +0 -0
  110. /package/{dist/src → lib/src/controllers}/jdd-table-paste.stimulus.js +0 -0
  111. /package/{dist/src → lib/src/controllers}/json-editor.stimulus.js +0 -0
  112. /package/{dist/src → lib/src/controllers}/markdown-textarea.stimulus.js +0 -0
  113. /package/{dist/src → lib/src/controllers}/submit-on-input.stimulus.js +0 -0
  114. /package/{dist/src → lib/src/controllers}/toast.stimulus.js +0 -0
@@ -1 +0,0 @@
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"}
@@ -1,184 +0,0 @@
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
@@ -1 +0,0 @@
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;QACA,IAAI,CAAC,KAAK,EAAE,CAAC;YACZ,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,UAAU,GACf,GAAG,CAAC,SAAS,YAAY,cAAQ;YACjC,GAAG,CAAC,WAAW,YAAY,cAAQ,CAAC;QAErC,OAAO,IAAA,uBAAU,CAAA,UAAU,EAAC;YACjB,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE;;KAEvB,UAAU;YACX,CAAC,CAAC,UAAU,CAAC;;;;4CAI2B,QAAQ,CAAC,IAAI,CAClD,GAAG,CACH;;SAEE;YACL,CAAC,CAAC,EAAE;;;;;;;;QAQA,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aAC7C,GAAG,CACH,CAAC,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC;;;WAG1B,IAAI,CAAC,gBAAgB,CACtB,KAAK,EACL;YACC,MAAM,EAAE,qBAAqB;YAC7B,KAAK,EAAE,eAAe;YACtB,OAAO,EAAE,UAAU,CAAC;;;mBAGZ,YAAY,CAClB,+BAA+B,CAC/B;cACC;SACH,EACD,QAAQ,EACR,YAAY,CACZ;WACC,YAAY;YACd,GAAG,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC;YAC7B,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,IAAI,CAAC,gBAAgB,CACrB,KA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@ -1,133 +0,0 @@
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.actionName = void 0;
13
- exports.ComponentInput = ComponentInput;
14
- const print_arg_path_js_1 = require("./print-arg-path.js");
15
- const jdd_1 = require("@sealcode/jdd");
16
- const jdd_2 = require("@sealcode/jdd");
17
- const component_input_structured_js_1 = require("./component-input-structured.js");
18
- const component_input_list_js_1 = require("./component-input-list.js");
19
- const component_input_enum_js_1 = require("./component-input-enum.js");
20
- const component_input_image_js_1 = require("./component-input-image.js");
21
- const component_input_table_js_1 = require("./component-input-table.js");
22
- const component_input_single_reference_js_1 = require("./component-input-single-reference.js");
23
- const ts_predicates_1 = require("@sealcode/ts-predicates");
24
- exports.actionName = "Components";
25
- const absoluteUrlPattern = "http(s?)(://)((www.)?)(([^.]+).)?([a-zA-z0-9-_]+)";
26
- function ComponentInput(_a) {
27
- return __awaiter(this, arguments, void 0, function* ({ ctx, state, arg_path, arg, value, page, makeJDDContext, makeAssetURL, }) {
28
- if (value === undefined) {
29
- value = yield arg.getEmptyValue(makeJDDContext(ctx));
30
- }
31
- if (arg instanceof jdd_2.List) {
32
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
33
- return (0, component_input_list_js_1.ComponentInputList)({
34
- ctx,
35
- state,
36
- arg_path,
37
- arg,
38
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
39
- value: value,
40
- page,
41
- makeJDDContext,
42
- makeAssetURL,
43
- });
44
- }
45
- const argType = arg.getTypeName();
46
- const isUrlAbsolute = arg instanceof jdd_2.ComponentArguments.URL && arg.urlType === "absolute";
47
- const inputType = isUrlAbsolute ? "url" : "text";
48
- if (arg instanceof jdd_2.Structured) {
49
- return (0, component_input_structured_js_1.ComponentInputStructured)({
50
- ctx,
51
- state,
52
- arg_path,
53
- arg,
54
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
55
- value: value,
56
- page,
57
- makeJDDContext,
58
- makeAssetURL,
59
- });
60
- }
61
- if (arg instanceof jdd_1.SingleReference) {
62
- return (0, component_input_single_reference_js_1.ComponentInputSingleReference)({
63
- ctx,
64
- state,
65
- arg_path,
66
- arg,
67
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
68
- value: value,
69
- onchange: page.rerender(),
70
- makeJDDContext,
71
- });
72
- }
73
- if (arg instanceof jdd_2.Enum) {
74
- return (0, component_input_enum_js_1.ComponentInputEnum)({
75
- state,
76
- arg_path,
77
- arg,
78
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
79
- value: value,
80
- onchange: page.rerender(),
81
- });
82
- }
83
- if (arg instanceof jdd_2.Image) {
84
- return (0, component_input_image_js_1.ComponentInputImage)({
85
- ctx,
86
- state,
87
- arg_path,
88
- arg,
89
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
90
- value: value,
91
- page,
92
- makeJDDContext,
93
- });
94
- }
95
- if (arg instanceof jdd_2.Table) {
96
- return (0, component_input_table_js_1.ComponentInputTable)({
97
- ctx,
98
- state,
99
- arg_path,
100
- arg,
101
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
102
- value: value,
103
- page,
104
- makeJDDContext,
105
- makeAssetURL,
106
- });
107
- }
108
- return /* HTML */ `<div>
109
- <label>
110
- ${arg_path.at(-1) || ""}
111
- ${argType == "markdown"
112
- ? /* HTML */ `<div class="grow-wrap">
113
- <textarea
114
- name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}`}"
115
- onblur="${page.rerender()}"
116
- cols="40"
117
- data-controller="markdown-textarea submit-on-input"
118
- 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"
119
- autocomplete="off"
120
- >
121
- ${(0, ts_predicates_1.is)(value, ts_predicates_1.predicates.string) ? value : ""}
122
- </textarea
123
- >
124
- </div>`
125
- : /* HTML */ `<input type="${inputType}"
126
- name="${`$${(0, print_arg_path_js_1.printArgPath)(arg_path)}`}"
127
- value="${(0, ts_predicates_1.is)(value, ts_predicates_1.predicates.string) ? value : ""}" size="40"
128
- ${isUrlAbsolute ? `pattern="${absoluteUrlPattern}"` : ""}" />`}
129
- </label>
130
- </div>`;
131
- });
132
- }
133
- //# sourceMappingURL=component-input.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"component-input.js","sourceRoot":"","sources":["../../src/inputs/component-input.ts"],"names":[],"mappings":";;;;;;;;;;;;AA2BA,wCAkIC;AA7JD,2DAAmD;AAGnD,uCAAgD;AAChD,uCAOuB;AACvB,mFAA2E;AAG3E,uEAA+D;AAE/D,uEAA+D;AAC/D,yEAAiE;AACjE,yEAAiE;AAEjE,+FAAsF;AACtF,2DAAyD;AAE5C,QAAA,UAAU,GAAG,YAAY,CAAC;AACvC,MAAM,kBAAkB,GAAG,mDAAmD,CAAC;AAE/E,SAAsB,cAAc;yDAAgC,EACnE,GAAG,EACH,KAAK,EACL,QAAQ,EACR,GAAG,EACH,KAAK,EACL,IAAI,EACJ,cAAc,EACd,YAAY,GAUZ;QACA,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,KAAK,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QACtD,CAAC;QACD,IAAI,GAAG,YAAY,UAAI,EAAE,CAAC;YACzB,yEAAyE;YACzE,OAAO,IAAA,4CAAkB,EAAC;gBACzB,GAAG;gBACH,KA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;gBACzE,KAAK,EAAE,KAAoB;gBAC3B,IAAI;gBACJ,cAAc;aACd,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,GAAG,YAAY,WAAK,EAAE,CAAC;YAC1B,OAAO,IAAA,8CAAmB,EAAC;gBAC1B,GAAG;gBACH,KAAK;gBACL,QAAQ;gBACR,GAAG;gBACH,yEAAyE;gBACzE,KAAK,EAAE,KAAoC;gBAC3C,IAAI;gBACJ,cAAc;gBACd,YAAY;aACZ,CAAC,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;;KAEd,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;KACrB,OAAO,IAAI,UAAU;YACtB,CAAC,CAAC,UAAU,CAAC;;eAEF,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,EAAE;iBAC1B,IAAI,CAAC,QAAQ,EAAE;;;;;;SAMvB,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;;;aAGrC;YACT,CAAC,CAAC,UAAU,CAAC,gBAAgB,SAAS;cAC5B,IAAI,IAAA,gCAAY,EAAC,QAAQ,CAAC,EAAE;eAC3B,IAAA,kBAAE,EAAC,KAAK,EAAE,0BAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QAChD,aAAa,CAAC,CAAC,CAAC,YAAY,kBAAkB,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM;;QAE5D,CAAC;IACT,CAAC;CAAA"}
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printArgPath = printArgPath;
4
- function printArgPath(path) {
5
- return path.map((e) => `[${e}]`).join("");
6
- }
7
- //# sourceMappingURL=print-arg-path.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"print-arg-path.js","sourceRoot":"","sources":["../../src/inputs/print-arg-path.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAFD,SAAgB,YAAY,CAAC,IAAc;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -1,113 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const component_preview_actions_js_1 = require("./component-preview-actions.js");
7
- const jdd_page_js_1 = __importDefault(require("./jdd-page.js"));
8
- const escape_goat_1 = require("escape-goat");
9
- const tempstream_1 = require("tempstream");
10
- class JDDCreator extends jdd_page_js_1.default {
11
- constructor() {
12
- super(...arguments);
13
- this.actions = component_preview_actions_js_1.ComponentPreviewActions;
14
- }
15
- /**
16
- * This method returns list of components allowed in JDD Editor instance.
17
- * If list is empty it will allow all of the components in registry,
18
- * if you overide this function you can decide on what components should
19
- * available.
20
- */
21
- getAllowedComponents() {
22
- return [];
23
- }
24
- getRegistryComponents() {
25
- const all_components = super.getRegistryComponents();
26
- const allowed_components = this.getAllowedComponents();
27
- if (allowed_components.length > 0) {
28
- return Object.fromEntries(Object.entries(all_components).filter(([name]) => allowed_components.includes(name)));
29
- }
30
- return all_components;
31
- }
32
- renderParameterButtons(state) {
33
- {
34
- /*The below button has to be here in order for it to be the default behavior */
35
- }
36
- return `<div class="jdd-editor__toolbar">
37
- <input type="submit" value="Preview" />
38
- <select name="component">
39
- ${Object.keys(this.getRegistryComponents())
40
- .map((cmp) => `<option value="${cmp}">${cmp}</option>`)
41
- .join("")}
42
- </select>
43
- ${this.makeActionButton(state, {
44
- action: "add_component",
45
- label: "Add component",
46
- })}
47
- </div>`;
48
- }
49
- renderComponentBlock(ctx, state, component_data, component_index) {
50
- const component = this.getRegistryComponents()[component_data.component_name];
51
- const checkbox_id = `component_${component_index}_open`;
52
- return (0, tempstream_1.tempstream /* HTML */) `<div
53
- class="jdd-editor__component-block jdd-editor__component-block--number-${component_index}"
54
- id="${`jdd-editor__component-block--${component_data.component_name}-${component_index}`}"
55
- data-component-debugger-target="componentBlock"
56
- data-component-index="${component_index.toString()}"
57
- >
58
- <summary class="jdd-editor__component-block__top_bar">
59
- ${this.makeActionButton(state, { action: "remove_component", label: "❌" }, component_index)}
60
- ${this.makeActionButton(state, {
61
- action: "move_component_up",
62
- label: "Move this row up",
63
- content: /* HTML */ `<img
64
- width="20"
65
- height="20"
66
- src="${this.makeAssetURL("icons/table-move-row-up.svg")}"
67
- />`,
68
- }, component_index)}
69
- ${this.makeActionButton(state, {
70
- action: "move_component_down",
71
- label: "Move this row down",
72
- content: /* HTML */ `<img
73
- width="20"
74
- height="20"
75
- src="${this.makeAssetURL("icons/table-move-row-down.svg")}"
76
- />`,
77
- }, component_index)}
78
- <span class="jdd-editor__component-block__title">
79
- <div class="jdd-editor__component-block__title__main">
80
- ${(0, escape_goat_1.htmlEscape)((component === null || component === void 0 ? void 0 : component.getTitle(this.makeJDDContext(ctx), component_data.args)) || "")}
81
- </div>
82
- <div class="jdd-editor__component-block__title__secondary">
83
- ${component_data.component_name}
84
- </div>
85
- </span>
86
- <label
87
- class="component-block__handle"
88
- for="${checkbox_id}"
89
- style="flex-grow: 1"
90
- data-action="click->component-debugger#labelClicked"
91
- >
92
- <span class="jdd-editor__component-block__chevron">
93
- ${" "} &gt;${" "}
94
- </span>
95
- </label>
96
- </summary>
97
- <input
98
- type="checkbox"
99
- class="component-collapse-toggle"
100
- name="${`$[components][${component_index}][open]`}"
101
- data-turbo-permanent
102
- id="${checkbox_id}"
103
- style="display:none"
104
- data-component-debugger-target="checkbox"
105
- />
106
- <div class="jdd-editor__component-block__inner">
107
- ${super.renderComponentBlock(ctx, state, component_data, component_index)}
108
- </div>
109
- </div>`;
110
- }
111
- }
112
- exports.default = JDDCreator;
113
- //# sourceMappingURL=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