@mattilsynet/design 2.2.1 → 2.2.2
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/mtds/illustrations/bucket-feed.svg +1 -0
- package/mtds/illustrations/index.json +20 -0
- package/mtds/illustrations/supplement-group.svg +1 -0
- package/mtds/illustrations/supplement-jar.svg +1 -0
- package/mtds/illustrations/supplement-tube.svg +1 -0
- package/mtds/index.iife.js +3 -3
- package/mtds/map/map.stories.d.ts +10 -0
- package/mtds/package.json.js +1 -1
- package/mtds/popover/popover-observer.js +15 -12
- package/mtds/popover/popover-observer.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +41 -41
- package/mtds/styles.module.css.js +29 -29
- package/package.json +2 -1
package/mtds/package.json.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { flip as g, shift as
|
|
1
|
+
import { flip as g, shift as f, size as m } from "../external/@floating-ui/dom/dist/floating-ui.dom.js";
|
|
2
2
|
import v from "../styles.module.css.js";
|
|
3
|
-
import { onLoaded as u, on as c, QUICK_EVENT as r, attr as
|
|
3
|
+
import { onLoaded as u, on as c, QUICK_EVENT as r, attr as a, anchorPosition as d } from "../utils.js";
|
|
4
4
|
const p = v.popover.split(" ")[0], l = "_mtds-popover-auto";
|
|
5
5
|
function h({ target: o, newState: t }) {
|
|
6
6
|
if (o instanceof HTMLElement && o.classList.contains(p)) {
|
|
7
|
-
const
|
|
7
|
+
const s = t === "closed", n = a(o, "data-overscroll") === "contain", e = o.getRootNode()?.querySelector(
|
|
8
8
|
`[popovertarget="${o.id}"]`
|
|
9
9
|
);
|
|
10
|
-
|
|
11
|
-
placement:
|
|
12
|
-
middleware: [g(),
|
|
13
|
-
n ?
|
|
10
|
+
s ? d(o, !1) : e && d(o, e, {
|
|
11
|
+
placement: a(o, "data-position") || "bottom",
|
|
12
|
+
middleware: [g(), f({ padding: 10 })].concat(
|
|
13
|
+
n ? m({
|
|
14
14
|
padding: 10,
|
|
15
15
|
apply({ availableHeight: i }) {
|
|
16
16
|
o.style.maxHeight = `${Math.max(50, i)}px`;
|
|
@@ -21,14 +21,17 @@ function h({ target: o, newState: t }) {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
function P({ target: o, newState: t }) {
|
|
24
|
-
t === "open" && o instanceof HTMLElement && o.classList.contains(p) &&
|
|
24
|
+
t === "open" && o instanceof HTMLElement && o.classList.contains(p) && a(o, "popover") !== "manual" && (o.classList.add(l), a(o, "popover", "manual"));
|
|
25
25
|
}
|
|
26
|
-
function C(
|
|
27
|
-
const t = o?.closest?.(
|
|
26
|
+
function C(o) {
|
|
27
|
+
const t = o.target?.closest?.(
|
|
28
|
+
"a,button,[popovertargetaction]"
|
|
29
|
+
), s = t && a(t, "popovertarget"), n = s ? document.getElementById(s) : t?.closest(`.${p}`);
|
|
28
30
|
for (const e of document.getElementsByClassName(l))
|
|
29
|
-
e.contains(o)
|
|
31
|
+
!e.contains(o.target) && n !== e && e.hidePopover();
|
|
30
32
|
if (n && t) {
|
|
31
|
-
|
|
33
|
+
o.preventDefault();
|
|
34
|
+
const e = a(t, "popovertargetaction") || "toggle", i = e === "show" || (e === "hide" ? !1 : void 0);
|
|
32
35
|
n instanceof HTMLElement && n.isConnected && n.togglePopover && n.togglePopover(i);
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover-observer.js","sources":["../../designsystem/popover/popover-observer.ts"],"sourcesContent":["import { flip, type Placement, shift, size } from \"@floating-ui/dom\";\nimport styles from \"../styles.module.css\";\nimport { anchorPosition, attr, on, onLoaded, QUICK_EVENT } from \"../utils\";\n\nconst CSS_POPOVER = styles.popover.split(\" \")[0];\nconst CSS_AUTO = `_mtds-popover-auto`;\n\ntype EventToggle = Event & Partial<ToggleEvent>;\n\nfunction handlePopoverToggle({ target: el, newState }: EventToggle) {\n\tif (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n\t\tconst isClosing = newState === \"closed\";\n\t\tconst isContain = attr(el, \"data-overscroll\") === \"contain\";\n\t\tconst anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(\n\t\t\t`[popovertarget=\"${el.id}\"]`,\n\t\t);\n\n\t\tif (isClosing) anchorPosition(el, false);\n\t\telse if (anchor)\n\t\t\tanchorPosition(el, anchor, {\n\t\t\t\tplacement: (attr(el, \"data-position\") || \"bottom\") as Placement,\n\t\t\t\tmiddleware: [flip(), shift({ padding: 10 })].concat(\n\t\t\t\t\tisContain\n\t\t\t\t\t\t? size({\n\t\t\t\t\t\t\t\tpadding: 10,\n\t\t\t\t\t\t\t\tapply({ availableHeight }) {\n\t\t\t\t\t\t\t\t\tel.style.maxHeight = `${Math.max(50, availableHeight)}px`;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: [],\n\t\t\t\t),\n\t\t\t});\n\t}\n}\n\nfunction handlePopoverBeforetoggle({ target: el, newState }: EventToggle) {\n\tif (\n\t\tnewState === \"open\" &&\n\t\tel instanceof HTMLElement &&\n\t\tel.classList.contains(CSS_POPOVER) &&\n\t\tattr(el, \"popover\") !== \"manual\"\n\t) {\n\t\tel.classList.add(CSS_AUTO);\n\t\tattr(el, \"popover\", \"manual\"); // Make manual to prevent closing when clicking scrollbar\n\t}\n}\n\n// Polyfill popovertarget for <a> (not supported by native)\n// and automatically assume popovertarget is the closest parent popover\n// but respect the popovertarget and popovertargetaction attribute\nfunction handlePopoverLinkClick(
|
|
1
|
+
{"version":3,"file":"popover-observer.js","sources":["../../designsystem/popover/popover-observer.ts"],"sourcesContent":["import { flip, type Placement, shift, size } from \"@floating-ui/dom\";\nimport styles from \"../styles.module.css\";\nimport { anchorPosition, attr, on, onLoaded, QUICK_EVENT } from \"../utils\";\n\nconst CSS_POPOVER = styles.popover.split(\" \")[0];\nconst CSS_AUTO = `_mtds-popover-auto`;\n\ntype EventToggle = Event & Partial<ToggleEvent>;\n\nfunction handlePopoverToggle({ target: el, newState }: EventToggle) {\n\tif (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n\t\tconst isClosing = newState === \"closed\";\n\t\tconst isContain = attr(el, \"data-overscroll\") === \"contain\";\n\t\tconst anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(\n\t\t\t`[popovertarget=\"${el.id}\"]`,\n\t\t);\n\n\t\tif (isClosing) anchorPosition(el, false);\n\t\telse if (anchor)\n\t\t\tanchorPosition(el, anchor, {\n\t\t\t\tplacement: (attr(el, \"data-position\") || \"bottom\") as Placement,\n\t\t\t\tmiddleware: [flip(), shift({ padding: 10 })].concat(\n\t\t\t\t\tisContain\n\t\t\t\t\t\t? size({\n\t\t\t\t\t\t\t\tpadding: 10,\n\t\t\t\t\t\t\t\tapply({ availableHeight }) {\n\t\t\t\t\t\t\t\t\tel.style.maxHeight = `${Math.max(50, availableHeight)}px`;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: [],\n\t\t\t\t),\n\t\t\t});\n\t}\n}\n\nfunction handlePopoverBeforetoggle({ target: el, newState }: EventToggle) {\n\tif (\n\t\tnewState === \"open\" &&\n\t\tel instanceof HTMLElement &&\n\t\tel.classList.contains(CSS_POPOVER) &&\n\t\tattr(el, \"popover\") !== \"manual\"\n\t) {\n\t\tel.classList.add(CSS_AUTO);\n\t\tattr(el, \"popover\", \"manual\"); // Make manual to prevent closing when clicking scrollbar\n\t}\n}\n\n// Polyfill popovertarget for <a> (not supported by native)\n// and automatically assume popovertarget is the closest parent popover\n// but respect the popovertarget and popovertargetaction attribute\nfunction handlePopoverLinkClick(event: Event) {\n\tconst el = (event.target as Element)?.closest?.(\n\t\t\"a,button,[popovertargetaction]\",\n\t);\n\tconst id = el && attr(el, \"popovertarget\");\n\tconst pop = id ? document.getElementById(id) : el?.closest(`.${CSS_POPOVER}`);\n\n\t// Manually close popovers where click was outside\n\tfor (const open of document.getElementsByClassName(CSS_AUTO))\n\t\tif (!open.contains(event.target as Node) && pop !== open)\n\t\t\t(open as HTMLElement).hidePopover();\n\n\tif (pop && el) {\n\t\tevent.preventDefault(); // Prevent browser popover API\n\t\tconst action = attr(el, \"popovertargetaction\") || \"toggle\";\n\t\tconst open = action === \"show\" || (action === \"hide\" ? false : undefined);\n\n\t\t// Popover can be disconneted by click handler deeper down in the DOM three before reaching document\n\t\tif (pop instanceof HTMLElement && pop.isConnected && pop.togglePopover)\n\t\t\tpop.togglePopover(open);\n\t}\n}\n\nonLoaded(() => {\n\ton(document, \"click\", handlePopoverLinkClick); // Allow `<a>` to use `popovertarget` as well\n\ton(document, \"toggle\", handlePopoverToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n\ton(document, \"beforetoggle\", handlePopoverBeforetoggle, QUICK_EVENT); // Use capture since toggle does not bubble\n});\n"],"names":["CSS_POPOVER","styles","CSS_AUTO","handlePopoverToggle","el","newState","isClosing","isContain","attr","anchor","anchorPosition","flip","shift","size","availableHeight","handlePopoverBeforetoggle","handlePopoverLinkClick","event","id","pop","open","action","onLoaded","on","QUICK_EVENT"],"mappings":";;;AAIA,MAAMA,IAAcC,EAAO,QAAQ,MAAM,GAAG,EAAE,CAAC,GACzCC,IAAW;AAIjB,SAASC,EAAoB,EAAE,QAAQC,GAAI,UAAAC,KAAyB;AACnE,MAAID,aAAc,eAAeA,EAAG,UAAU,SAASJ,CAAW,GAAG;AACpE,UAAMM,IAAYD,MAAa,UACzBE,IAAYC,EAAKJ,GAAI,iBAAiB,MAAM,WAC5CK,IAAUL,EAAG,YAAA,GAA8B;AAAA,MAChD,mBAAmBA,EAAG,EAAE;AAAA,IAAA;AAGzB,IAAIE,IAAWI,EAAeN,GAAI,EAAK,IAC9BK,KACRC,EAAeN,GAAIK,GAAQ;AAAA,MAC1B,WAAYD,EAAKJ,GAAI,eAAe,KAAK;AAAA,MACzC,YAAY,CAACO,EAAA,GAAQC,EAAM,EAAE,SAAS,GAAA,CAAI,CAAC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