@altinn/altinn-components 0.60.2 → 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
|
};
|
|
@@ -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
|
};
|