@nextbridgehq/payload-block-builder 0.1.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,276 @@
1
+ import { Plugin, Tab, CollectionConfig } from 'payload';
2
+
3
+ interface DynamicBlocksPluginOptions {
4
+ enabled?: boolean;
5
+ collections?: string[];
6
+ fieldName?: string;
7
+ tabLabel?: string;
8
+ }
9
+ declare const dynamicBlocksPlugin: (options?: DynamicBlocksPluginOptions) => Plugin;
10
+
11
+ declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab;
12
+
13
+ declare const BlockDefinitions: CollectionConfig;
14
+
15
+ declare const BlockDefinitionVersions: CollectionConfig;
16
+
17
+ type FieldType$1 = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks';
18
+ type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than' | 'in' | 'not_in' | 'exists' | 'empty';
19
+ interface ConditionRule {
20
+ field: string;
21
+ operator: ConditionOperator;
22
+ value?: unknown;
23
+ }
24
+ interface ValidationRules {
25
+ required?: boolean;
26
+ minLength?: number;
27
+ maxLength?: number;
28
+ regex?: string;
29
+ min?: number;
30
+ max?: number;
31
+ step?: number;
32
+ integerOnly?: boolean;
33
+ minRows?: number;
34
+ maxRows?: number;
35
+ uniqueItems?: boolean;
36
+ allowedMimeTypes?: string[];
37
+ maxFileSize?: number;
38
+ maxSelections?: number;
39
+ }
40
+ type UIWidth = 'full' | 'half' | 'third' | 'quarter';
41
+ interface UIMetadata {
42
+ tab?: string;
43
+ section?: string;
44
+ width?: UIWidth;
45
+ collapsed?: boolean;
46
+ order?: number;
47
+ }
48
+ interface BaseField {
49
+ name: string;
50
+ type: FieldType$1;
51
+ label?: string;
52
+ required?: boolean;
53
+ admin?: {
54
+ description?: string;
55
+ readOnly?: boolean;
56
+ hidden?: boolean;
57
+ placeholder?: string;
58
+ condition?: string;
59
+ };
60
+ conditions?: ConditionRule[];
61
+ conditionMode?: 'AND' | 'OR';
62
+ validation?: ValidationRules;
63
+ ui?: UIMetadata;
64
+ responsive?: boolean;
65
+ }
66
+ interface TextField extends BaseField {
67
+ type: 'text';
68
+ minLength?: number;
69
+ maxLength?: number;
70
+ defaultValue?: string;
71
+ }
72
+ interface TextareaField extends BaseField {
73
+ type: 'textarea';
74
+ minLength?: number;
75
+ maxLength?: number;
76
+ defaultValue?: string;
77
+ }
78
+ interface RichTextField extends BaseField {
79
+ type: 'richtext';
80
+ }
81
+ interface NumberField extends BaseField {
82
+ type: 'number';
83
+ min?: number;
84
+ max?: number;
85
+ defaultValue?: number;
86
+ }
87
+ interface CheckboxField extends BaseField {
88
+ type: 'checkbox';
89
+ defaultValue?: boolean;
90
+ }
91
+ interface SelectOption$1 {
92
+ label: string;
93
+ value: string;
94
+ }
95
+ interface SelectField extends BaseField {
96
+ type: 'select';
97
+ options: SelectOption$1[];
98
+ defaultValue?: string;
99
+ }
100
+ interface MultiSelectField extends BaseField {
101
+ type: 'multiselect';
102
+ options: SelectOption$1[];
103
+ defaultValue?: string[];
104
+ }
105
+ interface DateField extends BaseField {
106
+ type: 'date';
107
+ timeFormat?: boolean;
108
+ defaultValue?: string;
109
+ }
110
+ interface ImageField extends BaseField {
111
+ type: 'image';
112
+ }
113
+ interface FileField extends BaseField {
114
+ type: 'file';
115
+ allowedMimeTypes?: string[];
116
+ }
117
+ interface UrlField extends BaseField {
118
+ type: 'url';
119
+ }
120
+ interface EmailField extends BaseField {
121
+ type: 'email';
122
+ }
123
+ interface ColorField extends BaseField {
124
+ type: 'color';
125
+ }
126
+ interface ArrayField extends BaseField {
127
+ type: 'array';
128
+ fields: BlockField[];
129
+ minRows?: number;
130
+ maxRows?: number;
131
+ }
132
+ interface GroupField extends BaseField {
133
+ type: 'group';
134
+ fields: BlockField[];
135
+ }
136
+ interface RelationshipField extends BaseField {
137
+ type: 'relationship';
138
+ collection: string;
139
+ hasMany?: boolean;
140
+ }
141
+ interface JsonField extends BaseField {
142
+ type: 'json';
143
+ }
144
+ interface BlocksField extends BaseField {
145
+ type: 'blocks';
146
+ allowedBlocks?: string[];
147
+ minBlocks?: number;
148
+ maxBlocks?: number;
149
+ }
150
+ type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField;
151
+ interface BlockSchema {
152
+ fields: BlockField[];
153
+ layout?: 'default' | 'sidebar' | 'tabs';
154
+ }
155
+ interface ValidationResult {
156
+ valid: boolean;
157
+ errors: string[];
158
+ warnings: string[];
159
+ }
160
+ type BlockFieldDefinition = BlockField;
161
+
162
+ interface RawFieldInput {
163
+ name?: string;
164
+ type?: string;
165
+ label?: string;
166
+ required?: boolean;
167
+ fields?: RawFieldInput[];
168
+ options?: Array<{
169
+ label: string;
170
+ value: string;
171
+ } | string>;
172
+ min?: number;
173
+ max?: number;
174
+ minLength?: number;
175
+ maxLength?: number;
176
+ minRows?: number;
177
+ maxRows?: number;
178
+ defaultValue?: unknown;
179
+ collection?: string;
180
+ allowedMimeTypes?: string[];
181
+ hasMany?: boolean;
182
+ timeFormat?: boolean;
183
+ admin?: Record<string, unknown>;
184
+ conditions?: unknown;
185
+ conditionMode?: string;
186
+ validation?: Record<string, unknown>;
187
+ ui?: Record<string, unknown>;
188
+ allowedBlocks?: string[];
189
+ minBlocks?: number;
190
+ maxBlocks?: number;
191
+ [key: string]: unknown;
192
+ }
193
+ interface RawSchemaInput {
194
+ fields: RawFieldInput[];
195
+ layout?: string;
196
+ }
197
+ interface SaveSchemaRequest {
198
+ blockSlug: string;
199
+ name?: string;
200
+ description?: string;
201
+ category?: string;
202
+ schema: RawSchemaInput | BlockSchema;
203
+ changelog?: string;
204
+ }
205
+ interface SaveSchemaResult {
206
+ success: boolean;
207
+ definitionId: string;
208
+ versionId: string;
209
+ versionNumber: number;
210
+ errors?: string[];
211
+ warnings?: string[];
212
+ }
213
+
214
+ type FieldType = "text" | "textarea" | "number" | "email" | "checkbox" | "select" | "radio" | "date" | "richText" | "upload" | "relationship" | "array" | "group" | "tabs" | "row" | "collapsible" | "json" | "code" | "point" | "ui";
215
+ type ValidationRule = {
216
+ required?: boolean;
217
+ minLength?: number;
218
+ maxLength?: number;
219
+ min?: number;
220
+ max?: number;
221
+ };
222
+ type SelectOption = {
223
+ label: string;
224
+ value: string;
225
+ };
226
+ type AdminConfig = {
227
+ description?: string;
228
+ placeholder?: string;
229
+ readOnly?: boolean;
230
+ hidden?: boolean;
231
+ condition?: string;
232
+ };
233
+ type FieldDefinition = {
234
+ id: string;
235
+ type: FieldType;
236
+ name: string;
237
+ label?: string;
238
+ required?: boolean;
239
+ unique?: boolean;
240
+ localized?: boolean;
241
+ defaultValue?: string | number | boolean;
242
+ validation?: ValidationRule;
243
+ admin?: AdminConfig;
244
+ options?: SelectOption[];
245
+ relationTo?: string;
246
+ hasMany?: boolean;
247
+ maxDepth?: number;
248
+ minRows?: number;
249
+ maxRows?: number;
250
+ fields?: FieldDefinition[];
251
+ };
252
+ type BlockDefinition = {
253
+ id: string;
254
+ slug: string;
255
+ interfaceName?: string;
256
+ labels?: {
257
+ singular?: string;
258
+ plural?: string;
259
+ };
260
+ imageURL?: string;
261
+ imageAltText?: string;
262
+ fields: FieldDefinition[];
263
+ };
264
+ type BuilderState = {
265
+ blocks: BlockDefinition[];
266
+ activeBlockId: string | null;
267
+ activeFieldId: string | null;
268
+ isDirty: boolean;
269
+ };
270
+ type GeneratedOutput = {
271
+ filename: string;
272
+ code: string;
273
+ language: "typescript" | "javascript";
274
+ };
275
+
276
+ export { type BlockDefinition, BlockDefinitionVersions, BlockDefinitions, type BlockField, type BlockFieldDefinition, type BlockSchema, type FieldType as BuilderFieldType, type BuilderState, type ConditionRule, type DynamicBlocksPluginOptions, type FieldDefinition, type FieldType$1 as FieldType, type GeneratedOutput, type RawFieldInput, type RawSchemaInput, type SaveSchemaRequest, type SaveSchemaResult, type UIMetadata, type ValidationResult, type ValidationRules, dbLayoutField, dynamicBlocksPlugin };
@@ -0,0 +1,276 @@
1
+ import { Plugin, Tab, CollectionConfig } from 'payload';
2
+
3
+ interface DynamicBlocksPluginOptions {
4
+ enabled?: boolean;
5
+ collections?: string[];
6
+ fieldName?: string;
7
+ tabLabel?: string;
8
+ }
9
+ declare const dynamicBlocksPlugin: (options?: DynamicBlocksPluginOptions) => Plugin;
10
+
11
+ declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab;
12
+
13
+ declare const BlockDefinitions: CollectionConfig;
14
+
15
+ declare const BlockDefinitionVersions: CollectionConfig;
16
+
17
+ type FieldType$1 = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks';
18
+ type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than' | 'in' | 'not_in' | 'exists' | 'empty';
19
+ interface ConditionRule {
20
+ field: string;
21
+ operator: ConditionOperator;
22
+ value?: unknown;
23
+ }
24
+ interface ValidationRules {
25
+ required?: boolean;
26
+ minLength?: number;
27
+ maxLength?: number;
28
+ regex?: string;
29
+ min?: number;
30
+ max?: number;
31
+ step?: number;
32
+ integerOnly?: boolean;
33
+ minRows?: number;
34
+ maxRows?: number;
35
+ uniqueItems?: boolean;
36
+ allowedMimeTypes?: string[];
37
+ maxFileSize?: number;
38
+ maxSelections?: number;
39
+ }
40
+ type UIWidth = 'full' | 'half' | 'third' | 'quarter';
41
+ interface UIMetadata {
42
+ tab?: string;
43
+ section?: string;
44
+ width?: UIWidth;
45
+ collapsed?: boolean;
46
+ order?: number;
47
+ }
48
+ interface BaseField {
49
+ name: string;
50
+ type: FieldType$1;
51
+ label?: string;
52
+ required?: boolean;
53
+ admin?: {
54
+ description?: string;
55
+ readOnly?: boolean;
56
+ hidden?: boolean;
57
+ placeholder?: string;
58
+ condition?: string;
59
+ };
60
+ conditions?: ConditionRule[];
61
+ conditionMode?: 'AND' | 'OR';
62
+ validation?: ValidationRules;
63
+ ui?: UIMetadata;
64
+ responsive?: boolean;
65
+ }
66
+ interface TextField extends BaseField {
67
+ type: 'text';
68
+ minLength?: number;
69
+ maxLength?: number;
70
+ defaultValue?: string;
71
+ }
72
+ interface TextareaField extends BaseField {
73
+ type: 'textarea';
74
+ minLength?: number;
75
+ maxLength?: number;
76
+ defaultValue?: string;
77
+ }
78
+ interface RichTextField extends BaseField {
79
+ type: 'richtext';
80
+ }
81
+ interface NumberField extends BaseField {
82
+ type: 'number';
83
+ min?: number;
84
+ max?: number;
85
+ defaultValue?: number;
86
+ }
87
+ interface CheckboxField extends BaseField {
88
+ type: 'checkbox';
89
+ defaultValue?: boolean;
90
+ }
91
+ interface SelectOption$1 {
92
+ label: string;
93
+ value: string;
94
+ }
95
+ interface SelectField extends BaseField {
96
+ type: 'select';
97
+ options: SelectOption$1[];
98
+ defaultValue?: string;
99
+ }
100
+ interface MultiSelectField extends BaseField {
101
+ type: 'multiselect';
102
+ options: SelectOption$1[];
103
+ defaultValue?: string[];
104
+ }
105
+ interface DateField extends BaseField {
106
+ type: 'date';
107
+ timeFormat?: boolean;
108
+ defaultValue?: string;
109
+ }
110
+ interface ImageField extends BaseField {
111
+ type: 'image';
112
+ }
113
+ interface FileField extends BaseField {
114
+ type: 'file';
115
+ allowedMimeTypes?: string[];
116
+ }
117
+ interface UrlField extends BaseField {
118
+ type: 'url';
119
+ }
120
+ interface EmailField extends BaseField {
121
+ type: 'email';
122
+ }
123
+ interface ColorField extends BaseField {
124
+ type: 'color';
125
+ }
126
+ interface ArrayField extends BaseField {
127
+ type: 'array';
128
+ fields: BlockField[];
129
+ minRows?: number;
130
+ maxRows?: number;
131
+ }
132
+ interface GroupField extends BaseField {
133
+ type: 'group';
134
+ fields: BlockField[];
135
+ }
136
+ interface RelationshipField extends BaseField {
137
+ type: 'relationship';
138
+ collection: string;
139
+ hasMany?: boolean;
140
+ }
141
+ interface JsonField extends BaseField {
142
+ type: 'json';
143
+ }
144
+ interface BlocksField extends BaseField {
145
+ type: 'blocks';
146
+ allowedBlocks?: string[];
147
+ minBlocks?: number;
148
+ maxBlocks?: number;
149
+ }
150
+ type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField;
151
+ interface BlockSchema {
152
+ fields: BlockField[];
153
+ layout?: 'default' | 'sidebar' | 'tabs';
154
+ }
155
+ interface ValidationResult {
156
+ valid: boolean;
157
+ errors: string[];
158
+ warnings: string[];
159
+ }
160
+ type BlockFieldDefinition = BlockField;
161
+
162
+ interface RawFieldInput {
163
+ name?: string;
164
+ type?: string;
165
+ label?: string;
166
+ required?: boolean;
167
+ fields?: RawFieldInput[];
168
+ options?: Array<{
169
+ label: string;
170
+ value: string;
171
+ } | string>;
172
+ min?: number;
173
+ max?: number;
174
+ minLength?: number;
175
+ maxLength?: number;
176
+ minRows?: number;
177
+ maxRows?: number;
178
+ defaultValue?: unknown;
179
+ collection?: string;
180
+ allowedMimeTypes?: string[];
181
+ hasMany?: boolean;
182
+ timeFormat?: boolean;
183
+ admin?: Record<string, unknown>;
184
+ conditions?: unknown;
185
+ conditionMode?: string;
186
+ validation?: Record<string, unknown>;
187
+ ui?: Record<string, unknown>;
188
+ allowedBlocks?: string[];
189
+ minBlocks?: number;
190
+ maxBlocks?: number;
191
+ [key: string]: unknown;
192
+ }
193
+ interface RawSchemaInput {
194
+ fields: RawFieldInput[];
195
+ layout?: string;
196
+ }
197
+ interface SaveSchemaRequest {
198
+ blockSlug: string;
199
+ name?: string;
200
+ description?: string;
201
+ category?: string;
202
+ schema: RawSchemaInput | BlockSchema;
203
+ changelog?: string;
204
+ }
205
+ interface SaveSchemaResult {
206
+ success: boolean;
207
+ definitionId: string;
208
+ versionId: string;
209
+ versionNumber: number;
210
+ errors?: string[];
211
+ warnings?: string[];
212
+ }
213
+
214
+ type FieldType = "text" | "textarea" | "number" | "email" | "checkbox" | "select" | "radio" | "date" | "richText" | "upload" | "relationship" | "array" | "group" | "tabs" | "row" | "collapsible" | "json" | "code" | "point" | "ui";
215
+ type ValidationRule = {
216
+ required?: boolean;
217
+ minLength?: number;
218
+ maxLength?: number;
219
+ min?: number;
220
+ max?: number;
221
+ };
222
+ type SelectOption = {
223
+ label: string;
224
+ value: string;
225
+ };
226
+ type AdminConfig = {
227
+ description?: string;
228
+ placeholder?: string;
229
+ readOnly?: boolean;
230
+ hidden?: boolean;
231
+ condition?: string;
232
+ };
233
+ type FieldDefinition = {
234
+ id: string;
235
+ type: FieldType;
236
+ name: string;
237
+ label?: string;
238
+ required?: boolean;
239
+ unique?: boolean;
240
+ localized?: boolean;
241
+ defaultValue?: string | number | boolean;
242
+ validation?: ValidationRule;
243
+ admin?: AdminConfig;
244
+ options?: SelectOption[];
245
+ relationTo?: string;
246
+ hasMany?: boolean;
247
+ maxDepth?: number;
248
+ minRows?: number;
249
+ maxRows?: number;
250
+ fields?: FieldDefinition[];
251
+ };
252
+ type BlockDefinition = {
253
+ id: string;
254
+ slug: string;
255
+ interfaceName?: string;
256
+ labels?: {
257
+ singular?: string;
258
+ plural?: string;
259
+ };
260
+ imageURL?: string;
261
+ imageAltText?: string;
262
+ fields: FieldDefinition[];
263
+ };
264
+ type BuilderState = {
265
+ blocks: BlockDefinition[];
266
+ activeBlockId: string | null;
267
+ activeFieldId: string | null;
268
+ isDirty: boolean;
269
+ };
270
+ type GeneratedOutput = {
271
+ filename: string;
272
+ code: string;
273
+ language: "typescript" | "javascript";
274
+ };
275
+
276
+ export { type BlockDefinition, BlockDefinitionVersions, BlockDefinitions, type BlockField, type BlockFieldDefinition, type BlockSchema, type FieldType as BuilderFieldType, type BuilderState, type ConditionRule, type DynamicBlocksPluginOptions, type FieldDefinition, type FieldType$1 as FieldType, type GeneratedOutput, type RawFieldInput, type RawSchemaInput, type SaveSchemaRequest, type SaveSchemaResult, type UIMetadata, type ValidationResult, type ValidationRules, dbLayoutField, dynamicBlocksPlugin };