@altinn/altinn-components 0.67.6 → 0.67.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.
@@ -1 +1 @@
1
- ._stack_ilsfl_1{position:fixed;inset:auto 0 0;display:flex;flex-direction:column;row-gap:.5rem;padding:1rem;pointer-events:none}._stack_ilsfl_1>*{pointer-events:auto}@media(min-width:1024px){._stack_ilsfl_1{align-items:center}}
1
+ ._stack_1q54g_1{inset:auto 0 0;width:100%;margin:0;border:none;padding:1rem;background:transparent;overflow:visible;display:flex;flex-direction:column;row-gap:.5rem;pointer-events:none}._stack_1q54g_1>*{pointer-events:auto}@media(min-width:1024px){._stack_1q54g_1{align-items:center}}
@@ -1,27 +1,30 @@
1
1
  "use client";
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,
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ import { useRef as l, useEffect as d } from "react";
4
+ import { SnackbarBase as u } from "./SnackbarBase.js";
5
+ import { SnackbarItem as b } from "./SnackbarItem.js";
6
+ import { useSnackbar as h } from "./useSnackbar.js";
7
+ const S = 0.3, k = 0.4, w = ({ className: n }) => {
8
+ const { storedMessages: c, open: s, closeSnackbarItem: a } = h(), o = l(null);
9
+ d(() => {
10
+ const e = o.current;
11
+ e && (s ? e.showPopover() : e.matches(":popover-open") && e.hidePopover());
12
+ }, [s]);
13
+ const t = c || [], i = t.length - 1;
14
+ return /* @__PURE__ */ r(u, { ref: o, className: n, children: t.map((e, p) => {
15
+ const m = i - p, f = Math.max(k, 1 - m * S);
16
+ return /* @__PURE__ */ r(
17
+ b,
15
18
  {
16
- onDismiss: () => a(s.id),
17
- dismissable: s.dismissable,
18
- style: { opacity: p },
19
- ...s
19
+ onDismiss: () => a(e.id),
20
+ dismissable: e.dismissable,
21
+ style: { opacity: f },
22
+ ...e
20
23
  },
21
- s.id
24
+ e.id
22
25
  );
23
26
  }) });
24
27
  };
25
28
  export {
26
- y as Snackbar
29
+ w as Snackbar
27
30
  };
@@ -1,7 +1,7 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import '../../assets/SnackbarBase.css';const c = "_stack_ilsfl_1", a = {
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import '../../assets/SnackbarBase.css';const c = "_stack_1q54g_1", o = {
3
3
  stack: c
4
- }, e = ({ children: s }) => /* @__PURE__ */ t("section", { className: a.stack, children: s });
4
+ }, n = ({ children: s, ref: t }) => /* @__PURE__ */ a("section", { ref: t, popover: "manual", className: o.stack, children: s });
5
5
  export {
6
- e as SnackbarBase
6
+ n as SnackbarBase
7
7
  };
@@ -1,59 +1,78 @@
1
1
  "use client";
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-DyVcALSw.js";
5
- import a, { forwardRef as g } from "react";
2
+ import { jsx as a, jsxs as v } from "react/jsx-runtime";
3
+ import { c as h } from "../../index-p1eeF8LQ.js";
4
+ import d, { forwardRef as _, useEffect as g } from "react";
5
+ import { I as b, s as y } from "../../ToolbarSearch-DyVcALSw.js";
6
6
  import "../../tooltip-Ct39-719.js";
7
7
  import "../Typography/Link.js";
8
- import { Button as h } from "../Button/Button.js";
8
+ import { Button as w } from "../Button/Button.js";
9
9
  import "react-dom";
10
10
  import "../GlobalMenu/GlobalMenuBase.js";
11
11
  import "./useSnackbar.js";
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]);
12
+ import { u as x } from "../../useId-BVFxCjkq.js";
13
+ import '../../assets/SnackbarItem.css';var O = function(e, n) {
14
+ var i = {};
15
+ for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && n.indexOf(t) < 0 && (i[t] = e[t]);
16
16
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
17
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;
18
+ n.indexOf(t[r]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[r]) && (i[t[r]] = e[t[r]]);
19
+ return i;
20
20
  };
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(
21
+ const I = _((e, n) => {
22
+ var { title: i, titleId: t } = e, r = O(e, ["title", "titleId"]);
23
+ let l = x();
24
+ return l = i ? t || "title-" + l : void 0, d.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: o, "aria-labelledby": l }, r),
27
- n ? a.createElement("title", { id: l }, n) : null,
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" })
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: n, "aria-labelledby": l }, r),
27
+ i ? d.createElement("title", { id: l }, i) : null,
28
+ d.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
- }), 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
30
+ }), j = "_item_18ro3_1", A = "_itemWrapper_18ro3_24", N = "_icon_18ro3_29", S = "_content_18ro3_39", B = "_action_18ro3_47", c = {
31
+ item: j,
32
+ itemWrapper: A,
33
+ icon: N,
34
+ content: S,
35
+ action: B
36
36
  };
37
- var B = /* @__PURE__ */ ((e) => (e.company = "company", e.success = "success", e.warning = "warning", e.danger = "danger", e.info = "info", e))(B || {});
38
- const X = ({
37
+ var R = /* @__PURE__ */ ((e) => (e.company = "company", e.success = "success", e.warning = "warning", e.danger = "danger", e.info = "info", e))(R || {});
38
+ const T = ({
39
39
  as: e,
40
- message: o,
41
- className: n,
40
+ message: n,
41
+ className: i,
42
42
  color: t,
43
- icon: r = O,
43
+ icon: r = I,
44
44
  iconAltText: l = "Bell icon",
45
- dismissable: s = !0,
45
+ dismissable: p = !0,
46
46
  onDismiss: m,
47
- ...d
47
+ ...f
48
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" } }) }) })
49
+ const u = e || "div";
50
+ return g(() => {
51
+ if (!n)
52
+ return;
53
+ const s = document.querySelector("dialog[open]");
54
+ if (!s)
55
+ return;
56
+ let o = s.querySelector("[data-snackbar-live]");
57
+ o || (o = document.createElement("div"), o.setAttribute("data-snackbar-live", ""), o.setAttribute("aria-live", "polite"), o.setAttribute("aria-atomic", "true"), Object.assign(o.style, {
58
+ position: "absolute",
59
+ width: "1px",
60
+ height: "1px",
61
+ padding: "0",
62
+ overflow: "hidden",
63
+ clip: "rect(0,0,0,0)",
64
+ whiteSpace: "nowrap",
65
+ border: "0"
66
+ }), s.appendChild(o)), o.textContent = "", requestAnimationFrame(() => {
67
+ o.textContent = n;
68
+ });
69
+ }, [n]), /* @__PURE__ */ a("span", { className: c.itemWrapper, children: /* @__PURE__ */ v(u, { className: h(c.item, i), "data-color": t, role: "alert", ...f, children: [
70
+ /* @__PURE__ */ a(b, { svgElement: r, className: c.icon, "aria-hidden": "true" }),
71
+ /* @__PURE__ */ a("div", { className: c.content, children: n }),
72
+ p && /* @__PURE__ */ a("div", { className: c.action, children: /* @__PURE__ */ a(w, { variant: "solid", onClick: m, "aria-label": "close", children: /* @__PURE__ */ a(y, { style: { fontSize: "1.5em" } }) }) })
54
73
  ] }) });
55
74
  };
56
75
  export {
57
- B as SnackbarColorEnum,
58
- X as SnackbarItem
76
+ R as SnackbarColorEnum,
77
+ T as SnackbarItem
59
78
  };
@@ -2,4 +2,4 @@ export interface SnackbarProps {
2
2
  /** Optional classname */
3
3
  className?: string;
4
4
  }
5
- export declare const Snackbar: ({ className }: SnackbarProps) => import("react/jsx-runtime").JSX.Element | null;
5
+ export declare const Snackbar: ({ className }: SnackbarProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  declare const meta: {
2
2
  title: string;
3
- component: ({ className }: import('./Snackbar.tsx').SnackbarProps) => import("react/jsx-runtime").JSX.Element | null;
3
+ component: ({ className }: import('./Snackbar.tsx').SnackbarProps) => import("react/jsx-runtime").JSX.Element;
4
4
  tags: string[];
5
5
  parameters: {};
6
6
  args: {};
@@ -1,8 +1,9 @@
1
- import { ReactNode } from 'react';
1
+ import { ReactNode, Ref } from 'react';
2
2
  export interface SnackbarBaseProps {
3
3
  /** Optional classname */
4
4
  className?: string;
5
5
  /** Children */
6
6
  children: string | ReactNode;
7
+ ref?: Ref<HTMLElement>;
7
8
  }
8
- export declare const SnackbarBase: ({ children }: SnackbarBaseProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const SnackbarBase: ({ children, ref }: SnackbarBaseProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.67.6",
3
+ "version": "0.67.7",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",