@altinn/altinn-components 0.18.1 → 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,12 +1,12 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { createElement as e } from "react";
1
+ import { jsx as t } from "react/jsx-runtime";
3
2
  import "../../index-L8X2o7IH.js";
3
+ import "react";
4
4
  import "../RootProvider/RootProvider.js";
5
5
  import "../Search/AutocompleteBase.js";
6
6
  import "../Snackbar/useSnackbar.js";
7
- import { AccessAreaListItem as i } from "./AccessAreaListItem.js";
7
+ import { AccessAreaListItem as m } from "./AccessAreaListItem.js";
8
8
  import { ListBase as p } from "../List/ListBase.js";
9
- const l = ({ items: t, color: o }) => /* @__PURE__ */ m(p, { color: o, spacing: 1, children: t.map((r) => /* @__PURE__ */ e(i, { ...r, key: r.id, ...r })) });
9
+ const d = ({ items: i, color: o }) => /* @__PURE__ */ t(p, { color: o, spacing: 1, children: i.map((r) => /* @__PURE__ */ t(m, { ...r }, r.id)) });
10
10
  export {
11
- l as AccessAreaList
11
+ d as AccessAreaList
12
12
  };
@@ -4,36 +4,43 @@ import "react";
4
4
  import "../RootProvider/RootProvider.js";
5
5
  import "../Search/AutocompleteBase.js";
6
6
  import "../Snackbar/useSnackbar.js";
7
- import { ListItem as a } from "../List/ListItem.js";
8
- import '../../assets/AccessAreaListItem.css';const b = "_content_7hk0i_1", d = {
9
- content: b
10
- }, j = ({
7
+ import { ListItem as b } from "../List/ListItem.js";
8
+ import '../../assets/AccessAreaListItem.css';const d = "_content_7hk0i_1", f = {
9
+ content: d
10
+ }, k = ({
11
11
  name: c,
12
12
  icon: m,
13
- size: i = "md",
14
- children: r,
13
+ iconUrl: i,
14
+ size: r = "md",
15
+ children: l,
15
16
  expanded: t = !1,
16
- onClick: l,
17
- badgeText: o,
18
- colorTheme: e,
17
+ onClick: p,
18
+ badgeText: e,
19
+ colorTheme: o,
19
20
  loading: n,
20
- ...p
21
+ ...a
21
22
  }) => /* @__PURE__ */ s(
22
- a,
23
+ b,
23
24
  {
24
25
  as: "button",
25
- icon: { svgElement: m, theme: "subtle", color: e },
26
+ icon: {
27
+ svgElement: m,
28
+ iconUrl: i,
29
+ theme: "subtle",
30
+ color: o,
31
+ altText: ""
32
+ },
26
33
  title: c,
27
- size: i,
34
+ size: r,
28
35
  collapsible: !n,
29
36
  expanded: t,
30
- onClick: l,
31
- badge: o ? { label: o, color: e } : void 0,
37
+ onClick: p,
38
+ badge: e ? { label: e, color: o } : void 0,
32
39
  loading: n,
33
- ...p,
34
- children: t && /* @__PURE__ */ s("div", { className: d.content, children: r })
40
+ ...a,
41
+ children: t && /* @__PURE__ */ s("div", { className: f.content, children: l })
35
42
  }
36
43
  );
37
44
  export {
38
- j as AccessAreaListItem
45
+ k as AccessAreaListItem
39
46
  };
@@ -1,13 +1,22 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { c as i } from "../../index-L8X2o7IH.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { c as t } from "../../index-L8X2o7IH.js";
3
3
  import "react";
4
4
  import "../RootProvider/RootProvider.js";
5
5
  import { Skeleton as p } from "../Skeleton/Skeleton.js";
6
6
  import "../Search/AutocompleteBase.js";
7
7
  import "../Snackbar/useSnackbar.js";
8
- import '../../assets/Icon.css';const l = "_icon_3p8he_1", n = {
9
- icon: l
10
- }, j = ({ loading: a, altText: c, svgElement: r, size: e, color: s, theme: m, className: t }) => r ? /* @__PURE__ */ o(p, { loading: a, variant: "circle", children: /* @__PURE__ */ o("span", { "data-size": e, "data-color": s, "data-theme": m, className: i([n.icon], t), children: /* @__PURE__ */ o(r, { "aria-hidden": "true", "alt-label": c }) }) }) : /* @__PURE__ */ o("span", { className: i([n.icon], t) });
8
+ import '../../assets/Icon.css';const d = "_icon_3p8he_1", a = {
9
+ icon: d
10
+ }, b = ({
11
+ loading: c,
12
+ altText: n,
13
+ svgElement: o,
14
+ size: e,
15
+ color: s,
16
+ theme: m,
17
+ iconUrl: l,
18
+ className: i
19
+ }) => o ? /* @__PURE__ */ r(p, { loading: c, variant: "circle", children: /* @__PURE__ */ r("span", { "data-size": e, "data-color": s, "data-theme": m, className: t([a.icon], i), children: /* @__PURE__ */ r(o, { "aria-hidden": "true", "alt-label": n }) }) }) : l ? /* @__PURE__ */ r(p, { loading: c, variant: "circle", children: /* @__PURE__ */ r("span", { "data-size": e, "data-color": s, "data-theme": m, className: t([a.icon], i), children: /* @__PURE__ */ r("img", { src: l, alt: n, className: a.icon }) }) }) : /* @__PURE__ */ r("span", { className: t([a.icon], i) });
11
20
  export {
12
- j as Icon
21
+ b as Icon
13
22
  };
@@ -1,5 +1,5 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- import { isValidElement as n } from "react";
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { isValidElement as o } from "react";
3
3
  import { Icon as i } from "./Icon.js";
4
4
  import "../../index-L8X2o7IH.js";
5
5
  import { Avatar as s } from "../Avatar/Avatar.js";
@@ -8,17 +8,17 @@ import "../RootProvider/RootProvider.js";
8
8
  import "../Search/AutocompleteBase.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
10
  function u(r) {
11
- return typeof r == "string" || typeof r == "number" || typeof r == "boolean" || r === null || n(r);
11
+ return typeof r == "string" || typeof r == "number" || typeof r == "boolean" || r === null || o(r);
12
12
  }
13
- const l = (r) => r.svgElement !== void 0, x = ({ size: r, icon: t, iconTheme: f, avatar: e, avatarGroup: m }) => {
14
- if (!t && !e && !m)
13
+ const d = (r) => r.svgElement !== void 0 || r.iconUrl !== void 0, x = ({ size: r, icon: e, iconTheme: f, avatar: t, avatarGroup: m }) => {
14
+ if (!e && !t && !m)
15
15
  return null;
16
- if (t)
17
- return l(t) ? /* @__PURE__ */ o(i, { theme: t.theme || f, size: t.size || r, ...t }) : u(t) ? t : /* @__PURE__ */ o(i, { svgElement: t, theme: f, size: r });
18
16
  if (e)
19
- return /* @__PURE__ */ o(s, { ...e, size: e.size || r });
17
+ return d(e) ? /* @__PURE__ */ n(i, { theme: e.theme || f, size: e.size || r, ...e }) : u(e) ? e : /* @__PURE__ */ n(i, { svgElement: e, theme: f, size: r });
18
+ if (t)
19
+ return /* @__PURE__ */ n(s, { ...t, size: t.size || r });
20
20
  if (m)
21
- return /* @__PURE__ */ o(p, { ...m, size: m.size || r });
21
+ return /* @__PURE__ */ n(p, { ...m, size: m.size || r });
22
22
  };
23
23
  export {
24
24
  x as IconOrAvatar
@@ -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
  };
@@ -1,13 +1,11 @@
1
1
  import { Color } from '../../types';
2
2
  import { SvgElement } from '../Icon';
3
3
  import { ListItemProps } from '../List';
4
- export interface AccessAreaListItemProps extends Pick<ListItemProps, 'size' | 'onClick' | 'expanded' | 'loading'> {
4
+ interface AccessAreaListItemDefaultProps extends Pick<ListItemProps, 'size' | 'onClick' | 'expanded' | 'loading'> {
5
5
  /** Id of the item */
6
6
  id: string;
7
7
  /** Name of the Access Area */
8
8
  name: string;
9
- /** The icon associated with the Access Area */
10
- icon: SvgElement;
11
9
  /** Color theme of the Access Area */
12
10
  colorTheme?: Color;
13
11
  /** Optional Badge to display things like the number of packages a user has in the area */
@@ -15,4 +13,12 @@ export interface AccessAreaListItemProps extends Pick<ListItemProps, 'size' | 'o
15
13
  /** Children to render when the item is expanded */
16
14
  children?: React.ReactNode;
17
15
  }
18
- export declare const AccessAreaListItem: ({ name, icon, size, children, expanded, onClick, badgeText, colorTheme, loading, ...props }: AccessAreaListItemProps) => import("react/jsx-runtime").JSX.Element;
16
+ export type AccessAreaListItemProps = (AccessAreaListItemDefaultProps & {
17
+ icon: SvgElement;
18
+ iconUrl?: never;
19
+ }) | (AccessAreaListItemDefaultProps & {
20
+ iconUrl: string;
21
+ icon?: never;
22
+ });
23
+ export declare const AccessAreaListItem: ({ name, icon, iconUrl, size, children, expanded, onClick, badgeText, colorTheme, loading, ...props }: AccessAreaListItemProps) => import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -1,15 +1,14 @@
1
1
  import { StoryObj } from '@storybook/react';
2
- import { default as React } from 'react';
3
2
  import { AccessAreaListItemProps } from './AccessAreaListItem';
4
3
  declare const meta: {
5
4
  title: string;
6
- component: ({ name, icon, size, children, expanded, onClick, badgeText, colorTheme, loading, ...props }: AccessAreaListItemProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ name, icon, iconUrl, size, children, expanded, onClick, badgeText, colorTheme, loading, ...props }: AccessAreaListItemProps) => import("react/jsx-runtime").JSX.Element;
7
6
  tags: string[];
8
7
  args: {
9
8
  id: string;
10
9
  size: "md";
11
10
  name: string;
12
- icon: React.FC<React.SVGProps<SVGSVGElement>>;
11
+ iconUrl: string;
13
12
  badgeText: string;
14
13
  colorTheme: "company";
15
14
  loading: false;
@@ -26,11 +25,6 @@ declare const meta: {
26
25
  type: "inline-radio";
27
26
  };
28
27
  };
29
- icon: {
30
- control: {
31
- disable: true;
32
- };
33
- };
34
28
  colorTheme: {
35
29
  options: string[];
36
30
  control: {
@@ -4,7 +4,8 @@ export type IconSize = Size | undefined;
4
4
  export type IconColor = Color;
5
5
  export type IconTheme = Theme;
6
6
  export interface IconProps {
7
- svgElement: SvgElement | undefined | null | string;
7
+ svgElement?: SvgElement | undefined | null | string;
8
+ iconUrl?: string;
8
9
  altText?: string;
9
10
  loading?: boolean;
10
11
  size?: IconSize;
@@ -12,4 +13,4 @@ export interface IconProps {
12
13
  theme?: IconTheme;
13
14
  className?: string;
14
15
  }
15
- export declare const Icon: ({ loading, altText, svgElement: SvgElement, size, color, theme, className }: IconProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const Icon: ({ loading, altText, svgElement: SvgElement, size, color, theme, iconUrl, className, }: IconProps) => import("react/jsx-runtime").JSX.Element;
@@ -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.1",
3
+ "version": "0.18.3",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",