asma-ui-core 3.136.2 → 3.137.1

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.
@@ -1,72 +1,83 @@
1
- import { ACTIONS_COLUMN_ID as D, INTERNAL_COLUMN_IDS as R } from "../../types.js";
2
- import { useRootContext as L } from "../../context/RootContext.js";
3
- import { hasFixedWidth as A } from "../../helpers/columnSizingDefaults.js";
4
- import e from "../StyledTable.module.js";
5
- import { SortIndicator as O } from "./SortIndicator.js";
6
- import { getTableHeaderStyle as E } from "../../helpers/getTableHeaderStyle.js";
7
- import { getSortPreview as M } from "../../helpers/sortPreview.js";
1
+ import { ACTIONS_COLUMN_ID as C, INTERNAL_COLUMN_IDS as b } from "../../types.js";
2
+ import { useRootContext as j } from "../../context/RootContext.js";
3
+ import { hasFixedWidth as U } from "../../helpers/columnSizingDefaults.js";
4
+ import t from "../StyledTable.module.js";
5
+ import { StyledTooltip as $ } from "../../shared-components/tooltip/index.js";
6
+ import { headerLabelText as Z } from "../../helpers/headerLabel.js";
7
+ import { SortIndicator as K } from "./SortIndicator.js";
8
+ import { getTableHeaderStyle as W } from "../../helpers/getTableHeaderStyle.js";
9
+ import { getSortPreview as q } from "../../helpers/sortPreview.js";
10
+ import { useHeaderTruncation as J } from "./useHeaderTruncation.js";
8
11
  import _ from "clsx";
9
- import { useMemo as r } from "react";
10
- import { jsx as l, jsxs as k } from "react/jsx-runtime";
11
- import { flexRender as B } from "@tanstack/react-table";
12
- function Z({ styledTableProps: z, header: o, tableCanResize: b = !1, left: N, right: v, tableWidth: H }) {
13
- const { hideHeader: c = !1, enableResizing: m = !1, actions: I, customActionsNode: T } = z, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = L(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === D, h = !!I || !!T, S = r(() => o.headerGroup.headers.some((t) => t.id === D), [o.headerGroup.headers]), w = r(() => o.headerGroup.headers.some((t) => !!t.column.columnDef.fixedRight), [o.headerGroup.headers]), y = r(() => o.headerGroup.headers[o.headerGroup.headers.length - (S ? 2 : 1)], [o.headerGroup.headers, S]), n = o.column.getCanSort(), s = o.column.getIsSorted(), x = o.getContext().table.getState().sorting, F = M({
14
- sorted: s,
12
+ import { useMemo as c, useState as Q } from "react";
13
+ import { jsx as s, jsxs as V } from "react/jsx-runtime";
14
+ import { flexRender as X } from "@tanstack/react-table";
15
+ function po({ styledTableProps: T, header: o, tableCanResize: v = !1, left: N, right: H, tableWidth: I }) {
16
+ const { hideHeader: l = !1, enableResizing: m = !1, actions: w, customActionsNode: y } = T, { isResizing: a, enableResizingFlag: u, disableResizingFlag: d } = j(), g = o.column.columnDef.fixedLeft, f = !!o.column.columnDef.fixedRight, p = o.column.id === C, L = !!w || !!y, S = c(() => o.headerGroup.headers.some((e) => e.id === C), [o.headerGroup.headers]), h = c(() => o.headerGroup.headers.some((e) => !!e.column.columnDef.fixedRight), [o.headerGroup.headers]), F = c(() => o.headerGroup.headers[o.headerGroup.headers.length - (S ? 2 : 1)], [o.headerGroup.headers, S]), n = o.column.getCanSort(), r = o.column.getIsSorted(), x = o.getContext().table.getState().sorting, G = q({
17
+ sorted: r,
15
18
  firstDirection: o.column.getFirstSortDir(),
16
19
  nextOrder: o.column.getNextSortingOrder(),
17
20
  isLastSortEntry: x[x.length - 1]?.id === o.column.id
18
- }), G = n ? s === "asc" ? "ascending" : s === "desc" ? "descending" : "none" : void 0, C = b && (m ? !0 : o.id !== y?.id) && o.column.getCanResize() && !A(o.column.columnDef) && !R.includes(o.column.id);
19
- return /* @__PURE__ */ l("th", {
21
+ }), M = n ? r === "asc" ? "ascending" : r === "desc" ? "descending" : "none" : void 0, R = v && (m ? !0 : o.id !== F?.id) && o.column.getCanResize() && !U(o.column.columnDef) && !b.includes(o.column.id), D = Z(o.column.columnDef), { rowRef: O, labelRef: A, truncated: E } = J(!l && !!D?.trim()), [B, z] = Q(!1), k = E && !o.column.getIsResizing() && !B ? D : "", P = /* @__PURE__ */ V("div", {
22
+ ref: O,
23
+ className: _("flex items-center justify-start", l ? t["hide-table-header"] : t["show-table-header"], n && t["sortable-column"], R && t["has-resize-zone"], o.column.columnDef.className),
24
+ role: n ? "button" : void 0,
25
+ tabIndex: n && !l ? 0 : void 0,
26
+ onClick: (e) => {
27
+ const i = o.column.getToggleSortingHandler();
28
+ !a && i && i(e), d();
29
+ },
30
+ onKeyDown: n ? (e) => {
31
+ if (e.key !== "Enter" && e.key !== " ") return;
32
+ e.preventDefault();
33
+ const i = o.column.getToggleSortingHandler();
34
+ !a && i && i(e), d();
35
+ } : void 0,
36
+ children: [
37
+ /* @__PURE__ */ s("div", {
38
+ ref: A,
39
+ className: t["header-content"],
40
+ children: X(o.column.columnDef.header, o.getContext())
41
+ }),
42
+ n && /* @__PURE__ */ s(K, {
43
+ sorted: r,
44
+ firstDirection: o.column.getFirstSortDir(),
45
+ preview: G
46
+ }),
47
+ R && /* @__PURE__ */ s("div", {
48
+ onMouseEnter: () => z(!0),
49
+ onMouseLeave: () => z(!1),
50
+ onDoubleClick: () => o.column.resetSize(),
51
+ onMouseDown: (e) => {
52
+ e.stopPropagation(), u(), o.getResizeHandler()(e);
53
+ },
54
+ onTouchStart: (e) => {
55
+ e.stopPropagation(), u(), o.getResizeHandler()(e);
56
+ },
57
+ className: `${t.resizer} ${o.column.getIsResizing() ? t.isResizing : ""}`
58
+ })
59
+ ]
60
+ });
61
+ return /* @__PURE__ */ s("th", {
20
62
  colSpan: o.colSpan,
21
- "aria-sort": G,
22
- className: _(e["t-cell"], !R.includes(o.column.id) && o.column.getSize() > 64 && e["data-cell"], o.column.id === "select" && e["select-cell"], c && e["hide-header"], p && e["t-cell__actions"], p && (!h || w) && e["t-cell__actions--no-shadow"], g && e["t-cell__fixed"], f && e["t-cell__fixed-right"]),
63
+ "aria-sort": M,
64
+ className: _(t["t-cell"], !b.includes(o.column.id) && o.column.getSize() > 64 && t["data-cell"], o.column.id === "select" && t["select-cell"], l && t["hide-header"], p && t["t-cell__actions"], p && (!L || h) && t["t-cell__actions--no-shadow"], g && t["t-cell__fixed"], f && t["t-cell__fixed-right"]),
23
65
  style: {
24
- ...E({
66
+ ...W({
25
67
  enableResizing: m,
26
68
  header: o,
27
- tableWidth: H
69
+ tableWidth: I
28
70
  }),
29
71
  ...g && { left: N },
30
- ...f && { right: v }
72
+ ...f && { right: H }
31
73
  },
32
- children: /* @__PURE__ */ k("div", {
33
- className: _("flex items-center justify-start", c ? e["hide-table-header"] : e["show-table-header"], n && e["sortable-column"], C && e["has-resize-zone"], o.column.columnDef.className),
34
- role: n ? "button" : void 0,
35
- tabIndex: n && !c ? 0 : void 0,
36
- onClick: (t) => {
37
- const i = o.column.getToggleSortingHandler();
38
- !a && i && i(t), d();
39
- },
40
- onKeyDown: n ? (t) => {
41
- if (t.key !== "Enter" && t.key !== " ") return;
42
- t.preventDefault();
43
- const i = o.column.getToggleSortingHandler();
44
- !a && i && i(t), d();
45
- } : void 0,
46
- children: [
47
- /* @__PURE__ */ l("div", {
48
- className: e["header-content"],
49
- children: B(o.column.columnDef.header, o.getContext())
50
- }),
51
- n && /* @__PURE__ */ l(O, {
52
- sorted: s,
53
- firstDirection: o.column.getFirstSortDir(),
54
- preview: F
55
- }),
56
- C && /* @__PURE__ */ l("div", {
57
- onDoubleClick: () => o.column.resetSize(),
58
- onMouseDown: (t) => {
59
- t.stopPropagation(), u(), o.getResizeHandler()(t);
60
- },
61
- onTouchStart: (t) => {
62
- t.stopPropagation(), u(), o.getResizeHandler()(t);
63
- },
64
- className: `${e.resizer} ${o.column.getIsResizing() ? e.isResizing : ""}`
65
- })
66
- ]
74
+ children: /* @__PURE__ */ s($, {
75
+ title: k,
76
+ describesTrigger: !1,
77
+ children: P
67
78
  })
68
79
  }, o.id);
69
80
  }
70
81
  export {
71
- Z as TableHeaderCell
82
+ po as TableHeaderCell
72
83
  };
@@ -0,0 +1,35 @@
1
+ import { useEffect as f, useRef as l, useState as g } from "react";
2
+ var v = 20, d = (e) => e.scrollWidth > e.clientWidth, b = (e, t) => {
3
+ if (d(t) || Array.from(t.children).some((r) => r instanceof HTMLElement && d(r))) return !0;
4
+ const s = e.querySelector("[data-sort-state]");
5
+ if (!s) return !1;
6
+ const n = v - s.getBoundingClientRect().width;
7
+ if (n <= 0) return !1;
8
+ const i = getComputedStyle(e);
9
+ return e.getBoundingClientRect().right - parseFloat(i.paddingRight) - parseFloat(i.borderRightWidth) - t.getBoundingClientRect().right < n;
10
+ }, h = (e) => {
11
+ const t = l(null), s = l(null), [n, i] = g(!1);
12
+ return f(() => {
13
+ const r = t.current, o = s.current;
14
+ if (!e || !r || !o || typeof ResizeObserver > "u") return;
15
+ const a = () => i(b(r, o)), u = new ResizeObserver(a);
16
+ u.observe(r), u.observe(o);
17
+ const c = new MutationObserver(a);
18
+ return c.observe(o, {
19
+ attributeFilter: ["style", "class"],
20
+ attributes: !0,
21
+ characterData: !0,
22
+ childList: !0,
23
+ subtree: !0
24
+ }), () => {
25
+ u.disconnect(), c.disconnect();
26
+ };
27
+ }, [e]), {
28
+ rowRef: t,
29
+ labelRef: s,
30
+ truncated: e && n
31
+ };
32
+ };
33
+ export {
34
+ h as useHeaderTruncation
35
+ };
@@ -0,0 +1,4 @@
1
+ var r = (e) => e.pinnedHeaderText ?? (typeof e.header == "string" ? e.header : void 0);
2
+ export {
3
+ r as headerLabelText
4
+ };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.136.2",
6
+ "version": "3.137.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",