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.
package/dist/index.js CHANGED
@@ -6070,6 +6070,7 @@ var BottomPagination = ({
6070
6070
  };
6071
6071
  var defaultHeaderTextColor = "light-dark(var(--mantine-color-dimmed), var(--mantine-color-gray-4))";
6072
6072
  var defaultHeaderHoverBg = "light-dark(var(--mantine-color-gray-2), var(--mantine-color-dark-2))";
6073
+ var actionsColumnWidth = 56;
6073
6074
  function normalizeHeaderStyle(value) {
6074
6075
  if (value == null) {
6075
6076
  return {
@@ -6109,11 +6110,20 @@ var TableHeader = ({
6109
6110
  const bgColor = style.bgColor ?? defaultHeaderBgColor;
6110
6111
  const hoverBg = style.hoverBgColor ?? defaultHeaderHoverBg;
6111
6112
  const hoverText = style.hoverTextColor ?? style.textColor ?? defaultHeaderTextColor;
6113
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
6112
6114
  const getSortIcon = (sortState) => {
6113
6115
  if (sortState === "asc") return SortIconAsc;
6114
6116
  if (sortState === "desc") return SortIconDesc;
6115
6117
  return SortIcon;
6116
6118
  };
6119
+ const getColumnStyle = (size) => {
6120
+ if (!size || totalColumnsSize <= 0) return void 0;
6121
+ const baseWidth = `${size / totalColumnsSize * 100}%`;
6122
+ return {
6123
+ width: hasActionsColumn ? `calc((100% - ${actionsColumnWidth}px) * ${size / totalColumnsSize})` : baseWidth,
6124
+ minWidth: size
6125
+ };
6126
+ };
6117
6127
  const baseButtonStyle = {
6118
6128
  padding: style.padding ?? "4px 10px",
6119
6129
  fontSize: style.fontSize ?? 14,
@@ -6155,33 +6165,49 @@ var TableHeader = ({
6155
6165
  const sortState = header.column.getIsSorted();
6156
6166
  const Icon = canSort ? getSortIcon(sortState) : null;
6157
6167
  const isHovered = hoveredHeaderId === header.id;
6158
- 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(
6159
- UnstyledButton,
6168
+ return /* @__PURE__ */ jsx(
6169
+ Table.Th,
6160
6170
  {
6161
- style: {
6162
- ...baseButtonStyle,
6163
- color: isHovered ? hoverText : style.textColor ?? defaultHeaderTextColor,
6164
- backgroundColor: isHovered ? hoverBg : void 0
6165
- },
6166
- onClick: header.column.getToggleSortingHandler(),
6167
- onMouseEnter: () => setHoveredHeaderId(header.id),
6168
- onMouseLeave: () => setHoveredHeaderId(null),
6169
- children: [
6170
- header.isPlaceholder ? null : flexRender(
6171
- header.column.columnDef.header,
6172
- header.getContext()
6173
- ),
6174
- Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
6175
- ]
6176
- }
6177
- ) }, header.id);
6171
+ bg: bgColor,
6172
+ style: getColumnStyle(header.column.getSize()),
6173
+ children: /* @__PURE__ */ jsxs(
6174
+ UnstyledButton,
6175
+ {
6176
+ style: {
6177
+ ...baseButtonStyle,
6178
+ color: isHovered ? hoverText : style.textColor ?? defaultHeaderTextColor,
6179
+ backgroundColor: isHovered ? hoverBg : void 0
6180
+ },
6181
+ onClick: header.column.getToggleSortingHandler(),
6182
+ onMouseEnter: () => setHoveredHeaderId(header.id),
6183
+ onMouseLeave: () => setHoveredHeaderId(null),
6184
+ children: [
6185
+ header.isPlaceholder ? null : flexRender(
6186
+ header.column.columnDef.header,
6187
+ header.getContext()
6188
+ ),
6189
+ Icon && /* @__PURE__ */ jsx(Icon, { size: 16 })
6190
+ ]
6191
+ }
6192
+ )
6193
+ },
6194
+ header.id
6195
+ );
6178
6196
  }),
6179
- hasActionsColumn && /* @__PURE__ */ jsx(Table.Th, { bg: bgColor })
6197
+ hasActionsColumn && /* @__PURE__ */ jsx(
6198
+ Table.Th,
6199
+ {
6200
+ bg: bgColor,
6201
+ style: { width: actionsColumnWidth, minWidth: actionsColumnWidth }
6202
+ }
6203
+ )
6180
6204
  ] }, headerGroup.id)) });
6181
6205
  };
6206
+ var actionsColumnWidth2 = 56;
6182
6207
  var TableBody = ({
6183
6208
  table,
6184
6209
  canCheck = false,
6210
+ hasActionsColumn = false,
6185
6211
  columnActions,
6186
6212
  MenuIcon = MoreVertical,
6187
6213
  listMenuActions,
@@ -6189,6 +6215,15 @@ var TableBody = ({
6189
6215
  onRowHover
6190
6216
  }) => {
6191
6217
  const [hoveredRowId, setHoveredRowId] = useState(null);
6218
+ const totalColumnsSize = table.getVisibleLeafColumns().reduce((sum, column) => sum + column.getSize(), 0);
6219
+ const getColumnStyle = (size) => {
6220
+ if (!size || totalColumnsSize <= 0) return void 0;
6221
+ const baseWidth = `${size / totalColumnsSize * 100}%`;
6222
+ return {
6223
+ width: hasActionsColumn ? `calc((100% - ${actionsColumnWidth2}px) * ${size / totalColumnsSize})` : baseWidth,
6224
+ minWidth: size
6225
+ };
6226
+ };
6192
6227
  return /* @__PURE__ */ jsx(Table.Tbody, { children: table.getRowModel().rows.map((row) => /* @__PURE__ */ jsxs(
6193
6228
  Table.Tr,
6194
6229
  {
@@ -6232,7 +6267,7 @@ var TableBody = ({
6232
6267
  row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx(
6233
6268
  Table.Td,
6234
6269
  {
6235
- style: cell.column.columnDef.size ? { width: cell.column.columnDef.size, minWidth: cell.column.columnDef.size } : void 0,
6270
+ style: getColumnStyle(cell.column.getSize()),
6236
6271
  onClick: () => onRowClick?.(row.original),
6237
6272
  children: /* @__PURE__ */ jsx(
6238
6273
  Text,
@@ -6247,7 +6282,7 @@ var TableBody = ({
6247
6282
  },
6248
6283
  cell.id
6249
6284
  )),
6250
- (columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
6285
+ (columnActions || listMenuActions) && /* @__PURE__ */ jsx(Table.Td, { style: { width: actionsColumnWidth2, minWidth: actionsColumnWidth2 }, children: /* @__PURE__ */ jsxs(Flex, { justify: "flex-end", align: "center", gap: "sm", children: [
6251
6286
  columnActions?.(row.original),
6252
6287
  listMenuActions && /* @__PURE__ */ jsxs(Menu, { variant: "subtle", children: [
6253
6288
  /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(MenuIcon, { size: 16 }) }) }),
@@ -6436,6 +6471,7 @@ var SimpleDataTable = ({
6436
6471
  onRowHover,
6437
6472
  table,
6438
6473
  canCheck,
6474
+ hasActionsColumn,
6439
6475
  columnActions,
6440
6476
  listMenuActions
6441
6477
  }