@gears-frontx/ui-kit 0.4.5 → 0.4.6

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.
Files changed (146) hide show
  1. package/dist/chunks/actions.iasfkjWq.css +1 -0
  2. package/dist/chunks/create-column-auto-size.js +62 -0
  3. package/dist/chunks/create-column-auto-size.js.map +1 -0
  4. package/dist/chunks/data-grid-record-context.js +13 -0
  5. package/dist/chunks/data-grid-record-context.js.map +1 -0
  6. package/dist/chunks/data-grid.-6P4UQGJ.css +1 -0
  7. package/dist/chunks/hooked.js +27 -35
  8. package/dist/chunks/hooked.js.map +1 -1
  9. package/dist/chunks/ignore-row-click.js +5 -0
  10. package/dist/chunks/ignore-row-click.js.map +1 -0
  11. package/dist/chunks/messages.js +19 -3
  12. package/dist/chunks/messages.js.map +1 -1
  13. package/dist/chunks/resolve-body-cell-props.DGczzk1U.css +1 -0
  14. package/dist/chunks/resolve-body-cell-props.js +140 -0
  15. package/dist/chunks/resolve-body-cell-props.js.map +1 -0
  16. package/dist/chunks/row-actions.BprAXgu2.css +1 -0
  17. package/dist/chunks/row-click.DAYTmSBO.css +1 -0
  18. package/dist/chunks/row-number.C7fNu9Bw.css +1 -0
  19. package/dist/chunks/row-select.BjKdiMf5.css +1 -0
  20. package/dist/chunks/table-configuration.a6C_fp7B.css +1 -0
  21. package/dist/chunks/table-context.js +8 -0
  22. package/dist/chunks/table-context.js.map +1 -0
  23. package/dist/chunks/table-types.js +11 -0
  24. package/dist/chunks/table-types.js.map +1 -0
  25. package/dist/chunks/table.Dmz7LEk7.css +1 -0
  26. package/dist/components/data-grid/messages.d.ts +16 -0
  27. package/dist/components/data-grid/messages.d.ts.map +1 -1
  28. package/dist/components/data-grid/plugins/actions/actions-plugin.d.ts +4 -0
  29. package/dist/components/data-grid/plugins/actions/actions-plugin.d.ts.map +1 -0
  30. package/dist/components/data-grid/plugins/actions/actions-types.d.ts +11 -0
  31. package/dist/components/data-grid/plugins/actions/actions-types.d.ts.map +1 -0
  32. package/dist/components/data-grid/plugins/actions/components/data-grid-actions-wrapper.d.ts +3 -0
  33. package/dist/components/data-grid/plugins/actions/components/data-grid-actions-wrapper.d.ts.map +1 -0
  34. package/dist/components/data-grid/plugins/actions/public.d.ts +3 -0
  35. package/dist/components/data-grid/plugins/actions/public.d.ts.map +1 -0
  36. package/dist/components/data-grid/plugins/actions-menu/actions-menu-plugin.d.ts +3 -0
  37. package/dist/components/data-grid/plugins/actions-menu/actions-menu-plugin.d.ts.map +1 -0
  38. package/dist/components/data-grid/plugins/actions-menu/actions-menu-types.d.ts +25 -0
  39. package/dist/components/data-grid/plugins/actions-menu/actions-menu-types.d.ts.map +1 -0
  40. package/dist/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.d.ts +3 -0
  41. package/dist/components/data-grid/plugins/actions-menu/components/data-grid-actions-menu.d.ts.map +1 -0
  42. package/dist/components/data-grid/plugins/actions-menu/public.d.ts +3 -0
  43. package/dist/components/data-grid/plugins/actions-menu/public.d.ts.map +1 -0
  44. package/dist/components/data-grid/plugins/row-actions/components/data-grid-row-actions-cell.d.ts +3 -0
  45. package/dist/components/data-grid/plugins/row-actions/components/data-grid-row-actions-cell.d.ts.map +1 -0
  46. package/dist/components/data-grid/plugins/row-actions/public.d.ts +3 -0
  47. package/dist/components/data-grid/plugins/row-actions/public.d.ts.map +1 -0
  48. package/dist/components/data-grid/plugins/row-actions/row-actions-plugin.d.ts +6 -0
  49. package/dist/components/data-grid/plugins/row-actions/row-actions-plugin.d.ts.map +1 -0
  50. package/dist/components/data-grid/plugins/row-actions/row-actions-types.d.ts +24 -0
  51. package/dist/components/data-grid/plugins/row-actions/row-actions-types.d.ts.map +1 -0
  52. package/dist/components/data-grid/plugins/row-click/components/data-grid-row-click.d.ts +8 -0
  53. package/dist/components/data-grid/plugins/row-click/components/data-grid-row-click.d.ts.map +1 -0
  54. package/dist/components/data-grid/plugins/row-click/public.d.ts +3 -0
  55. package/dist/components/data-grid/plugins/row-click/public.d.ts.map +1 -0
  56. package/dist/components/data-grid/plugins/row-click/row-click-plugin.d.ts +14 -0
  57. package/dist/components/data-grid/plugins/row-click/row-click-plugin.d.ts.map +1 -0
  58. package/dist/components/data-grid/plugins/row-click/row-click-utils.d.ts +9 -0
  59. package/dist/components/data-grid/plugins/row-click/row-click-utils.d.ts.map +1 -0
  60. package/dist/components/data-grid/plugins/row-number/components/data-grid-row-number-cell.d.ts +3 -0
  61. package/dist/components/data-grid/plugins/row-number/components/data-grid-row-number-cell.d.ts.map +1 -0
  62. package/dist/components/data-grid/plugins/row-number/public.d.ts +3 -0
  63. package/dist/components/data-grid/plugins/row-number/public.d.ts.map +1 -0
  64. package/dist/components/data-grid/plugins/row-number/row-number-plugin.d.ts +4 -0
  65. package/dist/components/data-grid/plugins/row-number/row-number-plugin.d.ts.map +1 -0
  66. package/dist/components/data-grid/plugins/row-number/row-number-types.d.ts +6 -0
  67. package/dist/components/data-grid/plugins/row-number/row-number-types.d.ts.map +1 -0
  68. package/dist/components/data-grid/plugins/row-number/services/row-number-formula.d.ts +2 -0
  69. package/dist/components/data-grid/plugins/row-number/services/row-number-formula.d.ts.map +1 -0
  70. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-banner.d.ts +3 -0
  71. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-banner.d.ts.map +1 -0
  72. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-body.d.ts +3 -0
  73. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-body.d.ts.map +1 -0
  74. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-header.d.ts +3 -0
  75. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-header.d.ts.map +1 -0
  76. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-top.d.ts +3 -0
  77. package/dist/components/data-grid/plugins/row-select/components/data-grid-row-select-top.d.ts.map +1 -0
  78. package/dist/components/data-grid/plugins/row-select/public.d.ts +3 -0
  79. package/dist/components/data-grid/plugins/row-select/public.d.ts.map +1 -0
  80. package/dist/components/data-grid/plugins/row-select/row-select-plugin.d.ts +5 -0
  81. package/dist/components/data-grid/plugins/row-select/row-select-plugin.d.ts.map +1 -0
  82. package/dist/components/data-grid/plugins/row-select/row-select-types.d.ts +113 -0
  83. package/dist/components/data-grid/plugins/row-select/row-select-types.d.ts.map +1 -0
  84. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-group-item.d.ts +10 -0
  85. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-group-item.d.ts.map +1 -0
  86. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-item.d.ts +10 -0
  87. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-item.d.ts.map +1 -0
  88. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-pin-button.d.ts +8 -0
  89. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-pin-button.d.ts.map +1 -0
  90. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-trigger.d.ts +3 -0
  91. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration-trigger.d.ts.map +1 -0
  92. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration.d.ts +3 -0
  93. package/dist/components/data-grid/plugins/table-configuration/components/data-grid-table-configuration.d.ts.map +1 -0
  94. package/dist/components/data-grid/plugins/table-configuration/public.d.ts +3 -0
  95. package/dist/components/data-grid/plugins/table-configuration/public.d.ts.map +1 -0
  96. package/dist/components/data-grid/plugins/table-configuration/table-configuration-plugin.d.ts +5 -0
  97. package/dist/components/data-grid/plugins/table-configuration/table-configuration-plugin.d.ts.map +1 -0
  98. package/dist/components/data-grid/services/layout/components/data-grid-layout-top.d.ts.map +1 -1
  99. package/dist/components/data-grid/services/layout/components/toolbar-lines.d.ts +2 -0
  100. package/dist/components/data-grid/services/layout/components/toolbar-lines.d.ts.map +1 -0
  101. package/dist/components/data-grid/services/table/components/data-grid-cell.d.ts.map +1 -1
  102. package/dist/components/data-grid/services/table/components/data-grid-extra-header-cell.d.ts.map +1 -1
  103. package/dist/components/data-grid/services/table/components/data-grid-header-cell.d.ts.map +1 -1
  104. package/dist/components/data-grid/services/table/components/data-grid-header-group.d.ts.map +1 -1
  105. package/dist/components/data-grid/services/table/table-service.d.ts.map +1 -1
  106. package/dist/components/data-grid/services/table/table-sticky.d.ts +16 -0
  107. package/dist/components/data-grid/services/table/table-sticky.d.ts.map +1 -1
  108. package/dist/components/table/table.d.ts +20 -3
  109. package/dist/components/table/table.d.ts.map +1 -1
  110. package/dist/data-grid/actions-menu.d.ts +1 -0
  111. package/dist/data-grid/actions-menu.js +57 -0
  112. package/dist/data-grid/actions-menu.js.map +1 -0
  113. package/dist/data-grid/actions.d.ts +1 -0
  114. package/dist/data-grid/actions.js +36 -0
  115. package/dist/data-grid/actions.js.map +1 -0
  116. package/dist/data-grid/filters.js +24 -23
  117. package/dist/data-grid/filters.js.map +1 -1
  118. package/dist/data-grid/row-actions.d.ts +1 -0
  119. package/dist/data-grid/row-actions.js +52 -0
  120. package/dist/data-grid/row-actions.js.map +1 -0
  121. package/dist/data-grid/row-click.d.ts +1 -0
  122. package/dist/data-grid/row-click.js +69 -0
  123. package/dist/data-grid/row-click.js.map +1 -0
  124. package/dist/data-grid/row-number.d.ts +1 -0
  125. package/dist/data-grid/row-number.js +38 -0
  126. package/dist/data-grid/row-number.js.map +1 -0
  127. package/dist/data-grid/row-select.d.ts +1 -0
  128. package/dist/data-grid/row-select.js +293 -0
  129. package/dist/data-grid/row-select.js.map +1 -0
  130. package/dist/data-grid/table-configuration.d.ts +1 -0
  131. package/dist/data-grid/table-configuration.js +165 -0
  132. package/dist/data-grid/table-configuration.js.map +1 -0
  133. package/dist/data-grid.js +853 -921
  134. package/dist/data-grid.js.map +1 -1
  135. package/dist/docs/data-grid.md +336 -9
  136. package/dist/docs/table.md +57 -2
  137. package/dist/index.d.ts +7 -0
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +397 -382
  140. package/dist/index.js.map +1 -1
  141. package/dist/table.js +114 -112
  142. package/dist/table.js.map +1 -1
  143. package/llms.txt +9 -7
  144. package/package.json +1 -1
  145. package/dist/chunks/data-grid.DYrZEU-F.css +0 -1
  146. package/dist/chunks/table.CMm41tvy.css +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/table.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as m, jsxs as X } from "react/jsx-runtime";
3
- import { cx as y, cva as A } from "class-variance-authority";
4
- import { useRef as I, useState as w, useCallback as v, useEffect as B } from "react";
5
- import './chunks/table.CMm41tvy.css';const V = "_tableContainer_pfb4y_8", j = "_table_pfb4y_8", K = "_stickyHeader_pfb4y_79", U = "_tableHeader_pfb4y_91", Y = "_tableHead_pfb4y_70", q = "_tableRow_pfb4y_59", G = "_tableBody_pfb4y_147", J = "_columnResizer_pfb4y_279", Q = "_tableCell_pfb4y_127", Z = "_variantDefault_pfb4y_387", tt = "_variantCollection_pfb4y_94", et = "_densityCompact_pfb4y_461", nt = "_tableCaption_pfb4y_470", lt = "_tableFooter_pfb4y_492", c = {
3
+ import { cx as h, cva as A } from "class-variance-authority";
4
+ import { useRef as I, useState as g, useCallback as v, useEffect as B } from "react";
5
+ import './chunks/table.Dmz7LEk7.css';const V = "_tableContainer_16yux_8", j = "_table_16yux_8", K = "_stickyHeader_16yux_79", U = "_tableHeader_16yux_91", Y = "_tableHead_16yux_70", q = "_tableRow_16yux_59", G = "_tableBody_16yux_147", J = "_columnResizer_16yux_279", Q = "_tableCell_16yux_127", Z = "_pinned_16yux_397", tt = "_variantCollection_16yux_94", et = "_variantDefault_16yux_439", nt = "_densityCompact_16yux_531", lt = "_tableCaption_16yux_540", at = "_tableFooter_16yux_562", c = {
6
6
  tableContainer: V,
7
7
  table: j,
8
8
  stickyHeader: K,
@@ -12,28 +12,29 @@ import './chunks/table.CMm41tvy.css';const V = "_tableContainer_pfb4y_8", j = "_
12
12
  tableBody: G,
13
13
  columnResizer: J,
14
14
  tableCell: Q,
15
- variantDefault: Z,
15
+ pinned: Z,
16
16
  variantCollection: tt,
17
- densityCompact: et,
18
- tableCaption: nt,
19
- tableFooter: lt
20
- }, D = 12, E = 8, at = 72, ot = 32;
17
+ variantDefault: et,
18
+ densityCompact: nt,
19
+ tableCaption: lt,
20
+ tableFooter: at
21
+ }, D = 12, E = 8, ot = 72, rt = 32;
21
22
  function P(e) {
22
23
  var t;
23
24
  return Array.from(((t = e.parentElement) == null ? void 0 : t.children) ?? []).filter(
24
- (a) => a instanceof HTMLTableCellElement
25
+ (l) => l instanceof HTMLTableCellElement
25
26
  );
26
27
  }
27
28
  function N(e, t) {
28
- var a;
29
- return t !== void 0 ? t : (a = e.textContent) != null && a.trim() ? at : ot;
29
+ var l;
30
+ return t !== void 0 ? t : (l = e.textContent) != null && l.trim() ? ot : rt;
30
31
  }
31
32
  function F(e) {
32
- const t = P(e), a = e.closest("table");
33
- if (a && a.style.tableLayout !== "fixed") {
33
+ const t = P(e), l = e.closest("table");
34
+ if (l && l.style.tableLayout !== "fixed") {
34
35
  for (const o of t)
35
36
  o.style.width = `${Math.round(o.getBoundingClientRect().width)}px`;
36
- a.style.tableLayout = "fixed", W(t);
37
+ l.style.tableLayout = "fixed", W(t);
37
38
  }
38
39
  return t;
39
40
  }
@@ -41,109 +42,109 @@ function H(e) {
41
42
  return Number.parseFloat(e.style.width) || 0;
42
43
  }
43
44
  function W(e) {
44
- var a;
45
- const t = (a = e[0]) == null ? void 0 : a.closest("table");
45
+ var l;
46
+ const t = (l = e[0]) == null ? void 0 : l.closest("table");
46
47
  t && (t.style.width = `${e.reduce((o, s) => o + H(s), 0)}px`);
47
48
  }
48
- function x(e, t, a, o = H) {
49
+ function w(e, t, l, o = H) {
49
50
  const s = e[t];
50
51
  if (!s)
51
52
  return 0;
52
- const u = N(s, a), f = s.closest("table");
53
- if (t !== e.length - 1 || !f)
53
+ const u = N(s, l), d = s.closest("table");
54
+ if (t !== e.length - 1 || !d)
54
55
  return u;
55
- const r = Number.parseFloat(getComputedStyle(f).minWidth);
56
+ const r = Number.parseFloat(getComputedStyle(d).minWidth);
56
57
  if (!Number.isFinite(r))
57
58
  return u;
58
- const p = e.slice(0, t).reduce((_, h) => _ + o(h), 0);
59
- return Math.max(u, Math.ceil(r - p));
59
+ const _ = e.slice(0, t).reduce((C, y) => C + o(y), 0);
60
+ return Math.max(u, Math.ceil(r - _));
60
61
  }
61
- function O(e, t, a, o, s, u, f) {
62
+ function O(e, t, l, o, s, u, d) {
62
63
  const r = e[t];
63
64
  if (!r)
64
- return a;
65
- const p = o === null ? null : e[t + 1], _ = o === null || !p ? Number.POSITIVE_INFINITY : a + o - f, h = Math.round(Math.min(Math.max(a + s, u), _));
66
- return r.style.width = `${h}px`, p && o !== null && (p.style.width = `${a + o - h}px`), W(e), h;
65
+ return l;
66
+ const _ = o === null ? null : e[t + 1], C = o === null || !_ ? Number.POSITIVE_INFINITY : l + o - d, y = Math.round(Math.min(Math.max(l + s, u), C));
67
+ return r.style.width = `${y}px`, _ && o !== null && (_.style.width = `${l + o - y}px`), W(e), y;
67
68
  }
68
- function rt({ minWidth: e }) {
69
- const t = I(null), a = I(null), [o, s] = w(""), [u, f] = w(null), [r, p] = w(null), _ = v(() => {
70
- var d, C;
71
- const n = (d = t.current) == null ? void 0 : d.closest("th");
69
+ function it({ minWidth: e }) {
70
+ const t = I(null), l = I(null), [o, s] = g(""), [u, d] = g(null), [r, _] = g(null), C = v(() => {
71
+ var f, p;
72
+ const n = (f = t.current) == null ? void 0 : f.closest("th");
72
73
  if (!(n instanceof HTMLTableCellElement))
73
74
  return;
74
- const l = P(n), i = Math.round(n.getBoundingClientRect().width), b = (g) => H(g) || g.getBoundingClientRect().width;
75
- p({
75
+ const a = P(n), i = Math.round(n.getBoundingClientRect().width), b = (T) => H(T) || T.getBoundingClientRect().width;
76
+ _({
76
77
  now: i,
77
- min: Math.round(x(l, l.indexOf(n), e, b)),
78
- max: Math.round(((C = n.closest("table")) == null ? void 0 : C.getBoundingClientRect().width) ?? 0)
79
- }), a.current || f((g) => g === null ? null : i);
78
+ min: Math.round(w(a, a.indexOf(n), e, b)),
79
+ max: Math.round(((p = n.closest("table")) == null ? void 0 : p.getBoundingClientRect().width) ?? 0)
80
+ }), l.current || d((T) => T === null ? null : i);
80
81
  }, [e]);
81
82
  B(() => {
82
- var n, l, i;
83
- s(((i = (l = (n = t.current) == null ? void 0 : n.closest("th")) == null ? void 0 : l.textContent) == null ? void 0 : i.trim()) ?? ""), _();
84
- }, [_]);
85
- const h = u ?? (r == null ? void 0 : r.now) ?? 0, z = Math.min((r == null ? void 0 : r.min) ?? 0, h), L = Math.max((r == null ? void 0 : r.max) ?? 0, h), R = (n) => {
83
+ var n, a, i;
84
+ s(((i = (a = (n = t.current) == null ? void 0 : n.closest("th")) == null ? void 0 : a.textContent) == null ? void 0 : i.trim()) ?? ""), C();
85
+ }, [C]);
86
+ const y = u ?? (r == null ? void 0 : r.now) ?? 0, z = Math.min((r == null ? void 0 : r.min) ?? 0, y), L = Math.max((r == null ? void 0 : r.max) ?? 0, y), R = (n) => {
86
87
  document.body.style.cursor = n ? "col-resize" : "", document.body.style.userSelect = n ? "none" : "";
87
- }, M = (n, l, i) => {
88
+ }, M = (n, a, i) => {
88
89
  try {
89
- i ? n.setPointerCapture(l) : n.hasPointerCapture(l) && n.releasePointerCapture(l);
90
+ i ? n.setPointerCapture(a) : n.hasPointerCapture(a) && n.releasePointerCapture(a);
90
91
  } catch {
91
92
  }
92
- }, T = v(() => {
93
- const n = a.current;
93
+ }, x = v(() => {
94
+ const n = l.current;
94
95
  if (!n)
95
96
  return;
96
- a.current = null, R(!1);
97
- const l = t.current;
98
- l && M(l, n.pointerId, !1);
97
+ l.current = null, R(!1);
98
+ const a = t.current;
99
+ a && M(a, n.pointerId, !1);
99
100
  }, []);
100
- B(() => T, [T]);
101
+ B(() => x, [x]);
101
102
  const k = (n) => {
102
- const l = n.currentTarget.closest("th");
103
- if (!(l instanceof HTMLTableCellElement) || n.button !== 0)
103
+ const a = n.currentTarget.closest("th");
104
+ if (!(a instanceof HTMLTableCellElement) || n.button !== 0)
104
105
  return;
105
- const i = F(l), b = i.indexOf(l), d = i[b + 1] ?? null;
106
- a.current = {
106
+ const i = F(a), b = i.indexOf(a), f = i[b + 1] ?? null;
107
+ l.current = {
107
108
  pointerId: n.pointerId,
108
109
  startX: n.clientX,
109
110
  cells: i,
110
111
  index: b,
111
- selfStart: l.getBoundingClientRect().width,
112
- neighbourStart: d ? d.getBoundingClientRect().width : null,
113
- minSelf: x(i, b, e),
114
- minNeighbour: d ? N(d, void 0) : 0
115
- }, M(n.currentTarget, n.pointerId, !0), R(!0), f(Math.round(a.current.selfStart));
112
+ selfStart: a.getBoundingClientRect().width,
113
+ neighbourStart: f ? f.getBoundingClientRect().width : null,
114
+ minSelf: w(i, b, e),
115
+ minNeighbour: f ? N(f, void 0) : 0
116
+ }, M(n.currentTarget, n.pointerId, !0), R(!0), d(Math.round(l.current.selfStart));
116
117
  }, $ = (n) => {
117
- const l = a.current;
118
- !l || l.pointerId !== n.pointerId || f(
118
+ const a = l.current;
119
+ !a || a.pointerId !== n.pointerId || d(
119
120
  O(
120
- l.cells,
121
- l.index,
122
- l.selfStart,
123
- l.neighbourStart,
124
- n.clientX - l.startX,
125
- l.minSelf,
126
- l.minNeighbour
121
+ a.cells,
122
+ a.index,
123
+ a.selfStart,
124
+ a.neighbourStart,
125
+ n.clientX - a.startX,
126
+ a.minSelf,
127
+ a.minNeighbour
127
128
  )
128
129
  );
129
130
  }, S = (n) => {
130
- const l = n.key === "ArrowLeft" ? -D : n.key === "ArrowRight" ? D : 0;
131
- if (l === 0)
131
+ const a = n.key === "ArrowLeft" ? -D : n.key === "ArrowRight" ? D : 0;
132
+ if (a === 0)
132
133
  return;
133
134
  const i = n.currentTarget.closest("th");
134
135
  if (!(i instanceof HTMLTableCellElement))
135
136
  return;
136
137
  n.preventDefault();
137
- const b = F(i), d = b.indexOf(i), C = b[d + 1] ?? null;
138
- f(
138
+ const b = F(i), f = b.indexOf(i), p = b[f + 1] ?? null;
139
+ d(
139
140
  O(
140
141
  b,
141
- d,
142
+ f,
142
143
  i.getBoundingClientRect().width,
143
- C ? C.getBoundingClientRect().width : null,
144
- l,
145
- x(b, d, e),
146
- C ? N(C, void 0) : 0
144
+ p ? p.getBoundingClientRect().width : null,
145
+ a,
146
+ w(b, f, e),
147
+ p ? N(p, void 0) : 0
147
148
  )
148
149
  );
149
150
  };
@@ -154,22 +155,22 @@ function rt({ minWidth: e }) {
154
155
  role: "separator",
155
156
  "aria-orientation": "vertical",
156
157
  "aria-label": `${o || "Column"} width${u === null ? "" : `, ${u} pixels`}`,
157
- "aria-valuenow": h,
158
+ "aria-valuenow": y,
158
159
  "aria-valuemin": z,
159
160
  "aria-valuemax": L,
160
- onFocus: _,
161
+ onFocus: C,
161
162
  tabIndex: 0,
162
163
  className: c.columnResizer,
163
164
  style: { width: E, insetInlineEnd: -E / 2 },
164
165
  onPointerDown: k,
165
166
  onPointerMove: $,
166
- onPointerUp: T,
167
- onPointerCancel: T,
167
+ onPointerUp: x,
168
+ onPointerCancel: x,
168
169
  onKeyDown: S
169
170
  }
170
171
  );
171
172
  }
172
- const it = A(c.table, {
173
+ const ct = A(c.table, {
173
174
  variants: {
174
175
  /*
175
176
  * `collection` is the spec's own guide word for the dense arrangement:
@@ -188,19 +189,19 @@ const it = A(c.table, {
188
189
  function ft({
189
190
  className: e,
190
191
  label: t,
191
- density: a,
192
+ density: l,
192
193
  variant: o,
193
194
  containerClassName: s,
194
195
  containerStyle: u,
195
- containerRef: f,
196
+ containerRef: d,
196
197
  stickyHeader: r,
197
- ...p
198
+ ..._
198
199
  }) {
199
200
  return /* @__PURE__ */ m(
200
201
  "div",
201
202
  {
202
- ref: f,
203
- className: y(c.tableContainer, s),
203
+ ref: d,
204
+ className: h(c.tableContainer, s),
204
205
  style: u,
205
206
  tabIndex: 0,
206
207
  role: t === void 0 ? void 0 : "region",
@@ -208,58 +209,59 @@ function ft({
208
209
  children: /* @__PURE__ */ m(
209
210
  "table",
210
211
  {
211
- className: it({
212
+ className: ct({
212
213
  variant: o,
213
- className: y(
214
- a === "compact" && c.densityCompact,
214
+ className: h(
215
+ l === "compact" && c.densityCompact,
215
216
  r && c.stickyHeader,
216
217
  e
217
218
  )
218
219
  }),
219
- ...p
220
+ ..._
220
221
  }
221
222
  )
222
223
  }
223
224
  );
224
225
  }
225
- function dt({ className: e, ...t }) {
226
- return /* @__PURE__ */ m("thead", { className: y(c.tableHeader, e), ...t });
227
- }
228
226
  function bt({ className: e, ...t }) {
229
- return /* @__PURE__ */ m("tbody", { className: y(c.tableBody, e), ...t });
227
+ return /* @__PURE__ */ m("thead", { className: h(c.tableHeader, e), ...t });
230
228
  }
231
229
  function mt({ className: e, ...t }) {
232
- return /* @__PURE__ */ m("tfoot", { className: y(c.tableFooter, e), ...t });
230
+ return /* @__PURE__ */ m("tbody", { className: h(c.tableBody, e), ...t });
233
231
  }
234
- function pt({ className: e, ...t }) {
235
- return /* @__PURE__ */ m("tr", { className: y(c.tableRow, e), ...t });
232
+ function _t({ className: e, ...t }) {
233
+ return /* @__PURE__ */ m("tfoot", { className: h(c.tableFooter, e), ...t });
234
+ }
235
+ function yt({ className: e, ...t }) {
236
+ return /* @__PURE__ */ m("tr", { className: h(c.tableRow, e), ...t });
236
237
  }
237
238
  function ht({
238
239
  className: e,
239
- resizable: t,
240
- resizeMinWidth: a,
241
- children: o,
242
- ...s
240
+ pinned: t,
241
+ resizable: l,
242
+ resizeMinWidth: o,
243
+ children: s,
244
+ ...u
243
245
  }) {
244
- return /* @__PURE__ */ X("th", { className: y(c.tableHead, e), ...s, children: [
245
- o,
246
- t ? /* @__PURE__ */ m(rt, { minWidth: a }) : null
246
+ return /* @__PURE__ */ X("th", { className: h(c.tableHead, t && c.pinned, e), ...u, children: [
247
+ s,
248
+ l ? /* @__PURE__ */ m(it, { minWidth: o }) : null
247
249
  ] });
248
250
  }
249
- function yt({ className: e, ...t }) {
250
- return /* @__PURE__ */ m("td", { className: y(c.tableCell, e), ...t });
251
+ function Ct({ className: e, pinned: t, ...l }) {
252
+ return /* @__PURE__ */ m("td", { className: h(c.tableCell, t && c.pinned, e), ...l });
251
253
  }
252
- function _t({ className: e, ...t }) {
253
- return /* @__PURE__ */ m("caption", { className: y(c.tableCaption, e), ...t });
254
+ function pt({ className: e, ...t }) {
255
+ return /* @__PURE__ */ m("caption", { className: h(c.tableCaption, e), ...t });
254
256
  }
255
257
  export {
256
258
  ft as Table,
257
- bt as TableBody,
258
- _t as TableCaption,
259
- yt as TableCell,
260
- mt as TableFooter,
259
+ mt as TableBody,
260
+ pt as TableCaption,
261
+ Ct as TableCell,
262
+ _t as TableFooter,
261
263
  ht as TableHead,
262
- dt as TableHeader,
263
- pt as TableRow
264
+ bt as TableHeader,
265
+ yt as TableRow
264
266
  };
265
267
  //# sourceMappingURL=table.js.map
package/dist/table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","sources":["../src/components/table/table.tsx"],"sourcesContent":["'use client';\n\nimport { cva, cx, type VariantProps } from 'class-variance-authority';\nimport {\n type ComponentProps,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport styles from './table.module.css';\n\n/*\n * Resize behaviour constants. These are not style values: they decide how\n * the drag RESPONDS, not how anything looks, so they live here rather than\n * as unexplained numbers in the stylesheet. All four are the design spec's\n * own.\n */\n/** How far one arrow-key press moves the boundary. */\nconst KEYBOARD_STEP = 12;\n/** The grab area straddling the column's trailing edge, half on each side. */\nconst HANDLE_WIDTH = 8;\n/** A column carrying text needs room for a word. */\nconst MIN_WIDTH_WITH_TEXT = 72;\n/** One carrying only a control (a checkbox, a row action) does not. */\nconst MIN_WIDTH_WITHOUT_TEXT = 32;\n\nfunction headerCellsOf(cell: HTMLTableCellElement): HTMLTableCellElement[] {\n return Array.from(cell.parentElement?.children ?? []).filter(\n (child): child is HTMLTableCellElement => child instanceof HTMLTableCellElement,\n );\n}\n\nfunction minWidthOf(cell: HTMLTableCellElement, override: number | undefined): number {\n if (override !== undefined) {\n return override;\n }\n return cell.textContent?.trim() ? MIN_WIDTH_WITH_TEXT : MIN_WIDTH_WITHOUT_TEXT;\n}\n\n/*\n * The first drag freezes every column at the width it currently renders and\n * switches the table to a fixed layout. Without that the browser keeps\n * re-deriving every column from its content, so widening one column silently\n * reflows the rest and the drag does not hold.\n */\nfunction freezeColumns(cell: HTMLTableCellElement): HTMLTableCellElement[] {\n const cells = headerCellsOf(cell);\n const table = cell.closest('table');\n if (table && table.style.tableLayout !== 'fixed') {\n for (const column of cells) {\n column.style.width = `${Math.round(column.getBoundingClientRect().width)}px`;\n }\n table.style.tableLayout = 'fixed';\n pinTableWidth(cells);\n }\n return cells;\n}\n\nfunction frozenWidthOf(cell: HTMLTableCellElement): number {\n return Number.parseFloat(cell.style.width) || 0;\n}\n\n/*\n * A fixed layout still stretches its columns to the table's own width, and\n * `.table` is `width: 100%`: left alone, whatever a column gives up is handed\n * straight back to the others, which is why the last column could never be\n * narrowed. Pinning the table to the sum of its frozen columns makes the\n * columns the only thing deciding its width, so it can end up narrower than\n * its container or wider than it (the wrapper then scrolls).\n */\nfunction pinTableWidth(cells: HTMLTableCellElement[]): void {\n const table = cells[0]?.closest('table');\n if (table) {\n table.style.width = `${cells.reduce((sum, column) => sum + frozenWidthOf(column), 0)}px`;\n }\n}\n\n/*\n * The floor a dragged column resizes against. Only the last column can\n * change the table's width, so only the last one also has to respect a\n * `min-width` on the table (the collection view's 960px): below that the\n * browser would widen the table back and spread the difference over every\n * column, and the width the handle announced would no longer be the one on\n * screen.\n */\nfunction minSelfOf(\n cells: HTMLTableCellElement[],\n index: number,\n override: number | undefined,\n widthOf: (cell: HTMLTableCellElement) => number = frozenWidthOf,\n): number {\n const self = cells[index];\n if (!self) {\n return 0;\n }\n const own = minWidthOf(self, override);\n const table = self.closest('table');\n if (index !== cells.length - 1 || !table) {\n return own;\n }\n const tableFloor = Number.parseFloat(getComputedStyle(table).minWidth);\n if (!Number.isFinite(tableFloor)) {\n return own;\n }\n const others = cells.slice(0, index).reduce((sum, column) => sum + widthOf(column), 0);\n return Math.max(own, Math.ceil(tableFloor - others));\n}\n\n/*\n * A column resizes against its TRAILING neighbour: the pair's combined width\n * is what stays constant, so dragging an inner boundary never changes the\n * table's own width. The last column has no neighbour to trade with, and\n * there the table's pinned width (see pinTableWidth) follows it in both\n * directions.\n */\nfunction applyWidths(\n cells: HTMLTableCellElement[],\n index: number,\n selfStart: number,\n neighbourStart: number | null,\n delta: number,\n minSelf: number,\n minNeighbour: number,\n): number {\n const self = cells[index];\n if (!self) {\n return selfStart;\n }\n const neighbour = neighbourStart === null ? null : cells[index + 1];\n const ceiling =\n neighbourStart === null || !neighbour\n ? Number.POSITIVE_INFINITY\n : selfStart + neighbourStart - minNeighbour;\n const next = Math.round(Math.min(Math.max(selfStart + delta, minSelf), ceiling));\n self.style.width = `${next}px`;\n if (neighbour && neighbourStart !== null) {\n neighbour.style.width = `${selfStart + neighbourStart - next}px`;\n }\n pinTableWidth(cells);\n return next;\n}\n\ninterface DragState {\n pointerId: number;\n startX: number;\n cells: HTMLTableCellElement[];\n index: number;\n selfStart: number;\n neighbourStart: number | null;\n minSelf: number;\n minNeighbour: number;\n}\n\ninterface TableColumnResizerProps {\n minWidth?: number;\n}\n\n/*\n * The trailing-edge resize handle. Rendered inside its own <th>, which is\n * what it measures and resizes; the geometry it needs from JS (the grab\n * width and its half-overhang) comes from HANDLE_WIDTH above, and the\n * hairline it draws is the stylesheet's.\n */\nfunction TableColumnResizer({ minWidth }: TableColumnResizerProps) {\n const handleRef = useRef<HTMLSpanElement>(null);\n const dragRef = useRef<DragState | null>(null);\n const [columnName, setColumnName] = useState('');\n const [width, setWidth] = useState<number | null>(null);\n // The column's width and its bounds as the handle reports them: a\n // focusable separator is a widget, and assistive technology reads its\n // value from aria-valuenow (axe `aria-required-attr` without it). Read at\n // mount and again whenever the handle takes focus, since dragging a\n // neighbour's handle changes this column too; `width` above takes over\n // while this handle resizes. The floor is the one the resize clamps to.\n const [bounds, setBounds] = useState<{ now: number; min: number; max: number } | null>(null);\n\n const measure = useCallback(() => {\n const cell = handleRef.current?.closest('th');\n if (!(cell instanceof HTMLTableCellElement)) {\n return;\n }\n const cells = headerCellsOf(cell);\n const now = Math.round(cell.getBoundingClientRect().width);\n // Before the first resize no column has an inline width yet, so the\n // floor reads each other column's rendered width, as the drag will once\n // it freezes them.\n const renderedWidthOf = (column: HTMLTableCellElement) =>\n frozenWidthOf(column) || column.getBoundingClientRect().width;\n setBounds({\n now,\n min: Math.round(minSelfOf(cells, cells.indexOf(cell), minWidth, renderedWidthOf)),\n max: Math.round(cell.closest('table')?.getBoundingClientRect().width ?? 0),\n });\n // A width already announced follows the column (a neighbour's drag may\n // have changed it); a focus that starts a drag keeps the drag's own.\n if (!dragRef.current) {\n setWidth((announced) => (announced === null ? null : now));\n }\n }, [minWidth]);\n\n useEffect(() => {\n setColumnName(handleRef.current?.closest('th')?.textContent?.trim() ?? '');\n measure();\n }, [measure]);\n\n // Kept inside [min, max]: a column the layout squeezed below its floor\n // reports its real width, and the minimum is lowered to it rather than\n // announced above the value.\n const valueNow = width ?? bounds?.now ?? 0;\n const valueMin = Math.min(bounds?.min ?? 0, valueNow);\n const valueMax = Math.max(bounds?.max ?? 0, valueNow);\n\n /*\n * The cursor and the text selection are locked for the DURATION of the\n * drag, not for the pointer's position: without it, dragging past the\n * handle turns the pointer back into a caret and starts selecting the\n * header labels it crosses.\n */\n const lockPage = (locked: boolean) => {\n document.body.style.cursor = locked ? 'col-resize' : '';\n document.body.style.userSelect = locked ? 'none' : '';\n };\n\n /*\n * Pointer capture is what keeps the drag alive once the pointer leaves\n * the 8px handle, but it is not what the drag depends on: a pointer id\n * the platform does not consider active throws, and the drag still has to\n * work. Both calls are therefore best-effort, and the drag's own state is\n * the ref above.\n */\n const capturePointer = (handle: HTMLSpanElement, pointerId: number, capture: boolean) => {\n try {\n if (capture) {\n handle.setPointerCapture(pointerId);\n } else if (handle.hasPointerCapture(pointerId)) {\n handle.releasePointerCapture(pointerId);\n }\n } catch {\n // No capture to take or give back; the drag is unaffected either way.\n }\n };\n\n /*\n * Only a drag this handle started may release the lock: the unmount\n * cleanup and a stray pointerup both land here, and clearing the body\n * styles unconditionally would wipe a cursor something else on the page\n * had set.\n */\n const endDrag = useCallback(() => {\n const drag = dragRef.current;\n if (!drag) {\n return;\n }\n dragRef.current = null;\n lockPage(false);\n const handle = handleRef.current;\n if (handle) {\n capturePointer(handle, drag.pointerId, false);\n }\n }, []);\n\n // Releases the lock if the header unmounts mid-drag: the page would\n // otherwise keep the resize cursor and the suppressed selection forever.\n useEffect(() => endDrag, [endDrag]);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLSpanElement>) => {\n const cell = event.currentTarget.closest('th');\n if (!(cell instanceof HTMLTableCellElement) || event.button !== 0) {\n return;\n }\n const cells = freezeColumns(cell);\n const index = cells.indexOf(cell);\n const neighbour = cells[index + 1] ?? null;\n dragRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n cells,\n index,\n selfStart: cell.getBoundingClientRect().width,\n neighbourStart: neighbour ? neighbour.getBoundingClientRect().width : null,\n minSelf: minSelfOf(cells, index, minWidth),\n minNeighbour: neighbour ? minWidthOf(neighbour, undefined) : 0,\n };\n capturePointer(event.currentTarget, event.pointerId, true);\n lockPage(true);\n setWidth(Math.round(dragRef.current.selfStart));\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLSpanElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) {\n return;\n }\n setWidth(\n applyWidths(\n drag.cells,\n drag.index,\n drag.selfStart,\n drag.neighbourStart,\n event.clientX - drag.startX,\n drag.minSelf,\n drag.minNeighbour,\n ),\n );\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLSpanElement>) => {\n const step =\n event.key === 'ArrowLeft' ? -KEYBOARD_STEP : event.key === 'ArrowRight' ? KEYBOARD_STEP : 0;\n if (step === 0) {\n return;\n }\n const cell = event.currentTarget.closest('th');\n if (!(cell instanceof HTMLTableCellElement)) {\n return;\n }\n event.preventDefault();\n const cells = freezeColumns(cell);\n const index = cells.indexOf(cell);\n const neighbour = cells[index + 1] ?? null;\n setWidth(\n applyWidths(\n cells,\n index,\n cell.getBoundingClientRect().width,\n neighbour ? neighbour.getBoundingClientRect().width : null,\n step,\n minSelfOf(cells, index, minWidth),\n neighbour ? minWidthOf(neighbour, undefined) : 0,\n ),\n );\n };\n\n return (\n <span\n ref={handleRef}\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={`${columnName || 'Column'} width${width === null ? '' : `, ${width} pixels`}`}\n aria-valuenow={valueNow}\n aria-valuemin={valueMin}\n aria-valuemax={valueMax}\n onFocus={measure}\n tabIndex={0}\n className={styles.columnResizer}\n style={{ width: HANDLE_WIDTH, insetInlineEnd: -HANDLE_WIDTH / 2 }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={onKeyDown}\n />\n );\n}\n\n/*\n * Table has no Base UI primitive (registry/base-vega ships plain native\n * elements with data-slot markers, this kit drops data-slot everywhere —\n * see card.tsx) — pure styling translation over native `<table>` markup,\n * per design-notes.md: a composite data-table (sorting, filtering,\n * pagination, virtualisation, column defs) is deliberately out of scope\n * here. This is styled markup, nothing more.\n *\n * Table renders two elements, matching the source exactly: its own\n * scroll wrapper div around the <table>, rather than asking every consumer\n * to remember to add one. That wrapper is also the one to cap the table's\n * height with (`containerClassName` / `containerStyle`), not a div of the\n * consumer's own around <Table>: a sticky header sticks to its NEAREST\n * scrolling ancestor, and since the wrapper already scrolls horizontally it\n * is that ancestor. An outer div would scroll while the wrapper, having no\n * height of its own, never did, and the sticky header would scroll away\n * with the rows. `containerRef` reaches the same element for a caller that\n * measures it or drives its scroll.\n *\n * That wrapper is `tabIndex={0}`, a deliberate addition over the source,\n * which has none. A horizontally-overflowing region with no scrollbar\n * dragging alternative is otherwise unreachable from the keyboard (WCAG\n * 2.1.1) — a mouse/touch user can drag or swipe it, a keyboard-only user\n * cannot Tab to it and press the arrow keys, since a plain `div` isn't in\n * the tab order by default. This is unconditional rather than toggled on\n * only when the table actually overflows: detecting that needs a\n * ResizeObserver, which is exactly the behavior layer this \"primitive\n * markup\" component intentionally does not have. The trade-off is a table\n * that never overflows still gets one extra, functionless tab stop — minor\n * next to the alternative of a table that does overflow being silently\n * unreachable.\n *\n * A focus stop should announce something: `label` names the wrapper\n * (`role=\"region\"` + `aria-label` — a bare div's aria-label is ignored\n * without a role, which is also why wrapping the Table yourself and\n * labelling that wrapper doesn't work: the name lands on a non-focusable\n * element while the focusable one stays nameless). Without `label` the\n * wrapper stays roleless and nameless as before — prefer passing it\n * whenever the surrounding page doesn't already make the table's purpose\n * obvious the moment focus lands.\n */\nconst tableVariants = cva(styles.table, {\n variants: {\n /*\n * `collection` is the spec's own guide word for the dense arrangement:\n * a fixed layout with a sticky header and tall, wrapping rows. The\n * density axis below is orthogonal to it and still applies.\n */\n variant: {\n default: styles.variantDefault,\n collection: styles.variantCollection,\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nexport interface TableProps extends ComponentProps<'table'>, VariantProps<typeof tableVariants> {\n /**\n * Accessible name for the focusable scroll wrapper around the table\n * (`role=\"region\"` + `aria-label`). Announced when keyboard focus lands\n * on the wrapper; without it the stop announces nothing.\n */\n label?: string;\n /**\n * Cell metrics only — `compact` tightens row padding for operational\n * views (the mockups' Data Table density axis). Not a data-table\n * feature: no virtualization, no row model, purely the cells' padding.\n */\n density?: 'default' | 'compact';\n /**\n * className for the scroll wrapper around the table, merged after the\n * kit class. Give it a `max-height` to scroll the table vertically inside\n * the wrapper, which is what keeps a sticky header in place.\n */\n containerClassName?: string;\n /** Inline style for the same scroll wrapper, e.g. `{ maxHeight: 320 }`. */\n containerStyle?: CSSProperties;\n /**\n * Ref to the scroll wrapper `div`, for a caller that measures it or drives\n * its scroll position (`ref` itself lands on the `<table>`, as for every\n * other prop). Both a ref object and a callback ref work.\n */\n containerRef?: Ref<HTMLDivElement>;\n /**\n * Pins the header cells to the top of the scroll wrapper on an opaque\n * fill, so the rows scroll under them. Needs a bounded wrapper height\n * (`containerClassName` / `containerStyle`) to have anything to scroll\n * within. Independent of `variant`: it carries no layout, row height or\n * minimum width, only the pinning, and switches the table to separated\n * borders so the rule under the header stays with it.\n * @default false\n */\n stickyHeader?: boolean;\n}\n\nexport function Table({\n className,\n label,\n density,\n variant,\n containerClassName,\n containerStyle,\n containerRef,\n stickyHeader,\n ...props\n}: TableProps) {\n return (\n <div\n ref={containerRef}\n className={cx(styles.tableContainer, containerClassName)}\n style={containerStyle}\n tabIndex={0}\n role={label === undefined ? undefined : 'region'}\n aria-label={label}\n >\n <table\n className={tableVariants({\n variant,\n className: cx(\n density === 'compact' && styles.densityCompact,\n stickyHeader && styles.stickyHeader,\n className,\n ),\n })}\n {...props}\n />\n </div>\n );\n}\n\nexport type TableHeaderProps = ComponentProps<'thead'>;\n\nexport function TableHeader({ className, ...props }: TableHeaderProps) {\n return <thead className={cx(styles.tableHeader, className)} {...props} />;\n}\n\nexport type TableBodyProps = ComponentProps<'tbody'>;\n\nexport function TableBody({ className, ...props }: TableBodyProps) {\n return <tbody className={cx(styles.tableBody, className)} {...props} />;\n}\n\nexport type TableFooterProps = ComponentProps<'tfoot'>;\n\nexport function TableFooter({ className, ...props }: TableFooterProps) {\n return <tfoot className={cx(styles.tableFooter, className)} {...props} />;\n}\n\nexport type TableRowProps = ComponentProps<'tr'>;\n\nexport function TableRow({ className, ...props }: TableRowProps) {\n return <tr className={cx(styles.tableRow, className)} {...props} />;\n}\n\nexport interface TableHeadProps extends ComponentProps<'th'> {\n /**\n * Renders a draggable, keyboard-resizable handle on the column's trailing\n * edge. Off by default: the spec's own default is on, but turning it on\n * here would make every column of every shipped table draggable without\n * the caller asking for it.\n */\n resizable?: boolean;\n /**\n * Pixel floor for this column while resizing, overriding the 72 / 32\n * defaults (72 for a column carrying text, 32 for one that does not).\n */\n resizeMinWidth?: number;\n}\n\nexport function TableHead({\n className,\n resizable,\n resizeMinWidth,\n children,\n ...props\n}: TableHeadProps) {\n return (\n <th className={cx(styles.tableHead, className)} {...props}>\n {children}\n {resizable ? <TableColumnResizer minWidth={resizeMinWidth} /> : null}\n </th>\n );\n}\n\nexport type TableCellProps = ComponentProps<'td'>;\n\nexport function TableCell({ className, ...props }: TableCellProps) {\n return <td className={cx(styles.tableCell, className)} {...props} />;\n}\n\n/**\n * A table's accessible name/description, kept as a real semantic caption\n * regardless of where it's drawn — `.table`'s `caption-side: bottom` (see\n * table.module.css) only moves it visually below the rows; a `<caption>`\n * contributes to the table's accessibility tree the same way at either\n * position.\n */\nexport type TableCaptionProps = ComponentProps<'caption'>;\n\nexport function TableCaption({ className, ...props }: TableCaptionProps) {\n return <caption className={cx(styles.tableCaption, className)} {...props} />;\n}\n"],"names":["KEYBOARD_STEP","HANDLE_WIDTH","MIN_WIDTH_WITH_TEXT","MIN_WIDTH_WITHOUT_TEXT","headerCellsOf","cell","_a","child","minWidthOf","override","freezeColumns","cells","table","column","pinTableWidth","frozenWidthOf","sum","minSelfOf","index","widthOf","self","own","tableFloor","others","applyWidths","selfStart","neighbourStart","delta","minSelf","minNeighbour","neighbour","ceiling","next","TableColumnResizer","minWidth","handleRef","useRef","dragRef","columnName","setColumnName","useState","width","setWidth","bounds","setBounds","measure","useCallback","now","renderedWidthOf","_b","announced","useEffect","_c","valueNow","valueMin","valueMax","lockPage","locked","capturePointer","handle","pointerId","capture","endDrag","drag","onPointerDown","event","onPointerMove","onKeyDown","step","jsx","styles","tableVariants","cva","Table","className","label","density","variant","containerClassName","containerStyle","containerRef","stickyHeader","props","cx","TableHeader","TableBody","TableFooter","TableRow","TableHead","resizable","resizeMinWidth","children","jsxs","TableCell","TableCaption"],"mappings":";;;;;;;;;;;;;;;;;;;GAwBMA,IAAgB,IAEhBC,IAAe,GAEfC,KAAsB,IAEtBC,KAAyB;AAE/B,SAASC,EAAcC,GAAoD;;AACzE,SAAO,MAAM,OAAKC,IAAAD,EAAK,kBAAL,gBAAAC,EAAoB,aAAY,CAAA,CAAE,EAAE;AAAA,IACpD,CAACC,MAAyCA,aAAiB;AAAA,EAAA;AAE/D;AAEA,SAASC,EAAWH,GAA4BI,GAAsC;;AACpF,SAAIA,MAAa,SACRA,KAEFH,IAAAD,EAAK,gBAAL,QAAAC,EAAkB,SAASJ,KAAsBC;AAC1D;AAQA,SAASO,EAAcL,GAAoD;AACzE,QAAMM,IAAQP,EAAcC,CAAI,GAC1BO,IAAQP,EAAK,QAAQ,OAAO;AAClC,MAAIO,KAASA,EAAM,MAAM,gBAAgB,SAAS;AAChD,eAAWC,KAAUF;AACnB,MAAAE,EAAO,MAAM,QAAQ,GAAG,KAAK,MAAMA,EAAO,sBAAA,EAAwB,KAAK,CAAC;AAE1E,IAAAD,EAAM,MAAM,cAAc,SAC1BE,EAAcH,CAAK;AAAA,EACrB;AACA,SAAOA;AACT;AAEA,SAASI,EAAcV,GAAoC;AACzD,SAAO,OAAO,WAAWA,EAAK,MAAM,KAAK,KAAK;AAChD;AAUA,SAASS,EAAcH,GAAqC;;AAC1D,QAAMC,KAAQN,IAAAK,EAAM,CAAC,MAA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ources":["../src/components/table/table.tsx"],"sourcesContent":["'use client';\n\nimport { cva, cx, type VariantProps } from 'class-variance-authority';\nimport {\n type ComponentProps,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n type Ref,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from 'react';\n\nimport styles from './table.module.css';\n\n/*\n * Resize behaviour constants. These are not style values: they decide how\n * the drag RESPONDS, not how anything looks, so they live here rather than\n * as unexplained numbers in the stylesheet. All four are the design spec's\n * own.\n */\n/** How far one arrow-key press moves the boundary. */\nconst KEYBOARD_STEP = 12;\n/** The grab area straddling the column's trailing edge, half on each side. */\nconst HANDLE_WIDTH = 8;\n/** A column carrying text needs room for a word. */\nconst MIN_WIDTH_WITH_TEXT = 72;\n/** One carrying only a control (a checkbox, a row action) does not. */\nconst MIN_WIDTH_WITHOUT_TEXT = 32;\n\nfunction headerCellsOf(cell: HTMLTableCellElement): HTMLTableCellElement[] {\n return Array.from(cell.parentElement?.children ?? []).filter(\n (child): child is HTMLTableCellElement => child instanceof HTMLTableCellElement,\n );\n}\n\nfunction minWidthOf(cell: HTMLTableCellElement, override: number | undefined): number {\n if (override !== undefined) {\n return override;\n }\n return cell.textContent?.trim() ? MIN_WIDTH_WITH_TEXT : MIN_WIDTH_WITHOUT_TEXT;\n}\n\n/*\n * The first drag freezes every column at the width it currently renders and\n * switches the table to a fixed layout. Without that the browser keeps\n * re-deriving every column from its content, so widening one column silently\n * reflows the rest and the drag does not hold.\n */\nfunction freezeColumns(cell: HTMLTableCellElement): HTMLTableCellElement[] {\n const cells = headerCellsOf(cell);\n const table = cell.closest('table');\n if (table && table.style.tableLayout !== 'fixed') {\n for (const column of cells) {\n column.style.width = `${Math.round(column.getBoundingClientRect().width)}px`;\n }\n table.style.tableLayout = 'fixed';\n pinTableWidth(cells);\n }\n return cells;\n}\n\nfunction frozenWidthOf(cell: HTMLTableCellElement): number {\n return Number.parseFloat(cell.style.width) || 0;\n}\n\n/*\n * A fixed layout still stretches its columns to the table's own width, and\n * `.table` is `width: 100%`: left alone, whatever a column gives up is handed\n * straight back to the others, which is why the last column could never be\n * narrowed. Pinning the table to the sum of its frozen columns makes the\n * columns the only thing deciding its width, so it can end up narrower than\n * its container or wider than it (the wrapper then scrolls).\n */\nfunction pinTableWidth(cells: HTMLTableCellElement[]): void {\n const table = cells[0]?.closest('table');\n if (table) {\n table.style.width = `${cells.reduce((sum, column) => sum + frozenWidthOf(column), 0)}px`;\n }\n}\n\n/*\n * The floor a dragged column resizes against. Only the last column can\n * change the table's width, so only the last one also has to respect a\n * `min-width` on the table (the collection view's 960px): below that the\n * browser would widen the table back and spread the difference over every\n * column, and the width the handle announced would no longer be the one on\n * screen.\n */\nfunction minSelfOf(\n cells: HTMLTableCellElement[],\n index: number,\n override: number | undefined,\n widthOf: (cell: HTMLTableCellElement) => number = frozenWidthOf,\n): number {\n const self = cells[index];\n if (!self) {\n return 0;\n }\n const own = minWidthOf(self, override);\n const table = self.closest('table');\n if (index !== cells.length - 1 || !table) {\n return own;\n }\n const tableFloor = Number.parseFloat(getComputedStyle(table).minWidth);\n if (!Number.isFinite(tableFloor)) {\n return own;\n }\n const others = cells.slice(0, index).reduce((sum, column) => sum + widthOf(column), 0);\n return Math.max(own, Math.ceil(tableFloor - others));\n}\n\n/*\n * A column resizes against its TRAILING neighbour: the pair's combined width\n * is what stays constant, so dragging an inner boundary never changes the\n * table's own width. The last column has no neighbour to trade with, and\n * there the table's pinned width (see pinTableWidth) follows it in both\n * directions.\n */\nfunction applyWidths(\n cells: HTMLTableCellElement[],\n index: number,\n selfStart: number,\n neighbourStart: number | null,\n delta: number,\n minSelf: number,\n minNeighbour: number,\n): number {\n const self = cells[index];\n if (!self) {\n return selfStart;\n }\n const neighbour = neighbourStart === null ? null : cells[index + 1];\n const ceiling =\n neighbourStart === null || !neighbour\n ? Number.POSITIVE_INFINITY\n : selfStart + neighbourStart - minNeighbour;\n const next = Math.round(Math.min(Math.max(selfStart + delta, minSelf), ceiling));\n self.style.width = `${next}px`;\n if (neighbour && neighbourStart !== null) {\n neighbour.style.width = `${selfStart + neighbourStart - next}px`;\n }\n pinTableWidth(cells);\n return next;\n}\n\ninterface DragState {\n pointerId: number;\n startX: number;\n cells: HTMLTableCellElement[];\n index: number;\n selfStart: number;\n neighbourStart: number | null;\n minSelf: number;\n minNeighbour: number;\n}\n\ninterface TableColumnResizerProps {\n minWidth?: number;\n}\n\n/*\n * The trailing-edge resize handle. Rendered inside its own <th>, which is\n * what it measures and resizes; the geometry it needs from JS (the grab\n * width and its half-overhang) comes from HANDLE_WIDTH above, and the\n * hairline it draws is the stylesheet's.\n */\nfunction TableColumnResizer({ minWidth }: TableColumnResizerProps) {\n const handleRef = useRef<HTMLSpanElement>(null);\n const dragRef = useRef<DragState | null>(null);\n const [columnName, setColumnName] = useState('');\n const [width, setWidth] = useState<number | null>(null);\n // The column's width and its bounds as the handle reports them: a\n // focusable separator is a widget, and assistive technology reads its\n // value from aria-valuenow (axe `aria-required-attr` without it). Read at\n // mount and again whenever the handle takes focus, since dragging a\n // neighbour's handle changes this column too; `width` above takes over\n // while this handle resizes. The floor is the one the resize clamps to.\n const [bounds, setBounds] = useState<{ now: number; min: number; max: number } | null>(null);\n\n const measure = useCallback(() => {\n const cell = handleRef.current?.closest('th');\n if (!(cell instanceof HTMLTableCellElement)) {\n return;\n }\n const cells = headerCellsOf(cell);\n const now = Math.round(cell.getBoundingClientRect().width);\n // Before the first resize no column has an inline width yet, so the\n // floor reads each other column's rendered width, as the drag will once\n // it freezes them.\n const renderedWidthOf = (column: HTMLTableCellElement) =>\n frozenWidthOf(column) || column.getBoundingClientRect().width;\n setBounds({\n now,\n min: Math.round(minSelfOf(cells, cells.indexOf(cell), minWidth, renderedWidthOf)),\n max: Math.round(cell.closest('table')?.getBoundingClientRect().width ?? 0),\n });\n // A width already announced follows the column (a neighbour's drag may\n // have changed it); a focus that starts a drag keeps the drag's own.\n if (!dragRef.current) {\n setWidth((announced) => (announced === null ? null : now));\n }\n }, [minWidth]);\n\n useEffect(() => {\n setColumnName(handleRef.current?.closest('th')?.textContent?.trim() ?? '');\n measure();\n }, [measure]);\n\n // Kept inside [min, max]: a column the layout squeezed below its floor\n // reports its real width, and the minimum is lowered to it rather than\n // announced above the value.\n const valueNow = width ?? bounds?.now ?? 0;\n const valueMin = Math.min(bounds?.min ?? 0, valueNow);\n const valueMax = Math.max(bounds?.max ?? 0, valueNow);\n\n /*\n * The cursor and the text selection are locked for the DURATION of the\n * drag, not for the pointer's position: without it, dragging past the\n * handle turns the pointer back into a caret and starts selecting the\n * header labels it crosses.\n */\n const lockPage = (locked: boolean) => {\n document.body.style.cursor = locked ? 'col-resize' : '';\n document.body.style.userSelect = locked ? 'none' : '';\n };\n\n /*\n * Pointer capture is what keeps the drag alive once the pointer leaves\n * the 8px handle, but it is not what the drag depends on: a pointer id\n * the platform does not consider active throws, and the drag still has to\n * work. Both calls are therefore best-effort, and the drag's own state is\n * the ref above.\n */\n const capturePointer = (handle: HTMLSpanElement, pointerId: number, capture: boolean) => {\n try {\n if (capture) {\n handle.setPointerCapture(pointerId);\n } else if (handle.hasPointerCapture(pointerId)) {\n handle.releasePointerCapture(pointerId);\n }\n } catch {\n // No capture to take or give back; the drag is unaffected either way.\n }\n };\n\n /*\n * Only a drag this handle started may release the lock: the unmount\n * cleanup and a stray pointerup both land here, and clearing the body\n * styles unconditionally would wipe a cursor something else on the page\n * had set.\n */\n const endDrag = useCallback(() => {\n const drag = dragRef.current;\n if (!drag) {\n return;\n }\n dragRef.current = null;\n lockPage(false);\n const handle = handleRef.current;\n if (handle) {\n capturePointer(handle, drag.pointerId, false);\n }\n }, []);\n\n // Releases the lock if the header unmounts mid-drag: the page would\n // otherwise keep the resize cursor and the suppressed selection forever.\n useEffect(() => endDrag, [endDrag]);\n\n const onPointerDown = (event: ReactPointerEvent<HTMLSpanElement>) => {\n const cell = event.currentTarget.closest('th');\n if (!(cell instanceof HTMLTableCellElement) || event.button !== 0) {\n return;\n }\n const cells = freezeColumns(cell);\n const index = cells.indexOf(cell);\n const neighbour = cells[index + 1] ?? null;\n dragRef.current = {\n pointerId: event.pointerId,\n startX: event.clientX,\n cells,\n index,\n selfStart: cell.getBoundingClientRect().width,\n neighbourStart: neighbour ? neighbour.getBoundingClientRect().width : null,\n minSelf: minSelfOf(cells, index, minWidth),\n minNeighbour: neighbour ? minWidthOf(neighbour, undefined) : 0,\n };\n capturePointer(event.currentTarget, event.pointerId, true);\n lockPage(true);\n setWidth(Math.round(dragRef.current.selfStart));\n };\n\n const onPointerMove = (event: ReactPointerEvent<HTMLSpanElement>) => {\n const drag = dragRef.current;\n if (!drag || drag.pointerId !== event.pointerId) {\n return;\n }\n setWidth(\n applyWidths(\n drag.cells,\n drag.index,\n drag.selfStart,\n drag.neighbourStart,\n event.clientX - drag.startX,\n drag.minSelf,\n drag.minNeighbour,\n ),\n );\n };\n\n const onKeyDown = (event: ReactKeyboardEvent<HTMLSpanElement>) => {\n const step =\n event.key === 'ArrowLeft' ? -KEYBOARD_STEP : event.key === 'ArrowRight' ? KEYBOARD_STEP : 0;\n if (step === 0) {\n return;\n }\n const cell = event.currentTarget.closest('th');\n if (!(cell instanceof HTMLTableCellElement)) {\n return;\n }\n event.preventDefault();\n const cells = freezeColumns(cell);\n const index = cells.indexOf(cell);\n const neighbour = cells[index + 1] ?? null;\n setWidth(\n applyWidths(\n cells,\n index,\n cell.getBoundingClientRect().width,\n neighbour ? neighbour.getBoundingClientRect().width : null,\n step,\n minSelfOf(cells, index, minWidth),\n neighbour ? minWidthOf(neighbour, undefined) : 0,\n ),\n );\n };\n\n return (\n <span\n ref={handleRef}\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={`${columnName || 'Column'} width${width === null ? '' : `, ${width} pixels`}`}\n aria-valuenow={valueNow}\n aria-valuemin={valueMin}\n aria-valuemax={valueMax}\n onFocus={measure}\n tabIndex={0}\n className={styles.columnResizer}\n style={{ width: HANDLE_WIDTH, insetInlineEnd: -HANDLE_WIDTH / 2 }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={endDrag}\n onPointerCancel={endDrag}\n onKeyDown={onKeyDown}\n />\n );\n}\n\n/*\n * Table has no Base UI primitive (registry/base-vega ships plain native\n * elements with data-slot markers, this kit drops data-slot everywhere —\n * see card.tsx) — pure styling translation over native `<table>` markup,\n * per design-notes.md: a composite data-table (sorting, filtering,\n * pagination, virtualisation, column defs) is deliberately out of scope\n * here. This is styled markup, nothing more.\n *\n * Table renders two elements, matching the source exactly: its own\n * scroll wrapper div around the <table>, rather than asking every consumer\n * to remember to add one. That wrapper is also the one to cap the table's\n * height with (`containerClassName` / `containerStyle`), not a div of the\n * consumer's own around <Table>: a sticky header sticks to its NEAREST\n * scrolling ancestor, and since the wrapper already scrolls horizontally it\n * is that ancestor. An outer div would scroll while the wrapper, having no\n * height of its own, never did, and the sticky header would scroll away\n * with the rows. `containerRef` reaches the same element for a caller that\n * measures it or drives its scroll.\n *\n * That wrapper is `tabIndex={0}`, a deliberate addition over the source,\n * which has none. A horizontally-overflowing region with no scrollbar\n * dragging alternative is otherwise unreachable from the keyboard (WCAG\n * 2.1.1) — a mouse/touch user can drag or swipe it, a keyboard-only user\n * cannot Tab to it and press the arrow keys, since a plain `div` isn't in\n * the tab order by default. This is unconditional rather than toggled on\n * only when the table actually overflows: detecting that needs a\n * ResizeObserver, which is exactly the behavior layer this \"primitive\n * markup\" component intentionally does not have. The trade-off is a table\n * that never overflows still gets one extra, functionless tab stop — minor\n * next to the alternative of a table that does overflow being silently\n * unreachable.\n *\n * A focus stop should announce something: `label` names the wrapper\n * (`role=\"region\"` + `aria-label` — a bare div's aria-label is ignored\n * without a role, which is also why wrapping the Table yourself and\n * labelling that wrapper doesn't work: the name lands on a non-focusable\n * element while the focusable one stays nameless). Without `label` the\n * wrapper stays roleless and nameless as before — prefer passing it\n * whenever the surrounding page doesn't already make the table's purpose\n * obvious the moment focus lands.\n */\nconst tableVariants = cva(styles.table, {\n variants: {\n /*\n * `collection` is the spec's own guide word for the dense arrangement:\n * a fixed layout with a sticky header and tall, wrapping rows. The\n * density axis below is orthogonal to it and still applies.\n */\n variant: {\n default: styles.variantDefault,\n collection: styles.variantCollection,\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\nexport interface TableProps extends ComponentProps<'table'>, VariantProps<typeof tableVariants> {\n /**\n * Accessible name for the focusable scroll wrapper around the table\n * (`role=\"region\"` + `aria-label`). Announced when keyboard focus lands\n * on the wrapper; without it the stop announces nothing.\n */\n label?: string;\n /**\n * Cell metrics only — `compact` tightens row padding for operational\n * views (the mockups' Data Table density axis). Not a data-table\n * feature: no virtualization, no row model, purely the cells' padding.\n */\n density?: 'default' | 'compact';\n /**\n * className for the scroll wrapper around the table, merged after the\n * kit class. Give it a `max-height` to scroll the table vertically inside\n * the wrapper, which is what keeps a sticky header in place.\n */\n containerClassName?: string;\n /** Inline style for the same scroll wrapper, e.g. `{ maxHeight: 320 }`. */\n containerStyle?: CSSProperties;\n /**\n * Ref to the scroll wrapper `div`, for a caller that measures it or drives\n * its scroll position (`ref` itself lands on the `<table>`, as for every\n * other prop). Both a ref object and a callback ref work.\n */\n containerRef?: Ref<HTMLDivElement>;\n /**\n * Pins the header cells to the top of the scroll wrapper on an opaque\n * fill, so the rows scroll under them. Needs a bounded wrapper height\n * (`containerClassName` / `containerStyle`) to have anything to scroll\n * within. Independent of `variant`: it carries no layout, row height or\n * minimum width, only the pinning, and switches the table to separated\n * borders so the rule under the header stays with it.\n * @default false\n */\n stickyHeader?: boolean;\n}\n\nexport function Table({\n className,\n label,\n density,\n variant,\n containerClassName,\n containerStyle,\n containerRef,\n stickyHeader,\n ...props\n}: TableProps) {\n return (\n <div\n ref={containerRef}\n className={cx(styles.tableContainer, containerClassName)}\n style={containerStyle}\n tabIndex={0}\n role={label === undefined ? undefined : 'region'}\n aria-label={label}\n >\n <table\n className={tableVariants({\n variant,\n className: cx(\n density === 'compact' && styles.densityCompact,\n stickyHeader && styles.stickyHeader,\n className,\n ),\n })}\n {...props}\n />\n </div>\n );\n}\n\nexport type TableHeaderProps = ComponentProps<'thead'>;\n\nexport function TableHeader({ className, ...props }: TableHeaderProps) {\n return <thead className={cx(styles.tableHeader, className)} {...props} />;\n}\n\nexport type TableBodyProps = ComponentProps<'tbody'>;\n\nexport function TableBody({ className, ...props }: TableBodyProps) {\n return <tbody className={cx(styles.tableBody, className)} {...props} />;\n}\n\nexport type TableFooterProps = ComponentProps<'tfoot'>;\n\nexport function TableFooter({ className, ...props }: TableFooterProps) {\n return <tfoot className={cx(styles.tableFooter, className)} {...props} />;\n}\n\nexport type TableRowProps = ComponentProps<'tr'>;\n\nexport function TableRow({ className, ...props }: TableRowProps) {\n return <tr className={cx(styles.tableRow, className)} {...props} />;\n}\n\nexport interface TableHeadProps extends ComponentProps<'th'> {\n /**\n * Pins the cell to an inline edge so the other columns scroll under it. The offset is the\n * caller's: give `insetInlineStart` or `insetInlineEnd` in `style`. See `TableCellProps.pinned`.\n * @default false\n */\n pinned?: boolean;\n /**\n * Renders a draggable, keyboard-resizable handle on the column's trailing\n * edge. Off by default: the spec's own default is on, but turning it on\n * here would make every column of every shipped table draggable without\n * the caller asking for it.\n */\n resizable?: boolean;\n /**\n * Pixel floor for this column while resizing, overriding the 72 / 32\n * defaults (72 for a column carrying text, 32 for one that does not).\n */\n resizeMinWidth?: number;\n}\n\nexport function TableHead({\n className,\n pinned,\n resizable,\n resizeMinWidth,\n children,\n ...props\n}: TableHeadProps) {\n return (\n <th className={cx(styles.tableHead, pinned && styles.pinned, className)} {...props}>\n {children}\n {resizable ? <TableColumnResizer minWidth={resizeMinWidth} /> : null}\n </th>\n );\n}\n\nexport interface TableCellProps extends ComponentProps<'td'> {\n /**\n * Pins the cell to an inline edge, for a column that stays in view while the rest of a table\n * wider than its wrapper scrolls under it. Table makes the cell sticky, stacks it above the\n * cells beneath and fills it with the row's own fill over an opaque base (`--table-pinned-fill`,\n * `--card` by default), so it follows hover, `data-state` and the rest of the row. The offset is\n * the caller's: a column pins at the sum of the widths pinned before it, which only the caller\n * knows, so give `insetInlineStart` or `insetInlineEnd` in `style`.\n * @default false\n */\n pinned?: boolean;\n}\n\nexport function TableCell({ className, pinned, ...props }: TableCellProps) {\n return <td className={cx(styles.tableCell, pinned && styles.pinned, className)} {...props} />;\n}\n\n/**\n * A table's accessible name/description, kept as a real semantic caption\n * regardless of where it's drawn — `.table`'s `caption-side: bottom` (see\n * table.module.css) only moves it visually below the rows; a `<caption>`\n * contributes to the table's accessibility tree the same way at either\n * position.\n */\nexport type TableCaptionProps = ComponentProps<'caption'>;\n\nexport function TableCaption({ className, ...props }: TableCaptionProps) {\n return <caption className={cx(styles.tableCaption, className)} {...props} />;\n}\n"],"names":["KEYBOARD_STEP","HANDLE_WIDTH","MIN_WIDTH_WITH_TEXT","MIN_WIDTH_WITHOUT_TEXT","headerCellsOf","cell","_a","child","minWidthOf","override","freezeColumns","cells","table","column","pinTableWidth","frozenWidthOf","sum","minSelfOf","index","widthOf","self","own","tableFloor","others","applyWidths","selfStart","neighbourStart","delta","minSelf","minNeighbour","neighbour","ceiling","next","TableColumnResizer","minWidth","handleRef","useRef","dragRef","columnName","setColumnName","useState","width","setWidth","bounds","setBounds","measure","useCallback","now","renderedWidthOf","_b","announced","useEffect","_c","valueNow","valueMin","valueMax","lockPage","locked","capturePointer","handle","pointerId","capture","endDrag","drag","onPointerDown","event","onPointerMove","onKeyDown","step","jsx","styles","tableVariants","cva","Table","className","label","density","variant","containerClassName","containerStyle","containerRef","stickyHeader","props","cx","TableHeader","TableBody","TableFooter","TableRow","TableHead","pinned","resizable","resizeMinWidth","children","jsxs","TableCell","TableCaption"],"mappings":";;;;;;;;;;;;;;;;;;;;GAwBMA,IAAgB,IAEhBC,IAAe,GAEfC,KAAsB,IAEtBC,KAAyB;AAE/B,SAASC,EAAcC,GAAoD;;AACzE,SAAO,MAAM,OAAKC,IAAAD,EAAK,kBAAL,gBAAAC,EAAoB,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O,UAAUI,CAAS,GAAI,GAAGQ,GAAO;AACnE;AAuBO,SAASM,GAAU;AAAA,EACxB,WAAAd;AAAA,EACA,QAAAe;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGV;AACL,GAAmB;AACjB,SACE,gBAAAW,EAAC,MAAA,EAAG,WAAWV,EAAGb,EAAO,WAAWmB,KAAUnB,EAAO,QAAQI,CAAS,GAAI,GAAGQ,GAC1E,UAAA;AAAA,IAAAU;AAAA,IACAF,IAAY,gBAAArB,EAACpC,IAAA,EAAmB,UAAU0D,GAAgB,IAAK;AAAA,EAAA,GAClE;AAEJ;AAeO,SAASG,GAAU,EAAE,WAAApB,GAAW,QAAAe,GAAQ,GAAGP,KAAyB;AACzE,SAAO,gBAAAb,EAAC,MAAA,EAAG,WAAWc,EAAGb,EAAO,WAAWmB,KAAUnB,EAAO,QAAQI,CAAS,GAAI,GAAGQ,EAAA,CAAO;AAC7F;AAWO,SAASa,GAAa,EAAE,WAAArB,GAAW,GAAGQ,KAA4B;AACvE,SAAO,gBAAAb,EAAC,aAAQ,WAAWc,EAAGb,EAAO,cAAcI,CAAS,GAAI,GAAGQ,GAAO;AAC5E;"}
package/llms.txt CHANGED
@@ -222,13 +222,15 @@ Rules for generated code:
222
222
  menu (ContextMenu/ContextMenuTrigger/ContextMenuContent + the same
223
223
  item/checkbox/radio/submenu parts as DropdownMenu); always modal, no
224
224
  hover-open; opens at the pointer position.
225
- - [DataGrid](dist/docs/data-grid.md): server-driven data grid (`DataGrid`
226
- with a `load(ctx)` callback, `columns`, a slot-based layout and
227
- `createDataGridPlugin`) rendered on `Table`; the built-in plugins are
228
- opt-in entries of their own - pagination, text search, ordering, filters
229
- and a custom empty state, imported from `@gears-frontx/ui-kit/data-grid/<plugin>`
230
- or the package root; state can persist to local/session storage, the URL
231
- or memory.
225
+ - [DataGrid](dist/docs/data-grid.md): server-driven data grid
226
+ (`DataGrid` with a `load(ctx)` callback, `columns`, a slot-based
227
+ layout and `createDataGridPlugin`) rendered on `Table`; the built-in
228
+ plugins are opt-in entries of their own - pagination, text search,
229
+ ordering, filters, a custom empty state, row numbers, row click, a
230
+ toolbar actions slot, a row actions column, an actions menu, a column
231
+ configuration popover and row selection with a bulk-action bar,
232
+ imported from `@gears-frontx/ui-kit/data-grid/<plugin>` or the package
233
+ root; state can persist to local/session storage, the URL or memory.
232
234
  - [DataTable](dist/docs/data-table.md): sortable, paginated, optionally
233
235
  row-selectable table built on `Table` + `@tanstack/react-table` v9;
234
236
  productizes upstream's data-table *guide* into a real component
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gears-frontx/ui-kit",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Standard React component base for FrontX templates - Base UI behavior, CSS Modules styling on semantic tokens, CVA variants",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- ._delayed_1ys81_5{display:inline-flex;animation:_appear_1ys81_1 .5s forwards;animation-delay:.4s;opacity:0}@keyframes _appear_1ys81_1{to{opacity:1}}._root_9f4nk_13{position:relative;box-sizing:border-box;display:flex;flex-direction:column;flex-grow:1;min-block-size:0}._loaderOverlay_3znr7_29{position:absolute;z-index:4;display:flex;align-items:center;justify-content:center;animation:_appear_3znr7_1 .5s forwards;animation-delay:.4s;background-color:color-mix(in srgb,var(--surface) 75%,transparent);cursor:default;top:0;right:0;bottom:0;left:0;opacity:0;pointer-events:none}@keyframes _appear_3znr7_1{to{opacity:1;pointer-events:auto}}._emptyState_1tt1k_3{flex:none;margin:auto}._dataGridLayoutMain_ta8be_5{display:flex;overflow:auto;flex-direction:column;flex-grow:1;align-self:stretch;contain:inline-size}._dataGridTopDefault_5t4tt_1{display:flex;flex-wrap:wrap;align-items:center;row-gap:var(--space-2);margin-block-end:var(--space-2);min-inline-size:0}._topStartSlots_5t4tt_16{display:flex;flex:1 1 auto;flex-wrap:wrap;align-items:center;gap:var(--space-2);min-inline-size:0}._topStartSlot_5t4tt_16,._topEndSlot_5t4tt_32{display:contents}._topEndSlots_5t4tt_36{display:flex;flex-shrink:0;align-items:center;gap:var(--space-2);margin-inline-start:auto}._center_s4klt_3{flex:none;margin:auto}._cell_5zgpa_2:first-child{border-inline-start:var(--_data-grid-table-group-border, 0 solid transparent)}._cell_5zgpa_2:last-child{border-inline-end:var(--_data-grid-table-group-border, 0 solid transparent)}._stickyCell_5zgpa_16{position:sticky;z-index:1;background-color:var(--surface)}tbody tr:hover>._stickyCell_5zgpa_16{background-color:var(--card-hover)}._cell_5zgpa_2._stickyCell_5zgpa_16._stickyHeaderCell_5zgpa_33{z-index:3}._contentRow_5zgpa_38{display:flex;align-items:center;inline-size:min-content;min-block-size:var(--space-6)}[data-overflow=nowrap] ._contentRow_5zgpa_38,[data-capped] ._contentRow_5zgpa_38{max-inline-size:100%}[data-overflow=wrap] ._contentRow_5zgpa_38,[data-header-fill] ._contentRow_5zgpa_38{inline-size:100%}[data-header-fill] ._content_5zgpa_37{flex:1 1 auto}._content_5zgpa_37{display:block;min-inline-size:0;white-space:normal}[data-overflow=nowrap] ._content_5zgpa_37{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-inline-size:var(--_data-grid-col-max, none)}[data-capped][data-overflow=wrap] ._content_5zgpa_37{max-inline-size:var(--_data-grid-col-max, none);overflow-wrap:anywhere}._endSlot_5zgpa_37{display:flex;flex-shrink:0;align-items:center;gap:var(--space-1)}._endSlot_5zgpa_37:not(:empty){margin-inline-start:var(--space-1)}._headerCell_18ulc_1{box-sizing:border-box;border-inline-start:var(--_data-grid-table-group-border, 0 solid transparent);border-block-start:var(--_data-grid-header-border-block-start, 0);white-space:nowrap}._headerCellContent_18ulc_13{display:flex;align-items:center;inline-size:min-content;min-block-size:var(--space-6);white-space:nowrap}._extraHeaderCell_18ulc_21{box-sizing:border-box;border-inline-start:var(--_data-grid-table-group-border, 0 solid transparent);border-block-start:var(--_data-grid-header-border-block-start, 0);white-space:nowrap}._tableWrapper_1wbrz_6{contain:inline-size}._table_1wbrz_6{--table-header-fill: var(--data-grid-header-background, var(--card));min-inline-size:var(--data-grid-table-min-inline-size, max-content)}._table_1wbrz_6._layoutFixed_1wbrz_35{border-collapse:separate;border-spacing:0;inline-size:100%;table-layout:fixed}._table_1wbrz_6._layoutAuto_1wbrz_42{border-collapse:separate;border-spacing:0;inline-size:100%;table-layout:auto}._tableBordered_1wbrz_49{--_data-grid-table-group-border: var(--border-width) solid var(--border);--_data-grid-header-border-block-start: var(--border-width) solid var(--border)}._theadSticky_1kkfu_11{position:sticky;z-index:2;inset-block-start:0}
@@ -1 +0,0 @@
1
- ._tableContainer_pfb4y_8{position:relative;width:100%;overflow:auto}._tableContainer_pfb4y_8:focus-visible{outline:var(--border-width-focus) solid var(--ring);outline-offset:2px}@media(forced-colors:active){._tableContainer_pfb4y_8:focus-visible{outline:2px solid Highlight;outline-offset:2px}}._table_pfb4y_8{width:100%;border-collapse:collapse;caption-side:bottom;font-size:var(--text-meta-size);line-height:var(--text-meta-line-height);font-weight:var(--text-meta-weight);letter-spacing:var(--text-meta-tracking)}._stickyHeader_pfb4y_79{border-collapse:separate;border-spacing:0}:where(._stickyHeader_pfb4y_79) ._tableHeader_pfb4y_91 ._tableHead_pfb4y_70{position:sticky;top:0;z-index:2;background-color:var(--table-header-fill, var(--card))}._tableRow_pfb4y_59{--table-row-fill: transparent;background-color:var(--table-row-fill);transition:color .15s ease,background-color .15s ease}._tableBody_pfb4y_147:last-child ._tableRow_pfb4y_59:last-child>*{border-bottom:0}._tableBody_pfb4y_147 ._tableRow_pfb4y_59:hover,._tableBody_pfb4y_147 ._tableRow_pfb4y_59:has([aria-expanded=true]){--table-row-fill: var(--card-hover)}._tableBody_pfb4y_147 ._tableRow_pfb4y_59[data-state=selected]{--table-row-fill: var(--selection-subtle)}._tableBody_pfb4y_147 ._tableRow_pfb4y_59[data-state=stale]{--table-row-fill: var(--warning-soft)}._tableBody_pfb4y_147 ._tableRow_pfb4y_59[data-state=restricted]{--table-row-fill: var(--danger-soft)}._tableHead_pfb4y_70{box-sizing:border-box;position:relative;height:var(--control-height-md);padding:0 var(--space-4);border-bottom:var(--border-width) solid var(--border);text-align:start;vertical-align:middle;font-family:var(--font-mono);font-size:var(--text-mono-size);line-height:var(--text-mono-line-height);font-weight:var(--text-mono-weight);letter-spacing:var(--text-mono-tracking);text-transform:uppercase;white-space:nowrap;color:var(--subtle-foreground)}._tableHead_pfb4y_70:has([role=checkbox]){padding-inline-end:0}._columnResizer_pfb4y_279{position:absolute;top:0;bottom:0;z-index:1;padding:0;border:0;background:none;cursor:col-resize;touch-action:none;outline:none}._columnResizer_pfb4y_279:after{content:"";position:absolute;top:0;bottom:0;left:50%;width:var(--border-width);translate:-50% 0;background-color:var(--border);transition:width var(--duration-micro) var(--ease-standard),background-color var(--duration-micro) var(--ease-standard)}._columnResizer_pfb4y_279:hover:after,._columnResizer_pfb4y_279:focus-visible:after,._columnResizer_pfb4y_279:active:after{width:var(--border-width-focus);background-color:var(--primary)}@media(forced-colors:active){._columnResizer_pfb4y_279:focus-visible:after{background-color:Highlight}}._tableCell_pfb4y_127{box-sizing:border-box;padding:var(--space-3) var(--space-4);height:var(--control-height-lg);border-bottom:var(--border-width) solid var(--border);vertical-align:middle;white-space:nowrap}._tableCell_pfb4y_127:has([role=checkbox]){padding-inline-end:0}._variantCollection_pfb4y_94{table-layout:fixed;min-width:960px}._variantCollection_pfb4y_94 ._tableHead_pfb4y_70{position:sticky;top:0;z-index:2;height:var(--control-height-lg);padding:0 var(--space-3);background-color:var(--card);color:var(--muted-foreground);line-height:16px}._variantCollection_pfb4y_94 ._tableBody_pfb4y_147 ._tableRow_pfb4y_59{height:4rem}._variantCollection_pfb4y_94 ._tableCell_pfb4y_127{height:auto;padding:var(--space-3) var(--space-2);font-size:var(--text-meta-size);line-height:var(--text-meta-line-height);white-space:normal}._variantCollection_pfb4y_94 ._tableBody_pfb4y_147 ._tableRow_pfb4y_59:focus-visible{outline:none;box-shadow:inset 0 0 0 var(--border-width-focus) var(--primary)}._variantCollection_pfb4y_94 ._tableBody_pfb4y_147 ._tableRow_pfb4y_59[tabindex]{cursor:pointer;transition:background-color var(--duration-micro) var(--ease-standard)}._variantCollection_pfb4y_94 ._tableBody_pfb4y_147 ._tableRow_pfb4y_59[data-pending]{--table-row-fill: var(--muted);cursor:progress}._densityCompact_pfb4y_461 ._tableHead_pfb4y_70{height:var(--control-height-sm)}._densityCompact_pfb4y_461 ._tableCell_pfb4y_127{padding-block:var(--space-2);height:auto}._tableCaption_pfb4y_470{margin-top:var(--space-4);font-size:var(--text-body-size);line-height:var(--text-body-line-height);color:var(--muted-foreground)}._tableFooter_pfb4y_492{font-weight:var(--text-label-weight)}._tableFooter_pfb4y_492 ._tableRow_pfb4y_59{--table-row-fill: var(--muted)}._tableFooter_pfb4y_492 ._tableRow_pfb4y_59:last-child>*{border-bottom:0}