@tltdsh/mx 1.0.4 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +5 -5
  2. package/mx.d.ts +20 -20
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -38,7 +38,7 @@ import { mx, dom, define, components } from '@tltdsh/mx'
38
38
 
39
39
  | Global | Returns | Use for |
40
40
  |--------|---------|---------|
41
- | `mx.tag(attrs?, ...children)` | Description array | Inside `render()` — efficient reconciliation |
41
+ | `mx.tag(attrs?, ...children)` | Description array | Inside `render()` - efficient reconciliation |
42
42
  | `dom.tag(attrs?, ...children)` | HTMLElement | Persistent references, calling `.$()` later |
43
43
  | `define(name, { $() {} })` | void | Register a component |
44
44
  | `components` | object | Component registry |
@@ -180,7 +180,7 @@ let rowMap = new Map(
180
180
  data.map(d => [d.id, dom.tableRow({ data: d })])
181
181
  )
182
182
 
183
- // Nodes move by identity — internal state preserved on reorder
183
+ // Nodes move by identity - internal state preserved on reorder
184
184
  container.render(...data.map(d => rowMap.get(d.id)))
185
185
  ```
186
186
 
@@ -190,8 +190,8 @@ container.render(...data.map(d => rowMap.get(d.id)))
190
190
  - `dom.*` = real HTMLElements for persistent references
191
191
  - `$()` always returns array of children
192
192
  - `??=` protects `$state` from parent prop overwrites
193
- - Never `addEventListener` inside `$()` — use direct property assignment
194
- - Numbers auto-cast — no `String()` needed
193
+ - Never `addEventListener` inside `$()` - use direct property assignment
194
+ - Numbers auto-cast - no `String()` needed
195
195
  - Use `_ =>` for unused arrow params
196
196
  - `clearInterval(this._interval)` at top of `$()` for timers
197
197
  - `this._cache ||= new Map` for persistent Maps
@@ -206,4 +206,4 @@ import { mx, dom, define, type MxChild, type MxAttrs } from '@tltdsh/mx'
206
206
 
207
207
  ## License
208
208
 
209
- 0BSD — do whatever you want.
209
+ 0BSD - do whatever you want.
package/mx.d.ts CHANGED
@@ -2,12 +2,12 @@
2
2
  // https://mxjs.dev
3
3
 
4
4
  // ---------------------------------------------------------------------------
5
- // Children — everything render() and mx/dom accept as child nodes
5
+ // Children - everything render() and mx/dom accept as child nodes
6
6
  // ---------------------------------------------------------------------------
7
7
 
8
8
  /** A description array returned by mx.*() calls */
9
9
  interface MxDescription extends Array<any> {
10
- /** Internal marker — distinguishes descriptions from plain arrays */
10
+ /** Internal marker - distinguishes descriptions from plain arrays */
11
11
  _: 1 | true;
12
12
  }
13
13
 
@@ -233,11 +233,11 @@ interface MxSVGAttrs {
233
233
  /**
234
234
  * Full attribute type. Supports:
235
235
  * - Standard HTML/SVG attributes (autocomplete)
236
- * - `'.prop': value` — sets element property directly
237
- * - `onclick: fn` — event handler as property (auto-cleaned)
238
- * - `name: null | false` — removes attribute
239
- * - `name: true` — sets empty attribute
240
- * - `[key: string]: any` — custom attributes, data-*, aria-*
236
+ * - `'.prop': value` - sets element property directly
237
+ * - `onclick: fn` - event handler as property (auto-cleaned)
238
+ * - `name: null | false` - removes attribute
239
+ * - `name: true` - sets empty attribute
240
+ * - `[key: string]: any` - custom attributes, data-*, aria-*
241
241
  */
242
242
  type MxAttrs = MxHTMLAttrs & MxSVGAttrs & {
243
243
  [key: string]: any;
@@ -261,7 +261,7 @@ interface MxComponentDefinition {
261
261
  }
262
262
 
263
263
  // ---------------------------------------------------------------------------
264
- // Component element — an HTMLElement created by define()
264
+ // Component element - an HTMLElement created by define()
265
265
  // ---------------------------------------------------------------------------
266
266
 
267
267
  interface MxElement extends HTMLElement {
@@ -279,7 +279,7 @@ interface MxElement extends HTMLElement {
279
279
  }
280
280
 
281
281
  // ---------------------------------------------------------------------------
282
- // mx proxy — creates virtual descriptions for reconciliation
282
+ // mx proxy - creates virtual descriptions for reconciliation
283
283
  // ---------------------------------------------------------------------------
284
284
 
285
285
  /**
@@ -443,7 +443,7 @@ interface MxHTMLTags {
443
443
  }
444
444
 
445
445
  /**
446
- * `mx` — creates virtual descriptions for render reconciliation.
446
+ * `mx` - creates virtual descriptions for render reconciliation.
447
447
  *
448
448
  * CamelCase auto-converts to kebab-case:
449
449
  * `mx.priceChart()` → `<price-chart>`
@@ -454,12 +454,12 @@ interface MxHTMLTags {
454
454
  * mx.myComponent({ count: 5 })
455
455
  */
456
456
  interface MxProxy extends MxHTMLTags {
457
- /** Any tag name — CamelCase converts to kebab-case */
457
+ /** Any tag name - CamelCase converts to kebab-case */
458
458
  [tag: string]: MxTagFn;
459
459
  }
460
460
 
461
461
  // ---------------------------------------------------------------------------
462
- // dom proxy — creates real HTMLElements
462
+ // dom proxy - creates real HTMLElements
463
463
  // ---------------------------------------------------------------------------
464
464
 
465
465
  type DomTagFn<T extends Element = Element> = (attrs?: MxAttrs | MxChild, ...children: MxChild[]) => T;
@@ -575,7 +575,7 @@ interface DomHTMLTags {
575
575
  }
576
576
 
577
577
  /**
578
- * `dom` — creates real HTMLElements with attributes and children applied.
578
+ * `dom` - creates real HTMLElements with attributes and children applied.
579
579
  *
580
580
  * CamelCase auto-converts to kebab-case:
581
581
  * `dom.priceChart()` → `<price-chart>` HTMLElement
@@ -590,17 +590,17 @@ interface DomHTMLTags {
590
590
  * chart.$({ asset: newAsset }) // update later
591
591
  */
592
592
  interface DomProxy extends DomHTMLTags {
593
- /** Any tag name — CamelCase converts to kebab-case. Returns Element (or MxElement for components). */
593
+ /** Any tag name - CamelCase converts to kebab-case. Returns Element (or MxElement for components). */
594
594
  [tag: string]: DomTagFn<Element>;
595
595
  }
596
596
 
597
597
  // ---------------------------------------------------------------------------
598
- // define() — register a component
598
+ // define() - register a component
599
599
  // ---------------------------------------------------------------------------
600
600
 
601
601
  /**
602
602
  * Register a component by name. The `$` function becomes the render function.
603
- * Name is lowercased — CamelCase in mx/dom auto-converts to kebab-case.
603
+ * Name is lowercased - CamelCase in mx/dom auto-converts to kebab-case.
604
604
  *
605
605
  * @example
606
606
  * define('counter', {
@@ -636,7 +636,7 @@ declare global {
636
636
  /** Alias for removeAttribute (used internally) */
637
637
  R(name: string): void;
638
638
 
639
- /** Component state — merged via Object.assign on each $() call */
639
+ /** Component state - merged via Object.assign on each $() call */
640
640
  $state: Record<string, any>;
641
641
 
642
642
  /**
@@ -649,16 +649,16 @@ declare global {
649
649
  _$: any;
650
650
  }
651
651
 
652
- /** mx — virtual description proxy */
652
+ /** mx - virtual description proxy */
653
653
  var mx: MxProxy;
654
654
 
655
- /** dom — real element proxy */
655
+ /** dom - real element proxy */
656
656
  var dom: DomProxy;
657
657
 
658
658
  /** Register a component */
659
659
  var define: MxDefine;
660
660
 
661
- /** Component registry — maps lowercase names to definitions */
661
+ /** Component registry - maps lowercase names to definitions */
662
662
  var components: Record<string, MxComponentDefinition>;
663
663
  }
664
664
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tltdsh/mx",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Expressive UI library in 862 bytes for building high-end, enterprise-level applications. 4 globals, zero dependencies, no build step.",
5
5
  "license": "0BSD",
6
6
  "author": "tltdsh",