@mattilsynet/design 0.0.9 → 0.0.11

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.
@@ -0,0 +1,67 @@
1
+ /*! NanoPop 2.4.2 MIT | https://github.com/Simonwep/nanopop */
2
+ const T = {
3
+ variantFlipOrder: { start: "sme", middle: "mse", end: "ems" },
4
+ positionFlipOrder: { top: "tbrl", right: "rltb", bottom: "btrl", left: "lrbt" },
5
+ position: "bottom",
6
+ margin: 8,
7
+ padding: 0
8
+ }, V = (F, o, O) => {
9
+ const {
10
+ container: $,
11
+ arrow: d,
12
+ margin: s,
13
+ padding: b,
14
+ position: B,
15
+ variantFlipOrder: C,
16
+ positionFlipOrder: R
17
+ } = {
18
+ container: document.documentElement.getBoundingClientRect(),
19
+ ...T,
20
+ ...O
21
+ }, { left: E, top: j } = o.style;
22
+ o.style.left = "0", o.style.top = "0";
23
+ const t = F.getBoundingClientRect(), e = o.getBoundingClientRect(), k = {
24
+ t: t.top - e.height - s,
25
+ b: t.bottom + s,
26
+ r: t.right + s,
27
+ l: t.left - e.width - s
28
+ }, q = {
29
+ vs: t.left,
30
+ vm: t.left + t.width / 2 - e.width / 2,
31
+ ve: t.left + t.width - e.width,
32
+ hs: t.top,
33
+ hm: t.bottom - t.height / 2 - e.height / 2,
34
+ he: t.bottom - e.height
35
+ }, [z, A = "middle"] = B.split("-"), D = R[z], G = C[A], { top: u, left: w, bottom: y, right: v } = $;
36
+ for (const l of D) {
37
+ const i = l === "t" || l === "b";
38
+ let n = k[l];
39
+ const [p, g] = i ? ["top", "left"] : ["left", "top"], [f, m] = i ? [e.height, e.width] : [e.width, e.height], [H, I] = i ? [y, v] : [v, y], [J, K] = i ? [u, w] : [w, u];
40
+ if (!(n < J || n + f + b > H))
41
+ for (const a of G) {
42
+ let r = q[(i ? "v" : "h") + a];
43
+ if (!(r < K || r + m + b > I)) {
44
+ if (r -= e[g], n -= e[p], o.style[g] = `${r}px`, o.style[p] = `${n}px`, d) {
45
+ const c = i ? t.width / 2 : t.height / 2, h = m / 2, x = c > h, L = {
46
+ s: x ? h : c,
47
+ m: h,
48
+ e: x ? h : m - c
49
+ }, M = {
50
+ t: f,
51
+ b: 0,
52
+ r: 0,
53
+ l: f
54
+ }, P = r + L[a], S = n + M[l];
55
+ d.style[g] = `${P}px`, d.style[p] = `${S}px`;
56
+ }
57
+ return l + a;
58
+ }
59
+ }
60
+ }
61
+ return o.style.left = E, o.style.top = j, null;
62
+ };
63
+ export {
64
+ T as defaults,
65
+ V as reposition
66
+ };
67
+ //# sourceMappingURL=nanopop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanopop.js","sources":["../../../../node_modules/nanopop/dist/nanopop.mjs"],"sourcesContent":["/*! NanoPop 2.4.2 MIT | https://github.com/Simonwep/nanopop */\nconst N = \"2.4.2\", I = {\n variantFlipOrder: { start: \"sme\", middle: \"mse\", end: \"ems\" },\n positionFlipOrder: { top: \"tbrl\", right: \"rltb\", bottom: \"btrl\", left: \"lrbt\" },\n position: \"bottom\",\n margin: 8,\n padding: 0\n}, J = (n, i, m) => {\n const {\n container: r,\n arrow: a,\n margin: e,\n padding: l,\n position: V,\n variantFlipOrder: C,\n positionFlipOrder: M\n } = {\n container: document.documentElement.getBoundingClientRect(),\n ...I,\n ...m\n }, { left: F, top: K } = i.style;\n i.style.left = \"0\", i.style.top = \"0\";\n const t = n.getBoundingClientRect(), o = i.getBoundingClientRect(), P = {\n t: t.top - o.height - e,\n b: t.bottom + e,\n r: t.right + e,\n l: t.left - o.width - e\n }, R = {\n vs: t.left,\n vm: t.left + t.width / 2 - o.width / 2,\n ve: t.left + t.width - o.width,\n hs: t.top,\n hm: t.bottom - t.height / 2 - o.height / 2,\n he: t.bottom - o.height\n }, [$, E = \"middle\"] = V.split(\"-\"), L = M[$], j = C[E], { top: y, left: x, bottom: B, right: O } = r;\n for (const c of L) {\n const s = c === \"t\" || c === \"b\";\n let p = P[c];\n const [d, g] = s ? [\"top\", \"left\"] : [\"left\", \"top\"], [u, v] = s ? [o.height, o.width] : [o.width, o.height], [z, T] = s ? [B, O] : [O, B], [H, k] = s ? [y, x] : [x, y];\n if (!(p < H || p + u + l > z))\n for (const b of j) {\n let f = R[(s ? \"v\" : \"h\") + b];\n if (!(f < k || f + v + l > T)) {\n if (f -= o[g], p -= o[d], i.style[g] = `${f}px`, i.style[d] = `${p}px`, a) {\n const w = s ? t.width / 2 : t.height / 2, h = v / 2, S = w > h, q = {\n s: S ? h : w,\n m: h,\n e: S ? h : v - w\n }, A = {\n t: u,\n b: 0,\n r: 0,\n l: u\n }, D = f + q[b], G = p + A[c];\n a.style[g] = `${D}px`, a.style[d] = `${G}px`;\n }\n return c + b;\n }\n }\n }\n return i.style.left = F, i.style.top = K, null;\n}, Q = (n, i, m) => {\n const r = typeof n == \"object\" && !(n instanceof HTMLElement) ? n : { reference: n, popper: i, ...m };\n return {\n /**\n * Repositions the current popper.\n * @param options Optional options which get merged with the current ones.\n */\n update(a = r) {\n const { reference: e, popper: l } = Object.assign(r, a);\n if (!l || !e)\n throw new Error(\"Popper- or reference-element missing.\");\n return J(e, l, r);\n }\n };\n};\nexport {\n Q as createPopper,\n I as defaults,\n J as reposition,\n N as version\n};\n//# sourceMappingURL=nanopop.mjs.map\n"],"names":["I","J","n","i","m","r","a","e","l","V","M","F","K","o","P","R","$","E","L","j","y","x","B","O","c","s","p","d","u","v","z","T","H","k","b","f","w","S","q","A","D","G"],"mappings":"AAAA;AACK,MAAcA,IAAI;AAAA,EACrB,kBAAkB,EAAE,OAAO,OAAO,QAAQ,OAAO,KAAK,MAAO;AAAA,EAC7D,mBAAmB,EAAE,KAAK,QAAQ,OAAO,QAAQ,QAAQ,QAAQ,MAAM,OAAQ;AAAA,EAC/E,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AACX,GAAGC,IAAI,CAACC,GAAGC,GAAGC,MAAM;AAClB,QAAM;AAAA,IACJ,WAAWC;AAAA,IACX,OAAOC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;AAC5C;","x_google_ignoreList":[0]}
package/mtds/index.d.ts CHANGED
@@ -1,3 +1,17 @@
1
- export * as styles from './styles.module.css.js';
1
+ export declare const styles: {
2
+ alert: string;
3
+ breadcrumbs: string;
4
+ button: string;
5
+ details: string;
6
+ field: string;
7
+ fieldset: string;
8
+ autolayout: string;
9
+ input: string;
10
+ link: string;
11
+ logo: string;
12
+ popover: string;
13
+ validation: string;
14
+ body: string;
15
+ };
2
16
  export declare function observe(el: Element): void;
3
17
  export declare function unobserve(el: Element): void;
@@ -0,0 +1,4 @@
1
+ var mtds=function(a){"use strict";const L="_alert_1h1lt_1 _ds-alert_bbrk4_1",k="_breadcrumbs_1h1lt_1 _ds-breadcrumbs_bbrk4_1",M="_button_1h1lt_1 _ds-button_bbrk4_1",R="_details_1h1lt_1 _ds-details_bbrk4_1",C="_field_1h1lt_1 _ds-field_bbrk4_1",F="_fieldset_1h1lt_1 _ds-fieldset_bbrk4_1",I="_autolayout_1h1lt_1",T="_input_1h1lt_1 _ds-input_bbrk4_1",P="_link_1h1lt_1",A="_logo_1h1lt_1 _ds-focus_bbrk4_1",B="_popover_1h1lt_1",N="_validation_1h1lt_1",D="_body_1h1lt_50",_={alert:L,breadcrumbs:k,button:M,details:R,field:C,fieldset:F,autolayout:I,input:T,link:P,logo:A,popover:B,validation:N,body:D},Q=Object.freeze(Object.defineProperty({__proto__:null,alert:L,autolayout:I,body:D,breadcrumbs:k,button:M,default:_,details:R,field:C,fieldset:F,input:T,link:P,logo:A,popover:B,validation:N},Symbol.toStringTag,{value:"Module"})),H=typeof window<"u"&&typeof document<"u";let X=0;const Y=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function p(t){return t.id||(t.id=`${Y}${++X}`),t.id}function Z(t){const e=[],n=new MutationObserver(o=>{e[0]||requestAnimationFrame(i),e.push(...o)}),i=()=>{t(e,n),e.length=0};return n}const j=(t,e,n)=>{for(const i of n[0].split(","))n[0]=i,Element.prototype[`${t}EventListener`].apply(e,n)},m=(t,...e)=>j("add",t,e),g=(t,...e)=>j("remove",t,e),tt=_.field.split(" ")[0],et=_.validation.split(" ")[0],v=new WeakMap;function z(t){for(const e of t){const n=[],i=[];let o=null,d=!0;for(const s of e.getElementsByTagName("*"))s instanceof HTMLLabelElement?n.push(s):"validity"in s&&!(s instanceof HTMLButtonElement)?o=s:s.classList.contains(et)?(d=s.getAttribute("data-color")==="success",i.unshift(p(s))):s instanceof HTMLParagraphElement&&i.push(p(s));if(o)for(const s of n)s.htmlFor=p(o);o==null||o.setAttribute("aria-describedby",i.join(" ")),o==null||o.setAttribute("aria-invalid",`${!d}`)}}H&&q(document.body);function q(t){if(v.has(t))return;const e=t.getElementsByClassName(tt),n=Z(()=>z(e));n.observe(t,{attributeFilter:["class"],attributes:!0,childList:!0,subtree:!0}),z(e),v.set(t,n)}function ot(t){var e;(e=v.get(t))==null||e.disconnect()}/*! NanoPop 2.4.2 MIT | https://github.com/Simonwep/nanopop */const nt={variantFlipOrder:{start:"sme",middle:"mse",end:"ems"},positionFlipOrder:{top:"tbrl",right:"rltb",bottom:"btrl",left:"lrbt"},position:"bottom",margin:8,padding:0},it=(t,e,n)=>{const{container:i,arrow:o,margin:d,padding:s,position:ft,variantFlipOrder:bt,positionFlipOrder:_t}={container:document.documentElement.getBoundingClientRect(),...nt,...n},{left:ht,top:pt}=e.style;e.style.left="0",e.style.top="0";const r=t.getBoundingClientRect(),l=e.getBoundingClientRect(),mt={t:r.top-l.height-d,b:r.bottom+d,r:r.right+d,l:r.left-l.width-d},gt={vs:r.left,vm:r.left+r.width/2-l.width/2,ve:r.left+r.width-l.width,hs:r.top,hm:r.bottom-r.height/2-l.height/2,he:r.bottom-l.height},[vt,yt="middle"]=ft.split("-"),wt=_t[vt],Ot=bt[yt],{top:x,left:J,bottom:U,right:G}=i;for(const u of wt){const c=u==="t"||u==="b";let f=mt[u];const[y,w]=c?["top","left"]:["left","top"],[O,S]=c?[l.height,l.width]:[l.width,l.height],[St,Et]=c?[U,G]:[G,U],[$t,Lt]=c?[x,J]:[J,x];if(!(f<$t||f+O+s>St))for(const E of Ot){let b=gt[(c?"v":"h")+E];if(!(b<Lt||b+S+s>Et)){if(b-=l[w],f-=l[y],e.style[w]=`${b}px`,e.style[y]=`${f}px`,o){const $=c?r.width/2:r.height/2,h=S/2,K=$>h,kt={s:K?h:$,m:h,e:K?h:S-$},Mt={t:O,b:0,r:0,l:O},Rt=b+kt[E],Ct=f+Mt[u];o.style[w]=`${Rt}px`,o.style[y]=`${Ct}px`}return u+E}}}return e.style.left=ht,e.style.top=pt,null},st=_.popover.split(" ")[0],rt={toJSON:()=>"",bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0},lt=/(top|right|bottom|left)-(start|middle|end)/;H&&W(document);function dt(t,e){const n=e.getAttribute("data-position")||"bottom-start";if(!lt.test(n))return console.error(`Found invalid data-position="${n}"
2
+ - It must be [top|right|bottom|left]-[start|middle|end]
3
+ - Found on element:`,e);const i=()=>it(t,e,{container:{...rt,bottom:window.innerHeight,right:window.innerWidth},margin:4,padding:16,position:n}),o=({newState:d})=>{d!=="open"&&(g(document,"DOMContentReady",i),g(e,"toggle",o),g(window,"load,resize,scroll",i,!0))};document.fonts.ready.then(i),m(document,"DOMContentReady",i),m(e,"toggle",o),m(window,"load,resize,scroll",i,!0)}function V({target:t,newState:e}){var o;const i=e==="open"&&t instanceof HTMLElement&&t.classList.contains(st)&&((o=t.getRootNode())==null?void 0:o.querySelector(`[popovertarget="${t.id}"]`));i&&dt(i,t)}function W(t){t.addEventListener("toggle",V,!0)}function ct(t){t.removeEventListener("toggle",V,!0)}function at(t){q(t),W(t)}function ut(t){ot(t),ct(t)}return a.observe=at,a.styles=Q,a.unobserve=ut,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),a}({});
4
+ //# sourceMappingURL=index.iife.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.iife.js","sources":["../designsystem/utils.ts","../designsystem/field/field.ts","../node_modules/nanopop/dist/nanopop.mjs","../designsystem/popover/popover.ts","../designsystem/index.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\n\n/**\n * useId\n * @return A generated unique ID\n */\nlet id = 0;\nconst UUID = `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 5)}`;\nexport function useId (el: Element) {\n if (!el.id) el.id = `${UUID}${++id}`;\n\treturn el.id;\n};\n\n/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\n}\n\n// Internal helper for on / off\nconst events = (\n\taction: \"add\" | \"remove\",\n\telement: Node | Window,\n\trest: Parameters<typeof Element.prototype.addEventListener>,\n): void => {\n\tfor (const type of rest[0].split(\",\")) {\n\t\trest[0] = type;\n\t\tElement.prototype[`${action}EventListener`].apply(element, rest);\n\t}\n};\n\n/**\n * on\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const on = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.addEventListener>\n): void => events(\"add\", element, rest);\n\n/**\n * off\n * @param element The Element to use as EventTarget\n * @param types A comma separated string of event types\n * @param listener An event listener function or listener object\n */\nexport const off = (\n\telement: Node | Window,\n\t...rest: Parameters<typeof Element.prototype.removeEventListener>\n): void => events(\"remove\", element, rest);\n\n","import styles from '../styles.module.css';\nimport { IS_BROWSER, createOptimizedMutationObserver, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\nconst OBSERVERS = new WeakMap();\n\n\nfunction process(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: Element | null = null;\n let valid = true;\n\n for (const el of field.getElementsByTagName('*')) {\n if (el instanceof HTMLLabelElement) labels.push(el);\n else if ('validity' in el && !(el instanceof HTMLButtonElement)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before validation since it can also be a <p>\n valid = el.getAttribute('data-color') === 'success';\n descs.unshift(useId(el));\n } else if (el instanceof HTMLParagraphElement) descs.push(useId(el));\n }\n\n if (input) for (const label of labels) label.htmlFor = useId(input);\n input?.setAttribute('aria-describedby', descs.join(' '));\n input?.setAttribute('aria-invalid', `${!valid}`);\n }\n}\n\n// Automatically observe <body> if in browser\nif (IS_BROWSER) observe(document.body);\n\nexport function observe (el: Element) {\n if (OBSERVERS.has(el)) return;\n const fields = el.getElementsByClassName(CSS_FIELD); // Reutrns a live HTMLCollection\n const observer = createOptimizedMutationObserver(() => process(fields));\n observer.observe(el, {\n attributeFilter: ['class'],\n attributes: true,\n childList: true,\n subtree: true\n });\n\n process(fields); // Initial run\n OBSERVERS.set(el, observer);\n}\n\nexport function unobserve (el: Element) {\n OBSERVERS.get(el)?.disconnect();\n}\n","/*! NanoPop 2.4.2 MIT | https://github.com/Simonwep/nanopop */\nconst N = \"2.4.2\", I = {\n variantFlipOrder: { start: \"sme\", middle: \"mse\", end: \"ems\" },\n positionFlipOrder: { top: \"tbrl\", right: \"rltb\", bottom: \"btrl\", left: \"lrbt\" },\n position: \"bottom\",\n margin: 8,\n padding: 0\n}, J = (n, i, m) => {\n const {\n container: r,\n arrow: a,\n margin: e,\n padding: l,\n position: V,\n variantFlipOrder: C,\n positionFlipOrder: M\n } = {\n container: document.documentElement.getBoundingClientRect(),\n ...I,\n ...m\n }, { left: F, top: K } = i.style;\n i.style.left = \"0\", i.style.top = \"0\";\n const t = n.getBoundingClientRect(), o = i.getBoundingClientRect(), P = {\n t: t.top - o.height - e,\n b: t.bottom + e,\n r: t.right + e,\n l: t.left - o.width - e\n }, R = {\n vs: t.left,\n vm: t.left + t.width / 2 - o.width / 2,\n ve: t.left + t.width - o.width,\n hs: t.top,\n hm: t.bottom - t.height / 2 - o.height / 2,\n he: t.bottom - o.height\n }, [$, E = \"middle\"] = V.split(\"-\"), L = M[$], j = C[E], { top: y, left: x, bottom: B, right: O } = r;\n for (const c of L) {\n const s = c === \"t\" || c === \"b\";\n let p = P[c];\n const [d, g] = s ? [\"top\", \"left\"] : [\"left\", \"top\"], [u, v] = s ? [o.height, o.width] : [o.width, o.height], [z, T] = s ? [B, O] : [O, B], [H, k] = s ? [y, x] : [x, y];\n if (!(p < H || p + u + l > z))\n for (const b of j) {\n let f = R[(s ? \"v\" : \"h\") + b];\n if (!(f < k || f + v + l > T)) {\n if (f -= o[g], p -= o[d], i.style[g] = `${f}px`, i.style[d] = `${p}px`, a) {\n const w = s ? t.width / 2 : t.height / 2, h = v / 2, S = w > h, q = {\n s: S ? h : w,\n m: h,\n e: S ? h : v - w\n }, A = {\n t: u,\n b: 0,\n r: 0,\n l: u\n }, D = f + q[b], G = p + A[c];\n a.style[g] = `${D}px`, a.style[d] = `${G}px`;\n }\n return c + b;\n }\n }\n }\n return i.style.left = F, i.style.top = K, null;\n}, Q = (n, i, m) => {\n const r = typeof n == \"object\" && !(n instanceof HTMLElement) ? n : { reference: n, popper: i, ...m };\n return {\n /**\n * Repositions the current popper.\n * @param options Optional options which get merged with the current ones.\n */\n update(a = r) {\n const { reference: e, popper: l } = Object.assign(r, a);\n if (!l || !e)\n throw new Error(\"Popper- or reference-element missing.\");\n return J(e, l, r);\n }\n };\n};\nexport {\n Q as createPopper,\n I as defaults,\n J as reposition,\n N as version\n};\n//# sourceMappingURL=nanopop.mjs.map\n","import { type NanoPopPosition, reposition } from 'nanopop';\nimport styles from '../styles.module.css';\nimport { IS_BROWSER, off, on } from '../utils';\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst CONTAINER = { toJSON: () => '', bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 };\nconst POSITIONS = /(top|right|bottom|left)-(start|middle|end)/;\ntype Toggle = Event & { newState?: string };\n\nif (IS_BROWSER) observe(document);\n\n// Not exposed as a hook, as it is nice to allow consuming components to use it as a callback\nexport function anchorPosition(anchor: HTMLElement, popover: HTMLElement) {\n const position = (popover.getAttribute('data-position') || 'bottom-start') as NanoPopPosition;\n if (!POSITIONS.test(position)) return console.error(`Found invalid data-position=\"${position}\"\\n- It must be [top|right|bottom|left]-[start|middle|end]\\n- Found on element:`, popover);\n\n const update = () =>\n reposition(anchor, popover, {\n container: { ...CONTAINER, bottom: window.innerHeight, right: window.innerWidth },\n margin: 4, // Margin between the popper element and the reference\n padding: 16, // Minimum space between the popper and the container\n position // [top|right|bottom|left]-[start|middle|end]\n });\n\n const removeEvent = ({ newState }: Toggle) => {\n if (newState === 'open') return;\n off(document, 'DOMContentReady', update);\n off(popover, 'toggle', removeEvent);\n off(window, 'load,resize,scroll', update, true);\n }\n \n\n document.fonts.ready.then(update); // Inital render and when fonts load\n on(document, 'DOMContentReady', update);\n on(popover, 'toggle', removeEvent);\n on(window, 'load,resize,scroll', update, true); // Use capture to also listen for elements with overflow\n}\n\nfunction process ({ target: el, newState }: Toggle){\n const isPopping = newState === 'open' && el instanceof HTMLElement && el.classList.contains(CSS_POPOVER);\n const anchor = isPopping && (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n\n if (anchor) anchorPosition(anchor, el);\n}\n\nexport function observe(el: Node) {\n el.addEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}\nexport function unobserve(el: Node) {\n el.removeEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}","import * as field from './field/field';\nimport * as popover from './popover/popover';\nexport * as styles from './styles.module.css';\n\nexport function observe(el: Element) {\n field.observe(el);\n popover.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n popover.unobserve(el);\n}"],"names":["IS_BROWSER","id","UUID","useId","el","createOptimizedMutationObserver","callback","queue","observer","mutations","process","events","action","element","rest","type","on","off","CSS_FIELD","styles","CSS_VALIDATION","OBSERVERS","fields","field","labels","descs","input","valid","label","observe","unobserve","_a","I","J","n","i","m","r","a","e","l","V","C","M","F","K","t","o","P","R","$","E","L","j","y","x","B","O","c","s","p","d","g","u","v","z","T","H","k","b","f","w","S","q","A","D","G","CSS_POPOVER","CONTAINER","POSITIONS","anchorPosition","anchor","popover","position","update","reposition","removeEvent","newState","field.observe","popover.observe","field.unobserve","popover.unobserve"],"mappings":"szBAAaA,EAAa,OAAO,OAAW,KAAe,OAAO,SAAa,IAM/E,IAAIC,EAAK,EACT,MAAMC,EAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,CAAC,GACzE,SAASC,EAAOC,EAAa,CAC9B,OAACA,EAAG,KAAIA,EAAG,GAAK,GAAGF,CAAI,GAAG,EAAED,CAAE,IAC5BG,EAAG,EACX,CAMO,SAASC,EAAgCC,EAA4B,CAC1E,MAAMC,EAA0B,CAAC,EAC3BC,EAAW,IAAI,iBAAkBC,GAAc,CAC9CF,EAAM,CAAC,yBAAyBG,CAAO,EACtCH,EAAA,KAAK,GAAGE,CAAS,CAAA,CACxB,EAEKC,EAAU,IAAM,CACpBJ,EAASC,EAAOC,CAAQ,EACxBD,EAAM,OAAS,CACjB,EAEO,OAAAC,CACT,CAGA,MAAMG,EAAS,CACdC,EACAC,EACAC,IACU,CACV,UAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG,EACnCA,EAAK,CAAC,EAAIC,EACV,QAAQ,UAAU,GAAGH,CAAM,eAAe,EAAE,MAAMC,EAASC,CAAI,CAEjE,EAQaE,EAAK,CACjBH,KACGC,IACOH,EAAO,MAAOE,EAASC,CAAI,EAQzBG,EAAM,CAClBJ,KACGC,IACOH,EAAO,SAAUE,EAASC,CAAI,EC7DnCI,GAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,EACr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,EAAA,iBAAiB,SAAUM,EAAS,EAAI,CAC7C,CACO,SAASoB,GAAU1B,EAAU,CAC/BA,EAAA,oBAAoB,SAAUM,EAAS,EAAI,CAChD,CC9CO,SAASmB,GAAQzB,EAAa,CACnCoF,EAAcpF,CAAE,EAChBqF,EAAgBrF,CAAE,CACpB,CAEO,SAAS0B,GAAU1B,EAAa,CACrCsF,GAAgBtF,CAAE,EAClBuF,GAAkBvF,CAAE,CACtB","x_google_ignoreList":[2]}
package/mtds/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import * as v from "./styles.module.css.js";
2
1
  import { observe as o, unobserve as s } from "./field/field.js";
3
2
  import { observe as r, unobserve as b } from "./popover/popover.js";
3
+ import * as t from "./styles.module.css.js";
4
4
  function u(e) {
5
5
  o(e), r(e);
6
6
  }
@@ -9,7 +9,7 @@ function m(e) {
9
9
  }
10
10
  export {
11
11
  u as observe,
12
- v as styles,
12
+ t as styles,
13
13
  m as unobserve
14
14
  };
15
15
  //# sourceMappingURL=index.js.map
package/mtds/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["export * as styles from './styles.module.css';\nimport * as field from './field/field';\nimport * as popover from './popover/popover';\n\nexport function observe(el: Element) {\n field.observe(el);\n popover.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n popover.unobserve(el);\n}"],"names":["observe","el","field.observe","popover.observe","unobserve","field.unobserve","popover.unobserve"],"mappings":";;;AAIO,SAASA,EAAQC,GAAa;AACnCC,EAAAA,EAAcD,CAAE,GAChBE,EAAgBF,CAAE;AACpB;AAEO,SAASG,EAAUH,GAAa;AACrCI,EAAAA,EAAgBJ,CAAE,GAClBK,EAAkBL,CAAE;AACtB;"}
1
+ {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["import * as field from './field/field';\nimport * as popover from './popover/popover';\nexport * as styles from './styles.module.css';\n\nexport function observe(el: Element) {\n field.observe(el);\n popover.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n popover.unobserve(el);\n}"],"names":["observe","el","field.observe","popover.observe","unobserve","field.unobserve","popover.unobserve"],"mappings":";;;AAIO,SAASA,EAAQC,GAAa;AACnCC,EAAAA,EAAcD,CAAE,GAChBE,EAAgBF,CAAE;AACpB;AAEO,SAASG,EAAUH,GAAa;AACrCI,EAAAA,EAAgBJ,CAAE,GAClBK,EAAkBL,CAAE;AACtB;"}
@@ -1,40 +1,40 @@
1
- import { reposition as d } from "nanopop";
2
- import a from "../styles.module.css.js";
3
- import { IS_BROWSER as m } from "../utils.js";
4
- const c = a.popover.split(" ")[0], g = { toJSON: () => "", bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 }, u = /(top|right|bottom|left)-(start|middle|end)/;
5
- m && l(document);
6
- function v(e, n) {
7
- const i = n.getAttribute("data-position") || "bottom-start";
8
- if (!u.test(i)) return console.error(`Found invalid data-position="${i}"
1
+ import { reposition as a } from "../external/nanopop/dist/nanopop.js";
2
+ import m from "../styles.module.css.js";
3
+ import { IS_BROWSER as g, on as r, off as s } from "../utils.js";
4
+ const u = m.popover.split(" ")[0], l = { toJSON: () => "", bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 }, f = /(top|right|bottom|left)-(start|middle|end)/;
5
+ g && h(document);
6
+ function p(t, e) {
7
+ const i = e.getAttribute("data-position") || "bottom-start";
8
+ if (!f.test(i)) return console.error(`Found invalid data-position="${i}"
9
9
  - It must be [top|right|bottom|left]-[start|middle|end]
10
- - Found on element:`, n);
11
- const t = () => d(e, n, {
12
- container: { ...g, bottom: window.innerHeight, right: window.innerWidth },
10
+ - Found on element:`, e);
11
+ const o = () => a(t, e, {
12
+ container: { ...l, bottom: window.innerHeight, right: window.innerWidth },
13
13
  margin: 4,
14
14
  // Margin between the popper element and the reference
15
15
  padding: 16,
16
16
  // Minimum space between the popper and the container
17
17
  position: i
18
18
  // [top|right|bottom|left]-[start|middle|end]
19
- }), o = ({ newState: s }) => {
20
- s !== "open" && (document.removeEventListener("DOMContentReady", t), n.removeEventListener("toggle", o), window.removeEventListener("load", t), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0));
19
+ }), n = ({ newState: c }) => {
20
+ c !== "open" && (s(document, "DOMContentReady", o), s(e, "toggle", n), s(window, "load,resize,scroll", o, !0));
21
21
  };
22
- document.addEventListener("DOMContentReady", t), document.fonts.ready.then(t), n.addEventListener("toggle", o), window.addEventListener("load", t), window.addEventListener("resize", t), window.addEventListener("scroll", t, !0);
22
+ document.fonts.ready.then(o), r(document, "DOMContentReady", o), r(e, "toggle", n), r(window, "load,resize,scroll", o, !0);
23
23
  }
24
- function r({ target: e, newState: n }) {
25
- var o;
26
- const t = n === "open" && e instanceof HTMLElement && e.classList.contains(c) && ((o = e.getRootNode()) == null ? void 0 : o.querySelector(`[popovertarget="${e.id}"]`));
27
- t && v(t, e);
24
+ function d({ target: t, newState: e }) {
25
+ var n;
26
+ const o = e === "open" && t instanceof HTMLElement && t.classList.contains(u) && ((n = t.getRootNode()) == null ? void 0 : n.querySelector(`[popovertarget="${t.id}"]`));
27
+ o && p(o, t);
28
28
  }
29
- function l(e) {
30
- e.addEventListener("toggle", r, !0);
29
+ function h(t) {
30
+ t.addEventListener("toggle", d, !0);
31
31
  }
32
- function f(e) {
33
- e.removeEventListener("toggle", r, !0);
32
+ function S(t) {
33
+ t.removeEventListener("toggle", d, !0);
34
34
  }
35
35
  export {
36
- v as anchorPosition,
37
- l as observe,
38
- f as unobserve
36
+ p as anchorPosition,
37
+ h as observe,
38
+ S as unobserve
39
39
  };
40
40
  //# sourceMappingURL=popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import { type NanoPopPosition, reposition } from 'nanopop';\nimport styles from '../styles.module.css';\nimport { IS_BROWSER } from '../utils';\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst CONTAINER = { toJSON: () => '', bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 };\nconst POSITIONS = /(top|right|bottom|left)-(start|middle|end)/;\ntype Toggle = Event & { newState?: string };\n\nif (IS_BROWSER) observe(document);\n\n// Not exposed as a hook, as it is nice to allow consuming components to use it as a callback\nexport function anchorPosition(anchor: HTMLElement, popover: HTMLElement) {\n const position = (popover.getAttribute('data-position') || 'bottom-start') as NanoPopPosition;\n if (!POSITIONS.test(position)) return console.error(`Found invalid data-position=\"${position}\"\\n- It must be [top|right|bottom|left]-[start|middle|end]\\n- Found on element:`, popover);\n\n const update = () =>\n reposition(anchor, popover, {\n container: { ...CONTAINER, bottom: window.innerHeight, right: window.innerWidth },\n margin: 4, // Margin between the popper element and the reference\n padding: 16, // Minimum space between the popper and the container\n position // [top|right|bottom|left]-[start|middle|end]\n });\n\n const removeEvent = ({ newState }: Toggle) => {\n if (newState === 'open') return;\n document.removeEventListener('DOMContentReady', update);\n popover.removeEventListener('toggle', removeEvent);\n window.removeEventListener('load', update);\n window.removeEventListener('resize', update);\n window.removeEventListener('scroll', update, true);\n }\n \n\n document.addEventListener('DOMContentReady', update);\n document.fonts.ready.then(update); // Inital render and when fonts load\n popover.addEventListener('toggle', removeEvent);\n window.addEventListener('load', update);\n window.addEventListener('resize', update);\n window.addEventListener('scroll', update, true); // Use capture to also listen for elements with overflow\n}\n\nfunction process ({ target: el, newState }: Toggle){\n const isPopping = newState === 'open' && el instanceof HTMLElement && el.classList.contains(CSS_POPOVER);\n const anchor = isPopping && (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n\n if (anchor) anchorPosition(anchor, el);\n}\n\nexport function observe(el: Node) {\n el.addEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}\nexport function unobserve(el: Node) {\n el.removeEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}"],"names":["CSS_POPOVER","styles","CONTAINER","POSITIONS","IS_BROWSER","anch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3C,QAAAN,IADYM,MAAa,UAAUE,aAAc,eAAeA,EAAG,UAAU,SAASd,CAAW,OAC1Ee,IAAAD,EAAG,kBAAH,gBAAAC,EAAiC,cAA2B,mBAAmBD,EAAG,EAAE;AAE7G,EAAAR,KAAuBD,EAAAC,GAAQQ,CAAE;AACvC;AAEO,SAASE,EAAQF,GAAU;AAC7B,EAAAA,EAAA,iBAAiB,UAAUD,GAAS,EAAI;AAC7C;AACO,SAASI,EAAUH,GAAU;AAC/B,EAAAA,EAAA,oBAAoB,UAAUD,GAAS,EAAI;AAChD;"}
1
+ {"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import { type NanoPopPosition, reposition } from 'nanopop';\nimport styles from '../styles.module.css';\nimport { IS_BROWSER, off, on } from '../utils';\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst CONTAINER = { toJSON: () => '', bottom: 0, height: 0, left: 0, right: 0, top: 0, width: 0, x: 0, y: 0 };\nconst POSITIONS = /(top|right|bottom|left)-(start|middle|end)/;\ntype Toggle = Event & { newState?: string };\n\nif (IS_BROWSER) observe(document);\n\n// Not exposed as a hook, as it is nice to allow consuming components to use it as a callback\nexport function anchorPosition(anchor: HTMLElement, popover: HTMLElement) {\n const position = (popover.getAttribute('data-position') || 'bottom-start') as NanoPopPosition;\n if (!POSITIONS.test(position)) return console.error(`Found invalid data-position=\"${position}\"\\n- It must be [top|right|bottom|left]-[start|middle|end]\\n- Found on element:`, popover);\n\n const update = () =>\n reposition(anchor, popover, {\n container: { ...CONTAINER, bottom: window.innerHeight, right: window.innerWidth },\n margin: 4, // Margin between the popper element and the reference\n padding: 16, // Minimum space between the popper and the container\n position // [top|right|bottom|left]-[start|middle|end]\n });\n\n const removeEvent = ({ newState }: Toggle) => {\n if (newState === 'open') return;\n off(document, 'DOMContentReady', update);\n off(popover, 'toggle', removeEvent);\n off(window, 'load,resize,scroll', update, true);\n }\n \n\n document.fonts.ready.then(update); // Inital render and when fonts load\n on(document, 'DOMContentReady', update);\n on(popover, 'toggle', removeEvent);\n on(window, 'load,resize,scroll', update, true); // Use capture to also listen for elements with overflow\n}\n\nfunction process ({ target: el, newState }: Toggle){\n const isPopping = newState === 'open' && el instanceof HTMLElement && el.classList.contains(CSS_POPOVER);\n const anchor = isPopping && (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n\n if (anchor) anchorPosition(anchor, el);\n}\n\nexport function observe(el: Node) {\n el.addEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}\nexport function unobserve(el: Node) {\n el.removeEventListener('toggle', process, true); // Use capture since toggle does not bubble\n}"],"names":["CSS_POPOVER","styles","CONTAINER","POSITIONS","IS_BROWSER","anchorPosition","anchor","popover","position","update","reposition","removeEvent","newState","off","on","process","el","_a","observe","unobserve"],"mappings":";;;AAIA,MAAMA,IAAcC,EAAO,QAAQ,MAAM,GAAG,EAAE,CAAC,GACzCC,IAAY,EAAE,QAAQ,MAAM,IAAI,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,GAAG,GAAG,GAAG,EAAE,GACtGC,IAAY;AAGdC,OAAoB,QAAQ;AAGhB,SAAAC,EAAeC,GAAqBC,GAAsB;AACxE,QAAMC,IAAYD,EAAQ,aAAa,eAAe,KAAK;AACvD,MAAA,CAACJ,EAAU,KAAKK,CAAQ,EAAU,QAAA,QAAQ,MAAM,gCAAgCA,CAAQ;AAAA;AAAA,sBAAmFD,CAAO;AAEtL,QAAME,IAAS,MACbC,EAAWJ,GAAQC,GAAS;AAAA,IAC1B,WAAW,EAAE,GAAGL,GAAW,QAAQ,OAAO,aAAa,OAAO,OAAO,WAAW;AAAA,IAChF,QAAQ;AAAA;AAAA,IACR,SAAS;AAAA;AAAA,IACT,UAAAM;AAAA;AAAA,EAAA,CACD,GAEGG,IAAc,CAAC,EAAE,UAAAC,QAAuB;AAC5C,IAAIA,MAAa,WACbC,EAAA,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