@processmaker/screen-builder 3.8.13 → 3.8.15-patch.a.1
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/vue-form-builder.css +1 -1
- package/dist/vue-form-builder.es.js +6935 -6495
- package/dist/vue-form-builder.es.js.map +1 -1
- package/dist/vue-form-builder.umd.js +51 -51
- package/dist/vue-form-builder.umd.js.map +1 -1
- package/package.json +11 -3
- package/src/components/accordions.js +1 -0
- package/src/components/inspector/index.js +1 -0
- package/src/components/inspector/validation-select.vue +3 -3
- package/src/components/inspector/variables-to-submit.vue +782 -0
- package/src/components/renderer/form-button.vue +4 -2
- package/src/components/task.vue +19 -4
- package/src/components/vue-form-renderer.vue +4 -2
- package/src/form-builder-controls.js +8 -0
- package/src/mixins/Json2Vue.js +2 -1
- package/src/mixins/ScreenBase.js +28 -3
- package/src/mixins/VariablesToSubmitFilter.js +76 -0
- package/src/mixins/index.js +1 -0
- package/src/stories/VariablesToSubmit.stories.js +686 -0
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
|
+
import "../bootstrap";
|
|
3
|
+
import VariablesToSubmit from "../components/inspector/variables-to-submit.vue";
|
|
4
|
+
|
|
5
|
+
// Mock builder object
|
|
6
|
+
const createMockBuilder = (config = [], variablesTree = [], computed = []) => ({
|
|
7
|
+
config,
|
|
8
|
+
variablesTree,
|
|
9
|
+
computed,
|
|
10
|
+
screen: {
|
|
11
|
+
computed
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// Mock form config with various field types
|
|
16
|
+
const mockFormConfig = [
|
|
17
|
+
{
|
|
18
|
+
name: "Default",
|
|
19
|
+
items: [
|
|
20
|
+
{
|
|
21
|
+
component: "FormInput",
|
|
22
|
+
"editor-component": "FormInput",
|
|
23
|
+
config: {
|
|
24
|
+
name: "index",
|
|
25
|
+
label: "Index Number"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
component: "FormInput",
|
|
30
|
+
"editor-component": "FormInput",
|
|
31
|
+
config: {
|
|
32
|
+
name: "name",
|
|
33
|
+
label: "Name"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
component: "FormInput",
|
|
38
|
+
"editor-component": "FormInput",
|
|
39
|
+
config: {
|
|
40
|
+
name: "email",
|
|
41
|
+
label: "Email"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
component: "FormMultiColumn",
|
|
46
|
+
"editor-component": "MultiColumn",
|
|
47
|
+
config: {
|
|
48
|
+
container: true
|
|
49
|
+
},
|
|
50
|
+
items: [
|
|
51
|
+
[
|
|
52
|
+
{
|
|
53
|
+
component: "FormLoop",
|
|
54
|
+
"editor-component": "Loop",
|
|
55
|
+
config: {
|
|
56
|
+
container: true,
|
|
57
|
+
settings: {
|
|
58
|
+
varname: "loop_1"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
items: [
|
|
62
|
+
{
|
|
63
|
+
component: "FormInput",
|
|
64
|
+
config: {
|
|
65
|
+
name: "loop_1.field1",
|
|
66
|
+
label: "Field 1"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
[
|
|
73
|
+
{
|
|
74
|
+
component: "FormInput",
|
|
75
|
+
config: {
|
|
76
|
+
name: "selectedName",
|
|
77
|
+
label: "Selected Name"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
component: "FormButton",
|
|
85
|
+
"editor-component": "FormButton",
|
|
86
|
+
config: {
|
|
87
|
+
name: "submitButton",
|
|
88
|
+
label: "Submit",
|
|
89
|
+
event: "submit"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
|
|
96
|
+
// Mock variables tree
|
|
97
|
+
const mockVariablesTree = [
|
|
98
|
+
{ name: "index", config: {}, element: {} },
|
|
99
|
+
{ name: "name", config: {}, element: {} },
|
|
100
|
+
{ name: "email", config: {}, element: {} },
|
|
101
|
+
{ name: "loop_1", config: {}, element: {} },
|
|
102
|
+
{ name: "selectedName", config: {}, element: {} }
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
// Mock computed properties
|
|
106
|
+
const mockComputed = [
|
|
107
|
+
{
|
|
108
|
+
id: 1,
|
|
109
|
+
property: "totalAmount",
|
|
110
|
+
name: "Total Amount",
|
|
111
|
+
formula: "price * quantity",
|
|
112
|
+
type: "expression",
|
|
113
|
+
byPass: false
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
id: 2,
|
|
117
|
+
property: "discount",
|
|
118
|
+
name: "Discount",
|
|
119
|
+
formula: "totalAmount * 0.1",
|
|
120
|
+
type: "expression",
|
|
121
|
+
byPass: false
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 3,
|
|
125
|
+
property: "bypassedCalc",
|
|
126
|
+
name: "Bypassed Calculation",
|
|
127
|
+
formula: "someFormula()",
|
|
128
|
+
type: "javascript",
|
|
129
|
+
byPass: true
|
|
130
|
+
}
|
|
131
|
+
];
|
|
132
|
+
|
|
133
|
+
// Mock selected control (submit button)
|
|
134
|
+
const mockSelectedControl = {
|
|
135
|
+
config: {
|
|
136
|
+
name: "submitButton",
|
|
137
|
+
label: "Submit",
|
|
138
|
+
event: "submit"
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default {
|
|
143
|
+
title: "Components/Inspector/VariablesToSubmit",
|
|
144
|
+
component: VariablesToSubmit,
|
|
145
|
+
tags: ["autodocs"],
|
|
146
|
+
argTypes: {
|
|
147
|
+
value: {
|
|
148
|
+
control: { type: 'object' },
|
|
149
|
+
description: 'Array of selected variable names'
|
|
150
|
+
},
|
|
151
|
+
builder: {
|
|
152
|
+
control: { type: 'object' },
|
|
153
|
+
description: 'Builder object with config, variablesTree, and computed properties'
|
|
154
|
+
},
|
|
155
|
+
formConfig: {
|
|
156
|
+
control: { type: 'object' },
|
|
157
|
+
description: 'Form configuration array'
|
|
158
|
+
},
|
|
159
|
+
selectedControl: {
|
|
160
|
+
control: { type: 'object' },
|
|
161
|
+
description: 'Currently selected control (button)'
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
render: (args, { argTypes }) => ({
|
|
165
|
+
props: Object.keys(argTypes),
|
|
166
|
+
components: { VariablesToSubmit },
|
|
167
|
+
template: `
|
|
168
|
+
<div style="max-width: 400px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 4px;">
|
|
169
|
+
<variables-to-submit
|
|
170
|
+
v-bind="$props"
|
|
171
|
+
v-model="selectedVariables"
|
|
172
|
+
@input="handleInput"
|
|
173
|
+
@change="handleChange"
|
|
174
|
+
/>
|
|
175
|
+
</div>
|
|
176
|
+
`,
|
|
177
|
+
data() {
|
|
178
|
+
return {
|
|
179
|
+
selectedVariables: args.value || []
|
|
180
|
+
};
|
|
181
|
+
},
|
|
182
|
+
methods: {
|
|
183
|
+
handleInput(value) {
|
|
184
|
+
this.selectedVariables = value;
|
|
185
|
+
console.log('Input event:', value);
|
|
186
|
+
},
|
|
187
|
+
handleChange(value) {
|
|
188
|
+
console.log('Change event:', value);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
watch: {
|
|
192
|
+
value(newValue) {
|
|
193
|
+
this.selectedVariables = newValue || [];
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Stories of the component
|
|
201
|
+
*/
|
|
202
|
+
|
|
203
|
+
// Basic preview with default variables
|
|
204
|
+
export const Preview = {
|
|
205
|
+
args: {
|
|
206
|
+
value: [],
|
|
207
|
+
builder: createMockBuilder(mockFormConfig, mockVariablesTree, mockComputed),
|
|
208
|
+
formConfig: mockFormConfig,
|
|
209
|
+
selectedControl: mockSelectedControl
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// With some variables pre-selected
|
|
214
|
+
export const WithPreSelectedVariables = {
|
|
215
|
+
args: {
|
|
216
|
+
value: ["index", "name", "totalAmount"],
|
|
217
|
+
builder: createMockBuilder(mockFormConfig, mockVariablesTree, mockComputed),
|
|
218
|
+
formConfig: mockFormConfig,
|
|
219
|
+
selectedControl: mockSelectedControl
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
// With toggle enabled
|
|
224
|
+
export const ToggleEnabled = {
|
|
225
|
+
args: {
|
|
226
|
+
value: ["index", "email"],
|
|
227
|
+
builder: createMockBuilder(mockFormConfig, mockVariablesTree, mockComputed),
|
|
228
|
+
formConfig: mockFormConfig,
|
|
229
|
+
selectedControl: mockSelectedControl
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
// With calculated variables only
|
|
234
|
+
export const WithCalculatedVariables = {
|
|
235
|
+
args: {
|
|
236
|
+
value: [],
|
|
237
|
+
builder: createMockBuilder([], [], mockComputed),
|
|
238
|
+
formConfig: [],
|
|
239
|
+
selectedControl: mockSelectedControl
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// With no variables available
|
|
244
|
+
export const NoVariablesAvailable = {
|
|
245
|
+
args: {
|
|
246
|
+
value: [],
|
|
247
|
+
builder: createMockBuilder([], [], []),
|
|
248
|
+
formConfig: [],
|
|
249
|
+
selectedControl: mockSelectedControl
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// With variables from containers
|
|
254
|
+
export const WithContainerVariables = {
|
|
255
|
+
args: {
|
|
256
|
+
value: [],
|
|
257
|
+
builder: createMockBuilder(mockFormConfig, mockVariablesTree, []),
|
|
258
|
+
formConfig: mockFormConfig,
|
|
259
|
+
selectedControl: mockSelectedControl
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// All variables selected
|
|
264
|
+
export const AllVariablesSelected = {
|
|
265
|
+
args: {
|
|
266
|
+
value: ["index", "name", "email", "loop_1", "loop_1.field1", "selectedName", "totalAmount", "submitButton", "discount"],
|
|
267
|
+
builder: createMockBuilder(mockFormConfig, mockVariablesTree, mockComputed),
|
|
268
|
+
formConfig: mockFormConfig,
|
|
269
|
+
selectedControl: mockSelectedControl
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Mock nested screen configuration
|
|
274
|
+
const mockNestedScreenConfig = [
|
|
275
|
+
{
|
|
276
|
+
name: "Nested Page 1",
|
|
277
|
+
items: [
|
|
278
|
+
{
|
|
279
|
+
component: "FormInput",
|
|
280
|
+
config: {
|
|
281
|
+
name: "nestedFirstName",
|
|
282
|
+
label: "First Name (Nested)"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
component: "FormInput",
|
|
287
|
+
config: {
|
|
288
|
+
name: "nestedLastName",
|
|
289
|
+
label: "Last Name (Nested)"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
component: "FormInput",
|
|
294
|
+
config: {
|
|
295
|
+
name: "nestedEmail",
|
|
296
|
+
label: "Email (Nested)"
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
name: "Nested Page 2",
|
|
303
|
+
items: [
|
|
304
|
+
{
|
|
305
|
+
component: "FormInput",
|
|
306
|
+
config: {
|
|
307
|
+
name: "nestedPhone",
|
|
308
|
+
label: "Phone (Nested)"
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
component: "FormInput",
|
|
313
|
+
config: {
|
|
314
|
+
name: "nestedAddress",
|
|
315
|
+
label: "Address (Nested)"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
}
|
|
320
|
+
];
|
|
321
|
+
|
|
322
|
+
// Form config with nested screen
|
|
323
|
+
const mockFormConfigWithNested = [
|
|
324
|
+
{
|
|
325
|
+
name: "Default",
|
|
326
|
+
items: [
|
|
327
|
+
{
|
|
328
|
+
component: "FormInput",
|
|
329
|
+
config: {
|
|
330
|
+
name: "mainField1",
|
|
331
|
+
label: "Main Field 1"
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
component: "FormInput",
|
|
336
|
+
config: {
|
|
337
|
+
name: "mainField2",
|
|
338
|
+
label: "Main Field 2"
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
component: "FormNestedScreen",
|
|
343
|
+
config: {
|
|
344
|
+
name: "nestedScreen",
|
|
345
|
+
label: "Nested Screen",
|
|
346
|
+
screen: 123 // This ID will be used to lookup in window.nestedScreens
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
component: "FormInput",
|
|
351
|
+
config: {
|
|
352
|
+
name: "mainField3",
|
|
353
|
+
label: "Main Field 3"
|
|
354
|
+
}
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
component: "FormButton",
|
|
358
|
+
config: {
|
|
359
|
+
name: "submitButton",
|
|
360
|
+
label: "Submit",
|
|
361
|
+
event: "submit"
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
];
|
|
367
|
+
|
|
368
|
+
// Variables tree including nested screen variables
|
|
369
|
+
const mockVariablesTreeWithNested = [
|
|
370
|
+
{ name: "mainField1", config: {}, element: {} },
|
|
371
|
+
{ name: "mainField2", config: {}, element: {} },
|
|
372
|
+
{ name: "mainField3", config: {}, element: {} },
|
|
373
|
+
{ name: "nestedFirstName", config: {}, element: {} },
|
|
374
|
+
{ name: "nestedLastName", config: {}, element: {} },
|
|
375
|
+
{ name: "nestedEmail", config: {}, element: {} },
|
|
376
|
+
{ name: "nestedPhone", config: {}, element: {} },
|
|
377
|
+
{ name: "nestedAddress", config: {}, element: {} }
|
|
378
|
+
];
|
|
379
|
+
|
|
380
|
+
// Story with nested screen
|
|
381
|
+
export const WithNestedScreen = {
|
|
382
|
+
args: {
|
|
383
|
+
value: [],
|
|
384
|
+
builder: createMockBuilder(mockFormConfigWithNested, mockVariablesTreeWithNested, []),
|
|
385
|
+
formConfig: mockFormConfigWithNested,
|
|
386
|
+
selectedControl: mockSelectedControl
|
|
387
|
+
},
|
|
388
|
+
render: (args, { argTypes }) => ({
|
|
389
|
+
props: Object.keys(argTypes),
|
|
390
|
+
components: { VariablesToSubmit },
|
|
391
|
+
template: `
|
|
392
|
+
<div style="max-width: 400px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 4px;">
|
|
393
|
+
<div style="margin-bottom: 15px; padding: 10px; background: #f0f8ff; border-radius: 4px;">
|
|
394
|
+
<strong>📦 Nested Screen Story</strong>
|
|
395
|
+
<p style="margin: 5px 0; font-size: 12px; color: #666;">
|
|
396
|
+
This story demonstrates variables from a FormNestedScreen.
|
|
397
|
+
The nested screen contains variables like <code>nestedFirstName</code>,
|
|
398
|
+
<code>nestedLastName</code>, etc.
|
|
399
|
+
</p>
|
|
400
|
+
</div>
|
|
401
|
+
<variables-to-submit
|
|
402
|
+
v-bind="$props"
|
|
403
|
+
v-model="selectedVariables"
|
|
404
|
+
@input="handleInput"
|
|
405
|
+
@change="handleChange"
|
|
406
|
+
/>
|
|
407
|
+
<div style="margin-top: 15px; padding: 10px; background: #f9f9f9; border-radius: 4px;">
|
|
408
|
+
<strong>Selected Variables:</strong>
|
|
409
|
+
<pre style="margin: 5px 0; font-size: 11px; overflow-x: auto;">{{ selectedVariables }}</pre>
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
`,
|
|
413
|
+
data() {
|
|
414
|
+
return {
|
|
415
|
+
selectedVariables: args.value || []
|
|
416
|
+
};
|
|
417
|
+
},
|
|
418
|
+
methods: {
|
|
419
|
+
handleInput(value) {
|
|
420
|
+
this.selectedVariables = value;
|
|
421
|
+
console.log('Input event:', value);
|
|
422
|
+
},
|
|
423
|
+
handleChange(value) {
|
|
424
|
+
console.log('Change event:', value);
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
watch: {
|
|
428
|
+
value(newValue) {
|
|
429
|
+
this.selectedVariables = newValue || [];
|
|
430
|
+
}
|
|
431
|
+
},
|
|
432
|
+
created() {
|
|
433
|
+
// Setup window.nestedScreens for nested screen component
|
|
434
|
+
if (typeof window !== 'undefined') {
|
|
435
|
+
if (!window.nestedScreens) {
|
|
436
|
+
window.nestedScreens = {};
|
|
437
|
+
}
|
|
438
|
+
// Store the nested screen config with ID 123 (matching the screen ID in config)
|
|
439
|
+
window.nestedScreens['id_123'] = mockNestedScreenConfig;
|
|
440
|
+
console.log('✅ Nested screen data loaded:', window.nestedScreens);
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
beforeDestroy() {
|
|
444
|
+
// Cleanup
|
|
445
|
+
if (typeof window !== 'undefined' && window.nestedScreens) {
|
|
446
|
+
delete window.nestedScreens['id_123'];
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
})
|
|
450
|
+
};
|
|
451
|
+
|
|
452
|
+
// Story with nested screen and some variables pre-selected
|
|
453
|
+
export const WithNestedScreenPreSelected = {
|
|
454
|
+
args: {
|
|
455
|
+
value: ["mainField1", "nestedFirstName", "nestedEmail"],
|
|
456
|
+
builder: createMockBuilder(mockFormConfigWithNested, mockVariablesTreeWithNested, []),
|
|
457
|
+
formConfig: mockFormConfigWithNested,
|
|
458
|
+
selectedControl: mockSelectedControl
|
|
459
|
+
},
|
|
460
|
+
render: (args, { argTypes }) => ({
|
|
461
|
+
props: Object.keys(argTypes),
|
|
462
|
+
components: { VariablesToSubmit },
|
|
463
|
+
template: `
|
|
464
|
+
<div style="max-width: 400px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 4px;">
|
|
465
|
+
<div style="margin-bottom: 15px; padding: 10px; background: #e8f5e9; border-radius: 4px;">
|
|
466
|
+
<strong>✅ Nested Screen with Pre-Selected Variables</strong>
|
|
467
|
+
<p style="margin: 5px 0; font-size: 12px; color: #666;">
|
|
468
|
+
Main fields + Nested screen fields are pre-selected.
|
|
469
|
+
</p>
|
|
470
|
+
</div>
|
|
471
|
+
<variables-to-submit
|
|
472
|
+
v-bind="$props"
|
|
473
|
+
v-model="selectedVariables"
|
|
474
|
+
@input="handleInput"
|
|
475
|
+
@change="handleChange"
|
|
476
|
+
/>
|
|
477
|
+
<div style="margin-top: 15px; padding: 10px; background: #f9f9f9; border-radius: 4px;">
|
|
478
|
+
<strong>Selected Variables:</strong>
|
|
479
|
+
<pre style="margin: 5px 0; font-size: 11px; overflow-x: auto;">{{ selectedVariables }}</pre>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
`,
|
|
483
|
+
data() {
|
|
484
|
+
return {
|
|
485
|
+
selectedVariables: args.value || []
|
|
486
|
+
};
|
|
487
|
+
},
|
|
488
|
+
methods: {
|
|
489
|
+
handleInput(value) {
|
|
490
|
+
this.selectedVariables = value;
|
|
491
|
+
console.log('Input event:', value);
|
|
492
|
+
},
|
|
493
|
+
handleChange(value) {
|
|
494
|
+
console.log('Change event:', value);
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
watch: {
|
|
498
|
+
value(newValue) {
|
|
499
|
+
this.selectedVariables = newValue || [];
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
created() {
|
|
503
|
+
if (typeof window !== 'undefined') {
|
|
504
|
+
if (!window.nestedScreens) {
|
|
505
|
+
window.nestedScreens = {};
|
|
506
|
+
}
|
|
507
|
+
window.nestedScreens['id_123'] = mockNestedScreenConfig;
|
|
508
|
+
console.log('✅ Nested screen data loaded:', window.nestedScreens);
|
|
509
|
+
}
|
|
510
|
+
},
|
|
511
|
+
beforeDestroy() {
|
|
512
|
+
if (typeof window !== 'undefined' && window.nestedScreens) {
|
|
513
|
+
delete window.nestedScreens['id_123'];
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
})
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
// Story with multiple nested screens
|
|
520
|
+
const mockFormConfigWithMultipleNested = [
|
|
521
|
+
{
|
|
522
|
+
name: "Default",
|
|
523
|
+
items: [
|
|
524
|
+
{
|
|
525
|
+
component: "FormInput",
|
|
526
|
+
config: {
|
|
527
|
+
name: "mainField",
|
|
528
|
+
label: "Main Field"
|
|
529
|
+
}
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
component: "FormNestedScreen",
|
|
533
|
+
config: {
|
|
534
|
+
name: "nestedScreen1",
|
|
535
|
+
label: "Contact Information",
|
|
536
|
+
screen: 100
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
component: "FormNestedScreen",
|
|
541
|
+
config: {
|
|
542
|
+
name: "nestedScreen2",
|
|
543
|
+
label: "Address Information",
|
|
544
|
+
screen: 200
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
component: "FormButton",
|
|
549
|
+
config: {
|
|
550
|
+
name: "submitButton",
|
|
551
|
+
label: "Submit",
|
|
552
|
+
event: "submit"
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
]
|
|
556
|
+
}
|
|
557
|
+
];
|
|
558
|
+
|
|
559
|
+
const mockNestedScreen1Config = [
|
|
560
|
+
{
|
|
561
|
+
name: "Contact",
|
|
562
|
+
items: [
|
|
563
|
+
{
|
|
564
|
+
component: "FormInput",
|
|
565
|
+
config: {
|
|
566
|
+
name: "contactEmail",
|
|
567
|
+
label: "Email"
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
component: "FormInput",
|
|
572
|
+
config: {
|
|
573
|
+
name: "contactPhone",
|
|
574
|
+
label: "Phone"
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
]
|
|
578
|
+
}
|
|
579
|
+
];
|
|
580
|
+
|
|
581
|
+
const mockNestedScreen2Config = [
|
|
582
|
+
{
|
|
583
|
+
name: "Address",
|
|
584
|
+
items: [
|
|
585
|
+
{
|
|
586
|
+
component: "FormInput",
|
|
587
|
+
config: {
|
|
588
|
+
name: "street",
|
|
589
|
+
label: "Street"
|
|
590
|
+
}
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
component: "FormInput",
|
|
594
|
+
config: {
|
|
595
|
+
name: "city",
|
|
596
|
+
label: "City"
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
component: "FormInput",
|
|
601
|
+
config: {
|
|
602
|
+
name: "zipCode",
|
|
603
|
+
label: "ZIP Code"
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
]
|
|
607
|
+
}
|
|
608
|
+
];
|
|
609
|
+
|
|
610
|
+
const mockVariablesTreeMultipleNested = [
|
|
611
|
+
{ name: "mainField", config: {}, element: {} },
|
|
612
|
+
{ name: "contactEmail", config: {}, element: {} },
|
|
613
|
+
{ name: "contactPhone", config: {}, element: {} },
|
|
614
|
+
{ name: "street", config: {}, element: {} },
|
|
615
|
+
{ name: "city", config: {}, element: {} },
|
|
616
|
+
{ name: "zipCode", config: {}, element: {} }
|
|
617
|
+
];
|
|
618
|
+
|
|
619
|
+
export const WithMultipleNestedScreens = {
|
|
620
|
+
args: {
|
|
621
|
+
value: [],
|
|
622
|
+
builder: createMockBuilder(mockFormConfigWithMultipleNested, mockVariablesTreeMultipleNested, []),
|
|
623
|
+
formConfig: mockFormConfigWithMultipleNested,
|
|
624
|
+
selectedControl: mockSelectedControl
|
|
625
|
+
},
|
|
626
|
+
render: (args, { argTypes }) => ({
|
|
627
|
+
props: Object.keys(argTypes),
|
|
628
|
+
components: { VariablesToSubmit },
|
|
629
|
+
template: `
|
|
630
|
+
<div style="max-width: 400px; padding: 20px; border: 1px solid #e0e0e0; border-radius: 4px;">
|
|
631
|
+
<div style="margin-bottom: 15px; padding: 10px; background: #fff3e0; border-radius: 4px;">
|
|
632
|
+
<strong>🔗 Multiple Nested Screens</strong>
|
|
633
|
+
<p style="margin: 5px 0; font-size: 12px; color: #666;">
|
|
634
|
+
Form with two nested screens: Contact Info and Address Info.
|
|
635
|
+
</p>
|
|
636
|
+
</div>
|
|
637
|
+
<variables-to-submit
|
|
638
|
+
v-bind="$props"
|
|
639
|
+
v-model="selectedVariables"
|
|
640
|
+
@input="handleInput"
|
|
641
|
+
@change="handleChange"
|
|
642
|
+
/>
|
|
643
|
+
<div style="margin-top: 15px; padding: 10px; background: #f9f9f9; border-radius: 4px;">
|
|
644
|
+
<strong>Selected Variables:</strong>
|
|
645
|
+
<pre style="margin: 5px 0; font-size: 11px; overflow-x: auto;">{{ selectedVariables }}</pre>
|
|
646
|
+
</div>
|
|
647
|
+
</div>
|
|
648
|
+
`,
|
|
649
|
+
data() {
|
|
650
|
+
return {
|
|
651
|
+
selectedVariables: args.value || []
|
|
652
|
+
};
|
|
653
|
+
},
|
|
654
|
+
methods: {
|
|
655
|
+
handleInput(value) {
|
|
656
|
+
this.selectedVariables = value;
|
|
657
|
+
console.log('Input event:', value);
|
|
658
|
+
},
|
|
659
|
+
handleChange(value) {
|
|
660
|
+
console.log('Change event:', value);
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
watch: {
|
|
664
|
+
value(newValue) {
|
|
665
|
+
this.selectedVariables = newValue || [];
|
|
666
|
+
}
|
|
667
|
+
},
|
|
668
|
+
created() {
|
|
669
|
+
if (typeof window !== 'undefined') {
|
|
670
|
+
if (!window.nestedScreens) {
|
|
671
|
+
window.nestedScreens = {};
|
|
672
|
+
}
|
|
673
|
+
window.nestedScreens['id_100'] = mockNestedScreen1Config;
|
|
674
|
+
window.nestedScreens['id_200'] = mockNestedScreen2Config;
|
|
675
|
+
console.log('✅ Multiple nested screens loaded:', window.nestedScreens);
|
|
676
|
+
}
|
|
677
|
+
},
|
|
678
|
+
beforeDestroy() {
|
|
679
|
+
if (typeof window !== 'undefined' && window.nestedScreens) {
|
|
680
|
+
delete window.nestedScreens['id_100'];
|
|
681
|
+
delete window.nestedScreens['id_200'];
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
})
|
|
685
|
+
};
|
|
686
|
+
|