@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.
@@ -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: v,
17
- children: y,
18
- showResultsLabel: S,
19
- removeButtonAltText: h,
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: S,
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: v,
77
- buttonAltText: h,
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
- y
101
+ v
101
102
  ] });
102
103
  };
103
104
  export {
@@ -1,15 +1,15 @@
1
- import { jsxs as D, jsx as a } from "react/jsx-runtime";
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 I } from "../../hooks/useIsDesktop.js";
4
+ import { useIsDesktop as j } from "../../hooks/useIsDesktop.js";
5
5
  import "../Button/Button.js";
6
- import { useRootContext as j } from "../RootProvider/RootProvider.js";
7
- import { DrawerOrDropdown as F } from "../Dropdown/DrawerOrDropdown.js";
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 L } from "./ToolbarButton.js";
10
- import { ToolbarFilterBase as O } from "./ToolbarFilterBase.js";
11
- import { ToolbarOptions as R } from "./ToolbarOptions.js";
12
- const E = (i, t) => Array.isArray(t) ? t.join(", ") : t, P = ({
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
- optionType: A,
24
+ search: A,
25
+ optionType: h,
25
26
  id: s = `toolbar-filter-${o}`
26
27
  }) => {
27
- const { currentId: h, toggleId: v, closeAll: d } = j(), u = I(), k = (m ?? []).map((r) => {
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], w = g?.(o, n) ?? E(o, n), f = () => v(s), l = h === s, B = (r) => {
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
- }, C = Array.isArray(n) ? n.length > 0 : typeof n < "u";
38
- return /* @__PURE__ */ D(O, { expanded: l, onBlurCapture: B, "data-testid": "filter-base-" + s, children: [
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
- L,
41
+ O,
41
42
  {
42
43
  type: "select",
43
44
  removable: i,
44
- active: C,
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: w || t
52
+ children: B || t
52
53
  }
53
54
  ),
54
55
  /* @__PURE__ */ a(
55
- F,
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
- R,
66
+ E,
66
67
  {
67
68
  name: o,
68
- options: k,
69
+ options: w,
69
70
  optionGroups: b,
70
71
  onChange: y,
71
- optionType: A,
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
- P as ToolbarFilter
82
+ Q as ToolbarFilter
81
83
  };
@@ -1,77 +1,84 @@
1
- import { jsxs as b, jsx as e } from "react/jsx-runtime";
2
- import { useRef as A, Fragment as F } from "react";
3
- import { useMenu as H } from "../../hooks/useMenu.js";
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 K } from "../Menu/MenuOption.js";
8
- import { MenuSearch as N } from "../Menu/MenuSearch.js";
9
- import { MenuHeader as R } from "../Menu/MenuHeader.js";
10
- import { MenuBase as S, MenuList as q, MenuListItem as t } from "../Menu/MenuBase.js";
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: x,
14
- search: n,
15
- optionGroups: i = {},
16
- options: y,
17
- onChange: v,
18
- optionType: g,
19
- keyboardEvents: p,
20
- onBlurCapture: k
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 m = A(null), { menu: I, setActiveIndex: L } = H({
23
- items: y,
24
- groups: i,
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: p,
27
- ref: m
29
+ keyboardEvents: s,
30
+ ref: u
28
31
  });
29
- return /* @__PURE__ */ b(S, { variant: "default", ref: m, children: [
30
- n && /* @__PURE__ */ e(N, { ...n }),
31
- /* @__PURE__ */ e(q, { role: "menu", onBlurCapture: k, children: I.map((a, c) => {
32
- const T = a?.props || {}, { title: s, divider: j = !0 } = T;
33
- return /* @__PURE__ */ b(F, { children: [
34
- c && j ? /* @__PURE__ */ e(t, { role: "separator" }) : "",
35
- s && /* @__PURE__ */ e(t, { children: /* @__PURE__ */ e(R, { title: s }) }),
36
- a?.items.filter((r) => !r.props?.hidden).map((r, B) => {
37
- const { active: C, onMouseEnter: O } = r, { groupId: l, onClick: w, value: u, checked: d, type: f, ...o } = r.props || {}, { expanded: P } = o, h = o.name || x, M = f || l && i[l]?.optionType || g;
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
- t,
46
+ a,
40
47
  {
41
48
  expanded: P,
42
- onMouseEnter: O,
43
- onMouseLeave: () => L(-1),
44
- role: f === "radio" ? "menuitemradio" : "menuitemcheckbox",
45
- "aria-checked": d ?? !1,
49
+ onMouseEnter: B,
50
+ onMouseLeave: () => I(-1),
51
+ role: M === "radio" ? "menuitemradio" : "menuitemcheckbox",
52
+ "aria-checked": C ?? !1,
46
53
  children: /* @__PURE__ */ e(
47
- K,
54
+ R,
48
55
  {
49
56
  ...o,
50
- active: C,
51
- tabIndex: p ? -1 : 0,
57
+ active: w,
58
+ tabIndex: s ? -1 : 0,
52
59
  label: o.label,
53
60
  count: o.count,
54
- name: h,
55
- type: M,
56
- value: u,
57
- checked: d,
61
+ name: g,
62
+ type: b,
63
+ value: f,
64
+ checked: C,
58
65
  onClick: () => {
59
- v?.({
60
- name: h,
61
- value: u,
62
- type: M
66
+ x?.({
67
+ name: g,
68
+ value: f,
69
+ type: b
63
70
  });
64
71
  }
65
72
  }
66
73
  )
67
74
  },
68
- B
75
+ j
69
76
  );
70
77
  })
71
- ] }, c);
78
+ ] }, m);
72
79
  }) })
73
80
  ] });
74
81
  };
75
82
  export {
76
- _ as ToolbarOptions
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, MenuSearchProps } from '../Menu';
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?: MenuSearchProps;
14
+ search?: ToolbarSearchProps;
14
15
  optionType: ToolbarOptionType;
15
16
  optionGroups?: {
16
17
  [key: string]: OptionGroup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.53.1",
3
+ "version": "0.54.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",