asma-ui-core 3.45.1 → 3.46.0

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,22 +1,22 @@
1
1
  import { cn as n } from "../../../helpers/cn.js";
2
- import { resolveSx as T } from "../../../helpers/sx.js";
3
- import { ChevronRightIcon as H } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
- import { ChevronLeftIcon as K } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
5
- import { consumerOverrides as M } from "../../../helpers/classOverride.js";
6
- import { TabsContext as V } from "./TabsContext.js";
7
- import { Children as _, cloneElement as q, isValidElement as z, useCallback as u, useLayoutEffect as F, useMemo as G, useRef as R, useState as E } from "react";
8
- import { jsx as l, jsxs as A } from "react/jsx-runtime";
9
- var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: b = "default", className: x, sx: N, children: y }) => {
10
- const a = R(null), d = R(/* @__PURE__ */ new Map()), [h, O] = E({
2
+ import { resolveSx as M } from "../../../helpers/sx.js";
3
+ import { ChevronRightIcon as V } from "../../icons/chevron-right-icon/ChevronRightIcon.js";
4
+ import { ChevronLeftIcon as _ } from "../../icons/chevron-left-icon/ChevronLeftIcon.js";
5
+ import { consumerOverrides as q } from "../../../helpers/classOverride.js";
6
+ import { TabsContext as z } from "./TabsContext.js";
7
+ import { Children as F, cloneElement as G, isValidElement as J, useCallback as u, useLayoutEffect as Q, useMemo as U, useRef as E, useState as A } from "react";
8
+ import { jsx as l, jsxs as B } from "react/jsx-runtime";
9
+ var I = 120, le = ({ value: i, onChange: m, variant: g = "standard", scrollButtons: w = "auto", centered: j, size: b = "default", className: x, sx: N, children: y }) => {
10
+ const a = E(null), d = E(/* @__PURE__ */ new Map()), [h, O] = A({
11
11
  left: 0,
12
12
  width: 0,
13
13
  disabled: !1
14
- }), [c, W] = E({
14
+ }), [c, W] = A({
15
15
  left: !1,
16
16
  right: !1
17
17
  }), p = g === "scrollable", v = u((e, t) => {
18
18
  t ? d.current.set(e, t) : d.current.delete(e);
19
- }, []), k = u((e, t) => m?.(e, t), [m]), f = u(() => {
19
+ }, []), S = u((e, t) => m?.(e, t), [m]), f = u(() => {
20
20
  const e = d.current.get(i), t = a.current;
21
21
  if (e && O({
22
22
  left: e.offsetLeft,
@@ -30,19 +30,19 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
30
30
  });
31
31
  }
32
32
  }, [i]);
33
- F(() => {
33
+ Q(() => {
34
34
  f();
35
35
  const e = a.current;
36
36
  if (!e) return;
37
37
  const t = new ResizeObserver(f);
38
38
  return t.observe(e), () => t.disconnect();
39
39
  }, [f, y]);
40
- const S = (e) => {
40
+ const k = (e) => {
41
41
  a.current?.scrollBy({
42
42
  left: e,
43
43
  behavior: "smooth"
44
44
  });
45
- }, B = (e) => {
45
+ }, D = (e) => {
46
46
  if (![
47
47
  "ArrowRight",
48
48
  "ArrowLeft",
@@ -55,42 +55,42 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
55
55
  const o = t.findIndex((s) => s === document.activeElement);
56
56
  let r = o;
57
57
  e.key === "ArrowRight" ? r = (o + 1) % t.length : e.key === "ArrowLeft" ? r = (o - 1 + t.length) % t.length : e.key === "Home" ? r = 0 : e.key === "End" && (r = t.length - 1), t[r]?.focus();
58
- }, C = p && w !== !1 && (w === !0 || c.left || c.right), D = M(x, "padding-x"), P = G(() => ({
58
+ }, L = p && w !== !1, R = w === !0, P = L && (R || c.left), T = L && (R || c.right), H = q(x, "padding-x"), K = U(() => ({
59
59
  value: i,
60
60
  size: b,
61
- onSelect: k,
61
+ onSelect: S,
62
62
  register: v
63
63
  }), [
64
64
  i,
65
65
  b,
66
- k,
66
+ S,
67
67
  v
68
- ]), L = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
69
- return /* @__PURE__ */ l(V.Provider, {
70
- value: P,
71
- children: /* @__PURE__ */ A("div", {
72
- className: n("relative flex items-center rounded-t-lg bg-white", !D && "px-4", x),
73
- style: T(N),
68
+ ]), C = "flex h-10 w-10 shrink-0 items-center justify-center self-center rounded-[10%] border border-solid border-delta-500 text-delta-700 transition-colors hover:bg-gama-50 disabled:invisible";
69
+ return /* @__PURE__ */ l(z.Provider, {
70
+ value: K,
71
+ children: /* @__PURE__ */ B("div", {
72
+ className: n("relative flex items-center rounded-t-lg bg-white", !H && "px-4", x),
73
+ style: M(N),
74
74
  children: [
75
- C && /* @__PURE__ */ l("button", {
75
+ P && /* @__PURE__ */ l("button", {
76
76
  type: "button",
77
77
  "aria-label": "scroll tabs left",
78
- className: n(L, "mr-2"),
78
+ className: n(C, "mr-2"),
79
79
  disabled: !c.left,
80
- onClick: () => S(-I),
81
- children: /* @__PURE__ */ l(K, {
80
+ onClick: () => k(-I),
81
+ children: /* @__PURE__ */ l(_, {
82
82
  width: 24,
83
83
  height: 24
84
84
  })
85
85
  }),
86
- /* @__PURE__ */ A("div", {
86
+ /* @__PURE__ */ B("div", {
87
87
  ref: a,
88
88
  role: "tablist",
89
89
  "aria-orientation": "horizontal",
90
- onKeyDown: B,
90
+ onKeyDown: D,
91
91
  onScroll: f,
92
92
  className: n("relative flex border-x-0 border-b border-t-0 border-solid border-delta-200 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", p ? "flex-1 overflow-x-auto" : "w-full", g === "fullWidth" && "[&>*]:flex-1", j && "justify-center", b === "small" && "min-h-9"),
93
- children: [_.map(y, (e, t) => z(e) ? q(e, { index: t }) : e), /* @__PURE__ */ l("span", {
93
+ children: [F.map(y, (e, t) => J(e) ? G(e, { index: t }) : e), /* @__PURE__ */ l("span", {
94
94
  "aria-hidden": !0,
95
95
  className: n("absolute bottom-0 h-0.5 transition-all duration-300", h.disabled ? "bg-delta-300" : "bg-gama-500"),
96
96
  style: {
@@ -99,13 +99,13 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
99
99
  }
100
100
  })]
101
101
  }),
102
- C && /* @__PURE__ */ l("button", {
102
+ T && /* @__PURE__ */ l("button", {
103
103
  type: "button",
104
104
  "aria-label": "scroll tabs right",
105
- className: n(L, "ml-2"),
105
+ className: n(C, "ml-2"),
106
106
  disabled: !c.right,
107
- onClick: () => S(I),
108
- children: /* @__PURE__ */ l(H, {
107
+ onClick: () => k(I),
108
+ children: /* @__PURE__ */ l(V, {
109
109
  width: 24,
110
110
  height: 24
111
111
  })
@@ -115,5 +115,5 @@ var I = 120, te = ({ value: i, onChange: m, variant: g = "standard", scrollButto
115
115
  });
116
116
  };
117
117
  export {
118
- te as StyledTabs
118
+ le as StyledTabs
119
119
  };
@@ -1,4 +1,4 @@
1
1
  import { StyledTableProps } from '../types';
2
2
  export declare const injectColumns: <TData extends {
3
3
  id: string | number;
4
- }, TCustomData = Record<string, unknown>>(props: StyledTableProps<TData, TCustomData>) => void;
4
+ }, TCustomData = Record<string, unknown>>(props: StyledTableProps<TData, TCustomData>) => StyledTableProps<TData, TCustomData>["columns"];
@@ -0,0 +1,3 @@
1
+ import { ColumnSizingState, Table } from '@tanstack/react-table';
2
+ export declare const usePersistedColumnSizing: (uniqueKey?: string) => ColumnSizingState | undefined;
3
+ export declare const usePersistColumnSizing: <TData>(table: Table<TData>, uniqueKey?: string) => void;
@@ -1,57 +1,57 @@
1
- var e = "_tbody_v7jow_124", _ = "_expanded_row_v7jow_187", o = "_selected_v7jow_205", l = "_shadowed_v7jow_234", t = "_resizer_v7jow_288", a = "_isResizing_v7jow_300", r = {
2
- "asma-ui-table-styled-table": "_asma-ui-table-styled-table_v7jow_1",
3
- "table-wrapper": "_table-wrapper_v7jow_26",
4
- "table-shell": "_table-shell_v7jow_33",
5
- "table-wrapper--no-rows": "_table-wrapper--no-rows_v7jow_39",
6
- "table-wrapper--proxy": "_table-wrapper--proxy_v7jow_42",
7
- "table-wrapper--proxy-bottom": "_table-wrapper--proxy-bottom_v7jow_43",
8
- "table-wrapper-fetching": "_table-wrapper-fetching_v7jow_53",
9
- "table-scroll": "_table-scroll_v7jow_56",
10
- "table-x--fill-height": "_table-x--fill-height_v7jow_65",
11
- "table-x": "_table-x_v7jow_65",
12
- "table-content": "_table-content_v7jow_80",
13
- "table-header--sticky": "_table-header--sticky_v7jow_85",
14
- "table-hscroll": "_table-hscroll_v7jow_90",
15
- "table-hscroll__content": "_table-hscroll__content_v7jow_100",
16
- "no-rows-overlay-container": "_no-rows-overlay-container_v7jow_103",
17
- "no-rows-overlay-content": "_no-rows-overlay-content_v7jow_111",
18
- "styled-table": "_styled-table_v7jow_115",
1
+ var e = "_tbody_1g04u_124", _ = "_expanded_row_1g04u_187", l = "_selected_1g04u_205", t = "_shadowed_1g04u_234", a = "_resizer_1g04u_288", o = "_isResizing_1g04u_300", r = {
2
+ "asma-ui-table-styled-table": "_asma-ui-table-styled-table_1g04u_1",
3
+ "table-wrapper": "_table-wrapper_1g04u_26",
4
+ "table-shell": "_table-shell_1g04u_33",
5
+ "table-wrapper--no-rows": "_table-wrapper--no-rows_1g04u_39",
6
+ "table-wrapper--proxy": "_table-wrapper--proxy_1g04u_42",
7
+ "table-wrapper--proxy-bottom": "_table-wrapper--proxy-bottom_1g04u_43",
8
+ "table-wrapper-fetching": "_table-wrapper-fetching_1g04u_53",
9
+ "table-scroll": "_table-scroll_1g04u_56",
10
+ "table-x--fill-height": "_table-x--fill-height_1g04u_65",
11
+ "table-x": "_table-x_1g04u_65",
12
+ "table-content": "_table-content_1g04u_80",
13
+ "table-header--sticky": "_table-header--sticky_1g04u_85",
14
+ "table-hscroll": "_table-hscroll_1g04u_90",
15
+ "table-hscroll__content": "_table-hscroll__content_1g04u_100",
16
+ "no-rows-overlay-container": "_no-rows-overlay-container_1g04u_103",
17
+ "no-rows-overlay-content": "_no-rows-overlay-content_1g04u_111",
18
+ "styled-table": "_styled-table_1g04u_115",
19
19
  tbody: e,
20
- "loading-icon": "_loading-icon_v7jow_129",
21
- "t-row": "_t-row_v7jow_136",
22
- "t-cell": "_t-cell_v7jow_136",
23
- "action-cell": "_action-cell_v7jow_146",
24
- "fixed-cell": "_fixed-cell_v7jow_150",
25
- "fixed-right-cell": "_fixed-right-cell_v7jow_153",
20
+ "loading-icon": "_loading-icon_1g04u_129",
21
+ "t-row": "_t-row_1g04u_136",
22
+ "t-cell": "_t-cell_1g04u_136",
23
+ "action-cell": "_action-cell_1g04u_146",
24
+ "fixed-cell": "_fixed-cell_1g04u_150",
25
+ "fixed-right-cell": "_fixed-right-cell_1g04u_153",
26
26
  expanded_row: _,
27
- selected: o,
28
- "single-selection": "_single-selection_v7jow_208",
29
- "action-cell--no-shadow": "_action-cell--no-shadow_v7jow_225",
30
- "action-cell--not-fixed": "_action-cell--not-fixed_v7jow_228",
31
- shadowed: l,
32
- "shadowed-right": "_shadowed-right_v7jow_268",
33
- "is-loading": "_is-loading_v7jow_272",
34
- "action-cell-default-background": "_action-cell-default-background_v7jow_275",
35
- "fixed-cell-default-background": "_fixed-cell-default-background_v7jow_278",
36
- "fixed-right-cell-default-background": "_fixed-right-cell-default-background_v7jow_281",
37
- "sortable-column": "_sortable-column_v7jow_284",
38
- resizer: t,
39
- isResizing: a,
40
- "hide-table-header": "_hide-table-header_v7jow_312",
41
- "show-table-header": "_show-table-header_v7jow_316",
42
- "table-header": "_table-header_v7jow_85",
43
- "hide-header": "_hide-header_v7jow_342",
44
- "t-cell__actions": "_t-cell__actions_v7jow_345",
45
- "t-cell__actions--no-shadow": "_t-cell__actions--no-shadow_v7jow_353",
46
- "t-cell__actions--not-fixed": "_t-cell__actions--not-fixed_v7jow_356",
47
- "t-cell__fixed": "_t-cell__fixed_v7jow_363",
48
- "t-cell__fixed-right": "_t-cell__fixed-right_v7jow_370",
49
- "sort-icon": "_sort-icon_v7jow_377",
50
- "table-footer--sticky": "_table-footer--sticky_v7jow_380",
51
- "table-footer--inline": "_table-footer--inline_v7jow_391",
52
- "table-bottom": "_table-bottom_v7jow_402",
53
- "table-bottom--sticky": "_table-bottom--sticky_v7jow_416",
54
- "cursor-not-allowed": "_cursor-not-allowed_v7jow_420"
27
+ selected: l,
28
+ "single-selection": "_single-selection_1g04u_208",
29
+ "action-cell--no-shadow": "_action-cell--no-shadow_1g04u_225",
30
+ "action-cell--not-fixed": "_action-cell--not-fixed_1g04u_228",
31
+ shadowed: t,
32
+ "shadowed-right": "_shadowed-right_1g04u_268",
33
+ "is-loading": "_is-loading_1g04u_272",
34
+ "action-cell-default-background": "_action-cell-default-background_1g04u_275",
35
+ "fixed-cell-default-background": "_fixed-cell-default-background_1g04u_278",
36
+ "fixed-right-cell-default-background": "_fixed-right-cell-default-background_1g04u_281",
37
+ "sortable-column": "_sortable-column_1g04u_284",
38
+ resizer: a,
39
+ isResizing: o,
40
+ "hide-table-header": "_hide-table-header_1g04u_312",
41
+ "show-table-header": "_show-table-header_1g04u_316",
42
+ "table-header": "_table-header_1g04u_85",
43
+ "hide-header": "_hide-header_1g04u_348",
44
+ "t-cell__actions": "_t-cell__actions_1g04u_351",
45
+ "t-cell__actions--no-shadow": "_t-cell__actions--no-shadow_1g04u_359",
46
+ "t-cell__actions--not-fixed": "_t-cell__actions--not-fixed_1g04u_362",
47
+ "t-cell__fixed": "_t-cell__fixed_1g04u_369",
48
+ "t-cell__fixed-right": "_t-cell__fixed-right_1g04u_376",
49
+ "sort-icon": "_sort-icon_1g04u_383",
50
+ "table-footer--sticky": "_table-footer--sticky_1g04u_386",
51
+ "table-footer--inline": "_table-footer--inline_1g04u_397",
52
+ "table-bottom": "_table-bottom_1g04u_408",
53
+ "table-bottom--sticky": "_table-bottom--sticky_1g04u_422",
54
+ "cursor-not-allowed": "_cursor-not-allowed_1g04u_426"
55
55
  };
56
56
  export {
57
57
  r as default
@@ -17,7 +17,7 @@ import { DndContext as fe, closestCenter as he } from "@dnd-kit/core";
17
17
  import { restrictToParentElement as be, restrictToVerticalAxis as ue } from "@dnd-kit/modifiers";
18
18
  import { arrayMove as pe } from "@dnd-kit/sortable";
19
19
  function we({ enabled: l, data: o, setData: i, children: v }) {
20
- const y = O(() => o.map((c) => c.id), [o]), S = (c) => {
20
+ const y = O(() => o.map((c) => c.id), [o]), P = (c) => {
21
21
  if (!l || !i) return;
22
22
  const { active: m, over: f } = c;
23
23
  !m || !f || m.id === f.id || i((g) => pe(g, y.indexOf(m.id), y.indexOf(f.id)));
@@ -25,7 +25,7 @@ function we({ enabled: l, data: o, setData: i, children: v }) {
25
25
  return l ? /* @__PURE__ */ t(fe, {
26
26
  collisionDetection: he,
27
27
  modifiers: [ue, be],
28
- onDragEnd: S,
28
+ onDragEnd: P,
29
29
  children: v
30
30
  }) : /* @__PURE__ */ t(X, { children: v });
31
31
  }
@@ -36,61 +36,65 @@ function ve({ enabled: l, className: o, children: i }) {
36
36
  }) : /* @__PURE__ */ t(X, { children: i });
37
37
  }
38
38
  var Ve = (l) => {
39
- const o = O(() => ({
40
- ...l,
41
- rowHeight: l.rowHeight ?? 48
42
- }), [l]), { className: i, tableClassName: v, height: y, noRowsOverlay: S, data: c, enableDnd: m, setData: f, loading: g } = o;
43
- le(o);
44
- const { table: a } = ne(o), C = c.length > 0, F = C && !!g, h = !C && !g, z = oe(re()), r = !!o.stickyFooter && !z, [G, M] = me(!1), x = L(null), W = L(null), P = o.hideHeader ? 0 : 32, { tableScrollRef: R, tableXRef: H, hScrollRef: J, hScrollContentRef: K } = ce(!r);
39
+ const o = O(() => {
40
+ const r = {
41
+ ...l,
42
+ rowHeight: l.rowHeight ?? 48
43
+ };
44
+ return {
45
+ ...r,
46
+ columns: le(r)
47
+ };
48
+ }, [l]), { className: i, tableClassName: v, height: y, noRowsOverlay: P, data: c, enableDnd: m, setData: f, loading: g } = o, { table: a } = ne(o), C = c.length > 0, F = C && !!g, h = !C && !g, z = oe(re()), n = !!o.stickyFooter && !z, [G, M] = me(!1), x = L(null), W = L(null), S = o.hideHeader ? 0 : 32, { tableScrollRef: R, tableXRef: H, hScrollRef: J, hScrollContentRef: K } = ce(!n);
45
49
  q(() => {
46
- const n = r ? x.current : H.current ?? R.current;
47
- if (!n) {
50
+ const r = n ? x.current : H.current ?? R.current;
51
+ if (!r) {
48
52
  M(!1);
49
53
  return;
50
54
  }
51
- const s = n.querySelector("table"), b = () => {
52
- const u = n.scrollWidth > n.clientWidth;
55
+ const s = r.querySelector("table"), b = () => {
56
+ const u = r.scrollWidth > r.clientWidth;
53
57
  M((I) => I === u ? I : u);
54
58
  };
55
59
  b();
56
60
  const d = new ResizeObserver(b);
57
- return d.observe(n), s && d.observe(s), () => {
61
+ return d.observe(r), s && d.observe(s), () => {
58
62
  d.disconnect();
59
63
  };
60
64
  }, [
61
- r,
65
+ n,
62
66
  H,
63
67
  R
64
68
  ]);
65
69
  const { ref: Q, heightPx: k } = $(), { ref: U, heightPx: D } = $(), N = o.rowHeight ?? 48, E = a.getRowModel().rows.length, V = o.hideHeader ? 0 : 32, _ = 12, Y = O(() => {
66
70
  if (N <= 0) return 0;
67
- const n = r ? 0 : V + D + _, s = Math.max(0, k - n);
71
+ const r = n ? 0 : V + D + _, s = Math.max(0, k - r);
68
72
  return Math.floor(s / N);
69
73
  }, [
70
- r,
74
+ n,
71
75
  D,
72
76
  V,
73
77
  _,
74
78
  N,
75
79
  k
76
- ]), T = !r && E > 0 && E <= Y, Z = p(r ? e["table-wrapper"] : T || !r && h ? e["table-wrapper--proxy-bottom"] : e["table-wrapper--proxy"], F && e["table-wrapper-fetching"], h && e["table-wrapper--no-rows"], i), { columnWindow: j } = de({
80
+ ]), T = !n && E > 0 && E <= Y, Z = p(n ? e["table-wrapper"] : T || !n && h ? e["table-wrapper--proxy-bottom"] : e["table-wrapper--proxy"], F && e["table-wrapper-fetching"], h && e["table-wrapper--no-rows"], i), { columnWindow: j } = de({
77
81
  table: a,
78
- scrollRef: r ? x : R,
82
+ scrollRef: n ? x : R,
79
83
  isMobileView: z
80
84
  });
81
85
  q(() => {
82
- const n = x.current, s = W.current, b = () => n?.style.removeProperty("--no-rows-content-height");
83
- if (!n || !h || !s) {
86
+ const r = x.current, s = W.current, b = () => r?.style.removeProperty("--no-rows-content-height");
87
+ if (!r || !h || !s) {
84
88
  b();
85
89
  return;
86
90
  }
87
- const d = () => n.style.setProperty("--no-rows-content-height", `${Math.ceil(s.getBoundingClientRect().height) + P}px`);
91
+ const d = () => r.style.setProperty("--no-rows-content-height", `${Math.ceil(s.getBoundingClientRect().height) + S}px`);
88
92
  d();
89
93
  const u = new ResizeObserver(d);
90
94
  return u.observe(s), () => {
91
95
  u.disconnect(), b();
92
96
  };
93
- }, [h, P]);
97
+ }, [h, S]);
94
98
  const A = /* @__PURE__ */ w("div", {
95
99
  className: e["table-content"],
96
100
  children: [/* @__PURE__ */ w("table", {
@@ -113,11 +117,11 @@ var Ve = (l) => {
113
117
  }), /* @__PURE__ */ t(ae, { fetching: !!F })]
114
118
  }), ee = h ? /* @__PURE__ */ t("div", {
115
119
  className: e["no-rows-overlay-container"],
116
- style: { top: P },
120
+ style: { top: S },
117
121
  children: /* @__PURE__ */ t("div", {
118
122
  ref: W,
119
123
  className: e["no-rows-overlay-content"],
120
- children: S
124
+ children: P
121
125
  })
122
126
  }) : null;
123
127
  return /* @__PURE__ */ t(te, { children: /* @__PURE__ */ t(we, {
@@ -130,12 +134,12 @@ var Ve = (l) => {
130
134
  "data-x-overflow": G ? "true" : "false",
131
135
  style: { height: y },
132
136
  children: [/* @__PURE__ */ t(ve, {
133
- enabled: r,
137
+ enabled: n,
134
138
  className: e["table-shell"],
135
139
  children: /* @__PURE__ */ w("div", {
136
140
  ref: x,
137
141
  className: Z,
138
- children: [r ? A : /* @__PURE__ */ w("div", {
142
+ children: [n ? A : /* @__PURE__ */ w("div", {
139
143
  ref: R,
140
144
  className: p(e["table-scroll"]),
141
145
  children: [
@@ -164,7 +168,7 @@ var Ve = (l) => {
164
168
  ]
165
169
  }), ee]
166
170
  })
167
- }), r && /* @__PURE__ */ t(B, {
171
+ }), n && /* @__PURE__ */ t(B, {
168
172
  table: a,
169
173
  styledTableProps: o,
170
174
  canShowStickyFooter: !0
@@ -1,55 +1,62 @@
1
- import { ACTIONS_COLUMN_ID as U } from "../types.js";
2
- import { useRootContext as se } from "../context/RootContext.js";
1
+ import { ACTIONS_COLUMN_ID as O } from "../types.js";
2
+ import { useRootContext as ue } from "../context/RootContext.js";
3
3
  import n from "./StyledTable.module.js";
4
- import { compact as ae } from "../../helpers/arrays.js";
5
- import W from "clsx";
6
- import { Fragment as de, useCallback as ce, useEffect as re, useMemo as g } from "react";
7
- import { Fragment as me, jsx as l, jsxs as p } from "react/jsx-runtime";
8
- import { useSortable as ge } from "@dnd-kit/sortable";
9
- import { flexRender as ue } from "@tanstack/react-table";
10
- import { CSS as fe } from "@dnd-kit/utilities";
11
- function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft: u, paddingRight: f, indexes: F } }) {
12
- const { loading: O, getRowClassName: s, rowHeight: y, onRowClick: x, expandArrow: $, enableDnd: v, disableDndForRow: j, tdClassName: N, customSubRowData: I, renderSubRows: P, defaultExpanded: K, actions: C, customActionsNode: V, textExpandArrow: E, enableMultiRowSelection: Y, enableRowSelection: q, singleSelectionRow: G } = _, w = j?.(t), { transform: J, transition: Q, setNodeRef: X, isDragging: A } = ge({
4
+ import { compact as fe } from "../../helpers/arrays.js";
5
+ import $ from "clsx";
6
+ import { Fragment as he, useCallback as j, useEffect as pe, useLayoutEffect as xe, useMemo as g, useRef as Ce, useState as Re } from "react";
7
+ import { Fragment as Se, jsx as l, jsxs as C } from "react/jsx-runtime";
8
+ import { useSortable as be } from "@dnd-kit/sortable";
9
+ import { flexRender as De } from "@tanstack/react-table";
10
+ import { CSS as ke } from "@dnd-kit/utilities";
11
+ function Me({ styledTableProps: P, row: t, index: K, columnWindow: { paddingLeft: u, paddingRight: f, indexes: N } }) {
12
+ const { loading: V, getRowClassName: s, rowHeight: h, onRowClick: R, expandArrow: Y, enableDnd: I, disableDndForRow: q, tdClassName: w, customSubRowData: B, renderSubRows: G, defaultExpanded: J, actions: S, customActionsNode: Q, textExpandArrow: A, enableMultiRowSelection: X, enableRowSelection: Z, singleSelectionRow: ee } = P, b = q?.(t), { transform: te, transition: ne, setNodeRef: H, isDragging: L } = be({
13
13
  id: t.original.id,
14
- disabled: !v || w
15
- }), Z = {
16
- transform: fe.Transform.toString(J),
17
- transition: Q,
18
- opacity: A ? 0.8 : 1,
19
- zIndex: A ? 1 : 0,
14
+ disabled: !I || b
15
+ }), ie = {
16
+ transform: ke.Transform.toString(te),
17
+ transition: ne,
18
+ opacity: L ? 0.8 : 1,
19
+ zIndex: L ? 1 : 0,
20
20
  position: "relative"
21
- }, { isResizing: ee, disableResizingFlag: te } = se();
22
- re(() => {
23
- K && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
21
+ }, { isResizing: oe, disableResizingFlag: le } = ue(), D = t.isExpanded(), p = Ce(null), [se, ae] = Re(void 0);
22
+ xe(() => {
23
+ !D && p.current && ae(p.current.cells[0]?.clientHeight ?? p.current.offsetHeight);
24
+ }, [D]);
25
+ const de = j((e) => {
26
+ p.current = e, b || H(e);
27
+ }, [b, H]), M = D ? se ?? h : h;
28
+ pe(() => {
29
+ J && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
24
30
  }, []);
25
- const B = (e) => {
26
- t.getCanExpand() && !$ && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
27
- const i = window.getSelection()?.type !== "Range" && !ee, o = x instanceof Function;
28
- !o && E && i ? t.toggleExpand() : o && i && x(e, t), te();
29
- }, ne = (e) => {
30
- e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || B(e);
31
+ const T = (e) => {
32
+ t.getCanExpand() && !Y && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
33
+ const i = window.getSelection()?.type !== "Range" && !oe, o = R instanceof Function;
34
+ !o && A && i ? t.toggleExpand() : o && i && R(e, t), le();
35
+ }, ce = (e) => {
36
+ e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || T(e);
31
37
  }, r = t.getVisibleCells().map((e, i, o) => ({
32
38
  ...e,
33
39
  left: o.slice(0, i).reduce((d, c) => d + (c.column.getSize() ?? 0), 0)
34
- })), T = g(() => r.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [r]), a = g(() => r.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, i, o) => ({
40
+ })), z = g(() => r.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [r]), a = g(() => r.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, i, o) => ({
35
41
  ...e,
36
42
  right: o.slice(i + 1).reduce((d, c) => d + (c.column.getSize() ?? 0), 0)
37
- })), [r]), L = g(() => a.some((e) => e.column.id === U), [a]), h = !!C || !!V, M = g(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), m = g(() => r.filter((e) => e.column.columnDef.fixedLeft), [r]), S = !Y && !q && G, b = t.getIsSelected() && S, R = x instanceof Function, z = F.length > 0 ? ae(F.map((e) => T[e])) : T, D = ce((e, i) => {
38
- const o = e.column.id === U, d = e.column.columnDef.fixedLeft, c = !!e.column.columnDef.fixedRight, ie = e.id === m.at(-1)?.id, oe = e.id === a.at(0)?.id && !o, le = t.isExpanded(), k = i === 0;
43
+ })), [r]), U = g(() => a.some((e) => e.column.id === O), [a]), x = !!S || !!Q, W = g(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), m = g(() => r.filter((e) => e.column.columnDef.fixedLeft), [r]), k = !X && !Z && ee, y = t.getIsSelected() && k, F = R instanceof Function, _ = N.length > 0 ? fe(N.map((e) => z[e])) : z, E = j((e, i) => {
44
+ const o = e.column.id === O, d = e.column.columnDef.fixedLeft, c = !!e.column.columnDef.fixedRight, re = e.id === m.at(-1)?.id, me = e.id === a.at(0)?.id && !o, ge = t.isExpanded(), v = i === 0;
39
45
  return /* @__PURE__ */ l("td", {
40
- className: W(n["t-cell"], R && "cursor-pointer", N, o && n["action-cell"], o && !h && n["action-cell--not-fixed"], o && h && M && n["action-cell--no-shadow"], o && h && !!C && m.length && n.shadowed, o && (s?.(t) ? s?.(t) : n["action-cell-default-background"]), d && n["fixed-cell"], c && n["fixed-right-cell"], ie && n.shadowed, oe && n["shadowed-right"], t.getIsSelected() && n.selected, d && (s?.(t) ? s?.(t) : n["fixed-cell-default-background"]), c && (s?.(t) ? s?.(t) : n["fixed-right-cell-default-background"]), le && n.expanded_row, (!!b || t.isFocused()) && n["single-selection"]),
46
+ className: $(n["t-cell"], F && "cursor-pointer", w, o && n["action-cell"], o && !x && n["action-cell--not-fixed"], o && x && W && n["action-cell--no-shadow"], o && x && !!S && m.length && n.shadowed, o && (s?.(t) ? s?.(t) : n["action-cell-default-background"]), d && n["fixed-cell"], c && n["fixed-right-cell"], re && n.shadowed, me && n["shadowed-right"], t.getIsSelected() && n.selected, d && (s?.(t) ? s?.(t) : n["fixed-cell-default-background"]), c && (s?.(t) ? s?.(t) : n["fixed-right-cell-default-background"]), ge && n.expanded_row, (!!y || t.isFocused()) && n["single-selection"]),
41
47
  style: {
42
48
  left: d ? e.left : void 0,
43
- right: c ? e.right + (L ? -1 : 0) : void 0
49
+ right: c ? e.right + (U ? -1 : 0) : void 0
44
50
  },
45
- children: /* @__PURE__ */ p("div", {
51
+ children: /* @__PURE__ */ C("div", {
46
52
  style: {
47
53
  display: "flex",
48
54
  alignItems: "center",
49
- minWidth: k ? 32 : void 0,
55
+ minWidth: v ? 32 : void 0,
56
+ minHeight: M,
50
57
  position: "relative"
51
58
  },
52
- children: [k && b && /* @__PURE__ */ l("span", {
59
+ children: [v && y && /* @__PURE__ */ l("span", {
53
60
  style: {
54
61
  display: "inline-flex",
55
62
  alignItems: "center",
@@ -58,45 +65,46 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
58
65
  top: "50%",
59
66
  transform: "translateY(-50%)"
60
67
  },
61
- children: /* @__PURE__ */ l(he, {})
68
+ children: /* @__PURE__ */ l(ye, {})
62
69
  }), /* @__PURE__ */ l("span", {
63
70
  style: {
64
- marginLeft: k && S ? 30 : 0,
71
+ marginLeft: v && k ? 30 : 0,
65
72
  width: "100%"
66
73
  },
67
- children: ue(e.column.columnDef.cell, e.getContext())
74
+ children: De(e.column.columnDef.cell, e.getContext())
68
75
  })]
69
76
  })
70
77
  }, e.id);
71
78
  }, [
72
- b,
73
- C,
74
- s,
75
- R,
76
- L,
79
+ y,
80
+ S,
77
81
  M,
82
+ s,
83
+ F,
84
+ U,
85
+ W,
78
86
  m,
79
87
  a,
80
88
  t,
81
- h,
82
- S,
83
- N
89
+ x,
90
+ k,
91
+ w
84
92
  ]);
85
- return /* @__PURE__ */ p(de, { children: [/* @__PURE__ */ p("tr", {
93
+ return /* @__PURE__ */ C(he, { children: [/* @__PURE__ */ C("tr", {
86
94
  "aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
87
95
  tabIndex: t.isFocused() ? 0 : -1,
88
- "data-index": H,
96
+ "data-index": K,
89
97
  "data-test": t.id,
90
98
  id: t.id,
91
- className: W(n["t-row"], O && n["is-loading"], s?.(t)),
99
+ className: $(n["t-row"], V && n["is-loading"], s?.(t)),
92
100
  style: {
93
- height: y ? `${y}px` : "inherit",
94
- ...v && Z
101
+ height: h ? `${h}px` : "inherit",
102
+ ...I && ie
95
103
  },
96
- ref: w ? void 0 : X,
97
- onMouseUp: ne,
104
+ ref: de,
105
+ onMouseUp: ce,
98
106
  onMouseDown: (e) => {
99
- e.detail > 1 && !R && E && e.preventDefault();
107
+ e.detail > 1 && !F && A && e.preventDefault();
100
108
  },
101
109
  onKeyDown: (e) => {
102
110
  switch (e.key) {
@@ -108,12 +116,12 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
108
116
  t.focusPrevRow(), e.preventDefault();
109
117
  break;
110
118
  case "Enter":
111
- B(e);
119
+ T(e);
112
120
  break;
113
121
  }
114
122
  },
115
123
  children: [
116
- m.map((e, i) => D(e, i)),
124
+ m.map((e, i) => E(e, i)),
117
125
  u > 0 && /* @__PURE__ */ l("td", {
118
126
  "aria-hidden": !0,
119
127
  className: n["t-cell"],
@@ -125,7 +133,7 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
125
133
  border: "none"
126
134
  }
127
135
  }),
128
- z.map((e, i) => D(e, m.length + i)),
136
+ _.map((e, i) => E(e, m.length + i)),
129
137
  f > 0 && /* @__PURE__ */ l("td", {
130
138
  "aria-hidden": !0,
131
139
  className: n["t-cell"],
@@ -137,14 +145,14 @@ function ve({ styledTableProps: _, row: t, index: H, columnWindow: { paddingLeft
137
145
  border: "none"
138
146
  }
139
147
  }),
140
- a.map((e, i) => D(e, m.length + z.length + i))
148
+ a.map((e, i) => E(e, m.length + _.length + i))
141
149
  ]
142
- }), t.getIsExpanded() && /* @__PURE__ */ l(me, { children: I && P?.({
143
- rows: I.get(t.original.id.toString()) ?? [],
150
+ }), t.getIsExpanded() && /* @__PURE__ */ l(Se, { children: B && G?.({
151
+ rows: B.get(t.original.id.toString()) ?? [],
144
152
  row: t.original
145
153
  }) })] }, t.id);
146
154
  }
147
- var he = () => /* @__PURE__ */ p("svg", {
155
+ var ye = () => /* @__PURE__ */ C("svg", {
148
156
  xmlns: "http://www.w3.org/2000/svg",
149
157
  width: "20",
150
158
  height: "20",
@@ -156,5 +164,5 @@ var he = () => /* @__PURE__ */ p("svg", {
156
164
  })]
157
165
  });
158
166
  export {
159
- ve as TableRow
167
+ Me as TableRow
160
168
  };