@brandup/ui 1.0.44 → 2.0.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.
Files changed (63) hide show
  1. package/README.md +482 -33
  2. package/dist/cjs/constants.js +14 -0
  3. package/dist/cjs/constants.js.map +1 -0
  4. package/dist/cjs/dom/bind-each.js +90 -0
  5. package/dist/cjs/dom/bind-each.js.map +1 -0
  6. package/dist/cjs/dom/bind.js +29 -0
  7. package/dist/cjs/dom/bind.js.map +1 -0
  8. package/dist/cjs/dom/binding-cleanup.js +162 -0
  9. package/dist/cjs/dom/binding-cleanup.js.map +1 -0
  10. package/dist/cjs/dom/dom.js +184 -0
  11. package/dist/cjs/dom/dom.js.map +1 -0
  12. package/dist/cjs/dom/helpers.js +33 -0
  13. package/dist/cjs/dom/helpers.js.map +1 -0
  14. package/dist/cjs/dom/index.js +14 -0
  15. package/dist/cjs/dom/index.js.map +1 -0
  16. package/dist/cjs/dom/tag.js +207 -0
  17. package/dist/cjs/dom/tag.js.map +1 -0
  18. package/dist/cjs/element.js +265 -0
  19. package/dist/cjs/element.js.map +1 -0
  20. package/dist/cjs/events.js +204 -0
  21. package/dist/cjs/events.js.map +1 -0
  22. package/dist/cjs/ext.js +20 -0
  23. package/dist/cjs/ext.js.map +1 -0
  24. package/dist/cjs/index.js +37 -313
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/reactive/computed.js +36 -0
  27. package/dist/cjs/reactive/computed.js.map +1 -0
  28. package/dist/cjs/reactive/effect.js +197 -0
  29. package/dist/cjs/reactive/effect.js.map +1 -0
  30. package/dist/cjs/reactive/reactive.js +106 -0
  31. package/dist/cjs/reactive/reactive.js.map +1 -0
  32. package/dist/mjs/constants.js +10 -0
  33. package/dist/mjs/constants.js.map +1 -0
  34. package/dist/mjs/dom/bind-each.js +86 -0
  35. package/dist/mjs/dom/bind-each.js.map +1 -0
  36. package/dist/mjs/dom/bind.js +26 -0
  37. package/dist/mjs/dom/bind.js.map +1 -0
  38. package/dist/mjs/dom/binding-cleanup.js +156 -0
  39. package/dist/mjs/dom/binding-cleanup.js.map +1 -0
  40. package/dist/mjs/dom/dom.js +169 -0
  41. package/dist/mjs/dom/dom.js.map +1 -0
  42. package/dist/mjs/dom/helpers.js +29 -0
  43. package/dist/mjs/dom/helpers.js.map +1 -0
  44. package/dist/mjs/dom/index.js +12 -0
  45. package/dist/mjs/dom/index.js.map +1 -0
  46. package/dist/mjs/dom/tag.js +203 -0
  47. package/dist/mjs/dom/tag.js.map +1 -0
  48. package/dist/mjs/element.js +260 -0
  49. package/dist/mjs/element.js.map +1 -0
  50. package/dist/mjs/events.js +202 -0
  51. package/dist/mjs/events.js.map +1 -0
  52. package/dist/mjs/ext.js +18 -0
  53. package/dist/mjs/ext.js.map +1 -0
  54. package/dist/mjs/index.js +11 -314
  55. package/dist/mjs/index.js.map +1 -1
  56. package/dist/mjs/reactive/computed.js +33 -0
  57. package/dist/mjs/reactive/computed.js.map +1 -0
  58. package/dist/mjs/reactive/effect.js +187 -0
  59. package/dist/mjs/reactive/effect.js.map +1 -0
  60. package/dist/mjs/reactive/reactive.js +102 -0
  61. package/dist/mjs/reactive/reactive.js.map +1 -0
  62. package/dist/types.d.ts +489 -14
  63. package/package.json +9 -1
@@ -0,0 +1,106 @@
1
+ 'use strict';
2
+
3
+ var effect = require('./effect.js');
4
+
5
+ const RAW = Symbol("raw");
6
+ const reactiveMap = new WeakMap();
7
+ function isObject(value) {
8
+ return value !== null && typeof value === "object";
9
+ }
10
+ function isIntegerKey(key) {
11
+ return typeof key === "string" && /^\d+$/.test(key);
12
+ }
13
+ /** Whether a value is a reactive proxy created by {@link reactive}. */
14
+ function isReactive(value) {
15
+ return isObject(value) && !!value[RAW];
16
+ }
17
+ /** Return the underlying raw (non-reactive) object behind a reactive proxy, or the value itself. */
18
+ function toRaw(value) {
19
+ const raw = isObject(value) && value[RAW];
20
+ return raw ? raw : value;
21
+ }
22
+ const handlers = {
23
+ get(target, key, receiver) {
24
+ if (key === RAW)
25
+ return target;
26
+ const result = Reflect.get(target, key, receiver);
27
+ // don't track symbol keys (well-known symbols, internal lookups)
28
+ if (typeof key === "symbol")
29
+ return result;
30
+ effect.track(target, key);
31
+ // deep: wrap nested objects/arrays lazily on read
32
+ return isObject(result) ? reactive(result) : result;
33
+ },
34
+ set(target, key, value, receiver) {
35
+ const isArray = Array.isArray(target);
36
+ const isIndex = isArray && isIntegerKey(key);
37
+ const oldLength = isArray ? target.length : 0;
38
+ const hadKey = isIndex
39
+ ? Number(key) < oldLength
40
+ : Object.prototype.hasOwnProperty.call(target, key);
41
+ const oldValue = target[key];
42
+ const result = Reflect.set(target, key, toRaw(value), receiver);
43
+ if (!result)
44
+ return result;
45
+ if (!hadKey) {
46
+ effect.trigger(target, key);
47
+ effect.trigger(target, effect.ITERATE_KEY);
48
+ }
49
+ else if (!Object.is(oldValue, toRaw(value))) {
50
+ effect.trigger(target, key);
51
+ }
52
+ if (isArray && key === "length") {
53
+ // shrinking the array drops indices [newLength, oldLength) — notify
54
+ // effects that read them, plus iteration; growing only changes iteration
55
+ const newLength = Number(value);
56
+ for (let i = newLength; i < oldLength; i++)
57
+ effect.trigger(target, String(i));
58
+ if (newLength !== oldLength)
59
+ effect.trigger(target, effect.ITERATE_KEY);
60
+ }
61
+ else if (isIndex && Number(key) >= oldLength) {
62
+ // a new index extended the array, so its length changed
63
+ effect.trigger(target, "length");
64
+ }
65
+ return result;
66
+ },
67
+ deleteProperty(target, key) {
68
+ const hadKey = Object.prototype.hasOwnProperty.call(target, key);
69
+ const result = Reflect.deleteProperty(target, key);
70
+ if (hadKey && result) {
71
+ effect.trigger(target, key);
72
+ effect.trigger(target, effect.ITERATE_KEY);
73
+ }
74
+ return result;
75
+ },
76
+ has(target, key) {
77
+ if (typeof key !== "symbol")
78
+ effect.track(target, key);
79
+ return Reflect.has(target, key);
80
+ },
81
+ ownKeys(target) {
82
+ effect.track(target, effect.ITERATE_KEY);
83
+ return Reflect.ownKeys(target);
84
+ }
85
+ };
86
+ /**
87
+ * Wrap an object or array in a deep reactive proxy. Reads are tracked and writes
88
+ * notify effects. Returns the same proxy for the same target, and non-objects unchanged.
89
+ */
90
+ function reactive(target) {
91
+ if (!isObject(target))
92
+ return target;
93
+ if (target[RAW])
94
+ return target; // already reactive
95
+ const existing = reactiveMap.get(target);
96
+ if (existing)
97
+ return existing;
98
+ const proxy = new Proxy(target, handlers);
99
+ reactiveMap.set(target, proxy);
100
+ return proxy;
101
+ }
102
+
103
+ exports.isReactive = isReactive;
104
+ exports.reactive = reactive;
105
+ exports.toRaw = toRaw;
106
+ //# sourceMappingURL=reactive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive.js","sources":["../../../../source/reactive/reactive.ts"],"sourcesContent":[null],"names":["track","trigger","ITERATE_KEY"],"mappings":";;;;AAEA,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;AACzB,MAAM,WAAW,GAAG,IAAI,OAAO,EAAe;AAE9C,SAAS,QAAQ,CAAC,KAAc,EAAA;IAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;AACnD;AAEA,SAAS,YAAY,CAAC,GAAgB,EAAA;IACrC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AACpD;AAEA;AACM,SAAU,UAAU,CAAC,KAAc,EAAA;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAE,KAAa,CAAC,GAAG,CAAC;AAChD;AAEA;AACM,SAAU,KAAK,CAAI,KAAQ,EAAA;IAChC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAK,KAAa,CAAC,GAAG,CAAC;IAClD,OAAO,GAAG,GAAG,GAAQ,GAAG,KAAK;AAC9B;AAEA,MAAM,QAAQ,GAAyB;AACtC,IAAA,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAA;Q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,MAAM,EAAEE,kBAAW,CAAC;AAC1B,QAAA,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;IAC/B;CACA;AAED;;;AAGG;AACG,SAAU,QAAQ,CAAmB,MAAS,EAAA;AACnD,IAAA,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;AACpB,QAAA,OAAO,MAAM;IACd,IAAK,MAAc,CAAC,GAAG,CAAC;QACvB,OAAO,MAAM,CAAC;IAEf,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;AACxC,IAAA,IAAI,QAAQ;AACX,QAAA,OAAO,QAAQ;IAEhB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC;AACzC,IAAA,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC;AAC9B,IAAA,OAAO,KAAU;AAClB;;;;;;"}
@@ -0,0 +1,10 @@
1
+ /** Default constant values used across the library. */
2
+ const constants = {
3
+ ElemAttributeName: "uiElement",
4
+ ElemPropertyName: "uielement",
5
+ CommandAttributeName: "command",
6
+ CommandExecutingCssClassName: "executing"
7
+ };
8
+
9
+ export { constants as default };
10
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../source/constants.ts"],"sourcesContent":[null],"names":[],"mappings":"AAYA;AACA,MAAM,SAAS,GAAgB;AAC9B,IAAA,iBAAiB,EAAE,WAAW;AAC9B,IAAA,gBAAgB,EAAE,WAAW;AAC7B,IAAA,oBAAoB,EAAE,SAAS;AAC/B,IAAA,4BAA4B,EAAE;;;;;"}
@@ -0,0 +1,86 @@
1
+ import { effect, untrack } from '../reactive/effect.js';
2
+ import { autoDisposeBinding } from './binding-cleanup.js';
3
+
4
+ /** A keyed-list binding produced by {@link bindEach}; handled by `appendChild` in `tag.ts`. */
5
+ class BindingEach {
6
+ getItems;
7
+ getKey;
8
+ render;
9
+ constructor(getItems, getKey, render) {
10
+ this.getItems = getItems;
11
+ this.getKey = getKey;
12
+ this.render = render;
13
+ }
14
+ }
15
+ /**
16
+ * Create a reactive keyed-list binding for use as a {@link tag} child.
17
+ *
18
+ * The `getItems` function is tracked; the list is reconciled whenever the array
19
+ * changes (push, splice, reassignment, etc.). Items are matched by `getKey` so
20
+ * unchanged nodes stay in place — only new, removed, or reordered nodes are touched.
21
+ *
22
+ * `render` is called **once per key** and runs **untracked**. Use `bind()` inside
23
+ * the render function for item properties that should update independently:
24
+ *
25
+ * ⚠️ The item object passed to `render` is captured at first render for that key.
26
+ * Mutate items in place (`item.name = "..."`) so `bind()` reactions fire. Replacing
27
+ * the array with **new objects that reuse the same keys** keeps the cached node bound
28
+ * to the *old* object, so per-item `bind()`s won't update — change the key, or mutate
29
+ * the existing item, when its identity should change.
30
+ *
31
+ * @example
32
+ * DOM.tag("ul", null,
33
+ * bindEach(() => state.users, u => u.id, u =>
34
+ * DOM.tag("li", null, bind(() => u.name))
35
+ * )
36
+ * );
37
+ */
38
+ function bindEach(getItems, getKey, render) {
39
+ return new BindingEach(getItems, getKey, render);
40
+ }
41
+ /**
42
+ * Mount a {@link BindingEach} into `container` and start tracking.
43
+ * Called by `appendChild` in `tag.ts`; not intended for direct use.
44
+ * @internal
45
+ */
46
+ function appendBindingEach(container, binding) {
47
+ const nodes = new Map();
48
+ // Anchor comment marks the start of the managed region inside the container.
49
+ // Using an anchor (rather than container.firstChild) lets other children coexist.
50
+ const anchor = document.createComment("");
51
+ container.append(anchor);
52
+ const eff = effect(() => {
53
+ const items = binding.getItems();
54
+ const nextKeys = new Set();
55
+ for (let i = 0; i < items.length; i++)
56
+ nextKeys.add(binding.getKey(items[i], i));
57
+ // Remove nodes whose keys are no longer present
58
+ for (const [key, node] of nodes) {
59
+ if (!nextKeys.has(key)) {
60
+ node.remove();
61
+ nodes.delete(key);
62
+ }
63
+ }
64
+ // Insert new nodes and restore order in a single pass starting after the anchor.
65
+ // If the node is already at the expected position we advance; otherwise insertBefore moves it.
66
+ let cursor = anchor.nextSibling;
67
+ for (let i = 0; i < items.length; i++) {
68
+ const key = binding.getKey(items[i], i);
69
+ let node = nodes.get(key);
70
+ if (!node) {
71
+ // Render untracked so item-property reads don't create dependencies on
72
+ // this list effect — use bind() inside render for fine-grained updates.
73
+ node = untrack(() => binding.render(items[i]));
74
+ nodes.set(key, node);
75
+ }
76
+ if (cursor !== node)
77
+ container.insertBefore(node, cursor);
78
+ else
79
+ cursor = cursor.nextSibling;
80
+ }
81
+ });
82
+ autoDisposeBinding(container, () => anchor, eff);
83
+ }
84
+
85
+ export { BindingEach, appendBindingEach, bindEach };
86
+ //# sourceMappingURL=bind-each.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind-each.js","sources":["../../../../source/dom/bind-each.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;MACa,WAAW,CAAA;AAEb,IAAA,QAAA;AACA,IAAA,MAAA;AACA,IAAA,MAAA;AAHV,IAAA,WAAA,CACU,QAAmB,EACnB,MAAmD,EACnD,MAA4B,EAAA;QAF5B,IAAA,CAAA,QAAQ,GAAR,QAAQ;QACR,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,MAAM,GAAN,MAAM;IACZ;AACJ;AAED;;;;;;;;;;;;;;;;;;;;;;AAsBG;SACa,QAAQ,CACvB,QAAmB,EACnB,MAAmD,EACnD,MAA4B,EAAA;IAE5B,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;AACjD;AAEA;;;;AAIG;AACG,SAAU,iBAAiB,CAAI,SAAsB,EAAE,OAAuB,EAAA;AACnF,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,EAA4B;;;IAIjD,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;AACzC,IAAA,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC;AAExB,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,MAAK;AACvB,QAAA,MAAM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,MAAM,MAAM,EAAE,GAAG,CAAC;AACjD;;;;"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * A reactive binding for use as a {@link tag} child. Its `compute` function is
3
+ * re-evaluated and re-rendered whenever the reactive state it reads changes.
4
+ */
5
+ class Binding {
6
+ compute;
7
+ constructor(compute) {
8
+ this.compute = compute;
9
+ }
10
+ }
11
+ /**
12
+ * Create a reactive {@link Binding} that can be passed as a `tag` child. The
13
+ * compute function is tracked: it re-runs (updating the DOM in place) whenever
14
+ * any reactive value it reads changes.
15
+ *
16
+ * @example
17
+ * const state = reactive({ name: "Alice" });
18
+ * DOM.tag("div", null, "Hi, ", bind(() => state.name));
19
+ * state.name = "Bob"; // the text updates in place
20
+ */
21
+ function bind(compute) {
22
+ return new Binding(compute);
23
+ }
24
+
25
+ export { Binding, bind };
26
+ //# sourceMappingURL=bind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bind.js","sources":["../../../../source/dom/bind.ts"],"sourcesContent":[null],"names":[],"mappings":"AAKA;;;AAGG;MACU,OAAO,CAAA;AACE,IAAA,OAAA;AAArB,IAAA,WAAA,CAAqB,OAA2B,EAAA;QAA3B,IAAA,CAAA,OAAO,GAAP,OAAO;IAAwB;AACpD;AAED;;;;;;;;;AASG;AACG,SAAU,IAAI,CAAC,OAA2B,EAAA;AAC/C,IAAA,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;AAC5B;;;;"}
@@ -0,0 +1,156 @@
1
+ // UIElements are located via the data attribute `UIElement.setElement` already sets
2
+ // (`elem.dataset.uiElement` → `data-ui-element`), so no extra marker is needed for them.
3
+ const UIELEM_SELECTOR = "[data-ui-element]";
4
+ // Marker placed on every element a reactive binding renders into, so a removed
5
+ // subtree (or a cleared container) can be queried for affected bindings.
6
+ const BINDING_ATTR = "data-bui-binding";
7
+ const BINDING_SELECTOR = "[data-bui-binding]";
8
+ // node → UIElement auto-destroy entry
9
+ const trackedElements = new Map();
10
+ // container element → bindings rendered into it (one marker per container)
11
+ const bindingsByContainer = new Map();
12
+ let observer;
13
+ function ensureObserver() {
14
+ if (typeof MutationObserver !== "undefined" && !observer) {
15
+ observer = new MutationObserver(onMutations);
16
+ observer.observe(document, { childList: true, subtree: true });
17
+ }
18
+ }
19
+ function disconnectIfEmpty() {
20
+ if (trackedElements.size === 0 && bindingsByContainer.size === 0 && observer) {
21
+ observer.disconnect();
22
+ observer = undefined;
23
+ }
24
+ }
25
+ /**
26
+ * React only to *removed* nodes (insertions never disconnect anything). Two cases:
27
+ * - a removed element subtree → dispose the tracked UIElements/bindings inside it;
28
+ * - children removed from a surviving container (e.g. `container.innerHTML = ""`) →
29
+ * re-check the bindings rendered directly into that container.
30
+ * Work stays proportional to what changed, not to the total number tracked.
31
+ */
32
+ function onMutations(mutations) {
33
+ for (const mutation of mutations) {
34
+ mutation.removedNodes.forEach(node => {
35
+ if (node instanceof HTMLElement)
36
+ disposeDisconnectedWithin(node);
37
+ });
38
+ // A binding's managed node (a text/comment) can be removed while its container
39
+ // stays connected (a cleared/replaced container). The container itself is then
40
+ // the mutation target, not a removed node, so check its bindings here.
41
+ const target = mutation.target;
42
+ if (mutation.removedNodes.length && target instanceof HTMLElement && target.hasAttribute(BINDING_ATTR))
43
+ disposeDisconnectedBindings(target);
44
+ }
45
+ disconnectIfEmpty();
46
+ }
47
+ /** Apply `fn` to `root` itself (when it matches) and every descendant matching `selector`. */
48
+ function forEachSelfAndMatches(root, selector, fn) {
49
+ if (root.matches(selector))
50
+ fn(root);
51
+ root.querySelectorAll(selector).forEach(el => fn(el));
52
+ }
53
+ /** Destroy/stop tracked entries inside a removed subtree that are no longer in the document. */
54
+ function disposeDisconnectedWithin(removed) {
55
+ // UIElements first: destroying one cascades to its nested UIElements and bindings.
56
+ forEachSelfAndMatches(removed, UIELEM_SELECTOR, el => {
57
+ // `isConnected` guards against moves (removed from one place, re-inserted in another).
58
+ if (!el.isConnected) {
59
+ const entry = trackedElements.get(el);
60
+ if (entry)
61
+ entry.destroy(); // destroy() untracks itself, cascades, and disposes its bindings
62
+ }
63
+ });
64
+ forEachSelfAndMatches(removed, BINDING_SELECTOR, disposeDisconnectedBindings);
65
+ }
66
+ /** Stop the bindings of `container` whose managed node has left the document. */
67
+ function disposeDisconnectedBindings(container) {
68
+ const set = bindingsByContainer.get(container);
69
+ if (!set)
70
+ return;
71
+ for (const binding of [...set]) {
72
+ if (!binding.getNode().isConnected) {
73
+ set.delete(binding);
74
+ binding.effect.stop();
75
+ }
76
+ }
77
+ if (!set.size) {
78
+ bindingsByContainer.delete(container);
79
+ container.removeAttribute(BINDING_ATTR);
80
+ }
81
+ }
82
+ /** Stop and forget every binding of `container`, unconditionally (owner is being destroyed). */
83
+ function stopAllBindings(container) {
84
+ const set = bindingsByContainer.get(container);
85
+ if (!set)
86
+ return;
87
+ bindingsByContainer.delete(container);
88
+ container.removeAttribute(BINDING_ATTR);
89
+ set.forEach(binding => binding.effect.stop());
90
+ }
91
+ /**
92
+ * Track a binding so its reactive effect is stopped automatically once its managed node has
93
+ * been mounted and then removed from the document (via a shared `MutationObserver`), and so
94
+ * {@link disposeBindingsWithin} can stop it when its owning UIElement is destroyed.
95
+ *
96
+ * @param container Element the binding renders into (indexed/marked for subtree queries).
97
+ * @param getNode Returns the binding's current managed node — its connectivity drives disposal.
98
+ * @param effect The reactive effect to stop on disposal.
99
+ */
100
+ function autoDisposeBinding(container, getNode, effect) {
101
+ let set = bindingsByContainer.get(container);
102
+ if (!set) {
103
+ bindingsByContainer.set(container, set = new Set());
104
+ container.setAttribute(BINDING_ATTR, "");
105
+ }
106
+ set.add({ getNode, container, effect });
107
+ ensureObserver();
108
+ }
109
+ /**
110
+ * Register a `UIElement`'s DOM node for auto-destroy: once the node has been mounted
111
+ * into the document and then removed, `destroy` is called automatically.
112
+ * @internal — called by `UIElement.setElement`.
113
+ */
114
+ function trackAutoDestroy(node, destroy) {
115
+ trackedElements.set(node, { node, destroy });
116
+ ensureObserver();
117
+ }
118
+ /**
119
+ * Remove a node from auto-destroy tracking (called when `UIElement.destroy` is
120
+ * invoked explicitly so the entry does not linger).
121
+ * @internal — called by `UIElement.destroy`.
122
+ */
123
+ function untrackAutoDestroy(node) {
124
+ trackedElements.delete(node);
125
+ disconnectIfEmpty();
126
+ }
127
+ /**
128
+ * Destroy every tracked `UIElement` nested within `root` (excluding `root` itself),
129
+ * deepest first. Located via the `data-ui-element` marker, so the cost is proportional
130
+ * to the subtree rather than to the total number of tracked elements.
131
+ * @internal — called by `UIElement.destroy`.
132
+ */
133
+ function destroyUIElementsWithin(root) {
134
+ const victims = [];
135
+ root.querySelectorAll(UIELEM_SELECTOR).forEach(el => {
136
+ if (trackedElements.has(el))
137
+ victims.push(el);
138
+ });
139
+ // querySelectorAll yields document order (ancestors before descendants);
140
+ // iterate in reverse so deeper / nested elements are destroyed first.
141
+ for (let i = victims.length - 1; i >= 0; i--)
142
+ trackedElements.get(victims[i])?.destroy();
143
+ }
144
+ /**
145
+ * Stop and forget every tracked binding rendered within `root` (used when a UIElement is
146
+ * destroyed). Unlike the observer path this is unconditional — it does not check connectivity,
147
+ * because the owner is being torn down.
148
+ */
149
+ function disposeBindingsWithin(root) {
150
+ if (root instanceof HTMLElement)
151
+ forEachSelfAndMatches(root, BINDING_SELECTOR, stopAllBindings);
152
+ disconnectIfEmpty();
153
+ }
154
+
155
+ export { autoDisposeBinding, destroyUIElementsWithin, disposeBindingsWithin, trackAutoDestroy, untrackAutoDestroy };
156
+ //# sourceMappingURL=binding-cleanup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"binding-cleanup.js","sources":["../../../../source/dom/binding-cleanup.ts"],"sourcesContent":[null],"names":[],"mappings":"AAeA;AACA;AACA,MAAM,eAAe,GAAG,mBAAmB;AAC3C;AACA;AACA,MAAM,YAAY,GAAG,kBAAkB;AACvC,MAAM,gBAAgB,GAAG,oBAAoB;AAE7C;AACA,MAAM,eAAe,GAAG,IAAI,GAAG,EAA+B;AAC9D;AACA,MAAM,mBAAmB,GAAG,IAAI,GA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AC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE;AAC5C;AAEA;;;;AAIG;AACG,SAAU,qBAAqB,CAAC,IAAU,EAAA;IAC/C,IAAI,IAAI,YAAY,WAAW;AAC9B,QAAA,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,eAAe,CAAC;AAE/D,IAAA,iBAAiB,EAAE;AACpB;;;;"}
@@ -0,0 +1,169 @@
1
+ import helpers from './helpers.js';
2
+
3
+ /**
4
+ * Finds an element by its `id` within the whole document.
5
+ * @param id The element id to look up.
6
+ * @returns The matching element, or `null` if none exists.
7
+ */
8
+ function getById(id) {
9
+ return document.getElementById(id);
10
+ }
11
+ /**
12
+ * Returns the first descendant of `container` that has the given class.
13
+ * @param container Element to search within.
14
+ * @param className Single class name to match.
15
+ * @returns The first matching element, or `null` if none found.
16
+ */
17
+ function getByClass(container, className) {
18
+ const elements = container.getElementsByClassName(className);
19
+ if (elements.length === 0)
20
+ return null;
21
+ return elements.item(0);
22
+ }
23
+ /**
24
+ * Returns the first element in the document with the given `name` attribute.
25
+ * @param name The `name` attribute value to look up.
26
+ * @returns The first matching element, or `null` if none found.
27
+ */
28
+ function getByName(name) {
29
+ const elements = document.getElementsByName(name);
30
+ if (elements.length === 0)
31
+ return null;
32
+ return elements.item(0);
33
+ }
34
+ /**
35
+ * Returns the first descendant of `container` with the given tag name.
36
+ * @param container Element to search within.
37
+ * @param tagName Tag name to match (e.g. `"input"`).
38
+ * @returns The first matching element, or `null` if none found.
39
+ */
40
+ function getElementByTagName(container, tagName) {
41
+ const elements = container.getElementsByTagName(tagName);
42
+ if (elements.length === 0)
43
+ return null;
44
+ return elements.item(0);
45
+ }
46
+ /**
47
+ * Returns all descendants of `container` with the given tag name as a live collection.
48
+ * @param container Element to search within.
49
+ * @param tagName Tag name to match (e.g. `"li"`).
50
+ * @returns A live `HTMLCollection` of matching elements.
51
+ */
52
+ function getElementsByTagName(container, tagName) {
53
+ return container.getElementsByTagName(tagName);
54
+ }
55
+ /**
56
+ * Returns the first descendant of `container` matching the CSS selector.
57
+ * @param container Element to search within.
58
+ * @param query CSS selector.
59
+ * @returns The first matching element, or `null` if none found.
60
+ */
61
+ function queryElement(container, query) {
62
+ return container.querySelector(query);
63
+ }
64
+ /**
65
+ * Returns all descendants of `container` matching the CSS selector.
66
+ * @param container Element to search within.
67
+ * @param query CSS selector.
68
+ * @returns A static `NodeList` of matching elements.
69
+ */
70
+ function queryElements(container, query) {
71
+ return container.querySelectorAll(query);
72
+ }
73
+ /**
74
+ * Walks forward through the following siblings of `current` and returns the first one that has the given class.
75
+ * @param current Element to start from.
76
+ * @param className Class name to match.
77
+ * @returns The first matching following sibling, or `null` if none found.
78
+ */
79
+ function nextElementByClass(current, className) {
80
+ let elem = current.nextSibling;
81
+ while (elem) {
82
+ if (elem.nodeType === Node.ELEMENT_NODE && elem instanceof HTMLElement && elem.classList.contains(className))
83
+ return elem;
84
+ elem = elem.nextSibling;
85
+ }
86
+ return null;
87
+ }
88
+ /**
89
+ * Walks backward through the preceding siblings of `current` and returns the first one that has the given class.
90
+ * @param current Element to start from.
91
+ * @param className Class name to match.
92
+ * @returns The first matching preceding sibling, or `null` if none found.
93
+ */
94
+ function prevElementByClass(current, className) {
95
+ let elem = current.previousSibling;
96
+ while (elem) {
97
+ if (elem.nodeType === Node.ELEMENT_NODE && elem instanceof HTMLElement && elem.classList.contains(className))
98
+ return elem;
99
+ elem = elem.previousSibling;
100
+ }
101
+ return null;
102
+ }
103
+ /**
104
+ * Returns the nearest preceding sibling element of `current`, skipping non-element nodes (e.g. text nodes).
105
+ * @param current Element to start from.
106
+ * @returns The previous sibling element, or `null` if none found.
107
+ */
108
+ function prevElement(current) {
109
+ let elem = current.previousSibling;
110
+ while (elem) {
111
+ if (elem.nodeType === Node.ELEMENT_NODE && elem instanceof HTMLElement)
112
+ return elem;
113
+ elem = elem.previousSibling;
114
+ }
115
+ return null;
116
+ }
117
+ /**
118
+ * Returns the nearest following sibling element of `current`, skipping non-element nodes (e.g. text nodes).
119
+ * @param current Element to start from.
120
+ * @returns The next sibling element, or `null` if none found.
121
+ */
122
+ function nextElement(current) {
123
+ let elem = current.nextSibling;
124
+ while (elem) {
125
+ if (elem.nodeType === Node.ELEMENT_NODE && elem instanceof HTMLElement)
126
+ return elem;
127
+ elem = elem.nextSibling;
128
+ }
129
+ return null;
130
+ }
131
+ /**
132
+ * Adds the given CSS class(es) to every descendant of `container` matching the selector. No-op when `container` or `cssClass` is falsy.
133
+ * @param container Element to search within (ignored when null/undefined).
134
+ * @param selectors CSS selector for the elements to modify.
135
+ * @param cssClass Class name(s) to add.
136
+ */
137
+ function addClass(container, selectors, cssClass) {
138
+ if (!container || !cssClass)
139
+ return;
140
+ const nodes = container.querySelectorAll(selectors);
141
+ nodes.forEach(node => helpers.addCssClass(node, cssClass));
142
+ }
143
+ /**
144
+ * Removes the given CSS class(es) from every descendant of `container` matching the selector. No-op when `container` or `cssClass` is falsy.
145
+ * @param container Element to search within (ignored when null/undefined).
146
+ * @param selectors CSS selector for the elements to modify.
147
+ * @param cssClass Class name(s) to remove.
148
+ */
149
+ function removeClass(container, selectors, cssClass) {
150
+ if (!container || !cssClass)
151
+ return;
152
+ const nodes = container.querySelectorAll(selectors);
153
+ nodes.forEach(elem => helpers.removeCssClass(elem, cssClass));
154
+ }
155
+ /**
156
+ * Removes all child nodes from `container`, leaving it empty. No-op when `container` is null/undefined.
157
+ * @param container Element to clear.
158
+ */
159
+ function empty(container) {
160
+ if (!container)
161
+ return;
162
+ while (container.hasChildNodes()) {
163
+ if (container.firstChild)
164
+ container.removeChild(container.firstChild);
165
+ }
166
+ }
167
+
168
+ export { addClass, empty, getByClass, getById, getByName, getElementByTagName, getElementsByTagName, nextElement, nextElementByClass, prevElement, prevElementByClass, queryElement, queryElements, removeClass };
169
+ //# sourceMappingURL=dom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.js","sources":["../../../../source/dom/dom.ts"],"sourcesContent":[null],"names":[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AG,OAAO,CAAC,WAAW;IAC9B,OAAO,IAAI,EAAE;QACZ,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,IAAI,IAAI,YAAY,WAAW;AACrE,YAAA,OAAO,IAAgB;AAExB,QAAA,IAAI,GAAG,IAAI,CAAC,WAAW;IACxB;AACA,IAAA,OAAO,IAAI;AACZ;AAEA;;;;;AAKG;AACH,SAAS,QAAQ,CAAC,SAAqC,EAAE,SAAiB,EAAE,QAAkB,EAAA;AAC7F,IAAA,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ;QAC1B;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC;AACnD,IAAA,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC3D;AAEA;;;;;AAKG;AACH,SAAS,WAAW,CAAC,SAAqC,EAAE,SAAiB,EAAE,QAAkB,EAAA;AAChG,IAAA,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ;QAC1B;IAED,MAAM,KAAK,GAAG,SAAS,CAAC,gBAAgB,CAAC,SAAS,CAAC;AACnD,IAAA,KAAK,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC9D;AAEA;;;AAGG;AACH,SAAS,KAAK,CAAC,SAAqC,EAAA;AACnD,IAAA,IAAI,CAAC,SAAS;QACb;AAED,IAAA,OAAO,SAAS,CAAC,aAAa,EAAE,EAAE;QACjC,IAAI,SAAS,CAAC,UAAU;AACvB,YAAA,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,UAAU,CAAC;IAC7C;AACD;;;;"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @internal
3
+ * Adds one or more CSS classes to a single element. A string is split on spaces. No-op when `cssClass` is falsy.
4
+ */
5
+ const addCssClass = (elem, cssClass) => {
6
+ if (!cssClass)
7
+ return;
8
+ const tokens = (Array.isArray(cssClass) ? cssClass : cssClass.split(' ')).filter(Boolean);
9
+ if (tokens.length)
10
+ elem.classList.add(...tokens);
11
+ };
12
+ /**
13
+ * @internal
14
+ * Removes one or more CSS classes from a single element. A string is split on spaces. No-op when `cssClass` is falsy.
15
+ */
16
+ const removeCssClass = (elem, cssClass) => {
17
+ if (!cssClass)
18
+ return;
19
+ const tokens = (Array.isArray(cssClass) ? cssClass : cssClass.split(' ')).filter(Boolean);
20
+ if (tokens.length)
21
+ elem.classList.remove(...tokens);
22
+ };
23
+ var helpers = {
24
+ addCssClass,
25
+ removeCssClass
26
+ };
27
+
28
+ export { helpers as default };
29
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sources":["../../../../source/dom/helpers.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;AAGG;AACH,MAAM,WAAW,GAAG,CAAC,IAAa,EAAE,QAAkB,KAAI;AACzD,IAAA,IAAI,CAAC,QAAQ;QACZ;AAED,IAAA,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACzF,IAAI,MAAM,CAAC,MAAM;QAChB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;AAC/B,CAAC;AAED;;;AAGG;AACH,MAAM,cAAc,GAAG,CAAC,IAAa,EAAE,QAAkB,KAAI;AAC5D,IAAA,IAAI,CAAC,QAAQ;QACZ;AAED,IAAA,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACzF,IAAI,MAAM,CAAC,MAAM;QAChB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AAClC,CAAC;AAED,cAAe;IACd,WAAW;IACX;CACA;;;;"}
@@ -0,0 +1,12 @@
1
+ import '../reactive/effect.js';
2
+ import * as dom from './dom.js';
3
+ import * as tag from './tag.js';
4
+
5
+ /** Collection of DOM helper functions: element queries/traversal ({@link getById}, {@link queryElement}, {@link nextElement}, ...), class manipulation ({@link addClass}, {@link removeClass}), {@link empty}, and element creation via {@link tag}. */
6
+ const DOM = {
7
+ ...dom,
8
+ ...tag
9
+ };
10
+
11
+ export { DOM };
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../source/dom/index.ts"],"sourcesContent":[null],"names":["DomHelpers","TagHelpers"],"mappings":";;;;AAMA;AACO,MAAM,GAAG,GAAG;AAClB,IAAA,GAAGA,GAAU;AACb,IAAA,GAAGC;;;;;"}