@mattilsynet/design 0.2.16 → 0.2.18

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.
@@ -5,7 +5,7 @@ declare const meta: {
5
5
  export default meta;
6
6
  type Story = StoryObj<typeof meta>;
7
7
  export declare const Default: Story;
8
- export declare const Variants: Story;
8
+ export declare const Colors: Story;
9
9
  export declare const Sizes: Story;
10
10
  export declare const WithTitle: Story;
11
11
  export declare const WithClose: Story;
@@ -1,5 +1,5 @@
1
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";
2
+ import { onMutation as c, on as I, QUICK_EVENT as u, off as g, isInputLike as d, attr as r, useId as l } from "../utils.js";
3
3
  const m = f.field.split(" ")[0], b = f.validation.split(" "), L = b[0];
4
4
  function h(t) {
5
5
  for (const i of t) {
@@ -1,2 +1,2 @@
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}({});
1
+ var mtds=function(v){"use strict";const E="_validation_14niv_1 _ds-validation-message_1w6ss_1",I="_tag_14niv_1 _ds-tag_1w6ss_1",x="_tabs_14niv_1 _ds-tabs_1w6ss_1",C="_table_14niv_1 _ds-table_1w6ss_1",k="_scrollShadow_14niv_1",O="_skeleton_14niv_1 _ds-skeleton_1w6ss_1",H="_popover_14niv_1",D="_pagination_14niv_1 _ds-pagination_1w6ss_1",P="_modal_14niv_1 _ds-modal_1w6ss_1",B="_logo_14niv_1 _ds-focus_1w6ss_1",N="_link_14niv_1",W="_grid_14niv_1",F="_flex_14niv_1",U="_input_14niv_1 _ds-input_1w6ss_1",V="_fieldset_14niv_1 _ds-fieldset_1w6ss_1",R="_field_14niv_1 _ds-field_1w6ss_1",j="_affixes_14niv_1 _ds-field-affixes_1w6ss_1",Y="_count_14niv_1",q="_errorsummary_14niv_1 _ds-error-summary_1w6ss_1",z="_details_14niv_1 _ds-details_1w6ss_1",X="_chip_14niv_1 _ds-chip_1w6ss_1",G="_card_14niv_1",K="_info_14niv_1",Q="_button_14niv_1 _ds-button_1w6ss_1",J="_breadcrumbs_14niv_1 _ds-breadcrumbs_1w6ss_1",Z="_badge_14niv_1",tt="_avatar_14niv_1 _ds-avatar_1w6ss_1",ot="_alert_14niv_1 _ds-alert_1w6ss_1",et="_heading_14niv_1 _ds-heading_1w6ss_1",nt="_body_14niv_114",st="_tooltip_14niv_129",r={validation:E,tag:I,tabs:x,table:C,scrollShadow:k,skeleton:O,popover:H,pagination:D,modal:P,logo:B,link:N,grid:W,flex:F,input:U,fieldset:V,field:R,affixes:j,count:Y,errorsummary:q,details:z,chip:X,card:G,info:K,button:Q,breadcrumbs:J,badge:Z,avatar:tt,alert:ot,heading:et,body:nt,tooltip:st},yt=Object.freeze(Object.defineProperty({__proto__:null,affixes:j,alert:ot,avatar:tt,badge:Z,body:nt,breadcrumbs:J,button:Q,card:G,chip:X,count:Y,default:r,details:z,errorsummary:q,field:R,fieldset:V,flex:F,grid:W,heading:et,info:K,input:U,link:N,logo:B,modal:P,pagination:D,popover:H,scrollShadow:k,skeleton:O,table:C,tabs:x,tag:I,tooltip:st,validation:E},Symbol.toStringTag,{value:"Module"})),y=typeof window<"u"&&typeof document<"u",u={capture:!0,passive:!0};function a(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 Tt=0;const Mt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function g(t){return t.id||(t.id=`${Mt}${++Tt}`),t.id}const it=(t,o,e)=>{for(const s of e[0].split(","))e[0]=s,o[`${t}EventListener`](...e)},p=(t,...o)=>it("add",t,o),A=(t,...o)=>it("remove",t,o),T=new Map,l=y?document.createElement("div"):null;l&&a(l,"style","position:absolute;padding:1px;top:0;left:0px"),y&&p(window,"load,resize,scroll",()=>{for(const[t,o]of T)o()},u);const _={top:0,right:1,bottom:2,left:3,none:4};function M(t,o,e){var wt;if(!o||!o.isConnected||!t.isConnected)return T.delete(t);if(l!=null&&l.isConnected||document.body.append(l||""),!T.has(t)||_[e]===void 0){const to=_[e]??_.bottom;return(wt=T.set(t,()=>M(t,o,to)).get(t))==null?void 0:wt()}if(e===_.none)return t.style.setProperty("left","-100vw");const{offsetWidth:s,offsetHeight:n}=t,{offsetWidth:c,offsetHeight:i}=o,{width:h,height:$,left:jt,top:Yt}=o.getBoundingClientRect(),w=Math.round(jt-(c-h)/2),m=Math.round(Yt-(i-$)/2),qt=w-s>0,zt=c+c+s<window.innerWidth,Xt=m-n>0,Gt=m+i+n<window.innerHeight,Kt=e===_.bottom&&zt||!qt,Qt=e===_.bottom&&Gt||!Xt,Jt=Math.min(Math.max(10,w-(s-c)/2),window.innerWidth-s-10),Zt=Math.min(Math.max(10,m-(n-i)/2),window.innerHeight-n-10),ht=e===_.top||e===_.bottom;t.style.left=`${Math.round(ht?Jt:Kt?w+c:w-s)}px`,t.style.top=`${Math.round(ht?Qt?m+i:m-n:Zt)}px`,l==null||l.style.setProperty("translate",`${Math.round(window.scrollX+w+c+s+30)} ${Math.round(window.scrollY+m+i+n+30)}px`)}function St(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,At=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:St(()=>At(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)},L=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),ct=r.field.split(" ")[0],at=r.validation.split(" "),Lt=at[0];function $t(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):L(i)?n=i:i.classList.contains(Lt)?(c=i.getAttribute("data-color")==="success",s.unshift(g(i))):i instanceof HTMLParagraphElement&&s.push(g(i));if(n){for(const i of e)i.htmlFor=g(n);dt(n),a(n,"aria-describedby",s.join(" ")),a(n,"aria-invalid",`${!c}`)}}}function lt({target:t}){L(t)&&dt(t)}function dt(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){a(o,"aria-live",n?"polite":"off");for(const i of at)o.classList.toggle(i,n)}o.textContent=`${Math.abs(s)} tegn ${n?"for mye":"igjen"}`}}function Et(t){b(t,ct,$t),p(t,"input",lt,u)}function It(t){b(t,ct,!1),A(t,"input",lt,u)}const rt=r.fieldset.split(" ")[0],xt=r.validation.split(" ")[0];function Ct(t){for(const o of t){const e=[];let s="";for(const n of o.getElementsByTagName("*"))n.classList.contains(xt)?s=g(n):L(n)&&e.push(n);if(s)for(const n of e)a(n,"aria-describedby",s),a(n,"aria-invalid","true")}}const kt=t=>b(t,rt,Ct),Ot=t=>b(t,rt,!1);function Ht(t){p(t,"toggle",ft,u),p(t,"click",ut)}function Dt(t){A(t,"toggle",ft,u),A(t,"click",ut)}const _t=r.popover.split(" ")[0];function ft({target:t,newState:o}){var e;if(t instanceof HTMLElement&&t.classList.contains(_t)){const s=(e=t.getRootNode())==null?void 0:e.querySelector(`[popovertarget="${t.id}"]`);o==="closed"?M(t,!1):s&&M(t,s,t.getAttribute("data-position")||"bottom")}}function ut({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,a(o,"popovertarget")||""))||o.closest(`.${_t}`),i=a(o,"popovertargetaction")||"toggle";c==null||c.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const vt=r.table.split(" ")[0];function Pt(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 h of i.cells)a(h,"data-th",n[h.cellIndex]||":empty")}}const Bt=t=>b(t,vt,Pt),Nt=t=>b(t,vt,!1);let d=null,f=null,pt=0,bt=Number.NEGATIVE_INFINITY;const Wt=100;y&&(d=document.body.appendChild(document.createElement("div")),d.classList.add(...r.tooltip.split(" ")),a(d,"popover","manual"),p(document,"blur,focus,mouseout,mouseover",mt,u),p(window,"blur",mt,u));function mt({target:t}){const o=bt+Wt-Date.now();clearTimeout(pt),pt=setTimeout(Ft,Math.max(o,0),t)}function Ft(t){var s;if(bt=Date.now(),!d||t===d)return;let o=((s=t==null?void 0:t.closest)==null?void 0:s.call(t,"[data-tooltip],[data-expanded]"))||null;if(o===f)return;const e=(o==null?void 0:o.getAttribute("data-tooltip"))||(o==null?void 0:o.getAttribute("data-expanded"))||"";(!e||e==="false"||e==="true")&&(o=null),f==null||f.removeAttribute("aria-labelledby"),f=o,f==null||f.setAttribute("aria-labelledby",g(d)),d.togglePopover(!!o),M(d,o,(o==null?void 0:o.getAttribute("data-tooltip-position"))||"top"),o&&(d.textContent=e)}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},(h,$)=>$+n);return e>4&&n>1&&i.splice(0,2,1,0),e>3&&c<o&&i.splice(-2,2,0,o),i},Vt=({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(y){const t=document.readyState==="loading",o=()=>gt(document.body);t?document.addEventListener("DOMContentLoaded",o):o()}function gt(t){Et(t),kt(t),Ht(t),Bt(t)}function Rt(t){It(t),Ot(t),Dt(t),Nt(t)}return v.observe=gt,v.pagination=Vt,v.styles=yt,v.unobserve=Rt,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v}({});
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/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,EAAE,IAC5BH,EAAG,EACX,CAGA,MAAMM,GAAS,CACdC,EACAC,EACAC,IACU,CACV,UAAWC,KAAQ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AOR,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"}
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 */\ntype AnchorKeys = keyof typeof ANCHOR;\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 || !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) || ANCHOR[position as AnchorKeys] === undefined) { // Setup new target or update position\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 right when no hasSpaceLeft, as no OS scrolls further up than 0\n\tconst positionUnder = (position === ANCHOR.bottom && hasSpaceUnder) || !hasSpaceOver // Always position under when no hasSpaceOver, as no OS scrolls further up than 0\n\tconst centerX = Math.min(Math.max(10, anchorX - (targetW - anchorW) / 2), window.innerWidth - targetW - 10);\n\tconst centerY = Math.min(Math.max(10, anchorY - (targetH - anchorH) / 2), window.innerHeight - targetH - 10);\n\tconst isVertical = position === ANCHOR.top || position === ANCHOR.bottom;\n\n\ttarget.style.left = `${Math.round(isVertical ? centerX : (positionRight ? anchorX + anchorW : anchorX - targetW))}px`\n target.style.top = `${Math.round(isVertical ? (positionUnder ? anchorY + anchorH : anchorY - targetH) : centerY)}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, useId } from \"./utils\";\n\nlet TOOLTIP: HTMLElement | null = null;\nlet ANCHOR: Element | null = null;\nlet THROTTLE: number | ReturnType<typeof setTimeout> = 0;\nlet THROTTLE_LAST_CALL = Number.NEGATIVE_INFINITY;\nconst THROTTLE_DELAY = 100;\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, 'blur,focus,mouseout,mouseover', handleMove, QUICK_EVENT);\n on(window, 'blur', handleMove, QUICK_EVENT);\n}\n\nfunction handleMove({ target }: Event) {\n const wait = THROTTLE_LAST_CALL + THROTTLE_DELAY - Date.now();\n clearTimeout(THROTTLE);\n THROTTLE = setTimeout(handleMoveThrottled, Math.max(wait, 0), target);\n}\n\n// Using a throttled function to avoid performance issues\nfunction handleMoveThrottled(target: Element | null) {\n THROTTLE_LAST_CALL = Date.now();\n\n if (!TOOLTIP || target === TOOLTIP) return; // Allow tooltip to be hovered, following https://www.w3.org/TR/WCAG21/#content-on-hover-or-focus\n let anchor = target?.closest?.<HTMLElement>('[data-tooltip],[data-expanded]') || null;\n \n // No need to update\n if (anchor === ANCHOR) return;\n\n // Do not show tooltip if boolish value\n const content = anchor?.getAttribute('data-tooltip') || anchor?.getAttribute('data-expanded') || '';\n if (!content || content === 'false' || content === 'true') anchor = null;\n \n ANCHOR?.removeAttribute('aria-labelledby'); // Unbind previous anchor\n ANCHOR = anchor; // Store new anchor - might be null if no new anchor\n\n ANCHOR?.setAttribute('aria-labelledby', useId(TOOLTIP));\n TOOLTIP.togglePopover(!!anchor);\n // anchorPosition(TOOLTIP, false); // Reset anchor position\n anchorPosition(TOOLTIP, anchor, anchor?.getAttribute('data-tooltip-position') || 'top');\n if (anchor) TOOLTIP.textContent = content;\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\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n \n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\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","centerX","centerY","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","TOOLTIP","THROTTLE","THROTTLE_LAST_CALL","THROTTLE_DELAY","handleMove","wait","handleMoveThrottled","content","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":"2uDAAaA,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,gBA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EO,SAAS2E,GAAU3E,EAAa,CACrC4H,GAAgB5H,CAAE,EAClB6H,GAAmB7H,CAAE,EACrB8H,GAAkB9H,CAAE,EACpB+H,GAAgB/H,CAAE,CACpB"}
package/mtds/index.js CHANGED
@@ -1,24 +1,23 @@
1
- import { observe as s, unobserve as n } from "./field/field.js";
2
- import { observe as t, unobserve as b } from "./fieldset/fieldset.js";
3
- import { observe as a, unobserve as m } from "./popover/popover.js";
4
- import { observe as v, unobserve as i } from "./table/table.js";
1
+ import { observe as r, unobserve as s } from "./field/field.js";
2
+ import { observe as n, unobserve as t } from "./fieldset/fieldset.js";
3
+ import { observe as a, unobserve as b } from "./popover/popover.js";
4
+ import { observe as v, unobserve as m } from "./table/table.js";
5
5
  import "./tooltip.js";
6
- import { IS_BROWSER as d } from "./utils.js";
6
+ import { IS_BROWSER as i } from "./utils.js";
7
7
  import { pagination as E } from "./pagination/pagination.js";
8
8
  import * as L from "./styles.module.css.js";
9
- if (d) {
10
- const o = document.readyState === "loading", e = () => r(document.body);
9
+ if (i) {
10
+ const o = document.readyState === "loading", e = () => u(document.body);
11
11
  o ? document.addEventListener("DOMContentLoaded", e) : e();
12
12
  }
13
- r(document.body);
14
- function r(o) {
15
- s(o), t(o), a(o), v(o);
13
+ function u(o) {
14
+ r(o), n(o), a(o), v(o);
16
15
  }
17
16
  function g(o) {
18
- n(o), b(o), m(o), i(o);
17
+ s(o), t(o), b(o), m(o);
19
18
  }
20
19
  export {
21
- r as observe,
20
+ u as observe,
22
21
  E as pagination,
23
22
  L as styles,
24
23
  g as unobserve
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 './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
+ {"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\n// Automatic observe on browser\nif (IS_BROWSER) {\n const isLoading = document.readyState === \"loading\"; // Check if the page is still loading - might happen if the script is in <head>\n const onLoaded = () => observe(document.body);\n \n if (isLoading) document.addEventListener(\"DOMContentLoaded\", onLoaded);\n else onLoaded();\n}\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":";;;;;;;;AAUA,IAAIA,GAAY;AACR,QAAAC,IAAY,SAAS,eAAe,WACpCC,IAAW,MAAMC,EAAQ,SAAS,IAAI;AAE5C,EAAIF,IAAW,SAAS,iBAAiB,oBAAoBC,CAAQ,IACvDA,EAAA;AAChB;AAEO,SAASC,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,24 +1,24 @@
1
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";
2
+ import { on as f, QUICK_EVENT as a, off as l, anchorPosition as p, attr as r } from "../utils.js";
3
3
  function k(o) {
4
4
  f(o, "toggle", g, a), f(o, "click", v);
5
5
  }
6
6
  function E(o) {
7
- r(o, "toggle", g, a), r(o, "click", v);
7
+ l(o, "toggle", g, a), l(o, "click", v);
8
8
  }
9
9
  const d = m.popover.split(" ")[0];
10
10
  function g({ target: o, newState: t }) {
11
11
  var n;
12
12
  if (o instanceof HTMLElement && o.classList.contains(d)) {
13
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");
14
+ t === "closed" ? p(o, !1) : i && p(o, i, o.getAttribute("data-position") || "bottom");
15
15
  }
16
16
  }
17
17
  function v({ target: o }) {
18
18
  var n, i;
19
19
  const t = (n = o == null ? void 0 : o.closest) == null ? void 0 : n.call(o, "a");
20
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";
21
+ const e = t.getRootNode(), s = ((i = e.getElementById) == null ? void 0 : i.call(e, r(t, "popovertarget") || "")) || t.closest(`.${d}`), c = r(t, "popovertargetaction") || "toggle";
22
22
  s == null || s.togglePopover(c === "show" || (c === "hide" ? !1 : void 0));
23
23
  }
24
24
  }