@squaredr/fieldcraft-pro 1.6.4 → 1.8.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.
@@ -1,2 +1,2 @@
1
- export { PRESET_FAMILIES, PREVIEW_SCHEMA, ThemeEditor, ThemeEditorThemeProvider, resolveThemeFromDOM, themeEditorDarkPreset, themeEditorLightPreset, useEditorTheme } from '../chunk-CFVT2R42.mjs';
2
- import '../chunk-VECQKSWS.mjs';
1
+ export { PRESET_FAMILIES, PREVIEW_SCHEMA, ThemeEditor, ThemeEditorThemeProvider, resolveThemeFromDOM, themeEditorDarkPreset, themeEditorLightPreset, useEditorTheme } from '../chunk-CYXJGOQH.mjs';
2
+ import '../chunk-4MMKB2EW.mjs';
@@ -0,0 +1,217 @@
1
+ import { ReactNode } from 'react';
2
+ import { FormEngineSchema, QuestionType, FormEngineTheme, FormEngine, FormResponse, Section, Question, Option } from '@squaredr/fieldcraft-core';
3
+ import { FieldRegistry } from '@squaredr/fieldcraft-react';
4
+
5
+ /**
6
+ * FormBuilder theme configuration.
7
+ * All values are CSS color strings (hex, oklch, hsl, etc.).
8
+ * Set these to customize the builder's appearance.
9
+ */
10
+ type FormBuilderTheme = {
11
+ /** Main background of the entire builder */
12
+ background?: string;
13
+ /** Primary text color */
14
+ foreground?: string;
15
+ /** Card/panel background */
16
+ card?: string;
17
+ /** Primary accent color (buttons, selection, focus rings) */
18
+ primary?: string;
19
+ /** Text color on primary backgrounds */
20
+ primaryForeground?: string;
21
+ /** Secondary surfaces */
22
+ secondary?: string;
23
+ /** Text on secondary surfaces */
24
+ secondaryForeground?: string;
25
+ /** Muted background (disabled, subtle areas) */
26
+ muted?: string;
27
+ /** Muted text (labels, placeholders) */
28
+ mutedForeground?: string;
29
+ /** Hover/accent background */
30
+ accent?: string;
31
+ /** Text on accent background */
32
+ accentForeground?: string;
33
+ /** Destructive action color */
34
+ destructive?: string;
35
+ /** Text on destructive backgrounds */
36
+ destructiveForeground?: string;
37
+ /** Default border color */
38
+ border?: string;
39
+ /** Input border color */
40
+ input?: string;
41
+ /** Focus ring color */
42
+ ring?: string;
43
+ /** Border radius base (e.g. "6px", "0.375rem") */
44
+ radius?: string;
45
+ /** Surface color for panels/sidebars */
46
+ surface?: string;
47
+ /** Surface hover state */
48
+ surfaceHover?: string;
49
+ /** Main canvas background */
50
+ canvas?: string;
51
+ /** Panel background (palette, property panel) */
52
+ panel?: string;
53
+ /** Strong border color (for emphasis) */
54
+ borderStrong?: string;
55
+ /** Dim text color (secondary labels) */
56
+ textDim?: string;
57
+ };
58
+
59
+ type FormBuilderProps = {
60
+ /** Initial schema to load. If not provided, uses a default empty schema */
61
+ initialSchema?: FormEngineSchema;
62
+ /** URL to fetch schema JSON from on mount. Overrides initialSchema when provided and fetch succeeds. */
63
+ schemaUrl?: string;
64
+ /** Callback when schema changes */
65
+ onChange?: (schema: FormEngineSchema) => void;
66
+ /** Callback when user clicks "Save" */
67
+ onSave?: (schema: FormEngineSchema) => void;
68
+ /** Height of the builder container */
69
+ height?: string | number;
70
+ /** Theme customization — overrides CSS variables for all builder components */
71
+ theme?: FormBuilderTheme;
72
+ /** Additional CSS class name on the root element */
73
+ className?: string;
74
+ /** Extra content rendered in the toolbar, after the Save button */
75
+ toolbarExtra?: ReactNode;
76
+ /** Additional question type metadata — merged with built-in defaults (e.g. telehealth fields) */
77
+ questionTypes?: Record<string, QuestionTypeInfo>;
78
+ /** Additional palette categories — appended to built-in palette (e.g. telehealth categories) */
79
+ palette?: PaletteCategory[];
80
+ /** Configuration for the built-in preview mode renderer */
81
+ preview?: FormBuilderPreviewProps;
82
+ /** Templates to show in the template gallery */
83
+ templates?: FormBuilderTemplate[];
84
+ };
85
+ type FormBuilderPreviewProps = {
86
+ /** Theme passed to FormEngineRenderer in preview mode */
87
+ theme?: FormEngineTheme;
88
+ /** Custom field components for preview (e.g. telehealth fields) */
89
+ components?: FieldRegistry;
90
+ /** Callback when FormEngine is ready in preview mode */
91
+ onReady?: (engine: FormEngine) => void;
92
+ /** Callback when a field value changes in preview mode */
93
+ onFieldChange?: (fieldId: string, value: unknown) => void;
94
+ /** Callback when the preview form is submitted */
95
+ onSubmit?: (response: FormResponse) => void | Promise<void>;
96
+ };
97
+ type FormBuilderTemplate = {
98
+ meta: {
99
+ id: string;
100
+ name: string;
101
+ description: string;
102
+ category: string;
103
+ fieldCount: number;
104
+ sectionCount: number;
105
+ tags?: string[];
106
+ };
107
+ schema: FormEngineSchema;
108
+ };
109
+ type BuilderState = {
110
+ schema: FormEngineSchema;
111
+ selectedItem: SelectedItem | null;
112
+ isDirty: boolean;
113
+ };
114
+ type SelectedItem = {
115
+ type: "question";
116
+ sectionId: string;
117
+ questionId: string;
118
+ } | {
119
+ type: "section";
120
+ sectionId: string;
121
+ };
122
+ type DragItem = {
123
+ type: "palette-item";
124
+ questionType: QuestionType;
125
+ } | {
126
+ type: "question";
127
+ sectionId: string;
128
+ questionId: string;
129
+ questionIndex: number;
130
+ } | {
131
+ type: "section";
132
+ sectionId: string;
133
+ sectionIndex: number;
134
+ };
135
+ type DropTarget = {
136
+ type: "section";
137
+ sectionId: string;
138
+ index: number;
139
+ } | {
140
+ type: "canvas";
141
+ index: number;
142
+ };
143
+ type QuestionTypeCategory = "text" | "numeric" | "selection" | "datetime" | "media" | "advanced" | "structural" | "content" | (string & {});
144
+ type PaletteCategory = {
145
+ category: string;
146
+ label: string;
147
+ types: string[];
148
+ };
149
+ type QuestionTypeInfo = {
150
+ type: QuestionType;
151
+ label: string;
152
+ category: QuestionTypeCategory;
153
+ icon: string;
154
+ description: string;
155
+ defaultConfig?: Record<string, unknown>;
156
+ requiresOptions?: boolean;
157
+ };
158
+ type PropertyPanelTab = "basic" | "validation" | "logic" | "advanced" | "options";
159
+ type MutationAction = {
160
+ type: "add-section";
161
+ section: Section;
162
+ index: number;
163
+ } | {
164
+ type: "remove-section";
165
+ sectionId: string;
166
+ } | {
167
+ type: "update-section";
168
+ sectionId: string;
169
+ updates: Partial<Section>;
170
+ } | {
171
+ type: "move-section";
172
+ sectionId: string;
173
+ newIndex: number;
174
+ } | {
175
+ type: "add-question";
176
+ sectionId: string;
177
+ question: Question;
178
+ index: number;
179
+ } | {
180
+ type: "remove-question";
181
+ sectionId: string;
182
+ questionId: string;
183
+ } | {
184
+ type: "update-question";
185
+ sectionId: string;
186
+ questionId: string;
187
+ updates: Partial<Question>;
188
+ } | {
189
+ type: "move-question";
190
+ sectionId: string;
191
+ questionId: string;
192
+ targetSectionId: string;
193
+ newIndex: number;
194
+ } | {
195
+ type: "duplicate-question";
196
+ sectionId: string;
197
+ questionId: string;
198
+ } | {
199
+ type: "add-option";
200
+ sectionId: string;
201
+ questionId: string;
202
+ option: Option;
203
+ index: number;
204
+ } | {
205
+ type: "remove-option";
206
+ sectionId: string;
207
+ questionId: string;
208
+ optionIndex: number;
209
+ } | {
210
+ type: "update-option";
211
+ sectionId: string;
212
+ questionId: string;
213
+ optionIndex: number;
214
+ updates: Partial<Option>;
215
+ };
216
+
217
+ export type { BuilderState as B, DragItem as D, FormBuilderPreviewProps as F, MutationAction as M, PaletteCategory as P, QuestionTypeCategory as Q, SelectedItem as S, DropTarget as a, FormBuilderProps as b, FormBuilderTemplate as c, FormBuilderTheme as d, PropertyPanelTab as e, QuestionTypeInfo as f };
@@ -0,0 +1,217 @@
1
+ import { ReactNode } from 'react';
2
+ import { FormEngineSchema, QuestionType, FormEngineTheme, FormEngine, FormResponse, Section, Question, Option } from '@squaredr/fieldcraft-core';
3
+ import { FieldRegistry } from '@squaredr/fieldcraft-react';
4
+
5
+ /**
6
+ * FormBuilder theme configuration.
7
+ * All values are CSS color strings (hex, oklch, hsl, etc.).
8
+ * Set these to customize the builder's appearance.
9
+ */
10
+ type FormBuilderTheme = {
11
+ /** Main background of the entire builder */
12
+ background?: string;
13
+ /** Primary text color */
14
+ foreground?: string;
15
+ /** Card/panel background */
16
+ card?: string;
17
+ /** Primary accent color (buttons, selection, focus rings) */
18
+ primary?: string;
19
+ /** Text color on primary backgrounds */
20
+ primaryForeground?: string;
21
+ /** Secondary surfaces */
22
+ secondary?: string;
23
+ /** Text on secondary surfaces */
24
+ secondaryForeground?: string;
25
+ /** Muted background (disabled, subtle areas) */
26
+ muted?: string;
27
+ /** Muted text (labels, placeholders) */
28
+ mutedForeground?: string;
29
+ /** Hover/accent background */
30
+ accent?: string;
31
+ /** Text on accent background */
32
+ accentForeground?: string;
33
+ /** Destructive action color */
34
+ destructive?: string;
35
+ /** Text on destructive backgrounds */
36
+ destructiveForeground?: string;
37
+ /** Default border color */
38
+ border?: string;
39
+ /** Input border color */
40
+ input?: string;
41
+ /** Focus ring color */
42
+ ring?: string;
43
+ /** Border radius base (e.g. "6px", "0.375rem") */
44
+ radius?: string;
45
+ /** Surface color for panels/sidebars */
46
+ surface?: string;
47
+ /** Surface hover state */
48
+ surfaceHover?: string;
49
+ /** Main canvas background */
50
+ canvas?: string;
51
+ /** Panel background (palette, property panel) */
52
+ panel?: string;
53
+ /** Strong border color (for emphasis) */
54
+ borderStrong?: string;
55
+ /** Dim text color (secondary labels) */
56
+ textDim?: string;
57
+ };
58
+
59
+ type FormBuilderProps = {
60
+ /** Initial schema to load. If not provided, uses a default empty schema */
61
+ initialSchema?: FormEngineSchema;
62
+ /** URL to fetch schema JSON from on mount. Overrides initialSchema when provided and fetch succeeds. */
63
+ schemaUrl?: string;
64
+ /** Callback when schema changes */
65
+ onChange?: (schema: FormEngineSchema) => void;
66
+ /** Callback when user clicks "Save" */
67
+ onSave?: (schema: FormEngineSchema) => void;
68
+ /** Height of the builder container */
69
+ height?: string | number;
70
+ /** Theme customization — overrides CSS variables for all builder components */
71
+ theme?: FormBuilderTheme;
72
+ /** Additional CSS class name on the root element */
73
+ className?: string;
74
+ /** Extra content rendered in the toolbar, after the Save button */
75
+ toolbarExtra?: ReactNode;
76
+ /** Additional question type metadata — merged with built-in defaults (e.g. telehealth fields) */
77
+ questionTypes?: Record<string, QuestionTypeInfo>;
78
+ /** Additional palette categories — appended to built-in palette (e.g. telehealth categories) */
79
+ palette?: PaletteCategory[];
80
+ /** Configuration for the built-in preview mode renderer */
81
+ preview?: FormBuilderPreviewProps;
82
+ /** Templates to show in the template gallery */
83
+ templates?: FormBuilderTemplate[];
84
+ };
85
+ type FormBuilderPreviewProps = {
86
+ /** Theme passed to FormEngineRenderer in preview mode */
87
+ theme?: FormEngineTheme;
88
+ /** Custom field components for preview (e.g. telehealth fields) */
89
+ components?: FieldRegistry;
90
+ /** Callback when FormEngine is ready in preview mode */
91
+ onReady?: (engine: FormEngine) => void;
92
+ /** Callback when a field value changes in preview mode */
93
+ onFieldChange?: (fieldId: string, value: unknown) => void;
94
+ /** Callback when the preview form is submitted */
95
+ onSubmit?: (response: FormResponse) => void | Promise<void>;
96
+ };
97
+ type FormBuilderTemplate = {
98
+ meta: {
99
+ id: string;
100
+ name: string;
101
+ description: string;
102
+ category: string;
103
+ fieldCount: number;
104
+ sectionCount: number;
105
+ tags?: string[];
106
+ };
107
+ schema: FormEngineSchema;
108
+ };
109
+ type BuilderState = {
110
+ schema: FormEngineSchema;
111
+ selectedItem: SelectedItem | null;
112
+ isDirty: boolean;
113
+ };
114
+ type SelectedItem = {
115
+ type: "question";
116
+ sectionId: string;
117
+ questionId: string;
118
+ } | {
119
+ type: "section";
120
+ sectionId: string;
121
+ };
122
+ type DragItem = {
123
+ type: "palette-item";
124
+ questionType: QuestionType;
125
+ } | {
126
+ type: "question";
127
+ sectionId: string;
128
+ questionId: string;
129
+ questionIndex: number;
130
+ } | {
131
+ type: "section";
132
+ sectionId: string;
133
+ sectionIndex: number;
134
+ };
135
+ type DropTarget = {
136
+ type: "section";
137
+ sectionId: string;
138
+ index: number;
139
+ } | {
140
+ type: "canvas";
141
+ index: number;
142
+ };
143
+ type QuestionTypeCategory = "text" | "numeric" | "selection" | "datetime" | "media" | "advanced" | "structural" | "content" | (string & {});
144
+ type PaletteCategory = {
145
+ category: string;
146
+ label: string;
147
+ types: string[];
148
+ };
149
+ type QuestionTypeInfo = {
150
+ type: QuestionType;
151
+ label: string;
152
+ category: QuestionTypeCategory;
153
+ icon: string;
154
+ description: string;
155
+ defaultConfig?: Record<string, unknown>;
156
+ requiresOptions?: boolean;
157
+ };
158
+ type PropertyPanelTab = "basic" | "validation" | "logic" | "advanced" | "options";
159
+ type MutationAction = {
160
+ type: "add-section";
161
+ section: Section;
162
+ index: number;
163
+ } | {
164
+ type: "remove-section";
165
+ sectionId: string;
166
+ } | {
167
+ type: "update-section";
168
+ sectionId: string;
169
+ updates: Partial<Section>;
170
+ } | {
171
+ type: "move-section";
172
+ sectionId: string;
173
+ newIndex: number;
174
+ } | {
175
+ type: "add-question";
176
+ sectionId: string;
177
+ question: Question;
178
+ index: number;
179
+ } | {
180
+ type: "remove-question";
181
+ sectionId: string;
182
+ questionId: string;
183
+ } | {
184
+ type: "update-question";
185
+ sectionId: string;
186
+ questionId: string;
187
+ updates: Partial<Question>;
188
+ } | {
189
+ type: "move-question";
190
+ sectionId: string;
191
+ questionId: string;
192
+ targetSectionId: string;
193
+ newIndex: number;
194
+ } | {
195
+ type: "duplicate-question";
196
+ sectionId: string;
197
+ questionId: string;
198
+ } | {
199
+ type: "add-option";
200
+ sectionId: string;
201
+ questionId: string;
202
+ option: Option;
203
+ index: number;
204
+ } | {
205
+ type: "remove-option";
206
+ sectionId: string;
207
+ questionId: string;
208
+ optionIndex: number;
209
+ } | {
210
+ type: "update-option";
211
+ sectionId: string;
212
+ questionId: string;
213
+ optionIndex: number;
214
+ updates: Partial<Option>;
215
+ };
216
+
217
+ export type { BuilderState as B, DragItem as D, FormBuilderPreviewProps as F, MutationAction as M, PaletteCategory as P, QuestionTypeCategory as Q, SelectedItem as S, DropTarget as a, FormBuilderProps as b, FormBuilderTemplate as c, FormBuilderTheme as d, PropertyPanelTab as e, QuestionTypeInfo as f };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squaredr/fieldcraft-pro",
3
- "version": "1.6.4",
3
+ "version": "1.8.0",
4
4
  "description": "Pro components for FieldCraft — visual drag-and-drop Form Builder, Response Viewer, and Theme Editor for React",
5
5
  "keywords": [
6
6
  "fieldcraft",
@@ -40,6 +40,11 @@
40
40
  "import": "./dist/theme-editor/index.mjs",
41
41
  "require": "./dist/theme-editor/index.js"
42
42
  },
43
+ "./templates": {
44
+ "types": "./dist/templates/index.d.ts",
45
+ "import": "./dist/templates/index.mjs",
46
+ "require": "./dist/templates/index.js"
47
+ },
43
48
  "./styles.css": "./dist/styles.css",
44
49
  "./theme-editor/styles.css": "./theme-editor/styles.css"
45
50
  },
@@ -58,45 +63,52 @@
58
63
  "@dnd-kit/sortable": "^8.0.0",
59
64
  "@dnd-kit/utilities": "^3.2.2",
60
65
  "@monaco-editor/react": "^4.6.0",
66
+ "@radix-ui/react-select": "^2.3.7",
61
67
  "@xyflow/react": "^12.11.3",
62
68
  "clsx": "^2.1.1",
63
69
  "lucide-react": "^1.16.0",
64
70
  "tailwind-merge": "^3.6.0"
65
71
  },
66
72
  "peerDependencies": {
67
- "@squaredr/fieldcraft-core": "^1.6.0",
68
- "@squaredr/fieldcraft-react": "^1.6.0",
73
+ "@squaredr/fieldcraft-core": "^1.8.1",
74
+ "@squaredr/fieldcraft-react": "^1.9.0",
75
+ "@squaredr/paykit": "^0.10.0",
69
76
  "@squaredr/paykit-react": "^1.0.0",
70
- "@squaredr/paykit-stripe": "^1.0.0",
71
77
  "react": "^18 || ^19",
72
78
  "react-dom": "^18 || ^19"
73
79
  },
74
80
  "peerDependenciesMeta": {
75
- "@squaredr/paykit-react": {
81
+ "@squaredr/paykit": {
76
82
  "optional": true
77
83
  },
78
- "@squaredr/paykit-stripe": {
84
+ "@squaredr/paykit-react": {
79
85
  "optional": true
80
86
  }
81
87
  },
82
88
  "devDependencies": {
83
- "@squaredr/fieldcraft-core": "^1.6.0",
84
- "@squaredr/fieldcraft-react": "^1.6.0",
89
+ "@squaredr/fieldcraft-core": "^1.8.1",
90
+ "@squaredr/fieldcraft-react": "^1.9.0",
91
+ "@squaredr/paykit": "^0.10.1",
92
+ "@squaredr/paykit-react": "^1.1.0",
85
93
  "@tailwindcss/cli": "^4.3.0",
94
+ "@testing-library/jest-dom": "^7.0.1",
95
+ "@testing-library/react": "^16.3.3",
96
+ "@testing-library/user-event": "^14.6.6",
86
97
  "@types/react": "^19.2.14",
87
98
  "@types/react-dom": "^19.2.3",
99
+ "jsdom": "^30.0.1",
88
100
  "react": "^19.2.4",
89
101
  "react-dom": "^19.2.4",
90
102
  "tailwindcss": "^4.3.0",
91
103
  "tsup": "^8.0",
92
104
  "typescript": "^5.5",
93
105
  "vitest": "^2.0",
94
- "@squaredr/fieldcraft-pro-license": "1.2.0",
95
- "@squaredr/fieldcraft-pro-tsconfig": "0.0.1"
106
+ "@squaredr/fieldcraft-pro-tsconfig": "0.0.1",
107
+ "@squaredr/fieldcraft-pro-license": "1.4.0"
96
108
  },
97
109
  "license": "SEE LICENSE IN LICENSE.txt",
98
110
  "author": "SquaredR",
99
- "homepage": "https://squaredr.tech/products/fieldcraft/admin-pro",
111
+ "homepage": "https://fieldcraft.squaredr.tech/pro",
100
112
  "repository": {
101
113
  "type": "git",
102
114
  "url": "https://github.com/SquaredR98/fieldcraft-pro.git",