@prt-ts/fluent-react-table-v2 9.47.1-build-3.0 → 9.47.1-build-4.0

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/index.cjs.js CHANGED
@@ -1614,7 +1614,7 @@ const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular)
1614
1614
  const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
1615
1615
  const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
1616
1616
  function HeaderCell({ header, table, tabAttributes }) {
1617
- var _a, _b, _c;
1617
+ var _a;
1618
1618
  const { column, id } = header;
1619
1619
  const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = sortable.useSortable({
1620
1620
  id: id
@@ -1624,7 +1624,11 @@ function HeaderCell({ header, table, tabAttributes }) {
1624
1624
  transition
1625
1625
  };
1626
1626
  const styles = useTableHeaderStyles();
1627
- const isLeafHeaders = ((_b = (_a = `${id}`) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b.length) === 1;
1627
+ const isLeafHeaders = React.useMemo(() => {
1628
+ const leafCols = table.getAllLeafColumns();
1629
+ console.log("isLeafHeader");
1630
+ return !!(leafCols === null || leafCols === void 0 ? void 0 : leafCols.find(col => col.id === header.column.id));
1631
+ }, [table, header.column.id]);
1628
1632
  const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
1629
1633
  if (header.isPlaceholder) {
1630
1634
  return (jsxRuntime.jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
@@ -1645,10 +1649,10 @@ function HeaderCell({ header, table, tabAttributes }) {
1645
1649
  if (!header.column.getCanGroup())
1646
1650
  return;
1647
1651
  header.column.getToggleGroupingHandler()();
1648
- }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_c = {
1652
+ }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
1649
1653
  asc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortAscIcon, {}) })),
1650
1654
  desc: (jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(SortDescIcon, {}) })),
1651
- }[header.column.getIsSorted()]) !== null && _c !== void 0 ? _c : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: columnName }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsGrouped(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(GroupListRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsFiltered(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsPinned(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(PinRegular, {}) }) })] }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: isLeafHeaders, children: jsxRuntime.jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isLeafHeaders, children: jsxRuntime.jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
1655
+ }[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsxRuntime.jsx("strong", { children: columnName }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsGrouped(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(GroupListRegular, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsFiltered(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(FilterFilled, {}) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getIsPinned(), children: jsxRuntime.jsx("strong", { children: jsxRuntime.jsx(PinRegular, {}) }) })] }) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !!isLeafHeaders, children: jsxRuntime.jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsxRuntime.jsx(reactControlFlow.Show, { when: header.column.getCanResize(), children: jsxRuntime.jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: reactComponents.mergeClasses(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsxRuntime.jsx(reactControlFlow.Show, { when: !isLeafHeaders, children: jsxRuntime.jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
1652
1656
  }
1653
1657
  function HeaderMenu(props) {
1654
1658
  const { header, table } = props;
@@ -1726,18 +1730,20 @@ const useLoadingStyles = reactComponents.makeStyles({
1726
1730
  invertedWrapper: {
1727
1731
  backgroundColor: reactComponents.tokens.colorNeutralBackground1,
1728
1732
  },
1729
- row: Object.assign(Object.assign({ alignItems: "center", display: "grid", paddingBottom: "10px", position: "relative" }, reactComponents.shorthands.gap("10px")), { gridTemplateColumns: "min-content 20% 15% 30% 29%" }),
1733
+ row: Object.assign({ width: "100%", alignItems: "center", justifyContent: "space-between", display: "flex", position: "relative", paddingBottom: "10px", paddingTop: "10px" }, reactComponents.shorthands.gap("20px")),
1730
1734
  });
1731
1735
 
1732
1736
  const Loading = (props) => {
1733
- const { numberOfItems = 16, numberOfColumns = 5 } = props;
1737
+ var _a;
1738
+ const { numberOfItems = 16, visibleColumns, table } = props;
1739
+ const selectionMode = ((_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode) || "none";
1734
1740
  const styles = useLoadingStyles();
1735
- return (jsxRuntime.jsx("div", { className: styles.invertedWrapper, children: jsxRuntime.jsx(reactComponents.Skeleton, { children: [...Array(numberOfItems)].map((_, i) => (jsxRuntime.jsx("div", { className: styles.row, children: [...Array(numberOfColumns)].map((_, i) => {
1736
- if (i === 0) {
1737
- return jsxRuntime.jsx(reactComponents.SkeletonItem, { shape: "circle", size: 24 }, i);
1738
- }
1739
- return jsxRuntime.jsx(reactComponents.SkeletonItem, { size: 16 }, i);
1740
- }) }, i))) }) }));
1741
+ return (jsxRuntime.jsx("div", { style: { width: "100%" }, children: jsxRuntime.jsx(reactControlFlow.For, { each: [...Array(numberOfItems)], children: (rowIndex, index) => {
1742
+ return (jsxRuntime.jsxs(reactComponents.Skeleton, { className: styles.row, style: { width: "100%" }, children: [jsxRuntime.jsx(reactControlFlow.Show, { when: ["single", "multiple"].includes(selectionMode), children: jsxRuntime.jsx(reactComponents.SkeletonItem, { shape: "circle", size: 24, style: { width: "40px" } }, `${index}_select_row`) }), jsxRuntime.jsx(reactControlFlow.For, { each: visibleColumns || [], children: (column, i) => (jsxRuntime.jsx(reactComponents.SkeletonItem, { style: {
1743
+ minWidth: column.getSize(),
1744
+ width: "100%"
1745
+ } }, i)) })] }, `${rowIndex}_${index}`));
1746
+ } }) }));
1741
1747
  };
1742
1748
 
1743
1749
  const useNoItemGridStyles = reactComponents.makeStyles({
@@ -1943,7 +1949,7 @@ const TableContainer = (props) => {
1943
1949
  const isLoading = props.isLoading && itemLength === 0;
1944
1950
  const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
1945
1951
  const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
1946
- return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxRuntime.jsxs(reactControlFlow.Switch, { when: true, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: isLoading, children: jsxRuntime.jsx(Loading, {}) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noItems, children: jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noSearchResult, children: jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
1952
+ return (jsxRuntime.jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxRuntime.jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsxRuntime.jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsxRuntime.jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxRuntime.jsxs(reactControlFlow.Switch, { when: true, children: [jsxRuntime.jsx(reactControlFlow.Case, { value: isLoading, children: jsxRuntime.jsx(Loading, { visibleColumns: table.getVisibleLeafColumns(), table: table }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noItems, children: jsxRuntime.jsx(NoItemGrid, { message: props.noItemPage }) }), jsxRuntime.jsx(reactControlFlow.Case, { value: noSearchResult, children: jsxRuntime.jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
1947
1953
  };
1948
1954
 
1949
1955
  const useCheckboxFilterStyles = reactComponents.makeStyles({
package/index.esm.js CHANGED
@@ -1592,7 +1592,7 @@ const HideColumnIcon = bundleIcon$1(EyeTrackingOffFilled, EyeTrackingOffRegular)
1592
1592
  const GroupExpandIcon = bundleIcon$1(TextExpandFilled, TextExpandRegular);
1593
1593
  const GroupCollapseIcon = bundleIcon$1(TextCollapseFilled, TextCollapseRegular);
1594
1594
  function HeaderCell({ header, table, tabAttributes }) {
1595
- var _a, _b, _c;
1595
+ var _a;
1596
1596
  const { column, id } = header;
1597
1597
  const { isDragging, attributes, listeners, setNodeRef, transform, transition, } = useSortable({
1598
1598
  id: id
@@ -1602,7 +1602,11 @@ function HeaderCell({ header, table, tabAttributes }) {
1602
1602
  transition
1603
1603
  };
1604
1604
  const styles = useTableHeaderStyles();
1605
- const isLeafHeaders = ((_b = (_a = `${id}`) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b.length) === 1;
1605
+ const isLeafHeaders = useMemo(() => {
1606
+ const leafCols = table.getAllLeafColumns();
1607
+ console.log("isLeafHeader");
1608
+ return !!(leafCols === null || leafCols === void 0 ? void 0 : leafCols.find(col => col.id === header.column.id));
1609
+ }, [table, header.column.id]);
1606
1610
  const headerCellCombinedStyles = getHeaderCellPinningStyles(column, isDragging, dndStyle);
1607
1611
  if (header.isPlaceholder) {
1608
1612
  return (jsx("th", Object.assign({ colSpan: header.colSpan, className: styles.tHeadCell, style: headerCellCombinedStyles, ref: setNodeRef }, attributes, listeners, { children: jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }) })));
@@ -1623,10 +1627,10 @@ function HeaderCell({ header, table, tabAttributes }) {
1623
1627
  if (!header.column.getCanGroup())
1624
1628
  return;
1625
1629
  header.column.getToggleGroupingHandler()();
1626
- }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_c = {
1630
+ }, appearance: "transparent", className: styles.tHeadContentBtn, icon: (_a = {
1627
1631
  asc: (jsx("strong", { children: jsx(SortAscIcon, {}) })),
1628
1632
  desc: (jsx("strong", { children: jsx(SortDescIcon, {}) })),
1629
- }[header.column.getIsSorted()]) !== null && _c !== void 0 ? _c : undefined, iconPosition: "after", children: [jsx("strong", { children: columnName }), jsx(Show, { when: header.column.getIsGrouped(), children: jsx("strong", { children: jsx(GroupListRegular, {}) }) }), jsx(Show, { when: header.column.getIsFiltered(), children: jsx("strong", { children: jsx(FilterFilled, {}) }) }), jsx(Show, { when: header.column.getIsPinned(), children: jsx("strong", { children: jsx(PinRegular, {}) }) })] }) }) }), jsx(Show, { when: isLeafHeaders, children: jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsx(Show, { when: !isLeafHeaders, children: jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
1633
+ }[header.column.getIsSorted()]) !== null && _a !== void 0 ? _a : undefined, iconPosition: "after", children: [jsx("strong", { children: columnName }), jsx(Show, { when: header.column.getIsGrouped(), children: jsx("strong", { children: jsx(GroupListRegular, {}) }) }), jsx(Show, { when: header.column.getIsFiltered(), children: jsx("strong", { children: jsx(FilterFilled, {}) }) }), jsx(Show, { when: header.column.getIsPinned(), children: jsx("strong", { children: jsx(PinRegular, {}) }) })] }) }) }), jsx(Show, { when: !!isLeafHeaders, children: jsx(HeaderMenu, { header: header, table: table }) })] }) })), jsx(Show, { when: header.column.getCanResize(), children: jsx("div", { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler(), className: mergeClasses$1(styles.resizer, column.getIsResizing() && styles.resizerActive) }) }), jsx(Show, { when: !isLeafHeaders, children: jsx("div", { className: styles.tHeadNonLeafCellFakeBorder }) })] })));
1630
1634
  }
1631
1635
  function HeaderMenu(props) {
1632
1636
  const { header, table } = props;
@@ -1704,18 +1708,20 @@ const useLoadingStyles = makeStyles({
1704
1708
  invertedWrapper: {
1705
1709
  backgroundColor: tokens.colorNeutralBackground1,
1706
1710
  },
1707
- row: Object.assign(Object.assign({ alignItems: "center", display: "grid", paddingBottom: "10px", position: "relative" }, shorthands.gap("10px")), { gridTemplateColumns: "min-content 20% 15% 30% 29%" }),
1711
+ row: Object.assign({ width: "100%", alignItems: "center", justifyContent: "space-between", display: "flex", position: "relative", paddingBottom: "10px", paddingTop: "10px" }, shorthands.gap("20px")),
1708
1712
  });
1709
1713
 
1710
1714
  const Loading = (props) => {
1711
- const { numberOfItems = 16, numberOfColumns = 5 } = props;
1715
+ var _a;
1716
+ const { numberOfItems = 16, visibleColumns, table } = props;
1717
+ const selectionMode = ((_a = table.options.meta) === null || _a === void 0 ? void 0 : _a.rowSelectionMode) || "none";
1712
1718
  const styles = useLoadingStyles();
1713
- return (jsx("div", { className: styles.invertedWrapper, children: jsx(Skeleton, { children: [...Array(numberOfItems)].map((_, i) => (jsx("div", { className: styles.row, children: [...Array(numberOfColumns)].map((_, i) => {
1714
- if (i === 0) {
1715
- return jsx(SkeletonItem, { shape: "circle", size: 24 }, i);
1716
- }
1717
- return jsx(SkeletonItem, { size: 16 }, i);
1718
- }) }, i))) }) }));
1719
+ return (jsx("div", { style: { width: "100%" }, children: jsx(For, { each: [...Array(numberOfItems)], children: (rowIndex, index) => {
1720
+ return (jsxs(Skeleton, { className: styles.row, style: { width: "100%" }, children: [jsx(Show, { when: ["single", "multiple"].includes(selectionMode), children: jsx(SkeletonItem, { shape: "circle", size: 24, style: { width: "40px" } }, `${index}_select_row`) }), jsx(For, { each: visibleColumns || [], children: (column, i) => (jsx(SkeletonItem, { style: {
1721
+ minWidth: column.getSize(),
1722
+ width: "100%"
1723
+ } }, i)) })] }, `${rowIndex}_${index}`));
1724
+ } }) }));
1719
1725
  };
1720
1726
 
1721
1727
  const useNoItemGridStyles = makeStyles({
@@ -1921,7 +1927,7 @@ const TableContainer = (props) => {
1921
1927
  const isLoading = props.isLoading && itemLength === 0;
1922
1928
  const noItems = !isLoading && ((_a = props.data) === null || _a === void 0 ? void 0 : _a.length) === 0;
1923
1929
  const noSearchResult = !isLoading && ((_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.length) > 0 && itemLength === 0;
1924
- return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxs(Switch, { when: true, children: [jsx(Case, { value: isLoading, children: jsx(Loading, {}) }), jsx(Case, { value: noItems, children: jsx(NoItemGrid, { message: props.noItemPage }) }), jsx(Case, { value: noSearchResult, children: jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
1930
+ return (jsxs("div", { ref: tableContainerRef, className: styles.tableContainer, style: { height: tableHeight }, children: [jsxs("table", { className: styles.table, "aria-label": "Data Grid", style: { width: table.getTotalSize(), minWidth: "100%" }, children: [jsx(TableHeader, { table: table, rowSelectionMode: rowSelectionMode, headerGroups: headerGroups }), jsx(TableBody, { table: table, tableContainerRef: tableContainerRef })] }), jsxs(Switch, { when: true, children: [jsx(Case, { value: isLoading, children: jsx(Loading, { visibleColumns: table.getVisibleLeafColumns(), table: table }) }), jsx(Case, { value: noItems, children: jsx(NoItemGrid, { message: props.noItemPage }) }), jsx(Case, { value: noSearchResult, children: jsx(NoSearchResult, { message: props.noFilterMatchPage }) })] })] }));
1925
1931
  };
1926
1932
 
1927
1933
  const useCheckboxFilterStyles = makeStyles({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prt-ts/fluent-react-table-v2",
3
- "version": "9.47.1-build-3.0",
3
+ "version": "9.47.1-build-4.0",
4
4
  "peerDependencies": {
5
5
  "react": ">=17.0.0",
6
6
  "react-dom": ">=17.0.0",
@@ -1,7 +1,8 @@
1
- import * as React from "react";
2
- type LoadingProps = {
1
+ import { Column, RowData, Table } from "@tanstack/react-table";
2
+ type LoadingProps<TItem extends RowData> = {
3
3
  numberOfItems?: number;
4
- numberOfColumns?: number;
4
+ visibleColumns: Column<TItem, unknown>[];
5
+ table: Table<TItem>;
5
6
  };
6
- export declare const Loading: React.FC<LoadingProps>;
7
+ export declare const Loading: <TItem extends unknown>(props: LoadingProps<TItem>) => import("react/jsx-runtime").JSX.Element;
7
8
  export {};