@altinn/altinn-components 0.56.11 → 0.56.12
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/assets/AccountListVirtual.css +1 -1
- package/dist/components/Account/AccountListVirtual.js +23 -23
- package/dist/components/Toolbar/ToolbarFilterMenu.js +40 -40
- package/dist/components/Toolbar/ToolbarMenu.js +11 -11
- package/dist/components/Toolbar/example.data.js +19 -19
- package/dist/components/Toolbar/example.hooks.js +25 -25
- package/dist/types/lib/components/Toolbar/Toolbar.stories.d.ts +6 -6
- package/dist/types/lib/components/Toolbar/example.hooks.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._virtualScrollRef_1ahkg_1{height:100vh;overflow-y:auto;overflow-x:hidden;padding:0 .5rem;margin:0 -.5rem}._virtualList_1ahkg_9{list-style-type:none;padding:0;margin:0;isolation:isolate}._virtualListItem_1ahkg_16{position:absolute;top:0;left:0;width:100%}._virtualListItem_1ahkg_16:focus-within,._virtualListItem_1ahkg_16:has([aria-expanded=true]){z-index:20}._virtualListItem_1ahkg_16>*{margin:0}._lastChild_1ahkg_32{padding-bottom:1rem}._virtualTitleItem_1ahkg_36{position:absolute;top:0;left:0;width:100%;padding-top:1rem;padding-bottom:1rem}._virtualTitleItem_1ahkg_36:first-child{padding-top:0}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { u as y } from "../../useMenuVirtualization-Cs426RCN.js";
|
|
4
|
-
import { useRef as
|
|
4
|
+
import { useRef as h, useEffect as I } from "react";
|
|
5
5
|
import "../../index-p1eeF8LQ.js";
|
|
6
6
|
import { AccountListItem as v } from "./AccountListItem.js";
|
|
7
7
|
import { useMenu as x } from "../../hooks/useMenu.js";
|
|
8
|
-
import { Heading as
|
|
8
|
+
import { Heading as g } from "../Typography/Heading.js";
|
|
9
9
|
import "../Button/Button.js";
|
|
10
10
|
import "react-dom";
|
|
11
11
|
import "../RootProvider/RootProvider.js";
|
|
12
12
|
import "../Snackbar/useSnackbar.js";
|
|
13
|
-
import { Section as
|
|
14
|
-
import '../../assets/AccountListVirtual.css';const
|
|
15
|
-
virtualScrollRef:
|
|
13
|
+
import { Section as _ } from "../Page/Section.js";
|
|
14
|
+
import '../../assets/AccountListVirtual.css';const L = "_virtualScrollRef_1ahkg_1", S = "_virtualList_1ahkg_9", k = "_virtualListItem_1ahkg_16", $ = "_lastChild_1ahkg_32", C = "_virtualTitleItem_1ahkg_36", l = {
|
|
15
|
+
virtualScrollRef: L,
|
|
16
16
|
virtualList: S,
|
|
17
|
-
virtualListItem:
|
|
18
|
-
lastChild:
|
|
19
|
-
virtualTitleItem:
|
|
17
|
+
virtualListItem: k,
|
|
18
|
+
lastChild: $,
|
|
19
|
+
virtualTitleItem: C
|
|
20
20
|
}, B = ({ items: u, groups: p = {}, sortGroupBy: d }) => {
|
|
21
|
-
const s =
|
|
21
|
+
const s = h(null), { menu: f } = x({
|
|
22
22
|
items: u,
|
|
23
23
|
groups: p,
|
|
24
24
|
groupByKey: "groupId",
|
|
25
25
|
keyboardEvents: !1,
|
|
26
26
|
sortGroupBy: d
|
|
27
27
|
}), n = f.flatMap((t) => {
|
|
28
|
-
const e = t?.props || {}, { title: r } = e,
|
|
28
|
+
const e = t?.props || {}, { title: r } = e, a = t?.items || [];
|
|
29
29
|
return [
|
|
30
30
|
...r ? [{ type: "title", title: r }] : [],
|
|
31
|
-
...
|
|
31
|
+
...a.map((c) => ({
|
|
32
32
|
type: "item",
|
|
33
|
-
itemProps:
|
|
33
|
+
itemProps: c.props || {}
|
|
34
34
|
}))
|
|
35
35
|
];
|
|
36
|
-
}),
|
|
36
|
+
}), o = y({
|
|
37
37
|
count: n.length,
|
|
38
38
|
useAnimationFrameWithResizeObserver: !0,
|
|
39
39
|
gap: 8,
|
|
@@ -45,21 +45,21 @@ import '../../assets/AccountListVirtual.css';const g = "_virtualScrollRef_6cuj6_
|
|
|
45
45
|
return e.itemProps?.parentId && (!r || r.type === "title" || r.type === "item" && !r.itemProps?.parentId) ? 96 : 80;
|
|
46
46
|
},
|
|
47
47
|
getScrollElement: () => s.current
|
|
48
|
-
}),
|
|
49
|
-
return
|
|
50
|
-
for (const t of
|
|
48
|
+
}), m = o.getVirtualItems();
|
|
49
|
+
return I(() => {
|
|
50
|
+
for (const t of m) {
|
|
51
51
|
const e = s.current?.querySelector(`[data-index="${t.index}"]`) ?? s.current?.querySelector(`[dataindex="${t.index}"]`) ?? s.current?.querySelector(`[dataIndex="${t.index}"]`);
|
|
52
|
-
e &&
|
|
52
|
+
e && o.measureElement(e);
|
|
53
53
|
}
|
|
54
|
-
}, [
|
|
54
|
+
}, [m]), /* @__PURE__ */ i(_, { spacing: 6, children: /* @__PURE__ */ i("div", { ref: s, className: l.virtualScrollRef, children: /* @__PURE__ */ i(
|
|
55
55
|
"ul",
|
|
56
56
|
{
|
|
57
57
|
className: l.virtualList,
|
|
58
58
|
style: {
|
|
59
59
|
position: "relative",
|
|
60
|
-
height: `${
|
|
60
|
+
height: `${o.getTotalSize()}px`
|
|
61
61
|
},
|
|
62
|
-
children:
|
|
62
|
+
children: m.map((t) => {
|
|
63
63
|
const e = n[t.index];
|
|
64
64
|
if (!e) return null;
|
|
65
65
|
if (e.type === "title")
|
|
@@ -69,17 +69,17 @@ import '../../assets/AccountListVirtual.css';const g = "_virtualScrollRef_6cuj6_
|
|
|
69
69
|
"data-index": t.index,
|
|
70
70
|
className: l.virtualTitleItem,
|
|
71
71
|
style: { transform: `translateY(${t.start}px)` },
|
|
72
|
-
children: /* @__PURE__ */ i(
|
|
72
|
+
children: /* @__PURE__ */ i(g, { size: "lg", children: e.title })
|
|
73
73
|
},
|
|
74
74
|
t.key
|
|
75
75
|
);
|
|
76
76
|
if (e.type === "item") {
|
|
77
|
-
const r = n[t.index + 1],
|
|
77
|
+
const r = n[t.index + 1], a = e.itemProps?.parentId && (!r || r.type === "title" || r.type === "item" && !r.itemProps?.parentId);
|
|
78
78
|
return /* @__PURE__ */ i(
|
|
79
79
|
"li",
|
|
80
80
|
{
|
|
81
81
|
"data-index": t.index,
|
|
82
|
-
className: `${l.virtualListItem} ${
|
|
82
|
+
className: `${l.virtualListItem} ${a ? l.lastChild : ""}`,
|
|
83
83
|
style: { transform: `translateY(${t.start}px)` },
|
|
84
84
|
children: /* @__PURE__ */ i(v, { ...e.itemProps, containerAs: "div" })
|
|
85
85
|
},
|
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as q, useEffect as G } from "react";
|
|
3
3
|
import "../../index-p1eeF8LQ.js";
|
|
4
4
|
import "../Button/Button.js";
|
|
5
|
-
import { M as
|
|
6
|
-
import { useDropdownMenuController as
|
|
5
|
+
import { M as H } from "../../SearchField-CYYz0JvC.js";
|
|
6
|
+
import { useDropdownMenuController as J } from "../Menu/useDropdownMenuController.js";
|
|
7
7
|
import "../RootProvider/RootProvider.js";
|
|
8
8
|
import "../Snackbar/useSnackbar.js";
|
|
9
|
-
import { Dropdown as
|
|
10
|
-
import { ToolbarFilterButton as
|
|
9
|
+
import { Dropdown as F } from "../Dropdown/Dropdown.js";
|
|
10
|
+
import { ToolbarFilterButton as P } from "./ToolbarFilterButton.js";
|
|
11
11
|
const S = ({
|
|
12
|
-
as:
|
|
12
|
+
as: E,
|
|
13
13
|
size: a,
|
|
14
14
|
name: o,
|
|
15
15
|
label: f = "",
|
|
16
|
-
searchable:
|
|
16
|
+
searchable: d,
|
|
17
17
|
groups: p,
|
|
18
18
|
items: g,
|
|
19
|
-
removable:
|
|
20
|
-
removeLabel:
|
|
19
|
+
removable: j,
|
|
20
|
+
removeLabel: D = "Fjern filter",
|
|
21
21
|
filterState: c,
|
|
22
22
|
onFilterStateChange: v,
|
|
23
|
-
onFilterChange:
|
|
23
|
+
onFilterChange: O,
|
|
24
24
|
onRemove: h,
|
|
25
25
|
open: t,
|
|
26
26
|
onToggle: y,
|
|
27
|
-
onClose:
|
|
27
|
+
onClose: m,
|
|
28
28
|
submitLabel: b,
|
|
29
29
|
search: k,
|
|
30
30
|
virtualized: w,
|
|
31
31
|
title: I,
|
|
32
|
-
variant:
|
|
33
|
-
dropdownSize:
|
|
32
|
+
variant: x,
|
|
33
|
+
dropdownSize: A = "sm"
|
|
34
34
|
}) => {
|
|
35
|
-
const M =
|
|
36
|
-
|
|
35
|
+
const M = q(t), e = J({ id: "toolbar-filter-menu" });
|
|
36
|
+
G(() => {
|
|
37
37
|
const r = M.current;
|
|
38
38
|
M.current = t, r && !t && e?.triggerRef?.current?.focus();
|
|
39
39
|
}, [t, e.triggerRef]);
|
|
40
|
-
const
|
|
41
|
-
const i = r.target.type,
|
|
42
|
-
|
|
43
|
-
},
|
|
40
|
+
const V = (r) => {
|
|
41
|
+
const i = r.target.type, u = r.target.name, T = r.target.value;
|
|
42
|
+
O?.(i, u, T), i === "radio" && m();
|
|
43
|
+
}, l = g?.map((r) => ({
|
|
44
44
|
...r,
|
|
45
|
-
onChange: (i) =>
|
|
46
|
-
})),
|
|
47
|
-
|
|
45
|
+
onChange: (i) => V(i)
|
|
46
|
+
})), R = (g?.filter((r) => r.checked)?.map((r) => r.value || "true")).length > 0 || c?.[o]?.length ? "tinted" : "outline", C = E || H, s = d ? "combobox" : "menu", B = () => {
|
|
47
|
+
m();
|
|
48
48
|
const r = c?.[o]?.[0];
|
|
49
|
-
|
|
49
|
+
l?.filter((u) => u.checked)?.length === 0 && !r && h?.();
|
|
50
50
|
};
|
|
51
|
-
return
|
|
52
|
-
|
|
51
|
+
return j ? /* @__PURE__ */ n(
|
|
52
|
+
F,
|
|
53
53
|
{
|
|
54
54
|
submitLabel: b,
|
|
55
55
|
title: I,
|
|
56
56
|
variant: "drawer-dropdown",
|
|
57
|
-
size:
|
|
57
|
+
size: A,
|
|
58
58
|
trigger: /* @__PURE__ */ n(
|
|
59
|
-
|
|
59
|
+
P,
|
|
60
60
|
{
|
|
61
61
|
name: o,
|
|
62
62
|
onClick: y,
|
|
63
63
|
onRemove: h,
|
|
64
64
|
removable: !0,
|
|
65
|
-
variant:
|
|
66
|
-
removeLabel:
|
|
65
|
+
variant: x || R,
|
|
66
|
+
removeLabel: D,
|
|
67
67
|
open: t,
|
|
68
68
|
"aria-expanded": t,
|
|
69
69
|
"aria-controls": e.menuId,
|
|
@@ -72,10 +72,10 @@ const S = ({
|
|
|
72
72
|
}
|
|
73
73
|
),
|
|
74
74
|
open: t,
|
|
75
|
-
onClose:
|
|
75
|
+
onClose: B,
|
|
76
76
|
...e.dropdownA11yProps,
|
|
77
77
|
children: /* @__PURE__ */ n(
|
|
78
|
-
|
|
78
|
+
C,
|
|
79
79
|
{
|
|
80
80
|
open: t,
|
|
81
81
|
search: k,
|
|
@@ -83,9 +83,9 @@ const S = ({
|
|
|
83
83
|
filterState: c,
|
|
84
84
|
onFilterStateChange: v,
|
|
85
85
|
size: a,
|
|
86
|
-
searchable:
|
|
86
|
+
searchable: d,
|
|
87
87
|
groups: p,
|
|
88
|
-
items:
|
|
88
|
+
items: l,
|
|
89
89
|
keyboardEvents: t,
|
|
90
90
|
a11yMode: s,
|
|
91
91
|
...s === "combobox" ? { id: e.menuId } : e.menuA11yProps,
|
|
@@ -94,27 +94,27 @@ const S = ({
|
|
|
94
94
|
)
|
|
95
95
|
}
|
|
96
96
|
) : /* @__PURE__ */ n(
|
|
97
|
-
|
|
97
|
+
F,
|
|
98
98
|
{
|
|
99
|
-
size:
|
|
99
|
+
size: A,
|
|
100
100
|
title: I,
|
|
101
101
|
variant: "drawer-dropdown",
|
|
102
102
|
submitLabel: b,
|
|
103
|
-
trigger: /* @__PURE__ */ n(
|
|
103
|
+
trigger: /* @__PURE__ */ n(P, { name: o, onClick: y, variant: x || R, children: f }),
|
|
104
104
|
open: t,
|
|
105
|
-
onClose:
|
|
105
|
+
onClose: m,
|
|
106
106
|
...e.dropdownA11yProps,
|
|
107
107
|
children: /* @__PURE__ */ n(
|
|
108
|
-
|
|
108
|
+
C,
|
|
109
109
|
{
|
|
110
110
|
search: k,
|
|
111
111
|
name: o,
|
|
112
112
|
filterState: c,
|
|
113
113
|
onFilterStateChange: v,
|
|
114
114
|
size: a,
|
|
115
|
-
searchable:
|
|
115
|
+
searchable: d,
|
|
116
116
|
groups: p,
|
|
117
|
-
items:
|
|
117
|
+
items: l,
|
|
118
118
|
keyboardEvents: t,
|
|
119
119
|
a11yMode: s,
|
|
120
120
|
...s === "combobox" ? { id: e.menuId } : e.menuA11yProps,
|
|
@@ -11,15 +11,15 @@ import { S as h } from "../../ChevronUpDown-DqGsU4MC.js";
|
|
|
11
11
|
const D = ({
|
|
12
12
|
title: a = "Title",
|
|
13
13
|
label: i = "Label",
|
|
14
|
-
items:
|
|
15
|
-
dropdownSize:
|
|
16
|
-
onSelectId:
|
|
14
|
+
items: s = [],
|
|
15
|
+
dropdownSize: l = "sm",
|
|
16
|
+
onSelectId: p,
|
|
17
17
|
...e
|
|
18
18
|
}) => {
|
|
19
|
-
const o = f({ id: "toolbar-menu", returnFocusOnClose: !0 }),
|
|
20
|
-
...
|
|
19
|
+
const o = f({ id: "toolbar-menu", returnFocusOnClose: !0 }), t = e.searchable ? "combobox" : "menu", m = s.map((n) => ({
|
|
20
|
+
...n,
|
|
21
21
|
onClick: () => {
|
|
22
|
-
|
|
22
|
+
p?.(n?.id ?? ""), n?.role !== "checkbox" && o.setOpen(!1);
|
|
23
23
|
}
|
|
24
24
|
}));
|
|
25
25
|
return /* @__PURE__ */ r(
|
|
@@ -28,11 +28,11 @@ const D = ({
|
|
|
28
28
|
id: "toolbar-menu",
|
|
29
29
|
variant: "drawer-dropdown",
|
|
30
30
|
title: a,
|
|
31
|
-
size:
|
|
31
|
+
size: l,
|
|
32
32
|
trigger: /* @__PURE__ */ d(
|
|
33
33
|
u,
|
|
34
34
|
{
|
|
35
|
-
variant: "
|
|
35
|
+
variant: "solid",
|
|
36
36
|
onClick: o.toggleMenu,
|
|
37
37
|
"aria-expanded": o.open,
|
|
38
38
|
"aria-haspopup": "menu",
|
|
@@ -51,12 +51,12 @@ const D = ({
|
|
|
51
51
|
b,
|
|
52
52
|
{
|
|
53
53
|
...e,
|
|
54
|
-
items:
|
|
54
|
+
items: m,
|
|
55
55
|
keyboardEvents: o.open,
|
|
56
|
-
a11yMode:
|
|
56
|
+
a11yMode: t,
|
|
57
57
|
open: o.open,
|
|
58
58
|
scrollToTopOnOpen: e.virtualized,
|
|
59
|
-
...
|
|
59
|
+
...t === "combobox" ? { id: o.menuId } : o.menuA11yProps
|
|
60
60
|
}
|
|
61
61
|
)
|
|
62
62
|
}
|
|
@@ -16,7 +16,7 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
16
16
|
groupId: "3",
|
|
17
17
|
name: "owner",
|
|
18
18
|
icon: b,
|
|
19
|
-
|
|
19
|
+
title: "Tjenesteeier ...",
|
|
20
20
|
groups: {
|
|
21
21
|
1: {
|
|
22
22
|
title: "Velg tjenesteier"
|
|
@@ -47,7 +47,7 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
47
47
|
groupId: "1",
|
|
48
48
|
name: "status",
|
|
49
49
|
icon: u,
|
|
50
|
-
|
|
50
|
+
title: "Status ...",
|
|
51
51
|
groups: {
|
|
52
52
|
1: {
|
|
53
53
|
title: "Velg status"
|
|
@@ -103,12 +103,12 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
103
103
|
title: "Ingen status"
|
|
104
104
|
}
|
|
105
105
|
]
|
|
106
|
-
},
|
|
106
|
+
}, Q = {
|
|
107
107
|
id: "2",
|
|
108
108
|
groupId: "1",
|
|
109
109
|
icon: o,
|
|
110
110
|
name: "time",
|
|
111
|
-
|
|
111
|
+
title: "Dato ...",
|
|
112
112
|
groups: {
|
|
113
113
|
1: {
|
|
114
114
|
title: "Velg dato"
|
|
@@ -173,12 +173,12 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
173
173
|
linkIcon: !0
|
|
174
174
|
}
|
|
175
175
|
]
|
|
176
|
-
},
|
|
176
|
+
}, X = {
|
|
177
177
|
id: "seenBy",
|
|
178
178
|
groupId: "2",
|
|
179
179
|
icon: v,
|
|
180
180
|
name: "seenBy",
|
|
181
|
-
|
|
181
|
+
title: "Sett av ...",
|
|
182
182
|
searchable: !0,
|
|
183
183
|
search: {
|
|
184
184
|
name: "seenBy",
|
|
@@ -227,12 +227,12 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
227
227
|
title: "Kari Nordmann"
|
|
228
228
|
}
|
|
229
229
|
]
|
|
230
|
-
},
|
|
230
|
+
}, V = {
|
|
231
231
|
id: "content",
|
|
232
232
|
groupId: "2",
|
|
233
233
|
icon: I,
|
|
234
234
|
name: "content",
|
|
235
|
-
|
|
235
|
+
title: "Inneholder ...",
|
|
236
236
|
groups: {
|
|
237
237
|
1: {
|
|
238
238
|
title: "Inneholder ..."
|
|
@@ -272,7 +272,7 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
272
272
|
title: "Mottatte meldinger"
|
|
273
273
|
}
|
|
274
274
|
]
|
|
275
|
-
}, R = [S,
|
|
275
|
+
}, R = [S, Q, X, V, M], T = R?.map((e) => ({
|
|
276
276
|
...e,
|
|
277
277
|
removable: !0
|
|
278
278
|
})), a = [
|
|
@@ -358,16 +358,16 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
358
358
|
icon: {
|
|
359
359
|
type: "company",
|
|
360
360
|
name: e.name,
|
|
361
|
-
isParent:
|
|
361
|
+
isParent: !e?.parentId
|
|
362
362
|
}
|
|
363
363
|
};
|
|
364
|
-
}),
|
|
364
|
+
}), U = {
|
|
365
365
|
label: a[0].title,
|
|
366
366
|
items: a,
|
|
367
367
|
searchable: !0,
|
|
368
368
|
groups: {
|
|
369
369
|
favourites: { title: "Favoritter" },
|
|
370
|
-
aa: { title: "
|
|
370
|
+
aa: { title: "Alle virksomheter" },
|
|
371
371
|
search: { title: "{count} treff" }
|
|
372
372
|
},
|
|
373
373
|
size: "md"
|
|
@@ -409,21 +409,21 @@ const h = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAIAAABt+uBvAAA
|
|
|
409
409
|
icon: p,
|
|
410
410
|
title: "Papirkurv"
|
|
411
411
|
}
|
|
412
|
-
],
|
|
412
|
+
], W = {
|
|
413
413
|
label: i[0].title,
|
|
414
414
|
items: i,
|
|
415
415
|
size: "sm"
|
|
416
416
|
};
|
|
417
417
|
export {
|
|
418
|
-
|
|
418
|
+
U as accountMenu,
|
|
419
419
|
a as accountMenuItems,
|
|
420
|
-
|
|
420
|
+
V as contentFilter,
|
|
421
421
|
R as inboxFilters,
|
|
422
|
-
|
|
422
|
+
W as inboxMenu,
|
|
423
423
|
i as inboxMenuItems,
|
|
424
424
|
M as ownerFilter,
|
|
425
|
-
|
|
426
|
-
|
|
425
|
+
T as removableInboxFilters,
|
|
426
|
+
X as seenByFilter,
|
|
427
427
|
S as statusFilter,
|
|
428
|
-
|
|
428
|
+
Q as timeFilter
|
|
429
429
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { inboxFilters as
|
|
3
|
-
import { formatDateRange as
|
|
4
|
-
const p = ({ filters:
|
|
5
|
-
const [n, u] =
|
|
1
|
+
import { useState as v } from "react";
|
|
2
|
+
import { inboxFilters as b, accountMenu as l } from "./example.data.js";
|
|
3
|
+
import { formatDateRange as S } from "./formatDateRange.js";
|
|
4
|
+
const p = ({ filters: o = b, defaultFilterState: c = {} }) => {
|
|
5
|
+
const [n, u] = v(c), d = () => {
|
|
6
6
|
const t = n?.seenBy || [], e = t?.length;
|
|
7
7
|
return e > 1 && t?.includes("you") && t?.includes("others") ? "Sett av deg + andre" : e > 1 && t?.includes("you") ? `Sett av deg + ${e - 1}` : t?.includes("user") ? "Sett av deg" : t?.includes("others") ? "Sett av andre" : e ? `Sett av ${e}` : "Sett av ...";
|
|
8
|
-
},
|
|
8
|
+
}, g = () => {
|
|
9
9
|
const t = (n?.drafts?.length ?? 0) > 0 ? "Utkast" : void 0, e = (n?.attachments?.length ?? 0) > 0 ? "Vedlegg" : void 0, i = (n?.sent?.length ?? 0) > 0 ? "Sendt" : void 0, r = (n?.received?.length ?? 0) > 0 ? "Mottatt" : void 0;
|
|
10
10
|
return [t, e, i, r].filter(Boolean).join(" + ");
|
|
11
|
-
},
|
|
11
|
+
}, s = () => {
|
|
12
12
|
const t = n?.fromDate?.[0]?.toString(), e = n?.toDate?.[0]?.toString();
|
|
13
13
|
if (t && e)
|
|
14
|
-
return
|
|
14
|
+
return S(t, e);
|
|
15
15
|
if (t)
|
|
16
|
-
return
|
|
17
|
-
const i = n?.time || [], r = i?.length,
|
|
18
|
-
return r === 1 ?
|
|
16
|
+
return S(t);
|
|
17
|
+
const i = n?.time || [], r = i?.length, m = o?.find((a) => a.name === "time")?.items, f = i?.map((a) => m?.find((h) => h.value === a)?.title);
|
|
18
|
+
return r === 1 ? f?.[0] : r > 1 ? `${r} tider` : "Tid";
|
|
19
19
|
}, L = () => {
|
|
20
|
-
const t = n?.status || [], e = t?.length, i =
|
|
21
|
-
return [
|
|
20
|
+
const t = n?.status || [], e = t?.length, i = o?.find((a) => a.name === "status")?.items, r = t?.map((a) => i?.find((h) => h.value === a)?.title), m = (n?.unread?.length ?? 0) > 0 ? "Ulest" : void 0, f = e === 1 ? r?.[0] : e > 1 ? `${e} statuser` : void 0;
|
|
21
|
+
return [m, f].filter(Boolean).join(" + ");
|
|
22
22
|
};
|
|
23
23
|
return {
|
|
24
24
|
addLabel: "Legg til filter",
|
|
25
25
|
submitLabel: "Show results",
|
|
26
26
|
addNextLabel: "Legg til",
|
|
27
|
-
filters:
|
|
27
|
+
filters: o,
|
|
28
28
|
filterState: n,
|
|
29
29
|
onFilterStateChange: u,
|
|
30
30
|
getFilterLabel: (t) => {
|
|
@@ -32,33 +32,33 @@ const p = ({ filters: s = v, defaultFilterState: c = {} }) => {
|
|
|
32
32
|
case "status":
|
|
33
33
|
return L() || "Status";
|
|
34
34
|
case "time":
|
|
35
|
-
return
|
|
35
|
+
return s() || "Tid";
|
|
36
36
|
case "seenBy":
|
|
37
37
|
return d() || "Sett av";
|
|
38
38
|
case "content":
|
|
39
|
-
return
|
|
39
|
+
return g() || "Innhold";
|
|
40
40
|
default:
|
|
41
41
|
return t;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
}, F = () => {
|
|
46
|
-
const [
|
|
47
|
-
|
|
48
|
-
},
|
|
49
|
-
...
|
|
50
|
-
selected:
|
|
45
|
+
}, F = (o) => {
|
|
46
|
+
const [c, n] = v(o || l.items[0].id), u = (s) => {
|
|
47
|
+
n(s);
|
|
48
|
+
}, d = l.items.find((s) => s.id === c)?.title?.toString() || "Account", g = l.items.map((s) => ({
|
|
49
|
+
...s,
|
|
50
|
+
selected: s.id === c
|
|
51
51
|
}));
|
|
52
|
-
return { ...l, label:
|
|
52
|
+
return { ...l, label: d, onSelectId: u, items: g, virtualized: !0 };
|
|
53
53
|
}, A = () => {
|
|
54
|
-
const
|
|
54
|
+
const o = p({ filters: b });
|
|
55
55
|
return {
|
|
56
56
|
menus: [F()],
|
|
57
57
|
search: {
|
|
58
58
|
name: "search",
|
|
59
59
|
placeholder: "Søk"
|
|
60
60
|
},
|
|
61
|
-
filter:
|
|
61
|
+
filter: o
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
export {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { ToolbarFilterProps } from './';
|
|
1
|
+
import { ToolbarFilterProps, ToolbarMenuProps } from './';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
4
|
component: ({ accountMenu, menus, search, filter, children }: import('./Toolbar').ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
parameters: {};
|
|
6
6
|
decorators: ((Story: import('storybook/internal/csf').PartialStoryFn<import('@storybook/react-vite').ReactRenderer, {
|
|
7
|
-
accountMenu?:
|
|
8
|
-
menus?:
|
|
7
|
+
accountMenu?: ToolbarMenuProps | undefined;
|
|
8
|
+
menus?: ToolbarMenuProps[] | undefined;
|
|
9
9
|
search?: import('./ToolbarSearch').ToolbarSearchProps | undefined;
|
|
10
10
|
filter?: ToolbarFilterProps | undefined;
|
|
11
11
|
children?: import('react').ReactNode;
|
|
12
12
|
}>, _: import('storybook/internal/csf').StoryContext<import('@storybook/react-vite').ReactRenderer, {
|
|
13
|
-
accountMenu?:
|
|
14
|
-
menus?:
|
|
13
|
+
accountMenu?: ToolbarMenuProps | undefined;
|
|
14
|
+
menus?: ToolbarMenuProps[] | undefined;
|
|
15
15
|
search?: import('./ToolbarSearch').ToolbarSearchProps | undefined;
|
|
16
16
|
filter?: ToolbarFilterProps | undefined;
|
|
17
17
|
children?: import('react').ReactNode;
|
|
@@ -26,5 +26,5 @@ export declare const StaticFilters: () => import("react/jsx-runtime").JSX.Elemen
|
|
|
26
26
|
export declare const RemovableFilters: () => import("react/jsx-runtime").JSX.Element;
|
|
27
27
|
export declare const AccountMenuAndFilters: () => import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
export declare const AccountMenuAndSearch: () => import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export declare const AccountMenuAndSubmenu: () => import("react/jsx-runtime").JSX.Element;
|
|
30
29
|
export declare const AccountMenuAndSearchAutocomplete: () => import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare const AccountMenuAndSubmenu: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,7 +11,7 @@ export declare const useInboxFilter: ({ filters, defaultFilterState }: {
|
|
|
11
11
|
onFilterStateChange: import('react').Dispatch<import('react').SetStateAction<import('./useFilter').FilterState | undefined>>;
|
|
12
12
|
getFilterLabel: ToolbarFilterProps["getFilterLabel"];
|
|
13
13
|
};
|
|
14
|
-
export declare const useAccountMenu: () => {
|
|
14
|
+
export declare const useAccountMenu: (selectedId?: string) => {
|
|
15
15
|
label: string;
|
|
16
16
|
onSelectId: (id: string) => void;
|
|
17
17
|
items: {
|