asma-ui-core 3.121.5 → 3.122.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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/custom/module/header-layout/ToolbarRows.js +64 -60
- package/dist/components/custom/pathfinder-card/Pathfinder.module.js +14 -13
- package/dist/components/custom/pathfinder-card/PathfinderCard.js +64 -64
- package/dist/components/custom/widget/widget/StyledWidget.js +44 -37
- package/dist/components/custom/widget/widget-header/StyledWidgetHeader.js +7 -7
- package/dist/components/custom/widget/widget-title/StyledWidgetTitle.js +8 -8
- package/dist/components/data-display/chip/StyledChip.js +42 -42
- package/dist/components/data-display/form-label/components/StyledFormLabel.js +15 -15
- package/dist/components/feedback/dialog/StyledDialog.js +75 -75
- package/dist/components/feedback/dialog/StyledDialogActions.js +4 -4
- package/dist/components/feedback/dialog/StyledDialogTitle.js +13 -13
- package/dist/components/feedback/dialog/dialog-footer/StyledDialogFooter.js +70 -69
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +69 -69
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +81 -81
- package/dist/components/feedback/snack-bar/StyledAlert.js +16 -16
- package/dist/components/inputs/button/StyledButton.js +36 -35
- package/dist/components/inputs/input-field/StyledInputField.js +38 -38
- package/dist/components/inputs/search-field/StyledSearchField.js +18 -17
- package/dist/components/miscellaneous/StyledFormControlLabel.js +13 -13
- package/dist/components/navigation/link/StyledLink.js +44 -44
- package/dist/components/navigation/title-chevron/StyledTitleChevron.js +13 -13
- package/dist/components/utils/bottom-sheet/StyledBottomSheet.js +45 -45
- package/dist/components/utils/popover/PopoverAnatomy.js +23 -23
- package/dist/hooks/useMediaQuery.hook.js +3 -2
- package/dist/src/components/custom/module/header-layout/ToolbarRows.d.ts +3 -1
- package/dist/src/hooks/useMediaQuery.hook.d.ts +2 -0
- package/dist/src/table/types.d.ts +8 -0
- package/dist/table/components/TableRow.js +89 -87
- package/package.json +1 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as l } from "../../../helpers/cn.js";
|
|
2
2
|
import { registerOpenModalDialog as z } from "../../../hooks/useTopLayer.hook.js";
|
|
3
3
|
import { CloseIcon as J } from "../../icons/close-icon/CloseIcon.js";
|
|
4
4
|
import { IndeterminateIcon as W } from "../../icons/indeterminate-icon/IndeterminateIcon.js";
|
|
5
5
|
import { StyledButton as j } from "../../inputs/button/StyledButton.js";
|
|
6
6
|
import { useShortViewportMediaQuery as X } from "../../../hooks/useMediaQuery.hook.js";
|
|
7
|
-
import { OverlayBackOwnerContext as Z, isOverlayBackEnabled as P, requestCloseTopOverlayBack as
|
|
7
|
+
import { OverlayBackOwnerContext as Z, isOverlayBackEnabled as P, requestCloseTopOverlayBack as y, useBackCloses as ee } from "../../../hooks/useBackCloses.hook.js";
|
|
8
8
|
import { useDebouncedValue as te } from "../../../hooks/useDebouncedValue.hook.js";
|
|
9
9
|
import { useFocusTrap as re } from "../../../hooks/useFocusTrap.hook.js";
|
|
10
10
|
import { formatResultsLabel as oe } from "./formatResultsLabel.js";
|
|
11
11
|
import { useBodyScrollLock as ne } from "../../../hooks/useBodyScrollLock.hook.js";
|
|
12
12
|
import ae from "./StyledBottomSheet.module.js";
|
|
13
13
|
import { useDragToDismiss as se } from "./useDragToDismiss.hook.js";
|
|
14
|
-
import { useEffect as
|
|
14
|
+
import { useEffect as g, useId as ie, useLayoutEffect as le, useRef as c, useState as ce } from "react";
|
|
15
15
|
import { jsx as o, jsxs as u } from "react/jsx-runtime";
|
|
16
|
-
var de = 500, Le = ({ dataTest:
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
f.current = s,
|
|
16
|
+
var de = 500, Le = ({ dataTest: d, id: T, open: t, onClose: s, title: m, ariaLabel: _, children: q, viewResultsAction: E, resetAction: $, footerActions: A, resultCount: k, closeLabel: U = "Lukk", className: V, registerBackClose: H = !0, ownerRef: K }) => {
|
|
17
|
+
const S = ie(), i = c(null), N = c(null), R = c(null), L = K ?? i, h = c(!1), [x, B] = ce(!1), G = X(), f = c(s), C = c(t);
|
|
18
|
+
g(() => {
|
|
19
|
+
f.current = s, C.current = t;
|
|
20
20
|
}, [s, t]);
|
|
21
|
-
const { dragHandleProps: Q, dragOffset:
|
|
21
|
+
const { dragHandleProps: Q, dragOffset: O } = se(N, () => {
|
|
22
22
|
f.current("drag");
|
|
23
23
|
});
|
|
24
|
-
ne(t), re(t, i),
|
|
24
|
+
ne(t), re(t, i), g(() => {
|
|
25
25
|
if (!t) return;
|
|
26
26
|
const e = (r) => {
|
|
27
27
|
r.key === "Escape" && (h.current = !0, window.setTimeout(() => {
|
|
@@ -30,7 +30,7 @@ var de = 500, Le = ({ dataTest: c, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
30
30
|
}, n = (r) => {
|
|
31
31
|
if (r.key !== "Escape" || r.defaultPrevented) return;
|
|
32
32
|
const a = document.activeElement;
|
|
33
|
-
a instanceof Element && a.closest("dialog[open]") !== i.current || (r.preventDefault(), r.stopImmediatePropagation(),
|
|
33
|
+
a instanceof Element && a.closest("dialog[open]") !== i.current || (r.preventDefault(), r.stopImmediatePropagation(), y(r));
|
|
34
34
|
};
|
|
35
35
|
return window.addEventListener("keydown", e, !0), window.addEventListener("keydown", n), () => {
|
|
36
36
|
window.removeEventListener("keydown", e, !0), window.removeEventListener("keydown", n);
|
|
@@ -38,78 +38,78 @@ var de = 500, Le = ({ dataTest: c, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
38
38
|
}, [t]), ee({
|
|
39
39
|
active: t && H,
|
|
40
40
|
requestClose: () => f.current("escape"),
|
|
41
|
-
ownerRef:
|
|
41
|
+
ownerRef: L
|
|
42
42
|
}), le(() => {
|
|
43
43
|
const e = i.current;
|
|
44
44
|
if (!t || !e) return;
|
|
45
|
-
|
|
45
|
+
R.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.open || e.showModal(), e.focus({ preventScroll: !0 });
|
|
46
46
|
const n = requestAnimationFrame(() => {
|
|
47
|
-
|
|
47
|
+
B(!0);
|
|
48
48
|
}), r = z(e);
|
|
49
49
|
return () => {
|
|
50
|
-
cancelAnimationFrame(n), r(),
|
|
51
|
-
const a =
|
|
50
|
+
cancelAnimationFrame(n), r(), B(!1), e.open && e.close();
|
|
51
|
+
const a = R.current;
|
|
52
52
|
a?.isConnected && a.focus({ preventScroll: !0 });
|
|
53
53
|
};
|
|
54
|
-
}, [t]),
|
|
54
|
+
}, [t]), g(() => {
|
|
55
55
|
const e = i.current;
|
|
56
56
|
if (!e || !t) return;
|
|
57
57
|
let n = !1;
|
|
58
58
|
const r = () => {
|
|
59
59
|
requestAnimationFrame(() => {
|
|
60
|
-
n = !1,
|
|
60
|
+
n = !1, C.current && e.isConnected && !e.open && (e.showModal(), e.focus({ preventScroll: !0 }));
|
|
61
61
|
});
|
|
62
62
|
}, a = () => {
|
|
63
|
-
n || (n = !0, P() &&
|
|
63
|
+
n || (n = !0, P() && y(), r());
|
|
64
64
|
};
|
|
65
65
|
return e.addEventListener("close", a), () => e.removeEventListener("close", a);
|
|
66
66
|
}, [t]);
|
|
67
|
-
const
|
|
67
|
+
const I = oe(te(k, de));
|
|
68
68
|
if (!t) return null;
|
|
69
69
|
const Y = { close: () => {
|
|
70
70
|
s("action");
|
|
71
|
-
} }, p = (e) => typeof e == "function" ? e(Y) : e,
|
|
72
|
-
dataTest: `${
|
|
71
|
+
} }, p = (e) => typeof e == "function" ? e(Y) : e, D = k !== void 0, b = E !== void 0 ? p(E) : D ? /* @__PURE__ */ o(j, {
|
|
72
|
+
dataTest: `${d}-view-results`,
|
|
73
73
|
type: "button",
|
|
74
74
|
variant: "text",
|
|
75
75
|
onClick: () => {
|
|
76
76
|
s("viewResults");
|
|
77
77
|
},
|
|
78
|
-
children:
|
|
79
|
-
}) : void 0,
|
|
78
|
+
children: I
|
|
79
|
+
}) : void 0, F = p($), v = p(A), w = !!(b ?? F), M = O > 0;
|
|
80
80
|
return /* @__PURE__ */ o("dialog", {
|
|
81
81
|
ref: i,
|
|
82
82
|
id: T,
|
|
83
83
|
tabIndex: -1,
|
|
84
84
|
"aria-modal": "true",
|
|
85
|
-
"aria-labelledby": m ?
|
|
85
|
+
"aria-labelledby": m ? S : void 0,
|
|
86
86
|
"aria-label": m ? void 0 : _,
|
|
87
|
-
"data-test":
|
|
88
|
-
"data-testid":
|
|
87
|
+
"data-test": d,
|
|
88
|
+
"data-testid": d,
|
|
89
89
|
onCancel: (e) => {
|
|
90
90
|
if (e.cancelable && e.preventDefault(), !h.current) {
|
|
91
91
|
if (!P()) {
|
|
92
92
|
f.current("escape");
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
|
|
95
|
+
y();
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
|
-
className:
|
|
98
|
+
className: l(ae.StyledBottomSheet, "fixed inset-0 m-0 h-full max-h-none w-full max-w-none flex-col items-center justify-end overflow-hidden border-0 bg-transparent p-0 outline-none open:flex"),
|
|
99
99
|
children: /* @__PURE__ */ u(Z.Provider, {
|
|
100
|
-
value:
|
|
100
|
+
value: L,
|
|
101
101
|
children: [/* @__PURE__ */ o("div", {
|
|
102
102
|
"aria-hidden": "true",
|
|
103
|
-
"data-testid": `${
|
|
103
|
+
"data-testid": `${d}-scrim`,
|
|
104
104
|
onClick: () => {
|
|
105
105
|
s("scrim");
|
|
106
106
|
},
|
|
107
|
-
className:
|
|
107
|
+
className: l("absolute inset-0 bg-[#626e7eb2] transition-opacity duration-[250ms] ease-out motion-reduce:duration-150", x ? "opacity-100" : "opacity-0")
|
|
108
108
|
}), /* @__PURE__ */ u("div", {
|
|
109
|
-
ref:
|
|
110
|
-
"data-state":
|
|
111
|
-
style: M ? { transform: `translateY(${
|
|
112
|
-
className:
|
|
109
|
+
ref: N,
|
|
110
|
+
"data-state": x ? "open" : "closed",
|
|
111
|
+
style: M ? { transform: `translateY(${O}px)` } : void 0,
|
|
112
|
+
className: l("relative box-border flex w-full max-w-[640px] flex-col border border-solid border-delta-300 bg-white text-delta-700 outline-none", G ? "h-full max-h-none rounded-none" : "max-h-[90dvh] rounded-t-[28px]", !M && ["ease-out motion-safe:transition-transform motion-safe:duration-[250ms] motion-reduce:transition-opacity motion-reduce:duration-150", x ? "translate-y-0 opacity-100" : "motion-safe:translate-y-full motion-reduce:opacity-0"], V),
|
|
113
113
|
children: [
|
|
114
114
|
/* @__PURE__ */ u("div", {
|
|
115
115
|
className: "border-b-solid shrink-0 border-b border-delta-200 pb-2",
|
|
@@ -119,7 +119,7 @@ var de = 500, Le = ({ dataTest: c, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
119
119
|
children: [
|
|
120
120
|
/* @__PURE__ */ o("div", { className: "min-w-0 flex-1" }),
|
|
121
121
|
/* @__PURE__ */ o(j, {
|
|
122
|
-
dataTest: `${
|
|
122
|
+
dataTest: `${d}-close`,
|
|
123
123
|
variant: "textGray",
|
|
124
124
|
type: "button",
|
|
125
125
|
"aria-label": U,
|
|
@@ -140,31 +140,31 @@ var de = 500, Le = ({ dataTest: c, id: T, open: t, onClose: s, title: m, ariaLab
|
|
|
140
140
|
})
|
|
141
141
|
]
|
|
142
142
|
}), m && /* @__PURE__ */ o("div", {
|
|
143
|
-
id:
|
|
143
|
+
id: S,
|
|
144
144
|
className: "truncate px-4 text-lg font-semibold leading-7 text-delta-800",
|
|
145
145
|
children: m
|
|
146
146
|
})]
|
|
147
147
|
}),
|
|
148
148
|
/* @__PURE__ */ o("div", {
|
|
149
|
-
className:
|
|
149
|
+
className: l("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto overscroll-contain pl-4 pr-2 pt-2", w || v ? "pb-2" : "pb-[max(0.5rem,env(safe-area-inset-bottom))]"),
|
|
150
150
|
children: p(q)
|
|
151
151
|
}),
|
|
152
|
-
|
|
153
|
-
className:
|
|
152
|
+
w && /* @__PURE__ */ u("div", {
|
|
153
|
+
className: l("border-t-solid flex shrink-0 items-start border-t border-delta-200 bg-white p-1", b ? "justify-between" : "justify-end", "max-xs:flex-wrap max-xs:gap-y-2 max-xs:[&>:nth-child(2)]:ml-auto", !v && "pb-[max(0.25rem,env(safe-area-inset-bottom))]"),
|
|
154
154
|
children: [
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
b,
|
|
156
|
+
F,
|
|
157
|
+
D && /* @__PURE__ */ o("span", {
|
|
158
158
|
className: "sr-only",
|
|
159
159
|
role: "status",
|
|
160
160
|
"aria-live": "polite",
|
|
161
161
|
"aria-atomic": "true",
|
|
162
|
-
children:
|
|
162
|
+
children: I
|
|
163
163
|
})
|
|
164
164
|
]
|
|
165
165
|
}),
|
|
166
166
|
v && /* @__PURE__ */ o("div", {
|
|
167
|
-
className: "flex shrink-0 flex-col items-end bg-white p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]",
|
|
167
|
+
className: l("flex shrink-0 flex-col items-end bg-white p-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]", w && "max-xs:pt-1"),
|
|
168
168
|
children: v
|
|
169
169
|
})
|
|
170
170
|
]
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { CloseIcon as
|
|
3
|
-
import { StyledButton as
|
|
1
|
+
import { cn as r } from "../../../helpers/cn.js";
|
|
2
|
+
import { CloseIcon as h } from "../../icons/close-icon/CloseIcon.js";
|
|
3
|
+
import { StyledButton as c } from "../../inputs/button/StyledButton.js";
|
|
4
4
|
import { useScrollGutter as u } from "./useScrollGutter.js";
|
|
5
5
|
import { useRef as v } from "react";
|
|
6
|
-
import { Fragment as
|
|
7
|
-
var
|
|
8
|
-
const n = v(null),
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
/* @__PURE__ */
|
|
6
|
+
import { Fragment as g, jsx as e, jsxs as o } from "react/jsx-runtime";
|
|
7
|
+
var _ = 40, j = "relative box-border flex flex-col overflow-hidden rounded-lg bg-white text-delta-700 outline-none shadow-[0px_4px_40px_0px_#22213366]", b = "pointer-events-none absolute inset-0 rounded-[inherit] shadow-[inset_0_0_0_1px_var(--colors-delta-300)]", k = ({ dataTest: s, title: a, titleId: m, children: x, viewResultsAction: t, resetAction: l, footerActions: i, closeLabel: p, onClose: f }) => {
|
|
8
|
+
const n = v(null), d = u(n);
|
|
9
|
+
return /* @__PURE__ */ o(g, { children: [
|
|
10
|
+
/* @__PURE__ */ o("div", {
|
|
11
11
|
className: "relative flex min-h-0 flex-1 flex-col",
|
|
12
|
-
children: [
|
|
12
|
+
children: [a && /* @__PURE__ */ e("div", {
|
|
13
13
|
id: m,
|
|
14
14
|
className: "shrink-0 truncate pb-1 pl-4 pr-10 pt-2 text-lg font-semibold leading-7 text-delta-800",
|
|
15
|
-
children:
|
|
15
|
+
children: a
|
|
16
16
|
}), /* @__PURE__ */ e("div", {
|
|
17
17
|
ref: n,
|
|
18
|
-
className:
|
|
19
|
-
style: { paddingRight: Math.max(0,
|
|
20
|
-
children:
|
|
18
|
+
className: r("flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto py-2 pl-4 [scrollbar-gutter:stable]", !a && d.overflows && "mt-10"),
|
|
19
|
+
style: { paddingRight: Math.max(0, _ - d.width) },
|
|
20
|
+
children: x
|
|
21
21
|
})]
|
|
22
22
|
}),
|
|
23
|
-
(
|
|
24
|
-
className:
|
|
25
|
-
children: [
|
|
23
|
+
(t ?? l) && /* @__PURE__ */ o("div", {
|
|
24
|
+
className: r("flex shrink-0 items-start p-1", t ? "justify-between" : "justify-end", "max-xs:flex-wrap max-xs:gap-y-2 max-xs:[&>:last-child]:ml-auto"),
|
|
25
|
+
children: [t, l]
|
|
26
26
|
}),
|
|
27
27
|
i && /* @__PURE__ */ e("div", {
|
|
28
|
-
className: "flex shrink-0 flex-col items-end p-3",
|
|
28
|
+
className: r("flex shrink-0 flex-col items-end p-3", (t ?? l) && "max-xs:pt-1"),
|
|
29
29
|
children: i
|
|
30
30
|
}),
|
|
31
31
|
/* @__PURE__ */ e("div", {
|
|
32
32
|
className: "absolute right-0 top-0",
|
|
33
|
-
children: /* @__PURE__ */ e(
|
|
34
|
-
dataTest: `${
|
|
33
|
+
children: /* @__PURE__ */ e(c, {
|
|
34
|
+
dataTest: `${s}-close`,
|
|
35
35
|
variant: "textGray",
|
|
36
36
|
type: "button",
|
|
37
|
-
"aria-label":
|
|
38
|
-
onClick:
|
|
39
|
-
startIcon: /* @__PURE__ */ e(
|
|
37
|
+
"aria-label": p,
|
|
38
|
+
onClick: f,
|
|
39
|
+
startIcon: /* @__PURE__ */ e(h, {
|
|
40
40
|
width: 24,
|
|
41
41
|
height: 24
|
|
42
42
|
})
|
|
@@ -44,7 +44,7 @@ var g = 40, j = "relative box-border flex flex-col overflow-hidden rounded-lg bg
|
|
|
44
44
|
}),
|
|
45
45
|
/* @__PURE__ */ e("span", {
|
|
46
46
|
"aria-hidden": !0,
|
|
47
|
-
"data-test": `${
|
|
47
|
+
"data-test": `${s}-edge`,
|
|
48
48
|
className: b
|
|
49
49
|
})
|
|
50
50
|
] });
|
|
@@ -16,10 +16,11 @@ function e(t) {
|
|
|
16
16
|
return o(a, i, u);
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
var h = e("(max-width: 743px)"), s = e("(max-height: 480px)"), c = e("(max-height: 480px) and (min-width: 480px)"), m = e("(max-width: 743px), (max-height: 480px)");
|
|
19
|
+
var h = e("(max-width: 743px)"), s = e("not all and (min-width: 320px)"), x = e("(max-height: 480px)"), c = e("(max-height: 480px) and (min-width: 480px)"), m = e("(max-width: 743px), (max-height: 480px)");
|
|
20
20
|
export {
|
|
21
21
|
m as useFullScreenPickerMediaQuery,
|
|
22
|
+
s as useMaxXsMediaQuery,
|
|
22
23
|
h as useMobileMediaQuery,
|
|
23
24
|
c as usePickerOneRowHeaderMediaQuery,
|
|
24
|
-
|
|
25
|
+
x as useShortViewportMediaQuery
|
|
25
26
|
};
|
|
@@ -29,8 +29,10 @@ export declare function SearchSlot({ search, expanded, measureRef, }: {
|
|
|
29
29
|
measureRef?: MeasureRef;
|
|
30
30
|
}): JSX.Element;
|
|
31
31
|
/** Keeps children mounted while hidden so slots fade instead of popping. */
|
|
32
|
-
export declare function FadeSlot({ visible, children }: {
|
|
32
|
+
export declare function FadeSlot({ visible, flattenBelowXs, children, }: {
|
|
33
33
|
visible: boolean;
|
|
34
|
+
/** Below xs, drops both wrappers so each child wraps as its own item of the parent row. */
|
|
35
|
+
flattenBelowXs?: boolean;
|
|
34
36
|
children: ReactNode;
|
|
35
37
|
}): JSX.Element;
|
|
36
38
|
export declare function TitleText({ title, measureRef }: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare function makeMediaQueryStore(mediaQuery: string): () => boolean;
|
|
2
2
|
export declare const useMobileMediaQuery: () => boolean;
|
|
3
|
+
/** Narrower than any phone — the same query as the `max-xs:` Tailwind variant (tailwind.config.ts). */
|
|
4
|
+
export declare const useMaxXsMediaQuery: () => boolean;
|
|
3
5
|
/** A phone in landscape: too short for a sheet capped at 90vh to leave a usable body. */
|
|
4
6
|
export declare const useShortViewportMediaQuery: () => boolean;
|
|
5
7
|
/**
|
|
@@ -77,6 +77,14 @@ export type StyledTableProps<TData, TCustomData> = {
|
|
|
77
77
|
customActionsNode?: (row: CellContext<TData, unknown>) => ReactNode;
|
|
78
78
|
customSubRowData?: Map<string, TCustomData[]>;
|
|
79
79
|
headerPin?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Pins the internal actions column's body cells to the right edge. By default they are pinned
|
|
82
|
+
* when the column renders actions (`actions` / `customActionsNode`) or the table has fixed-right
|
|
83
|
+
* columns; a column that only hosts the header pin menu scrolls with the data. The header cell
|
|
84
|
+
* with the pin menu stays pinned either way. Not supported as `false` together with fixed-right
|
|
85
|
+
* columns: their body and header offsets would no longer match.
|
|
86
|
+
*/
|
|
87
|
+
stickyActions?: boolean;
|
|
80
88
|
expandArrow?: boolean;
|
|
81
89
|
defaultExpanded?: boolean;
|
|
82
90
|
loading?: boolean;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { ACTIONS_COLUMN_ID as
|
|
2
|
-
import { useRootContext as
|
|
1
|
+
import { ACTIONS_COLUMN_ID as w, INTERNAL_COLUMN_IDS as Re } from "../types.js";
|
|
2
|
+
import { useRootContext as Se } from "../context/RootContext.js";
|
|
3
3
|
import n from "./StyledTable.module.js";
|
|
4
|
-
import { compact as
|
|
5
|
-
import
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { useSortable as
|
|
9
|
-
import { flexRender as
|
|
10
|
-
import { CSS as
|
|
11
|
-
var
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
const
|
|
4
|
+
import { compact as De } from "../../helpers/arrays.js";
|
|
5
|
+
import V from "clsx";
|
|
6
|
+
import { Fragment as Ne, useCallback as Y, useEffect as ve, useLayoutEffect as Ee, useMemo as R, useRef as Ie, useState as ye } from "react";
|
|
7
|
+
import { Fragment as Te, jsx as s, jsxs as S } from "react/jsx-runtime";
|
|
8
|
+
import { useSortable as ke } from "@dnd-kit/sortable";
|
|
9
|
+
import { flexRender as Fe } from "@tanstack/react-table";
|
|
10
|
+
import { CSS as Ae } from "@dnd-kit/utilities";
|
|
11
|
+
var J = (D, t) => {
|
|
12
|
+
const g = D.closest("table");
|
|
13
|
+
if (!g) return !1;
|
|
14
|
+
const N = t === "next" ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING, r = Array.from(document.querySelectorAll('a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])')).filter((p) => !g.contains(p) && !!(g.compareDocumentPosition(p) & N)), l = t === "next" ? r[0] : r.at(-1);
|
|
15
15
|
return l ? (l.focus(), document.activeElement === l) : !1;
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
const { loading:
|
|
17
|
+
function je({ styledTableProps: D, row: t, index: g, hasFocusedRow: N, columnWindow: { paddingLeft: r, paddingRight: l, indexes: p } }) {
|
|
18
|
+
const { loading: Q, getRowClassName: a, activeRowId: _, rowHeight: x, onRowClick: v, expandArrow: X, enableDnd: B, disableDndForRow: Z, tdClassName: H, customSubRowData: U, renderSubRows: ee, defaultExpanded: te, actions: E, customActionsNode: ne, stickyActions: ie, textExpandArrow: z, enableMultiRowSelection: oe, enableRowSelection: se, singleSelectionRow: le } = D, I = Z?.(t), { transform: ae, transition: ce, setNodeRef: W, isDragging: P } = ke({
|
|
19
19
|
id: t.original.id,
|
|
20
|
-
disabled: !
|
|
21
|
-
}),
|
|
22
|
-
transform:
|
|
23
|
-
transition:
|
|
24
|
-
opacity:
|
|
25
|
-
zIndex:
|
|
20
|
+
disabled: !B || I
|
|
21
|
+
}), de = {
|
|
22
|
+
transform: Ae.Transform.toString(ae),
|
|
23
|
+
transition: ce,
|
|
24
|
+
opacity: P ? 0.8 : 1,
|
|
25
|
+
zIndex: P ? 1 : 0,
|
|
26
26
|
position: "relative"
|
|
27
|
-
}, { isResizing:
|
|
28
|
-
|
|
29
|
-
!
|
|
30
|
-
}, [
|
|
31
|
-
const
|
|
32
|
-
C.current = e,
|
|
33
|
-
}, [
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
}, { isResizing: re, disableResizingFlag: ue } = Se(), y = t.isExpanded(), C = Ie(null), [fe, me] = ye(void 0);
|
|
28
|
+
Ee(() => {
|
|
29
|
+
!y && C.current && me(C.current.cells[0]?.clientHeight ?? C.current.offsetHeight);
|
|
30
|
+
}, [y]);
|
|
31
|
+
const ge = Y((e) => {
|
|
32
|
+
C.current = e, I || W(e);
|
|
33
|
+
}, [I, W]), $ = y ? fe ?? x : x;
|
|
34
|
+
ve(() => {
|
|
35
|
+
te && t.getCanExpand() && !t.getIsExpanded() && t.toggleExpand();
|
|
36
36
|
}, []);
|
|
37
|
-
const
|
|
38
|
-
t.getCanExpand() && !
|
|
39
|
-
const i = window.getSelection()?.type !== "Range" && !
|
|
40
|
-
!o &&
|
|
41
|
-
},
|
|
42
|
-
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") ||
|
|
43
|
-
},
|
|
37
|
+
const j = (e) => {
|
|
38
|
+
t.getCanExpand() && !X && t.getToggleExpandedHandler()(), document.getElementById(t.id)?.focus();
|
|
39
|
+
const i = window.getSelection()?.type !== "Range" && !re, o = v instanceof Function;
|
|
40
|
+
!o && z && i ? t.toggleExpand() : o && i && v(e, t), ue();
|
|
41
|
+
}, he = (e) => {
|
|
42
|
+
e.target.classList.contains("MuiModal-backdrop") || e.target.nodeName === "INPUT" || e.target.nodeName === "BUTTON" || e.target.nodeName === "LI" || e.target.closest("li") || j(e);
|
|
43
|
+
}, pe = (e) => {
|
|
44
44
|
if (e.target === e.currentTarget)
|
|
45
45
|
switch (e.key) {
|
|
46
46
|
case "Tab":
|
|
47
47
|
if (e.shiftKey) {
|
|
48
48
|
const i = e.currentTarget.closest("table")?.querySelector('thead tr[tabindex="0"]');
|
|
49
|
-
i ? (e.preventDefault(), i.focus()) :
|
|
50
|
-
} else
|
|
49
|
+
i ? (e.preventDefault(), i.focus()) : J(e.currentTarget, "prev") && e.preventDefault();
|
|
50
|
+
} else J(e.currentTarget, "next") && e.preventDefault();
|
|
51
51
|
break;
|
|
52
52
|
case "ArrowDown":
|
|
53
53
|
t.focusNextRow() && e.preventDefault();
|
|
@@ -56,32 +56,32 @@ function We({ styledTableProps: R, row: t, index: f, hasFocusedRow: S, columnWin
|
|
|
56
56
|
t.focusPrevRow() && e.preventDefault();
|
|
57
57
|
break;
|
|
58
58
|
case "Enter":
|
|
59
|
-
e.preventDefault(),
|
|
59
|
+
e.preventDefault(), j(e);
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
|
-
},
|
|
62
|
+
}, c = t.getVisibleCells().map((e, i, o) => ({
|
|
63
63
|
...e,
|
|
64
|
-
left: o.slice(0, i).reduce((
|
|
65
|
-
})),
|
|
64
|
+
left: o.slice(0, i).reduce((f, m) => f + (m.column.getSize() ?? 0), 0)
|
|
65
|
+
})), T = !!E || !!ne, k = c.some((e) => !!e.column.columnDef.fixedRight), d = ie ?? (T || k), q = R(() => c.filter((e) => !e.column.columnDef.fixedLeft && !e.column.columnDef.fixedRight && e.column.id !== "actions"), [c]), h = R(() => c.filter((e) => !!e.column.columnDef.fixedRight || e.column.id === "actions" && d).map((e, i, o) => ({
|
|
66
66
|
...e,
|
|
67
|
-
right: o.slice(i + 1).reduce((
|
|
68
|
-
})), [
|
|
69
|
-
const o = e.column.id ===
|
|
67
|
+
right: o.slice(i + 1).reduce((f, m) => f + (m.column.getSize() ?? 0), 0)
|
|
68
|
+
})), [c, d]), G = R(() => h.some((e) => e.column.id === w), [h]), K = d ? void 0 : c.find((e) => e.column.id === w), u = R(() => c.filter((e) => e.column.columnDef.fixedLeft), [c]), F = !oe && !se && le, A = t.getIsSelected() && F, L = v instanceof Function, M = p.length > 0 ? De(p.map((e) => q[e])) : q, b = Y((e, i) => {
|
|
69
|
+
const o = e.column.id === w, f = e.column.columnDef.fixedLeft, m = !!e.column.columnDef.fixedRight, xe = e.id === u.at(-1)?.id, Ce = e.id === h.at(0)?.id && !o, be = t.isExpanded(), O = i === 0;
|
|
70
70
|
return /* @__PURE__ */ s("td", {
|
|
71
|
-
className:
|
|
71
|
+
className: V(n["t-cell"], !Re.includes(e.column.id) && e.column.getSize() > 64 && n["data-cell"], e.column.id === "select" && n["select-cell"], L && "cursor-pointer", H, o && d && n["action-cell"], o && d && (!T || k) && n["action-cell--no-shadow"], o && d && !!E && u.length && n.shadowed, o && d && (a?.(t) ? a?.(t) : n["action-cell-default-background"]), f && n["fixed-cell"], m && n["fixed-right-cell"], xe && n.shadowed, Ce && n["shadowed-right"], t.getIsSelected() && n.selected, f && (a?.(t) ? a?.(t) : n["fixed-cell-default-background"]), m && (a?.(t) ? a?.(t) : n["fixed-right-cell-default-background"]), be && n.expanded_row, !!A && n["single-selection"]),
|
|
72
72
|
style: {
|
|
73
|
-
left:
|
|
74
|
-
right:
|
|
73
|
+
left: f ? e.left : void 0,
|
|
74
|
+
right: m ? e.right + (G ? -1 : 0) : void 0
|
|
75
75
|
},
|
|
76
|
-
children: /* @__PURE__ */
|
|
76
|
+
children: /* @__PURE__ */ S("div", {
|
|
77
77
|
style: {
|
|
78
78
|
display: "flex",
|
|
79
79
|
alignItems: "center",
|
|
80
|
-
minWidth:
|
|
81
|
-
minHeight:
|
|
80
|
+
minWidth: O ? 32 : void 0,
|
|
81
|
+
minHeight: $,
|
|
82
82
|
position: "relative"
|
|
83
83
|
},
|
|
84
|
-
children: [
|
|
84
|
+
children: [O && A && /* @__PURE__ */ s("span", {
|
|
85
85
|
style: {
|
|
86
86
|
display: "inline-flex",
|
|
87
87
|
alignItems: "center",
|
|
@@ -90,66 +90,67 @@ function We({ styledTableProps: R, row: t, index: f, hasFocusedRow: S, columnWin
|
|
|
90
90
|
top: "50%",
|
|
91
91
|
transform: "translateY(-50%)"
|
|
92
92
|
},
|
|
93
|
-
children: /* @__PURE__ */ s(
|
|
93
|
+
children: /* @__PURE__ */ s(Le, {})
|
|
94
94
|
}), /* @__PURE__ */ s("span", {
|
|
95
95
|
style: {
|
|
96
|
-
marginLeft:
|
|
96
|
+
marginLeft: O && F ? 30 : 0,
|
|
97
97
|
width: "100%"
|
|
98
98
|
},
|
|
99
|
-
children:
|
|
99
|
+
children: Fe(e.column.columnDef.cell, e.getContext())
|
|
100
100
|
})]
|
|
101
101
|
})
|
|
102
102
|
}, e.id);
|
|
103
103
|
}, [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
A,
|
|
105
|
+
E,
|
|
106
|
+
$,
|
|
107
107
|
a,
|
|
108
|
+
L,
|
|
109
|
+
G,
|
|
110
|
+
k,
|
|
111
|
+
u,
|
|
112
|
+
h,
|
|
113
|
+
t,
|
|
108
114
|
T,
|
|
109
|
-
W,
|
|
110
|
-
$,
|
|
111
|
-
g,
|
|
112
115
|
d,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
I,
|
|
116
|
-
O
|
|
116
|
+
F,
|
|
117
|
+
H
|
|
117
118
|
]);
|
|
118
|
-
return /* @__PURE__ */
|
|
119
|
+
return /* @__PURE__ */ S(Ne, { children: [/* @__PURE__ */ S("tr", {
|
|
119
120
|
"aria-selected": t.getIsSelected() || t.isFocused() ? "true" : "false",
|
|
120
|
-
tabIndex: t.isFocused() ||
|
|
121
|
-
"data-index":
|
|
121
|
+
tabIndex: t.isFocused() || g === 0 && !N ? 0 : -1,
|
|
122
|
+
"data-index": g,
|
|
122
123
|
"data-test": t.id,
|
|
123
|
-
"data-active":
|
|
124
|
+
"data-active": _ != null && t.id === _ ? "true" : void 0,
|
|
124
125
|
id: t.id,
|
|
125
|
-
className:
|
|
126
|
+
className: V(n["t-row"], Q && n["is-loading"], a?.(t)),
|
|
126
127
|
style: {
|
|
127
128
|
height: x ? `${x}px` : "inherit",
|
|
128
|
-
...
|
|
129
|
+
...B && de
|
|
129
130
|
},
|
|
130
|
-
ref:
|
|
131
|
+
ref: ge,
|
|
131
132
|
onFocus: (e) => {
|
|
132
133
|
e.target === e.currentTarget && !t.isFocused() && t.onChangeFocused(!0);
|
|
133
134
|
},
|
|
134
|
-
onMouseUp:
|
|
135
|
+
onMouseUp: he,
|
|
135
136
|
onMouseDown: (e) => {
|
|
136
|
-
e.detail > 1 && !
|
|
137
|
+
e.detail > 1 && !L && z && e.preventDefault();
|
|
137
138
|
},
|
|
138
|
-
onKeyDownCapture:
|
|
139
|
+
onKeyDownCapture: pe,
|
|
139
140
|
children: [
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
u.map((e, i) => b(e, i)),
|
|
142
|
+
r > 0 && /* @__PURE__ */ s("td", {
|
|
142
143
|
"aria-hidden": !0,
|
|
143
144
|
className: n["t-cell"],
|
|
144
145
|
style: {
|
|
145
|
-
width: String(
|
|
146
|
-
minWidth: String(
|
|
147
|
-
maxWidth: String(
|
|
146
|
+
width: String(r) + "px",
|
|
147
|
+
minWidth: String(r) + "px",
|
|
148
|
+
maxWidth: String(r) + "px",
|
|
148
149
|
padding: 0,
|
|
149
150
|
border: "none"
|
|
150
151
|
}
|
|
151
152
|
}),
|
|
152
|
-
|
|
153
|
+
M.map((e, i) => b(e, u.length + i)),
|
|
153
154
|
l > 0 && /* @__PURE__ */ s("td", {
|
|
154
155
|
"aria-hidden": !0,
|
|
155
156
|
className: n["t-cell"],
|
|
@@ -161,14 +162,15 @@ function We({ styledTableProps: R, row: t, index: f, hasFocusedRow: S, columnWin
|
|
|
161
162
|
border: "none"
|
|
162
163
|
}
|
|
163
164
|
}),
|
|
164
|
-
|
|
165
|
+
h.map((e, i) => b(e, u.length + M.length + i)),
|
|
166
|
+
K && b(K, u.length + M.length + h.length)
|
|
165
167
|
]
|
|
166
|
-
}), t.getIsExpanded() && /* @__PURE__ */ s(
|
|
167
|
-
rows:
|
|
168
|
+
}), t.getIsExpanded() && /* @__PURE__ */ s(Te, { children: U && ee?.({
|
|
169
|
+
rows: U.get(t.original.id.toString()) ?? [],
|
|
168
170
|
row: t.original
|
|
169
171
|
}) })] }, t.id);
|
|
170
172
|
}
|
|
171
|
-
var
|
|
173
|
+
var Le = () => /* @__PURE__ */ S("svg", {
|
|
172
174
|
xmlns: "http://www.w3.org/2000/svg",
|
|
173
175
|
width: "20",
|
|
174
176
|
height: "20",
|
|
@@ -180,5 +182,5 @@ var Fe = () => /* @__PURE__ */ b("svg", {
|
|
|
180
182
|
})]
|
|
181
183
|
});
|
|
182
184
|
export {
|
|
183
|
-
|
|
185
|
+
je as TableRow
|
|
184
186
|
};
|