slicejs-cli 1.0.54 → 1.0.56

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 (85) hide show
  1. package/commands/listComponents/listComponents.js +69 -30
  2. package/package.json +1 -1
  3. package/PROJECT_TEMPLATES/Basic/Slice/Components/Provider/TestProvider/TestProvider.js +0 -0
  4. package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/FetchManager/FetchManager.js +0 -134
  5. package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/IndexedDbManager/IndexedDbManager.js +0 -138
  6. package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/LocalStorageManager/LocalStorageManager.js +0 -45
  7. package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/Translator/Translator.js +0 -59
  8. package/PROJECT_TEMPLATES/Basic/Slice/Components/Service/Translator/messages.json +0 -50
  9. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Controller/Controller.js +0 -106
  10. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.css +0 -95
  11. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.html +0 -10
  12. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Debugger/Debugger.js +0 -250
  13. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Logger/Log.js +0 -10
  14. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/Logger/Logger.js +0 -112
  15. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/StylesManager/CustomStylesManager/CustomStylesManager.js +0 -52
  16. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/StylesManager/StylesManager.js +0 -42
  17. package/PROJECT_TEMPLATES/Basic/Slice/Components/Structural/StylesManager/ThemeManager/ThemeManager.js +0 -25
  18. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.css +0 -44
  19. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.html +0 -5
  20. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Button/Button.js +0 -39
  21. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.css +0 -63
  22. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.html +0 -7
  23. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Card/Card.js +0 -110
  24. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.css +0 -87
  25. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.html +0 -8
  26. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Checkbox/Checkbox.js +0 -87
  27. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.css +0 -97
  28. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.html +0 -18
  29. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/CodeValidator/CodeValidator.js +0 -86
  30. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.css +0 -505
  31. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.html +0 -1
  32. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/Icon.js +0 -95
  33. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.eot +0 -0
  34. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.json +0 -550
  35. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.styl +0 -502
  36. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.svg +0 -1470
  37. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.symbol.svg +0 -1035
  38. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.ttf +0 -0
  39. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.woff +0 -0
  40. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Icon/slc.woff2 +0 -0
  41. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.css +0 -87
  42. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.html +0 -4
  43. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Input/Input.js +0 -210
  44. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.css +0 -56
  45. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.html +0 -83
  46. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Loading/Loading.js +0 -39
  47. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.css +0 -30
  48. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.html +0 -6
  49. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Navbar/Navbar.js +0 -39
  50. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.css +0 -91
  51. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.html +0 -8
  52. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Select/Select.js +0 -210
  53. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.css +0 -76
  54. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.html +0 -8
  55. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Switch/Switch.js +0 -109
  56. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/TestComponent/TestComponent.css +0 -0
  57. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/TestComponent/TestComponent.html +0 -0
  58. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/TestComponent/TestComponent.js +0 -0
  59. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.css +0 -34
  60. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.html +0 -7
  61. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester/Tester.js +0 -33
  62. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.css +0 -34
  63. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.html +0 -43
  64. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/Tester2/Tester2.js +0 -39
  65. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.css +0 -110
  66. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.html +0 -12
  67. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/ToastAlert/ToastAlert.js +0 -65
  68. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.css +0 -163
  69. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.html +0 -15
  70. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/complexNavbar/complexNavbar.js +0 -48
  71. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.css +0 -56
  72. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.html +0 -6
  73. package/PROJECT_TEMPLATES/Basic/Slice/Components/Visual/imageCarousel/img-carousel.js +0 -119
  74. package/PROJECT_TEMPLATES/Basic/Slice/Components/components.js +0 -23
  75. package/PROJECT_TEMPLATES/Basic/Slice/Slice.js +0 -194
  76. package/PROJECT_TEMPLATES/Basic/Slice/Styles/Custom/custom.css +0 -23
  77. package/PROJECT_TEMPLATES/Basic/Slice/Styles/sliceStyles.css +0 -10
  78. package/PROJECT_TEMPLATES/Basic/Slice/Themes/Dark.css +0 -38
  79. package/PROJECT_TEMPLATES/Basic/Slice/Themes/Light.css +0 -31
  80. package/PROJECT_TEMPLATES/Basic/Slice/Themes/Slice.css +0 -30
  81. package/PROJECT_TEMPLATES/Basic/Slice/package.json +0 -12
  82. package/PROJECT_TEMPLATES/Basic/Slice/sliceConfig.json +0 -32
  83. package/PROJECT_TEMPLATES/Basic/src/Views/LandingPage/index.html +0 -14
  84. package/PROJECT_TEMPLATES/Basic/src/Views/LandingPage/index.js +0 -395
  85. package/PROJECT_TEMPLATES/Basic/src/Views/LandingPage/style.css +0 -0
@@ -1,95 +0,0 @@
1
- #debugger-container {
2
- font-family: var(--font-family);
3
- display: none;
4
- position: fixed;
5
- top: 20px;
6
- left: 20px;
7
- padding: 10px;
8
- border: var(--slice-border) solid var(--primary-color);
9
- background-color: var(--primary-background-color);
10
- z-index: 1000;
11
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
12
- border-radius: 8px;
13
- }
14
-
15
- #debugger-container.active {
16
- display: block;
17
- }
18
-
19
- .slice_thead td {
20
- font-weight: bold;
21
- background-color: var(--primary-color);
22
- color: var(--primary-color-contrast);
23
- }
24
-
25
- #close-debugger {
26
- cursor: pointer;
27
- position: absolute;
28
- top: 10px;
29
- right: 10px;
30
- font-size: 14px;
31
- color: var(--danger-color);
32
- }
33
-
34
- h3 {
35
- color: var(--primary-color);
36
- margin-bottom: 10px;
37
- }
38
-
39
- #component-details {
40
- color: var(--font-primary-color);
41
- }
42
- .component-details-table {
43
- overflow: scroll;
44
- input {
45
- outline: none;
46
- border-bottom: 1px solid var(--tertiary-background-color);
47
- }
48
- }
49
- .component-details-table::-webkit-scrollbar {
50
- width: 5px;
51
- height: 5px;
52
- }
53
- .component-details-table::-webkit-scrollbar-thumb {
54
- background: var(--secondary-color);
55
- border-radius: var(--border-radius-slice);
56
- }
57
-
58
- #component-details table {
59
- width: 100%;
60
- border-collapse: collapse;
61
- margin-top: 10px;
62
- /* border: 1px solid var(--primary-color); */
63
- }
64
-
65
- .debugger-header {
66
- border-bottom: 1px solid var(--primary-color);
67
- user-select: none;
68
- cursor: grab;
69
- }
70
-
71
- .debugger-header:active {
72
- cursor: grabbing;
73
- }
74
-
75
- #component-details th,
76
- #component-details td {
77
- padding: 10px;
78
- text-align: left;
79
- border-bottom: 1px solid var(--primary-color);
80
- }
81
-
82
- input {
83
- border: 0px;
84
- }
85
-
86
- .slice_component-details td,
87
- input {
88
- background-color: var(--secondary-background-color);
89
- color: var(--font-primary-color);
90
- }
91
-
92
- /* Estilo para las filas impares, solo para mejorar la legibilidad */
93
- #component-details tr:nth-child(odd) {
94
- background-color: #f9f9f9;
95
- }
@@ -1,10 +0,0 @@
1
- <div id="debugger-container">
2
- <div class="debugger-header">
3
- <div id="close-debugger">[×]</div>
4
- <h3>Component Details</h3>
5
- </div>
6
- <div id="component-details">
7
- <ul class="component-details-list"></ul>
8
- <div class="component-details-table"></div>
9
- </div>
10
- </div>
@@ -1,250 +0,0 @@
1
- import sliceConfig from "../../../sliceConfig.json" assert { type: "json" };
2
-
3
- export default class Debugger extends HTMLElement {
4
- constructor() {
5
- super();
6
- this.toggleClick = sliceConfig.debugger.click;
7
- this.toggle = "click";
8
- this.selectedComponentSliceId = null;
9
- this.isActive = false;
10
- }
11
-
12
- async enableDebugMode() {
13
- const html = await slice.controller.fetchText("Debugger", "html");
14
- this.innerHTML = html;
15
- const css = await slice.controller.fetchText("Debugger", "css");
16
- slice.stylesManager.registerComponentStyles("Debugger", css);
17
-
18
- this.debuggerContainer = this.querySelector("#debugger-container");
19
- this.closeDebugger = this.querySelector("#close-debugger");
20
- this.componentDetails = this.querySelector("#component-details");
21
- this.componentDetailsTable = this.querySelector(".component-details-table");
22
- this.componentDetailsList = this.querySelector(".component-details-list");
23
-
24
- this.closeDebugger.addEventListener("click", () => {
25
- this.hideDebugger();
26
- this.isActive = false;
27
- });
28
-
29
- this.debuggerContainer.addEventListener("keypress", (event) => {
30
- if (event.key === "Enter") {
31
- this.applyChanges();
32
- }
33
- });
34
-
35
- this.applyChangesButton = await slice.build("Button", {
36
- value: "Apply Changes",
37
- onClickCallback: () => this.applyChanges(),
38
- });
39
-
40
- // Arrastrar y soltar
41
- this.makeDraggable();
42
-
43
- slice.logger.logInfo("Logger", "Debug mode enabled");
44
- return true;
45
- }
46
-
47
- attachDebugMode(component) {
48
- if (this.toggleClick === "right") {
49
- this.toggle = "contextmenu";
50
- } else {
51
- this.toggle = "click";
52
- }
53
- component.addEventListener(this.toggle, (event) =>
54
- this.handleDebugClick(event, component)
55
- );
56
- }
57
-
58
- makeDraggable() {
59
- let offset = {
60
- x: 0,
61
- y: 0,
62
- };
63
- let isDragging = false;
64
-
65
- const header = this.querySelector(".debugger-header");
66
-
67
- header.addEventListener("mousedown", (event) => {
68
- isDragging = true;
69
- offset.x =
70
- event.clientX - this.debuggerContainer.getBoundingClientRect().left;
71
- offset.y =
72
- event.clientY - this.debuggerContainer.getBoundingClientRect().top;
73
- });
74
-
75
- document.addEventListener("mousemove", (event) => {
76
- if (isDragging) {
77
- const x = event.clientX - offset.x;
78
- const y = event.clientY - offset.y;
79
-
80
- this.debuggerContainer.style.left = `${x}px`;
81
- this.debuggerContainer.style.top = `${y}px`;
82
- }
83
- });
84
-
85
- header.addEventListener("mouseup", () => {
86
- isDragging = false;
87
- });
88
- }
89
-
90
- handleDebugClick(event, component) {
91
- event.preventDefault();
92
-
93
- if (event.clientX > window.screen.width / 2) {
94
- this.debuggerContainer.style.left = `calc(${event.clientX}px - 25%)`;
95
- } else {
96
- this.debuggerContainer.style.left = `${event.clientX}px`;
97
- }
98
-
99
- if (event.clientY > window.screen.height / 2) {
100
- this.debuggerContainer.style.top = `calc(${event.clientY}px - 75%)`;
101
- } else {
102
- this.debuggerContainer.style.top = `${event.clientY}px`;
103
- }
104
-
105
- const sliceId = component.sliceId;
106
- this.isActive = true;
107
-
108
- const componentDetails = {
109
- SliceId: sliceId,
110
- ClassName: component.constructor.name,
111
- ComponentProps: {},
112
- };
113
- this.selectedComponentSliceId = component.sliceId; // Almacena el sliceId del componente seleccionado
114
-
115
- const realComponentProps = component.debuggerProps;
116
-
117
- realComponentProps.forEach((attr) => {
118
- if (component[attr] === undefined) {
119
- componentDetails.ComponentProps[attr] = component[`_${attr}`];
120
- } else {
121
- componentDetails.ComponentProps[attr] = component[attr];
122
- }
123
- });
124
-
125
- this.showComponentDetails(componentDetails);
126
- }
127
-
128
- showComponentDetails(details) {
129
- this.componentDetailsList.innerHTML = "";
130
-
131
- Object.entries(details).forEach(([key, value]) => {
132
- if (key === "ComponentProps") return;
133
- const listItem = document.createElement("li");
134
- listItem.textContent = `${key}: ${value}`;
135
- this.componentDetailsList.appendChild(listItem);
136
- });
137
-
138
- const ComponentPropsWithValues = this.getAttributesWithValues(
139
- details.ComponentProps
140
- );
141
-
142
- if (ComponentPropsWithValues.length > 0) {
143
- this.createTable("", ComponentPropsWithValues, details);
144
- }
145
-
146
- this.debuggerContainer.classList.add("active");
147
- this.debuggerContainer.appendChild(this.applyChangesButton); // Agregar el botón al debugger
148
- }
149
-
150
- createTable(title, attributes, details) {
151
- this.componentDetailsTable.innerHTML = "";
152
- const tableContainer = document.createElement("div");
153
- tableContainer.classList.add("table-container");
154
-
155
- const titleElement = document.createElement("h4");
156
- titleElement.textContent = title;
157
- tableContainer.appendChild(titleElement);
158
-
159
- const table = document.createElement("table");
160
- const thead = table.createTHead();
161
- const tbody = table.createTBody();
162
- thead.classList.add("slice_thead");
163
- tbody.classList.add("slice_component-details");
164
-
165
- const headerRow = thead.insertRow();
166
- const headerCell1 = headerRow.insertCell(0);
167
- const headerCell2 = headerRow.insertCell(1);
168
-
169
- headerCell1.textContent = "Attribute";
170
- headerCell2.textContent = "Value";
171
-
172
- attributes.forEach((attr) => {
173
- const row = tbody.insertRow();
174
- const cell1 = row.insertCell(0);
175
- const cell2 = row.insertCell(1);
176
-
177
- cell1.textContent = attr;
178
-
179
- // Crear un elemento editable para la celda de valor
180
- const valueInput = document.createElement("input");
181
- valueInput.value = details.ComponentProps[attr]; // Asignar el valor actual
182
- if (typeof details.ComponentProps[attr] === "function") {
183
- valueInput.disabled = true;
184
- }
185
- cell2.appendChild(valueInput);
186
-
187
- // Agregar evento de doble clic para permitir la edición
188
- cell2.addEventListener("dblclick", () => {
189
- valueInput.readOnly = false;
190
- });
191
- });
192
-
193
- tableContainer.appendChild(table);
194
- this.componentDetailsTable.appendChild(tableContainer);
195
- }
196
-
197
- getAttributesWithValues(attributes) {
198
- return Object.keys(attributes).filter((attr) => attributes[attr] !== null);
199
- }
200
-
201
- getAttributesWithoutValues(attributes) {
202
- return Object.keys(attributes).filter((attr) => attributes[attr] === null);
203
- }
204
-
205
- applyChanges() {
206
- const inputCells = this.componentDetailsTable.querySelectorAll("td input");
207
- const selectedComponent = slice.controller.getComponent(
208
- this.selectedComponentSliceId
209
- );
210
- inputCells.forEach((inputCell) => {
211
- const attributeName =
212
- inputCell.parentElement.previousElementSibling.textContent;
213
- let newValue = inputCell.value;
214
- const oldValue = slice.controller.getComponent(
215
- this.selectedComponentSliceId
216
- )[attributeName];
217
-
218
- // Verificar si el valor anterior y el nuevo valor son iguales como cadenas
219
- if (String(newValue) !== String(oldValue)) {
220
- //Verificar si es funcion para que no lo vuelva a guardar sin cambios
221
- /*
222
- if (typeof selectedComponent[attributeName] === 'function') {
223
- try {
224
- newValue = eval(`(${newValue})`);
225
- } catch (error) {
226
- console.error(`Error al analizar la función: ${error}`);
227
- return;
228
- }
229
- }
230
- */
231
- if (typeof selectedComponent[attributeName] === "function") {
232
- return;
233
- }
234
- console.log(
235
- `Changing ${attributeName} from ${oldValue} to ${newValue}`
236
- );
237
- if (newValue === "true") newValue = true;
238
- if (newValue === "false") newValue = false;
239
-
240
- selectedComponent[attributeName] = newValue;
241
- }
242
- });
243
- }
244
-
245
- hideDebugger() {
246
- this.debuggerContainer.classList.remove("active");
247
- }
248
- }
249
-
250
- customElements.define("slice-debugger", Debugger);
@@ -1,10 +0,0 @@
1
- export default class Log {
2
- constructor(logType, componentCategory, componentSliceId, message, error = null) {
3
- this.logType = logType;
4
- this.componentCategory = componentCategory;
5
- this.componentSliceId = componentSliceId;
6
- this.message = message;
7
- this.error = error;
8
- this.timestamp = new Date();
9
- }
10
- }
@@ -1,112 +0,0 @@
1
- import Log from "./Log.js";
2
- import sliceConfig from "../../../sliceConfig.json" assert { type: "json" };
3
-
4
-
5
- export default class Logger {
6
- constructor() {
7
- this.logs = [];
8
- this.logEnabled = sliceConfig.logger.enabled;
9
- this.showLogsConfig = sliceConfig.logger.showLogs;
10
-
11
- this.showLog = function showLog(log) {
12
- if (!this.showLogsConfig) return;
13
-
14
- const logType = log.logType;
15
-
16
- Object.keys(this.showLogsConfig).forEach(logConfig => {
17
- if (this.showLogsConfig[logConfig][logType] === true) {
18
- switch (logConfig) {
19
- case "console":
20
- switch (logType) {
21
- case logTypes.ERROR:
22
- console.error(`\x1b[31mERROR\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message} - ${log.error}`);
23
- break;
24
- case logTypes.WARNING:
25
- console.warn(`\x1b[33m⚠ WARNING\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`);
26
- break;
27
- case logTypes.INFO:
28
- console.log(`\x1b[32m✔ INFO\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`);
29
- break;
30
- default:
31
- console.log(`\x1b[37mUNKNOWN\x1b[0m - ${log.componentCategory} - ${log.componentSliceId} - ${log.message}`);
32
- }
33
- break;
34
- case "toast":
35
- // TODO: Implement displaying a ToastAlert with the log message for each log type
36
- break;
37
- }
38
- }
39
- });
40
- }
41
-
42
-
43
- }
44
-
45
- createLog(logType, componentSliceId, message, error = null) {
46
- if (!this.logEnabled) return;
47
- let componentName;
48
-
49
- try {
50
- componentName = slice.controller.activeComponents.get(componentSliceId).constructor.name
51
- } catch (error) {
52
- componentName = componentSliceId;
53
- }
54
-
55
-
56
- let componentCategory = slice.controller.getComponentCategory(componentName);
57
- if (componentSliceId === "Slice") componentCategory = "Structural"
58
- const log = new Log(logType, componentCategory, componentSliceId, message, error);
59
- this.logs.push(log);
60
- this.showLog(log);
61
- }
62
-
63
-
64
-
65
- logError(componentSliceId, message, error) {
66
- this.createLog(logTypes.ERROR, componentSliceId, message, error);
67
- }
68
-
69
- logWarning(componentSliceId, message) {
70
- this.createLog(logTypes.WARNING, componentSliceId, message);
71
- }
72
-
73
- logInfo(componentSliceId, message) {
74
- this.createLog(logTypes.INFO, componentSliceId, message);
75
- }
76
-
77
- getLogs() {
78
- return this.logs;
79
- }
80
-
81
- clearLogs() {
82
- this.logs = [];
83
- }
84
-
85
- getLogsByLogType(type) {
86
- return this.logs.filter(log => log.logType === type);
87
- }
88
-
89
- getLogsByComponentCategory(componentCategory) {
90
- return this.logs.filter(log => log.componentCategory === componentCategory);
91
- }
92
-
93
- getLogsByComponent(componentSliceId) {
94
- return this.logs.filter(log => log.componentSliceId === componentSliceId);
95
- }
96
-
97
-
98
-
99
-
100
- }
101
-
102
-
103
- // En esta misma idea, se tiene que tomar en cuenta que el componente de ToastAlert será un toastProvider y que solo debe
104
- // haber un toastProvider en la página, por lo que se debe implementar un Singleton para el ToastProvider
105
-
106
-
107
-
108
- const logTypes = {
109
- ERROR: 'error',
110
- WARNING: 'warning',
111
- INFO: 'info'
112
- };
@@ -1,52 +0,0 @@
1
- export default class CustomStylesComponent {
2
- constructor() {
3
- this.styles = document.createElement('style');
4
- document.head.appendChild(this.styles);
5
- this.cachedStyles = new Set();
6
- }
7
-
8
- async proccess(instance,props){
9
-
10
- const { customCSS } = props;
11
- if(customCSS.url){
12
- await this.loadStyles(customCSS.url);
13
- }
14
- if(customCSS.classNames){
15
-
16
- this.removeClasses(instance);
17
- await this.applyStyles(instance, customCSS.classNames);
18
- }
19
-
20
- }
21
-
22
- async loadStyles(url) {
23
- if (!this.cachedStyles.has(url)) {
24
- try {
25
- const response = await fetch(url);
26
- const cssText = await response.text();
27
-
28
- // Almacenar en caché el estilo
29
- this.cachedStyles.add(url);
30
-
31
- // Agregar los estilos del archivo CSS personalizado a la propiedad "styles"
32
- this.styles.appendChild(document.createTextNode(cssText));
33
- } catch (error) {
34
- console.error(`Error al cargar el estilo personalizado: ${url}`, error);
35
- }
36
- }
37
- }
38
-
39
- async applyStyles(instance, classNames) {
40
- classNames.forEach(className => {
41
- instance.classList.add(className);
42
- });
43
- }
44
-
45
- removeClasses(instance){
46
- while (instance.classList.length > 0) {
47
- instance.classList.remove(instance.classList.item(0));
48
- }
49
- }
50
-
51
-
52
- }
@@ -1,42 +0,0 @@
1
- import CustomStylesManager from "./CustomStylesManager/CustomStylesManager.js";
2
- import ThemeManager from "./ThemeManager/ThemeManager.js";
3
-
4
- export default class StylesManager {
5
- constructor() {
6
- this.componentStyles = document.createElement("style");
7
- this.componentStyles.id = "slice-component-styles";
8
- document.head.appendChild(this.componentStyles);
9
-
10
- this.customStylesManager = new CustomStylesManager();
11
- this.themeManager = new ThemeManager();
12
- }
13
-
14
- async init() {
15
- const sliceStyles = await slice.controller.fetchText(
16
- "sliceStyles",
17
- "styles"
18
- );
19
- this.componentStyles.innerText += sliceStyles;
20
- slice.logger.logInfo("StylesManager", "sliceStyles loaded");
21
- }
22
-
23
- handleInstanceStyles(instance, props) {
24
- if (props.customCSS) {
25
- this.customStylesManager.proccess(instance, props);
26
- }
27
- }
28
-
29
- setTheme(themeName) {
30
- this.themeManager.applyTheme(themeName);
31
- }
32
-
33
- //add a method that will add css as text to the componentStyles element
34
- appendComponentStyles(cssText) {
35
- this.componentStyles.appendChild(document.createTextNode(cssText));
36
- }
37
-
38
- registerComponentStyles(componentName, cssText) {
39
- slice.controller.requestedStyles.add(componentName);
40
- this.appendComponentStyles(cssText);
41
- }
42
- }
@@ -1,25 +0,0 @@
1
- export default class ThemeManager {
2
- constructor() {
3
- this.currentThemeLink = null;
4
- }
5
-
6
- async applyTheme(themeName) {
7
- // Eliminar el tema actual
8
- this.removeCurrentTheme();
9
-
10
- // Crear un nuevo link y agregarlo al head
11
- const themeLink = document.createElement("link");
12
- themeLink.setAttribute("rel", "stylesheet");
13
- themeLink.setAttribute("href", `Slice/${slice.paths.themes}/${themeName}.css`);
14
- document.head.appendChild(themeLink);
15
-
16
- // Establecer el nuevo link como el tema actual
17
- this.currentThemeLink = themeLink;
18
- }
19
-
20
- removeCurrentTheme() {
21
- if (this.currentThemeLink) {
22
- this.currentThemeLink.parentNode.removeChild(this.currentThemeLink);
23
- }
24
- }
25
- }
@@ -1,44 +0,0 @@
1
- .slice_button_container {
2
- padding: 10px;
3
- }
4
- .slice_button_value {
5
- user-select: none;
6
- cursor: pointer;
7
- }
8
- .slice_button {
9
- cursor: pointer;
10
- overflow: hidden;
11
- position: relative;
12
- max-width: fit-content;
13
- background-color: var(--primary-color);
14
- color: var(--primary-color-contrast);
15
- border-radius: var(--border-radius-slice);
16
- border: var(--slice-border) solid var(--primary-color);
17
- font-weight: 800;
18
- min-width: 100%;
19
- padding: 10px 0;
20
- -webkit-transition-duration: 0.4s; /* Safari */
21
- transition-duration: 0.4s;
22
- }
23
- .slice_button:after {
24
- content: "";
25
- width: 100%;
26
- height: 100%;
27
- border-radius: 100%;
28
- background: #ffffff50;
29
- position: absolute;
30
- display: block;
31
- opacity: 0;
32
- scale: 10;
33
- transition: all 1s;
34
- }
35
- .slice_button:active {
36
- transform: translateY(5px);
37
- }
38
- .slice_button:active:after {
39
- scale: 0;
40
- padding: 0;
41
- margin: 0;
42
- opacity: 1;
43
- transition: 0s;
44
- }
@@ -1,5 +0,0 @@
1
- <div class="slice_button_container">
2
- <button class="slice_button">
3
- <label class="slice_button_value"></label>
4
- </button>
5
- </div>
@@ -1,39 +0,0 @@
1
- export default class Button extends HTMLElement {
2
- constructor(props) {
3
- super();
4
- slice.attachTemplate(this);
5
- this.$value = this.querySelector(".slice_button_value");
6
- this.$button = this.querySelector(".slice_button");
7
- if (props.onClickCallback) {
8
- this.onClickCallback = props.onClickCallback;
9
- this.$button.addEventListener("click", () => this.onClickCallback());
10
- //revisar esta verga por si habria q deletear o no
11
- }
12
-
13
- slice.controller.setComponentProps(this, props);
14
- this.debuggerProps = ["value", "onClickCallback", "customColor"];
15
- }
16
-
17
- get value() {
18
- return this._value;
19
- }
20
-
21
- set value(value) {
22
- this._value = value;
23
- this.$value.textContent = value;
24
- }
25
-
26
- get customColor() {
27
- return this._customColor;
28
- }
29
-
30
- set customColor(value) {
31
- this._customColor = value;
32
- this.$button.style = `--primary-color: ${value};`;
33
- }
34
-
35
- handleButtonClick() {
36
- this.onClickCallback();
37
- }
38
- }
39
- window.customElements.define("slice-button", Button);