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