erp-pos-ecommerce-shared 0.2.19 → 0.2.21

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.
@@ -1296,6 +1296,7 @@ function useDataTable({
1296
1296
  }
1297
1297
  var defaultHeaderTextColor = "light-dark(var(--mantine-color-dimmed), var(--mantine-color-gray-4))";
1298
1298
  var defaultHeaderHoverBg = "light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-2))";
1299
+ var actionsColumnWidth = 56;
1299
1300
  function normalizeHeaderStyle(value) {
1300
1301
  if (value == null) {
1301
1302
  return {
@@ -1335,11 +1336,20 @@ var TableHeader = ({
1335
1336
  const bgColor = style.bgColor ?? defaultHeaderBgColor;
1336
1337
  const hoverBg = style.hoverBgColor ?? defaultHeaderHoverBg;
1337
1338
  const hoverText = style.hoverTextColor ?? style.textColor ?? defaultHeaderTextColor;
1339
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
1338
1340
  const getSortIcon = (sortState) => {
1339
1341
  if (sortState === "asc") return SortIconAsc;
1340
1342
  if (sortState === "desc") return SortIconDesc;
1341
1343
  return SortIcon;
1342
1344
  };
1345
+ const getColumnStyle = (size) => {
1346
+ if (!size || totalColumnsSize <= 0) return void 0;
1347
+ const baseWidth = `${size / totalColumnsSize * 100}%`;
1348
+ return {
1349
+ width: hasActionsColumn ? `calc((100% - ${actionsColumnWidth}px) * ${size / totalColumnsSize})` : baseWidth,
1350
+ minWidth: size
1351
+ };
1352
+ };
1343
1353
  const baseButtonStyle = {
1344
1354
  padding: style.padding ?? "4px 10px",
1345
1355
  fontSize: style.fontSize ?? 14,
@@ -1381,33 +1391,49 @@ var TableHeader = ({
1381
1391
  const sortState = header.column.getIsSorted();
1382
1392
  const Icon = canSort ? getSortIcon(sortState) : null;
1383
1393
  const isHovered = hoveredHeaderId === header.id;
1384
- return /* @__PURE__ */ jsx(Table.Th, { bg: bgColor, style: header.column.columnDef.size ? { width: header.column.columnDef.size, minWidth: header.column.columnDef.size } : void 0, children: /* @__PURE__ */ jsxs(
1385
- UnstyledButton,
1394
+ return /* @__PURE__ */ jsx(
1395
+ Table.Th,
1386
1396
  {
1387
- style: {
1388
- ...baseButtonStyle,
1389
- color: isHovered ? hoverText : style.textColor ?? defaultHeaderTextColor,
1390
- backgroundColor: isHovered ? hoverBg : void 0
1391
- },
1392
- onClick: header.column.getToggleSortingHandler(),
1393
- onMouseEnter: () => setHoveredHeaderId(header.id),
1394
- onMouseLeave: () => setHoveredHeaderId(null),
1395
- children: [
1396
- header.isPlaceholder ? null : flexRender(
1397
- header.column.columnDef.header,
1398
- header.getContext()
1399
- ),
1400
- Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
1401
- ]
1402
- }
1403
- ) }, header.id);
1397
+ bg: bgColor,
1398
+ style: getColumnStyle(header.column.getSize()),
1399
+ children: /* @__PURE__ */ jsxs(
1400
+ UnstyledButton,
1401
+ {
1402
+ style: {
1403
+ ...baseButtonStyle,
1404
+ color: isHovered ? hoverText : style.textColor ?? defaultHeaderTextColor,
1405
+ backgroundColor: isHovered ? hoverBg : void 0
1406
+ },
1407
+ onClick: header.column.getToggleSortingHandler(),
1408
+ onMouseEnter: () => setHoveredHeaderId(header.id),
1409
+ onMouseLeave: () => setHoveredHeaderId(null),
1410
+ children: [
1411
+ header.isPlaceholder ? null : flexRender(
1412
+ header.column.columnDef.header,
1413
+ header.getContext()
1414
+ ),
1415
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
1416
+ ]
1417
+ }
1418
+ )
1419
+ },
1420
+ header.id
1421
+ );
1404
1422
  }),
1405
- hasActionsColumn && /* @__PURE__ */ jsx(Table.Th, { bg: bgColor })
1423
+ hasActionsColumn && /* @__PURE__ */ jsx(
1424
+ Table.Th,
1425
+ {
1426
+ bg: bgColor,
1427
+ style: { width: actionsColumnWidth, minWidth: actionsColumnWidth }
1428
+ }
1429
+ )
1406
1430
  ] }, headerGroup.id)) });
1407
1431
  };
1432
+ var actionsColumnWidth2 = 56;
1408
1433
  var TableBody = ({
1409
1434
  table,
1410
1435
  canCheck = false,
1436
+ hasActionsColumn = false,
1411
1437
  columnActions,
1412
1438
  MenuIcon = MoreVertical,
1413
1439
  listMenuActions,
@@ -1415,6 +1441,15 @@ var TableBody = ({
1415
1441
  onRowHover
1416
1442
  }) => {
1417
1443
  const [hoveredRowId, setHoveredRowId] = useState(null);
1444
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
1445
+ const getColumnStyle = (size) => {
1446
+ if (!size || totalColumnsSize <= 0) return void 0;
1447
+ const baseWidth = `${size / totalColumnsSize * 100}%`;
1448
+ return {
1449
+ width: hasActionsColumn ? `calc((100% - ${actionsColumnWidth2}px) * ${size / totalColumnsSize})` : baseWidth,
1450
+ minWidth: size
1451
+ };
1452
+ };
1418
1453
  return /* @__PURE__ */ jsx(Table.Tbody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(
1419
1454
  Table.Tr,
1420
1455
  {
@@ -1458,7 +1493,7 @@ var TableBody = ({
1458
1493
  row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
1459
1494
  Table.Td,
1460
1495
  {
1461
- style: cell.column.columnDef.size ? { width: cell.column.columnDef.size, minWidth: cell.column.columnDef.size } : void 0,
1496
+ style: getColumnStyle(cell.column.getSize()),
1462
1497
  onClick: () => onRowClick?.(row.original),
1463
1498
  children: /* @__PURE__ */ jsx(
1464
1499
  Text,
@@ -1473,7 +1508,7 @@ var TableBody = ({
1473
1508
  },
1474
1509
  cell.id
1475
1510
  )),
1476
- (columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1511
+ (columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { style: { width: actionsColumnWidth2, minWidth: actionsColumnWidth2 }, children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
1477
1512
  columnActions?.(row.original),
1478
1513
  listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
1479
1514
  /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
@@ -1662,6 +1697,7 @@ var SimpleDataTable = ({
1662
1697
  onRowHover,
1663
1698
  table,
1664
1699
  canCheck,
1700
+ hasActionsColumn,
1665
1701
  columnActions,
1666
1702
  listMenuActions
1667
1703
  }