@symply.io/basic-components 1.6.11-alpha.3 → 1.6.11-alpha.5

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
- import type { TableBodyProps, KvProps } from "./types";
1
+ import type { TableBodyProps, KvProps } from "../types";
2
2
  declare function TBody<RowProps extends KvProps, ExtendedProps extends KvProps>(props: TableBodyProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
3
3
  export default TBody;
@@ -25,8 +25,10 @@ import TableRow from "@mui/material/TableRow";
25
25
  import TableBody from "@mui/material/TableBody";
26
26
  import TableCell from "@mui/material/TableCell";
27
27
  import TableBodyRow from "./TableBodyRow";
28
+ import { useTableVirtualizer } from "../VirtualizerContext";
28
29
  function TBody(props) {
29
- var rows = props.rows, columns = props.columns, virtualRows = props.virtualRows, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "virtualRows", "noDataText"]);
30
+ var rows = props.rows, columns = props.columns, _a = props.noDataText, noDataText = _a === void 0 ? "No Data!" : _a, rest = __rest(props, ["rows", "columns", "noDataText"]);
31
+ var virtualRows = useTableVirtualizer().virtualRows;
30
32
  return (_jsx(TableBody, { children: virtualRows.length > 0 ? (virtualRows.map(function (virtualRow) {
31
33
  return (_jsx(TableBodyRow, __assign({ rowIndex: virtualRow.index, virtualRow: virtualRow, rows: rows, columns: columns }, rest), "DataTable_".concat(virtualRow.key || virtualRow.index)));
32
34
  })) : (_jsx(TableRow, { children: _jsx(TableCell, __assign({ colSpan: columns.length, align: "center" }, { children: noDataText })) })) }));
@@ -1,3 +1,3 @@
1
- import type { TableBodyRowProps, KvProps } from "./types";
1
+ import type { TableBodyRowProps, KvProps } from "../types";
2
2
  declare function TableBodyRow<RowProps extends KvProps, ExtendedProps extends KvProps>(props: TableBodyRowProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
3
3
  export default TableBodyRow;
@@ -15,13 +15,15 @@ import TableRow from "@mui/material/TableRow";
15
15
  import TableCell from "@mui/material/TableCell";
16
16
  import useMediaQuery from "@mui/material/useMediaQuery";
17
17
  import useTheme from "@mui/material/styles/useTheme";
18
+ import { useTableVirtualizer } from "../VirtualizerContext";
18
19
  function TableBodyRow(props) {
19
- var rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, virtualRow = props.virtualRow, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
20
+ var rows = props.rows, columns = props.columns, rowIndex = props.rowIndex, virtualRow = props.virtualRow, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
20
21
  var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
21
22
  var theme = useTheme();
22
23
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
24
+ var _b = useTableVirtualizer(), leftShadowVisible = _b.leftShadowVisible, rightShadowVisible = _b.rightShadowVisible, onMeasureElement = _b.onMeasureElement;
23
25
  var row = useMemo(function () { return rows[virtualRow.index]; }, [rows, virtualRow]);
24
- var _b = useMemo(function () {
26
+ var _c = useMemo(function () {
25
27
  if (isUpMd) {
26
28
  var left = columns.filter(function (c) { return c.fixable === "left"; });
27
29
  var right = columns.filter(function (c) { return c.fixable === "right"; });
@@ -31,8 +33,8 @@ function TableBodyRow(props) {
31
33
  else {
32
34
  return [[], columns, []];
33
35
  }
34
- }, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
35
- var _c = useMemo(function () {
36
+ }, [isUpMd, columns]), fixedLeftCols = _c[0], dynamicCols = _c[1], fixedRightCols = _c[2];
37
+ var _d = useMemo(function () {
36
38
  if (onCustomizeRowBgColor) {
37
39
  var regex = /^#(\d|[a-f]|[A-F]){6}/i;
38
40
  var _a = onCustomizeRowBgColor({ row: row, columns: columns }), normal_1 = _a.normal, hover_1 = _a.hover;
@@ -42,7 +44,7 @@ function TableBodyRow(props) {
42
44
  };
43
45
  }
44
46
  return { normal: "#FEFEFE", hover: "#F2F1F3" };
45
- }, [row, columns, onCustomizeRowBgColor]), normal = _c.normal, hover = _c.hover;
47
+ }, [row, columns, onCustomizeRowBgColor]), normal = _d.normal, hover = _d.hover;
46
48
  return (_jsxs(TableRow, __assign({ sx: {
47
49
  backgroundColor: normal,
48
50
  transform: "translateY(".concat(virtualRow.start - rowIndex * virtualRow.size, "px)"),
@@ -50,7 +52,7 @@ function TableBodyRow(props) {
50
52
  cursor: onRowClick ? "pointer" : "default",
51
53
  backgroundColor: onRowClick ? hover : normal,
52
54
  },
53
- }, onMouseEnter: function (event) {
55
+ }, "data-index": virtualRow.index, ref: function (node) { return onMeasureElement(node); }, onMouseEnter: function (event) {
54
56
  setRowEl(event.currentTarget);
55
57
  }, onMouseLeave: function () {
56
58
  setRowEl(undefined);
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { TableFooterProps, KvProps } from "./types";
2
+ import type { TableFooterProps, KvProps } from "../types";
3
3
  declare function TableFooter<RowProps extends KvProps, ExtendedProps extends KvProps>(props: TableFooterProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof TableFooter>;
5
5
  export default _default;
@@ -16,11 +16,13 @@ import Footer from "@mui/material/TableFooter";
16
16
  import TableCell from "@mui/material/TableCell";
17
17
  import useMediaQuery from "@mui/material/useMediaQuery";
18
18
  import useTheme from "@mui/material/styles/useTheme";
19
+ import { useTableVirtualizer } from "../VirtualizerContext";
19
20
  function TableFooter(props) {
20
- var _a = props.footers, footers = _a === void 0 ? [] : _a, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
21
+ var _a = props.footers, footers = _a === void 0 ? [] : _a, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, noData = props.noData;
21
22
  var theme = useTheme();
22
23
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
23
- var _b = useMemo(function () {
24
+ var _b = useTableVirtualizer(), leftShadowVisible = _b.leftShadowVisible, rightShadowVisible = _b.rightShadowVisible;
25
+ var _c = useMemo(function () {
24
26
  if (isUpMd && !noData) {
25
27
  var left = footers.filter(function (f) { return f.fixable === "left"; });
26
28
  var right = footers.filter(function (f) { return f.fixable === "right"; });
@@ -30,7 +32,7 @@ function TableFooter(props) {
30
32
  else {
31
33
  return [[], footers, []];
32
34
  }
33
- }, [isUpMd, noData, footers]), fixedLeftFooters = _b[0], dynamicFooters = _b[1], fixedRightFooters = _b[2];
35
+ }, [isUpMd, noData, footers]), fixedLeftFooters = _c[0], dynamicFooters = _c[1], fixedRightFooters = _c[2];
34
36
  return (_jsx(Footer, __assign({ sx: { position: "sticky", bottom: "-1px", zIndex: 20 } }, { children: _jsxs(TableRow, __assign({ sx: {
35
37
  backgroundColor: "".concat(footerBgColor || "#eaf0f6", " !important"),
36
38
  color: "".concat(footerTextColor || "inherit", " !important"),
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { TableHeaderProps, KvProps } from "./types";
2
+ import type { TableHeaderProps, KvProps } from "../types";
3
3
  declare function TableHeader<RowProps extends KvProps, ExtendedProps extends KvProps>(props: TableHeaderProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof TableHeader>;
5
5
  export default _default;
@@ -16,11 +16,13 @@ import TableHead from "@mui/material/TableHead";
16
16
  import TableCell from "@mui/material/TableCell";
17
17
  import useMediaQuery from "@mui/material/useMediaQuery";
18
18
  import useTheme from "@mui/material/styles/useTheme";
19
+ import { useTableVirtualizer } from "../VirtualizerContext";
19
20
  function TableHeader(props) {
20
- var headers = props.headers, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
21
+ var headers = props.headers, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, noData = props.noData;
21
22
  var theme = useTheme();
22
23
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
23
- var _a = useMemo(function () {
24
+ var _a = useTableVirtualizer(), leftShadowVisible = _a.leftShadowVisible, rightShadowVisible = _a.rightShadowVisible;
25
+ var _b = useMemo(function () {
24
26
  if (isUpMd && !noData) {
25
27
  var left = headers.filter(function (h) { return h.fixable === "left"; });
26
28
  var right = headers.filter(function (h) { return h.fixable === "right"; });
@@ -30,7 +32,7 @@ function TableHeader(props) {
30
32
  else {
31
33
  return [[], headers, []];
32
34
  }
33
- }, [isUpMd, noData, headers]), fixedLeftHeaders = _a[0], dynamicHeaders = _a[1], fixedRightHeaders = _a[2];
35
+ }, [isUpMd, noData, headers]), fixedLeftHeaders = _b[0], dynamicHeaders = _b[1], fixedRightHeaders = _b[2];
34
36
  return (_jsx(TableHead, __assign({ sx: { position: "sticky", top: 0, zIndex: 20 } }, { children: _jsxs(TableRow, __assign({ sx: {
35
37
  backgroundColor: "".concat(headerBgColor || "#eaf0f6", " !important"),
36
38
  color: "".concat(headerTextColor || "inherit", " !important"),
@@ -0,0 +1,3 @@
1
+ import type { KvProps, DataTableCoreProps } from "../types";
2
+ declare function TableCore<RowProps extends KvProps, ExtendedProps extends KvProps>(props: DataTableCoreProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
3
+ export default TableCore;
@@ -0,0 +1,32 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import Table from "@mui/material/Table";
14
+ import TableContainer from "@mui/material/TableContainer";
15
+ import TableBody from "./TableBody";
16
+ import TableHeader from "./TableHeader";
17
+ import TableFooter from "./TableFooter";
18
+ import { useTableVirtualizer } from "../VirtualizerContext";
19
+ function TableCore(props) {
20
+ var dense = props.dense, _a = props.rows, rows = _a === void 0 ? [] : _a, _b = props.columns, columns = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
21
+ var _f = useTableVirtualizer(), tableRef = _f.tableRef, onProcessShadowVisible = _f.onProcessShadowVisible;
22
+ return (_jsx(TableContainer, __assign({ ref: tableRef, onScroll: onProcessShadowVisible, sx: {
23
+ maxHeight: "inherit",
24
+ borderWidth: "thin",
25
+ borderColor: "#e5e5e5",
26
+ borderStyle: "solid",
27
+ borderRadius: "4px",
28
+ borderCollapse: "unset !important",
29
+ transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
30
+ } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, headerBgColor: headerBgColor, headerTextColor: headerTextColor, noData: rows.length === 0 }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0 })) : (_jsx(_Fragment, {}))] })) })));
31
+ }
32
+ export default TableCore;
@@ -0,0 +1,3 @@
1
+ import type { KvProps, IVirtualizerContext, VirtualizerContextProviderProps } from "./types";
2
+ export declare function VirtualizerContextProvider<RowProps extends KvProps, ExtendedProps extends KvProps>(props: VirtualizerContextProviderProps<RowProps, ExtendedProps>): import("react/jsx-runtime").JSX.Element;
3
+ export declare const useTableVirtualizer: () => IVirtualizerContext;
@@ -0,0 +1,73 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { useRef, useState, useEffect, useContext, useCallback, createContext, } from "react";
14
+ import { useVirtualizer } from "@tanstack/react-virtual";
15
+ var VirtualizerContext = createContext({
16
+ tableRef: { current: null },
17
+ virtualRows: [],
18
+ leftShadowVisible: false,
19
+ rightShadowVisible: false,
20
+ onMeasureElement: function () { },
21
+ onProcessShadowVisible: function () { },
22
+ });
23
+ export function VirtualizerContextProvider(props) {
24
+ var children = props.children, rows = props.rows, columns = props.columns, dense = props.dense;
25
+ var tableRef = useRef(null);
26
+ var rowVirtualizer = useVirtualizer({
27
+ count: rows.length,
28
+ getScrollElement: function () { return tableRef.current; },
29
+ estimateSize: function () { return (dense ? 48 : 72); },
30
+ measureElement: typeof window !== "undefined" &&
31
+ navigator.userAgent.indexOf("Firefox") === -1
32
+ ? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
33
+ : undefined,
34
+ overscan: 6,
35
+ });
36
+ var _a = useState(false), leftShadowVisible = _a[0], setLeftShadowVisible = _a[1];
37
+ var _b = useState(false), rightShadowVisible = _b[0], setRightShadowVisible = _b[1];
38
+ var measureElement = rowVirtualizer.measureElement, getVirtualItems = rowVirtualizer.getVirtualItems;
39
+ var virtualRows = getVirtualItems();
40
+ var onProcessShadowVisible = useCallback(function () {
41
+ if (tableRef.current) {
42
+ var target = tableRef.current;
43
+ var scrollLeft = target.scrollLeft;
44
+ var scrollWidth = target.scrollWidth;
45
+ var clientWidth = target.clientWidth;
46
+ var hasScrollBar = scrollWidth > clientWidth;
47
+ setLeftShadowVisible(hasScrollBar && scrollLeft > 0);
48
+ setRightShadowVisible(hasScrollBar && scrollWidth - scrollLeft > clientWidth + 1);
49
+ }
50
+ }, []);
51
+ useEffect(function () {
52
+ if (columns) {
53
+ onProcessShadowVisible();
54
+ }
55
+ }, [columns, onProcessShadowVisible]);
56
+ useEffect(function () {
57
+ window.addEventListener("resize", onProcessShadowVisible);
58
+ }, [onProcessShadowVisible]);
59
+ useEffect(function () { return function () {
60
+ window.removeEventListener("scroll", onProcessShadowVisible);
61
+ }; }, [onProcessShadowVisible]);
62
+ return (_jsx(VirtualizerContext.Provider, __assign({ value: {
63
+ tableRef: tableRef,
64
+ virtualRows: virtualRows,
65
+ leftShadowVisible: leftShadowVisible,
66
+ rightShadowVisible: rightShadowVisible,
67
+ onMeasureElement: measureElement,
68
+ onProcessShadowVisible: onProcessShadowVisible,
69
+ } }, { children: children })));
70
+ }
71
+ export var useTableVirtualizer = function () {
72
+ return useContext(VirtualizerContext);
73
+ };
@@ -9,66 +9,27 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { useState, useCallback, useRef, useEffect } from "react";
14
- import Grid from "@mui/material/Grid";
15
- import Table from "@mui/material/Table";
16
- import TableContainer from "@mui/material/TableContainer";
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ import { jsx as _jsx } from "react/jsx-runtime";
17
24
  import ThemeProvider from "@mui/material/styles/ThemeProvider";
18
- import { useVirtualizer } from "@tanstack/react-virtual";
19
25
  import useCustomTheme from "../useCustomTheme";
20
26
  import useDataTable from "./useTable";
21
- import TableBody from "./TableBody";
22
- import TableHeader from "./TableHeader";
23
- import TableFooter from "./TableFooter";
27
+ import TableCore from "./TableCore";
28
+ import { VirtualizerContextProvider } from "./VirtualizerContext";
24
29
  function DataTable(props) {
25
- var dense = props.dense, _a = props.rows, rows = _a === void 0 ? [] : _a, _b = props.columns, columns = _b === void 0 ? [] : _b, _c = props.headers, headers = _c === void 0 ? [] : _c, _d = props.footers, footers = _d === void 0 ? [] : _d, _e = props.noDataText, noDataText = _e === void 0 ? "No Data!" : _e, headerBgColor = props.headerBgColor, headerTextColor = props.headerTextColor, footerBgColor = props.footerBgColor, footerTextColor = props.footerTextColor, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, onRowClick = props.onRowClick, onContextMenu = props.onContextMenu, onCustomizeRowBgColor = props.onCustomizeRowBgColor;
30
+ var primaryColor = props.primaryColor, secondaryColor = props.secondaryColor, rows = props.rows, columns = props.columns, dense = props.dense, rest = __rest(props, ["primaryColor", "secondaryColor", "rows", "columns", "dense"]);
26
31
  var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
27
- var tableRef = useRef(null);
28
- var rowVirtualizer = useVirtualizer({
29
- count: rows.length,
30
- getScrollElement: function () { return tableRef.current; },
31
- estimateSize: function () { return (dense ? 48 : 72); },
32
- measureElement: typeof window !== "undefined" &&
33
- navigator.userAgent.indexOf("Firefox") === -1
34
- ? function (element) { return element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height; }
35
- : undefined,
36
- overscan: 6,
37
- });
38
- var _f = useState(false), leftShadowVisible = _f[0], setLeftShadowVisible = _f[1];
39
- var _g = useState(false), rightShadowVisible = _g[0], setRightShadowVisible = _g[1];
40
- var virtualRows = rowVirtualizer.getVirtualItems();
41
- var onProcessShadowVisible = useCallback(function () {
42
- if (tableRef.current) {
43
- var target = tableRef.current;
44
- var scrollLeft = target.scrollLeft;
45
- var scrollWidth = target.scrollWidth;
46
- var clientWidth = target.clientWidth;
47
- var hasScrollBar = scrollWidth > clientWidth;
48
- setLeftShadowVisible(hasScrollBar && scrollLeft > 0);
49
- setRightShadowVisible(hasScrollBar && scrollWidth - scrollLeft > clientWidth + 1);
50
- }
51
- }, []);
52
- useEffect(function () {
53
- if (columns) {
54
- onProcessShadowVisible();
55
- }
56
- }, [columns, onProcessShadowVisible]);
57
- useEffect(function () {
58
- window.addEventListener("resize", onProcessShadowVisible);
59
- }, [onProcessShadowVisible]);
60
- useEffect(function () { return function () {
61
- window.removeEventListener("scroll", onProcessShadowVisible);
62
- }; }, [onProcessShadowVisible]);
63
- return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(TableContainer, __assign({ ref: tableRef, onScroll: onProcessShadowVisible, sx: {
64
- maxHeight: "inherit",
65
- borderWidth: "thin",
66
- borderColor: "#e5e5e5",
67
- borderStyle: "solid",
68
- borderRadius: "4px",
69
- borderCollapse: "unset !important",
70
- transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
71
- } }, { children: _jsx(Grid, __assign({ sx: { height: "".concat(rowVirtualizer.getTotalSize(), "px") } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, headerBgColor: headerBgColor, headerTextColor: headerTextColor, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, virtualRows: virtualRows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, onContextMenu: onContextMenu, onCustomizeRowBgColor: onCustomizeRowBgColor, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), (footers === null || footers === void 0 ? void 0 : footers.length) > 0 ? (_jsx(TableFooter, { footers: footers, footerBgColor: footerBgColor, footerTextColor: footerTextColor, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })) })));
32
+ return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(VirtualizerContextProvider, __assign({ rows: rows, columns: columns, dense: dense }, { children: _jsx(TableCore, __assign({}, rest, { rows: rows, columns: columns, dense: dense })) })) })));
72
33
  }
73
34
  export default DataTable;
74
35
  export * from "./types";
@@ -1,4 +1,4 @@
1
- import type { ReactElement, CSSProperties, MouseEvent } from "react";
1
+ import type { ReactNode, RefObject, MouseEvent, ReactElement, CSSProperties } from "react";
2
2
  import type { VirtualItem } from "@tanstack/react-virtual";
3
3
  declare type HexColor = `#${string}`;
4
4
  export declare type CustomRowBgColor = {
@@ -56,15 +56,10 @@ export declare type TableHeaderProps<RowProps extends KvProps, ExtendedProps ext
56
56
  headerBgColor?: CSSProperties["color"];
57
57
  headerTextColor?: CSSProperties["color"];
58
58
  noData?: boolean;
59
- leftShadowVisible?: boolean;
60
- rightShadowVisible?: boolean;
61
59
  };
62
60
  export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps extends KvProps> = {
63
61
  columns: Array<TableBodyCellProps<RowProps, ExtendedProps>>;
64
62
  rows: Array<RowProps>;
65
- virtualRows: Array<VirtualItem>;
66
- leftShadowVisible?: boolean;
67
- rightShadowVisible?: boolean;
68
63
  noDataText?: string;
69
64
  onRowClick?: (row: RowProps) => unknown;
70
65
  onContextMenu?: (event: MouseEvent<HTMLTableRowElement>, row: RowProps) => unknown;
@@ -73,7 +68,7 @@ export declare type TableBodyProps<RowProps extends KvProps, ExtendedProps exten
73
68
  columns: Array<TableBodyCellProps<RowProps, ExtendedProps>>;
74
69
  }) => CustomRowBgColor;
75
70
  };
76
- export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableBodyProps<RowProps, ExtendedProps>, "noDataText" | "virtualRows"> & {
71
+ export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableBodyProps<RowProps, ExtendedProps>, "noDataText"> & {
77
72
  rowIndex: number;
78
73
  virtualRow: VirtualItem;
79
74
  };
@@ -82,12 +77,28 @@ export declare type TableFooterProps<RowProps extends KvProps, ExtendedProps ext
82
77
  footerBgColor?: CSSProperties["color"];
83
78
  footerTextColor?: CSSProperties["color"];
84
79
  noData?: boolean;
85
- leftShadowVisible?: boolean;
86
- rightShadowVisible?: boolean;
87
80
  };
88
- export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & Omit<TableBodyProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "virtualRows"> & Omit<TableFooterProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & {
81
+ export declare type DataTableCoreProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "noData"> & TableBodyProps<RowProps, ExtendedProps> & Omit<TableFooterProps<RowProps, ExtendedProps>, "noData"> & {
89
82
  dense?: boolean;
90
83
  primaryColor?: CSSProperties["color"];
91
84
  secondaryColor?: CSSProperties["color"];
92
85
  };
86
+ export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = DataTableCoreProps<RowProps, ExtendedProps> & {
87
+ primaryColor?: CSSProperties["color"];
88
+ secondaryColor?: CSSProperties["color"];
89
+ };
90
+ export interface VirtualizerContextProviderProps<RowProps extends KvProps, ExtendedProps extends KvProps> {
91
+ dense?: boolean;
92
+ children: ReactNode;
93
+ rows: Array<RowProps>;
94
+ columns: Array<TableBodyCellProps<RowProps, ExtendedProps>>;
95
+ }
96
+ export interface IVirtualizerContext {
97
+ tableRef: RefObject<HTMLDivElement>;
98
+ virtualRows: Array<VirtualItem>;
99
+ leftShadowVisible: boolean;
100
+ rightShadowVisible: boolean;
101
+ onMeasureElement: (node: Element | null | undefined) => void;
102
+ onProcessShadowVisible: () => void;
103
+ }
93
104
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.6.11-alpha.3",
3
+ "version": "1.6.11-alpha.5",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",