tp-react-elements 1.3.9 → 1.3.10

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.
@@ -1,3 +1,3 @@
1
- var Month = {};
1
+ var InputRangeField = {};
2
2
 
3
- export { Month as __exports };
3
+ export { InputRangeField as __exports };
@@ -1,3 +1,3 @@
1
- var InputRangeField = {};
1
+ var Month = {};
2
2
 
3
- export { InputRangeField as __exports };
3
+ export { Month as __exports };
@@ -1,3 +1,3 @@
1
- var Calendar = {};
1
+ var DefinedRange = {};
2
2
 
3
- export { Calendar as __exports };
3
+ export { DefinedRange as __exports };
@@ -1,3 +1,3 @@
1
- var DateRangePicker = {};
1
+ var DateRange = {};
2
2
 
3
- export { DateRangePicker as __exports };
3
+ export { DateRange as __exports };
@@ -1,3 +1,3 @@
1
- var DefinedRange = {};
1
+ var DateRangePicker = {};
2
2
 
3
- export { DefinedRange as __exports };
3
+ export { DateRangePicker as __exports };
@@ -1,3 +1,3 @@
1
- var DateRange = {};
1
+ var Calendar = {};
2
2
 
3
- export { DateRange as __exports };
3
+ export { Calendar as __exports };
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useState, useRef, useLayoutEffect, useMemo } from 'react';
3
3
  import { useMaterialReactTable, MaterialReactTable } from 'material-react-table';
4
4
  import { useQuery, keepPreviousData } from '@tanstack/react-query';
5
- import { Box, Tooltip, IconButton, Button, GlobalStyles, Typography, Select, MenuItem, CircularProgress } from '@mui/material';
5
+ import { Box, Tooltip, IconButton, GlobalStyles, Typography, Select, MenuItem, CircularProgress } from '@mui/material';
6
6
  import RefreshIcon from '@mui/icons-material/Refresh';
7
7
  import FileDownloadIcon from '@mui/icons-material/FileDownload';
8
8
  import FirstPageIcon from '@mui/icons-material/FirstPage';
@@ -77,12 +77,35 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
77
77
  return;
78
78
  const update = () => {
79
79
  const top = el.getBoundingClientRect().top;
80
- setAutoHeight(`calc(100vh - ${Math.ceil(top) + 8}px)`);
80
+ // CSS max() guarantees a minimum visible height (300px) when the grid
81
+ // starts below the fold or when little viewport space remains — both
82
+ // cases produce a negative/tiny calc() that would otherwise collapse
83
+ // the grid to zero height.
84
+ setAutoHeight(`max(300px, calc(100vh - ${Math.ceil(top) + 8}px))`);
81
85
  };
82
86
  update();
87
+ // Re-measure on any document resize (window resize, sidebar toggle, etc.)
83
88
  const ro = new ResizeObserver(update);
84
89
  ro.observe(document.documentElement);
85
- return () => ro.disconnect();
90
+ // Re-measure when the scroll container scrolls — the grid's
91
+ // viewport-relative top offset shifts with scroll position, so the
92
+ // height must be recalculated to fill the remaining visible space.
93
+ const findScrollParent = (node) => {
94
+ let p = node.parentElement;
95
+ while (p && p !== document.documentElement) {
96
+ const { overflow, overflowY } = window.getComputedStyle(p);
97
+ if (/auto|scroll/.test(overflow) || /auto|scroll/.test(overflowY))
98
+ return p;
99
+ p = p.parentElement;
100
+ }
101
+ return window;
102
+ };
103
+ const scrollParent = findScrollParent(el);
104
+ scrollParent.addEventListener('scroll', update, { passive: true });
105
+ return () => {
106
+ ro.disconnect();
107
+ scrollParent.removeEventListener('scroll', update);
108
+ };
86
109
  }, [tableHeight]);
87
110
  // Resolved height: explicit prop › auto-calculated › safe fallback
88
111
  const resolvedHeight = tableHeight || autoHeight || '60vh';
@@ -184,8 +207,6 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
184
207
  a.click();
185
208
  URL.revokeObjectURL(url);
186
209
  };
187
- const hasAnyValue = Object.values(filterValues).some(Boolean) ||
188
- columnFilters.some((f) => f.value);
189
210
  // ── Table instance ─────────────────────────────────────────────────────────
190
211
  const table = useMaterialReactTable({
191
212
  columns: processedColumns,
@@ -226,12 +247,12 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
226
247
  enableStickyHeader: true,
227
248
  enableRowVirtualization: true,
228
249
  // The container fills whatever height is left after the top toolbar and
229
- // pagination footer. min-height: 0 is required so the flex child can
230
- // shrink below its natural content height and scroll its rows instead.
250
+ // pagination footer. minHeight ensures a visible body even when there are
251
+ // no records; flex: '1 1 0' lets it grow to fill the remaining space.
231
252
  muiTableContainerProps: {
232
253
  sx: {
233
254
  flex: '1 1 0',
234
- minHeight: 0,
255
+ minHeight: '150px',
235
256
  },
236
257
  },
237
258
  // Paper fills the wrapper Box height and acts as the flex column host for
@@ -301,15 +322,7 @@ function GenericPaginatedGrid({ columns, fetchPage, queryKey, serverFilterDefs,
301
322
  muiToolbarAlertBannerProps: isError
302
323
  ? { color: 'error', children: 'Failed to load data. Please try again.' }
303
324
  : undefined,
304
- renderTopToolbarCustomActions: () => (jsxs(Box, { sx: { display: 'flex', alignItems: 'center', flex: 1, minWidth: 0, pr: 1, gap: 0.5 }, children: [jsxs(Box, { sx: { display: 'flex', alignItems: 'center', flexShrink: 0, gap: 0.25 }, children: [jsx(Tooltip, { title: "Refresh current batch", children: jsx("span", { children: jsx(IconButton, { size: "small", onClick: () => refetch(), disabled: isFetching, children: jsx(RefreshIcon, { fontSize: "small" }) }) }) }), jsx(Tooltip, { title: "Export batch as CSV", children: jsx("span", { children: jsx(IconButton, { size: "small", onClick: handleExport, disabled: rows.length === 0 || isFetching, children: jsx(FileDownloadIcon, { fontSize: "small" }) }) }) })] }), jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: jsx(DynamicFilterBar, { serverFilterDefs: serverFilterDefs, visibleFilterIds: visibleFilterIds, onToggleFilter: handleToggleFilter, filterValues: filterValues, onFilterValuesChange: handleFilterValuesChange, columnFilters: columnFilters, onColumnFilterChange: setColumnFilters, availableColumns: availableColumns, maxVisibleFilters: maxVisibleFilters }) }), hasAnyValue && (jsx(Button, { size: "small", onClick: handleClearAll, sx: {
305
- flexShrink: 0,
306
- textTransform: 'none',
307
- fontSize: 12,
308
- color: 'error.main',
309
- minWidth: 'auto',
310
- px: 1,
311
- '&:hover': { bgcolor: 'rgba(211,47,47,0.06)' },
312
- }, children: "Clear All" }))] })),
325
+ renderTopToolbarCustomActions: () => (jsxs(Box, { sx: { display: 'flex', alignItems: 'center', flex: 1, minWidth: 0, pr: 1, gap: 0.5 }, children: [jsxs(Box, { sx: { display: 'flex', alignItems: 'center', flexShrink: 0, gap: 0.25 }, children: [jsx(Tooltip, { title: "Clear filters & refresh", children: jsx("span", { children: jsx(IconButton, { size: "small", onClick: () => { handleClearAll(); refetch(); }, disabled: isFetching, children: jsx(RefreshIcon, { fontSize: "small" }) }) }) }), jsx(Tooltip, { title: "Export batch as CSV", children: jsx("span", { children: jsx(IconButton, { size: "small", onClick: handleExport, disabled: rows.length === 0 || isFetching, children: jsx(FileDownloadIcon, { fontSize: "small" }) }) }) })] }), jsx(Box, { sx: { flex: 1, minWidth: 0 }, children: jsx(DynamicFilterBar, { serverFilterDefs: serverFilterDefs, visibleFilterIds: visibleFilterIds, onToggleFilter: handleToggleFilter, filterValues: filterValues, onFilterValuesChange: handleFilterValuesChange, columnFilters: columnFilters, onColumnFilterChange: setColumnFilters, availableColumns: availableColumns, maxVisibleFilters: maxVisibleFilters }) })] })),
313
326
  renderBottomToolbar: ({ table: t }) => (jsx(PaginationFooter, { pageIndex: t.getState().pagination.pageIndex, pageSize: t.getState().pagination.pageSize, totalRecords: totalRecords, isFetching: isFetching, isLoading: isLoading, canPrev: t.getCanPreviousPage() && !isFetching, canNext: t.getCanNextPage() && !isFetching, onFirst: () => t.firstPage(), onPrev: () => t.previousPage(), onNext: () => t.nextPage(), onLast: () => t.lastPage(), onPageSizeChange: (s) => t.setPageSize(s), pageSizeOptions: pageSizeOptions })),
314
327
  });
315
328
  return (jsxs(Box, { ref: containerRef, className: "tp-gpg-root", sx: {
@@ -1,4 +1,4 @@
1
- import { __exports as Calendar } from '../../../../../_virtual/index.esm4.js';
1
+ import { __exports as Calendar } from '../../../../../_virtual/index.esm7.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDayCell } from '../DayCell/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateRange } from '../../../../../_virtual/index.esm7.js';
1
+ import { __exports as DateRange } from '../../../../../_virtual/index.esm5.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireCalendar } from '../Calendar/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm5.js';
1
+ import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm6.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDateRange } from '../DateRange/index.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as DefinedRange } from '../../../../../_virtual/index.esm6.js';
1
+ import { __exports as DefinedRange } from '../../../../../_virtual/index.esm4.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireStyles } from '../../styles.esm.js';
@@ -1,4 +1,4 @@
1
- import { __exports as InputRangeField } from '../../../../../_virtual/index.esm14.js';
1
+ import { __exports as InputRangeField } from '../../../../../_virtual/index.esm12.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { __exports as Month } from '../../../../../_virtual/index.esm12.js';
1
+ import { __exports as Month } from '../../../../../_virtual/index.esm14.js';
2
2
  import React__default from 'react';
3
3
  import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
4
4
  import { __require as requireDayCell } from '../DayCell/index.esm.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tp-react-elements",
3
- "version": "1.3.9",
3
+ "version": "1.3.10",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "React form components library built with React Hook Form and Yup",