asma-ui-core 3.87.0 → 3.87.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,66 +1,68 @@
1
- import { ACTIONS_COLUMN_ID as $ } from "../types.js";
1
+ import { ACTIONS_COLUMN_ID as j } from "../types.js";
2
2
  import { useRootContext as ge } from "../context/RootContext.js";
3
3
  import n from "./StyledTable.module.js";
4
4
  import { compact as he } from "../../helpers/arrays.js";
5
- import j from "clsx";
6
- import { Fragment as pe, useCallback as q, 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 b } from "react/jsx-runtime";
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
8
  import { useSortable as De } 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 Fe = (C) => {
12
- const t = C.closest("table");
13
- t && Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).find((f) => !t.contains(f) && !!(t.compareDocumentPosition(f) & Node.DOCUMENT_POSITION_FOLLOWING))?.focus();
11
+ var ve = (R) => {
12
+ const t = R.closest("table");
13
+ if (!t) return !1;
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
+ return r ? (r.focus(), document.activeElement === r) : !1;
14
16
  };
15
- function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWindow: { paddingLeft: g, paddingRight: h, indexes: I } }) {
16
- const { loading: G, getRowClassName: l, rowHeight: p, onRowClick: R, expandArrow: V, enableDnd: T, disableDndForRow: Y, tdClassName: w, customSubRowData: A, renderSubRows: J, defaultExpanded: Q, actions: S, customActionsNode: X, textExpandArrow: B, enableMultiRowSelection: Z, enableRowSelection: ee, singleSelectionRow: te } = C, D = Y?.(t), { transform: ne, transition: oe, setNodeRef: L, isDragging: M } = De({
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
19
  id: t.original.id,
18
- disabled: !T || D
20
+ disabled: !w || y
19
21
  }), ie = {
20
22
  transform: Ne.Transform.toString(ne),
21
23
  transition: oe,
22
- opacity: M ? 0.8 : 1,
23
- zIndex: M ? 1 : 0,
24
+ opacity: H ? 0.8 : 1,
25
+ zIndex: H ? 1 : 0,
24
26
  position: "relative"
25
- }, { isResizing: se, disableResizingFlag: le } = ge(), y = t.isExpanded(), x = Ce(null), [ae, ce] = Re(void 0);
27
+ }, { isResizing: se, disableResizingFlag: le } = ge(), N = t.isExpanded(), b = Ce(null), [ae, ce] = Re(void 0);
26
28
  be(() => {
27
- !y && x.current && ce(x.current.cells[0]?.clientHeight ?? x.current.offsetHeight);
28
- }, [y]);
29
- const de = q((e) => {
30
- x.current = e, D || L(e);
31
- }, [D, L]), H = y ? ae ?? p : p;
29
+ !N && b.current && ce(b.current.cells[0]?.clientHeight ?? b.current.offsetHeight);
30
+ }, [N]);
31
+ const de = K((e) => {
32
+ b.current = e, y || M(e);
33
+ }, [y, M]), O = N ? ae ?? x : x;
32
34
  xe(() => {
33
35
  Q && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
34
36
  }, []);
35
- const O = (e) => {
37
+ const U = (e) => {
36
38
  t.getCanExpand() && !V && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
37
- const o = window.getSelection()?.type !== "Range" && !se, i = R instanceof Function;
38
- !i && B && o ? t.toggleExpand() : i && o && R(e, t), le();
39
+ const o = window.getSelection()?.type !== "Range" && !se, i = S instanceof Function;
40
+ !i && L && o ? t.toggleExpand() : i && o && S(e, t), le();
39
41
  }, re = (e) => {
40
- e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || O(e);
41
- }, r = t.getVisibleCells().map((e, o, i) => ({
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
+ }, u = t.getVisibleCells().map((e, o, i) => ({
42
44
  ...e,
43
45
  left: i.slice(0, o).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
44
- })), U = m(() => r.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [r]), a = m(() => r.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions").map((e, o, i) => ({
46
+ })), 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) => ({
45
47
  ...e,
46
48
  right: i.slice(o + 1).reduce((c, d) => c + (d.column.getSize() ?? 0), 0)
47
- })), [r]), W = m(() => a.some((e) => e.column.id === $), [a]), _ = !!S || !!X, z = m(() => a.some((e) => !!e.column.columnDef.fixedRight), [a]), u = m(() => r.filter((e) => e.column.columnDef.fixedLeft), [r]), N = !Z && !ee && te, F = t.getIsSelected() && N, k = R instanceof Function, P = I.length > 0 ? he(I.map((e) => U[e])) : U, v = q((e, o) => {
48
- const i = e.column.id === $, c = e.column.columnDef.fixedLeft, d = !!e.column.columnDef.fixedRight, ue = e.id === u.at(-1)?.id, fe = e.id === a.at(0)?.id && !i, me = t.isExpanded(), E = o === 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;
49
51
  return /* @__PURE__ */ s("td", {
50
- className: j(n["t-cell"], k && "cursor-pointer", w, i && n["action-cell"], i && (!_ || z) && n["action-cell--no-shadow"], i && !!S && u.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"]),
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"]),
51
53
  style: {
52
54
  left: c ? e.left : void 0,
53
- right: d ? e.right + (W ? -1 : 0) : void 0
55
+ right: d ? e.right + (_ ? -1 : 0) : void 0
54
56
  },
55
- children: /* @__PURE__ */ b("div", {
57
+ children: /* @__PURE__ */ C("div", {
56
58
  style: {
57
59
  display: "flex",
58
60
  alignItems: "center",
59
- minWidth: E ? 32 : void 0,
60
- minHeight: H,
61
+ minWidth: I ? 32 : void 0,
62
+ minHeight: O,
61
63
  position: "relative"
62
64
  },
63
- children: [E && F && /* @__PURE__ */ s("span", {
65
+ children: [I && F && /* @__PURE__ */ s("span", {
64
66
  style: {
65
67
  display: "inline-flex",
66
68
  alignItems: "center",
@@ -69,10 +71,10 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
69
71
  top: "50%",
70
72
  transform: "translateY(-50%)"
71
73
  },
72
- children: /* @__PURE__ */ s(ke, {})
74
+ children: /* @__PURE__ */ s(Fe, {})
73
75
  }), /* @__PURE__ */ s("span", {
74
76
  style: {
75
- marginLeft: E && N ? 30 : 0,
77
+ marginLeft: I && v ? 30 : 0,
76
78
  width: "100%"
77
79
  },
78
80
  children: ye(e.column.columnDef.cell, e.getContext())
@@ -81,29 +83,29 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
81
83
  }, e.id);
82
84
  }, [
83
85
  F,
84
- S,
85
- H,
86
+ D,
87
+ O,
86
88
  l,
87
89
  k,
88
- W,
89
- z,
90
- u,
90
+ _,
91
+ P,
92
+ f,
91
93
  a,
92
94
  t,
93
- _,
94
- N,
95
- w
95
+ z,
96
+ v,
97
+ A
96
98
  ]);
97
- return /* @__PURE__ */ b(pe, { children: [/* @__PURE__ */ b("tr", {
99
+ return /* @__PURE__ */ C(pe, { children: [/* @__PURE__ */ C("tr", {
98
100
  "aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
99
- tabIndex: t.isFocused() || f === 0 && !K ? 0 : -1,
100
- "data-index": f,
101
+ tabIndex: t.isFocused() || r === 0 && !g ? 0 : -1,
102
+ "data-index": r,
101
103
  "data-test": t.id,
102
104
  id: t.id,
103
- className: j(n["t-row"], G && n["is-loading"], l?.(t)),
105
+ className: q(n["t-row"], G && n["is-loading"], l?.(t)),
104
106
  style: {
105
- height: p ? `${p}px` : "inherit",
106
- ...T && ie
107
+ height: x ? `${x}px` : "inherit",
108
+ ...w && ie
107
109
  },
108
110
  ref: de,
109
111
  onFocus: (e) => {
@@ -111,15 +113,19 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
111
113
  },
112
114
  onMouseUp: re,
113
115
  onMouseDown: (e) => {
114
- e.detail > 1 && !k && B && e.preventDefault();
116
+ e.detail > 1 && !k && L && e.preventDefault();
115
117
  },
116
118
  onKeyDown: (e) => {
117
119
  switch (e.key) {
118
120
  case "Tab":
119
- if (e.preventDefault(), e.shiftKey) {
120
- if (t.focusPrevRow()) break;
121
- e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]')?.focus();
122
- } else t.focusNextRow() || Fe(e.currentTarget);
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();
123
129
  break;
124
130
  case "ArrowDown":
125
131
  t.focusNextRow() && e.preventDefault();
@@ -128,43 +134,43 @@ function Oe({ styledTableProps: C, row: t, index: f, hasFocusedRow: K, columnWin
128
134
  t.focusPrevRow() && e.preventDefault();
129
135
  break;
130
136
  case "Enter":
131
- O(e);
137
+ U(e);
132
138
  break;
133
139
  }
134
140
  },
135
141
  children: [
136
- u.map((e, o) => v(e, o)),
137
- g > 0 && /* @__PURE__ */ s("td", {
142
+ f.map((e, o) => E(e, o)),
143
+ h > 0 && /* @__PURE__ */ s("td", {
138
144
  "aria-hidden": !0,
139
145
  className: n["t-cell"],
140
146
  style: {
141
- width: String(g) + "px",
142
- minWidth: String(g) + "px",
143
- maxWidth: String(g) + "px",
147
+ width: String(h) + "px",
148
+ minWidth: String(h) + "px",
149
+ maxWidth: String(h) + "px",
144
150
  padding: 0,
145
151
  border: "none"
146
152
  }
147
153
  }),
148
- P.map((e, o) => v(e, u.length + o)),
149
- h > 0 && /* @__PURE__ */ s("td", {
154
+ $.map((e, o) => E(e, f.length + o)),
155
+ p > 0 && /* @__PURE__ */ s("td", {
150
156
  "aria-hidden": !0,
151
157
  className: n["t-cell"],
152
158
  style: {
153
- width: String(h) + "px",
154
- minWidth: String(h) + "px",
155
- maxWidth: String(h) + "px",
159
+ width: String(p) + "px",
160
+ minWidth: String(p) + "px",
161
+ maxWidth: String(p) + "px",
156
162
  padding: 0,
157
163
  border: "none"
158
164
  }
159
165
  }),
160
- a.map((e, o) => v(e, u.length + P.length + o))
166
+ a.map((e, o) => E(e, f.length + $.length + o))
161
167
  ]
162
- }), t.getIsExpanded() && /* @__PURE__ */ s(Se, { children: A && J?.({
163
- rows: A.get(t.original.id.toString()) ?? [],
168
+ }), t.getIsExpanded() && /* @__PURE__ */ s(Se, { children: B && J?.({
169
+ rows: B.get(t.original.id.toString()) ?? [],
164
170
  row: t.original
165
171
  }) })] }, t.id);
166
172
  }
167
- var ke = () => /* @__PURE__ */ b("svg", {
173
+ var Fe = () => /* @__PURE__ */ C("svg", {
168
174
  xmlns: "http://www.w3.org/2000/svg",
169
175
  width: "20",
170
176
  height: "20",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.87.0",
6
+ "version": "3.87.1",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",