asma-ui-core 3.54.2 → 3.55.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,47 +1,65 @@
1
- import { cn as f } from "../../../helpers/cn.js";
2
- import { resolveSx as n } from "../../../helpers/sx.js";
3
- import { useFocusTrap as v } from "../../../hooks/useFocusTrap.hook.js";
4
- import { useEffect as w, useRef as h } from "react";
5
- import { jsx as m, jsxs as b } from "react/jsx-runtime";
6
- import { FloatingPortal as g } from "@floating-ui/react";
7
- var k = {
1
+ import { cn as u } from "../../../helpers/cn.js";
2
+ import { resolveSx as c } from "../../../helpers/sx.js";
3
+ import { TOP_LAYER_PROPS as _, TOP_LAYER_RESET_STYLE as L, getOpenModalDialogAncestor as S, useTopLayerRef as T } from "../../../hooks/useTopLayer.hook.js";
4
+ import { useFocusTrap as b } from "../../../hooks/useFocusTrap.hook.js";
5
+ import { useEffect as m, useRef as k } from "react";
6
+ import { jsx as d, jsxs as D } from "react/jsx-runtime";
7
+ import { FloatingPortal as P } from "@floating-ui/react";
8
+ var O = {
8
9
  left: "inset-y-0 left-0 h-full",
9
10
  right: "inset-y-0 right-0 h-full",
10
11
  top: "inset-x-0 top-0 w-full",
11
12
  bottom: "inset-x-0 bottom-0 w-full"
12
- }, E = {
13
+ }, A = {
13
14
  left: "-translate-x-full",
14
15
  right: "translate-x-full",
15
16
  top: "-translate-y-full",
16
17
  bottom: "translate-y-full"
17
- }, F = ({ open: t = !1, onClose: l, anchor: o = "left", variant: u = "temporary", hideBackdrop: d, className: c, sx: x, PaperProps: a, ModalProps: p, children: y }) => {
18
- const e = u === "temporary", i = h(null);
19
- return w(() => {
20
- if (!t || !e) return;
21
- const r = (s) => {
22
- s.key === "Escape" && l?.(s, "escapeKeyDown");
18
+ }, K = ({ open: e = !1, onClose: n, anchor: a = "left", variant: p = "temporary", hideBackdrop: v, className: y, sx: x, PaperProps: i, ModalProps: E, anchorEl: h, children: R }) => {
19
+ const r = p === "temporary", s = S(h), o = s !== void 0, l = k(null), g = T((t) => {
20
+ l.current = t instanceof HTMLDivElement ? t : null;
21
+ }), w = o ? g : (t) => {
22
+ l.current = t;
23
+ };
24
+ return m(() => {
25
+ if (!e || !r) return;
26
+ const t = (f) => {
27
+ f.key === "Escape" && n?.(f, "escapeKeyDown");
23
28
  };
24
- return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
29
+ return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
25
30
  }, [
26
- t,
27
31
  e,
28
- l
29
- ]), v(t && e, i), e && !t && !p?.keepMounted ? null : /* @__PURE__ */ b(g, { children: [e && !d && t && /* @__PURE__ */ m("div", {
30
- className: "fixed inset-0 z-[1200] bg-[#626e7eb2]",
31
- onClick: (r) => l?.(r, "backdropClick")
32
- }), /* @__PURE__ */ m("div", {
33
- ref: i,
34
- role: e ? "dialog" : void 0,
35
- "aria-modal": e && t ? !0 : void 0,
36
- "aria-hidden": !t,
37
- className: f("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", t && "shadow-[0px_4px_40px_0px_#22213366]", k[o], !t && f(E[o], "pointer-events-none"), c, a?.className),
38
- style: {
39
- ...n(x),
40
- ...n(a?.sx)
41
- },
42
- children: y
43
- })] });
32
+ r,
33
+ n
34
+ ]), b(e && r, l), m(() => {
35
+ if (!e || !o) return;
36
+ const t = l.current;
37
+ if (!(!t || typeof t.showPopover != "function"))
38
+ try {
39
+ t.matches(":popover-open") || t.showPopover();
40
+ } catch {
41
+ }
42
+ }, [e, o]), r && !e && !E?.keepMounted ? null : /* @__PURE__ */ D(P, {
43
+ root: s,
44
+ children: [r && !v && e && /* @__PURE__ */ d("div", {
45
+ className: "fixed inset-0 z-[1200] bg-[#626e7eb2]",
46
+ onClick: (t) => n?.(t, "backdropClick")
47
+ }), /* @__PURE__ */ d("div", {
48
+ ref: w,
49
+ ...o ? _ : {},
50
+ role: r ? "dialog" : void 0,
51
+ "aria-modal": r && e ? !0 : void 0,
52
+ "aria-hidden": !e,
53
+ className: u("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", e && "shadow-[0px_4px_40px_0px_#22213366]", O[a], !e && u(A[a], "pointer-events-none"), y, i?.className),
54
+ style: {
55
+ ...o ? L : {},
56
+ ...c(x),
57
+ ...c(i?.sx)
58
+ },
59
+ children: R
60
+ })]
61
+ });
44
62
  };
45
63
  export {
46
- F as StyledDrawer
64
+ K as StyledDrawer
47
65
  };
@@ -1,32 +1,35 @@
1
1
  import { ContentCopyIcon as c } from "../../icons/content-copy-icon/ContentCopyIcon.js";
2
2
  import { StyledTooltip as d } from "../../data-display/tooltip/StyledTooltip.js";
3
3
  import { StyledButton as m } from "../../inputs/button/StyledButton.js";
4
- import { useMobileMediaQuery as s } from "../../../hooks/useMediaQuery.hook.js";
4
+ import { useMobileMediaQuery as h } from "../../../hooks/useMediaQuery.hook.js";
5
5
  import "react";
6
6
  import { jsx as t } from "react/jsx-runtime";
7
- var v = ({ className: e, contentToCopy: n, locale: i, messageInfo: p, text: r }) => {
8
- const o = i === "en" ? "Copy" : "Kopier", l = s();
7
+ var g = ({ className: n, contentToCopy: p, locale: r, messageInfo: a, text: e }) => {
8
+ const i = r === "en" ? "Copy" : "Kopier", l = h();
9
9
  return /* @__PURE__ */ t(d, {
10
- title: o,
10
+ title: i,
11
11
  children: /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(m, {
12
12
  dataTest: "copy-button",
13
- "aria-label": r ?? o,
14
- className: e,
13
+ "aria-label": e ?? i,
14
+ className: n,
15
15
  size: "small",
16
16
  variant: "text",
17
17
  startIcon: /* @__PURE__ */ t(c, {
18
18
  width: 20,
19
19
  height: 20
20
20
  }),
21
- onClick: () => {
22
- navigator.clipboard.writeText(n).then(() => {
23
- p(i === "no" ? "Kopiert til utklippstavle" : "Copied to clipboard");
24
- }).catch((a) => console.error("Copying failed with this: ", a));
21
+ onMouseDown: (o) => {
22
+ o.stopPropagation();
25
23
  },
26
- children: !l && (r ?? o)
24
+ onClick: (o) => {
25
+ o.preventDefault(), o.stopPropagation(), navigator.clipboard.writeText(p).then(() => {
26
+ a(r === "no" ? "Kopiert til utklippstavle" : "Copied to clipboard");
27
+ }).catch((s) => console.error("Copying failed with this: ", s));
28
+ },
29
+ children: !l && (e ?? i)
27
30
  }) })
28
31
  });
29
32
  };
30
33
  export {
31
- v as CopyButton
34
+ g as CopyButton
32
35
  };
@@ -1,13 +1,13 @@
1
1
  import { setPickerPosition as f } from "./helpers.js";
2
2
  import { StyledDayPicker as k } from "./components/StyledDayPicker.js";
3
- import { StyledCalendarPicker as x } from "./components/StyledCalendarPicker.js";
4
- import { DatePickerInputIndex as u } from "./components/DatePickerInputIndex.js";
3
+ import { StyledCalendarPicker as u } from "./components/StyledCalendarPicker.js";
4
+ import { DatePickerInputIndex as x } from "./components/DatePickerInputIndex.js";
5
5
  import { useIsMobileView as v } from "../../hooks/useWindowWidthSize.hook.js";
6
6
  import { StyledDrawer as C } from "../../../components/navigation/drawer/StyledDrawer.js";
7
7
  import { useBackNavigationClose as b } from "../../hooks/useBackNavigationClose.hook.js";
8
8
  import { useState as a } from "react";
9
9
  import { Fragment as h, jsx as o, jsxs as y } from "react/jsx-runtime";
10
- var j = (p) => {
10
+ var E = (p) => {
11
11
  const s = v(), [e, n] = a(null), [c, m] = a(!1), [d, i] = a(!1), P = (l) => {
12
12
  n(l.currentTarget), f(l, m);
13
13
  }, r = () => {
@@ -23,11 +23,11 @@ var j = (p) => {
23
23
  onValidatedOnce: () => i(!1)
24
24
  };
25
25
  return /* @__PURE__ */ y(h, { children: [
26
- /* @__PURE__ */ o(u, {
26
+ /* @__PURE__ */ o(x, {
27
27
  datePickerProps: t,
28
28
  onClick: P
29
29
  }),
30
- !s && /* @__PURE__ */ o(x, {
30
+ !s && /* @__PURE__ */ o(u, {
31
31
  datePickerProps: { ...t },
32
32
  popoverProps: {
33
33
  open: !!e,
@@ -40,8 +40,7 @@ var j = (p) => {
40
40
  anchor: "bottom",
41
41
  open: !!e,
42
42
  onClose: r,
43
- sx: { zIndex: 1300 },
44
- className: "z-[1300]",
43
+ anchorEl: e,
45
44
  children: /* @__PURE__ */ o("div", {
46
45
  className: "mx-auto max-w-[360px] px-2 pb-[max(1.5rem,env(safe-area-inset-bottom))]",
47
46
  children: /* @__PURE__ */ o(k, {
@@ -57,5 +56,5 @@ var j = (p) => {
57
56
  ] });
58
57
  };
59
58
  export {
60
- j as StyledDatePicker
59
+ E as StyledDatePicker
61
60
  };
@@ -20,6 +20,8 @@ export interface DrawerProps {
20
20
  ModalProps?: {
21
21
  keepMounted?: boolean;
22
22
  };
23
+ /** Trigger element — when inside a modal `<dialog>`, portal into it so the sheet is interactive. */
24
+ anchorEl?: Element | null;
23
25
  children?: ReactNode;
24
26
  }
25
27
  /**
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.54.2",
6
+ "version": "3.55.0",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",