@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/logic.mjs CHANGED
@@ -67,17 +67,58 @@ var plainTextLogic = {
67
67
  ]
68
68
  };
69
69
 
70
- // src/nodes/scale/manifest.ts
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: defaultCondition,
121
+ condition: defaultCondition2,
81
122
  responseMode: "single",
82
123
  items: []
83
124
  };
@@ -99,9 +140,8 @@ var commonProperties = [
99
140
  name: "condition",
100
141
  label: "Logic Rule",
101
142
  type: "condition",
102
- defaultValue: defaultCondition
103
- },
104
- { name: "items", label: "Items", type: "options", defaultValue: [] }
143
+ defaultValue: defaultCondition2
144
+ }
105
145
  ];
106
146
  var ratingDefaultData = {
107
147
  ...baseScaleData,
@@ -125,6 +165,7 @@ var ratingManifest = {
125
165
  defaultData: ratingDefaultData,
126
166
  properties: [
127
167
  ...commonProperties,
168
+ { name: "items", label: "Questions/Items", type: "options", defaultValue: [], visible: (data) => data.responseMode === "multi" },
128
169
  { name: "maxRating", label: "Max Stars", type: "number", defaultValue: 5 }
129
170
  ]
130
171
  };
@@ -137,6 +178,7 @@ var sliderManifest = {
137
178
  defaultData: sliderDefaultData,
138
179
  properties: [
139
180
  ...commonProperties,
181
+ { name: "items", label: "Items to Rate", type: "options", defaultValue: [], visible: (data) => data.responseMode === "multi" },
140
182
  { name: "min", label: "Minimum", type: "number", defaultValue: 0 },
141
183
  { name: "max", label: "Maximum", type: "number", defaultValue: 10 },
142
184
  { name: "step", label: "Step", type: "number", defaultValue: 1, min: 0 },
@@ -235,7 +277,7 @@ var sliderLogic = {
235
277
  };
236
278
 
237
279
  // src/nodes/choice/manifest.ts
238
- var defaultCondition2 = {
280
+ var defaultCondition3 = {
239
281
  id: "root",
240
282
  type: "group",
241
283
  logicType: "AND",
@@ -244,7 +286,7 @@ var defaultCondition2 = {
244
286
  var baseChoiceData = {
245
287
  label: "",
246
288
  description: "",
247
- condition: defaultCondition2,
289
+ condition: defaultCondition3,
248
290
  options: [],
249
291
  randomizeOptions: false
250
292
  };
@@ -255,27 +297,34 @@ var commonProperties2 = [
255
297
  name: "condition",
256
298
  label: "Logic Rule",
257
299
  type: "condition",
258
- defaultValue: defaultCondition2
300
+ defaultValue: defaultCondition3
259
301
  },
260
302
  { name: "options", label: "Options", type: "options", defaultValue: [] },
261
- { name: "bulkOptions", label: "Bulk Add (one per line)", type: "textarea", placeholder: "Option A\nOption B\nOption C..." }
303
+ { 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" }
262
304
  ];
263
305
  var singleChoiceDefaultData = {
264
306
  ...baseChoiceData,
265
307
  label: "Single Choice",
266
308
  allowOther: false,
267
- otherLabel: "Other"
309
+ otherLabel: "Other (Please specify)",
310
+ allowNone: false,
311
+ noneLabel: "None of these"
268
312
  };
269
313
  var dropdownDefaultData = {
270
314
  ...baseChoiceData,
271
- label: "Dropdown",
315
+ label: "Dropdown Select",
316
+ placeholder: "Select an option...",
272
317
  searchable: true
273
318
  };
274
319
  var multipleChoiceDefaultData = {
275
320
  ...baseChoiceData,
276
321
  label: "Multiple Choice",
277
322
  minChoices: 0,
278
- maxChoices: 0
323
+ maxChoices: 0,
324
+ allowOther: false,
325
+ otherLabel: "Other (Please specify)",
326
+ allowNone: false,
327
+ noneLabel: "None of these"
279
328
  };
280
329
  var rankingDefaultData = {
281
330
  ...baseChoiceData,
@@ -286,26 +335,29 @@ var rankingDefaultData = {
286
335
  var singleChoiceManifest = {
287
336
  type: "singleChoice",
288
337
  label: "Single Choice",
289
- description: "Select one option",
338
+ description: "Select one option from a list",
290
339
  category: "choice",
291
340
  dataType: "option",
292
341
  defaultData: singleChoiceDefaultData,
293
342
  properties: [
294
343
  ...commonProperties2,
295
- { name: "allowOther", label: "Allow Other", type: "switch", defaultValue: false },
296
- { name: "otherLabel", label: "Other Label", type: "text", defaultValue: "Other" },
344
+ { name: "allowOther", label: 'Allow "Other" Option', type: "switch", defaultValue: false },
345
+ { name: "otherLabel", label: '"Other" Placeholder', type: "text", placeholder: "Other (Please specify)", helperText: "Label for the open-ended option" },
346
+ { name: "allowNone", label: 'Allow "None of these"', type: "switch", defaultValue: false },
347
+ { name: "noneLabel", label: '"None" Label', type: "text", placeholder: "None of these", visible: (data) => Boolean(data.allowNone) },
297
348
  { name: "randomizeOptions", label: "Randomize Options", type: "switch", defaultValue: false }
298
349
  ]
299
350
  };
300
351
  var dropdownManifest = {
301
352
  type: "dropdown",
302
- label: "Dropdown",
353
+ label: "Dropdown Select",
303
354
  description: "Select from a dropdown menu",
304
355
  category: "choice",
305
356
  dataType: "option",
306
357
  defaultData: dropdownDefaultData,
307
358
  properties: [
308
359
  ...commonProperties2,
360
+ { name: "placeholder", label: "Placeholder Text", type: "text", placeholder: "Select an option..." },
309
361
  { name: "searchable", label: "Searchable", type: "switch", defaultValue: true }
310
362
  ]
311
363
  };
@@ -318,9 +370,12 @@ var multipleChoiceManifest = {
318
370
  defaultData: multipleChoiceDefaultData,
319
371
  properties: [
320
372
  ...commonProperties2,
321
- { name: "minChoices", label: "Minimum Choices", type: "number", defaultValue: 0 },
322
- { name: "maxChoices", label: "Maximum Choices", type: "number", defaultValue: 0 },
323
- { name: "randomizeOptions", label: "Randomize Options", type: "switch", defaultValue: false }
373
+ { name: "maxChoices", label: "Maximum Choices", type: "number", helperText: "Limit how many options a user can select. Leave empty for no limit.", defaultValue: 0 },
374
+ { name: "allowOther", label: 'Allow "Other" Option', type: "switch", defaultValue: false },
375
+ { name: "otherLabel", label: '"Other" Placeholder', type: "text", placeholder: "Other (Please specify)" },
376
+ { name: "allowNone", label: 'Allow "None of these"', type: "switch", defaultValue: false },
377
+ { name: "noneLabel", label: '"None" Label', type: "text", placeholder: "None of these", visible: (data) => Boolean(data.allowNone) },
378
+ { name: "randomizeOptions", label: "Randomize Options", type: "switch", defaultValue: false, helperText: "Shuffle options for every viewer" }
324
379
  ]
325
380
  };
326
381
  var rankingManifest = {
@@ -332,7 +387,6 @@ var rankingManifest = {
332
387
  defaultData: rankingDefaultData,
333
388
  properties: [
334
389
  ...commonProperties2,
335
- { name: "maxRank", label: "Maximum Rank", type: "number", defaultValue: 0 },
336
390
  {
337
391
  name: "displayMode",
338
392
  label: "Display Mode",
@@ -340,7 +394,7 @@ var rankingManifest = {
340
394
  defaultValue: "drag",
341
395
  options: [
342
396
  { label: "Drag and Drop", value: "drag" },
343
- { label: "Dropdown Selection", value: "select" }
397
+ { label: "Select Rank", value: "select" }
344
398
  ]
345
399
  }
346
400
  ]
@@ -446,7 +500,7 @@ var rankingLogic = {
446
500
  };
447
501
 
448
502
  // src/nodes/textLike/manifest.ts
449
- var defaultCondition3 = {
503
+ var defaultCondition4 = {
450
504
  id: "root",
451
505
  type: "group",
452
506
  logicType: "AND",
@@ -455,7 +509,7 @@ var defaultCondition3 = {
455
509
  var baseTextData = {
456
510
  label: "",
457
511
  description: "",
458
- condition: defaultCondition3,
512
+ condition: defaultCondition4,
459
513
  minChars: 0,
460
514
  maxChars: 0,
461
515
  minWords: 0,
@@ -468,7 +522,7 @@ var commonProperties3 = [
468
522
  name: "condition",
469
523
  label: "Logic Rule",
470
524
  type: "condition",
471
- defaultValue: defaultCondition3
525
+ defaultValue: defaultCondition4
472
526
  }
473
527
  ];
474
528
  var textLimitProperties = [
@@ -721,9 +775,11 @@ var logicRegistry = defineLogicRegistry({
721
775
  ranking: rankingLogic,
722
776
  rating: ratingLogic,
723
777
  slider: sliderLogic,
778
+ consent: consentLogic,
724
779
  plainText: plainTextLogic
725
780
  });
726
781
  export {
782
+ consentLogic,
727
783
  createInitialData,
728
784
  dateInputLogic,
729
785
  defineLogicRegistry,
package/dist/runner.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- export { e as CompleteRunnerRegistry, f as NodeRunner, g as NodeRunnerProps, Q as QuestionNodeDefinition, R as RunnerRegistry, c as defineQuestionNode, h as defineRunnerRegistry } from './types-4zXsOMLb.mjs';
1
+ export { e as CompleteRunnerRegistry, f as NodeRunner, g as NodeRunnerProps, Q as QuestionNodeDefinition, R as RunnerRegistry, c as defineQuestionNode, h as defineRunnerRegistry } from './types-CgiAR_DF.mjs';
2
2
  import 'react';
3
- import './coreTypes-CyFAym5A.mjs';
3
+ import './coreTypes-YSpR0Oyh.mjs';
4
4
 
5
5
  declare const plainTextRunner: {
6
6
  type: "plainText";
@@ -0,0 +1,151 @@
1
+ import { h as NodeData, J as JsonValue } from './coreTypes-YSpR0Oyh.mjs';
2
+
3
+ type PlainTextData = NodeData & {
4
+ label: string;
5
+ description: string;
6
+ buttonLabel: string;
7
+ condition: {
8
+ id: string;
9
+ type: "group";
10
+ logicType: "AND" | "OR";
11
+ children: JsonValue[];
12
+ };
13
+ };
14
+ type PlainTextValue = {
15
+ viewed: boolean;
16
+ };
17
+
18
+ type ConditionData$3 = {
19
+ id: string;
20
+ type: "group";
21
+ logicType: "AND" | "OR";
22
+ children: JsonValue[];
23
+ };
24
+ type ConsentData = NodeData & {
25
+ label: string;
26
+ description: string;
27
+ condition: ConditionData$3;
28
+ checkboxLabel: string;
29
+ disagreeLabel?: string;
30
+ };
31
+ type ConsentValue = boolean;
32
+
33
+ type ConditionData$2 = {
34
+ id: string;
35
+ type: "group";
36
+ logicType: "AND" | "OR";
37
+ children: JsonValue[];
38
+ };
39
+ type ChoiceOption = NodeData & {
40
+ id?: string;
41
+ label: string;
42
+ value: string;
43
+ imageUrl?: string;
44
+ };
45
+ type BaseChoiceData = NodeData & {
46
+ label: string;
47
+ description: string;
48
+ condition: ConditionData$2;
49
+ options: ChoiceOption[];
50
+ randomizeOptions?: boolean;
51
+ };
52
+ type SingleChoiceData = BaseChoiceData & {
53
+ allowOther?: boolean;
54
+ otherLabel?: string;
55
+ allowNone?: boolean;
56
+ noneLabel?: string;
57
+ };
58
+ type DropdownData = BaseChoiceData & {
59
+ placeholder?: string;
60
+ searchable?: boolean;
61
+ };
62
+ type MultipleChoiceData = BaseChoiceData & {
63
+ minChoices?: number;
64
+ maxChoices?: number;
65
+ allowOther?: boolean;
66
+ otherLabel?: string;
67
+ allowNone?: boolean;
68
+ noneLabel?: string;
69
+ };
70
+ type RankingData = BaseChoiceData & {
71
+ maxRank?: number;
72
+ displayMode?: "drag" | "select";
73
+ };
74
+ type SingleChoiceValue = string;
75
+ type MultipleChoiceValue = string[];
76
+ type RankingValue = string[];
77
+
78
+ type ConditionData$1 = {
79
+ id: string;
80
+ type: "group";
81
+ logicType: "AND" | "OR";
82
+ children: JsonValue[];
83
+ };
84
+ type ScaleItem = NodeData & {
85
+ id?: string;
86
+ exportId?: string;
87
+ technicalId?: string;
88
+ label?: string;
89
+ value?: string;
90
+ };
91
+ type ScaleResponseMode = "single" | "multi";
92
+ type BaseScaleData = NodeData & {
93
+ label: string;
94
+ description: string;
95
+ condition: ConditionData$1;
96
+ responseMode?: ScaleResponseMode;
97
+ items: ScaleItem[];
98
+ };
99
+ type RatingData = BaseScaleData & {
100
+ maxRating: number;
101
+ };
102
+ type SliderData = BaseScaleData & {
103
+ min: number;
104
+ max: number;
105
+ step: number;
106
+ startValue: number;
107
+ };
108
+ type ScaleValue = number | Record<string, number>;
109
+
110
+ type ConditionData = {
111
+ id: string;
112
+ type: "group";
113
+ logicType: "AND" | "OR";
114
+ children: JsonValue[];
115
+ };
116
+ type TextLimitData = NodeData & {
117
+ minChars?: number;
118
+ maxChars?: number;
119
+ minWords?: number;
120
+ maxWords?: number;
121
+ };
122
+ type BaseTextData = TextLimitData & {
123
+ label: string;
124
+ description: string;
125
+ condition: ConditionData;
126
+ };
127
+ type TextInputData = BaseTextData & {
128
+ placeholder: string;
129
+ longAnswer: boolean;
130
+ };
131
+ type EmailInputData = BaseTextData;
132
+ type DateInputData = BaseTextData;
133
+ type NumberInputData = BaseTextData & {
134
+ min?: number;
135
+ max?: number;
136
+ };
137
+ type ZipCodeInputData = BaseTextData & {
138
+ allowedZips: string;
139
+ };
140
+ type MultiInputField = {
141
+ id: string;
142
+ label?: string;
143
+ value?: string;
144
+ };
145
+ type MultiInputData = BaseTextData & {
146
+ fields: MultiInputField[];
147
+ };
148
+ type TextValue = string;
149
+ type MultiInputValue = Record<string, string>;
150
+
151
+ export type { BaseTextData as B, ConsentData as C, DropdownData as D, EmailInputData as E, MultipleChoiceData as M, NumberInputData as N, PlainTextData as P, RankingData as R, SingleChoiceData as S, TextInputData as T, ZipCodeInputData as Z, RatingData as a, SliderData as b, MultiInputData as c, PlainTextValue as d, ConsentValue as e, ScaleValue as f, SingleChoiceValue as g, MultipleChoiceValue as h, RankingValue as i, DateInputData as j, TextValue as k, MultiInputValue as l };
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ComponentType } from 'react';
2
- import { i as SurveyNodeType, b as NodeData, Q as QuestionNodeType, j as NodeValue, N as NodeManifest, c as NodeLogic } from './coreTypes-CyFAym5A.mjs';
2
+ import { i as SurveyNodeType, h as NodeData, Q as QuestionNodeType, j as NodeValue, N as NodeManifest, b as NodeLogic } from './coreTypes-YSpR0Oyh.mjs';
3
3
 
4
4
  interface NodeRunnerProps<TData extends NodeData = NodeData, TValue extends NodeValue = NodeValue> {
5
5
  readonly data: Readonly<TData>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surveystudio/node-registery",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Typed survey question node registry with split builder, runner, and logic entrypoints.",
5
5
  "main": "./dist/logic.mjs",
6
6
  "types": "./dist/logic.d.mts",
@@ -1,59 +0,0 @@
1
- import { b as NodeData, J as JsonValue } from './coreTypes-CyFAym5A.mjs';
2
-
3
- type PlainTextData = NodeData & {
4
- label: string;
5
- description: string;
6
- buttonLabel: string;
7
- condition: {
8
- id: string;
9
- type: "group";
10
- logicType: "AND" | "OR";
11
- children: JsonValue[];
12
- };
13
- };
14
- type PlainTextValue = {
15
- viewed: boolean;
16
- };
17
-
18
- type ConditionData = {
19
- id: string;
20
- type: "group";
21
- logicType: "AND" | "OR";
22
- children: JsonValue[];
23
- };
24
- type TextLimitData = NodeData & {
25
- minChars?: number;
26
- maxChars?: number;
27
- minWords?: number;
28
- maxWords?: number;
29
- };
30
- type BaseTextData = TextLimitData & {
31
- label: string;
32
- description: string;
33
- condition: ConditionData;
34
- };
35
- type TextInputData = BaseTextData & {
36
- placeholder: string;
37
- longAnswer: boolean;
38
- };
39
- type EmailInputData = BaseTextData;
40
- type DateInputData = BaseTextData;
41
- type NumberInputData = BaseTextData & {
42
- min?: number;
43
- max?: number;
44
- };
45
- type ZipCodeInputData = BaseTextData & {
46
- allowedZips: string;
47
- };
48
- type MultiInputField = {
49
- id: string;
50
- label?: string;
51
- value?: string;
52
- };
53
- type MultiInputData = BaseTextData & {
54
- fields: MultiInputField[];
55
- };
56
- type TextValue = string;
57
- type MultiInputValue = Record<string, string>;
58
-
59
- export type { BaseTextData as B, DateInputData as D, EmailInputData as E, MultiInputData as M, NumberInputData as N, PlainTextData as P, TextInputData as T, ZipCodeInputData as Z, PlainTextValue as a, TextValue as b, MultiInputValue as c };