lib-pixelbuild 0.1.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/LICENSE +15 -0
- package/README.md +176 -0
- package/dist/builders/PageBuilder.d.ts +7 -0
- package/dist/builders/PageBuilder.js +40 -0
- package/dist/components/CardComponent.d.ts +4 -0
- package/dist/components/CardComponent.js +13 -0
- package/dist/components/CarouselComponent.d.ts +4 -0
- package/dist/components/CarouselComponent.js +7 -0
- package/dist/components/FormComponent.d.ts +4 -0
- package/dist/components/FormComponent.js +26 -0
- package/dist/components/ListComponent.d.ts +4 -0
- package/dist/components/ListComponent.js +23 -0
- package/dist/components/LoadingComponent.d.ts +1 -0
- package/dist/components/LoadingComponent.js +5 -0
- package/dist/components/MapComponent.d.ts +4 -0
- package/dist/components/MapComponent.js +18 -0
- package/dist/components/SliderComponent.d.ts +5 -0
- package/dist/components/SliderComponent.js +16 -0
- package/dist/components/SocialIconsComponent.d.ts +4 -0
- package/dist/components/SocialIconsComponent.js +19 -0
- package/dist/components/TextComponent.d.ts +4 -0
- package/dist/components/TextComponent.js +13 -0
- package/dist/constants/ButtonActionEnum.d.ts +4 -0
- package/dist/constants/ButtonActionEnum.js +5 -0
- package/dist/constants/ComponentEnum.d.ts +17 -0
- package/dist/constants/ComponentEnum.js +16 -0
- package/dist/constants/ElementEnum.d.ts +18 -0
- package/dist/constants/ElementEnum.js +17 -0
- package/dist/constants/InputValidateEnum.d.ts +8 -0
- package/dist/constants/InputValidateEnum.js +9 -0
- package/dist/elements/AlertElement.d.ts +4 -0
- package/dist/elements/AlertElement.js +19 -0
- package/dist/elements/ButtonElement.d.ts +4 -0
- package/dist/elements/ButtonElement.js +50 -0
- package/dist/elements/ElementColWrapper.d.ts +6 -0
- package/dist/elements/ElementColWrapper.js +5 -0
- package/dist/elements/FileElement.d.ts +4 -0
- package/dist/elements/FileElement.js +6 -0
- package/dist/elements/IconElement.d.ts +4 -0
- package/dist/elements/IconElement.js +13 -0
- package/dist/elements/ImageElement.d.ts +4 -0
- package/dist/elements/ImageElement.js +6 -0
- package/dist/elements/InputElement.d.ts +4 -0
- package/dist/elements/InputElement.js +24 -0
- package/dist/elements/LinkElement.d.ts +4 -0
- package/dist/elements/LinkElement.js +6 -0
- package/dist/elements/TextElement.d.ts +4 -0
- package/dist/elements/TextElement.js +13 -0
- package/dist/factories/ButtonActionFactory.d.ts +5 -0
- package/dist/factories/ButtonActionFactory.js +13 -0
- package/dist/factories/ComponentFactory.d.ts +5 -0
- package/dist/factories/ComponentFactory.js +36 -0
- package/dist/factories/ElementFactory.d.ts +5 -0
- package/dist/factories/ElementFactory.js +42 -0
- package/dist/factories/InputValidateFactory.d.ts +9 -0
- package/dist/factories/InputValidateFactory.js +21 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +15 -0
- package/dist/layouts/Footer.d.ts +4 -0
- package/dist/layouts/Footer.js +11 -0
- package/dist/layouts/Header.d.ts +4 -0
- package/dist/layouts/Header.js +8 -0
- package/dist/layouts/Menu.d.ts +5 -0
- package/dist/layouts/Menu.js +34 -0
- package/dist/layouts/SiteLayout.d.ts +4 -0
- package/dist/layouts/SiteLayout.js +7 -0
- package/dist/renderers/SectionRenderer.d.ts +4 -0
- package/dist/renderers/SectionRenderer.js +39 -0
- package/dist/services/AnalyticsService.d.ts +8 -0
- package/dist/services/AnalyticsService.js +28 -0
- package/dist/services/ApiService.d.ts +5 -0
- package/dist/services/ApiService.js +17 -0
- package/dist/services/CacheService.d.ts +5 -0
- package/dist/services/CacheService.js +16 -0
- package/dist/services/ConstructorService.d.ts +12 -0
- package/dist/services/ConstructorService.js +33 -0
- package/dist/services/EmailService.d.ts +9 -0
- package/dist/services/EmailService.js +44 -0
- package/dist/services/InputValidateService.d.ts +17 -0
- package/dist/services/InputValidateService.js +31 -0
- package/dist/stores/UseFormStore.d.ts +32 -0
- package/dist/stores/UseFormStore.js +51 -0
- package/dist/types/AuthenticateResponseType.d.ts +5 -0
- package/dist/types/AuthenticateResponseType.js +1 -0
- package/dist/types/ButtonPropertiesType.d.ts +11 -0
- package/dist/types/ButtonPropertiesType.js +1 -0
- package/dist/types/ColumnWidthType.d.ts +7 -0
- package/dist/types/ColumnWidthType.js +1 -0
- package/dist/types/ComponentType.d.ts +11 -0
- package/dist/types/ComponentType.js +1 -0
- package/dist/types/ElementType.d.ts +11 -0
- package/dist/types/ElementType.js +1 -0
- package/dist/types/FilePropertiesType.d.ts +4 -0
- package/dist/types/FilePropertiesType.js +1 -0
- package/dist/types/FooterPropertiesType.d.ts +5 -0
- package/dist/types/FooterPropertiesType.js +1 -0
- package/dist/types/FooterType.d.ts +6 -0
- package/dist/types/FooterType.js +1 -0
- package/dist/types/FormFieldsType.d.ts +4 -0
- package/dist/types/FormFieldsType.js +1 -0
- package/dist/types/HeaderPropertiesType.d.ts +5 -0
- package/dist/types/HeaderPropertiesType.js +1 -0
- package/dist/types/HeaderType.d.ts +6 -0
- package/dist/types/HeaderType.js +1 -0
- package/dist/types/ImagePropertiesType.d.ts +4 -0
- package/dist/types/ImagePropertiesType.js +1 -0
- package/dist/types/InputPropertiesType.d.ts +7 -0
- package/dist/types/InputPropertiesType.js +1 -0
- package/dist/types/LinkPropertiesType.d.ts +4 -0
- package/dist/types/LinkPropertiesType.js +1 -0
- package/dist/types/MailBodyType.d.ts +8 -0
- package/dist/types/MailBodyType.js +1 -0
- package/dist/types/PageType.d.ts +17 -0
- package/dist/types/PageType.js +1 -0
- package/dist/types/PlanWebsiteType.d.ts +9 -0
- package/dist/types/PlanWebsiteType.js +1 -0
- package/dist/types/PropertiesType.d.ts +27 -0
- package/dist/types/PropertiesType.js +1 -0
- package/dist/types/RawWebsiteType.d.ts +346 -0
- package/dist/types/RawWebsiteType.js +1 -0
- package/dist/types/SectionColumnType.d.ts +14 -0
- package/dist/types/SectionColumnType.js +1 -0
- package/dist/types/SectionType.d.ts +10 -0
- package/dist/types/SectionType.js +1 -0
- package/dist/types/SocialPropertiesType.d.ts +11 -0
- package/dist/types/SocialPropertiesType.js +1 -0
- package/dist/types/StylesType.d.ts +35 -0
- package/dist/types/StylesType.js +1 -0
- package/dist/types/UserType.d.ts +10 -0
- package/dist/types/UserType.js +1 -0
- package/dist/types/WebsitePropertiesType.d.ts +5 -0
- package/dist/types/WebsitePropertiesType.js +1 -0
- package/dist/types/WebsiteType.d.ts +23 -0
- package/dist/types/WebsiteType.js +1 -0
- package/dist/utils/InputValidators.d.ts +14 -0
- package/dist/utils/InputValidators.js +88 -0
- package/package.json +90 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class EmailService {
|
|
2
|
+
constructor(urlApi) {
|
|
3
|
+
this.urlApi = urlApi;
|
|
4
|
+
}
|
|
5
|
+
async sendMail(params) {
|
|
6
|
+
try {
|
|
7
|
+
const body = this.createBody(params);
|
|
8
|
+
const response = await fetch(`${this.urlApi}/send-mail`, {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
headers: {
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
Authorization: `Bearer TOKEN`
|
|
13
|
+
},
|
|
14
|
+
body: JSON.stringify(body)
|
|
15
|
+
});
|
|
16
|
+
if (!response.ok) {
|
|
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));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
createBody(params) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
const firstName = params.find((e) => e.name === 'firstNameInput');
|
|
29
|
+
const lastName = params.find((e) => e.name === 'lastNameInput');
|
|
30
|
+
const birthDate = params.find((e) => e.name === 'birthDateField');
|
|
31
|
+
const document = params.find((e) => e.name === 'documentField');
|
|
32
|
+
const email = params.find((e) => e.name === 'emailField');
|
|
33
|
+
const phone = params.find((e) => e.name === 'phoneField');
|
|
34
|
+
return {
|
|
35
|
+
senderName: '[Site] CT Clean Foods',
|
|
36
|
+
sender: 'contato@nois.dev.br',
|
|
37
|
+
recipientName: 'CT Clean Foods',
|
|
38
|
+
recipient: 'lucas.2601@gmail.com',
|
|
39
|
+
title: 'Mensagem enviada pelo formulário do site',
|
|
40
|
+
message: `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 : ''}\nData de Nascimento: ${(_c = birthDate === null || birthDate === void 0 ? void 0 : birthDate.value) !== null && _c !== void 0 ? _c : ''}\nCPF: ${(_d = document === null || document === void 0 ? void 0 : document.value) !== null && _d !== void 0 ? _d : ''}\nE-mail: ${(_e = email === null || email === void 0 ? void 0 : email.value) !== null && _e !== void 0 ? _e : ''}\nCelular: ${(_f = phone === null || phone === void 0 ? void 0 : phone.value) !== null && _f !== void 0 ? _f : ''}`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export { EmailService };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface ValidationResult {
|
|
2
|
+
success: boolean;
|
|
3
|
+
message?: string;
|
|
4
|
+
[key: string]: string | boolean;
|
|
5
|
+
}
|
|
6
|
+
declare class InputValidateService {
|
|
7
|
+
nameValidation(name: string): ValidationResult;
|
|
8
|
+
birthDateValidation(birthDate: string): ValidationResult;
|
|
9
|
+
dateValidate(date: string): boolean;
|
|
10
|
+
emailValidation(email: string): ValidationResult;
|
|
11
|
+
emailValidate(email: string): boolean;
|
|
12
|
+
cpfValidation(cpf: string): ValidationResult;
|
|
13
|
+
cpfValidate(cpf: string): boolean;
|
|
14
|
+
phoneValidation(phone: string): ValidationResult;
|
|
15
|
+
phoneValidate(cel: string): boolean;
|
|
16
|
+
}
|
|
17
|
+
export { InputValidateService };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { nameValidation as nameValidationUtil, birthDateValidation as birthDateValidationUtil, dateValidate as dateValidateUtil, emailValidation as emailValidationUtil, emailValidate as emailValidateUtil, cpfValidation as cpfValidationUtil, cpfValidate as cpfValidateUtil, phoneValidation as phoneValidationUtil, phoneValidate as phoneValidateUtil } from '../utils/InputValidators.js';
|
|
2
|
+
class InputValidateService {
|
|
3
|
+
nameValidation(name) {
|
|
4
|
+
return nameValidationUtil(name);
|
|
5
|
+
}
|
|
6
|
+
birthDateValidation(birthDate) {
|
|
7
|
+
return birthDateValidationUtil(birthDate);
|
|
8
|
+
}
|
|
9
|
+
dateValidate(date) {
|
|
10
|
+
return dateValidateUtil(date);
|
|
11
|
+
}
|
|
12
|
+
emailValidation(email) {
|
|
13
|
+
return emailValidationUtil(email);
|
|
14
|
+
}
|
|
15
|
+
emailValidate(email) {
|
|
16
|
+
return emailValidateUtil(email);
|
|
17
|
+
}
|
|
18
|
+
cpfValidation(cpf) {
|
|
19
|
+
return cpfValidationUtil(cpf);
|
|
20
|
+
}
|
|
21
|
+
cpfValidate(cpf) {
|
|
22
|
+
return cpfValidateUtil(cpf);
|
|
23
|
+
}
|
|
24
|
+
phoneValidation(phone) {
|
|
25
|
+
return phoneValidationUtil(phone);
|
|
26
|
+
}
|
|
27
|
+
phoneValidate(cel) {
|
|
28
|
+
return phoneValidateUtil(cel);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export { InputValidateService };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface FormElement {
|
|
2
|
+
id: number;
|
|
3
|
+
name: string | null;
|
|
4
|
+
type: string | null;
|
|
5
|
+
formId: number | null;
|
|
6
|
+
value: string;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
hidden: boolean;
|
|
9
|
+
error: boolean;
|
|
10
|
+
errorMessage: string | null;
|
|
11
|
+
inputValidateId: number | null;
|
|
12
|
+
[key: string]: string | number | boolean | null;
|
|
13
|
+
}
|
|
14
|
+
export interface FormEntry {
|
|
15
|
+
elements: string[];
|
|
16
|
+
[key: string]: string[] | null;
|
|
17
|
+
}
|
|
18
|
+
export interface FormStoreState {
|
|
19
|
+
forms: Record<string, FormEntry>;
|
|
20
|
+
elements: Record<string, FormElement>;
|
|
21
|
+
registerForm: (formId: number) => void;
|
|
22
|
+
registerElement: (elementId: number, formId?: number | null, initialState?: Partial<FormElement>) => void;
|
|
23
|
+
validateFormData: (inputValidateId: number, elementId: number, value: string) => void;
|
|
24
|
+
validateAllFields: (formId: number) => void;
|
|
25
|
+
setElementState: (elementId: number, newState: Partial<FormElement>) => void;
|
|
26
|
+
getElementsByForm: (formId: number) => FormElement[];
|
|
27
|
+
showElement: (id: number) => void;
|
|
28
|
+
hideElement: (id: number) => void;
|
|
29
|
+
setLoading: (id: number, loading: boolean) => void;
|
|
30
|
+
}
|
|
31
|
+
declare const UseFormStore: import("zustand").UseBoundStore<import("zustand").StoreApi<FormStoreState>>;
|
|
32
|
+
export { UseFormStore };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { InputValidateFactory } from '../factories/InputValidateFactory.js';
|
|
3
|
+
const UseFormStore = create((set, get) => ({
|
|
4
|
+
forms: {},
|
|
5
|
+
elements: {},
|
|
6
|
+
registerForm: (formId) => set((state) => ({
|
|
7
|
+
forms: Object.assign(Object.assign({}, state.forms), { [formId]: state.forms[formId] || { elements: [] } })
|
|
8
|
+
})),
|
|
9
|
+
registerElement: (elementId, formId = null, initialState = {}) => set((state) => {
|
|
10
|
+
if (state.elements[elementId])
|
|
11
|
+
return {};
|
|
12
|
+
const newElements = Object.assign(Object.assign({}, state.elements), { [elementId]: Object.assign({ id: elementId, name: null, type: null, formId, value: null, loading: false, hidden: false, error: false, errorMessage: null, inputValidateId: null }, initialState) });
|
|
13
|
+
const newForms = Object.assign({}, state.forms);
|
|
14
|
+
if (formId) {
|
|
15
|
+
const existingForm = state.forms[formId] || { elements: [] };
|
|
16
|
+
const alreadyIncluded = existingForm.elements.includes(elementId.toString());
|
|
17
|
+
const updateElements = alreadyIncluded
|
|
18
|
+
? existingForm.elements
|
|
19
|
+
: [...existingForm.elements, elementId.toString()];
|
|
20
|
+
newForms[formId] = Object.assign(Object.assign({}, existingForm), { elements: updateElements });
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
elements: newElements,
|
|
24
|
+
forms: newForms
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
validateFormData: (inputValidateId, elementId, value) => {
|
|
28
|
+
const inputValidateFactory = new InputValidateFactory();
|
|
29
|
+
const validation = inputValidateFactory.build(inputValidateId, value);
|
|
30
|
+
get().setElementState(elementId, {
|
|
31
|
+
error: !validation.success,
|
|
32
|
+
errorMessage: validation.message
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
validateAllFields: (formId) => {
|
|
36
|
+
const elements = get().getElementsByForm(formId);
|
|
37
|
+
elements.forEach((element) => {
|
|
38
|
+
if (element.inputValidateId) {
|
|
39
|
+
get().validateFormData(element.inputValidateId, element.id, element.value);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
setElementState: (elementId, newState) => set((state) => ({
|
|
44
|
+
elements: Object.assign(Object.assign({}, state.elements), { [elementId]: Object.assign(Object.assign({}, state.elements[elementId]), newState) })
|
|
45
|
+
})),
|
|
46
|
+
getElementsByForm: (formId) => { var _a; return ((_a = get().forms[formId]) === null || _a === void 0 ? void 0 : _a.elements.map((id) => get().elements[id])) || []; },
|
|
47
|
+
showElement: (id) => get().setElementState(id, { hidden: false }),
|
|
48
|
+
hideElement: (id) => get().setElementState(id, { hidden: true }),
|
|
49
|
+
setLoading: (id, loading) => get().setElementState(id, { loading })
|
|
50
|
+
}));
|
|
51
|
+
export { UseFormStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PropertiesType } from './PropertiesType.js';
|
|
2
|
+
export interface ButtonPropertiesType extends PropertiesType {
|
|
3
|
+
path: string;
|
|
4
|
+
loadingTime: number;
|
|
5
|
+
hideOnClick: boolean;
|
|
6
|
+
actionId: number;
|
|
7
|
+
successActionId: number;
|
|
8
|
+
errorActionId: number;
|
|
9
|
+
successMessageId: number;
|
|
10
|
+
errorMessageId: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StylesType } from './StylesType.js';
|
|
2
|
+
import type { ElementType } from './ElementType.js';
|
|
3
|
+
export interface ComponentType {
|
|
4
|
+
id: number;
|
|
5
|
+
componentType: string;
|
|
6
|
+
sort: number;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
properties: Record<string, unknown>;
|
|
9
|
+
styles: StylesType;
|
|
10
|
+
elements: ElementType[];
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StylesType } from './StylesType.js';
|
|
2
|
+
import type { ColumnWidthType } from './ColumnWidthType.js';
|
|
3
|
+
export interface ElementType {
|
|
4
|
+
id: number;
|
|
5
|
+
elementType: string;
|
|
6
|
+
sort: number;
|
|
7
|
+
properties: Record<string, unknown>;
|
|
8
|
+
styles: StylesType;
|
|
9
|
+
width: ColumnWidthType;
|
|
10
|
+
offset: ColumnWidthType;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StylesType } from './StylesType.js';
|
|
2
|
+
import type { SectionType } from './SectionType.js';
|
|
3
|
+
export interface PageType {
|
|
4
|
+
id: number;
|
|
5
|
+
websiteId: number;
|
|
6
|
+
title: string;
|
|
7
|
+
slug: string;
|
|
8
|
+
path: string;
|
|
9
|
+
status: 'draft' | 'published';
|
|
10
|
+
sort: number;
|
|
11
|
+
menu: boolean;
|
|
12
|
+
menuOrder: number;
|
|
13
|
+
menuType: 'link' | 'dropdown';
|
|
14
|
+
properties: Record<string, unknown>;
|
|
15
|
+
styles: StylesType;
|
|
16
|
+
sections: SectionType[];
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface PropertiesType {
|
|
2
|
+
name?: string;
|
|
3
|
+
title?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
startHidden?: boolean;
|
|
7
|
+
path?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
size?: {
|
|
10
|
+
xs?: {
|
|
11
|
+
span?: number;
|
|
12
|
+
offset?: number;
|
|
13
|
+
};
|
|
14
|
+
sm?: {
|
|
15
|
+
span?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
};
|
|
18
|
+
md?: {
|
|
19
|
+
span?: number;
|
|
20
|
+
offset?: number;
|
|
21
|
+
};
|
|
22
|
+
lg?: {
|
|
23
|
+
span?: number;
|
|
24
|
+
offset?: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|