@altinn/altinn-components 0.64.2 → 0.65.0
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/SnackbarItem.css +1 -1
- package/dist/components/Snackbar/Snackbar.js +23 -16
- package/dist/components/Snackbar/SnackbarItem.js +38 -34
- package/dist/components/Snackbar/useSnackbar.js +32 -26
- package/dist/types/lib/components/Forms/EmailValidation.stories.d.ts +14 -0
- package/dist/types/lib/components/Snackbar/SnackbarItem.d.ts +2 -1
- package/dist/types/lib/components/Snackbar/useSnackbar.d.ts +1 -0
- package/dist/types/lib/stories/Color.stories.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._item_18ro3_1{border:none;color:inherit;font:inherit;text-align:inherit;line-height:normal;-webkit-font-smoothing:inherit;-moz-osx-font-smoothing:inherit;-webkit-user-select:none;user-select:none;border-radius:.5rem;box-shadow:var(--ds-shadow-xs);transition:opacity .2s ease}._item_18ro3_1{position:relative;display:flex;align-items:center;text-decoration:none;color:inherit;padding:.625rem}._itemWrapper_18ro3_24{background:#fff;border-radius:.5rem}._icon_18ro3_29{flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:1.5rem;width:2.75rem;height:2.75rem}._content_18ro3_39{flex-grow:1;display:flex;align-items:center;margin-left:.625rem;margin-right:1.25rem}._action_18ro3_47{flex-shrink:0;display:flex;align-items:center;justify-content:center}._item_18ro3_1{background-color:var(--ds-color-base-default);color:var(--ds-color-base-contrast-default)}
|
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { SnackbarBase as
|
|
4
|
-
import { SnackbarItem as
|
|
5
|
-
import { useSnackbar as
|
|
6
|
-
const
|
|
7
|
-
const { storedMessages: o, open:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { SnackbarBase as l } from "./SnackbarBase.js";
|
|
4
|
+
import { SnackbarItem as d } from "./SnackbarItem.js";
|
|
5
|
+
import { useSnackbar as b } from "./useSnackbar.js";
|
|
6
|
+
const u = 0.3, S = 0.4, y = ({ className: e }) => {
|
|
7
|
+
const { storedMessages: o, open: r, closeSnackbarItem: a } = b();
|
|
8
|
+
if (!r)
|
|
9
|
+
return null;
|
|
10
|
+
const t = o || [], c = t.length - 1;
|
|
11
|
+
return /* @__PURE__ */ n(l, { className: e, children: t.map((s, i) => {
|
|
12
|
+
const m = c - i, p = Math.max(S, 1 - m * u);
|
|
13
|
+
return /* @__PURE__ */ n(
|
|
14
|
+
d,
|
|
15
|
+
{
|
|
16
|
+
onDismiss: () => a(s.id),
|
|
17
|
+
dismissable: s.dismissable,
|
|
18
|
+
style: { opacity: p },
|
|
19
|
+
...s
|
|
20
|
+
},
|
|
21
|
+
s.id
|
|
22
|
+
);
|
|
23
|
+
}) });
|
|
17
24
|
};
|
|
18
25
|
export {
|
|
19
|
-
|
|
26
|
+
y as Snackbar
|
|
20
27
|
};
|
|
@@ -1,55 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { c as
|
|
4
|
-
import { I as
|
|
5
|
-
import a, { forwardRef as
|
|
2
|
+
import { jsx as i, jsxs as f } from "react/jsx-runtime";
|
|
3
|
+
import { c as u } from "../../index-p1eeF8LQ.js";
|
|
4
|
+
import { I as v, s as _ } from "../../ToolbarSearch-DeQTx93w.js";
|
|
5
|
+
import a, { forwardRef as g } from "react";
|
|
6
6
|
import "../../tooltip-Ct39-719.js";
|
|
7
7
|
import "../Typography/Link.js";
|
|
8
|
-
import { Button as
|
|
8
|
+
import { Button as h } from "../Button/Button.js";
|
|
9
9
|
import "react-dom";
|
|
10
10
|
import "../GlobalMenu/GlobalMenuBase.js";
|
|
11
11
|
import "./useSnackbar.js";
|
|
12
|
-
import { u as
|
|
13
|
-
import '../../assets/SnackbarItem.css';var
|
|
14
|
-
var
|
|
15
|
-
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) &&
|
|
12
|
+
import { u as y } from "../../useId-BVFxCjkq.js";
|
|
13
|
+
import '../../assets/SnackbarItem.css';var w = function(e, o) {
|
|
14
|
+
var n = {};
|
|
15
|
+
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && o.indexOf(t) < 0 && (n[t] = e[t]);
|
|
16
16
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
17
|
-
for (var
|
|
18
|
-
|
|
19
|
-
return
|
|
17
|
+
for (var r = 0, t = Object.getOwnPropertySymbols(e); r < t.length; r++)
|
|
18
|
+
o.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[r]) && (n[t[r]] = e[t[r]]);
|
|
19
|
+
return n;
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
var { title:
|
|
23
|
-
let
|
|
24
|
-
return
|
|
21
|
+
const O = g((e, o) => {
|
|
22
|
+
var { title: n, titleId: t } = e, r = w(e, ["title", "titleId"]);
|
|
23
|
+
let l = y();
|
|
24
|
+
return l = n ? t || "title-" + l : void 0, a.createElement(
|
|
25
25
|
"svg",
|
|
26
|
-
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:
|
|
27
|
-
|
|
26
|
+
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": l }, r),
|
|
27
|
+
n ? a.createElement("title", { id: l }, n) : null,
|
|
28
28
|
a.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M12.75 2.5a.75.75 0 0 0-1.5 0v1.273c-2.222.14-3.655.92-4.499 2.186-.887 1.33-1.001 3.04-1.001 4.541v3c0 .809-.424 1.92-.92 2.915a18 18 0 0 1-.936 1.641l-.014.022-.004.006A.75.75 0 0 0 4.5 19.25h4.338a3.25 3.25 0 0 0 6.324 0H19.5a.75.75 0 0 0 .624-1.166l-.004-.006-.014-.022-.06-.091c-.05-.081-.125-.2-.215-.35-.18-.301-.42-.722-.66-1.2-.497-.994-.921-2.106-.921-2.915v-3c0-1.501-.114-3.21-1.001-4.541-.844-1.266-2.277-2.046-4.499-2.186zm-1.987 17.237a1.8 1.8 0 0 1-.344-.487h3.162a1.75 1.75 0 0 1-1.581 1 1.75 1.75 0 0 1-1.237-.513", clipRule: "evenodd" })
|
|
29
29
|
);
|
|
30
|
-
}),
|
|
31
|
-
item:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
}), b = "_item_18ro3_1", x = "_itemWrapper_18ro3_24", I = "_icon_18ro3_29", j = "_content_18ro3_39", N = "_action_18ro3_47", c = {
|
|
31
|
+
item: b,
|
|
32
|
+
itemWrapper: x,
|
|
33
|
+
icon: I,
|
|
34
|
+
content: j,
|
|
35
|
+
action: N
|
|
35
36
|
};
|
|
36
|
-
var
|
|
37
|
+
var B = /* @__PURE__ */ ((e) => (e.company = "company", e.success = "success", e.warning = "warning", e.danger = "danger", e.info = "info", e))(B || {});
|
|
37
38
|
const X = ({
|
|
38
39
|
as: e,
|
|
39
|
-
message:
|
|
40
|
-
className:
|
|
40
|
+
message: o,
|
|
41
|
+
className: n,
|
|
41
42
|
color: t,
|
|
42
|
-
icon:
|
|
43
|
-
iconAltText:
|
|
43
|
+
icon: r = O,
|
|
44
|
+
iconAltText: l = "Bell icon",
|
|
44
45
|
dismissable: s = !0,
|
|
45
46
|
onDismiss: m,
|
|
46
47
|
...d
|
|
47
|
-
}) =>
|
|
48
|
-
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
}) => {
|
|
49
|
+
const p = e || "div";
|
|
50
|
+
return /* @__PURE__ */ i("span", { className: c.itemWrapper, children: /* @__PURE__ */ f(p, { className: u(c.item, n), "data-color": t, role: "alert", ...d, children: [
|
|
51
|
+
/* @__PURE__ */ i(v, { svgElement: r, className: c.icon, "aria-hidden": "true" }),
|
|
52
|
+
/* @__PURE__ */ i("div", { className: c.content, children: o }),
|
|
53
|
+
s && /* @__PURE__ */ i("div", { className: c.action, children: /* @__PURE__ */ i(h, { variant: "solid", onClick: m, "aria-label": "close", children: /* @__PURE__ */ i(_, { style: { fontSize: "1.5em" } }) }) })
|
|
54
|
+
] }) });
|
|
55
|
+
};
|
|
52
56
|
export {
|
|
53
|
-
|
|
57
|
+
B as SnackbarColorEnum,
|
|
54
58
|
X as SnackbarItem
|
|
55
59
|
};
|
|
@@ -1,47 +1,53 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as v } from "react/jsx-runtime";
|
|
3
|
-
import { createContext as
|
|
4
|
-
var
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { createContext as x, useState as d, useRef as M, useCallback as b, useEffect as w, useContext as C } from "react";
|
|
4
|
+
var S = /* @__PURE__ */ ((e) => (e[e.infinite = 0] = "infinite", e[e.short = 1e3] = "short", e[e.normal = 3e3] = "normal", e[e.long = 5e3] = "long", e))(S || {});
|
|
5
|
+
const g = x(void 0), f = 3e3, T = 3, E = ({
|
|
6
|
+
children: e,
|
|
7
|
+
maxSnacks: l = T
|
|
8
|
+
}) => {
|
|
9
|
+
const [m, c] = d(!1), [i, u] = d([]), o = M(null), h = () => {
|
|
10
|
+
u([]), c(!1), o.current && clearTimeout(o.current);
|
|
11
|
+
}, p = (t) => {
|
|
9
12
|
const s = btoa(String(Math.random())).substring(0, 12);
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
return u((n) => {
|
|
14
|
+
const r = [...n, { ...t, id: s }];
|
|
15
|
+
return r.length > l ? r.slice(r.length - l) : r;
|
|
16
|
+
}), c(!0), s;
|
|
17
|
+
}, a = b((t) => {
|
|
18
|
+
u((s) => {
|
|
19
|
+
const n = s.filter((r) => r.id !== t);
|
|
20
|
+
return c(n.length > 0), n;
|
|
15
21
|
});
|
|
16
22
|
}, []);
|
|
17
23
|
return w(() => {
|
|
18
|
-
const t = i.find((n) => (n.duration ??
|
|
19
|
-
return t && (
|
|
20
|
-
|
|
24
|
+
const t = i.find((n) => (n.duration ?? f) > 0), s = t?.duration || f;
|
|
25
|
+
return t && (o.current = window.setTimeout(() => {
|
|
26
|
+
a(t.id);
|
|
21
27
|
}, s)), () => {
|
|
22
|
-
|
|
28
|
+
o.current && clearTimeout(o.current);
|
|
23
29
|
};
|
|
24
|
-
}, [i,
|
|
25
|
-
|
|
30
|
+
}, [i, a]), /* @__PURE__ */ v(
|
|
31
|
+
g.Provider,
|
|
26
32
|
{
|
|
27
33
|
value: {
|
|
28
|
-
open:
|
|
34
|
+
open: m,
|
|
29
35
|
storedMessages: i,
|
|
30
|
-
openSnackbar:
|
|
31
|
-
closeSnackbarItem:
|
|
32
|
-
dismissSnackbar:
|
|
36
|
+
openSnackbar: p,
|
|
37
|
+
closeSnackbarItem: a,
|
|
38
|
+
dismissSnackbar: h
|
|
33
39
|
},
|
|
34
40
|
children: e
|
|
35
41
|
}
|
|
36
42
|
);
|
|
37
|
-
},
|
|
38
|
-
const e =
|
|
43
|
+
}, I = () => {
|
|
44
|
+
const e = C(g);
|
|
39
45
|
if (!e)
|
|
40
46
|
throw new Error("useSnackbar must be used within a SnackbarProvider");
|
|
41
47
|
return e;
|
|
42
48
|
};
|
|
43
49
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
S as SnackbarDuration,
|
|
51
|
+
E as SnackbarProvider,
|
|
52
|
+
I as useSnackbar
|
|
47
53
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
interface EmailDetailsProps {
|
|
3
|
+
/** Saved email for the account, if any. */
|
|
4
|
+
email?: string;
|
|
5
|
+
}
|
|
6
|
+
declare const meta: {
|
|
7
|
+
title: string;
|
|
8
|
+
component: ({ email }: EmailDetailsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
parameters: {};
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
/** Empty field — shows the neutral info hint, prompts to verify once valid. */
|
|
14
|
+
export declare const Empty: Story;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementType, ReactNode } from 'react';
|
|
1
|
+
import { CSSProperties, ElementType, ReactNode } from 'react';
|
|
2
2
|
import { SvgElement } from '..';
|
|
3
3
|
export declare enum SnackbarColorEnum {
|
|
4
4
|
company = "company",
|
|
@@ -16,6 +16,7 @@ export interface SnackbarItemProps {
|
|
|
16
16
|
iconAltText?: string;
|
|
17
17
|
href?: string;
|
|
18
18
|
className?: string;
|
|
19
|
+
style?: CSSProperties;
|
|
19
20
|
dismissable?: boolean;
|
|
20
21
|
onDismiss?: () => void;
|
|
21
22
|
children?: ReactNode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altinn/altinn-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@vitest/browser-playwright": "4.0.16",
|
|
49
49
|
"@vitest/coverage-v8": "^4.1.3",
|
|
50
50
|
"axe-core": "^4.10.3",
|
|
51
|
-
"axe-playwright": "^2.
|
|
51
|
+
"axe-playwright": "^2.2.2",
|
|
52
52
|
"glob": "^13.0.6",
|
|
53
53
|
"lint-staged": "^15.5.2",
|
|
54
54
|
"pixelmatch": "^7.1.0",
|