erp-pos-ecommerce-shared 0.2.18 → 0.2.20

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.
@@ -1335,11 +1335,19 @@ var TableHeader = ({
1335
1335
  const bgColor = style.bgColor ?? defaultHeaderBgColor;
1336
1336
  const hoverBg = style.hoverBgColor ?? defaultHeaderHoverBg;
1337
1337
  const hoverText = style.hoverTextColor ?? style.textColor ?? defaultHeaderTextColor;
1338
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
1338
1339
  const getSortIcon = (sortState) => {
1339
1340
  if (sortState === "asc") return SortIconAsc;
1340
1341
  if (sortState === "desc") return SortIconDesc;
1341
1342
  return SortIcon;
1342
1343
  };
1344
+ const getColumnStyle = (size) => {
1345
+ if (!size || totalColumnsSize <= 0) return void 0;
1346
+ return {
1347
+ width: `${size / totalColumnsSize * 100}%`,
1348
+ minWidth: size
1349
+ };
1350
+ };
1343
1351
  const baseButtonStyle = {
1344
1352
  padding: style.padding ?? "4px 10px",
1345
1353
  fontSize: style.fontSize ?? 14,
@@ -1381,26 +1389,34 @@ var TableHeader = ({
1381
1389
  const sortState = header.column.getIsSorted();
1382
1390
  const Icon = canSort ? getSortIcon(sortState) : null;
1383
1391
  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,
1392
+ return /* @__PURE__ */ jsx(
1393
+ Table.Th,
1386
1394
  {
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);
1395
+ bg: bgColor,
1396
+ style: getColumnStyle(header.column.getSize()),
1397
+ children: /* @__PURE__ */ jsxs(
1398
+ UnstyledButton,
1399
+ {
1400
+ style: {
1401
+ ...baseButtonStyle,
1402
+ color: isHovered ? hoverText : style.textColor ?? defaultHeaderTextColor,
1403
+ backgroundColor: isHovered ? hoverBg : void 0
1404
+ },
1405
+ onClick: header.column.getToggleSortingHandler(),
1406
+ onMouseEnter: () => setHoveredHeaderId(header.id),
1407
+ onMouseLeave: () => setHoveredHeaderId(null),
1408
+ children: [
1409
+ header.isPlaceholder ? null : flexRender(
1410
+ header.column.columnDef.header,
1411
+ header.getContext()
1412
+ ),
1413
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
1414
+ ]
1415
+ }
1416
+ )
1417
+ },
1418
+ header.id
1419
+ );
1404
1420
  }),
1405
1421
  hasActionsColumn && /* @__PURE__ */ jsx(Table.Th, { bg: bgColor })
1406
1422
  ] }, headerGroup.id)) });
@@ -1415,6 +1431,14 @@ var TableBody = ({
1415
1431
  onRowHover
1416
1432
  }) => {
1417
1433
  const [hoveredRowId, setHoveredRowId] = useState(null);
1434
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
1435
+ const getColumnStyle = (size) => {
1436
+ if (!size || totalColumnsSize <= 0) return void 0;
1437
+ return {
1438
+ width: `${size / totalColumnsSize * 100}%`,
1439
+ minWidth: size
1440
+ };
1441
+ };
1418
1442
  return /* @__PURE__ */ jsx(Table.Tbody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(
1419
1443
  Table.Tr,
1420
1444
  {
@@ -1458,7 +1482,7 @@ var TableBody = ({
1458
1482
  row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
1459
1483
  Table.Td,
1460
1484
  {
1461
- style: cell.column.columnDef.size ? { width: cell.column.columnDef.size, minWidth: cell.column.columnDef.size } : void 0,
1485
+ style: getColumnStyle(cell.column.getSize()),
1462
1486
  onClick: () => onRowClick?.(row.original),
1463
1487
  children: /* @__PURE__ */ jsx(
1464
1488
  Text,