@pagamio/frontend-commons-lib 0.8.315 → 0.8.317

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.
@@ -26,7 +26,7 @@ const sizeStyles = {
26
26
  const Spinner = () => (_jsxs("svg", { className: "mr-2 h-4 w-4 animate-spin", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z" })] }));
27
27
  const Button = React.forwardRef(({ className, variant = 'primary', size = 'default', asChild = false, href, pill = false, loading = false, fullWidth = false, disabled = false, children, ...props }, ref) => {
28
28
  const isDisabled = disabled || loading;
29
- const baseStyles = 'inline-flex items-center justify-center gap-2 font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50';
29
+ const baseStyles = 'inline-flex items-center justify-center gap-2 whitespace-nowrap font-semibold transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50';
30
30
  const classes = cn(baseStyles, variantStyles[variant], sizeStyles[size], pill ? 'rounded-full' : 'rounded-md', fullWidth && 'w-full', loading && 'cursor-wait', isDisabled && !loading && 'bg-gray-400 text-white cursor-not-allowed', className);
31
31
  // Render as <a> when href is provided
32
32
  if (href) {
@@ -24,11 +24,10 @@ export function getDefaultTableOptions() {
24
24
  // ── Layout: columns fill the row width, no horizontal scroll, no gaps ──
25
25
  // In `grid` mode, leftover row width is distributed proportionally to
26
26
  // each column's `size`, so larger columns naturally get more room.
27
- layoutMode: 'grid',
27
+ layoutMode: 'semantic',
28
28
  defaultColumn: {
29
29
  minSize: 50,
30
30
  size: 140,
31
- grow: true,
32
31
  },
33
32
  // ── Brand styling ──
34
33
  mantineTableContainerProps: {
@@ -41,7 +40,10 @@ export function getDefaultTableOptions() {
41
40
  mantineTableProps: {
42
41
  style: {
43
42
  width: '100%',
43
+ tableLayout: 'auto',
44
44
  },
45
+ verticalSpacing: 'xs',
46
+ horizontalSpacing: 'xs',
45
47
  },
46
48
  mantineLoadingOverlayProps: {
47
49
  children: _jsx(LoaderComponent, { size: "lg" }),
@@ -33,34 +33,32 @@ const MEDIUM_PATTERNS = /^(type|role|category|unit|sku|code|currency|country|met
33
33
  const LARGE_PATTERNS = /(name|description|address|email|message|label|title|product|item|note)/i;
34
34
  function inferColumnSize(id) {
35
35
  if (id === 'actions')
36
- return { size: 100, grow: false };
36
+ return 130;
37
37
  if (TINY_PATTERNS.test(id))
38
- return { size: 60, grow: false };
38
+ return 60;
39
39
  if (STATUS_PATTERNS.test(id))
40
- return { size: 170, grow: true };
40
+ return 170;
41
41
  if (SMALL_PATTERNS.test(id))
42
- return { size: 90, grow: false };
42
+ return 90;
43
43
  if (MEDIUM_PATTERNS.test(id))
44
- return { size: 130, grow: true };
44
+ return 130;
45
45
  if (LARGE_PATTERNS.test(id))
46
- return { size: 200, grow: true };
47
- return { size: 140, grow: true };
46
+ return 200;
47
+ return 140;
48
48
  }
49
49
  /**
50
50
  * Applies the `showHeader: false` column config and auto-sizes columns.
51
- * Inferred size is treated as a minimum — any explicit `col.size` is honoured
52
- * only if it is at least the inferred minimum. This guarantees columns like
53
- * `status` always have enough room for their chips even if a consumer hardcoded
54
- * a too-narrow size.
51
+ *
52
+ * Every column gets a compact pixel size based on its id/accessorKey. No
53
+ * column grows `layoutMode: 'grid-no-grow'` ensures MRT auto-adds a spacer
54
+ * column to absorb any leftover row width, so columns stay reasonably sized
55
+ * regardless of viewport. Consumer-supplied `size` values are ignored to keep
56
+ * sizing consistent across the app.
55
57
  */
56
58
  function processColumns(columns) {
57
59
  return columns.map((col) => {
58
60
  const id = (col.id ?? col.accessorKey ?? '');
59
- const inferred = inferColumnSize(id);
60
- const finalSize = col.size === undefined ? inferred.size : Math.max(col.size, inferred.size);
61
- const colWithGrow = col;
62
- const finalGrow = colWithGrow.grow ?? inferred.grow;
63
- const sized = { ...col, size: finalSize, grow: finalGrow };
61
+ const sized = { ...col, size: inferColumnSize(id) };
64
62
  if (sized.showHeader === false) {
65
63
  return {
66
64
  ...sized,
@@ -203,17 +201,6 @@ const PagamioTable = ({ columns, data, isLoading = false, rowCount, sorting, pag
203
201
  enableExpanding: expandable,
204
202
  renderDetailPanel,
205
203
  onExpandedChange: setExpanded,
206
- // Force detail panel to span the entire row in grid layoutMode.
207
- // The actual `width: var(--mrt-inner-width)` cap is overridden via global
208
- // CSS in src/index.css — these inline styles complement that.
209
- mantineDetailPanelProps: {
210
- style: {
211
- width: '100%',
212
- maxWidth: '100%',
213
- gridColumn: '1 / -1',
214
- flex: '1 1 100%',
215
- },
216
- },
217
204
  // Toolbar visibility
218
205
  enableTopToolbar: usesMrtToolbar,
219
206
  enableBottomToolbar: hasServerPagination || defaults.enableBottomToolbar,
package/lib/styles.css CHANGED
@@ -3876,22 +3876,7 @@ video {
3876
3876
  border-bottom-color: hsl(var(--border)) !important;
3877
3877
  }
3878
3878
 
3879
- /* ─────────────────────────────────────────────────────────────────
3880
- Mantine React Table — detail panel full-width override.
3881
- In `layoutMode: 'grid'`, MRT sets the cell width to
3882
- `var(--mrt-inner-width)` which equals the sum of column sizes.
3883
- Override it so the detail panel always spans the full row width,
3884
- and force the inner Collapse wrapper to fill the cell.
3885
- ───────────────────────────────────────────────────────────────── */
3886
- .mantine-Table-td-detail-panel {
3887
- width: 100% !important;
3888
- max-width: 100% !important;
3889
- }
3890
- .mantine-Table-td-detail-panel > div {
3891
- width: 100%;
3892
- }
3893
-
3894
- /* Ensure body cells wrap content instead of clipping in grid mode. */
3879
+ /* Ensure body cells wrap content instead of clipping. */
3895
3880
  .mantine-Table-td {
3896
3881
  white-space: normal !important;
3897
3882
  overflow: visible !important;
@@ -3903,6 +3888,16 @@ video {
3903
3888
  overflow: visible !important;
3904
3889
  text-overflow: clip !important;
3905
3890
  }
3891
+
3892
+ /* MRT semantic mode: the explicit `width: <n>px` on each cell prevents the
3893
+ table from filling its container — leftover space becomes dead gap on the
3894
+ right. Treat the inline width as a minimum hint instead by overriding it
3895
+ to `auto`; the browser's table-layout: auto then distributes width based
3896
+ on content + min-width while filling 100% of the table width. */
3897
+ .mantine-Table-table > thead > tr > .mantine-Table-th,
3898
+ .mantine-Table-table > tbody > tr > .mantine-Table-td {
3899
+ width: auto !important;
3900
+ }
3906
3901
  .file\:-ms-4::file-selector-button {
3907
3902
  margin-inline-start: -1rem;
3908
3903
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pagamio/frontend-commons-lib",
3
3
  "description": "Pagamio library for Frontend reusable components like the form engine and table container",
4
- "version": "0.8.315",
4
+ "version": "0.8.317",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": false