@surveystudio/node-registery 1.4.0 → 1.5.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/README.md +13 -2
- package/dist/builder.d.mts +431 -5
- package/dist/builder.mjs +421 -20
- package/dist/{coreTypes-YSpR0Oyh.d.mts → coreTypes-D5NniS2n.d.mts} +5 -0
- package/dist/logic.d.mts +31 -4
- package/dist/logic.mjs +549 -25
- package/dist/runner.d.mts +2 -2
- package/dist/{types-CgiAR_DF.d.mts → types-BMMQVXYP.d.mts} +1 -1
- package/dist/types-D3jarfsb.d.mts +265 -0
- package/package.json +1 -1
- package/dist/types-CR3fIHCT.d.mts +0 -151
package/dist/logic.mjs
CHANGED
|
@@ -67,17 +67,354 @@ var plainTextLogic = {
|
|
|
67
67
|
]
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
// src/nodes/
|
|
70
|
+
// src/nodes/captcha/manifest.ts
|
|
71
71
|
var defaultCondition = {
|
|
72
72
|
id: "root",
|
|
73
73
|
type: "group",
|
|
74
74
|
logicType: "AND",
|
|
75
75
|
children: []
|
|
76
76
|
};
|
|
77
|
+
var captchaDefaultData = {
|
|
78
|
+
label: "Captcha",
|
|
79
|
+
description: "",
|
|
80
|
+
isPii: false,
|
|
81
|
+
condition: defaultCondition,
|
|
82
|
+
sitekey: ""
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/nodes/captcha/logic.ts
|
|
86
|
+
var normalizeCaptchaValue = (rawValue) => typeof rawValue === "string" ? rawValue : "";
|
|
87
|
+
var captchaLogic = {
|
|
88
|
+
type: "captcha",
|
|
89
|
+
dataType: "text",
|
|
90
|
+
defaultData: captchaDefaultData,
|
|
91
|
+
defaultValue: "",
|
|
92
|
+
normalizeValue: normalizeCaptchaValue,
|
|
93
|
+
validate: (value) => value ? { valid: true } : { valid: false, error: "Captcha verification is required" },
|
|
94
|
+
extractValue: () => []
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/nodes/emojiRating/manifest.ts
|
|
98
|
+
var defaultCondition2 = {
|
|
99
|
+
id: "root",
|
|
100
|
+
type: "group",
|
|
101
|
+
logicType: "AND",
|
|
102
|
+
children: []
|
|
103
|
+
};
|
|
104
|
+
var emojiRatingDefaultData = {
|
|
105
|
+
label: "Emoji Rating",
|
|
106
|
+
description: "",
|
|
107
|
+
isPii: false,
|
|
108
|
+
condition: defaultCondition2,
|
|
109
|
+
options: [
|
|
110
|
+
{ label: "Angry", value: "\u{1F620}" },
|
|
111
|
+
{ label: "Sad", value: "\u{1F641}" },
|
|
112
|
+
{ label: "Neutral", value: "\u{1F610}" },
|
|
113
|
+
{ label: "Happy", value: "\u{1F642}" },
|
|
114
|
+
{ label: "Love", value: "\u{1F60D}" }
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/nodes/emojiRating/logic.ts
|
|
119
|
+
var normalizeEmojiValue = (rawValue) => {
|
|
120
|
+
if (typeof rawValue === "string") return rawValue;
|
|
121
|
+
if (typeof rawValue === "number" || typeof rawValue === "boolean") return String(rawValue);
|
|
122
|
+
return "";
|
|
123
|
+
};
|
|
124
|
+
var optionsFor = (nodeData) => Array.isArray(nodeData.options) ? nodeData.options : [];
|
|
125
|
+
var optionForValue = (nodeData, value) => optionsFor(nodeData).find((option) => option.exportId === value || option.value === value || option.id === value);
|
|
126
|
+
var optionId = (option, value) => option?.exportId || option?.value || option?.id || value;
|
|
127
|
+
var optionText = (option, value) => option?.value || option?.label || value;
|
|
128
|
+
var extractEmojiRatingValue = (value, nodeData) => {
|
|
129
|
+
if (!value) return [];
|
|
130
|
+
const option = optionForValue(nodeData, value);
|
|
131
|
+
return [{
|
|
132
|
+
optionUuid: optionId(option, value),
|
|
133
|
+
optionText: option?.label || optionText(option, value),
|
|
134
|
+
textValue: optionText(option, value)
|
|
135
|
+
}];
|
|
136
|
+
};
|
|
137
|
+
var emojiRatingLogic = {
|
|
138
|
+
type: "emojiRating",
|
|
139
|
+
dataType: "option",
|
|
140
|
+
defaultData: emojiRatingDefaultData,
|
|
141
|
+
defaultValue: "",
|
|
142
|
+
normalizeValue: normalizeEmojiValue,
|
|
143
|
+
validate: (value, nodeData) => {
|
|
144
|
+
if (!value) return { valid: true };
|
|
145
|
+
if (optionsFor(nodeData).length === 0) return { valid: true };
|
|
146
|
+
return optionForValue(nodeData, value) ? { valid: true } : { valid: false, error: "Selected emoji is not available" };
|
|
147
|
+
},
|
|
148
|
+
extractValue: extractEmojiRatingValue
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/nodes/media/manifest.ts
|
|
152
|
+
var defaultCondition3 = {
|
|
153
|
+
id: "root",
|
|
154
|
+
type: "group",
|
|
155
|
+
logicType: "AND",
|
|
156
|
+
children: []
|
|
157
|
+
};
|
|
158
|
+
var interactionOptions = [
|
|
159
|
+
{ label: "None (Display Only)", value: "none" },
|
|
160
|
+
{ label: "Text Question", value: "text" },
|
|
161
|
+
{ label: "Slider Rating", value: "slider" },
|
|
162
|
+
{ label: "Multiple Choice", value: "choice" }
|
|
163
|
+
];
|
|
164
|
+
var mediaCommonData = {
|
|
165
|
+
label: "",
|
|
166
|
+
description: "",
|
|
167
|
+
isPii: false,
|
|
168
|
+
condition: defaultCondition3,
|
|
169
|
+
interactionType: "none",
|
|
170
|
+
questionLabel: "",
|
|
171
|
+
sliderConfig: "0-10",
|
|
172
|
+
choices: []
|
|
173
|
+
};
|
|
174
|
+
var mediaInteractionProperties = [
|
|
175
|
+
{
|
|
176
|
+
name: "interactionType",
|
|
177
|
+
label: "Enable Interaction",
|
|
178
|
+
type: "select",
|
|
179
|
+
defaultValue: "none",
|
|
180
|
+
options: interactionOptions,
|
|
181
|
+
helperText: "Add a question below this media"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
name: "questionLabel",
|
|
185
|
+
label: "Question / Text",
|
|
186
|
+
type: "text",
|
|
187
|
+
placeholder: "Type your text here...",
|
|
188
|
+
visible: (data) => data.interactionType === "text"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "sliderConfig",
|
|
192
|
+
label: "Slider Config (Min-Max)",
|
|
193
|
+
type: "text",
|
|
194
|
+
placeholder: "0-10",
|
|
195
|
+
visible: (data) => data.interactionType === "slider"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: "choices",
|
|
199
|
+
label: "Choices",
|
|
200
|
+
type: "options",
|
|
201
|
+
defaultValue: [],
|
|
202
|
+
visible: (data) => data.interactionType === "choice"
|
|
203
|
+
}
|
|
204
|
+
];
|
|
205
|
+
var imageDefaultData = {
|
|
206
|
+
...mediaCommonData,
|
|
207
|
+
label: "Image",
|
|
208
|
+
urls: [],
|
|
209
|
+
alt: ""
|
|
210
|
+
};
|
|
211
|
+
var videoDefaultData = {
|
|
212
|
+
...mediaCommonData,
|
|
213
|
+
label: "Video",
|
|
214
|
+
url: "",
|
|
215
|
+
autoplay: false
|
|
216
|
+
};
|
|
217
|
+
var audioDefaultData = {
|
|
218
|
+
...mediaCommonData,
|
|
219
|
+
label: "Audio",
|
|
220
|
+
url: "",
|
|
221
|
+
autoplay: false
|
|
222
|
+
};
|
|
223
|
+
var imageManifest = {
|
|
224
|
+
type: "image",
|
|
225
|
+
label: "Image",
|
|
226
|
+
description: "Display an image",
|
|
227
|
+
category: "media",
|
|
228
|
+
dataType: "object",
|
|
229
|
+
defaultData: imageDefaultData,
|
|
230
|
+
properties: [
|
|
231
|
+
{ name: "label", label: "Field Label", type: "text", placeholder: "e.g., Product image" },
|
|
232
|
+
{ name: "description", label: "Description", type: "textarea", placeholder: "Helper text for the user", defaultValue: "" },
|
|
233
|
+
{ name: "isPii", label: "Contains PII", type: "switch", defaultValue: false, helperText: "Encrypt this field and exclude it from analytics/export." },
|
|
234
|
+
{ name: "condition", label: "When should this question be shown?", type: "condition", defaultValue: defaultCondition3, helperText: "If no rules are added, this question will always be shown." },
|
|
235
|
+
{ name: "urls", label: "Images", type: "files", defaultValue: [] },
|
|
236
|
+
{ name: "alt", label: "Alt Text", type: "text" },
|
|
237
|
+
...mediaInteractionProperties
|
|
238
|
+
]
|
|
239
|
+
};
|
|
240
|
+
var videoManifest = {
|
|
241
|
+
type: "video",
|
|
242
|
+
label: "Video",
|
|
243
|
+
description: "Embed a video",
|
|
244
|
+
category: "media",
|
|
245
|
+
dataType: "object",
|
|
246
|
+
defaultData: videoDefaultData,
|
|
247
|
+
properties: [
|
|
248
|
+
{ name: "label", label: "Field Label", type: "text", placeholder: "e.g., Watch this clip" },
|
|
249
|
+
{ name: "description", label: "Description", type: "textarea", placeholder: "Helper text for the user", defaultValue: "" },
|
|
250
|
+
{ name: "isPii", label: "Contains PII", type: "switch", defaultValue: false, helperText: "Encrypt this field and exclude it from analytics/export." },
|
|
251
|
+
{ name: "condition", label: "When should this question be shown?", type: "condition", defaultValue: defaultCondition3, helperText: "If no rules are added, this question will always be shown." },
|
|
252
|
+
{ name: "url", label: "Video URL", type: "file", placeholder: "Upload or paste URL..." },
|
|
253
|
+
{ name: "autoplay", label: "Autoplay", type: "switch", defaultValue: false },
|
|
254
|
+
...mediaInteractionProperties
|
|
255
|
+
]
|
|
256
|
+
};
|
|
257
|
+
var audioManifest = {
|
|
258
|
+
type: "audio",
|
|
259
|
+
label: "Audio",
|
|
260
|
+
description: "Play an audio clip",
|
|
261
|
+
category: "media",
|
|
262
|
+
dataType: "object",
|
|
263
|
+
defaultData: audioDefaultData,
|
|
264
|
+
properties: [
|
|
265
|
+
{ name: "label", label: "Field Label", type: "text", placeholder: "e.g., Listen to this clip" },
|
|
266
|
+
{ name: "description", label: "Description", type: "textarea", placeholder: "Helper text for the user", defaultValue: "" },
|
|
267
|
+
{ name: "isPii", label: "Contains PII", type: "switch", defaultValue: false, helperText: "Encrypt this field and exclude it from analytics/export." },
|
|
268
|
+
{ name: "condition", label: "When should this question be shown?", type: "condition", defaultValue: defaultCondition3, helperText: "If no rules are added, this question will always be shown." },
|
|
269
|
+
{ name: "url", label: "Audio URL", type: "file", placeholder: "Upload or paste URL..." },
|
|
270
|
+
{ name: "autoplay", label: "Autoplay", type: "switch", defaultValue: false },
|
|
271
|
+
...mediaInteractionProperties
|
|
272
|
+
]
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
// src/nodes/media/logic.ts
|
|
276
|
+
var normalizeMediaValue = (rawValue) => {
|
|
277
|
+
if (typeof rawValue === "number") return rawValue;
|
|
278
|
+
if (typeof rawValue === "string") return rawValue;
|
|
279
|
+
if (typeof rawValue === "boolean") return String(rawValue);
|
|
280
|
+
return void 0;
|
|
281
|
+
};
|
|
282
|
+
var choicesFor = (nodeData) => Array.isArray(nodeData.choices) ? nodeData.choices : [];
|
|
283
|
+
var choiceForValue = (nodeData, value) => choicesFor(nodeData).find((choice) => choice.exportId === value || choice.value === value || choice.id === value);
|
|
284
|
+
var choiceId = (choice, value) => choice?.exportId || choice?.value || choice?.id || value;
|
|
285
|
+
var choiceLabel = (choice, value) => choice?.label || value;
|
|
286
|
+
var extractMediaValue = (value, nodeData) => {
|
|
287
|
+
const interactionType = nodeData.interactionType || "none";
|
|
288
|
+
if (value === void 0 || value === "" || interactionType === "none") return [];
|
|
289
|
+
if (interactionType === "slider") {
|
|
290
|
+
const numberValue2 = Number(value);
|
|
291
|
+
return [Number.isFinite(numberValue2) ? { numberValue: numberValue2, textValue: String(value) } : { textValue: String(value) }];
|
|
292
|
+
}
|
|
293
|
+
if (interactionType === "choice") {
|
|
294
|
+
const selectedValue = String(value);
|
|
295
|
+
const choice = choiceForValue(nodeData, selectedValue);
|
|
296
|
+
const label = choiceLabel(choice, selectedValue);
|
|
297
|
+
return [{
|
|
298
|
+
optionUuid: choiceId(choice, selectedValue),
|
|
299
|
+
optionText: label,
|
|
300
|
+
textValue: label
|
|
301
|
+
}];
|
|
302
|
+
}
|
|
303
|
+
return [{ textValue: String(value) }];
|
|
304
|
+
};
|
|
305
|
+
var validateMediaValue = (value, nodeData) => {
|
|
306
|
+
const interactionType = nodeData.interactionType || "none";
|
|
307
|
+
if (interactionType === "none") return { valid: true };
|
|
308
|
+
if (value === void 0 || value === "") return { valid: false, error: "Media interaction answer is required" };
|
|
309
|
+
if (interactionType === "choice" && choicesFor(nodeData).length > 0 && !choiceForValue(nodeData, String(value))) {
|
|
310
|
+
return { valid: false, error: "Selected option is not available" };
|
|
311
|
+
}
|
|
312
|
+
return { valid: true };
|
|
313
|
+
};
|
|
314
|
+
var imageLogic = {
|
|
315
|
+
type: "image",
|
|
316
|
+
dataType: "object",
|
|
317
|
+
defaultData: imageDefaultData,
|
|
318
|
+
defaultValue: void 0,
|
|
319
|
+
normalizeValue: normalizeMediaValue,
|
|
320
|
+
validate: validateMediaValue,
|
|
321
|
+
extractValue: extractMediaValue
|
|
322
|
+
};
|
|
323
|
+
var videoLogic = {
|
|
324
|
+
type: "video",
|
|
325
|
+
dataType: "object",
|
|
326
|
+
defaultData: videoDefaultData,
|
|
327
|
+
defaultValue: void 0,
|
|
328
|
+
normalizeValue: normalizeMediaValue,
|
|
329
|
+
validate: validateMediaValue,
|
|
330
|
+
extractValue: extractMediaValue
|
|
331
|
+
};
|
|
332
|
+
var audioLogic = {
|
|
333
|
+
type: "audio",
|
|
334
|
+
dataType: "object",
|
|
335
|
+
defaultData: audioDefaultData,
|
|
336
|
+
defaultValue: void 0,
|
|
337
|
+
normalizeValue: normalizeMediaValue,
|
|
338
|
+
validate: validateMediaValue,
|
|
339
|
+
extractValue: extractMediaValue
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/nodes/flow/manifest.ts
|
|
343
|
+
var defaultCondition4 = {
|
|
344
|
+
id: "root",
|
|
345
|
+
type: "group",
|
|
346
|
+
logicType: "AND",
|
|
347
|
+
children: []
|
|
348
|
+
};
|
|
349
|
+
var startDefaultData = {
|
|
350
|
+
welcomeMessage: ""
|
|
351
|
+
};
|
|
352
|
+
var branchDefaultData = {
|
|
353
|
+
condition: defaultCondition4
|
|
354
|
+
};
|
|
355
|
+
var validationDefaultData = {
|
|
356
|
+
label: "Validation Gate",
|
|
357
|
+
condition: defaultCondition4,
|
|
358
|
+
outcome: "security_terminate"
|
|
359
|
+
};
|
|
360
|
+
var endDefaultData = {
|
|
361
|
+
message: "",
|
|
362
|
+
redirectUrl: "",
|
|
363
|
+
outcome: "completed"
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/nodes/flow/logic.ts
|
|
367
|
+
var normalizeNone = () => void 0;
|
|
368
|
+
var validatePass = () => ({ valid: true });
|
|
369
|
+
var extractNone = () => [];
|
|
370
|
+
var startLogic = {
|
|
371
|
+
type: "start",
|
|
372
|
+
dataType: "none",
|
|
373
|
+
defaultData: startDefaultData,
|
|
374
|
+
defaultValue: void 0,
|
|
375
|
+
normalizeValue: normalizeNone,
|
|
376
|
+
validate: validatePass,
|
|
377
|
+
extractValue: extractNone
|
|
378
|
+
};
|
|
379
|
+
var branchLogic = {
|
|
380
|
+
type: "branch",
|
|
381
|
+
dataType: "none",
|
|
382
|
+
defaultData: branchDefaultData,
|
|
383
|
+
defaultValue: void 0,
|
|
384
|
+
normalizeValue: normalizeNone,
|
|
385
|
+
validate: validatePass,
|
|
386
|
+
extractValue: extractNone
|
|
387
|
+
};
|
|
388
|
+
var validationLogic = {
|
|
389
|
+
type: "validation",
|
|
390
|
+
dataType: "none",
|
|
391
|
+
defaultData: validationDefaultData,
|
|
392
|
+
defaultValue: void 0,
|
|
393
|
+
normalizeValue: normalizeNone,
|
|
394
|
+
validate: validatePass,
|
|
395
|
+
extractValue: extractNone
|
|
396
|
+
};
|
|
397
|
+
var endLogic = {
|
|
398
|
+
type: "end",
|
|
399
|
+
dataType: "none",
|
|
400
|
+
defaultData: endDefaultData,
|
|
401
|
+
defaultValue: void 0,
|
|
402
|
+
normalizeValue: normalizeNone,
|
|
403
|
+
validate: validatePass,
|
|
404
|
+
extractValue: extractNone
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// src/nodes/consent/manifest.ts
|
|
408
|
+
var defaultCondition5 = {
|
|
409
|
+
id: "root",
|
|
410
|
+
type: "group",
|
|
411
|
+
logicType: "AND",
|
|
412
|
+
children: []
|
|
413
|
+
};
|
|
77
414
|
var consentDefaultData = {
|
|
78
415
|
label: "Consent",
|
|
79
416
|
description: "I agree to the terms and conditions.",
|
|
80
|
-
condition:
|
|
417
|
+
condition: defaultCondition5,
|
|
81
418
|
checkboxLabel: "I agree",
|
|
82
419
|
disagreeLabel: "I do not agree to the terms"
|
|
83
420
|
};
|
|
@@ -109,7 +446,7 @@ var consentLogic = {
|
|
|
109
446
|
};
|
|
110
447
|
|
|
111
448
|
// src/nodes/scale/manifest.ts
|
|
112
|
-
var
|
|
449
|
+
var defaultCondition6 = {
|
|
113
450
|
id: "root",
|
|
114
451
|
type: "group",
|
|
115
452
|
logicType: "AND",
|
|
@@ -118,7 +455,7 @@ var defaultCondition2 = {
|
|
|
118
455
|
var baseScaleData = {
|
|
119
456
|
label: "",
|
|
120
457
|
description: "",
|
|
121
|
-
condition:
|
|
458
|
+
condition: defaultCondition6,
|
|
122
459
|
responseMode: "single",
|
|
123
460
|
items: []
|
|
124
461
|
};
|
|
@@ -140,7 +477,7 @@ var commonProperties = [
|
|
|
140
477
|
name: "condition",
|
|
141
478
|
label: "Logic Rule",
|
|
142
479
|
type: "condition",
|
|
143
|
-
defaultValue:
|
|
480
|
+
defaultValue: defaultCondition6
|
|
144
481
|
}
|
|
145
482
|
];
|
|
146
483
|
var ratingDefaultData = {
|
|
@@ -277,7 +614,7 @@ var sliderLogic = {
|
|
|
277
614
|
};
|
|
278
615
|
|
|
279
616
|
// src/nodes/choice/manifest.ts
|
|
280
|
-
var
|
|
617
|
+
var defaultCondition7 = {
|
|
281
618
|
id: "root",
|
|
282
619
|
type: "group",
|
|
283
620
|
logicType: "AND",
|
|
@@ -286,7 +623,7 @@ var defaultCondition3 = {
|
|
|
286
623
|
var baseChoiceData = {
|
|
287
624
|
label: "",
|
|
288
625
|
description: "",
|
|
289
|
-
condition:
|
|
626
|
+
condition: defaultCondition7,
|
|
290
627
|
options: [],
|
|
291
628
|
randomizeOptions: false
|
|
292
629
|
};
|
|
@@ -297,7 +634,7 @@ var commonProperties2 = [
|
|
|
297
634
|
name: "condition",
|
|
298
635
|
label: "Logic Rule",
|
|
299
636
|
type: "condition",
|
|
300
|
-
defaultValue:
|
|
637
|
+
defaultValue: defaultCondition7
|
|
301
638
|
},
|
|
302
639
|
{ name: "options", label: "Options", type: "options", defaultValue: [] },
|
|
303
640
|
{ name: "bulkOptions", label: "Bulk Add (one per line)", type: "textarea", placeholder: "Option A\nOption B\nOption C...", helperText: "Paste a list to replace all options above" }
|
|
@@ -414,18 +751,18 @@ var positiveNumber2 = (value) => {
|
|
|
414
751
|
const parsed = Number(value);
|
|
415
752
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
416
753
|
};
|
|
417
|
-
var
|
|
418
|
-
var
|
|
419
|
-
var optionLabel = (nodeData, value) =>
|
|
420
|
-
var optionUuid = (nodeData, value) =>
|
|
754
|
+
var optionsFor2 = (nodeData) => Array.isArray(nodeData.options) ? nodeData.options : [];
|
|
755
|
+
var optionForValue2 = (nodeData, value) => optionsFor2(nodeData).find((option) => option.value === value || option.id === value);
|
|
756
|
+
var optionLabel = (nodeData, value) => optionForValue2(nodeData, value)?.label || value;
|
|
757
|
+
var optionUuid = (nodeData, value) => optionForValue2(nodeData, value)?.value || value;
|
|
421
758
|
var validateOptionExists = (value, nodeData) => {
|
|
422
759
|
if (!value) return { valid: true };
|
|
423
|
-
if (
|
|
424
|
-
return
|
|
760
|
+
if (optionsFor2(nodeData).length === 0) return { valid: true };
|
|
761
|
+
return optionForValue2(nodeData, value) ? { valid: true } : { valid: false, error: "Selected option is not available" };
|
|
425
762
|
};
|
|
426
763
|
var validateOptionArray = (value, nodeData) => {
|
|
427
|
-
if (
|
|
428
|
-
const invalid = value.find((item) => !
|
|
764
|
+
if (optionsFor2(nodeData).length === 0) return { valid: true };
|
|
765
|
+
const invalid = value.find((item) => !optionForValue2(nodeData, item));
|
|
429
766
|
return invalid ? { valid: false, error: "Selected option is not available" } : { valid: true };
|
|
430
767
|
};
|
|
431
768
|
var extractSingleChoiceValue = (value, nodeData) => [
|
|
@@ -499,8 +836,173 @@ var rankingLogic = {
|
|
|
499
836
|
})
|
|
500
837
|
};
|
|
501
838
|
|
|
839
|
+
// src/nodes/structuredChoice/manifest.ts
|
|
840
|
+
var defaultCondition8 = {
|
|
841
|
+
id: "root",
|
|
842
|
+
type: "group",
|
|
843
|
+
logicType: "AND",
|
|
844
|
+
children: []
|
|
845
|
+
};
|
|
846
|
+
var commonProperties3 = [
|
|
847
|
+
{ name: "label", label: "Field Label", type: "text" },
|
|
848
|
+
{ name: "description", label: "Description", type: "textarea" },
|
|
849
|
+
{
|
|
850
|
+
name: "condition",
|
|
851
|
+
label: "Logic Rule",
|
|
852
|
+
type: "condition",
|
|
853
|
+
defaultValue: defaultCondition8
|
|
854
|
+
}
|
|
855
|
+
];
|
|
856
|
+
var matrixChoiceDefaultData = {
|
|
857
|
+
label: "Grid / Matrix",
|
|
858
|
+
description: "",
|
|
859
|
+
condition: defaultCondition8,
|
|
860
|
+
rows: [],
|
|
861
|
+
columns: [],
|
|
862
|
+
multiple: false
|
|
863
|
+
};
|
|
864
|
+
var cascadingChoiceDefaultData = {
|
|
865
|
+
label: "Multi-Step Select",
|
|
866
|
+
description: "",
|
|
867
|
+
condition: defaultCondition8,
|
|
868
|
+
steps: []
|
|
869
|
+
};
|
|
870
|
+
var matrixChoiceManifest = {
|
|
871
|
+
type: "matrixChoice",
|
|
872
|
+
label: "Grid / Matrix",
|
|
873
|
+
description: "Grid of rows and columns",
|
|
874
|
+
category: "choice",
|
|
875
|
+
dataType: "object",
|
|
876
|
+
defaultData: matrixChoiceDefaultData,
|
|
877
|
+
properties: [
|
|
878
|
+
...commonProperties3,
|
|
879
|
+
{ name: "rows", label: "Rows (Questions)", type: "options", defaultValue: [] },
|
|
880
|
+
{ name: "columns", label: "Columns (Options)", type: "options", defaultValue: [] },
|
|
881
|
+
{ name: "multiple", label: "Allow Multiple", type: "switch", defaultValue: false }
|
|
882
|
+
]
|
|
883
|
+
};
|
|
884
|
+
var cascadingChoiceManifest = {
|
|
885
|
+
type: "cascadingChoice",
|
|
886
|
+
label: "Multi-Step Select",
|
|
887
|
+
description: "Conditional drill-down options",
|
|
888
|
+
category: "choice",
|
|
889
|
+
dataType: "array",
|
|
890
|
+
defaultData: cascadingChoiceDefaultData,
|
|
891
|
+
properties: [
|
|
892
|
+
...commonProperties3,
|
|
893
|
+
{ name: "steps", label: "Steps", type: "stepBuilder", defaultValue: [] }
|
|
894
|
+
]
|
|
895
|
+
};
|
|
896
|
+
|
|
897
|
+
// src/nodes/structuredChoice/logic.ts
|
|
898
|
+
var isRecord2 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
899
|
+
var normalizeText = (value) => {
|
|
900
|
+
if (typeof value === "string") return value;
|
|
901
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
902
|
+
return "";
|
|
903
|
+
};
|
|
904
|
+
var optionKey = (item) => item.exportId || item.value || item.id || item.label;
|
|
905
|
+
var optionLabel2 = (item, fallback) => item?.label || fallback;
|
|
906
|
+
var findByKey = (items, key) => items.find((item) => item.exportId === key || item.value === key || item.id === key);
|
|
907
|
+
var normalizeMatrixValue = (rawValue) => {
|
|
908
|
+
if (!isRecord2(rawValue)) return {};
|
|
909
|
+
return Object.fromEntries(Object.entries(rawValue).map(([key, value]) => {
|
|
910
|
+
if (Array.isArray(value)) return [key, value.map(normalizeText).filter(Boolean)];
|
|
911
|
+
if (typeof value === "boolean") return [key, value];
|
|
912
|
+
return [key, normalizeText(value)];
|
|
913
|
+
}));
|
|
914
|
+
};
|
|
915
|
+
var splitMatrixCellKey = (cellKey, rows, columns) => {
|
|
916
|
+
const rowKeys = rows.map(optionKey).sort((a, b) => b.length - a.length);
|
|
917
|
+
for (const rowId of rowKeys) {
|
|
918
|
+
const prefix = `${rowId}_`;
|
|
919
|
+
if (!cellKey.startsWith(prefix)) continue;
|
|
920
|
+
const colId = cellKey.slice(prefix.length);
|
|
921
|
+
if (colId) return [rowId, colId];
|
|
922
|
+
}
|
|
923
|
+
const separatorIndex = cellKey.indexOf("_");
|
|
924
|
+
if (separatorIndex <= 0) return null;
|
|
925
|
+
return [cellKey.slice(0, separatorIndex), cellKey.slice(separatorIndex + 1)];
|
|
926
|
+
};
|
|
927
|
+
var extractMatrixValue = (value, nodeData) => {
|
|
928
|
+
const rows = Array.isArray(nodeData.rows) ? nodeData.rows : [];
|
|
929
|
+
const columns = Array.isArray(nodeData.columns) ? nodeData.columns : [];
|
|
930
|
+
const extracted = [];
|
|
931
|
+
for (const [key, selected] of Object.entries(value)) {
|
|
932
|
+
if (typeof selected === "boolean") {
|
|
933
|
+
if (!selected) continue;
|
|
934
|
+
const parts = splitMatrixCellKey(key, rows, columns);
|
|
935
|
+
if (!parts) continue;
|
|
936
|
+
const [rowId2, colId] = parts;
|
|
937
|
+
const row2 = findByKey(rows, rowId2);
|
|
938
|
+
const column = findByKey(columns, colId);
|
|
939
|
+
extracted.push({
|
|
940
|
+
columnKey: rowId2,
|
|
941
|
+
columnLabel: optionLabel2(row2, rowId2),
|
|
942
|
+
columnId: colId,
|
|
943
|
+
columnTechnicalId: colId,
|
|
944
|
+
columnText: optionLabel2(column, colId),
|
|
945
|
+
textValue: optionLabel2(column, colId)
|
|
946
|
+
});
|
|
947
|
+
continue;
|
|
948
|
+
}
|
|
949
|
+
const rowId = key;
|
|
950
|
+
const selectedColumns = Array.isArray(selected) ? selected : [selected];
|
|
951
|
+
const row = findByKey(rows, rowId);
|
|
952
|
+
for (const selectedColumn of selectedColumns) {
|
|
953
|
+
if (!selectedColumn) continue;
|
|
954
|
+
const column = findByKey(columns, selectedColumn);
|
|
955
|
+
extracted.push({
|
|
956
|
+
columnKey: rowId,
|
|
957
|
+
columnLabel: optionLabel2(row, rowId),
|
|
958
|
+
columnId: selectedColumn,
|
|
959
|
+
columnTechnicalId: selectedColumn,
|
|
960
|
+
columnText: optionLabel2(column, selectedColumn),
|
|
961
|
+
textValue: optionLabel2(column, selectedColumn)
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return extracted;
|
|
966
|
+
};
|
|
967
|
+
var normalizeCascadingValue = (rawValue) => Array.isArray(rawValue) ? rawValue.map(normalizeText).filter(Boolean) : [];
|
|
968
|
+
var extractCascadingValue = (value, nodeData) => {
|
|
969
|
+
const steps = Array.isArray(nodeData.steps) ? nodeData.steps : [];
|
|
970
|
+
return value.map((optionId2, index) => {
|
|
971
|
+
const step = steps[index];
|
|
972
|
+
const stepId = step?.exportId || step?.id;
|
|
973
|
+
const option = step?.options?.find((item) => item.exportId === optionId2 || item.value === optionId2 || item.id === optionId2);
|
|
974
|
+
return {
|
|
975
|
+
columnKey: stepId || `level_${index + 1}`,
|
|
976
|
+
columnLabel: step?.title || `Level ${index + 1}`,
|
|
977
|
+
optionUuid: optionId2,
|
|
978
|
+
optionText: option?.label || optionId2,
|
|
979
|
+
textValue: option?.label || optionId2,
|
|
980
|
+
cascadeLevel: index + 1,
|
|
981
|
+
cascadeParentId: index > 0 ? value[index - 1] || null : null
|
|
982
|
+
};
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
var matrixChoiceLogic = {
|
|
986
|
+
type: "matrixChoice",
|
|
987
|
+
dataType: "object",
|
|
988
|
+
defaultData: matrixChoiceDefaultData,
|
|
989
|
+
defaultValue: {},
|
|
990
|
+
normalizeValue: normalizeMatrixValue,
|
|
991
|
+
validate: () => ({ valid: true }),
|
|
992
|
+
extractValue: extractMatrixValue
|
|
993
|
+
};
|
|
994
|
+
var cascadingChoiceLogic = {
|
|
995
|
+
type: "cascadingChoice",
|
|
996
|
+
dataType: "array",
|
|
997
|
+
defaultData: cascadingChoiceDefaultData,
|
|
998
|
+
defaultValue: [],
|
|
999
|
+
normalizeValue: normalizeCascadingValue,
|
|
1000
|
+
validate: () => ({ valid: true }),
|
|
1001
|
+
extractValue: extractCascadingValue
|
|
1002
|
+
};
|
|
1003
|
+
|
|
502
1004
|
// src/nodes/textLike/manifest.ts
|
|
503
|
-
var
|
|
1005
|
+
var defaultCondition9 = {
|
|
504
1006
|
id: "root",
|
|
505
1007
|
type: "group",
|
|
506
1008
|
logicType: "AND",
|
|
@@ -509,20 +1011,20 @@ var defaultCondition4 = {
|
|
|
509
1011
|
var baseTextData = {
|
|
510
1012
|
label: "",
|
|
511
1013
|
description: "",
|
|
512
|
-
condition:
|
|
1014
|
+
condition: defaultCondition9,
|
|
513
1015
|
minChars: 0,
|
|
514
1016
|
maxChars: 0,
|
|
515
1017
|
minWords: 0,
|
|
516
1018
|
maxWords: 0
|
|
517
1019
|
};
|
|
518
|
-
var
|
|
1020
|
+
var commonProperties4 = [
|
|
519
1021
|
{ name: "label", label: "Field Label", type: "text" },
|
|
520
1022
|
{ name: "description", label: "Description", type: "textarea" },
|
|
521
1023
|
{
|
|
522
1024
|
name: "condition",
|
|
523
1025
|
label: "Logic Rule",
|
|
524
1026
|
type: "condition",
|
|
525
|
-
defaultValue:
|
|
1027
|
+
defaultValue: defaultCondition9
|
|
526
1028
|
}
|
|
527
1029
|
];
|
|
528
1030
|
var textLimitProperties = [
|
|
@@ -561,7 +1063,7 @@ var textInputManifest = {
|
|
|
561
1063
|
dataType: "text",
|
|
562
1064
|
defaultData: textInputDefaultData,
|
|
563
1065
|
properties: [
|
|
564
|
-
...
|
|
1066
|
+
...commonProperties4,
|
|
565
1067
|
{ name: "placeholder", label: "Placeholder", type: "text", placeholder: "e.g., Type here...", defaultValue: "" },
|
|
566
1068
|
{ name: "longAnswer", label: "Long Answer (Multi-line)", type: "switch", defaultValue: false },
|
|
567
1069
|
...textLimitProperties
|
|
@@ -575,7 +1077,7 @@ var numberInputManifest = {
|
|
|
575
1077
|
dataType: "number",
|
|
576
1078
|
defaultData: numberInputDefaultData,
|
|
577
1079
|
properties: [
|
|
578
|
-
...
|
|
1080
|
+
...commonProperties4,
|
|
579
1081
|
{ name: "min", label: "Minimum Value", type: "number" },
|
|
580
1082
|
{ name: "max", label: "Maximum Value", type: "number" }
|
|
581
1083
|
]
|
|
@@ -588,7 +1090,7 @@ var zipCodeInputManifest = {
|
|
|
588
1090
|
dataType: "text",
|
|
589
1091
|
defaultData: zipCodeInputDefaultData,
|
|
590
1092
|
properties: [
|
|
591
|
-
...
|
|
1093
|
+
...commonProperties4,
|
|
592
1094
|
{ name: "allowedZips", label: "Allowed Zip Codes", type: "fileTextarea", placeholder: "10001, 10002, 90210... (Leave empty to allow all)", helperText: "Validation: Only users entering these zip codes can proceed. Others will be blocked." }
|
|
593
1095
|
]
|
|
594
1096
|
};
|
|
@@ -600,7 +1102,7 @@ var multiInputManifest = {
|
|
|
600
1102
|
dataType: "object",
|
|
601
1103
|
defaultData: multiInputDefaultData,
|
|
602
1104
|
properties: [
|
|
603
|
-
...
|
|
1105
|
+
...commonProperties4,
|
|
604
1106
|
{ name: "fields", label: "Input Fields", type: "options", defaultValue: [], helperText: "Value column represents input type (text, number, email)" },
|
|
605
1107
|
...textLimitProperties
|
|
606
1108
|
]
|
|
@@ -773,19 +1275,38 @@ var logicRegistry = defineLogicRegistry({
|
|
|
773
1275
|
multipleChoice: multipleChoiceLogic,
|
|
774
1276
|
dropdown: dropdownLogic,
|
|
775
1277
|
ranking: rankingLogic,
|
|
1278
|
+
cascadingChoice: cascadingChoiceLogic,
|
|
1279
|
+
matrixChoice: matrixChoiceLogic,
|
|
776
1280
|
rating: ratingLogic,
|
|
777
1281
|
slider: sliderLogic,
|
|
778
1282
|
consent: consentLogic,
|
|
779
|
-
|
|
1283
|
+
captcha: captchaLogic,
|
|
1284
|
+
image: imageLogic,
|
|
1285
|
+
video: videoLogic,
|
|
1286
|
+
audio: audioLogic,
|
|
1287
|
+
plainText: plainTextLogic,
|
|
1288
|
+
emojiRating: emojiRatingLogic,
|
|
1289
|
+
start: startLogic,
|
|
1290
|
+
end: endLogic,
|
|
1291
|
+
branch: branchLogic,
|
|
1292
|
+
validation: validationLogic
|
|
780
1293
|
});
|
|
781
1294
|
export {
|
|
1295
|
+
audioLogic,
|
|
1296
|
+
branchLogic,
|
|
1297
|
+
captchaLogic,
|
|
1298
|
+
cascadingChoiceLogic,
|
|
782
1299
|
consentLogic,
|
|
783
1300
|
createInitialData,
|
|
784
1301
|
dateInputLogic,
|
|
785
1302
|
defineLogicRegistry,
|
|
786
1303
|
dropdownLogic,
|
|
787
1304
|
emailInputLogic,
|
|
1305
|
+
emojiRatingLogic,
|
|
1306
|
+
endLogic,
|
|
1307
|
+
imageLogic,
|
|
788
1308
|
logicRegistry,
|
|
1309
|
+
matrixChoiceLogic,
|
|
789
1310
|
multiInputLogic,
|
|
790
1311
|
multipleChoiceLogic,
|
|
791
1312
|
numberInputLogic,
|
|
@@ -794,6 +1315,9 @@ export {
|
|
|
794
1315
|
ratingLogic,
|
|
795
1316
|
singleChoiceLogic,
|
|
796
1317
|
sliderLogic,
|
|
1318
|
+
startLogic,
|
|
797
1319
|
textInputLogic,
|
|
1320
|
+
validationLogic,
|
|
1321
|
+
videoLogic,
|
|
798
1322
|
zipCodeInputLogic
|
|
799
1323
|
};
|