@nextbridgehq/payload-block-builder 0.1.9 → 0.2.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/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin, Tab, CollectionConfig } from 'payload';
1
+ import { Plugin, Tab as Tab$1, CollectionConfig } from 'payload';
2
2
 
3
3
  interface DynamicBlocksPluginOptions {
4
4
  enabled?: boolean;
@@ -8,13 +8,13 @@ interface DynamicBlocksPluginOptions {
8
8
  }
9
9
  declare const dynamicBlocksPlugin: (options?: DynamicBlocksPluginOptions) => Plugin;
10
10
 
11
- declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab;
11
+ declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab$1;
12
12
 
13
13
  declare const BlockDefinitions: CollectionConfig;
14
14
 
15
15
  declare const BlockDefinitionVersions: CollectionConfig;
16
16
 
17
- type FieldType$1 = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks';
17
+ type FieldType = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks' | 'row' | 'tabs' | 'collapsible';
18
18
  type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than' | 'in' | 'not_in' | 'exists' | 'empty';
19
19
  interface ConditionRule {
20
20
  field: string;
@@ -47,9 +47,13 @@ interface UIMetadata {
47
47
  }
48
48
  interface BaseField {
49
49
  name: string;
50
- type: FieldType$1;
50
+ type: FieldType;
51
51
  label?: string;
52
52
  required?: boolean;
53
+ /** Payload's `unique` index flag. Settable on every field in the builder. */
54
+ unique?: boolean;
55
+ /** Payload's `localized` flag. Settable on every field in the builder. */
56
+ localized?: boolean;
53
57
  admin?: {
54
58
  description?: string;
55
59
  readOnly?: boolean;
@@ -77,6 +81,7 @@ interface TextareaField extends BaseField {
77
81
  }
78
82
  interface RichTextField extends BaseField {
79
83
  type: 'richtext';
84
+ defaultValue?: string;
80
85
  }
81
86
  interface NumberField extends BaseField {
82
87
  type: 'number';
@@ -109,19 +114,26 @@ interface DateField extends BaseField {
109
114
  }
110
115
  interface ImageField extends BaseField {
111
116
  type: 'image';
117
+ /** Upload-enabled collection this field points at. Defaults to `media`. */
118
+ collection?: string;
112
119
  }
113
120
  interface FileField extends BaseField {
114
121
  type: 'file';
115
122
  allowedMimeTypes?: string[];
123
+ /** Upload-enabled collection this field points at. Defaults to `media`. */
124
+ collection?: string;
116
125
  }
117
126
  interface UrlField extends BaseField {
118
127
  type: 'url';
128
+ defaultValue?: string;
119
129
  }
120
130
  interface EmailField extends BaseField {
121
131
  type: 'email';
132
+ defaultValue?: string;
122
133
  }
123
134
  interface ColorField extends BaseField {
124
135
  type: 'color';
136
+ defaultValue?: string;
125
137
  }
126
138
  interface ArrayField extends BaseField {
127
139
  type: 'array';
@@ -147,7 +159,26 @@ interface BlocksField extends BaseField {
147
159
  minBlocks?: number;
148
160
  maxBlocks?: number;
149
161
  }
150
- type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField;
162
+ interface RowField extends BaseField {
163
+ type: 'row';
164
+ fields: BlockField[];
165
+ }
166
+ interface Tab {
167
+ name?: string;
168
+ label: string;
169
+ description?: string;
170
+ fields: BlockField[];
171
+ }
172
+ interface TabsField extends BaseField {
173
+ type: 'tabs';
174
+ tabs: Tab[];
175
+ }
176
+ interface CollapsibleField extends BaseField {
177
+ type: 'collapsible';
178
+ label: string;
179
+ fields: BlockField[];
180
+ }
181
+ type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField | RowField | TabsField | CollapsibleField;
151
182
  interface BlockSchema {
152
183
  fields: BlockField[];
153
184
  layout?: 'default' | 'sidebar' | 'tabs';
@@ -211,7 +242,6 @@ interface SaveSchemaResult {
211
242
  warnings?: string[];
212
243
  }
213
244
 
214
- type FieldType = "text" | "textarea" | "number" | "email" | "checkbox" | "select" | "radio" | "date" | "richText" | "upload" | "relationship" | "array" | "group" | "tabs" | "row" | "collapsible" | "json" | "code" | "point" | "ui";
215
245
  type ValidationRule = {
216
246
  required?: boolean;
217
247
  minLength?: number;
@@ -242,12 +272,26 @@ type FieldDefinition = {
242
272
  validation?: ValidationRule;
243
273
  admin?: AdminConfig;
244
274
  options?: SelectOption[];
245
- relationTo?: string;
275
+ collection?: string;
246
276
  hasMany?: boolean;
247
277
  maxDepth?: number;
248
278
  minRows?: number;
249
279
  maxRows?: number;
250
280
  fields?: FieldDefinition[];
281
+ tabs?: TabDefinition[];
282
+ };
283
+ /** A single tab inside a `tabs` layout field. */
284
+ type TabDefinition = {
285
+ id?: string;
286
+ name?: string;
287
+ /** Display label shown on the tab itself. */
288
+ label: string;
289
+ description?: string;
290
+ /**
291
+ * A *named* tab nests its children's data under `name`; an unnamed tab is
292
+ * presentational and flattens them into the surrounding object.
293
+ */
294
+ fields: FieldDefinition[];
251
295
  };
252
296
  type BlockDefinition = {
253
297
  id: string;
@@ -273,4 +317,4 @@ type GeneratedOutput = {
273
317
  language: "typescript" | "javascript";
274
318
  };
275
319
 
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 };
320
+ 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, type GeneratedOutput, type RawFieldInput, type RawSchemaInput, type SaveSchemaRequest, type SaveSchemaResult, type UIMetadata, type ValidationResult, type ValidationRules, dbLayoutField, dynamicBlocksPlugin };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Plugin, Tab, CollectionConfig } from 'payload';
1
+ import { Plugin, Tab as Tab$1, CollectionConfig } from 'payload';
2
2
 
3
3
  interface DynamicBlocksPluginOptions {
4
4
  enabled?: boolean;
@@ -8,13 +8,13 @@ interface DynamicBlocksPluginOptions {
8
8
  }
9
9
  declare const dynamicBlocksPlugin: (options?: DynamicBlocksPluginOptions) => Plugin;
10
10
 
11
- declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab;
11
+ declare function dbLayoutField(fieldName?: string, tabLabel?: string): Tab$1;
12
12
 
13
13
  declare const BlockDefinitions: CollectionConfig;
14
14
 
15
15
  declare const BlockDefinitionVersions: CollectionConfig;
16
16
 
17
- type FieldType$1 = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks';
17
+ type FieldType = 'text' | 'textarea' | 'richtext' | 'number' | 'checkbox' | 'select' | 'multiselect' | 'date' | 'image' | 'file' | 'url' | 'email' | 'color' | 'array' | 'group' | 'relationship' | 'json' | 'blocks' | 'row' | 'tabs' | 'collapsible';
18
18
  type ConditionOperator = 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than' | 'in' | 'not_in' | 'exists' | 'empty';
19
19
  interface ConditionRule {
20
20
  field: string;
@@ -47,9 +47,13 @@ interface UIMetadata {
47
47
  }
48
48
  interface BaseField {
49
49
  name: string;
50
- type: FieldType$1;
50
+ type: FieldType;
51
51
  label?: string;
52
52
  required?: boolean;
53
+ /** Payload's `unique` index flag. Settable on every field in the builder. */
54
+ unique?: boolean;
55
+ /** Payload's `localized` flag. Settable on every field in the builder. */
56
+ localized?: boolean;
53
57
  admin?: {
54
58
  description?: string;
55
59
  readOnly?: boolean;
@@ -77,6 +81,7 @@ interface TextareaField extends BaseField {
77
81
  }
78
82
  interface RichTextField extends BaseField {
79
83
  type: 'richtext';
84
+ defaultValue?: string;
80
85
  }
81
86
  interface NumberField extends BaseField {
82
87
  type: 'number';
@@ -109,19 +114,26 @@ interface DateField extends BaseField {
109
114
  }
110
115
  interface ImageField extends BaseField {
111
116
  type: 'image';
117
+ /** Upload-enabled collection this field points at. Defaults to `media`. */
118
+ collection?: string;
112
119
  }
113
120
  interface FileField extends BaseField {
114
121
  type: 'file';
115
122
  allowedMimeTypes?: string[];
123
+ /** Upload-enabled collection this field points at. Defaults to `media`. */
124
+ collection?: string;
116
125
  }
117
126
  interface UrlField extends BaseField {
118
127
  type: 'url';
128
+ defaultValue?: string;
119
129
  }
120
130
  interface EmailField extends BaseField {
121
131
  type: 'email';
132
+ defaultValue?: string;
122
133
  }
123
134
  interface ColorField extends BaseField {
124
135
  type: 'color';
136
+ defaultValue?: string;
125
137
  }
126
138
  interface ArrayField extends BaseField {
127
139
  type: 'array';
@@ -147,7 +159,26 @@ interface BlocksField extends BaseField {
147
159
  minBlocks?: number;
148
160
  maxBlocks?: number;
149
161
  }
150
- type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField;
162
+ interface RowField extends BaseField {
163
+ type: 'row';
164
+ fields: BlockField[];
165
+ }
166
+ interface Tab {
167
+ name?: string;
168
+ label: string;
169
+ description?: string;
170
+ fields: BlockField[];
171
+ }
172
+ interface TabsField extends BaseField {
173
+ type: 'tabs';
174
+ tabs: Tab[];
175
+ }
176
+ interface CollapsibleField extends BaseField {
177
+ type: 'collapsible';
178
+ label: string;
179
+ fields: BlockField[];
180
+ }
181
+ type BlockField = TextField | TextareaField | RichTextField | NumberField | CheckboxField | SelectField | MultiSelectField | DateField | ImageField | FileField | UrlField | EmailField | ColorField | ArrayField | GroupField | RelationshipField | JsonField | BlocksField | RowField | TabsField | CollapsibleField;
151
182
  interface BlockSchema {
152
183
  fields: BlockField[];
153
184
  layout?: 'default' | 'sidebar' | 'tabs';
@@ -211,7 +242,6 @@ interface SaveSchemaResult {
211
242
  warnings?: string[];
212
243
  }
213
244
 
214
- type FieldType = "text" | "textarea" | "number" | "email" | "checkbox" | "select" | "radio" | "date" | "richText" | "upload" | "relationship" | "array" | "group" | "tabs" | "row" | "collapsible" | "json" | "code" | "point" | "ui";
215
245
  type ValidationRule = {
216
246
  required?: boolean;
217
247
  minLength?: number;
@@ -242,12 +272,26 @@ type FieldDefinition = {
242
272
  validation?: ValidationRule;
243
273
  admin?: AdminConfig;
244
274
  options?: SelectOption[];
245
- relationTo?: string;
275
+ collection?: string;
246
276
  hasMany?: boolean;
247
277
  maxDepth?: number;
248
278
  minRows?: number;
249
279
  maxRows?: number;
250
280
  fields?: FieldDefinition[];
281
+ tabs?: TabDefinition[];
282
+ };
283
+ /** A single tab inside a `tabs` layout field. */
284
+ type TabDefinition = {
285
+ id?: string;
286
+ name?: string;
287
+ /** Display label shown on the tab itself. */
288
+ label: string;
289
+ description?: string;
290
+ /**
291
+ * A *named* tab nests its children's data under `name`; an unnamed tab is
292
+ * presentational and flattens them into the surrounding object.
293
+ */
294
+ fields: FieldDefinition[];
251
295
  };
252
296
  type BlockDefinition = {
253
297
  id: string;
@@ -273,4 +317,4 @@ type GeneratedOutput = {
273
317
  language: "typescript" | "javascript";
274
318
  };
275
319
 
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 };
320
+ 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, type GeneratedOutput, type RawFieldInput, type RawSchemaInput, type SaveSchemaRequest, type SaveSchemaResult, type UIMetadata, type ValidationResult, type ValidationRules, dbLayoutField, dynamicBlocksPlugin };