@mattilsynet/design 0.2.11 → 0.2.13
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/button/button.stories.d.ts +1 -0
- package/mtds/field/field.js.map +1 -1
- package/mtds/index.iife.js +1 -1
- package/mtds/index.iife.js.map +1 -1
- package/mtds/layout/layout.stories.d.ts +0 -1
- package/mtds/popover/popover.js +27 -27
- package/mtds/popover/popover.js.map +1 -1
- package/mtds/styles.css +1 -1
- package/mtds/styles.json +34 -34
- package/mtds/styles.module.css.js +21 -21
- package/mtds/utils.d.ts +4 -2
- package/mtds/utils.js +3 -3
- package/mtds/utils.js.map +1 -1
- package/package.json +3 -4
|
@@ -6,6 +6,7 @@ export default meta;
|
|
|
6
6
|
type Story = StoryObj<typeof meta>;
|
|
7
7
|
export declare const Default: Story;
|
|
8
8
|
export declare const Sizes: Story;
|
|
9
|
+
export declare const Colors: Story;
|
|
9
10
|
export declare const Pressed: Story;
|
|
10
11
|
export declare const WithArrows: Story;
|
|
11
12
|
export declare const WithIcons: Story;
|
package/mtds/field/field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","sources":["../../designsystem/field/field.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, isInputLike, off, on, onAdd, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 | Document) {\n const fields = el.getElementsByClassName(CSS_FIELD);\n const add = onAdd(styles.fieldChildAdded, () => renderAria(fields));\n BOUND.set(el, add);\n add.observe(el);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n"],"names":["CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","BOUND","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","useId","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","add","onAdd","on","QUICK_EVENT","unobserve","_a","off"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAkBD,EAAO,WAAW,MAAM,GAAG,GAC7CE,IAAiBD,EAAgB,CAAC,GAClCE,wBAAY,QAAsD;AAExE,SAASC,EAAWC,GAAmC;A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AASE,EAASX,GAAwB;AACzC,QAAAN,IAASM,EAAG,uBAAuBZ,CAAS,GAC5CwB,IAAMC,EAAMxB,EAAO,iBAAiB,MAAMI,EAAWC,CAAM,CAAC;AAC5D,EAAAF,EAAA,IAAIQ,GAAIY,CAAG,GACjBA,EAAI,QAAQZ,CAAE,GACXc,EAAAd,GAAI,SAASI,GAAaW,CAAW;AAC1C;AAEO,SAASC,EAAWhB,GAAwB;;AACjD,GAAAiB,IAAAzB,EAAM,IAAIQ,CAAE,MAAZ,QAAAiB,EAAe,WAAWjB,IACtBkB,EAAAlB,GAAI,SAASI,GAAaW,CAAW;AAC3C;"}
|
|
1
|
+
{"version":3,"file":"field.js","sources":["../../designsystem/field/field.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { QUICK_EVENT, isInputLike, off, on, onAdd, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 | Document) {\n const fields = el.getElementsByClassName(CSS_FIELD);\n const add = onAdd(styles.fieldChildAdded, () => renderAria(fields));\n BOUND.set(el, add);\n add.observe(el);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n\n\n// TODO: Remove invalid when errormessage is gone"],"names":["CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","BOUND","renderAria","fields","field","labels","descs","input","valid","el","isInputLike","useId","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","add","onAdd","on","QUICK_EVENT","unobserve","_a","off"],"mappings":";;AAGA,MAAMA,IAAYC,EAAO,MAAM,MAAM,GAAG,EAAE,CAAC,GACrCC,IAAkBD,EAAO,WAAW,MAAM,GAAG,GAC7CE,IAAiBD,EAAgB,CAAC,GAClCE,wBAAY,QAAsD;AAExE,SAASC,EAAWC,GAAmC;AACrD,aAAUC,KAASD,GAAQ;AACzB,UAAME,IAA6B,CAAC,GAC9BC,IAAkB,CAAC;AACzB,QAAIC,IAAiC,MACjCC,IAAQ;AAEZ,eAAWC,KAAML,EAAM,qBAAqB,GAAG;AAC7C,MAAIK,aAAc,mBAAyBJ,EAAA,KAAKI,CAAE,IACzCC,EAAYD,CAAE,IAAWF,IAAAE,IACzBA,EAAG,UAAU,SAAST,CAAc,KACnCQ,IAAAC,EAAG,aAAa,Y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EAAM,IAAIQ,CAAE,MAAZ,QAAAiB,EAAe,WAAWjB,IACtBkB,EAAAlB,GAAI,SAASI,GAAaW,CAAW;AAC3C;"}
|
package/mtds/index.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var mtds=function(
|
|
1
|
+
var mtds=function(_){"use strict";const A="_validation_1p8e7_1 _ds-validation-message_1yo2l_1",S="_tag_1p8e7_1 _ds-tag_1yo2l_1",M="_tabs_1p8e7_1",$="_table_1p8e7_1 _ds-table_1yo2l_1",C="_scrollShadow_1p8e7_1",E="_tableChildAdded_1p8e7_1",I="_skeleton_1p8e7_1 _ds-skeleton_1yo2l_1",T="_popover_1p8e7_1",k="_pagination_1p8e7_1 _ds-pagination_1yo2l_1",w="_modal_1p8e7_1 _ds-modal_1yo2l_1",N="_logo_1p8e7_1 _ds-focus_1yo2l_1",x="_link_1p8e7_1",B="_grid_1p8e7_1",L="_flex_1p8e7_1",O="_box_1p8e7_1",P="_input_1p8e7_1 _ds-input_1yo2l_1",H="_fieldset_1p8e7_1 _ds-fieldset_1yo2l_1",D="_fieldsetValidationAdded_1p8e7_1",V="_field_1p8e7_1 _ds-field_1yo2l_1",W="_fieldChildAdded_1p8e7_1",U="_affixes_1p8e7_1 _ds-field-affixes_1yo2l_1",j="_count_1p8e7_1",F="_errorsummary_1p8e7_1 _ds-error-summary_1yo2l_1",q="_details_1p8e7_1 _ds-details_1yo2l_1",z="_chip_1p8e7_1 _ds-chip_1yo2l_1",Y="_card_1p8e7_1",G="_info_1p8e7_1",K="_button_1p8e7_1 _ds-button_1yo2l_1",Q="_breadcrumbs_1p8e7_1 _ds-breadcrumbs_1yo2l_1",R="_badge_1p8e7_1",X="_avatar_1p8e7_1 _ds-avatar_1yo2l_1",J="_alert_1p8e7_1 _ds-alert_1yo2l_1",Z="_heading_1p8e7_1 _ds-heading_1yo2l_1",tt="_body_1p8e7_104",d={validation:A,tag:S,tabs:M,table:$,scrollShadow:C,tableChildAdded:E,skeleton:I,popover:T,pagination:k,modal:w,logo:N,link:x,grid:B,flex:L,box:O,input:P,fieldset:H,fieldsetValidationAdded:D,field:V,fieldChildAdded:W,affixes:U,count:j,errorsummary:F,details:q,chip:z,card:Y,info:G,button:K,breadcrumbs:Q,badge:R,avatar:X,alert:J,heading:Z,body:tt},pt=Object.freeze(Object.defineProperty({__proto__:null,affixes:U,alert:J,avatar:X,badge:R,body:tt,box:O,breadcrumbs:Q,button:K,card:Y,chip:z,count:j,default:d,details:q,errorsummary:F,field:V,fieldChildAdded:W,fieldset:H,fieldsetValidationAdded:D,flex:L,grid:B,heading:Z,info:G,input:P,link:x,logo:N,modal:w,pagination:k,popover:T,scrollShadow:C,skeleton:I,table:$,tableChildAdded:E,tabs:M,tag:S,validation:A},Symbol.toStringTag,{value:"Module"})),et=typeof window<"u"&&typeof document<"u",c={capture:!0,passive:!0};let bt=0;const gt=`${Date.now().toString(36)}${Math.random().toString(36).slice(2,5)}`;function p(t){return t.id||(t.id=`${gt}${++bt}`),t.id}const ot=(t,e,n)=>{for(const s of n[0].split(","))n[0]=s,e[`${t}EventListener`](...n)},r=(t,...e)=>ot("add",t,e),b=(t,...e)=>ot("remove",t,e),y=(t,e)=>{let n=0;const s=o=>{o.animationName===t&&(cancelAnimationFrame(n),n=requestAnimationFrame(e))};return{observe:o=>r(o,"animationend",s,c),disconnect:o=>b(o,"animationstart",s,c)}},v=t=>t instanceof HTMLElement&&"validity"in t&&!(t instanceof HTMLButtonElement),mt=d.field.split(" ")[0],nt=d.validation.split(" "),yt=nt[0],st=new WeakMap;function vt(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):v(i)?o=i:i.classList.contains(yt)?(a=i.getAttribute("data-color")==="success",s.unshift(p(i))):i instanceof HTMLParagraphElement&&s.push(p(i));if(o)for(const i of n)i.htmlFor=p(o);o&&at(o),o==null||o.setAttribute("aria-describedby",s.join(" ")),o==null||o.setAttribute("aria-invalid",`${!a}`)}}function it({target:t}){v(t)&&at(t)}function at(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 nt)e.classList.toggle(i,o)}e.textContent=`${Math.abs(s)} tegn ${o?"for mye":"igjen"}`}}function ht(t){const e=t.getElementsByClassName(mt),n=y(d.fieldChildAdded,()=>vt(e));st.set(t,n),n.observe(t),r(t,"input",it,c)}function At(t){var e;(e=st.get(t))==null||e.disconnect(t),b(t,"input",it,c)}const St=d.fieldset.split(" ")[0],Mt=d.validation.split(" ")[0],dt=new WeakMap;function $t(t){for(const e of t){const n=[];let s="";for(const o of e.getElementsByTagName("*"))o.classList.contains(Mt)?s=p(o):v(o)&&n.push(o);if(s)for(const o of n)o.setAttribute("aria-describedby",s),o.setAttribute("aria-invalid","true")}}function Ct(t){const e=t.getElementsByClassName(St),n=y(d.fieldsetValidationAdded,()=>$t(e));dt.set(t,n),n.observe(t)}function Et(t){var e;(e=dt.get(t))==null||e.disconnect(t)}function It(t){r(t,"click",_t),r(t,"toggle",lt,c),r(window,"load,resize,scroll",m,c),r(document,"DOMContentReady",m,c),document.fonts.ready.then(m)}function Tt(t){b(t,"click",_t),b(t,"toggle",lt,c)}const ct=d.popover.split(" ")[0],l=et?document.createElement("div"):null,g=new Map;l==null||l.setAttribute("style","position:absolute;padding:1px");function lt({target:t,newState:e}){var n;if(t instanceof HTMLElement&&t.classList.contains(ct)){const s=(n=t.getRootNode())==null?void 0:n.querySelector(`[popovertarget="${t.id}"]`),o=t.getAttribute("data-position")==="over";e==="closed"?g.delete(t):s&&g.set(t,()=>kt(s,t,o)),document.body.append(l||""),m()}}function m(){for(const[t,e]of g)e()}function _t(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(`.${ct}`),a=e.getAttribute("popovertargetaction")||"toggle";t.defaultPrevented||o==null||o.togglePopover(a==="show"||(a==="hide"?!1:void 0))}}function kt(t,e,n=!1){if(!(t!=null&&t.isConnected)||!(e!=null&&e.isConnected))return g.delete(e);const{offsetWidth:s,offsetHeight:o}=e,{offsetWidth:a,offsetHeight:i}=t,{width:f,height:h,left:Ht,top:Dt}=t.getBoundingClientRect(),Vt=Math.round(Ht-(a-f)/2),u=Math.round(Dt-(i-h)/2),Wt=u+i+o<window.innerHeight,Ut=u-o>0,ut=!n&&Wt||!Ut,jt=ut?window.scrollY+u+i+o+30:0;e.style.left=`${Math.round(Math.min(Math.max(10,Vt),window.innerWidth-s-10))}px`,e.style.top=`${Math.round(ut?u+i:u-o)}px`,l==null||l.style.setProperty("top",`${Math.round(jt)}px`)}const wt=d.table.split(" ")[0],rt=new WeakMap;function Nt(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 f of i.cells)f.setAttribute("data-th",o[f.cellIndex]||":empty")}}function xt(t){const e=t.getElementsByClassName(wt),n=y(d.tableChildAdded,()=>Nt(e));rt.set(t,n),n.observe(t)}function Bt(t){var e;(e=rt.get(t))==null||e.disconnect(t)}const Lt=(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},(f,h)=>h+o);return n>4&&o>1&&i.splice(0,2,1,0),n>3&&a<e&&i.splice(-2,2,0,e),i},Ot=({current:t=1,total:e=10,show:n=7})=>({prev:t>1?t-1:0,next:t<e?t+1:0,pages:Lt(t,e,n).map((s,o)=>({current:s===t&&"page",key:`key-${s}-${o}`,page:s}))});et&&ft(document);function ft(t){ht(t),Ct(t),It(t),xt(t)}function Pt(t){At(t),Et(t),Tt(t),Bt(t)}return _.observe=ft,_.pagination=Ot,_.styles=pt,_.unobserve=Pt,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"}),_}({});
|
|
2
2
|
//# sourceMappingURL=index.iife.js.map
|
package/mtds/index.iife.js.map
CHANGED
|
@@ -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/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\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.prototype[`${action}EventListener`].apply(element, 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 * Child added event inspired by:\n * https://davidwalsh.name/detect-node-insertion\n */\nexport const onAdd = (animationName: string, callback: () => void) => {\n let timer: ReturnType<typeof requestAnimationFrame> | number = 0;\n const onAnimation = (event: Event & { animationName?: string }) => {\n if (event.animationName === animationName) {\n cancelAnimationFrame(timer);\n timer = requestAnimationFrame(callback);\n }\n };\n\n\treturn {\n\t\tobserve: (el: Element | Document, ) => on(el, 'animationend', onAnimation, QUICK_EVENT),\n\t\tdisconnect: (el: Element | Document, ) => off(el, 'animationstart', onAnimation, QUICK_EVENT)\n\t};\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\ndeclare global {\n\tnamespace React.JSX {\n\t\tinterface IntrinsicAttributes {\n\t\t\tpopovertargetaction?: string;\n\t\t\tpopovertarget?: string;\n\t\t\tpopover?: string | boolean;\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?: \"\" | \"auto\" | \"manual\" | undefined;\n\t\t}\n\t}\n}","import styles from '../styles.module.css';\nimport { QUICK_EVENT, isInputLike, off, on, onAdd, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 | Document) {\n const fields = el.getElementsByClassName(CSS_FIELD);\n const add = onAdd(styles.fieldChildAdded, () => renderAria(fields));\n BOUND.set(el, add);\n add.observe(el);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n","import styles from '../styles.module.css';\nimport { isInputLike, onAdd, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 function observe (el: Element | Document) {\n const fields = el.getElementsByClassName(CSS_FIELDSET);\n const add = onAdd(styles.fieldsetValidationAdded, () => process(fields));\n BOUND.set(el, add);\n add.observe(el);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n}\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}\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\ntype Toggle = Event & { newState?: string };\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nif (SCROLLER) SCROLLER.style.cssText = 'position:absolute;padding:1px';\n\nfunction handleToggle ({ target: el, newState }: Toggle){\n const isPopping = newState === 'open' && el instanceof HTMLElement && el.classList.contains(CSS_POPOVER);\n const anchor = isPopping && (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n\n if (anchor) {\n const isOver = el.getAttribute('data-position') === 'over';\n const update = () => place(anchor, el, isOver);\n const removeEvent = ({ newState }: Toggle) => {\n if (newState === 'open') return;\n off(document, 'DOMContentReady', update, QUICK_EVENT);\n off(el, 'toggle', removeEvent, QUICK_EVENT);\n off(window, 'load,resize,scroll', update, QUICK_EVENT);\n SCROLLER?.remove();\n }\n\n document.body.append(SCROLLER || '');\n document.fonts.ready.then(update); // Inital render and when fonts load\n on(window, 'load,resize,scroll', update, QUICK_EVENT);\n on(document, 'DOMContentReady', update, QUICK_EVENT);\n on(el, 'toggle', removeEvent, QUICK_EVENT);\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 (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 if (!event.defaultPrevented) target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}\n\nfunction place (anchor: HTMLElement | null, popper: HTMLElement, isOver = false) {\n if (!anchor) return;\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 { onAdd } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 function observe (el: Element | Document) {\n const tables = el.getElementsByClassName(CSS_TABLE);\n const add = onAdd(styles.tableChildAdded, () => process(tables));\n BOUND.set(el, add);\n add.observe(el);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\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 { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) observe(document); // Automatic observe on browser\n\nexport function observe(el: Element | Document) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element | Document) {\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","onAdd","animationName","callback","timer","onAnimation","event","isInputLike","CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","BOUND","renderAria","fields","field","labels","descs","input","valid","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","add","unobserve","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","handleLinkClick","handleToggle","CSS_POPOVER","SCROLLER","newState","anchor","_a","isOver","update","place","removeEvent","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":"w5DAAaA,EAAa,OAAO,OAAW,KAAe,OAAO,SAAa,IAClEC,EAAc,CAAE,QAAS,GAAM,QAAS,EAAK,EAM1D,IAAIC,GAAK,EACT,MAAMC,GAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,CAAC,GACzE,SAASC,EAAOC,EAAa,CAC9B,OAACA,EAAG,KAAIA,EAAG,GAAK,GAAGF,EAAI,GAAG,EAAED,EAAE,IAC5BG,EAAG,EACX,CAsBA,MAAMC,GAAS,CACdC,EACAC,EACAC,IACU,CACV,UAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG,EACnCA,EAAK,CAAC,EAAIC,EACV,QAAQ,UAAU,GAAGH,CAAM,eAAe,EAAE,MAAMC,EAASC,CAAI,CAEjE,EAQaE,EAAK,CACjBH,KACGC,IACOH,GAAO,MAAOE,EAASC,CAAI,EAQzBG,EAAM,CAClBJ,KACGC,IACOH,GAAO,SAAUE,EAASC,CAAI,EAM5BI,EAAQ,CAACC,EAAuBC,IAAyB,CACpE,IAAI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AUD,EAAO,GAAK,EACtBE,EAAQ,KAAK,IAAI,KAAK,IAAIJ,EAAM,KAAK,MAAMG,CAAM,EAAGF,EAAMC,EAAO,CAAC,EAAG,CAAC,EACtEG,EAAM,KAAK,IAAI,KAAK,IAAIL,EAAM,KAAK,KAAKG,CAAM,EAAGD,CAAI,EAAGD,CAAG,EAC3DK,EAAQ,MAAM,KAAK,CAAE,OAAQD,EAAM,EAAID,CAAS,EAAA,CAACG,EAAGC,IAAMA,EAAIJ,CAAK,EAErE,OAAAF,EAAO,GAAKE,EAAQ,KAAS,OAAO,EAAG,EAAG,EAAG,CAAC,EAC9CF,EAAO,GAAKG,EAAMJ,KAAW,OAAO,GAAI,EAAG,EAAGA,CAAG,EAC9CK,CACT,EAEaG,GAAa,CAAC,CACzB,QAAAC,EAAU,EACV,MAAAC,EAAQ,GACR,KAAAT,EAAO,CACT,KAAO,CACL,KAAMQ,EAAU,EAAIA,EAAU,EAAI,EAClC,KAAMA,EAAUC,EAAQD,EAAU,EAAI,EACtC,MAAOX,GAASW,EAASC,EAAOT,CAAI,EAAE,IAAI,CAACU,EAAMC,KAAW,CAC1D,QAASD,IAASF,GAAW,OAC7B,IAAK,OAAOE,CAAI,IAAIC,CAAK,GACzB,KAAAD,CAAA,EACA,CACJ,GCfIlG,MAAoB,QAAQ,EAEzB,SAASwC,GAAQnC,EAAwB,CAC9C+F,GAAc/F,CAAE,EAChBgG,GAAiBhG,CAAE,EACnBiG,GAAgBjG,CAAE,EAClBkG,GAAclG,CAAE,CAClB,CAEO,SAASqC,GAAUrC,EAAwB,CAChDmG,GAAgBnG,CAAE,EAClBoG,GAAmBpG,CAAE,EACrBqG,GAAkBrG,CAAE,EACpBsG,GAAgBtG,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/**\n * Speed up MutationObserver by debouncing and only running when page is visible\n * @return new MutaionObserver\n */\nexport function createOptimizedMutationObserver(callback: MutationCallback) {\n const queue: MutationRecord[] = [];\n const observer = new MutationObserver((mutations) => {\n if (!queue[0]) requestAnimationFrame(process);\n queue.push(...mutations);\n });\n\n const process = () => {\n callback(queue, observer);\n queue.length = 0; // Reset queue\n };\n\n return observer;\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 * Child added event inspired by:\n * https://davidwalsh.name/detect-node-insertion\n */\nexport const onAdd = (animationName: string, callback: () => void) => {\n let timer: ReturnType<typeof requestAnimationFrame> | number = 0;\n const onAnimation = (event: Event & { animationName?: string }) => {\n if (event.animationName === animationName) {\n cancelAnimationFrame(timer);\n timer = requestAnimationFrame(callback);\n }\n };\n\n\treturn {\n\t\tobserve: (el: Element | Document, ) => on(el, 'animationend', onAnimation, QUICK_EVENT),\n\t\tdisconnect: (el: Element | Document, ) => off(el, 'animationstart', onAnimation, QUICK_EVENT)\n\t};\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, onAdd, useId } from '../utils';\n\nconst CSS_FIELD = styles.field.split(' ')[0];\nconst CSS_VALIDATIONS = styles.validation.split(' ');\nconst CSS_VALIDATION = CSS_VALIDATIONS[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 | Document) {\n const fields = el.getElementsByClassName(CSS_FIELD);\n const add = onAdd(styles.fieldChildAdded, () => renderAria(fields));\n BOUND.set(el, add);\n add.observe(el);\n on(el, 'input', handleInput, QUICK_EVENT);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n off(el, 'input', handleInput, QUICK_EVENT);\n}\n\n\n// TODO: Remove invalid when errormessage is gone","import styles from '../styles.module.css';\nimport { isInputLike, onAdd, useId } from '../utils';\nconst CSS_FIELDSET = styles.fieldset.split(' ')[0];\nconst CSS_VALIDATION = styles.validation.split(' ')[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 function observe (el: Element | Document) {\n const fields = el.getElementsByClassName(CSS_FIELDSET);\n const add = onAdd(styles.fieldsetValidationAdded, () => process(fields));\n BOUND.set(el, add);\n add.observe(el);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\n}\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 if (!event.defaultPrevented) 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 { onAdd } from '../utils';\nconst CSS_TABLE = styles.table.split(' ')[0];\nconst BOUND = new WeakMap<Element | Document, ReturnType<typeof onAdd>>();\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 function observe (el: Element | Document) {\n const tables = el.getElementsByClassName(CSS_TABLE);\n const add = onAdd(styles.tableChildAdded, () => process(tables));\n BOUND.set(el, add);\n add.observe(el);\n}\n\nexport function unobserve (el: Element | Document) {\n BOUND.get(el)?.disconnect(el);\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 { IS_BROWSER } from './utils';\nexport { pagination } from './pagination/pagination';\nexport * as styles from './styles.module.css';\n\nif (IS_BROWSER) observe(document); // Automatic observe on browser\n\nexport function observe(el: Element | Document) {\n field.observe(el);\n fieldset.observe(el);\n popover.observe(el);\n table.observe(el);\n}\n\nexport function unobserve(el: Element | Document) {\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","onAdd","animationName","callback","timer","onAnimation","event","isInputLike","CSS_FIELD","styles","CSS_VALIDATIONS","CSS_VALIDATION","BOUND","renderAria","fields","field","labels","descs","input","valid","label","handleInput","target","renderCounter","limit","remainder","nextInvalid","css","observe","add","unobserve","CSS_FIELDSET","process","fieldsets","fieldset","inputs","validationId","handleLinkClick","handleToggle","updatePositions","CSS_POPOVER","SCROLLER","POPPING","newState","anchor","_a","isOver","place","_","updatePosition","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":"25DAAaA,GAAa,OAAO,OAAW,KAAe,OAAO,SAAa,IAClEC,EAAc,CAAE,QAAS,GAAM,QAAS,EAAK,EAM1D,IAAIC,GAAK,EACT,MAAMC,GAAO,GAAG,KAAK,IAAM,EAAA,SAAS,EAAE,CAAC,GAAG,KAAK,SAAS,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,CAAC,GACzE,SAASC,EAAOC,EAAa,CAC9B,OAACA,EAAG,KAAIA,EAAG,GAAK,GAAGF,EAAI,GAAG,EAAED,EAAE,IAC5BG,EAAG,EACX,CAsBA,MAAMC,GAAS,CACdC,EACAC,EACAC,IACU,CACV,UAAWC,KAAQD,EAAK,CAAC,EAAE,MAAM,GAAG,EACnCA,EAAK,CAAC,EAAIC,EACVF,EAAQ,GAAGD,CAAM,eAAe,EAAE,GAAGE,CAAI,CAE3C,EAQaE,EAAK,CACjBH,KACGC,IACOH,GAAO,MAAOE,EAASC,CAAI,EAQzBG,EAAM,CAClBJ,KACGC,IACOH,GAAO,SAAUE,EAASC,CAAI,EAM5BI,EAAQ,CAACC,EAAuBC,IAAyB,CACpE,IAAIC,EAA2D,EACzD,MAAAC,EAAeC,GAA8C,CAC7DA,EAAM,gBAAkBJ,IAC1B,qBAAqBE,CAAK,EAC1BA,EAAQ,sBAAsBD,CAAQ,EAE1C,EAEM,MAAA,CACN,QAAUV,GAA6BM,EAAGN,EAAI,eAAgBY,EAAahB,CAAW,EACtF,WAAaI,GAA6BO,EAAIP,EAAI,iBAAkBY,EAAahB,CAAW,CAC7F,CACD,EAEakB,EAAed,GAC3BA,aAAc,aAAe,aAAcA,GAAM,EAAEA,aAAc,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AO,EAAG,EAAG,EAAG,CAAC,EAC9CF,EAAO,GAAKG,EAAMJ,KAAW,OAAO,GAAI,EAAG,EAAGA,CAAG,EAC9CK,CACT,EAEaE,GAAa,CAAC,CACzB,QAAAC,EAAU,EACV,MAAAC,EAAQ,GACR,KAAAR,EAAO,CACT,KAAO,CACL,KAAMO,EAAU,EAAIA,EAAU,EAAI,EAClC,KAAMA,EAAUC,EAAQD,EAAU,EAAI,EACtC,MAAOV,GAASU,EAASC,EAAOR,CAAI,EAAE,IAAI,CAACS,EAAMC,KAAW,CAC1D,QAASD,IAASF,GAAW,OAC7B,IAAK,OAAOE,CAAI,IAAIC,CAAK,GACzB,KAAAD,CAAA,EACA,CACJ,GCfInG,OAAoB,QAAQ,EAEzB,SAASwC,GAAQnC,EAAwB,CAC9CgG,GAAchG,CAAE,EAChBiG,GAAiBjG,CAAE,EACnBkG,GAAgBlG,CAAE,EAClBmG,GAAcnG,CAAE,CAClB,CAEO,SAASqC,GAAUrC,EAAwB,CAChDoG,GAAgBpG,CAAE,EAClBqG,GAAmBrG,CAAE,EACrBsG,GAAkBtG,CAAE,EACpBuG,GAAgBvG,CAAE,CACpB"}
|
|
@@ -9,7 +9,6 @@ export default meta;
|
|
|
9
9
|
type Story = StoryObj<typeof meta>;
|
|
10
10
|
export declare const Flex: Story;
|
|
11
11
|
export declare const Grid: Story;
|
|
12
|
-
export declare const Box: Story;
|
|
13
12
|
export declare const Gap: Story;
|
|
14
13
|
export declare const Center: Story;
|
|
15
14
|
export declare const Align: Story;
|
package/mtds/popover/popover.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { IS_BROWSER as
|
|
3
|
-
function
|
|
4
|
-
|
|
1
|
+
import k from "../styles.module.css.js";
|
|
2
|
+
import { IS_BROWSER as E, on as r, QUICK_EVENT as l, off as h } from "../utils.js";
|
|
3
|
+
function I(t) {
|
|
4
|
+
r(t, "click", v), r(t, "toggle", m, l), r(window, "load,resize,scroll", f, l), r(document, "DOMContentReady", f, l), document.fonts.ready.then(f);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
6
|
+
function N(t) {
|
|
7
|
+
h(t, "click", v), h(t, "toggle", m, l);
|
|
8
8
|
}
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
function m({ target: t, newState:
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
f !== "open" && (p(document, "DOMContentReady", n, c), p(t, "toggle", g, c), p(window, "load,resize,scroll", n, c), s == null || s.remove());
|
|
17
|
-
};
|
|
18
|
-
document.body.append(s || ""), document.fonts.ready.then(n), l(window, "load,resize,scroll", n, c), l(document, "DOMContentReady", n, c), l(t, "toggle", g, c);
|
|
9
|
+
const p = k.popover.split(" ")[0], i = E ? document.createElement("div") : null, g = /* @__PURE__ */ new Map();
|
|
10
|
+
i == null || i.setAttribute("style", "position:absolute;padding:1px");
|
|
11
|
+
function m({ target: t, newState: e }) {
|
|
12
|
+
var s;
|
|
13
|
+
if (t instanceof HTMLElement && t.classList.contains(p)) {
|
|
14
|
+
const n = (s = t.getRootNode()) == null ? void 0 : s.querySelector(`[popovertarget="${t.id}"]`), o = t.getAttribute("data-position") === "over";
|
|
15
|
+
e === "closed" ? g.delete(t) : n && g.set(t, () => $(n, t, o)), document.body.append(i || ""), f();
|
|
19
16
|
}
|
|
20
17
|
}
|
|
18
|
+
function f() {
|
|
19
|
+
for (const [t, e] of g) e();
|
|
20
|
+
}
|
|
21
21
|
function v(t) {
|
|
22
|
-
var
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
t.defaultPrevented ||
|
|
22
|
+
var s;
|
|
23
|
+
const e = t.target instanceof Element && t.target.closest("a");
|
|
24
|
+
if (e) {
|
|
25
|
+
const n = e.getRootNode(), o = ((s = n.getElementById) == null ? void 0 : s.call(n, e.getAttribute("popovertarget") || "")) || e.closest(`.${p}`), d = e.getAttribute("popovertargetaction") || "toggle";
|
|
26
|
+
t.defaultPrevented || o == null || o.togglePopover(d === "show" || (d === "hide" ? !1 : void 0));
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
if (!t) return;
|
|
31
|
-
const { offsetWidth:
|
|
32
|
-
|
|
29
|
+
function $(t, e, s = !1) {
|
|
30
|
+
if (!(t != null && t.isConnected) || !(e != null && e.isConnected)) return g.delete(e);
|
|
31
|
+
const { offsetWidth: n, offsetHeight: o } = e, { offsetWidth: d, offsetHeight: a } = t, { width: w, height: y, left: M, top: P } = t.getBoundingClientRect(), b = Math.round(M - (d - w) / 2), c = Math.round(P - (a - y) / 2), x = c + a + o < window.innerHeight, H = c - o > 0, u = !s && x || !H, W = u ? window.scrollY + c + a + o + 30 : 0;
|
|
32
|
+
e.style.left = `${Math.round(Math.min(Math.max(10, b), window.innerWidth - n - 10))}px`, e.style.top = `${Math.round(u ? c + a : c - o)}px`, i == null || i.style.setProperty("top", `${Math.round(W)}px`);
|
|
33
33
|
}
|
|
34
34
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
I as observe,
|
|
36
|
+
N as unobserve
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=popover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n}\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\
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../designsystem/popover/popover.ts"],"sourcesContent":["import styles from '../styles.module.css';\nimport { IS_BROWSER, QUICK_EVENT, off, on } from '../utils';\n\nexport function observe(el: Node) {\n on(el, 'click', handleLinkClick); // Allow `<a>` to use `popovertarget` as well\n on(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n on(window, 'load,resize,scroll', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n on(document, 'DOMContentReady', updatePositions, QUICK_EVENT); // Use capture since toggle does not bubble\n document.fonts.ready.then(updatePositions); // Inital render and when fonts load\n}\nexport function unobserve(el: Node) {\n off(el, 'click', handleLinkClick);\n off(el, 'toggle', handleToggle, QUICK_EVENT); // Use capture since toggle does not bubble\n}\n\nconst CSS_POPOVER = styles.popover.split(' ')[0];\nconst SCROLLER = IS_BROWSER ? document.createElement('div') : null // Used to ensure we have scrollability under\nconst POPPING = new Map<Element, () => void>(); // Store current open poppers and their update functions\nSCROLLER?.setAttribute('style', 'position:absolute;padding:1px');\n\nfunction handleToggle ({ target: el, newState }: Event & { newState?: string }){\n if (el instanceof HTMLElement && el.classList.contains(CSS_POPOVER)) {\n const anchor = (el.getRootNode() as ShadowRoot)?.querySelector<HTMLElement>(`[popovertarget=\"${el.id}\"]`);\n const isOver = el.getAttribute('data-position') === 'over';\n \n if (newState === 'closed') POPPING.delete(el);\n else if (anchor) POPPING.set(el, () => place(anchor, el, isOver));\n document.body.append(SCROLLER || ''); // Ensure we have the scroller\n updatePositions();\n }\n}\n\nfunction updatePositions() {\n for (const [_, updatePosition] of POPPING) updatePosition();\n}\n\n// Polyfill popovertarget for <a> (not supported by native)\n// and automatically assume popovertarget is the closest parent popover\n// but respect the popovertarget and popovertargetaction attribute\nfunction handleLinkClick (event: Event){\n const link = event.target instanceof Element && event.target.closest('a');\n if (link) {\n const root = link.getRootNode() as ShadowRoot;\n const target = root.getElementById?.(link.getAttribute('popovertarget') || '') || link.closest(`.${CSS_POPOVER}`);\n const action = link.getAttribute('popovertargetaction') || 'toggle';\n\n if (!event.defaultPrevented) target?.togglePopover(action === 'show' || (action === 'hide' ? false : undefined));\n }\n}\n\nfunction place (anchor: HTMLElement | null, popper: HTMLElement, isOver = false) {\n if (!anchor?.isConnected || !popper?.isConnected) return POPPING.delete(popper); // Stop watchning if anchor is removed from DOM\n\n const { offsetWidth: popperW, offsetHeight: popperH } = popper;\n const { offsetWidth: anchorW, offsetHeight: anchorH } = anchor;\n const { width, height, left, top } = anchor.getBoundingClientRect();\n const anchorX = Math.round(left - (anchorW - width) / 2); // Correct for CSS transform scale\n const anchorY = Math.round(top - (anchorH - height) / 2); // Correct for CSS transform scale\n const hasSpaceUnder = anchorY + anchorH + popperH < window.innerHeight;\n const hasSpaceOver = anchorY - popperH > 0\n const placeUnder = (!isOver && hasSpaceUnder) || !hasSpaceOver // Always place under when no hasSpaceOver, as no OS can scroll further up than 0\n const scroll = placeUnder ? window.scrollY + anchorY + anchorH + popperH + 30 : 0\n\n popper.style.left = `${Math.round(Math.min(Math.max(10, anchorX), window.innerWidth - popperW - 10))}px`\n popper.style.top = `${Math.round(placeUnder ? anchorY + anchorH : anchorY - popperH)}px`\n SCROLLER?.style.setProperty('top', `${Math.round(scroll)}px`);\n}\n"],"names":["observe","el","on","handleLinkClick","handleToggle","QUICK_EVENT","updatePositions","unobserve","off","CSS_POPOVER","styles","SCROLLER","IS_BROWSER","POPPING","newState","anchor","_a","isOver","place","_","updatePosition","event","link","root","target","action","popper","popperW","popperH","anchorW","anchorH","width","height","left","top","anchorX","anchorY","hasSpaceUnder","hasSpaceOver","placeUnder","scroll"],"mappings":";;AAGO,SAASA,EAAQC,GAAU;AAC7B,EAAAC,EAAAD,GAAI,SAASE,CAAe,GAC5BD,EAAAD,GAAI,UAAUG,GAAcC,CAAW,GACvCH,EAAA,QAAQ,sBAAsBI,GAAiBD,CAAW,GAC1DH,EAAA,UAAU,mBAAmBI,GAAiBD,CAAW,GACnD,SAAA,MAAM,MAAM,KAAKC,CAAe;AAC3C;AACO,SAASC,EAAUN,GAAU;AAC9B,EAAAO,EAAAP,GAAI,SAASE,CAAe,GAC5BK,EAA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