@axzydev/axzy_ui_system 1.2.4 → 1.2.6
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/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -311
- package/dist/index.css.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/App.tsx +1 -1
- package/src/components/data-table/dataTable.tsx +2 -2
- package/src/components/table/table.tsx +158 -159
- package/src/index.css +5 -0
- package/src/showcases/DataShowcases.tsx +1 -1
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"packageManager": "pnpm@10.34.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"version": "1.2.
|
|
7
|
+
"version": "1.2.6",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"sideEffects": [
|
|
10
10
|
"*.css"
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
"dev": "vite",
|
|
30
30
|
"build": "tsc -b && vite build",
|
|
31
31
|
"build:app": "tsc -b && vite build -c vite.app.config.ts",
|
|
32
|
+
"build:css": "node scripts/build-css.mjs",
|
|
32
33
|
"lint": "eslint .",
|
|
33
34
|
"preview": "vite preview",
|
|
34
|
-
"bundle": "tsup src/index.ts",
|
|
35
|
+
"bundle": "tsup src/index.ts && node scripts/build-css.mjs",
|
|
35
36
|
"watch": "tsup src/index.ts --watch",
|
|
36
37
|
"storybook": "storybook dev -p 6006",
|
|
37
38
|
"build-storybook": "storybook build"
|
package/src/App.tsx
CHANGED
|
@@ -196,7 +196,7 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
196
196
|
|
|
197
197
|
return (
|
|
198
198
|
<div className={clsx("space-y-4 w-full relative", containerClassName)}>
|
|
199
|
-
<div className="rounded-xl shadow-sm
|
|
199
|
+
<div className="rounded-xl shadow-sm overflow-hidden" style={{ backgroundColor: 'var(--color-table-rowBg, #ffffff)' }}>
|
|
200
200
|
{title && (
|
|
201
201
|
<div className="px-6 py-5 border-b border-secondary-100 flex justify-between items-center" style={{ backgroundColor: 'var(--color-table-rowBg, #ffffff)' }}>
|
|
202
202
|
<ITText as="h2" className="text-xl font-bold text-secondary-900 leading-tight">{title}</ITText>
|
|
@@ -232,7 +232,7 @@ export default function ITDataTable<T extends Record<string, unknown>>({
|
|
|
232
232
|
)}
|
|
233
233
|
>
|
|
234
234
|
<thead>
|
|
235
|
-
<tr className="bg-
|
|
235
|
+
<tr className="bg-white border-b border-secondary-200 text-xs uppercase tracking-wider font-semibold text-secondary-500">
|
|
236
236
|
{columns.map((col) => (
|
|
237
237
|
<th key={col.key} scope="col" className={clsx("px-4 py-4 align-top", col.className)}>
|
|
238
238
|
<div className="flex flex-col gap-3 min-w-[150px]">
|
|
@@ -68,7 +68,7 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
68
68
|
comparison =
|
|
69
69
|
new Date(aValue as string).getTime() -
|
|
70
70
|
new Date(bValue as string).getTime();
|
|
71
|
-
break;
|
|
71
|
+
break;
|
|
72
72
|
case "boolean":
|
|
73
73
|
comparison = aValue === bValue ? 0 : aValue ? 1 : -1;
|
|
74
74
|
break;
|
|
@@ -142,48 +142,48 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
142
142
|
currentValue === undefined
|
|
143
143
|
? true
|
|
144
144
|
: currentValue === true
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
? false
|
|
146
|
+
: undefined;
|
|
147
147
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
148
|
+
const getToggleLabel = () => {
|
|
149
|
+
if (currentValue === undefined) return "Mostrar todos";
|
|
150
|
+
if (currentValue === true) return "Filtrar solo verdaderos";
|
|
151
|
+
return "Filtrar solo falsos";
|
|
152
|
+
};
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
return (
|
|
155
|
+
<button
|
|
156
|
+
className="flex items-center justify-center cursor-pointer focus:outline-none focus:ring-2 focus:ring-slate-400 focus:ring-offset-2 rounded-full p-1 transition-all duration-200"
|
|
157
|
+
onClick={() => handleFilterChange(col.key, nextValue)}
|
|
158
|
+
aria-label={`${getToggleLabel()} para ${col.label}`}
|
|
159
|
+
title={`${getToggleLabel()} para ${col.label}`}
|
|
160
|
+
>
|
|
161
|
+
<div className="relative w-10 h-5 bg-gray-300 rounded-full">
|
|
162
|
+
<div
|
|
163
|
+
className={clsx(
|
|
164
|
+
"absolute top-0.5 w-4 h-4 rounded-full transition-all duration-300 shadow-sm",
|
|
165
|
+
{
|
|
166
|
+
"left-0.5 bg-gray-400": currentValue === undefined,
|
|
167
|
+
"left-5 bg-slate-500": currentValue === true,
|
|
168
|
+
"left-0.5 bg-gray-500": currentValue === false,
|
|
169
|
+
}
|
|
170
|
+
)}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
</button>
|
|
174
|
+
);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
if (col.filter === "catalog" && col.catalogOptions) {
|
|
178
|
+
if (col.catalogOptions.loading) {
|
|
179
|
+
return (
|
|
180
|
+
<FaSpinner
|
|
181
|
+
className="animate-spin"
|
|
182
|
+
aria-label="Cargando opciones"
|
|
183
|
+
title="Cargando opciones"
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
187
|
|
|
188
188
|
if (col.catalogOptions.error) {
|
|
189
189
|
return <ITText as="span" className="text-red-500 text-xs">Error cargando</ITText>;
|
|
@@ -204,7 +204,7 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
204
204
|
const value = e.target.value === "" ? undefined : e.target.value;
|
|
205
205
|
handleFilterChange(col.key, value);
|
|
206
206
|
}}
|
|
207
|
-
onBlur={() => {}}
|
|
207
|
+
onBlur={() => { }}
|
|
208
208
|
className="w-full text-xs"
|
|
209
209
|
/>
|
|
210
210
|
);
|
|
@@ -217,7 +217,7 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
217
217
|
placeholder="Buscar..."
|
|
218
218
|
value={String(filters[col.key] || "")}
|
|
219
219
|
onChange={(e) => handleFilterChange(col.key, e.target.value)}
|
|
220
|
-
onBlur={() => {}}
|
|
220
|
+
onBlur={() => { }}
|
|
221
221
|
/>
|
|
222
222
|
);
|
|
223
223
|
};
|
|
@@ -230,22 +230,22 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
switch (col.type) {
|
|
233
|
-
case "number":
|
|
234
|
-
return (typeof value === "number") && col.currencyMX ?formatCurrencyMX(value)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
233
|
+
case "number":
|
|
234
|
+
return (typeof value === "number") && col.currencyMX ? formatCurrencyMX(value) : value;
|
|
235
|
+
case "boolean":
|
|
236
|
+
return value ? (
|
|
237
|
+
<FaCheck
|
|
238
|
+
className="text-green-500"
|
|
239
|
+
aria-label="Verdadero"
|
|
240
|
+
title="Verdadero"
|
|
241
|
+
/>
|
|
242
|
+
) : (
|
|
243
|
+
<FaTimes
|
|
244
|
+
className="text-red-500"
|
|
245
|
+
aria-label="Falso"
|
|
246
|
+
title="Falso"
|
|
247
|
+
/>
|
|
248
|
+
);
|
|
249
249
|
case "actions":
|
|
250
250
|
return col.actions ? col.actions(row) : null;
|
|
251
251
|
case "catalog":
|
|
@@ -261,116 +261,115 @@ export default function ITTable<T extends Record<string, unknown>>({
|
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
263
|
|
|
264
|
-
|
|
265
|
-
<div className={clsx("space-y-4 w-full", containerClassName)}>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)}
|
|
273
|
-
|
|
274
|
-
{/* Scrollable Table */}
|
|
275
|
-
<div className="overflow-x-auto">
|
|
276
|
-
<table
|
|
277
|
-
className={clsx(
|
|
278
|
-
"min-w-max w-full text-sm text-left text-secondary-600",
|
|
279
|
-
variantStyles[variant],
|
|
280
|
-
sizeStyles[size]
|
|
264
|
+
return (
|
|
265
|
+
<div className={clsx("space-y-4 w-full", containerClassName)}>
|
|
266
|
+
<div className="rounded-xl shadow-sm overflow-hidden" style={{ backgroundColor: 'var(--color-table-rowBg, #ffffff)' }}>
|
|
267
|
+
{/* Header outside overflow */}
|
|
268
|
+
{title && (
|
|
269
|
+
<div className="px-6 py-5 border-b border-secondary-100" style={{ backgroundColor: 'var(--color-table-rowBg, #ffffff)' }}>
|
|
270
|
+
<ITText as="h2" className="text-xl font-bold text-secondary-900 leading-tight">{title}</ITText>
|
|
271
|
+
</div>
|
|
281
272
|
)}
|
|
282
|
-
>
|
|
283
273
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
274
|
+
{/* Scrollable Table */}
|
|
275
|
+
<div className="overflow-x-auto">
|
|
276
|
+
<table
|
|
277
|
+
className={clsx(
|
|
278
|
+
"min-w-max w-full text-sm text-left text-secondary-600",
|
|
279
|
+
variantStyles[variant],
|
|
280
|
+
sizeStyles[size]
|
|
281
|
+
)}
|
|
282
|
+
>
|
|
283
|
+
|
|
284
|
+
<thead>
|
|
285
|
+
<tr className="bg-secondary-50 border-b border-secondary-200 text-xs uppercase tracking-wider font-semibold text-secondary-500">
|
|
286
|
+
{columns.map((col) => (
|
|
287
|
+
<th
|
|
288
|
+
key={col.key}
|
|
289
|
+
scope="col"
|
|
290
|
+
className={clsx("px-4 py-4 align-top", col.className)}
|
|
291
|
+
>
|
|
292
|
+
<div className="flex flex-col gap-3 min-w-[150px]">
|
|
293
|
+
{/* Column header */}
|
|
294
|
+
<div className="flex items-center justify-between gap-2">
|
|
295
295
|
<ITText as="span" className="text-secondary-700 font-bold">{col.label}</ITText>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
<div className="flex items-center justify-center gap-2">
|
|
334
|
-
{renderCellContent(col, row) as React.ReactNode}
|
|
335
|
-
</div>
|
|
336
|
-
) : (
|
|
337
|
-
<div className="text-secondary-700 font-medium">
|
|
296
|
+
{col.sortable && col.type !== "actions" && (
|
|
297
|
+
<button
|
|
298
|
+
onClick={() => handleSort(col.key)}
|
|
299
|
+
className={`p-1 rounded-md transition-colors ${sortConfig?.key === col.key
|
|
300
|
+
? "bg-secondary-200 text-secondary-900"
|
|
301
|
+
: "hover:bg-secondary-200 text-secondary-400 hover:text-secondary-700"
|
|
302
|
+
}`}
|
|
303
|
+
title={`Ordenar por ${col.label}`}
|
|
304
|
+
>
|
|
305
|
+
<MdOutlineSwapVert className="w-4 h-4" aria-hidden="true" />
|
|
306
|
+
</button>
|
|
307
|
+
)}
|
|
308
|
+
</div>
|
|
309
|
+
|
|
310
|
+
{/* Filter section */}
|
|
311
|
+
<div className="w-full">
|
|
312
|
+
{col.filter ? renderFilterInput(col) : null}
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</th>
|
|
316
|
+
))}
|
|
317
|
+
</tr>
|
|
318
|
+
</thead>
|
|
319
|
+
<tbody className="divide-y divide-secondary-100">
|
|
320
|
+
{currentData.length > 0 ? (
|
|
321
|
+
currentData.map((row, rowIndex) => (
|
|
322
|
+
<tr
|
|
323
|
+
key={rowIndex}
|
|
324
|
+
className="hover:bg-secondary-50/50 transition-colors duration-150 group"
|
|
325
|
+
>
|
|
326
|
+
{columns.map((col) => (
|
|
327
|
+
<td
|
|
328
|
+
key={`${rowIndex}-${col.key}`}
|
|
329
|
+
className={clsx("px-4 py-3 align-middle", col.className)}
|
|
330
|
+
>
|
|
331
|
+
{col.type === "actions" ? (
|
|
332
|
+
<div className="flex items-center justify-center gap-2">
|
|
338
333
|
{renderCellContent(col, row) as React.ReactNode}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
334
|
+
</div>
|
|
335
|
+
) : (
|
|
336
|
+
<div className="text-secondary-700 font-medium">
|
|
337
|
+
{renderCellContent(col, row) as React.ReactNode}
|
|
338
|
+
</div>
|
|
339
|
+
)}
|
|
340
|
+
</td>
|
|
341
|
+
))}
|
|
342
|
+
</tr>
|
|
343
|
+
))
|
|
344
|
+
) : (
|
|
345
|
+
<tr>
|
|
346
|
+
<td colSpan={columns.length} className="px-6 py-12 text-center">
|
|
347
|
+
<div className="flex flex-col items-center justify-center text-secondary-400">
|
|
348
|
+
<ITText as="span" className="text-lg">No se encontraron resultados</ITText>
|
|
349
|
+
<ITText as="span" className="text-sm mt-1">Intenta ajustar los filtros</ITText>
|
|
350
|
+
</div>
|
|
351
|
+
</td>
|
|
343
352
|
</tr>
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
<div className="flex flex-col items-center justify-center text-secondary-400">
|
|
349
|
-
<ITText as="span" className="text-lg">No se encontraron resultados</ITText>
|
|
350
|
-
<ITText as="span" className="text-sm mt-1">Intenta ajustar los filtros</ITText>
|
|
351
|
-
</div>
|
|
352
|
-
</td>
|
|
353
|
-
</tr>
|
|
354
|
-
)}
|
|
355
|
-
</tbody>
|
|
356
|
-
</table>
|
|
357
|
-
</div>
|
|
353
|
+
)}
|
|
354
|
+
</tbody>
|
|
355
|
+
</table>
|
|
356
|
+
</div>
|
|
358
357
|
|
|
359
358
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
359
|
+
{/* Pagination */}
|
|
360
|
+
<div className="rounded-b-xl border-t border-secondary-200 px-6 py-4" style={{ backgroundColor: 'var(--color-table-rowBg, #ffffff)' }}>
|
|
361
|
+
<ITPagination
|
|
362
|
+
currentPage={currentPage}
|
|
363
|
+
totalPages={computedTotalPages}
|
|
364
|
+
onPageChange={goToPage}
|
|
365
|
+
color="primary"
|
|
366
|
+
itemsPerPageOptions={itemsPerPageOptions}
|
|
367
|
+
itemsPerPage={itemsPerPage}
|
|
368
|
+
onItemsPerPageChange={handleItemsPerPageChange}
|
|
369
|
+
totalItems={filteredData.length}
|
|
370
|
+
/>
|
|
371
|
+
</div>
|
|
372
372
|
</div>
|
|
373
373
|
</div>
|
|
374
|
-
</div>
|
|
375
374
|
);
|
|
376
375
|
}
|
package/src/index.css
CHANGED
|
@@ -49,7 +49,7 @@ export const TableShowcase = () => {
|
|
|
49
49
|
description="Base de renderizado de tablas estructuradas con soporte de alineamiento y tipado estricto."
|
|
50
50
|
code={code}
|
|
51
51
|
demo={
|
|
52
|
-
<div className="w-full bg-white dark:bg-slate-900
|
|
52
|
+
<div className="w-full bg-white dark:bg-slate-900 rounded-xl overflow-hidden shadow-sm">
|
|
53
53
|
<ITTable
|
|
54
54
|
columns={columns}
|
|
55
55
|
data={data}
|