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.
Files changed (137) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +176 -0
  3. package/dist/builders/PageBuilder.d.ts +7 -0
  4. package/dist/builders/PageBuilder.js +40 -0
  5. package/dist/components/CardComponent.d.ts +4 -0
  6. package/dist/components/CardComponent.js +13 -0
  7. package/dist/components/CarouselComponent.d.ts +4 -0
  8. package/dist/components/CarouselComponent.js +7 -0
  9. package/dist/components/FormComponent.d.ts +4 -0
  10. package/dist/components/FormComponent.js +26 -0
  11. package/dist/components/ListComponent.d.ts +4 -0
  12. package/dist/components/ListComponent.js +23 -0
  13. package/dist/components/LoadingComponent.d.ts +1 -0
  14. package/dist/components/LoadingComponent.js +5 -0
  15. package/dist/components/MapComponent.d.ts +4 -0
  16. package/dist/components/MapComponent.js +18 -0
  17. package/dist/components/SliderComponent.d.ts +5 -0
  18. package/dist/components/SliderComponent.js +16 -0
  19. package/dist/components/SocialIconsComponent.d.ts +4 -0
  20. package/dist/components/SocialIconsComponent.js +19 -0
  21. package/dist/components/TextComponent.d.ts +4 -0
  22. package/dist/components/TextComponent.js +13 -0
  23. package/dist/constants/ButtonActionEnum.d.ts +4 -0
  24. package/dist/constants/ButtonActionEnum.js +5 -0
  25. package/dist/constants/ComponentEnum.d.ts +17 -0
  26. package/dist/constants/ComponentEnum.js +16 -0
  27. package/dist/constants/ElementEnum.d.ts +18 -0
  28. package/dist/constants/ElementEnum.js +17 -0
  29. package/dist/constants/InputValidateEnum.d.ts +8 -0
  30. package/dist/constants/InputValidateEnum.js +9 -0
  31. package/dist/elements/AlertElement.d.ts +4 -0
  32. package/dist/elements/AlertElement.js +19 -0
  33. package/dist/elements/ButtonElement.d.ts +4 -0
  34. package/dist/elements/ButtonElement.js +50 -0
  35. package/dist/elements/ElementColWrapper.d.ts +6 -0
  36. package/dist/elements/ElementColWrapper.js +5 -0
  37. package/dist/elements/FileElement.d.ts +4 -0
  38. package/dist/elements/FileElement.js +6 -0
  39. package/dist/elements/IconElement.d.ts +4 -0
  40. package/dist/elements/IconElement.js +13 -0
  41. package/dist/elements/ImageElement.d.ts +4 -0
  42. package/dist/elements/ImageElement.js +6 -0
  43. package/dist/elements/InputElement.d.ts +4 -0
  44. package/dist/elements/InputElement.js +24 -0
  45. package/dist/elements/LinkElement.d.ts +4 -0
  46. package/dist/elements/LinkElement.js +6 -0
  47. package/dist/elements/TextElement.d.ts +4 -0
  48. package/dist/elements/TextElement.js +13 -0
  49. package/dist/factories/ButtonActionFactory.d.ts +5 -0
  50. package/dist/factories/ButtonActionFactory.js +13 -0
  51. package/dist/factories/ComponentFactory.d.ts +5 -0
  52. package/dist/factories/ComponentFactory.js +36 -0
  53. package/dist/factories/ElementFactory.d.ts +5 -0
  54. package/dist/factories/ElementFactory.js +42 -0
  55. package/dist/factories/InputValidateFactory.d.ts +9 -0
  56. package/dist/factories/InputValidateFactory.js +21 -0
  57. package/dist/index.d.ts +27 -0
  58. package/dist/index.js +15 -0
  59. package/dist/layouts/Footer.d.ts +4 -0
  60. package/dist/layouts/Footer.js +11 -0
  61. package/dist/layouts/Header.d.ts +4 -0
  62. package/dist/layouts/Header.js +8 -0
  63. package/dist/layouts/Menu.d.ts +5 -0
  64. package/dist/layouts/Menu.js +34 -0
  65. package/dist/layouts/SiteLayout.d.ts +4 -0
  66. package/dist/layouts/SiteLayout.js +7 -0
  67. package/dist/renderers/SectionRenderer.d.ts +4 -0
  68. package/dist/renderers/SectionRenderer.js +39 -0
  69. package/dist/services/AnalyticsService.d.ts +8 -0
  70. package/dist/services/AnalyticsService.js +28 -0
  71. package/dist/services/ApiService.d.ts +5 -0
  72. package/dist/services/ApiService.js +17 -0
  73. package/dist/services/CacheService.d.ts +5 -0
  74. package/dist/services/CacheService.js +16 -0
  75. package/dist/services/ConstructorService.d.ts +12 -0
  76. package/dist/services/ConstructorService.js +33 -0
  77. package/dist/services/EmailService.d.ts +9 -0
  78. package/dist/services/EmailService.js +44 -0
  79. package/dist/services/InputValidateService.d.ts +17 -0
  80. package/dist/services/InputValidateService.js +31 -0
  81. package/dist/stores/UseFormStore.d.ts +32 -0
  82. package/dist/stores/UseFormStore.js +51 -0
  83. package/dist/types/AuthenticateResponseType.d.ts +5 -0
  84. package/dist/types/AuthenticateResponseType.js +1 -0
  85. package/dist/types/ButtonPropertiesType.d.ts +11 -0
  86. package/dist/types/ButtonPropertiesType.js +1 -0
  87. package/dist/types/ColumnWidthType.d.ts +7 -0
  88. package/dist/types/ColumnWidthType.js +1 -0
  89. package/dist/types/ComponentType.d.ts +11 -0
  90. package/dist/types/ComponentType.js +1 -0
  91. package/dist/types/ElementType.d.ts +11 -0
  92. package/dist/types/ElementType.js +1 -0
  93. package/dist/types/FilePropertiesType.d.ts +4 -0
  94. package/dist/types/FilePropertiesType.js +1 -0
  95. package/dist/types/FooterPropertiesType.d.ts +5 -0
  96. package/dist/types/FooterPropertiesType.js +1 -0
  97. package/dist/types/FooterType.d.ts +6 -0
  98. package/dist/types/FooterType.js +1 -0
  99. package/dist/types/FormFieldsType.d.ts +4 -0
  100. package/dist/types/FormFieldsType.js +1 -0
  101. package/dist/types/HeaderPropertiesType.d.ts +5 -0
  102. package/dist/types/HeaderPropertiesType.js +1 -0
  103. package/dist/types/HeaderType.d.ts +6 -0
  104. package/dist/types/HeaderType.js +1 -0
  105. package/dist/types/ImagePropertiesType.d.ts +4 -0
  106. package/dist/types/ImagePropertiesType.js +1 -0
  107. package/dist/types/InputPropertiesType.d.ts +7 -0
  108. package/dist/types/InputPropertiesType.js +1 -0
  109. package/dist/types/LinkPropertiesType.d.ts +4 -0
  110. package/dist/types/LinkPropertiesType.js +1 -0
  111. package/dist/types/MailBodyType.d.ts +8 -0
  112. package/dist/types/MailBodyType.js +1 -0
  113. package/dist/types/PageType.d.ts +17 -0
  114. package/dist/types/PageType.js +1 -0
  115. package/dist/types/PlanWebsiteType.d.ts +9 -0
  116. package/dist/types/PlanWebsiteType.js +1 -0
  117. package/dist/types/PropertiesType.d.ts +27 -0
  118. package/dist/types/PropertiesType.js +1 -0
  119. package/dist/types/RawWebsiteType.d.ts +346 -0
  120. package/dist/types/RawWebsiteType.js +1 -0
  121. package/dist/types/SectionColumnType.d.ts +14 -0
  122. package/dist/types/SectionColumnType.js +1 -0
  123. package/dist/types/SectionType.d.ts +10 -0
  124. package/dist/types/SectionType.js +1 -0
  125. package/dist/types/SocialPropertiesType.d.ts +11 -0
  126. package/dist/types/SocialPropertiesType.js +1 -0
  127. package/dist/types/StylesType.d.ts +35 -0
  128. package/dist/types/StylesType.js +1 -0
  129. package/dist/types/UserType.d.ts +10 -0
  130. package/dist/types/UserType.js +1 -0
  131. package/dist/types/WebsitePropertiesType.d.ts +5 -0
  132. package/dist/types/WebsitePropertiesType.js +1 -0
  133. package/dist/types/WebsiteType.d.ts +23 -0
  134. package/dist/types/WebsiteType.js +1 -0
  135. package/dist/utils/InputValidators.d.ts +14 -0
  136. package/dist/utils/InputValidators.js +88 -0
  137. package/package.json +90 -0
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from 'react';
2
+ import type { ElementType } from '../types/ElementType.js';
3
+ export declare function ElementColWrapper({ element, children }: {
4
+ readonly element: ElementType;
5
+ readonly children: ReactNode;
6
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Col } from 'react-bootstrap';
3
+ export function ElementColWrapper({ element, children }) {
4
+ return (_jsx(Col, { xs: element.width.xs, sm: element.width.sm, md: element.width.md, lg: element.width.lg, xl: element.width.xl, style: element.styles, children: children }, element.id));
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function FileElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function IconElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { Suspense } from 'react';
3
+ import { ElementColWrapper } from './ElementColWrapper.js';
4
+ export function IconElement({ element }) {
5
+ const name = String(element.properties.name || '');
6
+ const LazyIcon = React.lazy(() => import('react-icons/fa').then((module) => {
7
+ const Icon = module[name];
8
+ if (!Icon)
9
+ throw new Error(`Icon '${name}' not found in pack`);
10
+ return { default: Icon };
11
+ }));
12
+ return (_jsx(ElementColWrapper, { element: element, children: _jsx(Suspense, { fallback: null, children: _jsx(LazyIcon, { size: 20, style: element.styles }) }) }));
13
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function ImageElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ElementColWrapper } from './ElementColWrapper.js';
3
+ export function ImageElement({ element }) {
4
+ const properties = element.properties;
5
+ return (_jsx(ElementColWrapper, { element: element, children: _jsx("img", { src: String(properties.src || properties.path || ''), alt: String(properties.alt || properties.title || ''), style: element.styles }) }));
6
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function InputElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from 'react';
3
+ import { Form } from 'react-bootstrap';
4
+ import InputMask from 'react-input-mask';
5
+ import { ElementColWrapper } from './ElementColWrapper.js';
6
+ import { UseFormStore } from '../stores/UseFormStore.js';
7
+ export function InputElement({ element }) {
8
+ const properties = element.properties;
9
+ const hidden = UseFormStore((state) => { var _a; return (_a = state.elements[element.id]) === null || _a === void 0 ? void 0 : _a.hidden; });
10
+ const error = UseFormStore((state) => { var _a; return (_a = state.elements[element.id]) === null || _a === void 0 ? void 0 : _a.error; });
11
+ const errorMessage = UseFormStore((state) => { var _a; return (_a = state.elements[element.id]) === null || _a === void 0 ? void 0 : _a.errorMessage; });
12
+ const registerElement = UseFormStore((state) => state.registerElement);
13
+ const validateFormData = UseFormStore((state) => state.validateFormData);
14
+ useEffect(() => {
15
+ registerElement(element.id, properties.componentId, {
16
+ name: String(properties.name || ''),
17
+ type: 'input',
18
+ inputValidateId: properties.inputValidateId
19
+ });
20
+ }, [element.id, properties.name, properties.inputValidateId, registerElement]);
21
+ if (hidden)
22
+ return null;
23
+ return (_jsx(ElementColWrapper, { element: element, children: _jsxs(Form.Group, { className: "mb-3", controlId: String(properties.name || ''), children: [_jsx(Form.Label, { children: String(properties.title || '') }), _jsx(Form.Control, { as: InputMask, mask: String(properties.mask || ''), onChange: (e) => UseFormStore.getState().setElementState(element.id, { value: e.target.value }), onBlur: (e) => validateFormData(properties.inputValidateId, element.id, e.target.value), required: Boolean(properties.required), name: String(properties.name || ''), placeholder: String(properties.placeholder || ''), isInvalid: !!error, style: element.styles }), _jsx(Form.Control.Feedback, { type: "invalid", children: errorMessage })] }) }));
24
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function LinkElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ElementColWrapper } from './ElementColWrapper.js';
3
+ export function LinkElement({ element }) {
4
+ const properties = element.properties;
5
+ return (_jsx(ElementColWrapper, { element: element, children: _jsx("a", { href: String(properties.href || properties.path || '#'), target: String(properties.target || '_self'), rel: "noopener noreferrer", style: element.styles, children: String(properties.text || properties.title || '') }) }));
6
+ }
@@ -0,0 +1,4 @@
1
+ import type { ElementType } from '../types/ElementType.js';
2
+ export declare function TextElement({ element }: {
3
+ readonly element: ElementType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import DOMPurify from 'dompurify';
3
+ import { ElementColWrapper } from './ElementColWrapper.js';
4
+ export function TextElement({ element }) {
5
+ const properties = element.properties;
6
+ const text = String(properties.text || properties.title || properties.message || '');
7
+ if (element.elementType === 'title') {
8
+ const tag = String(properties.tag || 'h2');
9
+ const TitleTag = tag;
10
+ return (_jsx(ElementColWrapper, { element: element, children: _jsx(TitleTag, { style: element.styles, children: text }) }));
11
+ }
12
+ return (_jsx(ElementColWrapper, { element: element, children: _jsx("div", { dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(text) }, style: element.styles }) }));
13
+ }
@@ -0,0 +1,5 @@
1
+ import type { FormFieldsType } from '../types/FormFieldsType.js';
2
+ import type { MailBodyType } from '../types/MailBodyType.js';
3
+ export declare class ButtonActionFactory {
4
+ build(actionId: number, data: FormFieldsType[]): Promise<MailBodyType | boolean>;
5
+ }
@@ -0,0 +1,13 @@
1
+ import { EmailService } from '../services/EmailService.js';
2
+ import { ButtonActionEnum } from '../constants/ButtonActionEnum.js';
3
+ export class ButtonActionFactory {
4
+ async build(actionId, data) {
5
+ const emailService = new EmailService('https://api.example.com');
6
+ switch (actionId) {
7
+ case ButtonActionEnum.SendMail:
8
+ return emailService.sendMail(data);
9
+ default:
10
+ throw new Error('Invalid button action: ' + actionId);
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { ComponentType } from '../types/ComponentType.js';
3
+ export declare class ComponentFactory {
4
+ build(component: ComponentType): React.ReactElement | null;
5
+ }
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ComponentTypeEnum } from '../constants/ComponentEnum.js';
3
+ import { TextComponent } from '../components/TextComponent.js';
4
+ import { ListComponent } from '../components/ListComponent.js';
5
+ import { CarouselComponent } from '../components/CarouselComponent.js';
6
+ import { FormComponent } from '../components/FormComponent.js';
7
+ import { SliderComponent } from '../components/SliderComponent.js';
8
+ import { CardComponent } from '../components/CardComponent.js';
9
+ import { MapComponent } from '../components/MapComponent.js';
10
+ export class ComponentFactory {
11
+ build(component) {
12
+ switch (component.componentType) {
13
+ case ComponentTypeEnum.Text:
14
+ case ComponentTypeEnum.TextWithImage:
15
+ case ComponentTypeEnum.HeroBanner:
16
+ return _jsx(TextComponent, { component: component }, component.id);
17
+ case ComponentTypeEnum.List:
18
+ return _jsx(ListComponent, { component: component }, component.id);
19
+ case ComponentTypeEnum.Slider:
20
+ case ComponentTypeEnum.Gallery:
21
+ case ComponentTypeEnum.Testimonials:
22
+ return _jsx(SliderComponent, { component: component }, component.id);
23
+ case ComponentTypeEnum.Form:
24
+ return _jsx(FormComponent, { component: component }, component.id);
25
+ case ComponentTypeEnum.Card:
26
+ case ComponentTypeEnum.Faq:
27
+ return _jsx(CardComponent, { component: component }, component.id);
28
+ case ComponentTypeEnum.Image:
29
+ return _jsx(CarouselComponent, { component: component }, component.id);
30
+ case ComponentTypeEnum.Map:
31
+ return _jsx(MapComponent, { component: component }, component.id);
32
+ default:
33
+ throw new Error('Invalid component type: ' + component.componentType);
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { ElementType } from '../types/ElementType.js';
3
+ export declare class ElementFactory {
4
+ build(element: ElementType): React.ReactElement | null;
5
+ }
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ElementTypeEnum } from '../constants/ElementEnum.js';
3
+ import { TextElement } from '../elements/TextElement.js';
4
+ import { ImageElement } from '../elements/ImageElement.js';
5
+ import { InputElement } from '../elements/InputElement.js';
6
+ import { IconElement } from '../elements/IconElement.js';
7
+ import { ButtonElement } from '../elements/ButtonElement.js';
8
+ import { FileElement } from '../elements/FileElement.js';
9
+ import { AlertElement } from '../elements/AlertElement.js';
10
+ import { LinkElement } from '../elements/LinkElement.js';
11
+ export class ElementFactory {
12
+ build(element) {
13
+ switch (element.elementType) {
14
+ case ElementTypeEnum.Text:
15
+ case ElementTypeEnum.Textarea:
16
+ case ElementTypeEnum.Title:
17
+ return _jsx(TextElement, { element: element }, element.id);
18
+ case ElementTypeEnum.Image:
19
+ case ElementTypeEnum.Video:
20
+ return _jsx(ImageElement, { element: element }, element.id);
21
+ case ElementTypeEnum.Input:
22
+ case ElementTypeEnum.Select:
23
+ case ElementTypeEnum.Checkbox:
24
+ case ElementTypeEnum.Radio:
25
+ return _jsx(InputElement, { element: element }, element.id);
26
+ case ElementTypeEnum.Icon:
27
+ return _jsx(IconElement, { element: element }, element.id);
28
+ case ElementTypeEnum.Button:
29
+ return _jsx(ButtonElement, { element: element }, element.id);
30
+ case ElementTypeEnum.File:
31
+ return _jsx(FileElement, { element: element }, element.id);
32
+ case ElementTypeEnum.Alert:
33
+ return _jsx(AlertElement, { element: element }, element.id);
34
+ case ElementTypeEnum.Link:
35
+ return _jsx(LinkElement, { element: element }, element.id);
36
+ case ElementTypeEnum.Divider:
37
+ return _jsx("hr", { style: element.styles }, element.id);
38
+ default:
39
+ throw new Error('Invalid element type: ' + element.elementType);
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,9 @@
1
+ type ValidationResult = {
2
+ success: boolean;
3
+ message?: string;
4
+ [key: string]: string | boolean;
5
+ };
6
+ export declare class InputValidateFactory {
7
+ build(input_validate_type: number, value: string): ValidationResult;
8
+ }
9
+ export {};
@@ -0,0 +1,21 @@
1
+ import { InputValidateService } from '../services/InputValidateService.js';
2
+ import { InputValidateEnum } from '../constants/InputValidateEnum.js';
3
+ export class InputValidateFactory {
4
+ build(input_validate_type, value) {
5
+ const inputValidateService = new InputValidateService();
6
+ switch (input_validate_type) {
7
+ case InputValidateEnum.Name:
8
+ return inputValidateService.nameValidation(value);
9
+ case InputValidateEnum.Email:
10
+ return inputValidateService.emailValidation(value);
11
+ case InputValidateEnum.Cpf:
12
+ return inputValidateService.cpfValidation(value);
13
+ case InputValidateEnum.Phone:
14
+ return inputValidateService.phoneValidation(value);
15
+ case InputValidateEnum.BirthDate:
16
+ return inputValidateService.birthDateValidation(value);
17
+ default:
18
+ throw new Error('Input validate not found: ' + input_validate_type);
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,27 @@
1
+ export type { RawWebsiteType } from './types/RawWebsiteType.js';
2
+ export type { WebsiteType } from './types/WebsiteType.js';
3
+ export type { PageType } from './types/PageType.js';
4
+ export type { SectionType } from './types/SectionType.js';
5
+ export type { SectionColumnType } from './types/SectionColumnType.js';
6
+ export type { ColumnWidthType } from './types/ColumnWidthType.js';
7
+ export type { ComponentType } from './types/ComponentType.js';
8
+ export type { ElementType } from './types/ElementType.js';
9
+ export type { PropertiesType } from './types/PropertiesType.js';
10
+ export type { StylesType } from './types/StylesType.js';
11
+ export type { UserType } from './types/UserType.js';
12
+ export type { AuthenticateResponseType } from './types/AuthenticateResponseType.js';
13
+ export { Header } from './layouts/Header.js';
14
+ export { Footer } from './layouts/Footer.js';
15
+ export { SiteLayout } from './layouts/SiteLayout.js';
16
+ export { PageBuilder } from './builders/PageBuilder.js';
17
+ export { SectionRenderer } from './renderers/SectionRenderer.js';
18
+ export { LoadingComponent } from './components/LoadingComponent.js';
19
+ export { ComponentFactory } from './factories/ComponentFactory.js';
20
+ export { ElementFactory } from './factories/ElementFactory.js';
21
+ export { ComponentTypeEnum } from './constants/ComponentEnum.js';
22
+ export { ElementTypeEnum } from './constants/ElementEnum.js';
23
+ export { ApiService } from './services/ApiService.js';
24
+ export { analyticsService } from './services/AnalyticsService.js';
25
+ export { CacheService } from './services/CacheService.js';
26
+ export { ConstructorService } from './services/ConstructorService.js';
27
+ export { EmailService } from './services/EmailService.js';
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export { Header } from './layouts/Header.js';
2
+ export { Footer } from './layouts/Footer.js';
3
+ export { SiteLayout } from './layouts/SiteLayout.js';
4
+ export { PageBuilder } from './builders/PageBuilder.js';
5
+ export { SectionRenderer } from './renderers/SectionRenderer.js';
6
+ export { LoadingComponent } from './components/LoadingComponent.js';
7
+ export { ComponentFactory } from './factories/ComponentFactory.js';
8
+ export { ElementFactory } from './factories/ElementFactory.js';
9
+ export { ComponentTypeEnum } from './constants/ComponentEnum.js';
10
+ export { ElementTypeEnum } from './constants/ElementEnum.js';
11
+ export { ApiService } from './services/ApiService.js';
12
+ export { analyticsService } from './services/AnalyticsService.js';
13
+ export { CacheService } from './services/CacheService.js';
14
+ export { ConstructorService } from './services/ConstructorService.js';
15
+ export { EmailService } from './services/EmailService.js';
@@ -0,0 +1,4 @@
1
+ import { WebsiteType } from '../types/WebsiteType.js';
2
+ export declare function Footer({ website }: {
3
+ readonly website: WebsiteType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import DOMPurify from 'dompurify';
3
+ import { Container, Row, Col } from 'react-bootstrap';
4
+ import { SocialIconsComponent } from '../components/SocialIconsComponent.js';
5
+ export function Footer({ website }) {
6
+ var _a;
7
+ const social = (_a = website.properties) === null || _a === void 0 ? void 0 : _a.social;
8
+ const footer = website.footer.properties;
9
+ const styles = website.footer.styles;
10
+ return (_jsx(Container, { fluid: styles.fluid || undefined, style: { backgroundColor: styles.backgroundColor }, children: _jsxs(Row, { id: 'footer', style: styles, children: [_jsx(Col, { xs: 12, sm: 12, md: 12, lg: 12, className: "d-flex justify-content-center", style: { marginBottom: '30px' }, children: social && (_jsx(SocialIconsComponent, { social: social })) }), _jsx(Col, { xs: 12, sm: 12, md: 12, lg: 12, className: "d-flex flex-column align-items-center", style: { padding: '20px' }, dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(footer.text1) } }), _jsx(Col, { xs: 12, sm: 12, md: 12, lg: 12, className: "d-flex flex-column align-items-center", style: { padding: '20px' }, dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(footer.text2) } }), _jsx(Col, { xs: 12, sm: 12, md: 12, lg: 12, className: "d-flex justify-content-center", dangerouslySetInnerHTML: { __html: DOMPurify.sanitize(footer.text3) } }), _jsxs(Col, { xs: 12, sm: 12, md: 12, lg: 12, children: [_jsx("hr", { className: "footer-divider" }), _jsxs("p", { className: "text-center mb-0", children: ["\u00A9 ", new Date().getFullYear(), " ", website.name] })] })] }) }));
11
+ }
@@ -0,0 +1,4 @@
1
+ import type { WebsiteType } from '../types/WebsiteType.js';
2
+ export declare function Header({ website }: {
3
+ readonly website: WebsiteType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Container, Row, Col } from 'react-bootstrap';
3
+ export function Header({ website }) {
4
+ const headerProperties = website.header.properties;
5
+ const headerStyles = website.header.styles;
6
+ const domain = website.domain.replaceAll('.', '');
7
+ return (_jsx(Container, { fluid: headerStyles.fluid || undefined, style: { backgroundColor: headerStyles.backgroundColor }, children: _jsxs(Row, { id: "header", children: [_jsx(Col, { xs: 3, md: 3, lg: 3, style: Object.assign({ display: headerProperties.showLogo ? 'block' : 'none' }, headerStyles), children: _jsx("img", { src: `https://noisdev-website-images.s3.sa-east-1.amazonaws.com/${domain}/${website.logo}`, width: "200", className: "d-inline-block align-top", alt: "Logo", style: { textAlign: headerProperties.logoAlign } }) }), _jsx(Col, { lg: 2, children: "Social Icons" }), _jsx(Col, { lg: 3, children: "Email" }), _jsx(Col, { lg: 2, children: "Liga\u00E7\u00F5es" }), _jsx(Col, { lg: 2, children: "Localiza\u00E7\u00E3o" })] }) }));
8
+ }
@@ -0,0 +1,5 @@
1
+ import type { PageType } from '../types/PageType.js';
2
+ export declare function Menu({ page, websitePages }: {
3
+ readonly page?: PageType;
4
+ readonly websitePages?: PageType[];
5
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,34 @@
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
+ }
@@ -0,0 +1,4 @@
1
+ import type { WebsiteType } from '../types/WebsiteType.js';
2
+ export declare function SiteLayout({ website }: {
3
+ readonly website: WebsiteType;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Outlet } from 'react-router-dom';
3
+ import { Header } from './Header.js';
4
+ import { Footer } from './Footer.js';
5
+ export function SiteLayout({ website }) {
6
+ return (_jsxs("div", { id: "site-layout", style: { backgroundColor: website.styles.backgroundColor, color: website.styles.color }, children: [_jsx(Header, { website: website }), _jsx(Outlet, {}), _jsx(Footer, { website: website })] }));
7
+ }
@@ -0,0 +1,4 @@
1
+ import type { SectionType } from '../types/SectionType.js';
2
+ export declare function SectionRenderer({ sections }: {
3
+ readonly sections: SectionType[];
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Container, Row, Col } from 'react-bootstrap';
4
+ import { ComponentFactory } from '../factories/ComponentFactory.js';
5
+ function colWidthValue(width, offset) {
6
+ if (width === undefined && offset === undefined)
7
+ return undefined;
8
+ if (offset !== undefined) {
9
+ return { span: width !== null && width !== void 0 ? width : 12, offset };
10
+ }
11
+ return width;
12
+ }
13
+ function renderSection(section) {
14
+ const content = (_jsx(Row, { id: `section-${section.id}`, style: section.sectionType === 'row' ? section.styles : undefined, children: section.columns.map(renderColumn) }));
15
+ if (section.sectionType === 'container-fluid') {
16
+ return _jsx(Container, { fluid: true, style: section.styles, children: content });
17
+ }
18
+ if (section.sectionType === 'container') {
19
+ return _jsx(Container, { style: section.styles, children: content });
20
+ }
21
+ return content;
22
+ }
23
+ function renderColumn(column) {
24
+ const componentFactory = new ComponentFactory();
25
+ return (_jsxs(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: [column.components
26
+ .filter((c) => c.enabled)
27
+ .sort((a, b) => a.sort - b.sort)
28
+ .map((component) => componentFactory.build(component)), column.childSections
29
+ .sort((a, b) => a.sort - b.sort)
30
+ .map((childSection) => renderSection(childSection))] }, column.id));
31
+ }
32
+ export function SectionRenderer({ sections }) {
33
+ if (!sections || sections.length === 0) {
34
+ return null;
35
+ }
36
+ return (_jsx(_Fragment, { children: sections
37
+ .sort((a, b) => a.sort - b.sort)
38
+ .map((section) => (_jsx(React.Fragment, { children: renderSection(section) }, section.id))) }));
39
+ }
@@ -0,0 +1,8 @@
1
+ declare class AnalyticsService {
2
+ private initialized;
3
+ initialize(trackingId: string): void;
4
+ pageView(page: string, title: string): void;
5
+ sendEvent(category: string, action: string, label?: string, value?: number): void;
6
+ }
7
+ export declare const analyticsService: AnalyticsService;
8
+ export {};
@@ -0,0 +1,28 @@
1
+ var _a;
2
+ import ReactGAImport from 'react-ga4';
3
+ const ReactGA = (_a = ReactGAImport === null || ReactGAImport === void 0 ? void 0 : ReactGAImport.default) !== null && _a !== void 0 ? _a : ReactGAImport;
4
+ class AnalyticsService {
5
+ constructor() {
6
+ this.initialized = false;
7
+ }
8
+ initialize(trackingId) {
9
+ if (!trackingId || this.initialized)
10
+ return;
11
+ ReactGA.initialize(trackingId);
12
+ this.initialized = true;
13
+ }
14
+ pageView(page, title) {
15
+ ReactGA.send({ hitType: "pageview", page: page, title: title });
16
+ }
17
+ sendEvent(category, action, label, value) {
18
+ ReactGA.event({
19
+ category: category,
20
+ action: action,
21
+ label: label,
22
+ value: value,
23
+ nonInteraction: true,
24
+ transport: "xhr",
25
+ });
26
+ }
27
+ }
28
+ export const analyticsService = new AnalyticsService();
@@ -0,0 +1,5 @@
1
+ import type { RawWebsiteType } from '../types/RawWebsiteType.js';
2
+ declare class ApiService {
3
+ getStructure(websiteId: number, apiUrl: string): Promise<RawWebsiteType>;
4
+ }
5
+ export { ApiService };
@@ -0,0 +1,17 @@
1
+ class ApiService {
2
+ async getStructure(websiteId, apiUrl) {
3
+ try {
4
+ const response = await fetch(`${apiUrl}/website/${websiteId}/structure`);
5
+ if (!response.ok) {
6
+ throw new Error(response.status.toString());
7
+ }
8
+ const json = await response.json();
9
+ return json.data;
10
+ }
11
+ catch (error) {
12
+ console.error('Erro ao buscar dados da API:', error);
13
+ throw new Error(error instanceof Error ? error.message : JSON.stringify(error));
14
+ }
15
+ }
16
+ }
17
+ export { ApiService };
@@ -0,0 +1,5 @@
1
+ import type { RawWebsiteType } from '../types/RawWebsiteType.js';
2
+ declare class CacheService {
3
+ getStructure(): RawWebsiteType;
4
+ }
5
+ export { CacheService };
@@ -0,0 +1,16 @@
1
+ class CacheService {
2
+ getStructure() {
3
+ try {
4
+ const cachedData = localStorage.getItem('websiteData');
5
+ if (!cachedData) {
6
+ throw new Error('Sem dados em cache');
7
+ }
8
+ return JSON.parse(cachedData);
9
+ }
10
+ catch (error) {
11
+ console.error('Erro ao buscar dados do cache:', error);
12
+ throw new Error(error instanceof Error ? error.message : JSON.stringify(error));
13
+ }
14
+ }
15
+ }
16
+ export { CacheService };
@@ -0,0 +1,12 @@
1
+ import type { RawWebsiteType } from '../types/RawWebsiteType.js';
2
+ declare class ConstructorService {
3
+ fetchWebsiteFromApi(websiteId: number, apiUrl: string): Promise<RawWebsiteType>;
4
+ fetchWebsiteFromCache(): Promise<RawWebsiteType>;
5
+ fetchMenu(): Promise<{
6
+ id: number;
7
+ name: string;
8
+ path: string;
9
+ type: 'link';
10
+ }[]>;
11
+ }
12
+ export { ConstructorService };
@@ -0,0 +1,33 @@
1
+ import { ApiService } from './ApiService.js';
2
+ import { CacheService } from './CacheService.js';
3
+ class ConstructorService {
4
+ async fetchWebsiteFromApi(websiteId, apiUrl) {
5
+ const apiService = new ApiService();
6
+ const website = await apiService.getStructure(websiteId, apiUrl);
7
+ if (!website) {
8
+ throw new Error('Site não encontrado');
9
+ }
10
+ localStorage.setItem('websiteData', JSON.stringify(website));
11
+ return website;
12
+ }
13
+ async fetchWebsiteFromCache() {
14
+ const cacheService = new CacheService();
15
+ const website = cacheService.getStructure();
16
+ if (!website) {
17
+ throw new Error('Site não encontrado');
18
+ }
19
+ return website;
20
+ }
21
+ async fetchMenu() {
22
+ const websiteStructure = await this.fetchWebsiteFromCache();
23
+ return websiteStructure.pages
24
+ .filter((page) => page.menu === 1)
25
+ .map((page) => ({
26
+ id: page.id,
27
+ name: page.name,
28
+ path: page.path,
29
+ type: 'link'
30
+ }));
31
+ }
32
+ }
33
+ export { ConstructorService };
@@ -0,0 +1,9 @@
1
+ import type { FormFieldsType } from '../types/FormFieldsType.js';
2
+ import type { MailBodyType } from '../types/MailBodyType.js';
3
+ declare class EmailService {
4
+ private readonly urlApi;
5
+ constructor(urlApi: string);
6
+ sendMail(params: FormFieldsType[]): Promise<boolean>;
7
+ createBody(params: FormFieldsType[]): MailBodyType;
8
+ }
9
+ export { EmailService };