zero-query 0.3.1 → 0.5.2

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/index.d.ts CHANGED
@@ -4,14 +4,14 @@
4
4
  * Lightweight modern frontend library — jQuery-like selectors, reactive
5
5
  * components, SPA router, state management, HTTP client & utilities.
6
6
  *
7
- * @version 0.3.1
7
+ * @version 0.5.2
8
8
  * @license MIT
9
9
  * @see https://z-query.com/docs
10
10
  */
11
11
 
12
- // ───────────────────────────────────────────────────────────────────────────
12
+ // ---------------------------------------------------------------------------
13
13
  // ZQueryCollection
14
- // ───────────────────────────────────────────────────────────────────────────
14
+ // ---------------------------------------------------------------------------
15
15
 
16
16
  /**
17
17
  * Chainable wrapper around an array of DOM elements, similar to a jQuery object.
@@ -26,7 +26,7 @@ export class ZQueryCollection {
26
26
 
27
27
  constructor(elements: Element | Element[]);
28
28
 
29
- // ── Iteration ───────────────────────────────────────────────────────────
29
+ // -- Iteration -----------------------------------------------------------
30
30
  /**
31
31
  * Iterate over each element. `this` inside the callback is the element.
32
32
  * @returns The collection (for chaining).
@@ -53,7 +53,7 @@ export class ZQueryCollection {
53
53
  /** Iterable protocol — works with `for...of` and spread. */
54
54
  [Symbol.iterator](): IterableIterator<Element>;
55
55
 
56
- // ── Traversal ───────────────────────────────────────────────────────────
56
+ // -- Traversal -----------------------------------------------------------
57
57
  /** Descendants matching `selector`. */
58
58
  find(selector: string): ZQueryCollection;
59
59
 
@@ -75,7 +75,7 @@ export class ZQueryCollection {
75
75
  /** Previous sibling of each element. */
76
76
  prev(): ZQueryCollection;
77
77
 
78
- // ── Filtering ───────────────────────────────────────────────────────────
78
+ // -- Filtering -----------------------------------------------------------
79
79
  /** Keep elements matching a CSS selector or predicate. */
80
80
  filter(selector: string): ZQueryCollection;
81
81
  filter(fn: (element: Element, index: number) => boolean): ZQueryCollection;
@@ -87,7 +87,7 @@ export class ZQueryCollection {
87
87
  /** Keep elements that have a descendant matching `selector`. */
88
88
  has(selector: string): ZQueryCollection;
89
89
 
90
- // ── Classes ─────────────────────────────────────────────────────────────
90
+ // -- Classes -------------------------------------------------------------
91
91
  /** Add one or more classes (space-separated strings accepted). */
92
92
  addClass(...names: string[]): this;
93
93
 
@@ -100,7 +100,7 @@ export class ZQueryCollection {
100
100
  /** Check whether the first element has the given class. */
101
101
  hasClass(name: string): boolean;
102
102
 
103
- // ── Attributes & Properties ─────────────────────────────────────────────
103
+ // -- Attributes & Properties ---------------------------------------------
104
104
  /** Get attribute value of the first element. */
105
105
  attr(name: string): string | null;
106
106
  /** Set attribute on all elements. */
@@ -120,9 +120,9 @@ export class ZQueryCollection {
120
120
  /** Set data attribute on all elements. Objects are JSON-stringified. */
121
121
  data(key: string, value: any): this;
122
122
 
123
- // ── CSS & Dimensions ────────────────────────────────────────────────────
124
- /** Get computed style property of the first element. */
125
- css(property: string): string;
123
+ // -- CSS & Dimensions ----------------------------------------------------
124
+ /** Get computed style property of the first element, or `undefined` if empty. */
125
+ css(property: string): string | undefined;
126
126
  /** Set inline styles on all elements. */
127
127
  css(props: Partial<CSSStyleDeclaration>): this;
128
128
 
@@ -138,23 +138,23 @@ export class ZQueryCollection {
138
138
  /** Position relative to the offset parent. */
139
139
  position(): { top: number; left: number } | null;
140
140
 
141
- // ── Content ─────────────────────────────────────────────────────────────
142
- /** Get `innerHTML` of the first element. */
143
- html(): string;
141
+ // -- Content -------------------------------------------------------------
142
+ /** Get `innerHTML` of the first element, or `undefined` if empty. */
143
+ html(): string | undefined;
144
144
  /** Set `innerHTML` on all elements. */
145
145
  html(content: string): this;
146
146
 
147
- /** Get `textContent` of the first element. */
148
- text(): string;
147
+ /** Get `textContent` of the first element, or `undefined` if empty. */
148
+ text(): string | undefined;
149
149
  /** Set `textContent` on all elements. */
150
150
  text(content: string): this;
151
151
 
152
- /** Get value of the first input/select/textarea. */
153
- val(): string;
152
+ /** Get value of the first input/select/textarea, or `undefined` if empty. */
153
+ val(): string | undefined;
154
154
  /** Set value on all inputs. */
155
155
  val(value: string): this;
156
156
 
157
- // ── DOM Manipulation ────────────────────────────────────────────────────
157
+ // -- DOM Manipulation ----------------------------------------------------
158
158
  /** Insert content at the end of each element. */
159
159
  append(content: string | Node | ZQueryCollection): this;
160
160
 
@@ -182,7 +182,7 @@ export class ZQueryCollection {
182
182
  /** Replace elements with new content. */
183
183
  replaceWith(content: string | Node): this;
184
184
 
185
- // ── Visibility ──────────────────────────────────────────────────────────
185
+ // -- Visibility ----------------------------------------------------------
186
186
  /** Show elements. Optional display value (default: `''`). */
187
187
  show(display?: string): this;
188
188
 
@@ -192,7 +192,7 @@ export class ZQueryCollection {
192
192
  /** Toggle visibility. */
193
193
  toggle(display?: string): this;
194
194
 
195
- // ── Events ──────────────────────────────────────────────────────────────
195
+ // -- Events --------------------------------------------------------------
196
196
  /** Attach event handler. Space-separated events accepted. */
197
197
  on(events: string, handler: (event: Event) => void): this;
198
198
  /** Delegated event handler. */
@@ -222,7 +222,7 @@ export class ZQueryCollection {
222
222
  /** Blur the first element. */
223
223
  blur(): this;
224
224
 
225
- // ── Animation ───────────────────────────────────────────────────────────
225
+ // -- Animation -----------------------------------------------------------
226
226
  /**
227
227
  * CSS transition animation.
228
228
  * @param props CSS properties to animate to.
@@ -244,7 +244,7 @@ export class ZQueryCollection {
244
244
  /** Toggle height with a slide animation. Default 300 ms. */
245
245
  slideToggle(duration?: number): this;
246
246
 
247
- // ── Form Helpers ────────────────────────────────────────────────────────
247
+ // -- Form Helpers --------------------------------------------------------
248
248
  /** URL-encoded form data string. */
249
249
  serialize(): string;
250
250
 
@@ -253,9 +253,9 @@ export class ZQueryCollection {
253
253
  }
254
254
 
255
255
 
256
- // ───────────────────────────────────────────────────────────────────────────
256
+ // ---------------------------------------------------------------------------
257
257
  // Reactive
258
- // ───────────────────────────────────────────────────────────────────────────
258
+ // ---------------------------------------------------------------------------
259
259
 
260
260
  /** Marker properties added to every reactive proxy. */
261
261
  interface ReactiveProxy<T extends object = object> {
@@ -308,14 +308,19 @@ export function computed<T>(fn: () => T): Signal<T>;
308
308
  export function effect(fn: () => void): () => void;
309
309
 
310
310
 
311
- // ───────────────────────────────────────────────────────────────────────────
311
+ // ---------------------------------------------------------------------------
312
312
  // Component System
313
- // ───────────────────────────────────────────────────────────────────────────
313
+ // ---------------------------------------------------------------------------
314
314
 
315
315
  /** Item in a `pages` config — either a string id or an `{ id, label }` object. */
316
316
  type PageItem = string | { id: string; label?: string };
317
317
 
318
- /** Declarative multi-page configuration for a component. */
318
+ /**
319
+ * Declarative multi-page configuration for a component.
320
+ *
321
+ * Pages are **lazy-loaded**: only the active page is fetched on first render.
322
+ * Remaining pages are prefetched in the background for instant navigation.
323
+ */
319
324
  interface PagesConfig {
320
325
  /** Directory containing the page HTML files (resolved relative to `base`). */
321
326
  dir?: string;
@@ -388,8 +393,14 @@ interface ComponentInstance {
388
393
  /** Reactive state proxy. Mutating triggers re-render. */
389
394
  state: Record<string, any> & ReactiveProxy;
390
395
 
391
- /** Frozen props passed from parent / router. */
392
- readonly props: Readonly<Record<string, any>>;
396
+ /** Frozen props passed from parent / router.
397
+ * When mounted by the router, includes `$route` (NavigationContext), `$query`, and `$params`.
398
+ */
399
+ readonly props: Readonly<Record<string, any> & {
400
+ $route?: NavigationContext;
401
+ $query?: Record<string, string>;
402
+ $params?: Record<string, string>;
403
+ }>;
393
404
 
394
405
  /** Map of `z-ref` name → DOM element. Populated after each render. */
395
406
  refs: Record<string, Element>;
@@ -412,7 +423,7 @@ interface ComponentInstance {
412
423
  /** Teardown: removes listeners, scoped styles, clears DOM. */
413
424
  destroy(): void;
414
425
 
415
- /** Manually queue a re-render (microtask-batched). */
426
+ /** Manually queue a re-render (microtask-batched). Safe to call from anywhere — state mutations during render are coalesced (no infinite loop risk). */
416
427
  _scheduleUpdate(): void;
417
428
 
418
429
  /** Any user-defined methods from the component definition. */
@@ -480,9 +491,124 @@ interface StyleOptions {
480
491
  export function style(urls: string | string[], opts?: StyleOptions): StyleHandle;
481
492
 
482
493
 
483
- // ───────────────────────────────────────────────────────────────────────────
494
+ // ---------------------------------------------------------------------------
495
+ // Directive System
496
+ // ---------------------------------------------------------------------------
497
+ //
498
+ // Directives are special attributes processed by zQuery's component renderer.
499
+ // They work in both `render()` template literals and external `templateUrl`
500
+ // HTML files. All expressions evaluate in the component's state context
501
+ // (bare names resolve to `this.state.*`; `props` and `refs` also available).
502
+ //
503
+ // ─── Structural Directives ──────────────────────────────────────────────
504
+ //
505
+ // z-if="expression" Conditional rendering — element removed when falsy.
506
+ // z-else-if="expression" Else-if branch (must be immediate sibling of z-if).
507
+ // z-else Default branch (must follow z-if or z-else-if).
508
+ //
509
+ // z-for="item in items" List rendering — repeats the element per item.
510
+ // {{item.prop}} Use double-brace interpolation for item data.
511
+ // (item, index) in items Destructured index support.
512
+ // n in 5 Number range → [1, 2, 3, 4, 5].
513
+ // (val, key) in object Object iteration → {key, value} entries.
514
+ //
515
+ // z-show="expression" Toggle `display: none` (element stays in DOM).
516
+ //
517
+ // ─── Attribute Directives ───────────────────────────────────────────────
518
+ //
519
+ // z-bind:attr="expression" Dynamic attribute binding.
520
+ // :attr="expression" Shorthand for z-bind:attr.
521
+ // false/null/undefined → removes the attribute.
522
+ // true → sets empty attribute (e.g. disabled="").
523
+ //
524
+ // z-class="expression" Dynamic class binding.
525
+ // String: space-separated class names.
526
+ // Array: list of class names (falsy filtered).
527
+ // Object: { className: condition } map.
528
+ //
529
+ // z-style="expression" Dynamic inline styles.
530
+ // String: appended to existing cssText.
531
+ // Object: { property: value } map (camelCase keys).
532
+ //
533
+ // z-html="expression" Set innerHTML from expression (use trusted content only).
534
+ // z-text="expression" Set textContent from expression (safe, no HTML).
535
+ //
536
+ // ─── Form & Reference Directives ────────────────────────────────────────
537
+ //
538
+ // z-model="stateKey" Two-way binding for form elements.
539
+ // Supports: input, textarea, select, select[multiple], contenteditable.
540
+ // Nested keys: z-model="user.name" → this.state.user.name.
541
+ // Modifiers (boolean attributes on same element):
542
+ // z-lazy — update on 'change' instead of 'input' (update on blur).
543
+ // z-trim — auto .trim() whitespace before writing to state.
544
+ // z-number — force Number() conversion regardless of input type.
545
+ //
546
+ // z-ref="name" Element reference → this.refs.name.
547
+ //
548
+ // ─── Event Directives ───────────────────────────────────────────────────
549
+ //
550
+ // @event="method" Event binding with delegation (shorthand).
551
+ // z-on:event="method" Event binding with delegation (full syntax).
552
+ // @event="method(args)" Pass arguments: strings, numbers, booleans,
553
+ // null, $event, state.key references.
554
+ //
555
+ // Event Modifiers (chainable with dots):
556
+ // .prevent event.preventDefault()
557
+ // .stop event.stopPropagation()
558
+ // .self Only fire if event.target === element itself.
559
+ // .once Handler fires at most once per element.
560
+ // .capture addEventListener with { capture: true }.
561
+ // .passive addEventListener with { passive: true }.
562
+ // .debounce.{ms} Debounce: delay until {ms}ms idle (default 250).
563
+ // .throttle.{ms} Throttle: invoke at most once per {ms}ms (default 250).
564
+ //
565
+ // ─── Special Directives ─────────────────────────────────────────────────
566
+ //
567
+ // z-cloak Hidden until rendered (auto-removed after mount).
568
+ // Global CSS: [z-cloak] { display: none !important }.
569
+ // Also injects: *, *::before, *::after { -webkit-tap-highlight-color: transparent }.
570
+ //
571
+ // z-pre Skip all directive processing for this element
572
+ // and its descendants.
573
+ //
574
+ // ─── Processing Order ───────────────────────────────────────────────────
575
+ //
576
+ // 1. z-for (pre-innerHTML expansion)
577
+ // 2. z-if chain (DOM removal)
578
+ // 3. z-show (display toggle)
579
+ // 4. z-bind / : (dynamic attributes)
580
+ // 5. z-class (dynamic classes)
581
+ // 6. z-style (dynamic styles)
582
+ // 7. z-html/text (content injection)
583
+ // 8. @/z-on (event binding)
584
+ // 9. z-ref (element references)
585
+ // 10. z-model (two-way binding)
586
+ // 11. z-cloak (attribute removal)
587
+ //
588
+ // ---------------------------------------------------------------------------
589
+
590
+ /**
591
+ * Supported event modifier strings for `@event` and `z-on:event` bindings.
592
+ * Modifiers are appended to the event name with dots, e.g. `@click.prevent.stop`.
593
+ */
594
+ type EventModifier =
595
+ | 'prevent'
596
+ | 'stop'
597
+ | 'self'
598
+ | 'once'
599
+ | 'capture'
600
+ | 'passive'
601
+ | `debounce`
602
+ | `debounce.${number}`
603
+ | `throttle`
604
+ | `throttle.${number}`;
605
+
606
+ export { EventModifier };
607
+
608
+
609
+ // ---------------------------------------------------------------------------
484
610
  // Router
485
- // ───────────────────────────────────────────────────────────────────────────
611
+ // ---------------------------------------------------------------------------
486
612
 
487
613
  /** A single route definition. */
488
614
  interface RouteDefinition {
@@ -581,7 +707,7 @@ interface RouterInstance {
581
707
  /** Resolve a path applying the base prefix. */
582
708
  resolve(path: string): string;
583
709
 
584
- // ── Properties ──────────────────────────────────────────────────────────
710
+ // -- Properties ----------------------------------------------------------
585
711
  /** Current navigation context. */
586
712
  readonly current: NavigationContext | null;
587
713
  /** Current path (base-stripped in history mode). */
@@ -599,9 +725,9 @@ export function createRouter(config: RouterConfig): RouterInstance;
599
725
  export function getRouter(): RouterInstance | null;
600
726
 
601
727
 
602
- // ───────────────────────────────────────────────────────────────────────────
728
+ // ---------------------------------------------------------------------------
603
729
  // Store
604
- // ───────────────────────────────────────────────────────────────────────────
730
+ // ---------------------------------------------------------------------------
605
731
 
606
732
  /** Store configuration. */
607
733
  interface StoreConfig<
@@ -700,9 +826,9 @@ export function getStore<
700
826
  >(name?: string): StoreInstance<S, A, G> | null;
701
827
 
702
828
 
703
- // ───────────────────────────────────────────────────────────────────────────
829
+ // ---------------------------------------------------------------------------
704
830
  // HTTP Client
705
- // ───────────────────────────────────────────────────────────────────────────
831
+ // ---------------------------------------------------------------------------
706
832
 
707
833
  /** The response object resolved by all HTTP request methods (except `raw`). */
708
834
  interface HttpResponse<T = any> {
@@ -781,9 +907,9 @@ interface HttpClient {
781
907
  export const http: HttpClient;
782
908
 
783
909
 
784
- // ───────────────────────────────────────────────────────────────────────────
910
+ // ---------------------------------------------------------------------------
785
911
  // Utilities — Functions
786
- // ───────────────────────────────────────────────────────────────────────────
912
+ // ---------------------------------------------------------------------------
787
913
 
788
914
  /** Debounced function with a `.cancel()` helper. */
789
915
  interface DebouncedFunction<T extends (...args: any[]) => any> {
@@ -805,7 +931,11 @@ export function debounce<T extends (...args: any[]) => any>(fn: T, ms?: number):
805
931
  export function throttle<T extends (...args: any[]) => any>(fn: T, ms?: number): (...args: Parameters<T>) => void;
806
932
 
807
933
  /** Left-to-right function composition. */
808
- export function pipe<T>(...fns: Array<(value: T) => T>): (input: T) => T;
934
+ export function pipe<A, B>(f1: (a: A) => B): (input: A) => B;
935
+ export function pipe<A, B, C>(f1: (a: A) => B, f2: (b: B) => C): (input: A) => C;
936
+ export function pipe<A, B, C, D>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D): (input: A) => D;
937
+ export function pipe<A, B, C, D, E>(f1: (a: A) => B, f2: (b: B) => C, f3: (c: C) => D, f4: (d: D) => E): (input: A) => E;
938
+ export function pipe<T>(...fns: Array<(value: any) => any>): (input: T) => any;
809
939
 
810
940
  /**
811
941
  * Returns a function that only executes once, caching the result.
@@ -816,9 +946,9 @@ export function once<T extends (...args: any[]) => any>(fn: T): (...args: Parame
816
946
  export function sleep(ms: number): Promise<void>;
817
947
 
818
948
 
819
- // ───────────────────────────────────────────────────────────────────────────
949
+ // ---------------------------------------------------------------------------
820
950
  // Utilities — Strings
821
- // ───────────────────────────────────────────────────────────────────────────
951
+ // ---------------------------------------------------------------------------
822
952
 
823
953
  /** Escape HTML entities: `&`, `<`, `>`, `"`, `'`. */
824
954
  export function escapeHtml(str: string): string;
@@ -847,9 +977,9 @@ export function camelCase(str: string): string;
847
977
  export function kebabCase(str: string): string;
848
978
 
849
979
 
850
- // ───────────────────────────────────────────────────────────────────────────
980
+ // ---------------------------------------------------------------------------
851
981
  // Utilities — Objects
852
- // ───────────────────────────────────────────────────────────────────────────
982
+ // ---------------------------------------------------------------------------
853
983
 
854
984
  /** Deep clone using `structuredClone` (JSON fallback). */
855
985
  export function deepClone<T>(obj: T): T;
@@ -861,9 +991,9 @@ export function deepMerge<T extends object>(target: T, ...sources: Partial<T>[])
861
991
  export function isEqual(a: any, b: any): boolean;
862
992
 
863
993
 
864
- // ───────────────────────────────────────────────────────────────────────────
994
+ // ---------------------------------------------------------------------------
865
995
  // Utilities — URL
866
- // ───────────────────────────────────────────────────────────────────────────
996
+ // ---------------------------------------------------------------------------
867
997
 
868
998
  /** Serialize an object to a URL query string. */
869
999
  export function param(obj: Record<string, any>): string;
@@ -872,9 +1002,9 @@ export function param(obj: Record<string, any>): string;
872
1002
  export function parseQuery(str: string): Record<string, string>;
873
1003
 
874
1004
 
875
- // ───────────────────────────────────────────────────────────────────────────
1005
+ // ---------------------------------------------------------------------------
876
1006
  // Utilities — Storage
877
- // ───────────────────────────────────────────────────────────────────────────
1007
+ // ---------------------------------------------------------------------------
878
1008
 
879
1009
  /** JSON-aware `localStorage` wrapper. */
880
1010
  interface StorageWrapper {
@@ -895,9 +1025,9 @@ export const storage: StorageWrapper;
895
1025
  export const session: StorageWrapper;
896
1026
 
897
1027
 
898
- // ───────────────────────────────────────────────────────────────────────────
1028
+ // ---------------------------------------------------------------------------
899
1029
  // Utilities — Event Bus
900
- // ───────────────────────────────────────────────────────────────────────────
1030
+ // ---------------------------------------------------------------------------
901
1031
 
902
1032
  /** Singleton pub/sub event bus for cross-component communication. */
903
1033
  interface EventBus {
@@ -916,9 +1046,9 @@ interface EventBus {
916
1046
  export const bus: EventBus;
917
1047
 
918
1048
 
919
- // ───────────────────────────────────────────────────────────────────────────
1049
+ // ---------------------------------------------------------------------------
920
1050
  // $ — Main function & namespace
921
- // ───────────────────────────────────────────────────────────────────────────
1051
+ // ---------------------------------------------------------------------------
922
1052
 
923
1053
  /**
924
1054
  * Main selector / DOM-ready function.
@@ -934,7 +1064,7 @@ interface ZQueryStatic {
934
1064
  (nodeList: NodeList | HTMLCollection | Element[]): Element | null;
935
1065
  (fn: () => void): void;
936
1066
 
937
- // ── Collection selector ─────────────────────────────────────────────────
1067
+ // -- Collection selector -------------------------------------------------
938
1068
  /**
939
1069
  * Collection selector — returns a `ZQueryCollection`.
940
1070
  *
@@ -947,7 +1077,7 @@ interface ZQueryStatic {
947
1077
  all(element: Element): ZQueryCollection;
948
1078
  all(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
949
1079
 
950
- // ── Quick-ref shortcuts ─────────────────────────────────────────────────
1080
+ // -- Quick-ref shortcuts -------------------------------------------------
951
1081
  /** `document.getElementById(id)` */
952
1082
  id(id: string): Element | null;
953
1083
  /** `document.querySelector('.name')` */
@@ -956,10 +1086,16 @@ interface ZQueryStatic {
956
1086
  classes(name: string): Element[];
957
1087
  /** `document.getElementsByTagName(name)` as array. */
958
1088
  tag(name: string): Element[];
1089
+ /** `document.getElementsByName(name)` as array. */
1090
+ name(name: string): Element[];
1091
+ /** `document.querySelectorAll('[attr]')` or `[attr="value"]` as array. */
1092
+ attr(attr: string, value?: string): Element[];
1093
+ /** `document.querySelectorAll('[data-key]')` or `[data-key="value"]` as array. */
1094
+ data(key: string, value?: string): Element[];
959
1095
  /** Children of `#parentId` as array. */
960
1096
  children(parentId: string): Element[];
961
1097
 
962
- // ── Static helpers ──────────────────────────────────────────────────────
1098
+ // -- Static helpers ------------------------------------------------------
963
1099
  /**
964
1100
  * Create a DOM element.
965
1101
  * Special `attrs` keys: `class`, `style` (object), `on*` (handler), `data` (object).
@@ -976,16 +1112,23 @@ interface ZQueryStatic {
976
1112
  /** Global event delegation on `document`. */
977
1113
  on(event: string, selector: string, handler: (this: Element, e: Event) => void): void;
978
1114
 
1115
+ /** Direct event listener on `document` (for keydown, resize, etc.). */
1116
+ on(event: string, handler: (e: Event) => void): void;
1117
+
1118
+ /** Remove a direct global event listener previously attached with `$.on(event, handler)`. */
1119
+ off(event: string, handler: (e: Event) => void): void;
1120
+
979
1121
  /** Alias for `ZQueryCollection.prototype` — extend to add custom collection methods. */
980
1122
  fn: typeof ZQueryCollection.prototype;
981
1123
 
982
- // ── Reactive ────────────────────────────────────────────────────────────
1124
+ // -- Reactive ------------------------------------------------------------
983
1125
  reactive: typeof reactive;
1126
+ Signal: typeof Signal;
984
1127
  signal: typeof signal;
985
1128
  computed: typeof computed;
986
1129
  effect: typeof effect;
987
1130
 
988
- // ── Components ──────────────────────────────────────────────────────────
1131
+ // -- Components ----------------------------------------------------------
989
1132
  component: typeof component;
990
1133
  mount: typeof mount;
991
1134
  mountAll: typeof mountAll;
@@ -995,15 +1138,15 @@ interface ZQueryStatic {
995
1138
  components: typeof getRegistry;
996
1139
  style: typeof style;
997
1140
 
998
- // ── Router ──────────────────────────────────────────────────────────────
1141
+ // -- Router --------------------------------------------------------------
999
1142
  router: typeof createRouter;
1000
1143
  getRouter: typeof getRouter;
1001
1144
 
1002
- // ── Store ───────────────────────────────────────────────────────────────
1145
+ // -- Store ---------------------------------------------------------------
1003
1146
  store: typeof createStore;
1004
1147
  getStore: typeof getStore;
1005
1148
 
1006
- // ── HTTP ────────────────────────────────────────────────────────────────
1149
+ // -- HTTP ----------------------------------------------------------------
1007
1150
  http: HttpClient;
1008
1151
  get: HttpClient['get'];
1009
1152
  post: HttpClient['post'];
@@ -1011,7 +1154,7 @@ interface ZQueryStatic {
1011
1154
  patch: HttpClient['patch'];
1012
1155
  delete: HttpClient['delete'];
1013
1156
 
1014
- // ── Utilities ───────────────────────────────────────────────────────────
1157
+ // -- Utilities -----------------------------------------------------------
1015
1158
  debounce: typeof debounce;
1016
1159
  throttle: typeof throttle;
1017
1160
  pipe: typeof pipe;
@@ -1036,7 +1179,7 @@ interface ZQueryStatic {
1036
1179
  session: StorageWrapper;
1037
1180
  bus: EventBus;
1038
1181
 
1039
- // ── Meta ────────────────────────────────────────────────────────────────
1182
+ // -- Meta ----------------------------------------------------------------
1040
1183
  /** Library version string. */
1041
1184
  version: string;
1042
1185
  /** Populated at build time by the CLI bundler. */
@@ -1048,14 +1191,18 @@ interface ZQueryStatic {
1048
1191
  /** The main `$` / `zQuery` function + namespace. */
1049
1192
  export const $: ZQueryStatic;
1050
1193
  export { $ as zQuery };
1051
- export const queryAll: typeof ZQueryCollection;
1194
+
1195
+ /** Collection selector function — same as `$.all()`. */
1196
+ export function queryAll(selector: string, context?: string | Element): ZQueryCollection;
1197
+ export function queryAll(element: Element): ZQueryCollection;
1198
+ export function queryAll(nodeList: NodeList | HTMLCollection | Element[]): ZQueryCollection;
1052
1199
 
1053
1200
  export default $;
1054
1201
 
1055
1202
 
1056
- // ───────────────────────────────────────────────────────────────────────────
1203
+ // ---------------------------------------------------------------------------
1057
1204
  // Global augmentation (browser)
1058
- // ───────────────────────────────────────────────────────────────────────────
1205
+ // ---------------------------------------------------------------------------
1059
1206
 
1060
1207
  declare global {
1061
1208
  interface Window {
package/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  /**
2
- * ┌─────────────────────────────────────────────────────────┐
2
+ * ┌---------------------------------------------------------┐
3
3
  * │ zQuery (zeroQuery) — Lightweight Frontend Library │
4
4
  * │ │
5
5
  * │ jQuery-like selectors · Reactive components │
6
6
  * │ SPA router · State management · Zero dependencies │
7
7
  * │ │
8
8
  * │ https://github.com/tonywied17/zero-query │
9
- * └─────────────────────────────────────────────────────────┘
9
+ * └---------------------------------------------------------┘
10
10
  */
11
11
 
12
12
  import { query, queryAll, ZQueryCollection } from './src/core.js';
13
- import { reactive, signal, computed, effect } from './src/reactive.js';
13
+ import { reactive, Signal, signal, computed, effect } from './src/reactive.js';
14
14
  import { component, mount, mountAll, getInstance, destroy, getRegistry, style } from './src/component.js';
15
15
  import { createRouter, getRouter } from './src/router.js';
16
16
  import { createStore, getStore } from './src/store.js';
@@ -49,11 +49,16 @@ function $(selector, context) {
49
49
  }
50
50
 
51
51
 
52
- // --- Quick refs ------------------------------------------------------------
52
+ // --- Quick refs (DOM selectors) --------------------------------------------
53
53
  $.id = query.id;
54
54
  $.class = query.class;
55
55
  $.classes = query.classes;
56
56
  $.tag = query.tag;
57
+ Object.defineProperty($, 'name', {
58
+ value: query.name, writable: true, configurable: true
59
+ });
60
+ $.attr = query.attr;
61
+ $.data = query.data;
57
62
  $.children = query.children;
58
63
 
59
64
  // --- Collection selector ---------------------------------------------------
@@ -77,10 +82,12 @@ $.all = function(selector, context) {
77
82
  $.create = query.create;
78
83
  $.ready = query.ready;
79
84
  $.on = query.on;
85
+ $.off = query.off;
80
86
  $.fn = query.fn;
81
87
 
82
88
  // --- Reactive primitives ---------------------------------------------------
83
89
  $.reactive = reactive;
90
+ $.Signal = Signal;
84
91
  $.signal = signal;
85
92
  $.computed = computed;
86
93
  $.effect = effect;
@@ -160,13 +167,13 @@ export {
160
167
  $ as zQuery,
161
168
  ZQueryCollection,
162
169
  queryAll,
163
- reactive, signal, computed, effect,
164
- component, mount, mountAll, getInstance, destroy, style,
170
+ reactive, Signal, signal, computed, effect,
171
+ component, mount, mountAll, getInstance, destroy, getRegistry, style,
165
172
  createRouter, getRouter,
166
173
  createStore, getStore,
167
174
  http,
168
175
  debounce, throttle, pipe, once, sleep,
169
- escapeHtml, html, trust, uuid,
176
+ escapeHtml, html, trust, uuid, camelCase, kebabCase,
170
177
  deepClone, deepMerge, isEqual, param, parseQuery,
171
178
  storage, session, bus,
172
179
  };