@midas-ds/layout 0.0.24 → 0.0.25

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.25 (2026-03-26)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - **layout:** match API for NavigationLink and HeaderAction ([dffda24844](https://github.com/migrationsverket/midas/commit/dffda24844))
6
+
1
7
  ## 0.0.24 (2026-03-25)
2
8
 
3
9
  This was a version bump only for layout to align it with other projects, there were no code changes.
@@ -0,0 +1,166 @@
1
+ 'use client';
2
+ import { jsx as t, jsxs as _ } from "react/jsx-runtime";
3
+ import { Collection as k, OverlayTriggerStateContext as M, Focusable as j, Link as H } from "react-aria-components";
4
+ import { useContext as s } from "react";
5
+ import { Text as I, clsx as S, TooltipTrigger as T, Tooltip as D } from "@midas-ds/components";
6
+ import { S as r } from "./SidebarContext-CoDRKR2m.js";
7
+ import { M as O } from "./MobileMenuContext-Coj0sJ0N.js";
8
+ import { c as m } from "./clsx-OuTLNxxd.js";
9
+ import { Collection as h } from "@react-aria/collections";
10
+ import '../assets/NavigationSubMenu.css';const q = "_rootList_l3v98_1", w = {
11
+ rootList: q
12
+ }, io = ({
13
+ className: n,
14
+ items: o,
15
+ children: e,
16
+ dependencies: i,
17
+ idScope: c,
18
+ addIdAndValue: a,
19
+ ...l
20
+ }) => /* @__PURE__ */ t(
21
+ "nav",
22
+ {
23
+ className: n,
24
+ ...l,
25
+ children: /* @__PURE__ */ t("ul", { className: w.rootList, children: /* @__PURE__ */ t(
26
+ k,
27
+ {
28
+ items: o,
29
+ children: e,
30
+ dependencies: i,
31
+ idScope: c,
32
+ addIdAndValue: a
33
+ }
34
+ ) })
35
+ }
36
+ ), E = "_navigationHeader_j94pq_1", P = "_collapsed_j94pq_6", f = {
37
+ navigationHeader: E,
38
+ collapsed: P
39
+ }, A = ({ className: n, ...o }) => {
40
+ const e = s(r);
41
+ return /* @__PURE__ */ t(
42
+ I,
43
+ {
44
+ className: S(n, f.navigationHeader, {
45
+ [f.collapsed]: e?.isCollapsed
46
+ }),
47
+ ...o
48
+ }
49
+ );
50
+ }, F = "_navigationItem_1jt2l_1", x = {
51
+ navigationItem: F
52
+ }, V = ({ className: n, ...o }) => {
53
+ const e = s(r);
54
+ return /* @__PURE__ */ t(
55
+ "li",
56
+ {
57
+ className: m(n, x.navigationItem, {
58
+ [x.collapsed]: e?.isCollapsed
59
+ }),
60
+ ...o
61
+ }
62
+ );
63
+ }, z = "_navigationLink_14vyt_1", B = "_sidebar_14vyt_21", G = "_collapsed_14vyt_37", J = "_title_14vyt_40", p = {
64
+ navigationLink: z,
65
+ sidebar: B,
66
+ collapsed: G,
67
+ title: J
68
+ }, ao = ({
69
+ as: n,
70
+ children: o,
71
+ className: e,
72
+ isActive: i,
73
+ icon: c,
74
+ "aria-label": a,
75
+ ...l
76
+ }) => {
77
+ const L = s(O), u = s(r), v = u?.isCollapsed, C = s(M), $ = n || H, b = () => {
78
+ C?.isOpen && C?.setOpen(!1);
79
+ }, d = typeof o == "string" ? o : void 0;
80
+ return !d && !a && process.env.NODE_ENV !== "production" && console.warn(
81
+ "An 'aria-label' is required for <NavigationLink> elements with non plain text children"
82
+ ), /* @__PURE__ */ _(T, { isDisabled: !v || !d && !a, children: [
83
+ /* @__PURE__ */ t(j, { children: /* @__PURE__ */ _(
84
+ $,
85
+ {
86
+ "aria-current": i && "page",
87
+ "aria-label": a || (v ? d : void 0),
88
+ className: S(e, p.navigationLink, {
89
+ [p.sidebar]: u || L,
90
+ [p.collapsed]: v
91
+ }),
92
+ "data-active": i || void 0,
93
+ ...n ? {
94
+ onClick: (g) => {
95
+ b(), l.onClick?.(g);
96
+ }
97
+ } : {
98
+ onPress: (g) => {
99
+ b(), l.onPress?.(g);
100
+ }
101
+ },
102
+ ...l,
103
+ children: [
104
+ c,
105
+ /* @__PURE__ */ t("span", { className: p.title, children: o })
106
+ ]
107
+ }
108
+ ) }),
109
+ /* @__PURE__ */ t(D, { placement: "right", children: d })
110
+ ] });
111
+ }, K = "_navigationSection_1ae77_1", Q = "_collapsed_1ae77_5", y = {
112
+ navigationSection: K,
113
+ collapsed: Q
114
+ }, so = ({
115
+ className: n,
116
+ title: o,
117
+ ...e
118
+ }) => {
119
+ const i = s(r);
120
+ return /* @__PURE__ */ t(V, { children: /* @__PURE__ */ _(
121
+ "ul",
122
+ {
123
+ className: m(n, y.navigationSection, {
124
+ [y.collapsed]: i?.isCollapsed
125
+ }),
126
+ children: [
127
+ o && /* @__PURE__ */ t(A, { children: o }),
128
+ /* @__PURE__ */ t(h, { ...e })
129
+ ]
130
+ }
131
+ ) });
132
+ }, R = "_navigationSubMenu_vfyl6_1", U = "_collapsed_vfyl6_5", N = {
133
+ navigationSubMenu: R,
134
+ collapsed: U
135
+ }, lo = ({
136
+ className: n,
137
+ children: o,
138
+ items: e,
139
+ ...i
140
+ }) => {
141
+ const c = s(r), { length: a } = Array.from(e || []);
142
+ return typeof o == "function" && a === 0 ? null : /* @__PURE__ */ t(
143
+ "ul",
144
+ {
145
+ className: m(n, N.navigationSubMenu, {
146
+ [N.collapsed]: c?.isCollapsed
147
+ }),
148
+ children: /* @__PURE__ */ t(
149
+ h,
150
+ {
151
+ items: e,
152
+ ...i,
153
+ children: o
154
+ }
155
+ )
156
+ }
157
+ );
158
+ };
159
+ export {
160
+ io as N,
161
+ A as a,
162
+ V as b,
163
+ ao as c,
164
+ so as d,
165
+ lo as e
166
+ };
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { H as o, a as t, b as r, M as n } from "./chunks/Header-B1Nk3vII.js";
2
2
  import { L as i, a as x } from "./chunks/LayoutContent-CvlzZxeo.js";
3
3
  import { M as m } from "./chunks/Main-Dt0CIYBE.js";
4
- import { N as b, a as d, b as f, c as p, d as M, e as N } from "./chunks/NavigationSubMenu-G-WkaNZA.js";
4
+ import { N as b, a as d, b as f, c as p, d as M, e as N } from "./chunks/NavigationSubMenu-D3hvuVFG.js";
5
5
  import { P as v, a as g, b as H, c as S, u as c } from "./chunks/PanelRegion-zsKP1Rye.js";
6
6
  import { S as L } from "./chunks/Sidebar-BFIjN5q6.js";
7
7
  import { S as A } from "./chunks/SidebarContext-CoDRKR2m.js";
@@ -1,4 +1,4 @@
1
- import { N as n, a as o, b as t, c as e, d as N, e as g } from "../chunks/NavigationSubMenu-G-WkaNZA.js";
1
+ import { N as n, a as o, b as t, c as e, d as N, e as g } from "../chunks/NavigationSubMenu-D3hvuVFG.js";
2
2
  export {
3
3
  n as Navigation,
4
4
  o as NavigationHeader,
@@ -1,10 +1,10 @@
1
1
  import { ReactNode, ElementType, ComponentProps } from 'react';
2
2
  import { Link } from 'react-aria-components';
3
3
  export interface NavigationLinkComponentProps<C extends ElementType> {
4
- /** The icon to display. */
5
- children: ReactNode;
6
4
  /** The visible label text and tooltip content. */
7
- title: string;
5
+ children?: ReactNode;
6
+ /** The icon to display. */
7
+ icon: ReactNode;
8
8
  isActive?: boolean;
9
9
  variant?: 'sidebar' | 'navbar';
10
10
  className?: string;
@@ -14,4 +14,4 @@ export interface NavigationLinkComponentProps<C extends ElementType> {
14
14
  as?: C;
15
15
  }
16
16
  export type NavigationLinkProps<C extends ElementType> = NavigationLinkComponentProps<C> & Omit<ComponentProps<C>, keyof NavigationLinkComponentProps<C>>;
17
- export declare const NavigationLink: <C extends ElementType = typeof Link>({ as, children, className, isActive, title, "aria-label": ariaLabel, ...rest }: NavigationLinkProps<C>) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const NavigationLink: <C extends ElementType = typeof Link>({ as, children, className, isActive, icon, "aria-label": ariaLabel, ...rest }: NavigationLinkProps<C>) => import("react/jsx-runtime").JSX.Element;
@@ -2,13 +2,13 @@ import { StoryObj } from '@storybook/react-vite';
2
2
  import { NavigationLink } from '.';
3
3
  type Story = StoryObj<typeof NavigationLink>;
4
4
  declare const _default: {
5
- component: <C extends import('react').ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ as, children, className, isActive, title, "aria-label": ariaLabel, ...rest }: import('./NavigationLink').NavigationLinkProps<C>) => import("react/jsx-runtime").JSX.Element;
5
+ component: <C extends import('react').ElementType = (props: import('react-aria-components').LinkProps & React.RefAttributes<HTMLAnchorElement>) => React.ReactElement | null>({ as, children, className, isActive, icon, "aria-label": ariaLabel, ...rest }: import('./NavigationLink').NavigationLinkProps<C>) => import("react/jsx-runtime").JSX.Element;
6
6
  title: string;
7
7
  tags: string[];
8
8
  args: {
9
- title: string;
9
+ children: string;
10
10
  href: string;
11
- children: import("react/jsx-runtime").JSX.Element;
11
+ icon: import("react/jsx-runtime").JSX.Element;
12
12
  };
13
13
  parameters: {
14
14
  layout: string;
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "description": "Midas Layout components",
15
15
  "homepage": "https://designsystem.migrationsverket.se/",
16
16
  "license": "CC0-1.0",
17
- "version": "0.0.24",
17
+ "version": "0.0.25",
18
18
  "module": "./index.js",
19
19
  "type": "module",
20
20
  "main": "./index.js",
@@ -1,164 +0,0 @@
1
- 'use client';
2
- import { jsx as n, jsxs as g } from "react/jsx-runtime";
3
- import { Collection as $, OverlayTriggerStateContext as M, Focusable as k, Link as j } from "react-aria-components";
4
- import { useContext as s } from "react";
5
- import { Text as H, clsx as N, TooltipTrigger as I, Tooltip as T } from "@midas-ds/components";
6
- import { S as r } from "./SidebarContext-CoDRKR2m.js";
7
- import { M as D } from "./MobileMenuContext-Coj0sJ0N.js";
8
- import { c as _ } from "./clsx-OuTLNxxd.js";
9
- import { Collection as h } from "@react-aria/collections";
10
- import '../assets/NavigationSubMenu.css';const O = "_rootList_l3v98_1", q = {
11
- rootList: O
12
- }, ao = ({
13
- className: t,
14
- items: o,
15
- children: a,
16
- dependencies: e,
17
- idScope: i,
18
- addIdAndValue: c,
19
- ...l
20
- }) => /* @__PURE__ */ n(
21
- "nav",
22
- {
23
- className: t,
24
- ...l,
25
- children: /* @__PURE__ */ n("ul", { className: q.rootList, children: /* @__PURE__ */ n(
26
- $,
27
- {
28
- items: o,
29
- children: a,
30
- dependencies: e,
31
- idScope: i,
32
- addIdAndValue: c
33
- }
34
- ) })
35
- }
36
- ), P = "_navigationHeader_j94pq_1", F = "_collapsed_j94pq_6", b = {
37
- navigationHeader: P,
38
- collapsed: F
39
- }, w = ({ className: t, ...o }) => {
40
- const a = s(r);
41
- return /* @__PURE__ */ n(
42
- H,
43
- {
44
- className: N(t, b.navigationHeader, {
45
- [b.collapsed]: a?.isCollapsed
46
- }),
47
- ...o
48
- }
49
- );
50
- }, z = "_navigationItem_1jt2l_1", x = {
51
- navigationItem: z
52
- }, A = ({ className: t, ...o }) => {
53
- const a = s(r);
54
- return /* @__PURE__ */ n(
55
- "li",
56
- {
57
- className: _(t, x.navigationItem, {
58
- [x.collapsed]: a?.isCollapsed
59
- }),
60
- ...o
61
- }
62
- );
63
- }, B = "_navigationLink_14vyt_1", E = "_sidebar_14vyt_21", G = "_collapsed_14vyt_37", J = "_title_14vyt_40", d = {
64
- navigationLink: B,
65
- sidebar: E,
66
- collapsed: G,
67
- title: J
68
- }, eo = ({
69
- as: t,
70
- children: o,
71
- className: a,
72
- isActive: e,
73
- title: i,
74
- "aria-label": c,
75
- ...l
76
- }) => {
77
- const S = s(D), m = s(r), p = m?.isCollapsed, u = s(M), L = t || j, C = () => {
78
- u?.isOpen && u?.setOpen(!1);
79
- };
80
- return /* @__PURE__ */ g(I, { isDisabled: !p, children: [
81
- /* @__PURE__ */ n(k, { children: /* @__PURE__ */ g(
82
- L,
83
- {
84
- "aria-current": e && "page",
85
- "aria-label": c || (p ? i : void 0),
86
- className: N(a, d.navigationLink, {
87
- [d.sidebar]: m || S,
88
- [d.collapsed]: p
89
- }),
90
- "data-active": e || void 0,
91
- ...t ? {
92
- onClick: (v) => {
93
- C(), l.onClick?.(v);
94
- }
95
- } : {
96
- onPress: (v) => {
97
- C(), l.onPress?.(v);
98
- }
99
- },
100
- ...l,
101
- children: [
102
- o,
103
- /* @__PURE__ */ n("span", { className: d.title, children: i })
104
- ]
105
- }
106
- ) }),
107
- /* @__PURE__ */ n(T, { placement: "right", children: i })
108
- ] });
109
- }, K = "_navigationSection_1ae77_1", Q = "_collapsed_1ae77_5", y = {
110
- navigationSection: K,
111
- collapsed: Q
112
- }, io = ({
113
- className: t,
114
- title: o,
115
- ...a
116
- }) => {
117
- const e = s(r);
118
- return /* @__PURE__ */ n(A, { children: /* @__PURE__ */ g(
119
- "ul",
120
- {
121
- className: _(t, y.navigationSection, {
122
- [y.collapsed]: e?.isCollapsed
123
- }),
124
- children: [
125
- o && /* @__PURE__ */ n(w, { children: o }),
126
- /* @__PURE__ */ n(h, { ...a })
127
- ]
128
- }
129
- ) });
130
- }, R = "_navigationSubMenu_vfyl6_1", U = "_collapsed_vfyl6_5", f = {
131
- navigationSubMenu: R,
132
- collapsed: U
133
- }, so = ({
134
- className: t,
135
- children: o,
136
- items: a,
137
- ...e
138
- }) => {
139
- const i = s(r), { length: c } = Array.from(a || []);
140
- return typeof o == "function" && c === 0 ? null : /* @__PURE__ */ n(
141
- "ul",
142
- {
143
- className: _(t, f.navigationSubMenu, {
144
- [f.collapsed]: i?.isCollapsed
145
- }),
146
- children: /* @__PURE__ */ n(
147
- h,
148
- {
149
- items: a,
150
- ...e,
151
- children: o
152
- }
153
- )
154
- }
155
- );
156
- };
157
- export {
158
- ao as N,
159
- w as a,
160
- A as b,
161
- eo as c,
162
- io as d,
163
- so as e
164
- };