@mattilsynet/design 0.2.14 → 0.2.15

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/README.md CHANGED
@@ -1,8 +1,31 @@
1
- # Design
2
- Mattilsynets designsystem og designmanual
1
+ `@mattilsynet/design`
2
+ ================
3
3
 
4
- ## Releasing a new version
5
- 1. Manually update the version number in `package.json`
4
+ Mattilsynets designsystem bygger oppå [designsystemet.no](https://www.designsystemet.no/), men utvider med egenart, visuelle identitet og interne behov. Designsystemet fungerer som et felles språk mellom team og fagfelt, slik at vi lettere kan skape gode og gjenkjennbare brukeropplevelser som er tilgjengelig for alle.
5
+
6
+ ## Kom i gang
7
+
8
+ - Se [design.mattilsynet.no](https://design.mattilsynet.no/?path=/docs/designsystem-introduksjon--docs) for hvordan bruke `@mattilsynet/design`
9
+
10
+ ## Henvendelser
11
+
12
+ - Spørsmål knyttet til koden eller prosjektet kan stilles som issues her på GitHub
13
+ - Mattilsynet-ansatte kan benytte Slack-kanalen [#designsystem](https://mattilsynet-hq.slack.com/archives/C03FAJ7N1EU).
14
+
15
+ ## Utvikling
16
+
17
+ Klon ned `@mattilsynet/design`, installer og kjør:
18
+ 1. `git clone git@github.com:Mattilsynet/design.git`
19
+ 2. `cd design`
20
+ 3. `npm install`
21
+ 4. `npm run storybook`
22
+ - Du har nå dokumentasjonen kjørende med hot-reloading
23
+ 5. Sjekk ut egen branck `git checkout -b fix/din-branch-her` - vi følger [conventional commits navnekonvensjon](https://www.conventionalcommits.org/)
24
+ 6. Lag PR mot `next` branchen
25
+
26
+
27
+ ## Publisering
28
+ 1. Mannuelt oppdatert versjonsnummer i `package.json` (vi følger [semver](https://semver.org/))
6
29
  2. Run `npm install`
7
30
  3. Commit the update with the message `chore: update version to x.y.z` to the `next` branch, and push it
8
31
  4. Create a pull request from `next` into `main`
@@ -5,3 +5,4 @@ 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 Center: Story;
package/mtds/index.d.ts CHANGED
@@ -13,7 +13,6 @@ logo: string;
13
13
  link: string;
14
14
  grid: string;
15
15
  flex: string;
16
- box: string;
17
16
  input: string;
18
17
  fieldset: string;
19
18
  field: string;
@@ -1,2 +1,2 @@
1
- var mtds=function(r){"use strict";const S="_validation_1p8e7_1 _ds-validation-message_1yo2l_1",A="_tag_1p8e7_1 _ds-tag_1yo2l_1",$="_tabs_1p8e7_1",T="_table_1p8e7_1 _ds-table_1yo2l_1",I="_scrollShadow_1p8e7_1",E="_skeleton_1p8e7_1 _ds-skeleton_1yo2l_1",w="_popover_1p8e7_1",L="_pagination_1p8e7_1 _ds-pagination_1yo2l_1",k="_modal_1p8e7_1 _ds-modal_1yo2l_1",C="_logo_1p8e7_1 _ds-focus_1yo2l_1",x="_link_1p8e7_1",O="_grid_1p8e7_1",H="_flex_1p8e7_1",P="_box_1p8e7_1",B="_input_1p8e7_1 _ds-input_1yo2l_1",N="_fieldset_1p8e7_1 _ds-fieldset_1yo2l_1",D="_field_1p8e7_1 _ds-field_1yo2l_1",U="_affixes_1p8e7_1 _ds-field-affixes_1yo2l_1",W="_count_1p8e7_1",F="_errorsummary_1p8e7_1 _ds-error-summary_1yo2l_1",j="_details_1p8e7_1 _ds-details_1yo2l_1",V="_chip_1p8e7_1 _ds-chip_1yo2l_1",q="_card_1p8e7_1",z="_info_1p8e7_1",R="_button_1p8e7_1 _ds-button_1yo2l_1",K="_breadcrumbs_1p8e7_1 _ds-breadcrumbs_1yo2l_1",Y="_badge_1p8e7_1",G="_avatar_1p8e7_1 _ds-avatar_1yo2l_1",Q="_alert_1p8e7_1 _ds-alert_1yo2l_1",X="_heading_1p8e7_1 _ds-heading_1yo2l_1",J="_body_1p8e7_104",c={validation:S,tag:A,tabs:$,table:T,scrollShadow:I,skeleton:E,popover:w,pagination:L,modal:k,logo:C,link:x,grid:O,flex:H,box:P,input:B,fieldset:N,field:D,affixes:U,count:W,errorsummary:F,details:j,chip:V,card:q,info:z,button:R,breadcrumbs:K,badge:Y,avatar:G,alert:Q,heading:X,body:J},ft=Object.freeze(Object.defineProperty({__proto__:null,affixes:U,alert:Q,avatar:G,badge:Y,body:J,box:P,breadcrumbs:K,button:R,card:q,chip:V,count:W,default:c,details:j,errorsummary:F,field:D,fieldset:N,flex:H,grid:O,heading:X,info:z,input:B,link:x,logo:C,modal:k,pagination:L,popover:w,scrollShadow:I,skeleton:E,table:T,tabs:$,tag:A,validation:S},Symbol.toStringTag,{value:"Module"})),Z=typeof window<"u"&&typeof document<"u",d={capture:!0,passive:!0};let ut=0;const pt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function b(t){return t.id||(t.id=`${pt}${++ut}`),t.id}const tt=(t,e,n)=>{for(const s of n[0].split(","))n[0]=s,e[`${t}EventListener`](...n)},f=(t,...e)=>tt("add",t,e),m=(t,...e)=>tt("remove",t,e);function bt(t){let e=0;const n=()=>setTimeout(s,200),s=()=>{t([],o),e=0},o=new MutationObserver(()=>{e||(e=requestAnimationFrame(n))});return o}const g=new WeakMap,gt=t=>{var n;const e=g.get(t);if(!e||!t.isConnected)(n=e==null?void 0:e.observer)==null||n.disconnect(),g.delete(t);else for(const[,s]of e.collections)s()},_=(t,e,n)=>{const s=t.getElementsByClassName(e);let o=g.get(t);o||(o={collections:new Map,observer:bt(()=>gt(t))},o.observer.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),g.set(t,o)),n?o.collections.set(e,()=>n(s)):o.collections.delete(e)},h=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),et=c.field.split(" ")[0],ot=c.validation.split(" "),vt=ot[0];function yt(t){for(const e of t){const n=[],s=[];let o=null,a=!0;for(const i of e.getElementsByTagName("*"))i instanceof HTMLLabelElement?n.push(i):h(i)?o=i:i.classList.contains(vt)?(a=i.getAttribute("data-color")==="success",s.unshift(b(i))):i instanceof HTMLParagraphElement&&s.push(b(i));if(o)for(const i of n)i.htmlFor=b(o);o&&st(o),o==null||o.setAttribute("aria-describedby",s.join(" ")),o==null||o.setAttribute("aria-invalid",`${!a}`)}}function nt({target:t}){h(t)&&st(t)}function st(t){const e=t==null?void 0:t.nextElementSibling,n=e==null?void 0:e.getAttribute("data-count");if(e&&n){const s=Number(n)-t.value.length,o=s<0;if(e.getAttribute("aria-live")==="polite"!==o){e.setAttribute("aria-live",o?"polite":"off");for(const i of ot)e.classList.toggle(i,o)}e.textContent=`${Math.abs(s)} tegn ${o?"for mye":"igjen"}`}}function mt(t){_(t,et,yt),f(t,"input",nt,d)}function ht(t){_(t,et,!1),m(t,"input",nt,d)}const it=c.fieldset.split(" ")[0],Mt=c.validation.split(" ")[0];function St(t){for(const e of t){const n=[];let s="";for(const o of e.getElementsByTagName("*"))o.classList.contains(Mt)?s=b(o):h(o)&&n.push(o);if(s)for(const o of n)o.setAttribute("aria-describedby",s),o.setAttribute("aria-invalid","true")}}const At=t=>_(t,it,St),$t=t=>_(t,it,!1);function Tt(t){f(t,"click",lt),f(t,"toggle",ct,d),f(window,"load,resize,scroll",y,d),f(document,"DOMContentReady",y,d),document.fonts.ready.then(y)}function It(t){m(t,"click",lt),m(t,"toggle",ct,d)}const at=c.popover.split(" ")[0],l=Z?document.createElement("div"):null,v=new Map;l==null||l.setAttribute("style","position:absolute;padding:1px");function ct({target:t,newState:e}){var n;if(t instanceof HTMLElement&&t.classList.contains(at)){const s=(n=t.getRootNode())==null?void 0:n.querySelector(`[popovertarget="${t.id}"]`),o=t.getAttribute("data-position")==="over";e==="closed"?v.delete(t):s&&v.set(t,()=>Et(s,t,o)),document.body.append(l||""),y()}}function y(){for(const[t,e]of v)e()}function lt(t){var n;const e=t.target instanceof Element&&t.target.closest("a");if(e){const s=e.getRootNode(),o=((n=s.getElementById)==null?void 0:n.call(s,e.getAttribute("popovertarget")||""))||e.closest(`.${at}`),a=e.getAttribute("popovertargetaction")||"toggle";o==null||o.togglePopover(a==="show"||(a==="hide"?!1:void 0))}}function Et(t,e,n=!1){if(!(t!=null&&t.isConnected)||!(e!=null&&e.isConnected))return v.delete(e);const{offsetWidth:s,offsetHeight:o}=e,{offsetWidth:a,offsetHeight:i}=t,{width:u,height:M,left:Ht,top:Pt}=t.getBoundingClientRect(),Bt=Math.round(Ht-(a-u)/2),p=Math.round(Pt-(i-M)/2),Nt=p+i+o<window.innerHeight,Dt=p-o>0,_t=!n&&Nt||!Dt,Ut=_t?window.scrollY+p+i+o+30:0;e.style.left=`${Math.round(Math.min(Math.max(10,Bt),window.innerWidth-s-10))}px`,e.style.top=`${Math.round(_t?p+i:p-o)}px`,l==null||l.style.setProperty("top",`${Math.round(Ut)}px`)}const rt=c.table.split(" ")[0];function wt(t){var e,n;for(const s of t)if(s instanceof HTMLTableElement){const o=Array.from(((n=(e=s.tHead)==null?void 0:e.rows[0])==null?void 0:n.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",o[u.cellIndex]||":empty")}}const Lt=t=>_(t,rt,wt),kt=t=>_(t,rt,!1),Ct=(t,e,n)=>{const s=(n-1)/2,o=Math.max(Math.min(t-Math.floor(s),e-n+1),1),a=Math.min(Math.max(t+Math.ceil(s),n),e),i=Array.from({length:a+1-o},(u,M)=>M+o);return n>4&&o>1&&i.splice(0,2,1,0),n>3&&a<e&&i.splice(-2,2,0,e),i},xt=({current:t=1,total:e=10,show:n=7})=>({prev:t>1?t-1:0,next:t<e?t+1:0,pages:Ct(t,e,n).map((s,o)=>({current:s===t&&"page",key:`key-${s}-${o}`,page:s}))});Z&&dt(document.body);function dt(t){mt(t),At(t),Tt(t),Lt(t)}function Ot(t){ht(t),$t(t),It(t),kt(t)}return r.observe=dt,r.pagination=xt,r.styles=ft,r.unobserve=Ot,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),r}({});
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}({});
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) 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","field.observe","fieldset.observe","popover.observe","table.observe","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":"6rDAAaA,EAAa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,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,GCfIxG,GAAoB8C,GAAA,SAAS,IAAI,EAE9B,SAASA,GAAQzC,EAAa,CACnCqG,GAAcrG,CAAE,EAChBsG,GAAiBtG,CAAE,EACnBuG,GAAgBvG,CAAE,EAClBwG,GAAcxG,CAAE,CAClB,CAEO,SAAS0C,GAAU1C,EAAa,CACrCyG,GAAgBzG,CAAE,EAClB0G,GAAmB1G,CAAE,EACrB2G,GAAkB3G,CAAE,EACpB4G,GAAgB5G,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/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,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zB,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"}
package/mtds/index.js CHANGED
@@ -1,21 +1,25 @@
1
- import { observe as e, unobserve as r } from "./field/field.js";
2
- import { observe as s, unobserve as b } from "./fieldset/fieldset.js";
3
- import { observe as v, unobserve as n } from "./popover/popover.js";
4
- import { observe as m, unobserve as t } from "./table/table.js";
5
- import { IS_BROWSER as u } from "./utils.js";
1
+ import { observe as r, 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 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
6
  import { pagination as S } from "./pagination/pagination.js";
7
- import * as d from "./styles.module.css.js";
8
- u && a(document.body);
9
- function a(o) {
10
- e(o), s(o), v(o), m(o);
7
+ import * as y from "./styles.module.css.js";
8
+ if (i) {
9
+ const o = document.readyState === "loading", e = () => s(document.body);
10
+ o ? document.addEventListener("DOMContentLoaded", e) : e();
11
11
  }
12
- function x(o) {
13
- r(o), b(o), n(o), t(o);
12
+ s(document.body);
13
+ function s(o) {
14
+ r(o), t(o), a(o), m(o);
15
+ }
16
+ function L(o) {
17
+ n(o), b(o), v(o), d(o);
14
18
  }
15
19
  export {
16
- a as observe,
20
+ s as observe,
17
21
  S as pagination,
18
- d as styles,
19
- x as unobserve
22
+ y as styles,
23
+ L as unobserve
20
24
  };
21
25
  //# 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) 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","observe","el","field.observe","fieldset.observe","popover.observe","table.observe","unobserve","field.unobserve","fieldset.unobserve","popover.unobserve","table.unobserve"],"mappings":";;;;;;;AAQIA,KAAoBC,EAAA,SAAS,IAAI;AAE9B,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 { 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;"}
@@ -14,3 +14,4 @@ export declare const Center: Story;
14
14
  export declare const Align: Story;
15
15
  export declare const Justify: Story;
16
16
  export declare const AlignContent: Story;
17
+ export declare const App: Story;