asma-ui-core 3.88.0 → 3.88.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,37 +1,37 @@
1
1
  import { ACTIONS_COLUMN_ID as j } from "../types.js";
2
- import { useRootContext as ge } from "../context/RootContext.js";
2
+ import { useRootContext as he } from "../context/RootContext.js";
3
3
  import n from "./StyledTable.module.js";
4
- import { compact as he } from "../../helpers/arrays.js";
4
+ import { compact as pe } from "../../helpers/arrays.js";
5
5
  import q from "clsx";
6
- import { Fragment as pe, useCallback as K, useEffect as xe, useLayoutEffect as be, useMemo as m, useRef as Ce, useState as Re } from "react";
7
- import { Fragment as Se, jsx as s, jsxs as C } from "react/jsx-runtime";
8
- import { useSortable as De } from "@dnd-kit/sortable";
6
+ import { Fragment as xe, useCallback as K, useEffect as be, useLayoutEffect as Ce, useMemo as m, useRef as Re, useState as Se } from "react";
7
+ import { Fragment as De, jsx as s, jsxs as C } from "react/jsx-runtime";
8
+ import { useSortable as ve } from "@dnd-kit/sortable";
9
9
  import { flexRender as ye } from "@tanstack/react-table";
10
10
  import { CSS as Ne } from "@dnd-kit/utilities";
11
- var ve = (R) => {
11
+ var Fe = (R) => {
12
12
  const t = R.closest("table");
13
13
  if (!t) return !1;
14
14
  const r = Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).find((g) => !t.contains(g) && !!(t.compareDocumentPosition(g) & Node.DOCUMENT_POSITION_FOLLOWING));
15
15
  return r ? (r.focus(), document.activeElement === r) : !1;
16
16
  };
17
- function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWindow: { paddingLeft: h, paddingRight: p, indexes: T } }) {
18
- const { loading: G, getRowClassName: l, rowHeight: x, onRowClick: S, expandArrow: V, enableDnd: w, disableDndForRow: Y, tdClassName: A, customSubRowData: B, renderSubRows: J, defaultExpanded: Q, actions: D, customActionsNode: X, textExpandArrow: L, enableMultiRowSelection: Z, enableRowSelection: ee, singleSelectionRow: te } = R, y = Y?.(t), { transform: ne, transition: oe, setNodeRef: M, isDragging: H } = De({
17
+ function Ue({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWindow: { paddingLeft: h, paddingRight: p, indexes: T } }) {
18
+ const { loading: G, getRowClassName: l, rowHeight: x, onRowClick: S, expandArrow: V, enableDnd: w, disableDndForRow: Y, tdClassName: A, customSubRowData: B, renderSubRows: J, defaultExpanded: Q, actions: D, customActionsNode: X, textExpandArrow: L, enableMultiRowSelection: Z, enableRowSelection: ee, singleSelectionRow: te } = R, v = Y?.(t), { transform: ne, transition: oe, setNodeRef: M, isDragging: H } = ve({
19
19
  id: t.original.id,
20
- disabled: !w || y
20
+ disabled: !w || v
21
21
  }), ie = {
22
22
  transform: Ne.Transform.toString(ne),
23
23
  transition: oe,
24
24
  opacity: H ? 0.8 : 1,
25
25
  zIndex: H ? 1 : 0,
26
26
  position: "relative"
27
- }, { isResizing: se, disableResizingFlag: le } = ge(), N = t.isExpanded(), b = Ce(null), [ae, ce] = Re(void 0);
28
- be(() => {
29
- !N && b.current && ce(b.current.cells[0]?.clientHeight ?? b.current.offsetHeight);
30
- }, [N]);
27
+ }, { isResizing: se, disableResizingFlag: le } = he(), y = t.isExpanded(), b = Re(null), [ae, ce] = Se(void 0);
28
+ Ce(() => {
29
+ !y && b.current && ce(b.current.cells[0]?.clientHeight ?? b.current.offsetHeight);
30
+ }, [y]);
31
31
  const de = K((e) => {
32
- b.current = e, y || M(e);
33
- }, [y, M]), O = N ? ae ?? x : x;
34
- xe(() => {
32
+ b.current = e, v || M(e);
33
+ }, [v, M]), O = y ? ae ?? x : x;
34
+ be(() => {
35
35
  Q && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
36
36
  }, []);
37
37
  const U = (e) => {
@@ -40,16 +40,39 @@ function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWin
40
40
  !i && L && o ? t.toggleExpand() : i && o && S(e, t), le();
41
41
  }, re = (e) => {
42
42
  e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || U(e);
43
+ }, ue = (e) => {
44
+ if (e.target === e.currentTarget)
45
+ switch (e.key) {
46
+ case "Tab":
47
+ if (e.shiftKey) {
48
+ if (t.focusPrevRow()) {
49
+ e.preventDefault();
50
+ break;
51
+ }
52
+ const o = e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]');
53
+ o && (e.preventDefault(), o.focus());
54
+ } else (t.focusNextRow() || Fe(e.currentTarget)) && e.preventDefault();
55
+ break;
56
+ case "ArrowDown":
57
+ t.focusNextRow() && e.preventDefault();
58
+ break;
59
+ case "ArrowUp":
60
+ t.focusPrevRow() && e.preventDefault();
61
+ break;
62
+ case "Enter":
63
+ e.preventDefault(), U(e);
64
+ break;
65
+ }
43
66
  }, u = t.getVisibleCells().map((e, o, i) => ({
44
67
  ...e,
45
68
  left: i.slice(0, o).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
46
69
  })), W = m(() => u.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [u]), a = m(() => u.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, o, i) => ({
47
70
  ...e,
48
71
  right: i.slice(o + 1).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
49
- })), [u]), _ = m(() => a.some((e) => e.column.id === j), [a]), z = !!D || !!X, P = m(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), f = m(() => u.filter((e) => e.column.columnDef.fixedLeft), [u]), v = !Z && !ee && te, F = t.getIsSelected() && v, k = S instanceof Function, $ = T.length > 0 ? he(T.map((e) => W[e])) : W, E = K((e, o) => {
50
- const i = e.column.id === j, c = e.column.columnDef.fixedLeft, d = !!e.column.columnDef.fixedRight, ue = e.id === f.at(-1)?.id, fe = e.id === a.at(0)?.id && !i, me = t.isExpanded(), I = o === 0;
72
+ })), [u]), _ = m(() => a.some((e) => e.column.id === j), [a]), z = !!D || !!X, P = m(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), f = m(() => u.filter((e) => e.column.columnDef.fixedLeft), [u]), N = !Z && !ee && te, F = t.getIsSelected() && N, k = S instanceof Function, $ = T.length > 0 ? pe(T.map((e) => W[e])) : W, E = K((e, o) => {
73
+ const i = e.column.id === j, c = e.column.columnDef.fixedLeft, d = !!e.column.columnDef.fixedRight, fe = e.id === f.at(-1)?.id, me = e.id === a.at(0)?.id && !i, ge = t.isExpanded(), I = o === 0;
51
74
  return /* @__PURE__ */ s("td", {
52
- className: q(n["t-cell"], k && "cursor-pointer", A, i && n["action-cell"], i && (!z || P) && n["action-cell--no-shadow"], i && !!D && f.length && n.shadowed, i && (l?.(t) ? l?.(t) : n["action-cell-default-background"]), c && n["fixed-cell"], d && n["fixed-right-cell"], ue && n.shadowed, fe && n["shadowed-right"], t.getIsSelected() && n.selected, c && (l?.(t) ? l?.(t) : n["fixed-cell-default-background"]), d && (l?.(t) ? l?.(t) : n["fixed-right-cell-default-background"]), me && n.expanded_row, !!F && n["single-selection"]),
75
+ className: q(n["t-cell"], k && "cursor-pointer", A, i && n["action-cell"], i && (!z || P) && n["action-cell--no-shadow"], i && !!D && f.length && n.shadowed, i && (l?.(t) ? l?.(t) : n["action-cell-default-background"]), c && n["fixed-cell"], d && n["fixed-right-cell"], fe && n.shadowed, me && n["shadowed-right"], t.getIsSelected() && n.selected, c && (l?.(t) ? l?.(t) : n["fixed-cell-default-background"]), d && (l?.(t) ? l?.(t) : n["fixed-right-cell-default-background"]), ge && n.expanded_row, !!F && n["single-selection"]),
53
76
  style: {
54
77
  left: c ? e.left : void 0,
55
78
  right: d ? e.right + (_ ? -1 : 0) : void 0
@@ -71,10 +94,10 @@ function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWin
71
94
  top: "50%",
72
95
  transform: "translateY(-50%)"
73
96
  },
74
- children: /* @__PURE__ */ s(Fe, {})
97
+ children: /* @__PURE__ */ s(ke, {})
75
98
  }), /* @__PURE__ */ s("span", {
76
99
  style: {
77
- marginLeft: I && v ? 30 : 0,
100
+ marginLeft: I && N ? 30 : 0,
78
101
  width: "100%"
79
102
  },
80
103
  children: ye(e.column.columnDef.cell, e.getContext())
@@ -93,10 +116,10 @@ function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWin
93
116
  a,
94
117
  t,
95
118
  z,
96
- v,
119
+ N,
97
120
  A
98
121
  ]);
99
- return /* @__PURE__ */ C(pe, { children: [/* @__PURE__ */ C("tr", {
122
+ return /* @__PURE__ */ C(xe, { children: [/* @__PURE__ */ C("tr", {
100
123
  "aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
101
124
  tabIndex: t.isFocused() || r === 0 && !g ? 0 : -1,
102
125
  "data-index": r,
@@ -115,29 +138,7 @@ function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWin
115
138
  onMouseDown: (e) => {
116
139
  e.detail > 1 && !k && L && e.preventDefault();
117
140
  },
118
- onKeyDown: (e) => {
119
- switch (e.key) {
120
- case "Tab":
121
- if (e.shiftKey) {
122
- if (t.focusPrevRow()) {
123
- e.preventDefault();
124
- break;
125
- }
126
- const o = e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]');
127
- o && (e.preventDefault(), o.focus());
128
- } else (t.focusNextRow() || ve(e.currentTarget)) && e.preventDefault();
129
- break;
130
- case "ArrowDown":
131
- t.focusNextRow() && e.preventDefault();
132
- break;
133
- case "ArrowUp":
134
- t.focusPrevRow() && e.preventDefault();
135
- break;
136
- case "Enter":
137
- U(e);
138
- break;
139
- }
140
- },
141
+ onKeyDownCapture: ue,
141
142
  children: [
142
143
  f.map((e, o) => E(e, o)),
143
144
  h > 0 && /* @__PURE__ */ s("td", {
@@ -165,12 +166,12 @@ function Oe({ styledTableProps: R, row: t, index: r, hasFocusedRow: g, columnWin
165
166
  }),
166
167
  a.map((e, o) => E(e, f.length + $.length + o))
167
168
  ]
168
- }), t.getIsExpanded() && /* @__PURE__ */ s(Se, { children: B && J?.({
169
+ }), t.getIsExpanded() && /* @__PURE__ */ s(De, { children: B && J?.({
169
170
  rows: B.get(t.original.id.toString()) ?? [],
170
171
  row: t.original
171
172
  }) })] }, t.id);
172
173
  }
173
- var Fe = () => /* @__PURE__ */ C("svg", {
174
+ var ke = () => /* @__PURE__ */ C("svg", {
174
175
  xmlns: "http://www.w3.org/2000/svg",
175
176
  width: "20",
176
177
  height: "20",
@@ -182,5 +183,5 @@ var Fe = () => /* @__PURE__ */ C("svg", {
182
183
  })]
183
184
  });
184
185
  export {
185
- Oe as TableRow
186
+ Ue as TableRow
186
187
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.88.0",
6
+ "version": "3.88.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",