@surveystudio/node-registery 1.2.0 → 1.3.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 +1 -0
- package/dist/logic.d.mts +19 -1
- package/dist/logic.mjs +52 -9
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/logic.d.mts
CHANGED
|
@@ -2,6 +2,21 @@ import { P as PlainTextData, a as PlainTextValue, D as DateInputData, b as TextV
|
|
|
2
2
|
import { b as NodeData, J as JsonValue, c as NodeLogic } from './coreTypes-CyFAym5A.mjs';
|
|
3
3
|
export { C as CompleteLogicRegistry, D as DataType, E as ExtractedValue, d as ExtractionContext, L as LogicRegistry, e as NodeLogicContext, V as ValidationContext, f as ValidationResult, g as createInitialData, h as defineLogicRegistry } from './coreTypes-CyFAym5A.mjs';
|
|
4
4
|
|
|
5
|
+
type ConditionData$2 = {
|
|
6
|
+
id: string;
|
|
7
|
+
type: "group";
|
|
8
|
+
logicType: "AND" | "OR";
|
|
9
|
+
children: JsonValue[];
|
|
10
|
+
};
|
|
11
|
+
type ConsentData = NodeData & {
|
|
12
|
+
label: string;
|
|
13
|
+
description: string;
|
|
14
|
+
condition: ConditionData$2;
|
|
15
|
+
checkboxLabel: string;
|
|
16
|
+
disagreeLabel?: string;
|
|
17
|
+
};
|
|
18
|
+
type ConsentValue = boolean;
|
|
19
|
+
|
|
5
20
|
type ConditionData$1 = {
|
|
6
21
|
id: string;
|
|
7
22
|
type: "group";
|
|
@@ -74,6 +89,8 @@ type RankingValue = string[];
|
|
|
74
89
|
|
|
75
90
|
declare const plainTextLogic: NodeLogic<"plainText", PlainTextData, PlainTextValue>;
|
|
76
91
|
|
|
92
|
+
declare const consentLogic: NodeLogic<"consent", ConsentData, ConsentValue>;
|
|
93
|
+
|
|
77
94
|
declare const ratingLogic: NodeLogic<"rating", RatingData, ScaleValue>;
|
|
78
95
|
declare const sliderLogic: NodeLogic<"slider", SliderData, ScaleValue>;
|
|
79
96
|
|
|
@@ -102,7 +119,8 @@ declare const logicRegistry: {
|
|
|
102
119
|
readonly ranking: NodeLogic<"ranking", RankingData, RankingValue>;
|
|
103
120
|
readonly rating: NodeLogic<"rating", RatingData, ScaleValue>;
|
|
104
121
|
readonly slider: NodeLogic<"slider", SliderData, ScaleValue>;
|
|
122
|
+
readonly consent: NodeLogic<"consent", ConsentData, boolean>;
|
|
105
123
|
readonly plainText: NodeLogic<"plainText", PlainTextData, PlainTextValue>;
|
|
106
124
|
};
|
|
107
125
|
|
|
108
|
-
export { NodeLogic, dateInputLogic, dropdownLogic, emailInputLogic, logicRegistry, multiInputLogic, multipleChoiceLogic, numberInputLogic, plainTextLogic, rankingLogic, ratingLogic, singleChoiceLogic, sliderLogic, textInputLogic, zipCodeInputLogic };
|
|
126
|
+
export { NodeLogic, consentLogic, dateInputLogic, dropdownLogic, emailInputLogic, logicRegistry, multiInputLogic, multipleChoiceLogic, numberInputLogic, plainTextLogic, rankingLogic, ratingLogic, singleChoiceLogic, sliderLogic, textInputLogic, zipCodeInputLogic };
|
package/dist/logic.mjs
CHANGED
|
@@ -67,17 +67,58 @@ var plainTextLogic = {
|
|
|
67
67
|
]
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
// src/nodes/
|
|
70
|
+
// src/nodes/consent/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 consentDefaultData = {
|
|
78
|
+
label: "Consent",
|
|
79
|
+
description: "I agree to the terms and conditions.",
|
|
80
|
+
condition: defaultCondition,
|
|
81
|
+
checkboxLabel: "I agree",
|
|
82
|
+
disagreeLabel: "I do not agree to the terms"
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// src/nodes/consent/logic.ts
|
|
86
|
+
var normalizeConsentValue = (value) => {
|
|
87
|
+
if (typeof value === "boolean") return value;
|
|
88
|
+
if (typeof value === "string") {
|
|
89
|
+
const normalized = value.trim().toLowerCase();
|
|
90
|
+
if (["true", "yes", "agree", "agreed", "1"].includes(normalized)) return true;
|
|
91
|
+
if (["false", "no", "disagree", "disagreed", "0"].includes(normalized)) return false;
|
|
92
|
+
}
|
|
93
|
+
if (typeof value === "number") return value !== 0;
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
var consentLogic = {
|
|
97
|
+
type: "consent",
|
|
98
|
+
dataType: "boolean",
|
|
99
|
+
defaultData: consentDefaultData,
|
|
100
|
+
defaultValue: false,
|
|
101
|
+
normalizeValue: normalizeConsentValue,
|
|
102
|
+
validate: () => ({ valid: true }),
|
|
103
|
+
extractValue: (value) => [
|
|
104
|
+
{
|
|
105
|
+
booleanValue: value,
|
|
106
|
+
textValue: value ? "Yes" : "No"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/nodes/scale/manifest.ts
|
|
112
|
+
var defaultCondition2 = {
|
|
113
|
+
id: "root",
|
|
114
|
+
type: "group",
|
|
115
|
+
logicType: "AND",
|
|
116
|
+
children: []
|
|
117
|
+
};
|
|
77
118
|
var baseScaleData = {
|
|
78
119
|
label: "",
|
|
79
120
|
description: "",
|
|
80
|
-
condition:
|
|
121
|
+
condition: defaultCondition2,
|
|
81
122
|
responseMode: "single",
|
|
82
123
|
items: []
|
|
83
124
|
};
|
|
@@ -99,7 +140,7 @@ var commonProperties = [
|
|
|
99
140
|
name: "condition",
|
|
100
141
|
label: "Logic Rule",
|
|
101
142
|
type: "condition",
|
|
102
|
-
defaultValue:
|
|
143
|
+
defaultValue: defaultCondition2
|
|
103
144
|
},
|
|
104
145
|
{ name: "items", label: "Items", type: "options", defaultValue: [] }
|
|
105
146
|
];
|
|
@@ -235,7 +276,7 @@ var sliderLogic = {
|
|
|
235
276
|
};
|
|
236
277
|
|
|
237
278
|
// src/nodes/choice/manifest.ts
|
|
238
|
-
var
|
|
279
|
+
var defaultCondition3 = {
|
|
239
280
|
id: "root",
|
|
240
281
|
type: "group",
|
|
241
282
|
logicType: "AND",
|
|
@@ -244,7 +285,7 @@ var defaultCondition2 = {
|
|
|
244
285
|
var baseChoiceData = {
|
|
245
286
|
label: "",
|
|
246
287
|
description: "",
|
|
247
|
-
condition:
|
|
288
|
+
condition: defaultCondition3,
|
|
248
289
|
options: [],
|
|
249
290
|
randomizeOptions: false
|
|
250
291
|
};
|
|
@@ -255,7 +296,7 @@ var commonProperties2 = [
|
|
|
255
296
|
name: "condition",
|
|
256
297
|
label: "Logic Rule",
|
|
257
298
|
type: "condition",
|
|
258
|
-
defaultValue:
|
|
299
|
+
defaultValue: defaultCondition3
|
|
259
300
|
},
|
|
260
301
|
{ name: "options", label: "Options", type: "options", defaultValue: [] },
|
|
261
302
|
{ name: "bulkOptions", label: "Bulk Add (one per line)", type: "textarea", placeholder: "Option A\nOption B\nOption C..." }
|
|
@@ -446,7 +487,7 @@ var rankingLogic = {
|
|
|
446
487
|
};
|
|
447
488
|
|
|
448
489
|
// src/nodes/textLike/manifest.ts
|
|
449
|
-
var
|
|
490
|
+
var defaultCondition4 = {
|
|
450
491
|
id: "root",
|
|
451
492
|
type: "group",
|
|
452
493
|
logicType: "AND",
|
|
@@ -455,7 +496,7 @@ var defaultCondition3 = {
|
|
|
455
496
|
var baseTextData = {
|
|
456
497
|
label: "",
|
|
457
498
|
description: "",
|
|
458
|
-
condition:
|
|
499
|
+
condition: defaultCondition4,
|
|
459
500
|
minChars: 0,
|
|
460
501
|
maxChars: 0,
|
|
461
502
|
minWords: 0,
|
|
@@ -468,7 +509,7 @@ var commonProperties3 = [
|
|
|
468
509
|
name: "condition",
|
|
469
510
|
label: "Logic Rule",
|
|
470
511
|
type: "condition",
|
|
471
|
-
defaultValue:
|
|
512
|
+
defaultValue: defaultCondition4
|
|
472
513
|
}
|
|
473
514
|
];
|
|
474
515
|
var textLimitProperties = [
|
|
@@ -721,9 +762,11 @@ var logicRegistry = defineLogicRegistry({
|
|
|
721
762
|
ranking: rankingLogic,
|
|
722
763
|
rating: ratingLogic,
|
|
723
764
|
slider: sliderLogic,
|
|
765
|
+
consent: consentLogic,
|
|
724
766
|
plainText: plainTextLogic
|
|
725
767
|
});
|
|
726
768
|
export {
|
|
769
|
+
consentLogic,
|
|
727
770
|
createInitialData,
|
|
728
771
|
dateInputLogic,
|
|
729
772
|
defineLogicRegistry,
|
package/package.json
CHANGED