@graview/guest 0.1.73 → 0.2.0
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.
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* The audit as one classic script (0.1.48): `graview view check --audit
|
|
4
4
|
* --browser` puts it in the Chromium it opens, where it leaves `__graviewAudit`.
|
|
5
5
|
*/
|
|
6
|
-
export const AUDIT_PAGE_SCRIPT = "/*! @graview/guest audit, as a page runs it. Elastic License 2.0. */\n\"use strict\";(()=>{var be=Symbol.for(\"graview.view.clicked\");function Q(e){for(let o=e,r=0;o&&r<64;r+=1){let a=o[be];if(Array.isArray(a))return a;o=o.host??o.parentNode}}var ee=\"http://www.w3.org/1999/xhtml\",te=new Set([\"button\",\"submit\",\"reset\",\"checkbox\",\"radio\",\"image\"]);var ge=new Set([\"div\",\"span\",\"section\",\"article\",\"aside\",\"header\",\"footer\",\"figure\",\"p\",\"b\",\"i\",\"em\",\"strong\",\"small\",\"mark\",\"time\",\"img\"]),S=(e,...o)=>e.namespaceURI===ee&&o.includes(e.localName),re=e=>(e.getAttribute(\"type\")??\"text\").toLowerCase(),W=e=>S(e,\"textarea\",\"select\")||S(e,\"input\")&&!te.has(re(e)),$=e=>S(e,\"input\",\"select\",\"textarea\");function K(e){return S(e,\"button\",\"summary\")||S(e,\"input\")&&te.has(re(e))||e.localName===\"a\"&&e.hasAttribute(\"data-graview-link\")}function Ae(e){if(S(e,\"option\",\"optgroup\",\"datalist\"))return'An option is never pressed by itself: put data-act on its select, with data-save=\"change\", or on a button.';if(S(e,\"label\"))return\"A press on a label presses its field too, and would ask for the act twice: put data-act on a button, or on the field.\";if(W(e)&&!e.hasAttribute(\"data-save\"))return'A click into a field to type or to pick is not a press: give it data-save (\"input\" or \"change\") to save it as it is typed, or put data-act on a button beside it.'}var oe=e=>e.hasAttribute(\"data-act\")&&Ae(e)===void 0&&!($(e)&&e.hasAttribute(\"data-save\")),ye=new Set([\"button\",\"checkbox\",\"switch\",\"tab\"]);function ae(e,o=e.getAttribute(\"role\")){return K(e)||$(e)||S(e,\"label\",\"option\")||e.hasAttribute(\"data-graview-link\")?!1:ye.has(o??\"\")||e.hasAttribute(\"aria-pressed\")||e.hasAttribute(\"aria-expanded\")}function B(e){return S(e,\"button\",\"input\",\"select\",\"textarea\",\"summary\",\"iframe\")||e.localName===\"a\"&&e.hasAttribute(\"href\")?!0:e.hasAttribute(\"tabindex\")||(e.getAttribute(\"contenteditable\")??\"false\")!==\"false\"}var V=e=>!e.hasAttribute(\"role\")&&(e.namespaceURI!==ee||ge.has(e.localName));function ne(e,o){return!e.hasAttribute(\"data-record\")&&!e.hasAttribute(\"data-place\")?!1:e.localName===\"a\"?!0:o||$(e)||S(e,\"fieldset\",\"form\",\"label\",\"option\")||e.localName===\"graview-video\"||e.hasAttribute(\"data-act\")||e.hasAttribute(\"data-lightbox\")||e.hasAttribute(\"data-drop\")||e.hasAttribute(\"data-field\")?!1:e.getAttribute(\"role\")!==\"group\"}function j(e,o){if(e.localName===\"a\"||e.localName===\"button\")return!1;let r=e.getAttribute(\"data-record\"),a=e.getAttribute(\"data-place\");for(let i of o)if(i.localName===\"a\"&&(r!==null?i.getAttribute(\"data-record\")===r:a!==null&&i.getAttribute(\"data-place\")===a))return!0;return!1}var we=/^#([0-9a-f]{3,8})$/i,Ee=/(rgba?|hsla?)\\(([^)]+)\\)/gi;function xe(e){let o=we.exec(e.trim());if(!o)return null;let r=o[1];if((r.length===3||r.length===4)&&(r=[...r].map(n=>n+n).join(\"\")),r.length!==6&&r.length!==8)return null;let a=Number.parseInt(r.slice(0,6),16),i=r.length===8?Number.parseInt(r.slice(6,8),16)/255:1;return{r:a>>16&255,g:a>>8&255,b:a&255,a:i}}function ke(e){let o=e.slice(0,e.indexOf(\"(\")).toLowerCase(),a=e.slice(e.indexOf(\"(\")+1,e.lastIndexOf(\")\")).split(/[,\\s/]+/).filter(Boolean).map(h=>h.endsWith(\"%\")?Number.parseFloat(h)/100:Number.parseFloat(h));if(a.some(Number.isNaN))return null;if(o.startsWith(\"rgb\")){let[h,s,b,k]=a;return h===void 0||s===void 0||b===void 0?null:{r:h,g:s,b,a:k??1}}let[i,n,l,m]=a;return i===void 0||n===void 0||l===void 0?null:{...ve(i,n>1?n/100:n,l>1?l/100:l),a:m??1}}function ve(e,o,r){let a=(1-Math.abs(2*r-1))*o,i=(e%360+360)%360/60,n=a*(1-Math.abs(i%2-1)),[l,m,h]=i<1?[a,n,0]:i<2?[n,a,0]:i<3?[0,a,n]:i<4?[0,n,a]:i<5?[n,0,a]:[a,0,n],s=r-a/2;return{r:Math.round((l+s)*255),g:Math.round((m+s)*255),b:Math.round((h+s)*255)}}function z(e){let o=[];for(let r of e.matchAll(Ee)){let a=ke(r[0]);a&&o.push(a)}for(let r of e.matchAll(/#[0-9a-fA-F]{3,8}\\b/g)){let a=xe(r[0]);a&&o.push(a)}return o}function F(e,o){let r=e.a+o.a*(1-e.a);if(r===0)return{r:0,g:0,b:0,a:0};let a=(i,n)=>(i*e.a+n*o.a*(1-e.a))/r;return{r:a(e.r,o.r),g:a(e.g,o.g),b:a(e.b,o.b),a:r}}function Y(e){let o=e/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4}function q(e){return .2126*Y(e.r)+.7152*Y(e.g)+.0722*Y(e.b)}function H(e,o){let[r,a]=[q(e),q(o)].sort((i,n)=>n-i);return(r+.05)/(a+.05)}var Ie={r:255,g:255,b:255,a:1},Se={r:18,g:18,b:18,a:1},G=e=>e.parentElement??e.getRootNode().host??null,L;function X(e,o){if(e===\"transparent\")return{r:0,g:0,b:0,a:0};let[r]=z(e);if(r)return r;if(L===void 0&&(L=o.createElement(\"canvas\").getContext(\"2d\",{willReadFrequently:!0})),!L)return;L.clearRect(0,0,1,1),L.fillStyle=\"#000\",L.fillStyle=e,L.fillRect(0,0,1,1);let[a,i,n,l]=L.getImageData(0,0,1,1).data;return{r:a,g:i,b:n,a:l/255}}function ie(e){let o=e.ownerDocument,r=o.defaultView,a=[];for(let n=e;n;n=G(n)){let l=r.getComputedStyle(n);if(l.backgroundImage&&l.backgroundImage!==\"none\")return;let m=X(l.backgroundColor,o);if(!m)return;if(m.a>0&&a.push(m),m.a>=1)break}let i=r.getComputedStyle(o.documentElement).colorScheme.includes(\"dark\")&&r.matchMedia?.(\"(prefers-color-scheme: dark)\").matches;return a.reverse().reduce((n,l)=>F(l,n),i?Se:Ie)}var se=e=>`${Math.floor(e*100)/100}:1`;function le(e,o){let r={},a=d=>r[d]=(r[d]??0)+1,i=e.filter(d=>typeof d.getBoundingClientRect==\"function\"),n=i[0];if(!n)return{unmeasured:r,measured:{contrast:0,\"focus-visible\":0}};let l=n.ownerDocument,m=l.defaultView,h=d=>{let O=d.getBoundingClientRect();return O.width>1&&O.height>1},s=0;for(let d of i){if(s>=o.limit)break;if(!Array.from(d.childNodes).some(c=>c.nodeType===3&&(c.textContent??\"\").trim()!==\"\")||d.namespaceURI!==\"http://www.w3.org/1999/xhtml\"||d.hasAttribute(\"disabled\")||d.getAttribute(\"aria-disabled\")===\"true\")continue;let v=m.getComputedStyle(d);if(v.visibility!==\"visible\"||v.display===\"none\"||!h(d))continue;s+=1;let g=X(v.color,l),I=ie(d);if(!g||!I){a(\"contrast\");continue}let E=H(F(g,I),I),T=Number.parseFloat(v.fontSize),P=Number.parseInt(v.fontWeight,10),t=T>=24||T>=18.66&&P>=700,u=t?3:4.5;E+.005<u&&o.say(\"contrast\",d,\"serious\",`Its words are at ${se(E)} against their ground; ${u}:1 is the least ${t?\"large \":\"\"}text may be.`,\"Give it a color further from its ground: --graview-ink and --graview-ink-muted are held to the app's grounds.\")}let b=l.activeElement,k=0;for(let d of i){if(k>=o.limit)break;if(!o.tabbable(d)||!h(d))continue;if(k+=1,d.focus({preventScroll:!0,focusVisible:!0}),d.getRootNode().activeElement!==d||!d.matches(\":focus-visible\")){a(\"focus-visible\");continue}let g=m.getComputedStyle(d),I=Number.parseFloat(g.outlineWidth)||0,E=!1;for(let u=d;u;u=G(u))u.hasAttribute(\"data-graview-view-root\")&&(E=!0);if(g.outlineStyle===\"auto\"){a(\"focus-visible\");continue}if(g.outlineStyle===\"none\"||I===0){g.boxShadow&&g.boxShadow!==\"none\"?a(\"focus-visible\"):o.say(\"focus-visible\",d,\"serious\",\"It shows no ring when it has the keyboard: a person cannot see where they are.\",\"Leave the outline on :focus-visible (in a view the host draws it; restyle it with --graview-focus-color).\",\"2.4.7\",E);continue}if(I+.01<2){o.say(\"focus-visible\",d,\"serious\",`Its ring is ${I}px: at least 2px is seen.`,\"Give the outline 2px or more (--graview-focus-width in a view).\",\"2.4.7\",E);continue}let T=X(g.outlineColor,l),P=G(d)?ie(G(d)):void 0;if(!T||!P){a(\"focus-visible\");continue}let t=H(F(T,P),P);t+.005<3&&o.say(\"focus-visible\",d,\"serious\",`Its ring is at ${se(t)} against what is around it; 3:1 is the least a ring may be.`,\"Give the ring a color at 3:1 against the ground (--graview-focus-color in a view; the app's accent is held to it).\",\"1.4.11\",E)}k>0&&(l.activeElement?.blur?.(),b&&b!==l.body&&b.focus?.({preventScroll:!0}));for(let d of i){let O=m.getComputedStyle(d);if(!(/(auto|scroll)/.test(O.overflowX)||/(auto|scroll)/.test(O.overflowY)))continue;let g=d;(g.scrollHeight>g.clientHeight+1||g.scrollWidth>g.clientWidth+1)&&o.scrollsOnPage(d)}return{unmeasured:r,measured:{contrast:s,\"focus-visible\":k}}}var de={keyboard:{wcag:\"2.1.1\",says:\"What a person can click is reached by the keyboard.\",needs:\"structure\"},role:{wcag:\"4.1.2\",says:\"What takes the keyboard says what it is.\",needs:\"structure\"},name:{wcag:\"4.1.2\",says:\"Every control and link has a name.\",needs:\"structure\"},\"toggle-state\":{wcag:\"4.1.2\",says:\"A toggle says whether it is on, open or chosen.\",needs:\"structure\"},\"nested-interactive\":{wcag:\"4.1.2\",says:\"No control or link is inside another.\",needs:\"structure\"},\"img-alt\":{wcag:\"1.1.1\",says:'Every image says what it shows, or says it is decoration (alt=\"\").',needs:\"structure\"},\"svg-name\":{wcag:\"1.1.1\",says:'A picture drawn in SVG that means something is role=\"img\" with a name; one that does not is hidden.',needs:\"structure\"},\"scroll-region\":{wcag:\"2.1.1\",says:\"A box that scrolls by itself takes the keyboard and has a name.\",needs:\"structure\"},\"focus-visible\":{wcag:\"2.4.7\",says:\"Whatever has the keyboard shows a ring at least 2px wide, at 3:1 against its ground.\",needs:\"layout\"},contrast:{wcag:\"1.4.3\",says:\"Text is at 4.5:1 against its ground, 3:1 when large.\",needs:\"layout\"},\"keyboard-trap\":{wcag:\"2.1.2\",says:\"Tab leaves the view: the keyboard is never held inside it.\",needs:\"keys\"}};var me=\"http://www.w3.org/1999/xhtml\",U=\"http://www.w3.org/2000/svg\",p=(e,...o)=>e.namespaceURI===me&&o.includes(e.localName),he=e=>e.nodeType===1,_=e=>Array.from(e.childNodes).filter(he),Re=new Set([\"button\",\"link\",\"checkbox\",\"switch\",\"radio\",\"tab\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"slider\",\"spinbutton\",\"textbox\",\"searchbox\",\"combobox\",\"treeitem\"]),Oe=new Set([\"button\",\"link\",\"checkbox\",\"switch\",\"radio\",\"tab\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"img\",\"slider\",\"progressbar\",\"scrollbar\",\"separator\"]),Ne={checkbox:\"aria-checked\",switch:\"aria-checked\",radio:\"aria-checked\",menuitemcheckbox:\"aria-checked\",menuitemradio:\"aria-checked\",tab:\"aria-selected\",option:\"aria-selected\"},ue=new Set([\"true\",\"false\",\"mixed\"]),Te=/^(show|hide|expand|collapse)?\\s*(more|less|all|details|everything)?$/i;function N(e){let o=[],r=a=>{for(let i of _(a))o.push(i),r(i)};return r(e),o}function ce(e){for(let o=e;o;o=o.parentElement)if(o.getAttribute(\"aria-hidden\")===\"true\"||o.hasAttribute(\"hidden\"))return!0;return!1}var M=e=>e.getAttribute(\"role\")?.trim().split(/\\s+/)[0]?.toLowerCase()??null,Pe=e=>{let o=e.getAttribute(\"tabindex\");if(o===null)return;let r=Number.parseInt(o,10);return Number.isNaN(r)?void 0:r},Le=e=>e.hasAttribute(\"disabled\")||e.getAttribute(\"aria-disabled\")===\"true\",R=e=>p(e,\"input\")&&(e.getAttribute(\"type\")??\"\").toLowerCase()===\"hidden\"||p(e,\"button\",\"input\",\"select\",\"textarea\")&&e.hasAttribute(\"disabled\")?!1:B(e)&&(Pe(e)??0)>=0,Z=e=>p(e,\"button\",\"select\",\"textarea\",\"summary\")||p(e,\"input\")&&(e.getAttribute(\"type\")??\"\").toLowerCase()!==\"hidden\"||e.localName===\"a\"&&e.hasAttribute(\"href\"),fe=e=>Z(e)||e.hasAttribute(\"data-graview-link\")||e.hasAttribute(\"data-graview-press\")?!0:Re.has(M(e)??\"\"),_e=e=>e.hasAttribute(\"role\")||!V(e);function Ce(e){let o=[],r=a=>JSON.stringify(a);for(let a=e;a&&!a.hasAttribute(\"data-graview-view-root\");a=a.parentElement){let i=a.getAttribute(\"data-key\");if(i!==null){o.unshift(`[data-key=${r(i)}]`);break}let n=a.getAttribute(\"id\");if(n){o.unshift(`[id=${r(n)}]`);break}let l=a.getAttribute(\"class\")?.trim().split(/\\s+/)[0],m=`${a.localName}${l?`.${l}`:\"\"}`,h=a.parentElement;if(h){let s=_(h).filter(b=>b.localName===a.localName);s.length>1&&(m+=`:nth-of-type(${s.indexOf(a)+1})`)}o.unshift(m)}return o.join(\" > \")}var Me=e=>{for(let o=e;o;o=o.parentElement){let r=o.getAttribute(\"data-key\");if(r!==null)return r}};function x(e){if(e.nodeType===3)return e.textContent??\"\";if(!he(e)||e.getAttribute(\"aria-hidden\")===\"true\"||e.hasAttribute(\"hidden\"))return\"\";let o=e.getAttribute(\"aria-label\")?.trim();if(o)return` ${o} `;if(e.localName===\"img\")return` ${e.getAttribute(\"alt\")??\"\"} `;if(e.namespaceURI===U&&e.localName===\"svg\"){let r=_(e).find(a=>a.localName===\"title\");return r?` ${x(r)} `:\"\"}return p(e,\"input\",\"select\",\"textarea\")?\"\":Array.from(e.childNodes).map(x).join(\"\")}var y=e=>e.replace(/\\s+/g,\" \").trim();function Fe(e,o,r){let a=e.getAttribute(\"aria-labelledby\");if(a){let n=y(a.split(/\\s+/).map(l=>o.get(l)?x(o.get(l)):\"\").join(\" \"));if(n)return n}let i=y(e.getAttribute(\"aria-label\")??\"\");if(i)return i;if(p(e,\"input\",\"select\",\"textarea\")){let n=(e.getAttribute(\"type\")??\"\").toLowerCase();if(p(e,\"input\")&&[\"submit\",\"reset\",\"button\"].includes(n))return y(e.getAttribute(\"value\")??(n===\"submit\"?\"Submit\":n===\"reset\"?\"Reset\":\"\"));if(p(e,\"input\")&&n===\"image\")return y(e.getAttribute(\"alt\")??\"\");let l=e.getAttribute(\"id\"),m=l?r.find(s=>s.getAttribute(\"for\")===l):void 0;if(m&&y(x(m)))return y(x(m));for(let s=e.parentElement;s;s=s.parentElement)if(p(s,\"label\")&&y(x(s)))return y(x(s));let h=y(e.getAttribute(\"placeholder\")??\"\");return h||y(e.getAttribute(\"title\")??\"\")}return e.localName===\"img\"?y(e.getAttribute(\"alt\")??e.getAttribute(\"title\")??\"\"):y(x(e))||y(e.getAttribute(\"title\")??\"\")}function De(e){let o=N(e);for(let r of o){let a=N(r).some(W);if(!ne(r,a)||(r.setAttribute(\"data-graview-link\",\"\"),j(r,N(r))))continue;let i=r.localName===\"a\";if(!r.hasAttribute(\"role\")&&(i||V(r))&&r.setAttribute(\"role\",\"link\"),p(r,\"tr\")){let n=_(r).find(l=>l.localName===\"td\"||l.localName===\"th\");n&&!n.hasAttribute(\"tabindex\")&&n.setAttribute(\"tabindex\",\"0\");continue}!p(r,\"button\")&&!r.hasAttribute(\"tabindex\")&&r.setAttribute(\"tabindex\",\"0\")}for(let r of o){let a=oe(r)&&!K(r)&&!p(r,\"input\",\"select\",\"textarea\"),i=!a&&ae(r);!a&&!i||(B(r)||r.setAttribute(\"tabindex\",\"0\"),a&&V(r)&&r.setAttribute(\"role\",\"button\"),r.setAttribute(\"data-graview-press\",\"\"))}for(let r of o.filter(a=>a.namespaceURI===U&&a.localName===\"svg\")){let a=r.hasAttribute(\"role\")||r.hasAttribute(\"aria-label\")||r.hasAttribute(\"aria-labelledby\")||_(r).some(n=>n.localName===\"title\"),i=[r,...N(r)].some(n=>n.hasAttribute(\"tabindex\")||n.hasAttribute(\"data-graview-link\")||n.hasAttribute(\"data-graview-press\")||n.localName===\"a\");!a&&!i&&!r.hasAttribute(\"aria-hidden\")&&r.setAttribute(\"aria-hidden\",\"true\")}}function Ve(e,o){let r=e;return typeof r.querySelectorAll!=\"function\"?[]:o.flatMap(a=>{try{return Array.from(r.querySelectorAll(a))}catch{return[]}})}function J(e){for(let o of _(e)){if(R(o)||J(o))return!0;let r=o.shadowRoot;if(r&&J(r))return!0}return!1}function He(e){let o=e.ownerDocument?.defaultView;if(!o||typeof o.getComputedStyle!=\"function\")return!1;let a=(e.host??e).getBoundingClientRect?.();return!!(a&&(a.width>0||a.height>0))}function pe(e,o={}){o.host===\"pending\"&&De(e);let r=N(e),a=new Map(r.flatMap(t=>t.getAttribute(\"id\")?[[t.getAttribute(\"id\"),t]]:[])),i=r.filter(t=>p(t,\"label\")),n=o.clicked?Array.from(o.clicked):[...Q(e)??[]],l=new Set([...n.filter(t=>typeof t==\"object\"),...Ve(e,n.filter(t=>typeof t==\"string\"))]),m=o.chrome===!0,h=[],s=(t,u,c,A,f,w=!1,C=de[t].wcag)=>{let D=Me(u);h.push({rule:t,wcag:C,impact:c,at:Ce(u),...D!==void 0?{key:D}:{},says:A,fix:f,automatic:w||m})},b=r.filter(t=>!ce(t)),k=t=>Fe(t,a,i)!==\"\",d=new Set(b.filter(t=>t.hasAttribute(\"data-graview-link\")&&j(t,N(t))));for(let t of b){if(Le(t))continue;let u=t.hasAttribute(\"data-graview-link\"),c=t.hasAttribute(\"data-graview-press\"),A=l.has(t);if(!u&&!c&&!A||Z(t)&&R(t)||d.has(t)&&!A||p(t,\"tr\")&&_(t).some(w=>(w.localName===\"td\"||w.localName===\"th\")&&R(w)))continue;if(!(R(t)||A&&N(t).some(w=>R(w)&&(Z(w)||w.hasAttribute(\"data-graview-press\")||w.hasAttribute(\"data-graview-link\"))))){u||c?s(\"keyboard\",t,\"serious\",\"It is a link or a press the host makes, and Tab does not reach it.\",\"The host gives it the keyboard when it draws the view; audit the view as the host drew it.\",!0):s(\"keyboard\",t,\"serious\",`A <${t.localName}> the view hears a click on, which Tab does not reach: a mouse can press it and a keyboard cannot.`,'Draw it as a <button type=\"button\"> (the host resets its look), or give it role=\"button\" and the host gives it the keyboard, Enter and Space.');continue}R(t)&&!_e(t)&&!(t.localName===\"a\"&&t.hasAttribute(\"href\"))&&s(\"role\",t,\"serious\",`A <${t.localName}> that takes the keyboard says nothing of what it is: a screen reader says \"group\" or nothing.`,'Draw it as a <button type=\"button\">, or give it role=\"button\" (or role=\"link\" when it goes somewhere).',u||c)}for(let t of b){if(!fe(t)||d.has(t)||k(t))continue;let u=M(t),c=p(t,\"button\")||u===\"button\"||t.hasAttribute(\"data-graview-press\"),A=p(t,\"input\",\"select\",\"textarea\")||[\"textbox\",\"searchbox\",\"combobox\",\"slider\",\"spinbutton\"].includes(u??\"\"),f=A?\"field\":c?\"button\":t.hasAttribute(\"data-graview-link\")||t.localName===\"a\"||u===\"link\"?\"link\":\"control\";s(\"name\",t,c||A?\"critical\":\"serious\",`A ${f} with no name: a screen reader says only \"${f}\".`,A?'Give it a <label for> or aria-label=\"\\u2026\".':'Put words in it \\u2014 a .graview-sr span when it shows only an icon \\u2014 or aria-label=\"\\u2026\".')}for(let t of b){let u=M(t),c=u&&!p(t,\"input\")?Ne[u]:void 0;if(c&&!t.hasAttribute(c)){s(\"toggle-state\",t,\"serious\",`It is role=\"${u}\" and says no ${c}: a screen reader cannot say whether it is ${c===\"aria-checked\"?\"on\":\"chosen\"}.`,`Give it ${c}=\"true\" or \"false\", and draw it again as it changes.`);continue}for(let[f,w]of[[\"aria-checked\",ue],[\"aria-pressed\",ue],[\"aria-expanded\",new Set([\"true\",\"false\"])],[\"aria-selected\",new Set([\"true\",\"false\"])]]){let C=t.getAttribute(f);C!==null&&!w.has(C)&&s(\"toggle-state\",t,\"serious\",`${f}=\"${C}\" is no state a screen reader can say.`,`Give ${f} \"true\" or \"false\"${w.has(\"mixed\")?' (or \"mixed\")':\"\"}.`)}!(p(t,\"button\")||u===\"button\"||t.hasAttribute(\"data-graview-press\"))||t.hasAttribute(\"aria-expanded\")||t.hasAttribute(\"aria-pressed\")||(t.hasAttribute(\"aria-controls\")?s(\"toggle-state\",t,\"serious\",\"A button that says what it controls (aria-controls) and not whether that is open.\",'Give it aria-expanded=\"true\" or \"false\", and draw it again as it opens and closes.'):l.has(t)&&y(x(t))!==\"\"&&Te.test(y(x(t)))&&s(\"toggle-state\",t,\"moderate\",`A button the view hears that reads \"${y(x(t))}\" \\u2014 it opens and closes something \\u2014 and says no state.`,'Give it aria-expanded=\"true\" or \"false\" (or aria-pressed for a toggle), and draw it again as it changes.'))}for(let t of b){let u=M(t)??(p(t,\"button\")?\"button\":t.localName===\"a\"&&t.hasAttribute(\"href\")?\"link\":null);if(!u||!Oe.has(u)||u===\"img\")continue;let c=N(t).find(f=>!ce(f)&&(R(f)||fe(f)));if(!c)continue;let A=t.hasAttribute(\"data-graview-link\")&&!p(t,\"a\");s(\"nested-interactive\",t,\"serious\",`A ${u} holds a <${c.localName}> a person presses on its own: a screen reader reads the ${u} as one thing and never reaches what is inside.`,A?\"Put an <a> to the card's own record or place on its heading: the card is then a bigger target for a pointer, and the <a> the keyboard's way in.\":`Move the <${c.localName}> out of the ${u}, beside it.`)}for(let t of b){if(t.localName===\"img\"&&t.namespaceURI===me){if(t.hasAttribute(\"alt\")||t.hasAttribute(\"aria-label\")||t.hasAttribute(\"aria-labelledby\")||[\"none\",\"presentation\"].includes(M(t)??\"\"))continue;s(\"img-alt\",t,\"critical\",\"An image with no alt: a screen reader reads its address, or nothing.\",'Give it alt=\"what it shows\", or alt=\"\" when it is decoration.');continue}if(t.namespaceURI!==U||t.localName!==\"svg\"||t.parentElement?.namespaceURI===U||[t,...N(t)].some(f=>R(f)||f.hasAttribute(\"data-graview-link\")||f.hasAttribute(\"data-graview-press\")||f.localName===\"a\"))continue;let c=M(t);if(c===\"none\"||c===\"presentation\")continue;let A=k(t)&&(t.hasAttribute(\"aria-label\")||t.hasAttribute(\"aria-labelledby\")||_(t).some(f=>f.localName===\"title\"));!c&&!A?s(\"svg-name\",t,\"minor\",\"An SVG that says nothing, which a screen reader still meets.\",\"The host hides an SVG that says nothing when it draws the view.\",!0):c!==\"img\"&&c!==\"graphics-document\"?s(\"svg-name\",t,\"minor\",\"An SVG with a name and no role: some screen readers skip it.\",'Give it role=\"img\" beside its aria-label.'):A||s(\"svg-name\",t,\"serious\",'An SVG that is role=\"img\" with no name: a screen reader says \"image\" and nothing more.','Give it aria-label=\"what it shows\", or a <title> first inside it.')}let O=t=>/overflow(-[xy])?\\s*:\\s*(auto|scroll)/i.test(t.getAttribute(\"style\")??\"\"),v=t=>{R(t)&&k(t)||J(t)||s(\"scroll-region\",t,\"serious\",\"A box that scrolls by itself and holds nothing Tab reaches: the keyboard cannot scroll it, and what is past its edge is out of reach.\",'Give it tabindex=\"0\", role=\"region\" and aria-label=\"what it holds\", or let it flow with the page.')},g=o.measure!==!1&&He(e);if(!g)for(let t of b)O(t)&&v(t);let I=[\"keyboard\",\"role\",\"name\",\"toggle-state\",\"nested-interactive\",\"img-alt\",\"svg-name\",\"scroll-region\"],E=[],T={},P={};if(g){let t=le(b,{limit:o.limit??400,tabbable:R,scrollsOnPage:v,say:(u,c,A,f,w,C,D)=>s(u,c,A,f,w,D===!0,C)});I.push(\"focus-visible\",\"contrast\"),Object.assign(T,t.unmeasured),Object.assign(P,t.measured)}else{let t=o.measure===!1?\"Asked not to measure.\":\"Nothing here is laid out (a headless run, or a DOM with no layout): it needs a browser's styles and boxes.\";E.push({rule:\"focus-visible\",why:t},{rule:\"contrast\",why:t})}return E.push({rule:\"keyboard-trap\",why:\"It needs keys pressed in a browser: a harness's Tab walk presses them (pnpm verify a11y).\"}),{problems:h,ran:I,skipped:E,unmeasured:T,measured:P}}globalThis.__graviewAudit=pe;})();\n";
|
|
6
|
+
export const AUDIT_PAGE_SCRIPT = "/*! @graview/guest audit, as a page runs it. Elastic License 2.0. */\n\"use strict\";(()=>{var be=Symbol.for(\"graview.view.clicked\");function Q(e){for(let o=e,r=0;o&&r<64;r+=1){let a=o[be];if(Array.isArray(a))return a;o=o.host??o.parentNode}}var ee=\"http://www.w3.org/1999/xhtml\",te=new Set([\"button\",\"submit\",\"reset\",\"checkbox\",\"radio\",\"image\"]);var ge=new Set([\"div\",\"span\",\"section\",\"article\",\"aside\",\"header\",\"footer\",\"figure\",\"p\",\"b\",\"i\",\"em\",\"strong\",\"small\",\"mark\",\"time\",\"img\"]),S=(e,...o)=>e.namespaceURI===ee&&o.includes(e.localName),re=e=>(e.getAttribute(\"type\")??\"text\").toLowerCase(),W=e=>S(e,\"textarea\",\"select\")||S(e,\"input\")&&!te.has(re(e)),$=e=>S(e,\"input\",\"select\",\"textarea\");function K(e){return S(e,\"button\",\"summary\")||S(e,\"input\")&&te.has(re(e))||e.localName===\"a\"&&e.hasAttribute(\"data-graview-link\")}function Ae(e){if(S(e,\"option\",\"optgroup\",\"datalist\"))return'An option is never pressed by itself: put data-act on its select, with data-save=\"change\", or on a button.';if(S(e,\"label\"))return\"A press on a label presses its field too, and would ask for the act twice: put data-act on a button, or on the field.\";if(W(e)&&!e.hasAttribute(\"data-save\"))return'A click into a field to type or to pick is not a press: give it data-save (\"input\" or \"change\") to save it as it is typed, or put data-act on a button beside it.'}var oe=e=>e.hasAttribute(\"data-act\")&&Ae(e)===void 0&&!($(e)&&e.hasAttribute(\"data-save\")),ye=new Set([\"button\",\"checkbox\",\"switch\",\"tab\"]);function ae(e,o=e.getAttribute(\"role\")){return K(e)||$(e)||S(e,\"label\",\"option\")||e.hasAttribute(\"data-graview-link\")?!1:ye.has(o??\"\")||e.hasAttribute(\"aria-pressed\")||e.hasAttribute(\"aria-expanded\")}function B(e){return S(e,\"button\",\"input\",\"select\",\"textarea\",\"summary\",\"iframe\")||e.localName===\"a\"&&e.hasAttribute(\"href\")?!0:e.hasAttribute(\"tabindex\")||(e.getAttribute(\"contenteditable\")??\"false\")!==\"false\"}var V=e=>!e.hasAttribute(\"role\")&&(e.namespaceURI!==ee||ge.has(e.localName));function ne(e,o){return!e.hasAttribute(\"data-record\")&&!e.hasAttribute(\"data-place\")?!1:e.localName===\"a\"?!0:o||$(e)||S(e,\"fieldset\",\"form\",\"label\",\"option\")||e.localName===\"graview-video\"||e.hasAttribute(\"data-act\")||e.hasAttribute(\"data-lightbox\")||e.hasAttribute(\"data-drop\")||e.hasAttribute(\"data-field\")?!1:e.getAttribute(\"role\")!==\"group\"}function Y(e,o){if(e.localName===\"a\"||e.localName===\"button\")return!1;let r=e.getAttribute(\"data-record\"),a=e.getAttribute(\"data-place\");for(let i of o)if(i.localName===\"a\"&&(r!==null?i.getAttribute(\"data-record\")===r:a!==null&&i.getAttribute(\"data-place\")===a))return!0;return!1}var Ee=/^#([0-9a-f]{3,8})$/i,we=/(rgba?|hsla?)\\(([^)]+)\\)/gi;function xe(e){let o=Ee.exec(e.trim());if(!o)return null;let r=o[1];if((r.length===3||r.length===4)&&(r=[...r].map(n=>n+n).join(\"\")),r.length!==6&&r.length!==8)return null;let a=Number.parseInt(r.slice(0,6),16),i=r.length===8?Number.parseInt(r.slice(6,8),16)/255:1;return{r:a>>16&255,g:a>>8&255,b:a&255,a:i}}function ke(e){let o=e.slice(0,e.indexOf(\"(\")).toLowerCase(),a=e.slice(e.indexOf(\"(\")+1,e.lastIndexOf(\")\")).split(/[,\\s/]+/).filter(Boolean).map(h=>h.endsWith(\"%\")?Number.parseFloat(h)/100:Number.parseFloat(h));if(a.some(Number.isNaN))return null;if(o.startsWith(\"rgb\")){let[h,s,b,k]=a;return h===void 0||s===void 0||b===void 0?null:{r:h,g:s,b,a:k??1}}let[i,n,l,m]=a;return i===void 0||n===void 0||l===void 0?null:{...ve(i,n>1?n/100:n,l>1?l/100:l),a:m??1}}function ve(e,o,r){let a=(1-Math.abs(2*r-1))*o,i=(e%360+360)%360/60,n=a*(1-Math.abs(i%2-1)),[l,m,h]=i<1?[a,n,0]:i<2?[n,a,0]:i<3?[0,a,n]:i<4?[0,n,a]:i<5?[n,0,a]:[a,0,n],s=r-a/2;return{r:Math.round((l+s)*255),g:Math.round((m+s)*255),b:Math.round((h+s)*255)}}function z(e){let o=[];for(let r of e.matchAll(we)){let a=ke(r[0]);a&&o.push(a)}for(let r of e.matchAll(/#[0-9a-fA-F]{3,8}\\b/g)){let a=xe(r[0]);a&&o.push(a)}return o}function F(e,o){let r=e.a+o.a*(1-e.a);if(r===0)return{r:0,g:0,b:0,a:0};let a=(i,n)=>(i*e.a+n*o.a*(1-e.a))/r;return{r:a(e.r,o.r),g:a(e.g,o.g),b:a(e.b,o.b),a:r}}function j(e){let o=e/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4}function q(e){return .2126*j(e.r)+.7152*j(e.g)+.0722*j(e.b)}function G(e,o){let[r,a]=[q(e),q(o)].sort((i,n)=>n-i);return(r+.05)/(a+.05)}var Ie={r:255,g:255,b:255,a:1},Se={r:18,g:18,b:18,a:1},H=e=>e.parentElement??e.getRootNode().host??null,L;function X(e,o){if(e===\"transparent\")return{r:0,g:0,b:0,a:0};let[r]=z(e);if(r)return r;if(L===void 0&&(L=o.createElement(\"canvas\").getContext(\"2d\",{willReadFrequently:!0})),!L)return;L.clearRect(0,0,1,1),L.fillStyle=\"#000\",L.fillStyle=e,L.fillRect(0,0,1,1);let[a,i,n,l]=L.getImageData(0,0,1,1).data;return{r:a,g:i,b:n,a:l/255}}function ie(e){let o=e.ownerDocument,r=o.defaultView,a=[];for(let n=e;n;n=H(n)){let l=r.getComputedStyle(n);if(l.backgroundImage&&l.backgroundImage!==\"none\")return;let m=X(l.backgroundColor,o);if(!m)return;if(m.a>0&&a.push(m),m.a>=1)break}let i=r.getComputedStyle(o.documentElement).colorScheme.includes(\"dark\")&&r.matchMedia?.(\"(prefers-color-scheme: dark)\").matches;return a.reverse().reduce((n,l)=>F(l,n),i?Se:Ie)}var se=e=>`${Math.floor(e*100)/100}:1`;function le(e,o){let r={},a=d=>r[d]=(r[d]??0)+1,i=e.filter(d=>typeof d.getBoundingClientRect==\"function\"),n=i[0];if(!n)return{unmeasured:r,measured:{contrast:0,\"focus-visible\":0}};let l=n.ownerDocument,m=l.defaultView,h=d=>{let O=d.getBoundingClientRect();return O.width>1&&O.height>1},s=0;for(let d of i){if(s>=o.limit)break;if(!Array.from(d.childNodes).some(c=>c.nodeType===3&&(c.textContent??\"\").trim()!==\"\")||d.namespaceURI!==\"http://www.w3.org/1999/xhtml\"||d.hasAttribute(\"disabled\")||d.getAttribute(\"aria-disabled\")===\"true\")continue;let v=m.getComputedStyle(d);if(v.visibility!==\"visible\"||v.display===\"none\"||!h(d))continue;s+=1;let g=X(v.color,l),I=ie(d);if(!g||!I){a(\"contrast\");continue}let w=G(F(g,I),I),T=Number.parseFloat(v.fontSize),P=Number.parseInt(v.fontWeight,10),t=T>=24||T>=18.66&&P>=700,u=t?3:4.5;w+.005<u&&o.say(\"contrast\",d,\"serious\",`Its words are at ${se(w)} against their ground; ${u}:1 is the least ${t?\"large \":\"\"}text may be.`,\"Give it a color further from its ground: --graview-ink and --graview-ink-muted are held to the app's grounds.\")}let b=l.activeElement,k=0;for(let d of i){if(k>=o.limit)break;if(!o.tabbable(d)||!h(d))continue;if(k+=1,d.focus({preventScroll:!0,focusVisible:!0}),d.getRootNode().activeElement!==d||!d.matches(\":focus-visible\")){a(\"focus-visible\");continue}let g=m.getComputedStyle(d),I=Number.parseFloat(g.outlineWidth)||0,w=!1;for(let u=d;u;u=H(u))u.hasAttribute(\"data-graview-view-root\")&&(w=!0);if(g.outlineStyle===\"auto\"){a(\"focus-visible\");continue}if(g.outlineStyle===\"none\"||I===0){g.boxShadow&&g.boxShadow!==\"none\"?a(\"focus-visible\"):o.say(\"focus-visible\",d,\"serious\",\"It shows no ring when it has the keyboard: a person cannot see where they are.\",\"Leave the outline on :focus-visible (in a view the host draws it; restyle it with --graview-focus-color).\",\"2.4.7\",w);continue}if(I+.01<2){o.say(\"focus-visible\",d,\"serious\",`Its ring is ${I}px: at least 2px is seen.`,\"Give the outline 2px or more (--graview-focus-width in a view).\",\"2.4.7\",w);continue}let T=X(g.outlineColor,l),P=H(d)?ie(H(d)):void 0;if(!T||!P){a(\"focus-visible\");continue}let t=G(F(T,P),P);t+.005<3&&o.say(\"focus-visible\",d,\"serious\",`Its ring is at ${se(t)} against what is around it; 3:1 is the least a ring may be.`,\"Give the ring a color at 3:1 against the ground (--graview-focus-color in a view; the app's accent is held to it).\",\"1.4.11\",w)}k>0&&(l.activeElement?.blur?.(),b&&b!==l.body&&b.focus?.({preventScroll:!0}));for(let d of i){let O=m.getComputedStyle(d);if(!(/(auto|scroll)/.test(O.overflowX)||/(auto|scroll)/.test(O.overflowY)))continue;let g=d;(g.scrollHeight>g.clientHeight+1||g.scrollWidth>g.clientWidth+1)&&o.scrollsOnPage(d)}return{unmeasured:r,measured:{contrast:s,\"focus-visible\":k}}}var de={keyboard:{wcag:\"2.1.1\",says:\"What a person can click is reached by the keyboard.\",needs:\"structure\"},role:{wcag:\"4.1.2\",says:\"What takes the keyboard says what it is.\",needs:\"structure\"},name:{wcag:\"4.1.2\",says:\"Every control and link has a name.\",needs:\"structure\"},\"toggle-state\":{wcag:\"4.1.2\",says:\"A toggle says whether it is on, open or chosen.\",needs:\"structure\"},\"nested-interactive\":{wcag:\"4.1.2\",says:\"No control or link is inside another.\",needs:\"structure\"},\"img-alt\":{wcag:\"1.1.1\",says:'Every image says what it shows, or says it is decoration (alt=\"\").',needs:\"structure\"},\"svg-name\":{wcag:\"1.1.1\",says:'A picture drawn in SVG that means something is role=\"img\" with a name; one that does not is hidden.',needs:\"structure\"},\"scroll-region\":{wcag:\"2.1.1\",says:\"A box that scrolls by itself takes the keyboard and has a name.\",needs:\"structure\"},\"focus-visible\":{wcag:\"2.4.7\",says:\"Whatever has the keyboard shows a ring at least 2px wide, at 3:1 against its ground.\",needs:\"layout\"},contrast:{wcag:\"1.4.3\",says:\"Text is at 4.5:1 against its ground, 3:1 when large.\",needs:\"layout\"},\"keyboard-trap\":{wcag:\"2.1.2\",says:\"Tab leaves the view: the keyboard is never held inside it.\",needs:\"keys\"}};var me=\"http://www.w3.org/1999/xhtml\",U=\"http://www.w3.org/2000/svg\",p=(e,...o)=>e.namespaceURI===me&&o.includes(e.localName),he=e=>e.nodeType===1,_=e=>Array.from(e.childNodes).filter(he),Re=new Set([\"button\",\"link\",\"checkbox\",\"switch\",\"radio\",\"tab\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"slider\",\"spinbutton\",\"textbox\",\"searchbox\",\"combobox\",\"treeitem\"]),Oe=new Set([\"button\",\"link\",\"checkbox\",\"switch\",\"radio\",\"tab\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"img\",\"slider\",\"progressbar\",\"scrollbar\",\"separator\"]),Ne={checkbox:\"aria-checked\",switch:\"aria-checked\",radio:\"aria-checked\",menuitemcheckbox:\"aria-checked\",menuitemradio:\"aria-checked\",tab:\"aria-selected\",option:\"aria-selected\"},ue=new Set([\"true\",\"false\",\"mixed\"]),Te=/^(show|hide|expand|collapse)?\\s*(more|less|all|details|everything)?$/i;function N(e){let o=[],r=a=>{for(let i of _(a))o.push(i),r(i)};return r(e),o}function ce(e){for(let o=e;o;o=o.parentElement)if(o.getAttribute(\"aria-hidden\")===\"true\"||o.hasAttribute(\"hidden\"))return!0;return!1}var M=e=>e.getAttribute(\"role\")?.trim().split(/\\s+/)[0]?.toLowerCase()??null,Pe=e=>{let o=e.getAttribute(\"tabindex\");if(o===null)return;let r=Number.parseInt(o,10);return Number.isNaN(r)?void 0:r},Le=e=>e.hasAttribute(\"disabled\")||e.getAttribute(\"aria-disabled\")===\"true\",R=e=>p(e,\"input\")&&(e.getAttribute(\"type\")??\"\").toLowerCase()===\"hidden\"||p(e,\"button\",\"input\",\"select\",\"textarea\")&&e.hasAttribute(\"disabled\")?!1:B(e)&&(Pe(e)??0)>=0,Z=e=>p(e,\"button\",\"select\",\"textarea\",\"summary\")||p(e,\"input\")&&(e.getAttribute(\"type\")??\"\").toLowerCase()!==\"hidden\"||e.localName===\"a\"&&e.hasAttribute(\"href\"),fe=e=>Z(e)||e.hasAttribute(\"data-graview-link\")||e.hasAttribute(\"data-graview-press\")?!0:Re.has(M(e)??\"\"),_e=e=>e.hasAttribute(\"role\")||!V(e);function Ce(e){let o=[],r=a=>JSON.stringify(a);for(let a=e;a&&!a.hasAttribute(\"data-graview-view-root\");a=a.parentElement){let i=a.getAttribute(\"data-key\");if(i!==null){o.unshift(`[data-key=${r(i)}]`);break}let n=a.getAttribute(\"id\");if(n){o.unshift(`[id=${r(n)}]`);break}let l=a.getAttribute(\"class\")?.trim().split(/\\s+/)[0],m=`${a.localName}${l?`.${l}`:\"\"}`,h=a.parentElement;if(h){let s=_(h).filter(b=>b.localName===a.localName);s.length>1&&(m+=`:nth-of-type(${s.indexOf(a)+1})`)}o.unshift(m)}return o.join(\" > \")}var Me=e=>{for(let o=e;o;o=o.parentElement){let r=o.getAttribute(\"data-key\");if(r!==null)return r}};function x(e){if(e.nodeType===3)return e.textContent??\"\";if(!he(e)||e.getAttribute(\"aria-hidden\")===\"true\"||e.hasAttribute(\"hidden\"))return\"\";let o=e.getAttribute(\"aria-label\")?.trim();if(o)return` ${o} `;if(e.localName===\"img\")return` ${e.getAttribute(\"alt\")??\"\"} `;if(e.namespaceURI===U&&e.localName===\"svg\"){let r=_(e).find(a=>a.localName===\"title\");return r?` ${x(r)} `:\"\"}return p(e,\"input\",\"select\",\"textarea\")?\"\":Array.from(e.childNodes).map(x).join(\"\")}var y=e=>e.replace(/\\s+/g,\" \").trim();function Fe(e,o,r){let a=e.getAttribute(\"aria-labelledby\");if(a){let n=y(a.split(/\\s+/).map(l=>o.get(l)?x(o.get(l)):\"\").join(\" \"));if(n)return n}let i=y(e.getAttribute(\"aria-label\")??\"\");if(i)return i;if(p(e,\"input\",\"select\",\"textarea\")){let n=(e.getAttribute(\"type\")??\"\").toLowerCase();if(p(e,\"input\")&&[\"submit\",\"reset\",\"button\"].includes(n))return y(e.getAttribute(\"value\")??(n===\"submit\"?\"Submit\":n===\"reset\"?\"Reset\":\"\"));if(p(e,\"input\")&&n===\"image\")return y(e.getAttribute(\"alt\")??\"\");let l=e.getAttribute(\"id\"),m=l?r.find(s=>s.getAttribute(\"for\")===l):void 0;if(m&&y(x(m)))return y(x(m));for(let s=e.parentElement;s;s=s.parentElement)if(p(s,\"label\")&&y(x(s)))return y(x(s));let h=y(e.getAttribute(\"placeholder\")??\"\");return h||y(e.getAttribute(\"title\")??\"\")}return e.localName===\"img\"?y(e.getAttribute(\"alt\")??e.getAttribute(\"title\")??\"\"):y(x(e))||y(e.getAttribute(\"title\")??\"\")}function De(e){let o=N(e);for(let r of o){let a=N(r).some(W);if(!ne(r,a)||(r.setAttribute(\"data-graview-link\",\"\"),Y(r,N(r))))continue;let i=r.localName===\"a\";if(!r.hasAttribute(\"role\")&&(i||V(r))&&r.setAttribute(\"role\",\"link\"),p(r,\"tr\")){let n=_(r).find(l=>l.localName===\"td\"||l.localName===\"th\");n&&!n.hasAttribute(\"tabindex\")&&n.setAttribute(\"tabindex\",\"0\");continue}!p(r,\"button\")&&!r.hasAttribute(\"tabindex\")&&r.setAttribute(\"tabindex\",\"0\")}for(let r of o){let a=oe(r)&&!K(r)&&!p(r,\"input\",\"select\",\"textarea\"),i=!a&&ae(r);!a&&!i||(B(r)||r.setAttribute(\"tabindex\",\"0\"),a&&V(r)&&r.setAttribute(\"role\",\"button\"),r.setAttribute(\"data-graview-press\",\"\"))}for(let r of o.filter(a=>a.namespaceURI===U&&a.localName===\"svg\")){let a=r.hasAttribute(\"role\")||r.hasAttribute(\"aria-label\")||r.hasAttribute(\"aria-labelledby\")||_(r).some(n=>n.localName===\"title\"),i=[r,...N(r)].some(n=>n.hasAttribute(\"tabindex\")||n.hasAttribute(\"data-graview-link\")||n.hasAttribute(\"data-graview-press\")||n.localName===\"a\");!a&&!i&&!r.hasAttribute(\"aria-hidden\")&&r.setAttribute(\"aria-hidden\",\"true\")}}function Ve(e,o){let r=e;return typeof r.querySelectorAll!=\"function\"?[]:o.flatMap(a=>{try{return Array.from(r.querySelectorAll(a))}catch{return[]}})}function J(e){for(let o of _(e)){if(R(o)||J(o))return!0;let r=o.shadowRoot;if(r&&J(r))return!0}return!1}function Ge(e){let o=e.ownerDocument?.defaultView;if(!o||typeof o.getComputedStyle!=\"function\")return!1;let a=(e.host??e).getBoundingClientRect?.();return!!(a&&(a.width>0||a.height>0))}function pe(e,o={}){o.host===\"pending\"&&De(e);let r=N(e),a=new Map(r.flatMap(t=>t.getAttribute(\"id\")?[[t.getAttribute(\"id\"),t]]:[])),i=r.filter(t=>p(t,\"label\")),n=o.clicked?Array.from(o.clicked):[...Q(e)??[]],l=new Set([...n.filter(t=>typeof t==\"object\"),...Ve(e,n.filter(t=>typeof t==\"string\"))]),m=o.chrome===!0,h=[],s=(t,u,c,A,f,E=!1,C=de[t].wcag)=>{let D=Me(u);h.push({rule:t,wcag:C,impact:c,at:Ce(u),...D!==void 0?{key:D}:{},says:A,fix:f,automatic:E||m})},b=r.filter(t=>!ce(t)),k=t=>Fe(t,a,i)!==\"\",d=new Set(b.filter(t=>t.hasAttribute(\"data-graview-link\")&&Y(t,N(t))));for(let t of b){if(Le(t))continue;let u=t.hasAttribute(\"data-graview-link\"),c=t.hasAttribute(\"data-graview-press\"),A=l.has(t);if(!u&&!c&&!A||Z(t)&&R(t)||d.has(t)&&!A||p(t,\"tr\")&&_(t).some(E=>(E.localName===\"td\"||E.localName===\"th\")&&R(E)))continue;if(!(R(t)||A&&N(t).some(E=>R(E)&&(Z(E)||E.hasAttribute(\"data-graview-press\")||E.hasAttribute(\"data-graview-link\"))))){u||c?s(\"keyboard\",t,\"serious\",\"It is a link or a press the host makes, and Tab does not reach it.\",\"The host gives it the keyboard when it draws the view; audit the view as the host drew it.\",!0):s(\"keyboard\",t,\"serious\",`A <${t.localName}> the view hears a click on, which Tab does not reach: a mouse can press it and a keyboard cannot.`,'Draw it as a <button type=\"button\"> (the host resets its look), or give it role=\"button\" and the host gives it the keyboard, Enter and Space.');continue}R(t)&&!_e(t)&&!(t.localName===\"a\"&&t.hasAttribute(\"href\"))&&s(\"role\",t,\"serious\",`A <${t.localName}> that takes the keyboard says nothing of what it is: a screen reader says \"group\" or nothing.`,'Draw it as a <button type=\"button\">, or give it role=\"button\" (or role=\"link\" when it goes somewhere).',u||c)}for(let t of b){if(!fe(t)||d.has(t)||k(t))continue;let u=M(t),c=p(t,\"button\")||u===\"button\"||t.hasAttribute(\"data-graview-press\"),A=p(t,\"input\",\"select\",\"textarea\")||[\"textbox\",\"searchbox\",\"combobox\",\"slider\",\"spinbutton\"].includes(u??\"\"),f=A?\"field\":c?\"button\":t.hasAttribute(\"data-graview-link\")||t.localName===\"a\"||u===\"link\"?\"link\":\"control\";s(\"name\",t,c||A?\"critical\":\"serious\",`A ${f} with no name: a screen reader says only \"${f}\".`,A?'Give it a <label for> or aria-label=\"\\u2026\".':'Put words in it \\u2014 a .graview-sr span when it shows only an icon \\u2014 or aria-label=\"\\u2026\".')}for(let t of b){let u=M(t),c=u&&!p(t,\"input\")?Ne[u]:void 0;if(c&&!t.hasAttribute(c)){s(\"toggle-state\",t,\"serious\",`It is role=\"${u}\" and says no ${c}: a screen reader cannot say whether it is ${c===\"aria-checked\"?\"on\":\"chosen\"}.`,`Give it ${c}=\"true\" or \"false\", and draw it again as it changes.`);continue}for(let[f,E]of[[\"aria-checked\",ue],[\"aria-pressed\",ue],[\"aria-expanded\",new Set([\"true\",\"false\"])],[\"aria-selected\",new Set([\"true\",\"false\"])]]){let C=t.getAttribute(f);C!==null&&!E.has(C)&&s(\"toggle-state\",t,\"serious\",`${f}=\"${C}\" is no state a screen reader can say.`,`Give ${f} \"true\" or \"false\"${E.has(\"mixed\")?' (or \"mixed\")':\"\"}.`)}!(p(t,\"button\")||u===\"button\"||t.hasAttribute(\"data-graview-press\"))||t.hasAttribute(\"aria-expanded\")||t.hasAttribute(\"aria-pressed\")||(t.hasAttribute(\"aria-controls\")?s(\"toggle-state\",t,\"serious\",\"A button that says what it controls (aria-controls) and not whether that is open.\",'Give it aria-expanded=\"true\" or \"false\", and draw it again as it opens and closes.'):l.has(t)&&y(x(t))!==\"\"&&Te.test(y(x(t)))&&s(\"toggle-state\",t,\"moderate\",`A button the view hears that reads \"${y(x(t))}\" \\u2014 it opens and closes something \\u2014 and says no state.`,'Give it aria-expanded=\"true\" or \"false\" (or aria-pressed for a toggle), and draw it again as it changes.'))}for(let t of b){let u=M(t)??(p(t,\"button\")?\"button\":t.localName===\"a\"&&t.hasAttribute(\"href\")?\"link\":null);if(!u||!Oe.has(u)||u===\"img\")continue;let c=N(t).find(f=>!ce(f)&&(R(f)||fe(f)));if(!c)continue;let A=t.hasAttribute(\"data-graview-link\")&&!p(t,\"a\");s(\"nested-interactive\",t,\"serious\",`A ${u} holds a <${c.localName}> a person presses on its own: a screen reader reads the ${u} as one thing and never reaches what is inside.`,A?\"Put an <a> to the card's own record or place on its heading: the card is then a bigger target for a pointer, and the <a> the keyboard's way in.\":`Move the <${c.localName}> out of the ${u}, beside it.`)}for(let t of b){if(t.localName===\"img\"&&t.namespaceURI===me){if(t.hasAttribute(\"alt\")||t.hasAttribute(\"aria-label\")||t.hasAttribute(\"aria-labelledby\")||[\"none\",\"presentation\"].includes(M(t)??\"\"))continue;s(\"img-alt\",t,\"critical\",\"An image with no alt: a screen reader reads its address, or nothing.\",'Give it alt=\"what it shows\", or alt=\"\" when it is decoration.');continue}if(t.namespaceURI!==U||t.localName!==\"svg\"||t.parentElement?.namespaceURI===U||[t,...N(t)].some(f=>R(f)||f.hasAttribute(\"data-graview-link\")||f.hasAttribute(\"data-graview-press\")||f.localName===\"a\"))continue;let c=M(t);if(c===\"none\"||c===\"presentation\")continue;let A=k(t)&&(t.hasAttribute(\"aria-label\")||t.hasAttribute(\"aria-labelledby\")||_(t).some(f=>f.localName===\"title\"));!c&&!A?s(\"svg-name\",t,\"minor\",\"An SVG that says nothing, which a screen reader still meets.\",\"The host hides an SVG that says nothing when it draws the view.\",!0):c!==\"img\"&&c!==\"graphics-document\"?s(\"svg-name\",t,\"minor\",\"An SVG with a name and no role: some screen readers skip it.\",'Give it role=\"img\" beside its aria-label.'):A||s(\"svg-name\",t,\"serious\",'An SVG that is role=\"img\" with no name: a screen reader says \"image\" and nothing more.','Give it aria-label=\"what it shows\", or a <title> first inside it.')}let O=t=>/overflow(-[xy])?\\s*:\\s*(auto|scroll)/i.test(t.getAttribute(\"style\")??\"\"),v=t=>{R(t)&&k(t)||J(t)||s(\"scroll-region\",t,\"serious\",\"A box that scrolls by itself and holds nothing Tab reaches: the keyboard cannot scroll it, and what is past its edge is out of reach.\",'Give it tabindex=\"0\", role=\"region\" and aria-label=\"what it holds\", or let it flow with the page.')},g=o.measure!==!1&&Ge(e);if(!g)for(let t of b)O(t)&&v(t);let I=[\"keyboard\",\"role\",\"name\",\"toggle-state\",\"nested-interactive\",\"img-alt\",\"svg-name\",\"scroll-region\"],w=[],T={},P={};if(g){let t=le(b,{limit:o.limit??400,tabbable:R,scrollsOnPage:v,say:(u,c,A,f,E,C,D)=>s(u,c,A,f,E,D===!0,C)});I.push(\"focus-visible\",\"contrast\"),Object.assign(T,t.unmeasured),Object.assign(P,t.measured)}else{let t=o.measure===!1?\"Asked not to measure.\":\"Nothing here is laid out (a headless run, or a DOM with no layout): it needs a browser's styles and boxes.\";w.push({rule:\"focus-visible\",why:t},{rule:\"contrast\",why:t})}return w.push({rule:\"keyboard-trap\",why:\"It needs keys pressed in a browser: a harness's Tab walk presses them (pnpm verify a11y).\"}),{problems:h,ran:I,skipped:w,unmeasured:T,measured:P}}globalThis.__graviewAudit=pe;})();\n";
|
|
7
7
|
//# sourceMappingURL=page.generated.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graview/guest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Guest views: somebody else's React or plain script in a sandboxed frame, or a hardened classic worker drawing a component kit, shown only what the viewer may see, able only to ask for acts the viewer's seat then applies.",
|
|
6
6
|
"keywords": [
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@remote-dom/core": "1.12.0",
|
|
92
92
|
"@remote-dom/polyfill": "1.6.0",
|
|
93
|
-
"@graview/
|
|
94
|
-
"@graview/
|
|
93
|
+
"@graview/react": "0.2.0",
|
|
94
|
+
"@graview/core": "0.2.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"react": ">=18",
|