@altinn/altinn-components 0.55.0 → 0.55.2
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/dist/assets/SearchField.css +1 -1
- package/dist/components/Forms/SearchField.js +28 -28
- package/dist/components/GlobalMenu/GlobalMenu.js +36 -40
- package/dist/components/GlobalMenu/LocaleSwitcher.js +35 -17
- package/dist/components/Menu/VirtualizedMenuItems.js +1 -1
- package/dist/types/lib/components/Footer/Footer.stories.d.ts +1 -10
- package/dist/types/lib/components/GlobalMenu/LocaleSwitcher.d.ts +3 -1
- package/package.json +1 -1
- package/dist/components/GlobalMenu/BackButton.js +0 -12
- package/dist/types/lib/components/GlobalMenu/BackButton.d.ts +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._container_nkg1g_1{position:relative;display:inline-flex;width:100%}._icon_nkg1g_7{position:absolute;top:0;bottom:0;left:0;width:2.5em;height:100%;color:var(--ds-color-text-subtle);display:flex;justify-content:center;align-items:center;pointer-events:none}._icon_nkg1g_7>*{pointer-events:none}._icon_nkg1g_7>svg{font-size:1.25em;width:1.25em;height:1.25em}._input_nkg1g_31{padding-left:2.25em;padding-right:2.25em}._input_nkg1g_31[type=search]::-webkit-search-decoration,._input_nkg1g_31[type=search]::-webkit-search-cancel-button{appearance:none}@media(max-width:1023px){._field_nkg1g_43[data-size=xs] input[type=search]{font-size:1rem;padding-left:2em;padding-right:2em}}._clear_nkg1g_50{position:absolute;top:0;right:0;bottom:0;width:2.5em;height:100%;display:flex;justify-content:center;align-items:center}._clearButton_nkg1g_62[data-size=xs]{--dsc-button-size: 2.5em;--dsc-button-padding: 0;font-size:.75em;border:none}._clearButton_nkg1g_62:focus-visible{outline-offset:0;outline-width:2px}._input_nkg1g_31[data-collapsible=true]{transition:width .5s ease-in-out}._input_nkg1g_31[data-collapsible=true]:placeholder-shown{background-color:transparent;width:8rem}._input_nkg1g_31[data-collapsible=true]:focus,._input_nkg1g_31[data-collapsible=true]:not(:placeholder-shown){width:auto;background-color:var(--ds-color-background-default)}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { Icon as
|
|
1
|
+
import { jsx as t, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import { c as _ } from "../../index-p1eeF8LQ.js";
|
|
3
|
+
import { Icon as f } from "../Icon/Icon.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import { Button as
|
|
5
|
+
import { Button as g } from "../Button/Button.js";
|
|
6
6
|
import "../RootProvider/RootProvider.js";
|
|
7
|
-
import { Input as
|
|
8
|
-
import { FieldBase as
|
|
7
|
+
import { Input as u } from "./Input.js";
|
|
8
|
+
import { FieldBase as d } from "./FieldBase.js";
|
|
9
9
|
import "../Snackbar/useSnackbar.js";
|
|
10
|
-
import { S as
|
|
11
|
-
import { S as
|
|
12
|
-
import '../../assets/SearchField.css';const
|
|
13
|
-
container:
|
|
14
|
-
icon:
|
|
10
|
+
import { S as k } from "../../MagnifyingGlass-bwVhw07z.js";
|
|
11
|
+
import { S as h } from "../../XMark-tKk6aExO.js";
|
|
12
|
+
import '../../assets/SearchField.css';const B = "_container_nkg1g_1", N = "_icon_nkg1g_7", x = "_input_nkg1g_31", S = "_field_nkg1g_43", v = "_clear_nkg1g_50", y = "_clearButton_nkg1g_62", n = {
|
|
13
|
+
container: B,
|
|
14
|
+
icon: N,
|
|
15
15
|
input: x,
|
|
16
16
|
field: S,
|
|
17
|
-
clear:
|
|
18
|
-
clearButton:
|
|
17
|
+
clear: v,
|
|
18
|
+
clearButton: y
|
|
19
19
|
}, w = ({
|
|
20
|
-
className:
|
|
21
|
-
collapsible:
|
|
22
|
-
size:
|
|
20
|
+
className: r,
|
|
21
|
+
collapsible: a,
|
|
22
|
+
size: i,
|
|
23
23
|
color: c = "neutral",
|
|
24
24
|
label: s,
|
|
25
25
|
value: o,
|
|
26
|
-
onClear:
|
|
26
|
+
onClear: e,
|
|
27
27
|
clearButtonAltText: l = "Clear search",
|
|
28
28
|
...m
|
|
29
|
-
}) => /* @__PURE__ */
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
|
|
29
|
+
}) => /* @__PURE__ */ t(d, { size: i, color: c, label: s, className: _(n.field, r), children: /* @__PURE__ */ p("div", { className: n.container, children: [
|
|
30
|
+
/* @__PURE__ */ t(
|
|
31
|
+
u,
|
|
32
32
|
{
|
|
33
33
|
...m,
|
|
34
34
|
type: "search",
|
|
35
35
|
value: o,
|
|
36
|
-
className:
|
|
37
|
-
"data-collapsible":
|
|
36
|
+
className: n.input,
|
|
37
|
+
"data-collapsible": a,
|
|
38
38
|
autoCapitalize: "off",
|
|
39
39
|
autoComplete: "off"
|
|
40
40
|
}
|
|
41
41
|
),
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
/* @__PURE__ */ t(f, { svgElement: k, className: n.icon }),
|
|
43
|
+
e && !!o && /* @__PURE__ */ t("span", { className: n.clear, children: /* @__PURE__ */ t(
|
|
44
|
+
g,
|
|
45
45
|
{
|
|
46
46
|
size: "xs",
|
|
47
47
|
rounded: !0,
|
|
48
48
|
icon: !0,
|
|
49
49
|
variant: "tinted",
|
|
50
|
-
className:
|
|
51
|
-
onClick:
|
|
50
|
+
className: n.clearButton,
|
|
51
|
+
onClick: e,
|
|
52
52
|
"aria-label": l,
|
|
53
|
-
children: /* @__PURE__ */
|
|
53
|
+
children: /* @__PURE__ */ t(h, {})
|
|
54
54
|
}
|
|
55
55
|
) })
|
|
56
56
|
] }) });
|
|
@@ -1,65 +1,61 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { useState as d, useCallback as
|
|
4
|
-
import { Menu as
|
|
2
|
+
import { jsxs as p, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { useState as d, useCallback as G, useEffect as L, useMemo as C } from "react";
|
|
4
|
+
import { Menu as S } from "../Menu/Menu.js";
|
|
5
5
|
import "../../index-p1eeF8LQ.js";
|
|
6
6
|
import "../Button/Button.js";
|
|
7
7
|
import "../RootProvider/RootProvider.js";
|
|
8
|
-
import { LocaleSwitcher as
|
|
8
|
+
import { LocaleSwitcher as h } from "./LocaleSwitcher.js";
|
|
9
9
|
import "../Snackbar/useSnackbar.js";
|
|
10
|
-
import { MenuListItem as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
backLabel: k = "Back",
|
|
10
|
+
import { MenuListItem as v } from "../Menu/MenuListItem.js";
|
|
11
|
+
import { GlobalMenuBase as u, GlobalMenuHeader as x, GlobalMenuFooter as T } from "./GlobalMenuBase.js";
|
|
12
|
+
import { LogoutButton as j } from "./LogoutButton.js";
|
|
13
|
+
import { S as y } from "../../Globe-BcPkcH4E.js";
|
|
14
|
+
const N = ({
|
|
15
|
+
menu: o,
|
|
16
|
+
backLabel: g = "Back",
|
|
18
17
|
onClose: l,
|
|
19
|
-
logoutButton:
|
|
20
|
-
ariaLabel:
|
|
18
|
+
logoutButton: a,
|
|
19
|
+
ariaLabel: n = "Menu",
|
|
21
20
|
localeSwitcher: r,
|
|
22
|
-
isOpen:
|
|
21
|
+
isOpen: m = !1
|
|
23
22
|
}) => {
|
|
24
|
-
const [
|
|
25
|
-
|
|
23
|
+
const [k, c] = d(!1), s = G(() => {
|
|
24
|
+
c((t) => !t);
|
|
26
25
|
}, []);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}, [
|
|
30
|
-
const
|
|
31
|
-
const t = (
|
|
26
|
+
L(() => {
|
|
27
|
+
m || c(!1);
|
|
28
|
+
}, [m]);
|
|
29
|
+
const M = C(() => {
|
|
30
|
+
const t = (o?.items ?? []).map((i) => ({
|
|
32
31
|
...i,
|
|
33
32
|
onClick: () => {
|
|
34
33
|
i.onClick?.(), l?.();
|
|
35
34
|
},
|
|
36
|
-
items: Array.isArray(i.items) ? i.items.map((
|
|
37
|
-
...
|
|
35
|
+
items: Array.isArray(i.items) ? i.items.map((f) => ({
|
|
36
|
+
...f,
|
|
38
37
|
onClick: () => {
|
|
39
|
-
|
|
38
|
+
f.onClick?.(), l?.();
|
|
40
39
|
}
|
|
41
40
|
})) : void 0
|
|
42
41
|
}));
|
|
43
42
|
if (!r) return t;
|
|
44
|
-
const
|
|
43
|
+
const b = {
|
|
45
44
|
title: "Språk/language",
|
|
46
|
-
icon:
|
|
45
|
+
icon: y,
|
|
47
46
|
size: "sm",
|
|
48
|
-
onClick:
|
|
47
|
+
onClick: s
|
|
49
48
|
};
|
|
50
|
-
return [...t,
|
|
51
|
-
}, [
|
|
52
|
-
return
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
] }) : /* @__PURE__ */ s(u, { "aria-label": m, children: [
|
|
59
|
-
e && /* @__PURE__ */ o(B, { ...e, items: b }),
|
|
60
|
-
n && /* @__PURE__ */ o(j, { children: /* @__PURE__ */ o(y, { ...n }) })
|
|
49
|
+
return [...t, b];
|
|
50
|
+
}, [o, l, r, s]);
|
|
51
|
+
return k ? /* @__PURE__ */ p(u, { "aria-label": n, children: [
|
|
52
|
+
/* @__PURE__ */ e(x, { children: r && /* @__PURE__ */ e(h, { ...r, backLabel: g, onToggle: s }) }),
|
|
53
|
+
/* @__PURE__ */ e(v, { as: "div", role: "separator" })
|
|
54
|
+
] }) : /* @__PURE__ */ p(u, { "aria-label": n, children: [
|
|
55
|
+
o && /* @__PURE__ */ e(S, { ...o, items: M }),
|
|
56
|
+
a && /* @__PURE__ */ e(T, { children: /* @__PURE__ */ e(j, { ...a }) })
|
|
61
57
|
] });
|
|
62
58
|
};
|
|
63
59
|
export {
|
|
64
|
-
|
|
60
|
+
N as GlobalMenu
|
|
65
61
|
};
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useEnterKey as
|
|
2
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as g, useMemo as l } from "react";
|
|
4
|
+
import { useEnterKey as v } from "../../hooks/useEnterKey.js";
|
|
5
5
|
import { MenuItems as h } from "../Menu/MenuItems.js";
|
|
6
6
|
import "../../index-p1eeF8LQ.js";
|
|
7
7
|
import "../Button/Button.js";
|
|
8
|
-
import { useRootContext as
|
|
8
|
+
import { useRootContext as b } from "../RootProvider/RootProvider.js";
|
|
9
9
|
import "../Snackbar/useSnackbar.js";
|
|
10
|
-
import { S
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import { S } from "../../Checkmark-Byz_C9x4.js";
|
|
11
|
+
import { S as x } from "../../ArrowUndo-hge1gMu8.js";
|
|
12
|
+
const q = ({
|
|
13
|
+
title: s = "Select language",
|
|
14
|
+
options: r,
|
|
15
|
+
onSelect: a,
|
|
16
|
+
onToggle: u,
|
|
17
|
+
backLabel: d
|
|
18
|
+
}) => {
|
|
19
|
+
const n = g(null), { currentId: m, closeAll: o } = b(), p = m === "locale", i = l(() => r.find((e) => e.checked)?.value ?? r[0]?.value, [r]), f = l(() => r.map((t) => {
|
|
20
|
+
const e = t.value === i;
|
|
14
21
|
return {
|
|
15
22
|
...t,
|
|
16
23
|
id: String(t.value),
|
|
@@ -19,22 +26,33 @@ const M = ({ title: s = "Select language", options: r, onSelect: a }) => {
|
|
|
19
26
|
role: "radio",
|
|
20
27
|
name: "locale",
|
|
21
28
|
checked: e,
|
|
22
|
-
icon: e ?
|
|
29
|
+
icon: e ? S : /* @__PURE__ */ c("span", { "aria-hidden": "true" }),
|
|
23
30
|
onClick: () => {
|
|
24
|
-
a?.(String(t.value)),
|
|
31
|
+
a?.(String(t.value)), o();
|
|
25
32
|
}
|
|
26
33
|
};
|
|
27
|
-
}), [r, a,
|
|
34
|
+
}), [r, a, o, i]), k = {
|
|
28
35
|
locales: { title: s || "Språk/language" }
|
|
29
36
|
};
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
37
|
+
return v((t) => {
|
|
38
|
+
if (p) {
|
|
32
39
|
t.preventDefault();
|
|
33
|
-
const e =
|
|
34
|
-
e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))),
|
|
40
|
+
const e = n.current?.querySelector('[data-active="true"]');
|
|
41
|
+
e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), o();
|
|
35
42
|
}
|
|
36
|
-
}), /* @__PURE__ */
|
|
43
|
+
}), /* @__PURE__ */ c("div", { ref: n, "data-testid": "locale-switcher", role: "radiogroup", children: /* @__PURE__ */ c(
|
|
44
|
+
h,
|
|
45
|
+
{
|
|
46
|
+
variant: "default",
|
|
47
|
+
groups: k,
|
|
48
|
+
items: [
|
|
49
|
+
{ onClick: u, label: d, as: "button", icon: x, id: "back" },
|
|
50
|
+
...f
|
|
51
|
+
],
|
|
52
|
+
keyboardEvents: !1
|
|
53
|
+
}
|
|
54
|
+
) });
|
|
37
55
|
};
|
|
38
56
|
export {
|
|
39
|
-
|
|
57
|
+
q as LocaleSwitcher
|
|
40
58
|
};
|
|
@@ -6,16 +6,7 @@ declare const meta: {
|
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
8
|
};
|
|
9
|
-
args:
|
|
10
|
-
address: string;
|
|
11
|
-
address2: string;
|
|
12
|
-
menu: {
|
|
13
|
-
items: {
|
|
14
|
-
id: string;
|
|
15
|
-
title: string;
|
|
16
|
-
}[];
|
|
17
|
-
};
|
|
18
|
-
};
|
|
9
|
+
args: import('./Footer').FooterProps;
|
|
19
10
|
};
|
|
20
11
|
export default meta;
|
|
21
12
|
type Story = StoryObj<typeof meta>;
|
|
@@ -3,5 +3,7 @@ export interface LocaleSwitcherProps {
|
|
|
3
3
|
title?: string;
|
|
4
4
|
options: MenuOptionProps[];
|
|
5
5
|
onSelect?: (value: string) => void;
|
|
6
|
+
backLabel?: string;
|
|
7
|
+
onToggle?: () => void;
|
|
6
8
|
}
|
|
7
|
-
export declare const LocaleSwitcher: ({ title, options, onSelect }: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const LocaleSwitcher: ({ title, options, onSelect, onToggle, backLabel, }: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
-
import "react";
|
|
3
|
-
import "../../index-p1eeF8LQ.js";
|
|
4
|
-
import "../Button/Button.js";
|
|
5
|
-
import "../RootProvider/RootProvider.js";
|
|
6
|
-
import "../Snackbar/useSnackbar.js";
|
|
7
|
-
import { MenuItem as i } from "../Menu/MenuItem.js";
|
|
8
|
-
import { S as p } from "../../ArrowUndo-hge1gMu8.js";
|
|
9
|
-
const k = ({ label: o, onClick: r, as: t }) => /* @__PURE__ */ m(i, { size: "sm", id: "back", icon: p, title: o, onClick: r, as: t });
|
|
10
|
-
export {
|
|
11
|
-
k as BackButton
|
|
12
|
-
};
|