@mattilsynet/design 0.2.15 → 0.2.16

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,38 +1,40 @@
1
- import r from "../styles.module.css.js";
2
- import { onMutation as f, on as I, QUICK_EVENT as c, off as g, isInputLike as u, useId as a } from "../utils.js";
3
- const d = r.field.split(" ")[0], b = r.validation.split(" "), A = b[0];
4
- function L(e) {
5
- for (const i of e) {
1
+ import f from "../styles.module.css.js";
2
+ import { onMutation as c, on as I, QUICK_EVENT as u, isInputLike as d, attr as r, off as g, useId as l } from "../utils.js";
3
+ const m = f.field.split(" ")[0], b = f.validation.split(" "), L = b[0];
4
+ function h(t) {
5
+ for (const i of t) {
6
6
  const s = [], o = [];
7
- let t = null, l = !0;
8
- for (const n of i.getElementsByTagName("*"))
9
- n instanceof HTMLLabelElement ? s.push(n) : u(n) ? t = n : n.classList.contains(A) ? (l = n.getAttribute("data-color") === "success", o.unshift(a(n))) : n instanceof HTMLParagraphElement && o.push(a(n));
10
- if (t) for (const n of s) n.htmlFor = a(t);
11
- t && v(t), t == null || t.setAttribute("aria-describedby", o.join(" ")), t == null || t.setAttribute("aria-invalid", `${!l}`);
7
+ let n = null, a = !0;
8
+ for (const e of i.getElementsByTagName("*"))
9
+ e instanceof HTMLLabelElement ? s.push(e) : d(e) ? n = e : e.classList.contains(L) ? (a = e.getAttribute("data-color") === "success", o.unshift(l(e))) : e instanceof HTMLParagraphElement && o.push(l(e));
10
+ if (n) {
11
+ for (const e of s) e.htmlFor = l(n);
12
+ p(n), r(n, "aria-describedby", o.join(" ")), r(n, "aria-invalid", `${!a}`);
13
+ }
12
14
  }
13
15
  }
14
- function m({ target: e }) {
15
- u(e) && v(e);
16
+ function v({ target: t }) {
17
+ d(t) && p(t);
16
18
  }
17
- function v(e) {
18
- const i = e == null ? void 0 : e.nextElementSibling, s = i == null ? void 0 : i.getAttribute("data-count");
19
+ function p(t) {
20
+ const i = t == null ? void 0 : t.nextElementSibling, s = i == null ? void 0 : i.getAttribute("data-count");
19
21
  if (i && s) {
20
- const o = Number(s) - e.value.length, t = o < 0;
21
- if (i.getAttribute("aria-live") === "polite" !== t) {
22
- i.setAttribute("aria-live", t ? "polite" : "off");
23
- for (const n of b) i.classList.toggle(n, t);
22
+ const o = Number(s) - t.value.length, n = o < 0;
23
+ if (i.getAttribute("aria-live") === "polite" !== n) {
24
+ r(i, "aria-live", n ? "polite" : "off");
25
+ for (const e of b) i.classList.toggle(e, n);
24
26
  }
25
- i.textContent = `${Math.abs(o)} tegn ${t ? "for mye" : "igjen"}`;
27
+ i.textContent = `${Math.abs(o)} tegn ${n ? "for mye" : "igjen"}`;
26
28
  }
27
29
  }
28
- function S(e) {
29
- f(e, d, L), I(e, "input", m, c);
30
+ function E(t) {
31
+ c(t, m, h), I(t, "input", v, u);
30
32
  }
31
- function E(e) {
32
- f(e, d, !1), g(e, "input", m, c);
33
+ function C(t) {
34
+ c(t, m, !1), g(t, "input", v, u);
33
35
  }
34
36
  export {
35
- S as observe,
36
- E as unobserve
37
+ E as observe,
38
+ C as unobserve
37
39
  };
38
40
  //# sourceMappingURL=field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sources":["../../designsystem/field/field.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | 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 (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation 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 if (input) renderCounter(input);\n\n input?.setAttribute('aria-describedby', descs.join(' '));\n input?.setAttribute('aria-invalid', `${!valid}`);\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n\n if (prevInvalid !== nextInvalid) {\n el.setAttribute('aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = `${Math.abs(remainder)} tegn ${nextInvalid ? 'for mye' : 'igjen'}`;\n }\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n\n// TODO: Remove invalid when errormessage is gone"],"names":["CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","useId","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","onMutation","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAkBD,EAAO,WAAW,MAAM,GAAG,GAC7CE,IAAiBD,EAAgB,CAAC;AAExC,SAASE,EAAWC,GAAmC;AACrD,aAAUC,KAASD,GAAQ;AACzB,UAAME,IAA6B,CAAC,GAC9BC,IAAkB,CAAC;AACzB,QAAIC,IAAiC,MACjCC,IAAQ;AAEZ,eAAW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AAWf,GAAa;AAC3B,EAAAY,EAAAZ,GAAIX,GAAW,EAAK,GAC3B2B,EAAAhB,GAAI,SAASI,GAAaU,CAAW;AAC3C;"}
1
+ {"version":3,"file":"field.js","sources":["../../designsystem/field/field.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, attr, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | 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 (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation 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) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, 'aria-describedby', descs.join(' '));\n attr(input, 'aria-invalid', `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n\n if (prevInvalid !== nextInvalid) {\n attr(el, 'aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = `${Math.abs(remainder)} tegn ${nextInvalid ? 'for mye' : 'igjen'}`;\n }\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n"],"names":["CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","useId","label","renderCounter","attr","handleInput","target","limit","remainder","nextInvalid","css","observe","onMutation","on","QUICK_EVENT","unobserve","off"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAkBD,EAAO,WAAW,MAAM,GAAG,GAC7CE,IAAiBD,EAAgB,CAAC;AAExC,SAASE,EAAWC,GAAmC;AACrD,aAAUC,KAASD,GAAQ;AACzB,UAAME,IAA6B,CAAC,GAC9BC,IAAkB,CAAC;AACzB,QAAIC,IAAiC,MACjCC,IAAQ;AAEZ,eAAWC,KAAML,EAAM,qBAAqB,GAAG;AAC7C,MAAIK,aAAc,mBAAyBJ,EAAA,KAAKI,CAAE,IACzCC,EAAYD,CAAE,IAAWF,IAAAE,IACzBA,EAAG,UAAU,SAASR,CAAc,KACnCO,IAAAC,EAAG,aAAa,YAAY,MAAM,WACpCH,EAAA,QAAQK,EAAMF,CAAE,CAAC,KACdA,aAAc,0BAA4B,KAAKE,EAAMF,CAAE,CAAC;AAGrE,QAAIF,GAAO;AACT,iBAAWK,KAASP,EAAc,CAAAO,EAAA,UAAUD,EAAMJ,CAAK;AACvD,MAAAM,EAAcN,CAAK,GACnBO,EAAKP,GAAO,oBAAoBD,EAAM,KAAK,GAAG,CAAC,GAC/CQ,EAAKP,GAAO,gBAAgB,GAAG,CAACC,CAAK,EAAE;AAAA,IAAA;AAAA,EACzC;AAEJ;AACA,SAASO,EAAY,EAAE,QAAAC,KAAiB;AACtC,EAAIN,EAAYM,CAAM,KAAGH,EAAcG,CAAM;AAC/C;AAEA,SAASH,EAAcN,GAAyB;AAC9C,QAAME,IAAKF,KAAA,gBAAAA,EAAO,oBACZU,IAAQR,KAAA,gBAAAA,EAAI,aAAa;AAE/B,MAAIA,KAAMQ,GAAO;AACf,UAAMC,IAAY,OAAOD,CAAK,IAAIV,EAAM,MAAM,QACxCY,IAAcD,IAAY;AAGhC,QAFoBT,EAAG,aAAa,WAAW,MAAM,aAEjCU,GAAa;AAC/B,MAAAL,EAAKL,GAAI,aAAaU,IAAc,WAAW,KAAK;AACpD,iBAAWC,KAAOpB,EAAiB,CAAAS,EAAG,UAAU,OAAOW,GAAKD,CAAW;AAAA,IAAA;AAEtE,IAAAV,EAAA,cAAc,GAAG,KAAK,IAAIS,CAAS,CAAC,SAASC,IAAc,YAAY,OAAO;AAAA,EAAA;AAErF;AAEO,SAASE,EAASZ,GAAa;AACzB,EAAAa,EAAAb,GAAIX,GAAWI,CAAU,GACjCqB,EAAAd,GAAI,SAASM,GAAaS,CAAW;AAC1C;AAEO,SAASC,EAAWhB,GAAa;AAC3B,EAAAa,EAAAb,GAAIX,GAAW,EAAK,GAC3B4B,EAAAjB,GAAI,SAASM,GAAaS,CAAW;AAC3C;"}
@@ -1,20 +1,20 @@
1
- import o from "../styles.module.css.js";
2
- import { onMutation as n, useId as f, isInputLike as l } from "../utils.js";
3
- const r = o.fieldset.split(" ")[0], c = o.validation.split(" ")[0];
4
- function u(s) {
5
- for (const a of s) {
1
+ import n from "../styles.module.css.js";
2
+ import { onMutation as a, useId as l, attr as e, isInputLike as c } from "../utils.js";
3
+ const r = n.fieldset.split(" ")[0], p = n.validation.split(" ")[0];
4
+ function d(s) {
5
+ for (const f of s) {
6
6
  const i = [];
7
- let e = "";
8
- for (const t of a.getElementsByTagName("*"))
9
- t.classList.contains(c) ? e = f(t) : l(t) && i.push(t);
10
- if (e)
7
+ let o = "";
8
+ for (const t of f.getElementsByTagName("*"))
9
+ t.classList.contains(p) ? o = l(t) : c(t) && i.push(t);
10
+ if (o)
11
11
  for (const t of i)
12
- t.setAttribute("aria-describedby", e), t.setAttribute("aria-invalid", "true");
12
+ e(t, "aria-describedby", o), e(t, "aria-invalid", "true");
13
13
  }
14
14
  }
15
- const b = (s) => n(s, r, u), m = (s) => n(s, r, !1);
15
+ const I = (s) => a(s, r, d), v = (s) => a(s, r, !1);
16
16
  export {
17
- b as observe,
18
- m as unobserve
17
+ I as observe,
18
+ v as unobserve
19
19
  };
20
20
  //# sourceMappingURL=fieldset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldset.js","sources":["../../designsystem/fieldset/fieldset.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n input.setAttribute('aria-describedby', validationId);\n input.setAttribute('aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n"],"names":["CSS_FIELDSET","styles","CSS_VALIDATION","process","fieldsets","fieldset","inputs","validationId","el","useId","isInputLike","input","observe","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAeC,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,GAC3CC,IAAiBD,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC;AAErD,SAASE,EAAQC,GAAsC;AACrD,aAAUC,KAAYD,GAAW;AAC/B,UAAME,IAA6B,CAAC;AACpC,QAAIC,IAAe;AAEnB,eAAWC,KAAMH,EAAS,qBAAqB,GAAG;AAChD,MAAIG,EAAG,UAAU,SAASN,CAAc,IAAGK,IAAeE,EAAMD,CAAE,IACzDE,EAAYF,CAAE,KAAGF,EAAO,KAAKE,CAAE;AAGtC,QAAAD;AACF,iBAAUI,KAASL;AACX,QAAAK,EAAA,aAAa,oBAAoBJ,CAAY,GAC7CI,EAAA,aAAa,gBAAgB,MAAM;AAAA,EAC3C;AAEN;AAEO,MAAMC,IAAU,CAACJ,MAAgBK,EAAWL,GAAIR,GAAcG,CAAO,GAC/DW,IAAY,CAACN,MAAgBK,EAAWL,GAAIR,GAAc,EAAK;"}
1
+ {"version":3,"file":"fieldset.js","sources":["../../designsystem/fieldset/fieldset.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { attr, isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n attr(input, 'aria-describedby', validationId);\n attr(input, 'aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n"],"names":["CSS_FIELDSET","styles","CSS_VALIDATION","process","fieldsets","fieldset","inputs","validationId","el","useId","isInputLike","input","attr","observe","onMutation","unobserve"],"mappings":";;AAEA,MAAMA,IAAeC,EAAO,SAAS,MAAM,GAAG,EAAE,CAAC,GAC3CC,IAAiBD,EAAO,WAAW,MAAM,GAAG,EAAE,CAAC;AAErD,SAASE,EAAQC,GAAsC;AACrD,aAAUC,KAAYD,GAAW;AAC/B,UAAME,IAA6B,CAAC;AACpC,QAAIC,IAAe;AAEnB,eAAWC,KAAMH,EAAS,qBAAqB,GAAG;AAChD,MAAIG,EAAG,UAAU,SAASN,CAAc,IAAGK,IAAeE,EAAMD,CAAE,IACzDE,EAAYF,CAAE,KAAGF,EAAO,KAAKE,CAAE;AAGtC,QAAAD;AACF,iBAAUI,KAASL;AACZ,QAAAM,EAAAD,GAAO,oBAAoBJ,CAAY,GACvCK,EAAAD,GAAO,gBAAgB,MAAM;AAAA,EACpC;AAEN;AAEO,MAAME,IAAU,CAACL,MAAgBM,EAAWN,GAAIR,GAAcG,CAAO,GAC/DY,IAAY,CAACP,MAAgBM,EAAWN,GAAIR,GAAc,EAAK;"}
package/mtds/index.d.ts CHANGED
@@ -30,6 +30,7 @@ avatar: string;
30
30
  alert: string;
31
31
  heading: string;
32
32
  body: string;
33
+ tooltip: string;
33
34
  };
34
35
  export declare function observe(el: Element): void;
35
36
  export declare function unobserve(el: Element): void;
@@ -1,2 +1,2 @@
1
- var mtds=function(d){"use strict";const M="_validation_122jn_1 _ds-validation-message_1w6ss_1",S="_tag_122jn_1 _ds-tag_1w6ss_1",A="_tabs_122jn_1",$="_table_122jn_1 _ds-table_1w6ss_1",T="_scrollShadow_122jn_1",I="_skeleton_122jn_1 _ds-skeleton_1w6ss_1",L="_popover_122jn_1",E="_pagination_122jn_1 _ds-pagination_1w6ss_1",C="_modal_122jn_1 _ds-modal_1w6ss_1",k="_logo_122jn_1 _ds-focus_1w6ss_1",O="_link_122jn_1",x="_grid_122jn_1",H="_flex_122jn_1",P="_input_122jn_1 _ds-input_1w6ss_1",B="_fieldset_122jn_1 _ds-fieldset_1w6ss_1",D="_field_122jn_1 _ds-field_1w6ss_1",N="_affixes_122jn_1 _ds-field-affixes_1w6ss_1",U="_count_122jn_1",W="_errorsummary_122jn_1 _ds-error-summary_1w6ss_1",F="_details_122jn_1 _ds-details_1w6ss_1",V="_chip_122jn_1 _ds-chip_1w6ss_1",q="_card_122jn_1",z="_info_122jn_1",R="_button_122jn_1 _ds-button_1w6ss_1",K="_breadcrumbs_122jn_1 _ds-breadcrumbs_1w6ss_1",Y="_badge_122jn_1",G="_avatar_122jn_1 _ds-avatar_1w6ss_1",Q="_alert_122jn_1 _ds-alert_1w6ss_1",X="_heading_122jn_1 _ds-heading_1w6ss_1",J="_body_122jn_113",c={validation:M,tag:S,tabs:A,table:$,scrollShadow:T,skeleton:I,popover:L,pagination:E,modal:C,logo:k,link:O,grid:x,flex:H,input:P,fieldset:B,field:D,affixes:N,count:U,errorsummary:W,details:F,chip:V,card:q,info:z,button:R,breadcrumbs:K,badge:Y,avatar:G,alert:Q,heading:X,body:J},_t=Object.freeze(Object.defineProperty({__proto__:null,affixes:N,alert:Q,avatar:G,badge:Y,body:J,breadcrumbs:K,button:R,card:q,chip:V,count:U,default:c,details:F,errorsummary:W,field:D,fieldset:B,flex:H,grid:x,heading:X,info:z,input:P,link:O,logo:k,modal:C,pagination:E,popover:L,scrollShadow:T,skeleton:I,table:$,tabs:A,tag:S,validation:M},Symbol.toStringTag,{value:"Module"})),Z=typeof window<"u"&&typeof document<"u",l={capture:!0,passive:!0};let ft=0;const ut=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function g(t){return t.id||(t.id=`${ut}${++ft}`),t.id}const tt=(t,e,o)=>{for(const s of o[0].split(","))o[0]=s,e[`${t}EventListener`](...o)},f=(t,...e)=>tt("add",t,e),h=(t,...e)=>tt("remove",t,e);function bt(t){let e=0;const o=()=>setTimeout(s,200),s=()=>{t([],n),e=0},n=new MutationObserver(()=>{e||(e=requestAnimationFrame(o))});return n}const v=new WeakMap,gt=t=>{var o;const e=v.get(t);if(!e||!t.isConnected)(o=e==null?void 0:e.observer)==null||o.disconnect(),v.delete(t);else for(const[,s]of e.collections)s()},_=(t,e,o)=>{const s=t.getElementsByClassName(e);let n=v.get(t);n||(n={collections:new Map,observer:bt(()=>gt(t))},n.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),v.set(t,n)),o?n.collections.set(e,()=>o(s)):n.collections.delete(e)},y=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),et=c.field.split(" ")[0],nt=c.validation.split(" "),vt=nt[0];function pt(t){for(const e of t){const o=[],s=[];let n=null,a=!0;for(const i of e.getElementsByTagName("*"))i instanceof HTMLLabelElement?o.push(i):y(i)?n=i:i.classList.contains(vt)?(a=i.getAttribute("data-color")==="success",s.unshift(g(i))):i instanceof HTMLParagraphElement&&s.push(g(i));if(n)for(const i of o)i.htmlFor=g(n);n&&st(n),n==null||n.setAttribute("aria-describedby",s.join(" ")),n==null||n.setAttribute("aria-invalid",`${!a}`)}}function ot({target:t}){y(t)&&st(t)}function st(t){const e=t==null?void 0:t.nextElementSibling,o=e==null?void 0:e.getAttribute("data-count");if(e&&o){const s=Number(o)-t.value.length,n=s<0;if(e.getAttribute("aria-live")==="polite"!==n){e.setAttribute("aria-live",n?"polite":"off");for(const i of nt)e.classList.toggle(i,n)}e.textContent=`${Math.abs(s)} tegn ${n?"for mye":"igjen"}`}}function mt(t){_(t,et,pt),f(t,"input",ot,l)}function ht(t){_(t,et,!1),h(t,"input",ot,l)}const it=c.fieldset.split(" ")[0],yt=c.validation.split(" ")[0];function wt(t){for(const e of t){const o=[];let s="";for(const n of e.getElementsByTagName("*"))n.classList.contains(yt)?s=g(n):y(n)&&o.push(n);if(s)for(const n of o)n.setAttribute("aria-describedby",s),n.setAttribute("aria-invalid","true")}}const jt=t=>_(t,it,wt),Mt=t=>_(t,it,!1);function St(t){f(t,"click",rt),f(t,"toggle",ct,l),f(window,"load,resize,scroll",m,l),f(document,"DOMContentReady",m,l),document.fonts.ready.then(m)}function At(t){h(t,"click",rt),h(t,"toggle",ct,l)}const at=c.popover.split(" ")[0],r=Z?document.createElement("div"):null,p=new Map;r==null||r.setAttribute("style","position:absolute;padding:1px");function ct({target:t,newState:e}){var o;if(t instanceof HTMLElement&&t.classList.contains(at)){const s=(o=t.getRootNode())==null?void 0:o.querySelector(`[popovertarget="${t.id}"]`),n=t.getAttribute("data-position")==="over";e==="closed"?p.delete(t):s&&p.set(t,()=>$t(s,t,n)),document.body.append(r||""),m()}}function m(){for(const[t,e]of p)e()}function rt(t){var o;const e=t.target instanceof Element&&t.target.closest("a");if(e){const s=e.getRootNode(),n=((o=s.getElementById)==null?void 0:o.call(s,e.getAttribute("popovertarget")||""))||e.closest(`.${at}`),a=e.getAttribute("popovertargetaction")||"toggle";n==null||n.togglePopover(a==="show"||(a==="hide"?!1:void 0))}}function $t(t,e,o=!1){if(!(t!=null&&t.isConnected)||!(e!=null&&e.isConnected))return p.delete(e);const{offsetWidth:s,offsetHeight:n}=e,{offsetWidth:a,offsetHeight:i}=t,{width:u,height:j,left:Ot,top:xt}=t.getBoundingClientRect(),Ht=Math.round(Ot-(a-u)/2),b=Math.round(xt-(i-j)/2),Pt=b+i+n<window.innerHeight,Bt=b-n>0,lt=!o&&Pt||!Bt,Dt=lt?window.scrollY+b+i+n+30:0;e.style.left=`${Math.round(Math.min(Math.max(10,Ht),window.innerWidth-s-10))}px`,e.style.top=`${Math.round(lt?b+i:b-n)}px`,r==null||r.style.setProperty("top",`${Math.round(Dt)}px`)}const dt=c.table.split(" ")[0];function Tt(t){var e,o;for(const s of t)if(s instanceof HTMLTableElement){const n=Array.from(((o=(e=s.tHead)==null?void 0:e.rows[0])==null?void 0:o.cells)||[],a=>{var i;return(i=a.innerText)==null?void 0:i.trim()});for(const a of s.tBodies)for(const i of a.rows)for(const u of i.cells)u.setAttribute("data-th",n[u.cellIndex]||":empty")}}const It=t=>_(t,dt,Tt),Lt=t=>_(t,dt,!1),Et=(t,e,o)=>{const s=(o-1)/2,n=Math.max(Math.min(t-Math.floor(s),e-o+1),1),a=Math.min(Math.max(t+Math.ceil(s),o),e),i=Array.from({length:a+1-n},(u,j)=>j+n);return o>4&&n>1&&i.splice(0,2,1,0),o>3&&a<e&&i.splice(-2,2,0,e),i},Ct=({current:t=1,total:e=10,show:o=7})=>({prev:t>1?t-1:0,next:t<e?t+1:0,pages:Et(t,e,o).map((s,n)=>({current:s===t&&"page",key:`key-${s}-${n}`,page:s}))});if(Z){const t=document.readyState==="loading",e=()=>w(document.body);t?document.addEventListener("DOMContentLoaded",e):e()}w(document.body);function w(t){mt(t),jt(t),St(t),It(t)}function kt(t){ht(t),Mt(t),At(t),Lt(t)}return d.observe=w,d.pagination=Ct,d.styles=_t,d.unobserve=kt,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}),d}({});
1
+ var mtds=function(f){"use strict";const L="_validation_cpy8b_1 _ds-validation-message_1w6ss_1",I="_tag_cpy8b_1 _ds-tag_1w6ss_1",k="_tabs_cpy8b_1 _ds-tabs_1w6ss_1",x="_table_cpy8b_1 _ds-table_1w6ss_1",H="_scrollShadow_cpy8b_1",O="_skeleton_cpy8b_1 _ds-skeleton_1w6ss_1",B="_popover_cpy8b_1",N="_pagination_cpy8b_1 _ds-pagination_1w6ss_1",D="_modal_cpy8b_1 _ds-modal_1w6ss_1",P="_logo_cpy8b_1 _ds-focus_1w6ss_1",U="_link_cpy8b_1",W="_grid_cpy8b_1",R="_flex_cpy8b_1",F="_input_cpy8b_1 _ds-input_1w6ss_1",V="_fieldset_cpy8b_1 _ds-fieldset_1w6ss_1",j="_field_cpy8b_1 _ds-field_1w6ss_1",q="_affixes_cpy8b_1 _ds-field-affixes_1w6ss_1",z="_count_cpy8b_1",K="_errorsummary_cpy8b_1 _ds-error-summary_1w6ss_1",X="_details_cpy8b_1 _ds-details_1w6ss_1",Y="_chip_cpy8b_1 _ds-chip_1w6ss_1",G="_card_cpy8b_1",Q="_info_cpy8b_1",J="_button_cpy8b_1 _ds-button_1w6ss_1",Z="_breadcrumbs_cpy8b_1 _ds-breadcrumbs_1w6ss_1",tt="_badge_cpy8b_1",ot="_avatar_cpy8b_1 _ds-avatar_1w6ss_1",et="_alert_cpy8b_1 _ds-alert_1w6ss_1",nt="_heading_cpy8b_1 _ds-heading_1w6ss_1",st="_body_cpy8b_113",it="_tooltip_cpy8b_128",r={validation:L,tag:I,tabs:k,table:x,scrollShadow:H,skeleton:O,popover:B,pagination:N,modal:D,logo:P,link:U,grid:W,flex:R,input:F,fieldset:V,field:j,affixes:q,count:z,errorsummary:K,details:X,chip:Y,card:G,info:Q,button:J,breadcrumbs:Z,badge:tt,avatar:ot,alert:et,heading:nt,body:st,tooltip:it},ht=Object.freeze(Object.defineProperty({__proto__:null,affixes:q,alert:et,avatar:ot,badge:tt,body:st,breadcrumbs:Z,button:J,card:G,chip:Y,count:z,default:r,details:X,errorsummary:K,field:j,fieldset:V,flex:R,grid:W,heading:nt,info:Q,input:F,link:U,logo:P,modal:D,pagination:N,popover:B,scrollShadow:H,skeleton:O,table:x,tabs:k,tag:I,tooltip:it,validation:L},Symbol.toStringTag,{value:"Module"})),g=typeof window<"u"&&typeof document<"u",u={capture:!0,passive:!0};function l(t,o,e){return e===void 0?t.getAttribute(o)??null:(e===null?t.removeAttribute(o):t.getAttribute(o)!==e&&t.setAttribute(o,e),null)}let gt=0;const wt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function w(t){return t.id||(t.id=`${wt}${++gt}`),t.id}const ct=(t,o,e)=>{for(const s of e[0].split(","))e[0]=s,o[`${t}EventListener`](...e)},m=(t,...o)=>ct("add",t,o),A=(t,...o)=>ct("remove",t,o),M=new Map,d=g?document.createElement("div"):null;d&&l(d,"style","position:absolute;padding:1px;top:0;left:0px"),g&&m(window,"load,resize,scroll",()=>{for(const[t,o]of M)o()},u);const _={top:0,right:1,bottom:2,left:3,none:4};function p(t,o,e){var vt;if(o===!1||!(o!=null&&o.isConnected)||!(t!=null&&t.isConnected))return M.delete(t);if(d!=null&&d.isConnected||document.body.append(d||""),!M.has(t)){const Gt=_[e]??_.bottom;return(vt=M.set(t,()=>p(t,o,Gt)).get(t))==null?void 0:vt()}if(e===_.none)return t.style.setProperty("left","-100vw");const{offsetWidth:s,offsetHeight:n}=t,{offsetWidth:c,offsetHeight:i}=o,{width:v,height:C,left:Ft,top:Vt}=o.getBoundingClientRect(),h=Math.round(Ft-(c-v)/2),y=Math.round(Vt-(i-C)/2),jt=h-s>0,qt=c+c+s<window.innerWidth,zt=y-n>0,Kt=y+i+n<window.innerHeight,Xt=e===_.bottom&&qt||!jt,Yt=e===_.bottom&&Kt||!zt,mt=e===_.top||e===_.bottom;t.style.left=`${Math.round(mt?Math.min(Math.max(10,h-(s-c)/2),window.innerWidth-s-10):Xt?h+c:h-s)}px`,t.style.top=`${Math.round(mt?Yt?y+i:y-n:Math.min(Math.max(10,y-(n-i)/2),window.innerHeight-n-10))}px`,d==null||d.style.setProperty("translate",`${Math.round(window.scrollX+h+c+s+30)} ${Math.round(window.scrollY+y+i+n+30)}px`)}function Mt(t){let o=0;const e=()=>setTimeout(s,200),s=()=>{t([],n),o=0},n=new MutationObserver(()=>{o||(o=requestAnimationFrame(e))});return n}const S=new WeakMap,St=t=>{var e;const o=S.get(t);if(!o||!t.isConnected)(e=o==null?void 0:o.observer)==null||e.disconnect(),S.delete(t);else for(const[,s]of o.collections)s()},b=(t,o,e)=>{const s=t.getElementsByClassName(o);let n=S.get(t);n||(n={collections:new Map,observer:Mt(()=>St(t))},n.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),S.set(t,n)),e?n.collections.set(o,()=>e(s)):n.collections.delete(o)},T=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),at=r.field.split(" ")[0],lt=r.validation.split(" "),$t=lt[0];function At(t){for(const o of t){const e=[],s=[];let n=null,c=!0;for(const i of o.getElementsByTagName("*"))i instanceof HTMLLabelElement?e.push(i):T(i)?n=i:i.classList.contains($t)?(c=i.getAttribute("data-color")==="success",s.unshift(w(i))):i instanceof HTMLParagraphElement&&s.push(w(i));if(n){for(const i of e)i.htmlFor=w(n);rt(n),l(n,"aria-describedby",s.join(" ")),l(n,"aria-invalid",`${!c}`)}}}function dt({target:t}){T(t)&&rt(t)}function rt(t){const o=t==null?void 0:t.nextElementSibling,e=o==null?void 0:o.getAttribute("data-count");if(o&&e){const s=Number(e)-t.value.length,n=s<0;if(o.getAttribute("aria-live")==="polite"!==n){l(o,"aria-live",n?"polite":"off");for(const i of lt)o.classList.toggle(i,n)}o.textContent=`${Math.abs(s)} tegn ${n?"for mye":"igjen"}`}}function Tt(t){b(t,at,At),m(t,"input",dt,u)}function Et(t){b(t,at,!1),A(t,"input",dt,u)}const _t=r.fieldset.split(" ")[0],Ct=r.validation.split(" ")[0];function Lt(t){for(const o of t){const e=[];let s="";for(const n of o.getElementsByTagName("*"))n.classList.contains(Ct)?s=w(n):T(n)&&e.push(n);if(s)for(const n of e)l(n,"aria-describedby",s),l(n,"aria-invalid","true")}}const It=t=>b(t,_t,Lt),kt=t=>b(t,_t,!1);function xt(t){m(t,"toggle",ut,u),m(t,"click",pt)}function Ht(t){A(t,"toggle",ut,u),A(t,"click",pt)}const ft=r.popover.split(" ")[0];function ut({target:t,newState:o}){var e;if(t instanceof HTMLElement&&t.classList.contains(ft)){const s=(e=t.getRootNode())==null?void 0:e.querySelector(`[popovertarget="${t.id}"]`);o==="closed"?p(t,!1):s&&p(t,s,t.getAttribute("data-position")||"bottom")}}function pt({target:t}){var e,s;const o=(e=t==null?void 0:t.closest)==null?void 0:e.call(t,"a");if(o){const n=o.getRootNode(),c=((s=n.getElementById)==null?void 0:s.call(n,l(o,"popovertarget")||""))||o.closest(`.${ft}`),i=l(o,"popovertargetaction")||"toggle";c==null||c.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const bt=r.table.split(" ")[0];function Ot(t){var o,e;for(const s of t)if(s instanceof HTMLTableElement){const n=Array.from(((e=(o=s.tHead)==null?void 0:o.rows[0])==null?void 0:e.cells)||[],c=>{var i;return(i=c.innerText)==null?void 0:i.trim()});for(const c of s.tBodies)for(const i of c.rows)for(const v of i.cells)l(v,"data-th",n[v.cellIndex]||":empty")}}const Bt=t=>b(t,bt,Ot),Nt=t=>b(t,bt,!1);let $=null,yt=0,a=null;g&&(a=document.body.appendChild(document.createElement("div")),a.classList.add(...r.tooltip.split(" ")),l(a,"popover","manual"),m(document,"mousemove",Dt,u));function Dt({target:t}){clearTimeout(yt),yt=setTimeout(Pt,20,t)}function Pt(t){var e;if(!a||t===a)return;const o=(e=t==null?void 0:t.closest)==null?void 0:e.call(t,"[data-tooltip]");!o&&$?(p(a,!1),a==null||a.hidePopover(),$=null):o&&o!==$&&($=o,a.textContent=o.getAttribute("data-tooltip")||"",a.showPopover(),p(a,!1),p(a,o,"top"))}const Ut=(t,o,e)=>{const s=(e-1)/2,n=Math.max(Math.min(t-Math.floor(s),o-e+1),1),c=Math.min(Math.max(t+Math.ceil(s),e),o),i=Array.from({length:c+1-n},(v,C)=>C+n);return e>4&&n>1&&i.splice(0,2,1,0),e>3&&c<o&&i.splice(-2,2,0,o),i},Wt=({current:t=1,total:o=10,show:e=7})=>({prev:t>1?t-1:0,next:t<o?t+1:0,pages:Ut(t,o,e).map((s,n)=>({current:s===t&&"page",key:`key-${s}-${n}`,page:s}))});if(g){const t=document.readyState==="loading",o=()=>E(document.body);t?document.addEventListener("DOMContentLoaded",o):o()}E(document.body);function E(t){Tt(t),It(t),xt(t),Bt(t)}function Rt(t){Et(t),kt(t),Ht(t),Nt(t)}return f.observe=E,f.pagination=Wt,f.styles=ht,f.unobserve=Rt,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"}),f}({});
2
2
  //# sourceMappingURL=index.iife.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.iife.js","sources":["../designsystem/utils.ts","../designsystem/field/field.ts","../designsystem/fieldset/fieldset.ts","../designsystem/popover/popover.ts","../designsystem/table/table.ts","../designsystem/pagination/pagination.ts","../designsystem/index.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\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// 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[`${action}EventListener`](...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/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n let queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tqueue = 0;\n\t};\n const observer = new MutationObserver(() => {\n if (!queue) queue = requestAnimationFrame(onFrame);\n });\n\n return observer;\n}\n\ntype Mutator = { observer: MutationObserver, collections: Map<string, () => void> };\nconst MUTATORS = new WeakMap<Element, Mutator>();\nconst MUTATORS_CALLBACK = (element: Element) => {\n\tconst mutator = MUTATORS.get(element);\n\n\tif (!mutator || !element.isConnected) {\n\t\tmutator?.observer?.disconnect();\n\t\tMUTATORS.delete(element);\n\t} else for(const [, callback] of mutator.collections) callback();\n};\n\nexport const onMutation = (\n\telement: Element,\n\tclassName: string,\n\tcallback: ((collection: HTMLCollection) => void) | false\n) => {\n\tconst collection = element.getElementsByClassName(className);\n\tlet mutator = MUTATORS.get(element);\n\n\tif (!mutator) {\n\t\tmutator = { collections: new Map(), observer: createOptimizedMutationObserver(() => MUTATORS_CALLBACK(element)) };\n\t\tmutator.observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n\t\tMUTATORS.set(element, mutator);\n\t}\n\tif (callback) mutator.collections.set(className, () => callback(collection));\n\telse mutator.collections.delete(className);\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}","import styles from '../styles.module.css';\nimport { QUICK_EVENT, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | 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 (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation 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 if (input) renderCounter(input);\n\n input?.setAttribute('aria-describedby', descs.join(' '));\n input?.setAttribute('aria-invalid', `${!valid}`);\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n\n if (prevInvalid !== nextInvalid) {\n el.setAttribute('aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = `${Math.abs(remainder)} tegn ${nextInvalid ? 'for mye' : 'igjen'}`;\n }\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n\n// TODO: Remove invalid when errormessage is gone","import styles from '../styles.module.css';\nimport { isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n input.setAttribute('aria-describedby', validationId);\n input.setAttribute('aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n","import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(window, 'load,resize,scroll', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n on(document, 'DOMContentReady', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n document.fonts.ready.then(updatePositions); // Inital render and when fonts load\n}\nexport function unobserve(el: Node) {\n off(el, 'click', handleLinkClick);\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nconst POPPING = new Map<Element, () => void>(); // Store current open poppers and their update functions\nSCROLLER?.setAttribute('style', 'position:absolute;padding:1px');\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n const isOver = el.getAttribute('data-position') === 'over';\n \n if (newState === 'closed') POPPING.delete(el);\n else if (anchor) POPPING.set(el, () => place(anchor, el, isOver));\n document.body.append(SCROLLER || ''); // Ensure we have the scroller\n updatePositions();\n }\n}\n\nfunction updatePositions() {\n for (const [_, updatePosition] of POPPING) updatePosition();\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 handleLinkClick (event: Event){\n const link = event.target instanceof Element && event.target.closest('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(link.getAttribute('popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = link.getAttribute('popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}\n\nfunction place (anchor: HTMLElement | null, popper: HTMLElement, isOver = false) {\n if (!anchor?.isConnected || !popper?.isConnected) return POPPING.delete(popper); // Stop watchning if anchor is removed from DOM\n\n const { offsetWidth: popperW, offsetHeight: popperH } = popper;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n const anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n const hasSpaceUnder = anchorY + anchorH + popperH < window.innerHeight;\n const hasSpaceOver = anchorY - popperH > 0\n const placeUnder = (!isOver && hasSpaceUnder) || !hasSpaceOver // Always place under when no hasSpaceOver, as no OS can scroll further up than 0\n const scroll = placeUnder ? window.scrollY + anchorY + anchorH + popperH + 30 : 0\n\n popper.style.left = `${Math.round(Math.min(Math.max(10, anchorX), window.innerWidth - popperW - 10))}px`\n popper.style.top = `${Math.round(placeUnder ? anchorY + anchorH : anchorY - popperH)}px`\n SCROLLER?.style.setProperty('top', `${Math.round(scroll)}px`);\n}\n","import styles from '../styles.module.css';\nimport { onMutation } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n cell.setAttribute('data-th', ths[cell.cellIndex] || ':empty'); // Using U+200B to prevent empty string from collapsing\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_TABLE, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_TABLE, false);\n","const getSteps = (now: number, max: number, show: number) => {\n const offset = (show - 1) / 2;\n const start = Math.max(Math.min(now - Math.floor(offset), max - show + 1), 1);\n const end = Math.min(Math.max(now + Math.ceil(offset), show), max);\n const pages = Array.from({ length: end + 1 - start }, (_, i) => i + start);\n\n if (show > 4 && start > 1) pages.splice(0, 2, 1, 0);\n if (show > 3 && end < max) pages.splice(-2, 2, 0, max);\n return pages;\n};\n\nexport const pagination = ({\n current = 1,\n total = 10,\n show = 7,\n}) => ({\n prev: current > 1 ? current - 1 : 0,\n next: current < total ? current + 1 : 0,\n pages: getSteps(current, total, show).map((page, index) => ({\n current: page === current && 'page' as const,\n key: `key-${page}-${index}`,\n page,\n })),\n});\n","import * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) {\n // Check if the page is still loading - might happen if the script is in <head>\n const isLoading = document.readyState === \"loading\";\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n \n observe(document.body); // Automatic observe on browser\n\nexport function observe(el: Element) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n fieldset.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","QUICK_EVENT","id","UUID","useId","el","events","action","element","rest","type","on","off","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","_a","onMutation","className","collection","isInputLike","CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","unobserve","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","handleLinkClick","handleToggle","updatePositions","CSS_POPOVER","SCROLLER","POPPING","newState","anchor","isOver","place","_","updatePosition","event","link","root","popper","popperW","popperH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceUnder","hasSpaceOver","placeUnder","scroll","CSS_TABLE","tables","table","ths","_b","tbody","row","cell","getSteps","now","max","show","offset","start","end","pages","i","pagination","current","total","page","index","isLoading","onLoaded","field.observe","fieldset.observe","popover.observe","table.observe","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":"gqDAAaA,EAAa,OAAO,OAAW,KAAe,OAAO,SAAa,IAClEC,EAAc,CAAE,QAAS,GAAM,QAAS,EAAK,EAM1D,IAAIC,GAAK,EACT,MAAMC,GAAO,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,EAAI,GAAG,EAAED,EAAE,IAC5BG,EAAG,EACX,CAGA,MAAMC,GAAS,CACdC,EACAC,EACAC,IACU,CACV,UAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG,EACnCA,EAAK,CAAC,EAAIC,EACVF,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGE,CAAI,CAE3C,EAQaE,EAAK,CACjBH,KACGC,IACOH,GAAO,MAAOE,EAASC,CAAI,EAQzBG,EAAM,CAClBJ,KACGC,IACOH,GAAO,SAAUE,EAASC,CAAI,EAMlC,SAASI,GAAgCC,EAA4B,CAC1E,IAAIC,EAAQ,EAEb,MAAMC,EAAU,IAAM,WAAWC,EAAS,GAAG,EACvCA,EAAU,IAAM,CACZH,EAAA,GAAII,CAAQ,EACbH,EAAA,CACT,EACOG,EAAW,IAAI,iBAAiB,IAAM,CACrCH,IAAeA,EAAA,sBAAsBC,CAAO,EAAA,CAClD,EAEM,OAAAE,CACT,CAGA,MAAMC,MAAe,QACfC,GAAqBZ,GAAqB,OACzC,MAAAa,EAAUF,EAAS,IAAIX,CAAO,EAEpC,GAAI,CAACa,GAAW,CAACb,EAAQ,aACxBc,EAAAD,GAAA,YAAAA,EAAS,WAAT,MAAAC,EAAmB,aACnBH,EAAS,OAAOX,CAAO,gBACP,CAAA,CAAGM,CAAQ,IAAKO,EAAQ,YAAsBP,EAAA,CAChE,EAEaS,E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T,EAEaE,GAAa,CAAC,CACzB,QAAAC,EAAU,EACV,MAAAC,EAAQ,GACR,KAAAR,EAAO,CACT,KAAO,CACL,KAAMO,EAAU,EAAIA,EAAU,EAAI,EAClC,KAAMA,EAAUC,EAAQD,EAAU,EAAI,EACtC,MAAOV,GAASU,EAASC,EAAOR,CAAI,EAAE,IAAI,CAACS,EAAMC,KAAW,CAC1D,QAASD,IAASF,GAAW,OAC7B,IAAK,OAAOE,CAAI,IAAIC,CAAK,GACzB,KAAAD,CAAA,EACA,CACJ,GCfA,GAAIxG,EAAY,CAER,MAAA0G,EAAY,SAAS,aAAe,UACpCC,EAAW,IAAM7D,EAAQ,SAAS,IAAI,EAExC4D,EAAW,SAAS,iBAAiB,mBAAoBC,CAAQ,EACvDA,EAAA,CAChB,CAEE7D,EAAQ,SAAS,IAAI,EAEhB,SAASA,EAAQzC,EAAa,CACnCuG,GAAcvG,CAAE,EAChBwG,GAAiBxG,CAAE,EACnByG,GAAgBzG,CAAE,EAClB0G,GAAc1G,CAAE,CAClB,CAEO,SAAS0C,GAAU1C,EAAa,CACrC2G,GAAgB3G,CAAE,EAClB4G,GAAmB5G,CAAE,EACrB6G,GAAkB7G,CAAE,EACpB8G,GAAgB9G,CAAE,CACpB"}
1
+ {"version":3,"file":"index.iife.js","sources":["../designsystem/utils.ts","../designsystem/field/field.ts","../designsystem/fieldset/fieldset.ts","../designsystem/popover/popover.ts","../designsystem/table/table.ts","../designsystem/tooltip.ts","../designsystem/pagination/pagination.ts","../designsystem/index.ts"],"sourcesContent":["export const IS_BROWSER = typeof window !== 'undefined' && typeof document !== 'undefined';\nexport const QUICK_EVENT = { capture: true, passive: true };\n\n/**\n * attr\n * @description Utility to quickly get, set and remove attributes\n * @param el The Element to use as EventTarget\n * @param name The attribute name to get, set or remove, or a object to set multiple attributes\n * @param value A valid attribute value or null to remove attribute\n */\nexport function attr(\n\tel: Element,\n\tname: string,\n\tvalue?: string | null,\n): string | null {\n\tif (value === undefined) return el.getAttribute(name) ?? null; // Fallback to null only if el is undefined\n\tif (value === null) el.removeAttribute(name);\n\telse if (el.getAttribute(name) !== value) el.setAttribute(name, value);\n\treturn null;\n}\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// 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[`${action}EventListener`](...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\nconst TARGETS = new Map<Element, () => void>(); // Store current open poppers and their update functions\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) attr(SCROLLER, 'style', 'position:absolute;padding:1px;top:0;left:0px');\n\nif (IS_BROWSER){\n\ton(window, 'load,resize,scroll', () => {\n\t\tfor (const [_, update] of TARGETS) update();\n\t}, QUICK_EVENT);}\n\t\n/**\n * anchorPosition\n * @param target The Element to position\n * @param anchor The Element to use as anchor\n */\nconst ANCHOR = { top: 0, right: 1, bottom: 2, left: 3, none: 4 }; // Speed up by using a const map\n\nexport function anchorPosition (target: HTMLElement, anchor: HTMLElement | null | false, position?: string | number) {\n\tif (anchor === false || !anchor?.isConnected || !target?.isConnected) return TARGETS.delete(target); // Stop watchning if anchor is removed from DOM\n\tif (!SCROLLER?.isConnected) document.body.append(SCROLLER || ''); // Ensure we have t´he scroller\n\tif (!TARGETS.has(target)) {\n\t\tconst place = ANCHOR[position as keyof typeof ANCHOR] ?? ANCHOR.bottom; // Use CSS property to store position for more flexibility\n\t\treturn TARGETS.set(target, () => anchorPosition(target, anchor, place)).get(target)?.(); // Start watching if not already watching\n\t}\n\tif (position === ANCHOR.none) return target.style.setProperty('left', '-100vw'); // Hide target if anchor is set to none\n\n const { offsetWidth: targetW, offsetHeight: targetH } = target;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n\tconst anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n\n\tconst hasSpaceLeft = anchorX - targetW > 0\n\tconst hasSpaceRight = anchorW + anchorW + targetW < window.innerWidth;\n\tconst hasSpaceOver = anchorY - targetH > 0\n\tconst hasSpaceUnder = anchorY + anchorH + targetH < window.innerHeight;\n\tconst positionRight = (position === ANCHOR.bottom && hasSpaceRight) || !hasSpaceLeft // Always position under when no hasSpaceOver, as no OS can scroll further up than 0\n\tconst positionUnder = (position === ANCHOR.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS can scroll further up than 0\n\tconst isVertical = position === ANCHOR.top || position === ANCHOR.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10) : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10))}px`\n SCROLLER?.style.setProperty('translate', `${Math.round(window.scrollX + anchorX + anchorW + targetW + 30)} ${Math.round(window.scrollY + anchorY + anchorH + targetH + 30)}px`);\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 let queue = 0;\n\n\tconst onFrame = () => setTimeout(onTimer, 200); // Use both requestAnimationFrame and setTimeout to debounce and only run when visible\n\tconst onTimer = () => {\n\t\tcallback([], observer);\n\t\tqueue = 0;\n\t};\n const observer = new MutationObserver(() => {\n if (!queue) queue = requestAnimationFrame(onFrame);\n });\n\n return observer;\n}\n\ntype Mutator = { observer: MutationObserver, collections: Map<string, () => void> };\nconst MUTATORS = new WeakMap<Element, Mutator>();\nconst MUTATORS_CALLBACK = (element: Element) => {\n\tconst mutator = MUTATORS.get(element);\n\n\tif (!mutator || !element.isConnected) {\n\t\tmutator?.observer?.disconnect();\n\t\tMUTATORS.delete(element);\n\t} else for(const [, callback] of mutator.collections) callback();\n};\n\n/**\n * onMutation\n * @description Utility to quickly observe mutations on a specific class name\n * @param element The Element to use as EventTarget\n * @param className The class name to observe\n * @param callback The callback to run when mutations are detected or false to stop observing\n */\nexport const onMutation = (\n\telement: Element,\n\tclassName: string,\n\tcallback: ((collection: HTMLCollection) => void) | false\n) => {\n\tconst collection = element.getElementsByClassName(className);\n\tlet mutator = MUTATORS.get(element);\n\n\tif (!mutator) {\n\t\tmutator = { collections: new Map(), observer: createOptimizedMutationObserver(() => MUTATORS_CALLBACK(element)) };\n\t\tmutator.observer.observe(element, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });\n\t\tMUTATORS.set(element, mutator);\n\t}\n\tif (callback) mutator.collections.set(className, () => callback(collection));\n\telse mutator.collections.delete(className);\n}\n\nexport const isInputLike = (el: unknown): el is HTMLInputElement =>\n\tel instanceof HTMLElement && 'validity' in el && !(el instanceof HTMLButtonElement);\n\n// Make React support popover=\"\"target attribute\n// https://github.com/facebook/react/issues/27479\ntype Popover = \"\" | \"auto\" | \"manual\" | undefined;\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n\tnamespace React {\n\t\tinterface HTMLAttributes<T> {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: Popover;\n\t\t}\n\t}\n}","import styles from '../styles.module.css';\nimport { QUICK_EVENT, attr, isInputLike, off, on, onMutation, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\n\nfunction renderAria(fields: HTMLCollectionOf<Element>) {\n for(const field of fields) {\n const labels: HTMLLabelElement[] = [];\n const descs: string[] = [];\n let input: HTMLInputElement | 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 (isInputLike(el)) input = el;\n else if (el.classList.contains(CSS_VALIDATION)) { // Must be before instanceof HTMLParagraphElement since validation 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) {\n for (const label of labels) label.htmlFor = useId(input);\n renderCounter(input);\n attr(input, 'aria-describedby', descs.join(' '));\n attr(input, 'aria-invalid', `${!valid}`);\n }\n }\n}\nfunction handleInput({ target }: Event) {\n if (isInputLike(target)) renderCounter(target);\n}\n\nfunction renderCounter(input: HTMLInputElement) {\n const el = input?.nextElementSibling;\n const limit = el?.getAttribute('data-count');\n\n if (el && limit) {\n const remainder = Number(limit) - input.value.length;\n const nextInvalid = remainder < 0;\n const prevInvalid = el.getAttribute('aria-live') === 'polite';\n\n if (prevInvalid !== nextInvalid) {\n attr(el, 'aria-live', nextInvalid ? 'polite' : 'off');\n for (const css of CSS_VALIDATIONS) el.classList.toggle(css, nextInvalid);\n }\n el.textContent = `${Math.abs(remainder)} tegn ${nextInvalid ? 'for mye' : 'igjen'}`;\n }\n}\n\nexport function observe (el: Element) {\n onMutation(el, CSS_FIELD, renderAria);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element) {\n onMutation(el, CSS_FIELD, false);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n","import styles from '../styles.module.css';\nimport { attr, isInputLike, onMutation, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\n\nfunction process(fieldsets: HTMLCollectionOf<Element>) {\n for(const fieldset of fieldsets) {\n const inputs: HTMLInputElement[] = [];\n let validationId = '';\n\n for (const el of fieldset.getElementsByTagName('*')) {\n if (el.classList.contains(CSS_VALIDATION)) validationId = useId(el);\n else if (isInputLike(el)) inputs.push(el);\n }\n\n if (validationId) \n for(const input of inputs) {\n attr(input, 'aria-describedby', validationId);\n attr(input, 'aria-invalid', 'true');\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_FIELDSET, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_FIELDSET, false);\n","import styles from '../styles.module.css';\nimport { QUICK_EVENT, anchorPosition, attr, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n}\nexport function unobserve(el: Node) {\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n off(el, 'click', handleLinkClick);\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n \n if (newState === 'closed') anchorPosition(el, false);\n else if (anchor) anchorPosition(el, anchor, el.getAttribute('data-position') || 'bottom');\n }\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 handleLinkClick ({ target }: Event){\n const link = (target as Element )?.closest?.('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(attr(link, 'popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = attr(link, 'popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}","import styles from '../styles.module.css';\nimport { attr, onMutation } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\n\nfunction process(tables: HTMLCollectionOf<Element>) {\n for(const table of tables) if (table instanceof HTMLTableElement) {\n const ths = Array.from(table.tHead?.rows[0]?.cells || [], (el) => el.innerText?.trim()); // Using innerText to only include visible text\n for (const tbody of table.tBodies) {\n for (const row of tbody.rows) {\n for (const cell of row.cells) {\n attr(cell, 'data-th', ths[cell.cellIndex] || ':empty');\n }\n }\n }\n }\n}\n\nexport const observe = (el: Element) => onMutation(el, CSS_TABLE, process);\nexport const unobserve = (el: Element) => onMutation(el, CSS_TABLE, false);\n","import styles from './styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, anchorPosition, attr, on } from \"./utils\";\n\nlet ANCHOR: Element | null = null;\nlet DEBOUNCE: number | ReturnType<typeof setTimeout> = 0;\nlet TOOLTIP: HTMLElement | null = null;\n\nif (IS_BROWSER) {\n TOOLTIP = document.body.appendChild(document.createElement('div'));\n TOOLTIP.classList.add(...styles.tooltip.split(' '));\n attr(TOOLTIP, 'popover', 'manual');\n on(document, 'mousemove', handleMove, QUICK_EVENT);\n}\n\nfunction handleMove({ target }: Event) {\n clearTimeout(DEBOUNCE);\n DEBOUNCE = setTimeout(handleMoveDebounced, 20, target);\n}\n\nfunction handleMoveDebounced(target: Element | null) {\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n const anchor = target?.closest?.<HTMLElement>('[data-tooltip]');\n \n if (!anchor && ANCHOR) {\n anchorPosition(TOOLTIP, false);\n TOOLTIP?.hidePopover();\n ANCHOR = null;\n } else if (anchor && anchor !== ANCHOR) {\n ANCHOR = anchor;\n TOOLTIP.textContent = anchor.getAttribute('data-tooltip') || '';\n TOOLTIP.showPopover();\n anchorPosition(TOOLTIP, false); // Reset position\n anchorPosition(TOOLTIP, anchor, 'top');\n }\n}","const getSteps = (now: number, max: number, show: number) => {\n const offset = (show - 1) / 2;\n const start = Math.max(Math.min(now - Math.floor(offset), max - show + 1), 1);\n const end = Math.min(Math.max(now + Math.ceil(offset), show), max);\n const pages = Array.from({ length: end + 1 - start }, (_, i) => i + start);\n\n if (show > 4 && start > 1) pages.splice(0, 2, 1, 0);\n if (show > 3 && end < max) pages.splice(-2, 2, 0, max);\n return pages;\n};\n\nexport const pagination = ({\n current = 1,\n total = 10,\n show = 7,\n}) => ({\n prev: current > 1 ? current - 1 : 0,\n next: current < total ? current + 1 : 0,\n pages: getSteps(current, total, show).map((page, index) => ({\n current: page === current && 'page' as const,\n key: `key-${page}-${index}`,\n page,\n })),\n});\n","import * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport './tooltip'; // Load data-tooltip behaviour\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) {\n // Check if the page is still loading - might happen if the script is in <head>\n const isLoading = document.readyState === \"loading\";\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n \n observe(document.body); // Automatic observe on browser\n\nexport function observe(el: Element) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n fieldset.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","QUICK_EVENT","attr","el","name","value","id","UUID","useId","events","action","element","rest","type","on","off","TARGETS","SCROLLER","_","update","ANCHOR","anchorPosition","target","anchor","position","place","_a","targetW","targetH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceLeft","hasSpaceRight","hasSpaceOver","hasSpaceUnder","positionRight","positionUnder","isVertical","createOptimizedMutationObserver","callback","queue","onFrame","onTimer","observer","MUTATORS","MUTATORS_CALLBACK","mutator","onMutation","className","collection","isInputLike","CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","renderAria","fields","field","labels","descs","input","valid","label","renderCounter","handleInput","limit","remainder","nextInvalid","css","observe","unobserve","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","handleToggle","handleLinkClick","CSS_POPOVER","newState","link","root","_b","CSS_TABLE","tables","table","ths","tbody","row","cell","DEBOUNCE","TOOLTIP","handleMove","handleMoveDebounced","getSteps","now","max","show","offset","start","end","pages","i","pagination","current","total","page","index","isLoading","onLoaded","field.observe","fieldset.observe","popover.observe","table.observe","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":"8uDAAaA,EAAa,OAAO,OAAW,KAAe,OAAO,SAAa,IAClEC,EAAc,CAAE,QAAS,GAAM,QAAS,EAAK,EAS1C,SAAAC,EACfC,EACAC,EACAC,EACgB,CAChB,OAAIA,IAAU,OAAkBF,EAAG,aAAaC,CAAI,GAAK,MACrDC,IAAU,KAASF,EAAA,gBAAgBC,CAAI,EAClCD,EAAG,aAAaC,CAAI,IAAMC,GAAUF,EAAA,aAAaC,EAAMC,CAAK,EAC9D,KACR,CAMA,IAAIC,GAAK,EACT,MAAMC,GAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,CAAC,GACzE,SAASC,EAAOL,EAAa,CAC9B,OAACA,EAAG,KAAIA,EAAG,GAAK,GAAGI,EAAI,GAAG,EAAED,E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IA,EAAU,EAAI,EAClC,KAAMA,EAAUC,EAAQD,EAAU,EAAI,EACtC,MAAOV,GAASU,EAASC,EAAOR,CAAI,EAAE,IAAI,CAACS,EAAMC,KAAW,CAC1D,QAASD,IAASF,GAAW,OAC7B,IAAK,OAAOE,CAAI,IAAIC,CAAK,GACzB,KAAAD,CAAA,EACA,CACJ,GCdA,GAAIjH,EAAY,CAER,MAAAmH,EAAY,SAAS,aAAe,UACpCC,EAAW,IAAMzC,EAAQ,SAAS,IAAI,EAExCwC,EAAW,SAAS,iBAAiB,mBAAoBC,CAAQ,EACvDA,EAAA,CAChB,CAEEzC,EAAQ,SAAS,IAAI,EAEhB,SAASA,EAAQxE,EAAa,CACnCkH,GAAclH,CAAE,EAChBmH,GAAiBnH,CAAE,EACnBoH,GAAgBpH,CAAE,EAClBqH,GAAcrH,CAAE,CAClB,CAEO,SAASyE,GAAUzE,EAAa,CACrCsH,GAAgBtH,CAAE,EAClBuH,GAAmBvH,CAAE,EACrBwH,GAAkBxH,CAAE,EACpByH,GAAgBzH,CAAE,CACpB"}
package/mtds/index.js CHANGED
@@ -1,25 +1,26 @@
1
- import { observe as r, unobserve as n } from "./field/field.js";
1
+ import { observe as s, unobserve as n } from "./field/field.js";
2
2
  import { observe as t, unobserve as b } from "./fieldset/fieldset.js";
3
- import { observe as a, unobserve as v } from "./popover/popover.js";
4
- import { observe as m, unobserve as d } from "./table/table.js";
5
- import { IS_BROWSER as i } from "./utils.js";
6
- import { pagination as S } from "./pagination/pagination.js";
7
- import * as y from "./styles.module.css.js";
8
- if (i) {
9
- const o = document.readyState === "loading", e = () => s(document.body);
3
+ import { observe as a, unobserve as m } from "./popover/popover.js";
4
+ import { observe as v, unobserve as i } from "./table/table.js";
5
+ import "./tooltip.js";
6
+ import { IS_BROWSER as d } from "./utils.js";
7
+ import { pagination as E } from "./pagination/pagination.js";
8
+ import * as L from "./styles.module.css.js";
9
+ if (d) {
10
+ const o = document.readyState === "loading", e = () => r(document.body);
10
11
  o ? document.addEventListener("DOMContentLoaded", e) : e();
11
12
  }
12
- s(document.body);
13
- function s(o) {
14
- r(o), t(o), a(o), m(o);
13
+ r(document.body);
14
+ function r(o) {
15
+ s(o), t(o), a(o), v(o);
15
16
  }
16
- function L(o) {
17
- n(o), b(o), v(o), d(o);
17
+ function g(o) {
18
+ n(o), b(o), m(o), i(o);
18
19
  }
19
20
  export {
20
- s as observe,
21
- S as pagination,
22
- y as styles,
23
- L as unobserve
21
+ r as observe,
22
+ E as pagination,
23
+ L as styles,
24
+ g as unobserve
24
25
  };
25
26
  //# sourceMappingURL=index.js.map
package/mtds/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["import * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) {\n // Check if the page is still loading - might happen if the script is in <head>\n const isLoading = document.readyState === \"loading\";\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n \n observe(document.body); // Automatic observe on browser\n\nexport function observe(el: Element) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n fieldset.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","isLoading","onLoaded","observe","el","field.observe","fieldset.observe","popover.observe","table.observe","unobserve","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":";;;;;;;AAQA,IAAIA,GAAY;AAER,QAAAC,IAAY,SAAS,eAAe,WACpCC,IAAW,MAAMC,EAAQ,SAAS,IAAI;AAE5C,EAAIF,IAAW,SAAS,iBAAiB,oBAAoBC,CAAQ,IACvDA,EAAA;AAChB;AAEEC,EAAQ,SAAS,IAAI;AAEhB,SAASA,EAAQC,GAAa;AACnCC,EAAAA,EAAcD,CAAE,GAChBE,EAAiBF,CAAE,GACnBG,EAAgBH,CAAE,GAClBI,EAAcJ,CAAE;AAClB;AAEO,SAASK,EAAUL,GAAa;AACrCM,EAAAA,EAAgBN,CAAE,GAClBO,EAAmBP,CAAE,GACrBQ,EAAkBR,CAAE,GACpBS,EAAgBT,CAAE;AACpB;"}
1
+ {"version":3,"file":"index.js","sources":["../designsystem/index.ts"],"sourcesContent":["import * as field from './field/field';\nimport * as fieldset from './fieldset/fieldset';\nimport * as popover from './popover/popover';\nimport * as table from './table/table';\nimport './tooltip'; // Load data-tooltip behaviour\nimport { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) {\n // Check if the page is still loading - might happen if the script is in <head>\n const isLoading = document.readyState === \"loading\";\n const onLoaded = () => observe(document.body);\n\n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\n \n observe(document.body); // Automatic observe on browser\n\nexport function observe(el: Element) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element) {\n field.unobserve(el);\n fieldset.unobserve(el);\n popover.unobserve(el);\n table.unobserve(el);\n}"],"names":["IS_BROWSER","isLoading","onLoaded","observe","el","field.observe","fieldset.observe","popover.observe","table.observe","unobserve","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":";;;;;;;;AASA,IAAIA,GAAY;AAER,QAAAC,IAAY,SAAS,eAAe,WACpCC,IAAW,MAAMC,EAAQ,SAAS,IAAI;AAE5C,EAAIF,IAAW,SAAS,iBAAiB,oBAAoBC,CAAQ,IACvDA,EAAA;AAChB;AAEEC,EAAQ,SAAS,IAAI;AAEhB,SAASA,EAAQC,GAAa;AACnCC,EAAAA,EAAcD,CAAE,GAChBE,EAAiBF,CAAE,GACnBG,EAAgBH,CAAE,GAClBI,EAAcJ,CAAE;AAClB;AAEO,SAASK,EAAUL,GAAa;AACrCM,EAAAA,EAAgBN,CAAE,GAClBO,EAAmBP,CAAE,GACrBQ,EAAkBR,CAAE,GACpBS,EAAgBT,CAAE;AACpB;"}
@@ -1,38 +1,29 @@
1
- import k from "../styles.module.css.js";
2
- import { IS_BROWSER as E, on as r, QUICK_EVENT as l, off as h } from "../utils.js";
3
- function I(t) {
4
- r(t, "click", v), r(t, "toggle", m, l), r(window, "load,resize,scroll", f, l), r(document, "DOMContentReady", f, l), document.fonts.ready.then(f);
1
+ import m from "../styles.module.css.js";
2
+ import { on as f, QUICK_EVENT as a, anchorPosition as l, attr as p, off as r } from "../utils.js";
3
+ function k(o) {
4
+ f(o, "toggle", g, a), f(o, "click", v);
5
5
  }
6
- function N(t) {
7
- h(t, "click", v), h(t, "toggle", m, l);
6
+ function E(o) {
7
+ r(o, "toggle", g, a), r(o, "click", v);
8
8
  }
9
- const p = k.popover.split(" ")[0], i = E ? document.createElement("div") : null, g = /* @__PURE__ */ new Map();
10
- i == null || i.setAttribute("style", "position:absolute;padding:1px");
11
- function m({ target: t, newState: o }) {
12
- var s;
13
- if (t instanceof HTMLElement && t.classList.contains(p)) {
14
- const n = (s = t.getRootNode()) == null ? void 0 : s.querySelector(`[popovertarget="${t.id}"]`), e = t.getAttribute("data-position") === "over";
15
- o === "closed" ? g.delete(t) : n && g.set(t, () => $(n, t, e)), document.body.append(i || ""), f();
9
+ const d = m.popover.split(" ")[0];
10
+ function g({ target: o, newState: t }) {
11
+ var n;
12
+ if (o instanceof HTMLElement && o.classList.contains(d)) {
13
+ const i = (n = o.getRootNode()) == null ? void 0 : n.querySelector(`[popovertarget="${o.id}"]`);
14
+ t === "closed" ? l(o, !1) : i && l(o, i, o.getAttribute("data-position") || "bottom");
16
15
  }
17
16
  }
18
- function f() {
19
- for (const [t, o] of g) o();
20
- }
21
- function v(t) {
22
- var s;
23
- const o = t.target instanceof Element && t.target.closest("a");
24
- if (o) {
25
- const n = o.getRootNode(), e = ((s = n.getElementById) == null ? void 0 : s.call(n, o.getAttribute("popovertarget") || "")) || o.closest(`.${p}`), d = o.getAttribute("popovertargetaction") || "toggle";
26
- e == null || e.togglePopover(d === "show" || (d === "hide" ? !1 : void 0));
17
+ function v({ target: o }) {
18
+ var n, i;
19
+ const t = (n = o == null ? void 0 : o.closest) == null ? void 0 : n.call(o, "a");
20
+ if (t) {
21
+ const e = t.getRootNode(), s = ((i = e.getElementById) == null ? void 0 : i.call(e, p(t, "popovertarget") || "")) || t.closest(`.${d}`), c = p(t, "popovertargetaction") || "toggle";
22
+ s == null || s.togglePopover(c === "show" || (c === "hide" ? !1 : void 0));
27
23
  }
28
24
  }
29
- function $(t, o, s = !1) {
30
- if (!(t != null && t.isConnected) || !(o != null && o.isConnected)) return g.delete(o);
31
- const { offsetWidth: n, offsetHeight: e } = o, { offsetWidth: d, offsetHeight: a } = t, { width: w, height: y, left: M, top: P } = t.getBoundingClientRect(), b = Math.round(M - (d - w) / 2), c = Math.round(P - (a - y) / 2), x = c + a + e < window.innerHeight, H = c - e > 0, u = !s && x || !H, W = u ? window.scrollY + c + a + e + 30 : 0;
32
- o.style.left = `${Math.round(Math.min(Math.max(10, b), window.innerWidth - n - 10))}px`, o.style.top = `${Math.round(u ? c + a : c - e)}px`, i == null || i.style.setProperty("top", `${Math.round(W)}px`);
33
- }
34
25
  export {
35
- I as observe,
36
- N as unobserve
26
+ k as observe,
27
+ E as unobserve
37
28
  };
38
29
  //# sourceMappingURL=popover.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(window, 'load,resize,scroll', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n on(document, 'DOMContentReady', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n document.fonts.ready.then(updatePositions); // Inital render and when fonts load\n}\nexport function unobserve(el: Node) {\n off(el, 'click', handleLinkClick);\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nconst POPPING = new Map<Element, () => void>(); // Store current open poppers and their update functions\nSCROLLER?.setAttribute('style', 'position:absolute;padding:1px');\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n const isOver = el.getAttribute('data-position') === 'over';\n \n if (newState === 'closed') POPPING.delete(el);\n else if (anchor) POPPING.set(el, () => place(anchor, el, isOver));\n document.body.append(SCROLLER || ''); // Ensure we have the scroller\n updatePositions();\n }\n}\n\nfunction updatePositions() {\n for (const [_, updatePosition] of POPPING) updatePosition();\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 handleLinkClick (event: Event){\n const link = event.target instanceof Element && event.target.closest('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(link.getAttribute('popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = link.getAttribute('popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}\n\nfunction place (anchor: HTMLElement | null, popper: HTMLElement, isOver = false) {\n if (!anchor?.isConnected || !popper?.isConnected) return POPPING.delete(popper); // Stop watchning if anchor is removed from DOM\n\n const { offsetWidth: popperW, offsetHeight: popperH } = popper;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n const anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n const hasSpaceUnder = anchorY + anchorH + popperH < window.innerHeight;\n const hasSpaceOver = anchorY - popperH > 0\n const placeUnder = (!isOver && hasSpaceUnder) || !hasSpaceOver // Always place under when no hasSpaceOver, as no OS can scroll further up than 0\n const scroll = placeUnder ? window.scrollY + anchorY + anchorH + popperH + 30 : 0\n\n popper.style.left = `${Math.round(Math.min(Math.max(10, anchorX), window.innerWidth - popperW - 10))}px`\n popper.style.top = `${Math.round(placeUnder ? anchorY + anchorH : anchorY - popperH)}px`\n SCROLLER?.style.setProperty('top', `${Math.round(scroll)}px`);\n}\n"],"names":["observe","el","on","handleLinkClick","handleToggle","QUICK_EVENT","updatePositions","unobserve","off","CSS_POPOVER","styles","SCROLLER","IS_BROWSER","POPPING","newState","anchor","_a","isOver","place","_","updatePosition","event","link","root","target","action","popper","popperW","popperH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceUnder","hasSpaceOver","placeUnder","scroll"],"mappings":";;AAGO,SAASA,EAAQC,GAAU;AAC7B,EAAAC,EAAAD,GAAI,SAASE,CAAe,GAC5BD,EAAAD,GAAI,UAAUG,GAAcC,CAAW,GACvCH,EAAA,QAAQ,sBAAsBI,GAAiBD,CAAW,GAC1DH,EAAA,UAAU,mBAAmBI,GAAiBD,CAAW,GACnD,SAAA,MAAM,MAAM,KAAKC,CAAe;AAC3C;AACO,SAASC,EAAUN,GAAU;AAC9B,EAAAO,EAAAP,GAAI,SAASE,CAAe,GAC5BK,EAAAP,GAAI,UAAUG,GAAcC,CAAW;AAC7C;AAEA,MAAMI,IAAcC,EAAO,QAAQ,MAAM,GAAG,EAAE,CAAC,GACzCC,IAAWC,IAAa,SAAS,cAAc,KAAK,IAAI,MACxDC,wBAAc,IAAyB;AAC7CF,KAAA,QAAAA,EA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Q,MAAAC,GAAM,KAAAC,EAAI,IAAInB,EAAO,sBAAsB,GAC5DoB,IAAU,KAAK,MAAMF,KAAQJ,IAAUE,KAAS,CAAC,GACjDK,IAAU,KAAK,MAAMF,KAAOJ,IAAUE,KAAU,CAAC,GACjDK,IAAgBD,IAAUN,IAAUF,IAAU,OAAO,aACrDU,IAAeF,IAAUR,IAAU,GACnCW,IAAc,CAACtB,KAAUoB,KAAkB,CAACC,GAC5CE,IAASD,IAAa,OAAO,UAAUH,IAAUN,IAAUF,IAAU,KAAK;AAEhF,EAAAF,EAAO,MAAM,OAAO,GAAG,KAAK,MAAM,KAAK,IAAI,KAAK,IAAI,IAAIS,CAAO,GAAG,OAAO,aAAaR,IAAU,EAAE,CAAC,CAAC,MAC7FD,EAAA,MAAM,MAAM,GAAG,KAAK,MAAMa,IAAaH,IAAUN,IAAUM,IAAUR,CAAO,CAAC,MAC1EjB,KAAA,QAAAA,EAAA,MAAM,YAAY,OAAO,GAAG,KAAK,MAAM6B,CAAM,CAAC;AAC1D;"}
1
+ {"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, anchorPosition, attr, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n}\nexport function unobserve(el: Node) {\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n off(el, 'click', handleLinkClick);\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n \n if (newState === 'closed') anchorPosition(el, false);\n else if (anchor) anchorPosition(el, anchor, el.getAttribute('data-position') || 'bottom');\n }\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 handleLinkClick ({ target }: Event){\n const link = (target as Element )?.closest?.('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(attr(link, 'popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = attr(link, 'popovertargetaction') || 'toggle';\n\n target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}"],"names":["observe","el","on","handleToggle","QUICK_EVENT","handleLinkClick","unobserve","off","CSS_POPOVER","styles","newState","anchor","_a","anchorPosition","target","link","root","_b","attr","action"],"mappings":";;AAGO,SAASA,EAAQC,GAAU;AAC7B,EAAAC,EAAAD,GAAI,UAAUE,GAAcC,CAAW,GACvCF,EAAAD,GAAI,SAASI,CAAe;AACjC;AACO,SAASC,EAAUL,GAAU;AAC9B,EAAAM,EAAAN,GAAI,UAAUE,GAAcC,CAAW,GACvCG,EAAAN,GAAI,SAASI,CAAe;AAClC;AAEA,MAAMG,IAAcC,EAAO,QAAQ,MAAM,GAAG,EAAE,CAAC;AAE/C,SAASN,EAAc,EAAE,QAAQF,GAAI,UAAAS,KAA0C;;AAC7E,MAAIT,aAAc,eAAeA,EAAG,UAAU,SAASO,CAAW,GAAG;AAC7D,UAAAG,KAAUC,IAAAX,EAAG,kBAAH,gBAAAW,EAAiC,cAA2B,mBAAmBX,EAAG,EAAE;AAEpG,IAAIS,MAAa,WAAyBG,EAAAZ,GAAI,EAAK,IAC1CU,OAAuBV,GAAIU,GAAQV,EAAG,aAAa,eAAe,KAAK,QAAQ;AAAA,EAAA;AAE5F;AAKA,SAASI,EAAiB,EAAE,QAAAS,KAAgB;;AACpC,QAAAC,KAAQH,IAAAE,KAAA,gBAAAA,EAAqB,YAArB,gBAAAF,EAAA,KAAAE,GAA+B;AAC7C,MAAIC,GAAM;AACF,UAAAC,IAAOD,EAAK,YAAY,GACxBD,MAASG,IAAAD,EAAK,mBAAL,gBAAAC,EAAA,KAAAD,GAAsBE,EAAKH,GAAM,eAAe,KAAK,QAAOA,EAAK,QAAQ,IAAIP,CAAW,EAAE,GACnGW,IAASD,EAAKH,GAAM,qBAAqB,KAAK;AAEpDD,IAAAA,KAAAA,QAAAA,EAAQ,cAAcK,MAAW,WAAWA,MAAW,SAAS,KAAQ;AAAA,EAAU;AAEtF;"}