@aatulwork/customform-renderer 1.8.0 → 1.10.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.
- package/dist/fields-BM8DDh8m.d.mts +186 -0
- package/dist/fields-BM8DDh8m.d.ts +186 -0
- package/dist/fields.d.mts +3 -0
- package/dist/fields.d.ts +3 -0
- package/dist/fields.js +1230 -0
- package/dist/fields.js.map +1 -0
- package/dist/fields.mjs +1210 -0
- package/dist/fields.mjs.map +1 -0
- package/dist/index.d.mts +10 -186
- package/dist/index.d.ts +10 -186
- package/dist/index.js +84 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
colors?: FormColors;
|
|
77
|
+
}
|
|
78
|
+
interface FormServices {
|
|
79
|
+
fileUpload?: FileUploadService;
|
|
80
|
+
formReference?: FormReferenceService;
|
|
81
|
+
apiReference?: ApiReferenceService;
|
|
82
|
+
dateFormatter?: DateFormatterService;
|
|
83
|
+
SelectComponent?: React.ComponentType<any>;
|
|
84
|
+
FileDisplayComponent?: React.ComponentType<{
|
|
85
|
+
fieldValue: any;
|
|
86
|
+
}>;
|
|
87
|
+
CKEditorDisplayComponent?: React.ComponentType<{
|
|
88
|
+
content: string;
|
|
89
|
+
maxLength?: number;
|
|
90
|
+
showViewButton?: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
fileBaseUrl?: string;
|
|
93
|
+
ckEditorLicenseKey?: string;
|
|
94
|
+
ckEditorScriptPath?: string;
|
|
95
|
+
}
|
|
96
|
+
interface FileUploadService {
|
|
97
|
+
uploadFiles: (formName: string, fieldName: string, files: File[]) => Promise<UploadedFile[]>;
|
|
98
|
+
}
|
|
99
|
+
interface UploadedFile {
|
|
100
|
+
_id?: string;
|
|
101
|
+
fileName: string;
|
|
102
|
+
originalName?: string;
|
|
103
|
+
fileUrl: string;
|
|
104
|
+
size?: number;
|
|
105
|
+
mimeType?: string;
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}
|
|
108
|
+
interface FormReferenceService {
|
|
109
|
+
fetchOptions: (formName: string, fieldName: string) => Promise<OptionItem[]>;
|
|
110
|
+
}
|
|
111
|
+
interface ApiReferenceService {
|
|
112
|
+
fetchOptions: (endpoint: string, labelField: string, valueField?: string) => Promise<OptionItem[]>;
|
|
113
|
+
}
|
|
114
|
+
interface DateFormatterService {
|
|
115
|
+
format: (value: any, options?: {
|
|
116
|
+
datePickerMode?: 'date' | 'datetime' | 'time';
|
|
117
|
+
}) => string;
|
|
118
|
+
}
|
|
119
|
+
interface FormColors {
|
|
120
|
+
primary?: string;
|
|
121
|
+
secondary?: string;
|
|
122
|
+
error?: string;
|
|
123
|
+
success?: string;
|
|
124
|
+
warning?: string;
|
|
125
|
+
info?: string;
|
|
126
|
+
textPrimary?: string;
|
|
127
|
+
textSecondary?: string;
|
|
128
|
+
divider?: string;
|
|
129
|
+
background?: string;
|
|
130
|
+
backgroundPaper?: string;
|
|
131
|
+
}
|
|
132
|
+
interface FieldRendererProps {
|
|
133
|
+
field: FormField;
|
|
134
|
+
control: any;
|
|
135
|
+
defaultValue: any;
|
|
136
|
+
rules: any;
|
|
137
|
+
errors: any;
|
|
138
|
+
setValue: any;
|
|
139
|
+
formSchema?: FormSchema;
|
|
140
|
+
uploadingFiles?: Record<string, boolean>;
|
|
141
|
+
setUploadingFiles?: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
142
|
+
setError?: (name: string, error: {
|
|
143
|
+
type: string;
|
|
144
|
+
message: string;
|
|
145
|
+
}) => void;
|
|
146
|
+
clearErrors?: (name?: string) => void;
|
|
147
|
+
services?: FormServices;
|
|
148
|
+
colors?: FormColors;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare const TextField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
152
|
+
|
|
153
|
+
declare const SelectField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
154
|
+
|
|
155
|
+
declare const CheckboxField: ({ field, control, defaultValue, rules }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
156
|
+
|
|
157
|
+
declare const RadioField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
declare const ToggleField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
160
|
+
|
|
161
|
+
declare const ColorField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
|
|
163
|
+
declare const DateTimePickerField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
164
|
+
|
|
165
|
+
declare global {
|
|
166
|
+
interface Window {
|
|
167
|
+
ClassicEditor: any;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
declare const CKEditorField: ({ field, control, defaultValue, rules, errors, setValue, formSchema, services, colors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
171
|
+
|
|
172
|
+
interface FileFieldProps extends FieldRendererProps {
|
|
173
|
+
uploadingFiles?: Record<string, boolean>;
|
|
174
|
+
setUploadingFiles?: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
|
|
175
|
+
setError?: (name: string, error: {
|
|
176
|
+
type: string;
|
|
177
|
+
message: string;
|
|
178
|
+
}) => void;
|
|
179
|
+
clearErrors?: (name?: string) => void;
|
|
180
|
+
}
|
|
181
|
+
declare const FileField: ({ field, control, defaultValue, rules, errors, formSchema, uploadingFiles, setUploadingFiles, setError, clearErrors, services, colors, }: FileFieldProps) => react_jsx_runtime.JSX.Element;
|
|
182
|
+
|
|
183
|
+
declare const FormReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
184
|
+
declare const ApiReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
export { type ApiReferenceService as A, CKEditorField as C, type DateFormatterService as D, type FormRendererProps as F, type OptionItem as O, RadioField as R, SelectField as S, TextField as T, type UploadedFile as U, type FieldRendererProps as a, type FormSchema as b, type FormServices as c, type FormColors as d, type FormField as e, type FileUploadService as f, type FormReferenceService as g, ApiReferenceField as h, CheckboxField as i, ColorField as j, DateTimePickerField as k, type FieldType as l, type FieldValidation as m, FileField as n, FormReferenceField as o, type FormSection as p, ToggleField as q };
|
|
@@ -0,0 +1,186 @@
|
|
|
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
|
+
colors?: FormColors;
|
|
77
|
+
}
|
|
78
|
+
interface FormServices {
|
|
79
|
+
fileUpload?: FileUploadService;
|
|
80
|
+
formReference?: FormReferenceService;
|
|
81
|
+
apiReference?: ApiReferenceService;
|
|
82
|
+
dateFormatter?: DateFormatterService;
|
|
83
|
+
SelectComponent?: React.ComponentType<any>;
|
|
84
|
+
FileDisplayComponent?: React.ComponentType<{
|
|
85
|
+
fieldValue: any;
|
|
86
|
+
}>;
|
|
87
|
+
CKEditorDisplayComponent?: React.ComponentType<{
|
|
88
|
+
content: string;
|
|
89
|
+
maxLength?: number;
|
|
90
|
+
showViewButton?: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
fileBaseUrl?: string;
|
|
93
|
+
ckEditorLicenseKey?: string;
|
|
94
|
+
ckEditorScriptPath?: string;
|
|
95
|
+
}
|
|
96
|
+
interface FileUploadService {
|
|
97
|
+
uploadFiles: (formName: string, fieldName: string, files: File[]) => Promise<UploadedFile[]>;
|
|
98
|
+
}
|
|
99
|
+
interface UploadedFile {
|
|
100
|
+
_id?: string;
|
|
101
|
+
fileName: string;
|
|
102
|
+
originalName?: string;
|
|
103
|
+
fileUrl: string;
|
|
104
|
+
size?: number;
|
|
105
|
+
mimeType?: string;
|
|
106
|
+
[key: string]: any;
|
|
107
|
+
}
|
|
108
|
+
interface FormReferenceService {
|
|
109
|
+
fetchOptions: (formName: string, fieldName: string) => Promise<OptionItem[]>;
|
|
110
|
+
}
|
|
111
|
+
interface ApiReferenceService {
|
|
112
|
+
fetchOptions: (endpoint: string, labelField: string, valueField?: string) => Promise<OptionItem[]>;
|
|
113
|
+
}
|
|
114
|
+
interface DateFormatterService {
|
|
115
|
+
format: (value: any, options?: {
|
|
116
|
+
datePickerMode?: 'date' | 'datetime' | 'time';
|
|
117
|
+
}) => string;
|
|
118
|
+
}
|
|
119
|
+
interface FormColors {
|
|
120
|
+
primary?: string;
|
|
121
|
+
secondary?: string;
|
|
122
|
+
error?: string;
|
|
123
|
+
success?: string;
|
|
124
|
+
warning?: string;
|
|
125
|
+
info?: string;
|
|
126
|
+
textPrimary?: string;
|
|
127
|
+
textSecondary?: string;
|
|
128
|
+
divider?: string;
|
|
129
|
+
background?: string;
|
|
130
|
+
backgroundPaper?: string;
|
|
131
|
+
}
|
|
132
|
+
interface FieldRendererProps {
|
|
133
|
+
field: FormField;
|
|
134
|
+
control: any;
|
|
135
|
+
defaultValue: any;
|
|
136
|
+
rules: any;
|
|
137
|
+
errors: any;
|
|
138
|
+
setValue: any;
|
|
139
|
+
formSchema?: FormSchema;
|
|
140
|
+
uploadingFiles?: Record<string, boolean>;
|
|
141
|
+
setUploadingFiles?: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
142
|
+
setError?: (name: string, error: {
|
|
143
|
+
type: string;
|
|
144
|
+
message: string;
|
|
145
|
+
}) => void;
|
|
146
|
+
clearErrors?: (name?: string) => void;
|
|
147
|
+
services?: FormServices;
|
|
148
|
+
colors?: FormColors;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare const TextField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
152
|
+
|
|
153
|
+
declare const SelectField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
154
|
+
|
|
155
|
+
declare const CheckboxField: ({ field, control, defaultValue, rules }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
156
|
+
|
|
157
|
+
declare const RadioField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
158
|
+
|
|
159
|
+
declare const ToggleField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
160
|
+
|
|
161
|
+
declare const ColorField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
162
|
+
|
|
163
|
+
declare const DateTimePickerField: ({ field, control, defaultValue, rules, errors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
164
|
+
|
|
165
|
+
declare global {
|
|
166
|
+
interface Window {
|
|
167
|
+
ClassicEditor: any;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
declare const CKEditorField: ({ field, control, defaultValue, rules, errors, setValue, formSchema, services, colors }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
171
|
+
|
|
172
|
+
interface FileFieldProps extends FieldRendererProps {
|
|
173
|
+
uploadingFiles?: Record<string, boolean>;
|
|
174
|
+
setUploadingFiles?: React$1.Dispatch<React$1.SetStateAction<Record<string, boolean>>>;
|
|
175
|
+
setError?: (name: string, error: {
|
|
176
|
+
type: string;
|
|
177
|
+
message: string;
|
|
178
|
+
}) => void;
|
|
179
|
+
clearErrors?: (name?: string) => void;
|
|
180
|
+
}
|
|
181
|
+
declare const FileField: ({ field, control, defaultValue, rules, errors, formSchema, uploadingFiles, setUploadingFiles, setError, clearErrors, services, colors, }: FileFieldProps) => react_jsx_runtime.JSX.Element;
|
|
182
|
+
|
|
183
|
+
declare const FormReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
184
|
+
declare const ApiReferenceField: ({ field, control, defaultValue, rules, errors, services }: FieldRendererProps) => react_jsx_runtime.JSX.Element;
|
|
185
|
+
|
|
186
|
+
export { type ApiReferenceService as A, CKEditorField as C, type DateFormatterService as D, type FormRendererProps as F, type OptionItem as O, RadioField as R, SelectField as S, TextField as T, type UploadedFile as U, type FieldRendererProps as a, type FormSchema as b, type FormServices as c, type FormColors as d, type FormField as e, type FileUploadService as f, type FormReferenceService as g, ApiReferenceField as h, CheckboxField as i, ColorField as j, DateTimePickerField as k, type FieldType as l, type FieldValidation as m, FileField as n, FormReferenceField as o, type FormSection as p, ToggleField as q };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { h as ApiReferenceField, C as CKEditorField, i as CheckboxField, j as ColorField, k as DateTimePickerField, a as FieldRendererProps, n as FileField, o as FormReferenceField, R as RadioField, S as SelectField, T as TextField, q as ToggleField } from './fields-BM8DDh8m.mjs';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|
package/dist/fields.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { h as ApiReferenceField, C as CKEditorField, i as CheckboxField, j as ColorField, k as DateTimePickerField, a as FieldRendererProps, n as FileField, o as FormReferenceField, R as RadioField, S as SelectField, T as TextField, q as ToggleField } from './fields-BM8DDh8m.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'react';
|