@mattilsynet/design 1.3.2 → 1.3.3

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,17 +1,17 @@
1
1
  import m from "../styles.module.css.js";
2
- import { onLoaded as C, onMutation as T, on as r, QUICK_EVENT as p, debounce as P } from "../utils.js";
2
+ import { onLoaded as C, onMutation as T, on as p, QUICK_EVENT as c, debounce as P } from "../utils.js";
3
3
  import "./app-toggle2.js";
4
4
  const f = m.app.split(" ")[0], _ = m.sticky.split(" ")[0], h = '[data-command="toggle-app-expanded"]', g = `.${f} > dialog,.${f} dialog ~ main`, S = (t) => {
5
5
  document.startViewTransition ? document.startViewTransition(t) : t();
6
6
  }, E = (t) => (
7
7
  // @ts-expect-error window.mtdsAppToggle comes from app-toggle.js
8
8
  S(() => {
9
- var o;
10
- return (o = window.mtdsToggleAppExpanded) == null ? void 0 : o.call(window, t);
9
+ var i;
10
+ return (i = window.mtdsToggleAppExpanded) == null ? void 0 : i.call(window, t);
11
11
  })
12
12
  );
13
- function x({ target: t }) {
14
- if (!(!(t instanceof HTMLButtonElement) || !t.matches(h))) {
13
+ function x({ target: t, defaultPrevented: i }) {
14
+ if (!(i || !(t instanceof HTMLButtonElement) || !t.matches(h))) {
15
15
  if (getComputedStyle(t).position === "sticky") return E();
16
16
  S(() => {
17
17
  const o = document.querySelector(g);
@@ -23,18 +23,18 @@ function I() {
23
23
  var t;
24
24
  (t = document.querySelector(g)) == null || t.close();
25
25
  }
26
- let c = 0, s, n = 0, e, d = 0, l = 0, a = !1, u = 0, i = 0;
26
+ let d = 0, l, n = 0, e, a = 0, r = 0, u = !1, y = 0, s = 0;
27
27
  function H([t]) {
28
28
  e = t, w();
29
29
  }
30
30
  function w() {
31
- var y;
31
+ var o;
32
32
  if (!(e != null && e.isConnected)) return;
33
- const t = window.scrollY, o = t < i;
34
- i = t, o !== s && (c = (((y = e.parentElement) == null ? void 0 : y.getBoundingClientRect().top) || 0) + i, s = o, d = e.offsetHeight, l = e.getBoundingClientRect().top + i, a = e.offsetHeight <= window.innerHeight, u = window.innerHeight), !(n === -1 && a) && (n !== -1 && (a || s && i <= l) ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", "0px"), n = -1) : n === -1 && !s ? (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${Math.max(0, i - c)}px`), n = 0) : n !== 1 && !s && i + u >= l + d ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", `${u - d}px`), n = 1) : n === 1 && s && (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${l - c}px`), n = 0));
33
+ const t = window.scrollY, i = t < s;
34
+ s = t, i !== l && (d = (((o = e.parentElement) == null ? void 0 : o.getBoundingClientRect().top) || 0) + s, l = i, a = e.offsetHeight, r = e.getBoundingClientRect().top + s, u = e.offsetHeight <= window.innerHeight, y = window.innerHeight), !(n === -1 && u) && (n !== -1 && (u || l && s <= r) ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", "0px"), n = -1) : n === -1 && !l ? (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${Math.max(0, s - d)}px`), n = 0) : n !== 1 && !l && s + y >= r + a ? (e.style.setProperty("--pos", "sticky"), e.style.setProperty("--top", `${y - a}px`), n = 1) : n === 1 && l && (e.style.setProperty("--pos", "relative"), e.style.setProperty("--top", `${r - d}px`), n = 0));
35
35
  }
36
36
  C(() => {
37
- T(document.documentElement, _, H), r(document, "click", x, p), r(window, "resize", P(I, 100), p), r(window, "scroll", w, p);
37
+ T(document.documentElement, _, H), p(document, "click", x, c), p(window, "resize", P(I, 100), c), p(window, "scroll", w, c);
38
38
  });
39
39
  export {
40
40
  E as toggleAppExpanded
@@ -1 +1 @@
1
- {"version":3,"file":"app-observer.js","sources":["../../designsystem/app/app-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { QUICK_EVENT, debounce, on, onLoaded, onMutation } from \"../utils\";\nimport \"./app-toggle\";\n\nconst CSS_APP = styles.app.split(\" \")[0];\nconst CSS_STICKY = styles.sticky.split(\" \")[0];\nconst CSS_TOGGLE = '[data-command=\"toggle-app-expanded\"]';\nconst CSS_SIDEBAR = `.${CSS_APP} > dialog,.${CSS_APP} dialog ~ main`;\n\nconst useTransition = (callback: () => void) => {\n\tif (!document.startViewTransition) callback();\n\telse document.startViewTransition(callback);\n};\n\nexport const toggleAppExpanded = (force?: boolean) =>\n\t// @ts-expect-error window.mtdsAppToggle comes from app-toggle.js\n\tuseTransition(() => window.mtdsToggleAppExpanded?.(force));\n\nfunction handleToggleClick({ target: el }: Event) {\n\tif (!(el instanceof HTMLButtonElement) || !el.matches(CSS_TOGGLE)) return;\n\tif (getComputedStyle(el).position === \"sticky\") return toggleAppExpanded();\n\tuseTransition(() => {\n\t\tconst sidebar = document.querySelector<HTMLDialogElement>(CSS_SIDEBAR);\n\t\tsidebar?.setAttribute(\"data-closedby\", \"any\"); // Allow closing by clicking outside\n\t\tsidebar?.showModal();\n\t});\n}\n\nfunction handleResize() {\n\tdocument.querySelector<HTMLDialogElement>(CSS_SIDEBAR)?.close();\n}\n\n// Scroll state\nlet MIN_Y = 0; // Offset to avoid scroll jump when sticky is set to relative\nlet SCROLL_UP: boolean;\nlet STICK = 0; // -1 = stick top, 0 = relative, 1 = stick bottom\nlet STICK_EL: HTMLElement;\nlet STICK_H = 0;\nlet STICK_Y = 0;\nlet STUCK = false; // Used to figure if nav is larger than viewport\nlet WIN_H = 0;\nlet WIN_Y = 0;\n\nfunction handleMutation([sticky]: HTMLCollectionOf<HTMLElement>) {\n\tSTICK_EL = sticky;\n\thandleScroll(); // Run on connect\n}\n\nfunction handleScroll() {\n\tif (!STICK_EL?.isConnected) return;\n\tconst NEXT_Y = window.scrollY;\n\tconst NEXT_UP = NEXT_Y < WIN_Y;\n\tWIN_Y = NEXT_Y;\n\n\t// Only calculate if scroll direction has changed\n\tif (NEXT_UP !== SCROLL_UP) {\n\t\tMIN_Y = (STICK_EL.parentElement?.getBoundingClientRect().top || 0) + WIN_Y;\n\t\tSCROLL_UP = NEXT_UP;\n\t\tSTICK_H = STICK_EL.offsetHeight;\n\t\tSTICK_Y = STICK_EL.getBoundingClientRect().top + WIN_Y;\n\t\tSTUCK = STICK_EL.offsetHeight <= window.innerHeight;\n\t\tWIN_H = window.innerHeight;\n\t}\n\n\tif (STICK === -1 && STUCK) return; // Allways sticky when sidebar is smaller than viewport\n\tif (STICK !== -1 && (STUCK || (SCROLL_UP && WIN_Y <= STICK_Y))) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"sticky\");\n\t\tSTICK_EL.style.setProperty(\"--top\", \"0px\");\n\t\tSTICK = -1; // Not sticking to top and sidebar is smaller than viewport or scrolling up\n\t} else if (STICK === -1 && !SCROLL_UP) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"relative\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${Math.max(0, WIN_Y - MIN_Y)}px`);\n\t\tSTICK = 0; // Sticking to top and scrolling down\n\t} else if (STICK !== 1 && !SCROLL_UP && WIN_Y + WIN_H >= STICK_Y + STICK_H) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"sticky\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${WIN_H - STICK_H}px`);\n\t\tSTICK = 1; // Not sticking to bottom and scrolling down\n\t} else if (STICK === 1 && SCROLL_UP) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"relative\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${STICK_Y - MIN_Y}px`);\n\t\tSTICK = 0; // Sticking to bottom and scrolling up\n\t}\n}\n\nonLoaded(() => {\n\tonMutation(document.documentElement, CSS_STICKY, handleMutation);\n\ton(document, \"click\", handleToggleClick, QUICK_EVENT);\n\ton(window, \"resize\", debounce(handleResize, 100), QUICK_EVENT);\n\ton(window, \"scroll\", handleScroll, QUICK_EVENT);\n});\n"],"names":["CSS_APP","styles","CSS_STICKY","CSS_TOGGLE","CSS_SIDEBAR","useTransition","callback","toggleAppExpanded","force","_a","handleToggleClick","el","sidebar","handleResize","MIN_Y","SCROLL_UP","STICK","STICK_EL","STICK_H","STICK_Y","STUCK","WIN_H","WIN_Y","handleMutation","sticky","handleScroll","NEXT_Y","NEXT_UP","onLoaded","onMutation","on","QUICK_EVENT","debounce"],"mappings":";;;AAIA,MAAMA,IAAUC,EAAO,IAAI,MAAM,GAAG,EAAE,CAAC,GACjCC,IAAaD,EAAO,OAAO,MAAM,GAAG,EAAE,CAAC,GACvCE,IAAa,wCACbC,IAAc,IAAIJ,CAAO,cAAcA,CAAO,kBAE9CK,IAAgB,CAACC,MAAyB;AAC3C,EAAC,SAAS,sBACT,SAAS,oBAAoBA,CAAQ,IADEA,EAAA;AAE7C,GAEaC,IAAoB,CAACC;AAAA;AAAA,EAEjCH,EAAc,MAAM;;AAAA,YAAAI,IAAA,OAAO,0BAAP,gBAAAA,EAAA,aAA+BD;AAAA,GAAM;AAAA;AAE1D,SAASE,EAAkB,EAAE,QAAQC,KAAa;AACjD,MAAI,IAAEA,aAAc,sBAAsB,CAACA,EAAG,QAAQR,CAAU,IAChE;AAAA,QAAI,iBAAiBQ,CAAE,EAAE,aAAa,iBAAiBJ,EAAkB;AACzE,IAAAF,EAAc,MAAM;AACb,YAAAO,IAAU,SAAS,cAAiCR,CAAW;AAC5D,MAAAQ,KAAA,QAAAA,EAAA,aAAa,iBAAiB,QACvCA,KAAA,QAAAA,EAAS;AAAA,IAAU,CACnB;AAAA;AACF;AAEA,SAASC,IAAe;;AACd,GAAAJ,IAAA,SAAA,cAAiCL,CAAW,MAA5C,QAAAK,EAA+C;AACzD;AAGA,IAAIK,IAAQ,GACRC,GACAC,IAAQ,GACRC,GACAC,IAAU,GACVC,IAAU,GACVC,IAAQ,IACRC,IAAQ,GACRC,IAAQ;AAEZ,SAASC,EAAe,CAACC,CAAM,GAAkC;AACrD,EAAAP,IAAAO,GACEC,EAAA;AACd;AAEA,SAASA,IAAe;;AACnB,MAAA,EAACR,KAAA,QAAAA,EAAU,aAAa;AAC5B,QAAMS,IAAS,OAAO,SAChBC,IAAUD,IAASJ;AAarB,EAZIA,IAAAI,GAGJC,MAAYZ,MACfD,OAASL,IAAAQ,EAAS,kBAAT,gBAAAR,EAAwB,wBAAwB,QAAO,KAAKa,GACzDP,IAAAY,GACZT,IAAUD,EAAS,cACTE,IAAAF,EAAS,sBAAsB,EAAE,MAAMK,GACzCF,IAAAH,EAAS,gBAAgB,OAAO,aACxCI,IAAQ,OAAO,cAGZ,EAAAL,MAAU,MAAMI,OAChBJ,MAAU,OAAOI,KAAUL,KAAaO,KAASH,MAC3CF,EAAA,MAAM,YAAY,SAAS,QAAQ,GACnCA,EAAA,MAAM,YAAY,SAAS,KAAK,GACjCD,IAAA,MACEA,MAAU,MAAM,CAACD,KAClBE,EAAA,MAAM,YAAY,SAAS,UAAU,GACrCA,EAAA,MAAM,YAAY,SAAS,GAAG,KAAK,IAAI,GAAGK,IAAQR,CAAK,CAAC,IAAI,GAC7DE,IAAA,KACEA,MAAU,KAAK,CAACD,KAAaO,IAAQD,KAASF,IAAUD,KACzDD,EAAA,MAAM,YAAY,SAAS,QAAQ,GAC5CA,EAAS,MAAM,YAAY,SAAS,GAAGI,IAAQH,CAAO,IAAI,GAClDF,IAAA,KACEA,MAAU,KAAKD,MAChBE,EAAA,MAAM,YAAY,SAAS,UAAU,GAC9CA,EAAS,MAAM,YAAY,SAAS,GAAGE,IAAUL,CAAK,IAAI,GAClDE,IAAA;AAEV;AAEAY,EAAS,MAAM;AACH,EAAAC,EAAA,SAAS,iBAAiB3B,GAAYqB,CAAc,GAC5DO,EAAA,UAAU,SAASpB,GAAmBqB,CAAW,GACpDD,EAAG,QAAQ,UAAUE,EAASnB,GAAc,GAAG,GAAGkB,CAAW,GAC1DD,EAAA,QAAQ,UAAUL,GAAcM,CAAW;AAC/C,CAAC;"}
1
+ {"version":3,"file":"app-observer.js","sources":["../../designsystem/app/app-observer.ts"],"sourcesContent":["import styles from \"../styles.module.css\";\nimport { QUICK_EVENT, debounce, on, onLoaded, onMutation } from \"../utils\";\nimport \"./app-toggle\";\n\nconst CSS_APP = styles.app.split(\" \")[0];\nconst CSS_STICKY = styles.sticky.split(\" \")[0];\nconst CSS_TOGGLE = '[data-command=\"toggle-app-expanded\"]';\nconst CSS_SIDEBAR = `.${CSS_APP} > dialog,.${CSS_APP} dialog ~ main`;\n\nconst useTransition = (callback: () => void) => {\n\tif (!document.startViewTransition) callback();\n\telse document.startViewTransition(callback);\n};\n\nexport const toggleAppExpanded = (force?: boolean) =>\n\t// @ts-expect-error window.mtdsAppToggle comes from app-toggle.js\n\tuseTransition(() => window.mtdsToggleAppExpanded?.(force));\n\nfunction handleToggleClick({ target: el, defaultPrevented: stop }: Event) {\n\tif (stop || !(el instanceof HTMLButtonElement) || !el.matches(CSS_TOGGLE))\n\t\treturn;\n\tif (getComputedStyle(el).position === \"sticky\") return toggleAppExpanded();\n\tuseTransition(() => {\n\t\tconst sidebar = document.querySelector<HTMLDialogElement>(CSS_SIDEBAR);\n\t\tsidebar?.setAttribute(\"data-closedby\", \"any\"); // Allow closing by clicking outside\n\t\tsidebar?.showModal();\n\t});\n}\n\nfunction handleResize() {\n\tdocument.querySelector<HTMLDialogElement>(CSS_SIDEBAR)?.close();\n}\n\n// Scroll state\nlet MIN_Y = 0; // Offset to avoid scroll jump when sticky is set to relative\nlet SCROLL_UP: boolean;\nlet STICK = 0; // -1 = stick top, 0 = relative, 1 = stick bottom\nlet STICK_EL: HTMLElement;\nlet STICK_H = 0;\nlet STICK_Y = 0;\nlet STUCK = false; // Used to figure if nav is larger than viewport\nlet WIN_H = 0;\nlet WIN_Y = 0;\n\nfunction handleMutation([sticky]: HTMLCollectionOf<HTMLElement>) {\n\tSTICK_EL = sticky;\n\thandleScroll(); // Run on connect\n}\n\nfunction handleScroll() {\n\tif (!STICK_EL?.isConnected) return;\n\tconst NEXT_Y = window.scrollY;\n\tconst NEXT_UP = NEXT_Y < WIN_Y;\n\tWIN_Y = NEXT_Y;\n\n\t// Only calculate if scroll direction has changed\n\tif (NEXT_UP !== SCROLL_UP) {\n\t\tMIN_Y = (STICK_EL.parentElement?.getBoundingClientRect().top || 0) + WIN_Y;\n\t\tSCROLL_UP = NEXT_UP;\n\t\tSTICK_H = STICK_EL.offsetHeight;\n\t\tSTICK_Y = STICK_EL.getBoundingClientRect().top + WIN_Y;\n\t\tSTUCK = STICK_EL.offsetHeight <= window.innerHeight;\n\t\tWIN_H = window.innerHeight;\n\t}\n\n\tif (STICK === -1 && STUCK) return; // Allways sticky when sidebar is smaller than viewport\n\tif (STICK !== -1 && (STUCK || (SCROLL_UP && WIN_Y <= STICK_Y))) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"sticky\");\n\t\tSTICK_EL.style.setProperty(\"--top\", \"0px\");\n\t\tSTICK = -1; // Not sticking to top and sidebar is smaller than viewport or scrolling up\n\t} else if (STICK === -1 && !SCROLL_UP) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"relative\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${Math.max(0, WIN_Y - MIN_Y)}px`);\n\t\tSTICK = 0; // Sticking to top and scrolling down\n\t} else if (STICK !== 1 && !SCROLL_UP && WIN_Y + WIN_H >= STICK_Y + STICK_H) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"sticky\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${WIN_H - STICK_H}px`);\n\t\tSTICK = 1; // Not sticking to bottom and scrolling down\n\t} else if (STICK === 1 && SCROLL_UP) {\n\t\tSTICK_EL.style.setProperty(\"--pos\", \"relative\");\n\t\tSTICK_EL.style.setProperty(\"--top\", `${STICK_Y - MIN_Y}px`);\n\t\tSTICK = 0; // Sticking to bottom and scrolling up\n\t}\n}\n\nonLoaded(() => {\n\tonMutation(document.documentElement, CSS_STICKY, handleMutation);\n\ton(document, \"click\", handleToggleClick, QUICK_EVENT);\n\ton(window, \"resize\", debounce(handleResize, 100), QUICK_EVENT);\n\ton(window, \"scroll\", handleScroll, QUICK_EVENT);\n});\n"],"names":["CSS_APP","styles","CSS_STICKY","CSS_TOGGLE","CSS_SIDEBAR","useTransition","callback","toggleAppExpanded","force","_a","handleToggleClick","el","stop","sidebar","handleResize","MIN_Y","SCROLL_UP","STICK","STICK_EL","STICK_H","STICK_Y","STUCK","WIN_H","WIN_Y","handleMutation","sticky","handleScroll","NEXT_Y","NEXT_UP","onLoaded","onMutation","on","QUICK_EVENT","debounce"],"mappings":";;;AAIA,MAAMA,IAAUC,EAAO,IAAI,MAAM,GAAG,EAAE,CAAC,GACjCC,IAAaD,EAAO,OAAO,MAAM,GAAG,EAAE,CAAC,GACvCE,IAAa,wCACbC,IAAc,IAAIJ,CAAO,cAAcA,CAAO,kBAE9CK,IAAgB,CAACC,MAAyB;AAC3C,EAAC,SAAS,sBACT,SAAS,oBAAoBA,CAAQ,IADEA,EAAA;AAE7C,GAEaC,IAAoB,CAACC;AAAA;AAAA,EAEjCH,EAAc,MAAM;;AAAA,YAAAI,IAAA,OAAO,0BAAP,gBAAAA,EAAA,aAA+BD;AAAA,GAAM;AAAA;AAE1D,SAASE,EAAkB,EAAE,QAAQC,GAAI,kBAAkBC,KAAe;AACzE,MAAI,EAAAA,KAAQ,EAAED,aAAc,sBAAsB,CAACA,EAAG,QAAQR,CAAU,IAExE;AAAA,QAAI,iBAAiBQ,CAAE,EAAE,aAAa,iBAAiBJ,EAAkB;AACzE,IAAAF,EAAc,MAAM;AACb,YAAAQ,IAAU,SAAS,cAAiCT,CAAW;AAC5D,MAAAS,KAAA,QAAAA,EAAA,aAAa,iBAAiB,QACvCA,KAAA,QAAAA,EAAS;AAAA,IAAU,CACnB;AAAA;AACF;AAEA,SAASC,IAAe;;AACd,GAAAL,IAAA,SAAA,cAAiCL,CAAW,MAA5C,QAAAK,EAA+C;AACzD;AAGA,IAAIM,IAAQ,GACRC,GACAC,IAAQ,GACRC,GACAC,IAAU,GACVC,IAAU,GACVC,IAAQ,IACRC,IAAQ,GACRC,IAAQ;AAEZ,SAASC,EAAe,CAACC,CAAM,GAAkC;AACrD,EAAAP,IAAAO,GACEC,EAAA;AACd;AAEA,SAASA,IAAe;;AACnB,MAAA,EAACR,KAAA,QAAAA,EAAU,aAAa;AAC5B,QAAMS,IAAS,OAAO,SAChBC,IAAUD,IAASJ;AAarB,EAZIA,IAAAI,GAGJC,MAAYZ,MACfD,OAASN,IAAAS,EAAS,kBAAT,gBAAAT,EAAwB,wBAAwB,QAAO,KAAKc,GACzDP,IAAAY,GACZT,IAAUD,EAAS,cACTE,IAAAF,EAAS,sBAAsB,EAAE,MAAMK,GACzCF,IAAAH,EAAS,gBAAgB,OAAO,aACxCI,IAAQ,OAAO,cAGZ,EAAAL,MAAU,MAAMI,OAChBJ,MAAU,OAAOI,KAAUL,KAAaO,KAASH,MAC3CF,EAAA,MAAM,YAAY,SAAS,QAAQ,GACnCA,EAAA,MAAM,YAAY,SAAS,KAAK,GACjCD,IAAA,MACEA,MAAU,MAAM,CAACD,KAClBE,EAAA,MAAM,YAAY,SAAS,UAAU,GACrCA,EAAA,MAAM,YAAY,SAAS,GAAG,KAAK,IAAI,GAAGK,IAAQR,CAAK,CAAC,IAAI,GAC7DE,IAAA,KACEA,MAAU,KAAK,CAACD,KAAaO,IAAQD,KAASF,IAAUD,KACzDD,EAAA,MAAM,YAAY,SAAS,QAAQ,GAC5CA,EAAS,MAAM,YAAY,SAAS,GAAGI,IAAQH,CAAO,IAAI,GAClDF,IAAA,KACEA,MAAU,KAAKD,MAChBE,EAAA,MAAM,YAAY,SAAS,UAAU,GAC9CA,EAAS,MAAM,YAAY,SAAS,GAAGE,IAAUL,CAAK,IAAI,GAClDE,IAAA;AAEV;AAEAY,EAAS,MAAM;AACH,EAAAC,EAAA,SAAS,iBAAiB5B,GAAYsB,CAAc,GAC5DO,EAAA,UAAU,SAASrB,GAAmBsB,CAAW,GACpDD,EAAG,QAAQ,UAAUE,EAASnB,GAAc,GAAG,GAAGkB,CAAW,GAC1DD,EAAA,QAAQ,UAAUL,GAAcM,CAAW;AAC/C,CAAC;"}
package/mtds/app/app.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { JSX } from 'react';
2
+ import { ButtonProps } from '../react';
2
3
  import { PolymorphicComponentPropWithRef } from '../react-types';
3
4
  export type AppHeaderProps = React.ComponentPropsWithoutRef<"header">;
4
5
  export type AppSidebarProps = React.ComponentPropsWithoutRef<"dialog">;
@@ -11,6 +12,7 @@ export declare const App: AppComponent & {
11
12
  Header: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
12
13
  Sidebar: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>, "ref"> & React.RefAttributes<HTMLDialogElement>>;
13
14
  Sticky: AppComponent;
15
+ Toggle: React.ForwardRefExoticComponent<Omit<ButtonProps<"button">, "ref"> & React.RefAttributes<HTMLButtonElement>>;
14
16
  Main: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
15
17
  Footer: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & React.RefAttributes<HTMLElement>>;
16
18
  Script: () => import("react/jsx-runtime").JSX.Element;
package/mtds/app/app.js CHANGED
@@ -1,36 +1,80 @@
1
1
  import { jsx as o } from "react/jsx-runtime";
2
- import { clsx as a } from "../external/clsx/dist/clsx.js";
2
+ import { clsx as e } from "../external/clsx/dist/clsx.js";
3
3
  import { forwardRef as p } from "react";
4
- import c from "../styles.module.css.js";
5
- import m from "./app-toggle.js";
6
- const f = p(function({ as: r, className: t, ...n }, e) {
7
- return /* @__PURE__ */ o(r || "div", { className: a(c.app, t), ref: e, ...n });
8
- }), d = p(function({ as: r, className: t, ...n }, e) {
9
- return /* @__PURE__ */ o(r || "div", { className: a(c.sticky, t), ref: e, ...n });
10
- }), y = Object.assign(f, {
4
+ import "../alert/alert.js";
5
+ import "../avatar/avatar.js";
6
+ import "../badge/badge.js";
7
+ import "../breadcrumbs/breadcrumbs.js";
8
+ import { Button as s } from "../button/button.js";
9
+ import "../card/card.js";
10
+ import "../chip/chip.js";
11
+ import "../details/details.js";
12
+ import "../dialog/dialog.js";
13
+ import "../divider/divider.js";
14
+ import "../errorsummary/errorsummary.js";
15
+ import "../field/field.js";
16
+ import "../fieldset/fieldset.js";
17
+ import "../helptext/helptext.js";
18
+ import "../input/input.js";
19
+ import "../layout/layout.js";
20
+ import "../link/link.js";
21
+ import "../logo/logo.js";
22
+ import "../pagination/pagination.js";
23
+ import "../popover/popover.js";
24
+ import "../progress/progress.js";
25
+ import "../skeleton/skeleton.js";
26
+ import "../spinner/spinner.js";
27
+ import "../steps/steps.js";
28
+ import "../table/table.js";
29
+ import "../tabs/tabs.js";
30
+ import "../tag/tag.js";
31
+ import "../togglegroup/togglegroup.js";
32
+ import "../typography/typography.js";
33
+ import "../validation/validation.js";
34
+ import a from "../styles.module.css.js";
35
+ import d from "./app-toggle.js";
36
+ const f = p(function({ as: t, className: r, ...m }, n) {
37
+ return /* @__PURE__ */ o(t || "div", { className: e(a.app, r), ref: n, ...m });
38
+ }), u = p(function({ as: t, className: r, ...m }, n) {
39
+ return /* @__PURE__ */ o(t || "div", { className: e(a.sticky, r), ref: n, ...m });
40
+ }), X = Object.assign(f, {
11
41
  Header: p(
12
- function(r, t) {
13
- return /* @__PURE__ */ o("header", { ref: t, ...r });
42
+ function(t, r) {
43
+ return /* @__PURE__ */ o("header", { ref: r, ...t });
14
44
  }
15
45
  ),
16
46
  Sidebar: p(
17
- function(r, t) {
18
- return /* @__PURE__ */ o("dialog", { role: "navigation", ref: t, ...r });
47
+ function(t, r) {
48
+ return /* @__PURE__ */ o("dialog", { role: "navigation", ref: r, ...t });
19
49
  }
20
50
  ),
21
- Sticky: d,
22
- Main: p(function(r, t) {
23
- return /* @__PURE__ */ o("main", { ref: t, ...r });
51
+ Sticky: u,
52
+ Toggle: p(
53
+ function({ children: t, ...r }, m) {
54
+ return /* @__PURE__ */ o(
55
+ s,
56
+ {
57
+ "data-command": "toggle-app-expanded",
58
+ "data-tooltip": "Vis meny",
59
+ ref: m,
60
+ ...r,
61
+ children: t ?? "Skjul meny"
62
+ }
63
+ );
64
+ }
65
+ ),
66
+ Main: p(function(t, r) {
67
+ return /* @__PURE__ */ o("main", { ref: r, ...t });
24
68
  }),
25
69
  Footer: p(
26
- function(r, t) {
27
- return /* @__PURE__ */ o("footer", { ref: t, ...r });
70
+ function(t, r) {
71
+ return /* @__PURE__ */ o("footer", { ref: r, ...t });
28
72
  }
29
73
  ),
30
74
  // Needed to avoid flash of unstyled content and still be Next.js hydration compatible
31
- Script: () => /* @__PURE__ */ o("script", { id: "mtds-app-script", children: m })
75
+ Script: () => /* @__PURE__ */ o("script", { id: "mtds-app-script", children: d })
32
76
  });
33
77
  export {
34
- y as App
78
+ X as App
35
79
  };
36
80
  //# sourceMappingURL=app.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn <dialog role=\"navigation\" ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"names":["AppComp","forwardRef","as","className","rest","ref","jsx","clsx","styles","AppSticky","App","script"],"mappings":";;;;;AAqBA,MAAMA,IAAUC,EAAiB,SAE/B,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAiBC,GAA0B;AAG9D,SAAA,gBAAAC,EAFKJ,KAAM,OAEN,EAAA,WAAWK,EAAKC,EAAO,KAAKL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AACzE,CAAC,GAEKK,IAAYR,EAAiB,SAEjC,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAiBC,GAA0B;AAG9D,SAAA,gBAAAC,EAFKJ,KAAM,OAEN,EAAA,WAAWK,EAAKC,EAAO,QAAQL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AAC5E,CAAC,GAEYM,IAAM,OAAO,OAAOV,GAAS;AAAA,EACzC,QAAQC;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAQ,gBAAAC,EAAA,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,IAAA;AAAA,EAErC;AAAA,EACA,SAASH;AAAA,IACR,SAAoBG,GAAMC,GAAK;AAC9B,+BAAQ,UAAO,EAAA,MAAK,cAAa,KAAAA,GAAW,GAAGD,GAAM;AAAA,IAAA;AAAA,EAEvD;AAAA,EACA,QAAQK;AAAA,EACR,MAAMR,EAAsC,SAAiBG,GAAMC,GAAK;AACvE,WAAQ,gBAAAC,EAAA,QAAA,EAAK,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,EAAA,CACjC;AAAA,EACD,QAAQH;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAQ,gBAAAC,EAAA,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,IAAA;AAAA,EAErC;AAAA;AAAA,EAEA,QAAQ,MAAM,gBAAAE,EAAC,UAAO,EAAA,IAAG,mBAAmB,UAAOK,EAAA,CAAA;AACpD,CAAC;"}
1
+ {"version":3,"file":"app.js","sources":["../../designsystem/app/app.tsx"],"sourcesContent":["import clsx from \"clsx\";\nimport { type JSX, forwardRef } from \"react\";\nimport { Button, type ButtonProps } from \"../react\";\nimport type {\n\tPolymorphicComponentPropWithRef,\n\tPolymorphicRef,\n} from \"../react-types\";\nimport styles from \"../styles.module.css\";\nimport script from \"./app-toggle.js?raw\";\n\nexport type AppHeaderProps = React.ComponentPropsWithoutRef<\"header\">;\nexport type AppSidebarProps = React.ComponentPropsWithoutRef<\"dialog\">;\nexport type AppStickyProps = React.ComponentPropsWithoutRef<\"div\">;\nexport type AppMainProps = React.ComponentPropsWithoutRef<\"main\">;\nexport type AppFooterProps = React.ComponentPropsWithoutRef<\"footer\">;\nexport type AppProps<As extends React.ElementType = \"div\"> =\n\tPolymorphicComponentPropWithRef<As>;\n\ntype AppComponent = <As extends React.ElementType = \"div\">(\n\tprops: AppProps<As>,\n) => JSX.Element;\n\nconst AppComp = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.app, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nconst AppSticky = forwardRef<null>(function App<\n\tAs extends React.ElementType = \"div\",\n>({ as, className, ...rest }: AppProps<As>, ref?: PolymorphicRef<As>) {\n\tconst Tag = as || \"div\";\n\n\treturn <Tag className={clsx(styles.sticky, className)} ref={ref} {...rest} />;\n}) as AppComponent; // Needed to tell Typescript this does not return ReactNode but acutally JSX.Element\n\nexport const App = Object.assign(AppComp, {\n\tHeader: forwardRef<HTMLElement, AppHeaderProps>(\n\t\tfunction AppHeader(rest, ref) {\n\t\t\treturn <header ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSidebar: forwardRef<HTMLDialogElement, AppSidebarProps>(\n\t\tfunction AppSidebar(rest, ref) {\n\t\t\treturn <dialog role=\"navigation\" ref={ref} {...rest} />;\n\t\t},\n\t),\n\tSticky: AppSticky,\n\tToggle: forwardRef<HTMLButtonElement, ButtonProps<\"button\">>(\n\t\tfunction AppToggle({ children, ...rest }: ButtonProps<\"button\">, ref) {\n\t\t\treturn (\n\t\t\t\t<Button\n\t\t\t\t\tdata-command=\"toggle-app-expanded\"\n\t\t\t\t\tdata-tooltip=\"Vis meny\"\n\t\t\t\t\tref={ref as React.Ref<HTMLAnchorElement>}\n\t\t\t\t\t{...rest}\n\t\t\t\t>\n\t\t\t\t\t{children ?? \"Skjul meny\"}\n\t\t\t\t</Button>\n\t\t\t);\n\t\t},\n\t),\n\tMain: forwardRef<HTMLElement, AppMainProps>(function AppMain(rest, ref) {\n\t\treturn <main ref={ref} {...rest} />;\n\t}),\n\tFooter: forwardRef<HTMLElement, AppFooterProps>(\n\t\tfunction AppFooter(rest, ref) {\n\t\t\treturn <footer ref={ref} {...rest} />;\n\t\t},\n\t),\n\t// Needed to avoid flash of unstyled content and still be Next.js hydration compatible\n\tScript: () => <script id=\"mtds-app-script\">{script}</script>,\n});\n"],"names":["AppComp","forwardRef","as","className","rest","ref","jsx","clsx","styles","AppSticky","App","children","Button","script"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAMA,IAAUC,EAAiB,SAE/B,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAiBC,GAA0B;AAG9D,SAAA,gBAAAC,EAFKJ,KAAM,OAEN,EAAA,WAAWK,EAAKC,EAAO,KAAKL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AACzE,CAAC,GAEKK,IAAYR,EAAiB,SAEjC,EAAE,IAAAC,GAAI,WAAAC,GAAW,GAAGC,EAAK,GAAiBC,GAA0B;AAG9D,SAAA,gBAAAC,EAFKJ,KAAM,OAEN,EAAA,WAAWK,EAAKC,EAAO,QAAQL,CAAS,GAAG,KAAAE,GAAW,GAAGD,EAAM,CAAA;AAC5E,CAAC,GAEYM,IAAM,OAAO,OAAOV,GAAS;AAAA,EACzC,QAAQC;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAQ,gBAAAC,EAAA,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,IAAA;AAAA,EAErC;AAAA,EACA,SAASH;AAAA,IACR,SAAoBG,GAAMC,GAAK;AAC9B,+BAAQ,UAAO,EAAA,MAAK,cAAa,KAAAA,GAAW,GAAGD,GAAM;AAAA,IAAA;AAAA,EAEvD;AAAA,EACA,QAAQK;AAAA,EACR,QAAQR;AAAA,IACP,SAAmB,EAAE,UAAAU,GAAU,GAAGP,EAAA,GAA+BC,GAAK;AAEpE,aAAA,gBAAAC;AAAA,QAACM;AAAA,QAAA;AAAA,UACA,gBAAa;AAAA,UACb,gBAAa;AAAA,UACb,KAAAP;AAAA,UACC,GAAGD;AAAA,UAEH,UAAYO,KAAA;AAAA,QAAA;AAAA,MACd;AAAA,IAAA;AAAA,EAGH;AAAA,EACA,MAAMV,EAAsC,SAAiBG,GAAMC,GAAK;AACvE,WAAQ,gBAAAC,EAAA,QAAA,EAAK,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,EAAA,CACjC;AAAA,EACD,QAAQH;AAAA,IACP,SAAmBG,GAAMC,GAAK;AAC7B,aAAQ,gBAAAC,EAAA,UAAA,EAAO,KAAAD,GAAW,GAAGD,EAAM,CAAA;AAAA,IAAA;AAAA,EAErC;AAAA;AAAA,EAEA,QAAQ,MAAM,gBAAAE,EAAC,UAAO,EAAA,IAAG,mBAAmB,UAAOO,EAAA,CAAA;AACpD,CAAC;"}
@@ -1,53 +1,53 @@
1
- var U = Object.defineProperty, L = Object.getOwnPropertySymbols, X = Object.prototype.hasOwnProperty, W = Object.prototype.propertyIsEnumerable, M = (t, e, o) => e in t ? U(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, Y = (t, e) => {
1
+ var X = Object.defineProperty, D = Object.getOwnPropertySymbols, W = Object.prototype.hasOwnProperty, Y = Object.prototype.propertyIsEnumerable, N = (t, e, o) => e in t ? X(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, z = (t, e) => {
2
2
  for (var o in e || (e = {}))
3
- X.call(e, o) && M(t, o, e[o]);
4
- if (L)
5
- for (var o of L(e))
6
- W.call(e, o) && M(t, o, e[o]);
3
+ W.call(e, o) && N(t, o, e[o]);
4
+ if (D)
5
+ for (var o of D(e))
6
+ Y.call(e, o) && N(t, o, e[o]);
7
7
  return t;
8
- }, E = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", R = E && /android/i.test(navigator.userAgent), z = E && /firefox/i.test(navigator.userAgent), G = E && /iPad|iPhone|iPod/.test(navigator.userAgent), D;
9
- E && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
10
- /^Mac/i.test(((D = navigator.userAgentData) == null ? void 0 : D.platform) || navigator.platform);
11
- var J = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", Q = typeof HTMLElement > "u" ? class {
8
+ }, w = typeof window < "u" && typeof window.document < "u" && typeof window.navigator < "u", H = w && /android/i.test(navigator.userAgent), G = w && /firefox/i.test(navigator.userAgent), J = w && /iPad|iPhone|iPod/.test(navigator.userAgent), R;
9
+ w && // @ts-expect-error Typescript has not implemented userAgentData yet https://stackoverflow.com/a/71392474
10
+ /^Mac/i.test(((R = navigator.userAgentData) == null ? void 0 : R.platform) || navigator.platform);
11
+ var Q = "outline: 1px dotted; outline: 5px auto Highlight; outline: 5px auto -webkit-focus-ring-color", Z = typeof HTMLElement > "u" ? class {
12
12
  } : HTMLElement;
13
- function l(t, e, o) {
13
+ function u(t, e, o) {
14
14
  return o === void 0 ? t.getAttribute(e) : (o === null ? t.removeAttribute(e) : t.getAttribute(e) !== o && t.setAttribute(e, o), null);
15
15
  }
16
- var H = (t, e, o) => {
17
- for (const a of o[0].split(","))
18
- o[0] = a, Element.prototype[`${t}EventListener`].apply(e, o);
19
- }, O = (t, ...e) => H("add", t, e), Z = (t, ...e) => H("remove", t, e), w = /* @__PURE__ */ new WeakMap(), N = (t, e) => {
20
- if (e === void 0) return w.get(t);
16
+ var B = (t, e, o) => {
17
+ for (const n of o[0].split(","))
18
+ o[0] = n, Element.prototype[`${t}EventListener`].apply(e, o);
19
+ }, A = (t, ...e) => B("add", t, e), tt = (t, ...e) => B("remove", t, e), x = /* @__PURE__ */ new WeakMap(), O = (t, e) => {
20
+ if (e === void 0) return x.get(t);
21
21
  try {
22
- w.get(t).disconnect(), w.delete(t);
22
+ x.get(t).disconnect(), x.delete(t);
23
23
  } catch {
24
24
  }
25
25
  if (e) {
26
26
  const o = new MutationObserver(
27
- (a) => t.handleEvent({ type: "mutation", detail: a })
27
+ (n) => t.handleEvent({ type: "mutation", detail: n })
28
28
  );
29
- o.observe(t, e), w.set(t, o);
29
+ o.observe(t, e), x.set(t, o);
30
30
  }
31
- }, tt = (t) => {
31
+ }, et = (t) => {
32
32
  const e = "key" in t && (t.key === " " || t.key === "Enter");
33
33
  return e && t.preventDefault(), e && t.target instanceof HTMLElement && t.target.click(), e;
34
- }, et = (t) => {
34
+ }, ot = (t) => {
35
35
  var e;
36
36
  const o = ((e = t.getRootNode) == null ? void 0 : e.call(t)) || t.ownerDocument;
37
37
  return o instanceof Document || o instanceof ShadowRoot ? o : document;
38
- }, ot = 0, it = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++ot).toString(32)}`), t.id) : "", C = (t, e, o) => {
39
- const a = document.createElement(t);
40
- if (e && (a.textContent = e), o) for (const [i, r] of Object.entries(o)) l(a, i, r);
41
- return a;
42
- }, nt = {
43
- define: (t, e) => !E || window.customElements.get(t) || window.customElements.define(t, e)
44
- }, b, at = 0, $ = (t) => {
45
- b || (b = C("div"), b.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", l(b, "aria-live", "assertive")), b.isConnected || document.body.append(b), t && (b.textContent = `${t}${at++ % 2 ? " " : ""}`);
46
- }, B = (t, e, o = "") => {
47
- var a, i;
48
- const r = { bubbles: !0, composed: !0, data: e, inputType: o }, n = HTMLInputElement.prototype;
49
- t.dispatchEvent(new InputEvent("beforeinput", r)), (i = (a = Object.getOwnPropertyDescriptor(n, "value")) == null ? void 0 : a.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", r)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
50
- }, S = !1, P = "beforeinput,blur,focus,click,input,keydown,mousedown,mouseup", F = { once: !0, passive: !0 }, rt = z && !R, lt = R || G, x = "false", st = "insertReplacementText", k = {
38
+ }, it = 0, nt = (t) => t ? (t.id || (t.id = `:${t.nodeName.toLowerCase()}${(++it).toString(32)}`), t.id) : "", I = (t, e, o) => {
39
+ const n = document.createElement(t);
40
+ if (e && (n.textContent = e), o) for (const [i, a] of Object.entries(o)) u(n, i, a);
41
+ return n;
42
+ }, at = {
43
+ define: (t, e) => !w || window.customElements.get(t) || window.customElements.define(t, e)
44
+ }, b, rt = 0, L = (t) => {
45
+ b || (b = I("div"), b.style.cssText = "position:fixed;overflow:hidden;width:1px;white-space:nowrap", u(b, "aria-live", "assertive")), b.isConnected || document.body.append(b), t && (b.textContent = `${t}${rt++ % 2 ? " " : ""}`);
46
+ }, F = (t, e, o = "") => {
47
+ var n, i;
48
+ const a = { bubbles: !0, composed: !0, data: e, inputType: o }, r = HTMLInputElement.prototype;
49
+ t.dispatchEvent(new InputEvent("beforeinput", a)), (i = (n = Object.getOwnPropertyDescriptor(r, "value")) == null ? void 0 : n.set) == null || i.call(t, e), t.dispatchEvent(new InputEvent("input", a)), t.dispatchEvent(new Event("change", { bubbles: !0 }));
50
+ }, $ = !1, P = "beforeinput,blur,focus,click,input,keydown,mousedown,mouseup", V = { once: !0, passive: !0 }, lt = G && !H, st = H || J, k = "false", ut = "insertReplacementText", C = {
51
51
  added: "Added",
52
52
  empty: "No selected",
53
53
  found: "Navigate left to find %d selected",
@@ -55,12 +55,12 @@ var H = (t, e, o) => {
55
55
  of: "of",
56
56
  remove: "Press to remove",
57
57
  removed: "Removed"
58
- }, ut = class extends Q {
58
+ }, ct = class extends Z {
59
59
  constructor() {
60
- super(), this._speak = "", this._texts = Y({}, k), this._value = "", this.attachShadow({ mode: "open" }).append(
61
- C("slot"),
60
+ super(), this._speak = "", this._texts = z({}, C), this._value = "", this.attachShadow({ mode: "open" }).append(
61
+ I("slot"),
62
62
  // Content slot
63
- C(
63
+ I(
64
64
  "style",
65
65
  `:host(:not([hidden])) { display: block; cursor: pointer; -webkit-tap-highlight-color: rgba(0, 0, 0, 0) } /* Must be display block in Safari to allow focus inside */
66
66
  :host(:not([data-multiple])) ::slotted(data),
@@ -69,42 +69,42 @@ var H = (t, e, o) => {
69
69
  ::slotted(del) { text-decoration: none }
70
70
  ::slotted(data:not([hidden])) { display: inline-block; pointer-events: none }
71
71
  ::slotted(data)::after { content: '\\00D7'; content: '\\00D7' / ''; padding-inline: .5ch; pointer-events: auto }
72
- ::slotted(data:focus) { ${J} }`
72
+ ::slotted(data:focus) { ${Q} }`
73
73
  )
74
74
  );
75
75
  }
76
76
  // Locally store value to store value before input-click
77
77
  // Using ES2015 syntax for backwards compatibility
78
78
  static get observedAttributes() {
79
- return Object.keys(k).map((t) => `data-sr-${t}`);
79
+ return Object.keys(C).map((t) => `data-sr-${t}`);
80
80
  }
81
81
  connectedCallback() {
82
- this._root = et(this), O(this, P, this, !0), N(this, { childList: !0 }), setTimeout(I, 0, this), setTimeout(A, 0, this);
82
+ this._root = ot(this), A(this, P, this, !0), O(this, { childList: !0, subtree: !0 }), setTimeout(T, 0, this), setTimeout(M, 0, this);
83
83
  }
84
84
  attributeChangedCallback(t, e, o) {
85
- const a = t.split("data-sr-")[1];
86
- k[a] && (this._texts[a] = o || k[a]);
85
+ const n = t.split("data-sr-")[1];
86
+ C[n] && (this._texts[n] = o || C[n]);
87
87
  }
88
88
  disconnectedCallback() {
89
- N(this, !1), Z(this, P, this, !0), this._items = this._clear = this._focus = this._control = void 0, this._list = this._options = this._root = void 0;
89
+ O(this, !1), tt(this, P, this, !0), this._items = this._clear = this._focus = this._control = void 0, this._list = this._options = this._root = void 0;
90
90
  }
91
91
  handleEvent(t) {
92
92
  const e = t.target;
93
- t.type === "beforeinput" && (this._value = (e == null ? void 0 : e.value) || ""), t.type === "blur" && dt(this), t.type === "click" && vt(this, t), t.type === "focus" && ct(this, t), t.type === "input" && ft(this, t), t.type === "keydown" && mt(this, t), t.type === "mousedown" && (S = this.contains(e)), t.type === "mouseup" && (S = !1), t.type === "mutation" && I(this, t);
93
+ t.type === "beforeinput" && (this._value = (e == null ? void 0 : e.value) || ""), t.type === "blur" && pt(this), t.type === "click" && ft(this, t), t.type === "focus" && dt(this, t), t.type === "input" && mt(this, t), t.type === "keydown" && ht(this, t), t.type === "mousedown" && ($ = this.contains(e)), t.type === "mouseup" && ($ = !1), t.type === "mutation" && T(this, t);
94
94
  }
95
95
  get multiple() {
96
96
  var t;
97
- return ((t = l(this, "data-multiple")) != null ? t : x) !== x;
97
+ return ((t = u(this, "data-multiple")) != null ? t : k) !== k;
98
98
  }
99
99
  set multiple(t) {
100
- l(this, "data-multiple", t ? "" : null);
100
+ u(this, "data-multiple", t ? "" : null);
101
101
  }
102
102
  get creatable() {
103
103
  var t;
104
- return ((t = l(this, "data-creatable")) != null ? t : x) !== x;
104
+ return ((t = u(this, "data-creatable")) != null ? t : k) !== k;
105
105
  }
106
106
  set creatable(t) {
107
- l(this, "data-creatable", t ? "" : null);
107
+ u(this, "data-creatable", t ? "" : null);
108
108
  }
109
109
  get control() {
110
110
  var t;
@@ -132,111 +132,111 @@ var H = (t, e, o) => {
132
132
  get values() {
133
133
  return [...this.items].map(({ value: t }) => t);
134
134
  }
135
- }, g = (t) => {
135
+ }, y = (t) => {
136
136
  var e;
137
137
  return ((e = t == null ? void 0 : t.textContent) == null ? void 0 : e.trim()) || "";
138
- }, T = (t) => t instanceof HTMLDataElement, I = (t, e) => {
139
- var o;
140
- const { _focus: a, _texts: i, items: r, control: n, list: d, multiple: s } = t;
141
- let c = `${g((o = n == null ? void 0 : n.labels) == null ? void 0 : o[0])}, ${s ? r.length ? i.found.replace("%d", `${r.length}`) : i.empty : ""}`;
142
- const p = [];
143
- for (const { addedNodes: f, removedNodes: h } of (e == null ? void 0 : e.detail) || []) {
144
- for (const m of f) T(m) && p.unshift(m);
145
- for (const m of h) T(m) && p.push(m);
146
- }
147
- const u = s ? p.length === 1 : p[0] === a;
148
- if (a && n && u) {
149
- const f = l(n, "inputmode"), h = T(a) ? n : a;
150
- t._speak = `${i[p[0].isConnected ? "added" : "removed"]} ${g(p[0])}, `, (lt || a === n) && $(t._speak), n !== h && (l(n, "aria-expanded", null), l(n, "inputmode", "none"), c = " ", n.focus()), setTimeout(() => {
151
- var m;
152
- l(n, "aria-expanded", "true"), l(n, "inputmode", f), (m = h == null ? void 0 : h.focus) == null || m.call(h), t._speak = "", rt ? O(t, "blur", () => I(t), F) : setTimeout(I, 100, t);
138
+ }, S = (t) => t instanceof HTMLDataElement, T = (t, e) => {
139
+ var o, n;
140
+ const { _focus: i, _texts: a, items: r, control: l, list: d, multiple: c } = t;
141
+ let v = `${y((o = l == null ? void 0 : l.labels) == null ? void 0 : o[0])}, ${c ? r.length ? a.found.replace("%d", `${r.length}`) : a.empty : ""}`;
142
+ const s = [];
143
+ for (const { addedNodes: p, removedNodes: h } of (e == null ? void 0 : e.detail) || []) {
144
+ for (const f of p) S(f) && s.unshift(f);
145
+ for (const f of h) S(f) && s.push(f);
146
+ }
147
+ const _ = c ? s.length === 1 : s[0] === i;
148
+ if (i && l && _) {
149
+ const p = u(l, "inputmode"), h = S(i) ? l : i;
150
+ t._speak = `${a[s[0].isConnected ? "added" : "removed"]} ${y(s[0])}, `, (st || i === l) && L(t._speak), l !== h && (u(l, "aria-expanded", null), u(l, "inputmode", "none"), v = " ", l.focus()), setTimeout(() => {
151
+ var f;
152
+ u(l, "aria-expanded", "true"), u(l, "inputmode", p), (f = h == null ? void 0 : h.focus) == null || f.call(h), t._speak = "", lt ? A(t, "blur", () => T(t), V) : setTimeout(T, 100, t);
153
153
  }, 100);
154
154
  }
155
- let _ = 0;
156
- for (const f of r) {
157
- const h = g(f), m = f.value || h, K = `${t._speak}${h}, ${i.remove}, ${++_} ${i.of} ${r.length}`;
158
- l(f, "role", "button"), l(f, "value", m), l(f, "tabindex", "-1"), l(f, "aria-label", K);
155
+ let m = 0;
156
+ for (const p of r) {
157
+ const h = y(p), f = p.value || h, U = `${t._speak}${h}, ${a.remove}, ${++m} ${a.of} ${r.length}`;
158
+ u(p, "role", "button"), u(p, "value", f), u(p, "tabindex", "-1"), u(p, "aria-label", U);
159
159
  }
160
- !s && _ > 1 && console.warn("u-combobox: Multiple <data> found in single mode."), d && l(d, "aria-multiselectable", `${s}`), n && l(n, "list", it(d)), n && l(n, "aria-label", `${t._speak}${c}`);
161
- const v = t.querySelector("select");
162
- v && (v.multiple = s), v && (v.textContent = ""), v == null || v.append(...t.values.map((f) => new Option(f, f, !0, !0))), V(t), j(t);
163
- }, V = (t) => {
164
- var e;
165
- t.clear && l(t.clear, "role", "button"), t.clear && (t.clear.hidden = !((e = t.control) != null && e.value));
160
+ !c && m > 1 && console.warn("u-combobox: Multiple <data> found in single mode."), d && u(d, "aria-multiselectable", `${c}`), l && u(l, "list", nt(d)), l && u(l, "aria-label", `${t._speak}${v}`);
161
+ const g = t.querySelector("select");
162
+ g && (g.multiple = c), g && (g.textContent = ""), g == null || g.append(...t.values.map((p) => new Option(p, p, !0, !0))), j(t), q(t), (n = O(t)) == null || n.takeRecords();
166
163
  }, j = (t) => {
167
164
  var e;
168
- const { _speak: o, options: a = [], values: i } = t;
169
- for (const r of a) {
170
- const n = (e = l(r, "value")) != null ? e : g(r);
171
- l(r, "aria-label", o ? `${o}${g(r)}` : null), l(r, "selected", i.includes(n) ? "" : null);
172
- }
173
- }, A = (t) => {
174
- const { multiple: e, control: o, items: a } = t, i = g(a[0]);
175
- !e && o && i !== o.value && B(o, i, "insertText");
176
- }, q = (t, e = !0) => {
165
+ t.clear && u(t.clear, "role", "button"), t.clear && (t.clear.hidden = !((e = t.control) != null && e.value));
166
+ }, q = (t) => {
167
+ var e;
168
+ const { _speak: o, options: n = [], values: i } = t;
169
+ for (const a of n) {
170
+ const r = (e = u(a, "value")) != null ? e : y(a);
171
+ u(a, "aria-label", o ? `${o}${y(a)}` : null), u(a, "selected", i.includes(r) ? "" : null);
172
+ }
173
+ }, M = (t) => {
174
+ const { multiple: e, control: o, items: n } = t, i = y(n[0]);
175
+ !e && o && i !== o.value && F(o, i, "insertText");
176
+ }, K = (t, e = !0) => {
177
177
  var o;
178
- const { _texts: a, options: i = [], creatable: r, control: n, items: d, multiple: s } = t, c = ((o = n == null ? void 0 : n.value) == null ? void 0 : o.trim()) || "", p = c.toLowerCase() || null;
179
- let u = [...i].find((v) => v.label.trim().toLowerCase() === p);
180
- const _ = { bubbles: !0, cancelable: !0, detail: u };
178
+ const { _texts: n, options: i = [], creatable: a, control: r, items: l, multiple: d } = t, c = ((o = r == null ? void 0 : r.value) == null ? void 0 : o.trim()) || "", v = c.toLowerCase() || null;
179
+ let s = [...i].find((m) => m.label.trim().toLowerCase() === v);
180
+ const _ = { bubbles: !0, cancelable: !0, detail: s };
181
181
  if (t.dispatchEvent(new CustomEvent("beforematch", _)))
182
- for (const v of i) v.selected = v === u;
183
- if (u = [...i].find((v) => v.selected), j(t), u) return y(t, u, !1, !!e);
184
- if (r && c) return y(t, { value: c }, !1);
185
- !s && d[0] && y(t, d[0], !0, !1), e && $(a.invalid);
186
- }, y = (t, e, o = !0, a = !0) => {
187
- const { control: i, items: r, multiple: n } = t, d = C("data", e.label || e.value, {
182
+ for (const m of i) m.selected = m === s;
183
+ if (s = [...i].find((m) => m.selected), q(t), s) return E(t, s, !1, !!e);
184
+ if (a && c) return E(t, { value: c }, !1);
185
+ !d && l[0] && E(t, l[0], !0, !1), e && L(n.invalid);
186
+ }, E = (t, e, o = !0, n = !0) => {
187
+ const { control: i, items: a, multiple: r } = t, l = I("data", e.label || e.value, {
188
188
  value: e.value
189
- }), s = [...r].find((u) => u.value === e.value), c = { bubbles: !0, cancelable: !0, detail: s || d };
190
- if (!(s && !o) && t.dispatchEvent(new CustomEvent("beforechange", c))) {
191
- if (!n) for (const u of [...r]) u.remove();
192
- s ? s.remove() : i == null || i.insertAdjacentElement("beforebegin", d), t.dispatchEvent(new CustomEvent("afterchange", c));
193
- }
194
- a && setTimeout(A, 10, t);
195
- }, ct = (t, { target: e }) => {
196
- e instanceof HTMLElement && (t._focus = e), $();
197
- }, dt = (t) => S || setTimeout(pt, 0, t), pt = (t) => {
189
+ }), d = [...a].find((s) => s.value === e.value), c = { bubbles: !0, cancelable: !0, detail: d || l };
190
+ if (!(d && !o) && t.dispatchEvent(new CustomEvent("beforechange", c))) {
191
+ if (!r) for (const s of [...a]) s.remove();
192
+ d ? d.remove() : i == null || i.insertAdjacentElement("beforebegin", l), t.dispatchEvent(new CustomEvent("afterchange", c));
193
+ }
194
+ n && setTimeout(M, 10, t);
195
+ }, dt = (t, { target: e }) => {
196
+ e instanceof HTMLElement && (t._focus = e), L();
197
+ }, pt = (t) => $ || setTimeout(vt, 0, t), vt = (t) => {
198
198
  var e;
199
- !t._focus || t.contains((e = t._root) == null ? void 0 : e.activeElement) || A(t);
200
- }, vt = (t, e) => {
201
- const { clientX: o, clientY: a, target: i } = e, { clear: r, control: n, items: d } = t;
202
- if (r != null && r.contains(i))
203
- return n && B(n, "", "deleteContentBackward"), n == null ? void 0 : n.focus();
204
- for (const s of d) {
205
- const { top: c, right: p, bottom: u, left: _ } = s.getBoundingClientRect();
206
- if (s.contains(i)) return y(t, s);
207
- if (a >= c && a <= u && o >= _ && o <= p) return s.focus();
208
- }
209
- i === t && (n == null || n.focus());
199
+ !t._focus || t.contains((e = t._root) == null ? void 0 : e.activeElement) || M(t);
210
200
  }, ft = (t, e) => {
201
+ const { clientX: o, clientY: n, target: i } = e, { clear: a, control: r, items: l } = t;
202
+ if (a != null && a.contains(i))
203
+ return r && F(r, "", "deleteContentBackward"), r == null ? void 0 : r.focus();
204
+ for (const d of l) {
205
+ const { top: c, right: v, bottom: s, left: _ } = d.getBoundingClientRect();
206
+ if (d.contains(i)) return E(t, d);
207
+ if (n >= c && n <= s && o >= _ && o <= v) return d.focus();
208
+ }
209
+ i === t && (r == null || r.focus());
210
+ }, mt = (t, e) => {
211
211
  var o;
212
- const { options: a = [], control: i, multiple: r } = t, n = ((o = i == null ? void 0 : i.value) == null ? void 0 : o.trim()) || "";
213
- if (e instanceof InputEvent ? !e.inputType || e.inputType === st : !!n) {
212
+ const { options: n = [], control: i, multiple: a } = t, r = ((o = i == null ? void 0 : i.value) == null ? void 0 : o.trim()) || "";
213
+ if (e instanceof InputEvent ? !e.inputType || e.inputType === ut : !!r) {
214
214
  e.stopImmediatePropagation(), i && (i.value = t._value);
215
- for (const s of a)
216
- if (s.value && s.value === n)
217
- return y(t, s, r);
218
- } else r || q(t, !1);
219
- V(t);
220
- }, mt = (t, e) => {
215
+ for (const d of n)
216
+ if (d.value && d.value === r)
217
+ return E(t, d, a);
218
+ } else a || K(t, !1);
219
+ j(t);
220
+ }, ht = (t, e) => {
221
221
  var o;
222
222
  if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) return;
223
- const { clear: a, control: i, items: r } = t, { key: n, repeat: d, target: s } = e, c = i && i === s, p = c && (i == null ? void 0 : i.selectionEnd);
224
- let u = c ? r.length : [...r].indexOf(s);
225
- if (c && n === "Tab" && a && !a.hidden && (e.preventDefault(), a.tabIndex = -1, a.focus(), O(a, "blur", () => l(a, "tabindex", null), F)), !(!c && tt(e) || u === -1)) {
226
- if (n === "ArrowRight" && !c) u += 1;
227
- else if (n === "ArrowLeft" && !p) u -= 1;
228
- else if (n === "Enter" && c) {
229
- const _ = l(i, "form");
230
- return l(i, "form", "#"), requestAnimationFrame(() => l(i, "form", _)), q(t);
231
- } else if ((n === "Backspace" || n === "Delete") && !p) {
232
- if (e.preventDefault(), !d && r[u]) return y(t, r[u]);
233
- c && (u -= 1);
223
+ const { clear: n, control: i, items: a } = t, { key: r, repeat: l, target: d } = e, c = i && i === d, v = c && (i == null ? void 0 : i.selectionEnd);
224
+ let s = c ? a.length : [...a].indexOf(d);
225
+ if (c && r === "Tab" && n && !n.hidden && (e.preventDefault(), n.tabIndex = -1, n.focus(), A(n, "blur", () => u(n, "tabindex", null), V)), !(!c && et(e) || s === -1)) {
226
+ if (r === "ArrowRight" && !c) s += 1;
227
+ else if (r === "ArrowLeft" && !v) s -= 1;
228
+ else if (r === "Enter" && c) {
229
+ const _ = u(i, "form");
230
+ return u(i, "form", "#"), requestAnimationFrame(() => u(i, "form", _)), K(t);
231
+ } else if ((r === "Backspace" || r === "Delete") && !v) {
232
+ if (e.preventDefault(), !l && a[s]) return E(t, a[s]);
233
+ c && (s -= 1);
234
234
  } else return c || (i == null ? void 0 : i.focus());
235
- e.preventDefault(), (o = r[Math.max(0, u)] || i) == null || o.focus();
235
+ e.preventDefault(), (o = a[Math.max(0, s)] || i) == null || o.focus();
236
236
  }
237
237
  };
238
- nt.define("u-combobox", ut);
238
+ at.define("u-combobox", ct);
239
239
  export {
240
- ut as UHTMLComboboxElement
240
+ ct as UHTMLComboboxElement
241
241
  };
242
242
  //# sourceMappingURL=u-combobox.js.map