@cntrl-site/sdk-nextjs 1.9.135-alpha.2 → 1.9.135-alpha.3

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.
@@ -29,7 +29,8 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
29
29
  const [ref, setRef] = (0, react_1.useState)(null);
30
30
  const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
31
31
  const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
32
- const { blur: itemBlur, wordSpacing: itemWordSpacing, letterSpacing: itemLetterSpacing, color: itemColor, fontSize, lineHeight, xSizing } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
32
+ const { blur: itemBlur, wordSpacing: itemWordSpacing, letterSpacing: itemLetterSpacing, color: itemColor, fontSize, lineHeight, xSizing, columns, columnGutter, hyphens } = (0, useRichTextItemValues_1.useRichTextItemValues)(item, sectionId);
33
+ const columnsEnabled = (columns !== null && columns !== void 0 ? columns : 1) > 1;
33
34
  const layoutValues = [item.area, item.layoutParams];
34
35
  const exemplary = (0, useExemplary_1.useExemplary)();
35
36
  const { layoutId } = (0, useCurrentLayout_1.useCurrentLayout)();
@@ -61,7 +62,7 @@ const RichTextItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
61
62
  (0, react_1.useEffect)(() => {
62
63
  onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
63
64
  }, [isInteractive, onVisibilityChange]);
64
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Wrapper, { ref: setRef, lang: "en", className: `rich-text-wrapper-${item.id}${layoutId ? '' : ` ${RichTextConverter_1.RICH_TEXT_LAYOUT_PENDING_CLASS}`}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (letterSpacing !== undefined ? { letterSpacing: `${letterSpacing * exemplary}px` } : {})), (wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {})), (fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {})), (lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition }), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
65
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Wrapper, { ref: setRef, lang: "en", className: `rich-text-wrapper-${item.id}${layoutId ? '' : ` ${RichTextConverter_1.RICH_TEXT_LAYOUT_PENDING_CLASS}`}`, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (textColor ? { color: `${textColor.fmt('rgba')}` } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (letterSpacing !== undefined ? { letterSpacing: `${letterSpacing * exemplary}px` } : {})), (wordSpacing !== undefined ? { wordSpacing: `${wordSpacing * exemplary}px` } : {})), (fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {})), (lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {})), (columnsEnabled ? { columnCount: columns, columnFill: 'balance' } : {})), (columnsEnabled && columnGutter !== undefined ? { columnGap: `${Math.round(columnGutter * exemplary)}px` } : {})), (hyphens !== undefined ? { hyphens, WebkitHyphens: hyphens } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition }), children: content }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [styles, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([area, layoutParams]) => {
65
66
  var _a, _b, _c;
66
67
  const color = color_1.CntrlColor.parse(layoutParams.color);
67
68
  const columns = (_a = layoutParams.columns) !== null && _a !== void 0 ? _a : 1;
@@ -34,6 +34,9 @@ const useRichTextItemValues = (item, sectionId) => {
34
34
  const fontSize = layoutId ? item.layoutParams[layoutId].fontSize : undefined;
35
35
  const lineHeight = layoutId ? item.layoutParams[layoutId].lineHeight : undefined;
36
36
  const xSizing = layoutId ? item.layoutParams[layoutId].sizing : undefined;
37
- return { blur, letterSpacing, wordSpacing, color, fontSize, lineHeight, xSizing };
37
+ const columns = layoutId ? item.layoutParams[layoutId].columns : undefined;
38
+ const columnGutter = layoutId ? item.layoutParams[layoutId].columnGutter : undefined;
39
+ const hyphens = layoutId ? item.layoutParams[layoutId].hyphens : undefined;
40
+ return { blur, letterSpacing, wordSpacing, color, fontSize, lineHeight, xSizing, columns, columnGutter, hyphens };
38
41
  };
39
42
  exports.useRichTextItemValues = useRichTextItemValues;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cntrl-site/sdk-nextjs",
3
- "version": "1.9.135-alpha.2",
3
+ "version": "1.9.135-alpha.3",
4
4
  "description": "SDK for Next.js",
5
5
  "author": "arsen@momdesign.nyc",
6
6
  "license": "MIT",
@@ -30,8 +30,12 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
30
30
  color: itemColor,
31
31
  fontSize,
32
32
  lineHeight,
33
- xSizing
33
+ xSizing,
34
+ columns,
35
+ columnGutter,
36
+ hyphens
34
37
  } = useRichTextItemValues(item, sectionId);
38
+ const columnsEnabled = (columns ?? 1) > 1;
35
39
  const layoutValues: Record<string, any>[] = [item.area, item.layoutParams];
36
40
  const exemplary = useExemplary();
37
41
  const { layoutId } = useCurrentLayout();
@@ -77,6 +81,9 @@ export const RichTextItem: FC<ItemProps<TRichTextItem>> = ({ item, sectionId, on
77
81
  ...(wordSpacing !== undefined ? { wordSpacing: `${wordSpacing as number * exemplary}px` } : {}),
78
82
  ...(fontSize !== undefined ? { fontSize: `${Math.round(fontSize * exemplary)}px` } : {}),
79
83
  ...(lineHeight !== undefined ? { lineHeight: `${lineHeight * exemplary}px` } : {}),
84
+ ...(columnsEnabled ? { columnCount: columns, columnFill: 'balance' as const } : {}),
85
+ ...(columnsEnabled && columnGutter !== undefined ? { columnGap: `${Math.round(columnGutter * exemplary)}px` } : {}),
86
+ ...(hyphens !== undefined ? { hyphens, WebkitHyphens: hyphens } : {}),
80
87
  willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset',
81
88
  transition
82
89
  }}
@@ -61,6 +61,9 @@ export const useRichTextItemValues = (item: RichTextItem, sectionId: string) =>
61
61
  const fontSize = layoutId ? item.layoutParams[layoutId].fontSize : undefined;
62
62
  const lineHeight = layoutId ? item.layoutParams[layoutId].lineHeight : undefined;
63
63
  const xSizing = layoutId ? item.layoutParams[layoutId].sizing : undefined;
64
+ const columns = layoutId ? item.layoutParams[layoutId].columns : undefined;
65
+ const columnGutter = layoutId ? item.layoutParams[layoutId].columnGutter : undefined;
66
+ const hyphens = layoutId ? item.layoutParams[layoutId].hyphens : undefined;
64
67
 
65
- return { blur, letterSpacing, wordSpacing, color, fontSize, lineHeight, xSizing };
68
+ return { blur, letterSpacing, wordSpacing, color, fontSize, lineHeight, xSizing, columns, columnGutter, hyphens };
66
69
  };