@surveystudio/node-registery 1.2.0 → 1.4.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/dist/builder.mjs CHANGED
@@ -12,6 +12,19 @@ var plainTextBuilder = {
12
12
  label: "Info / Text"
13
13
  };
14
14
 
15
+ // src/nodes/consent/builder.ts
16
+ var consentBuilder = { type: "consent", label: "Consent" };
17
+
18
+ // src/nodes/choice/builder.ts
19
+ var singleChoiceBuilder = { type: "singleChoice", label: "Single Choice" };
20
+ var multipleChoiceBuilder = { type: "multipleChoice", label: "Multiple Choice" };
21
+ var dropdownBuilder = { type: "dropdown", label: "Dropdown Select" };
22
+ var rankingBuilder = { type: "ranking", label: "Ranking" };
23
+
24
+ // src/nodes/scale/builder.ts
25
+ var ratingBuilder = { type: "rating", label: "Rating" };
26
+ var sliderBuilder = { type: "slider", label: "Slider / Scale" };
27
+
15
28
  // src/nodes/textLike/builder.ts
16
29
  var textInputBuilder = { type: "textInput", label: "Text Answer" };
17
30
  var emailInputBuilder = { type: "emailInput", label: "Email" };
@@ -58,30 +71,267 @@ var plainTextManifest = {
58
71
  ]
59
72
  };
60
73
 
61
- // src/nodes/textLike/manifest.ts
74
+ // src/nodes/consent/manifest.ts
62
75
  var defaultCondition = {
63
76
  id: "root",
64
77
  type: "group",
65
78
  logicType: "AND",
66
79
  children: []
67
80
  };
81
+ var consentDefaultData = {
82
+ label: "Consent",
83
+ description: "I agree to the terms and conditions.",
84
+ condition: defaultCondition,
85
+ checkboxLabel: "I agree",
86
+ disagreeLabel: "I do not agree to the terms"
87
+ };
88
+ var consentManifest = {
89
+ type: "consent",
90
+ label: "Consent",
91
+ description: "Terms and agreement checkbox",
92
+ category: "choice",
93
+ dataType: "boolean",
94
+ defaultData: consentDefaultData,
95
+ properties: [
96
+ { name: "label", label: "Title", type: "text", placeholder: "Terms of Service" },
97
+ { name: "description", label: "Terms Text", type: "textarea", placeholder: "I agree to the terms and conditions..." },
98
+ { name: "checkboxLabel", label: "Checkbox Label", type: "text", placeholder: "I agree" },
99
+ { name: "disagreeLabel", label: "Disagree Label", type: "text", placeholder: "I do not agree to the terms" },
100
+ {
101
+ name: "condition",
102
+ label: "Logic Rule",
103
+ type: "condition",
104
+ defaultValue: defaultCondition
105
+ }
106
+ ]
107
+ };
108
+
109
+ // src/nodes/choice/manifest.ts
110
+ var defaultCondition2 = {
111
+ id: "root",
112
+ type: "group",
113
+ logicType: "AND",
114
+ children: []
115
+ };
116
+ var baseChoiceData = {
117
+ label: "",
118
+ description: "",
119
+ condition: defaultCondition2,
120
+ options: [],
121
+ randomizeOptions: false
122
+ };
123
+ var commonProperties = [
124
+ { name: "label", label: "Question Label", type: "text" },
125
+ { name: "description", label: "Description", type: "textarea" },
126
+ {
127
+ name: "condition",
128
+ label: "Logic Rule",
129
+ type: "condition",
130
+ defaultValue: defaultCondition2
131
+ },
132
+ { name: "options", label: "Options", type: "options", defaultValue: [] },
133
+ { 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" }
134
+ ];
135
+ var singleChoiceDefaultData = {
136
+ ...baseChoiceData,
137
+ label: "Single Choice",
138
+ allowOther: false,
139
+ otherLabel: "Other (Please specify)",
140
+ allowNone: false,
141
+ noneLabel: "None of these"
142
+ };
143
+ var dropdownDefaultData = {
144
+ ...baseChoiceData,
145
+ label: "Dropdown Select",
146
+ placeholder: "Select an option...",
147
+ searchable: true
148
+ };
149
+ var multipleChoiceDefaultData = {
150
+ ...baseChoiceData,
151
+ label: "Multiple Choice",
152
+ minChoices: 0,
153
+ maxChoices: 0,
154
+ allowOther: false,
155
+ otherLabel: "Other (Please specify)",
156
+ allowNone: false,
157
+ noneLabel: "None of these"
158
+ };
159
+ var rankingDefaultData = {
160
+ ...baseChoiceData,
161
+ label: "Ranking",
162
+ maxRank: 0,
163
+ displayMode: "drag"
164
+ };
165
+ var singleChoiceManifest = {
166
+ type: "singleChoice",
167
+ label: "Single Choice",
168
+ description: "Select one option from a list",
169
+ category: "choice",
170
+ dataType: "option",
171
+ defaultData: singleChoiceDefaultData,
172
+ properties: [
173
+ ...commonProperties,
174
+ { name: "allowOther", label: 'Allow "Other" Option', type: "switch", defaultValue: false },
175
+ { name: "otherLabel", label: '"Other" Placeholder', type: "text", placeholder: "Other (Please specify)", helperText: "Label for the open-ended option" },
176
+ { name: "allowNone", label: 'Allow "None of these"', type: "switch", defaultValue: false },
177
+ { name: "noneLabel", label: '"None" Label', type: "text", placeholder: "None of these", visible: (data) => Boolean(data.allowNone) },
178
+ { name: "randomizeOptions", label: "Randomize Options", type: "switch", defaultValue: false }
179
+ ]
180
+ };
181
+ var dropdownManifest = {
182
+ type: "dropdown",
183
+ label: "Dropdown Select",
184
+ description: "Select from a dropdown menu",
185
+ category: "choice",
186
+ dataType: "option",
187
+ defaultData: dropdownDefaultData,
188
+ properties: [
189
+ ...commonProperties,
190
+ { name: "placeholder", label: "Placeholder Text", type: "text", placeholder: "Select an option..." },
191
+ { name: "searchable", label: "Searchable", type: "switch", defaultValue: true }
192
+ ]
193
+ };
194
+ var multipleChoiceManifest = {
195
+ type: "multipleChoice",
196
+ label: "Multiple Choice",
197
+ description: "Select multiple options",
198
+ category: "choice",
199
+ dataType: "array",
200
+ defaultData: multipleChoiceDefaultData,
201
+ properties: [
202
+ ...commonProperties,
203
+ { name: "maxChoices", label: "Maximum Choices", type: "number", helperText: "Limit how many options a user can select. Leave empty for no limit.", defaultValue: 0 },
204
+ { name: "allowOther", label: 'Allow "Other" Option', type: "switch", defaultValue: false },
205
+ { name: "otherLabel", label: '"Other" Placeholder', type: "text", placeholder: "Other (Please specify)" },
206
+ { name: "allowNone", label: 'Allow "None of these"', type: "switch", defaultValue: false },
207
+ { name: "noneLabel", label: '"None" Label', type: "text", placeholder: "None of these", visible: (data) => Boolean(data.allowNone) },
208
+ { name: "randomizeOptions", label: "Randomize Options", type: "switch", defaultValue: false, helperText: "Shuffle options for every viewer" }
209
+ ]
210
+ };
211
+ var rankingManifest = {
212
+ type: "ranking",
213
+ label: "Ranking",
214
+ description: "Rank options in order",
215
+ category: "choice",
216
+ dataType: "array",
217
+ defaultData: rankingDefaultData,
218
+ properties: [
219
+ ...commonProperties,
220
+ {
221
+ name: "displayMode",
222
+ label: "Display Mode",
223
+ type: "select",
224
+ defaultValue: "drag",
225
+ options: [
226
+ { label: "Drag and Drop", value: "drag" },
227
+ { label: "Select Rank", value: "select" }
228
+ ]
229
+ }
230
+ ]
231
+ };
232
+
233
+ // src/nodes/scale/manifest.ts
234
+ var defaultCondition3 = {
235
+ id: "root",
236
+ type: "group",
237
+ logicType: "AND",
238
+ children: []
239
+ };
240
+ var baseScaleData = {
241
+ label: "",
242
+ description: "",
243
+ condition: defaultCondition3,
244
+ responseMode: "single",
245
+ items: []
246
+ };
247
+ var responseModeProperty = {
248
+ name: "responseMode",
249
+ label: "Response Mode",
250
+ type: "select",
251
+ defaultValue: "single",
252
+ options: [
253
+ { label: "Single Question", value: "single" },
254
+ { label: "Multiple Items", value: "multi" }
255
+ ]
256
+ };
257
+ var commonProperties2 = [
258
+ responseModeProperty,
259
+ { name: "label", label: "Question Label", type: "text" },
260
+ { name: "description", label: "Description", type: "textarea" },
261
+ {
262
+ name: "condition",
263
+ label: "Logic Rule",
264
+ type: "condition",
265
+ defaultValue: defaultCondition3
266
+ }
267
+ ];
268
+ var ratingDefaultData = {
269
+ ...baseScaleData,
270
+ label: "Rating",
271
+ maxRating: 5
272
+ };
273
+ var sliderDefaultData = {
274
+ ...baseScaleData,
275
+ label: "Slider / Scale",
276
+ min: 0,
277
+ max: 10,
278
+ step: 1,
279
+ startValue: 5
280
+ };
281
+ var ratingManifest = {
282
+ type: "rating",
283
+ label: "Rating",
284
+ description: "Star rating scale",
285
+ category: "choice",
286
+ dataType: "number",
287
+ defaultData: ratingDefaultData,
288
+ properties: [
289
+ ...commonProperties2,
290
+ { name: "items", label: "Questions/Items", type: "options", defaultValue: [], visible: (data) => data.responseMode === "multi" },
291
+ { name: "maxRating", label: "Max Stars", type: "number", defaultValue: 5 }
292
+ ]
293
+ };
294
+ var sliderManifest = {
295
+ type: "slider",
296
+ label: "Slider / Scale",
297
+ description: "Single or multi-item scale",
298
+ category: "choice",
299
+ dataType: "number",
300
+ defaultData: sliderDefaultData,
301
+ properties: [
302
+ ...commonProperties2,
303
+ { name: "items", label: "Items to Rate", type: "options", defaultValue: [], visible: (data) => data.responseMode === "multi" },
304
+ { name: "min", label: "Minimum", type: "number", defaultValue: 0 },
305
+ { name: "max", label: "Maximum", type: "number", defaultValue: 10 },
306
+ { name: "step", label: "Step", type: "number", defaultValue: 1, min: 0 },
307
+ { name: "startValue", label: "Start Value", type: "number", defaultValue: 5 }
308
+ ]
309
+ };
310
+
311
+ // src/nodes/textLike/manifest.ts
312
+ var defaultCondition4 = {
313
+ id: "root",
314
+ type: "group",
315
+ logicType: "AND",
316
+ children: []
317
+ };
68
318
  var baseTextData = {
69
319
  label: "",
70
320
  description: "",
71
- condition: defaultCondition,
321
+ condition: defaultCondition4,
72
322
  minChars: 0,
73
323
  maxChars: 0,
74
324
  minWords: 0,
75
325
  maxWords: 0
76
326
  };
77
- var commonProperties = [
327
+ var commonProperties3 = [
78
328
  { name: "label", label: "Field Label", type: "text" },
79
329
  { name: "description", label: "Description", type: "textarea" },
80
330
  {
81
331
  name: "condition",
82
332
  label: "Logic Rule",
83
333
  type: "condition",
84
- defaultValue: defaultCondition
334
+ defaultValue: defaultCondition4
85
335
  }
86
336
  ];
87
337
  var textLimitProperties = [
@@ -120,7 +370,7 @@ var textInputManifest = {
120
370
  dataType: "text",
121
371
  defaultData: textInputDefaultData,
122
372
  properties: [
123
- ...commonProperties,
373
+ ...commonProperties3,
124
374
  { name: "placeholder", label: "Placeholder", type: "text", placeholder: "e.g., Type here...", defaultValue: "" },
125
375
  { name: "longAnswer", label: "Long Answer (Multi-line)", type: "switch", defaultValue: false },
126
376
  ...textLimitProperties
@@ -133,7 +383,7 @@ var emailInputManifest = {
133
383
  category: "input",
134
384
  dataType: "text",
135
385
  defaultData: emailInputDefaultData,
136
- properties: commonProperties
386
+ properties: commonProperties3
137
387
  };
138
388
  var dateInputManifest = {
139
389
  type: "dateInput",
@@ -142,7 +392,7 @@ var dateInputManifest = {
142
392
  category: "input",
143
393
  dataType: "text",
144
394
  defaultData: dateInputDefaultData,
145
- properties: commonProperties
395
+ properties: commonProperties3
146
396
  };
147
397
  var numberInputManifest = {
148
398
  type: "numberInput",
@@ -152,7 +402,7 @@ var numberInputManifest = {
152
402
  dataType: "number",
153
403
  defaultData: numberInputDefaultData,
154
404
  properties: [
155
- ...commonProperties,
405
+ ...commonProperties3,
156
406
  { name: "min", label: "Minimum Value", type: "number" },
157
407
  { name: "max", label: "Maximum Value", type: "number" }
158
408
  ]
@@ -165,7 +415,7 @@ var zipCodeInputManifest = {
165
415
  dataType: "text",
166
416
  defaultData: zipCodeInputDefaultData,
167
417
  properties: [
168
- ...commonProperties,
418
+ ...commonProperties3,
169
419
  { 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." }
170
420
  ]
171
421
  };
@@ -177,7 +427,7 @@ var multiInputManifest = {
177
427
  dataType: "object",
178
428
  defaultData: multiInputDefaultData,
179
429
  properties: [
180
- ...commonProperties,
430
+ ...commonProperties3,
181
431
  { name: "fields", label: "Input Fields", type: "options", defaultValue: [], helperText: "Value column represents input type (text, number, email)" },
182
432
  ...textLimitProperties
183
433
  ]
@@ -191,22 +441,43 @@ var builderRegistry = defineBuilderRegistry({
191
441
  dateInput: dateInputBuilder,
192
442
  multiInput: multiInputBuilder,
193
443
  zipCodeInput: zipCodeInputBuilder,
444
+ singleChoice: singleChoiceBuilder,
445
+ multipleChoice: multipleChoiceBuilder,
446
+ dropdown: dropdownBuilder,
447
+ ranking: rankingBuilder,
448
+ rating: ratingBuilder,
449
+ slider: sliderBuilder,
450
+ consent: consentBuilder,
194
451
  plainText: plainTextBuilder
195
452
  });
196
453
  export {
197
454
  builderRegistry,
455
+ consentBuilder,
456
+ consentManifest,
198
457
  dateInputBuilder,
199
458
  dateInputManifest,
200
459
  defineBuilderRegistry,
201
460
  defineQuestionNode,
461
+ dropdownBuilder,
462
+ dropdownManifest,
202
463
  emailInputBuilder,
203
464
  emailInputManifest,
204
465
  multiInputBuilder,
205
466
  multiInputManifest,
467
+ multipleChoiceBuilder,
468
+ multipleChoiceManifest,
206
469
  numberInputBuilder,
207
470
  numberInputManifest,
208
471
  plainTextBuilder,
209
472
  plainTextManifest,
473
+ rankingBuilder,
474
+ rankingManifest,
475
+ ratingBuilder,
476
+ ratingManifest,
477
+ singleChoiceBuilder,
478
+ singleChoiceManifest,
479
+ sliderBuilder,
480
+ sliderManifest,
210
481
  textInputBuilder,
211
482
  textInputManifest,
212
483
  zipCodeInputBuilder,
@@ -82,4 +82,4 @@ type RegistryKeySet = Readonly<Partial<Record<SurveyNodeType, unknown>>>;
82
82
  declare function defineLogicRegistry<const TRegistry extends RegistryKeySet>(registry: TRegistry): TRegistry;
83
83
  declare function createInitialData<TData extends NodeData>(manifest: NodeManifest<SurveyNodeType, TData>): TData;
84
84
 
85
- export { type CompleteLogicRegistry as C, type DataType as D, type ExtractedValue as E, type JsonValue as J, type LogicRegistry as L, type NodeManifest as N, type PropertyField as P, type QuestionNodeType as Q, type SelectOption as S, type ValidationContext as V, type PropertyFieldType as a, type NodeData as b, type NodeLogic as c, type ExtractionContext as d, type NodeLogicContext as e, type ValidationResult as f, createInitialData as g, defineLogicRegistry as h, type SurveyNodeType as i, type NodeValue as j };
85
+ export { type CompleteLogicRegistry as C, type DataType as D, type ExtractedValue as E, type JsonValue as J, type LogicRegistry as L, type NodeManifest as N, type PropertyField as P, type QuestionNodeType as Q, type SelectOption as S, type ValidationContext as V, type PropertyFieldType as a, type NodeLogic as b, type ExtractionContext as c, type NodeLogicContext as d, type ValidationResult as e, createInitialData as f, defineLogicRegistry as g, type NodeData as h, type SurveyNodeType as i, type NodeValue as j };
package/dist/logic.d.mts CHANGED
@@ -1,79 +1,11 @@
1
- import { P as PlainTextData, a as PlainTextValue, D as DateInputData, b as TextValue, E as EmailInputData, M as MultiInputData, c as MultiInputValue, N as NumberInputData, T as TextInputData, Z as ZipCodeInputData, B as BaseTextData } from './types-BMnck1ag.mjs';
2
- import { b as NodeData, J as JsonValue, c as NodeLogic } from './coreTypes-CyFAym5A.mjs';
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
-
5
- type ConditionData$1 = {
6
- id: string;
7
- type: "group";
8
- logicType: "AND" | "OR";
9
- children: JsonValue[];
10
- };
11
- type ScaleItem = NodeData & {
12
- id?: string;
13
- exportId?: string;
14
- technicalId?: string;
15
- label?: string;
16
- value?: string;
17
- };
18
- type ScaleResponseMode = "single" | "multi";
19
- type BaseScaleData = NodeData & {
20
- label: string;
21
- description: string;
22
- condition: ConditionData$1;
23
- responseMode?: ScaleResponseMode;
24
- items: ScaleItem[];
25
- };
26
- type RatingData = BaseScaleData & {
27
- maxRating: number;
28
- };
29
- type SliderData = BaseScaleData & {
30
- min: number;
31
- max: number;
32
- step: number;
33
- startValue: number;
34
- };
35
- type ScaleValue = number | Record<string, number>;
36
-
37
- type ConditionData = {
38
- id: string;
39
- type: "group";
40
- logicType: "AND" | "OR";
41
- children: JsonValue[];
42
- };
43
- type ChoiceOption = NodeData & {
44
- id?: string;
45
- label: string;
46
- value: string;
47
- imageUrl?: string;
48
- };
49
- type BaseChoiceData = NodeData & {
50
- label: string;
51
- description: string;
52
- condition: ConditionData;
53
- options: ChoiceOption[];
54
- randomizeOptions?: boolean;
55
- };
56
- type SingleChoiceData = BaseChoiceData & {
57
- allowOther?: boolean;
58
- otherLabel?: string;
59
- };
60
- type DropdownData = BaseChoiceData & {
61
- searchable?: boolean;
62
- };
63
- type MultipleChoiceData = BaseChoiceData & {
64
- minChoices?: number;
65
- maxChoices?: number;
66
- };
67
- type RankingData = BaseChoiceData & {
68
- maxRank?: number;
69
- displayMode?: "drag" | "select";
70
- };
71
- type SingleChoiceValue = string;
72
- type MultipleChoiceValue = string[];
73
- type RankingValue = string[];
1
+ import { P as PlainTextData, d as PlainTextValue, C as ConsentData, e as ConsentValue, a as RatingData, f as ScaleValue, b as SliderData, D as DropdownData, g as SingleChoiceValue, M as MultipleChoiceData, h as MultipleChoiceValue, R as RankingData, i as RankingValue, S as SingleChoiceData, j as DateInputData, k as TextValue, E as EmailInputData, c as MultiInputData, l as MultiInputValue, N as NumberInputData, T as TextInputData, Z as ZipCodeInputData, B as BaseTextData } from './types-CR3fIHCT.mjs';
2
+ import { b as NodeLogic } from './coreTypes-YSpR0Oyh.mjs';
3
+ export { C as CompleteLogicRegistry, D as DataType, E as ExtractedValue, c as ExtractionContext, L as LogicRegistry, d as NodeLogicContext, V as ValidationContext, e as ValidationResult, f as createInitialData, g as defineLogicRegistry } from './coreTypes-YSpR0Oyh.mjs';
74
4
 
75
5
  declare const plainTextLogic: NodeLogic<"plainText", PlainTextData, PlainTextValue>;
76
6
 
7
+ declare const consentLogic: NodeLogic<"consent", ConsentData, ConsentValue>;
8
+
77
9
  declare const ratingLogic: NodeLogic<"rating", RatingData, ScaleValue>;
78
10
  declare const sliderLogic: NodeLogic<"slider", SliderData, ScaleValue>;
79
11
 
@@ -102,7 +34,8 @@ declare const logicRegistry: {
102
34
  readonly ranking: NodeLogic<"ranking", RankingData, RankingValue>;
103
35
  readonly rating: NodeLogic<"rating", RatingData, ScaleValue>;
104
36
  readonly slider: NodeLogic<"slider", SliderData, ScaleValue>;
37
+ readonly consent: NodeLogic<"consent", ConsentData, boolean>;
105
38
  readonly plainText: NodeLogic<"plainText", PlainTextData, PlainTextValue>;
106
39
  };
107
40
 
108
- export { NodeLogic, dateInputLogic, dropdownLogic, emailInputLogic, logicRegistry, multiInputLogic, multipleChoiceLogic, numberInputLogic, plainTextLogic, rankingLogic, ratingLogic, singleChoiceLogic, sliderLogic, textInputLogic, zipCodeInputLogic };
41
+ export { NodeLogic, consentLogic, dateInputLogic, dropdownLogic, emailInputLogic, logicRegistry, multiInputLogic, multipleChoiceLogic, numberInputLogic, plainTextLogic, rankingLogic, ratingLogic, singleChoiceLogic, sliderLogic, textInputLogic, zipCodeInputLogic };