@aiquants/console-ui 0.6.3 → 0.6.5

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/dist/testing.js CHANGED
@@ -1 +1 @@
1
- import{d as h,e as T}from"./chunk-FXEGLGL7.js";var g=new Set,y=new WeakMap,O="[autofocus], a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])",L=()=>[...g].filter(e=>e.isConnected&&e.open),D=e=>{let t=e.dispatchEvent(new Event("cancel",{cancelable:!0}));return t&&e.close(),t},k=()=>{typeof HTMLDialogElement>"u"||"showModal"in HTMLDialogElement.prototype||Object.defineProperties(HTMLDialogElement.prototype,{showModal:{configurable:!0,writable:!0,value(){if(!this.isConnected)throw new DOMException("The dialog is not connected","InvalidStateError");if(this.open){if(g.has(this))return;throw new DOMException("The dialog is already open as a non-modal dialog","InvalidStateError")}y.set(this,this.ownerDocument.activeElement),this.setAttribute("open",""),g.add(this),this.querySelector(O)?.focus()}},close:{configurable:!0,writable:!0,value(){if(!this.open)return;this.removeAttribute("open"),g.delete(this);let e=y.get(this)??null;y.delete(this),e instanceof HTMLElement&&e.isConnected&&e.focus(),setTimeout(()=>{this.dispatchEvent(new Event("close"))},0)}}})};var v=/color|background|fill|stroke|shadow|^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?$|^border-image|^(?:outline|text-decoration|column-rule|text-emphasis|opacity)$|filter$|blend-mode$/,I=/^(?:fill|stroke|color|bgcolor|opacity|[a-z]+(?:-[a-z]+)*-opacity|stop-color|flood-color|lighting-color|filter|mask)$/,A="http://www.w3.org/2000/svg",S="path, rect, circle, ellipse, line, polyline, polygon",_="title, desc, metadata",$="[data-cui-marker]",C=e=>{let t=e.style,a=[];for(let s=0;s<t.length;s+=1){let n=t.item(s);v.test(n)&&a.push(n)}return a},R=(e,t,a)=>{let s=[];for(let n=t;n!==null;n=n.parentElement){let i=C(n);i.length>0&&s.push(`\u30A4\u30F3\u30E9\u30A4\u30F3\u306E\u8272: ${e} \u306E ${n.tagName} \u306E ${i.join(", ")}`);let c=n.getAttributeNames().filter(d=>I.test(d));if(c.length>0&&s.push(`\u5857\u308A\u306E\u5C5E\u6027: ${e} \u306E ${n.tagName} \u306E ${c.join(", ")}`),n===a)break}return s},H=e=>{let t=e.closest("[data-testid]");return t===null?e.tagName:`${e.tagName} ${t.getAttribute("data-testid")}`},P=e=>{for(let t=e.parentElement;t!==null;t=t.parentElement)if(t.hasAttribute("data-cui-surface"))return t;return null},U=e=>Object.hasOwn(T,e)&&T[e]==="nonText",j=(e,t)=>{let a=h.light,s=t.closest("[data-cui-fg]"),n=t.closest("[data-cui-surface]");if(s===null||n===null)return{failures:[`\u5F79\u5272\u306E\u7121\u3044\u6587\u5B57: ${e}`],pair:null};let i=s.getAttribute("data-cui-fg"),c=n.getAttribute("data-cui-surface");return Object.hasOwn(a,i)&&Object.hasOwn(a[i],c)?{failures:R(e,t,s.contains(n)?s:n),pair:`${i}/${c}`}:{failures:[`\u8868\u306B\u7121\u3044\u7D44: ${e}: ${i} on ${c}`],pair:null}},q=e=>{let t=[],a=new Set,s=new Set,n=0,i=0,c=h.light,d=(o,l)=>{n+=1;let r=j(o,l);t.push(...r.failures),r.pair!==null&&a.add(r.pair)},b=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let o=b.nextNode();o!==null;o=b.nextNode()){let l=o.data.trim(),r=o.parentElement;l===""||r.closest(_)?.namespaceURI===A||d(l,r)}let w=[e,...e.querySelectorAll($)].filter(o=>o.matches($));for(let o of w)for(let l of o.children)d(`\u5370 ${l.getAttribute("data-testid")??l.tagName}`,l);let x=[e,...e.querySelectorAll(S)].filter(o=>o.namespaceURI===A&&o.matches(S));for(let o of x){i+=1;let l=H(o),r=o.getAttribute("data-cui-stroke"),u=o.getAttribute("data-cui-fill"),p=o.closest("[data-cui-surface]");if(r===null&&u===null||p===null){t.push(`\u5F79\u5272\u306E\u7121\u3044\u56F3\u5F62: ${l}`);continue}let f=p.getAttribute("data-cui-surface");u!==null&&u!==f&&t.push(`\u9762\u3068\u9055\u3046\u5857\u308A: ${l}: ${u} on ${f}`);let m=u===null?null:P(p),N=m===null?p:m;if(r!==null){let M=m===null?[f]:[f,m.getAttribute("data-cui-surface")];for(let E of M)U(r)&&Object.hasOwn(c[r],E)?s.add(`${r}/${E}`):t.push(`\u8868\u306B\u7121\u3044\u7DDA\u306E\u7D44: ${l}: ${r} on ${E}`)}t.push(...R(l,o,N))}return{failures:t,measured:a,texts:n,measuredGraphics:s,graphics:i}};export{k as installDialogModel,L as openModals,D as pressEscape,q as scanColourRoles};
1
+ import{d as h,e as T}from"./chunk-FXEGLGL7.js";var g=new Set,y=new WeakMap,_="[autofocus], a[href], button, input, select, textarea, [tabindex]:not([tabindex='-1'])",k=()=>[...g].filter(e=>e.isConnected&&e.open),I=e=>{let t=e.dispatchEvent(new Event("cancel",{cancelable:!0}));return t&&e.close(),t},v=()=>{typeof HTMLDialogElement>"u"||"showModal"in HTMLDialogElement.prototype||Object.defineProperties(HTMLDialogElement.prototype,{showModal:{configurable:!0,writable:!0,value(){if(!this.isConnected)throw new DOMException("The dialog is not connected","InvalidStateError");if(this.open){if(g.has(this))return;throw new DOMException("The dialog is already open as a non-modal dialog","InvalidStateError")}y.set(this,this.ownerDocument.activeElement),this.setAttribute("open",""),g.add(this),this.querySelector(_)?.focus()}},close:{configurable:!0,writable:!0,value(){if(!this.open)return;this.removeAttribute("open"),g.delete(this);let e=y.get(this)??null;y.delete(this),e instanceof HTMLElement&&e.isConnected&&e.focus(),setTimeout(()=>{this.dispatchEvent(new Event("close"))},0)}}})};var C=/color|background|fill|stroke|shadow|^border(?:-(?:top|right|bottom|left|block|inline)(?:-(?:start|end))?)?$|^border-image|^(?:outline|text-decoration|column-rule|text-emphasis|opacity)$|filter$|blend-mode$/,H=/^(?:fill|stroke|color|bgcolor|opacity|[a-z]+(?:-[a-z]+)*-opacity|stop-color|flood-color|lighting-color|filter|mask)$/,S="http://www.w3.org/2000/svg",$="path, rect, circle, ellipse, line, polyline, polygon",P="title, desc, metadata",w="[data-cui-marker]",U=/^\[data-[a-z0-9_-]+(?:[~|^$*]?="[^"\\]*")?\]$/,j=e=>{let t=e.style,l=[];for(let s=0;s<t.length;s+=1){let n=t.item(s);C.test(n)&&l.push(n)}return l},x=(e,t,l)=>{let s=[];for(let n=t;n!==null;n=n.parentElement){let i=j(n);i.length>0&&s.push(`\u30A4\u30F3\u30E9\u30A4\u30F3\u306E\u8272: ${e} \u306E ${n.tagName} \u306E ${i.join(", ")}`);let c=n.getAttributeNames().filter(d=>H.test(d));if(c.length>0&&s.push(`\u5857\u308A\u306E\u5C5E\u6027: ${e} \u306E ${n.tagName} \u306E ${c.join(", ")}`),n===l)break}return s},q=e=>{let t=e.closest("[data-testid]");return t===null?e.tagName:`${e.tagName} ${t.getAttribute("data-testid")}`},z=e=>{for(let t=e.parentElement;t!==null;t=t.parentElement)if(t.hasAttribute("data-cui-surface"))return t;return null},B=e=>Object.hasOwn(T,e)&&T[e]==="nonText",F=(e,t)=>{let l=h.light,s=t.closest("[data-cui-fg]"),n=t.closest("[data-cui-surface]");if(s===null||n===null)return{failures:[`\u5F79\u5272\u306E\u7121\u3044\u6587\u5B57: ${e}`],pair:null};let i=s.getAttribute("data-cui-fg"),c=n.getAttribute("data-cui-surface");return Object.hasOwn(l,i)&&Object.hasOwn(l[i],c)?{failures:x(e,t,s.contains(n)?s:n),pair:`${i}/${c}`}:{failures:[`\u8868\u306B\u7121\u3044\u7D44: ${e}: ${i} on ${c}`],pair:null}},G=(e,t)=>t.flatMap(l=>{if(!U.test(l))throw new RangeError(`A role scan excludes only by one data-* attribute selector: ${l}`);if(e.matches(l))throw new RangeError(`A role scan exclusion must not match the root it scans: ${l}`);let s=[...e.querySelectorAll(l)];if(s.length===0)throw new RangeError(`A role scan exclusion matches no element under the root: ${l}`);return s}),K=(e,t)=>{let l=G(e,t===void 0?[]:t.exclude),s=o=>l.some(r=>r.contains(o)),n=[],i=new Set,c=new Set,d=0,b=0,O=h.light,A=(o,r)=>{d+=1;let a=F(o,r);n.push(...a.failures),a.pair!==null&&i.add(a.pair)},R=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let o=R.nextNode();o!==null;o=R.nextNode()){let r=o.data.trim(),a=o.parentElement;r===""||a.closest(P)?.namespaceURI===S||s(a)||A(r,a)}let M=[e,...e.querySelectorAll(w)].filter(o=>o.matches(w)&&!s(o));for(let o of M)for(let r of o.children)s(r)||A(`\u5370 ${r.getAttribute("data-testid")??r.tagName}`,r);let N=[e,...e.querySelectorAll($)].filter(o=>o.namespaceURI===S&&o.matches($)&&!s(o));for(let o of N){b+=1;let r=q(o),a=o.getAttribute("data-cui-stroke"),u=o.getAttribute("data-cui-fill"),p=o.closest("[data-cui-surface]");if(a===null&&u===null||p===null){n.push(`\u5F79\u5272\u306E\u7121\u3044\u56F3\u5F62: ${r}`);continue}let f=p.getAttribute("data-cui-surface");u!==null&&u!==f&&n.push(`\u9762\u3068\u9055\u3046\u5857\u308A: ${r}: ${u} on ${f}`);let m=u===null?null:z(p),L=m===null?p:m;if(a!==null){let D=m===null?[f]:[f,m.getAttribute("data-cui-surface")];for(let E of D)B(a)&&Object.hasOwn(O[a],E)?c.add(`${a}/${E}`):n.push(`\u8868\u306B\u7121\u3044\u7DDA\u306E\u7D44: ${r}: ${a} on ${E}`)}n.push(...x(r,o,L))}return{failures:n,measured:i,texts:d,measuredGraphics:c,graphics:b}};export{v as installDialogModel,k as openModals,I as pressEscape,K as scanColourRoles};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/console-ui",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "Host-agnostic UI foundation for React admin consoles, with a React entry, a React-free core entry, a DOM testing entry and a stylesheet.",
5
5
  "sideEffects": [
6
6
  "**/*.css"