@contentful/experiences-visual-editor-react 1.40.0-dev-20250604T0933-fc115de.0 → 1.40.1-beta.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.js CHANGED
@@ -1406,6 +1406,7 @@ const sanitizeNodeProps = (nodeProps) => {
1406
1406
  return omit(nodeProps, stylesToRemove, propsToRemove);
1407
1407
  };
1408
1408
 
1409
+ /** Turn the visibility value into a style object that can be used for inline styles in React */
1409
1410
  const transformVisibility = (value) => {
1410
1411
  if (value === false) {
1411
1412
  return {
@@ -1574,7 +1575,6 @@ const buildStyleTag = ({ styles, nodeId }) => {
1574
1575
  const buildCfStyles = (values) => {
1575
1576
  const cssProperties = {
1576
1577
  boxSizing: 'border-box',
1577
- ...transformVisibility(values.cfVisibility),
1578
1578
  margin: values.cfMargin,
1579
1579
  padding: values.cfPadding,
1580
1580
  backgroundColor: values.cfBackgroundColor,
@@ -2232,6 +2232,17 @@ class EntityStoreBase {
2232
2232
  resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
2233
2233
  entityToResolveFieldsFrom = entity; // we move up
2234
2234
  }
2235
+ else if (this.isAsset(fieldValue) || this.isEntry(fieldValue)) {
2236
+ resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
2237
+ entityToResolveFieldsFrom = fieldValue; // we move up
2238
+ }
2239
+ else {
2240
+ return {
2241
+ resolvedFieldset,
2242
+ isFullyResolved: false,
2243
+ reason: `Deep path points to an invalid field value of type '${typeof fieldValue}' (value=${fieldValue})`,
2244
+ };
2245
+ }
2235
2246
  }
2236
2247
  return {
2237
2248
  resolvedFieldset,
@@ -2257,8 +2268,17 @@ class EntityStoreBase {
2257
2268
  const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
2258
2269
  return leafEntity;
2259
2270
  }
2260
- isAsset(entity) {
2261
- return entity.sys.type === 'Asset';
2271
+ isAsset(value) {
2272
+ return (null !== value &&
2273
+ typeof value === 'object' &&
2274
+ 'sys' in value &&
2275
+ value.sys?.type === 'Asset');
2276
+ }
2277
+ isEntry(value) {
2278
+ return (null !== value &&
2279
+ typeof value === 'object' &&
2280
+ 'sys' in value &&
2281
+ value.sys?.type === 'Entry');
2262
2282
  }
2263
2283
  getEntity(type, id) {
2264
2284
  if (type === 'Asset') {
@@ -4813,7 +4833,11 @@ const useComponentProps = ({ node, areEntitiesFetched, resolveDesignValue, rende
4813
4833
  entityStore,
4814
4834
  renderDropzone,
4815
4835
  ]);
4816
- const cfStyles = useMemo(() => buildCfStyles(props), [props]);
4836
+ const cfStyles = useMemo(() => ({
4837
+ ...buildCfStyles(props),
4838
+ // This is not handled by buildCfStyles as it requires separate disjunct media queries in preview mode
4839
+ ...transformVisibility(props.cfVisibility),
4840
+ }), [props]);
4817
4841
  const cfVisibility = props['cfVisibility'];
4818
4842
  const isAssemblyBlock = node.type === ASSEMBLY_BLOCK_NODE_TYPE;
4819
4843
  const isSingleColumn = node?.data.blockId === CONTENTFUL_COMPONENTS$1.columns.id;