@mattilsynet/design 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/mtds/errorsummary/errorsummary.stories.d.ts +1 -0
- package/mtds/index.iife.js +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +33 -33
- package/mtds/styles.module.css.js +49 -49
- package/package.json +1 -1
package/mtds/index.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var mtds=function(b){"use strict";const T=typeof window<"u"&&typeof document<"u",l={capture:!0,passive:!0};function
|
|
1
|
+
var mtds=function(b){"use strict";const T=typeof window<"u"&&typeof document<"u",l={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 $t=0;const kt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function S(t){return t.id||(t.id=`${kt}${++$t}`),t.id}const C=(t,o,e)=>{for(const s of e[0].split(","))e[0]=s,o[`${t}EventListener`](...e)},r=(t,...o)=>C("add",t,o),v=(t,...o)=>C("remove",t,o),M=new Map,_=T?document.createElement("div"):null;_&&a(_,"style","position:absolute;padding:1px;top:0;left:0px"),T&&r(window,"load,resize,scroll",()=>{for(const[t,o]of M)o()},l);const p={top:0,right:1,bottom:2,left:3};function h(t,o,e){var At;if(!o||!o.isConnected||!t.isConnected)return M.delete(t);if(_!=null&&_.isConnected||document.body.append(_||""),!M.has(t)){const po=p[e]??p.bottom;return(At=M.set(t,()=>h(t,o,po)).get(t))==null?void 0:At()}const{offsetWidth:s,offsetHeight:n}=t,{offsetWidth:c,offsetHeight:i}=o,{width:w,height:k,left:so,top:io}=o.getBoundingClientRect(),y=Math.round(so-(c-w)/2),m=Math.round(io-(i-k)/2),co=y-s>0,lo=c+c+s<window.innerWidth,ao=m-n>0,ro=m+i+n<window.innerHeight,_o=e===p.bottom&&lo||!co,fo=e===p.bottom&&ro||!ao,uo=Math.min(Math.max(10,y-(s-c)/2),window.innerWidth-s-10),bo=Math.min(Math.max(10,m-(n-i)/2),window.innerHeight-n-10),It=e===p.top||e===p.bottom;t.style.left=`${Math.round(It?uo:_o?y+c:y-s)}px`,t.style.top=`${Math.round(It?fo?m+i:m-n:bo)}px`,_==null||_.style.setProperty("translate",`${Math.round(window.scrollX+y+c+s+30)} ${Math.round(window.scrollY+m+i+n+30)}px`)}function Ct(t){let o=0;const e=()=>setTimeout(s,200),s=()=>{t([],n),o=0},n=new MutationObserver(()=>{o||(o=requestAnimationFrame(e))});return n}const L=new WeakMap,Ot=t=>{var e;const o=L.get(t);if(!o||!t.isConnected)(e=o==null?void 0:o.observer)==null||e.disconnect(),L.delete(t);else for(const[,s]of o.collections)s()},g=(t,o,e)=>{const s=t.getElementsByClassName(o);let n=L.get(t);n||(n={collections:new Map,observer:Ct(()=>Ot(t))},n.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),L.set(t,n)),e?n.collections.set(o,()=>e(s)):n.collections.delete(o)},A=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),O=({clientX:t,clientY:o,target:e})=>{if(e instanceof HTMLDialogElement&&a(e,"data-closedby")==="any"){const{top:s,right:n,bottom:c,left:i}=e.getBoundingClientRect();s<=o&&o<=c&&i<=t&&t<=n||e.close()}};function Bt(t){r(t,"click",O,l)}function xt(t){v(t,"click",O,l)}const B="_alert_wob7g_1 _ds-alert_1w6ss_1",x="_avatar_wob7g_1 _ds-avatar_1w6ss_1",D="_badge_wob7g_1",P="_breadcrumbs_wob7g_1 _ds-breadcrumbs_1w6ss_1",H="_button_wob7g_1 _ds-button_1w6ss_1",N="_card_wob7g_1",Y="_chip_wob7g_1 _ds-chip_1w6ss_1",R="_details_wob7g_1 _ds-details_1w6ss_1",V="_dialog_wob7g_1 _ds-modal_1w6ss_1",W="_divider_wob7g_1",F="_errorsummary_wob7g_1 _ds-error-summary_1w6ss_1",U="_field_wob7g_1 _ds-field_1w6ss_1",j="_affixes_wob7g_1 _ds-field-affixes_1w6ss_1",X="_count_wob7g_1",q="_fieldset_wob7g_1 _ds-fieldset_1w6ss_1",z="_heading_wob7g_1 _ds-heading_1w6ss_1",G="_input_wob7g_1 _ds-input_1w6ss_1",K="_grid_wob7g_1",Q="_flex_wob7g_1",J="_link_wob7g_1",Z="_logo_wob7g_1 _ds-focus_1w6ss_1",tt="_pagination_wob7g_1 _ds-pagination_1w6ss_1",ot="_popover_wob7g_1",et="_skeleton_wob7g_1 _ds-skeleton_1w6ss_1",nt="_spinner_wob7g_1",st="_table_wob7g_1 _ds-table_1w6ss_1",it="_scrollShadow_wob7g_1",ct="_tabs_wob7g_1 _ds-tabs_1w6ss_1",lt="_tag_wob7g_1 _ds-tag_1w6ss_1",at="_togglegroup_wob7g_1",dt="_tooltip_wob7g_1",rt="_validation_wob7g_1 _ds-validation-message_1w6ss_1",_t="_body_wob7g_120",u={alert:B,avatar:x,badge:D,breadcrumbs:P,button:H,card:N,chip:Y,details:R,dialog:V,divider:W,errorsummary:F,field:U,affixes:j,count:X,fieldset:q,heading:z,input:G,grid:K,flex:Q,link:J,logo:Z,pagination:tt,popover:ot,skeleton:et,spinner:nt,table:st,scrollShadow:it,tabs:ct,tag:lt,togglegroup:at,tooltip:dt,validation:rt,body:_t},Dt=Object.freeze(Object.defineProperty({__proto__:null,affixes:j,alert:B,avatar:x,badge:D,body:_t,breadcrumbs:P,button:H,card:N,chip:Y,count:X,default:u,details:R,dialog:V,divider:W,errorsummary:F,field:U,fieldset:q,flex:Q,grid:K,heading:z,input:G,link:J,logo:Z,pagination:tt,popover:ot,scrollShadow:it,skeleton:et,spinner:nt,table:st,tabs:ct,tag:lt,togglegroup:at,tooltip:dt,validation:rt},Symbol.toStringTag,{value:"Module"})),ft=u.field.split(" ")[0],ut=u.validation.split(" "),Pt=ut[0];function Ht(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):A(i)?n=i:i.classList.contains(Pt)?(c=i.getAttribute("data-color")==="success",s.unshift(S(i))):i instanceof HTMLParagraphElement&&s.push(S(i));if(n){for(const i of e)i.htmlFor=S(n);pt(n),a(n,"aria-describedby",s.join(" ")),a(n,"aria-invalid",`${!c}`)}}}function bt({target:t}){A(t)&&pt(t)}function pt(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 ut)o.classList.toggle(i,n)}o.textContent=`${Math.abs(s)} tegn ${n?"for mye":"igjen"}`}}function Nt(t){g(t,ft,Ht),r(t,"input",bt,l)}function Yt(t){g(t,ft,!1),v(t,"input",bt,l)}const gt=u.fieldset.split(" ")[0],Rt=u.validation.split(" ")[0];function Vt(t){for(const o of t){const e=[];let s="";for(const n of o.getElementsByTagName("*"))n.classList.contains(Rt)?s=S(n):A(n)&&e.push(n);if(s)for(const n of e)a(n,"aria-describedby",s),a(n,"aria-invalid","true")}}const Wt=t=>g(t,gt,Vt),Ft=t=>g(t,gt,!1),wt=({target:t})=>{};function Ut(t){r(t,"click",wt,l)}function jt(t){v(t,"click",wt,l)}function Xt(t){r(t,"toggle",vt,l),r(t,"click",ht)}function qt(t){v(t,"toggle",vt,l),v(t,"click",ht)}const mt=u.popover.split(" ")[0];function vt({target:t,newState:o}){var e;if(t instanceof HTMLElement&&t.classList.contains(mt)){const s=(e=t.getRootNode())==null?void 0:e.querySelector(`[popovertarget="${t.id}"]`);o==="closed"?h(t,!1):s&&h(t,s,t.getAttribute("data-position")||"bottom")}}function ht({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(`.${mt}`),i=a(o,"popovertargetaction")||"toggle";c==null||c.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const yt=u.table.split(" ")[0];function zt(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 w of i.cells)a(w,"data-th",n[w.cellIndex]||":empty")}}const Gt=t=>g(t,yt,zt),Kt=t=>g(t,yt,!1),Qt={tooltip:"_tooltip_1pse6_5"},Tt="aria-describedby",E="aria-labelledby",Jt="--mtds-tooltip-position",Zt=100,I="mtds-tooltip",St="Escape";let f=null,Mt=Number.NEGATIVE_INFINITY,Lt=0,d=null;function $({target:t,type:o,key:e}){if(o==="keydown"&&e!==St)return;const s=Mt+Zt-Date.now();clearTimeout(Lt),Lt=setTimeout(to,Math.max(s,0),e===St?null:t)}function to(t){var c;if(Mt=Date.now(),!d||t===d)return;let o=((c=t==null?void 0:t.closest)==null?void 0:c.call(t,"[data-tooltip]"))||null;if(o===f)return;const e=(o==null?void 0:o.getAttribute("data-tooltip"))||"",s=(o==null?void 0:o.getAttribute("data-tooltip-position"))||window.getComputedStyle(o||document.body).getPropertyValue(Jt)||"top",n=!!(o!=null&&o.innerText.trim())||(o==null?void 0:o.hasAttribute(E))||(o==null?void 0:o.hasAttribute("aria-label"));(!e||e==="false"||e==="true"||s==="none")&&(o=null),o&&(d.textContent=e),f==null||f.removeAttribute(f.getAttribute(E)===I?E:Tt),h(d,!1),f=o,f==null||f.setAttribute(n?Tt:E,I),d.togglePopover(!!o),h(d,o,s)}T&&!document.getElementById(I)&&(d=document.body.appendChild(document.createElement("div")),d.classList.add(...Qt.tooltip.split(" ")),d.id=I,a(d,"popover","manual"),r(document,"blur,focus,mouseout,mouseover",$,l),r(window,"keydown",$,l),r(window,"blur",$,l));const oo=(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},(w,k)=>k+n);return e>4&&n>1&&i.splice(0,2,1,0),e>3&&c<o&&i.splice(-2,2,0,o),i},eo=({current:t=1,total:o=10,show:e=7})=>({prev:t>1?t-1:0,next:t<o?t+1:0,pages:oo(t,o,e).map((s,n)=>({current:s===t&&"page",key:`key-${s}-${n}`,page:s}))});if(T){const t=document.readyState==="loading",o=()=>Et(document.body);t?document.addEventListener("DOMContentLoaded",o):o()}function Et(t){Bt(t),Nt(t),Wt(t),Ut(t),Xt(t),Gt(t)}function no(t){xt(t),Yt(t),Ft(t),jt(t),qt(t),Kt(t)}return b.observe=Et,b.pagination=eo,b.styles=Dt,b.unobserve=no,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),b}({});
|
|
2
2
|
//# sourceMappingURL=index.iife.js.map
|