@altinn/altinn-components 0.24.5 → 0.24.7

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/README.md CHANGED
@@ -9,8 +9,22 @@ Today these teams are [Team Arbeidsflate](https://github.com/digdir/dialogporten
9
9
  Note that this package is specifically designed to meet the unique needs of the aforementioned teams and is not intended to serve as a general-purpose library.
10
10
  We already have the amazing [Norwegian public sector's Design System](https://designsystemet.no/), and we aim to incorporate its elements wherever it makes sense, ensuring alignment and leveraging its strengths while adapting to the specific requirements of Altinn.
11
11
 
12
- Currently, we do not use components from the design system _directly_ but rely on its token structure and continue to explore opportunities for deeper integration.
13
- This approach helps us align with brand guidelines and the broader vision of a unified Altinn product.
12
+
13
+ ## Strategy for Adopting Designsystemet
14
+
15
+ As of April 10th, 2024, we’ve decided to start importing components from the [Norwegian public sector’s Design System](https://designsystemet.no/) as needed. These components will be exported from our own library using the `DS<Component>` prefix.
16
+ Consumers of `altinn-components` will be able to use these components directly, without needing `@digdir/designsystemet` as a dependency.
17
+
18
+ This approach allows us to:
19
+
20
+ - Avoid conflicts with existing components during the transition phase.
21
+ - Experiment with and adapt the appearance and behavior to fit the Altinn brand.
22
+ - Gradually replace legacy components: once a `DS<Component>` has been sufficiently customized and tested, we will remove the `DS` prefix and promote it to a first-class component.
23
+ - Leverage the strengths of the Design System while maintaining full control over the visual consistency of our solutions.
24
+ - Maintain a curated and well-integrated selection of components from the `@digdir/designsystemet` with the look and feel of Altinn.
25
+
26
+ This strategy is a natural progression from our previous approach, where we did not use components from `@digdir/designsystemet` directly but relied on its token structure and explored opportunities for deeper integration.
27
+ That approach helped us move faster and build understanding — and now we're ready to take the next step.
14
28
 
15
29
  ## Feedback and questions
16
30
 
@@ -1,29 +1,29 @@
1
- import { jsx as f } from "react/jsx-runtime";
1
+ import { jsx as l } from "react/jsx-runtime";
2
2
  import { createElement as t } from "react";
3
3
  import "../../index-L8X2o7IH.js";
4
- import { useMenu as l } from "../../hooks/useMenu.js";
4
+ import { useMenu as y } from "../../hooks/useMenu.js";
5
5
  import "../RootProvider/RootProvider.js";
6
- import { DialogListGroup as y } from "./DialogListGroup.js";
6
+ import { DialogListGroup as u } from "./DialogListGroup.js";
7
7
  import { DialogListItem as d } from "./DialogListItem.js";
8
8
  import "../Search/AutocompleteBase.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
10
  import { Section as g } from "../Page/Section.js";
11
- const j = ({ items: i, groups: m = {}, sortGroupBy: e }) => {
12
- const { menu: r } = l({
11
+ const v = ({ items: i, groups: m = {}, sortGroupBy: e, isLoading: p }) => {
12
+ const { menu: o } = y({
13
13
  items: i,
14
14
  groups: m,
15
15
  groupByKey: "groupId",
16
16
  keyboardEvents: !1,
17
17
  sortGroupBy: e
18
18
  });
19
- return /* @__PURE__ */ f(g, { spacing: 3, margin: "section", children: r == null ? void 0 : r.map((o, p) => {
20
- const s = o.props || {};
21
- return /* @__PURE__ */ t(y, { ...s, key: p }, o == null ? void 0 : o.items.map((n, a) => {
22
- const c = n.props || {};
23
- return /* @__PURE__ */ t(d, { ...c, key: a });
19
+ return /* @__PURE__ */ l(g, { spacing: 3, margin: "section", "aria-busy": p, children: o == null ? void 0 : o.map((r, s) => {
20
+ const n = r.props || {};
21
+ return /* @__PURE__ */ t(u, { ...n, key: s }, r == null ? void 0 : r.items.map((a, c) => {
22
+ const f = a.props || {};
23
+ return /* @__PURE__ */ t(d, { ...f, key: c });
24
24
  }));
25
25
  }) });
26
26
  };
27
27
  export {
28
- j as DialogList
28
+ v as DialogList
29
29
  };
@@ -1,17 +1,31 @@
1
1
  "use client";
2
- import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
+ import { jsx as t, jsxs as a } from "react/jsx-runtime";
3
3
  import "../../index-L8X2o7IH.js";
4
4
  import "react";
5
- import "../RootProvider/RootProvider.js";
5
+ import { useRootContext as n } from "../RootProvider/RootProvider.js";
6
6
  import "../Search/AutocompleteBase.js";
7
7
  import "../Snackbar/useSnackbar.js";
8
- import { MenuOption as a } from "../Menu/MenuOption.js";
9
- import { MenuHeader as c } from "../Menu/MenuHeader.js";
10
- import { MenuBase as m, MenuList as p, MenuListItem as t } from "../Menu/MenuBase.js";
11
- const b = ({ title: o = "Select language", options: i, onChange: l }) => /* @__PURE__ */ e(m, { theme: "default", children: /* @__PURE__ */ n(p, { children: [
12
- /* @__PURE__ */ e(t, { children: /* @__PURE__ */ e(c, { title: o }) }),
13
- i.map((r) => /* @__PURE__ */ e(t, { children: /* @__PURE__ */ e(a, { onChange: l, label: r.label, type: "radio", value: r.value, checked: r.checked }) }, r.value))
14
- ] }) });
8
+ import { MenuOption as p } from "../Menu/MenuOption.js";
9
+ import { MenuHeader as u } from "../Menu/MenuHeader.js";
10
+ import { MenuBase as d, MenuList as s, MenuListItem as o } from "../Menu/MenuBase.js";
11
+ const k = ({ title: l = "Select language", options: c, onChange: r }) => {
12
+ const { toggleId: i } = n(), m = (e) => {
13
+ i("locale"), r == null || r(e);
14
+ };
15
+ return /* @__PURE__ */ t(d, { theme: "default", children: /* @__PURE__ */ a(s, { children: [
16
+ /* @__PURE__ */ t(o, { children: /* @__PURE__ */ t(u, { title: l }) }),
17
+ c.map((e) => /* @__PURE__ */ t(o, { children: /* @__PURE__ */ t(
18
+ p,
19
+ {
20
+ onChange: m,
21
+ label: e.label,
22
+ type: "radio",
23
+ value: e.value,
24
+ checked: e.checked
25
+ }
26
+ ) }, e.value))
27
+ ] }) });
28
+ };
15
29
  export {
16
- b as LocaleSwitcher
30
+ k as LocaleSwitcher
17
31
  };
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { jsxs as B, jsx as i } from "react/jsx-runtime";
2
+ import { jsxs as v, jsx as i } from "react/jsx-runtime";
3
3
  import { useState as F, useMemo as T } from "react";
4
- import { useRootContext as M } from "../RootProvider/RootProvider.js";
5
- import { ToolbarAccountMenu as V } from "./ToolbarAccountMenu.js";
6
- import { ToolbarAdd as $ } from "./ToolbarAdd.js";
7
- import { ToolbarBase as q } from "./ToolbarBase.js";
8
- import { ToolbarFilter as w } from "./ToolbarFilter.js";
9
- import { ToolbarSearch as z } from "./ToolbarSearch.js";
4
+ import { useRootContext as B } from "../RootProvider/RootProvider.js";
5
+ import { ToolbarAccountMenu as M } from "./ToolbarAccountMenu.js";
6
+ import { ToolbarAdd as V } from "./ToolbarAdd.js";
7
+ import { ToolbarBase as $ } from "./ToolbarBase.js";
8
+ import { ToolbarFilter as q } from "./ToolbarFilter.js";
9
+ import { ToolbarSearch as w } from "./ToolbarSearch.js";
10
10
  const g = (n, l) => l || `toolbar-filter-${n}`, Q = ({
11
11
  filters: n = [],
12
12
  filterState: l,
@@ -19,45 +19,45 @@ const g = (n, l) => l || `toolbar-filter-${n}`, Q = ({
19
19
  removeButtonAltText: S,
20
20
  addFilterButtonLabel: h
21
21
  }) => {
22
- const { openId: C, closeAll: I } = M(), [N, R] = F(
22
+ const { openId: C, closeAll: I } = B(), [N, R] = F(
23
23
  l ?? {}
24
- ), c = typeof s == "function" ? s : R, t = l || N, [d, f] = F(
24
+ ), p = typeof s == "function" ? s : R, t = l || N, [c, u] = F(
25
25
  (n == null ? void 0 : n.filter((o) => !(o.removable && typeof t[o.name] > "u")).map((o) => o.name)) ?? []
26
- ), u = n == null ? void 0 : n.filter((o) => !d.includes(o.name)), j = T(
27
- () => d.map((o) => n.find((e) => e.name === o)).filter((o) => typeof o < "u"),
28
- [n, d]
26
+ ), f = n == null ? void 0 : n.filter((o) => !c.includes(o.name)), j = T(
27
+ () => c.map((o) => n.find((e) => e.name === o)).filter((o) => typeof o < "u"),
28
+ [n, c]
29
29
  ), a = T(
30
- () => n.filter((o) => u.includes(o)),
31
- [n, u]
32
- ), L = (o, e, r) => {
33
- r === "radio" ? (I(), c({
30
+ () => n.filter((o) => f.includes(o)),
31
+ [n, f]
32
+ ), G = (o, e, r) => {
33
+ r === "radio" ? (I(), p({
34
34
  ...t,
35
35
  [o]: e
36
- })) : c({
36
+ })) : p({
37
37
  ...t,
38
- [o]: t[o] ? t[o].some((p) => e == null ? void 0 : e.includes(p)) ? t[o].filter((p) => !e.includes(p)) : [...t[o], ...e] : e
38
+ [o]: t[o] ? t[o].some((d) => e == null ? void 0 : e.includes(d)) ? t[o].filter((d) => !e.includes(d)) : [...t[o], ...e] : e
39
39
  });
40
- }, k = (o) => {
41
- f((e) => e.filter((r) => r !== o)), c({
40
+ }, L = (o) => {
41
+ u((e) => e.filter((r) => r !== o)), p({
42
42
  ...t,
43
43
  [o]: void 0
44
44
  });
45
- }, v = (o, e) => {
46
- f((r) => [...r, o]), C(e);
45
+ }, k = (o, e) => {
46
+ u((r) => [...r, o]), C(e);
47
47
  };
48
- return /* @__PURE__ */ B(q, { children: [
49
- b && /* @__PURE__ */ i(V, { ...b }),
50
- m && /* @__PURE__ */ i(z, { ...m }),
48
+ return /* @__PURE__ */ v($, { children: [
49
+ b && /* @__PURE__ */ i(M, { ...b }),
50
+ m && /* @__PURE__ */ i(w, { ...m }),
51
51
  j.map((o) => /* @__PURE__ */ i(
52
- w,
52
+ q,
53
53
  {
54
54
  id: g(o.name, o.id),
55
55
  showResultsLabel: A,
56
56
  onRemove: () => {
57
- k(o.name);
57
+ L(o.name);
58
58
  },
59
59
  onChange: (e) => {
60
- L(o.name, [e.target.value], o.optionType);
60
+ G(o.name, [e.target.value], o.optionType);
61
61
  },
62
62
  name: o.name,
63
63
  options: o.options,
@@ -66,12 +66,13 @@ const g = (n, l) => l || `toolbar-filter-${n}`, Q = ({
66
66
  optionType: o.optionType,
67
67
  removable: o.removable,
68
68
  getSelectedLabel: y,
69
- buttonAltText: S
69
+ buttonAltText: S,
70
+ optionGroups: o.optionGroups
70
71
  },
71
72
  o.name
72
73
  )),
73
74
  (a == null ? void 0 : a.length) > 0 && /* @__PURE__ */ i(
74
- $,
75
+ V,
75
76
  {
76
77
  id: "toolbar-filter-add",
77
78
  label: h,
@@ -82,7 +83,7 @@ const g = (n, l) => l || `toolbar-filter-${n}`, Q = ({
82
83
  title: o.label,
83
84
  name: o.name,
84
85
  onClick: () => {
85
- v(o.name, e);
86
+ k(o.name, e);
86
87
  }
87
88
  };
88
89
  })
@@ -3,5 +3,6 @@ export interface DialogListProps {
3
3
  items: DialogListItemProps[];
4
4
  groups?: Record<string, DialogListGroupProps>;
5
5
  sortGroupBy?: (a: [string, DialogListItemProps[]], b: [string, DialogListItemProps[]]) => number;
6
+ isLoading?: boolean;
6
7
  }
7
- export declare const DialogList: ({ items, groups, sortGroupBy }: DialogListProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const DialogList: ({ items, groups, sortGroupBy, isLoading }: DialogListProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,12 +1,13 @@
1
1
  import { StoryObj } from '@storybook/react';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ items, groups, sortGroupBy }: import('./DialogList').DialogListProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ items, groups, sortGroupBy, isLoading }: import('./DialogList').DialogListProps) => import("react/jsx-runtime").JSX.Element;
5
5
  tags: string[];
6
6
  args: {
7
7
  items: import('./DialogListItem').DialogListItemProps[];
8
8
  groups?: Record<string, import('./DialogListGroup').DialogListGroupProps>;
9
9
  sortGroupBy?: (a: [string, import('./DialogListItem').DialogListItemProps[]], b: [string, import('./DialogListItem').DialogListItemProps[]]) => number;
10
+ isLoading?: boolean;
10
11
  };
11
12
  };
12
13
  export default meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.24.5",
3
+ "version": "0.24.7",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",