@tltdsh/mx 1.6.3 → 1.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/README.md +3 -3
- package/mx.d.ts +7 -0
- package/mx.min.js +1 -1
- package/mx.mjs +1 -1
- package/package.json +1 -1
- package/skill/ui-mx.js +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tltdsh/mx)
|
|
4
4
|
[](https://bundlejs.com/?q=@tltdsh/mx)
|
|
5
|
-
[](https://mxjs.dev)
|
|
6
6
|
[](https://opensource.org/license/0bsd)
|
|
7
7
|
|
|
8
8
|
A DOM reconciliation engine for building user interfaces in plain JavaScript, from a single widget to a large platform. It is **under 1KB** with brotli, has four API names and no dependencies, and needs no virtual DOM or build step, so the whole library fits in an AI context window.
|
|
@@ -26,7 +26,7 @@ A DOM reconciliation engine for building user interfaces in plain JavaScript, fr
|
|
|
26
26
|
### Pinned version
|
|
27
27
|
|
|
28
28
|
```html
|
|
29
|
-
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.6.
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.6.5/mx.min.js"></script>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### npm / yarn / bun
|
|
@@ -236,7 +236,7 @@ The same skill is a zip at [mxjs.dev/mx-skill.zip](https://mxjs.dev/mx-skill.zip
|
|
|
236
236
|
|
|
237
237
|
## TypeScript
|
|
238
238
|
|
|
239
|
-
Type definitions are included, with autocomplete for common HTML and SVG elements and attributes, and any other tag through an index signature. Children can be nested arrays, and
|
|
239
|
+
Type definitions are included, with autocomplete for common HTML and SVG elements and attributes, and any other tag through an index signature. Children can be nested arrays, and typed attributes also take `null` or `false` to remove them. The four ARIA states `aria-expanded`, `aria-selected`, `aria-checked` and `aria-pressed` take only `null` for removal. Use `String(flag)` to write their `"false"` state.
|
|
240
240
|
|
|
241
241
|
```ts
|
|
242
242
|
import { mx, dom, define, type MxChild, type MxAttrs } from '@tltdsh/mx'
|
package/mx.d.ts
CHANGED
|
@@ -132,6 +132,7 @@ interface MxHTMLAttrs {
|
|
|
132
132
|
// ARIA relations cluster (accessibility)
|
|
133
133
|
'aria-controls'?: string;
|
|
134
134
|
'aria-owns'?: string;
|
|
135
|
+
'aria-flowto'?: string;
|
|
135
136
|
'aria-haspopup'?: boolean | 'true' | 'false' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
136
137
|
|
|
137
138
|
// ARIA live region cluster (accessibility)
|
|
@@ -155,6 +156,10 @@ interface MxHTMLAttrs {
|
|
|
155
156
|
'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling';
|
|
156
157
|
'aria-readonly'?: boolean | 'true' | 'false';
|
|
157
158
|
|
|
159
|
+
// ARIA text input (accessibility)
|
|
160
|
+
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
|
|
161
|
+
'aria-multiline'?: boolean | 'true' | 'false';
|
|
162
|
+
|
|
158
163
|
// ARIA misc cluster (accessibility)
|
|
159
164
|
'aria-modal'?: boolean | 'true' | 'false';
|
|
160
165
|
'aria-roledescription'?: string;
|
|
@@ -180,6 +185,8 @@ interface MxHTMLAttrs {
|
|
|
180
185
|
'aria-rowindex'?: number;
|
|
181
186
|
'aria-colcount'?: number;
|
|
182
187
|
'aria-colindex'?: number;
|
|
188
|
+
'aria-colspan'?: number;
|
|
189
|
+
'aria-rowspan'?: number;
|
|
183
190
|
|
|
184
191
|
// Loading
|
|
185
192
|
fetchpriority?: 'high' | 'low' | 'auto';
|
package/mx.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(
|
|
1
|
+
!function(a,i){let f=Object.assign,d={__proto__:null,value:1,checked:1,selected:1},R=components={__proto__:null},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[null,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=a=>s[a]||=a.replace(/[A-Z]/g,'-$&').toLowerCase(),s={__proto__:null},$=(a,n={__proto__:null})=>new Proxy(a,{get:(_,i)=>n[i]||=a.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(a.createElement(i),R[i]):a.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,a={})=>{R[w(i)]=a;if(a.$)a.$$||=a.$,a.$=function(i){let _=a.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((a,i,..._)=>(a=n(w(a)),i?.__proto__==Object.prototype&&!i?.nodeType?a.$?a.$(i):a.render(..._).$attrs(i):a.render(i,..._),a)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,a=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;a&&a!=_&&a[g]!=f;a=$)$=a.nextSibling,i.removeChild(a);a!=_&&(a?.nextSibling==_?i.removeChild(a):i.insertBefore(_,a)),a=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(a?.[g]?(e||M(e=f),a[g]!=f):a)?!$?a.splitText?a.data!=''+_&&(a.data=''+_):a.replaceWith(a=new Text(_)):$!=a.localName&&a.replaceWith(a=n($,R)):a=i.insertBefore($?n($,R):new Text(_),a);if($)if(a.$)a[A]=0,a.$(w);else{let R=a[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(a[i]=null,a.removeAttribute(i))):(d[i]?a[i]='':R[i]?.call&&(a[i]=null),a.removeAttribute(i),delete R[i]));a.render(...m);for(let i in w)_=w[i],i[0]=='.'?(R[i]=_,a[i=i.slice(1)]===_||(a[i]=_)):i in R&&R[i]===_?d[i]&&(a[i]===_||(a[i]=_)):_!=null&!1!==_?(_.call?a[i]=_:(d[i]&&(a[i]===_||(a[i]=_)),a.setAttribute(i,_)),R[i]=_):(d[i]?a[i]==''||(a[i]=''):R[i]?.call&&(a[i]=null),a.removeAttribute(i),delete R[i])}a=a.nextSibling}for(let $;a;a=$)$=a.nextSibling,i.removeChild(a);return this},i.$attrs=function(a,i,_){for(i in a)_=a[i],i[0]=='.'?this[i.slice(1)]=_:_!=null&!1!==_?(_.call?this[i]=_:this.setAttribute(i,_)):this.removeAttribute(i);return this},mx=$((a,i,..._)=>(a=w(a),_=i?.__proto__==Object.prototype&&!i?.nodeType?[a,i,_]:[a,null,[i,..._]],_._=1,_))}(document,Element.prototype)
|
package/mx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
let mx, dom, define, components;
|
|
2
|
-
!function(
|
|
2
|
+
!function(a,i){let f=Object.assign,d={__proto__:null,value:1,checked:1,selected:1},R=components={__proto__:null},F=_=>_.flatMap(_=>_?._||!_?.pop?[_]:[null,...F(_)]),M=f=>{for(let _ of f)_?.nodeType?_[g]=f:_?._||_?.pop&&f.splice(0,1/0,...F(f))},A=Symbol(),g=Symbol(),w=a=>s[a]||=a.replace(/[A-Z]/g,'-$&').toLowerCase(),s={__proto__:null},$=(a,n={__proto__:null})=>new Proxy(a,{get:(_,i)=>n[i]||=a.bind(0,i)}),n=(i,d)=>'svg'!=i&!d?f(a.createElement(i),R[i]):a.createElementNS(_,i),_='http://www.w3.org/2000/svg';define=(i,a={})=>{R[w(i)]=a;if(a.$)a.$$||=a.$,a.$=function(i){let _=a.$$.call(this,f(this.$state||={},i));return this.render(..._?._?[_]:_||[])}},dom=$((a,i,..._)=>(a=n(w(a)),i?.__proto__==Object.prototype&&!i?.nodeType?a.$?a.$(i):a.render(..._).$attrs(i):a.render(i,..._),a)),i.render=function(...f){let i=this,R=i.namespaceURI==_&'foreignObject'!=i.localName,a=i.firstChild,e;for(let _ of f){let $,w,m;if(_==null|!1===_)continue;if(_._)[$,w,m]=_;else if(_.nodeType){e||M(e=f);for(;a&&a!=_&&a[g]!=f;a=$)$=a.nextSibling,i.removeChild(a);a!=_&&(a?.nextSibling==_?i.removeChild(a):i.insertBefore(_,a)),a=_.nextSibling;continue}else if(_.pop){f.splice(0,1/0,...F(f));continue}(a?.[g]?(e||M(e=f),a[g]!=f):a)?!$?a.splitText?a.data!=''+_&&(a.data=''+_):a.replaceWith(a=new Text(_)):$!=a.localName&&a.replaceWith(a=n($,R)):a=i.insertBefore($?n($,R):new Text(_),a);if($)if(a.$)a[A]=0,a.$(w);else{let R=a[A]||={__proto__:null};for(let i in R)w&&Object.hasOwn(w,i)||(i[0]=='.'?(delete R[i],d[i=i.slice(1)]||w&&Object.hasOwn(w,i)&&w[i]||(a[i]=null,a.removeAttribute(i))):(d[i]?a[i]='':R[i]?.call&&(a[i]=null),a.removeAttribute(i),delete R[i]));a.render(...m);for(let i in w)_=w[i],i[0]=='.'?(R[i]=_,a[i=i.slice(1)]===_||(a[i]=_)):i in R&&R[i]===_?d[i]&&(a[i]===_||(a[i]=_)):_!=null&!1!==_?(_.call?a[i]=_:(d[i]&&(a[i]===_||(a[i]=_)),a.setAttribute(i,_)),R[i]=_):(d[i]?a[i]==''||(a[i]=''):R[i]?.call&&(a[i]=null),a.removeAttribute(i),delete R[i])}a=a.nextSibling}for(let $;a;a=$)$=a.nextSibling,i.removeChild(a);return this},i.$attrs=function(a,i,_){for(i in a)_=a[i],i[0]=='.'?this[i.slice(1)]=_:_!=null&!1!==_?(_.call?this[i]=_:this.setAttribute(i,_)):this.removeAttribute(i);return this},mx=$((a,i,..._)=>(a=w(a),_=i?.__proto__==Object.prototype&&!i?.nodeType?[a,i,_]:[a,null,[i,..._]],_._=1,_))}(document,Element.prototype)
|
|
3
3
|
export { mx, dom, define, components };
|
package/package.json
CHANGED
package/skill/ui-mx.js
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
store = Symbol(),
|
|
19
19
|
claimed = Symbol(),
|
|
20
20
|
// plain child arrays flatten, nested ones too; a description (an array marked ._) stays
|
|
21
|
-
// whole. Each flattened array leaves a
|
|
21
|
+
// whole. Each flattened array leaves a null (skipped) where it stood, so an iterator
|
|
22
22
|
// already past that index resumes on the array's first item.
|
|
23
|
-
flatten = list => list.flatMap(item => item?._ || !item?.pop ? [item] : [
|
|
23
|
+
flatten = list => list.flatMap(item => item?._ || !item?.pop ? [item] : [null, ...flatten(item)]),
|
|
24
24
|
// mark every real node in the argument list with the list itself: a fresh array per
|
|
25
25
|
// call, so the mark needs no cleanup and no counter. An unspread array anywhere in the
|
|
26
26
|
// list is flattened in place first, so real nodes inside it are claimed before any
|