@ctlyst.id/internal-ui 5.1.0 → 5.2.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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +46 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
@@ -260,6 +260,8 @@ interface DataTableProps<T> {
|
|
260
260
|
disabledRow?: (row: T) => boolean;
|
261
261
|
highlightedRow?: (row: T) => boolean;
|
262
262
|
highlightRowColor?: BackgroundProps['bg'];
|
263
|
+
/** paddingRowX in px */
|
264
|
+
paddingRowX?: number;
|
263
265
|
}
|
264
266
|
declare const isCellDisabled: (row: DisabledRowData, cellId: string) => boolean;
|
265
267
|
type DataTableRefs<T> = Pick<RowSelectionInstance<T>, 'toggleAllRowsSelected'>;
|
package/dist/index.d.ts
CHANGED
@@ -260,6 +260,8 @@ interface DataTableProps<T> {
|
|
260
260
|
disabledRow?: (row: T) => boolean;
|
261
261
|
highlightedRow?: (row: T) => boolean;
|
262
262
|
highlightRowColor?: BackgroundProps['bg'];
|
263
|
+
/** paddingRowX in px */
|
264
|
+
paddingRowX?: number;
|
263
265
|
}
|
264
266
|
declare const isCellDisabled: (row: DisabledRowData, cellId: string) => boolean;
|
265
267
|
type DataTableRefs<T> = Pick<RowSelectionInstance<T>, 'toggleAllRowsSelected'>;
|
package/dist/index.js
CHANGED
@@ -1355,23 +1355,23 @@ var isCellDisabled = (row, cellId) => {
|
|
1355
1355
|
}
|
1356
1356
|
return false;
|
1357
1357
|
};
|
1358
|
-
var getCommonPinningStyles = (column) => {
|
1358
|
+
var getCommonPinningStyles = (column, paddingRowX) => {
|
1359
1359
|
const isPinned = column.getIsPinned();
|
1360
1360
|
const isFirstLeftPinnedColumn = isPinned === "left" && column.getIsFirstColumn("left");
|
1361
1361
|
const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
1362
1362
|
const isFirstRightPinnedColumn = isPinned === "right" && column.getIsFirstColumn("right");
|
1363
1363
|
const isLastRightPinnedColumn = isPinned === "right" && column.getIsLastColumn("right");
|
1364
1364
|
return {
|
1365
|
-
left: isPinned === "left" ? `${column.getStart("left") + (!isFirstLeftPinnedColumn ?
|
1366
|
-
right: isPinned === "right" ? `${column.getAfter("right") + (!isLastRightPinnedColumn ?
|
1365
|
+
left: isPinned === "left" ? `${column.getStart("left") + (!isFirstLeftPinnedColumn ? paddingRowX : 0)}px` : void 0,
|
1366
|
+
right: isPinned === "right" ? `${column.getAfter("right") + (!isLastRightPinnedColumn ? paddingRowX : 0)}px` : void 0,
|
1367
1367
|
position: isPinned ? "sticky" : "relative",
|
1368
1368
|
zIndex: isPinned ? 1 : 0,
|
1369
1369
|
...isFirstLeftPinnedColumn ? {
|
1370
|
-
pl:
|
1371
|
-
} : {
|
1370
|
+
pl: `${paddingRowX + 8}px`
|
1371
|
+
} : {},
|
1372
1372
|
...isLastRightPinnedColumn ? {
|
1373
|
-
pr:
|
1374
|
-
} : {
|
1373
|
+
pr: `${paddingRowX + 8}px`
|
1374
|
+
} : {},
|
1375
1375
|
...isLastLeftPinnedColumn ? {
|
1376
1376
|
py: "16px",
|
1377
1377
|
pr: "8px",
|
@@ -1528,7 +1528,7 @@ var useDataTable = ({
|
|
1528
1528
|
};
|
1529
1529
|
};
|
1530
1530
|
var DataTable = React5.forwardRef((props, ref) => {
|
1531
|
-
var _a, _b, _c, _d, _e
|
1531
|
+
var _a, _b, _c, _d, _e;
|
1532
1532
|
const {
|
1533
1533
|
isLoading,
|
1534
1534
|
styles,
|
@@ -1540,7 +1540,8 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1540
1540
|
highlightedRow,
|
1541
1541
|
withSelectedRow,
|
1542
1542
|
highlightRowColor,
|
1543
|
-
cellLineClamp = 2
|
1543
|
+
cellLineClamp = 2,
|
1544
|
+
paddingRowX = 8
|
1544
1545
|
} = props;
|
1545
1546
|
const { clickOrDragged, getDragOrClickProps } = useDragOrClick();
|
1546
1547
|
const { table, action, toggleAllRowsSelected, generateColumn } = useDataTable(props);
|
@@ -1587,18 +1588,28 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1587
1588
|
};
|
1588
1589
|
}, []);
|
1589
1590
|
const hasScroll = ((_a = refTable == null ? void 0 : refTable.current) == null ? void 0 : _a.offsetWidth) && ((_b = refTable == null ? void 0 : refTable.current) == null ? void 0 : _b.scrollWidth) && ((_c = refTable == null ? void 0 : refTable.current) == null ? void 0 : _c.offsetWidth) < ((_d = refTable == null ? void 0 : refTable.current) == null ? void 0 : _d.scrollWidth);
|
1591
|
+
const getTableHeaderSize = (header, index, totalColumn) => {
|
1592
|
+
if (header.column.getIsFirstColumn("left") || header.column.getIsLastColumn("right")) {
|
1593
|
+
return { width: `${header.getSize() + paddingRowX}px` };
|
1594
|
+
}
|
1595
|
+
if (index === 0) {
|
1596
|
+
return { width: `${header.getSize() + paddingRowX}px`, paddingLeft: `${8 + paddingRowX}` };
|
1597
|
+
}
|
1598
|
+
if (index === totalColumn - 1) {
|
1599
|
+
return { width: `${header.getSize() + paddingRowX}px`, paddingRight: `${8 + paddingRowX}` };
|
1600
|
+
}
|
1601
|
+
return { width: `${header.getSize()}px` };
|
1602
|
+
};
|
1590
1603
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
1591
1604
|
import_react29.Box,
|
1592
1605
|
{
|
1593
1606
|
overflowX: "auto",
|
1594
1607
|
overflowY: "hidden",
|
1595
1608
|
position: "relative",
|
1596
|
-
pl: ((_e = columnPinning == null ? void 0 : columnPinning.left) == null ? void 0 : _e.length) ? 0 : 2,
|
1597
|
-
pr: ((_f = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _f.length) ? 0 : 2,
|
1598
1609
|
maxW: "100%",
|
1599
1610
|
w: "full",
|
1600
1611
|
ref: refTable,
|
1601
|
-
...((
|
1612
|
+
...((_e = columnPinning == null ? void 0 : columnPinning.right) == null ? void 0 : _e.length) && hasScroll ? { "data-pin-right": true } : {},
|
1602
1613
|
...container,
|
1603
1614
|
children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_react29.Table, { ...styles == null ? void 0 : styles.table, "data-loading": "true", children: [
|
1604
1615
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react29.Thead, { ...(styles == null ? void 0 : styles.tableHead, headerSticky ? { position: "sticky", top: 0, bg: "white", zIndex: 1 } : {}), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react29.Tr, { mx: "2", ...styles == null ? void 0 : styles.tableRow, children: headerGroup.headers.map((header, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
@@ -1636,8 +1647,10 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1636
1647
|
import_react29.Th,
|
1637
1648
|
{
|
1638
1649
|
colSpan: header.colSpan,
|
1639
|
-
|
1640
|
-
|
1650
|
+
_first: { paddingLeft: `${paddingRowX + 8}px` },
|
1651
|
+
_last: { paddingRight: `${paddingRowX + 8}px` },
|
1652
|
+
sx: getCommonPinningStyles(header.column, paddingRowX),
|
1653
|
+
...getTableHeaderSize(header, index, headerGroup.headers.length),
|
1641
1654
|
...styles == null ? void 0 : styles.tableColumnHeader,
|
1642
1655
|
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
1643
1656
|
import_react29.Flex,
|
@@ -1673,7 +1686,7 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1673
1686
|
}) }, headerGroup.id))
|
1674
1687
|
}
|
1675
1688
|
),
|
1676
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react29.Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row) => {
|
1689
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_react29.Tbody, { ...styles == null ? void 0 : styles.tableBody, children: table.getRowModel().rows.map((row, index) => {
|
1677
1690
|
const isDisabledRow = disabledRow && disabledRow(row.original);
|
1678
1691
|
const isHighlightedRow = highlightedRow && highlightedRow(row.original);
|
1679
1692
|
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
@@ -1722,8 +1735,10 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1722
1735
|
{
|
1723
1736
|
"data-test-id": `CT_Component_TableCell_${cell.id}`,
|
1724
1737
|
fontSize: "text.sm",
|
1738
|
+
_first: { paddingLeft: `${paddingRowX + 8}px` },
|
1739
|
+
_last: { paddingRight: `${paddingRowX + 8}px` },
|
1725
1740
|
sx: {
|
1726
|
-
...getCommonPinningStyles(cell.column)
|
1741
|
+
...getCommonPinningStyles(cell.column, paddingRowX)
|
1727
1742
|
},
|
1728
1743
|
...styles == null ? void 0 : styles.tableCell,
|
1729
1744
|
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
@@ -1735,14 +1750,22 @@ var DataTable = React5.forwardRef((props, ref) => {
|
|
1735
1750
|
align: "center",
|
1736
1751
|
"data-test-id": `CT_Component_TableCell_Content-${cell.id}`,
|
1737
1752
|
opacity: isDisabled ? 0.5 : 1,
|
1738
|
-
...cellLineClamp > 0 ? {
|
1739
|
-
noOfLines: cellLineClamp,
|
1740
|
-
sx: {
|
1741
|
-
display: "-webkit-inline-box"
|
1742
|
-
}
|
1743
|
-
} : {},
|
1744
1753
|
sx: { ...meta && meta.columnStyles ? meta.columnStyles : {} },
|
1745
|
-
children: (0,
|
1754
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
1755
|
+
import_react29.Box,
|
1756
|
+
{
|
1757
|
+
onMouseUp: (e) => {
|
1758
|
+
e.stopPropagation();
|
1759
|
+
},
|
1760
|
+
...cellLineClamp > 0 ? {
|
1761
|
+
noOfLines: cellLineClamp,
|
1762
|
+
sx: {
|
1763
|
+
display: "-webkit-inline-box"
|
1764
|
+
}
|
1765
|
+
} : {},
|
1766
|
+
children: (0, import_react_table.flexRender)(cell.column.columnDef.cell, cell.getContext())
|
1767
|
+
}
|
1768
|
+
)
|
1746
1769
|
}
|
1747
1770
|
)
|
1748
1771
|
},
|