@aatulwork/customform-renderer 1.0.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.
@@ -0,0 +1,352 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1 from 'react';
3
+
4
+ /**
5
+ * Core types for Custom Form Renderer
6
+ */
7
+ interface OptionItem {
8
+ label: string;
9
+ value: string | number;
10
+ icon?: string;
11
+ group?: string;
12
+ }
13
+ type FieldType = 'text' | 'email' | 'number' | 'select' | 'checkbox' | 'radio' | 'datepicker' | 'file' | 'ckeditor' | 'toggle' | 'color' | 'formReference' | 'apiReference';
14
+ interface FieldValidation {
15
+ min?: number;
16
+ max?: number;
17
+ pattern?: string;
18
+ maxFileSize?: number;
19
+ allowedFileTypes?: string[];
20
+ }
21
+ interface FormField {
22
+ type: FieldType;
23
+ label: string;
24
+ name: string;
25
+ required?: boolean;
26
+ placeholder?: string;
27
+ allowFilter?: boolean;
28
+ options?: OptionItem[] | string[];
29
+ validation?: FieldValidation;
30
+ referenceFormName?: string;
31
+ referenceFieldName?: string;
32
+ apiEndpoint?: string;
33
+ referenceModel?: string;
34
+ apiLabelField?: string;
35
+ apiValueField?: string;
36
+ allowMultiple?: boolean;
37
+ datePickerMode?: 'date' | 'datetime' | 'time';
38
+ /** @deprecated Use datePickerMode instead */
39
+ displayTime?: boolean;
40
+ }
41
+ interface FormSection {
42
+ id: string;
43
+ title: string;
44
+ description?: string;
45
+ fields: FormField[];
46
+ }
47
+ interface FormSchema {
48
+ _id?: string;
49
+ id?: string;
50
+ title: string;
51
+ name: string;
52
+ module?: string | null;
53
+ formType?: 'system' | 'custom';
54
+ collectionName?: string;
55
+ sections?: FormSection[];
56
+ fields?: FormField[];
57
+ settings?: {
58
+ sectionDisplayMode?: 'panel' | 'stepper';
59
+ fieldsPerRow?: number;
60
+ [key: string]: any;
61
+ };
62
+ createdAt?: string;
63
+ updatedAt?: string;
64
+ }
65
+ interface FormRendererProps {
66
+ formSchema: FormSchema;
67
+ onSubmit?: (data: Record<string, any>) => void | Promise<void>;
68
+ onCancel?: () => void;
69
+ isLoading?: boolean;
70
+ onSuccess?: () => void;
71
+ initialValues?: Record<string, any>;
72
+ hideTitle?: boolean;
73
+ allowResetOnValuesChange?: boolean;
74
+ mode?: 'edit' | 'view';
75
+ services?: FormServices;
76
+ }
77
+ interface FormServices {
78
+ fileUpload?: FileUploadService;
79
+ formReference?: FormReferenceService;
80
+ apiReference?: ApiReferenceService;
81
+ dateFormatter?: DateFormatterService;
82
+ SelectComponent?: React.ComponentType<any>;
83
+ FileDisplayComponent?: React.ComponentType<{
84
+ fieldValue: any;
85
+ }>;
86
+ CKEditorDisplayComponent?: React.ComponentType<{
87
+ content: string;
88
+ maxLength?: number;
89
+ showViewButton?: boolean;
90
+ }>;
91
+ fileBaseUrl?: string;
92
+ ckEditorLicenseKey?: string;
93
+ ckEditorScriptPath?: string;
94
+ }
95
+ interface FileUploadService {
96
+ uploadFiles: (formName: string, fieldName: string, files: File[]) => Promise<UploadedFile[]>;
97
+ }
98
+ interface UploadedFile {
99
+ _id?: string;
100
+ fileName: string;
101
+ originalName?: string;
102
+ fileUrl: string;
103
+ size?: number;
104
+ mimeType?: string;
105
+ [key: string]: any;
106
+ }
107
+ interface FormReferenceService {
108
+ fetchOptions: (formName: string, fieldName: string) => Promise<OptionItem[]>;
109
+ }
110
+ interface ApiReferenceService {
111
+ fetchOptions: (endpoint: string, labelField: string, valueField?: string) => Promise<OptionItem[]>;
112
+ }
113
+ interface DateFormatterService {
114
+ format: (value: any, options?: {
115
+ datePickerMode?: 'date' | 'datetime' | 'time';
116
+ }) => string;
117
+ }
118
+ interface FieldRendererProps {
119
+ field: FormField;
120
+ control: any;
121
+ defaultValue: any;
122
+ rules: any;
123
+ errors: any;
124
+ setValue: any;
125
+ formSchema?: FormSchema;
126
+ uploadingFiles?: Record<string, boolean>;
127
+ setUploadingFiles?: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
128
+ setError?: (name: string, error: {
129
+ type: string;
130
+ message: string;
131
+ }) => void;
132
+ clearErrors?: (name?: string) => void;
133
+ services?: FormServices;
134
+ }
135
+
136
+ declare const FormRenderer: ({ formSchema, onSubmit, onCancel, isLoading, onSuccess, initialValues, hideTitle, allowResetOnValuesChange, mode, services, }: FormRendererProps) => react_jsx_runtime.JSX.Element;
137
+
138
+ interface FieldRendererComponentProps extends Omit<FieldRendererProps, 'defaultValue' | 'rules'> {
139
+ formSchema: any;
140
+ uploadingFiles: Record<string, boolean>;
141
+ setUploadingFiles: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
142
+ setError: (name: string, error: {
143
+ type: string;
144
+ message: string;
145
+ }) => void;
146
+ clearErrors: (name?: string) => void;
147
+ }
148
+ declare const FieldRenderer: (props: FieldRendererComponentProps) => react_jsx_runtime.JSX.Element | null;
149
+
150
+ interface FormViewModeProps {
151
+ formSchema: FormSchema;
152
+ initialValues?: Record<string, any>;
153
+ hideTitle?: boolean;
154
+ services?: FormServices;
155
+ }
156
+ declare const FormViewMode: ({ formSchema, initialValues, hideTitle, services }: FormViewModeProps) => react_jsx_runtime.JSX.Element;
157
+
158
+ interface FieldViewProps {
159
+ field: FormField;
160
+ value: any;
161
+ services?: FormServices;
162
+ }
163
+ declare const FieldView: ({ field, value, services }: FieldViewProps) => react_jsx_runtime.JSX.Element;
164
+
165
+ declare const TextField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
166
+
167
+ declare const SelectField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
168
+
169
+ declare const CheckboxField: ({ field, control, defaultValue, rules }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
170
+
171
+ declare const RadioField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
172
+
173
+ declare const ToggleField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
174
+
175
+ declare const ColorField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
176
+
177
+ declare const DateTimePickerField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
178
+
179
+ declare global {
180
+ interface Window {
181
+ ClassicEditor: any;
182
+ }
183
+ }
184
+ declare const CKEditorField: ({ field, control, defaultValue, rules, errors, setValue, formSchema, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
185
+
186
+ interface FileFieldProps extends FieldRendererProps {
187
+ uploadingFiles?: Record<string, boolean>;
188
+ setUploadingFiles?: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
189
+ setError?: (name: string, error: {
190
+ type: string;
191
+ message: string;
192
+ }) => void;
193
+ clearErrors?: (name?: string) => void;
194
+ }
195
+ declare const FileField: ({ field, control, defaultValue, rules, errors, formSchema, uploadingFiles, setUploadingFiles, setError, clearErrors, services, }: FileFieldProps) => react_jsx_runtime.JSX.Element;
196
+
197
+ declare const FormReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
198
+ declare const ApiReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
199
+
200
+ interface SimpleSelectOption {
201
+ value: string | number;
202
+ label: string;
203
+ }
204
+ interface SimpleSelectProps {
205
+ label: string;
206
+ value: string | string[] | number | number[] | null | undefined;
207
+ onChange: (value: string | string[] | null) => void;
208
+ options: SimpleSelectOption[];
209
+ placeholder?: string;
210
+ helperText?: string;
211
+ fullWidth?: boolean;
212
+ size?: 'small' | 'medium';
213
+ required?: boolean;
214
+ error?: boolean;
215
+ disabled?: boolean;
216
+ multiple?: boolean;
217
+ isLoading?: boolean;
218
+ }
219
+ declare const SimpleSelect: React$1.FC<SimpleSelectProps>;
220
+
221
+ /**
222
+ * Get all fields from form schema (sections or legacy fields)
223
+ */
224
+ declare const getAllFields: (formSchema: FormSchema) => FormField[];
225
+ /**
226
+ * Normalize initial values to handle backward compatibility
227
+ * - Single value -> array for multiple fields
228
+ * - Array -> first element for single fields
229
+ */
230
+ declare const normalizeInitialValues: (values: Record<string, any>, formSchema: FormSchema) => Record<string, any>;
231
+ /**
232
+ * Get default value for a field based on its type
233
+ */
234
+ declare const getDefaultValue: (field: FormField) => any;
235
+ /**
236
+ * Transform form values based on field types.
237
+ */
238
+ declare const transformFormValues: (data: Record<string, any>, formSchema: FormSchema) => Record<string, any>;
239
+
240
+ /**
241
+ * Format file size in human-readable format
242
+ */
243
+ declare const formatFileSize: (bytes: number) => string;
244
+ /**
245
+ * Validate file based on field configuration
246
+ */
247
+ declare const validateFile: (file: File, field: FormField) => string | true;
248
+ /**
249
+ * Build validation rules for a field
250
+ */
251
+ declare const buildFieldRules: (field: FormField) => any;
252
+ /**
253
+ * Normalize options to OptionItem format
254
+ */
255
+ declare const normalizeOptions: (options?: FormField["options"]) => Array<{
256
+ label: string;
257
+ value: string | number;
258
+ }>;
259
+
260
+ /**
261
+ * CKEditor Loader Utility
262
+ *
263
+ * This utility helps load CKEditor from the lib/ckeditor/ckeditor.js file
264
+ * and provides a way to check if CKEditor is available.
265
+ */
266
+ /**
267
+ * Load CKEditor script dynamically
268
+ * @param scriptPath - Path to ckeditor.js file (default: '/lib/ckeditor/ckeditor.js')
269
+ * @returns Promise that resolves when CKEditor is loaded
270
+ */
271
+ declare const loadCKEditor: (scriptPath?: string) => Promise<void>;
272
+ /**
273
+ * Check if CKEditor is available
274
+ * @returns true if ClassicEditor is available on window
275
+ */
276
+ declare const isCKEditorAvailable: () => boolean;
277
+ /**
278
+ * Wait for CKEditor to be available
279
+ * @param timeout - Maximum time to wait in milliseconds (default: 10000)
280
+ * @returns Promise that resolves when CKEditor is available
281
+ */
282
+ declare const waitForCKEditor: (timeout?: number) => Promise<void>;
283
+
284
+ interface UseCKEditorOptions {
285
+ /**
286
+ * Path to CKEditor script (default: '/lib/ckeditor/ckeditor.js')
287
+ */
288
+ scriptPath?: string;
289
+ /**
290
+ * Auto-load CKEditor if not available (default: true)
291
+ */
292
+ autoLoad?: boolean;
293
+ /**
294
+ * Timeout for waiting for CKEditor (default: 10000ms)
295
+ */
296
+ timeout?: number;
297
+ }
298
+ interface UseCKEditorReturn {
299
+ /**
300
+ * Whether CKEditor is ready
301
+ */
302
+ isReady: boolean;
303
+ /**
304
+ * Loading state
305
+ */
306
+ isLoading: boolean;
307
+ /**
308
+ * Error if loading failed
309
+ */
310
+ error: Error | null;
311
+ /**
312
+ * Manually trigger loading
313
+ */
314
+ load: () => Promise<void>;
315
+ }
316
+ /**
317
+ * React hook for loading and checking CKEditor availability
318
+ *
319
+ * @example
320
+ * ```tsx
321
+ * const { isReady, isLoading, error } = useCKEditor();
322
+ *
323
+ * if (!isReady) {
324
+ * return <div>Loading CKEditor...</div>;
325
+ * }
326
+ * ```
327
+ */
328
+ declare const useCKEditor: (options?: UseCKEditorOptions) => UseCKEditorReturn;
329
+
330
+ /**
331
+ * Default service implementations
332
+ * These are fallback implementations that can be overridden
333
+ */
334
+
335
+ /**
336
+ * Default file upload service - throws error, must be provided
337
+ */
338
+ declare const defaultFileUploadService: FileUploadService;
339
+ /**
340
+ * Default form reference service - throws error, must be provided
341
+ */
342
+ declare const defaultFormReferenceService: FormReferenceService;
343
+ /**
344
+ * Default API reference service - throws error, must be provided
345
+ */
346
+ declare const defaultApiReferenceService: ApiReferenceService;
347
+ /**
348
+ * Default date formatter service
349
+ */
350
+ declare const defaultDateFormatterService: DateFormatterService;
351
+
352
+ export { ApiReferenceField, type ApiReferenceService, CKEditorField, CheckboxField, ColorField, type DateFormatterService, DateTimePickerField, FieldRenderer, type FieldRendererProps, type FieldType, type FieldValidation, FieldView, FileField, type FileUploadService, type FormField, FormReferenceField, type FormReferenceService, FormRenderer, type FormRendererProps, type FormSchema, type FormSection, type FormServices, FormViewMode, type OptionItem, RadioField, SelectField, SimpleSelect, type SimpleSelectOption, type SimpleSelectProps, TextField, ToggleField, type UploadedFile, buildFieldRules, defaultApiReferenceService, defaultDateFormatterService, defaultFileUploadService, defaultFormReferenceService, formatFileSize, getAllFields, getDefaultValue, isCKEditorAvailable, loadCKEditor, normalizeInitialValues, normalizeOptions, transformFormValues, useCKEditor, validateFile, waitForCKEditor };
@@ -0,0 +1,352 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React$1 from 'react';
3
+
4
+ /**
5
+ * Core types for Custom Form Renderer
6
+ */
7
+ interface OptionItem {
8
+ label: string;
9
+ value: string | number;
10
+ icon?: string;
11
+ group?: string;
12
+ }
13
+ type FieldType = 'text' | 'email' | 'number' | 'select' | 'checkbox' | 'radio' | 'datepicker' | 'file' | 'ckeditor' | 'toggle' | 'color' | 'formReference' | 'apiReference';
14
+ interface FieldValidation {
15
+ min?: number;
16
+ max?: number;
17
+ pattern?: string;
18
+ maxFileSize?: number;
19
+ allowedFileTypes?: string[];
20
+ }
21
+ interface FormField {
22
+ type: FieldType;
23
+ label: string;
24
+ name: string;
25
+ required?: boolean;
26
+ placeholder?: string;
27
+ allowFilter?: boolean;
28
+ options?: OptionItem[] | string[];
29
+ validation?: FieldValidation;
30
+ referenceFormName?: string;
31
+ referenceFieldName?: string;
32
+ apiEndpoint?: string;
33
+ referenceModel?: string;
34
+ apiLabelField?: string;
35
+ apiValueField?: string;
36
+ allowMultiple?: boolean;
37
+ datePickerMode?: 'date' | 'datetime' | 'time';
38
+ /** @deprecated Use datePickerMode instead */
39
+ displayTime?: boolean;
40
+ }
41
+ interface FormSection {
42
+ id: string;
43
+ title: string;
44
+ description?: string;
45
+ fields: FormField[];
46
+ }
47
+ interface FormSchema {
48
+ _id?: string;
49
+ id?: string;
50
+ title: string;
51
+ name: string;
52
+ module?: string | null;
53
+ formType?: 'system' | 'custom';
54
+ collectionName?: string;
55
+ sections?: FormSection[];
56
+ fields?: FormField[];
57
+ settings?: {
58
+ sectionDisplayMode?: 'panel' | 'stepper';
59
+ fieldsPerRow?: number;
60
+ [key: string]: any;
61
+ };
62
+ createdAt?: string;
63
+ updatedAt?: string;
64
+ }
65
+ interface FormRendererProps {
66
+ formSchema: FormSchema;
67
+ onSubmit?: (data: Record<string, any>) => void | Promise<void>;
68
+ onCancel?: () => void;
69
+ isLoading?: boolean;
70
+ onSuccess?: () => void;
71
+ initialValues?: Record<string, any>;
72
+ hideTitle?: boolean;
73
+ allowResetOnValuesChange?: boolean;
74
+ mode?: 'edit' | 'view';
75
+ services?: FormServices;
76
+ }
77
+ interface FormServices {
78
+ fileUpload?: FileUploadService;
79
+ formReference?: FormReferenceService;
80
+ apiReference?: ApiReferenceService;
81
+ dateFormatter?: DateFormatterService;
82
+ SelectComponent?: React.ComponentType<any>;
83
+ FileDisplayComponent?: React.ComponentType<{
84
+ fieldValue: any;
85
+ }>;
86
+ CKEditorDisplayComponent?: React.ComponentType<{
87
+ content: string;
88
+ maxLength?: number;
89
+ showViewButton?: boolean;
90
+ }>;
91
+ fileBaseUrl?: string;
92
+ ckEditorLicenseKey?: string;
93
+ ckEditorScriptPath?: string;
94
+ }
95
+ interface FileUploadService {
96
+ uploadFiles: (formName: string, fieldName: string, files: File[]) => Promise<UploadedFile[]>;
97
+ }
98
+ interface UploadedFile {
99
+ _id?: string;
100
+ fileName: string;
101
+ originalName?: string;
102
+ fileUrl: string;
103
+ size?: number;
104
+ mimeType?: string;
105
+ [key: string]: any;
106
+ }
107
+ interface FormReferenceService {
108
+ fetchOptions: (formName: string, fieldName: string) => Promise<OptionItem[]>;
109
+ }
110
+ interface ApiReferenceService {
111
+ fetchOptions: (endpoint: string, labelField: string, valueField?: string) => Promise<OptionItem[]>;
112
+ }
113
+ interface DateFormatterService {
114
+ format: (value: any, options?: {
115
+ datePickerMode?: 'date' | 'datetime' | 'time';
116
+ }) => string;
117
+ }
118
+ interface FieldRendererProps {
119
+ field: FormField;
120
+ control: any;
121
+ defaultValue: any;
122
+ rules: any;
123
+ errors: any;
124
+ setValue: any;
125
+ formSchema?: FormSchema;
126
+ uploadingFiles?: Record<string, boolean>;
127
+ setUploadingFiles?: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
128
+ setError?: (name: string, error: {
129
+ type: string;
130
+ message: string;
131
+ }) => void;
132
+ clearErrors?: (name?: string) => void;
133
+ services?: FormServices;
134
+ }
135
+
136
+ declare const FormRenderer: ({ formSchema, onSubmit, onCancel, isLoading, onSuccess, initialValues, hideTitle, allowResetOnValuesChange, mode, services, }: FormRendererProps) => react_jsx_runtime.JSX.Element;
137
+
138
+ interface FieldRendererComponentProps extends Omit<FieldRendererProps, 'defaultValue' | 'rules'> {
139
+ formSchema: any;
140
+ uploadingFiles: Record<string, boolean>;
141
+ setUploadingFiles: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
142
+ setError: (name: string, error: {
143
+ type: string;
144
+ message: string;
145
+ }) => void;
146
+ clearErrors: (name?: string) => void;
147
+ }
148
+ declare const FieldRenderer: (props: FieldRendererComponentProps) => react_jsx_runtime.JSX.Element | null;
149
+
150
+ interface FormViewModeProps {
151
+ formSchema: FormSchema;
152
+ initialValues?: Record<string, any>;
153
+ hideTitle?: boolean;
154
+ services?: FormServices;
155
+ }
156
+ declare const FormViewMode: ({ formSchema, initialValues, hideTitle, services }: FormViewModeProps) => react_jsx_runtime.JSX.Element;
157
+
158
+ interface FieldViewProps {
159
+ field: FormField;
160
+ value: any;
161
+ services?: FormServices;
162
+ }
163
+ declare const FieldView: ({ field, value, services }: FieldViewProps) => react_jsx_runtime.JSX.Element;
164
+
165
+ declare const TextField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
166
+
167
+ declare const SelectField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
168
+
169
+ declare const CheckboxField: ({ field, control, defaultValue, rules }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
170
+
171
+ declare const RadioField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
172
+
173
+ declare const ToggleField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
174
+
175
+ declare const ColorField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
176
+
177
+ declare const DateTimePickerField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
178
+
179
+ declare global {
180
+ interface Window {
181
+ ClassicEditor: any;
182
+ }
183
+ }
184
+ declare const CKEditorField: ({ field, control, defaultValue, rules, errors, setValue, formSchema, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
185
+
186
+ interface FileFieldProps extends FieldRendererProps {
187
+ uploadingFiles?: Record<string, boolean>;
188
+ setUploadingFiles?: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
189
+ setError?: (name: string, error: {
190
+ type: string;
191
+ message: string;
192
+ }) => void;
193
+ clearErrors?: (name?: string) => void;
194
+ }
195
+ declare const FileField: ({ field, control, defaultValue, rules, errors, formSchema, uploadingFiles, setUploadingFiles, setError, clearErrors, services, }: FileFieldProps) => react_jsx_runtime.JSX.Element;
196
+
197
+ declare const FormReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
198
+ declare const ApiReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
199
+
200
+ interface SimpleSelectOption {
201
+ value: string | number;
202
+ label: string;
203
+ }
204
+ interface SimpleSelectProps {
205
+ label: string;
206
+ value: string | string[] | number | number[] | null | undefined;
207
+ onChange: (value: string | string[] | null) => void;
208
+ options: SimpleSelectOption[];
209
+ placeholder?: string;
210
+ helperText?: string;
211
+ fullWidth?: boolean;
212
+ size?: 'small' | 'medium';
213
+ required?: boolean;
214
+ error?: boolean;
215
+ disabled?: boolean;
216
+ multiple?: boolean;
217
+ isLoading?: boolean;
218
+ }
219
+ declare const SimpleSelect: React$1.FC<SimpleSelectProps>;
220
+
221
+ /**
222
+ * Get all fields from form schema (sections or legacy fields)
223
+ */
224
+ declare const getAllFields: (formSchema: FormSchema) => FormField[];
225
+ /**
226
+ * Normalize initial values to handle backward compatibility
227
+ * - Single value -> array for multiple fields
228
+ * - Array -> first element for single fields
229
+ */
230
+ declare const normalizeInitialValues: (values: Record<string, any>, formSchema: FormSchema) => Record<string, any>;
231
+ /**
232
+ * Get default value for a field based on its type
233
+ */
234
+ declare const getDefaultValue: (field: FormField) => any;
235
+ /**
236
+ * Transform form values based on field types.
237
+ */
238
+ declare const transformFormValues: (data: Record<string, any>, formSchema: FormSchema) => Record<string, any>;
239
+
240
+ /**
241
+ * Format file size in human-readable format
242
+ */
243
+ declare const formatFileSize: (bytes: number) => string;
244
+ /**
245
+ * Validate file based on field configuration
246
+ */
247
+ declare const validateFile: (file: File, field: FormField) => string | true;
248
+ /**
249
+ * Build validation rules for a field
250
+ */
251
+ declare const buildFieldRules: (field: FormField) => any;
252
+ /**
253
+ * Normalize options to OptionItem format
254
+ */
255
+ declare const normalizeOptions: (options?: FormField["options"]) => Array<{
256
+ label: string;
257
+ value: string | number;
258
+ }>;
259
+
260
+ /**
261
+ * CKEditor Loader Utility
262
+ *
263
+ * This utility helps load CKEditor from the lib/ckeditor/ckeditor.js file
264
+ * and provides a way to check if CKEditor is available.
265
+ */
266
+ /**
267
+ * Load CKEditor script dynamically
268
+ * @param scriptPath - Path to ckeditor.js file (default: '/lib/ckeditor/ckeditor.js')
269
+ * @returns Promise that resolves when CKEditor is loaded
270
+ */
271
+ declare const loadCKEditor: (scriptPath?: string) => Promise<void>;
272
+ /**
273
+ * Check if CKEditor is available
274
+ * @returns true if ClassicEditor is available on window
275
+ */
276
+ declare const isCKEditorAvailable: () => boolean;
277
+ /**
278
+ * Wait for CKEditor to be available
279
+ * @param timeout - Maximum time to wait in milliseconds (default: 10000)
280
+ * @returns Promise that resolves when CKEditor is available
281
+ */
282
+ declare const waitForCKEditor: (timeout?: number) => Promise<void>;
283
+
284
+ interface UseCKEditorOptions {
285
+ /**
286
+ * Path to CKEditor script (default: '/lib/ckeditor/ckeditor.js')
287
+ */
288
+ scriptPath?: string;
289
+ /**
290
+ * Auto-load CKEditor if not available (default: true)
291
+ */
292
+ autoLoad?: boolean;
293
+ /**
294
+ * Timeout for waiting for CKEditor (default: 10000ms)
295
+ */
296
+ timeout?: number;
297
+ }
298
+ interface UseCKEditorReturn {
299
+ /**
300
+ * Whether CKEditor is ready
301
+ */
302
+ isReady: boolean;
303
+ /**
304
+ * Loading state
305
+ */
306
+ isLoading: boolean;
307
+ /**
308
+ * Error if loading failed
309
+ */
310
+ error: Error | null;
311
+ /**
312
+ * Manually trigger loading
313
+ */
314
+ load: () => Promise<void>;
315
+ }
316
+ /**
317
+ * React hook for loading and checking CKEditor availability
318
+ *
319
+ * @example
320
+ * ```tsx
321
+ * const { isReady, isLoading, error } = useCKEditor();
322
+ *
323
+ * if (!isReady) {
324
+ * return <div>Loading CKEditor...</div>;
325
+ * }
326
+ * ```
327
+ */
328
+ declare const useCKEditor: (options?: UseCKEditorOptions) => UseCKEditorReturn;
329
+
330
+ /**
331
+ * Default service implementations
332
+ * These are fallback implementations that can be overridden
333
+ */
334
+
335
+ /**
336
+ * Default file upload service - throws error, must be provided
337
+ */
338
+ declare const defaultFileUploadService: FileUploadService;
339
+ /**
340
+ * Default form reference service - throws error, must be provided
341
+ */
342
+ declare const defaultFormReferenceService: FormReferenceService;
343
+ /**
344
+ * Default API reference service - throws error, must be provided
345
+ */
346
+ declare const defaultApiReferenceService: ApiReferenceService;
347
+ /**
348
+ * Default date formatter service
349
+ */
350
+ declare const defaultDateFormatterService: DateFormatterService;
351
+
352
+ export { ApiReferenceField, type ApiReferenceService, CKEditorField, CheckboxField, ColorField, type DateFormatterService, DateTimePickerField, FieldRenderer, type FieldRendererProps, type FieldType, type FieldValidation, FieldView, FileField, type FileUploadService, type FormField, FormReferenceField, type FormReferenceService, FormRenderer, type FormRendererProps, type FormSchema, type FormSection, type FormServices, FormViewMode, type OptionItem, RadioField, SelectField, SimpleSelect, type SimpleSelectOption, type SimpleSelectProps, TextField, ToggleField, type UploadedFile, buildFieldRules, defaultApiReferenceService, defaultDateFormatterService, defaultFileUploadService, defaultFormReferenceService, formatFileSize, getAllFields, getDefaultValue, isCKEditorAvailable, loadCKEditor, normalizeInitialValues, normalizeOptions, transformFormValues, useCKEditor, validateFile, waitForCKEditor };