@firecms/core 3.0.0-canary.119 → 3.0.0-canary.120

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.
@@ -1,4 +1,4 @@
1
- import { CMSType, ResolvedProperty } from "../types";
1
+ import { CMSType, Property, ResolvedProperty } from "../types";
2
2
  /**
3
3
  * Hook we use to restore a value after it has been cleared
4
4
  * @param property
@@ -7,7 +7,7 @@ import { CMSType, ResolvedProperty } from "../types";
7
7
  * @ignore
8
8
  */
9
9
  export declare function useClearRestoreValue<T extends CMSType>({ property, value, setValue }: {
10
- property: ResolvedProperty<T>;
10
+ property: Property<T> | ResolvedProperty<T>;
11
11
  value: T;
12
12
  setValue: (value: T | null, shouldValidate?: boolean) => void;
13
13
  }): void;
package/dist/index.es.js CHANGED
@@ -6603,6 +6603,10 @@ function useStorageUploadController({
6603
6603
  setInternalValue(internalInitialValue);
6604
6604
  }
6605
6605
  }, [internalInitialValue, value, initialValue]);
6606
+ const resolvedProperty = resolveProperty({
6607
+ propertyOrBuilder: property,
6608
+ values: entityValues
6609
+ });
6606
6610
  const fileNameBuilder = useCallback(async (file) => {
6607
6611
  if (storage.fileName) {
6608
6612
  const fileName = await resolveStorageFilenameString({
@@ -6611,7 +6615,7 @@ function useStorageUploadController({
6611
6615
  values: entityValues,
6612
6616
  entityId,
6613
6617
  path,
6614
- property,
6618
+ property: resolvedProperty,
6615
6619
  file,
6616
6620
  propertyKey
6617
6621
  });
@@ -6621,7 +6625,7 @@ function useStorageUploadController({
6621
6625
  return fileName;
6622
6626
  }
6623
6627
  return randomString() + "_" + file.name;
6624
- }, [entityId, entityValues, path, property, propertyKey, storage]);
6628
+ }, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
6625
6629
  const storagePathBuilder = useCallback((file) => {
6626
6630
  return resolveStoragePathString({
6627
6631
  input: storage.storagePath,
@@ -6629,11 +6633,11 @@ function useStorageUploadController({
6629
6633
  values: entityValues,
6630
6634
  entityId,
6631
6635
  path,
6632
- property,
6636
+ property: resolvedProperty,
6633
6637
  file,
6634
6638
  propertyKey
6635
6639
  }) ?? "/";
6636
- }, [entityId, entityValues, path, property, propertyKey, storage]);
6640
+ }, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
6637
6641
  const onFileUploadComplete = useCallback(async (uploadedPath, entry, metadata2) => {
6638
6642
  console.debug("onFileUploadComplete", uploadedPath, entry);
6639
6643
  let uploadPathOrDownloadUrl = uploadedPath;
@@ -13892,7 +13896,7 @@ function SelectFieldBinding({
13892
13896
  includeDescription,
13893
13897
  size = "medium"
13894
13898
  }) {
13895
- const enumValues = property.enumValues;
13899
+ const enumValues = resolveEnumValues(property.enumValues ?? []);
13896
13900
  useClearRestoreValue({
13897
13901
  property,
13898
13902
  value,
@@ -14331,6 +14335,9 @@ function StorageUploadFieldBinding({
14331
14335
  value,
14332
14336
  setValue
14333
14337
  });
14338
+ const resolvedProperty = resolveProperty({
14339
+ propertyOrBuilder: property
14340
+ });
14334
14341
  return /* @__PURE__ */ jsxs(Fragment, { children: [
14335
14342
  !minimalistView && /* @__PURE__ */ jsx(
14336
14343
  LabelWithIconAndTooltip,
@@ -14349,7 +14356,7 @@ function StorageUploadFieldBinding({
14349
14356
  name: propertyKey,
14350
14357
  disabled: disabled ?? false,
14351
14358
  autoFocus: autoFocus ?? false,
14352
- property,
14359
+ property: resolvedProperty,
14353
14360
  onChange: setValue,
14354
14361
  setInternalValue,
14355
14362
  onFilesAdded,
@@ -15968,7 +15975,7 @@ function RepeatFieldBinding({
15968
15975
  }) {
15969
15976
  if (!property.of)
15970
15977
  throw Error("RepeatFieldBinding misconfiguration. Property `of` not set");
15971
- let resolvedProperties = property.resolvedProperties;
15978
+ let resolvedProperties = "resolvedProperties" in property ? property.resolvedProperties : void 0;
15972
15979
  if (!resolvedProperties) {
15973
15980
  resolvedProperties = getArrayResolvedProperties({
15974
15981
  propertyValue: value,
@@ -16282,6 +16289,10 @@ function MarkdownEditorFieldBinding({
16282
16289
  setFieldVersion(fieldVersion + 1);
16283
16290
  }
16284
16291
  }, [value]);
16292
+ const resolvedProperty = resolveProperty({
16293
+ propertyOrBuilder: property,
16294
+ values: entityValues
16295
+ });
16285
16296
  const fileNameBuilder = useCallback(async (file) => {
16286
16297
  if (storage?.fileName) {
16287
16298
  const fileName = await resolveStorageFilenameString({
@@ -16290,7 +16301,7 @@ function MarkdownEditorFieldBinding({
16290
16301
  values: entityValues,
16291
16302
  entityId,
16292
16303
  path,
16293
- property,
16304
+ property: resolvedProperty,
16294
16305
  file,
16295
16306
  propertyKey
16296
16307
  });
@@ -16300,16 +16311,20 @@ function MarkdownEditorFieldBinding({
16300
16311
  return fileName;
16301
16312
  }
16302
16313
  return randomString() + "_" + file.name;
16303
- }, [entityId, entityValues, path, property, propertyKey, storage]);
16314
+ }, [entityId, entityValues, path, resolvedProperty, propertyKey, storage]);
16304
16315
  const storagePathBuilder = useCallback((file) => {
16305
16316
  if (!storage) return "/";
16317
+ const resolvedProperty2 = resolveProperty({
16318
+ propertyOrBuilder: property,
16319
+ values: entityValues
16320
+ });
16306
16321
  return resolveStoragePathString({
16307
16322
  input: storage.storagePath,
16308
16323
  storage,
16309
16324
  values: entityValues,
16310
16325
  entityId,
16311
16326
  path,
16312
- property,
16327
+ property: resolvedProperty2,
16313
16328
  file,
16314
16329
  propertyKey
16315
16330
  }) ?? "/";
@@ -16378,8 +16393,15 @@ function ArrayCustomShapedFieldBinding({
16378
16393
  context,
16379
16394
  disabled
16380
16395
  }) {
16381
- if (!Array.isArray(property.resolvedProperties))
16382
- throw Error("ArrayCustomShapedFieldBinding misconfiguration. Property `of` not set");
16396
+ let resolvedProperties = "resolvedProperties" in property ? property.resolvedProperties : void 0;
16397
+ if (!resolvedProperties) {
16398
+ resolvedProperties = getArrayResolvedProperties({
16399
+ propertyValue: value,
16400
+ propertyKey,
16401
+ property,
16402
+ ignoreMissingFields: false
16403
+ });
16404
+ }
16383
16405
  const expanded = property.expanded === void 0 ? true : property.expanded;
16384
16406
  useClearRestoreValue({
16385
16407
  property,
@@ -16403,7 +16425,7 @@ function ArrayCustomShapedFieldBinding({
16403
16425
  ")"
16404
16426
  ] })
16405
16427
  ] });
16406
- const body = property.resolvedProperties.map((childProperty, index) => {
16428
+ const body = resolvedProperties.map((childProperty, index) => {
16407
16429
  const fieldProps = {
16408
16430
  propertyKey: `${propertyKey}[${index}]`,
16409
16431
  disabled,