@altinn/altinn-components 0.60.1 → 0.61.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.
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
import { jsxs as l, Fragment as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { Button as
|
|
1
|
+
import { jsxs as l, Fragment as L, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as N, useState as O, createElement as y } from "react";
|
|
3
|
+
import { Button as E } from "../Button/Button.js";
|
|
4
4
|
import "../../index-p1eeF8LQ.js";
|
|
5
|
-
import { s as
|
|
5
|
+
import { s as X } from "../../ToolbarSearch-56Sm2j7P.js";
|
|
6
6
|
import "../Typography/Link.js";
|
|
7
7
|
import "react-dom";
|
|
8
8
|
import "../Snackbar/useSnackbar.js";
|
|
9
|
-
import { ToolbarFilterMenu as
|
|
10
|
-
import { useFilter as
|
|
11
|
-
import { ToolbarControls as
|
|
12
|
-
import { ToolbarFilterAddMenu as
|
|
13
|
-
const
|
|
9
|
+
import { ToolbarFilterMenu as q } from "./ToolbarFilterMenu.js";
|
|
10
|
+
import { useFilter as w } from "./useFilter.js";
|
|
11
|
+
import { ToolbarControls as z } from "./ToolbarControls.js";
|
|
12
|
+
import { ToolbarFilterAddMenu as D } from "./ToolbarFilterAddMenu.js";
|
|
13
|
+
const $ = ({
|
|
14
14
|
disabled: n,
|
|
15
15
|
filters: r,
|
|
16
16
|
filterState: e = {},
|
|
17
17
|
onFilterStateChange: t,
|
|
18
|
-
addLabel:
|
|
19
|
-
addNextLabel:
|
|
20
|
-
resetLabel:
|
|
21
|
-
removeLabel:
|
|
22
|
-
submitLabel:
|
|
23
|
-
getFilterLabel:
|
|
24
|
-
virtualized:
|
|
25
|
-
|
|
18
|
+
addLabel: b = "Legg til filter",
|
|
19
|
+
addNextLabel: T = "Legg til",
|
|
20
|
+
resetLabel: j = "Nullstill",
|
|
21
|
+
removeLabel: M = "Fjern filter",
|
|
22
|
+
submitLabel: k,
|
|
23
|
+
getFilterLabel: x,
|
|
24
|
+
virtualized: A,
|
|
25
|
+
showResetButton: R = !0,
|
|
26
|
+
controls: s
|
|
26
27
|
}) => {
|
|
27
|
-
const { visibleFilters:
|
|
28
|
+
const { visibleFilters: a, hiddenFilters: d, onFilterAdd: f, onFilterChange: B, onFilterRemove: p } = w({
|
|
28
29
|
filters: r,
|
|
29
30
|
filterState: e,
|
|
30
31
|
onFilterStateChange: t
|
|
31
|
-
}),
|
|
32
|
+
}), c = N(
|
|
32
33
|
() => r?.filter((o) => o.removable)?.map((o) => o.name) ?? [],
|
|
33
34
|
[r]
|
|
34
|
-
),
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
},
|
|
39
|
-
for (const o of
|
|
40
|
-
|
|
35
|
+
), g = R && c.length > 0 && Object.values(e)?.some((o) => o && o?.length > 0), [u, h] = O(void 0), v = (o) => {
|
|
36
|
+
h((m) => m === o ? void 0 : o);
|
|
37
|
+
}, F = () => {
|
|
38
|
+
h(void 0);
|
|
39
|
+
}, C = () => {
|
|
40
|
+
for (const o of c)
|
|
41
|
+
p(o);
|
|
41
42
|
t?.({});
|
|
42
43
|
};
|
|
43
|
-
return /* @__PURE__ */ l(
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
return /* @__PURE__ */
|
|
47
|
-
|
|
44
|
+
return /* @__PURE__ */ l(L, { children: [
|
|
45
|
+
a?.map((o, m) => {
|
|
46
|
+
const I = x?.(o?.name, e?.[o?.id]) ?? o?.label;
|
|
47
|
+
return /* @__PURE__ */ y(
|
|
48
|
+
q,
|
|
48
49
|
{
|
|
49
50
|
...o,
|
|
50
51
|
disabled: n,
|
|
51
|
-
submitLabel:
|
|
52
|
+
submitLabel: k,
|
|
52
53
|
key: m,
|
|
53
|
-
onToggle: () =>
|
|
54
|
-
onClose:
|
|
55
|
-
open:
|
|
56
|
-
label:
|
|
57
|
-
onRemove: () =>
|
|
58
|
-
removeLabel:
|
|
59
|
-
onFilterChange:
|
|
54
|
+
onToggle: () => v(o.name),
|
|
55
|
+
onClose: F,
|
|
56
|
+
open: u === o.name,
|
|
57
|
+
label: I,
|
|
58
|
+
onRemove: () => p(o.name),
|
|
59
|
+
removeLabel: M,
|
|
60
|
+
onFilterChange: B,
|
|
60
61
|
onFilterStateChange: t,
|
|
61
62
|
filterState: e
|
|
62
63
|
}
|
|
63
64
|
);
|
|
64
65
|
}),
|
|
65
|
-
!n &&
|
|
66
|
-
|
|
66
|
+
!n && d?.length > 0 && /* @__PURE__ */ i(
|
|
67
|
+
D,
|
|
67
68
|
{
|
|
68
69
|
name: "add",
|
|
69
|
-
onToggle: () =>
|
|
70
|
-
onClose:
|
|
71
|
-
open:
|
|
72
|
-
items:
|
|
73
|
-
onAdd:
|
|
74
|
-
label:
|
|
75
|
-
virtualized:
|
|
70
|
+
onToggle: () => v("add"),
|
|
71
|
+
onClose: F,
|
|
72
|
+
open: u === "add",
|
|
73
|
+
items: d,
|
|
74
|
+
onAdd: f,
|
|
75
|
+
label: a?.length > 0 ? T : b,
|
|
76
|
+
virtualized: A
|
|
76
77
|
}
|
|
77
78
|
),
|
|
78
|
-
/* @__PURE__ */ l(
|
|
79
|
-
!n &&
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */
|
|
79
|
+
(g || s) && /* @__PURE__ */ l(z, { children: [
|
|
80
|
+
!n && g && /* @__PURE__ */ l(E, { onClick: C, variant: "ghost", children: [
|
|
81
|
+
/* @__PURE__ */ i(X, { "aria-hidden": "true" }),
|
|
82
|
+
/* @__PURE__ */ i("span", { children: j })
|
|
82
83
|
] }),
|
|
83
|
-
|
|
84
|
+
s
|
|
84
85
|
] })
|
|
85
86
|
] });
|
|
86
87
|
};
|
|
87
88
|
export {
|
|
88
|
-
|
|
89
|
+
$ as ToolbarFilter
|
|
89
90
|
};
|
|
@@ -1,39 +1,42 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
const m = (
|
|
4
|
-
const i =
|
|
5
|
-
}, [
|
|
6
|
-
() =>
|
|
2
|
+
import { useState as h, useMemo as f, useEffect as p } from "react";
|
|
3
|
+
const m = (n, o) => o || `toolbar-filter-${n}`, x = ({ filters: n = [], filterState: o, onFilterStateChange: u }) => {
|
|
4
|
+
const i = o || {}, c = typeof u == "function" ? u : () => {
|
|
5
|
+
}, [d, a] = h(
|
|
6
|
+
() => n.filter((e) => !e.removable || typeof i[e.name] < "u").map((e) => e.name)
|
|
7
7
|
), F = f(
|
|
8
|
-
() =>
|
|
9
|
-
[
|
|
8
|
+
() => d.map((e) => n.find((t) => t.name === e)).filter((e) => typeof e < "u"),
|
|
9
|
+
[n, d]
|
|
10
10
|
), b = f(
|
|
11
|
-
() =>
|
|
12
|
-
[
|
|
11
|
+
() => n.filter((e) => !d.includes(e.name)),
|
|
12
|
+
[n, d]
|
|
13
13
|
);
|
|
14
|
-
|
|
15
|
-
const e =
|
|
16
|
-
|
|
17
|
-
const s =
|
|
18
|
-
|
|
14
|
+
p(() => {
|
|
15
|
+
const e = n.filter((t) => !t.removable || typeof i[t.name] < "u").map((t) => t.name);
|
|
16
|
+
a((t) => {
|
|
17
|
+
const s = [
|
|
18
|
+
...t.filter((l) => e.includes(l)),
|
|
19
|
+
...e.filter((l) => !t.includes(l))
|
|
20
|
+
];
|
|
21
|
+
return s.length === t.length && s.every((l, r) => l === t[r]) ? t : s;
|
|
19
22
|
});
|
|
20
|
-
}, [
|
|
23
|
+
}, [n, i]);
|
|
21
24
|
const v = (e, t, s) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
25
|
+
const l = [s];
|
|
26
|
+
c(e === "radio" ? {
|
|
24
27
|
...i,
|
|
25
|
-
[t]:
|
|
28
|
+
[t]: l
|
|
26
29
|
} : {
|
|
27
30
|
...i,
|
|
28
|
-
[t]: i[t] ? i[t].some((
|
|
31
|
+
[t]: i[t] ? i[t].some((r) => l.includes(String(r))) ? i[t].filter((r) => !(l || []).includes(String(r))) : [...i[t], ...l || []] : l
|
|
29
32
|
});
|
|
30
|
-
},
|
|
31
|
-
|
|
33
|
+
}, y = (e) => {
|
|
34
|
+
a((t) => t.filter((s) => s !== e)), c({
|
|
32
35
|
...i,
|
|
33
36
|
[e]: void 0
|
|
34
37
|
});
|
|
35
|
-
},
|
|
36
|
-
|
|
38
|
+
}, g = (e) => {
|
|
39
|
+
d.includes(e) || a((t) => [...t, e]), c({
|
|
37
40
|
...i,
|
|
38
41
|
[e]: i[e] ?? []
|
|
39
42
|
}), requestAnimationFrame(() => {
|
|
@@ -55,10 +58,10 @@ const m = (l, c) => c || `toolbar-filter-${l}`, N = ({ filters: l = [], filterSt
|
|
|
55
58
|
id: m(e.name, e.id)
|
|
56
59
|
})),
|
|
57
60
|
onFilterChange: v,
|
|
58
|
-
onFilterRemove:
|
|
59
|
-
onFilterAdd:
|
|
61
|
+
onFilterRemove: y,
|
|
62
|
+
onFilterAdd: g
|
|
60
63
|
};
|
|
61
64
|
};
|
|
62
65
|
export {
|
|
63
|
-
|
|
66
|
+
x as useFilter
|
|
64
67
|
};
|
|
@@ -13,5 +13,6 @@ export interface ToolbarFilterProps {
|
|
|
13
13
|
onFilterStateChange?: (state: FilterState) => void;
|
|
14
14
|
virtualized?: boolean;
|
|
15
15
|
controls?: ReactNode;
|
|
16
|
+
showResetButton?: boolean;
|
|
16
17
|
}
|
|
17
|
-
export declare const ToolbarFilter: ({ disabled, filters, filterState, onFilterStateChange, addLabel, addNextLabel, resetLabel, removeLabel, submitLabel, getFilterLabel, virtualized, controls, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const ToolbarFilter: ({ disabled, filters, filterState, onFilterStateChange, addLabel, addNextLabel, resetLabel, removeLabel, submitLabel, getFilterLabel, virtualized, showResetButton, controls, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ToolbarFilterProps } from './ToolbarFilter';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ disabled, filters, filterState, onFilterStateChange, addLabel, addNextLabel, resetLabel, removeLabel, submitLabel, getFilterLabel, virtualized, controls, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ disabled, filters, filterState, onFilterStateChange, addLabel, addNextLabel, resetLabel, removeLabel, submitLabel, getFilterLabel, virtualized, showResetButton, controls, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
parameters: {};
|
|
6
6
|
args: {};
|
|
7
7
|
};
|