@altinn/altinn-components 0.18.2 → 0.18.3

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,44 +1,46 @@
1
1
  import { jsx as m } from "react/jsx-runtime";
2
- import { useRef as v, createElement as x } from "react";
2
+ import { useRef as v, createElement as A } from "react";
3
3
  import "../../index-L8X2o7IH.js";
4
- import { useMenu as A } from "../../hooks/useMenu.js";
4
+ import { useMenu as I } from "../../hooks/useMenu.js";
5
5
  import "../RootProvider/RootProvider.js";
6
- import { AutocompleteBase as I } from "./AutocompleteBase.js";
7
- import { AutocompleteGroup as l } from "./AutocompleteGroup.js";
6
+ import { AutocompleteBase as l } from "./AutocompleteBase.js";
7
+ import { AutocompleteGroup as x } from "./AutocompleteGroup.js";
8
8
  import { AutocompleteItem as h } from "./AutocompleteItem.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
10
  import { useEnterKey as k } from "../../hooks/useEnterKey.js";
11
- const C = ({ className: u, items: s, groups: i = {}, expanded: n, onSelect: r }) => {
11
+ const C = ({ className: s, items: i, groups: n = {}, expanded: u, onSelect: r }) => {
12
12
  const p = v(null);
13
13
  k(() => {
14
- var e;
15
- const t = (e = p.current) == null ? void 0 : e.querySelector('[data-active="true"]');
16
- t == null || t.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), r == null || r();
14
+ var t;
15
+ if (u) {
16
+ const e = (t = p.current) == null ? void 0 : t.querySelector('[data-active="true"]');
17
+ e == null || e.dispatchEvent(new MouseEvent("click", { bubbles: !0 })), r == null || r();
18
+ }
17
19
  });
18
- const { menu: a, setActiveIndex: c } = A({
19
- items: s,
20
- groups: i,
20
+ const { menu: c, setActiveIndex: f } = I({
21
+ items: i,
22
+ groups: n,
21
23
  groupByKey: "groupId",
22
24
  keyboardEvents: !0
23
25
  });
24
- return /* @__PURE__ */ m(I, { className: u, expanded: n, ref: p, children: a.map((t, e) => /* @__PURE__ */ x(l, { ...t.props, key: e }, /* @__PURE__ */ m("ul", { children: t.items.map((d, f) => {
26
+ return /* @__PURE__ */ m(l, { className: s, expanded: u, ref: p, children: c.map((t, e) => /* @__PURE__ */ A(x, { ...t.props, key: e }, /* @__PURE__ */ m("ul", { children: t.items.map((a, d) => {
25
27
  const {
26
28
  active: y,
27
29
  menuIndex: E,
28
30
  props: { groupId: M, onClick: o, ...b }
29
- } = d;
31
+ } = a;
30
32
  return /* @__PURE__ */ m(
31
33
  h,
32
34
  {
33
35
  tabIndex: -1,
34
- onMouseEnter: () => c(E),
36
+ onMouseEnter: () => f(E),
35
37
  ...b,
36
38
  onClick: () => {
37
39
  o == null || o(), r == null || r();
38
40
  },
39
41
  active: y
40
42
  },
41
- f
43
+ d
42
44
  );
43
45
  }) }))) });
44
46
  };
@@ -1,20 +1,34 @@
1
- import { jsxs as n, jsx as r } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as m } from "react/jsx-runtime";
2
2
  import "../../index-L8X2o7IH.js";
3
3
  import "react";
4
- import { useRootContext as a } from "../RootProvider/RootProvider.js";
5
- import { ToolbarButton as d } from "./ToolbarButton.js";
6
- import { ToolbarFilterBase as f } from "./ToolbarFilterBase.js";
7
- import { DrawerOrDropdown as x } from "../Dropdown/DrawerOrDropdown.js";
8
- import { AccountMenu as T } from "../GlobalMenu/AccountMenu.js";
4
+ import { useRootContext as n } from "../RootProvider/RootProvider.js";
5
+ import { ToolbarButton as x } from "./ToolbarButton.js";
6
+ import { ToolbarFilterBase as T } from "./ToolbarFilterBase.js";
7
+ import { DrawerOrDropdown as b } from "../Dropdown/DrawerOrDropdown.js";
8
+ import { AccountMenu as g } from "../GlobalMenu/AccountMenu.js";
9
9
  import "../Search/AutocompleteBase.js";
10
10
  import "../Snackbar/useSnackbar.js";
11
- const k = ({ currentAccount: o, id: t = "toolbar-accounts", ...m }) => {
12
- const { currentId: i, toggleId: l, closeAll: p } = a(), s = () => l(t), e = i === t;
13
- return /* @__PURE__ */ n(f, { expanded: e, children: [
14
- /* @__PURE__ */ r(d, { type: "switch", onToggle: s, active: !!o, children: o == null ? void 0 : o.name }),
15
- /* @__PURE__ */ r(x, { open: e, drawerTitle: "Endre konto", onClose: p, children: /* @__PURE__ */ r(T, { ...m, currentAccount: o }) })
11
+ const y = ({
12
+ currentAccount: o,
13
+ id: i = "toolbar-accounts",
14
+ onSelectAccount: r,
15
+ ...e
16
+ }) => {
17
+ const { currentId: s, toggleId: l, closeAll: p } = n(), a = () => l(i), t = s === i;
18
+ return /* @__PURE__ */ f(T, { expanded: t, children: [
19
+ /* @__PURE__ */ m(x, { type: "switch", onToggle: a, active: !!o, children: o == null ? void 0 : o.name }),
20
+ /* @__PURE__ */ m(b, { open: t, drawerTitle: "Endre konto", onClose: p, children: /* @__PURE__ */ m(
21
+ g,
22
+ {
23
+ ...e,
24
+ onSelectAccount: (d) => {
25
+ r == null || r(d), p();
26
+ },
27
+ currentAccount: o
28
+ }
29
+ ) })
16
30
  ] });
17
31
  };
18
32
  export {
19
- k as ToolbarAccountMenu
33
+ y as ToolbarAccountMenu
20
34
  };
@@ -19,3 +19,4 @@ export declare const HiddenFilters: Story;
19
19
  export declare const WithAccountMenu: Story;
20
20
  export declare const WithSearch: Story;
21
21
  export declare const ControlledStateFilters: (args: typeof Toolbar) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const ControlledStateAccount: () => import("react/jsx-runtime").JSX.Element;
@@ -2,4 +2,4 @@ import { AccountMenuProps } from '../';
2
2
  export interface ToolbarAccountMenuProps extends AccountMenuProps {
3
3
  id?: string;
4
4
  }
5
- export declare const ToolbarAccountMenu: ({ currentAccount, id, ...rest }: ToolbarAccountMenuProps) => import("react/jsx-runtime").JSX.Element;
5
+ export declare const ToolbarAccountMenu: ({ currentAccount, id, onSelectAccount, ...rest }: ToolbarAccountMenuProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",