@symply.io/basic-components 1.1.2-beta.11 → 1.1.2-beta.13

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.
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { cloneElement, useState } from "react";
13
+ import { cloneElement, useState, useMemo } from "react";
14
14
  import TableRow from "@mui/material/TableRow";
15
15
  import TableCell from "@mui/material/TableCell";
16
16
  import useMediaQuery from "@mui/material/useMediaQuery";
@@ -20,11 +20,17 @@ function TableBodyRow(props) {
20
20
  var _a = useState(), rowEl = _a[0], setRowEl = _a[1];
21
21
  var theme = useTheme();
22
22
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
23
- var fixedLeftCols = isUpMd ? columns.filter(function (c) { return c.fixable === "left"; }) : [];
24
- var fixedRightCols = isUpMd
25
- ? columns.filter(function (c) { return c.fixable === "right"; })
26
- : [];
27
- var dynamicCols = isUpMd ? columns.filter(function (c) { return !c.fixable; }) : columns;
23
+ var _b = useMemo(function () {
24
+ if (isUpMd) {
25
+ var left = columns.filter(function (c) { return c.fixable === "left"; });
26
+ var right = columns.filter(function (c) { return c.fixable === "right"; });
27
+ var dynamic = columns.filter(function (c) { return !c.fixable; });
28
+ return [left, dynamic, right];
29
+ }
30
+ else {
31
+ return [[], columns, []];
32
+ }
33
+ }, [isUpMd, columns]), fixedLeftCols = _b[0], dynamicCols = _b[1], fixedRightCols = _b[2];
28
34
  return (_jsxs(TableRow, __assign({ sx: {
29
35
  "&:hover": {
30
36
  cursor: onRowClick ? "pointer" : "default",
@@ -10,23 +10,27 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { cloneElement } from "react";
13
+ import { cloneElement, useMemo } from "react";
14
14
  import TableRow from "@mui/material/TableRow";
15
15
  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
19
  function TableFooter(props) {
20
- var footers = props.footers, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
20
+ var footers = props.footers, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
21
21
  var theme = useTheme();
22
22
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
23
- var fixedLeftFooters = isUpMd
24
- ? footers.filter(function (f) { return f.fixable === "left"; })
25
- : [];
26
- var fixedRightFooters = isUpMd
27
- ? footers.filter(function (f) { return f.fixable === "right"; })
28
- : [];
29
- var dynamicFooters = isUpMd ? footers.filter(function (f) { return !f.fixable; }) : footers;
23
+ var _a = useMemo(function () {
24
+ if (isUpMd && !noData) {
25
+ var left = footers.filter(function (f) { return f.fixable === "left"; });
26
+ var right = footers.filter(function (f) { return f.fixable === "right"; });
27
+ var dynamic = footers.filter(function (f) { return !f.fixable; });
28
+ return [left, dynamic, right];
29
+ }
30
+ else {
31
+ return [[], footers, []];
32
+ }
33
+ }, [isUpMd, noData, footers]), fixedLeftFooters = _a[0], dynamicFooters = _a[1], fixedRightFooters = _a[2];
30
34
  return (_jsx(Footer, { children: _jsxs(TableRow, __assign({ sx: { backgroundColor: "#eaf0f6" } }, { children: [fixedLeftFooters.map(function (footer, index) {
31
35
  var accessor = footer.accessor, Cell = footer.Cell, _a = footer.align, align = _a === void 0 ? "center" : _a, width = footer.width;
32
36
  var left = fixedLeftFooters
@@ -10,23 +10,27 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { cloneElement } from "react";
13
+ import { cloneElement, useMemo } from "react";
14
14
  import TableRow from "@mui/material/TableRow";
15
15
  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
19
  function TableHeader(props) {
20
- var headers = props.headers, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
20
+ var headers = props.headers, noData = props.noData, leftShadowVisible = props.leftShadowVisible, rightShadowVisible = props.rightShadowVisible;
21
21
  var theme = useTheme();
22
22
  var isUpMd = useMediaQuery(theme.breakpoints.up("md"));
23
- var fixedLeftHeaders = isUpMd
24
- ? headers.filter(function (h) { return h.fixable === "left"; })
25
- : [];
26
- var fixedRightHeaders = isUpMd
27
- ? headers.filter(function (h) { return h.fixable === "right"; })
28
- : [];
29
- var dynamicHeaders = isUpMd ? headers.filter(function (h) { return !h.fixable; }) : headers;
23
+ var _a = useMemo(function () {
24
+ if (isUpMd && !noData) {
25
+ var left = headers.filter(function (h) { return h.fixable === "left"; });
26
+ var right = headers.filter(function (h) { return h.fixable === "right"; });
27
+ var dynamic = headers.filter(function (h) { return !h.fixable; });
28
+ return [left, dynamic, right];
29
+ }
30
+ else {
31
+ return [[], headers, []];
32
+ }
33
+ }, [isUpMd, noData, headers]), fixedLeftHeaders = _a[0], dynamicHeaders = _a[1], fixedRightHeaders = _a[2];
30
34
  return (_jsx(TableHead, { children: _jsxs(TableRow, __assign({ sx: { backgroundColor: "#eaf0f6" } }, { children: [fixedLeftHeaders.map(function (header, index) {
31
35
  var accessor = header.accessor, Cell = header.Cell, _a = header.align, align = _a === void 0 ? "center" : _a, width = header.width, title = header.title, _b = header.sortable, sortable = _b === void 0 ? false : _b, onSort = header.onSort;
32
36
  var left = fixedLeftHeaders
@@ -32,7 +32,7 @@ function DataTable(props) {
32
32
  var clientWidth = target.clientWidth;
33
33
  var hasScrollBar = scrollWidth > clientWidth;
34
34
  setLeftShadowVisible(hasScrollBar && scrollLeft > 0);
35
- setRightShadowVisible(hasScrollBar && scrollWidth - scrollLeft !== clientWidth);
35
+ setRightShadowVisible(hasScrollBar && scrollWidth - scrollLeft > clientWidth);
36
36
  }
37
37
  }, []);
38
38
  useEffect(function () {
@@ -53,7 +53,7 @@ function DataTable(props) {
53
53
  borderRadius: "4px",
54
54
  borderCollapse: "unset !important",
55
55
  transition: "all 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms"
56
- } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
56
+ } }, { children: _jsxs(Table, __assign({ sx: { minWidth: 600, tableLayout: "fixed" }, stickyHeader: stickyHeader, size: dense ? "small" : "medium" }, { children: [_jsx(TableHeader, { headers: headers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), _jsx(TableBody, { rows: rows, columns: columns, noDataText: noDataText, onRowClick: onRowClick, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible }), footers.length > 0 ? (_jsx(TableFooter, { footers: footers, noData: rows.length === 0, leftShadowVisible: leftShadowVisible, rightShadowVisible: rightShadowVisible })) : (_jsx(_Fragment, {}))] })) })) })));
57
57
  }
58
58
  export default DataTable;
59
59
  export { default as useDataTable } from "./useTable";
@@ -46,6 +46,7 @@ export declare type UserTableReturns<RowProps extends KvProps, ExtendedProps ext
46
46
  };
47
47
  export declare type TableHeaderProps<RowProps extends KvProps, ExtendedProps extends KvProps> = {
48
48
  headers: Array<TableHeaderCellProps<RowProps, ExtendedProps>>;
49
+ noData?: boolean;
49
50
  leftShadowVisible?: boolean;
50
51
  rightShadowVisible?: boolean;
51
52
  };
@@ -62,10 +63,11 @@ export declare type TableBodyRowProps<RowProps extends KvProps, ExtendedProps ex
62
63
  };
63
64
  export declare type TableFooterProps<RowProps extends KvProps, ExtendedProps extends KvProps> = {
64
65
  footers: Array<TableFooterCellProps<RowProps, ExtendedProps>>;
66
+ noData?: boolean;
65
67
  leftShadowVisible?: boolean;
66
68
  rightShadowVisible?: boolean;
67
69
  };
68
- export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible"> & Omit<TableBodyProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible"> & Omit<TableFooterProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible"> & {
70
+ export declare type DataTableProps<RowProps extends KvProps, ExtendedProps extends KvProps> = Omit<TableHeaderProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & Omit<TableBodyProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible"> & Omit<TableFooterProps<RowProps, ExtendedProps>, "leftShadowVisible" | "rightShadowVisible" | "noData"> & {
69
71
  dense?: boolean;
70
72
  stickyHeader?: boolean;
71
73
  primaryColor?: CSSProperties["color"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.1.2-beta.11",
3
+ "version": "1.1.2-beta.13",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",