@altinn/altinn-components 0.38.19 → 0.38.20

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,16 +1,16 @@
1
1
  "use client";
2
2
  import { jsx as f } from "react/jsx-runtime";
3
- import { useRef as S, useEffect as u } from "react";
3
+ import { useRef as x, useEffect as u } from "react";
4
4
  import "../../index-L8X2o7IH.js";
5
5
  import "../RootProvider/RootProvider.js";
6
6
  import "../Snackbar/useSnackbar.js";
7
- import { Section as x } from "../Page/Section.js";
7
+ import { Section as C } from "../Page/Section.js";
8
8
  import '../../assets/ModalBase.css';const R = "_modal_4vfmr_1", I = "_content_4vfmr_35", d = {
9
9
  modal: R,
10
10
  content: I
11
11
  }, Y = ({
12
- open: c,
13
- onClose: a,
12
+ open: a,
13
+ onClose: r,
14
14
  closedBy: n = "any",
15
15
  children: v,
16
16
  backdropColor: p = "inherit",
@@ -20,16 +20,22 @@ import '../../assets/ModalBase.css';const R = "_modal_4vfmr_1", I = "_content_4v
20
20
  spacing: b = 0,
21
21
  variant: k = "default"
22
22
  }) => {
23
- const r = S(null);
23
+ const c = x(null);
24
24
  return u(() => {
25
- const e = r.current, o = (t) => {
25
+ const e = c.current, o = (t) => {
26
26
  var m;
27
27
  const { clientY: s, clientX: l, target: L } = t;
28
- if (t instanceof KeyboardEvent)
29
- return n === "none" && t.key === "Escape" && t.preventDefault();
28
+ if (t instanceof KeyboardEvent && t.key === "Escape") {
29
+ if (n === "none") {
30
+ t.preventDefault();
31
+ return;
32
+ }
33
+ r();
34
+ return;
35
+ }
30
36
  if (!((m = window.getSelection()) != null && m.toString()) && e && L === e && n === "any") {
31
- const { top: _, left: w, right: C, bottom: D } = e.getBoundingClientRect();
32
- _ <= s && s <= D && w <= l && l <= C || e == null || e.close();
37
+ const { top: _, left: w, right: D, bottom: S } = e.getBoundingClientRect();
38
+ _ <= s && s <= S && w <= l && l <= D || e == null || e.close();
33
39
  }
34
40
  }, i = () => {
35
41
  const t = e == null ? void 0 : e.querySelector("[autofocus]");
@@ -38,24 +44,24 @@ import '../../assets/ModalBase.css';const R = "_modal_4vfmr_1", I = "_content_4v
38
44
  return e == null || e.addEventListener("animationend", i), e == null || e.addEventListener("click", o), e == null || e.addEventListener("keydown", o), () => {
39
45
  e == null || e.removeEventListener("animationend", i), e == null || e.removeEventListener("click", o), e == null || e.removeEventListener("keydown", o);
40
46
  };
41
- }, [n]), u(() => {
42
- const e = r.current;
43
- e && (c ? e.open || e.showModal() : e.open && e.close());
44
- }, [c]), /* @__PURE__ */ f(
47
+ }, [n, r]), u(() => {
48
+ const e = c.current;
49
+ e && (a ? e.open || e.showModal() : e.open && e.close());
50
+ }, [a]), /* @__PURE__ */ f(
45
51
  "dialog",
46
52
  {
47
- ref: r,
53
+ ref: c,
48
54
  "aria-modal": "true",
49
55
  "aria-labelledby": "modal-title",
50
56
  onCancel: (e) => {
51
- e.preventDefault(), n === "any" && a();
57
+ e.preventDefault(), n === "any" && r();
52
58
  },
53
59
  "data-backdrop-color": p,
54
60
  className: d.modal,
55
61
  "data-variant": k,
56
- onClose: n !== "none" ? a : void 0,
62
+ onClose: n !== "none" ? r : void 0,
57
63
  children: /* @__PURE__ */ f(
58
- x,
64
+ C,
59
65
  {
60
66
  className: d.content,
61
67
  "aria-label": "modal content",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.38.19",
3
+ "version": "0.38.20",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",