lib-pixelbuild 0.1.3 → 0.2.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/README.md +102 -127
- package/dist/builders/PageBuilder.d.ts +3 -2
- package/dist/builders/PageBuilder.js +41 -33
- package/dist/components/CardComponent.d.ts +3 -3
- package/dist/components/CardComponent.js +65 -6
- package/dist/components/FormComponent.d.ts +3 -3
- package/dist/components/FormComponent.js +8 -14
- package/dist/components/ListComponent.d.ts +3 -2
- package/dist/components/ListComponent.js +20 -15
- package/dist/components/LoadingComponent.js +1 -1
- package/dist/components/MapComponent.js +18 -4
- package/dist/components/SliderComponent.js +69 -33
- package/dist/components/SocialIconsComponent.js +1 -1
- package/dist/components/TextComponent.d.ts +3 -3
- package/dist/components/TextComponent.js +6 -7
- package/dist/elements/AlertElement.js +4 -3
- package/dist/elements/ButtonElement.js +19 -17
- package/dist/elements/IconElement.d.ts +1 -2
- package/dist/elements/IconElement.js +10 -9
- package/dist/elements/IconMap.d.ts +2 -0
- package/dist/elements/IconMap.js +30 -0
- package/dist/elements/InputElement.js +16 -16
- package/dist/factories/ButtonActionFactory.d.ts +6 -1
- package/dist/factories/ButtonActionFactory.js +14 -4
- package/dist/index.d.ts +2 -6
- package/dist/index.js +1 -4
- package/dist/layouts/Header.d.ts +2 -1
- package/dist/layouts/Header.js +33 -5
- package/dist/layouts/SiteLayout.d.ts +2 -1
- package/dist/layouts/SiteLayout.js +2 -2
- package/dist/renderers/SectionRenderer.d.ts +3 -3
- package/dist/renderers/SectionRenderer.js +45 -29
- package/dist/services/EmailService.d.ts +10 -2
- package/dist/services/EmailService.js +25 -25
- package/dist/types/RawWebsiteType.d.ts +8 -184
- package/dist/utils/InputValidators.js +11 -11
- package/dist/utils/propertyUtils.d.ts +3 -0
- package/dist/utils/propertyUtils.js +28 -0
- package/package.json +32 -19
- package/dist/elements/FileElement.d.ts +0 -4
- package/dist/elements/FileElement.js +0 -6
- package/dist/services/ApiService.d.ts +0 -5
- package/dist/services/ApiService.js +0 -17
- package/dist/services/CacheService.d.ts +0 -5
- package/dist/services/CacheService.js +0 -16
- package/dist/services/ConstructorService.d.ts +0 -12
- package/dist/services/ConstructorService.js +0 -33
- package/dist/types/AuthenticateResponseType.d.ts +0 -5
- package/dist/types/AuthenticateResponseType.js +0 -1
- package/dist/types/ButtonPropertiesType.d.ts +0 -11
- package/dist/types/ButtonPropertiesType.js +0 -1
- package/dist/types/FilePropertiesType.d.ts +0 -4
- package/dist/types/FilePropertiesType.js +0 -1
- package/dist/types/ImagePropertiesType.d.ts +0 -4
- package/dist/types/ImagePropertiesType.js +0 -1
- package/dist/types/InputPropertiesType.d.ts +0 -7
- package/dist/types/InputPropertiesType.js +0 -1
- package/dist/types/LinkPropertiesType.d.ts +0 -4
- package/dist/types/LinkPropertiesType.js +0 -1
- package/dist/types/PlanWebsiteType.d.ts +0 -9
- package/dist/types/PlanWebsiteType.js +0 -1
- package/dist/types/UserType.d.ts +0 -10
- package/dist/types/UserType.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
3
|
import { Container, Row, Col } from 'react-bootstrap';
|
|
4
4
|
import { ComponentFactory } from '../factories/ComponentFactory.js';
|
|
5
5
|
import { orderBySort } from '../utils/orderBySort.js';
|
|
@@ -12,30 +12,44 @@ function colWidthValue(width, offset) {
|
|
|
12
12
|
}
|
|
13
13
|
return width;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
});
|
|
18
20
|
function gridClass(id) {
|
|
19
21
|
return `pixelbuild-grid-${String(id).replace(/[^a-zA-Z0-9_-]/g, '_')}`;
|
|
20
22
|
}
|
|
21
|
-
function
|
|
23
|
+
const GridRenderer = memo(function GridRenderer({ section, editionMode }) {
|
|
22
24
|
const grid = gridClass(section.id);
|
|
23
|
-
const columns = section.columns.filter((
|
|
24
|
-
const css =
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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.map((column) => {
|
|
28
|
+
const properties = column.properties || {};
|
|
29
|
+
const row = Math.max(0, Number(properties.row) || 0);
|
|
30
|
+
const rowSpan = Math.max(1, Number(properties.rowSpan) || 1);
|
|
31
|
+
const xs = column.width.xs || 12;
|
|
32
|
+
const sm = column.width.sm || xs;
|
|
33
|
+
const md = column.width.md || sm;
|
|
34
|
+
const columnClass = gridClass(column.id);
|
|
35
|
+
return [
|
|
36
|
+
`.${grid} .${columnClass}{grid-column:span ${xs};grid-row:auto;min-width:0}`,
|
|
37
|
+
`@media (min-width:576px){.${grid} .${columnClass}{grid-column:span ${sm}}}`,
|
|
38
|
+
`@media (min-width:768px){.${grid} .${columnClass}{grid-column:span ${md};grid-row:${row + 1}/span ${rowSpan}}}`
|
|
39
|
+
].join('');
|
|
40
|
+
}).join('');
|
|
41
|
+
return `.${grid}{display:grid;grid-template-columns:repeat(12,minmax(0,1fr));gap:1rem}${rules}`;
|
|
42
|
+
}, [grid, columns]);
|
|
43
|
+
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))) })] }));
|
|
44
|
+
});
|
|
45
|
+
const SectionContent = memo(function SectionContent({ section, editionMode }) {
|
|
46
|
+
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]);
|
|
47
|
+
const content = useMemo(() => {
|
|
48
|
+
if (usesGrid) {
|
|
49
|
+
return _jsx(GridRenderer, { section: section, editionMode: editionMode });
|
|
50
|
+
}
|
|
51
|
+
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))) }));
|
|
52
|
+
}, [usesGrid, section, editionMode]);
|
|
39
53
|
if (section.sectionType === 'container-fluid') {
|
|
40
54
|
return _jsx(Container, { fluid: true, style: section.styles, children: content });
|
|
41
55
|
}
|
|
@@ -43,13 +57,15 @@ function renderSection(section, editionMode) {
|
|
|
43
57
|
return _jsx(Container, { style: section.styles, children: content });
|
|
44
58
|
}
|
|
45
59
|
return _jsx(Container, { fluid: true, children: content });
|
|
46
|
-
}
|
|
47
|
-
function
|
|
48
|
-
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:
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
60
|
+
});
|
|
61
|
+
const ColumnRenderer = memo(function ColumnRenderer({ column, editionMode }) {
|
|
62
|
+
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));
|
|
63
|
+
});
|
|
64
|
+
const SectionRenderer = memo(function SectionRenderer({ sections, editionMode = false }) {
|
|
65
|
+
const sorted = useMemo(() => orderBySort(sections || []), [sections]);
|
|
66
|
+
if (sorted.length === 0) {
|
|
52
67
|
return null;
|
|
53
68
|
}
|
|
54
|
-
return (_jsx(_Fragment, { children:
|
|
55
|
-
}
|
|
69
|
+
return (_jsx(_Fragment, { children: sorted.map((section) => (_jsx(SectionContent, { section: section, editionMode: editionMode }, section.id))) }));
|
|
70
|
+
});
|
|
71
|
+
export { SectionRenderer };
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import type { FormFieldsType } from '../types/FormFieldsType.js';
|
|
2
2
|
import type { MailBodyType } from '../types/MailBodyType.js';
|
|
3
|
+
export interface EmailServiceConfig {
|
|
4
|
+
apiUrl: string;
|
|
5
|
+
authToken: string;
|
|
6
|
+
senderName: string;
|
|
7
|
+
sender: string;
|
|
8
|
+
recipientName: string;
|
|
9
|
+
recipient: string;
|
|
10
|
+
}
|
|
3
11
|
declare class EmailService {
|
|
4
|
-
private readonly
|
|
5
|
-
constructor(
|
|
12
|
+
private readonly config;
|
|
13
|
+
constructor(config: EmailServiceConfig);
|
|
6
14
|
sendMail(params: FormFieldsType[]): Promise<boolean>;
|
|
7
15
|
createBody(params: FormFieldsType[]): MailBodyType;
|
|
8
16
|
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
class EmailService {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
2
|
+
constructor(config) {
|
|
3
|
+
this.config = config;
|
|
4
4
|
}
|
|
5
5
|
async sendMail(params) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
throw new Error(response.status.toString());
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error('Erro ao buscar dados da API:', error);
|
|
23
|
-
throw new Error(error instanceof Error ? error.message : JSON.stringify(error));
|
|
6
|
+
const body = this.createBody(params);
|
|
7
|
+
const response = await fetch(`${this.config.apiUrl}/send-mail`, {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers: {
|
|
10
|
+
'Content-Type': 'application/json',
|
|
11
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
12
|
+
},
|
|
13
|
+
body: JSON.stringify(body)
|
|
14
|
+
});
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new Error(`Email send failed: ${response.status}`);
|
|
24
17
|
}
|
|
18
|
+
return true;
|
|
25
19
|
}
|
|
26
20
|
createBody(params) {
|
|
27
21
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -32,12 +26,18 @@ class EmailService {
|
|
|
32
26
|
const email = params.find((e) => e.name === 'emailField');
|
|
33
27
|
const phone = params.find((e) => e.name === 'phoneField');
|
|
34
28
|
return {
|
|
35
|
-
senderName:
|
|
36
|
-
sender:
|
|
37
|
-
recipientName:
|
|
38
|
-
recipient:
|
|
29
|
+
senderName: this.config.senderName,
|
|
30
|
+
sender: this.config.sender,
|
|
31
|
+
recipientName: this.config.recipientName,
|
|
32
|
+
recipient: this.config.recipient,
|
|
39
33
|
title: 'Mensagem enviada pelo formulário do site',
|
|
40
|
-
message:
|
|
34
|
+
message: [
|
|
35
|
+
`Nome: ${(_a = firstName === null || firstName === void 0 ? void 0 : firstName.value) !== null && _a !== void 0 ? _a : ''} ${(_b = lastName === null || lastName === void 0 ? void 0 : lastName.value) !== null && _b !== void 0 ? _b : ''}`,
|
|
36
|
+
`Data de Nascimento: ${(_c = birthDate === null || birthDate === void 0 ? void 0 : birthDate.value) !== null && _c !== void 0 ? _c : ''}`,
|
|
37
|
+
`CPF: ${(_d = document === null || document === void 0 ? void 0 : document.value) !== null && _d !== void 0 ? _d : ''}`,
|
|
38
|
+
`E-mail: ${(_e = email === null || email === void 0 ? void 0 : email.value) !== null && _e !== void 0 ? _e : ''}`,
|
|
39
|
+
`Celular: ${(_f = phone === null || phone === void 0 ? void 0 : phone.value) !== null && _f !== void 0 ? _f : ''}`
|
|
40
|
+
].filter(Boolean).join('\n')
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StylesType } from './StylesType.js';
|
|
1
2
|
export type RawWebsiteType = {
|
|
2
3
|
id: number;
|
|
3
4
|
name: string;
|
|
@@ -9,32 +10,7 @@ export type RawWebsiteType = {
|
|
|
9
10
|
logoAlign: 'left' | 'right' | 'center';
|
|
10
11
|
showLogo: boolean;
|
|
11
12
|
};
|
|
12
|
-
styles:
|
|
13
|
-
alignItems?: string;
|
|
14
|
-
backgroundColor?: string;
|
|
15
|
-
borderColor?: string;
|
|
16
|
-
borderRadius?: string;
|
|
17
|
-
borderStyle?: string;
|
|
18
|
-
borderWidth?: string;
|
|
19
|
-
color?: string;
|
|
20
|
-
display?: string;
|
|
21
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
22
|
-
fluid?: boolean;
|
|
23
|
-
fontSize?: string;
|
|
24
|
-
fontWeight?: string;
|
|
25
|
-
height?: string;
|
|
26
|
-
marginTop?: string;
|
|
27
|
-
marginLeft?: string;
|
|
28
|
-
marginRight?: string;
|
|
29
|
-
marginBottom?: string;
|
|
30
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
31
|
-
paddingTop?: string;
|
|
32
|
-
paddingLeft?: string;
|
|
33
|
-
paddingRight?: string;
|
|
34
|
-
paddingBottom?: string;
|
|
35
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
36
|
-
width?: string;
|
|
37
|
-
};
|
|
13
|
+
styles: StylesType;
|
|
38
14
|
};
|
|
39
15
|
footer: {
|
|
40
16
|
properties: {
|
|
@@ -42,32 +18,7 @@ export type RawWebsiteType = {
|
|
|
42
18
|
text2: string;
|
|
43
19
|
text3: string;
|
|
44
20
|
};
|
|
45
|
-
styles:
|
|
46
|
-
alignItems?: string;
|
|
47
|
-
backgroundColor?: string;
|
|
48
|
-
borderColor?: string;
|
|
49
|
-
borderRadius?: string;
|
|
50
|
-
borderStyle?: string;
|
|
51
|
-
borderWidth?: string;
|
|
52
|
-
color?: string;
|
|
53
|
-
display?: string;
|
|
54
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
55
|
-
fluid?: boolean;
|
|
56
|
-
fontSize?: string;
|
|
57
|
-
fontWeight?: string;
|
|
58
|
-
height?: string;
|
|
59
|
-
marginTop?: string;
|
|
60
|
-
marginLeft?: string;
|
|
61
|
-
marginRight?: string;
|
|
62
|
-
marginBottom?: string;
|
|
63
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
64
|
-
paddingTop?: string;
|
|
65
|
-
paddingLeft?: string;
|
|
66
|
-
paddingRight?: string;
|
|
67
|
-
paddingBottom?: string;
|
|
68
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
69
|
-
width?: string;
|
|
70
|
-
};
|
|
21
|
+
styles: StylesType;
|
|
71
22
|
};
|
|
72
23
|
properties: {
|
|
73
24
|
loadingMessage: string;
|
|
@@ -83,36 +34,7 @@ export type RawWebsiteType = {
|
|
|
83
34
|
};
|
|
84
35
|
};
|
|
85
36
|
};
|
|
86
|
-
styles:
|
|
87
|
-
alignItems?: string;
|
|
88
|
-
backgroundColor?: string;
|
|
89
|
-
backgroundImage?: string;
|
|
90
|
-
backgroundGradientColorStart?: string;
|
|
91
|
-
backgroundGradientColorEnd?: string;
|
|
92
|
-
backgroundPosition?: string;
|
|
93
|
-
backgroundSize?: string;
|
|
94
|
-
borderColor?: string;
|
|
95
|
-
borderRadius?: string;
|
|
96
|
-
borderStyle?: string;
|
|
97
|
-
borderWidth?: string;
|
|
98
|
-
color?: string;
|
|
99
|
-
display?: string;
|
|
100
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
101
|
-
fontSize?: string;
|
|
102
|
-
fontWeight?: string;
|
|
103
|
-
height?: string;
|
|
104
|
-
marginTop?: string;
|
|
105
|
-
marginLeft?: string;
|
|
106
|
-
marginRight?: string;
|
|
107
|
-
marginBottom?: string;
|
|
108
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
109
|
-
paddingTop?: string;
|
|
110
|
-
paddingLeft?: string;
|
|
111
|
-
paddingRight?: string;
|
|
112
|
-
paddingBottom?: string;
|
|
113
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
114
|
-
width?: string;
|
|
115
|
-
};
|
|
37
|
+
styles: StylesType;
|
|
116
38
|
enabled: boolean;
|
|
117
39
|
publishedAt: string | null;
|
|
118
40
|
createdAt: string;
|
|
@@ -132,32 +54,7 @@ export type RawWebsiteType = {
|
|
|
132
54
|
section: string;
|
|
133
55
|
name: string;
|
|
134
56
|
order: number;
|
|
135
|
-
styles:
|
|
136
|
-
alignItems?: string;
|
|
137
|
-
backgroundColor?: string;
|
|
138
|
-
borderColor?: string;
|
|
139
|
-
borderRadius?: string;
|
|
140
|
-
borderStyle?: string;
|
|
141
|
-
borderWidth?: string;
|
|
142
|
-
color?: string;
|
|
143
|
-
display?: string;
|
|
144
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
145
|
-
fluid?: boolean;
|
|
146
|
-
fontSize?: string;
|
|
147
|
-
fontWeight?: string;
|
|
148
|
-
height?: string;
|
|
149
|
-
marginTop?: string;
|
|
150
|
-
marginLeft?: string;
|
|
151
|
-
marginRight?: string;
|
|
152
|
-
marginBottom?: string;
|
|
153
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
154
|
-
paddingTop?: string;
|
|
155
|
-
paddingLeft?: string;
|
|
156
|
-
paddingRight?: string;
|
|
157
|
-
paddingBottom?: string;
|
|
158
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
159
|
-
width?: string;
|
|
160
|
-
};
|
|
57
|
+
styles: StylesType;
|
|
161
58
|
}>;
|
|
162
59
|
enabled: boolean;
|
|
163
60
|
properties: {
|
|
@@ -180,32 +77,7 @@ export type RawWebsiteType = {
|
|
|
180
77
|
};
|
|
181
78
|
};
|
|
182
79
|
};
|
|
183
|
-
styles:
|
|
184
|
-
alignItems?: string;
|
|
185
|
-
backgroundColor?: string;
|
|
186
|
-
borderColor?: string;
|
|
187
|
-
borderRadius?: string;
|
|
188
|
-
borderStyle?: string;
|
|
189
|
-
borderWidth?: string;
|
|
190
|
-
color?: string;
|
|
191
|
-
display?: string;
|
|
192
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
193
|
-
fluid?: boolean;
|
|
194
|
-
fontSize?: string;
|
|
195
|
-
fontWeight?: string;
|
|
196
|
-
height?: string;
|
|
197
|
-
marginTop?: string;
|
|
198
|
-
marginLeft?: string;
|
|
199
|
-
marginRight?: string;
|
|
200
|
-
marginBottom?: string;
|
|
201
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
202
|
-
paddingTop?: string;
|
|
203
|
-
paddingLeft?: string;
|
|
204
|
-
paddingRight?: string;
|
|
205
|
-
paddingBottom?: string;
|
|
206
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
207
|
-
width?: string;
|
|
208
|
-
};
|
|
80
|
+
styles: StylesType;
|
|
209
81
|
createdAt: string;
|
|
210
82
|
updatedAt: string;
|
|
211
83
|
deletedAt: string | null;
|
|
@@ -234,31 +106,7 @@ export type RawWebsiteType = {
|
|
|
234
106
|
};
|
|
235
107
|
};
|
|
236
108
|
};
|
|
237
|
-
styles:
|
|
238
|
-
alignItems?: string;
|
|
239
|
-
backgroundColor?: string;
|
|
240
|
-
borderColor?: string;
|
|
241
|
-
borderRadius?: string;
|
|
242
|
-
borderStyle?: string;
|
|
243
|
-
borderWidth?: string;
|
|
244
|
-
color?: string;
|
|
245
|
-
display?: string;
|
|
246
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
247
|
-
fontSize?: string;
|
|
248
|
-
fontWeight?: string;
|
|
249
|
-
height?: string;
|
|
250
|
-
marginTop?: string;
|
|
251
|
-
marginLeft?: string;
|
|
252
|
-
marginRight?: string;
|
|
253
|
-
marginBottom?: string;
|
|
254
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
255
|
-
paddingTop?: string;
|
|
256
|
-
paddingLeft?: string;
|
|
257
|
-
paddingRight?: string;
|
|
258
|
-
paddingBottom?: string;
|
|
259
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
260
|
-
width?: string;
|
|
261
|
-
};
|
|
109
|
+
styles: StylesType;
|
|
262
110
|
sort: number;
|
|
263
111
|
enabled: boolean;
|
|
264
112
|
createdAt: string;
|
|
@@ -310,31 +158,7 @@ export type RawWebsiteType = {
|
|
|
310
158
|
successMessageId?: number;
|
|
311
159
|
errorMessageId?: number;
|
|
312
160
|
};
|
|
313
|
-
styles:
|
|
314
|
-
alignItems?: string;
|
|
315
|
-
backgroundColor?: string;
|
|
316
|
-
borderColor?: string;
|
|
317
|
-
borderRadius?: string;
|
|
318
|
-
borderStyle?: string;
|
|
319
|
-
borderWidth?: string;
|
|
320
|
-
color?: string;
|
|
321
|
-
display?: string;
|
|
322
|
-
float?: 'left' | 'right' | 'none' | 'inline-start' | 'inline-end';
|
|
323
|
-
fontSize?: string;
|
|
324
|
-
fontWeight?: string;
|
|
325
|
-
height?: string;
|
|
326
|
-
marginTop?: string;
|
|
327
|
-
marginLeft?: string;
|
|
328
|
-
marginRight?: string;
|
|
329
|
-
marginBottom?: string;
|
|
330
|
-
objectFit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
331
|
-
paddingTop?: string;
|
|
332
|
-
paddingLeft?: string;
|
|
333
|
-
paddingRight?: string;
|
|
334
|
-
paddingBottom?: string;
|
|
335
|
-
textAlign?: 'left' | 'right' | 'center' | 'justify' | 'start' | 'end';
|
|
336
|
-
width?: string;
|
|
337
|
-
};
|
|
161
|
+
styles: StylesType;
|
|
338
162
|
createdAt: string;
|
|
339
163
|
updatedAt: string;
|
|
340
164
|
deletedAt: string | null;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
export function nameValidation(name) {
|
|
2
2
|
if (!name || name.length === 0) {
|
|
3
|
-
return { success: false, message: '
|
|
3
|
+
return { success: false, message: 'Required field' };
|
|
4
4
|
}
|
|
5
5
|
if (name.length < 3) {
|
|
6
|
-
return { success: false, message: '
|
|
6
|
+
return { success: false, message: 'Name too short' };
|
|
7
7
|
}
|
|
8
8
|
if (name.length > 50) {
|
|
9
|
-
return { success: false, message: '
|
|
9
|
+
return { success: false, message: 'Name too long' };
|
|
10
10
|
}
|
|
11
11
|
return { success: true };
|
|
12
12
|
}
|
|
13
13
|
export function birthDateValidation(birthDate) {
|
|
14
14
|
if (!birthDate || birthDate.length === 0) {
|
|
15
|
-
return { success: false, message: '
|
|
15
|
+
return { success: false, message: 'Required field' };
|
|
16
16
|
}
|
|
17
17
|
if (!dateValidate(birthDate)) {
|
|
18
|
-
return { success: false, message: '
|
|
18
|
+
return { success: false, message: 'Invalid date' };
|
|
19
19
|
}
|
|
20
20
|
return { success: true };
|
|
21
21
|
}
|
|
@@ -29,12 +29,12 @@ export function dateValidate(data) {
|
|
|
29
29
|
}
|
|
30
30
|
export function emailValidation(email) {
|
|
31
31
|
if (!email || email.length === 0) {
|
|
32
|
-
return { success: false, message: '
|
|
32
|
+
return { success: false, message: 'Required field' };
|
|
33
33
|
}
|
|
34
34
|
if (emailValidate(email)) {
|
|
35
35
|
return { success: true };
|
|
36
36
|
}
|
|
37
|
-
return { success: false, message: '
|
|
37
|
+
return { success: false, message: 'Invalid email' };
|
|
38
38
|
}
|
|
39
39
|
export function emailValidate(email) {
|
|
40
40
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
|
@@ -42,13 +42,13 @@ export function emailValidate(email) {
|
|
|
42
42
|
export function cpfValidation(cpf) {
|
|
43
43
|
const onlyDigits = cpf === null || cpf === void 0 ? void 0 : cpf.replaceAll(/\D/g, '');
|
|
44
44
|
if (!cpf || onlyDigits.length === 0) {
|
|
45
|
-
return { success: false, message: '
|
|
45
|
+
return { success: false, message: 'Required field' };
|
|
46
46
|
}
|
|
47
47
|
else if (cpfValidate(onlyDigits)) {
|
|
48
48
|
return { success: true };
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
|
-
return { success: false, message: 'CPF
|
|
51
|
+
return { success: false, message: 'Invalid CPF' };
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
export function cpfValidate(cpf) {
|
|
@@ -74,13 +74,13 @@ export function cpfValidate(cpf) {
|
|
|
74
74
|
export function phoneValidation(phone) {
|
|
75
75
|
const onlyDigits = phone === null || phone === void 0 ? void 0 : phone.replaceAll(/\D/g, '');
|
|
76
76
|
if (!onlyDigits || onlyDigits.length === 0) {
|
|
77
|
-
return { success: false, message: '
|
|
77
|
+
return { success: false, message: 'Required field' };
|
|
78
78
|
}
|
|
79
79
|
else if (phoneValidate(phone)) {
|
|
80
80
|
return { success: true };
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
return { success: false, message: '
|
|
83
|
+
return { success: false, message: 'Invalid phone' };
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
export function phoneValidate(cel) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function getString(props: Record<string, unknown>, key: string, fallback?: string): string;
|
|
2
|
+
export declare function getNumber(props: Record<string, unknown>, key: string, fallback?: number): number | undefined;
|
|
3
|
+
export declare function getBoolean(props: Record<string, unknown>, key: string, fallback?: boolean): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function getString(props, key, fallback = '') {
|
|
2
|
+
const val = props[key];
|
|
3
|
+
if (typeof val === 'string')
|
|
4
|
+
return val;
|
|
5
|
+
if (typeof val === 'number' || typeof val === 'boolean')
|
|
6
|
+
return String(val);
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
export function getNumber(props, key, fallback) {
|
|
10
|
+
const val = props[key];
|
|
11
|
+
if (typeof val === 'number')
|
|
12
|
+
return val;
|
|
13
|
+
if (typeof val === 'string') {
|
|
14
|
+
const n = Number(val);
|
|
15
|
+
return Number.isNaN(n) ? fallback : n;
|
|
16
|
+
}
|
|
17
|
+
return fallback;
|
|
18
|
+
}
|
|
19
|
+
export function getBoolean(props, key, fallback = false) {
|
|
20
|
+
const val = props[key];
|
|
21
|
+
if (typeof val === 'boolean')
|
|
22
|
+
return val;
|
|
23
|
+
if (typeof val === 'string')
|
|
24
|
+
return val === 'true' || val === '1';
|
|
25
|
+
if (typeof val === 'number')
|
|
26
|
+
return val !== 0;
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lib-pixelbuild",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": "^24.18.0",
|
|
6
6
|
"npm": ">=10"
|
|
7
7
|
},
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
|
-
"module": "./dist/index.
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
|
-
"types": "./dist/index.d.ts"
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
@@ -21,9 +22,13 @@
|
|
|
21
22
|
"*.css"
|
|
22
23
|
],
|
|
23
24
|
"scripts": {
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"prebuild": "rm -rf dist",
|
|
26
|
+
"prepare": "husky || true",
|
|
27
|
+
"prepublishOnly": "npm run build && npm test && npm run lint",
|
|
28
|
+
"build": "tsc -p tsconfig.build.json && tsc-esm-fix dist",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
27
32
|
"lint": "eslint . --ext .ts,.tsx",
|
|
28
33
|
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
|
29
34
|
"format": "prettier --write .",
|
|
@@ -55,24 +60,28 @@
|
|
|
55
60
|
"homepage": "https://github.com/Lucas-SCCP/lib-pixelbuild#readme",
|
|
56
61
|
"devDependencies": {
|
|
57
62
|
"@eslint/js": "^9.29.0",
|
|
63
|
+
"@testing-library/dom": "^10.4.1",
|
|
64
|
+
"@testing-library/jest-dom": "^7.0.0",
|
|
65
|
+
"@testing-library/react": "^16.3.2",
|
|
66
|
+
"@testing-library/user-event": "^14.6.1",
|
|
58
67
|
"@types/node": "^24.0.13",
|
|
59
68
|
"@types/react": "^18.3.3",
|
|
60
69
|
"@types/react-bootstrap": "^1.0.1",
|
|
61
70
|
"@types/react-dom": "^18.3.0",
|
|
62
|
-
"@types/react-slick": "^0.23.13",
|
|
63
71
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
64
72
|
"@typescript-eslint/parser": "^8.35.0",
|
|
73
|
+
"@vitejs/plugin-react": "^6.0.4",
|
|
65
74
|
"bootstrap": "^5.3.7",
|
|
75
|
+
"dompurify": "^3.2.6",
|
|
66
76
|
"eslint": "^10.8.0",
|
|
67
|
-
"eslint-
|
|
68
|
-
"eslint-plugin-prettier": "^5.5.1",
|
|
69
|
-
"eslint-plugin-react": "^7.22.0",
|
|
70
|
-
"eslint-plugin-react-hooks": "^5.2.0",
|
|
77
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
71
78
|
"eslint-plugin-react-refresh": "^0.4.20",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
79
|
+
"globals": "^17.8.0",
|
|
80
|
+
"husky": "^9.1.7",
|
|
81
|
+
"jsdom": "^30.0.0",
|
|
82
|
+
"lint-staged": "^15.5.2",
|
|
75
83
|
"keen-slider": "^6.8.6",
|
|
84
|
+
"prettier": "^3.6.2",
|
|
76
85
|
"react": "^18.2.0",
|
|
77
86
|
"react-bootstrap": "^2.10.10",
|
|
78
87
|
"react-dom": "^18.2.0",
|
|
@@ -81,12 +90,18 @@
|
|
|
81
90
|
"react-icons": "^5.3.0",
|
|
82
91
|
"react-imask": "^7.6.1",
|
|
83
92
|
"react-router-dom": "^6.28.0",
|
|
84
|
-
"
|
|
85
|
-
"slick-carousel": "^1.8.1",
|
|
93
|
+
"tsc-esm-fix": "^3.1.2",
|
|
86
94
|
"typescript": "^5.8.3",
|
|
87
95
|
"typescript-eslint": "^8.34.1",
|
|
96
|
+
"vitest": "^4.1.10",
|
|
88
97
|
"zustand": "^5.0.5"
|
|
89
98
|
},
|
|
99
|
+
"lint-staged": {
|
|
100
|
+
"*.{ts,tsx}": [
|
|
101
|
+
"eslint --fix",
|
|
102
|
+
"prettier --write"
|
|
103
|
+
]
|
|
104
|
+
},
|
|
90
105
|
"peerDependencies": {
|
|
91
106
|
"bootstrap": "^5.0.0",
|
|
92
107
|
"dompurify": "^3.2.6",
|
|
@@ -97,10 +112,8 @@
|
|
|
97
112
|
"react-ga4": "^2.1.0",
|
|
98
113
|
"react-helmet-async": "^2.0.5",
|
|
99
114
|
"react-icons": "^5.3.0",
|
|
100
|
-
"react-router-dom": "^6.28.0 || ^7.0.0",
|
|
101
|
-
"react-slick": "^0.30.3",
|
|
102
|
-
"slick-carousel": "^1.8.1",
|
|
103
115
|
"react-imask": "^7.6.1",
|
|
116
|
+
"react-router-dom": "^6.28.0 || ^7.0.0",
|
|
104
117
|
"zustand": "^5.0.5"
|
|
105
118
|
}
|
|
106
119
|
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import DOMPurify from 'dompurify';
|
|
3
|
-
import { ElementColWrapper } from './ElementColWrapper.js';
|
|
4
|
-
export function FileElement({ element }) {
|
|
5
|
-
return (_jsx(ElementColWrapper, { element: element, children: _jsx("div", { dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(String(element.id)) } }) }));
|
|
6
|
-
}
|