@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.
@@ -1 +1 @@
1
- ._item_1a13i_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)}._item_1a13i_1{position:relative;display:flex;align-items:center;text-decoration:none;color:inherit;padding:.625rem}._icon_1a13i_23{flex-shrink:0;display:flex;align-items:center;justify-content:center;font-size:1.5rem;width:2.75rem;height:2.75rem}._content_1a13i_33{flex-grow:1;display:flex;align-items:center;margin-left:.625rem;margin-right:1.25rem}._action_1a13i_41{flex-shrink:0;display:flex;align-items:center;justify-content:center}._item_1a13i_1{background-color:var(--ds-color-base-default);color:var(--ds-color-base-contrast-default)}
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 s } from "react/jsx-runtime";
3
- import { SnackbarBase as i } from "./SnackbarBase.js";
4
- import { SnackbarItem as m } from "./SnackbarItem.js";
5
- import { useSnackbar as c } from "./useSnackbar.js";
6
- const d = ({ className: a }) => {
7
- const { storedMessages: o, open: e, closeSnackbarItem: n } = c();
8
- return e ? /* @__PURE__ */ s(i, { className: a, children: (o || []).map((r) => /* @__PURE__ */ s(
9
- m,
10
- {
11
- onDismiss: () => n(r.id),
12
- dismissable: r.dismissable,
13
- ...r
14
- },
15
- r.id
16
- )) }) : null;
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
- d as Snackbar
26
+ y as Snackbar
20
27
  };
@@ -1,55 +1,59 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as l } from "react/jsx-runtime";
3
- import { c as p } from "../../index-p1eeF8LQ.js";
4
- import { I as u, s as v } from "../../ToolbarSearch-DeQTx93w.js";
5
- import a, { forwardRef as _ } from "react";
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 g } from "../Button/Button.js";
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 h } from "../../useId-BVFxCjkq.js";
13
- import '../../assets/SnackbarItem.css';var y = function(e, i) {
14
- var o = {};
15
- for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && i.indexOf(t) < 0 && (o[t] = 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 n = 0, t = Object.getOwnPropertySymbols(e); n < t.length; n++)
18
- i.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (o[t[n]] = e[t[n]]);
19
- return o;
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 w = _((e, i) => {
22
- var { title: o, titleId: t } = e, n = y(e, ["title", "titleId"]);
23
- let r = h();
24
- return r = o ? t || "title-" + r : void 0, a.createElement(
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: i, "aria-labelledby": r }, n),
27
- o ? a.createElement("title", { id: r }, o) : null,
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
- }), O = "_item_1a13i_1", b = "_icon_1a13i_23", x = "_content_1a13i_33", I = "_action_1a13i_41", c = {
31
- item: O,
32
- icon: b,
33
- content: x,
34
- action: I
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 j = /* @__PURE__ */ ((e) => (e.company = "company", e.success = "success", e.warning = "warning", e.danger = "danger", e.info = "info", e))(j || {});
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: i,
40
- className: o,
40
+ message: o,
41
+ className: n,
41
42
  color: t,
42
- icon: n = w,
43
- iconAltText: r = "Bell icon",
43
+ icon: r = O,
44
+ iconAltText: l = "Bell icon",
44
45
  dismissable: s = !0,
45
46
  onDismiss: m,
46
47
  ...d
47
- }) => /* @__PURE__ */ f(e || "div", { className: p(c.item, o), "data-color": t, role: "alert", ...d, children: [
48
- /* @__PURE__ */ l(u, { svgElement: n, className: c.icon, "aria-hidden": "true" }),
49
- /* @__PURE__ */ l("div", { className: c.content, children: i }),
50
- s && /* @__PURE__ */ l("div", { className: c.action, children: /* @__PURE__ */ l(g, { variant: "solid", onClick: m, "aria-label": "close", children: /* @__PURE__ */ l(v, { style: { fontSize: "1.5em" } }) }) })
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
- j as SnackbarColorEnum,
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 h, useState as a, useRef as x, useCallback as b, useEffect as w, useContext as M } from "react";
4
- var C = /* @__PURE__ */ ((e) => (e[e.infinite = 0] = "infinite", e[e.short = 1e3] = "short", e[e.normal = 3e3] = "normal", e[e.long = 5e3] = "long", e))(C || {});
5
- const l = h(void 0), d = 3e3, P = ({ children: e }) => {
6
- const [f, o] = a(!1), [i, c] = a([]), r = x(null), m = () => {
7
- c([]), o(!1), r.current && clearTimeout(r.current);
8
- }, g = (t) => {
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 c((n) => [...n, { ...t, id: s }]), o(!0), s;
11
- }, u = b((t) => {
12
- c((s) => {
13
- const n = s.filter((p) => p.id !== t);
14
- return o(n.length > 0), n;
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 ?? d) > 0), s = t?.duration || d;
19
- return t && (r.current = window.setTimeout(() => {
20
- u(t.id);
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
- r.current && clearTimeout(r.current);
28
+ o.current && clearTimeout(o.current);
23
29
  };
24
- }, [i, u]), /* @__PURE__ */ v(
25
- l.Provider,
30
+ }, [i, a]), /* @__PURE__ */ v(
31
+ g.Provider,
26
32
  {
27
33
  value: {
28
- open: f,
34
+ open: m,
29
35
  storedMessages: i,
30
- openSnackbar: g,
31
- closeSnackbarItem: u,
32
- dismissSnackbar: m
36
+ openSnackbar: p,
37
+ closeSnackbarItem: a,
38
+ dismissSnackbar: h
33
39
  },
34
40
  children: e
35
41
  }
36
42
  );
37
- }, k = () => {
38
- const e = M(l);
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
- C as SnackbarDuration,
45
- P as SnackbarProvider,
46
- k as useSnackbar
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;
@@ -34,6 +34,7 @@ interface SnackbarContextValue {
34
34
  }
35
35
  export declare const SnackbarProvider: React.FC<{
36
36
  children: React.ReactNode;
37
+ maxSnacks?: number;
37
38
  }>;
38
39
  export declare const useSnackbar: () => SnackbarContextValue;
39
40
  export {};
@@ -8,7 +8,7 @@ declare const meta: {
8
8
  };
9
9
  export default meta;
10
10
  interface DesignToken {
11
- $type?: "color" | string;
11
+ $type?: 'color' | string;
12
12
  $value: string;
13
13
  $description?: string;
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.64.2",
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.1.0",
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",