@firecms/core 3.0.0-canary.94 → 3.0.0-canary.96

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.
@@ -178,4 +178,9 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
178
178
  * Should this field be disabled
179
179
  */
180
180
  disabled?: boolean;
181
+ /**
182
+ * Index of the field in the array.
183
+ * Only used when the field is part of an array.
184
+ */
185
+ index?: number;
181
186
  }
@@ -207,7 +207,7 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
207
207
  * current value of the property, as well as the path and entity ID.
208
208
  * @group Entity properties
209
209
  */
210
- export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, path, entityId }: PropertyBuilderProps<M>) => Property<T> | null;
210
+ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId }: PropertyBuilderProps<M>) => Property<T> | null;
211
211
  /**
212
212
  * @group Entity properties
213
213
  */
@@ -43,7 +43,8 @@ export declare function resolveArrayProperty<T extends any[], M>({ propertyKey,
43
43
  * @param properties
44
44
  * @param value
45
45
  */
46
- export declare function resolveProperties<M extends Record<string, any>>({ properties, ignoreMissingFields, ...props }: {
46
+ export declare function resolveProperties<M extends Record<string, any>>({ propertyKey, properties, ignoreMissingFields, ...props }: {
47
+ propertyKey?: string;
47
48
  properties: PropertiesOrBuilders<M>;
48
49
  values?: Partial<M>;
49
50
  previousValues?: Partial<M>;
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.94",
4
+ "version": "3.0.0-canary.96",
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.94",
50
- "@firecms/ui": "^3.0.0-canary.94",
49
+ "@firecms/formex": "^3.0.0-canary.96",
50
+ "@firecms/ui": "^3.0.0-canary.96",
51
51
  "@hello-pangea/dnd": "^16.6.0",
52
52
  "@radix-ui/react-portal": "^1.1.1",
53
53
  "clsx": "^2.1.1",
@@ -100,7 +100,7 @@
100
100
  "dist",
101
101
  "src"
102
102
  ],
103
- "gitHead": "b8ffd164de526795849d098ba9a0356381f43102",
103
+ "gitHead": "aae97531a2c2fb0be4a324e806af26783f6d2346",
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
@@ -746,7 +746,7 @@ export function EntityEditViewInner<M extends Record<string, any>>({
746
746
  const underlyingValueHasChanged: boolean =
747
747
  !!underlyingChanges &&
748
748
  Object.keys(underlyingChanges).includes(key) &&
749
- !!formex.touched[key];
749
+ formex.touched[key];
750
750
 
751
751
  const disabled = (!autoSave && formex.isSubmitting) || isReadOnly(property) || Boolean(property.disabled);
752
752
  const hidden = isHidden(property);
@@ -51,6 +51,9 @@ export const PropertyFieldBinding = React.memo(PropertyFieldBindingInternal, (a:
51
51
  if (a.propertyKey !== b.propertyKey) {
52
52
  return false;
53
53
  }
54
+ if (a.index !== b.index) {
55
+ return false;
56
+ }
54
57
  const aIsBuilder = isPropertyBuilder(a.property) || a.property.fromBuilder;
55
58
  const bIsBuilder = isPropertyBuilder(b.property) || b.property.fromBuilder;
56
59
 
@@ -79,6 +82,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
79
82
  partOfArray,
80
83
  partOfBlock,
81
84
  autoFocus,
85
+ index,
82
86
  }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
83
87
 
84
88
  const customizationController = useCustomizationController();
@@ -97,7 +101,8 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
97
101
  values: fieldProps.form.values,
98
102
  path: context.path,
99
103
  entityId: context.entityId,
100
- fields: customizationController.propertyConfigs
104
+ fields: customizationController.propertyConfigs,
105
+ index
101
106
  });
102
107
 
103
108
  if (resolvedProperty === null || isHidden(resolvedProperty)) {
@@ -120,11 +125,13 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
120
125
  throw new Error(`INTERNAL: Could not find field config for property ${propertyKey}`);
121
126
  }
122
127
  const configProperty = resolveProperty({
128
+ propertyKey,
123
129
  propertyOrBuilder: propertyConfig.property,
124
130
  values: fieldProps.form.values,
125
131
  path: context.path,
126
132
  entityId: context.entityId,
127
- fields: customizationController.propertyConfigs
133
+ fields: customizationController.propertyConfigs,
134
+ index
128
135
  });
129
136
  Component = configProperty.Field as ComponentType<FieldProps<T>>;
130
137
  }
@@ -63,7 +63,7 @@ export function RepeatFieldBinding<T extends Array<any>>({
63
63
  autoFocus: internalId === lastAddedId
64
64
  };
65
65
  return <ErrorBoundary>
66
- <PropertyFieldBinding {...fieldProps}/>
66
+ <PropertyFieldBinding {...fieldProps} index={index}/>
67
67
  </ErrorBoundary>;
68
68
  };
69
69
 
@@ -217,4 +217,10 @@ export interface PropertyFieldBindingProps<T extends CMSType, M extends Record<s
217
217
  * Should this field be disabled
218
218
  */
219
219
  disabled?: boolean;
220
+
221
+ /**
222
+ * Index of the field in the array.
223
+ * Only used when the field is part of an array.
224
+ */
225
+ index?: number;
220
226
  }
@@ -277,6 +277,7 @@ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, an
277
277
  values,
278
278
  previousValues,
279
279
  propertyValue,
280
+ index,
280
281
  path,
281
282
  entityId
282
283
  }: PropertyBuilderProps<M>) => Property<T> | null;
@@ -255,16 +255,17 @@ export function resolveArrayProperty<T extends any[], M>({
255
255
  } else {
256
256
  const of = property.of;
257
257
  const resolvedProperties: ResolvedProperty[] = Array.isArray(propertyValue)
258
- ? propertyValue.map((v: any, index: number) => resolveProperty({
259
- propertyKey: `${propertyKey}.${index}`,
260
- propertyOrBuilder: of,
261
- ignoreMissingFields,
262
- ...props,
263
- index
264
- })).filter(e => Boolean(e)) as ResolvedProperty[]
258
+ ? propertyValue.map((v: any, index: number) => {
259
+ return resolveProperty({
260
+ propertyKey: `${propertyKey}.${index}`,
261
+ propertyOrBuilder: of,
262
+ ignoreMissingFields,
263
+ ...props,
264
+ index
265
+ });
266
+ }).filter(e => Boolean(e)) as ResolvedProperty[]
265
267
  : [];
266
268
  const ofProperty = resolveProperty({
267
- propertyKey: `${propertyKey}`,
268
269
  propertyOrBuilder: of,
269
270
  ignoreMissingFields,
270
271
  ...props
@@ -295,6 +296,7 @@ export function resolveArrayProperty<T extends any[], M>({
295
296
  }).filter(e => Boolean(e)) as ResolvedProperty[]
296
297
  : [];
297
298
  const properties = resolveProperties<any>({
299
+ propertyKey,
298
300
  properties: property.oneOf.properties,
299
301
  ignoreMissingFields,
300
302
  ...props
@@ -327,10 +329,12 @@ export function resolveArrayProperty<T extends any[], M>({
327
329
  * @param value
328
330
  */
329
331
  export function resolveProperties<M extends Record<string, any>>({
332
+ propertyKey,
330
333
  properties,
331
334
  ignoreMissingFields,
332
335
  ...props
333
336
  }: {
337
+ propertyKey?: string,
334
338
  properties: PropertiesOrBuilders<M>,
335
339
  values?: Partial<M>,
336
340
  previousValues?: Partial<M>,
@@ -344,7 +348,7 @@ export function resolveProperties<M extends Record<string, any>>({
344
348
  return Object.entries<PropertyOrBuilder>(properties as Record<string, PropertyOrBuilder>)
345
349
  .map(([key, property]) => {
346
350
  const childResolvedProperty = resolveProperty({
347
- propertyKey: key,
351
+ propertyKey: propertyKey ? `${propertyKey}.${key}` : undefined,
348
352
  propertyOrBuilder: property,
349
353
  ignoreMissingFields,
350
354
  ...props