@contentful/experiences-visual-editor-react 1.34.0 → 1.34.1-dev-20250305T1630-a40e5df.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/renderApp.js CHANGED
@@ -37,8 +37,8 @@ function styleInject(css, ref) {
37
37
  }
38
38
  }
39
39
 
40
- var css_248z$a = "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\n/*\n * All of these variables are tokens from Forma-36 and should not be adjusted as these\n * are global variables that may affect multiple places.\n * As our customers may use other design libraries, we try to avoid overlapping global\n * variables by always using the prefix `--exp-builder-` inside this SDK.\n */\n\n:root {\n /* Color tokens from Forma 36: https://f36.contentful.com/tokens/color-system */\n --exp-builder-blue100: #e8f5ff;\n --exp-builder-blue200: #ceecff;\n --exp-builder-blue300: #98cbff;\n --exp-builder-blue400: #40a0ff;\n --exp-builder-blue500: #036fe3;\n --exp-builder-blue600: #0059c8;\n --exp-builder-blue700: #0041ab;\n --exp-builder-blue800: #003298;\n --exp-builder-blue900: #002a8e;\n --exp-builder-gray100: #f7f9fa;\n --exp-builder-gray200: #e7ebee;\n --exp-builder-gray300: #cfd9e0;\n --exp-builder-gray400: #aec1cc;\n --exp-builder-gray500: #67728a;\n --exp-builder-gray600: #5a657c;\n --exp-builder-gray700: #414d63;\n --exp-builder-gray800: #1b273a;\n --exp-builder-gray900: #111b2b;\n --exp-builder-purple600: #6c3ecf;\n --exp-builder-red200: #ffe0e0;\n --exp-builder-red800: #7f0010;\n --exp-builder-color-white: #ffffff;\n --exp-builder-glow-primary: 0px 0px 0px 3px #e8f5ff;\n\n /* RGB colors for applying opacity */\n --exp-builder-blue100-rgb: 232, 245, 255;\n --exp-builder-blue300-rgb: 152, 203, 255;\n\n /* Spacing tokens from Forma 36: https://f36.contentful.com/tokens/spacing */\n --exp-builder-spacing-s: 0.75rem;\n --exp-builder-spacing-2xs: 0.25rem;\n\n /* Typography tokens from Forma 36: https://f36.contentful.com/tokens/typography */\n --exp-builder-font-size-l: 1rem;\n --exp-builder-font-size-m: 0.875rem;\n --exp-builder-font-stack-primary: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,\n sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;\n --exp-builder-line-height-condensed: 1.25;\n}\n";
41
- styleInject(css_248z$a);
40
+ var css_248z$b = "html,\nbody {\n margin: 0;\n padding: 0;\n}\n\n/*\n * All of these variables are tokens from Forma-36 and should not be adjusted as these\n * are global variables that may affect multiple places.\n * As our customers may use other design libraries, we try to avoid overlapping global\n * variables by always using the prefix `--exp-builder-` inside this SDK.\n */\n\n:root {\n /* Color tokens from Forma 36: https://f36.contentful.com/tokens/color-system */\n --exp-builder-blue100: #e8f5ff;\n --exp-builder-blue200: #ceecff;\n --exp-builder-blue300: #98cbff;\n --exp-builder-blue400: #40a0ff;\n --exp-builder-blue500: #036fe3;\n --exp-builder-blue600: #0059c8;\n --exp-builder-blue700: #0041ab;\n --exp-builder-blue800: #003298;\n --exp-builder-blue900: #002a8e;\n --exp-builder-gray100: #f7f9fa;\n --exp-builder-gray200: #e7ebee;\n --exp-builder-gray300: #cfd9e0;\n --exp-builder-gray400: #aec1cc;\n --exp-builder-gray500: #67728a;\n --exp-builder-gray600: #5a657c;\n --exp-builder-gray700: #414d63;\n --exp-builder-gray800: #1b273a;\n --exp-builder-gray900: #111b2b;\n --exp-builder-purple600: #6c3ecf;\n --exp-builder-red200: #ffe0e0;\n --exp-builder-red800: #7f0010;\n --exp-builder-color-white: #ffffff;\n --exp-builder-glow-primary: 0px 0px 0px 3px #e8f5ff;\n\n /* RGB colors for applying opacity */\n --exp-builder-blue100-rgb: 232, 245, 255;\n --exp-builder-blue300-rgb: 152, 203, 255;\n\n /* Spacing tokens from Forma 36: https://f36.contentful.com/tokens/spacing */\n --exp-builder-spacing-s: 0.75rem;\n --exp-builder-spacing-2xs: 0.25rem;\n\n /* Typography tokens from Forma 36: https://f36.contentful.com/tokens/typography */\n --exp-builder-font-size-l: 1rem;\n --exp-builder-font-size-m: 0.875rem;\n --exp-builder-font-stack-primary: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,\n sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;\n --exp-builder-line-height-condensed: 1.25;\n}\n";
41
+ styleInject(css_248z$b);
42
42
 
43
43
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
44
44
 
@@ -43005,45 +43005,85 @@ const toCSSAttribute = (key) => {
43005
43005
  val = val.replace(/\d+$/, '');
43006
43006
  return val;
43007
43007
  };
43008
- const buildStyleTag = ({ styles, nodeId }) => {
43009
- const stylesStr = Object.entries(styles)
43008
+ /**
43009
+ * Turns a list of CSSProperties into a joined CSS string that can be
43010
+ * used for <style> tags. Per default it creates a minimized version.
43011
+ * For editor mode, use the `useWhitespaces` flag to create a more readable version.
43012
+ *
43013
+ * @param cssProperties list of CSS properties
43014
+ * @param useWhitespaces adds whitespaces and newlines between each rule
43015
+ * @returns a string of CSS rules
43016
+ */
43017
+ const stringifyCssProperties = (cssProperties, useWhitespaces = false) => {
43018
+ const rules = Object.entries(cssProperties)
43010
43019
  .filter(([, value]) => value !== undefined)
43011
- .reduce((acc, [key, value]) => `${acc}
43012
- ${toCSSAttribute(key)}: ${value};`, '');
43013
- const className = `cfstyles-${nodeId ? nodeId : md5(stylesStr)}`;
43014
- const styleRule = `.${className}{ ${stylesStr} }`;
43020
+ .map(([key, value]) => useWhitespaces ? `${toCSSAttribute(key)}: ${value};` : `${toCSSAttribute(key)}:${value};`);
43021
+ return rules.join(useWhitespaces ? '\n' : '');
43022
+ };
43023
+ const buildStyleTag = ({ styles, nodeId }) => {
43024
+ const generatedStyles = stringifyCssProperties(styles, true);
43025
+ const className = `cfstyles-${nodeId ? nodeId : md5(generatedStyles)}`;
43026
+ const styleRule = `.${className}{ ${generatedStyles} }`;
43015
43027
  return [className, styleRule];
43016
43028
  };
43017
- const buildCfStyles = ({ cfHorizontalAlignment, cfVerticalAlignment, cfFlexDirection, cfFlexReverse, cfFlexWrap, cfMargin, cfPadding, cfBackgroundColor, cfWidth, cfHeight, cfMaxWidth, cfBorder, cfBorderRadius, cfGap, cfBackgroundImageUrl, cfBackgroundImageOptions, cfFontSize, cfFontWeight, cfImageOptions, cfLineHeight, cfLetterSpacing, cfTextColor, cfTextAlign, cfTextTransform, cfTextBold, cfTextItalic, cfTextUnderline, cfColumnSpan, cfVisibility, }) => {
43018
- return {
43029
+ /**
43030
+ * Takes plain design values and transforms them into CSS properties. Undefined values will
43031
+ * be filtered out.
43032
+ *
43033
+ * **Example Input**
43034
+ * ```
43035
+ * values = {
43036
+ * cfVisibility: 'visible',
43037
+ * cfMargin: '10px',
43038
+ * cfFlexReverse: true,
43039
+ * cfImageOptions: { objectFit: 'cover' },
43040
+ * // ...
43041
+ * }
43042
+ * ```
43043
+ * **Example Output**
43044
+ * ```
43045
+ * cssProperties = {
43046
+ * margin: '10px',
43047
+ * flexDirection: 'row-reverse',
43048
+ * objectFit: 'cover',
43049
+ * // ...
43050
+ * }
43051
+ * ```
43052
+ */
43053
+ const buildCfStyles = (values) => {
43054
+ const cssProperties = {
43019
43055
  boxSizing: 'border-box',
43020
- ...transformVisibility(cfVisibility),
43021
- margin: cfMargin,
43022
- padding: cfPadding,
43023
- backgroundColor: cfBackgroundColor,
43024
- width: transformFill(cfWidth || cfImageOptions?.width),
43025
- height: transformFill(cfHeight || cfImageOptions?.height),
43026
- maxWidth: cfMaxWidth,
43027
- ...transformGridColumn(cfColumnSpan),
43028
- ...transformBorderStyle(cfBorder),
43029
- borderRadius: cfBorderRadius,
43030
- gap: cfGap,
43031
- ...transformAlignment(cfHorizontalAlignment, cfVerticalAlignment, cfFlexDirection),
43032
- flexDirection: cfFlexReverse && cfFlexDirection ? `${cfFlexDirection}-reverse` : cfFlexDirection,
43033
- flexWrap: cfFlexWrap,
43034
- ...transformBackgroundImage(cfBackgroundImageUrl, cfBackgroundImageOptions),
43035
- fontSize: cfFontSize,
43036
- fontWeight: cfTextBold ? 'bold' : cfFontWeight,
43037
- fontStyle: cfTextItalic ? 'italic' : undefined,
43038
- textDecoration: cfTextUnderline ? 'underline' : undefined,
43039
- lineHeight: cfLineHeight,
43040
- letterSpacing: cfLetterSpacing,
43041
- color: cfTextColor,
43042
- textAlign: cfTextAlign,
43043
- textTransform: cfTextTransform,
43044
- objectFit: cfImageOptions?.objectFit,
43045
- objectPosition: cfImageOptions?.objectPosition,
43056
+ ...transformVisibility(values.cfVisibility),
43057
+ margin: values.cfMargin,
43058
+ padding: values.cfPadding,
43059
+ backgroundColor: values.cfBackgroundColor,
43060
+ width: transformFill(values.cfWidth || values.cfImageOptions?.width),
43061
+ height: transformFill(values.cfHeight || values.cfImageOptions?.height),
43062
+ maxWidth: values.cfMaxWidth,
43063
+ ...transformGridColumn(values.cfColumnSpan),
43064
+ ...transformBorderStyle(values.cfBorder),
43065
+ borderRadius: values.cfBorderRadius,
43066
+ gap: values.cfGap,
43067
+ ...transformAlignment(values.cfHorizontalAlignment, values.cfVerticalAlignment, values.cfFlexDirection),
43068
+ flexDirection: values.cfFlexReverse && values.cfFlexDirection
43069
+ ? `${values.cfFlexDirection}-reverse`
43070
+ : values.cfFlexDirection,
43071
+ flexWrap: values.cfFlexWrap,
43072
+ ...transformBackgroundImage(values.cfBackgroundImageUrl, values.cfBackgroundImageOptions),
43073
+ fontSize: values.cfFontSize,
43074
+ fontWeight: values.cfTextBold ? 'bold' : values.cfFontWeight,
43075
+ fontStyle: values.cfTextItalic ? 'italic' : undefined,
43076
+ textDecoration: values.cfTextUnderline ? 'underline' : undefined,
43077
+ lineHeight: values.cfLineHeight,
43078
+ letterSpacing: values.cfLetterSpacing,
43079
+ color: values.cfTextColor,
43080
+ textAlign: values.cfTextAlign,
43081
+ textTransform: values.cfTextTransform,
43082
+ objectFit: values.cfImageOptions?.objectFit,
43083
+ objectPosition: values.cfImageOptions?.objectPosition,
43046
43084
  };
43085
+ const cssPropertiesWithoutUndefined = Object.fromEntries(Object.entries(cssProperties).filter(([, value]) => value !== undefined));
43086
+ return cssPropertiesWithoutUndefined;
43047
43087
  };
43048
43088
  /**
43049
43089
  * Container/section default behavior:
@@ -56697,9 +56737,9 @@ const cloneDeepAsPOJO = (obj) => {
56697
56737
  return JSON.parse(JSON.stringify(obj));
56698
56738
  };
56699
56739
 
56700
- var css_248z$9 = ".render-module_hitbox__l4ysJ {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 10px;\n z-index: 1000000;\n}\n\n.render-module_hitboxLower__tgsA1 {\n position: absolute;\n bottom: -20px;\n left: 0;\n width: 100%;\n height: 20px;\n z-index: 1000000;\n}\n\n.render-module_canvasBottomSpacer__JuxVh {\n position: absolute;\n width: 100%;\n height: 50px;\n}\n\n.render-module_container__-C3d7 {\n position: relative;\n display: flex;\n flex-direction: column;\n}\n\nbody {\n margin: 0;\n}\n\nhtml {\n -ms-overflow-style: none; /* Internet Explorer 10+ */\n scrollbar-width: none; /* Firefox */\n}\n\nhtml::-webkit-scrollbar {\n display: none;\n}\n";
56740
+ var css_248z$a = ".render-module_hitbox__l4ysJ {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 10px;\n z-index: 1000000;\n}\n\n.render-module_hitboxLower__tgsA1 {\n position: absolute;\n bottom: -20px;\n left: 0;\n width: 100%;\n height: 20px;\n z-index: 1000000;\n}\n\n.render-module_canvasBottomSpacer__JuxVh {\n position: absolute;\n width: 100%;\n height: 50px;\n}\n\n.render-module_container__-C3d7 {\n position: relative;\n display: flex;\n flex-direction: column;\n}\n\nbody {\n margin: 0;\n}\n\nhtml {\n -ms-overflow-style: none; /* Internet Explorer 10+ */\n scrollbar-width: none; /* Firefox */\n}\n\nhtml::-webkit-scrollbar {\n display: none;\n}\n";
56701
56741
  var styles$3 = {"hitbox":"render-module_hitbox__l4ysJ","hitboxLower":"render-module_hitboxLower__tgsA1","canvasBottomSpacer":"render-module_canvasBottomSpacer__JuxVh","container":"render-module_container__-C3d7"};
56702
- styleInject(css_248z$9);
56742
+ styleInject(css_248z$a);
56703
56743
 
56704
56744
  // TODO: In order to support integrations without React, we should extract this heavy logic into simple
56705
56745
  // functions that we can reuse in other frameworks.
@@ -58094,6 +58134,9 @@ function getSchemaWithNodeType(nodeType) {
58094
58134
 
58095
58135
  } (dist));
58096
58136
 
58137
+ var css_248z$8 = "/* Initially added with PR #253 for each component, this is now a global setting\n * It is recommended on MDN to use this as a default for layouting.\n*/\n* {\n box-sizing: border-box;\n}\n";
58138
+ styleInject(css_248z$8);
58139
+
58097
58140
  /**
58098
58141
  * These modes are ONLY intended to be internally used within the context of
58099
58142
  * editing an experience inside of Contentful Studio. i.e. these modes
@@ -58612,8 +58655,8 @@ Flex.displayName = 'Flex';
58612
58655
  var css_248z$1$1 = ".cf-divider {\n display: contents;\n position: relative;\n width: 100%;\n height: 100%;\n}\n\n.cf-divider hr {\n border: none;\n}\n\n/* For the editor mode add this 10px tolerance to make it easier picking up the divider component.\n * Using the DND zone as precondition makes sure that we don't render this pseudo element in delivery. */\n\n[data-ctfl-zone-id='root'] .cf-divider::before {\n content: \"\";\n position: absolute;\n top: -5px;\n left: -5px;\n bottom: -5px;\n right: -5px;\n pointer-events: all;\n}\n";
58613
58656
  styleInject(css_248z$1$1);
58614
58657
 
58615
- var css_248z$8 = ".cf-columns {\n display: flex;\n gap: 24px;\n grid-template-columns: repeat(12, 1fr);\n flex-direction: column;\n min-height: 0; /* NEW */\n min-width: 0; /* NEW; needed for Firefox */\n}\n\n@media (min-width: 768px) {\n .cf-columns {\n display: grid;\n }\n}\n\n.cf-single-column-wrapper {\n position: relative;\n display: flex;\n}\n\n.cf-single-column {\n pointer-events: all;\n}\n\n.cf-single-column-wrapper:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.cf-single-column-label:after {\n content: 'Column';\n}\n";
58616
- styleInject(css_248z$8);
58658
+ var css_248z$9 = ".cf-columns {\n display: flex;\n gap: 24px;\n grid-template-columns: repeat(12, 1fr);\n flex-direction: column;\n min-height: 0; /* NEW */\n min-width: 0; /* NEW; needed for Firefox */\n}\n\n@media (min-width: 768px) {\n .cf-columns {\n display: grid;\n }\n}\n\n.cf-single-column-wrapper {\n position: relative;\n display: flex;\n}\n\n.cf-single-column {\n pointer-events: all;\n}\n\n.cf-single-column-wrapper:after {\n content: '';\n display: block;\n position: absolute;\n pointer-events: none;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n overflow-x: clip;\n font-family: var(--exp-builder-font-stack-primary);\n font-size: 12px;\n color: var(--exp-builder-gray400);\n z-index: 1;\n}\n\n.cf-single-column-label:after {\n content: 'Column';\n}\n";
58659
+ styleInject(css_248z$9);
58617
58660
 
58618
58661
  const ColumnWrapper = reactExports.forwardRef((props, ref) => {
58619
58662
  return (React$1.createElement("div", { ref: ref, ...props, style: {