@firecms/core 3.0.0-canary.66 → 3.0.0-canary.67

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 (40) hide show
  1. package/dist/core/EntityEditView.d.ts +17 -3
  2. package/dist/form/PropertiesForm.d.ts +8 -0
  3. package/dist/form/components/FieldHelperText.d.ts +3 -3
  4. package/dist/form/components/StorageItemPreview.d.ts +2 -4
  5. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  6. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -4
  7. package/dist/form/index.d.ts +0 -2
  8. package/dist/index.es.js +4269 -4322
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.umd.js +5 -5
  11. package/dist/index.umd.js.map +1 -1
  12. package/dist/types/collections.d.ts +14 -0
  13. package/dist/types/fields.d.ts +31 -30
  14. package/dist/types/plugins.d.ts +2 -2
  15. package/dist/types/properties.d.ts +1 -1
  16. package/dist/util/storage.d.ts +23 -2
  17. package/dist/util/useStorageUploadController.d.ts +1 -1
  18. package/package.json +4 -4
  19. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +2 -1
  20. package/src/core/EntityEditView.tsx +662 -120
  21. package/src/core/EntitySidePanel.tsx +0 -1
  22. package/src/form/PropertiesForm.tsx +81 -0
  23. package/src/form/PropertyFieldBinding.tsx +28 -5
  24. package/src/form/components/FieldHelperText.tsx +3 -3
  25. package/src/form/components/StorageItemPreview.tsx +0 -4
  26. package/src/form/field_bindings/MapFieldBinding.tsx +10 -3
  27. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +0 -7
  28. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +3 -26
  29. package/src/form/index.tsx +4 -4
  30. package/src/form/validation.ts +1 -17
  31. package/src/types/collections.ts +14 -0
  32. package/src/types/customization_controller.tsx +0 -1
  33. package/src/types/fields.tsx +33 -33
  34. package/src/types/plugins.tsx +2 -2
  35. package/src/types/properties.ts +1 -1
  36. package/src/util/permissions.ts +1 -0
  37. package/src/util/storage.ts +75 -21
  38. package/src/util/useStorageUploadController.tsx +21 -3
  39. package/dist/form/EntityForm.d.ts +0 -77
  40. package/src/form/EntityForm.tsx +0 -735
@@ -402,8 +402,22 @@ export interface AdditionalFieldDelegate<M extends Record<string, any> = any, Us
402
402
  * @group Models
403
403
  */
404
404
  export type EntityCustomView<M extends Record<string, any> = any> = {
405
+ /**
406
+ * Key of this custom view.
407
+ */
405
408
  key: string;
409
+ /**
410
+ * Name of this custom view.
411
+ */
406
412
  name: string;
413
+ /**
414
+ * If set to true, the actions of the entity will be included in the
415
+ * bottom of the panel (save buttons, delete buttons, etc.)
416
+ */
417
+ includeActions?: boolean;
418
+ /**
419
+ * Builder for rendering the custom view
420
+ */
407
421
  Builder?: React.ComponentType<EntityCustomViewParams<M>>;
408
422
  };
409
423
  /**
@@ -1,6 +1,6 @@
1
- import { EntityValues } from "./entities";
2
1
  import { CMSType, PropertyOrBuilder } from "./properties";
3
2
  import { ResolvedEntityCollection, ResolvedProperty } from "./resolved_entities";
3
+ import { FormexController } from "@firecms/formex";
4
4
  /**
5
5
  * When building a custom field you need to create a React component that takes
6
6
  * this interface as props.
@@ -17,9 +17,6 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
17
17
  * Current value of this field
18
18
  */
19
19
  value: T;
20
- /**
21
- * Initial value of this field
22
- */
23
20
  /**
24
21
  * Set value of field directly
25
22
  */
@@ -34,24 +31,24 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
34
31
  /**
35
32
  * Is the form currently submitting
36
33
  */
37
- isSubmitting: boolean;
34
+ isSubmitting?: boolean;
38
35
  /**
39
36
  * Should this field show the error indicator.
40
37
  * Note that there might be an error (like an empty field that should be
41
38
  * filled) but we don't want to show the error until the user has tried
42
39
  * saving.
43
40
  */
44
- showError: boolean;
41
+ showError?: boolean;
45
42
  /**
46
43
  * Is there an error in this field. The error field has the same shape as
47
44
  * the field, replacing values with a string containing the error.
48
45
  * It takes the value `null` if there is no error
49
46
  */
50
- error: any | null;
47
+ error?: any | null;
51
48
  /**
52
49
  * Has this field been touched
53
50
  */
54
- touched: boolean;
51
+ touched?: boolean;
55
52
  /**
56
53
  * Property related to this field
57
54
  */
@@ -59,32 +56,32 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
59
56
  /**
60
57
  * Should this field include a description
61
58
  */
62
- includeDescription: boolean;
59
+ includeDescription?: boolean;
63
60
  /**
64
61
  * Flag to indicate that the underlying value has been updated in the
65
62
  * datasource
66
63
  */
67
- underlyingValueHasChanged: boolean;
64
+ underlyingValueHasChanged?: boolean;
68
65
  /**
69
66
  * Is this field part of an array
70
67
  */
71
- partOfArray: boolean;
68
+ partOfArray?: boolean;
72
69
  /**
73
70
  * Is this field part of a block (oneOf array)
74
71
  */
75
- partOfBlock: boolean;
72
+ partOfBlock?: boolean;
76
73
  /**
77
74
  * Is this field being rendered in the entity table popup
78
75
  */
79
- tableMode: boolean;
76
+ tableMode?: boolean;
80
77
  /**
81
78
  * Should this field autofocus on mount
82
79
  */
83
- autoFocus: boolean;
80
+ autoFocus?: boolean;
84
81
  /**
85
82
  * Additional properties set by the developer
86
83
  */
87
- customProps: CustomProps;
84
+ customProps?: CustomProps;
88
85
  /**
89
86
  * Additional values related to the state of the form or the entity
90
87
  */
@@ -92,7 +89,7 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
92
89
  /**
93
90
  * Flag to indicate if this field should be disabled
94
91
  */
95
- disabled: boolean;
92
+ disabled?: boolean;
96
93
  }
97
94
  /**
98
95
  * Context passed to custom fields
@@ -100,13 +97,24 @@ export interface FieldProps<T extends CMSType = any, CustomProps = any, M extend
100
97
  */
101
98
  export interface FormContext<M extends Record<string, any> = any> {
102
99
  /**
103
- * Collection of the entity being modified
100
+ * Current values of the entity
104
101
  */
105
- collection: ResolvedEntityCollection<M>;
102
+ values: M;
106
103
  /**
107
- * Current values of the entity
104
+ * Update the value of a field
105
+ * @param key
106
+ * @param value
107
+ * @param shouldValidate
108
+ */
109
+ setFieldValue: (key: string, value: any, shouldValidate?: boolean) => void;
110
+ /**
111
+ * Save the entity.
112
+ */
113
+ save: (values: M) => void;
114
+ /**
115
+ * Collection of the entity being modified
108
116
  */
109
- values: EntityValues<M>;
117
+ collection?: ResolvedEntityCollection<M>;
110
118
  /**
111
119
  * Entity id, it can be null if it's a new entity
112
120
  */
@@ -114,18 +122,11 @@ export interface FormContext<M extends Record<string, any> = any> {
114
122
  /**
115
123
  * Path this entity is located at
116
124
  */
117
- path: string;
118
- /**
119
- * Update the value of a field
120
- * @param key
121
- * @param value
122
- * @param shouldValidate
123
- */
124
- setFieldValue: (key: string, value: any, shouldValidate?: boolean) => void;
125
+ path?: string;
125
126
  /**
126
- * Save the entity
127
+ * This is the underlying formex controller that powers the form
127
128
  */
128
- save: (values: EntityValues<M>) => void;
129
+ formex: FormexController<M>;
129
130
  }
130
131
  /**
131
132
  * In case you need to render a field bound to a Property inside your
@@ -161,8 +161,8 @@ export type PluginFieldBuilderParams<T extends CMSType = CMSType, M extends Reco
161
161
  property: Property<T> | ResolvedProperty<T>;
162
162
  Field: React.ComponentType<FieldProps<T, any, M>>;
163
163
  plugin: FireCMSPlugin;
164
- path: string;
165
- collection: EC;
164
+ path?: string;
165
+ collection?: EC;
166
166
  };
167
167
  export interface PluginGenericProps<UserType extends User = User> {
168
168
  context: FireCMSContext<UserType>;
@@ -652,7 +652,7 @@ export interface UploadedFileContext {
652
652
  /**
653
653
  * Entity path. E.g. `products/PID/locales`
654
654
  */
655
- path: string;
655
+ path?: string;
656
656
  /**
657
657
  * Values of the current entity
658
658
  */
@@ -1,3 +1,24 @@
1
1
  import { EntityValues, ResolvedArrayProperty, ResolvedStringProperty, StorageConfig, UploadedFileContext } from "../types";
2
- export declare function resolveFilenameString<M extends object>(input: string | ((context: UploadedFileContext) => Promise<string> | string), storage: StorageConfig, values: EntityValues<M>, entityId: string, path: string, property: ResolvedStringProperty | ResolvedArrayProperty<string[]>, file: File, propertyKey: string): Promise<string>;
3
- export declare function resolveStoragePathString<M extends object>(input: string | ((context: UploadedFileContext) => string), storage: StorageConfig, values: EntityValues<M>, entityId: string, path: string, property: ResolvedStringProperty | ResolvedArrayProperty<string[]>, file: File, propertyKey: string): string;
2
+ interface ResolveFilenameStringParams<M extends object> {
3
+ input: string | ((context: UploadedFileContext) => (Promise<string> | string));
4
+ storage: StorageConfig;
5
+ values: EntityValues<M>;
6
+ entityId: string;
7
+ path?: string;
8
+ property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
9
+ file: File;
10
+ propertyKey: string;
11
+ }
12
+ export declare function resolveFilenameString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveFilenameStringParams<M>): Promise<string>;
13
+ interface ResolveStoragePathStringParams<M extends object> {
14
+ input: string | ((context: UploadedFileContext) => string);
15
+ storage: StorageConfig;
16
+ values: EntityValues<M>;
17
+ entityId: string;
18
+ path?: string;
19
+ property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
20
+ file: File;
21
+ propertyKey: string;
22
+ }
23
+ export declare function resolveStoragePathString<M extends object>({ input, storage, values, entityId, path, property, file, propertyKey }: ResolveStoragePathStringParams<M>): string;
24
+ export {};
@@ -18,7 +18,7 @@ export declare function useStorageUploadController<M extends object>({ entityId,
18
18
  entityId: string;
19
19
  entityValues: EntityValues<M>;
20
20
  value: string | string[] | null;
21
- path: string;
21
+ path?: string;
22
22
  propertyKey: string;
23
23
  property: ResolvedStringProperty | ResolvedArrayProperty<string[]>;
24
24
  storageSource: StorageSource;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.66",
4
+ "version": "3.0.0-canary.67",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -46,8 +46,8 @@
46
46
  "./package.json": "./package.json"
47
47
  },
48
48
  "dependencies": {
49
- "@firecms/formex": "^3.0.0-canary.66",
50
- "@firecms/ui": "^3.0.0-canary.66",
49
+ "@firecms/formex": "^3.0.0-canary.67",
50
+ "@firecms/ui": "^3.0.0-canary.67",
51
51
  "@fontsource/jetbrains-mono": "^5.0.20",
52
52
  "@hello-pangea/dnd": "^16.6.0",
53
53
  "@radix-ui/react-portal": "^1.0.4",
@@ -111,7 +111,7 @@
111
111
  "dist",
112
112
  "src"
113
113
  ],
114
- "gitHead": "12ca26d459381c77e4419e13a8170fc286c96a66",
114
+ "gitHead": "1b00fdca862f86ddec3fbed0cefc1e6a95d076d6",
115
115
  "publishConfig": {
116
116
  "access": "public"
117
117
  },
@@ -264,7 +264,8 @@ export function PopupFormFieldInternal<M extends Record<string, any>>({
264
264
  values,
265
265
  path,
266
266
  setFieldValue,
267
- save: saveValue
267
+ save: saveValue,
268
+ formex
268
269
  };
269
270
 
270
271
  const property: ResolvedProperty<any> | undefined = propertyKey && getPropertyInPath(collection.properties, propertyKey as string);