@tltdsh/mx 1.3.2 → 1.4.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.
- package/README.md +2 -2
- package/mx.d.ts +41 -41
- package/mx.min.js +1 -1
- package/mx.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Sub-1KB reactive DOM reconciliation engine for building massive platforms and us
|
|
|
21
21
|
### Pinned version
|
|
22
22
|
|
|
23
23
|
```html
|
|
24
|
-
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.
|
|
24
|
+
<script src="https://cdn.jsdelivr.net/npm/@tltdsh/mx@1.4.0/mx.min.js"></script>
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
### npm / yarn / bun
|
|
@@ -42,7 +42,7 @@ import { mx, dom, define, components } from '@tltdsh/mx'
|
|
|
42
42
|
const { mx, dom, define, components } = await import('https://cdn.jsdelivr.net/npm/@tltdsh/mx/mx.mjs')
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Works in any modern browser,
|
|
45
|
+
Works in any modern browser, with or without a bundler - no install, one line. Browser runtimes only: the module reads `document` at evaluation time, so importing it under Node, Deno, or Bun throws `ReferenceError: document is not defined`.
|
|
46
46
|
|
|
47
47
|
## 4 Globals
|
|
48
48
|
|
package/mx.d.ts
CHANGED
|
@@ -114,12 +114,16 @@ interface MxHTMLAttrs {
|
|
|
114
114
|
'aria-errormessage'?: string;
|
|
115
115
|
|
|
116
116
|
// ARIA states cluster (accessibility)
|
|
117
|
+
// NOTE: `false` REMOVES an attribute (`removeAttribute`), it does not write "false".
|
|
118
|
+
// For the four states below, absent is NOT the same as "false" to a screen reader
|
|
119
|
+
// (absent aria-expanded means "not expandable", absent aria-pressed means "not a
|
|
120
|
+
// toggle button"), so they only accept the explicit strings. Pass String(flag).
|
|
117
121
|
'aria-hidden'?: boolean | 'true' | 'false';
|
|
118
|
-
'aria-expanded'?:
|
|
122
|
+
'aria-expanded'?: 'true' | 'false';
|
|
119
123
|
'aria-disabled'?: boolean | 'true' | 'false';
|
|
120
|
-
'aria-selected'?:
|
|
121
|
-
'aria-checked'?:
|
|
122
|
-
'aria-pressed'?:
|
|
124
|
+
'aria-selected'?: 'true' | 'false';
|
|
125
|
+
'aria-checked'?: 'true' | 'false' | 'mixed';
|
|
126
|
+
'aria-pressed'?: 'true' | 'false' | 'mixed';
|
|
123
127
|
|
|
124
128
|
// ARIA relations cluster (accessibility)
|
|
125
129
|
'aria-controls'?: string;
|
|
@@ -132,6 +136,14 @@ interface MxHTMLAttrs {
|
|
|
132
136
|
'aria-busy'?: boolean | 'true' | 'false';
|
|
133
137
|
'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';
|
|
134
138
|
|
|
139
|
+
// ARIA values cluster (accessibility)
|
|
140
|
+
'aria-valuemin'?: number;
|
|
141
|
+
'aria-valuemax'?: number;
|
|
142
|
+
'aria-valuenow'?: number;
|
|
143
|
+
'aria-valuetext'?: string;
|
|
144
|
+
'aria-orientation'?: 'horizontal' | 'vertical';
|
|
145
|
+
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
|
146
|
+
|
|
135
147
|
// Loading
|
|
136
148
|
fetchpriority?: 'high' | 'low' | 'auto';
|
|
137
149
|
|
|
@@ -327,9 +339,6 @@ interface MxElement extends HTMLElement {
|
|
|
327
339
|
* reconciles DOM. Returns this element.
|
|
328
340
|
*/
|
|
329
341
|
$(props?: Record<string, any>): this;
|
|
330
|
-
|
|
331
|
-
/** Internal tracking object (stamp system) */
|
|
332
|
-
_$: any;
|
|
333
342
|
}
|
|
334
343
|
|
|
335
344
|
// ---------------------------------------------------------------------------
|
|
@@ -441,6 +450,21 @@ interface MxHTMLTags {
|
|
|
441
450
|
embed: MxTagFn;
|
|
442
451
|
|
|
443
452
|
// SVG
|
|
453
|
+
//
|
|
454
|
+
// Only all-lowercase SVG tags are listed. Tag names are kebab-cased
|
|
455
|
+
// unconditionally, so a camelCase SVG tag cannot be produced by the proxy:
|
|
456
|
+
// `mx.clipPath()` emits `<clip-path>`, `mx.linearGradient()` emits
|
|
457
|
+
// `<linear-gradient>` - invalid elements that parse fine and paint nothing.
|
|
458
|
+
// Affected: clipPath, foreignObject, linearGradient, radialGradient, textPath,
|
|
459
|
+
// animateTransform and every fe* filter primitive (feGaussianBlur, feOffset,
|
|
460
|
+
// feMerge, feMergeNode, feBlend, feColorMatrix, ...).
|
|
461
|
+
//
|
|
462
|
+
// Workaround - build the node yourself and pass it in as a child; render()
|
|
463
|
+
// matches real DOM nodes by identity:
|
|
464
|
+
// let clip = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath')
|
|
465
|
+
// clip.id = 'c'
|
|
466
|
+
// clip.append(document.createElementNS('http://www.w3.org/2000/svg', 'rect'))
|
|
467
|
+
// mx.svg(mx.defs(clip), mx.rect({ 'clip-path': 'url(#c)' }))
|
|
444
468
|
svg: MxTagFn;
|
|
445
469
|
path: MxTagFn;
|
|
446
470
|
circle: MxTagFn;
|
|
@@ -455,23 +479,12 @@ interface MxHTMLTags {
|
|
|
455
479
|
defs: MxTagFn;
|
|
456
480
|
use: MxTagFn;
|
|
457
481
|
symbol: MxTagFn;
|
|
458
|
-
clipPath: MxTagFn;
|
|
459
482
|
mask: MxTagFn;
|
|
460
483
|
pattern: MxTagFn;
|
|
461
484
|
image: MxTagFn;
|
|
462
|
-
foreignObject: MxTagFn;
|
|
463
|
-
linearGradient: MxTagFn;
|
|
464
|
-
radialGradient: MxTagFn;
|
|
465
485
|
stop: MxTagFn;
|
|
466
486
|
filter: MxTagFn;
|
|
467
|
-
feGaussianBlur: MxTagFn;
|
|
468
|
-
feOffset: MxTagFn;
|
|
469
|
-
feMerge: MxTagFn;
|
|
470
|
-
feMergeNode: MxTagFn;
|
|
471
|
-
feBlend: MxTagFn;
|
|
472
|
-
feColorMatrix: MxTagFn;
|
|
473
487
|
animate: MxTagFn;
|
|
474
|
-
animateTransform: MxTagFn;
|
|
475
488
|
|
|
476
489
|
// Interactive
|
|
477
490
|
details: MxTagFn;
|
|
@@ -592,27 +605,17 @@ interface DomHTMLTags {
|
|
|
592
605
|
iframe: DomTagFn<HTMLIFrameElement>;
|
|
593
606
|
|
|
594
607
|
// SVG
|
|
608
|
+
//
|
|
609
|
+
// `svg` is the only SVG tag dom() can build: createElement special-cases the
|
|
610
|
+
// tag name 'svg' and switches to the SVG namespace. Every other SVG tag goes
|
|
611
|
+
// through createElement and lands in the HTML namespace, so `dom.path()` is an
|
|
612
|
+
// HTMLUnknownElement - it serializes as `<path d="...">` and looks correct in
|
|
613
|
+
// DevTools, but has no geometry API and never renders. Those tags are therefore
|
|
614
|
+
// not declared here; they fall through to the index signature as plain Element.
|
|
615
|
+
//
|
|
616
|
+
// Build SVG subtrees with mx.*() inside an mx-rendered `svg` (render() namespaces
|
|
617
|
+
// children of an svg correctly), or with document.createElementNS by hand.
|
|
595
618
|
svg: DomTagFn<SVGSVGElement>;
|
|
596
|
-
path: DomTagFn<SVGPathElement>;
|
|
597
|
-
circle: DomTagFn<SVGCircleElement>;
|
|
598
|
-
ellipse: DomTagFn<SVGEllipseElement>;
|
|
599
|
-
line: DomTagFn<SVGLineElement>;
|
|
600
|
-
polyline: DomTagFn<SVGPolylineElement>;
|
|
601
|
-
polygon: DomTagFn<SVGPolygonElement>;
|
|
602
|
-
rect: DomTagFn<SVGRectElement>;
|
|
603
|
-
text: DomTagFn<SVGTextElement>;
|
|
604
|
-
g: DomTagFn<SVGGElement>;
|
|
605
|
-
defs: DomTagFn<SVGDefsElement>;
|
|
606
|
-
use: DomTagFn<SVGUseElement>;
|
|
607
|
-
symbol: DomTagFn<SVGSymbolElement>;
|
|
608
|
-
clipPath: DomTagFn<SVGClipPathElement>;
|
|
609
|
-
image: DomTagFn<SVGImageElement>;
|
|
610
|
-
foreignObject: DomTagFn<SVGForeignObjectElement>;
|
|
611
|
-
linearGradient: DomTagFn<SVGLinearGradientElement>;
|
|
612
|
-
radialGradient: DomTagFn<SVGRadialGradientElement>;
|
|
613
|
-
stop: DomTagFn<SVGStopElement>;
|
|
614
|
-
filter: DomTagFn<SVGFilterElement>;
|
|
615
|
-
animate: DomTagFn<SVGAnimateElement>;
|
|
616
619
|
|
|
617
620
|
// Interactive
|
|
618
621
|
details: DomTagFn<HTMLDetailsElement>;
|
|
@@ -698,9 +701,6 @@ declare global {
|
|
|
698
701
|
* Only available on elements created from defined components.
|
|
699
702
|
*/
|
|
700
703
|
$(props?: Record<string, any>): this;
|
|
701
|
-
|
|
702
|
-
/** Internal stamp tracking (do not use directly) */
|
|
703
|
-
_$: any;
|
|
704
704
|
}
|
|
705
705
|
|
|
706
706
|
/** mx - virtual description proxy */
|
package/mx.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={
|
|
1
|
+
!function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={__proto__:null,value:1,checked:1,selected:1},x=Symbol(),n=(i,t)=>!t&'svg'!=i?l(m.createElement(i),_[i]):m.createElementNS($,i),R=m=>h[m]||=m.replace(/[A-Z]/g,'-$&').toLowerCase(),h={},l=Object.assign,w=(m,n={})=>new Proxy(m,{get:(i,_)=>n[_]||=m.bind(0,_)});define=(i,m={})=>{if(m.$)m.$$||=m.$,m.$=function(i){let _=m.$$.call(this,l(this.$state||={},i));return this.render(..._?._?[_]:_||[])};_[R(i)]=m};i.render=function(...l){let i=this,_=i.namespaceURI==$&'foreignObject'!=i.localName,m=i.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){$!=m&&(m?m.replaceWith($):i.append($)),m=$.nextSibling;continue}if(m)!w?m.splitText?m.data!=$+''&&(m.data=$+''):m.replaceWith(m=new Text($)):w!=m.localName&&m.replaceWith(m=n(w,_));else if(w)i.append(m=n(w,_));else{i.append($);continue}if(w)if(m.$)m[x]=0,m.$(R);else{m.render(...g);let[_,n]=m[x]||=[{},{}],l=u=-~u;for(let i in _){R&&Object.hasOwn(R,i)||(('.'==i[0]?t[i.slice(1)]&&delete n[i.slice(1)]:(t[i]&&(delete n[i],m[i]=''),m.R(i))),delete _[i])}for(let i in R){let $=R[i],k=i.slice(1);_[i]===$?'.'==i[0]?(m[k]===$||(m[k]=$),n[k]=l):t[i]?(m[i]===$||(m[i]=$),n[i]=l):$?.call&&(n[i]=l):'.'==i[0]?(m[k]===$||(m[k]=$),n[k]=l,_[i]=$):$!=null&!1!==$?($.call?(m[i]=$,n[i]=l):(t[i]?(m[i]===$||(m[i]=$),n[i]=l):delete n[i],m.setAttribute(i,$)),_[i]=$):(t[i]&&(delete n[i],m[i]=''),m.R(i),delete _[i])}for(let i in n)l-n[i]&&(delete n[i],m[i]=null,m.R(i))}m=m.nextSibling}for(let $;m;m=$)$=m.nextSibling,i.removeChild(m);return this},i.R=i.removeAttribute,_=components={},i.$attrs=function(m,i,$){for(i in m)$=m[i],'.'==i[0]?this[i.slice(1)]=$:$!=null&!1!==$?($.call?this[i]=$:this.setAttribute(i,$)):this.R(i);return this},mx=w((m,i,..._)=>(m=R(m),_=i?.__proto__==Object.prototype&&!i?.nodeType?[m,i,_]:[m,null,[i,..._]],_._=1,_)),dom=w((m,i,..._)=>(m=n(R(m)),i?.__proto__==Object.prototype&&!i?.nodeType?m.$?m.$(i):m.render(..._).$attrs(i):m.render(i,..._),m))}(document,Element.prototype)
|
package/mx.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
let mx, dom, define, components;
|
|
2
|
-
!function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={
|
|
2
|
+
!function(m,i,_,u){let $='http://www.w3.org/2000/svg',t={__proto__:null,value:1,checked:1,selected:1},x=Symbol(),n=(i,t)=>!t&'svg'!=i?l(m.createElement(i),_[i]):m.createElementNS($,i),R=m=>h[m]||=m.replace(/[A-Z]/g,'-$&').toLowerCase(),h={},l=Object.assign,w=(m,n={})=>new Proxy(m,{get:(i,_)=>n[_]||=m.bind(0,_)});define=(i,m={})=>{if(m.$)m.$$||=m.$,m.$=function(i){let _=m.$$.call(this,l(this.$state||={},i));return this.render(..._?._?[_]:_||[])};_[R(i)]=m};i.render=function(...l){let i=this,_=i.namespaceURI==$&'foreignObject'!=i.localName,m=i.firstChild;for(let $ of l){let w,R,g;if($==null|!1===$)continue;if($._)[w,R,g]=$;else if($.nodeType){$!=m&&(m?m.replaceWith($):i.append($)),m=$.nextSibling;continue}if(m)!w?m.splitText?m.data!=$+''&&(m.data=$+''):m.replaceWith(m=new Text($)):w!=m.localName&&m.replaceWith(m=n(w,_));else if(w)i.append(m=n(w,_));else{i.append($);continue}if(w)if(m.$)m[x]=0,m.$(R);else{m.render(...g);let[_,n]=m[x]||=[{},{}],l=u=-~u;for(let i in _){R&&Object.hasOwn(R,i)||(('.'==i[0]?t[i.slice(1)]&&delete n[i.slice(1)]:(t[i]&&(delete n[i],m[i]=''),m.R(i))),delete _[i])}for(let i in R){let $=R[i],k=i.slice(1);_[i]===$?'.'==i[0]?(m[k]===$||(m[k]=$),n[k]=l):t[i]?(m[i]===$||(m[i]=$),n[i]=l):$?.call&&(n[i]=l):'.'==i[0]?(m[k]===$||(m[k]=$),n[k]=l,_[i]=$):$!=null&!1!==$?($.call?(m[i]=$,n[i]=l):(t[i]?(m[i]===$||(m[i]=$),n[i]=l):delete n[i],m.setAttribute(i,$)),_[i]=$):(t[i]&&(delete n[i],m[i]=''),m.R(i),delete _[i])}for(let i in n)l-n[i]&&(delete n[i],m[i]=null,m.R(i))}m=m.nextSibling}for(let $;m;m=$)$=m.nextSibling,i.removeChild(m);return this},i.R=i.removeAttribute,_=components={},i.$attrs=function(m,i,$){for(i in m)$=m[i],'.'==i[0]?this[i.slice(1)]=$:$!=null&!1!==$?($.call?this[i]=$:this.setAttribute(i,$)):this.R(i);return this},mx=w((m,i,..._)=>(m=R(m),_=i?.__proto__==Object.prototype&&!i?.nodeType?[m,i,_]:[m,null,[i,..._]],_._=1,_)),dom=w((m,i,..._)=>(m=n(R(m)),i?.__proto__==Object.prototype&&!i?.nodeType?m.$?m.$(i):m.render(..._).$attrs(i):m.render(i,..._),m))}(document,Element.prototype)
|
|
3
3
|
export { mx, dom, define, components };
|