@raketa-builder/support 1.3.3 → 1.3.5
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/AdminPageRender/AdminWidgetMinimal.js +118 -0
- package/dist/AdminPageRender/IconButton.js +49 -0
- package/dist/AdminPageRender/index.js +118 -0
- package/dist/Container.js +45 -0
- package/dist/EmbeddedVideo.js +131 -0
- package/dist/Image.js +132 -0
- package/dist/WidgetRender/index.js +67 -0
- package/{src → dist}/extractImageValue.js +4 -2
- package/dist/imagePlaceholder.js +8 -0
- package/{src → dist}/imageSrc.js +5 -8
- package/dist/index.js +68 -0
- package/{src → dist}/isImagePresent.js +4 -7
- package/dist/lib/SelectedWidgetsToolbar.js +56 -0
- package/dist/toHTML.js +27 -0
- package/package.json +23 -6
- package/CHANGELOG.md +0 -7
- package/biome.json +0 -3
- package/src/AdminPageRender/AdminWidgetMinimal.js +0 -101
- package/src/AdminPageRender/IconButton.js +0 -31
- package/src/AdminPageRender/index.js +0 -113
- package/src/Container.js +0 -15
- package/src/EmbeddedVideo.js +0 -150
- package/src/Image.js +0 -130
- package/src/WidgetRender/index.js +0 -47
- package/src/imagePlaceholder.js +0 -5
- package/src/index.js +0 -23
- package/src/lib/SelectedWidgetsToolbar.js +0 -48
- package/src/toHTML.js +0 -19
- package/tsconfig.json +0 -5
- package/tsup.config.js +0 -12
package/src/Image.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
const getWebp = (url) => {
|
|
4
|
-
if (!url) return null;
|
|
5
|
-
|
|
6
|
-
const segments = url.split(".");
|
|
7
|
-
segments[segments.length - 1] = "webp";
|
|
8
|
-
|
|
9
|
-
return segments.join(".");
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const getAvif = (url) => {
|
|
13
|
-
if (!url) return null;
|
|
14
|
-
|
|
15
|
-
const segments = url.split(".");
|
|
16
|
-
segments[segments.length - 1] = "avif";
|
|
17
|
-
|
|
18
|
-
return segments.join(".");
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const getDimensions = (src, variant) => {
|
|
22
|
-
if (typeof src === "object" && src?.name?.includes(".svg")) {
|
|
23
|
-
const width = src.width || null;
|
|
24
|
-
const height = src.height || null;
|
|
25
|
-
|
|
26
|
-
return [width, height];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof src === "object") {
|
|
30
|
-
const width = src.sizes[variant]?.width || null;
|
|
31
|
-
const height = src.sizes[variant]?.height || null;
|
|
32
|
-
|
|
33
|
-
return [width, height];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return [null, null];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getAlt = (src) => {
|
|
40
|
-
const type = typeof src;
|
|
41
|
-
|
|
42
|
-
if (type === "object" && src.alt) {
|
|
43
|
-
return src.alt;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (type === "object") {
|
|
47
|
-
const imageObj = src.image || src;
|
|
48
|
-
|
|
49
|
-
const altSetting = (imageObj?.settings || []).find(
|
|
50
|
-
(setting) => setting.key === "alt"
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
if (altSetting) {
|
|
54
|
-
return altSetting.value;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return "";
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const getSrc = (src, variant) => {
|
|
62
|
-
if (typeof src === "object") {
|
|
63
|
-
if (src?.name?.includes(".svg") || src?.name?.includes(".gif")) {
|
|
64
|
-
return [null, null, src.urls?.original];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const fallback = src.urls[variant];
|
|
68
|
-
const webp = getWebp(fallback);
|
|
69
|
-
const avif = getAvif(fallback);
|
|
70
|
-
|
|
71
|
-
return [webp, avif, fallback];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return [null, null, src];
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const getImageObjOrSrc = (value) => {
|
|
78
|
-
const type = typeof value;
|
|
79
|
-
|
|
80
|
-
if (type === "object" && value.hasOwnProperty("image")) {
|
|
81
|
-
return value.image;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return value;
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const Image = ({ variant, src, alt, loading = "lazy", ...props }) => {
|
|
88
|
-
if (!variant) {
|
|
89
|
-
console.error("Image with no variant", { variant, src, alt, props });
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!src) {
|
|
94
|
-
console.error("Image with no src", { variant, src, alt, props });
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const imageObjOrSrc = getImageObjOrSrc(src);
|
|
99
|
-
|
|
100
|
-
if (
|
|
101
|
-
imageObjOrSrc &&
|
|
102
|
-
typeof imageObjOrSrc === "object" &&
|
|
103
|
-
!imageObjOrSrc.sizes
|
|
104
|
-
) {
|
|
105
|
-
console.error("Image with no sizes", { variant, src, alt, props });
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const [width, height] = getDimensions(imageObjOrSrc, variant);
|
|
110
|
-
const altAttr = alt || getAlt(src);
|
|
111
|
-
const [webp, avif, fallback] = getSrc(imageObjOrSrc, variant);
|
|
112
|
-
|
|
113
|
-
return (
|
|
114
|
-
<picture>
|
|
115
|
-
{avif && <source srcSet={encodeURI(avif)} type="image/avif" />}
|
|
116
|
-
{webp && <source srcSet={encodeURI(webp)} type="image/webp" />}
|
|
117
|
-
<source srcSet={encodeURI(fallback)} type={src.mime_type} />
|
|
118
|
-
<img
|
|
119
|
-
src={fallback}
|
|
120
|
-
alt={altAttr}
|
|
121
|
-
width={width}
|
|
122
|
-
height={height}
|
|
123
|
-
loading={loading}
|
|
124
|
-
{...props}
|
|
125
|
-
/>
|
|
126
|
-
</picture>
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export default Image;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Container from "../Container";
|
|
3
|
-
|
|
4
|
-
const WidgetRender = ({
|
|
5
|
-
library,
|
|
6
|
-
entity,
|
|
7
|
-
page,
|
|
8
|
-
context = {},
|
|
9
|
-
preloaded = {},
|
|
10
|
-
locale = "es",
|
|
11
|
-
}) => {
|
|
12
|
-
const pageData = page || entity;
|
|
13
|
-
|
|
14
|
-
context = {
|
|
15
|
-
...context,
|
|
16
|
-
locale: context.locale ?? locale,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<>
|
|
21
|
-
{pageData.widgets.map(({ widgetId, component, settings }) => {
|
|
22
|
-
if (!library[component]) {
|
|
23
|
-
console.error(
|
|
24
|
-
`Unknown widget: {widgetId: ${widgetId}, component: ${component}, settings: ${settings}}`
|
|
25
|
-
);
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<Container
|
|
31
|
-
key={widgetId}
|
|
32
|
-
settings={settings?.containerSettings || {}}
|
|
33
|
-
data-widget={component}
|
|
34
|
-
>
|
|
35
|
-
{React.createElement(library[component], {
|
|
36
|
-
...settings,
|
|
37
|
-
__ctx: context,
|
|
38
|
-
__data: preloaded?.[widgetId] || {},
|
|
39
|
-
})}
|
|
40
|
-
</Container>
|
|
41
|
-
);
|
|
42
|
-
})}
|
|
43
|
-
</>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default WidgetRender;
|
package/src/imagePlaceholder.js
DELETED
package/src/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Image from "./Image";
|
|
2
|
-
import imageSrc from "./imageSrc";
|
|
3
|
-
import imagePlaceholder from "./imagePlaceholder";
|
|
4
|
-
import Container from "./Container";
|
|
5
|
-
import EmbeddedVideo from "./EmbeddedVideo";
|
|
6
|
-
import toHTML from "./toHTML";
|
|
7
|
-
import isImagePresent from "./isImagePresent";
|
|
8
|
-
import AdminPageRender from "./AdminPageRender";
|
|
9
|
-
import WidgetRender from "./WidgetRender";
|
|
10
|
-
import extractImageValue from "./extractImageValue";
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
Image,
|
|
14
|
-
imageSrc,
|
|
15
|
-
imagePlaceholder,
|
|
16
|
-
isImagePresent,
|
|
17
|
-
extractImageValue,
|
|
18
|
-
Container,
|
|
19
|
-
EmbeddedVideo,
|
|
20
|
-
toHTML,
|
|
21
|
-
AdminPageRender,
|
|
22
|
-
WidgetRender,
|
|
23
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const IconCopy = () => (
|
|
2
|
-
<svg
|
|
3
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
4
|
-
width="16"
|
|
5
|
-
height="16"
|
|
6
|
-
viewBox="0 0 16 16"
|
|
7
|
-
fill="none"
|
|
8
|
-
>
|
|
9
|
-
<g clipPath="url(#clip0_2312_498)">
|
|
10
|
-
<path
|
|
11
|
-
d="M13.3334 5.33331H6.66671C5.93033 5.33331 5.33337 5.93027 5.33337 6.66665V13.3333C5.33337 14.0697 5.93033 14.6666 6.66671 14.6666H13.3334C14.0698 14.6666 14.6667 14.0697 14.6667 13.3333V6.66665C14.6667 5.93027 14.0698 5.33331 13.3334 5.33331Z"
|
|
12
|
-
stroke="white"
|
|
13
|
-
strokeWidth="2"
|
|
14
|
-
strokeLinecap="round"
|
|
15
|
-
strokeLinejoin="round"
|
|
16
|
-
/>
|
|
17
|
-
<path
|
|
18
|
-
d="M2.66671 10.6666C1.93337 10.6666 1.33337 10.0666 1.33337 9.33331V2.66665C1.33337 1.93331 1.93337 1.33331 2.66671 1.33331H9.33337C10.0667 1.33331 10.6667 1.93331 10.6667 2.66665"
|
|
19
|
-
stroke="white"
|
|
20
|
-
strokeWidth="2"
|
|
21
|
-
strokeLinecap="round"
|
|
22
|
-
strokeLinejoin="round"
|
|
23
|
-
/>
|
|
24
|
-
</g>
|
|
25
|
-
<defs>
|
|
26
|
-
<clipPath id="clip0_2312_498">
|
|
27
|
-
<rect width="16" height="16" fill="white" />
|
|
28
|
-
</clipPath>
|
|
29
|
-
</defs>
|
|
30
|
-
</svg>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
const SelectedWidgetsToolbar = ({ length, onCopy }) => (
|
|
34
|
-
<div className="r-selected-widgets-toolbar">
|
|
35
|
-
<div className="r-toolbar-inner">
|
|
36
|
-
<button
|
|
37
|
-
type="button"
|
|
38
|
-
className="r-button-reset r-toolbar-button"
|
|
39
|
-
onClick={onCopy}
|
|
40
|
-
>
|
|
41
|
-
<IconCopy />
|
|
42
|
-
Copy selected ({length})
|
|
43
|
-
</button>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
export default SelectedWidgetsToolbar;
|
package/src/toHTML.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import MarkdownIt from "markdown-it";
|
|
2
|
-
import markdownItAttrs from "markdown-it-attrs";
|
|
3
|
-
|
|
4
|
-
const parser = new MarkdownIt({
|
|
5
|
-
html: true,
|
|
6
|
-
breaks: true,
|
|
7
|
-
}).use(markdownItAttrs, {
|
|
8
|
-
// optional, these are default options
|
|
9
|
-
leftDelimiter: "{",
|
|
10
|
-
rightDelimiter: "}",
|
|
11
|
-
allowedAttributes: [], // empty array = all attributes are allowed
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const toHTML = (string, inline = false) => {
|
|
15
|
-
if (!string) return;
|
|
16
|
-
return inline ? parser.renderInline(string) : parser.render(string);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default toHTML;
|
package/tsconfig.json
DELETED