@mattilsynet/design 0.5.1 → 0.5.2
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/index.iife.js +2 -2
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +33 -33
- package/mtds/styles.module.css.js +39 -39
- package/package.json +1 -1
package/mtds/index.iife.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var mtds=function(y){"use strict";const
|
|
1
|
+
var mtds=function(y){"use strict";const N="_alert_1p6jx_1 _ds-alert_194o1_1",R="_avatar_1p6jx_1 _ds-avatar_194o1_1",H="_badge_1p6jx_1",V="_breadcrumbs_1p6jx_1 _ds-breadcrumbs_194o1_1",U="_button_1p6jx_1 _ds-button_194o1_1",Y="_card_1p6jx_1",F="_group_1p6jx_1",W="_chip_1p6jx_1 _ds-chip_194o1_1",q="_details_1p6jx_1 _ds-details_194o1_1",G="_dialog_1p6jx_1 _ds-dialog_194o1_1",X="_divider_1p6jx_1",z="_errorsummary_1p6jx_1 _ds-error-summary_194o1_1",K="_field_1p6jx_1 _ds-field_194o1_1",Q="_affixes_1p6jx_1 _ds-field-affixes_194o1_1",J="_count_1p6jx_1",Z="_fieldset_1p6jx_1 _ds-fieldset_194o1_1",tt="_heading_1p6jx_1 _ds-heading_194o1_1",et="_typostack_1p6jx_1",ot="_input_1p6jx_1 _ds-input_194o1_1",nt="_grid_1p6jx_1",st="_flex_1p6jx_1",it="_app_1p6jx_1",ct="_link_1p6jx_1",at="_logo_1p6jx_1",lt="_pagination_1p6jx_1 _ds-pagination_194o1_1",rt="_popover_1p6jx_1",dt="_skeleton_1p6jx_1 _ds-skeleton_194o1_1",ut="_spinner_1p6jx_1",ft="_table_1p6jx_1 _ds-table_194o1_1",pt="__scrollShadow_1p6jx_1",_t="_tabs_1p6jx_1 _ds-tabs_194o1_1",mt="_tag_1p6jx_1 _ds-tag_194o1_1",ht="__tooltip_1p6jx_1",bt="_validation_1p6jx_1 _ds-validation-message_194o1_1",gt="_body_1p6jx_141",d={alert:N,avatar:R,badge:H,breadcrumbs:V,button:U,card:Y,group:F,chip:W,details:q,dialog:G,divider:X,errorsummary:z,field:K,affixes:Q,count:J,fieldset:Z,heading:tt,typostack:et,input:ot,grid:nt,flex:st,app:it,link:ct,logo:at,pagination:lt,popover:rt,skeleton:dt,spinner:ut,table:ft,_scrollShadow:pt,tabs:_t,tag:mt,_tooltip:ht,validation:bt,body:gt},Gt=Object.freeze(Object.defineProperty({__proto__:null,_scrollShadow:pt,_tooltip:ht,affixes:Q,alert:N,app:it,avatar:R,badge:H,body:gt,breadcrumbs:V,button:U,card:Y,chip:W,count:J,default:d,details:q,dialog:G,divider:X,errorsummary:z,field:K,fieldset:Z,flex:st,grid:nt,group:F,heading:tt,input:ot,link:ct,logo:at,pagination:lt,popover:rt,skeleton:dt,spinner:ut,table:ft,tabs:_t,tag:mt,typostack:et,validation:bt},Symbol.toStringTag,{value:"Module"})),Xt=(t,e,o)=>{const n=(o-1)/2,s=Math.max(Math.min(t-Math.floor(n),e-o+1),1),c=Math.min(Math.max(t+Math.ceil(n),o),e),i=Array.from({length:c+1-s},(r,p)=>p+s);return o>4&&s>1&&i.splice(0,2,1,0),o>3&&c<e&&i.splice(-2,2,0,e),i},zt=({current:t=1,total:e=10,show:o=7})=>({prev:t>1?t-1:0,next:t<e?t+1:0,pages:Xt(t,e,o).map((n,s)=>({current:n===t&&"page",key:`key-${n}-${s}`,page:n}))}),x=typeof window<"u"&&typeof document<"u",l={capture:!0,passive:!0};function a(t,e,o){return o===void 0?t.getAttribute(e)??null:(o===null?t.removeAttribute(e):t.getAttribute(e)!==o&&t.setAttribute(e,o),null)}let Kt=0;const Qt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function $(t){return t.id||(t.id=`${Qt}${++Kt}`),t.id}const vt=(t,e,o)=>{for(const n of o[0].split(","))o[0]=n,e[`${t}EventListener`](...o)},u=(t,...e)=>vt("add",t,e),w=(t,...e)=>vt("remove",t,e),L=new Map,_=x?document.createElement("div"):null;_&&a(_,"style","position:absolute;padding:1px;top:0;left:0px"),x&&u(window,"load,resize,scroll",()=>{for(const[t,e]of L)e()},l);const S={top:0,right:1,bottom:2,left:3};function E(t,e,o){var qt;if(!e||!e.isConnected||!t.isConnected)return L.delete(t);if(_!=null&&_.isConnected||document.body.append(_||""),!L.has(t)){const He=S[o]??S.bottom;return(qt=L.set(t,()=>E(t,e,He)).get(t))==null?void 0:qt()}const{offsetWidth:n,offsetHeight:s}=t,{offsetWidth:c,offsetHeight:i}=e,{width:r,height:p,left:T,top:k}=e.getBoundingClientRect(),h=Math.round(T-(c-r)/2),g=Math.round(k-(i-p)/2),je=h-n>0,Ae=c+c+n<window.innerWidth,Oe=g-s>0,De=g+i+s<window.innerHeight,Pe=o===S.bottom&&Ae||!je,Be=o===S.bottom&&De||!Oe,Ne=Math.min(Math.max(10,h-(n-c)/2),window.innerWidth-n-10),Re=Math.min(Math.max(10,g-(s-i)/2),window.innerHeight-s-10),Wt=o===S.top||o===S.bottom;t.style.left=`${Math.round(Wt?Ne:Pe?h+c:h-n)}px`,t.style.top=`${Math.round(Wt?Be?g+i:g-s:Re)}px`,_==null||_.style.setProperty("translate",`${Math.round(window.scrollX+h+c+n+30)} ${Math.round(window.scrollY+g+i+s+30)}px`)}function Jt(t){let e=0;const o=()=>setTimeout(n,200),n=()=>{t([],s),e=0},s=new MutationObserver(()=>{e||(e=requestAnimationFrame(o))});return s}const C=new WeakMap,Zt=t=>{var o;const e=C.get(t);if(!e||!t.isConnected)(o=e==null?void 0:e.observer)==null||o.disconnect(),C.delete(t);else for(const[,n]of e.collections)n()},b=(t,e,o)=>{const n=t.getElementsByClassName(e);let s=C.get(t);s||(s={collections:new Map,observer:Jt(()=>Zt(t))},s.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),C.set(t,s)),o?s.collections.set(e,()=>o(n)):s.collections.delete(e)},j=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),te=d._tooltip.split(" "),yt="aria-describedby",wt="Escape",M="aria-labelledby",ee="--mtds-tooltip-position",oe=300,I="mtds-tooltip";let m=null,St=Number.NEGATIVE_INFINITY,Tt=0,f=null;function A({target:t,type:e,key:o}){if(e==="keydown"&&o!==wt)return;const n=St+oe-Date.now();clearTimeout(Tt),Tt=setTimeout(ne,Math.max(n,0),o===wt?null:t)}function ne(t){var r;if(St=Date.now(),!f||t===f)return;let e=((r=t==null?void 0:t.closest)==null?void 0:r.call(t,"[data-tooltip]"))||null;if(e===m)return;const o=e&&a(e,"data-tooltip")||"",n=e&&a(e,"data-tooltip-position")||window.getComputedStyle(e||document.body).getPropertyValue(ee)||"top";(!o||o==="false"||o==="true"||n==="none")&&(e=null),e&&(f.textContent=o);const c=m&&a(m,M)===I,i=!!(e!=null&&e.innerText.trim())||(e==null?void 0:e.hasAttribute(M))||(e==null?void 0:e.hasAttribute("aria-label"));m==null||m.removeAttribute(c?M:yt),E(f,!1),m=e,m&&a(m,i?yt:M,I),f.togglePopover(!!e),E(f,e,n)}x&&!document.getElementById(I)&&(f=document.body.appendChild(document.createElement("div")),f.classList.add(...te),f.id=I,a(f,"popover","manual"),u(document,"blur,focus,mouseout,mouseover",A,l),u(window,"keydown",A,l),u(window,"blur",A,l));var xt=typeof window<"u"&&typeof window.document<"u"&&typeof window.navigator<"u",Et;xt&&/^Mac/i.test(((Et=navigator.userAgentData)==null?void 0:Et.platform)||navigator.platform);var se=":host(:not([hidden])) { display: block }",kt=typeof HTMLElement>"u"?class{}:HTMLElement;function v(t,e,o){var n;return o===void 0?(n=t.getAttribute(e))!=null?n:null:(o===null?t.removeAttribute(e):t.getAttribute(e)!==o&&t.setAttribute(e,o),null)}var $t=(t,e,o)=>{for(const n of o[0].split(","))o[0]=n,Element.prototype[`${t}EventListener`].apply(e,o)},Lt=(t,...e)=>$t("add",t,e),Ct=(t,...e)=>$t("remove",t,e),ie=t=>{const e="key"in t&&(t.key===" "||t.key==="Enter");return e&&t.preventDefault(),e&&t.target instanceof HTMLElement&&t.target.click(),e},ce=t=>{var e;const o=((e=t.getRootNode)==null?void 0:e.call(t))||t.ownerDocument;return o instanceof Document||o instanceof ShadowRoot?o:document},O=(t,e,o)=>{const n=document.createElement(t);if(e&&(n.textContent=e),o)for(const[s,c]of Object.entries(o))v(n,s,c);return n},Mt={define:(t,e)=>!xt||window.customElements.get(t)||window.customElements.define(t,e)},ae=class extends kt{constructor(){super(),this._content=null,this.attachShadow({mode:"open"}).append(O("slot",null,{name:"summary"}),O("slot",null,{part:"details-content"}),O("style",`${se}
|
|
2
2
|
::slotted(u-summary) { cursor: pointer; display: list-item; counter-increment: list-item 0; list-style: disclosure-closed inside }
|
|
3
3
|
::slotted(u-summary[aria-expanded="true"]) { list-style-type: disclosure-open }
|
|
4
|
-
:host > [part="details-content"]:not([hidden=""]) { display: block }`))}static get observedAttributes(){return["open"]}connectedCallback(){var t;this._content=(t=this.shadowRoot)==null?void 0:t.children[1],
|
|
4
|
+
:host > [part="details-content"]:not([hidden=""]) { display: block }`))}static get observedAttributes(){return["open"]}connectedCallback(){var t;this._content=(t=this.shadowRoot)==null?void 0:t.children[1],Lt(this._content,"beforematch",this),Lt(this,"click,keydown",this),this.attributeChangedCallback()}disconnectedCallback(){this._content&&Ct(this._content,"beforematch",this),Ct(this,"click,keydown",this),this._content=null}attributeChangedCallback(t,e,o){const n="onbeforematch"in this?"until-found":!0,s=this.open;for(const c of this.children)c.nodeName==="U-SUMMARY"&&v(c,"aria-expanded",`${s}`);if(this._content&&(v(this._content,"aria-hidden",`${!s}`),this._content.hidden=s?!1:n),s&&this.name){const c=ce(this).querySelectorAll(`${this.nodeName}[name="${this.name}"]`);for(const i of c)i!==this&&(i.open=!1)}t==="open"&&e===null!=(o===null)&&this.dispatchEvent(new Event("toggle"))}handleEvent(t){const e=this.querySelector(":scope > u-summary"),o=e==null?void 0:e.contains(t.target);t.defaultPrevented||(t.type==="beforematch"&&(this.open=!0),o&&t.type==="keydown"&&ie(t),o&&t.type==="click"&&(this.open=!this.open))}get open(){return this.hasAttribute("open")}set open(t){v(this,"open",t?"":null)}get name(){return v(this,"name")||""}set name(t){v(this,"name",t)}},le=class extends kt{connectedCallback(){v(this,"role","button"),this.slot="summary",this.tabIndex=0}};Mt.define("u-details",ae),Mt.define("u-summary",le);const It=({clientX:t,clientY:e,target:o})=>{var n;if(o instanceof HTMLDialogElement&&a(o,"data-closedby")==="any"){const{top:s,right:c,bottom:i,left:r}=o.getBoundingClientRect();s<=e&&e<=i&&r<=t&&t<=c||o.close()}else o instanceof Element&&o.closest('button[data-command="close"]')&&((n=o==null?void 0:o.closest("dialog"))==null||n.close())};function re(t){u(t,"click",It,l)}function de(t){w(t,"click",It,l)}const D=d.field.split(" ")[0],ue="--mtds-text-count-over",fe="--mtds-text-count-under",jt=d.validation.split(" "),pe=jt[0];function _e(t){for(const e of t){const o=[],n=[];let s=null,c=!0;for(const i of e.getElementsByTagName("*"))i instanceof HTMLLabelElement?o.push(i):j(i)?s=i:i.classList.contains(pe)?(c=a(i,"data-color")==="success",n.unshift($(i))):i instanceof HTMLParagraphElement&&n.push($(i));if(s){for(const i of o)i.htmlFor=$(s);Ot(s),a(s,"aria-describedby",n.join(" ")),a(s,"aria-invalid",`${!c}`)}}}function At({target:t}){j(t)&&Ot(t)}function Ot(t){var n,s;const e=t==null?void 0:t.nextElementSibling,o=e&&a(e,"data-count");if(e&&o){const c=Number(o)-t.value.length,i=c<0,r=a(e,"aria-live")==="polite",p=window.getComputedStyle(e||t),T=((n=p.getPropertyValue(ue))==null?void 0:n.slice(1,-1))||"",k=((s=p.getPropertyValue(fe))==null?void 0:s.slice(1,-1))||"";if(r!==i){a(e,"aria-live",i?"polite":"off");for(const h of jt)e.classList.toggle(h,i)}e.textContent=(i?T:k).replace("%d",`${Math.abs(c)}`)}}function Dt(t){var e,o;(o=(e=t.target)==null?void 0:e.closest)!=null&&o.call(e,`.${D}`)&&t.preventDefault()}function me(t){b(t,D,_e),u(t,"input",At,l),u(t,"invalid",Dt,!0)}function he(t){b(t,D,!1),w(t,"input",At,l),w(t,"invalid",Dt,!0)}const Pt=d.fieldset.split(" ")[0],be=d.validation.split(" ")[0];function ge(t){for(const e of t){const o=[];let n=null;for(const s of e.getElementsByTagName("*"))s.classList.contains(be)?n=$(s):j(s)&&o.push(s);for(const s of o)a(s,"aria-describedby",n),a(s,"aria-invalid",`${!!n}`)}}const ve=t=>b(t,Pt,ge),ye=t=>b(t,Pt,!1),Bt=d.app.split(" ")[0],we=`.${Bt} > header + :not(main) > button:empty:first-child`,Nt=({target:t})=>{const e=(t==null?void 0:t.nodeName)==="BUTTON"&&(t==null?void 0:t.closest(we));if(!e)return;const o=e.closest(`.${Bt} > *`),n=()=>o&&a(o,"data-expanded",`${a(o,"data-expanded")==="false"}`);document.startViewTransition?document.startViewTransition(()=>n()):n()};function Se(t){u(t,"click",Nt,l)}function Te(t){w(t,"click",Nt,l)}const P=d.logo.split(" ")[0];let B;function Rt(t){var i,r,p;const e=(i=t[0])==null?void 0:i.firstElementChild;if(!e)return;if(!B){const{head:T}=((r=window.top)==null?void 0:r.document)||document,k=T.getElementsByTagName("link[rel~='icon']"),h=document.createElement("link");for(const g of k)g.remove();B=T.appendChild(Object.assign(h,{rel:"icon"}))}const o=(p=e.parentElement)==null?void 0:p.hasAttribute("data-color"),n=window.getComputedStyle(e),s=n.getPropertyValue("color"),c=n.getPropertyValue("background-color");B.href=`data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 55 55'><rect fill='${o?"none":c}' width='51' height='51' x='2' y='2' stroke='${s}' stroke-dasharray='0.09 6.38' stroke-linecap='round' stroke-opacity='${o?.6:0}' stroke-width='2.3' rx='25.5'/><g transform="translate(7.5 7.5)">${encodeURIComponent(e.outerHTML.replace(/(fill|width|height|xmlns)=\S+/gi,"").replace("<svg",`<svg width="40" height="40" fill="${s}"`))}</g></svg>`}x&&setTimeout(()=>Rt(document.getElementsByClassName(P)),300);const xe=t=>b(t,P,Rt),Ee=t=>b(t,P,!1),Ht=d.popover.split(" ")[0];function ke(t){u(t,"toggle",Vt,l),u(t,"click",Ut)}function $e(t){w(t,"toggle",Vt,l),w(t,"click",Ut)}function Vt({target:t,newState:e}){var o;if(t instanceof HTMLElement&&t.classList.contains(Ht)){const n=(o=t.getRootNode())==null?void 0:o.querySelector(`[popovertarget="${t.id}"]`);e==="closed"?E(t,!1):n&&E(t,n,a(t,"data-position")||"bottom")}}function Ut({target:t}){var o,n;const e=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,"a");if(e){const s=e.getRootNode(),c=((n=s.getElementById)==null?void 0:n.call(s,a(e,"popovertarget")||""))||e.closest(`.${Ht}`),i=a(e,"popovertargetaction")||"toggle";c==null||c.togglePopover(i==="show"||(i==="hide"?!1:void 0))}}const Yt=d.table.split(" ")[0];function Le(t){for(const e of t){const o=[];a(e,"role","table"),e.caption&&a(e.caption,"role","caption");for(const n of[e.tHead,e.tFoot,...e.tBodies])if(n){a(n,"role","rowgroup");const s=n.nodeName==="TBODY";for(const c of n.rows){a(c,"role","row");for(const i of c.cells)s?a(i,"data-th",o[i.cellIndex]||":empty"):o.push(i.innerText.trim()),i.nodeName==="TD"?a(i,"role","cell"):(a(i,"role",s?"rowheader":"columnheader"),a(i,"scope",s?"row":"col"))}}}}const Ce=t=>b(t,Yt,Le),Me=t=>b(t,Yt,!1);if(x){const t=document.readyState==="loading",e=()=>Ft(document.body);t?document.addEventListener("DOMContentLoaded",e):e()}function Ft(t){re(t),me(t),ve(t),Se(t),xe(t),ke(t),Ce(t)}function Ie(t){de(t),he(t),ye(t),Te(t),Ee(t),$e(t),Me(t)}return y.observe=Ft,y.pagination=zt,y.styles=Gt,y.unobserve=Ie,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y}({});
|
|
5
5
|
//# sourceMappingURL=index.iife.js.map
|