@surveystudio/node-registery 1.0.0 → 1.0.2

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/ui.mjs ADDED
@@ -0,0 +1,32 @@
1
+ // src/ui/plainText.ts
2
+ import { createElement } from "react";
3
+ var cn = (...values) => values.filter(Boolean).join(" ") || void 0;
4
+ function Root({ className, ...props }) {
5
+ return createElement("div", { ...props, className: cn(className) });
6
+ }
7
+ function Content({ className, ...props }) {
8
+ return createElement("div", { ...props, className: cn(className) });
9
+ }
10
+ function Title({ className, ...props }) {
11
+ return createElement("p", { ...props, className: cn(className) });
12
+ }
13
+ function Description({ className, ...props }) {
14
+ return createElement("p", { ...props, className: cn(className) });
15
+ }
16
+ function Actions({ className, ...props }) {
17
+ return createElement("div", { ...props, className: cn(className) });
18
+ }
19
+ function Button({ className, type = "button", ...props }) {
20
+ return createElement("button", { ...props, className: cn(className), type });
21
+ }
22
+ var PlainTextNode = {
23
+ Root,
24
+ Content,
25
+ Title,
26
+ Description,
27
+ Actions,
28
+ Button
29
+ };
30
+ export {
31
+ PlainTextNode
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surveystudio/node-registery",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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",
@@ -21,7 +21,11 @@
21
21
  "import": "./dist/builder.mjs",
22
22
  "types": "./dist/builder.d.mts"
23
23
  },
24
- "./package.json": "./package.json"
24
+ "./package.json": "./package.json",
25
+ "./ui": {
26
+ "import": "./dist/ui.mjs",
27
+ "types": "./dist/ui.d.mts"
28
+ }
25
29
  },
26
30
  "keywords": [
27
31
  "survey",
@@ -42,7 +46,7 @@
42
46
  "react-dom": "^19.2.3"
43
47
  },
44
48
  "scripts": {
45
- "test": "node --test test/*.test.mjs",
49
+ "test": "pnpm build && node --test test/*.test.mjs",
46
50
  "typecheck": "tsc --noEmit",
47
51
  "build": "tsup",
48
52
  "prepack": "pnpm build",
@@ -1,140 +0,0 @@
1
- import { ReactNode, ComponentType } from 'react';
2
-
3
- declare const QUESTION_NODE_TYPES: readonly ["textInput", "numberInput", "emailInput", "dateInput", "multiInput", "zipCodeInput", "singleChoice", "multipleChoice", "dropdown", "ranking", "cascadingChoice", "matrixChoice", "rating", "slider", "consent", "captcha", "image", "video", "audio", "plainText", "emojiRating"];
4
- declare const FLOW_NODE_TYPES: readonly ["start", "end", "branch", "validation"];
5
- type QuestionNodeType = (typeof QUESTION_NODE_TYPES)[number];
6
- type FlowNodeType = (typeof FLOW_NODE_TYPES)[number];
7
- type SurveyNodeType = QuestionNodeType | FlowNodeType;
8
- type NodeCategory = "input" | "choice" | "logic" | "media" | "flow";
9
- type PrimitiveValue = string | number | boolean | null;
10
- type JsonValue = PrimitiveValue | JsonValue[] | {
11
- [key: string]: JsonValue;
12
- };
13
- type NodeData = Record<string, JsonValue | undefined>;
14
- type NodeValue = JsonValue | undefined;
15
- type DataType = "text" | "number" | "boolean" | "option" | "array" | "object" | "none";
16
- type PropertyFieldType = "text" | "textarea" | "number" | "switch" | "select" | "color" | "options" | "condition" | "stepBuilder" | "fileTextarea" | "file" | "files" | "emojiOptions";
17
- interface SelectOption {
18
- readonly label: string;
19
- readonly value: string;
20
- }
21
- interface PropertyField<TData extends NodeData = NodeData> {
22
- readonly name: keyof TData & string;
23
- readonly label: string;
24
- readonly type: PropertyFieldType;
25
- readonly placeholder?: string;
26
- readonly helperText?: string;
27
- readonly defaultValue?: JsonValue;
28
- readonly options?: readonly SelectOption[];
29
- readonly visible?: (data: Readonly<TData>) => boolean;
30
- readonly min?: number;
31
- readonly max?: number;
32
- }
33
- interface NodeManifest<TType extends SurveyNodeType = SurveyNodeType, TData extends NodeData = NodeData> {
34
- readonly type: TType;
35
- readonly label: string;
36
- readonly description: string;
37
- readonly category: NodeCategory;
38
- readonly dataType: DataType;
39
- readonly defaultData: Readonly<TData>;
40
- readonly properties: readonly PropertyField<TData>[];
41
- }
42
- interface ValidationResult {
43
- readonly valid: boolean;
44
- readonly error?: string;
45
- }
46
- interface ExtractedValue {
47
- readonly questionId?: string;
48
- readonly columnKey?: string;
49
- readonly columnLabel?: string;
50
- readonly textValue?: string;
51
- readonly numberValue?: number;
52
- readonly booleanValue?: boolean;
53
- readonly optionUuid?: string;
54
- readonly optionText?: string;
55
- readonly arrayValue?: readonly JsonValue[];
56
- readonly objectValue?: Readonly<Record<string, JsonValue>>;
57
- readonly metadata?: Readonly<Record<string, JsonValue>>;
58
- }
59
- interface ExtractionContext<TType extends SurveyNodeType = SurveyNodeType> {
60
- readonly nodeId: string;
61
- readonly nodeType: TType;
62
- readonly questionLabel?: string;
63
- }
64
- interface NodeLogic<TType extends SurveyNodeType = SurveyNodeType, TData extends NodeData = NodeData, TValue extends NodeValue = NodeValue> {
65
- readonly type: TType;
66
- readonly dataType: DataType;
67
- readonly defaultData: Readonly<TData>;
68
- readonly defaultValue?: TValue;
69
- validate(value: TValue, nodeData: Readonly<TData>): ValidationResult;
70
- extractValue(value: TValue, nodeData: Readonly<TData>, context: ExtractionContext<TType>): readonly ExtractedValue[];
71
- }
72
- interface NodeRunnerProps<TData extends NodeData = NodeData, TValue extends NodeValue = NodeValue> {
73
- readonly data: Readonly<TData>;
74
- readonly value: TValue;
75
- readonly onChange: (newValue: TValue) => void;
76
- readonly onNext?: () => void;
77
- readonly error?: string;
78
- readonly isActive?: boolean;
79
- }
80
- interface NodeRunner<TType extends SurveyNodeType = SurveyNodeType, TData extends NodeData = NodeData, TValue extends NodeValue = NodeValue> {
81
- readonly type: TType;
82
- readonly Component: ComponentType<NodeRunnerProps<TData, TValue>>;
83
- }
84
- interface NodeBuilderProps<TData extends NodeData = NodeData> {
85
- readonly data: Readonly<TData>;
86
- readonly onChange: (newData: TData) => void;
87
- }
88
- interface NodeCanvasProps<TData extends NodeData = NodeData> {
89
- readonly id: string;
90
- readonly type: SurveyNodeType;
91
- readonly data: Readonly<TData>;
92
- readonly selected?: boolean;
93
- }
94
- interface NodeBuilder<TType extends SurveyNodeType = SurveyNodeType, TData extends NodeData = NodeData> {
95
- readonly type: TType;
96
- readonly label: string;
97
- readonly icon?: ReactNode;
98
- readonly SettingsComponent?: ComponentType<NodeBuilderProps<TData>>;
99
- readonly CanvasComponent?: ComponentType<NodeCanvasProps<TData>>;
100
- }
101
- interface QuestionNodeDefinition<TType extends QuestionNodeType = QuestionNodeType, TData extends NodeData = NodeData, TValue extends NodeValue = NodeValue> {
102
- readonly manifest: NodeManifest<TType, TData>;
103
- readonly logic: NodeLogic<TType, TData, TValue>;
104
- readonly builder: NodeBuilder<TType, TData>;
105
- readonly runner: NodeRunner<TType, TData, TValue>;
106
- }
107
- type CompleteLogicRegistry<TType extends QuestionNodeType = QuestionNodeType> = Readonly<Record<TType, NodeLogic<TType, NodeData, NodeValue>>>;
108
- type CompleteBuilderRegistry<TType extends QuestionNodeType = QuestionNodeType> = Readonly<Record<TType, NodeBuilder<TType, NodeData>>>;
109
- type CompleteRunnerRegistry<TType extends QuestionNodeType = QuestionNodeType> = Readonly<Record<TType, NodeRunner<TType, NodeData, NodeValue>>>;
110
- type LogicRegistry<TType extends SurveyNodeType = SurveyNodeType> = Readonly<Partial<{
111
- [K in TType]: NodeLogic<K, NodeData, NodeValue>;
112
- }>>;
113
- type BuilderRegistry<TType extends SurveyNodeType = SurveyNodeType> = Readonly<Partial<{
114
- [K in TType]: NodeBuilder<K, NodeData>;
115
- }>>;
116
- type RunnerRegistry<TType extends SurveyNodeType = SurveyNodeType> = Readonly<Partial<{
117
- [K in TType]: NodeRunner<K, NodeData, NodeValue>;
118
- }>>;
119
- declare function defineQuestionNode<const TType extends QuestionNodeType, TData extends NodeData, TValue extends NodeValue>(definition: QuestionNodeDefinition<TType, TData, TValue>): QuestionNodeDefinition<TType, TData, TValue>;
120
- type RegistryKeySet = Readonly<Partial<Record<SurveyNodeType, unknown>>>;
121
- declare function defineLogicRegistry<const TRegistry extends RegistryKeySet>(registry: TRegistry): TRegistry;
122
- declare function defineBuilderRegistry<const TRegistry extends RegistryKeySet>(registry: TRegistry): TRegistry;
123
- declare function defineRunnerRegistry<const TRegistry extends RegistryKeySet>(registry: TRegistry): TRegistry;
124
-
125
- type PlainTextData = NodeData & {
126
- label: string;
127
- description: string;
128
- buttonLabel: string;
129
- condition: {
130
- id: string;
131
- type: "group";
132
- logicType: "AND" | "OR";
133
- children: JsonValue[];
134
- };
135
- };
136
- type PlainTextValue = {
137
- viewed: boolean;
138
- };
139
-
140
- export { type BuilderRegistry as B, type CompleteLogicRegistry as C, type DataType as D, type ExtractedValue as E, type JsonValue as J, type LogicRegistry as L, type NodeLogic as N, type PlainTextData as P, type QuestionNodeDefinition as Q, type RunnerRegistry as R, type SelectOption as S, type ValidationResult as V, type PlainTextValue as a, type ExtractionContext as b, defineQuestionNode as c, defineLogicRegistry as d, type NodeRunnerProps as e, type CompleteRunnerRegistry as f, type NodeRunner as g, defineRunnerRegistry as h, type NodeBuilderProps as i, type NodeCanvasProps as j, type CompleteBuilderRegistry as k, type NodeBuilder as l, type NodeManifest as m, type PropertyField as n, type PropertyFieldType as o, defineBuilderRegistry as p };