@dmitryvim/form-builder 0.1.31 → 0.1.34
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/dist/demo.js +88 -11
- package/dist/elements.html +1151 -0
- package/dist/elements.js +488 -0
- package/dist/form-builder.js +1868 -298
- package/dist/index.html +29 -1
- package/package.json +9 -4
- package/dist/images/final_video.mp4 +0 -0
- package/dist/images/infographic_draft.jpg +0 -0
package/dist/demo.js
CHANGED
|
@@ -25,18 +25,19 @@ const EXAMPLE_SCHEMA = {
|
|
|
25
25
|
],
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
|
-
type: "
|
|
28
|
+
type: "file",
|
|
29
29
|
key: "assets",
|
|
30
30
|
label: "Другие изображения",
|
|
31
31
|
description:
|
|
32
32
|
"Additional images that provide context, show different angles, or demonstrate product usage. These will be used to enhance the infographic composition.",
|
|
33
33
|
required: false,
|
|
34
|
+
multiple: true,
|
|
35
|
+
minCount: 0,
|
|
36
|
+
maxCount: 10,
|
|
34
37
|
accept: {
|
|
35
38
|
extensions: ["png", "jpg", "gif"],
|
|
36
39
|
mime: ["image/png", "image/jpeg", "image/gif"],
|
|
37
40
|
},
|
|
38
|
-
minCount: 0,
|
|
39
|
-
maxCount: 10,
|
|
40
41
|
maxSizeMB: 5,
|
|
41
42
|
},
|
|
42
43
|
{
|
|
@@ -47,6 +48,9 @@ const EXAMPLE_SCHEMA = {
|
|
|
47
48
|
description:
|
|
48
49
|
"The exact product name as it should appear on the infographic. Use the official product name without marketing terms or decorative elements.",
|
|
49
50
|
required: true,
|
|
51
|
+
multiple: true,
|
|
52
|
+
minCount: 1,
|
|
53
|
+
maxCount: 4,
|
|
50
54
|
minLength: 1,
|
|
51
55
|
maxLength: 100,
|
|
52
56
|
pattern: "^[A-Za-zА-Яа-я0-9 _*-]+$",
|
|
@@ -97,6 +101,69 @@ const EXAMPLE_SCHEMA = {
|
|
|
97
101
|
step: 0.01,
|
|
98
102
|
default: 0.5,
|
|
99
103
|
},
|
|
104
|
+
{
|
|
105
|
+
type: "text",
|
|
106
|
+
key: "tags",
|
|
107
|
+
label: "Теги товара",
|
|
108
|
+
description: "Добавьте ключевые теги для лучшего описания товара",
|
|
109
|
+
placeholder: "Введите тег",
|
|
110
|
+
required: false,
|
|
111
|
+
multiple: true,
|
|
112
|
+
minCount: 1,
|
|
113
|
+
maxCount: 5,
|
|
114
|
+
minLength: 2,
|
|
115
|
+
maxLength: 20,
|
|
116
|
+
default: "popular",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: "textarea",
|
|
120
|
+
key: "features",
|
|
121
|
+
label: "Особенности товара",
|
|
122
|
+
description: "Опишите ключевые особенности и преимущества товара",
|
|
123
|
+
placeholder: "Опишите особенность...",
|
|
124
|
+
required: false,
|
|
125
|
+
multiple: true,
|
|
126
|
+
minCount: 2,
|
|
127
|
+
maxCount: 4,
|
|
128
|
+
minLength: 10,
|
|
129
|
+
maxLength: 200,
|
|
130
|
+
rows: 3,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: "number",
|
|
134
|
+
key: "dimensions",
|
|
135
|
+
label: "Размеры (см)",
|
|
136
|
+
description:
|
|
137
|
+
"Укажите размеры товара в сантиметрах: длина, ширина, высота",
|
|
138
|
+
placeholder: "0",
|
|
139
|
+
required: false,
|
|
140
|
+
multiple: true,
|
|
141
|
+
minCount: 2,
|
|
142
|
+
maxCount: 3,
|
|
143
|
+
min: 0,
|
|
144
|
+
max: 500,
|
|
145
|
+
step: 0.1,
|
|
146
|
+
decimals: 1,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: "select",
|
|
150
|
+
key: "colors",
|
|
151
|
+
label: "Доступные цвета",
|
|
152
|
+
description: "Выберите доступные цветовые варианты товара",
|
|
153
|
+
required: false,
|
|
154
|
+
multiple: true,
|
|
155
|
+
minCount: 1,
|
|
156
|
+
maxCount: 3,
|
|
157
|
+
options: [
|
|
158
|
+
{ value: "white", label: "Белый" },
|
|
159
|
+
{ value: "black", label: "Черный" },
|
|
160
|
+
{ value: "red", label: "Красный" },
|
|
161
|
+
{ value: "blue", label: "Синий" },
|
|
162
|
+
{ value: "green", label: "Зеленый" },
|
|
163
|
+
{ value: "gray", label: "Серый" },
|
|
164
|
+
],
|
|
165
|
+
default: "white",
|
|
166
|
+
},
|
|
100
167
|
{
|
|
101
168
|
type: "file",
|
|
102
169
|
key: "video",
|
|
@@ -111,12 +178,14 @@ const EXAMPLE_SCHEMA = {
|
|
|
111
178
|
maxSizeMB: 50,
|
|
112
179
|
},
|
|
113
180
|
{
|
|
114
|
-
type: "
|
|
181
|
+
type: "container",
|
|
115
182
|
key: "slides",
|
|
116
183
|
label: "Слайды",
|
|
117
184
|
description:
|
|
118
185
|
"Additional slides to showcase different aspects of your product. Each slide can have its own main image and decorative elements to create a comprehensive infographic presentation.",
|
|
119
|
-
|
|
186
|
+
multiple: true,
|
|
187
|
+
minCount: 1,
|
|
188
|
+
maxCount: 5,
|
|
120
189
|
elements: [
|
|
121
190
|
{
|
|
122
191
|
type: "text",
|
|
@@ -140,6 +209,14 @@ const EXAMPLE_SCHEMA = {
|
|
|
140
209
|
},
|
|
141
210
|
],
|
|
142
211
|
},
|
|
212
|
+
{
|
|
213
|
+
type: "text",
|
|
214
|
+
key: "session_id",
|
|
215
|
+
label: "Session ID",
|
|
216
|
+
description: "Hidden session identifier for tracking purposes",
|
|
217
|
+
hidden: true,
|
|
218
|
+
default: "session_" + Math.random().toString(36).substr(2, 9),
|
|
219
|
+
},
|
|
143
220
|
],
|
|
144
221
|
};
|
|
145
222
|
|
|
@@ -252,10 +329,10 @@ let actionLabelMap = new Map();
|
|
|
252
329
|
// Build action value -> label mapping from schema for efficient lookup
|
|
253
330
|
function buildActionLabelMap(schema) {
|
|
254
331
|
const map = new Map();
|
|
255
|
-
|
|
332
|
+
|
|
256
333
|
function processElements(elements) {
|
|
257
334
|
if (!Array.isArray(elements)) return;
|
|
258
|
-
|
|
335
|
+
|
|
259
336
|
for (const element of elements) {
|
|
260
337
|
if (element.actions && Array.isArray(element.actions)) {
|
|
261
338
|
for (const action of element.actions) {
|
|
@@ -264,18 +341,18 @@ function buildActionLabelMap(schema) {
|
|
|
264
341
|
}
|
|
265
342
|
}
|
|
266
343
|
}
|
|
267
|
-
|
|
344
|
+
|
|
268
345
|
// Process nested group elements
|
|
269
346
|
if (element.elements && Array.isArray(element.elements)) {
|
|
270
347
|
processElements(element.elements);
|
|
271
348
|
}
|
|
272
349
|
}
|
|
273
350
|
}
|
|
274
|
-
|
|
351
|
+
|
|
275
352
|
if (schema && schema.elements) {
|
|
276
353
|
processElements(schema.elements);
|
|
277
354
|
}
|
|
278
|
-
|
|
355
|
+
|
|
279
356
|
return map;
|
|
280
357
|
}
|
|
281
358
|
|
|
@@ -366,7 +443,7 @@ function setupFormBuilder() {
|
|
|
366
443
|
const actionLabel = actionLabelMap.get(value) || value; // fallback to value
|
|
367
444
|
|
|
368
445
|
console.log("Action clicked:", { label: actionLabel, value });
|
|
369
|
-
|
|
446
|
+
|
|
370
447
|
// Show message to user (compatible with all environments)
|
|
371
448
|
if (typeof window !== "undefined" && window.alert) {
|
|
372
449
|
window.alert(`${actionLabel} clicked: ${value}`);
|