@fusion.dev/helix-headless 0.241.2 → 0.241.3
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/custom-elements.json +1 -1
- package/dist/data-table/binding.d.ts +22 -0
- package/dist/data-table/binding.js +52 -7
- package/lint.json +1 -1
- package/package.json +5 -5
|
@@ -55,6 +55,12 @@ type BoundHost = ReactiveControllerHost & HTMLElement & {
|
|
|
55
55
|
*
|
|
56
56
|
* **Looked up on every read**, so a table defined after the tool, or one that
|
|
57
57
|
* replaces another under the same id, is found the next time the tool draws.
|
|
58
|
+
* **And watched for until it is there.** A tool parsed before its table, on a
|
|
59
|
+
* page whose elements are defined before the parser reaches the table, found
|
|
60
|
+
* nothing when it connected and had no reason to draw again: November 17,
|
|
61
|
+
* 2026, a Table Export written above its table read "Export 0 rows" for good.
|
|
62
|
+
* So while the id names nothing, the binding watches the tool's tree for it,
|
|
63
|
+
* and stops once it appears.
|
|
58
64
|
*
|
|
59
65
|
* **A controller on the table, and no events.** A page that sets `view` or
|
|
60
66
|
* `selected` fires nothing, and a table that leaves a column out at a narrow
|
|
@@ -67,6 +73,10 @@ export declare class TableBinding implements ReactiveController {
|
|
|
67
73
|
private heard;
|
|
68
74
|
/** Whether the tool has drawn once, after which it looks for the table. */
|
|
69
75
|
private drawn;
|
|
76
|
+
/** Watches the tool's tree while its `for` names nothing in it. */
|
|
77
|
+
private watching;
|
|
78
|
+
/** The tag the binding is waiting to see defined, so it asks once. */
|
|
79
|
+
private defining;
|
|
70
80
|
/** What the binding adds to the table it follows. */
|
|
71
81
|
private readonly watcher;
|
|
72
82
|
constructor(host: BoundHost);
|
|
@@ -79,6 +89,18 @@ export declare class TableBinding implements ReactiveController {
|
|
|
79
89
|
hostConnected(): void;
|
|
80
90
|
hostDisconnected(): void;
|
|
81
91
|
hostUpdated(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Asks the tool to draw again once the table it names is there and defined:
|
|
94
|
+
* when the id appears in its tree, and when the table's tag is defined. A
|
|
95
|
+
* table defined after the tool upgrades with no event the tool can hear.
|
|
96
|
+
*/
|
|
97
|
+
private await;
|
|
98
|
+
/**
|
|
99
|
+
* Draws the tool again once the table's tag is defined, or now where it
|
|
100
|
+
* just appeared already defined.
|
|
101
|
+
*/
|
|
102
|
+
private awaitDefined;
|
|
103
|
+
private stopWatching;
|
|
82
104
|
private listen;
|
|
83
105
|
private follow;
|
|
84
106
|
}
|
|
@@ -7,6 +7,7 @@ export class TableBinding {
|
|
|
7
7
|
this.host = host;
|
|
8
8
|
this.heard = null;
|
|
9
9
|
this.drawn = false;
|
|
10
|
+
this.defining = '';
|
|
10
11
|
this.watcher = {
|
|
11
12
|
hostUpdated: () => this.host.requestUpdate(),
|
|
12
13
|
};
|
|
@@ -26,20 +27,64 @@ export class TableBinding {
|
|
|
26
27
|
}
|
|
27
28
|
hostConnected() {
|
|
28
29
|
this.listen();
|
|
29
|
-
|
|
30
|
-
const scope = this.host.getRootNode();
|
|
31
|
-
const tag = scope.getElementById?.(this.host.for)?.localName;
|
|
32
|
-
if (tag?.includes('-')) {
|
|
33
|
-
customElements.whenDefined(tag).then(() => this.host.requestUpdate());
|
|
34
|
-
}
|
|
35
|
-
}
|
|
30
|
+
this.await();
|
|
36
31
|
}
|
|
37
32
|
hostDisconnected() {
|
|
33
|
+
this.stopWatching();
|
|
38
34
|
this.follow(null);
|
|
39
35
|
}
|
|
40
36
|
hostUpdated() {
|
|
41
37
|
this.drawn = true;
|
|
42
38
|
this.listen();
|
|
39
|
+
if (!this.heard) {
|
|
40
|
+
this.await();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
await() {
|
|
44
|
+
if (this.host.for === '' ||
|
|
45
|
+
typeof customElements === 'undefined' ||
|
|
46
|
+
typeof MutationObserver === 'undefined') {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const scope = this.host.getRootNode();
|
|
50
|
+
const target = scope.getElementById?.(this.host.for);
|
|
51
|
+
if (target) {
|
|
52
|
+
this.stopWatching();
|
|
53
|
+
this.awaitDefined(target, false);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (this.watching) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.watching = new MutationObserver(() => {
|
|
60
|
+
const found = scope.getElementById?.(this.host.for);
|
|
61
|
+
if (found) {
|
|
62
|
+
this.stopWatching();
|
|
63
|
+
this.awaitDefined(found, true);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
this.watching.observe(scope, { childList: true, subtree: true });
|
|
67
|
+
}
|
|
68
|
+
awaitDefined(target, appeared) {
|
|
69
|
+
const tag = target.localName;
|
|
70
|
+
if (!tag.includes('-') || customElements.get(tag)) {
|
|
71
|
+
if (appeared) {
|
|
72
|
+
this.host.requestUpdate();
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (this.defining === tag) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.defining = tag;
|
|
80
|
+
void customElements.whenDefined(tag).then(() => {
|
|
81
|
+
this.defining = '';
|
|
82
|
+
this.host.requestUpdate();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
stopWatching() {
|
|
86
|
+
this.watching?.disconnect();
|
|
87
|
+
this.watching = undefined;
|
|
43
88
|
}
|
|
44
89
|
listen() {
|
|
45
90
|
this.follow(this.table);
|