@altinn/altinn-components 0.18.3 → 0.18.4
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,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as B, jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { useState as F, useMemo as T } from "react";
|
|
4
|
-
import { useRootContext as
|
|
5
|
-
import { ToolbarAccountMenu as
|
|
6
|
-
import { ToolbarAdd as
|
|
7
|
-
import { ToolbarBase as
|
|
8
|
-
import { ToolbarFilter as
|
|
9
|
-
import { ToolbarSearch as
|
|
10
|
-
const g = (n, l) => l || `toolbar-filter-${n}`,
|
|
4
|
+
import { useRootContext as M } from "../RootProvider/RootProvider.js";
|
|
5
|
+
import { ToolbarAccountMenu as V } from "./ToolbarAccountMenu.js";
|
|
6
|
+
import { ToolbarAdd as $ } from "./ToolbarAdd.js";
|
|
7
|
+
import { ToolbarBase as q } from "./ToolbarBase.js";
|
|
8
|
+
import { ToolbarFilter as w } from "./ToolbarFilter.js";
|
|
9
|
+
import { ToolbarSearch as z } from "./ToolbarSearch.js";
|
|
10
|
+
const g = (n, l) => l || `toolbar-filter-${n}`, Q = ({
|
|
11
11
|
filters: n = [],
|
|
12
12
|
filterState: l,
|
|
13
13
|
onFilterStateChange: s,
|
|
@@ -16,47 +16,48 @@ const g = (n, l) => l || `toolbar-filter-${n}`, P = ({
|
|
|
16
16
|
getFilterLabel: y,
|
|
17
17
|
children: x,
|
|
18
18
|
showResultsLabel: A,
|
|
19
|
-
removeButtonAltText: S
|
|
19
|
+
removeButtonAltText: S,
|
|
20
|
+
addFilterButtonLabel: h
|
|
20
21
|
}) => {
|
|
21
|
-
const { openId:
|
|
22
|
+
const { openId: C, closeAll: I } = M(), [N, R] = F(
|
|
22
23
|
l ?? {}
|
|
23
|
-
), c = typeof s == "function" ? s :
|
|
24
|
+
), c = typeof s == "function" ? s : R, t = l || N, [d, f] = F(
|
|
24
25
|
(n == null ? void 0 : n.filter((o) => !(o.removable && typeof t[o.name] > "u")).map((o) => o.name)) ?? []
|
|
25
|
-
), u = n == null ? void 0 : n.filter((o) => !d.includes(o.name)),
|
|
26
|
+
), u = n == null ? void 0 : n.filter((o) => !d.includes(o.name)), j = T(
|
|
26
27
|
() => d.map((o) => n.find((e) => e.name === o)).filter((o) => typeof o < "u"),
|
|
27
28
|
[n, d]
|
|
28
29
|
), a = T(
|
|
29
30
|
() => n.filter((o) => u.includes(o)),
|
|
30
31
|
[n, u]
|
|
31
|
-
),
|
|
32
|
-
r === "radio" ? (
|
|
32
|
+
), L = (o, e, r) => {
|
|
33
|
+
r === "radio" ? (I(), c({
|
|
33
34
|
...t,
|
|
34
35
|
[o]: e
|
|
35
36
|
})) : c({
|
|
36
37
|
...t,
|
|
37
38
|
[o]: t[o] ? t[o].some((p) => e == null ? void 0 : e.includes(p)) ? t[o].filter((p) => !e.includes(p)) : [...t[o], ...e] : e
|
|
38
39
|
});
|
|
39
|
-
},
|
|
40
|
+
}, k = (o) => {
|
|
40
41
|
f((e) => e.filter((r) => r !== o)), c({
|
|
41
42
|
...t,
|
|
42
43
|
[o]: void 0
|
|
43
44
|
});
|
|
44
|
-
},
|
|
45
|
-
f((r) => [...r, o]),
|
|
45
|
+
}, v = (o, e) => {
|
|
46
|
+
f((r) => [...r, o]), C(e);
|
|
46
47
|
};
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
b && /* @__PURE__ */ i(
|
|
49
|
-
m && /* @__PURE__ */ i(
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
return /* @__PURE__ */ B(q, { children: [
|
|
49
|
+
b && /* @__PURE__ */ i(V, { ...b }),
|
|
50
|
+
m && /* @__PURE__ */ i(z, { ...m }),
|
|
51
|
+
j.map((o) => /* @__PURE__ */ i(
|
|
52
|
+
w,
|
|
52
53
|
{
|
|
53
54
|
id: g(o.name, o.id),
|
|
54
55
|
showResultsLabel: A,
|
|
55
56
|
onRemove: () => {
|
|
56
|
-
|
|
57
|
+
k(o.name);
|
|
57
58
|
},
|
|
58
59
|
onChange: (e) => {
|
|
59
|
-
|
|
60
|
+
L(o.name, [e.target.value], o.optionType);
|
|
60
61
|
},
|
|
61
62
|
name: o.name,
|
|
62
63
|
options: o.options,
|
|
@@ -70,9 +71,10 @@ const g = (n, l) => l || `toolbar-filter-${n}`, P = ({
|
|
|
70
71
|
o.name
|
|
71
72
|
)),
|
|
72
73
|
(a == null ? void 0 : a.length) > 0 && /* @__PURE__ */ i(
|
|
73
|
-
|
|
74
|
+
$,
|
|
74
75
|
{
|
|
75
76
|
id: "toolbar-filter-add",
|
|
77
|
+
label: h,
|
|
76
78
|
items: a.map((o) => {
|
|
77
79
|
const e = g(o.name, o.id);
|
|
78
80
|
return {
|
|
@@ -80,7 +82,7 @@ const g = (n, l) => l || `toolbar-filter-${n}`, P = ({
|
|
|
80
82
|
title: o.label,
|
|
81
83
|
name: o.name,
|
|
82
84
|
onClick: () => {
|
|
83
|
-
|
|
85
|
+
v(o.name, e);
|
|
84
86
|
}
|
|
85
87
|
};
|
|
86
88
|
})
|
|
@@ -90,5 +92,5 @@ const g = (n, l) => l || `toolbar-filter-${n}`, P = ({
|
|
|
90
92
|
] });
|
|
91
93
|
};
|
|
92
94
|
export {
|
|
93
|
-
|
|
95
|
+
Q as Toolbar
|
|
94
96
|
};
|
|
@@ -11,7 +11,8 @@ export interface ToolbarProps {
|
|
|
11
11
|
getFilterLabel?: (name: string, value: ToolbarFilterProps['value']) => string;
|
|
12
12
|
onFilterStateChange?: (state: FilterState) => void;
|
|
13
13
|
showResultsLabel?: string;
|
|
14
|
+
addFilterButtonLabel?: string;
|
|
14
15
|
removeButtonAltText?: string;
|
|
15
16
|
children?: ReactNode;
|
|
16
17
|
}
|
|
17
|
-
export declare const Toolbar: ({ filters, filterState, onFilterStateChange, search, accountMenu, getFilterLabel, children, showResultsLabel, removeButtonAltText, }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const Toolbar: ({ filters, filterState, onFilterStateChange, search, accountMenu, getFilterLabel, children, showResultsLabel, removeButtonAltText, addFilterButtonLabel, }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react';
|
|
|
2
2
|
import { Toolbar } from './Toolbar';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ filters, filterState, onFilterStateChange, search, accountMenu, getFilterLabel, children, showResultsLabel, removeButtonAltText, }: import('./Toolbar').ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
component: ({ filters, filterState, onFilterStateChange, search, accountMenu, getFilterLabel, children, showResultsLabel, removeButtonAltText, addFilterButtonLabel, }: import('./Toolbar').ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {};
|
|
8
8
|
args: {
|