asma-ui-core 3.88.0 → 3.89.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/Readme.md +61 -0
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +6 -6
- package/dist/components/utils/popover/PopoverAnatomy.js +46 -0
- package/dist/components/utils/popover/StyledPopoverV2.js +140 -0
- package/dist/index.js +180 -178
- package/dist/src/components/utils/popover/PopoverAnatomy.d.ts +36 -0
- package/dist/src/components/utils/popover/StyledPopoverV2.d.ts +76 -0
- package/dist/src/components/utils/popover/index.d.ts +1 -0
- package/dist/src/components/utils/popover/story/PopoverCases.d.ts +1 -0
- package/dist/src/components/utils/popover/story/PopoverGallery.d.ts +1 -0
- package/dist/src/components/utils/popover/story/popoverStoryFixtures.d.ts +21 -0
- package/dist/table/components/TableRow.js +50 -49
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Sample data lifted from the Figma "Popover" frames so the stories read like the design. */
|
|
2
|
+
export declare const KARTLEGGING: string[];
|
|
3
|
+
export declare const EGENRAPPORTERING: string[];
|
|
4
|
+
export interface FilterState {
|
|
5
|
+
kartlegging: string[];
|
|
6
|
+
egenrapportering: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const EMPTY_FILTER: FilterState;
|
|
9
|
+
export declare const noop: () => void;
|
|
10
|
+
/** How many results the mock list reports for a given number of active criteria. */
|
|
11
|
+
export declare const matchCountFor: (activeCount: number) => number;
|
|
12
|
+
export declare const countActive: (filter: FilterState) => number;
|
|
13
|
+
export declare const toggleInList: (list: string[], option: string) => string[];
|
|
14
|
+
/** The Figma "Chips select" group — a heading plus a wrapping row of checkbox/radio chips. */
|
|
15
|
+
export declare const ChipGroup: ({ heading, options, isSelected, onToggle, type, }: {
|
|
16
|
+
heading: string;
|
|
17
|
+
options: string[];
|
|
18
|
+
isSelected: (option: string) => boolean;
|
|
19
|
+
onToggle: (option: string) => void;
|
|
20
|
+
type: "checkbox" | "radio";
|
|
21
|
+
}) => JSX.Element;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
import { ACTIONS_COLUMN_ID as j } from "../types.js";
|
|
2
|
-
import { useRootContext as
|
|
2
|
+
import { useRootContext as he } from "../context/RootContext.js";
|
|
3
3
|
import n from "./StyledTable.module.js";
|
|
4
|
-
import { compact as
|
|
4
|
+
import { compact as pe } from "../../helpers/arrays.js";
|
|
5
5
|
import q from "clsx";
|
|
6
|
-
import { Fragment as
|
|
7
|
-
import { Fragment as
|
|
8
|
-
import { useSortable as
|
|
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
|
|
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
|
|
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,
|
|
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 ||
|
|
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 } =
|
|
28
|
-
|
|
29
|
-
!
|
|
30
|
-
}, [
|
|
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,
|
|
33
|
-
}, [
|
|
34
|
-
|
|
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]),
|
|
50
|
-
const i = e.column.id === j, c = e.column.columnDef.fixedLeft, d = !!e.column.columnDef.fixedRight,
|
|
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"],
|
|
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(
|
|
97
|
+
children: /* @__PURE__ */ s(ke, {})
|
|
75
98
|
}), /* @__PURE__ */ s("span", {
|
|
76
99
|
style: {
|
|
77
|
-
marginLeft: I &&
|
|
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
|
-
|
|
119
|
+
N,
|
|
97
120
|
A
|
|
98
121
|
]);
|
|
99
|
-
return /* @__PURE__ */ C(
|
|
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
|
-
|
|
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(
|
|
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
|
|
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
|
-
|
|
186
|
+
Ue as TableRow
|
|
186
187
|
};
|