@webiny/app-headless-cms-common 6.4.5 → 6.6.0-alpha.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.
Files changed (103) hide show
  1. package/index.d.ts +1 -10
  2. package/index.js +1 -10
  3. package/package.json +10 -17
  4. package/types/index.d.ts +5 -338
  5. package/types/index.js +1 -1
  6. package/types/model.d.ts +9 -18
  7. package/types/model.js +1 -2
  8. package/types/model.js.map +1 -1
  9. package/types/shared.d.ts +6 -0
  10. package/Fields/ErrorBoundary.d.ts +0 -24
  11. package/Fields/ErrorBoundary.js +0 -35
  12. package/Fields/ErrorBoundary.js.map +0 -1
  13. package/Fields/FieldElement.d.ts +0 -64
  14. package/Fields/FieldElement.js +0 -54
  15. package/Fields/FieldElement.js.map +0 -1
  16. package/Fields/FieldElementError.d.ts +0 -7
  17. package/Fields/FieldElementError.js +0 -16
  18. package/Fields/FieldElementError.js.map +0 -1
  19. package/Fields/FieldRulesProvider.d.ts +0 -9
  20. package/Fields/FieldRulesProvider.js +0 -14
  21. package/Fields/FieldRulesProvider.js.map +0 -1
  22. package/Fields/Fields.d.ts +0 -11
  23. package/Fields/Fields.js +0 -93
  24. package/Fields/Fields.js.map +0 -1
  25. package/Fields/Label.d.ts +0 -6
  26. package/Fields/Label.js +0 -10
  27. package/Fields/Label.js.map +0 -1
  28. package/Fields/LayoutDescriptorCell.d.ts +0 -12
  29. package/Fields/LayoutDescriptorCell.js +0 -40
  30. package/Fields/LayoutDescriptorCell.js.map +0 -1
  31. package/Fields/evaluateExpression.d.ts +0 -23
  32. package/Fields/evaluateExpression.js +0 -66
  33. package/Fields/evaluateExpression.js.map +0 -1
  34. package/Fields/fieldOptions.d.ts +0 -36
  35. package/Fields/fieldOptions.js +0 -65
  36. package/Fields/fieldOptions.js.map +0 -1
  37. package/Fields/index.d.ts +0 -8
  38. package/Fields/index.js +0 -8
  39. package/Fields/layoutFieldRenderers/AlertFieldRenderer.d.ts +0 -7
  40. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js +0 -10
  41. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js.map +0 -1
  42. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.d.ts +0 -7
  43. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js +0 -15
  44. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js.map +0 -1
  45. package/Fields/layoutFieldRenderers/TabsFieldRenderer.d.ts +0 -12
  46. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js +0 -61
  47. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js.map +0 -1
  48. package/Fields/operatorOptions.d.ts +0 -10
  49. package/Fields/operatorOptions.js +0 -120
  50. package/Fields/operatorOptions.js.map +0 -1
  51. package/Fields/useBind.d.ts +0 -10
  52. package/Fields/useBind.js +0 -111
  53. package/Fields/useBind.js.map +0 -1
  54. package/Fields/useFieldRules.d.ts +0 -32
  55. package/Fields/useFieldRules.js +0 -99
  56. package/Fields/useFieldRules.js.map +0 -1
  57. package/Fields/useRenderPlugins.d.ts +0 -2
  58. package/Fields/useRenderPlugins.js +0 -8
  59. package/Fields/useRenderPlugins.js.map +0 -1
  60. package/ModelFieldProvider/CanEditField.d.ts +0 -5
  61. package/ModelFieldProvider/CanEditField.js +0 -10
  62. package/ModelFieldProvider/CanEditField.js.map +0 -1
  63. package/ModelFieldProvider/ModelFieldContext.d.ts +0 -39
  64. package/ModelFieldProvider/ModelFieldContext.js +0 -19
  65. package/ModelFieldProvider/ModelFieldContext.js.map +0 -1
  66. package/ModelFieldProvider/index.d.ts +0 -3
  67. package/ModelFieldProvider/index.js +0 -3
  68. package/ModelFieldProvider/useModelField.d.ts +0 -15
  69. package/ModelFieldProvider/useModelField.js +0 -23
  70. package/ModelFieldProvider/useModelField.js.map +0 -1
  71. package/ModelProvider/ModelContext.d.ts +0 -9
  72. package/ModelProvider/ModelContext.js +0 -14
  73. package/ModelProvider/ModelContext.js.map +0 -1
  74. package/ModelProvider/index.d.ts +0 -2
  75. package/ModelProvider/index.js +0 -2
  76. package/ModelProvider/useModel.d.ts +0 -9
  77. package/ModelProvider/useModel.js +0 -12
  78. package/ModelProvider/useModel.js.map +0 -1
  79. package/createFieldsList.d.ts +0 -12
  80. package/createFieldsList.js +0 -31
  81. package/createFieldsList.js.map +0 -1
  82. package/createValidationContainer.d.ts +0 -18
  83. package/createValidationContainer.js +0 -16
  84. package/createValidationContainer.js.map +0 -1
  85. package/createValidators.d.ts +0 -3
  86. package/createValidators.js +0 -47
  87. package/createValidators.js.map +0 -1
  88. package/entries.graphql.d.ts +0 -229
  89. package/entries.graphql.js +0 -335
  90. package/entries.graphql.js.map +0 -1
  91. package/exports/admin/cms/model.d.ts +0 -1
  92. package/exports/admin/cms/model.js +0 -1
  93. package/getModelTitleFieldId.d.ts +0 -2
  94. package/getModelTitleFieldId.js +0 -7
  95. package/getModelTitleFieldId.js.map +0 -1
  96. package/normalizeIcon.d.ts +0 -3
  97. package/normalizeIcon.js +0 -11
  98. package/normalizeIcon.js.map +0 -1
  99. package/prepareFormData.d.ts +0 -2
  100. package/prepareFormData.js +0 -49
  101. package/prepareFormData.js.map +0 -1
  102. package/types/validation.d.ts +0 -79
  103. package/types/validation.js +0 -0
package/index.d.ts CHANGED
@@ -1,10 +1 @@
1
- export * from "./Fields/index.js";
2
- export * from "./ModelFieldProvider/index.js";
3
- export * from "./ModelProvider/index.js";
4
- export * from "./entries.graphql.js";
5
- export * from "./getModelTitleFieldId.js";
6
- export * from "./createFieldsList.js";
7
- export * from "./createValidationContainer.js";
8
- export * from "./createValidators.js";
9
- export * from "./prepareFormData.js";
10
- export * from "./constants.js";
1
+ export { CMS_MODEL_SINGLETON_TAG } from "./constants.js";
package/index.js CHANGED
@@ -1,10 +1 @@
1
- export * from "./Fields/index.js";
2
- export * from "./ModelFieldProvider/index.js";
3
- export * from "./ModelProvider/index.js";
4
- export * from "./entries.graphql.js";
5
- export * from "./getModelTitleFieldId.js";
6
- export * from "./createFieldsList.js";
7
- export * from "./createValidationContainer.js";
8
- export * from "./createValidators.js";
9
- export * from "./prepareFormData.js";
10
- export * from "./constants.js";
1
+ export { CMS_MODEL_SINGLETON_TAG } from "./constants.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms-common",
3
- "version": "6.4.5",
3
+ "version": "6.6.0-alpha.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,28 +17,21 @@
17
17
  ],
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@emotion/react": "11.14.0",
21
- "@emotion/styled": "11.14.1",
22
- "@fortawesome/fontawesome-svg-core": "7.3.0",
23
- "@fortawesome/react-fontawesome": "3.4.0",
24
- "@webiny/admin-ui": "6.4.5",
25
- "@webiny/app": "6.4.5",
26
- "@webiny/app-admin": "6.4.5",
27
- "@webiny/form": "6.4.5",
28
- "@webiny/plugins": "6.4.5",
29
- "@webiny/react-composition": "6.4.5",
30
- "@webiny/validation": "6.4.5",
20
+ "@fortawesome/fontawesome-svg-core": "7.3.1",
21
+ "@webiny/admin-ui": "6.6.0-alpha.0",
22
+ "@webiny/app": "6.6.0-alpha.0",
23
+ "@webiny/app-admin": "6.6.0-alpha.0",
24
+ "@webiny/form": "6.6.0-alpha.0",
25
+ "@webiny/plugins": "6.6.0-alpha.0",
26
+ "@webiny/validation": "6.6.0-alpha.0",
31
27
  "dnd-core": "16.0.1",
32
- "graphql": "16.14.2",
33
- "graphql-tag": "2.12.7",
34
- "lodash": "4.18.1",
35
28
  "react": "18.3.1"
36
29
  },
37
30
  "devDependencies": {
38
31
  "@types/react": "18.3.31",
39
- "@webiny/build-tools": "6.4.5",
32
+ "@webiny/build-tools": "6.6.0-alpha.0",
40
33
  "rimraf": "6.1.3",
41
- "typescript": "6.0.3"
34
+ "typescript": "7.0.2"
42
35
  },
43
36
  "publishConfig": {
44
37
  "access": "public"
package/types/index.d.ts CHANGED
@@ -3,25 +3,19 @@ import type { ReactElement, ReactNode } from "react";
3
3
  import type { Plugin } from "@webiny/plugins/types.js";
4
4
  import type { BindComponent as BaseBindComponent, BindComponentProps as BaseBindComponentProps, BindComponentRenderProp as BaseBindComponentRenderProp, FormAPI } from "@webiny/form";
5
5
  import type { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
6
- import type { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation.js";
7
- import type { CmsModelLayoutField, CmsEditorFieldsLayout, CmsLayoutField, CmsModel, CmsModelField } from "./model.js";
6
+ import type { CmsEditorFieldsLayout, CmsLayoutField, CmsModel, CmsModelField } from "./model.js";
8
7
  import type { CmsIdentity } from "../types/shared.js";
9
8
  import type { SourceType } from "dnd-core";
10
9
  import type { IconPickerIconDto } from "@webiny/admin-ui";
11
- import { GenericRecord } from "@webiny/app/types.js";
12
- import { Identity } from "@webiny/app-admin/domain/Identity.js";
10
+ import type { GenericRecord } from "@webiny/app/types.js";
11
+ import type { Identity } from "@webiny/app-admin/domain/Identity.js";
12
+ import type { CmsModelFieldValidator } from "./model.js";
13
13
  export type DragObjectWithType = {
14
14
  type: SourceType;
15
15
  };
16
- export type * from "./validation.js";
17
16
  export type * from "./model.js";
18
- export { isLayoutField, isLayoutDescriptor } from "./model.js";
17
+ export { isLayoutField } from "./model.js";
19
18
  export type * from "./shared.js";
20
- interface QueryFieldParams {
21
- model: CmsModel;
22
- field: CmsModelField;
23
- graphQLTypePrefix: string;
24
- }
25
19
  interface Position {
26
20
  row: number;
27
21
  index: number;
@@ -39,319 +33,6 @@ export interface DragSource extends DragObjectWithType {
39
33
  fields?: CmsModelField[];
40
34
  layoutField?: CmsLayoutField;
41
35
  }
42
- export interface CmsModelFieldTypePlugin extends Plugin {
43
- /**
44
- * a plugin type
45
- */
46
- type: "cms-editor-field-type";
47
- field: {
48
- /**
49
- * A unique identifier of the field type (text, number, json, myField, ...).
50
- *
51
- * ```ts
52
- * type: "myField"
53
- * ```
54
- */
55
- type: string;
56
- /**
57
- * A display name for the field.
58
- *
59
- * ```ts
60
- * label: "Field name"
61
- * ```
62
- */
63
- label: string;
64
- /**
65
- * A list of available validators for the model field.
66
- *
67
- * ```ts
68
- * validators: [
69
- * "required",
70
- * "gte",
71
- * "lte"
72
- * ]
73
- * ```
74
- */
75
- validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;
76
- /**
77
- * A list of available validators when a model field accepts a list (array) of values.
78
- *
79
- * ```ts
80
- * listValidators: [
81
- * "minLength",
82
- * "maxLength"
83
- * ]
84
- * ```
85
- */
86
- listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;
87
- /**
88
- * An explanation of the field displayed beneath the label.
89
- *
90
- * ```ts
91
- * description: "A short description of the field"
92
- * ```
93
- */
94
- description: string;
95
- /**
96
- * A ReactNode to display the icon for the field.
97
- *
98
- * ```tsx
99
- * icon: <MyIconComponent />
100
- * ```
101
- */
102
- icon: React.ReactNode;
103
- /**
104
- * Is it allowed to have multiple values in this field?
105
- *
106
- * ```ts
107
- * allowList: true
108
- * ```
109
- */
110
- allowList?: boolean;
111
- /**
112
- * Does this field type have a fixed list of values that can be selected?
113
- *
114
- * ```ts
115
- * allowPredefinedValues: false
116
- * ```
117
- */
118
- allowPredefinedValues?: boolean;
119
- /**
120
- * A ReactNode label when multiple values are enabled.
121
- */
122
- listLabel?: React.ReactNode;
123
- /**
124
- * Determines if this field type should be hidden from the admin UI.
125
- * If set to `true`, the field type will not be visible or selectable in the admin interface.
126
- */
127
- hideInAdmin?: boolean;
128
- /**
129
- * These are default values when the field is first created. This is a representation of the field that is stored in the database.
130
- *
131
- * ```ts
132
- * createField: () => ({
133
- * type: "fieldType",
134
- * validation: [],
135
- * renderer: {
136
- * name: "fieldTypeRenderer"
137
- * }
138
- * })
139
- * ```
140
- */
141
- createField: () => Pick<CmsModelField, "type" | "validation" | "renderer" | "settings">;
142
- /**
143
- * If `true` (default), this field will be configurable via a settings dialog.
144
- * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.
145
- */
146
- canEditSettings?: boolean;
147
- /**
148
- * Determine if a `draggable` can be dropped into this field.
149
- * NOTE: This is only applicable to nested field types.
150
- */
151
- canAccept?(field: CmsModelField, draggable: DragSource): boolean;
152
- /**
153
- * If `true` (default), will allow fields to be laid out into columns (next to each other).
154
- * If `false`, horizontal layout will not be allowed.
155
- * NOTE: This is only applicable to nested field types.
156
- */
157
- allowLayout?: boolean;
158
- /**
159
- * A ReactNode that you can add in the section below the help text when creating/editing field.
160
- *
161
- * ```tsx
162
- * renderSettings: (params) => {
163
- * return <FieldSettingsComponent />;
164
- * }
165
- * ```
166
- */
167
- renderSettings?: (params: {
168
- afterChangeLabel: (value: string) => void;
169
- uniqueFieldIdValidator: (fieldId: string) => void;
170
- contentModel: CmsModel;
171
- }) => React.ReactNode;
172
- /**
173
- * A ReactNode that renders in the Predefined values tab.
174
- *
175
- * ```tsx
176
- * renderPredefinedValues: (params) => {
177
- * const {form: {Bind}} = params;
178
- * return (
179
- * <Bind name="fieldProperty">
180
- * <InputComponent />
181
- * </Bind>
182
- * );
183
- * }
184
- * ```
185
- */
186
- renderPredefinedValues?: (params: {
187
- getBind: (index?: number) => any;
188
- }) => React.ReactElement;
189
- /**
190
- * Object wrapper for GraphQL stuff
191
- */
192
- graphql?: {
193
- /**
194
- * Define field selection.
195
- *
196
- * ```ts
197
- * graphql: {
198
- * queryField: `
199
- * {
200
- * id
201
- * title
202
- * createdOn
203
- * }
204
- * `,
205
- * }
206
- * ```
207
- */
208
- queryField?: string | ((params: QueryFieldParams) => string | null);
209
- };
210
- render?(params: any): React.ReactElement;
211
- tags?: string[];
212
- /**
213
- * Render additional information in the Admin UI Model edit view
214
- */
215
- renderInfo?: (params: {
216
- field: CmsModelField;
217
- model: CmsModel;
218
- }) => React.ReactElement;
219
- };
220
- }
221
- export interface CmsModelLayoutFieldTypePlugin<T extends CmsModelLayoutField = CmsModelLayoutField> extends Plugin {
222
- type: "cms-editor-layout-field-type";
223
- field: {
224
- type: T["type"];
225
- label: string;
226
- description: string;
227
- icon: React.ReactElement;
228
- createField(): Omit<T, "id">;
229
- canEditSettings?: boolean;
230
- renderSettings?(): React.ReactNode;
231
- /**
232
- * Collect all model fields embedded inside a layout field's nested layout.
233
- * Used during drag-and-drop to move embedded fields along with the layout field
234
- * across parent boundaries. Return `[]` or omit for layout fields with no nested fields.
235
- */
236
- collectFields?(params: {
237
- field: T;
238
- getField: (id: string) => CmsModelField | undefined;
239
- }): CmsModelField[];
240
- /**
241
- * Return a label prefix for each field ID nested inside this layout field.
242
- * Used by `buildFieldOptions` to include layout hierarchy in field labels.
243
- *
244
- * For example, a tabs layout field with label "My Tabs" containing a tab "SEO"
245
- * with field "metaTitle" would return: `{ "metaTitle": "My Tabs › SEO" }`.
246
- *
247
- * Omit or return `{}` for layout fields that don't group fields.
248
- */
249
- getFieldLabelPrefixes?(params: {
250
- field: T;
251
- }): Record<string, string>;
252
- /**
253
- * Controls how this layout field looks on the model editor canvas.
254
- * Each plugin fully owns its visual representation.
255
- */
256
- render(params: {
257
- field: T;
258
- onUpdate: (d: T) => void;
259
- onDelete: () => void;
260
- }): React.ReactElement;
261
- };
262
- }
263
- export interface CmsModelLayoutFieldRendererPlugin<T extends CmsModelLayoutField = CmsModelLayoutField> extends Plugin {
264
- type: "cms-layout-field-renderer";
265
- fieldType: string;
266
- render(props: {
267
- field: T;
268
- Bind: BindComponent;
269
- fields: CmsModelField[];
270
- contentModel: CmsModel;
271
- gridClassName?: string;
272
- }): React.ReactElement | null;
273
- }
274
- export interface CmsModelFieldRendererSettingsProps {
275
- field: CmsModelField;
276
- }
277
- export interface CmsModelFieldRendererProps {
278
- field: CmsModelField;
279
- Label: React.ComponentType<React.PropsWithChildren>;
280
- getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;
281
- contentModel: CmsModel;
282
- }
283
- export interface CmsModelFieldRendererPlugin extends Plugin {
284
- /**
285
- * a plugin type
286
- */
287
- type: "cms-editor-field-renderer";
288
- renderer: {
289
- /**
290
- * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.
291
- *
292
- * ```ts
293
- * renderName: "myFieldTypeRenderer"
294
- * ```
295
- */
296
- rendererName: string;
297
- /**
298
- * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.
299
- *
300
- * ```tsx
301
- * name: <MyFieldNameComponent />
302
- * ```
303
- */
304
- name: React.ReactNode;
305
- /**
306
- * A description for the field in the UI. Works exactly like the `name` property.
307
- *
308
- * ```tsx
309
- * name: <MyFieldDescriptionComponent />
310
- * ```
311
- */
312
- description: React.ReactNode;
313
- /**
314
- * A method that determines if the field can be rendered by this plugin.
315
- *
316
- * ```ts
317
- * canUse({ field }) {
318
- * return (
319
- * field.type === "myType" && !field.list
320
- * );
321
- * }
322
- * ```
323
- */
324
- canUse(props: {
325
- field: CmsModelField;
326
- fieldPlugin: CmsModelFieldTypePlugin;
327
- model: CmsModel;
328
- }): boolean;
329
- /**
330
- * Renders a field in the UI.
331
- *
332
- * ```tsx
333
- * render({ field, getBind }) {
334
- * const Bind = getBind();
335
- *
336
- * return (
337
- * <Bind>
338
- * {bind => {
339
- * return (
340
- * <Input
341
- * value={bind.value}
342
- * onChange={bind.onChange}
343
- * />
344
- * )
345
- * }}
346
- * </Bind>
347
- * );
348
- * }
349
- * ```
350
- */
351
- render(props: CmsModelFieldRendererProps): React.ReactNode;
352
- renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;
353
- };
354
- }
355
36
  export interface CmsEditorFieldPredefinedValuesEntry {
356
37
  label: string;
357
38
  value: string;
@@ -372,14 +53,7 @@ export interface CmsDynamicZoneTemplate {
372
53
  validation: CmsModelFieldValidator[];
373
54
  tags?: string[];
374
55
  }
375
- export interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {
376
- __typename: string;
377
- }
378
56
  export type CmsContentEntryStatusType = "draft" | "published" | "unpublished";
379
- /**
380
- * @deprecated Use `CmsContentEntry`.
381
- */
382
- export type CmsEditorContentEntry = CmsContentEntry;
383
57
  export interface CmsContentEntryLive {
384
58
  version: number;
385
59
  }
@@ -457,9 +131,6 @@ export interface CmsContentEntryRevision {
457
131
  version: number;
458
132
  };
459
133
  }
460
- export type CmsEditorContentTab = React.ComponentType<{
461
- activeTab: boolean;
462
- }>;
463
134
  export interface CmsEditorFieldOptionPlugin extends Plugin {
464
135
  type: "cms-editor-field-option";
465
136
  render(): ReactElement;
@@ -467,10 +138,6 @@ export interface CmsEditorFieldOptionPlugin extends Plugin {
467
138
  export interface CmsContentDetailsPlugin extends Plugin {
468
139
  render: (params: any) => ReactNode;
469
140
  }
470
- export interface FieldLayoutPosition {
471
- row: number;
472
- index: number | null;
473
- }
474
141
  export interface CmsEditorFormSettingsPlugin<T = GenericRecord> extends Plugin {
475
142
  type: "cms-editor-form-settings";
476
143
  title: string;
package/types/index.js CHANGED
@@ -1 +1 @@
1
- export { isLayoutDescriptor, isLayoutField } from "./model.js";
1
+ export { isLayoutField } from "./model.js";
package/types/model.d.ts CHANGED
@@ -1,8 +1,12 @@
1
+ import type React from "react";
1
2
  import type { Validator } from "@webiny/validation/types.js";
2
- import type { CmsModelFieldValidator } from "../types/validation.js";
3
- import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "../types/index.js";
3
+ import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues } from "../types/index.js";
4
4
  import type { CmsIdentity } from "../types/shared.js";
5
- import type React from "react";
5
+ export interface CmsModelFieldValidator {
6
+ name: string;
7
+ message?: string;
8
+ settings?: any;
9
+ }
6
10
  export interface CmsModelFieldSettings<T = unknown> {
7
11
  defaultValue?: string | boolean | number | null | undefined;
8
12
  defaultSetValue?: string;
@@ -40,12 +44,7 @@ export type CmsModelField<T = unknown> = T & {
40
44
  renderer: {
41
45
  name: string;
42
46
  settings?: Record<string, any>;
43
- }
44
- /**
45
- * Use this only for programmatic assignment of renderers.
46
- * Since functions cannot be serialized, this can only work via code.
47
- */
48
- | CmsModelFieldRendererPlugin["renderer"]["render"];
47
+ };
49
48
  tags?: string[];
50
49
  rules?: FieldRule[];
51
50
  };
@@ -93,15 +92,6 @@ export type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];
93
92
  * has `fieldId`, so we use its absence as the discriminator.
94
93
  */
95
94
  export declare function isLayoutField(cell: unknown): cell is CmsLayoutField;
96
- /**
97
- * @deprecated Use `isLayoutField` instead.
98
- */
99
- export declare const isLayoutDescriptor: typeof isLayoutField;
100
- /**
101
- * @category GraphQL
102
- * @category Model
103
- */
104
- export type CmsEditorContentModel = CmsModel;
105
95
  /**
106
96
  * @category GraphQL
107
97
  * @category Group
@@ -147,6 +137,7 @@ export interface CmsModel {
147
137
  * Is model currently being deleted?
148
138
  */
149
139
  isBeingDeleted?: boolean;
140
+ valuesSelection?: string;
150
141
  settings: {
151
142
  [key: string]: any;
152
143
  };
package/types/model.js CHANGED
@@ -1,7 +1,6 @@
1
1
  function isLayoutField(cell) {
2
2
  return "object" == typeof cell && null !== cell && "type" in cell && "string" == typeof cell.type && !("fieldId" in cell);
3
3
  }
4
- const isLayoutDescriptor = isLayoutField;
5
- export { isLayoutDescriptor, isLayoutField };
4
+ export { isLayoutField };
6
5
 
7
6
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types/model.js","sources":["../../src/types/model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsModelFieldValidator } from \"~/types/validation.js\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type React from \"react\";\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: CmsEditorFieldsLayout;\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"condition\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n rules?: FieldRule[];\n};\n\nexport type CmsEditorFieldId = string;\n\nexport interface CmsModelLayoutField {\n id: string;\n type: string;\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutField extends CmsModelLayoutField {\n type: \"separator\";\n label: string;\n description?: string;\n}\n\nexport interface CmsAlertLayoutField extends CmsModelLayoutField {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n}\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: string;\n layout: CmsEditorFieldsLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutField extends CmsModelLayoutField {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n}\n\nexport type CmsLayoutField =\n | CmsSeparatorLayoutField\n | CmsAlertLayoutField\n | CmsTabLayoutField\n | CmsModelLayoutField;\n\nexport type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;\nexport type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];\n\n/**\n * Distinguish layout fields from field IDs (strings) and CmsModelField objects.\n *\n * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)\n * or layout field objects — the `typeof` check handles that.\n *\n * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`\n * or layout field objects — both have `{ id, type }`, but only `CmsModelField`\n * has `fieldId`, so we use its absence as the discriminator.\n */\nexport function isLayoutField(cell: unknown): cell is CmsLayoutField {\n return (\n typeof cell === \"object\" &&\n cell !== null &&\n \"type\" in cell &&\n typeof (cell as any).type === \"string\" &&\n !(\"fieldId\" in cell)\n );\n}\n\n/**\n * @deprecated Use `isLayoutField` instead.\n */\nexport const isLayoutDescriptor = isLayoutField;\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n settings: {\n [key: string]: any;\n };\n}\n"],"names":["isLayoutField","cell","isLayoutDescriptor"],"mappings":"AAoHO,SAASA,cAAcC,IAAa;IACvC,OACI,AAAgB,YAAhB,OAAOA,QACPA,AAAS,SAATA,QACA,UAAUA,QACV,AAA8B,YAA9B,OAAQA,KAAa,IAAI,IACzB,CAAE,cAAaA,IAAG;AAE1B;AAKO,MAAMC,qBAAqBF"}
1
+ {"version":3,"file":"types/model.js","sources":["../../src/types/model.ts"],"sourcesContent":["import type React from \"react\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues } from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: CmsEditorFieldsLayout;\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"condition\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer: {\n name: string;\n settings?: Record<string, any>;\n };\n tags?: string[];\n rules?: FieldRule[];\n};\n\nexport type CmsEditorFieldId = string;\n\nexport interface CmsModelLayoutField {\n id: string;\n type: string;\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutField extends CmsModelLayoutField {\n type: \"separator\";\n label: string;\n description?: string;\n}\n\nexport interface CmsAlertLayoutField extends CmsModelLayoutField {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n}\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: string;\n layout: CmsEditorFieldsLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutField extends CmsModelLayoutField {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n}\n\nexport type CmsLayoutField =\n | CmsSeparatorLayoutField\n | CmsAlertLayoutField\n | CmsTabLayoutField\n | CmsModelLayoutField;\n\nexport type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;\nexport type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];\n\n/**\n * Distinguish layout fields from field IDs (strings) and CmsModelField objects.\n *\n * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)\n * or layout field objects — the `typeof` check handles that.\n *\n * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`\n * or layout field objects — both have `{ id, type }`, but only `CmsModelField`\n * has `fieldId`, so we use its absence as the discriminator.\n */\nexport function isLayoutField(cell: unknown): cell is CmsLayoutField {\n return (\n typeof cell === \"object\" &&\n cell !== null &&\n \"type\" in cell &&\n typeof (cell as any).type === \"string\" &&\n !(\"fieldId\" in cell)\n );\n}\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n valuesSelection?: string;\n settings: {\n [key: string]: any;\n };\n}\n"],"names":["isLayoutField","cell"],"mappings":"AA+GO,SAASA,cAAcC,IAAa;IACvC,OACI,AAAgB,YAAhB,OAAOA,QACPA,AAAS,SAATA,QACA,UAAUA,QACV,AAA8B,YAA9B,OAAQA,KAAa,IAAI,IACzB,CAAE,cAAaA,IAAG;AAE1B"}
package/types/shared.d.ts CHANGED
@@ -1,5 +1,11 @@
1
+ import type { IconPickerIconDto } from "@webiny/admin-ui";
2
+ import type { Plugin } from "@webiny/plugins/types.js";
1
3
  export interface CmsIdentity {
2
4
  id: string;
3
5
  displayName: string;
4
6
  type: string;
5
7
  }
8
+ export interface CmsIconsPlugin extends Plugin {
9
+ type: "cms-icons";
10
+ getIcons(): IconPickerIconDto[];
11
+ }
@@ -1,24 +0,0 @@
1
- import type { ErrorInfo } from "react";
2
- import React from "react";
3
- import type { CmsModelField } from "../types/index.js";
4
- type State = {
5
- hasError: true;
6
- error: Error;
7
- } | {
8
- hasError: false;
9
- error: undefined;
10
- };
11
- interface Props {
12
- field: CmsModelField;
13
- [key: string]: any;
14
- }
15
- export declare class ErrorBoundary extends React.Component<Props, State> {
16
- constructor(props: Props);
17
- static getDerivedStateFromError(error: Error): {
18
- hasError: boolean;
19
- error: Error;
20
- };
21
- componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
22
- render(): any;
23
- }
24
- export {};
@@ -1,35 +0,0 @@
1
- import react from "react";
2
- import { FieldElementError } from "./FieldElementError.js";
3
- class ErrorBoundary extends react.Component {
4
- constructor(props){
5
- super(props);
6
- this.state = {
7
- hasError: false,
8
- error: void 0
9
- };
10
- }
11
- static getDerivedStateFromError(error) {
12
- return {
13
- hasError: true,
14
- error
15
- };
16
- }
17
- componentDidCatch(error, errorInfo) {
18
- const { field } = this.props;
19
- if (!field) return;
20
- console.groupCollapsed(`%cFIELD ERROR%c: An error occurred while rendering model field "${field.fieldId}" (${field.id}) of type "${field.type}".`, "color:red", "color:default");
21
- console.log("Field definition", field);
22
- console.error(error, errorInfo);
23
- console.groupEnd();
24
- }
25
- render() {
26
- if (this.state.hasError) return /*#__PURE__*/ react.createElement(FieldElementError, {
27
- title: `Error: ${this.state.error.message}`,
28
- description: "See developer console for more details."
29
- });
30
- return this.props.children;
31
- }
32
- }
33
- export { ErrorBoundary };
34
-
35
- //# sourceMappingURL=ErrorBoundary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Fields/ErrorBoundary.js","sources":["../../src/Fields/ErrorBoundary.tsx"],"sourcesContent":["import type { ErrorInfo } from \"react\";\nimport React from \"react\";\nimport type { CmsModelField } from \"~/types/index.js\";\nimport { FieldElementError } from \"./FieldElementError.js\";\n\ntype State =\n | {\n hasError: true;\n error: Error;\n }\n | { hasError: false; error: undefined };\n\ninterface Props {\n field: CmsModelField;\n [key: string]: any;\n}\n\nexport class ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n error: undefined\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n return {\n hasError: true,\n error\n };\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { field } = this.props;\n if (!field) {\n return;\n }\n console.groupCollapsed(\n `%cFIELD ERROR%c: An error occurred while rendering model field \"${field.fieldId}\" (${field.id}) of type \"${field.type}\".`,\n \"color:red\",\n \"color:default\"\n );\n console.log(\"Field definition\", field);\n console.error(error, errorInfo);\n console.groupEnd();\n }\n\n public override render() {\n if (this.state.hasError) {\n return (\n <FieldElementError\n title={`Error: ${this.state.error.message}`}\n description={\"See developer console for more details.\"}\n />\n );\n }\n\n return this.props.children;\n }\n}\n"],"names":["ErrorBoundary","React","props","undefined","error","errorInfo","field","console","FieldElementError"],"mappings":";;AAiBO,MAAMA,sBAAsBC,MAAAA,SAAe;IAC9C,YAAYC,KAAY,CAAE;QACtB,KAAK,CAACA;QACN,IAAI,CAAC,KAAK,GAAG;YACT,UAAU;YACV,OAAOC;QACX;IACJ;IAEA,OAAO,yBAAyBC,KAAY,EAAE;QAC1C,OAAO;YACH,UAAU;YACVA;QACJ;IACJ;IAEgB,kBAAkBA,KAAY,EAAEC,SAAoB,EAAE;QAClE,MAAM,EAAEC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK;QAC5B,IAAI,CAACA,OACD;QAEJC,QAAQ,cAAc,CAClB,CAAC,gEAAgE,EAAED,MAAM,OAAO,CAAC,GAAG,EAAEA,MAAM,EAAE,CAAC,WAAW,EAAEA,MAAM,IAAI,CAAC,EAAE,CAAC,EAC1H,aACA;QAEJC,QAAQ,GAAG,CAAC,oBAAoBD;QAChCC,QAAQ,KAAK,CAACH,OAAOC;QACrBE,QAAQ,QAAQ;IACpB;IAEgB,SAAS;QACrB,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EACnB,OAAO,WAAP,GACI,oBAACC,mBAAiBA;YACd,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YAC3C,aAAa;;QAKzB,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ;IAC9B;AACJ"}