@webiny/api-headless-cms 6.0.0-rc.2 → 6.0.0-rc.4

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.
Files changed (96) hide show
  1. package/crud/contentEntry/searchableFields.js +6 -2
  2. package/crud/contentEntry/searchableFields.js.map +1 -1
  3. package/crud/contentModel/validation.d.ts +9 -9
  4. package/crud/contentModel/validation.js +3 -3
  5. package/crud/contentModel/validation.js.map +1 -1
  6. package/domain/contentModel/errors.d.ts +1 -1
  7. package/domain/contentModel/errors.js.map +1 -1
  8. package/domain/contentModel/schemas.d.ts +126 -8
  9. package/domain/contentModel/schemas.js +12 -13
  10. package/domain/contentModel/schemas.js.map +1 -1
  11. package/export/graphql/index.js +1 -1
  12. package/export/graphql/index.js.map +1 -1
  13. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +2 -2
  14. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -4
  15. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  16. package/features/contentModel/CreateModel/CreateModelRepository.js +4 -1
  17. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  18. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +12 -3
  19. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  20. package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -2
  21. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  22. package/features/contentModel/UpdateModel/UpdateModelUseCase.js +4 -1
  23. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  24. package/features/modelBuilder/feature.js +2 -2
  25. package/features/modelBuilder/feature.js.map +1 -1
  26. package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +36 -0
  27. package/features/modelBuilder/fields/BaseFieldBuilder.js +41 -0
  28. package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -0
  29. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +228 -0
  30. package/features/modelBuilder/fields/DataFieldBuilder.js +219 -0
  31. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -0
  32. package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +2 -2
  33. package/features/modelBuilder/fields/DynamicZoneFieldType.js +6 -3
  34. package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
  35. package/features/modelBuilder/fields/FieldBuilder.d.ts +5 -228
  36. package/features/modelBuilder/fields/FieldBuilder.js +3 -231
  37. package/features/modelBuilder/fields/FieldBuilder.js.map +1 -1
  38. package/features/modelBuilder/fields/LayoutFieldBuilder.d.ts +7 -0
  39. package/features/modelBuilder/fields/LayoutFieldBuilder.js +9 -0
  40. package/features/modelBuilder/fields/LayoutFieldBuilder.js.map +1 -0
  41. package/features/modelBuilder/fields/ObjectFieldType.d.ts +4 -3
  42. package/features/modelBuilder/fields/ObjectFieldType.js +19 -4
  43. package/features/modelBuilder/fields/ObjectFieldType.js.map +1 -1
  44. package/features/modelBuilder/fields/UiAlertFieldType.d.ts +8 -4
  45. package/features/modelBuilder/fields/UiAlertFieldType.js +23 -6
  46. package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
  47. package/features/modelBuilder/fields/UiSeparatorFieldType.d.ts +6 -4
  48. package/features/modelBuilder/fields/UiSeparatorFieldType.js +18 -4
  49. package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
  50. package/features/modelBuilder/fields/UiTabsFieldType.d.ts +28 -0
  51. package/features/modelBuilder/fields/UiTabsFieldType.js +75 -0
  52. package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -0
  53. package/features/modelBuilder/fields/abstractions.d.ts +2 -2
  54. package/features/modelBuilder/fields/abstractions.js.map +1 -1
  55. package/features/modelBuilder/index.d.ts +2 -0
  56. package/features/modelBuilder/index.js +2 -0
  57. package/features/modelBuilder/index.js.map +1 -1
  58. package/features/modelBuilder/models/BaseModelBuilder.d.ts +8 -3
  59. package/features/modelBuilder/models/BaseModelBuilder.js +19 -0
  60. package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
  61. package/features/modelBuilder/models/PrivateModelBuilder.js +4 -2
  62. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  63. package/features/modelBuilder/models/PublicModelBuilder.js +16 -11
  64. package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
  65. package/graphql/schema/cms/helpers/index.d.ts +1 -0
  66. package/graphql/schema/cms/helpers/index.js +1 -0
  67. package/graphql/schema/cms/helpers/index.js.map +1 -1
  68. package/graphql/schema/cms/helpers/transformWhereToNested.d.ts +17 -0
  69. package/graphql/schema/cms/helpers/transformWhereToNested.js +54 -0
  70. package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -0
  71. package/graphql/schema/cms/helpers.d.ts +1 -0
  72. package/graphql/schema/cms/helpers.js +1 -0
  73. package/graphql/schema/cms/helpers.js.map +1 -1
  74. package/graphql/schema/cms/listEntriesResolver.js +6 -2
  75. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  76. package/graphql/schema/contentModels.js +21 -3
  77. package/graphql/schema/contentModels.js.map +1 -1
  78. package/graphqlFields/index.js +1 -2
  79. package/graphqlFields/index.js.map +1 -1
  80. package/package.json +20 -20
  81. package/plugins/CmsModelPlugin.js +19 -4
  82. package/plugins/CmsModelPlugin.js.map +1 -1
  83. package/types/fields/objectField.d.ts +2 -0
  84. package/types/fields/objectField.js.map +1 -1
  85. package/types/model.d.ts +32 -3
  86. package/types/model.js.map +1 -1
  87. package/types/modelField.d.ts +19 -3
  88. package/types/modelField.js.map +1 -1
  89. package/utils/createModelField.js +4 -2
  90. package/utils/createModelField.js.map +1 -1
  91. package/features/modelBuilder/fields/UiFieldType.d.ts +0 -18
  92. package/features/modelBuilder/fields/UiFieldType.js +0 -25
  93. package/features/modelBuilder/fields/UiFieldType.js.map +0 -1
  94. package/graphqlFields/ui.d.ts +0 -2
  95. package/graphqlFields/ui.js +0 -32
  96. package/graphqlFields/ui.js.map +0 -1
@@ -1,228 +1,5 @@
1
- import type { CmsModelField, CmsModelFieldPredefinedValues, CmsModelFieldValidation } from "../../../types/index.js";
2
- export interface FieldBuilderConfig extends Omit<CmsModelField, "id" | "fieldId" | "storageId" | "type"> {
3
- _storageId?: string;
4
- _fieldId?: string;
5
- description?: string | null;
6
- note?: string | null;
7
- }
8
- /**
9
- * Augmentable renderer registry.
10
- * Each entry maps a renderer name to its applicable field type(s) and settings.
11
- *
12
- * Example:
13
- * declare module "@webiny/api-headless-cms/features/modelBuilder/fields/FieldBuilder" {
14
- * interface FieldRendererRegistry {
15
- * "my-renderer": { fieldType: "text" | "long-text"; settings: { color: string } };
16
- * }
17
- * }
18
- */
19
- export interface FieldRendererRegistry {
20
- switch: {
21
- fieldType: "boolean";
22
- settings: undefined;
23
- };
24
- checkboxes: {
25
- fieldType: "text" | "number";
26
- settings: undefined;
27
- };
28
- dateTimeInput: {
29
- fieldType: "datetime";
30
- settings: undefined;
31
- };
32
- dateTimeInputs: {
33
- fieldType: "datetime";
34
- settings?: {
35
- multiValue?: {
36
- addValueButtonLabel?: string;
37
- };
38
- };
39
- };
40
- dynamicZone: {
41
- fieldType: "dynamicZone";
42
- settings?: {
43
- open?: boolean;
44
- };
45
- };
46
- hidden: {
47
- fieldType: string;
48
- settings: undefined;
49
- };
50
- lexicalEditor: {
51
- fieldType: "rich-text";
52
- settings: undefined;
53
- };
54
- lexicalEditors: {
55
- fieldType: "rich-text";
56
- settings?: {
57
- multiValue?: {
58
- addValueButtonLabel?: string;
59
- };
60
- };
61
- };
62
- textarea: {
63
- fieldType: "long-text";
64
- settings: undefined;
65
- };
66
- textareas: {
67
- fieldType: "long-text";
68
- settings: {
69
- multiValue?: {
70
- addValueButtonLabel?: string;
71
- };
72
- };
73
- };
74
- numberInput: {
75
- fieldType: "number";
76
- settings: undefined;
77
- };
78
- numberInputs: {
79
- fieldType: "number";
80
- settings?: {
81
- multiValue?: {
82
- addValueButtonLabel?: string;
83
- };
84
- };
85
- };
86
- objectAccordionSingle: {
87
- fieldType: "object";
88
- settings?: {
89
- open?: boolean;
90
- };
91
- };
92
- objectAccordionMultiple: {
93
- fieldType: "object";
94
- settings?: {
95
- open?: boolean;
96
- multiValue?: {
97
- addValueButtonLabel?: string;
98
- };
99
- };
100
- };
101
- passthrough: {
102
- fieldType: string;
103
- settings: undefined;
104
- };
105
- radioButtons: {
106
- fieldType: "text" | "number";
107
- settings: undefined;
108
- };
109
- refDialogSingle: {
110
- fieldType: "ref";
111
- settings: undefined;
112
- };
113
- refDialogMultiple: {
114
- fieldType: "ref";
115
- settings?: {
116
- newItemPosition?: "first" | "last";
117
- };
118
- };
119
- refAutocompleteSingle: {
120
- fieldType: "ref";
121
- settings: undefined;
122
- };
123
- refAutocompleteMultiple: {
124
- fieldType: "ref";
125
- settings: undefined;
126
- };
127
- refCheckboxes: {
128
- fieldType: "ref";
129
- settings: undefined;
130
- };
131
- refRadioButtons: {
132
- fieldType: "ref";
133
- settings: undefined;
134
- };
135
- dropdown: {
136
- fieldType: "text" | "number";
137
- settings: undefined;
138
- };
139
- tags: {
140
- fieldType: "text";
141
- settings: undefined;
142
- };
143
- textInput: {
144
- fieldType: "text";
145
- settings: undefined;
146
- };
147
- textInputs: {
148
- fieldType: "text";
149
- settings?: {
150
- multiValue?: {
151
- addValueButtonLabel?: string;
152
- };
153
- };
154
- };
155
- file: {
156
- fieldType: "file";
157
- settings?: {
158
- imagesOnly?: boolean;
159
- };
160
- };
161
- files: {
162
- fieldType: "file";
163
- settings?: {
164
- imagesOnly?: boolean;
165
- };
166
- };
167
- uiSeparator: {
168
- fieldType: "ui";
169
- settings: undefined;
170
- };
171
- uiAlert: {
172
- fieldType: "ui";
173
- settings: {
174
- type: "info" | "success" | "warning" | "danger";
175
- };
176
- };
177
- }
178
- /**
179
- * Extracts renderer names valid for the given field type.
180
- * When TType is a broad `string`, all renderer names are returned.
181
- */
182
- export type FieldRendererName<TType extends string = string> = string extends TType ? keyof FieldRendererRegistry & string : {
183
- [K in keyof FieldRendererRegistry]: TType extends FieldRendererRegistry[K]["fieldType"] ? K : never;
184
- }[keyof FieldRendererRegistry] & string;
185
- export type FieldRendererSettings<TName extends string> = TName extends keyof FieldRendererRegistry ? FieldRendererRegistry[TName]["settings"] : Record<string, any> | undefined;
186
- /**
187
- * Base FieldBuilder class providing common field configuration methods
188
- */
189
- export declare class FieldBuilder<TType extends string = string> {
190
- readonly type: TType;
191
- protected config: FieldBuilderConfig;
192
- constructor(type: TType, label?: string);
193
- label(text: string): this;
194
- help(text: string): this;
195
- description(text: string): this;
196
- note(text: string): this;
197
- placeholder(text: string): this;
198
- storageId(id: string): this;
199
- fieldId(id: string): this;
200
- defaultValue(value: any): this;
201
- list(): this;
202
- tags(tags: string[]): this;
203
- /**
204
- * List validators - these methods are available after calling list()
205
- */
206
- listMinLength(value: number, message?: string): this;
207
- listMaxLength(value: number, message?: string): this;
208
- /**
209
- * Add a validation rule to this field.
210
- * This method is protected and should only be used by field-specific validator methods.
211
- * @internal
212
- */
213
- protected validation(validation: CmsModelFieldValidation): this;
214
- /**
215
- * Add a list validation rule to this field (for list fields).
216
- * This method is protected and should only be used by field-specific validator methods.
217
- * @internal
218
- */
219
- protected listValidation(validation: CmsModelFieldValidation): this;
220
- predefinedValues(values: CmsModelFieldPredefinedValues["values"]): this;
221
- renderer<TName extends FieldRendererName<TType>>(name: TName, ...args: undefined extends FieldRendererSettings<TName> ? [settings?: FieldRendererSettings<TName>] : FieldRendererSettings<TName> extends undefined ? [] : [settings: FieldRendererSettings<TName>]): this;
222
- settings(settings: Record<string, any>): this;
223
- /**
224
- * Build the final CmsModelField
225
- * @internal
226
- */
227
- build(): CmsModelField;
228
- }
1
+ export { DataFieldBuilder, DataFieldBuilder as FieldBuilder } from "./DataFieldBuilder.js";
2
+ export { LayoutFieldBuilder } from "./LayoutFieldBuilder.js";
3
+ export { BaseFieldBuilder } from "./BaseFieldBuilder.js";
4
+ export type { FieldBuildResult, DataFieldBuildResult, LayoutFieldBuildResult } from "./BaseFieldBuilder.js";
5
+ export type { FieldRendererRegistry, FieldRendererName, FieldRendererSettings, FieldBuilderConfig } from "./DataFieldBuilder.js";
@@ -1,233 +1,5 @@
1
- import camelCase from "lodash/camelCase.js";
2
- import { getBaseFieldType } from "../../../utils/getBaseFieldType.js";
3
-
4
- /**
5
- * Augmentable renderer registry.
6
- * Each entry maps a renderer name to its applicable field type(s) and settings.
7
- *
8
- * Example:
9
- * declare module "@webiny/api-headless-cms/features/modelBuilder/fields/FieldBuilder" {
10
- * interface FieldRendererRegistry {
11
- * "my-renderer": { fieldType: "text" | "long-text"; settings: { color: string } };
12
- * }
13
- * }
14
- */
15
-
16
- /**
17
- * Maps camelCase renderer names (used in the builder API) to the
18
- * kebab-case names expected by the frontend renderer registry.
19
- */
20
- const rendererNameMap = {
21
- switch: "boolean-input",
22
- checkboxes: "checkboxes",
23
- dateTimeInput: "date-time-input",
24
- dateTimeInputs: "date-time-inputs",
25
- dynamicZone: "dynamicZone",
26
- hidden: "hidden",
27
- lexicalEditor: "lexical-text-input",
28
- lexicalEditors: "lexical-text-inputs",
29
- textarea: "long-text-text-area",
30
- textareas: "long-text-inputs",
31
- numberInput: "number-input",
32
- numberInputs: "number-inputs",
33
- objectAccordionSingle: "object-accordion",
34
- objectAccordionMultiple: "objects-accordion",
35
- passthrough: "passthrough",
36
- radioButtons: "radio-buttons",
37
- refDialogSingle: "ref-advanced-single",
38
- refDialogMultiple: "ref-advanced-multiple",
39
- refAutocompleteSingle: "ref-input",
40
- refAutocompleteMultiple: "ref-inputs",
41
- refCheckboxes: "ref-simple-multiple",
42
- refRadioButtons: "ref-simple-single",
43
- dropdown: "select-box",
44
- tags: "tags",
45
- textInput: "text-input",
46
- textInputs: "text-inputs",
47
- file: "file-input",
48
- files: "file-inputs",
49
- uiSeparator: "uiSeparator",
50
- uiAlert: "uiAlert"
51
- };
52
-
53
- /**
54
- * Resolves a camelCase renderer name to the kebab-case name used by the frontend.
55
- */
56
- function resolveRendererName(name) {
57
- return rendererNameMap[name] ?? name;
58
- }
59
-
60
- /**
61
- * Extracts renderer names valid for the given field type.
62
- * When TType is a broad `string`, all renderer names are returned.
63
- */
64
-
65
- /**
66
- * Base FieldBuilder class providing common field configuration methods
67
- */
68
- export class FieldBuilder {
69
- constructor(type, label) {
70
- this.type = type;
71
- this.config = {
72
- label: label || "",
73
- validation: [],
74
- listValidation: [],
75
- list: false,
76
- predefinedValues: {
77
- enabled: false,
78
- values: []
79
- },
80
- help: null,
81
- placeholder: null,
82
- description: null,
83
- note: null,
84
- renderer: null,
85
- settings: {},
86
- tags: []
87
- };
88
- }
89
- label(text) {
90
- this.config.label = text;
91
- return this;
92
- }
93
- help(text) {
94
- this.config.help = text;
95
- return this;
96
- }
97
- description(text) {
98
- this.config.description = text;
99
- return this;
100
- }
101
- note(text) {
102
- this.config.note = text;
103
- return this;
104
- }
105
- placeholder(text) {
106
- this.config.placeholder = text;
107
- return this;
108
- }
109
- storageId(id) {
110
- // We do not allow developers to specify the field type!
111
- this.config._storageId = id.split("@").pop();
112
- return this;
113
- }
114
- fieldId(id) {
115
- this.config._fieldId = id;
116
- return this;
117
- }
118
- defaultValue(value) {
119
- this.config.settings = {
120
- ...this.config.settings,
121
- defaultValue: value
122
- };
123
- return this;
124
- }
125
- list() {
126
- this.config.list = true;
127
- return this;
128
- }
129
- tags(tags) {
130
- this.config.tags = tags;
131
- return this;
132
- }
133
-
134
- /**
135
- * List validators - these methods are available after calling list()
136
- */
137
- listMinLength(value, message) {
138
- return this.listValidation({
139
- name: "minLength",
140
- message: message || `At least ${value} item(s) required.`,
141
- settings: {
142
- value
143
- }
144
- });
145
- }
146
- listMaxLength(value, message) {
147
- return this.listValidation({
148
- name: "maxLength",
149
- message: message || `At most ${value} item(s) allowed.`,
150
- settings: {
151
- value
152
- }
153
- });
154
- }
155
-
156
- /**
157
- * Add a validation rule to this field.
158
- * This method is protected and should only be used by field-specific validator methods.
159
- * @internal
160
- */
161
- validation(validation) {
162
- this.config.validation = this.config.validation || [];
163
- this.config.validation.push(validation);
164
- return this;
165
- }
166
-
167
- /**
168
- * Add a list validation rule to this field (for list fields).
169
- * This method is protected and should only be used by field-specific validator methods.
170
- * @internal
171
- */
172
- listValidation(validation) {
173
- this.config.listValidation = this.config.listValidation || [];
174
- this.config.listValidation.push(validation);
175
- return this;
176
- }
177
- predefinedValues(values) {
178
- this.config.predefinedValues = {
179
- enabled: true,
180
- values
181
- };
182
- return this;
183
- }
184
- renderer(name, ...args) {
185
- this.config.renderer = {
186
- name: resolveRendererName(name),
187
- settings: args[0] ?? null
188
- };
189
- return this;
190
- }
191
- settings(settings) {
192
- this.config.settings = {
193
- ...this.config.settings,
194
- ...settings
195
- };
196
- return this;
197
- }
198
-
199
- /**
200
- * Build the final CmsModelField
201
- * @internal
202
- */
203
- build() {
204
- const fieldId = this.config._fieldId || camelCase(this.config.label);
205
- const baseType = getBaseFieldType({
206
- type: this.type
207
- });
208
- const storageId = `${baseType}@${this.config._storageId ?? fieldId}`;
209
- return {
210
- id: fieldId,
211
- fieldId,
212
- storageId,
213
- type: this.type,
214
- label: this.config.label,
215
- validation: this.config.validation || [],
216
- listValidation: this.config.listValidation || [],
217
- list: this.config.list || false,
218
- predefinedValues: this.config.predefinedValues || {
219
- enabled: false,
220
- values: []
221
- },
222
- help: this.config.help || null,
223
- placeholder: this.config.placeholder || null,
224
- description: this.config.description || null,
225
- note: this.config.note || null,
226
- renderer: this.config.renderer || null,
227
- settings: this.config.settings || {},
228
- tags: this.config.tags || []
229
- };
230
- }
231
- }
1
+ export { DataFieldBuilder, DataFieldBuilder as FieldBuilder } from "./DataFieldBuilder.js";
2
+ export { LayoutFieldBuilder } from "./LayoutFieldBuilder.js";
3
+ export { BaseFieldBuilder } from "./BaseFieldBuilder.js";
232
4
 
233
5
  //# sourceMappingURL=FieldBuilder.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["camelCase","getBaseFieldType","rendererNameMap","switch","checkboxes","dateTimeInput","dateTimeInputs","dynamicZone","hidden","lexicalEditor","lexicalEditors","textarea","textareas","numberInput","numberInputs","objectAccordionSingle","objectAccordionMultiple","passthrough","radioButtons","refDialogSingle","refDialogMultiple","refAutocompleteSingle","refAutocompleteMultiple","refCheckboxes","refRadioButtons","dropdown","tags","textInput","textInputs","file","files","uiSeparator","uiAlert","resolveRendererName","name","FieldBuilder","constructor","type","label","config","validation","listValidation","list","predefinedValues","enabled","values","help","placeholder","description","note","renderer","settings","text","storageId","id","_storageId","split","pop","fieldId","_fieldId","defaultValue","value","listMinLength","message","listMaxLength","push","args","build","baseType"],"sources":["FieldBuilder.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport type {\n CmsModelField,\n CmsModelFieldPredefinedValues,\n CmsModelFieldValidation\n} from \"~/types/index.js\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType.js\";\n\nexport interface FieldBuilderConfig\n extends Omit<CmsModelField, \"id\" | \"fieldId\" | \"storageId\" | \"type\"> {\n _storageId?: string;\n _fieldId?: string;\n description?: string | null;\n note?: string | null;\n}\n\n/**\n * Augmentable renderer registry.\n * Each entry maps a renderer name to its applicable field type(s) and settings.\n *\n * Example:\n * declare module \"@webiny/api-headless-cms/features/modelBuilder/fields/FieldBuilder\" {\n * interface FieldRendererRegistry {\n * \"my-renderer\": { fieldType: \"text\" | \"long-text\"; settings: { color: string } };\n * }\n * }\n */\nexport interface FieldRendererRegistry {\n switch: {\n fieldType: \"boolean\";\n settings: undefined;\n };\n checkboxes: {\n fieldType: \"text\" | \"number\";\n settings: undefined;\n };\n dateTimeInput: {\n fieldType: \"datetime\";\n settings: undefined;\n };\n dateTimeInputs: {\n fieldType: \"datetime\";\n settings?: {\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n dynamicZone: {\n fieldType: \"dynamicZone\";\n settings?: {\n open?: boolean;\n };\n };\n hidden: {\n fieldType: string;\n settings: undefined;\n };\n lexicalEditor: {\n fieldType: \"rich-text\";\n settings: undefined;\n };\n lexicalEditors: {\n fieldType: \"rich-text\";\n settings?: {\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n textarea: {\n fieldType: \"long-text\";\n settings: undefined;\n };\n textareas: {\n fieldType: \"long-text\";\n settings: {\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n numberInput: {\n fieldType: \"number\";\n settings: undefined;\n };\n numberInputs: {\n fieldType: \"number\";\n settings?: {\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n objectAccordionSingle: {\n fieldType: \"object\";\n settings?: {\n open?: boolean;\n };\n };\n objectAccordionMultiple: {\n fieldType: \"object\";\n settings?: {\n open?: boolean;\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n passthrough: {\n fieldType: string;\n settings: undefined;\n };\n radioButtons: {\n fieldType: \"text\" | \"number\";\n settings: undefined;\n };\n refDialogSingle: {\n fieldType: \"ref\";\n settings: undefined;\n };\n refDialogMultiple: {\n fieldType: \"ref\";\n settings?: {\n newItemPosition?: \"first\" | \"last\";\n };\n };\n refAutocompleteSingle: {\n fieldType: \"ref\";\n settings: undefined;\n };\n refAutocompleteMultiple: {\n fieldType: \"ref\";\n settings: undefined;\n };\n refCheckboxes: {\n fieldType: \"ref\";\n settings: undefined;\n };\n refRadioButtons: {\n fieldType: \"ref\";\n settings: undefined;\n };\n dropdown: {\n fieldType: \"text\" | \"number\";\n settings: undefined;\n };\n tags: {\n fieldType: \"text\";\n settings: undefined;\n };\n textInput: {\n fieldType: \"text\";\n settings: undefined;\n };\n textInputs: {\n fieldType: \"text\";\n settings?: {\n multiValue?: {\n addValueButtonLabel?: string;\n };\n };\n };\n file: {\n fieldType: \"file\";\n settings?: {\n imagesOnly?: boolean;\n };\n };\n files: {\n fieldType: \"file\";\n settings?: {\n imagesOnly?: boolean;\n };\n };\n uiSeparator: {\n fieldType: \"ui\";\n settings: undefined;\n };\n uiAlert: {\n fieldType: \"ui\";\n settings: {\n type: \"info\" | \"success\" | \"warning\" | \"danger\";\n };\n };\n}\n\n/**\n * Maps camelCase renderer names (used in the builder API) to the\n * kebab-case names expected by the frontend renderer registry.\n */\nconst rendererNameMap: Record<keyof FieldRendererRegistry, string> = {\n switch: \"boolean-input\",\n checkboxes: \"checkboxes\",\n dateTimeInput: \"date-time-input\",\n dateTimeInputs: \"date-time-inputs\",\n dynamicZone: \"dynamicZone\",\n hidden: \"hidden\",\n lexicalEditor: \"lexical-text-input\",\n lexicalEditors: \"lexical-text-inputs\",\n textarea: \"long-text-text-area\",\n textareas: \"long-text-inputs\",\n numberInput: \"number-input\",\n numberInputs: \"number-inputs\",\n objectAccordionSingle: \"object-accordion\",\n objectAccordionMultiple: \"objects-accordion\",\n passthrough: \"passthrough\",\n radioButtons: \"radio-buttons\",\n refDialogSingle: \"ref-advanced-single\",\n refDialogMultiple: \"ref-advanced-multiple\",\n refAutocompleteSingle: \"ref-input\",\n refAutocompleteMultiple: \"ref-inputs\",\n refCheckboxes: \"ref-simple-multiple\",\n refRadioButtons: \"ref-simple-single\",\n dropdown: \"select-box\",\n tags: \"tags\",\n textInput: \"text-input\",\n textInputs: \"text-inputs\",\n file: \"file-input\",\n files: \"file-inputs\",\n uiSeparator: \"uiSeparator\",\n uiAlert: \"uiAlert\"\n};\n\n/**\n * Resolves a camelCase renderer name to the kebab-case name used by the frontend.\n */\nfunction resolveRendererName(name: string): string {\n return rendererNameMap[name as keyof FieldRendererRegistry] ?? name;\n}\n\n/**\n * Extracts renderer names valid for the given field type.\n * When TType is a broad `string`, all renderer names are returned.\n */\nexport type FieldRendererName<TType extends string = string> = string extends TType\n ? keyof FieldRendererRegistry & string\n : {\n [K in keyof FieldRendererRegistry]: TType extends FieldRendererRegistry[K][\"fieldType\"]\n ? K\n : never;\n }[keyof FieldRendererRegistry] &\n string;\n\nexport type FieldRendererSettings<TName extends string> = TName extends keyof FieldRendererRegistry\n ? FieldRendererRegistry[TName][\"settings\"]\n : Record<string, any> | undefined;\n\n/**\n * Base FieldBuilder class providing common field configuration methods\n */\nexport class FieldBuilder<TType extends string = string> {\n public readonly type: TType;\n protected config: FieldBuilderConfig;\n\n public constructor(type: TType, label?: string) {\n this.type = type;\n this.config = {\n label: label || \"\",\n validation: [],\n listValidation: [],\n list: false,\n predefinedValues: {\n enabled: false,\n values: []\n },\n help: null,\n placeholder: null,\n description: null,\n note: null,\n renderer: null,\n settings: {},\n tags: []\n };\n }\n\n label(text: string): this {\n this.config.label = text;\n return this;\n }\n\n help(text: string): this {\n this.config.help = text;\n return this;\n }\n\n description(text: string): this {\n this.config.description = text;\n return this;\n }\n\n note(text: string): this {\n this.config.note = text;\n return this;\n }\n\n placeholder(text: string): this {\n this.config.placeholder = text;\n return this;\n }\n\n storageId(id: string): this {\n // We do not allow developers to specify the field type!\n this.config._storageId = id.split(\"@\").pop();\n return this;\n }\n\n fieldId(id: string): this {\n this.config._fieldId = id;\n return this;\n }\n\n defaultValue(value: any): this {\n this.config.settings = { ...this.config.settings, defaultValue: value };\n return this;\n }\n\n list(): this {\n this.config.list = true;\n return this as this;\n }\n\n tags(tags: string[]): this {\n this.config.tags = tags;\n return this;\n }\n\n /**\n * List validators - these methods are available after calling list()\n */\n listMinLength(value: number, message?: string): this {\n return this.listValidation({\n name: \"minLength\",\n message: message || `At least ${value} item(s) required.`,\n settings: { value }\n });\n }\n\n listMaxLength(value: number, message?: string): this {\n return this.listValidation({\n name: \"maxLength\",\n message: message || `At most ${value} item(s) allowed.`,\n settings: { value }\n });\n }\n\n /**\n * Add a validation rule to this field.\n * This method is protected and should only be used by field-specific validator methods.\n * @internal\n */\n protected validation(validation: CmsModelFieldValidation): this {\n this.config.validation = this.config.validation || [];\n this.config.validation.push(validation);\n return this;\n }\n\n /**\n * Add a list validation rule to this field (for list fields).\n * This method is protected and should only be used by field-specific validator methods.\n * @internal\n */\n protected listValidation(validation: CmsModelFieldValidation): this {\n this.config.listValidation = this.config.listValidation || [];\n this.config.listValidation.push(validation);\n return this;\n }\n\n predefinedValues(values: CmsModelFieldPredefinedValues[\"values\"]): this {\n this.config.predefinedValues = {\n enabled: true,\n values\n };\n return this;\n }\n\n renderer<TName extends FieldRendererName<TType>>(\n name: TName,\n ...args: undefined extends FieldRendererSettings<TName>\n ? [settings?: FieldRendererSettings<TName>]\n : FieldRendererSettings<TName> extends undefined\n ? []\n : [settings: FieldRendererSettings<TName>]\n ): this {\n this.config.renderer = {\n name: resolveRendererName(name),\n settings: args[0] ?? null\n };\n return this;\n }\n\n settings(settings: Record<string, any>): this {\n this.config.settings = { ...this.config.settings, ...settings };\n return this;\n }\n\n /**\n * Build the final CmsModelField\n * @internal\n */\n build(): CmsModelField {\n const fieldId = this.config._fieldId || camelCase(this.config.label);\n const baseType = getBaseFieldType({\n type: this.type\n });\n const storageId = `${baseType}@${this.config._storageId ?? fieldId}`;\n\n return {\n id: fieldId,\n fieldId,\n storageId,\n type: this.type,\n label: this.config.label,\n validation: this.config.validation || [],\n listValidation: this.config.listValidation || [],\n list: this.config.list || false,\n predefinedValues: this.config.predefinedValues || {\n enabled: false,\n values: []\n },\n help: this.config.help || null,\n placeholder: this.config.placeholder || null,\n description: this.config.description || null,\n note: this.config.note || null,\n renderer: this.config.renderer || null,\n settings: this.config.settings || {},\n tags: this.config.tags || []\n };\n }\n}\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,qBAAqB;AAM3C,SAASC,gBAAgB;;AAUzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiKA;AACA;AACA;AACA;AACA,MAAMC,eAA4D,GAAG;EACjEC,MAAM,EAAE,eAAe;EACvBC,UAAU,EAAE,YAAY;EACxBC,aAAa,EAAE,iBAAiB;EAChCC,cAAc,EAAE,kBAAkB;EAClCC,WAAW,EAAE,aAAa;EAC1BC,MAAM,EAAE,QAAQ;EAChBC,aAAa,EAAE,oBAAoB;EACnCC,cAAc,EAAE,qBAAqB;EACrCC,QAAQ,EAAE,qBAAqB;EAC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W,IAAI,IAAI;MAC5CC,IAAI,EAAE,IAAI,CAACV,MAAM,CAACU,IAAI,IAAI,IAAI;MAC9BC,QAAQ,EAAE,IAAI,CAACX,MAAM,CAACW,QAAQ,IAAI,IAAI;MACtCC,QAAQ,EAAE,IAAI,CAACZ,MAAM,CAACY,QAAQ,IAAI,CAAC,CAAC;MACpCzB,IAAI,EAAE,IAAI,CAACa,MAAM,CAACb,IAAI,IAAI;IAC9B,CAAC;EACL;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["DataFieldBuilder","FieldBuilder","LayoutFieldBuilder","BaseFieldBuilder"],"sources":["FieldBuilder.ts"],"sourcesContent":["export { DataFieldBuilder, DataFieldBuilder as FieldBuilder } from \"./DataFieldBuilder.js\";\nexport { LayoutFieldBuilder } from \"./LayoutFieldBuilder.js\";\nexport { BaseFieldBuilder } from \"./BaseFieldBuilder.js\";\nexport type {\n FieldBuildResult,\n DataFieldBuildResult,\n LayoutFieldBuildResult\n} from \"./BaseFieldBuilder.js\";\nexport type {\n FieldRendererRegistry,\n FieldRendererName,\n FieldRendererSettings,\n FieldBuilderConfig\n} from \"./DataFieldBuilder.js\";\n"],"mappings":"AAAA,SAASA,gBAAgB,EAAEA,gBAAgB,IAAIC,YAAY;AAC3D,SAASC,kBAAkB;AAC3B,SAASC,gBAAgB","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ import { BaseFieldBuilder } from "./BaseFieldBuilder.js";
2
+ /**
3
+ * Slim base class for layout fields (separators, alerts, tabs, etc.).
4
+ * Layout fields only support label, description, help, and note — no list(), storageId(), etc.
5
+ */
6
+ export declare abstract class LayoutFieldBuilder<TType extends string = string> extends BaseFieldBuilder<TType> {
7
+ }
@@ -0,0 +1,9 @@
1
+ import { BaseFieldBuilder } from "./BaseFieldBuilder.js";
2
+
3
+ /**
4
+ * Slim base class for layout fields (separators, alerts, tabs, etc.).
5
+ * Layout fields only support label, description, help, and note — no list(), storageId(), etc.
6
+ */
7
+ export class LayoutFieldBuilder extends BaseFieldBuilder {}
8
+
9
+ //# sourceMappingURL=LayoutFieldBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BaseFieldBuilder","LayoutFieldBuilder"],"sources":["LayoutFieldBuilder.ts"],"sourcesContent":["import { BaseFieldBuilder } from \"./BaseFieldBuilder.js\";\n\n/**\n * Slim base class for layout fields (separators, alerts, tabs, etc.).\n * Layout fields only support label, description, help, and note — no list(), storageId(), etc.\n */\nexport abstract class LayoutFieldBuilder<\n TType extends string = string\n> extends BaseFieldBuilder<TType> {}\n"],"mappings":"AAAA,SAASA,gBAAgB;;AAEzB;AACA;AACA;AACA;AACA,OAAO,MAAeC,kBAAkB,SAE9BD,gBAAgB,CAAQ","ignoreList":[]}
@@ -1,10 +1,11 @@
1
1
  import { type IFieldTypeFactory } from "./abstractions.js";
2
+ import { BaseFieldBuilder } from "./BaseFieldBuilder.js";
2
3
  import { FieldBuilder } from "./FieldBuilder.js";
3
4
  import { FieldBuilderRegistry } from "../abstractions.js";
4
5
  import { LayoutBuilder } from "../LayoutBuilder.js";
5
6
  export interface IObjectFieldBuilder extends FieldBuilder<"object"> {
6
7
  required(message?: string): this;
7
- fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string, FieldBuilder<any>>): this;
8
+ fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>): this;
8
9
  layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this;
9
10
  }
10
11
  export declare class ObjectFieldBuilder extends FieldBuilder<"object"> implements IObjectFieldBuilder {
@@ -13,9 +14,9 @@ export declare class ObjectFieldBuilder extends FieldBuilder<"object"> implement
13
14
  private fieldBuildersMap;
14
15
  constructor(registry: FieldBuilderRegistry.Interface);
15
16
  required(message?: string): this;
16
- fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string, FieldBuilder<any>>): this;
17
+ fields(builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>): this;
17
18
  layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this;
18
- build(): import("../../../types/modelField.js").CmsModelField;
19
+ build(): import("./BaseFieldBuilder.js").DataFieldBuildResult;
19
20
  }
20
21
  declare class ObjectFieldTypeFactory implements IFieldTypeFactory {
21
22
  readonly type = "object";
@@ -40,12 +40,27 @@ export class ObjectFieldBuilder extends FieldBuilder {
40
40
  return this;
41
41
  }
42
42
  build() {
43
- // Build all nested fields from field builders
44
43
  this.config.settings = this.config.settings || {};
45
- this.config.settings.fields = Array.from(this.fieldBuildersMap.values()).map(builder => builder.build());
46
44
 
47
- // Build layout
48
- this.config.settings.layout = this.layoutBuilder.build();
45
+ // Build nested fields, separating data fields from layout fields
46
+ const fields = [];
47
+ const layoutReplacements = new Map();
48
+ for (const [fieldId, builder] of this.fieldBuildersMap) {
49
+ const result = builder.build();
50
+ if (result.type === "layout") {
51
+ layoutReplacements.set(fieldId, result.layoutCell);
52
+ if (result.fields) {
53
+ fields.push(...result.fields);
54
+ }
55
+ } else {
56
+ fields.push(result.field);
57
+ }
58
+ }
59
+ this.config.settings.fields = fields;
60
+
61
+ // Build layout and apply replacements
62
+ const rawLayout = this.layoutBuilder.build();
63
+ this.config.settings.layout = rawLayout.map(row => row.map(cell => layoutReplacements.get(cell) ?? cell));
49
64
  return super.build();
50
65
  }
51
66
  }
@@ -1 +1 @@
1
- {"version":3,"names":["FieldType","FieldBuilder","LayoutBuilder","ObjectFieldBuilder","fieldBuildersMap","Map","constructor","registry","layoutBuilder","required","message","validation","name","config","push","fields","builder","existingFields","fieldBuilders","key","fieldBuilder","Object","entries","fieldId","set","layout","layoutOrBuilder","Array","isArray","setLayout","addModifier","build","settings","from","values","map","ObjectFieldTypeFactory","type","create","ObjectFieldType","createImplementation","implementation","dependencies"],"sources":["ObjectFieldType.ts"],"sourcesContent":["import { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\nimport { FieldBuilder } from \"./FieldBuilder.js\";\nimport { FieldBuilderRegistry } from \"../abstractions.js\";\nimport { LayoutBuilder } from \"../LayoutBuilder.js\";\n\nexport interface IObjectFieldBuilder extends FieldBuilder<\"object\"> {\n required(message?: string): this;\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, FieldBuilder<any>>\n ): this;\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this;\n}\n\nexport class ObjectFieldBuilder extends FieldBuilder<\"object\"> implements IObjectFieldBuilder {\n private layoutBuilder: LayoutBuilder;\n private fieldBuildersMap = new Map<string, FieldBuilder<any>>();\n\n public constructor(private registry: FieldBuilderRegistry.Interface) {\n super(\"object\");\n this.layoutBuilder = new LayoutBuilder();\n }\n\n required(message?: string): this {\n const validation = {\n name: \"required\",\n message: message || \"Value is required.\"\n };\n this.config.validation = this.config.validation || [];\n this.config.validation.push(validation);\n return this;\n }\n\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, FieldBuilder<any>>\n ): this {\n // Pass existing fields to registry so it can return them when extending\n (this.registry as any).existingFields = this.fieldBuildersMap;\n\n const fieldBuilders = builder(this.registry);\n for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {\n // Automatically set the fieldId from the object key\n fieldBuilder.fieldId(key);\n // Store builder (not built field)\n this.fieldBuildersMap.set(key, fieldBuilder);\n }\n\n return this;\n }\n\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this {\n if (Array.isArray(layoutOrBuilder)) {\n // Set base layout and clear modifiers\n this.layoutBuilder.setLayout(layoutOrBuilder);\n } else {\n // Queue the modifier callback\n this.layoutBuilder.addModifier(layoutOrBuilder);\n }\n\n return this;\n }\n\n override build() {\n // Build all nested fields from field builders\n this.config.settings = this.config.settings || {};\n this.config.settings.fields = Array.from(this.fieldBuildersMap.values()).map(builder =>\n builder.build()\n );\n\n // Build layout\n this.config.settings.layout = this.layoutBuilder.build();\n\n return super.build();\n }\n}\n\nclass ObjectFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"object\";\n\n create(registry: FieldBuilderRegistry.Interface): IObjectFieldBuilder {\n return new ObjectFieldBuilder(registry);\n }\n}\n\nexport const ObjectFieldType = FieldType.createImplementation({\n implementation: ObjectFieldTypeFactory,\n dependencies: []\n});\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n object(): IObjectFieldBuilder;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAClB,SAASC,YAAY;AAErB,SAASC,aAAa;AAUtB,OAAO,MAAMC,kBAAkB,SAASF,YAAY,CAA0C;EAElFG,gBAAgB,GAAG,IAAIC,GAAG,CAA4B,CAAC;EAExDC,WAAWA,CAASC,QAAwC,EAAE;IACjE,KAAK,CAAC,QAAQ,CAAC;IAAC,KADOA,QAAwC,GAAxCA,QAAwC;IAE/D,IAAI,CAACC,aAAa,GAAG,IAAIN,aAAa,CAAC,CAAC;EAC5C;EAEAO,QAAQA,CAACC,OAAgB,EAAQ;IAC7B,MAAMC,UAAU,GAAG;MACfC,IAAI,EAAE,UAAU;MAChBF,OAAO,EAAEA,OAAO,IAAI;IACxB,CAAC;IACD,IAAI,CAACG,MAAM,CAACF,UAAU,GAAG,IAAI,CAACE,MAAM,CAACF,UAAU,IAAI,EAAE;IACrD,IAAI,CAACE,MAAM,CAACF,UAAU,CAACG,IAAI,CAACH,UAAU,CAAC;IACvC,OAAO,IAAI;EACf;EAEAI,MAAMA,CACFC,OAAwF,EACpF;IACJ;IACC,IAAI,CAACT,QAAQ,CAASU,cAAc,GAAG,IAAI,CAACb,gBAAgB;IAE7D,MAAMc,aAAa,GAAGF,OAAO,CAAC,IAAI,CAACT,QAAQ,CAAC;IAC5C,KAAK,MAAM,CAACY,GAAG,EAAEC,YAAY,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACJ,aAAa,CAAC,EAAE;MAC7D;MACAE,YAAY,CAACG,OAAO,CAACJ,GAAG,CAAC;MACzB;MACA,IAAI,CAACf,gBAAgB,CAACoB,GAAG,CAACL,GAAG,EAAEC,YAAY,CAAC;IAChD;IAEA,OAAO,IAAI;EACf;EAEAK,MAAMA,CAACC,eAAgE,EAAQ;IAC3E,IAAIC,KAAK,CAACC,OAAO,CAACF,eAAe,CAAC,EAAE;MAChC;MACA,IAAI,CAAClB,aAAa,CAACqB,SAAS,CAACH,eAAe,CAAC;IACjD,CAAC,MAAM;MACH;MACA,IAAI,CAAClB,aAAa,CAACsB,WAAW,CAACJ,eAAe,CAAC;IACnD;IAEA,OAAO,IAAI;EACf;EAESK,KAAKA,CAAA,EAAG;IACb;IACA,IAAI,CAAClB,MAAM,CAACmB,QAAQ,GAAG,IAAI,CAACnB,MAAM,CAACmB,QAAQ,IAAI,CAAC,CAAC;IACjD,IAAI,CAACnB,MAAM,CAACmB,QAAQ,CAACjB,MAAM,GAAGY,KAAK,CAACM,IAAI,CAAC,IAAI,CAAC7B,gBAAgB,CAAC8B,MAAM,CAAC,CAAC,CAAC,CAACC,GAAG,CAACnB,OAAO,IAChFA,OAAO,CAACe,KAAK,CAAC,CAClB,CAAC;;IAED;IACA,IAAI,CAAClB,MAAM,CAACmB,QAAQ,CAACP,MAAM,GAAG,IAAI,CAACjB,aAAa,CAACuB,KAAK,CAAC,CAAC;IAExD,OAAO,KAAK,CAACA,KAAK,CAAC,CAAC;EACxB;AACJ;AAEA,MAAMK,sBAAsB,CAA8B;EAC7CC,IAAI,GAAG,QAAQ;EAExBC,MAAMA,CAAC/B,QAAwC,EAAuB;IAClE,OAAO,IAAIJ,kBAAkB,CAACI,QAAQ,CAAC;EAC3C;AACJ;AAEA,OAAO,MAAMgC,eAAe,GAAGvC,SAAS,CAACwC,oBAAoB,CAAC;EAC1DC,cAAc,EAAEL,sBAAsB;EACtCM,YAAY,EAAE;AAClB,CAAC,CAAC;;AAEF","ignoreList":[]}
1
+ {"version":3,"names":["FieldType","FieldBuilder","LayoutBuilder","ObjectFieldBuilder","fieldBuildersMap","Map","constructor","registry","layoutBuilder","required","message","validation","name","config","push","fields","builder","existingFields","fieldBuilders","key","fieldBuilder","Object","entries","fieldId","set","layout","layoutOrBuilder","Array","isArray","setLayout","addModifier","build","settings","layoutReplacements","result","type","layoutCell","field","rawLayout","map","row","cell","get","ObjectFieldTypeFactory","create","ObjectFieldType","createImplementation","implementation","dependencies"],"sources":["ObjectFieldType.ts"],"sourcesContent":["import { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\nimport { BaseFieldBuilder } from \"./BaseFieldBuilder.js\";\nimport { FieldBuilder } from \"./FieldBuilder.js\";\nimport { FieldBuilderRegistry } from \"../abstractions.js\";\nimport { LayoutBuilder } from \"../LayoutBuilder.js\";\nimport type { CmsModelField, CmsModelLayoutCell } from \"~/types/index.js\";\n\nexport interface IObjectFieldBuilder extends FieldBuilder<\"object\"> {\n required(message?: string): this;\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>\n ): this;\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this;\n}\n\nexport class ObjectFieldBuilder extends FieldBuilder<\"object\"> implements IObjectFieldBuilder {\n private layoutBuilder: LayoutBuilder;\n private fieldBuildersMap = new Map<string, BaseFieldBuilder<any>>();\n\n public constructor(private registry: FieldBuilderRegistry.Interface) {\n super(\"object\");\n this.layoutBuilder = new LayoutBuilder();\n }\n\n required(message?: string): this {\n const validation = {\n name: \"required\",\n message: message || \"Value is required.\"\n };\n this.config.validation = this.config.validation || [];\n this.config.validation.push(validation);\n return this;\n }\n\n fields(\n builder: (registry: FieldBuilderRegistry.Interface) => Record<string, BaseFieldBuilder<any>>\n ): this {\n // Pass existing fields to registry so it can return them when extending\n (this.registry as any).existingFields = this.fieldBuildersMap;\n\n const fieldBuilders = builder(this.registry);\n for (const [key, fieldBuilder] of Object.entries(fieldBuilders)) {\n // Automatically set the fieldId from the object key\n fieldBuilder.fieldId(key);\n // Store builder (not built field)\n this.fieldBuildersMap.set(key, fieldBuilder);\n }\n\n return this;\n }\n\n layout(layoutOrBuilder: string[][] | ((builder: LayoutBuilder) => void)): this {\n if (Array.isArray(layoutOrBuilder)) {\n // Set base layout and clear modifiers\n this.layoutBuilder.setLayout(layoutOrBuilder);\n } else {\n // Queue the modifier callback\n this.layoutBuilder.addModifier(layoutOrBuilder);\n }\n\n return this;\n }\n\n override build() {\n this.config.settings = this.config.settings || {};\n\n // Build nested fields, separating data fields from layout fields\n const fields: CmsModelField[] = [];\n const layoutReplacements = new Map<string, CmsModelLayoutCell>();\n\n for (const [fieldId, builder] of this.fieldBuildersMap) {\n const result = builder.build();\n if (result.type === \"layout\") {\n layoutReplacements.set(fieldId, result.layoutCell);\n if (result.fields) {\n fields.push(...result.fields);\n }\n } else {\n fields.push(result.field);\n }\n }\n\n this.config.settings.fields = fields;\n\n // Build layout and apply replacements\n const rawLayout = this.layoutBuilder.build();\n this.config.settings.layout = rawLayout.map(row =>\n row.map(cell => layoutReplacements.get(cell) ?? cell)\n );\n\n return super.build();\n }\n}\n\nclass ObjectFieldTypeFactory implements IFieldTypeFactory {\n readonly type = \"object\";\n\n create(registry: FieldBuilderRegistry.Interface): IObjectFieldBuilder {\n return new ObjectFieldBuilder(registry);\n }\n}\n\nexport const ObjectFieldType = FieldType.createImplementation({\n implementation: ObjectFieldTypeFactory,\n dependencies: []\n});\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n object(): IObjectFieldBuilder;\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS;AAElB,SAASC,YAAY;AAErB,SAASC,aAAa;AAWtB,OAAO,MAAMC,kBAAkB,SAASF,YAAY,CAA0C;EAElFG,gBAAgB,GAAG,IAAIC,GAAG,CAAgC,CAAC;EAE5DC,WAAWA,CAASC,QAAwC,EAAE;IACjE,KAAK,CAAC,QAAQ,CAAC;IAAC,KADOA,QAAwC,GAAxCA,QAAwC;IAE/D,IAAI,CAACC,aAAa,GAAG,IAAIN,aAAa,CAAC,CAAC;EAC5C;EAEAO,QAAQA,CAACC,OAAg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IAAI,IAAI,CAACZ,gBAAgB,EAAE;MACpD,MAAM8B,MAAM,GAAGlB,OAAO,CAACe,KAAK,CAAC,CAAC;MAC9B,IAAIG,MAAM,CAACC,IAAI,KAAK,QAAQ,EAAE;QAC1BF,kBAAkB,CAACT,GAAG,CAACD,OAAO,EAAEW,MAAM,CAACE,UAAU,CAAC;QAClD,IAAIF,MAAM,CAACnB,MAAM,EAAE;UACfA,MAAM,CAACD,IAAI,CAAC,GAAGoB,MAAM,CAACnB,MAAM,CAAC;QACjC;MACJ,CAAC,MAAM;QACHA,MAAM,CAACD,IAAI,CAACoB,MAAM,CAACG,KAAK,CAAC;MAC7B;IACJ;IAEA,IAAI,CAACxB,MAAM,CAACmB,QAAQ,CAACjB,MAAM,GAAGA,MAAM;;IAEpC;IACA,MAAMuB,SAAS,GAAG,IAAI,CAAC9B,aAAa,CAACuB,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAClB,MAAM,CAACmB,QAAQ,CAACP,MAAM,GAAGa,SAAS,CAACC,GAAG,CAACC,GAAG,IAC3CA,GAAG,CAACD,GAAG,CAACE,IAAI,IAAIR,kBAAkB,CAACS,GAAG,CAACD,IAAI,CAAC,IAAIA,IAAI,CACxD,CAAC;IAED,OAAO,KAAK,CAACV,KAAK,CAAC,CAAC;EACxB;AACJ;AAEA,MAAMY,sBAAsB,CAA8B;EAC7CR,IAAI,GAAG,QAAQ;EAExBS,MAAMA,CAACrC,QAAwC,EAAuB;IAClE,OAAO,IAAIJ,kBAAkB,CAACI,QAAQ,CAAC;EAC3C;AACJ;AAEA,OAAO,MAAMsC,eAAe,GAAG7C,SAAS,CAAC8C,oBAAoB,CAAC;EAC1DC,cAAc,EAAEJ,sBAAsB;EACtCK,YAAY,EAAE;AAClB,CAAC,CAAC;;AAEF","ignoreList":[]}
@@ -1,15 +1,19 @@
1
1
  import { type IFieldTypeFactory } from "./abstractions.js";
2
- import { IUiFieldBuilder } from "./UiFieldType.js";
2
+ import { LayoutFieldBuilder } from "./LayoutFieldBuilder.js";
3
+ type AlertType = "info" | "success" | "warning" | "danger";
4
+ export interface IUiAlertFieldBuilder extends LayoutFieldBuilder<"uiAlert"> {
5
+ alertType(type: AlertType): this;
6
+ }
3
7
  declare class UiAlertFieldTypeFactory implements IFieldTypeFactory {
4
- readonly type = "ui:alert";
5
- create(): IUiFieldBuilder;
8
+ readonly type = "uiAlert";
9
+ create(): IUiAlertFieldBuilder;
6
10
  }
7
11
  export declare const UiAlertFieldType: typeof UiAlertFieldTypeFactory & {
8
12
  __abstraction: import("@webiny/di").Abstraction<IFieldTypeFactory>;
9
13
  };
10
14
  declare module "../abstractions.js" {
11
15
  interface IFieldBuilderRegistry {
12
- uiAlert(): IUiFieldBuilder;
16
+ uiAlert(): IUiAlertFieldBuilder;
13
17
  }
14
18
  }
15
19
  export {};