lib-pixelbuild 0.2.1 → 0.2.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.
- package/dist/builders/PageBuilder.js +42 -26
- package/dist/components/ButtonsComponent.d.ts +5 -0
- package/dist/components/ButtonsComponent.js +45 -0
- package/dist/components/CardComponent.js +31 -6
- package/dist/components/FormComponent.js +9 -4
- package/dist/components/{CarouselComponent.d.ts → IconComponent.d.ts} +3 -2
- package/dist/components/IconComponent.js +12 -0
- package/dist/components/ImageComponent.d.ts +5 -0
- package/dist/components/ImageComponent.js +18 -0
- package/dist/components/ListComponent.js +5 -2
- package/dist/components/LoadingComponent.js +2 -2
- package/dist/components/MapComponent.js +11 -12
- package/dist/components/SliderComponent.d.ts +0 -1
- package/dist/components/SliderComponent.js +173 -93
- package/dist/components/SocialIconsComponent.d.ts +3 -2
- package/dist/components/SocialIconsComponent.js +20 -16
- package/dist/components/TextComponent.js +5 -3
- package/dist/constants/ComponentEnum.d.ts +2 -0
- package/dist/constants/ComponentEnum.js +2 -0
- package/dist/designSystem/baseCss.d.ts +8 -0
- package/dist/designSystem/baseCss.js +406 -0
- package/dist/designSystem/buildSiteCss.d.ts +8 -0
- package/dist/designSystem/buildSiteCss.js +11 -0
- package/dist/designSystem/index.d.ts +6 -0
- package/dist/designSystem/index.js +5 -0
- package/dist/designSystem/theme.d.ts +9 -0
- package/dist/designSystem/theme.js +11 -0
- package/dist/designSystem/themeVars.d.ts +8 -0
- package/dist/designSystem/themeVars.js +9 -0
- package/dist/designSystem/tokens.d.ts +82 -0
- package/dist/designSystem/tokens.js +144 -0
- package/dist/elements/AlertElement.js +4 -4
- package/dist/elements/ButtonElement.js +21 -7
- package/dist/elements/ElementColWrapper.js +11 -2
- package/dist/elements/IconElement.js +5 -5
- package/dist/elements/IconMap.js +101 -28
- package/dist/elements/InputElement.js +10 -9
- package/dist/elements/TextElement.js +5 -1
- package/dist/factories/ButtonActionFactory.d.ts +3 -4
- package/dist/factories/ButtonActionFactory.js +2 -2
- package/dist/factories/ComponentFactory.d.ts +2 -1
- package/dist/factories/ComponentFactory.js +29 -12
- package/dist/index.d.ts +20 -5
- package/dist/index.js +15 -1
- package/dist/layouts/Footer.js +13 -2
- package/dist/layouts/Header.js +43 -16
- package/dist/layouts/SiteLayout.d.ts +8 -1
- package/dist/layouts/SiteLayout.js +36 -3
- package/dist/renderers/BlockRenderer.d.ts +8 -0
- package/dist/renderers/BlockRenderer.js +68 -0
- package/dist/services/EmailService.d.ts +14 -5
- package/dist/services/EmailService.js +21 -24
- package/dist/stores/UseFormStore.d.ts +7 -2
- package/dist/stores/UseFormStore.js +8 -3
- package/dist/types/{SectionColumnType.d.ts → BlockType.d.ts} +2 -6
- package/dist/types/ComponentType.d.ts +3 -0
- package/dist/types/ElementType.d.ts +1 -0
- package/dist/types/EmailSettingsType.d.ts +5 -0
- package/dist/types/HeaderPropertiesType.d.ts +1 -0
- package/dist/types/MailBodyType.d.ts +2 -0
- package/dist/types/PageType.d.ts +2 -2
- package/dist/types/SocialPropertiesType.d.ts +3 -11
- package/dist/types/StylesType.d.ts +12 -0
- package/dist/types/WebsitePropertiesType.d.ts +2 -0
- package/dist/types/WebsiteType.d.ts +6 -0
- package/dist/ui/PbAlert.d.ts +10 -0
- package/dist/ui/PbAlert.js +8 -0
- package/dist/ui/PbButton.d.ts +20 -0
- package/dist/ui/PbButton.js +20 -0
- package/dist/ui/PbCol.d.ts +14 -0
- package/dist/ui/PbCol.js +43 -0
- package/dist/ui/PbContainer.d.ts +7 -0
- package/dist/ui/PbContainer.js +17 -0
- package/dist/ui/PbRow.d.ts +7 -0
- package/dist/ui/PbRow.js +17 -0
- package/dist/ui/PbSpinner.d.ts +3 -0
- package/dist/ui/PbSpinner.js +5 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +6 -0
- package/dist/utils/emailTemplate.d.ts +7 -0
- package/dist/utils/emailTemplate.js +66 -0
- package/dist/utils/fonts.d.ts +2 -0
- package/dist/utils/fonts.js +10 -0
- package/dist/utils/imageCustomization.d.ts +3 -0
- package/dist/utils/imageCustomization.js +9 -0
- package/dist/utils/responsiveProperties.d.ts +2 -0
- package/dist/utils/responsiveProperties.js +28 -0
- package/dist/utils/responsiveStyles.d.ts +6 -0
- package/dist/utils/responsiveStyles.js +73 -0
- package/package.json +1 -8
- package/dist/components/CarouselComponent.js +0 -6
- package/dist/layouts/Menu.d.ts +0 -5
- package/dist/layouts/Menu.js +0 -34
- package/dist/renderers/SectionRenderer.d.ts +0 -6
- package/dist/renderers/SectionRenderer.js +0 -73
- package/dist/types/SectionType.d.ts +0 -10
- /package/dist/types/{SectionColumnType.js → BlockType.js} +0 -0
- /package/dist/types/{SectionType.js → EmailSettingsType.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Botão próprio do design system. Substitui o `Button` do react-bootstrap,
|
|
4
|
+
* mantendo o comportamento de link (`href`) e botão de formulário.
|
|
5
|
+
*/
|
|
6
|
+
export function PbButton({ as, href, target, rel, type, variant = 'primary', size, disabled, onClick, className, style, children }) {
|
|
7
|
+
const isAnchor = Boolean(href) || as === 'a';
|
|
8
|
+
const classes = [
|
|
9
|
+
'pb-button',
|
|
10
|
+
variant ? `pb-button-${variant}` : 'pb-button-primary',
|
|
11
|
+
size ? `pb-button-${size}` : '',
|
|
12
|
+
className || ''
|
|
13
|
+
]
|
|
14
|
+
.filter(Boolean)
|
|
15
|
+
.join(' ');
|
|
16
|
+
if (isAnchor) {
|
|
17
|
+
return (_jsx("a", { href: href, target: target, rel: rel || 'noopener noreferrer', className: classes, style: style, onClick: onClick, children: children }));
|
|
18
|
+
}
|
|
19
|
+
return (_jsx("button", { type: type || 'button', disabled: disabled, className: classes, style: style, onClick: onClick, children: children }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import type { ColumnWidthType } from '../types/ColumnWidthType.js';
|
|
3
|
+
/**
|
|
4
|
+
* Célula do grid de 12 colunas. Responde por breakpoint gerando um `<style>`
|
|
5
|
+
* próprio quando `width`/`offset` variam entre dispositivos.
|
|
6
|
+
*/
|
|
7
|
+
export declare function PbCol({ colId, width, offset, style, className, children, ...rest }: {
|
|
8
|
+
readonly colId?: number | string;
|
|
9
|
+
readonly width?: ColumnWidthType;
|
|
10
|
+
readonly offset?: ColumnWidthType;
|
|
11
|
+
readonly style?: CSSProperties;
|
|
12
|
+
readonly className?: string;
|
|
13
|
+
readonly children?: ReactNode;
|
|
14
|
+
} & Record<string, unknown>): import("react").JSX.Element;
|
package/dist/ui/PbCol.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
const BREAKPOINTS = [
|
|
14
|
+
{ key: 'sm', min: 576 },
|
|
15
|
+
{ key: 'md', min: 768 },
|
|
16
|
+
{ key: 'lg', min: 992 },
|
|
17
|
+
{ key: 'xl', min: 1200 }
|
|
18
|
+
];
|
|
19
|
+
function gridColumn(span, offset) {
|
|
20
|
+
const start = offset && offset > 0 ? offset + 1 : undefined;
|
|
21
|
+
return start ? `${start} / span ${span}` : `span ${span}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Célula do grid de 12 colunas. Responde por breakpoint gerando um `<style>`
|
|
25
|
+
* próprio quando `width`/`offset` variam entre dispositivos.
|
|
26
|
+
*/
|
|
27
|
+
export function PbCol(_a) {
|
|
28
|
+
var { colId, width, offset, style, className, children } = _a, rest = __rest(_a, ["colId", "width", "offset", "style", "className", "children"]);
|
|
29
|
+
const w = width || {};
|
|
30
|
+
const off = offset || {};
|
|
31
|
+
const base = w.xs || 12;
|
|
32
|
+
const cls = `pb-col pb-col-${colId !== null && colId !== void 0 ? colId : 'static'}`;
|
|
33
|
+
const inline = Object.assign({ gridColumn: gridColumn(base, off.xs), minWidth: 0 }, style);
|
|
34
|
+
const rules = [];
|
|
35
|
+
for (const bp of BREAKPOINTS) {
|
|
36
|
+
const span = w[bp.key];
|
|
37
|
+
const offSpan = off[bp.key];
|
|
38
|
+
if (span || offSpan) {
|
|
39
|
+
rules.push(`@media (min-width:${bp.min}px){.${cls}{grid-column:${gridColumn(span || base, offSpan)}}}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return (_jsxs(_Fragment, { children: [rules.length > 0 && _jsx("style", { children: rules.join('') }), _jsx("div", Object.assign({ className: `${cls} ${className || ''}`.trim(), style: inline }, rest, { children: children }))] }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export declare function PbContainer({ fluid, style, className, children, ...rest }: {
|
|
3
|
+
readonly fluid?: boolean;
|
|
4
|
+
readonly style?: CSSProperties;
|
|
5
|
+
readonly className?: string;
|
|
6
|
+
readonly children?: ReactNode;
|
|
7
|
+
} & Record<string, unknown>): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export function PbContainer(_a) {
|
|
14
|
+
var { fluid, style, className, children } = _a, rest = __rest(_a, ["fluid", "style", "className", "children"]);
|
|
15
|
+
const classes = ['pb-container', fluid ? 'pb-container-fluid' : '', className || ''].filter(Boolean).join(' ');
|
|
16
|
+
return (_jsx("div", Object.assign({ className: classes, style: style }, rest, { children: children })));
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
export declare function PbRow({ id, style, className, children, ...rest }: {
|
|
3
|
+
readonly id?: string;
|
|
4
|
+
readonly style?: CSSProperties;
|
|
5
|
+
readonly className?: string;
|
|
6
|
+
readonly children?: ReactNode;
|
|
7
|
+
} & Record<string, unknown>): import("react").JSX.Element;
|
package/dist/ui/PbRow.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export function PbRow(_a) {
|
|
14
|
+
var { id, style, className, children } = _a, rest = __rest(_a, ["id", "style", "className", "children"]);
|
|
15
|
+
const classes = ['pb-row', className || ''].filter(Boolean).join(' ');
|
|
16
|
+
return (_jsx("div", Object.assign({ id: id, className: classes, style: style }, rest, { children: children })));
|
|
17
|
+
}
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function escapeHtml(value) {
|
|
2
|
+
return String(value !== null && value !== void 0 ? value : '')
|
|
3
|
+
.replace(/&/g, '&')
|
|
4
|
+
.replace(/</g, '<')
|
|
5
|
+
.replace(/>/g, '>')
|
|
6
|
+
.replace(/"/g, '"')
|
|
7
|
+
.replace(/'/g, ''');
|
|
8
|
+
}
|
|
9
|
+
export function buildFormEmailHtml(title, rows) {
|
|
10
|
+
const safeTitle = escapeHtml(title);
|
|
11
|
+
const rowsHtml = rows
|
|
12
|
+
.filter((row) => String(row.value).trim() !== '')
|
|
13
|
+
.map((row) => `
|
|
14
|
+
<tr>
|
|
15
|
+
<td style="padding:12px 0;border-bottom:1px solid #e5e7eb;font-size:13px;color:#6b7280;width:40%;vertical-align:top;">${escapeHtml(row.label)}</td>
|
|
16
|
+
<td style="padding:12px 0;border-bottom:1px solid #e5e7eb;font-size:14px;color:#172033;vertical-align:top;white-space:pre-wrap;word-break:break-word;">${escapeHtml(row.value)}</td>
|
|
17
|
+
</tr>`)
|
|
18
|
+
.join('');
|
|
19
|
+
return `<!DOCTYPE html>
|
|
20
|
+
<html lang="pt-BR">
|
|
21
|
+
<head>
|
|
22
|
+
<meta charset="UTF-8">
|
|
23
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
24
|
+
<title>${safeTitle}</title>
|
|
25
|
+
</head>
|
|
26
|
+
<body style="margin:0;padding:0;background-color:#eef2f7;font-family:Arial,Helvetica,sans-serif;color:#172033;">
|
|
27
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="background-color:#eef2f7;margin:0;padding:24px 0;width:100%;">
|
|
28
|
+
<tr>
|
|
29
|
+
<td align="center">
|
|
30
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="max-width:600px;width:100%;margin:0 auto;">
|
|
31
|
+
<tr>
|
|
32
|
+
<td style="padding:0 16px;">
|
|
33
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="background-color:#111933;border-radius:20px 20px 0 0;width:100%;">
|
|
34
|
+
<tr>
|
|
35
|
+
<td align="center" style="padding:32px 24px 24px 24px;">
|
|
36
|
+
<div style="font-size:12px;line-height:12px;letter-spacing:1.6px;text-transform:uppercase;color:#98a2c3;margin-bottom:12px;">PixelBuild</div>
|
|
37
|
+
<div style="font-size:24px;line-height:30px;font-weight:700;color:#ffffff;">${safeTitle}</div>
|
|
38
|
+
</td>
|
|
39
|
+
</tr>
|
|
40
|
+
</table>
|
|
41
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="background-color:#ffffff;border-radius:0 0 20px 20px;width:100%;">
|
|
42
|
+
<tr>
|
|
43
|
+
<td style="padding:16px 32px 32px 32px;">
|
|
44
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
45
|
+
${rowsHtml || '<tr><td style="padding:12px 0;font-size:14px;color:#6b7280;">Nenhuma informação enviada.</td></tr>'}
|
|
46
|
+
</table>
|
|
47
|
+
</td>
|
|
48
|
+
</tr>
|
|
49
|
+
</table>
|
|
50
|
+
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;">
|
|
51
|
+
<tr>
|
|
52
|
+
<td align="center" style="padding:20px 24px 0 24px;font-size:12px;line-height:18px;color:#8a94a6;text-align:center;">
|
|
53
|
+
Este e-mail foi enviado automaticamente pelo formulário do site.
|
|
54
|
+
</td>
|
|
55
|
+
</tr>
|
|
56
|
+
</table>
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
</table>
|
|
60
|
+
</td>
|
|
61
|
+
</tr>
|
|
62
|
+
</table>
|
|
63
|
+
</body>
|
|
64
|
+
</html>`;
|
|
65
|
+
}
|
|
66
|
+
export { escapeHtml };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function buildFontFamily(fontFamily) {
|
|
2
|
+
if (!fontFamily)
|
|
3
|
+
return undefined;
|
|
4
|
+
return `"${fontFamily}", sans-serif`;
|
|
5
|
+
}
|
|
6
|
+
export function buildGoogleFontsHref(fontFamily) {
|
|
7
|
+
if (!fontFamily)
|
|
8
|
+
return undefined;
|
|
9
|
+
return `https://fonts.googleapis.com/css2?family=${fontFamily.replaceAll(' ', '+')}&display=swap`;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function resolveImageElement(component, element) {
|
|
2
|
+
if (element.elementType !== 'image' && element.elementType !== 'video') {
|
|
3
|
+
return element;
|
|
4
|
+
}
|
|
5
|
+
const properties = component.properties || {};
|
|
6
|
+
const useShared = properties.imageCustomization !== 'separate';
|
|
7
|
+
const imageStyles = useShared ? properties.imageStyles || {} : element.styles;
|
|
8
|
+
return Object.assign(Object.assign({}, element), { styles: Object.assign({ width: '100%' }, imageStyles) });
|
|
9
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const BREAKPOINT_ORDER = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
2
|
+
export function resolveResponsiveProperties(properties, breakpoint) {
|
|
3
|
+
const responsive = properties === null || properties === void 0 ? void 0 : properties.responsive;
|
|
4
|
+
const resolved = Object.assign({}, properties);
|
|
5
|
+
delete resolved.responsive;
|
|
6
|
+
if (!responsive)
|
|
7
|
+
return resolved;
|
|
8
|
+
const idx = BREAKPOINT_ORDER.indexOf(breakpoint);
|
|
9
|
+
if (idx < 0)
|
|
10
|
+
return resolved;
|
|
11
|
+
for (let i = 0; i <= idx; i++) {
|
|
12
|
+
const overrides = responsive[BREAKPOINT_ORDER[i]];
|
|
13
|
+
if (overrides)
|
|
14
|
+
Object.assign(resolved, overrides);
|
|
15
|
+
}
|
|
16
|
+
return resolved;
|
|
17
|
+
}
|
|
18
|
+
export function breakpointFromWidth(width) {
|
|
19
|
+
if (width >= 1200)
|
|
20
|
+
return 'xl';
|
|
21
|
+
if (width >= 992)
|
|
22
|
+
return 'lg';
|
|
23
|
+
if (width >= 768)
|
|
24
|
+
return 'md';
|
|
25
|
+
if (width >= 576)
|
|
26
|
+
return 'sm';
|
|
27
|
+
return 'xs';
|
|
28
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BlockType } from '../types/BlockType.js';
|
|
2
|
+
import type { StylesType } from '../types/StylesType.js';
|
|
3
|
+
declare const BREAKPOINT_MIN_WIDTHS: Record<string, number>;
|
|
4
|
+
export declare function buildResponsiveCssForStyles(selector: string, styles: StylesType | undefined): string;
|
|
5
|
+
export declare function buildResponsiveCss(blocks: BlockType[]): string;
|
|
6
|
+
export { BREAKPOINT_MIN_WIDTHS };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const BREAKPOINT_MIN_WIDTHS = {
|
|
2
|
+
sm: 576,
|
|
3
|
+
md: 768,
|
|
4
|
+
lg: 992,
|
|
5
|
+
xl: 1200
|
|
6
|
+
};
|
|
7
|
+
const SKIP_KEYS = new Set([
|
|
8
|
+
'responsive',
|
|
9
|
+
'customCss',
|
|
10
|
+
'fluid',
|
|
11
|
+
'backgroundGradientColorStart',
|
|
12
|
+
'backgroundGradientColorEnd'
|
|
13
|
+
]);
|
|
14
|
+
function kebabCase(key) {
|
|
15
|
+
return key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
function cssValue(key, value) {
|
|
18
|
+
if (value === undefined || value === null || value === '')
|
|
19
|
+
return null;
|
|
20
|
+
const stringValue = String(value);
|
|
21
|
+
if (key === 'backgroundImage')
|
|
22
|
+
return `url(${stringValue})`;
|
|
23
|
+
return stringValue;
|
|
24
|
+
}
|
|
25
|
+
function declarationFor(key, value) {
|
|
26
|
+
const css = cssValue(key, value);
|
|
27
|
+
if (!css)
|
|
28
|
+
return null;
|
|
29
|
+
return `${kebabCase(key)}:${css}!important`;
|
|
30
|
+
}
|
|
31
|
+
function styleDeclarations(styles) {
|
|
32
|
+
if (!styles)
|
|
33
|
+
return '';
|
|
34
|
+
const declarations = [];
|
|
35
|
+
for (const [key, value] of Object.entries(styles)) {
|
|
36
|
+
if (SKIP_KEYS.has(key))
|
|
37
|
+
continue;
|
|
38
|
+
const declaration = declarationFor(key, value);
|
|
39
|
+
if (declaration)
|
|
40
|
+
declarations.push(declaration);
|
|
41
|
+
}
|
|
42
|
+
return declarations.join(';');
|
|
43
|
+
}
|
|
44
|
+
function buildRules(selector, responsive) {
|
|
45
|
+
if (!responsive)
|
|
46
|
+
return [];
|
|
47
|
+
const rules = [];
|
|
48
|
+
for (const [breakpoint, minWidth] of Object.entries(BREAKPOINT_MIN_WIDTHS)) {
|
|
49
|
+
const declarations = styleDeclarations(responsive[breakpoint]);
|
|
50
|
+
if (!declarations)
|
|
51
|
+
continue;
|
|
52
|
+
rules.push(`@media (min-width:${minWidth}px){${selector}{${declarations}}}`);
|
|
53
|
+
}
|
|
54
|
+
return rules;
|
|
55
|
+
}
|
|
56
|
+
export function buildResponsiveCssForStyles(selector, styles) {
|
|
57
|
+
return buildRules(selector, styles === null || styles === void 0 ? void 0 : styles.responsive).join('');
|
|
58
|
+
}
|
|
59
|
+
export function buildResponsiveCss(blocks) {
|
|
60
|
+
var _a, _b, _c;
|
|
61
|
+
const rules = [];
|
|
62
|
+
for (const block of blocks) {
|
|
63
|
+
rules.push(...buildRules(`[data-pb-block="${block.id}"]`, (_a = block.styles) === null || _a === void 0 ? void 0 : _a.responsive));
|
|
64
|
+
for (const component of block.components) {
|
|
65
|
+
rules.push(...buildRules(`[data-pb-component="${component.id}"]`, (_b = component.styles) === null || _b === void 0 ? void 0 : _b.responsive));
|
|
66
|
+
for (const element of component.elements) {
|
|
67
|
+
rules.push(...buildRules(`[data-pb-element="${element.id}"]`, (_c = element.styles) === null || _c === void 0 ? void 0 : _c.responsive));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return rules.join('');
|
|
72
|
+
}
|
|
73
|
+
export { BREAKPOINT_MIN_WIDTHS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib-pixelbuild",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "^24.0.0",
|
|
6
6
|
"npm": ">=10"
|
|
@@ -66,12 +66,10 @@
|
|
|
66
66
|
"@testing-library/user-event": "^14.6.1",
|
|
67
67
|
"@types/node": "^24.0.13",
|
|
68
68
|
"@types/react": "^18.3.3",
|
|
69
|
-
"@types/react-bootstrap": "^1.0.1",
|
|
70
69
|
"@types/react-dom": "^18.3.0",
|
|
71
70
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
72
71
|
"@typescript-eslint/parser": "^8.35.0",
|
|
73
72
|
"@vitejs/plugin-react": "^6.0.4",
|
|
74
|
-
"bootstrap": "^5.3.7",
|
|
75
73
|
"dompurify": "^3.2.6",
|
|
76
74
|
"eslint": "^10.8.0",
|
|
77
75
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
@@ -80,10 +78,8 @@
|
|
|
80
78
|
"husky": "^9.1.7",
|
|
81
79
|
"jsdom": "^30.0.0",
|
|
82
80
|
"lint-staged": "^15.5.2",
|
|
83
|
-
"keen-slider": "^6.8.6",
|
|
84
81
|
"prettier": "^3.6.2",
|
|
85
82
|
"react": "^18.2.0",
|
|
86
|
-
"react-bootstrap": "^2.10.10",
|
|
87
83
|
"react-dom": "^18.2.0",
|
|
88
84
|
"react-ga4": "^2.1.0",
|
|
89
85
|
"react-helmet-async": "^2.0.5",
|
|
@@ -103,11 +99,8 @@
|
|
|
103
99
|
]
|
|
104
100
|
},
|
|
105
101
|
"peerDependencies": {
|
|
106
|
-
"bootstrap": "^5.0.0",
|
|
107
102
|
"dompurify": "^3.2.6",
|
|
108
|
-
"keen-slider": "^6.8.6",
|
|
109
103
|
"react": "^18.0.0",
|
|
110
|
-
"react-bootstrap": "^2.10.10",
|
|
111
104
|
"react-dom": "^18.0.0",
|
|
112
105
|
"react-ga4": "^2.1.0",
|
|
113
106
|
"react-helmet-async": "^2.0.5",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Row, Col, Carousel } from 'react-bootstrap';
|
|
3
|
-
import { orderBySort } from '../utils/orderBySort.js';
|
|
4
|
-
export function CarouselComponent({ component }) {
|
|
5
|
-
return (_jsx(Row, { children: _jsx(Col, { children: _jsx(Carousel, { indicators: false, className: "slider", children: orderBySort(component.elements).map((element, index) => (_jsx(Carousel.Item, { children: _jsx("img", { src: String(element.properties.name || element.properties.src || ''), alt: String(element.properties.title || element.properties.alt || ''), style: { width: '100%', height: 'auto', objectFit: 'cover' } }) }, element.id || index))) }) }) }));
|
|
6
|
-
}
|
package/dist/layouts/Menu.d.ts
DELETED
package/dist/layouts/Menu.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Navbar, Nav, Container } from 'react-bootstrap';
|
|
3
|
-
export function Menu({ page, websitePages }) {
|
|
4
|
-
if (!websitePages || websitePages.length === 0) {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
const menuPages = websitePages
|
|
8
|
-
.filter((p) => p.menu === true)
|
|
9
|
-
.sort((a, b) => a.menuOrder - b.menuOrder);
|
|
10
|
-
if (menuPages.length === 0) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
const currentPath = (page === null || page === void 0 ? void 0 : page.path) || '';
|
|
14
|
-
const isActive = (path) => {
|
|
15
|
-
if (!currentPath)
|
|
16
|
-
return false;
|
|
17
|
-
if (path === '/')
|
|
18
|
-
return currentPath === '/' || currentPath === '';
|
|
19
|
-
return currentPath === path || currentPath.startsWith(path + '/');
|
|
20
|
-
};
|
|
21
|
-
return (_jsx(Navbar, { expand: "lg", className: "py-3", children: _jsxs(Container, { children: [_jsx(Navbar.Toggle, { "aria-controls": "basic-navbar-nav", className: "menu" }), _jsx(Navbar.Collapse, { id: "basic-navbar-nav", children: _jsx(Nav, { className: "me-auto", children: menuPages.map((p) => {
|
|
22
|
-
const active = isActive(p.path);
|
|
23
|
-
return (_jsx(Nav.Link, { href: p.path, style: {
|
|
24
|
-
color: active ? '#c0ad5b' : '#a4a4a4',
|
|
25
|
-
fontSize: '0.9rem',
|
|
26
|
-
letterSpacing: '0.05em',
|
|
27
|
-
textTransform: 'uppercase',
|
|
28
|
-
margin: '0 12px',
|
|
29
|
-
paddingBottom: '4px',
|
|
30
|
-
borderBottom: active ? '2px solid #c0ad5b' : '2px solid transparent',
|
|
31
|
-
transition: 'color 0.3s, border-color 0.3s',
|
|
32
|
-
}, children: p.title }, p.id));
|
|
33
|
-
}) }) })] }) }));
|
|
34
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { memo, useMemo } from 'react';
|
|
3
|
-
import { Container, Row, Col } from 'react-bootstrap';
|
|
4
|
-
import { ComponentFactory } from '../factories/ComponentFactory.js';
|
|
5
|
-
import { orderBySort } from '../utils/orderBySort.js';
|
|
6
|
-
const componentFactory = new ComponentFactory();
|
|
7
|
-
function colWidthValue(width, offset) {
|
|
8
|
-
if (width === undefined && offset === undefined)
|
|
9
|
-
return undefined;
|
|
10
|
-
if (offset !== undefined) {
|
|
11
|
-
return { span: width !== null && width !== void 0 ? width : 12, offset };
|
|
12
|
-
}
|
|
13
|
-
return width;
|
|
14
|
-
}
|
|
15
|
-
const ColumnContent = memo(function ColumnContent({ column, editionMode }) {
|
|
16
|
-
const components = useMemo(() => orderBySort(column.components.filter((c) => c.enabled)), [column.components]);
|
|
17
|
-
const childSections = useMemo(() => orderBySort(column.childSections), [column.childSections]);
|
|
18
|
-
return (_jsxs(_Fragment, { children: [components.map((component) => componentFactory.build(component, editionMode)), childSections.map((childSection) => (_jsx(SectionContent, { section: childSection, editionMode: editionMode }, childSection.id)))] }));
|
|
19
|
-
});
|
|
20
|
-
function gridClass(id) {
|
|
21
|
-
return `pixelbuild-grid-${String(id).replace(/[^a-zA-Z0-9_-]/g, '_')}`;
|
|
22
|
-
}
|
|
23
|
-
const GridRenderer = memo(function GridRenderer({ section, editionMode }) {
|
|
24
|
-
const grid = gridClass(section.id);
|
|
25
|
-
const columns = useMemo(() => section.columns.filter((col) => col.components.some((c) => c.enabled) || col.childSections.length > 0), [section.columns]);
|
|
26
|
-
const css = useMemo(() => {
|
|
27
|
-
const rules = columns
|
|
28
|
-
.map((column) => {
|
|
29
|
-
const properties = column.properties || {};
|
|
30
|
-
const row = Math.max(0, Number(properties.row) || 0);
|
|
31
|
-
const rowSpan = Math.max(1, Number(properties.rowSpan) || 1);
|
|
32
|
-
const xs = column.width.xs || 12;
|
|
33
|
-
const sm = column.width.sm || xs;
|
|
34
|
-
const md = column.width.md || sm;
|
|
35
|
-
const columnClass = gridClass(column.id);
|
|
36
|
-
return [
|
|
37
|
-
`.${grid} .${columnClass}{grid-column:span ${xs};grid-row:auto;min-width:0}`,
|
|
38
|
-
`@media (min-width:576px){.${grid} .${columnClass}{grid-column:span ${sm}}}`,
|
|
39
|
-
`@media (min-width:768px){.${grid} .${columnClass}{grid-column:span ${md};grid-row:${row + 1}/span ${rowSpan}}}`
|
|
40
|
-
].join('');
|
|
41
|
-
})
|
|
42
|
-
.join('');
|
|
43
|
-
return `.${grid}{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:1rem}${rules}`;
|
|
44
|
-
}, [grid, columns]);
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx("style", { children: css }), _jsx("div", { id: `section-${section.id}`, className: grid, style: section.sectionType === 'row' ? section.styles : undefined, children: columns.map((column) => (_jsx("div", { id: `column-${column.id}`, className: gridClass(column.id), style: column.styles, children: _jsx(ColumnContent, { column: column, editionMode: editionMode }) }, column.id))) })] }));
|
|
46
|
-
});
|
|
47
|
-
const SectionContent = memo(function SectionContent({ section, editionMode }) {
|
|
48
|
-
const usesGrid = useMemo(() => section.columns.some((column) => { var _a, _b; return ((_a = column.properties) === null || _a === void 0 ? void 0 : _a.row) !== undefined || Number((_b = column.properties) === null || _b === void 0 ? void 0 : _b.rowSpan) > 1; }), [section.columns]);
|
|
49
|
-
const content = useMemo(() => {
|
|
50
|
-
if (usesGrid) {
|
|
51
|
-
return _jsx(GridRenderer, { section: section, editionMode: editionMode });
|
|
52
|
-
}
|
|
53
|
-
return (_jsx(Row, { id: `section-${section.id}`, style: section.sectionType === 'row' ? section.styles : undefined, children: section.columns.map((column) => (_jsx(ColumnRenderer, { column: column, editionMode: editionMode }, column.id))) }));
|
|
54
|
-
}, [usesGrid, section, editionMode]);
|
|
55
|
-
if (section.sectionType === 'container-fluid') {
|
|
56
|
-
return (_jsx(Container, { fluid: true, style: section.styles, children: content }));
|
|
57
|
-
}
|
|
58
|
-
if (section.sectionType === 'container') {
|
|
59
|
-
return _jsx(Container, { style: section.styles, children: content });
|
|
60
|
-
}
|
|
61
|
-
return _jsx(Container, { fluid: true, children: content });
|
|
62
|
-
});
|
|
63
|
-
const ColumnRenderer = memo(function ColumnRenderer({ column, editionMode }) {
|
|
64
|
-
return (_jsx(Col, { id: `column-${column.id}`, xs: colWidthValue(column.width.xs, column.offset.xs), sm: colWidthValue(column.width.sm, column.offset.sm), md: colWidthValue(column.width.md, column.offset.md), lg: colWidthValue(column.width.lg, column.offset.lg), xl: colWidthValue(column.width.xl, column.offset.xl), style: column.styles, children: _jsx(ColumnContent, { column: column, editionMode: editionMode }) }, column.id));
|
|
65
|
-
});
|
|
66
|
-
const SectionRenderer = memo(function SectionRenderer({ sections, editionMode = false }) {
|
|
67
|
-
const sorted = useMemo(() => orderBySort(sections || []), [sections]);
|
|
68
|
-
if (sorted.length === 0) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
return (_jsx(_Fragment, { children: sorted.map((section) => (_jsx(SectionContent, { section: section, editionMode: editionMode }, section.id))) }));
|
|
72
|
-
});
|
|
73
|
-
export { SectionRenderer };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { StylesType } from './StylesType.js';
|
|
2
|
-
import type { SectionColumnType } from './SectionColumnType.js';
|
|
3
|
-
export interface SectionType {
|
|
4
|
-
id: number;
|
|
5
|
-
sectionType: 'container' | 'container-fluid' | 'row';
|
|
6
|
-
sort: number;
|
|
7
|
-
properties: Record<string, unknown>;
|
|
8
|
-
styles: StylesType;
|
|
9
|
-
columns: SectionColumnType[];
|
|
10
|
-
}
|
|
File without changes
|
|
File without changes
|