form-builder-pro 0.0.1 → 0.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/index.d.mts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { z } from 'zod';
2
- import React from 'react';
3
- import * as zustand from 'zustand';
4
- export { registerWebComponents } from './web-components.mjs';
2
+ import * as zustand_vanilla from 'zustand/vanilla';
5
3
 
6
4
  type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'email' | 'phone';
7
5
  type FieldWidth = '25%' | '50%' | '100%';
@@ -71,14 +69,29 @@ declare const FormSchemaValidation: z.ZodObject<{
71
69
  }[];
72
70
  }>;
73
71
 
74
- declare const FormBuilder: React.FC;
72
+ declare class FormBuilder {
73
+ private container;
74
+ private unsubscribe;
75
+ constructor(container: HTMLElement);
76
+ private setupSubscriptions;
77
+ destroy(): void;
78
+ private render;
79
+ private renderToolbar;
80
+ private renderToolbox;
81
+ private renderCanvas;
82
+ private renderConfigPanel;
83
+ private initSortable;
84
+ }
75
85
 
76
- interface FormRendererProps {
77
- schema: FormSchema;
78
- onSubmit?: (data: Record<string, any>) => void;
79
- className?: string;
86
+ declare class FormRenderer {
87
+ private container;
88
+ private schema;
89
+ private data;
90
+ private onSubmit?;
91
+ constructor(container: HTMLElement, schema: FormSchema, onSubmit?: (data: any) => void);
92
+ setSchema(schema: FormSchema): void;
93
+ private render;
80
94
  }
81
- declare const FormRenderer: React.FC<FormRendererProps>;
82
95
 
83
96
  interface FormState {
84
97
  schema: FormSchema;
@@ -86,22 +99,24 @@ interface FormState {
86
99
  history: FormSchema[];
87
100
  historyIndex: number;
88
101
  isPreviewMode: boolean;
102
+ }
103
+ interface FormActions {
89
104
  setSchema: (schema: FormSchema) => void;
90
105
  togglePreview: () => void;
91
106
  addSection: () => void;
92
107
  removeSection: (sectionId: string) => void;
93
108
  updateSection: (sectionId: string, updates: Partial<FormSection>) => void;
94
- moveSection: (activeId: string, overId: string) => void;
109
+ moveSection: (oldIndex: number, newIndex: number) => void;
95
110
  addField: (sectionId: string, type: FieldType, index?: number) => void;
96
111
  removeField: (fieldId: string) => void;
97
112
  updateField: (fieldId: string, updates: Partial<FormField>) => void;
98
113
  selectField: (fieldId: string | null) => void;
99
- moveField: (activeId: string, overId: string, activeSectionId: string, overSectionId: string) => void;
114
+ moveField: (fieldId: string, targetSectionId: string, newIndex: number) => void;
100
115
  undo: () => void;
101
116
  redo: () => void;
102
117
  canUndo: () => boolean;
103
118
  canRedo: () => boolean;
104
119
  }
105
- declare const useFormStore: zustand.UseBoundStore<zustand.StoreApi<FormState>>;
120
+ declare const formStore: zustand_vanilla.StoreApi<FormState & FormActions>;
106
121
 
107
- export { FieldType, FieldWidth, FormBuilder, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ValidationRule, useFormStore };
122
+ export { FieldType, FieldWidth, FormBuilder, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ValidationRule, formStore };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { z } from 'zod';
2
- import React from 'react';
3
- import * as zustand from 'zustand';
4
- export { registerWebComponents } from './web-components.js';
2
+ import * as zustand_vanilla from 'zustand/vanilla';
5
3
 
6
4
  type FieldType = 'text' | 'textarea' | 'number' | 'date' | 'select' | 'checkbox' | 'radio' | 'toggle' | 'file' | 'email' | 'phone';
7
5
  type FieldWidth = '25%' | '50%' | '100%';
@@ -71,14 +69,29 @@ declare const FormSchemaValidation: z.ZodObject<{
71
69
  }[];
72
70
  }>;
73
71
 
74
- declare const FormBuilder: React.FC;
72
+ declare class FormBuilder {
73
+ private container;
74
+ private unsubscribe;
75
+ constructor(container: HTMLElement);
76
+ private setupSubscriptions;
77
+ destroy(): void;
78
+ private render;
79
+ private renderToolbar;
80
+ private renderToolbox;
81
+ private renderCanvas;
82
+ private renderConfigPanel;
83
+ private initSortable;
84
+ }
75
85
 
76
- interface FormRendererProps {
77
- schema: FormSchema;
78
- onSubmit?: (data: Record<string, any>) => void;
79
- className?: string;
86
+ declare class FormRenderer {
87
+ private container;
88
+ private schema;
89
+ private data;
90
+ private onSubmit?;
91
+ constructor(container: HTMLElement, schema: FormSchema, onSubmit?: (data: any) => void);
92
+ setSchema(schema: FormSchema): void;
93
+ private render;
80
94
  }
81
- declare const FormRenderer: React.FC<FormRendererProps>;
82
95
 
83
96
  interface FormState {
84
97
  schema: FormSchema;
@@ -86,22 +99,24 @@ interface FormState {
86
99
  history: FormSchema[];
87
100
  historyIndex: number;
88
101
  isPreviewMode: boolean;
102
+ }
103
+ interface FormActions {
89
104
  setSchema: (schema: FormSchema) => void;
90
105
  togglePreview: () => void;
91
106
  addSection: () => void;
92
107
  removeSection: (sectionId: string) => void;
93
108
  updateSection: (sectionId: string, updates: Partial<FormSection>) => void;
94
- moveSection: (activeId: string, overId: string) => void;
109
+ moveSection: (oldIndex: number, newIndex: number) => void;
95
110
  addField: (sectionId: string, type: FieldType, index?: number) => void;
96
111
  removeField: (fieldId: string) => void;
97
112
  updateField: (fieldId: string, updates: Partial<FormField>) => void;
98
113
  selectField: (fieldId: string | null) => void;
99
- moveField: (activeId: string, overId: string, activeSectionId: string, overSectionId: string) => void;
114
+ moveField: (fieldId: string, targetSectionId: string, newIndex: number) => void;
100
115
  undo: () => void;
101
116
  redo: () => void;
102
117
  canUndo: () => boolean;
103
118
  canRedo: () => boolean;
104
119
  }
105
- declare const useFormStore: zustand.UseBoundStore<zustand.StoreApi<FormState>>;
120
+ declare const formStore: zustand_vanilla.StoreApi<FormState & FormActions>;
106
121
 
107
- export { FieldType, FieldWidth, FormBuilder, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ValidationRule, useFormStore };
122
+ export { FieldType, FieldWidth, FormBuilder, FormField, FormRenderer, FormSchema, FormSchemaValidation, FormSection, ValidationRule, formStore };