@altinn/altinn-components 0.53.1 → 0.54.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/dist/components/Toolbar/Toolbar.js +10 -9
- package/dist/components/Toolbar/ToolbarFilter.js +24 -22
- package/dist/components/Toolbar/ToolbarOptions.js +56 -49
- package/dist/types/lib/components/Toolbar/ToolbarDate.stories.d.ts +1 -1
- package/dist/types/lib/components/Toolbar/ToolbarFilter.d.ts +3 -2
- package/dist/types/lib/components/Toolbar/ToolbarFilter.stories.d.ts +2 -1
- package/dist/types/lib/components/Toolbar/ToolbarOptions.d.ts +3 -2
- package/package.json +1 -1
|
@@ -13,10 +13,10 @@ const g = (n, c) => c || `toolbar-filter-${n}`, P = ({
|
|
|
13
13
|
onFilterStateChange: f,
|
|
14
14
|
search: m,
|
|
15
15
|
accountMenu: b,
|
|
16
|
-
getFilterLabel:
|
|
17
|
-
children:
|
|
18
|
-
showResultsLabel:
|
|
19
|
-
removeButtonAltText:
|
|
16
|
+
getFilterLabel: h,
|
|
17
|
+
children: v,
|
|
18
|
+
showResultsLabel: y,
|
|
19
|
+
removeButtonAltText: S,
|
|
20
20
|
addFilterButtonLabel: x
|
|
21
21
|
}) => {
|
|
22
22
|
const { openId: A, closeAll: F } = V(), t = c || {}, a = typeof f == "function" ? f : () => {
|
|
@@ -65,7 +65,7 @@ const g = (n, c) => c || `toolbar-filter-${n}`, P = ({
|
|
|
65
65
|
B,
|
|
66
66
|
{
|
|
67
67
|
id: g(e.name, e.id),
|
|
68
|
-
showResultsLabel:
|
|
68
|
+
showResultsLabel: y,
|
|
69
69
|
onRemove: () => C(e.name),
|
|
70
70
|
onChange: j,
|
|
71
71
|
name: e.name,
|
|
@@ -73,10 +73,11 @@ const g = (n, c) => c || `toolbar-filter-${n}`, P = ({
|
|
|
73
73
|
label: e.label,
|
|
74
74
|
optionType: e.optionType,
|
|
75
75
|
removable: e.removable,
|
|
76
|
-
getSelectedLabel:
|
|
77
|
-
buttonAltText:
|
|
76
|
+
getSelectedLabel: h,
|
|
77
|
+
buttonAltText: S,
|
|
78
78
|
optionGroups: e.optionGroups,
|
|
79
|
-
filterState: t
|
|
79
|
+
filterState: t,
|
|
80
|
+
search: e.search
|
|
80
81
|
},
|
|
81
82
|
e.name
|
|
82
83
|
)),
|
|
@@ -97,7 +98,7 @@ const g = (n, c) => c || `toolbar-filter-${n}`, P = ({
|
|
|
97
98
|
},
|
|
98
99
|
u.join(",")
|
|
99
100
|
),
|
|
100
|
-
|
|
101
|
+
v
|
|
101
102
|
] });
|
|
102
103
|
};
|
|
103
104
|
export {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as I, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import "../../index-p1eeF8LQ.js";
|
|
3
3
|
import "react";
|
|
4
|
-
import { useIsDesktop as
|
|
4
|
+
import { useIsDesktop as j } from "../../hooks/useIsDesktop.js";
|
|
5
5
|
import "../Button/Button.js";
|
|
6
|
-
import { useRootContext as
|
|
7
|
-
import { DrawerOrDropdown as
|
|
6
|
+
import { useRootContext as F } from "../RootProvider/RootProvider.js";
|
|
7
|
+
import { DrawerOrDropdown as L } from "../Dropdown/DrawerOrDropdown.js";
|
|
8
8
|
import "../Snackbar/useSnackbar.js";
|
|
9
|
-
import { ToolbarButton as
|
|
10
|
-
import { ToolbarFilterBase as
|
|
11
|
-
import { ToolbarOptions as
|
|
12
|
-
const
|
|
9
|
+
import { ToolbarButton as O } from "./ToolbarButton.js";
|
|
10
|
+
import { ToolbarFilterBase as R } from "./ToolbarFilterBase.js";
|
|
11
|
+
import { ToolbarOptions as E } from "./ToolbarOptions.js";
|
|
12
|
+
const G = (i, t) => Array.isArray(t) ? t.join(", ") : t, Q = ({
|
|
13
13
|
removable: i,
|
|
14
14
|
label: t,
|
|
15
15
|
name: o,
|
|
@@ -21,38 +21,39 @@ const E = (i, t) => Array.isArray(t) ? t.join(", ") : t, P = ({
|
|
|
21
21
|
buttonAltText: p = "Remove button",
|
|
22
22
|
getSelectedLabel: g,
|
|
23
23
|
showResultsLabel: x = "Show results",
|
|
24
|
-
|
|
24
|
+
search: A,
|
|
25
|
+
optionType: h,
|
|
25
26
|
id: s = `toolbar-filter-${o}`
|
|
26
27
|
}) => {
|
|
27
|
-
const { currentId:
|
|
28
|
+
const { currentId: v, toggleId: k, closeAll: d } = F(), u = j(), w = (m ?? []).map((r) => {
|
|
28
29
|
const e = c?.[r.name || o];
|
|
29
30
|
return {
|
|
30
31
|
name: o,
|
|
31
32
|
...r,
|
|
32
33
|
checked: Array.isArray(e) ? e.includes(r.value) : r.value === e
|
|
33
34
|
};
|
|
34
|
-
}), n = c?.[o],
|
|
35
|
+
}), n = c?.[o], B = g?.(o, n) ?? G(o, n), f = () => k(s), l = v === s, C = (r) => {
|
|
35
36
|
const e = r.relatedTarget;
|
|
36
37
|
u && (!e || !r.currentTarget.contains(e)) && d();
|
|
37
|
-
},
|
|
38
|
-
return /* @__PURE__ */
|
|
38
|
+
}, D = Array.isArray(n) ? n.length > 0 : typeof n < "u";
|
|
39
|
+
return /* @__PURE__ */ I(R, { expanded: l, onBlurCapture: C, "data-testid": "filter-base-" + s, children: [
|
|
39
40
|
/* @__PURE__ */ a(
|
|
40
|
-
|
|
41
|
+
O,
|
|
41
42
|
{
|
|
42
43
|
type: "select",
|
|
43
44
|
removable: i,
|
|
44
|
-
active:
|
|
45
|
+
active: D,
|
|
45
46
|
onToggle: f,
|
|
46
47
|
ariaLabel: p,
|
|
47
48
|
iconAltText: p,
|
|
48
49
|
onRemove: T,
|
|
49
50
|
"data-testid": s,
|
|
50
51
|
tabIndex: l ? -1 : 0,
|
|
51
|
-
children:
|
|
52
|
+
children: B || t
|
|
52
53
|
}
|
|
53
54
|
),
|
|
54
55
|
/* @__PURE__ */ a(
|
|
55
|
-
|
|
56
|
+
L,
|
|
56
57
|
{
|
|
57
58
|
open: l,
|
|
58
59
|
drawerTitle: t,
|
|
@@ -62,14 +63,15 @@ const E = (i, t) => Array.isArray(t) ? t.join(", ") : t, P = ({
|
|
|
62
63
|
label: x
|
|
63
64
|
},
|
|
64
65
|
children: /* @__PURE__ */ a(
|
|
65
|
-
|
|
66
|
+
E,
|
|
66
67
|
{
|
|
67
68
|
name: o,
|
|
68
|
-
options:
|
|
69
|
+
options: w,
|
|
69
70
|
optionGroups: b,
|
|
70
71
|
onChange: y,
|
|
71
|
-
optionType:
|
|
72
|
-
keyboardEvents: l && u
|
|
72
|
+
optionType: h,
|
|
73
|
+
keyboardEvents: l && u,
|
|
74
|
+
search: A
|
|
73
75
|
}
|
|
74
76
|
)
|
|
75
77
|
}
|
|
@@ -77,5 +79,5 @@ const E = (i, t) => Array.isArray(t) ? t.join(", ") : t, P = ({
|
|
|
77
79
|
] });
|
|
78
80
|
};
|
|
79
81
|
export {
|
|
80
|
-
|
|
82
|
+
Q as ToolbarFilter
|
|
81
83
|
};
|
|
@@ -1,77 +1,84 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as A,
|
|
3
|
-
import { useMenu as
|
|
1
|
+
import { jsxs as v, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as A, useState as F, useMemo as H, Fragment as K } from "react";
|
|
3
|
+
import { useMenu as N } from "../../hooks/useMenu.js";
|
|
4
4
|
import "../../index-p1eeF8LQ.js";
|
|
5
5
|
import "../Button/Button.js";
|
|
6
6
|
import "../RootProvider/RootProvider.js";
|
|
7
|
-
import { MenuOption as
|
|
8
|
-
import { MenuSearch as
|
|
9
|
-
import { MenuHeader as
|
|
10
|
-
import { MenuBase as
|
|
7
|
+
import { MenuOption as R } from "../Menu/MenuOption.js";
|
|
8
|
+
import { MenuSearch as q } from "../Menu/MenuSearch.js";
|
|
9
|
+
import { MenuHeader as z } from "../Menu/MenuHeader.js";
|
|
10
|
+
import { MenuBase as D, MenuList as E, MenuListItem as a } from "../Menu/MenuBase.js";
|
|
11
11
|
import "../Snackbar/useSnackbar.js";
|
|
12
|
-
const
|
|
13
|
-
name:
|
|
14
|
-
search:
|
|
15
|
-
optionGroups:
|
|
16
|
-
options:
|
|
17
|
-
onChange:
|
|
18
|
-
optionType:
|
|
19
|
-
keyboardEvents:
|
|
20
|
-
onBlurCapture:
|
|
12
|
+
const ne = ({
|
|
13
|
+
name: S,
|
|
14
|
+
search: i,
|
|
15
|
+
optionGroups: l = {},
|
|
16
|
+
options: c,
|
|
17
|
+
onChange: x,
|
|
18
|
+
optionType: y,
|
|
19
|
+
keyboardEvents: s,
|
|
20
|
+
onBlurCapture: V
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const u = A(null), [t, p] = F(""), L = H(
|
|
23
|
+
() => c.filter((r) => t ? r.label.toLowerCase().includes(t.toLowerCase()) : !0),
|
|
24
|
+
[c, t]
|
|
25
|
+
), { menu: k, setActiveIndex: I } = N({
|
|
26
|
+
items: L,
|
|
27
|
+
groups: l,
|
|
25
28
|
groupByKey: "groupId",
|
|
26
|
-
keyboardEvents:
|
|
27
|
-
ref:
|
|
29
|
+
keyboardEvents: s,
|
|
30
|
+
ref: u
|
|
28
31
|
});
|
|
29
|
-
return /* @__PURE__ */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
return /* @__PURE__ */ v(D, { variant: "default", ref: u, children: [
|
|
33
|
+
i && /* @__PURE__ */ e(q, { ...i, value: t, onChange: (r) => {
|
|
34
|
+
p(r.target.value);
|
|
35
|
+
}, onClear: () => {
|
|
36
|
+
p("");
|
|
37
|
+
} }),
|
|
38
|
+
/* @__PURE__ */ e(E, { role: "menu", onBlurCapture: V, children: k.map((r, m) => {
|
|
39
|
+
const O = r?.props || {}, { title: d, divider: T = !0 } = O;
|
|
40
|
+
return /* @__PURE__ */ v(K, { children: [
|
|
41
|
+
m && T ? /* @__PURE__ */ e(a, { role: "separator" }) : "",
|
|
42
|
+
d && /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(z, { title: d }) }),
|
|
43
|
+
r?.items.filter((n) => !n.props?.hidden).map((n, j) => {
|
|
44
|
+
const { active: w, onMouseEnter: B } = n, { groupId: h, onClick: U, value: f, checked: C, type: M, ...o } = n.props || {}, { expanded: P } = o, g = o.name || S, b = M || h && l[h]?.optionType || y;
|
|
38
45
|
return /* @__PURE__ */ e(
|
|
39
|
-
|
|
46
|
+
a,
|
|
40
47
|
{
|
|
41
48
|
expanded: P,
|
|
42
|
-
onMouseEnter:
|
|
43
|
-
onMouseLeave: () =>
|
|
44
|
-
role:
|
|
45
|
-
"aria-checked":
|
|
49
|
+
onMouseEnter: B,
|
|
50
|
+
onMouseLeave: () => I(-1),
|
|
51
|
+
role: M === "radio" ? "menuitemradio" : "menuitemcheckbox",
|
|
52
|
+
"aria-checked": C ?? !1,
|
|
46
53
|
children: /* @__PURE__ */ e(
|
|
47
|
-
|
|
54
|
+
R,
|
|
48
55
|
{
|
|
49
56
|
...o,
|
|
50
|
-
active:
|
|
51
|
-
tabIndex:
|
|
57
|
+
active: w,
|
|
58
|
+
tabIndex: s ? -1 : 0,
|
|
52
59
|
label: o.label,
|
|
53
60
|
count: o.count,
|
|
54
|
-
name:
|
|
55
|
-
type:
|
|
56
|
-
value:
|
|
57
|
-
checked:
|
|
61
|
+
name: g,
|
|
62
|
+
type: b,
|
|
63
|
+
value: f,
|
|
64
|
+
checked: C,
|
|
58
65
|
onClick: () => {
|
|
59
|
-
|
|
60
|
-
name:
|
|
61
|
-
value:
|
|
62
|
-
type:
|
|
66
|
+
x?.({
|
|
67
|
+
name: g,
|
|
68
|
+
value: f,
|
|
69
|
+
type: b
|
|
63
70
|
});
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
)
|
|
67
74
|
},
|
|
68
|
-
|
|
75
|
+
j
|
|
69
76
|
);
|
|
70
77
|
})
|
|
71
|
-
] },
|
|
78
|
+
] }, m);
|
|
72
79
|
}) })
|
|
73
80
|
] });
|
|
74
81
|
};
|
|
75
82
|
export {
|
|
76
|
-
|
|
83
|
+
ne as ToolbarOptions
|
|
77
84
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, optionType, id, }: import('./ToolbarFilter').ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, search, optionType, id, }: import('./ToolbarFilter').ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
parameters: {};
|
|
7
7
|
args: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MouseEventHandler } from 'react';
|
|
2
|
-
import { FilterChangePayload, FilterState } from '../';
|
|
2
|
+
import { FilterChangePayload, FilterState, ToolbarSearchProps } from '../';
|
|
3
3
|
import { MenuOptionProps } from '../Menu';
|
|
4
4
|
import { OptionGroup } from './ToolbarOptions';
|
|
5
5
|
type ToolbarFilterValue = (string | number)[];
|
|
@@ -20,6 +20,7 @@ export interface ToolbarFilterProps {
|
|
|
20
20
|
onChange?: (payload: FilterChangePayload) => void;
|
|
21
21
|
onRemove?: MouseEventHandler;
|
|
22
22
|
showResultsLabel?: string;
|
|
23
|
+
search?: ToolbarSearchProps;
|
|
23
24
|
}
|
|
24
|
-
export declare const ToolbarFilter: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, optionType, id, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const ToolbarFilter: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, search, optionType, id, }: ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
26
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StoryObj } from '@storybook/react-vite';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, optionType, id, }: import('./ToolbarFilter').ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ removable, label, name, filterState, options, optionGroups, onChange, onRemove, buttonAltText, getSelectedLabel, showResultsLabel, search, optionType, id, }: import('./ToolbarFilter').ToolbarFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
parameters: {};
|
|
7
7
|
args: {
|
|
@@ -17,3 +17,4 @@ export default meta;
|
|
|
17
17
|
type Story = StoryObj<typeof meta>;
|
|
18
18
|
export declare const Single: Story;
|
|
19
19
|
export declare const Multiple: Story;
|
|
20
|
+
export declare const MultipleWithSearch: Story;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { MenuOptionProps
|
|
1
|
+
import { MenuOptionProps } from '../Menu';
|
|
2
2
|
import { FilterChangePayload } from './Toolbar.tsx';
|
|
3
|
+
import { ToolbarSearchProps } from './ToolbarSearch';
|
|
3
4
|
export type ToolbarOptionType = 'checkbox' | 'radio';
|
|
4
5
|
export interface OptionGroup {
|
|
5
6
|
title?: string;
|
|
@@ -10,7 +11,7 @@ export interface ToolbarOptionsProps {
|
|
|
10
11
|
name: string;
|
|
11
12
|
options: MenuOptionProps[];
|
|
12
13
|
onChange?: (input: FilterChangePayload) => void;
|
|
13
|
-
search?:
|
|
14
|
+
search?: ToolbarSearchProps;
|
|
14
15
|
optionType: ToolbarOptionType;
|
|
15
16
|
optionGroups?: {
|
|
16
17
|
[key: string]: OptionGroup;
|