@cntrl-site/sdk-nextjs 1.11.2 → 1.11.4-alpha.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/lib/components/Article.js +4 -1
- package/lib/components/Section/Section.js +5 -3
- package/lib/components/StructuredBlockItem/BlockCaption/BlockCaption.js +19 -8
- package/lib/components/StructuredBlockItem/StructuredRichText/StructuredRichText.js +11 -18
- package/lib/components/StructuredBlockItem/StructuredTable/StructuredTable.js +10 -8
- package/lib/components/StructuredBlockItem/textStylesRule.js +24 -6
- package/lib/components/StructuredBlockItem/vw.js +8 -0
- package/lib/components/items/CodeEmbedItem/CodeEmbedItem.js +2 -2
- package/lib/components/items/ComponentItem/ComponentItem.js +3 -3
- package/lib/components/items/CompoundItem/CompoundItem.js +2 -2
- package/lib/components/items/EmbedVideoItem/VimeoEmbed.js +4 -4
- package/lib/components/items/EmbedVideoItem/YoutubeEmbed.js +5 -5
- package/lib/components/items/FileItem/ImageItem.js +2 -2
- package/lib/components/items/FileItem/VideoItem.js +3 -3
- package/lib/components/items/GroupItem/GroupItem.js +2 -2
- package/lib/components/items/LinkWrapper.js +33 -1
- package/lib/components/items/RectangleItem/RectangleItem.js +3 -3
- package/lib/utils/RichTextConverter/RichTextConverter.js +19 -9
- package/package.json +3 -3
- package/src/components/Article.test.tsx +52 -0
- package/src/components/Article.tsx +3 -0
- package/src/components/Section/Section.tsx +8 -4
- package/src/components/StructuredBlockItem/BlockCaption/BlockCaption.tsx +18 -8
- package/src/components/StructuredBlockItem/StructuredRichText/StructuredRichText.tsx +11 -14
- package/src/components/StructuredBlockItem/StructuredTable/StructuredTable.tsx +18 -14
- package/src/components/StructuredBlockItem/textStylesRule.ts +24 -6
- package/src/components/StructuredBlockItem/vw.ts +4 -0
- package/src/components/StructuredContent/StructuredContent.test.tsx +30 -3
- package/src/components/items/CodeEmbedItem/CodeEmbedItem.tsx +1 -1
- package/src/components/items/ComponentItem/ComponentItem.tsx +1 -0
- package/src/components/items/CompoundItem/CompoundItem.tsx +1 -1
- package/src/components/items/EmbedVideoItem/VimeoEmbed.tsx +1 -1
- package/src/components/items/EmbedVideoItem/YoutubeEmbed.tsx +1 -1
- package/src/components/items/FileItem/ImageItem.tsx +1 -1
- package/src/components/items/FileItem/VideoItem.tsx +1 -1
- package/src/components/items/GroupItem/GroupItem.tsx +1 -1
- package/src/components/items/LinkWrapper.tsx +43 -2
- package/src/components/items/RectangleItem/RectangleItem.tsx +1 -1
- package/src/utils/RichTextConverter/RichTextConverter.test.tsx +17 -0
- package/src/utils/RichTextConverter/RichTextConverter.tsx +23 -8
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/modules.xml +0 -8
- package/.idea/sdk-nextjs.iml +0 -12
- package/.idea/vcs.xml +0 -6
|
@@ -16,6 +16,7 @@ const WebGLContextManagerContext_1 = require("../provider/WebGLContextManagerCon
|
|
|
16
16
|
const effects_1 = require("@cntrl-site/effects");
|
|
17
17
|
const Navigation_1 = require("./Navigation/Navigation");
|
|
18
18
|
const Article = ({ article, sectionData, navigation, pages = [] }) => {
|
|
19
|
+
var _a;
|
|
19
20
|
const articleRef = (0, react_1.useRef)(null);
|
|
20
21
|
const articleRectObserver = (0, useArticleRectObserver_1.useArticleRectObserver)(articleRef.current);
|
|
21
22
|
const id = (0, react_1.useId)();
|
|
@@ -29,9 +30,11 @@ const Article = ({ article, sectionData, navigation, pages = [] }) => {
|
|
|
29
30
|
}, [articleRectObserver]);
|
|
30
31
|
const webglContextManager = (0, react_1.useMemo)(() => new effects_1.WebGLContextManager(), []);
|
|
31
32
|
const sectionsLength = article.sections.length;
|
|
33
|
+
// a page has one main content: its first content-based section
|
|
34
|
+
const mainSectionId = (_a = article.sections.find(section => section.type === 'content-based')) === null || _a === void 0 ? void 0 : _a.id;
|
|
32
35
|
return ((0, jsx_runtime_1.jsx)(ArticleRectContext_1.ArticleRectContext.Provider, { value: articleRectObserver, children: (0, jsx_runtime_1.jsxs)(InteractionsContext_1.InteractionsProvider, { article: article, children: [(0, jsx_runtime_1.jsxs)(ArticleWrapper_1.ArticleWrapper, { children: [navigation && ((0, jsx_runtime_1.jsx)(Navigation_1.Navigation, { navigation: navigation, pages: pages, hidden: article.navigationHidden })), (0, jsx_runtime_1.jsxs)("div", { className: "article", ref: articleRef, children: [(0, jsx_runtime_1.jsx)(WebGLContextManagerContext_1.WebglContextManagerContext.Provider, { value: webglContextManager, children: article.sections.map((section, i) => {
|
|
33
36
|
const data = section.name ? sectionData[section.name] : {};
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { articleHeight: articleHeight, section: section, data: data, zIndex: sectionsLength - i }, section.id));
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(Section_1.Section, { articleHeight: articleHeight, section: section, data: data, zIndex: sectionsLength - i, isMain: section.id === mainSectionId }, section.id));
|
|
35
38
|
}) }), (0, jsx_runtime_1.jsx)("div", { id: "component-portal" }), (0, jsx_runtime_1.jsx)("div", { id: "grid-component-lightbox-portal" })] })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
36
39
|
.article {
|
|
37
40
|
position: relative;
|
|
@@ -18,7 +18,7 @@ const checkOverflowClipSupport_1 = require("../../utils/checkOverflowClipSupport
|
|
|
18
18
|
const StructuredContent_1 = require("../StructuredContent/StructuredContent");
|
|
19
19
|
const Item_1 = require("../items/Item");
|
|
20
20
|
const DEFAULT_COLOR = 'rgba(0, 0, 0, 0)';
|
|
21
|
-
const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
21
|
+
const Section = ({ section, data, zIndex, articleHeight, isMain = false }) => {
|
|
22
22
|
var _a;
|
|
23
23
|
const reactId = (0, react_1.useId)();
|
|
24
24
|
const id = `${reactId}-section-${section.id}`;
|
|
@@ -32,6 +32,8 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
|
32
32
|
(_a = section.media) !== null && _a !== void 0 ? _a : {}
|
|
33
33
|
];
|
|
34
34
|
const SectionComponent = section.name ? customSections.getComponent(section.name) : undefined;
|
|
35
|
+
// a content-based section holds a post's own content: the first is the page's main content, any other a section of it
|
|
36
|
+
const Tag = (section.type === 'content-based' ? (isMain ? 'main' : 'section') : 'div');
|
|
35
37
|
(0, useSectionRegistry_1.useSectionRegistry)(section.id, sectionRef.current);
|
|
36
38
|
const layoutMedia = layout && section.media && section.media[layout] ? section.media[layout] : undefined;
|
|
37
39
|
const media = (0, react_1.useMemo)(() => {
|
|
@@ -67,8 +69,8 @@ const Section = ({ section, data, zIndex, articleHeight }) => {
|
|
|
67
69
|
}, []);
|
|
68
70
|
const children = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StructuredContent_1.StructuredContent, { section: section }), section.items.map(item => ((0, jsx_runtime_1.jsx)(Item_1.Item, { sectionHeight: sectionHeight, item: item, sectionId: section.id, articleHeight: articleHeight }, item.id)))] }));
|
|
69
71
|
if (SectionComponent)
|
|
70
|
-
return (0, jsx_runtime_1.jsx)(
|
|
71
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(
|
|
72
|
+
return (0, jsx_runtime_1.jsx)(Tag, { ref: sectionRef, children: (0, jsx_runtime_1.jsx)(SectionComponent, { data: data, children: children }) });
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Tag, { className: `section-${section.id}`, id: section.name, ref: sectionRef, style: { zIndex }, children: [media && sectionRef.current && ((0, jsx_runtime_1.jsx)("div", { className: `section-background-overlay-${section.id}`, children: (0, jsx_runtime_1.jsxs)("div", { className: `section-background-wrapper-${section.id}`, style: Object.assign({ transform: media.position === 'fixed' ? 'translateY(-100vh)' : 'unset' }, (sectionHeight && { height: media.position === 'fixed' ? `calc(${sectionHeight}px + 200vh)` : `${sectionHeight}px` })), children: [media.type === 'video' && ((0, jsx_runtime_1.jsx)(SectionVideo_1.SectionVideo, { container: sectionRef.current, sectionId: section.id, media: media })), media.type === 'image' && ((0, jsx_runtime_1.jsx)(SectionImage_1.SectionImage, { media: media, sectionId: section.id }))] }, `section-background-wrapper-${section.id}`) })), children] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
72
74
|
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([height, color, media]) => (`
|
|
73
75
|
.section-${section.id} {
|
|
74
76
|
min-height: ${getSectionHeightFallback(height)};
|
|
@@ -10,8 +10,12 @@ const react_1 = require("react");
|
|
|
10
10
|
const style_1 = __importDefault(require("styled-jsx/style"));
|
|
11
11
|
const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
12
12
|
const textStylesRule_1 = require("../textStylesRule");
|
|
13
|
+
const vw_1 = require("../vw");
|
|
13
14
|
const CAPTION_GAP_PX = 5;
|
|
14
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* The caption under an image, centered under it: as wide as the caption preset says, else as the
|
|
17
|
+
* reading column, or as the image where that is narrower; with the preset's space above and below its text.
|
|
18
|
+
*/
|
|
15
19
|
const BlockCaption = ({ blockId, caption, layoutParams, readingWidth }) => {
|
|
16
20
|
const reactId = (0, react_1.useId)();
|
|
17
21
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -23,13 +27,20 @@ const BlockCaption = ({ blockId, caption, layoutParams, readingWidth }) => {
|
|
|
23
27
|
white-space: pre-wrap;
|
|
24
28
|
overflow-wrap: break-word;
|
|
25
29
|
}
|
|
26
|
-
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([params,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([params, readingColumn], exemplary) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const captionStyles = params === null || params === void 0 ? void 0 : params.captionStyles;
|
|
33
|
+
const width = (_a = captionStyles === null || captionStyles === void 0 ? void 0 : captionStyles.maxWidth) !== null && _a !== void 0 ? _a : readingColumn;
|
|
34
|
+
return `
|
|
35
|
+
.structured-caption-${blockId} {
|
|
36
|
+
width: ${width !== undefined ? `min(${(0, vw_1.vw)(width)}, 100%)` : '100%'};
|
|
37
|
+
margin-top: ${CAPTION_GAP_PX / exemplary * 100}vw;
|
|
38
|
+
padding-top: ${(0, vw_1.vw)(captionStyles === null || captionStyles === void 0 ? void 0 : captionStyles.innerPaddingTop)};
|
|
39
|
+
padding-bottom: ${(0, vw_1.vw)(captionStyles === null || captionStyles === void 0 ? void 0 : captionStyles.innerPaddingBottom)};
|
|
40
|
+
}
|
|
41
|
+
${captionStyles ? (0, textStylesRule_1.textStylesRule)(`.structured-caption-${blockId}`, captionStyles) : ''}
|
|
42
|
+
`;
|
|
43
|
+
})}
|
|
33
44
|
` })] }));
|
|
34
45
|
};
|
|
35
46
|
exports.BlockCaption = BlockCaption;
|
|
@@ -17,40 +17,33 @@ const textStylesRule_1 = require("../textStylesRule");
|
|
|
17
17
|
const richTextConverter = new RichTextConverter_1.RichTextConverter();
|
|
18
18
|
/**
|
|
19
19
|
* A block of text: rich text, a quote, which is drawn in a box of its own, or a date, which comes as
|
|
20
|
-
* the text it reads as. Its text is set in the styles it was drawn with, its ranges styled over them
|
|
20
|
+
* the text it reads as. Its text is set in the styles it was drawn with, its ranges styled over them,
|
|
21
|
+
* and each paragraph is one of the page's; a quote is a quotation, and a heading, which takes no
|
|
22
|
+
* paragraphs, holds its lines in spans that look the same.
|
|
21
23
|
*/
|
|
22
24
|
const StructuredRichText = ({ block }) => {
|
|
23
|
-
var _a;
|
|
24
25
|
const reactId = (0, react_1.useId)();
|
|
25
26
|
const id = `${reactId}-structured-text-${block.id}`;
|
|
26
27
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
27
28
|
const [ref, setRef] = (0, react_1.useState)(null);
|
|
28
29
|
(0, useItemGeometry_1.useItemGeometry)(block.id, ref);
|
|
29
|
-
const
|
|
30
|
-
const lang = (0, react_1.useMemo)(() => (0, detectLang_1.detectLang)(block.commonParams.text), [block.commonParams.text]);
|
|
30
|
+
const headingTag = (0, getHeadingTag_1.getHeadingTag)(block);
|
|
31
31
|
const isQuote = block.type === sdk_1.StructuredBlockType.Quote;
|
|
32
|
+
const paragraphTag = headingTag ? 'span' : 'p';
|
|
33
|
+
const [content, rangeStyles, listStyles] = (0, react_1.useMemo)(() => richTextConverter.toHtml(block, layouts, { isScaledToViewport: false, paragraphTag }), [block, layouts, paragraphTag]);
|
|
34
|
+
const lang = (0, react_1.useMemo)(() => (0, detectLang_1.detectLang)(block.commonParams.text), [block.commonParams.text]);
|
|
32
35
|
// only a text block of the stack flows in columns: a quote keeps to its box, a date to its line
|
|
33
36
|
const isText = block.type === sdk_1.StructuredBlockType.RichText;
|
|
34
|
-
const Wrapper = (
|
|
37
|
+
const Wrapper = (headingTag !== null && headingTag !== void 0 ? headingTag : (isQuote ? 'blockquote' : 'div'));
|
|
35
38
|
const layoutValues = [block.layoutParams];
|
|
36
39
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Wrapper, { ref: setRef, lang: lang, className: `structured-text-${block.id}`, children: isQuote ? (0, jsx_runtime_1.jsx)("div", { className: `structured-quote-box-${block.id}`, children: content }) : content }), listStyles && (0, jsx_runtime_1.jsx)(style_1.default, { id: RichTextConverter_1.LIST_STYLES_ID, children: listStyles }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: id, children: [rangeStyles, `
|
|
37
40
|
.structured-text-${block.id} {
|
|
38
41
|
margin: 0;
|
|
39
42
|
}
|
|
40
|
-
`, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([layoutParams]) =>
|
|
41
|
-
var _a;
|
|
42
|
-
return (`
|
|
43
|
+
`, `${(0, sdk_1.getLayoutStyles)(layouts, layoutValues, ([layoutParams]) => (`
|
|
43
44
|
${(0, textStylesRule_1.textStylesRule)(`.structured-text-${block.id}`, layoutParams)}
|
|
44
45
|
${isText ? (0, textStylesRule_1.textColumnsRule)(`.structured-text-${block.id}`, layoutParams) : ''}
|
|
45
|
-
${isQuote ?
|
|
46
|
-
|
|
47
|
-
padding: ${[layoutParams.boxPaddingTop, layoutParams.boxPaddingRight, layoutParams.boxPaddingBottom, layoutParams.boxPaddingLeft].map(side => `${(side !== null && side !== void 0 ? side : 0) * 100}vw`).join(' ')};
|
|
48
|
-
border-radius: ${((_a = layoutParams.boxRadius) !== null && _a !== void 0 ? _a : 0) * 100}vw;
|
|
49
|
-
background-color: transparent;
|
|
50
|
-
}
|
|
51
|
-
${layoutParams.background ? (0, textStylesRule_1.colorRule)(`.structured-quote-box-${block.id}`, 'background-color', layoutParams.background) : ''}
|
|
52
|
-
` : ''}
|
|
53
|
-
`);
|
|
54
|
-
})}`] })] }));
|
|
46
|
+
${isQuote ? (0, textStylesRule_1.boxRule)(`.structured-quote-box-${block.id}`, layoutParams) : ''}
|
|
47
|
+
`))}`] })] }));
|
|
55
48
|
};
|
|
56
49
|
exports.StructuredRichText = StructuredRichText;
|
|
@@ -12,6 +12,7 @@ const useCntrlContext_1 = require("../../../provider/useCntrlContext");
|
|
|
12
12
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
13
13
|
const RichTextConverter_1 = require("../../../utils/RichTextConverter/RichTextConverter");
|
|
14
14
|
const textStylesRule_1 = require("../textStylesRule");
|
|
15
|
+
const vw_1 = require("../vw");
|
|
15
16
|
// the lines between the cells, in pixels of the layout, scaled with it like everything drawn in it
|
|
16
17
|
const BORDER_PX = 1;
|
|
17
18
|
const richTextConverter = new RichTextConverter_1.RichTextConverter();
|
|
@@ -39,7 +40,7 @@ function convertCells(block, layouts) {
|
|
|
39
40
|
* lined in the styles it comes with, their ranges styled over them, each column its share of the
|
|
40
41
|
* width and padded on either side as its own values say. Cells draw a heading row over a grid; rows
|
|
41
42
|
* draw every row plain, the two fills alternating from the first; lines draw the heading and a line
|
|
42
|
-
* between each pair of rows only.
|
|
43
|
+
* between each pair of rows only. The table is drawn in a box, which grows out past its columns.
|
|
43
44
|
*/
|
|
44
45
|
const StructuredTable = ({ block }) => {
|
|
45
46
|
const reactId = (0, react_1.useId)();
|
|
@@ -51,9 +52,10 @@ const StructuredTable = ({ block }) => {
|
|
|
51
52
|
const headingAsRow = kind === 'rows';
|
|
52
53
|
const Heading = headingAsRow ? 'td' : 'th';
|
|
53
54
|
const table = `.structured-table-${block.id}`;
|
|
55
|
+
const box = `.structured-table-box-${block.id}`;
|
|
54
56
|
const cells = `${table} th, ${table} td`;
|
|
55
57
|
const cellContent = (cell) => content.get(cell.id);
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("table", { ref: setRef, className: `structured-table-${block.id}`, children: [(0, jsx_runtime_1.jsx)("colgroup", { children: header.map((_, col) => (0, jsx_runtime_1.jsx)("col", {}, col)) }), (0, jsx_runtime_1.jsx)("thead", { className: `structured-table-heading-${block.id}`, children: (0, jsx_runtime_1.jsx)("tr", { children: header.map(cell => (0, jsx_runtime_1.jsx)(Heading, { children: cellContent(cell) }, cell.id)) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: `structured-table-body-${block.id}`, children: rows.map((row, index) => { var _a, _b; return (0, jsx_runtime_1.jsx)("tr", { children: row.map(cell => (0, jsx_runtime_1.jsx)("td", { children: cellContent(cell) }, cell.id)) }, (_b = (_a = row[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : index); }) })] }), listStyles && (0, jsx_runtime_1.jsx)(style_1.default, { id: RichTextConverter_1.LIST_STYLES_ID, children: listStyles }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: `${reactId}-table-${block.id}`, children: [rangeStyles, `
|
|
58
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `structured-table-box-${block.id}`, children: (0, jsx_runtime_1.jsxs)("table", { ref: setRef, className: `structured-table-${block.id}`, children: [(0, jsx_runtime_1.jsx)("colgroup", { children: header.map((_, col) => (0, jsx_runtime_1.jsx)("col", {}, col)) }), (0, jsx_runtime_1.jsx)("thead", { className: `structured-table-heading-${block.id}`, children: (0, jsx_runtime_1.jsx)("tr", { children: header.map(cell => (0, jsx_runtime_1.jsx)(Heading, { children: cellContent(cell) }, cell.id)) }) }), (0, jsx_runtime_1.jsx)("tbody", { className: `structured-table-body-${block.id}`, children: rows.map((row, index) => { var _a, _b; return (0, jsx_runtime_1.jsx)("tr", { children: row.map(cell => (0, jsx_runtime_1.jsx)("td", { children: cellContent(cell) }, cell.id)) }, (_b = (_a = row[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : index); }) })] }) }), listStyles && (0, jsx_runtime_1.jsx)(style_1.default, { id: RichTextConverter_1.LIST_STYLES_ID, children: listStyles }), (0, jsx_runtime_1.jsxs)(style_1.default, { id: `${reactId}-table-${block.id}`, children: [rangeStyles, `
|
|
57
59
|
${table} {
|
|
58
60
|
width: 100%;
|
|
59
61
|
table-layout: fixed;
|
|
@@ -69,14 +71,14 @@ const StructuredTable = ({ block }) => {
|
|
|
69
71
|
overflow-wrap: anywhere;
|
|
70
72
|
}
|
|
71
73
|
${(0, sdk_1.getLayoutStyles)(layouts, [block.layoutParams], ([layoutParams], exemplary) => {
|
|
72
|
-
const
|
|
73
|
-
const border = vw(BORDER_PX / exemplary);
|
|
74
|
+
const border = (0, vw_1.vw)(BORDER_PX / exemplary);
|
|
74
75
|
const fill = (selector, color) => (color ? (0, textStylesRule_1.colorRule)(selector, 'background-color', color) : '');
|
|
75
76
|
return (`
|
|
77
|
+
${(0, textStylesRule_1.boxRule)(box, layoutParams)}
|
|
76
78
|
${(0, textStylesRule_1.textStylesRule)(table, layoutParams)}
|
|
77
79
|
${cells} {
|
|
78
|
-
padding-top: ${vw(layoutParams.cellPaddingTop)};
|
|
79
|
-
padding-bottom: ${vw(layoutParams.cellPaddingBottom)};
|
|
80
|
+
padding-top: ${(0, vw_1.vw)(layoutParams.cellPaddingTop)};
|
|
81
|
+
padding-bottom: ${(0, vw_1.vw)(layoutParams.cellPaddingBottom)};
|
|
80
82
|
border-width: ${kind === 'lines' ? '0' : border};
|
|
81
83
|
}
|
|
82
84
|
${kind === 'lines' ? `${table} tbody > tr > th, ${table} tbody > tr > td { border-top-width: ${border}; }` : ''}
|
|
@@ -85,8 +87,8 @@ const StructuredTable = ({ block }) => {
|
|
|
85
87
|
width: ${column.width * 100}%;
|
|
86
88
|
}
|
|
87
89
|
${table} th:nth-child(${index + 1}), ${table} td:nth-child(${index + 1}) {
|
|
88
|
-
padding-left: ${vw(column.paddingLeft)};
|
|
89
|
-
padding-right: ${vw(column.paddingRight)};
|
|
90
|
+
padding-left: ${(0, vw_1.vw)(column.paddingLeft)};
|
|
91
|
+
padding-right: ${(0, vw_1.vw)(column.paddingRight)};
|
|
90
92
|
}
|
|
91
93
|
`).join('')}
|
|
92
94
|
${layoutParams.borderColor ? (0, textStylesRule_1.colorRule)(cells, 'border-color', layoutParams.borderColor) : ''}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colorRule = exports.textColumnsRule = exports.textStylesRule = void 0;
|
|
3
|
+
exports.colorRule = exports.boxRule = exports.textColumnsRule = exports.textStylesRule = void 0;
|
|
4
4
|
const color_1 = require("@cntrl-site/color");
|
|
5
5
|
const sdk_1 = require("@cntrl-site/sdk");
|
|
6
6
|
const getFontFamilyValue_1 = require("../../utils/getFontFamilyValue");
|
|
7
|
+
const vw_1 = require("./vw");
|
|
7
8
|
/** A block's text styles as a CSS rule for `selector`, its lengths in viewport units as the block's own. */
|
|
8
9
|
function textStylesRule(selector, styles) {
|
|
9
10
|
return `
|
|
10
11
|
${selector} {
|
|
11
12
|
font-family: ${(0, getFontFamilyValue_1.getFontFamilyValue)(styles.typeFace)};
|
|
12
|
-
font-size: ${styles.fontSize
|
|
13
|
-
line-height: ${styles.lineHeight
|
|
14
|
-
letter-spacing: ${styles.letterSpacing
|
|
15
|
-
word-spacing: ${styles.wordSpacing
|
|
13
|
+
font-size: ${(0, vw_1.vw)(styles.fontSize)};
|
|
14
|
+
line-height: ${(0, vw_1.vw)(styles.lineHeight)};
|
|
15
|
+
letter-spacing: ${(0, vw_1.vw)(styles.letterSpacing)};
|
|
16
|
+
word-spacing: ${(0, vw_1.vw)(styles.wordSpacing)};
|
|
16
17
|
font-weight: ${styles.fontWeight};
|
|
17
18
|
font-style: ${styles.fontStyle || 'normal'};
|
|
18
19
|
font-variant: ${styles.fontVariant};
|
|
@@ -34,11 +35,28 @@ function textColumnsRule(selector, { columns = 1, columnGap = 0, hyphens = sdk_1
|
|
|
34
35
|
${selector} {
|
|
35
36
|
hyphens: ${hyphens};
|
|
36
37
|
-webkit-hyphens: ${hyphens};
|
|
37
|
-
${columns > 1 ? `column-count: ${columns}; column-gap: ${columnGap
|
|
38
|
+
${columns > 1 ? `column-count: ${columns}; column-gap: ${(0, vw_1.vw)(columnGap)}; column-fill: balance;` : 'column-count: auto; column-gap: normal;'}
|
|
38
39
|
}
|
|
39
40
|
`;
|
|
40
41
|
}
|
|
41
42
|
exports.textColumnsRule = textColumnsRule;
|
|
43
|
+
/**
|
|
44
|
+
* The box a quote's text or a table is drawn in, as a CSS rule for `selector`: padded inside, its
|
|
45
|
+
* sides grown out past the columns the block is placed on by as much as they pad it, so what it
|
|
46
|
+
* holds stays on them; rounded, and filled where it has a fill.
|
|
47
|
+
*/
|
|
48
|
+
function boxRule(selector, box) {
|
|
49
|
+
return `
|
|
50
|
+
${selector} {
|
|
51
|
+
padding: ${[box.boxPaddingTop, box.boxPaddingRight, box.boxPaddingBottom, box.boxPaddingLeft].map(vw_1.vw).join(' ')};
|
|
52
|
+
margin: 0 -${(0, vw_1.vw)(box.boxPaddingRight)} 0 -${(0, vw_1.vw)(box.boxPaddingLeft)};
|
|
53
|
+
border-radius: ${(0, vw_1.vw)(box.boxRadius)};
|
|
54
|
+
background-color: transparent;
|
|
55
|
+
}
|
|
56
|
+
${box.boxBackground ? colorRule(selector, 'background-color', box.boxBackground) : ''}
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
exports.boxRule = boxRule;
|
|
42
60
|
/** A colour of the palette as CSS for `property`, with a fallback where oklch is not supported. */
|
|
43
61
|
function colorRule(selector, property, value) {
|
|
44
62
|
const color = color_1.CntrlColor.parse(value);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vw = void 0;
|
|
4
|
+
/** A share of the layout width as CSS: the layout is the viewport's width, so a share is so many `vw`. */
|
|
5
|
+
function vw(share) {
|
|
6
|
+
return `${(share !== null && share !== void 0 ? share : 0) * 100}vw`;
|
|
7
|
+
}
|
|
8
|
+
exports.vw = vw;
|
|
@@ -26,7 +26,7 @@ const stylesMap = {
|
|
|
26
26
|
[sdk_1.AreaAnchor.BottomRight]: { justifyContent: 'flex-end', alignItems: 'flex-end' }
|
|
27
27
|
};
|
|
28
28
|
const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
30
30
|
const reactId = (0, react_1.useId)();
|
|
31
31
|
const id = `${reactId}-codeembed-${item.id}`;
|
|
32
32
|
const { layouts, fonts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -84,7 +84,7 @@ const CodeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
84
84
|
(0, react_1.useEffect)(() => {
|
|
85
85
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
86
86
|
}, [isInteractive, onVisibilityChange]);
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_h = item.link) === null || _h === void 0 ? void 0 : _h.url, target: (_j = item.link) === null || _j === void 0 ? void 0 : _j.target, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
87
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_h = item.link) === null || _h === void 0 ? void 0 : _h.url, target: (_j = item.link) === null || _j === void 0 ? void 0 : _j.target, download: (_k = item.link) === null || _k === void 0 ? void 0 : _k.download, children: [(0, jsx_runtime_1.jsx)("div", { className: `embed-wrapper-${item.id}`, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), (opacity !== undefined ? { opacity } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_l = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _l !== void 0 ? _l : 'none' }), ref: setRef, children: item.commonParams.iframe ? ((0, jsx_runtime_1.jsx)("iframe", { "data-embed": item.id, className: `embed-${item.id}`, style: Object.assign(Object.assign({}, pos), { border: 'unset' }) })) : ((0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, style: Object.assign({}, pos), dangerouslySetInnerHTML: { __html: html } })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
88
88
|
.embed-wrapper-${item.id} {
|
|
89
89
|
position: absolute;
|
|
90
90
|
width: 100%;
|
|
@@ -19,7 +19,7 @@ const LinkWrapper_1 = require("../LinkWrapper");
|
|
|
19
19
|
const mergeComponentSettings_1 = require("../../../utils/mergeComponentSettings");
|
|
20
20
|
const useComponentElement_1 = require("../../../common/useComponentElement");
|
|
21
21
|
const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23
23
|
const sdk = (0, useCntrlContext_1.useCntrlContext)();
|
|
24
24
|
const { layouts } = sdk;
|
|
25
25
|
const itemAngle = (0, useItemAngle_1.useItemAngle)(item, sectionId);
|
|
@@ -41,12 +41,12 @@ const ComponentItem = ({ item, sectionId, onResize, interactionCtrl }) => {
|
|
|
41
41
|
const commonParameters = item.commonParams.parameters;
|
|
42
42
|
const parameters = layoutParameters ? Object.assign(Object.assign({}, layoutParameters), { settings: (0, mergeComponentSettings_1.mergeComponentSettings)(layoutParameters.settings, commonParameters === null || commonParameters === void 0 ? void 0 : commonParameters.settings) }) : undefined;
|
|
43
43
|
const hasLink = Boolean((_f = item.link) === null || _f === void 0 ? void 0 : _f.url);
|
|
44
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_g = item.link) === null || _g === void 0 ? void 0 : _g.url, target: (_h = item.link) === null || _h === void 0 ? void 0 : _h.target,
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_g = item.link) === null || _g === void 0 ? void 0 : _g.url, target: (_h = item.link) === null || _h === void 0 ? void 0 : _h.target, download: (_j = item.link) === null || _j === void 0 ? void 0 : _j.download,
|
|
45
45
|
// Let the component define its own hit area (e.g. rounded button),
|
|
46
46
|
// so empty space around it does not activate the link.
|
|
47
47
|
style: hasLink ? { pointerEvents: 'none' } : undefined, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", Object.assign({ className: `custom-component-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined
|
|
48
48
|
? { opacity: layout == null || isPending ? 0 : opacity }
|
|
49
|
-
: layout == null || isPending ? { opacity: 0 } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined && blur !== 0 ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
49
|
+
: layout == null || isPending ? { opacity: 0 } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined && blur !== 0 ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_k = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _k !== void 0 ? _k : 'none' }) }, (keepsServerMarkup ? useComponentElement_1.pendingElementProps : {}), { children: keepsServerMarkup ? null : parameters && Element && ((0, jsx_runtime_1.jsx)(Element, Object.assign({ metadata: {
|
|
50
50
|
itemId: item.id,
|
|
51
51
|
submitUrl: sdk.getSubmitUrl(commonParameters === null || commonParameters === void 0 ? void 0 : commonParameters.pluginConfigId)
|
|
52
52
|
}, portalId: "component-portal", content: item.commonParams.content }, parameters, { hasLink: hasLink }))) }), keepsServerMarkup ? 'pending' : 'ready'), (0, jsx_runtime_1.jsx)(style_1.default, { id: item.id, children: `
|
|
@@ -18,7 +18,7 @@ const useCompoundItem_1 = require("./useCompoundItem");
|
|
|
18
18
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
19
19
|
const ItemGeometryContext_1 = require("../../../ItemGeometry/ItemGeometryContext");
|
|
20
20
|
const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
21
|
-
var _a, _b, _c, _d, _e;
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
22
|
const reactId = (0, react_1.useId)();
|
|
23
23
|
const id = `${reactId}-compounditem-${item.id}`;
|
|
24
24
|
const { items } = item;
|
|
@@ -50,7 +50,7 @@ const CompoundItem = ({ item, sectionId, onResize, interactionCtrl, onVisibility
|
|
|
50
50
|
}
|
|
51
51
|
}, 0);
|
|
52
52
|
}, [itemIds, item.id]);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_c = item.link) === null || _c === void 0 ? void 0 : _c.url, target: (_d = item.link) === null || _d === void 0 ? void 0 : _d.target, download: (_e = item.link) === null || _e === void 0 ? void 0 : _e.download, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `compound-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), { transition: (_f = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _f !== void 0 ? _f : 'none' }), children: items && items.map(item => ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
54
54
|
.compound-${item.id} {
|
|
55
55
|
overflow: ${item.commonParams.overflow};
|
|
56
56
|
position: absolute;
|
|
@@ -28,7 +28,7 @@ const useLayoutContext_1 = require("../../useLayoutContext");
|
|
|
28
28
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
29
29
|
const getVimeoEmbedUrl_1 = require("../../../utils/getVimeoEmbedUrl");
|
|
30
30
|
const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
32
32
|
const reactId = (0, react_1.useId)();
|
|
33
33
|
const id = `${reactId}-vimeo-${item.id}`;
|
|
34
34
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -109,7 +109,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
}, [interactionCtrl, vimeoPlayer]);
|
|
112
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
112
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, download: (_g = item.link) === null || _g === void 0 ? void 0 : _g.download, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _h !== void 0 ? _h : 'none' }), onMouseEnter: () => {
|
|
113
113
|
if (!vimeoPlayer || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible)
|
|
114
114
|
return;
|
|
115
115
|
vimeoPlayer.play();
|
|
@@ -122,7 +122,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
122
122
|
return;
|
|
123
123
|
setIsCoverVisible(false);
|
|
124
124
|
vimeoPlayer.play();
|
|
125
|
-
} } : {}), { src: (
|
|
125
|
+
} } : {}), { src: (_j = item.commonParams.coverUrl) !== null && _j !== void 0 ? _j : '', style: {
|
|
126
126
|
display: isCoverVisible ? 'block' : 'none',
|
|
127
127
|
cursor: 'pointer',
|
|
128
128
|
position: 'absolute',
|
|
@@ -137,7 +137,7 @@ const VimeoEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibili
|
|
|
137
137
|
width: '100%',
|
|
138
138
|
top: '0',
|
|
139
139
|
left: '0'
|
|
140
|
-
} })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (
|
|
140
|
+
} })), (0, jsx_runtime_1.jsx)("iframe", { ref: setIframeRef, className: "embed-video", src: validUrl || '', allow: "autoplay; fullscreen; picture-in-picture;", allowFullScreen: true, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_k = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _k !== void 0 ? _k : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
141
141
|
.embed-video-wrapper-${item.id} {
|
|
142
142
|
position: absolute;
|
|
143
143
|
width: 100%;
|
|
@@ -19,7 +19,7 @@ const getStyleFromItemStateAndParams_1 = require("../../../utils/getStyleFromIte
|
|
|
19
19
|
const useLayoutContext_1 = require("../../useLayoutContext");
|
|
20
20
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
21
21
|
const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
23
23
|
const reactId = (0, react_1.useId)();
|
|
24
24
|
const id = `${reactId}-youtube-${item.id}`;
|
|
25
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -117,7 +117,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
}, [interactionCtrl, player]);
|
|
120
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
120
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_e = item.link) === null || _e === void 0 ? void 0 : _e.url, target: (_f = item.link) === null || _f === void 0 ? void 0 : _f.target, download: (_g = item.link) === null || _g === void 0 ? void 0 : _g.download, children: [(0, jsx_runtime_1.jsxs)("div", { className: `embed-youtube-video-wrapper-${item.id}`, onMouseEnter: () => {
|
|
121
121
|
if (!player || !layoutParams || layoutParams.play !== 'on-hover' || isCoverVisible)
|
|
122
122
|
return;
|
|
123
123
|
player.playVideo();
|
|
@@ -125,12 +125,12 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
125
125
|
if (!player || !layoutParams || layoutParams.play !== 'on-hover')
|
|
126
126
|
return;
|
|
127
127
|
player.pauseVideo();
|
|
128
|
-
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
128
|
+
}, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_h = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _h !== void 0 ? _h : 'none' }), children: [item.commonParams.coverUrl && ((0, jsx_runtime_1.jsx)("img", Object.assign({ ref: setImgRef }, ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-click' ? { onClick: () => onCoverClick() } : {}), ((layoutParams === null || layoutParams === void 0 ? void 0 : layoutParams.play) === 'on-hover' ? { onMouseEnter: () => {
|
|
129
129
|
if (!player || !layoutParams || layoutParams.play !== 'on-hover')
|
|
130
130
|
return;
|
|
131
131
|
setIsCoverVisible(false);
|
|
132
132
|
player.playVideo();
|
|
133
|
-
} } : {}), { src: (
|
|
133
|
+
} } : {}), { src: (_j = item.commonParams.coverUrl) !== null && _j !== void 0 ? _j : '', style: {
|
|
134
134
|
display: isCoverVisible ? 'block' : 'none',
|
|
135
135
|
cursor: 'pointer',
|
|
136
136
|
position: 'absolute',
|
|
@@ -140,7 +140,7 @@ const YoutubeEmbedItem = ({ item, sectionId, onResize, interactionCtrl, onVisibi
|
|
|
140
140
|
top: '0',
|
|
141
141
|
left: '0',
|
|
142
142
|
zIndex: 1
|
|
143
|
-
}, alt: "Cover img" }))), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (
|
|
143
|
+
}, alt: "Cover img" }))), (0, jsx_runtime_1.jsx)("div", { className: `embed-${item.id}`, ref: setDiv, style: Object.assign(Object.assign({}, (radius !== undefined ? { borderRadius: `${radius * 100}vw` } : {})), { transition: (_k = frameStateParams === null || frameStateParams === void 0 ? void 0 : frameStateParams.transition) !== null && _k !== void 0 ? _k : 'none' }) })] }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
144
144
|
.embed-youtube-video-wrapper-${item.id},
|
|
145
145
|
.embed-${item.id} {
|
|
146
146
|
position: absolute;
|
|
@@ -21,7 +21,7 @@ const useItemFXData_1 = require("../../../common/useItemFXData");
|
|
|
21
21
|
const getFill_1 = require("../../../utils/getFill");
|
|
22
22
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
23
23
|
const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
24
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
25
25
|
const reactId = (0, react_1.useId)();
|
|
26
26
|
const id = `${reactId}-image-${item.id}`;
|
|
27
27
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -73,7 +73,7 @@ const ImageItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
73
73
|
(0, react_1.useEffect)(() => {
|
|
74
74
|
onVisibilityChange === null || onVisibilityChange === void 0 ? void 0 : onVisibilityChange(isInteractive);
|
|
75
75
|
}, [isInteractive, onVisibilityChange]);
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_p = item.link) === null || _p === void 0 ? void 0 : _p.url, target: (_q = item.link) === null || _q === void 0 ? void 0 : _q.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_p = item.link) === null || _p === void 0 ? void 0 : _p.url, target: (_q = item.link) === null || _q === void 0 ? void 0 : _q.target, download: (_r = item.link) === null || _r === void 0 ? void 0 : _r.download, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `image-wrapper-${item.id}`, ref: setWrapperRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_s = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _s !== void 0 ? _s : 'none' }), children: hasGLEffect && isFXAllowed
|
|
77
77
|
? ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `img-canvas image-${item.id}`, width: rectWidth, height: rectHeight, role: "img", "aria-label": altText }))
|
|
78
78
|
: ((0, jsx_runtime_1.jsx)("img", { alt: altText, className: `image image-${item.id}`, style: inlineStyles, src: item.commonParams.url })) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
79
79
|
.image-wrapper-${item.id} {
|
|
@@ -23,7 +23,7 @@ const getFill_1 = require("../../../utils/getFill");
|
|
|
23
23
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
24
24
|
const useLazyVideo_1 = require("../../../common/useLazyVideo");
|
|
25
25
|
const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
27
27
|
const reactId = (0, react_1.useId)();
|
|
28
28
|
const id = `${reactId}-video-${item.id}`;
|
|
29
29
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -103,7 +103,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
103
103
|
observer.observe(ref);
|
|
104
104
|
return () => observer.disconnect();
|
|
105
105
|
}, [layoutParams, videoRef, ref, userPaused, isVideoInteracted]);
|
|
106
|
-
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_q = item.link) === null || _q === void 0 ? void 0 : _q.url, target: (_r = item.link) === null || _r === void 0 ? void 0 : _r.target, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (
|
|
106
|
+
return ((0, jsx_runtime_1.jsxs)(LinkWrapper_1.LinkWrapper, { url: (_q = item.link) === null || _q === void 0 ? void 0 : _q.url, target: (_r = item.link) === null || _r === void 0 ? void 0 : _r.target, download: (_s = item.link) === null || _s === void 0 ? void 0 : _s.download, children: [(0, jsx_runtime_1.jsxs)("div", { className: `video-wrapper-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset', transition: (_t = wrapperStateParams === null || wrapperStateParams === void 0 ? void 0 : wrapperStateParams.transition) !== null && _t !== void 0 ? _t : 'none' }), children: [hasScrollPlayback && ((0, jsx_runtime_1.jsx)(ScrollPlaybackVideo_1.ScrollPlaybackVideo, { sectionId: sectionId, src: item.commonParams.url, playbackParams: scrollPlayback, style: inlineStyles, className: `video video-playback-wrapper video-${item.id}`, scrollPlaybackFrameData: item.commonParams.scrollPlaybackFrameData, frameBaseUrl: (_u = item.commonParams.scrollPlaybackFrameData) === null || _u === void 0 ? void 0 : _u.framesUrl })), hasGLEffect && isFXAllowed && ((0, jsx_runtime_1.jsx)("canvas", { style: inlineStyles, ref: fxCanvas, className: `video-canvas video-${item.id}`, width: rectWidth, height: rectHeight })), !hasScrollPlayback && !hasGLEffect && layoutParams && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("video", { poster: (_v = item.commonParams.coverUrl) !== null && _v !== void 0 ? _v : '', ref: setVideoRef, preload: "none", onClick: () => {
|
|
107
107
|
setIsVideoInteracted(true);
|
|
108
108
|
}, muted: layoutParams.muted, onPlay: () => {
|
|
109
109
|
setIsVideoPlaying(true);
|
|
@@ -126,7 +126,7 @@ const VideoItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
126
126
|
return;
|
|
127
127
|
setIsVideoInteracted(true);
|
|
128
128
|
videoRef.play();
|
|
129
|
-
}, src: (
|
|
129
|
+
}, src: (_w = item.commonParams.coverUrl) !== null && _w !== void 0 ? _w : '', className: `video-cover-${item.id}`, onClick: () => {
|
|
130
130
|
if (!videoRef)
|
|
131
131
|
return;
|
|
132
132
|
setIsVideoInteracted(true);
|
|
@@ -19,7 +19,7 @@ const CompoundChild_1 = require("../CompoundItem/CompoundChild");
|
|
|
19
19
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
20
20
|
const ItemGeometryContext_1 = require("../../../ItemGeometry/ItemGeometryContext");
|
|
21
21
|
const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange, isInCompound }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
23
23
|
const reactId = (0, react_1.useId)();
|
|
24
24
|
const id = `${reactId}-group-${item.id}`;
|
|
25
25
|
const { items } = item;
|
|
@@ -52,7 +52,7 @@ const GroupItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityCha
|
|
|
52
52
|
}
|
|
53
53
|
}, 0);
|
|
54
54
|
}, [itemIds, item.id]);
|
|
55
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_d = item.link) === null || _d === void 0 ? void 0 : _d.url, target: (_e = item.link) === null || _e === void 0 ? void 0 : _e.target, download: (_f = item.link) === null || _f === void 0 ? void 0 : _f.download, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `group-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign({}, (opacity !== undefined ? { opacity } : {})), (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { transition: (_g = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _g !== void 0 ? _g : 'none', willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), children: items && items.map(item => isInCompound ? ((0, jsx_runtime_1.jsx)(CompoundChild_1.CompoundChild, { item: item, sectionId: sectionId, isParentVisible: isInteractive }, item.id)) : ((0, jsx_runtime_1.jsx)(Item_1.Item, { item: item, sectionId: sectionId, isParentVisible: isInteractive, isInGroup: true }, item.id))) }), (0, jsx_runtime_1.jsx)(style_1.default, { id: id, children: `
|
|
56
56
|
.group-${item.id} {
|
|
57
57
|
position: absolute;
|
|
58
58
|
width: 100%;
|
|
@@ -2,17 +2,49 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LinkWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const LinkWrapper = ({ url, children, target, style }) => {
|
|
5
|
+
const LinkWrapper = ({ url, children, target, download, style }) => {
|
|
6
6
|
const validUrl = url && buildValidUrl(url);
|
|
7
7
|
const targetParams = target === '_blank' ? { target, rel: 'noreferrer' } : {};
|
|
8
|
+
if (url && validUrl && download !== undefined) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)("a", { href: validUrl, style: style, download: download, onClick: (event) => downloadFile(event, validUrl, download), children: children }));
|
|
10
|
+
}
|
|
8
11
|
return url ? ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: validUrl, style: style }, targetParams, { children: children }))) : ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }));
|
|
9
12
|
};
|
|
10
13
|
exports.LinkWrapper = LinkWrapper;
|
|
14
|
+
function downloadFile(event, url, name) {
|
|
15
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
|
|
16
|
+
return;
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
fetch(url)
|
|
19
|
+
.then((response) => {
|
|
20
|
+
if (!response.ok)
|
|
21
|
+
throw new Error(`Could not download ${url}: ${response.status}`);
|
|
22
|
+
return response.blob();
|
|
23
|
+
})
|
|
24
|
+
.then((blob) => {
|
|
25
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
26
|
+
const link = document.createElement('a');
|
|
27
|
+
link.href = objectUrl;
|
|
28
|
+
link.download = name || fileNameOf(url);
|
|
29
|
+
document.body.appendChild(link);
|
|
30
|
+
link.click();
|
|
31
|
+
link.remove();
|
|
32
|
+
window.setTimeout(() => URL.revokeObjectURL(objectUrl), 0);
|
|
33
|
+
})
|
|
34
|
+
.catch(() => {
|
|
35
|
+
window.location.assign(url);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function fileNameOf(url) {
|
|
39
|
+
var _a;
|
|
40
|
+
return decodeURIComponent((_a = url.split('?')[0].split('/').pop()) !== null && _a !== void 0 ? _a : '');
|
|
41
|
+
}
|
|
11
42
|
function buildValidUrl(url) {
|
|
12
43
|
const prefixes = [
|
|
13
44
|
'http://',
|
|
14
45
|
'https://',
|
|
15
46
|
'/',
|
|
47
|
+
'./',
|
|
16
48
|
'mailto:',
|
|
17
49
|
'tel:',
|
|
18
50
|
'file:',
|
|
@@ -19,7 +19,7 @@ const getFill_1 = require("../../../utils/getFill");
|
|
|
19
19
|
const areFillsVisible_1 = require("../../../utils/areFillsVisible/areFillsVisible");
|
|
20
20
|
const useItemGeometry_1 = require("../../../ItemGeometry/useItemGeometry");
|
|
21
21
|
const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilityChange }) => {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
23
23
|
const reactId = (0, react_1.useId)();
|
|
24
24
|
const id = `${reactId}-rect-${item.id}`;
|
|
25
25
|
const { layouts } = (0, useCntrlContext_1.useCntrlContext)();
|
|
@@ -49,9 +49,9 @@ const RectangleItem = ({ item, sectionId, onResize, interactionCtrl, onVisibilit
|
|
|
49
49
|
const stroke = strokeFill
|
|
50
50
|
? (_k = (0, getFill_1.getFill)(strokeFill)) !== null && _k !== void 0 ? _k : 'transparent'
|
|
51
51
|
: 'transparent';
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.target, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { url: (_l = item.link) === null || _l === void 0 ? void 0 : _l.url, target: (_m = item.link) === null || _m === void 0 ? void 0 : _m.target, download: (_o = item.link) === null || _o === void 0 ? void 0 : _o.download, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: `rectangle-${item.id}`, ref: setRef, style: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (angle !== undefined ? { transform: `rotate(${angle}deg)` } : {})), (blur !== undefined ? { filter: `blur(${blur * 100}vw)` } : {})), { willChange: blur !== 0 && blur !== undefined ? 'transform' : 'unset' }), (backdropFilterValue !== undefined
|
|
53
53
|
? { backdropFilter: backdropFilterValue, WebkitBackdropFilter: backdropFilterValue }
|
|
54
|
-
: {})), { transition: (
|
|
54
|
+
: {})), { transition: (_p = stateParams === null || stateParams === void 0 ? void 0 : stateParams.transition) !== null && _p !== void 0 ? _p : 'none' }), children: itemFill && itemFill.map((fill, index) => {
|
|
55
55
|
var _a, _b;
|
|
56
56
|
const stateFillLayer = stateFillLayers === null || stateFillLayers === void 0 ? void 0 : stateFillLayers.find((layer) => layer.id === fill.id);
|
|
57
57
|
const value = stateFillLayer
|