@asteby/metacore-runtime-react 39.0.0 → 39.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 39.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a05f1bb: DynamicTable: un 403 en el endpoint de lista ya no se enmascara como "No se encontraron resultados"; muestra "Sin permiso para ver este módulo" (i18n `dynamic.forbidden_title` / `dynamic.forbidden_hint`) sin disparar refetch.
8
+
9
+ ## 39.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 6549688: DynamicTable virtualizes desktop rows and mobile cards once the visible row model reaches 40+ rows (override with `virtualizeRows`). Cuts DOM cost for infinite scroll and large page sizes.
14
+
3
15
  ## 39.0.0
4
16
 
5
17
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Asteby, Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -6,7 +6,7 @@ import type { ActionFieldDef, FieldOptionsConfig, OptionDef, VisibleWhen } from
6
6
  */
7
7
  export declare function registerValidator(slug: string, fn: (s: z.ZodString) => z.ZodString): void;
8
8
  export declare function buildZodSchema(fields: ActionFieldDef[]): z.ZodObject<{
9
- [x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
9
+ [x: string]: z.ZodTypeAny;
10
10
  }, z.core.$strip>;
11
11
  /**
12
12
  * Returns the line-items columns of a repeatable-group field, tolerating both
@@ -83,6 +83,13 @@ export interface DynamicTableProps {
83
83
  * mode exactly as before.
84
84
  */
85
85
  infiniteScroll?: boolean;
86
+ /**
87
+ * Row virtualization. When the visible row model has at least N rows,
88
+ * only viewport rows are mounted (helps infinite scroll and large page
89
+ * sizes). `true` / omitted → default threshold (40). `false` → always
90
+ * render every row. A positive number overrides the threshold.
91
+ */
92
+ virtualizeRows?: boolean | number;
86
93
  }
87
- export declare function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync, hideImport, hideExport, hiddenColumns, allowedActionKeys, onAction, onRowClick, refreshTrigger, defaultFilters, extraColumns, getDynamicColumns, timeZone, currency, pagination: paginationMode, infiniteScroll: infiniteScrollProp, }: DynamicTableProps): import("react").JSX.Element;
94
+ export declare function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync, hideImport, hideExport, hiddenColumns, allowedActionKeys, onAction, onRowClick, refreshTrigger, defaultFilters, extraColumns, getDynamicColumns, timeZone, currency, pagination: paginationMode, infiniteScroll: infiniteScrollProp, virtualizeRows, }: DynamicTableProps): import("react").JSX.Element;
88
95
  //# sourceMappingURL=dynamic-table.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-table.d.ts","sourceRoot":"","sources":["../src/dynamic-table.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAKH,KAAK,SAAS,EAajB,MAAM,uBAAuB,CAAA;AAgC9B,OAAO,KAAK,EAAsB,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAkGnF,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC7C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAC/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o, useCallback, useRef } from 'react';
15
15
  import { useTranslation } from 'react-i18next';
16
16
  import { format } from 'date-fns';
17
+ import { useVirtualizer } from '@tanstack/react-virtual';
17
18
  import { flexRender, getCoreRowModel, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from '@tanstack/react-table';
18
19
  import { cn } from '@asteby/metacore-ui/lib';
19
20
  import { Table, TableBody, TableCell, TableFooter, TableHead, TableHeader, TableRow, Button, Skeleton, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@asteby/metacore-ui/primitives';
@@ -27,6 +28,7 @@ import { defaultGetDynamicColumns, DATE_CELL_TYPES, aggregateOf, formatAggregate
27
28
  import { useFacetLoaders, isLongTextColumn } from './use-facet-loaders';
28
29
  import { translateOptionLabels } from './filter-chips';
29
30
  import { dedupeById, useInfiniteScrollSentinel } from './use-infinite-scroll';
31
+ import { DYNAMIC_TABLE_CARD_ESTIMATE_PX, DYNAMIC_TABLE_ROW_ESTIMATE_PX, resolveVirtualizeThreshold, } from './table-virtualization';
30
32
  import { OptionsContext } from './options-context';
31
33
  import { getSearchableColumnKeys } from './column-visibility';
32
34
  import { useDebouncedValue } from './use-debounced-value';
@@ -105,7 +107,12 @@ function writeStoredPageSize(model, size) {
105
107
  // quota / private mode — persistence is a nicety, never fatal
106
108
  }
107
109
  }
108
- export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync = true, hideImport, hideExport, hiddenColumns = [], allowedActionKeys, onAction, onRowClick, refreshTrigger, defaultFilters, extraColumns = [], getDynamicColumns = defaultGetDynamicColumns, timeZone, currency, pagination: paginationMode, infiniteScroll: infiniteScrollProp = false, }) {
110
+ /** True when an api-client error is an HTTP 403 (axios-style or fetch-style). */
111
+ function isForbiddenError(error) {
112
+ const e = error;
113
+ return e?.response?.status === 403 || e?.status === 403;
114
+ }
115
+ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync = true, hideImport, hideExport, hiddenColumns = [], allowedActionKeys, onAction, onRowClick, refreshTrigger, defaultFilters, extraColumns = [], getDynamicColumns = defaultGetDynamicColumns, timeZone, currency, pagination: paginationMode, infiniteScroll: infiniteScrollProp = false, virtualizeRows, }) {
109
116
  // The explicit `pagination` prop wins; the legacy `infiniteScroll` boolean
110
117
  // still selects the mode when `pagination` is absent (back-compat).
111
118
  const infiniteScroll = paginationMode ? paginationMode === 'infinite' : infiniteScrollProp;
@@ -139,6 +146,10 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
139
146
  // even if meta.total says otherwise (count/list drift would otherwise
140
147
  // keep the sentinel re-firing forever). Reset by any page-1 fetch.
141
148
  const [infExhausted, setInfExhausted] = useState(false);
149
+ // The list endpoint answered 403: the user lacks read permission on this
150
+ // model. Rendered as "no permission" instead of masquerading as an empty
151
+ // list. Purely display state — never a fetch dependency (no refetch loop).
152
+ const [forbidden, setForbidden] = useState(false);
142
153
  const infPageRef = useRef(1);
143
154
  const [optionsMap, setOptionsMap] = useState(new Map());
144
155
  const [exportOpen, setExportOpen] = useState(false);
@@ -709,6 +720,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
709
720
  ...buildFilterParams(),
710
721
  };
711
722
  const res = await api.get(endpoint || `/data/${model}`, { params });
723
+ setForbidden(false);
712
724
  if (res.data.success) {
713
725
  const rows = res.data.data || [];
714
726
  setData(rows);
@@ -722,7 +734,14 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
722
734
  }
723
735
  }
724
736
  catch (error) {
725
- console.error('Error al cargar los datos', error);
737
+ if (isForbiddenError(error)) {
738
+ setForbidden(true);
739
+ setData([]);
740
+ setRowCount(0);
741
+ }
742
+ else {
743
+ console.error('Error al cargar los datos', error);
744
+ }
726
745
  }
727
746
  finally {
728
747
  setLoadingData(false);
@@ -768,6 +787,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
768
787
  const res = (await api.get(endpoint || `/data/${model}`, {
769
788
  params,
770
789
  }));
790
+ setForbidden(false);
771
791
  if (res.data.success) {
772
792
  const rows = res.data.data || [];
773
793
  setData((prev) => (append ? dedupeById(prev, rows) : rows));
@@ -785,7 +805,17 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
785
805
  }
786
806
  }
787
807
  catch (error) {
788
- console.error('Error al cargar los datos', error);
808
+ if (isForbiddenError(error)) {
809
+ setForbidden(true);
810
+ if (!append) {
811
+ setData([]);
812
+ setRowCount(0);
813
+ }
814
+ setInfExhausted(true);
815
+ }
816
+ else {
817
+ console.error('Error al cargar los datos', error);
818
+ }
789
819
  }
790
820
  finally {
791
821
  if (append)
@@ -1171,6 +1201,24 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
1171
1201
  getFacetedRowModel: getFacetedRowModel(),
1172
1202
  getFacetedUniqueValues: getFacetedUniqueValues(),
1173
1203
  });
1204
+ const tableRows = table.getRowModel().rows;
1205
+ const virtualizeThreshold = resolveVirtualizeThreshold(virtualizeRows);
1206
+ const shouldVirtualize = virtualizeThreshold !== false && tableRows.length >= virtualizeThreshold;
1207
+ const colSpan = Math.max(columns.length, 1);
1208
+ const desktopVirtualizer = useVirtualizer({
1209
+ count: shouldVirtualize ? tableRows.length : 0,
1210
+ getScrollElement: () => infDesktopRoot.current,
1211
+ estimateSize: () => DYNAMIC_TABLE_ROW_ESTIMATE_PX,
1212
+ overscan: 8,
1213
+ enabled: shouldVirtualize,
1214
+ });
1215
+ const mobileVirtualizer = useVirtualizer({
1216
+ count: shouldVirtualize ? tableRows.length : 0,
1217
+ getScrollElement: () => infMobileRoot.current,
1218
+ estimateSize: () => DYNAMIC_TABLE_CARD_ESTIMATE_PX,
1219
+ overscan: 6,
1220
+ enabled: shouldVirtualize,
1221
+ });
1174
1222
  const TableSkeleton = () => (_jsx(_Fragment, { children: Array.from({ length: 5 }).map((_, i) => (_jsxs(TableRow, { className: "hover:bg-transparent", children: [_jsx(TableCell, { className: "py-3 w-10", children: _jsx(Skeleton, { className: "h-4 w-4" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[70%]" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[50%]" }) }), _jsx(TableCell, { className: "py-3", children: _jsx(Skeleton, { className: "h-4 w-[60%]" }) }), _jsx(TableCell, { className: "py-3 w-16", children: _jsx(Skeleton, { className: "h-6 w-6" }) })] }, `skeleton-${i}`))) }));
1175
1223
  if (loading) {
1176
1224
  return (_jsxs("div", { className: 'flex flex-col h-full min-h-0 w-full', children: [_jsx("div", { className: 'pb-4 shrink-0', children: _jsxs("div", { className: "flex items-center justify-between", children: [_jsx(Skeleton, { className: "h-9 w-[280px]" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(Skeleton, { className: "h-9 w-9" }), _jsx(Skeleton, { className: "h-9 w-[70px]" })] })] }) }), _jsx("div", { className: 'flex-1 min-h-0 overflow-auto border rounded-md bg-card', children: _jsxs(Table, { noWrapper: true, className: "min-w-max w-full", children: [_jsx(TableHeader, { className: 'sticky top-0 z-10', children: _jsxs(TableRow, { className: 'border-b-0 hover:bg-transparent', children: [_jsx(TableHead, { className: 'bg-card border-b h-10 w-10', children: _jsx(Skeleton, { className: "h-4 w-4" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-16" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-14" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10', children: _jsx(Skeleton, { className: "h-4 w-20" }) }), _jsx(TableHead, { className: 'bg-card border-b h-10 w-16', children: _jsx(Skeleton, { className: "h-4 w-12" }) })] }) }), _jsx(TableBody, { children: _jsx(TableSkeleton, {}) })] }) })] }));
@@ -1181,11 +1229,31 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
1181
1229
  return (_jsxs(OptionsContext.Provider, { value: { optionsMap }, children: [_jsxs("div", { className: 'flex flex-col h-full min-h-0 w-full', children: [_jsx("div", { className: 'pb-4 shrink-0', children: _jsx(DataTableToolbar, { table: table, searchPlaceholder: metadata.searchPlaceholder || 'Buscar...', filters: filters, activeFilters: dynamicFilters, onDynamicFilterChange: handleDynamicFilterChange, dateFilter: { value: dateRange, onChange: setDateRange, placeholder: 'Filtrar por fecha' }, perPageOptions: metadata.perPageOptions, onRefresh: handleRefresh, isLoading: loadingData, selectedCount: Object.keys(rowSelection).length, onBulkDelete: () => setShowBulkDeleteConfirm(true), extraActions: _jsxs(_Fragment, { children: [exportEnabled && (_jsxs(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => setExportOpen(true), children: [_jsx(Download, { className: "h-4 w-4 mr-1" }), " Exportar"] })), importEnabled && (_jsxs(Button, { variant: "outline", size: "sm", className: "h-8", onClick: () => setImportOpen(true), children: [_jsx(Upload, { className: "h-4 w-4 mr-1" }), " Importar"] }))] }) }) }), _jsxs("div", { ref: infDesktopRoot, className: 'hidden sm:block flex-1 min-h-0 overflow-auto border rounded-md bg-card', children: [_jsxs(Table, { noWrapper: true, className: cn('min-w-max w-full', aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && 'h-full'), children: [_jsx(TableHeader, { className: 'sticky top-0 z-10', children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: headerGroup.headers.map((header) => {
1182
1230
  const isActionsColumn = header.id === 'actions';
1183
1231
  return (_jsx(TableHead, { colSpan: header.colSpan, style: header.column.columnDef.size ? { width: header.column.columnDef.size } : undefined, className: cn('bg-card border-b h-10', isActionsColumn && 'sticky right-0 z-20 bg-card shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]'), children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id));
1184
- }) }, headerGroup.id))) }), _jsx(TableBody, { children: loadingData && data.length === 0 ? (_jsx(TableSkeleton, {})) : table.getRowModel().rows?.length ? (_jsxs(_Fragment, { children: [table.getRowModel().rows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && 'selected', className: cn(onRowClick && 'cursor-pointer'), onClick: onRowClick ? () => onRowClick(row.original) : undefined, children: row.getVisibleCells().map((cell) => {
1232
+ }) }, headerGroup.id))) }), _jsx(TableBody, { children: loadingData && data.length === 0 ? (_jsx(TableSkeleton, {})) : tableRows.length ? (_jsxs(_Fragment, { children: [shouldVirtualize ? (_jsxs(_Fragment, { children: [desktopVirtualizer.getVirtualItems().length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', "aria-hidden": true, children: _jsx(TableCell, { colSpan: colSpan, className: 'p-0', style: {
1233
+ height: desktopVirtualizer.getVirtualItems()[0]?.start ?? 0,
1234
+ } }) })), desktopVirtualizer.getVirtualItems().map((virtualRow) => {
1235
+ const row = tableRows[virtualRow.index];
1236
+ if (!row)
1237
+ return null;
1238
+ return (_jsx(TableRow, { "data-index": virtualRow.index, ref: desktopVirtualizer.measureElement, "data-state": row.getIsSelected() && 'selected', className: cn(onRowClick && 'cursor-pointer'), onClick: onRowClick ? () => onRowClick(row.original) : undefined, children: row.getVisibleCells().map((cell) => {
1239
+ const isActionsColumn = cell.column.id === 'actions';
1240
+ const isSelectColumn = cell.column.id === 'select';
1241
+ return (_jsx(TableCell, { style: cell.column.columnDef.size ? { width: cell.column.columnDef.size } : undefined, className: cn('py-2', isActionsColumn && 'sticky right-0 bg-card shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]'), onClick: (isActionsColumn || isSelectColumn) ? (e) => e.stopPropagation() : undefined, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
1242
+ }) }, row.id));
1243
+ }), (() => {
1244
+ const items = desktopVirtualizer.getVirtualItems();
1245
+ const last = items[items.length - 1];
1246
+ const pad = last != null
1247
+ ? desktopVirtualizer.getTotalSize() - last.end
1248
+ : 0;
1249
+ if (pad <= 0)
1250
+ return null;
1251
+ return (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', "aria-hidden": true, children: _jsx(TableCell, { colSpan: colSpan, className: 'p-0', style: { height: pad } }) }));
1252
+ })()] })) : (tableRows.map((row) => (_jsx(TableRow, { "data-state": row.getIsSelected() && 'selected', className: cn(onRowClick && 'cursor-pointer'), onClick: onRowClick ? () => onRowClick(row.original) : undefined, children: row.getVisibleCells().map((cell) => {
1185
1253
  const isActionsColumn = cell.column.id === 'actions';
1186
1254
  const isSelectColumn = cell.column.id === 'select';
1187
1255
  return (_jsx(TableCell, { style: cell.column.columnDef.size ? { width: cell.column.columnDef.size } : undefined, className: cn('py-2', isActionsColumn && 'sticky right-0 bg-card shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]'), onClick: (isActionsColumn || isSelectColumn) ? (e) => e.stopPropagation() : undefined, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id));
1188
- }) }, row.id))), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0' }) }))] })) : (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0', children: _jsxs("div", { className: "flex h-full py-12 flex-col items-center justify-center gap-2 text-muted-foreground", children: [_jsx("div", { className: "flex h-20 w-20 items-center justify-center rounded-full bg-muted/50", children: _jsx(Inbox, { className: "h-10 w-10" }) }), _jsxs("div", { className: "flex flex-col items-center gap-1", children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", children: "No se encontraron resultados" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "No hay datos para mostrar en este momento." })] })] }) }) })) }), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableFooter, { className: "bg-transparent", children: _jsx(TableRow, { className: "hover:bg-transparent", children: table.getVisibleLeafColumns().map((leaf, idx) => {
1256
+ }) }, row.id)))), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableRow, { className: 'border-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0' }) }))] })) : (_jsx(TableRow, { className: 'border-b-0 hover:bg-transparent', children: _jsx(TableCell, { colSpan: columns.length, className: 'h-full p-0', children: _jsxs("div", { className: "flex h-full py-12 flex-col items-center justify-center gap-2 text-muted-foreground", children: [_jsx("div", { className: "flex h-20 w-20 items-center justify-center rounded-full bg-muted/50", children: _jsx(Inbox, { className: "h-10 w-10" }) }), _jsx("div", { className: "flex flex-col items-center gap-1", children: forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", role: "alert", children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: "text-sm text-muted-foreground", children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) : (_jsxs(_Fragment, { children: [_jsx("h3", { className: "text-lg font-semibold text-foreground", children: "No se encontraron resultados" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "No hay datos para mostrar en este momento." })] })) })] }) }) })) }), aggregateColumns.length > 0 && Object.keys(footerTotals).length > 0 && (_jsx(TableFooter, { className: "bg-transparent", children: _jsx(TableRow, { className: "hover:bg-transparent", children: table.getVisibleLeafColumns().map((leaf, idx) => {
1189
1257
  const col = (metadata?.columns ?? []).find((c) => c.key === leaf.id);
1190
1258
  const isFirst = idx === 0;
1191
1259
  const stickyBase = 'sticky bottom-0 z-10 border-t bg-background py-2 font-semibold';
@@ -1195,7 +1263,21 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
1195
1263
  }
1196
1264
  // First non-aggregate column carries the "Total" label.
1197
1265
  return (_jsx(TableCell, { className: stickyBase, children: isFirst ? t('common.total', 'Total') : '' }, leaf.id));
1198
- }) }) }))] }), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx("div", { className: 'p-2', children: _jsx(Skeleton, { className: 'h-8 w-full', "data-testid": 'table-loading-more' }) })), _jsx("div", { ref: infDesktopSentinel, className: 'h-1 w-full', "aria-hidden": true })] }))] }), _jsxs("div", { ref: infMobileRoot, className: 'flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto sm:hidden', children: [loadingData && data.length === 0 ? (Array.from({ length: 5 }).map((_, i) => (_jsxs("div", { className: 'rounded-lg border bg-card p-3', children: [_jsx(Skeleton, { className: 'h-4 w-24' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-40' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-32' })] }, i)))) : table.getRowModel().rows?.length ? (table.getRowModel().rows.map((row) => {
1266
+ }) }) }))] }), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx("div", { className: 'p-2', children: _jsx(Skeleton, { className: 'h-8 w-full', "data-testid": 'table-loading-more' }) })), _jsx("div", { ref: infDesktopSentinel, className: 'h-1 w-full', "aria-hidden": true })] }))] }), _jsxs("div", { ref: infMobileRoot, className: 'flex flex-1 min-h-0 flex-col gap-2 overflow-y-auto sm:hidden', children: [loadingData && data.length === 0 ? (Array.from({ length: 5 }).map((_, i) => (_jsxs("div", { className: 'rounded-lg border bg-card p-3', children: [_jsx(Skeleton, { className: 'h-4 w-24' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-40' }), _jsx(Skeleton, { className: 'mt-2 h-4 w-32' })] }, i)))) : tableRows.length ? (shouldVirtualize ? (_jsx("div", { className: 'relative w-full', style: { height: mobileVirtualizer.getTotalSize() }, children: mobileVirtualizer.getVirtualItems().map((virtualRow) => {
1267
+ const row = tableRows[virtualRow.index];
1268
+ if (!row)
1269
+ return null;
1270
+ const cells = row.getVisibleCells();
1271
+ const actionsCell = cells.find((c) => c.column.id === 'actions');
1272
+ const dataCells = cells.filter((c) => c.column.id !== 'actions' && c.column.id !== 'select');
1273
+ return (_jsxs("div", { "data-index": virtualRow.index, ref: mobileVirtualizer.measureElement, "data-state": row.getIsSelected() && 'selected', className: cn('absolute left-0 right-0 flex flex-col gap-1.5 rounded-lg border bg-card p-3 data-[state=selected]:border-primary/40', onRowClick && 'cursor-pointer'), style: { transform: `translateY(${virtualRow.start}px)` }, onClick: onRowClick ? () => onRowClick(row.original) : undefined, children: [dataCells.map((cell) => {
1274
+ const cellMeta = cell.column.columnDef.meta;
1275
+ const header = cell.column.columnDef.header;
1276
+ const label = cellMeta?.label ??
1277
+ (typeof header === 'string' ? header : cell.column.id);
1278
+ return (_jsxs("div", { className: 'flex items-start justify-between gap-3 text-sm', children: [_jsx("span", { className: 'shrink-0 text-muted-foreground', children: label }), _jsx("span", { className: 'min-w-0 overflow-hidden break-words text-right font-medium [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:whitespace-normal [&_[data-slot=badge]]:text-start', children: flexRender(cell.column.columnDef.cell, cell.getContext()) })] }, cell.id));
1279
+ }), actionsCell && (_jsx("div", { className: 'flex justify-end border-t pt-2', onClick: onRowClick ? (e) => e.stopPropagation() : undefined, children: flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext()) }))] }, row.id));
1280
+ }) })) : (tableRows.map((row) => {
1199
1281
  const cells = row.getVisibleCells();
1200
1282
  const actionsCell = cells.find((c) => c.column.id === 'actions');
1201
1283
  const dataCells = cells.filter((c) => c.column.id !== 'actions' && c.column.id !== 'select');
@@ -1211,7 +1293,7 @@ export function DynamicTable({ model, endpoint, mutationEndpoint, enableUrlSync
1211
1293
  (typeof header === 'string' ? header : cell.column.id);
1212
1294
  return (_jsxs("div", { className: 'flex items-start justify-between gap-3 text-sm', children: [_jsx("span", { className: 'shrink-0 text-muted-foreground', children: label }), _jsx("span", { className: 'min-w-0 overflow-hidden break-words text-right font-medium [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:whitespace-normal [&_[data-slot=badge]]:text-start', children: flexRender(cell.column.columnDef.cell, cell.getContext()) })] }, cell.id));
1213
1295
  }), actionsCell && (_jsx("div", { className: 'flex justify-end border-t pt-2', onClick: onRowClick ? (e) => e.stopPropagation() : undefined, children: flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext()) }))] }, row.id));
1214
- })) : (_jsxs("div", { className: 'flex flex-col items-center justify-center gap-2 rounded-lg border bg-card py-12 text-muted-foreground', children: [_jsx("div", { className: 'flex h-16 w-16 items-center justify-center rounded-full bg-muted/50', children: _jsx(Inbox, { className: 'h-8 w-8' }) }), _jsx("h3", { className: 'text-base font-semibold text-foreground', children: "No se encontraron resultados" }), _jsx("p", { className: 'text-sm text-muted-foreground', children: "No hay datos para mostrar en este momento." })] })), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx(Skeleton, { className: 'h-16 w-full shrink-0', "data-testid": 'table-loading-more-mobile' })), _jsx("div", { ref: infMobileSentinel, className: 'h-1 w-full shrink-0', "aria-hidden": true })] }))] }), _jsx("div", { className: 'shrink-0 pt-4', children: infiniteScroll ? (data.length > 0 && (_jsx("p", { className: 'text-center text-xs text-muted-foreground tabular-nums', children: t('common.showingCount', {
1296
+ }))) : (_jsxs("div", { className: 'flex flex-col items-center justify-center gap-2 rounded-lg border bg-card py-12 text-muted-foreground', children: [_jsx("div", { className: 'flex h-16 w-16 items-center justify-center rounded-full bg-muted/50', children: _jsx(Inbox, { className: 'h-8 w-8' }) }), forbidden ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', role: 'alert', children: t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' }) }), _jsx("p", { className: 'text-sm text-muted-foreground', children: t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' }) })] })) : (_jsxs(_Fragment, { children: [_jsx("h3", { className: 'text-base font-semibold text-foreground', children: "No se encontraron resultados" }), _jsx("p", { className: 'text-sm text-muted-foreground', children: "No hay datos para mostrar en este momento." })] }))] })), infiniteScroll && (_jsxs(_Fragment, { children: [loadingMore && (_jsx(Skeleton, { className: 'h-16 w-full shrink-0', "data-testid": 'table-loading-more-mobile' })), _jsx("div", { ref: infMobileSentinel, className: 'h-1 w-full shrink-0', "aria-hidden": true })] }))] }), _jsx("div", { className: 'shrink-0 pt-4', children: infiniteScroll ? (data.length > 0 && (_jsx("p", { className: 'text-center text-xs text-muted-foreground tabular-nums', children: t('common.showingCount', {
1215
1297
  defaultValue: '{{count}} de {{total}}',
1216
1298
  count: data.length,
1217
1299
  total: rowCount,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './types';
2
+ export * from './table-virtualization';
2
3
  export { LicenseGate, LicenseExpiryBanner, LicenseStatusBadge, isLicenseOperable, isLicenseBlocking, isPresetEntitled, isTrialExpired, type LicenseGateProps, type LicenseExpiryBannerProps, type LicenseStatusBadgeProps, type LicenseState, type LicenseStatus, type LicenseBranding, } from './license';
3
4
  export * from './options-context';
4
5
  export { extractServerError, extractFieldErrors, localizeFieldIssue, localizeFieldErrorMap, toastServerError, toastServerSuccess, type ExtractedError, type Translate, type FieldIssue, } from './server-error';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,SAAS,CAAA;AACvB,OAAO,EACH,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,GACvB,MAAM,WAAW,CAAA;AAClB,cAAc,mBAAmB,CAAA;AACjC,OAAO,EACH,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,GAClB,MAAM,gBAAgB,CAAA;AACv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,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,YAAY,EACR,UAAU,EACV,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,UAAU,EACV,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,cAAc,EACd,KAAK,iBAAiB,GACzB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACH,cAAc,EACd,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,mBAAmB,GAC3B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACH,UAAU,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,KAAK,eAAe,GACvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,aAAa,EACb,YAAY,EACZ,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,eAAe,GACvB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,SAAS,CAAA;AACvB,cAAc,wBAAwB,CAAA;AACtC,OAAO,EACH,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAC5B,KAAK,Y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 +4,7 @@
4
4
  // duplicate-symbol conflict; consumers who want the canonical SDK type
5
5
  // should import from `@asteby/metacore-sdk` directly.
6
6
  export * from './types';
7
+ export * from './table-virtualization';
7
8
  export { LicenseGate, LicenseExpiryBanner, LicenseStatusBadge, isLicenseOperable, isLicenseBlocking, isPresetEntitled, isTrialExpired, } from './license';
8
9
  export * from './options-context';
9
10
  export { extractServerError, extractFieldErrors, localizeFieldIssue, localizeFieldErrorMap, toastServerError, toastServerSuccess, } from './server-error';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Row virtualization defaults for DynamicTable.
3
+ *
4
+ * When the visible row model grows past the threshold (common in
5
+ * `pagination="infinite"` as pages accumulate, or when the user picks a large
6
+ * page size), we only mount the rows in the viewport via
7
+ * `@tanstack/react-virtual`. Below the threshold we keep the simple map so
8
+ * short tables stay trivial to debug.
9
+ */
10
+ export declare const DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD = 40;
11
+ /** Estimated desktop table row height (py-2 + content). */
12
+ export declare const DYNAMIC_TABLE_ROW_ESTIMATE_PX = 44;
13
+ /** Estimated mobile card height (padding + a few label/value rows). */
14
+ export declare const DYNAMIC_TABLE_CARD_ESTIMATE_PX = 120;
15
+ export declare function resolveVirtualizeThreshold(virtualizeRows?: boolean | number): number | false;
16
+ //# sourceMappingURL=table-virtualization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-virtualization.d.ts","sourceRoot":"","sources":["../src/table-virtualization.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,KAAK,CAAA;AAEpD,2DAA2D;AAC3D,eAAO,MAAM,6BAA6B,KAAK,CAAA;AAE/C,uEAAuE;AACvE,eAAO,MAAM,8BAA8B,MAAM,CAAA;AAEjD,wBAAgB,0BAA0B,CACxC,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,GAChC,MAAM,GAAG,KAAK,CAOhB"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Row virtualization defaults for DynamicTable.
3
+ *
4
+ * When the visible row model grows past the threshold (common in
5
+ * `pagination="infinite"` as pages accumulate, or when the user picks a large
6
+ * page size), we only mount the rows in the viewport via
7
+ * `@tanstack/react-virtual`. Below the threshold we keep the simple map so
8
+ * short tables stay trivial to debug.
9
+ */
10
+ export const DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD = 40;
11
+ /** Estimated desktop table row height (py-2 + content). */
12
+ export const DYNAMIC_TABLE_ROW_ESTIMATE_PX = 44;
13
+ /** Estimated mobile card height (padding + a few label/value rows). */
14
+ export const DYNAMIC_TABLE_CARD_ESTIMATE_PX = 120;
15
+ export function resolveVirtualizeThreshold(virtualizeRows) {
16
+ if (virtualizeRows === false)
17
+ return false;
18
+ if (typeof virtualizeRows === 'number') {
19
+ return virtualizeRows > 0 ? virtualizeRows : false;
20
+ }
21
+ // true or undefined → default threshold
22
+ return DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "39.0.0",
3
+ "version": "39.1.1",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,10 +21,13 @@
21
21
  "@dnd-kit/sortable": "^10.0.0",
22
22
  "@dnd-kit/utilities": "^3.2.2",
23
23
  "@module-federation/runtime": "^2.5.0",
24
+ "@tanstack/react-virtual": "^3.14.13",
24
25
  "recharts": "^2.15.0",
25
26
  "zod": "^4.3.0"
26
27
  },
27
28
  "peerDependencies": {
29
+ "@asteby/metacore-sdk": "^3.8.0",
30
+ "@asteby/metacore-ui": "^2.18.1",
28
31
  "@tanstack/react-query": ">=5",
29
32
  "@tanstack/react-router": ">=1.100",
30
33
  "@tanstack/react-table": ">=8",
@@ -36,9 +39,7 @@
36
39
  "react-dom": ">=18",
37
40
  "react-i18next": ">=13",
38
41
  "sonner": ">=1.7",
39
- "zustand": ">=5",
40
- "@asteby/metacore-sdk": "^3.8.0",
41
- "@asteby/metacore-ui": "^2.18.1"
42
+ "zustand": ">=5"
42
43
  },
43
44
  "peerDependenciesMeta": {
44
45
  "@tanstack/react-router": {
@@ -49,6 +50,8 @@
49
50
  }
50
51
  },
51
52
  "devDependencies": {
53
+ "@asteby/metacore-sdk": "3.8.0",
54
+ "@asteby/metacore-ui": "2.18.1",
52
55
  "@tanstack/react-query": "^5.95.0",
53
56
  "@tanstack/react-router": "^1.168.0",
54
57
  "@tanstack/react-table": "^8.20.0",
@@ -66,9 +69,7 @@
66
69
  "tsx": "^4.21.0",
67
70
  "typescript": "^6.0.0",
68
71
  "vitest": "^4.0.0",
69
- "zustand": "^5.0.0",
70
- "@asteby/metacore-sdk": "3.8.0",
71
- "@asteby/metacore-ui": "2.18.1"
72
+ "zustand": "^5.0.0"
72
73
  },
73
74
  "scripts": {
74
75
  "build": "tsc -p tsconfig.json",
@@ -0,0 +1,67 @@
1
+ // @vitest-environment happy-dom
2
+ //
3
+ // Un 403 en el endpoint de lista NO debe verse como "sin resultados": se
4
+ // muestra "Sin permiso para ver este módulo" y no hay bucle de refetch.
5
+ import { afterEach, describe, expect, it, vi } from 'vitest'
6
+ import { cleanup, render, screen } from '@testing-library/react'
7
+
8
+ vi.mock('@tanstack/react-router', () => ({ useNavigate: () => () => {} }))
9
+
10
+ import { ApiProvider, type ApiClient } from '../api-context'
11
+ import { useMetadataCache } from '../metadata-cache'
12
+ import { DynamicCRUDPage } from '../dynamic-crud-page'
13
+ import type { TableMetadata } from '../types'
14
+
15
+ afterEach(cleanup)
16
+
17
+ const meta = {
18
+ title: 'Ajustes',
19
+ endpoint: '/data/stock_adjustments',
20
+ columns: [],
21
+ actions: [],
22
+ perPageOptions: [10],
23
+ defaultPerPage: 10,
24
+ searchPlaceholder: 'Buscar...',
25
+ enableCRUDActions: false,
26
+ hasActions: false,
27
+ } as unknown as TableMetadata
28
+
29
+ function mount(listBehavior: 'forbidden' | 'empty', model: string) {
30
+ useMetadataCache.getState().setMetadata(model, meta)
31
+ let listCalls = 0
32
+ const client: ApiClient = {
33
+ get: vi.fn(async (url: string) => {
34
+ if (url.startsWith('/metadata/table/')) return { data: { success: true, data: meta } }
35
+ listCalls++
36
+ if (listBehavior === 'forbidden') {
37
+ throw Object.assign(new Error('403'), { response: { status: 403 } })
38
+ }
39
+ return { data: { success: true, data: [], meta: { total: 0 } } }
40
+ }),
41
+ post: vi.fn(async () => ({ data: { success: true, data: null } })),
42
+ put: vi.fn(async () => ({ data: { success: true, data: null } })),
43
+ delete: vi.fn(async () => ({ data: { success: true, data: null } })),
44
+ }
45
+ render(
46
+ <ApiProvider client={client}>
47
+ <DynamicCRUDPage model={model} />
48
+ </ApiProvider>,
49
+ )
50
+ return () => listCalls
51
+ }
52
+
53
+ describe('DynamicTable — 403 en la lista', () => {
54
+ it('muestra "Sin permiso" y no "No se encontraron resultados"', async () => {
55
+ const calls = mount('forbidden', 'forb_a')
56
+ expect((await screen.findAllByText('Sin permiso para ver este módulo')).length).toBeGreaterThan(0)
57
+ expect(screen.queryByText('No se encontraron resultados')).toBeNull()
58
+ await new Promise((r) => setTimeout(r, 200))
59
+ expect(calls()).toBeLessThanOrEqual(2) // sin bucle de refetch
60
+ })
61
+
62
+ it('lista vacía real sigue diciendo "No se encontraron resultados"', async () => {
63
+ mount('empty', 'forb_b')
64
+ expect((await screen.findAllByText('No se encontraron resultados')).length).toBeGreaterThan(0)
65
+ expect(screen.queryByText('Sin permiso para ver este módulo')).toBeNull()
66
+ })
67
+ })
@@ -0,0 +1,25 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import {
3
+ DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD,
4
+ resolveVirtualizeThreshold,
5
+ } from '../table-virtualization'
6
+
7
+ describe('resolveVirtualizeThreshold', () => {
8
+ it('defaults to the shared threshold', () => {
9
+ expect(resolveVirtualizeThreshold()).toBe(DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD)
10
+ expect(resolveVirtualizeThreshold(true)).toBe(DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD)
11
+ })
12
+
13
+ it('can be disabled', () => {
14
+ expect(resolveVirtualizeThreshold(false)).toBe(false)
15
+ })
16
+
17
+ it('accepts a custom positive threshold', () => {
18
+ expect(resolveVirtualizeThreshold(80)).toBe(80)
19
+ })
20
+
21
+ it('treats non-positive numbers as disabled', () => {
22
+ expect(resolveVirtualizeThreshold(0)).toBe(false)
23
+ expect(resolveVirtualizeThreshold(-1)).toBe(false)
24
+ })
25
+ })
@@ -10,10 +10,11 @@
10
10
  // * `@/components/dynamic/dynamic-columns` → host-injected via the
11
11
  // `getDynamicColumns` prop (hosts retain ownership because the rendered
12
12
  // column cells are tightly coupled to their design system).
13
- import { useEffect, useState, useMemo, useCallback, useRef } from 'react'
13
+ import { useEffect, useState, useMemo, useCallback, useRef, type MouseEvent } from 'react'
14
14
  import { useTranslation } from 'react-i18next'
15
15
  import { format } from 'date-fns'
16
16
  import type { DateRange } from 'react-day-picker'
17
+ import { useVirtualizer } from '@tanstack/react-virtual'
17
18
  import {
18
19
  type SortingState,
19
20
  type VisibilityState,
@@ -69,6 +70,11 @@ import { defaultGetDynamicColumns, DATE_CELL_TYPES, aggregateOf, formatAggregate
69
70
  import { useFacetLoaders, isLongTextColumn } from './use-facet-loaders'
70
71
  import { translateOptionLabels } from './filter-chips'
71
72
  import { dedupeById, useInfiniteScrollSentinel } from './use-infinite-scroll'
73
+ import {
74
+ DYNAMIC_TABLE_CARD_ESTIMATE_PX,
75
+ DYNAMIC_TABLE_ROW_ESTIMATE_PX,
76
+ resolveVirtualizeThreshold,
77
+ } from './table-virtualization'
72
78
  import { OptionsContext } from './options-context'
73
79
  import type { TableMetadata, ApiResponse, ColumnDefinition } from './types'
74
80
  import { getSearchableColumnKeys } from './column-visibility'
@@ -245,6 +251,19 @@ export interface DynamicTableProps {
245
251
  * mode exactly as before.
246
252
  */
247
253
  infiniteScroll?: boolean
254
+ /**
255
+ * Row virtualization. When the visible row model has at least N rows,
256
+ * only viewport rows are mounted (helps infinite scroll and large page
257
+ * sizes). `true` / omitted → default threshold (40). `false` → always
258
+ * render every row. A positive number overrides the threshold.
259
+ */
260
+ virtualizeRows?: boolean | number
261
+ }
262
+
263
+ /** True when an api-client error is an HTTP 403 (axios-style or fetch-style). */
264
+ function isForbiddenError(error: unknown): boolean {
265
+ const e = error as { response?: { status?: number }; status?: number } | null
266
+ return e?.response?.status === 403 || e?.status === 403
248
267
  }
249
268
 
250
269
  export function DynamicTable({
@@ -266,6 +285,7 @@ export function DynamicTable({
266
285
  currency,
267
286
  pagination: paginationMode,
268
287
  infiniteScroll: infiniteScrollProp = false,
288
+ virtualizeRows,
269
289
  }: DynamicTableProps) {
270
290
  // The explicit `pagination` prop wins; the legacy `infiniteScroll` boolean
271
291
  // still selects the mode when `pagination` is absent (back-compat).
@@ -308,6 +328,10 @@ export function DynamicTable({
308
328
  // even if meta.total says otherwise (count/list drift would otherwise
309
329
  // keep the sentinel re-firing forever). Reset by any page-1 fetch.
310
330
  const [infExhausted, setInfExhausted] = useState(false)
331
+ // The list endpoint answered 403: the user lacks read permission on this
332
+ // model. Rendered as "no permission" instead of masquerading as an empty
333
+ // list. Purely display state — never a fetch dependency (no refetch loop).
334
+ const [forbidden, setForbidden] = useState(false)
311
335
  const infPageRef = useRef(1)
312
336
  const [optionsMap, setOptionsMap] = useState<Map<string, any[]>>(new Map())
313
337
 
@@ -845,6 +869,7 @@ export function DynamicTable({
845
869
  ...buildFilterParams(),
846
870
  }
847
871
  const res = await api.get(endpoint || `/data/${model}`, { params }) as { data: ApiResponse<any[]> }
872
+ setForbidden(false)
848
873
  if (res.data.success) {
849
874
  const rows = res.data.data || []
850
875
  setData(rows)
@@ -860,7 +885,13 @@ export function DynamicTable({
860
885
  }
861
886
  }
862
887
  } catch (error) {
863
- console.error('Error al cargar los datos', error)
888
+ if (isForbiddenError(error)) {
889
+ setForbidden(true)
890
+ setData([])
891
+ setRowCount(0)
892
+ } else {
893
+ console.error('Error al cargar los datos', error)
894
+ }
864
895
  } finally {
865
896
  setLoadingData(false)
866
897
  }
@@ -908,6 +939,7 @@ export function DynamicTable({
908
939
  const res = (await api.get(endpoint || `/data/${model}`, {
909
940
  params,
910
941
  })) as { data: ApiResponse<any[]> }
942
+ setForbidden(false)
911
943
  if (res.data.success) {
912
944
  const rows = res.data.data || []
913
945
  setData((prev) => (append ? dedupeById(prev, rows) : rows))
@@ -927,7 +959,16 @@ export function DynamicTable({
927
959
  setInfExhausted(rows.length < infPageSize)
928
960
  }
929
961
  } catch (error) {
930
- console.error('Error al cargar los datos', error)
962
+ if (isForbiddenError(error)) {
963
+ setForbidden(true)
964
+ if (!append) {
965
+ setData([])
966
+ setRowCount(0)
967
+ }
968
+ setInfExhausted(true)
969
+ } else {
970
+ console.error('Error al cargar los datos', error)
971
+ }
931
972
  } finally {
932
973
  if (append) setLoadingMore(false)
933
974
  else setLoadingData(false)
@@ -1300,6 +1341,27 @@ export function DynamicTable({
1300
1341
  getFacetedUniqueValues: getFacetedUniqueValues(),
1301
1342
  })
1302
1343
 
1344
+ const tableRows = table.getRowModel().rows
1345
+ const virtualizeThreshold = resolveVirtualizeThreshold(virtualizeRows)
1346
+ const shouldVirtualize =
1347
+ virtualizeThreshold !== false && tableRows.length >= virtualizeThreshold
1348
+ const colSpan = Math.max(columns.length, 1)
1349
+
1350
+ const desktopVirtualizer = useVirtualizer({
1351
+ count: shouldVirtualize ? tableRows.length : 0,
1352
+ getScrollElement: () => infDesktopRoot.current,
1353
+ estimateSize: () => DYNAMIC_TABLE_ROW_ESTIMATE_PX,
1354
+ overscan: 8,
1355
+ enabled: shouldVirtualize,
1356
+ })
1357
+ const mobileVirtualizer = useVirtualizer({
1358
+ count: shouldVirtualize ? tableRows.length : 0,
1359
+ getScrollElement: () => infMobileRoot.current,
1360
+ estimateSize: () => DYNAMIC_TABLE_CARD_ESTIMATE_PX,
1361
+ overscan: 6,
1362
+ enabled: shouldVirtualize,
1363
+ })
1364
+
1303
1365
  const TableSkeleton = () => (
1304
1366
  <>
1305
1367
  {Array.from({ length: 5 }).map((_, i) => (
@@ -1407,9 +1469,70 @@ export function DynamicTable({
1407
1469
  <TableBody>
1408
1470
  {loadingData && data.length === 0 ? (
1409
1471
  <TableSkeleton />
1410
- ) : table.getRowModel().rows?.length ? (
1472
+ ) : tableRows.length ? (
1411
1473
  <>
1412
- {table.getRowModel().rows.map((row: Row<any>) => (
1474
+ {shouldVirtualize ? (
1475
+ <>
1476
+ {desktopVirtualizer.getVirtualItems().length > 0 && (
1477
+ <TableRow
1478
+ className='border-0 hover:bg-transparent'
1479
+ aria-hidden
1480
+ >
1481
+ <TableCell
1482
+ colSpan={colSpan}
1483
+ className='p-0'
1484
+ style={{
1485
+ height: desktopVirtualizer.getVirtualItems()[0]?.start ?? 0,
1486
+ }}
1487
+ />
1488
+ </TableRow>
1489
+ )}
1490
+ {desktopVirtualizer.getVirtualItems().map((virtualRow) => {
1491
+ const row = tableRows[virtualRow.index]
1492
+ if (!row) return null
1493
+ return (
1494
+ <TableRow
1495
+ key={row.id}
1496
+ data-index={virtualRow.index}
1497
+ ref={desktopVirtualizer.measureElement}
1498
+ data-state={row.getIsSelected() && 'selected'}
1499
+ className={cn(onRowClick && 'cursor-pointer')}
1500
+ onClick={onRowClick ? () => onRowClick(row.original) : undefined}
1501
+ >
1502
+ {row.getVisibleCells().map((cell: Cell<any, unknown>) => {
1503
+ const isActionsColumn = cell.column.id === 'actions'
1504
+ const isSelectColumn = cell.column.id === 'select'
1505
+ return (
1506
+ <TableCell
1507
+ key={cell.id}
1508
+ style={cell.column.columnDef.size ? { width: cell.column.columnDef.size } : undefined}
1509
+ className={cn('py-2', isActionsColumn && 'sticky right-0 bg-card shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]')}
1510
+ onClick={(isActionsColumn || isSelectColumn) ? (e: MouseEvent) => e.stopPropagation() : undefined}
1511
+ >
1512
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
1513
+ </TableCell>
1514
+ )
1515
+ })}
1516
+ </TableRow>
1517
+ )
1518
+ })}
1519
+ {(() => {
1520
+ const items = desktopVirtualizer.getVirtualItems()
1521
+ const last = items[items.length - 1]
1522
+ const pad =
1523
+ last != null
1524
+ ? desktopVirtualizer.getTotalSize() - last.end
1525
+ : 0
1526
+ if (pad <= 0) return null
1527
+ return (
1528
+ <TableRow className='border-0 hover:bg-transparent' aria-hidden>
1529
+ <TableCell colSpan={colSpan} className='p-0' style={{ height: pad }} />
1530
+ </TableRow>
1531
+ )
1532
+ })()}
1533
+ </>
1534
+ ) : (
1535
+ tableRows.map((row: Row<any>) => (
1413
1536
  <TableRow
1414
1537
  key={row.id}
1415
1538
  data-state={row.getIsSelected() && 'selected'}
@@ -1424,14 +1547,15 @@ export function DynamicTable({
1424
1547
  key={cell.id}
1425
1548
  style={cell.column.columnDef.size ? { width: cell.column.columnDef.size } : undefined}
1426
1549
  className={cn('py-2', isActionsColumn && 'sticky right-0 bg-card shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]')}
1427
- onClick={(isActionsColumn || isSelectColumn) ? (e: React.MouseEvent) => e.stopPropagation() : undefined}
1550
+ onClick={(isActionsColumn || isSelectColumn) ? (e: MouseEvent) => e.stopPropagation() : undefined}
1428
1551
  >
1429
1552
  {flexRender(cell.column.columnDef.cell, cell.getContext())}
1430
1553
  </TableCell>
1431
1554
  )
1432
1555
  })}
1433
1556
  </TableRow>
1434
- ))}
1557
+ ))
1558
+ )}
1435
1559
  {/* Spacer row: absorbs the table's leftover height (table is
1436
1560
  h-full when a footer shows) so the totals footer is pinned to
1437
1561
  the bottom of the box even with only a few rows. */}
@@ -1449,8 +1573,17 @@ export function DynamicTable({
1449
1573
  <Inbox className="h-10 w-10" />
1450
1574
  </div>
1451
1575
  <div className="flex flex-col items-center gap-1">
1452
- <h3 className="text-lg font-semibold text-foreground">No se encontraron resultados</h3>
1453
- <p className="text-sm text-muted-foreground">No hay datos para mostrar en este momento.</p>
1576
+ {forbidden ? (
1577
+ <>
1578
+ <h3 className="text-lg font-semibold text-foreground" role="alert">{t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' })}</h3>
1579
+ <p className="text-sm text-muted-foreground">{t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' })}</p>
1580
+ </>
1581
+ ) : (
1582
+ <>
1583
+ <h3 className="text-lg font-semibold text-foreground">No se encontraron resultados</h3>
1584
+ <p className="text-sm text-muted-foreground">No hay datos para mostrar en este momento.</p>
1585
+ </>
1586
+ )}
1454
1587
  </div>
1455
1588
  </div>
1456
1589
  </TableCell>
@@ -1526,8 +1659,64 @@ export function DynamicTable({
1526
1659
  <Skeleton className='mt-2 h-4 w-32' />
1527
1660
  </div>
1528
1661
  ))
1529
- ) : table.getRowModel().rows?.length ? (
1530
- table.getRowModel().rows.map((row: Row<any>) => {
1662
+ ) : tableRows.length ? (
1663
+ shouldVirtualize ? (
1664
+ <div
1665
+ className='relative w-full'
1666
+ style={{ height: mobileVirtualizer.getTotalSize() }}
1667
+ >
1668
+ {mobileVirtualizer.getVirtualItems().map((virtualRow) => {
1669
+ const row = tableRows[virtualRow.index]
1670
+ if (!row) return null
1671
+ const cells = row.getVisibleCells()
1672
+ const actionsCell = cells.find((c: Cell<any, unknown>) => c.column.id === 'actions')
1673
+ const dataCells = cells.filter(
1674
+ (c: Cell<any, unknown>) => c.column.id !== 'actions' && c.column.id !== 'select',
1675
+ )
1676
+ return (
1677
+ <div
1678
+ key={row.id}
1679
+ data-index={virtualRow.index}
1680
+ ref={mobileVirtualizer.measureElement}
1681
+ data-state={row.getIsSelected() && 'selected'}
1682
+ className={cn(
1683
+ 'absolute left-0 right-0 flex flex-col gap-1.5 rounded-lg border bg-card p-3 data-[state=selected]:border-primary/40',
1684
+ onRowClick && 'cursor-pointer',
1685
+ )}
1686
+ style={{ transform: `translateY(${virtualRow.start}px)` }}
1687
+ onClick={onRowClick ? () => onRowClick(row.original) : undefined}
1688
+ >
1689
+ {dataCells.map((cell: Cell<any, unknown>) => {
1690
+ const cellMeta = cell.column.columnDef.meta as
1691
+ | { label?: string }
1692
+ | undefined
1693
+ const header = cell.column.columnDef.header
1694
+ const label =
1695
+ cellMeta?.label ??
1696
+ (typeof header === 'string' ? header : cell.column.id)
1697
+ return (
1698
+ <div key={cell.id} className='flex items-start justify-between gap-3 text-sm'>
1699
+ <span className='shrink-0 text-muted-foreground'>{label}</span>
1700
+ <span className='min-w-0 overflow-hidden break-words text-right font-medium [&_[data-slot=badge]]:max-w-full [&_[data-slot=badge]]:whitespace-normal [&_[data-slot=badge]]:text-start'>
1701
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
1702
+ </span>
1703
+ </div>
1704
+ )
1705
+ })}
1706
+ {actionsCell && (
1707
+ <div
1708
+ className='flex justify-end border-t pt-2'
1709
+ onClick={onRowClick ? (e: MouseEvent) => e.stopPropagation() : undefined}
1710
+ >
1711
+ {flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext())}
1712
+ </div>
1713
+ )}
1714
+ </div>
1715
+ )
1716
+ })}
1717
+ </div>
1718
+ ) : (
1719
+ tableRows.map((row: Row<any>) => {
1531
1720
  const cells = row.getVisibleCells()
1532
1721
  const actionsCell = cells.find((c: Cell<any, unknown>) => c.column.id === 'actions')
1533
1722
  const dataCells = cells.filter(
@@ -1569,7 +1758,7 @@ export function DynamicTable({
1569
1758
  {actionsCell && (
1570
1759
  <div
1571
1760
  className='flex justify-end border-t pt-2'
1572
- onClick={onRowClick ? (e: React.MouseEvent) => e.stopPropagation() : undefined}
1761
+ onClick={onRowClick ? (e: MouseEvent) => e.stopPropagation() : undefined}
1573
1762
  >
1574
1763
  {flexRender(actionsCell.column.columnDef.cell, actionsCell.getContext())}
1575
1764
  </div>
@@ -1577,13 +1766,23 @@ export function DynamicTable({
1577
1766
  </div>
1578
1767
  )
1579
1768
  })
1769
+ )
1580
1770
  ) : (
1581
1771
  <div className='flex flex-col items-center justify-center gap-2 rounded-lg border bg-card py-12 text-muted-foreground'>
1582
1772
  <div className='flex h-16 w-16 items-center justify-center rounded-full bg-muted/50'>
1583
1773
  <Inbox className='h-8 w-8' />
1584
1774
  </div>
1585
- <h3 className='text-base font-semibold text-foreground'>No se encontraron resultados</h3>
1586
- <p className='text-sm text-muted-foreground'>No hay datos para mostrar en este momento.</p>
1775
+ {forbidden ? (
1776
+ <>
1777
+ <h3 className='text-base font-semibold text-foreground' role='alert'>{t('dynamic.forbidden_title', { defaultValue: 'Sin permiso para ver este módulo' })}</h3>
1778
+ <p className='text-sm text-muted-foreground'>{t('dynamic.forbidden_hint', { defaultValue: 'Tu rol no tiene acceso de lectura a estos datos. Pide acceso a un administrador.' })}</p>
1779
+ </>
1780
+ ) : (
1781
+ <>
1782
+ <h3 className='text-base font-semibold text-foreground'>No se encontraron resultados</h3>
1783
+ <p className='text-sm text-muted-foreground'>No hay datos para mostrar en este momento.</p>
1784
+ </>
1785
+ )}
1587
1786
  </div>
1588
1787
  )}
1589
1788
  {infiniteScroll && (
@@ -1636,7 +1835,7 @@ export function DynamicTable({
1636
1835
  {!isBulkDeleting && (
1637
1836
  <AlertDialogFooter>
1638
1837
  <AlertDialogCancel>{t('common.cancel')}</AlertDialogCancel>
1639
- <AlertDialogAction onClick={(e: React.MouseEvent) => { e.preventDefault(); confirmBulkDelete() }} className="bg-red-600 hover:bg-red-700">Eliminar todos</AlertDialogAction>
1838
+ <AlertDialogAction onClick={(e: MouseEvent) => { e.preventDefault(); confirmBulkDelete() }} className="bg-red-600 hover:bg-red-700">Eliminar todos</AlertDialogAction>
1640
1839
  </AlertDialogFooter>
1641
1840
  )}
1642
1841
  </AlertDialogContent>
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  // duplicate-symbol conflict; consumers who want the canonical SDK type
5
5
  // should import from `@asteby/metacore-sdk` directly.
6
6
  export * from './types'
7
+ export * from './table-virtualization'
7
8
  export {
8
9
  LicenseGate,
9
10
  LicenseExpiryBanner,
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Row virtualization defaults for DynamicTable.
3
+ *
4
+ * When the visible row model grows past the threshold (common in
5
+ * `pagination="infinite"` as pages accumulate, or when the user picks a large
6
+ * page size), we only mount the rows in the viewport via
7
+ * `@tanstack/react-virtual`. Below the threshold we keep the simple map so
8
+ * short tables stay trivial to debug.
9
+ */
10
+ export const DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD = 40
11
+
12
+ /** Estimated desktop table row height (py-2 + content). */
13
+ export const DYNAMIC_TABLE_ROW_ESTIMATE_PX = 44
14
+
15
+ /** Estimated mobile card height (padding + a few label/value rows). */
16
+ export const DYNAMIC_TABLE_CARD_ESTIMATE_PX = 120
17
+
18
+ export function resolveVirtualizeThreshold(
19
+ virtualizeRows?: boolean | number,
20
+ ): number | false {
21
+ if (virtualizeRows === false) return false
22
+ if (typeof virtualizeRows === 'number') {
23
+ return virtualizeRows > 0 ? virtualizeRows : false
24
+ }
25
+ // true or undefined → default threshold
26
+ return DYNAMIC_TABLE_VIRTUALIZE_THRESHOLD
27
+ }