form-builder-pro 0.0.5 → 0.0.7
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/index.css +118 -18
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +59 -6
- package/dist/index.d.ts +59 -6
- package/dist/index.js +831 -31988
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +829 -31989
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,18 @@ import { z } from 'zod';
|
|
|
2
2
|
import * as zustand_vanilla from 'zustand/vanilla';
|
|
3
3
|
|
|
4
4
|
type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'email' | 'phone';
|
|
5
|
-
type FieldWidth = '25%' | '50%' | '100%';
|
|
5
|
+
type FieldWidth = '25%' | '33%' | '50%' | '66%' | '75%' | '100%';
|
|
6
6
|
interface ValidationRule {
|
|
7
7
|
type: 'required' | 'min' | 'max' | 'minLength' | 'maxLength' | 'pattern' | 'email';
|
|
8
8
|
value?: string | number | boolean;
|
|
9
9
|
message?: string;
|
|
10
|
+
regex?: string;
|
|
11
|
+
}
|
|
12
|
+
interface AsyncOptionSource {
|
|
13
|
+
api: string;
|
|
14
|
+
method: 'GET' | 'POST';
|
|
15
|
+
labelKey: string;
|
|
16
|
+
valueKey: string;
|
|
10
17
|
}
|
|
11
18
|
interface FormField {
|
|
12
19
|
id: string;
|
|
@@ -20,15 +27,21 @@ interface FormField {
|
|
|
20
27
|
label: string;
|
|
21
28
|
value: string;
|
|
22
29
|
}[];
|
|
30
|
+
optionsSource?: AsyncOptionSource;
|
|
23
31
|
validation?: ValidationRule[];
|
|
24
32
|
width: FieldWidth;
|
|
25
33
|
hidden?: boolean;
|
|
34
|
+
position?: {
|
|
35
|
+
row: number;
|
|
36
|
+
column: number;
|
|
37
|
+
};
|
|
26
38
|
}
|
|
27
39
|
interface FormSection {
|
|
28
40
|
id: string;
|
|
29
41
|
title: string;
|
|
30
42
|
fields: FormField[];
|
|
31
43
|
isExpanded?: boolean;
|
|
44
|
+
columns?: 1 | 2 | 3;
|
|
32
45
|
}
|
|
33
46
|
interface FormSchema {
|
|
34
47
|
id: string;
|
|
@@ -73,18 +86,34 @@ declare const FormSchemaValidation: z.ZodObject<{
|
|
|
73
86
|
}[];
|
|
74
87
|
}>;
|
|
75
88
|
|
|
89
|
+
interface FormBuilderOptions {
|
|
90
|
+
existingForms?: FormSchema[];
|
|
91
|
+
reusableSections?: FormSection[];
|
|
92
|
+
mode?: 'create' | 'edit';
|
|
93
|
+
formJson?: FormSchema;
|
|
94
|
+
onSave?: (schema: FormSchema) => void;
|
|
95
|
+
onClone?: (schema: FormSchema) => void;
|
|
96
|
+
onSectionImported?: (section: FormSection) => void;
|
|
97
|
+
onTemplateSave?: (template: FormSection) => void;
|
|
98
|
+
}
|
|
76
99
|
declare class FormBuilder {
|
|
77
100
|
private container;
|
|
78
101
|
private unsubscribe;
|
|
79
|
-
private
|
|
80
|
-
constructor(container: HTMLElement, options?:
|
|
81
|
-
|
|
82
|
-
|
|
102
|
+
private options;
|
|
103
|
+
constructor(container: HTMLElement, options?: FormBuilderOptions);
|
|
104
|
+
loadForm(json: FormSchema): void;
|
|
105
|
+
cloneForm(json: FormSchema): void;
|
|
106
|
+
importSection(section: FormSection): void;
|
|
107
|
+
saveSectionAsTemplate(section: FormSection): void;
|
|
108
|
+
applyTemplate(template: FormSection): void;
|
|
109
|
+
updateExistingForms(forms: FormSchema[]): void;
|
|
83
110
|
private setupSubscriptions;
|
|
84
111
|
destroy(): void;
|
|
85
112
|
private render;
|
|
86
113
|
private renderToolbar;
|
|
114
|
+
private activeTab;
|
|
87
115
|
private renderToolbox;
|
|
116
|
+
private renderImportList;
|
|
88
117
|
private renderCanvas;
|
|
89
118
|
private renderConfigPanel;
|
|
90
119
|
private initSortable;
|
|
@@ -106,10 +135,17 @@ interface FormState {
|
|
|
106
135
|
history: FormSchema[];
|
|
107
136
|
historyIndex: number;
|
|
108
137
|
isPreviewMode: boolean;
|
|
138
|
+
existingForms: FormSchema[];
|
|
139
|
+
templates: FormSection[];
|
|
109
140
|
}
|
|
110
141
|
interface FormActions {
|
|
111
142
|
setSchema: (schema: FormSchema) => void;
|
|
112
143
|
togglePreview: () => void;
|
|
144
|
+
setExistingForms: (forms: FormSchema[]) => void;
|
|
145
|
+
setTemplates: (templates: FormSection[]) => void;
|
|
146
|
+
loadForm: (formId: string) => void;
|
|
147
|
+
cloneExistingForm: (formId: string) => void;
|
|
148
|
+
importSection: (section: FormSection) => void;
|
|
113
149
|
addSection: () => void;
|
|
114
150
|
removeSection: (sectionId: string) => void;
|
|
115
151
|
updateSection: (sectionId: string, updates: Partial<FormSection>) => void;
|
|
@@ -126,4 +162,21 @@ interface FormActions {
|
|
|
126
162
|
}
|
|
127
163
|
declare const formStore: zustand_vanilla.StoreApi<FormState & FormActions>;
|
|
128
164
|
|
|
129
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Transforms Form Builder JSON to Platform JSON
|
|
167
|
+
* @param builderSchema
|
|
168
|
+
* @returns
|
|
169
|
+
*/
|
|
170
|
+
declare const builderToPlatform: (builderSchema: FormSchema) => any;
|
|
171
|
+
/**
|
|
172
|
+
* Transforms Platform JSON to Form Builder JSON
|
|
173
|
+
* @param platformSchema
|
|
174
|
+
* @returns
|
|
175
|
+
*/
|
|
176
|
+
declare const platformToBuilder: (platformSchema: any) => FormSchema;
|
|
177
|
+
|
|
178
|
+
declare const initFormBuilder: (options: FormBuilderOptions & {
|
|
179
|
+
containerId: string;
|
|
180
|
+
}) => FormBuilder;
|
|
181
|
+
|
|
182
|
+
export { AsyncOptionSource, FieldType, FieldWidth, FormBuilder, FormBuilderOptions, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ValidationRule, builderToPlatform, formStore, initFormBuilder, platformToBuilder };
|