@altinn/altinn-components 0.41.0 → 0.41.1

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,28 +1,44 @@
1
- import { jsxs as l, jsx as n } from "react/jsx-runtime";
2
- import { Fragment as u, createElement as p } from "react";
1
+ import { jsxs as o, jsx as r } from "react/jsx-runtime";
2
+ import { Fragment as y, createElement as k } from "react";
3
3
  import "../../index-L8X2o7IH.js";
4
- import { AccountListItem as f } from "./AccountListItem.js";
5
- import { Typography as y } from "../Typography/Typography.js";
6
- import { Heading as d } from "../Typography/Heading.js";
4
+ import { AccountListItem as u } from "./AccountListItem.js";
5
+ import { Typography as x } from "../Typography/Typography.js";
6
+ import { Heading as m } from "../Typography/Heading.js";
7
+ import { useMenu as I } from "../../hooks/useMenu.js";
7
8
  import "../RootProvider/RootProvider.js";
8
- import { List as m } from "../List/List.js";
9
+ import { List as L } from "../List/List.js";
9
10
  import "../Snackbar/useSnackbar.js";
10
- import { Section as h } from "../Page/Section.js";
11
- const F = ({
12
- items: t,
13
- groups: i,
14
- emptyTitle: g = "Ingen treff",
15
- emptyDescription: s = "Søket ga ingen treff"
16
- }) => !t || t.length === 0 ? /* @__PURE__ */ l(h, { children: [
17
- /* @__PURE__ */ n(d, { size: "lg", children: g }),
18
- /* @__PURE__ */ n(y, { children: s })
19
- ] }) : i ? /* @__PURE__ */ n(h, { spacing: 6, children: Object.entries(i).map(([r, a]) => {
20
- const { title: o } = a, c = t.filter((e) => e.groupId === r && !e.hidden);
21
- return c.length === 0 ? null : /* @__PURE__ */ l(u, { children: [
22
- o && /* @__PURE__ */ n(d, { size: "lg", children: o }),
23
- /* @__PURE__ */ n(m, { children: c.map((e) => /* @__PURE__ */ p(f, { ...e, key: e.id })) })
24
- ] }, r);
25
- }) }) : /* @__PURE__ */ n(m, { children: t.filter((r) => !(r != null && r.hidden)).map((r) => /* @__PURE__ */ p(f, { ...r, key: r.id })) });
11
+ import { Section as c } from "../Page/Section.js";
12
+ const M = ({
13
+ items: i,
14
+ groups: p = {},
15
+ sortGroupBy: s,
16
+ emptyTitle: f = "Ingen treff",
17
+ emptyDescription: l = "Søket ga ingen treff"
18
+ }) => {
19
+ if (!i || i.length === 0)
20
+ return /* @__PURE__ */ o(c, { children: [
21
+ /* @__PURE__ */ r(m, { size: "lg", children: f }),
22
+ /* @__PURE__ */ r(x, { children: l })
23
+ ] });
24
+ const { menu: n } = I({
25
+ items: i,
26
+ groups: p,
27
+ groupByKey: "groupId",
28
+ keyboardEvents: !1,
29
+ sortGroupBy: s
30
+ });
31
+ return /* @__PURE__ */ r(c, { spacing: 6, children: n == null ? void 0 : n.map((t, a) => {
32
+ const e = t.props || {};
33
+ return /* @__PURE__ */ o(y, { children: [
34
+ (e == null ? void 0 : e.title) && /* @__PURE__ */ r(m, { size: "lg", children: e.title }),
35
+ /* @__PURE__ */ r(L, { children: t == null ? void 0 : t.items.map((d, h) => {
36
+ const g = d.props || {};
37
+ return /* @__PURE__ */ k(u, { ...g, key: h });
38
+ }) })
39
+ ] }, a);
40
+ }) });
41
+ };
26
42
  export {
27
- F as AccountList
43
+ M as AccountList
28
44
  };
@@ -1,57 +1,59 @@
1
- import { jsx as o } from "react/jsx-runtime";
1
+ import { jsx as r } from "react/jsx-runtime";
2
2
  import "../../index-L8X2o7IH.js";
3
3
  import "react";
4
4
  import "../RootProvider/RootProvider.js";
5
- import { ListItem as k } from "../List/ListItem.js";
5
+ import { ListItem as C } from "../List/ListItem.js";
6
6
  import "../Snackbar/useSnackbar.js";
7
- import { AccountListItemControls as C } from "./AccountListItemControls.js";
8
- const y = ({
9
- id: r,
10
- type: i,
11
- size: m,
7
+ import { AccountListItemControls as M } from "./AccountListItemControls.js";
8
+ const B = ({
9
+ id: i,
10
+ type: m,
11
+ size: c,
12
12
  expanded: t,
13
- icon: c,
14
- title: s,
13
+ icon: s,
14
+ title: e,
15
15
  description: n,
16
- isCurrentEndUser: e,
17
- isDeleted: p,
18
- badge: l,
19
- favourite: u = !1,
20
- favouriteLabel: f,
21
- onToggleFavourite: I,
22
- contextMenu: L,
23
- children: v,
24
- interactive: A,
25
- ...j
26
- }) => /* @__PURE__ */ o(
27
- k,
16
+ isCurrentEndUser: p,
17
+ isDeleted: u,
18
+ badge: f,
19
+ favourite: I = !1,
20
+ favouriteLabel: l,
21
+ onToggleFavourite: L,
22
+ contextMenu: v,
23
+ children: A,
24
+ interactive: j,
25
+ loading: o,
26
+ ...k
27
+ }) => /* @__PURE__ */ r(
28
+ C,
28
29
  {
29
- ...j,
30
- size: m,
31
- icon: c,
32
- title: s,
30
+ ...k,
31
+ loading: o,
32
+ size: c,
33
+ icon: s,
34
+ title: e,
33
35
  description: t ? void 0 : n,
34
36
  expanded: t,
35
37
  selected: t,
36
- controls: /* @__PURE__ */ o(
37
- C,
38
+ controls: !o && /* @__PURE__ */ r(
39
+ M,
38
40
  {
39
- id: r,
40
- type: i,
41
- favourite: u,
42
- favouriteLabel: f,
43
- badge: l,
44
- isCurrentEndUser: e,
45
- isDeleted: p,
46
- onToggleFavourite: I,
47
- contextMenu: t ? void 0 : L
41
+ id: i,
42
+ type: m,
43
+ favourite: I,
44
+ favouriteLabel: l,
45
+ badge: f,
46
+ isCurrentEndUser: p,
47
+ isDeleted: u,
48
+ onToggleFavourite: L,
49
+ contextMenu: t ? void 0 : v
48
50
  }
49
51
  ),
50
- linkIcon: !0,
51
- interactive: A,
52
- children: v
52
+ linkIcon: !o && !0,
53
+ interactive: j,
54
+ children: A
53
55
  }
54
56
  );
55
57
  export {
56
- y as AccountListItem
58
+ B as AccountListItem
57
59
  };
@@ -2,9 +2,9 @@
2
2
  import { jsxs as y, jsx as f } from "react/jsx-runtime";
3
3
  import { c as I } from "../../index-L8X2o7IH.js";
4
4
  import m, { forwardRef as w, useRef as O, useMemo as k } from "react";
5
- import { IconButton as E } from "../Button/IconButton.js";
6
- import { useClickOutside as _ } from "../../hooks/useClickOutside.js";
7
- import { useEnterKey as C } from "../../hooks/useEnterKey.js";
5
+ import { useClickOutside as E } from "../../hooks/useClickOutside.js";
6
+ import { useEnterKey as _ } from "../../hooks/useEnterKey.js";
7
+ import { IconButton as C } from "../Button/IconButton.js";
8
8
  import { DropdownBase as M } from "../Dropdown/DropdownBase.js";
9
9
  import { MenuItems as j } from "../Menu/MenuItems.js";
10
10
  import { useRootContext as R } from "../RootProvider/RootProvider.js";
@@ -38,7 +38,7 @@ const A = w((e, s) => {
38
38
  items: i
39
39
  }) => {
40
40
  const { currentId: v, toggleId: p, closeAll: a } = R(), d = O(null), g = "context-menu-" + e, x = () => p(e), u = v === e;
41
- _(d, () => {
41
+ E(d, () => {
42
42
  u && p(e);
43
43
  });
44
44
  const b = k(() => i.map((n) => ({
@@ -49,7 +49,7 @@ const A = w((e, s) => {
49
49
  (c = n.onClick) == null || c.call(n), a();
50
50
  }
51
51
  })), [i, a]);
52
- C((n) => {
52
+ _((n) => {
53
53
  var c;
54
54
  if (u) {
55
55
  n.preventDefault();
@@ -63,7 +63,7 @@ const A = w((e, s) => {
63
63
  };
64
64
  return /* @__PURE__ */ y("div", { className: I(S.toggle, o), ref: d, "data-testid": g, children: [
65
65
  /* @__PURE__ */ f(
66
- E,
66
+ C,
67
67
  {
68
68
  size: "xs",
69
69
  rounded: !0,
@@ -6,24 +6,24 @@ import "../RootProvider/RootProvider.js";
6
6
  import "../Snackbar/useSnackbar.js";
7
7
  import { MenuItem as m } from "../Menu/MenuItem.js";
8
8
  import { u as c } from "../../useId-BVFxCjkq.js";
9
- var d = function(t, o) {
9
+ var d = function(t, l) {
10
10
  var r = {};
11
- for (var e in t) Object.prototype.hasOwnProperty.call(t, e) && o.indexOf(e) < 0 && (r[e] = t[e]);
11
+ for (var e in t) Object.prototype.hasOwnProperty.call(t, e) && l.indexOf(e) < 0 && (r[e] = t[e]);
12
12
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
13
- for (var l = 0, e = Object.getOwnPropertySymbols(t); l < e.length; l++)
14
- o.indexOf(e[l]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[l]) && (r[e[l]] = t[e[l]]);
13
+ for (var o = 0, e = Object.getOwnPropertySymbols(t); o < e.length; o++)
14
+ l.indexOf(e[o]) < 0 && Object.prototype.propertyIsEnumerable.call(t, e[o]) && (r[e[o]] = t[e[o]]);
15
15
  return r;
16
16
  };
17
- const p = f((t, o) => {
18
- var { title: r, titleId: e } = t, l = d(t, ["title", "titleId"]);
17
+ const p = f((t, l) => {
18
+ var { title: r, titleId: e } = t, o = d(t, ["title", "titleId"]);
19
19
  let n = c();
20
20
  return n = r ? e || "title-" + n : void 0, i.createElement(
21
21
  "svg",
22
- Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: o, "aria-labelledby": n }, l),
22
+ Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": n }, o),
23
23
  r ? i.createElement("title", { id: n }, r) : null,
24
- i.createElement("path", { fill: "currentColor", d: "M14.97 3.97a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1 0 1.06l-4.5 4.5a.75.75 0 1 1-1.06-1.06l3.22-3.22H8a4.25 4.25 0 0 0 0 8.5h1.5a.75.75 0 0 1 0 1.5H8a5.75 5.75 0 0 1 0-11.5h10.19l-3.22-3.22a.75.75 0 0 1 0-1.06" })
24
+ i.createElement("path", { fill: "currentColor", d: "M9.03 5.03a.75.75 0 1 0-1.06-1.06l-4.5 4.5a.75.75 0 0 0 0 1.06l4.5 4.5a.75.75 0 1 0 1.06-1.06L5.81 9.75H16a4.25 4.25 0 0 1 0 8.5h-1.5a.75.75 0 0 0 0 1.5H16a5.75 5.75 0 0 0 0-11.5H5.81z" })
25
25
  );
26
- }), h = ({ label: t, onClick: o, as: r }) => /* @__PURE__ */ a(m, { size: "sm", id: "back", icon: p, title: t, onClick: o, as: r });
26
+ }), v = ({ label: t, onClick: l, as: r }) => /* @__PURE__ */ a(m, { size: "sm", id: "back", icon: p, title: t, onClick: l, as: r });
27
27
  export {
28
- h as BackButton
28
+ v as BackButton
29
29
  };
@@ -1,38 +1,37 @@
1
- import { jsx as t, jsxs as m } from "react/jsx-runtime";
2
- import { Fragment as s } from "react";
1
+ import { jsx as t, jsxs as o } from "react/jsx-runtime";
2
+ import { Fragment as s, createElement as f } from "react";
3
3
  import "../../index-L8X2o7IH.js";
4
- import { Heading as x } from "../Typography/Heading.js";
4
+ import { useMenu as h } from "../../hooks/useMenu.js";
5
+ import { Heading as g } from "../Typography/Heading.js";
5
6
  import "../RootProvider/RootProvider.js";
6
- import { Divider as f } from "../Divider/Divider.js";
7
- import { List as h } from "../List/List.js";
7
+ import { Divider as y } from "../Divider/Divider.js";
8
+ import { List as S } from "../List/List.js";
8
9
  import "../Snackbar/useSnackbar.js";
9
- import { Flex as I } from "../Page/Flex.js";
10
- import { SettingsSection as a } from "./SettingsSection.js";
11
- import { SettingsItem as p } from "./SettingsItem.js";
12
- const O = ({ items: r, groups: d }) => {
13
- var c;
14
- if (d) {
15
- const e = (c = Object.keys(d).map((i) => {
16
- const n = r == null ? void 0 : r.filter((o) => o.groupId === i && !o.hidden), { title: l } = d[i] || {};
17
- return {
18
- groupId: i,
19
- title: l,
20
- items: n
21
- };
22
- })) == null ? void 0 : c.filter((i) => i.items.length > 0);
23
- return /* @__PURE__ */ t(I, { as: "div", spacing: "page", direction: "col", children: e.map((i) => /* @__PURE__ */ m(s, { children: [
24
- (i == null ? void 0 : i.title) && /* @__PURE__ */ t(x, { size: "lg", children: i == null ? void 0 : i.title }),
25
- /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(h, { size: "sm", children: i.items.map((n, l) => /* @__PURE__ */ m(s, { children: [
26
- l > 0 && /* @__PURE__ */ t(f, {}),
27
- /* @__PURE__ */ t(p, { ...n })
28
- ] }, n.id)) }) })
29
- ] }, i.groupId)) });
30
- }
31
- return /* @__PURE__ */ t(a, { children: /* @__PURE__ */ t(h, { size: "sm", children: r.filter((e) => !(e != null && e.hidden)).map((e, i) => /* @__PURE__ */ m(s, { children: [
32
- i > 0 && /* @__PURE__ */ t(f, {}),
33
- /* @__PURE__ */ t(p, { ...e })
34
- ] }, e.id)) }) });
10
+ import { Flex as v } from "../Page/Flex.js";
11
+ import { SettingsSection as j } from "./SettingsSection.js";
12
+ import { SettingsItem as k } from "./SettingsItem.js";
13
+ const q = ({ items: n, groups: p = {}, sortGroupBy: c }) => {
14
+ const { menu: r } = h({
15
+ items: n,
16
+ groups: p,
17
+ groupByKey: "groupId",
18
+ keyboardEvents: !1,
19
+ sortGroupBy: c
20
+ });
21
+ return /* @__PURE__ */ t(v, { as: "div", spacing: "page", direction: "col", children: r == null ? void 0 : r.map((i, l) => {
22
+ const e = i.props || {};
23
+ return /* @__PURE__ */ o(s, { children: [
24
+ (e == null ? void 0 : e.title) && /* @__PURE__ */ t(g, { size: "lg", children: e.title }),
25
+ /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(S, { size: "sm", children: i == null ? void 0 : i.items.map((a, m) => {
26
+ const d = a.props || {};
27
+ return /* @__PURE__ */ o(s, { children: [
28
+ m > 0 && /* @__PURE__ */ t(y, {}),
29
+ /* @__PURE__ */ f(k, { ...d, key: "settings-list-item" + m })
30
+ ] }, m);
31
+ }) }) })
32
+ ] }, l);
33
+ }) });
35
34
  };
36
35
  export {
37
- O as SettingsList
36
+ q as SettingsList
38
37
  };
@@ -6,7 +6,8 @@ export interface AccountListGroupProps {
6
6
  export interface AccountListProps {
7
7
  items: AccountListItemProps[];
8
8
  groups?: Record<string, AccountListGroupProps>;
9
+ sortGroupBy?: (a: [string, AccountListItemProps[]], b: [string, AccountListItemProps[]]) => number;
9
10
  emptyTitle?: string;
10
11
  emptyDescription?: string;
11
12
  }
12
- export declare const AccountList: ({ items, groups, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const AccountList: ({ items, groups, sortGroupBy, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,13 +3,14 @@ import { AccountListItemProps, AccountListProps } from '..';
3
3
  import { UseAccountsProps } from '../../../examples';
4
4
  declare const meta: {
5
5
  title: string;
6
- component: ({ items, groups, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
6
+ component: ({ items, groups, sortGroupBy, emptyTitle, emptyDescription, }: AccountListProps) => import("react/jsx-runtime").JSX.Element;
7
7
  tags: string[];
8
8
  parameters: {};
9
9
  args: AccountListProps;
10
10
  };
11
11
  export default meta;
12
12
  export declare const Default: ({ includeGroups }: UseAccountsProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const Loading: () => import("react/jsx-runtime").JSX.Element;
13
14
  interface ControlledProps {
14
15
  includeGroups?: boolean;
15
16
  contextMenu?: boolean;
@@ -16,4 +16,4 @@ export interface AccountListItemProps extends ListItemProps, AccountListItemCont
16
16
  contextMenu?: ContextMenuProps;
17
17
  label?: string;
18
18
  }
19
- export declare const AccountListItem: ({ id, type, size, expanded, icon, title, description, isCurrentEndUser, isDeleted, badge, favourite, favouriteLabel, onToggleFavourite, contextMenu, children, interactive, ...item }: AccountListItemProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const AccountListItem: ({ id, type, size, expanded, icon, title, description, isCurrentEndUser, isDeleted, badge, favourite, favouriteLabel, onToggleFavourite, contextMenu, children, interactive, loading, ...item }: AccountListItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react-vite';
2
2
  import { AccountListItemProps } from '..';
3
3
  declare const meta: {
4
4
  title: string;
5
- component: ({ id, type, size, expanded, icon, title, description, isCurrentEndUser, isDeleted, badge, favourite, favouriteLabel, onToggleFavourite, contextMenu, children, interactive, ...item }: AccountListItemProps) => import("react/jsx-runtime").JSX.Element;
5
+ component: ({ id, type, size, expanded, icon, title, description, isCurrentEndUser, isDeleted, badge, favourite, favouriteLabel, onToggleFavourite, contextMenu, children, interactive, loading, ...item }: AccountListItemProps) => import("react/jsx-runtime").JSX.Element;
6
6
  tags: string[];
7
7
  parameters: {};
8
8
  args: {
@@ -5,5 +5,6 @@ export interface SettingsGroupProps {
5
5
  export interface SettingsListProps {
6
6
  items: SettingsItemProps[];
7
7
  groups?: Record<string, SettingsGroupProps>;
8
+ sortGroupBy?: (a: [string, SettingsItemProps[]], b: [string, SettingsItemProps[]]) => number;
8
9
  }
9
- export declare const SettingsList: ({ items, groups }: SettingsListProps) => import("react/jsx-runtime").JSX.Element;
10
+ export declare const SettingsList: ({ items, groups, sortGroupBy }: SettingsListProps) => import("react/jsx-runtime").JSX.Element;
@@ -30,7 +30,7 @@ interface LocaleSettingsModal extends SettingsModalProps {
30
30
  value?: string;
31
31
  }
32
32
  export declare const LocaleSettingsModal: ({ open, onClose, value, onChange, }: LocaleSettingsModal) => import("react/jsx-runtime").JSX.Element;
33
- export declare const SearchSettings: ({ query, groups }: UseSettingsProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const AllSettings: ({ query, groups, includeGroups, excludeGroups, }: UseSettingsProps) => import("react/jsx-runtime").JSX.Element;
34
34
  export declare const AlertSettings: () => import("react/jsx-runtime").JSX.Element;
35
35
  export declare const AccountSettings: () => import("react/jsx-runtime").JSX.Element;
36
36
  export declare const PersonSettings: () => 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.41.0",
3
+ "version": "0.41.1",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",