grav-svelte 0.1.239 → 0.1.241

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.
@@ -35,6 +35,7 @@
35
35
  export let labelLimpiar: string = 'Limpiar';
36
36
  export let tooltipFiltrar: string = 'Aplicar filtro';
37
37
  export let labelFiltrar: string = 'Filtrar';
38
+ export let labelMostrando: string = 'Showing:';
38
39
 
39
40
  // Dynamic grid columns calculation
40
41
  $: gridColumns = Math.min(Filtros.length, 6);
@@ -348,7 +349,7 @@
348
349
  {#if showMostrandoInput}
349
350
  <div class="filter-item">
350
351
  <InputFormText
351
- label="Mostrando:"
352
+ label={labelMostrando}
352
353
  bind:valueVar={localPageSizeStr}
353
354
  />
354
355
  </div>
@@ -19,6 +19,7 @@ declare const __propDef: {
19
19
  labelLimpiar?: string;
20
20
  tooltipFiltrar?: string;
21
21
  labelFiltrar?: string;
22
+ labelMostrando?: string;
22
23
  };
23
24
  events: {
24
25
  add: CustomEvent<any>;
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { ButtonConfig } from "./interfaces.js";
3
3
  import Tooltip from "./Tooltip.svelte";
4
- import { onMount, afterUpdate, onDestroy } from "svelte";
5
4
 
6
5
  export let id = 1;
7
6
  export let buttonsConfig: ButtonConfig[];
@@ -14,138 +13,9 @@
14
13
  event.stopPropagation();
15
14
  button.action(id, row);
16
15
  }
17
-
18
- // Prevenir que Font Awesome procese iconos múltiples veces
19
- function preventIconDuplication(element: HTMLElement) {
20
- if (!element) return;
21
-
22
- const buttons = element.querySelectorAll("button");
23
- buttons.forEach((button) => {
24
- // Buscar todos los iconos (tanto <i> como SVGs generados por Font Awesome)
25
- const iconElements = button.querySelectorAll(
26
- 'i[class*="fa-"], svg[data-icon]',
27
- );
28
- const iconClasses = new Set<string>();
29
-
30
- iconElements.forEach((icon, index) => {
31
- const iconClass = icon.getAttribute("class") || "";
32
- const faClasses = iconClass.split(" ").filter((c) => c.startsWith("fa-"));
33
-
34
- // Si es un elemento <i> con clase fa-
35
- if (icon.tagName === "I" && faClasses.length > 0) {
36
- const iconName = faClasses[faClasses.length - 1];
37
- const existingSvg =
38
- button.querySelector(`svg[data-icon="${iconName}"]`) ||
39
- button.querySelector(`svg[data-icon="${iconName.replace(/^fa-/, "")}"]`);
40
-
41
- if (existingSvg) {
42
- icon.remove();
43
- return;
44
- }
45
-
46
- const faKey = faClasses.join(" ");
47
- if (!iconClasses.has(faKey)) {
48
- iconClasses.add(faKey);
49
- icon.setAttribute("data-fa-processed", "true");
50
- icon.setAttribute("data-fa-i2svg-processed", "true");
51
- } else {
52
- icon.remove();
53
- }
54
- }
55
-
56
- // Si es un SVG duplicado (más de uno con el mismo data-icon)
57
- if (icon.tagName === "SVG") {
58
- const dataIcon = icon.getAttribute("data-icon");
59
- if (dataIcon) {
60
- const existingSvgs = button.querySelectorAll(
61
- `svg[data-icon="${dataIcon}"]`,
62
- );
63
- if (existingSvgs.length > 1) {
64
- // Mantener solo el primero, eliminar los demás
65
- for (let i = 1; i < existingSvgs.length; i++) {
66
- existingSvgs[i].remove();
67
- }
68
- }
69
- }
70
- }
71
- });
72
-
73
- // Limpiar iconos <i> que ya tienen SVG correspondiente
74
- const allIcons = button.querySelectorAll('i[class*="fa-"]');
75
- allIcons.forEach((icon) => {
76
- const iconClass = icon.getAttribute("class") || "";
77
- const faClasses = iconClass.split(" ").filter((c) => c.startsWith("fa-"));
78
- if (faClasses.length > 0) {
79
- const iconName = faClasses[faClasses.length - 1];
80
- const svg =
81
- button.querySelector(`svg[data-icon="${iconName}"]`) ||
82
- button.querySelector(`svg[data-icon="${iconName.replace(/^fa-/, "")}"]`);
83
- if (svg) {
84
- icon.remove();
85
- }
86
- }
87
- });
88
- });
89
- }
90
-
91
- let buttonGroupElement: HTMLDivElement;
92
- let mutationObserver: MutationObserver | null = null;
93
-
94
- onMount(() => {
95
- if (buttonGroupElement) {
96
- preventIconDuplication(buttonGroupElement);
97
-
98
- // Observar cambios en el DOM para detectar cuando Font Awesome agrega SVGs
99
- mutationObserver = new MutationObserver((mutations) => {
100
- let shouldClean = false;
101
- mutations.forEach((mutation) => {
102
- if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
103
- mutation.addedNodes.forEach((node) => {
104
- if (node.nodeType === 1) {
105
- // Element node
106
- const element = node as Element;
107
- if (element.tagName === "SVG" || element.querySelector("svg")) {
108
- shouldClean = true;
109
- }
110
- }
111
- });
112
- }
113
- });
114
-
115
- if (shouldClean) {
116
- // Usar setTimeout para evitar procesar múltiples veces en el mismo ciclo
117
- setTimeout(() => {
118
- preventIconDuplication(buttonGroupElement);
119
- }, 0);
120
- }
121
- });
122
-
123
- mutationObserver.observe(buttonGroupElement, {
124
- childList: true,
125
- subtree: true,
126
- });
127
- }
128
- });
129
-
130
- afterUpdate(() => {
131
- if (buttonGroupElement) {
132
- // Usar setTimeout para evitar procesar en medio de una actualización
133
- setTimeout(() => {
134
- preventIconDuplication(buttonGroupElement);
135
- }, 0);
136
- }
137
- });
138
-
139
- // Limpiar el observer cuando el componente se destruya
140
- onDestroy(() => {
141
- if (mutationObserver) {
142
- mutationObserver.disconnect();
143
- mutationObserver = null;
144
- }
145
- });
146
16
  </script>
147
17
 
148
- <div class="button-group" role="group" bind:this={buttonGroupElement}>
18
+ <div class="button-group" role="group">
149
19
  {#each visibleButtons as button, i (button.icon + id + i)}
150
20
  <Tooltip text={button.tooltip}>
151
21
  <button
@@ -32,6 +32,9 @@
32
32
  export let labelLimpiar: string = 'Limpiar';
33
33
  export let tooltipFiltrar: string = 'Aplicar filtro';
34
34
  export let labelFiltrar: string = 'Filtrar';
35
+ export let labelMostrando: string = 'Mostrando:';
36
+ export let labelDe: string = 'de';
37
+ export let labelRegistros: string = 'registros';
35
38
  export let dragEnabled: boolean = false;
36
39
  export let orderField: string = "inOrden";
37
40
  export let minHeightScreen: boolean = false;
@@ -159,6 +162,7 @@
159
162
  {labelLimpiar}
160
163
  {tooltipFiltrar}
161
164
  {labelFiltrar}
165
+ {labelMostrando}
162
166
  />
163
167
  </div>
164
168
  <div class="crud-table-container crud-anim-item crud-anim-table">
@@ -182,6 +186,9 @@
182
186
  {totalRows}
183
187
  bind:currentPage
184
188
  on:pageChange={handlePageChange}
189
+ {labelMostrando}
190
+ {labelDe}
191
+ {labelRegistros}
185
192
  />
186
193
  </div>
187
194
 
@@ -26,6 +26,9 @@ declare const __propDef: {
26
26
  labelLimpiar?: string;
27
27
  tooltipFiltrar?: string;
28
28
  labelFiltrar?: string;
29
+ labelMostrando?: string;
30
+ labelDe?: string;
31
+ labelRegistros?: string;
29
32
  dragEnabled?: boolean;
30
33
  orderField?: string;
31
34
  minHeightScreen?: boolean;
@@ -7,6 +7,9 @@
7
7
  export let perPage;
8
8
  export let totalRows;
9
9
  export let currentPage = 1;
10
+ export let labelMostrando = 'Showing:';
11
+ export let labelDe = 'of';
12
+ export let labelRegistros = 'records';
10
13
 
11
14
  $: totalPages = Math.ceil(totalRows / perPage);
12
15
  $: start = (currentPage - 1) * perPage;
@@ -85,7 +88,7 @@
85
88
 
86
89
  <div class="pagination-info-container">
87
90
  <p class="pagination-info">
88
- Mostrando: {start + 1} - {end + 1} de {totalRows} registros
91
+ {labelMostrando} {start + 1} - {end + 1} {labelDe} {totalRows} {labelRegistros}
89
92
  </p>
90
93
  </div>
91
94
 
@@ -5,6 +5,9 @@ export default class PaginationCrud extends SvelteComponentTyped<{
5
5
  perPage: any;
6
6
  totalRows: any;
7
7
  currentPage?: number | undefined;
8
+ labelMostrando?: string | undefined;
9
+ labelDe?: string | undefined;
10
+ labelRegistros?: string | undefined;
8
11
  }, {
9
12
  pageChange: CustomEvent<any>;
10
13
  } & {
@@ -20,6 +23,9 @@ declare const __propDef: {
20
23
  perPage: any;
21
24
  totalRows: any;
22
25
  currentPage?: number | undefined;
26
+ labelMostrando?: string | undefined;
27
+ labelDe?: string | undefined;
28
+ labelRegistros?: string | undefined;
23
29
  };
24
30
  events: {
25
31
  pageChange: CustomEvent<any>;
@@ -26,6 +26,7 @@
26
26
  bind:value={valueVar}
27
27
  placeholder=" "
28
28
  class="input-field"
29
+ on:wheel|preventDefault={() => {}}
29
30
  />
30
31
 
31
32
  <label for={inputId} class="input-label"
@@ -21,6 +21,8 @@
21
21
  export let onPlusClick: () => void = () => {};
22
22
  export let multiple = false;
23
23
  export let placeholder: string | undefined = undefined;
24
+ export let placeholderSingle: string = "Seleccione una opción";
25
+ export let placeholderMultiple: string = "Seleccione opciones";
24
26
 
25
27
  let containerEl: HTMLDivElement;
26
28
 
@@ -130,7 +132,7 @@
130
132
  class="select-input"
131
133
  inputStyles="font-size: 16px; color: currentColor !important; background-color: transparent;"
132
134
  containerStyles="font-size: 16px; background-color: transparent; border: var(--grav-crud-input-border-width) solid currentColor; border-radius: 0.5rem;"
133
- placeholder={placeholder ?? (multiple ? "Seleccione opciones" : "Seleccione una opción")}
135
+ placeholder={placeholder ?? (multiple ? placeholderMultiple : placeholderSingle)}
134
136
  --placeholder-color="currentColor"
135
137
  --chevron-color="currentColor"
136
138
  --item-color="black"
@@ -25,6 +25,8 @@ declare const __propDef: {
25
25
  onPlusClick?: () => void;
26
26
  multiple?: boolean;
27
27
  placeholder?: string | undefined;
28
+ placeholderSingle?: string;
29
+ placeholderMultiple?: string;
28
30
  };
29
31
  events: {
30
32
  [evt: string]: CustomEvent<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grav-svelte",
3
- "version": "0.1.239",
3
+ "version": "0.1.241",
4
4
  "description": "A collection of Svelte components",
5
5
  "license": "MIT",
6
6
  "scripts": {