@rebasepro/common 0.0.1-canary.eae7889 → 0.1.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.
package/dist/index.es.js CHANGED
@@ -6,17 +6,17 @@ import cloneDeep from "lodash/cloneDeep.js";
6
6
  const DEFAULT_ONE_OF_TYPE = "type";
7
7
  const DEFAULT_ONE_OF_VALUE = "value";
8
8
  function isReadOnly(property) {
9
- if (property.readOnly) return true;
9
+ if (property.ui?.readOnly) return true;
10
10
  if (property.type === "date") {
11
11
  if (property.autoValue) return true;
12
12
  }
13
13
  if (property.type === "reference") {
14
- return !property.path && !("Field" in property && property.Field);
14
+ return !property.path && !("Field" in (property.ui || {}) && property.ui?.Field);
15
15
  }
16
16
  return false;
17
17
  }
18
18
  function isHidden(property) {
19
- return typeof property.disabled === "object" && Boolean(property.disabled.hidden);
19
+ return typeof property.ui?.disabled === "object" && Boolean(property.ui?.disabled.hidden);
20
20
  }
21
21
  function isPropertyBuilder(property) {
22
22
  return typeof property?.dynamicProps === "function";
@@ -500,7 +500,7 @@ function resolveArrayProperties({
500
500
  });
501
501
  }).filter((e) => Boolean(e)) : [];
502
502
  return resolvedProperties;
503
- } else if (!("Field" in property && property.Field)) {
503
+ } else if (!("Field" in (property.ui || {}) && property.ui?.Field)) {
504
504
  throw Error(`The array property (${propertyKey}) needs to declare an 'of' or a 'oneOf' property, or provide a custom \`Field\` component`);
505
505
  } else {
506
506
  return [];
@@ -730,7 +730,7 @@ function getEntityImagePreviewPropertyKey(collection) {
730
730
  }
731
731
  for (const key in collection.properties) {
732
732
  const property = collection.properties[key];
733
- if (property.type === "string" && property.url === "image") {
733
+ if (property.type === "string" && property.ui?.url === "image") {
734
734
  return key;
735
735
  }
736
736
  }
@@ -1453,7 +1453,8 @@ function applyPropertyConditions(property, context) {
1453
1453
  if (conditions.disabled) {
1454
1454
  const isDisabled = evaluateCondition(conditions.disabled, context);
1455
1455
  if (isDisabled) {
1456
- result.disabled = {
1456
+ result.ui = result.ui || {};
1457
+ result.ui.disabled = {
1457
1458
  clearOnDisabled: conditions.clearOnDisabled ?? false,
1458
1459
  disabledMessage: conditions.disabledMessage,
1459
1460
  hidden: false
@@ -1463,8 +1464,9 @@ function applyPropertyConditions(property, context) {
1463
1464
  if (conditions.hidden) {
1464
1465
  const isHidden2 = evaluateCondition(conditions.hidden, context);
1465
1466
  if (isHidden2) {
1466
- result.disabled = {
1467
- ...typeof result.disabled === "object" ? result.disabled : {},
1467
+ result.ui = result.ui || {};
1468
+ result.ui.disabled = {
1469
+ ...typeof result.ui?.disabled === "object" ? result.ui.disabled : {},
1468
1470
  hidden: true,
1469
1471
  clearOnDisabled: conditions.clearOnDisabled ?? false
1470
1472
  };
@@ -1473,7 +1475,8 @@ function applyPropertyConditions(property, context) {
1473
1475
  if (conditions.readOnly) {
1474
1476
  const isReadOnly2 = evaluateCondition(conditions.readOnly, context);
1475
1477
  if (isReadOnly2) {
1476
- result.readOnly = true;
1478
+ result.ui = result.ui || {};
1479
+ result.ui.readOnly = true;
1477
1480
  }
1478
1481
  }
1479
1482
  if (conditions.required !== void 0) {
@@ -1495,7 +1498,7 @@ function applyPropertyConditions(property, context) {
1495
1498
  result.path = evaluateCondition(conditions.referencePath, context);
1496
1499
  }
1497
1500
  if (conditions.referenceFilter) {
1498
- result.forceFilter = evaluateCondition(conditions.referenceFilter, context);
1501
+ result.fixedFilter = evaluateCondition(conditions.referenceFilter, context);
1499
1502
  }
1500
1503
  }
1501
1504
  if (result.type === "array") {
@@ -1823,7 +1826,10 @@ class CollectionRegistry {
1823
1826
  if (!relation) {
1824
1827
  throw new Error(`Relation '${relationKey}' not found in collection '${currentCollection.slug}'`);
1825
1828
  }
1826
- currentCollection = relation.target();
1829
+ const target = relation.target();
1830
+ const targetRelationKey = relation.relationName || target.slug;
1831
+ const targetSlug = relation.overrides?.slug ?? targetRelationKey;
1832
+ currentCollection = this.get(targetSlug) || this.normalizeCollection(target);
1827
1833
  if (i + 1 < pathSegments.length) ;
1828
1834
  }
1829
1835
  return currentCollection;
@@ -1872,7 +1878,7 @@ class CollectionRegistry {
1872
1878
  if (!subcollection) {
1873
1879
  throw new Error(`Subcollection '${subcollectionSlug}' not found in ${currentCollection.slug}`);
1874
1880
  }
1875
- currentCollection = subcollection;
1881
+ currentCollection = this.get(subcollection.slug) || this.normalizeCollection(subcollection);
1876
1882
  collections.push(currentCollection);
1877
1883
  }
1878
1884
  }