juxscript 1.1.239 → 1.1.243
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.js +7 -137
- package/lib/components/dataframe.ts +0 -569
- package/lib/components/tag.ts +68 -0
- package/lib/styles/shadcn.css +20 -7
- package/lib/utils/idgen.ts +6 -0
- package/package.json +5 -6
- package/index.d.ts +0 -239
- package/index.d.ts.map +0 -1
- package/lib/components/alert.d.ts +0 -36
- package/lib/components/alert.d.ts.map +0 -1
- package/lib/components/alert.js +0 -172
- package/lib/components/alert.ts +0 -219
- package/lib/components/app.d.ts +0 -89
- package/lib/components/app.d.ts.map +0 -1
- package/lib/components/app.js +0 -175
- package/lib/components/app.ts +0 -247
- package/lib/components/badge.d.ts +0 -26
- package/lib/components/badge.d.ts.map +0 -1
- package/lib/components/badge.js +0 -91
- package/lib/components/badge.ts +0 -118
- package/lib/components/base/Animations.d.ts +0 -36
- package/lib/components/base/Animations.d.ts.map +0 -1
- package/lib/components/base/Animations.js +0 -70
- package/lib/components/base/Animations.ts +0 -112
- package/lib/components/base/BaseComponent.d.ts +0 -294
- package/lib/components/base/BaseComponent.d.ts.map +0 -1
- package/lib/components/base/BaseComponent.js +0 -735
- package/lib/components/base/BaseComponent.ts +0 -884
- package/lib/components/base/FormInput.d.ts +0 -77
- package/lib/components/base/FormInput.d.ts.map +0 -1
- package/lib/components/base/FormInput.js +0 -171
- package/lib/components/base/FormInput.ts +0 -237
- package/lib/components/blueprint.d.ts +0 -40
- package/lib/components/blueprint.d.ts.map +0 -1
- package/lib/components/blueprint.js +0 -327
- package/lib/components/button.d.ts +0 -70
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js +0 -177
- package/lib/components/button.ts +0 -237
- package/lib/components/card.d.ts +0 -35
- package/lib/components/card.d.ts.map +0 -1
- package/lib/components/card.js +0 -130
- package/lib/components/card.ts +0 -177
- package/lib/components/chart.d.ts +0 -49
- package/lib/components/chart.d.ts.map +0 -1
- package/lib/components/chart.js +0 -205
- package/lib/components/chart.ts +0 -254
- package/lib/components/checkbox.d.ts +0 -33
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js +0 -202
- package/lib/components/checkbox.ts +0 -260
- package/lib/components/code.d.ts +0 -52
- package/lib/components/code.d.ts.map +0 -1
- package/lib/components/code.js +0 -201
- package/lib/components/code.ts +0 -260
- package/lib/components/container.d.ts +0 -60
- package/lib/components/container.d.ts.map +0 -1
- package/lib/components/container.js +0 -195
- package/lib/components/container.ts +0 -259
- package/lib/components/data.d.ts +0 -36
- package/lib/components/data.d.ts.map +0 -1
- package/lib/components/data.js +0 -110
- package/lib/components/data.ts +0 -135
- package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
- package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
- package/lib/components/dataframe/DataFrameSource.js +0 -421
- package/lib/components/dataframe/DataFrameSource.ts +0 -532
- package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
- package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
- package/lib/components/dataframe/ImportSettingsModal.js +0 -442
- package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
- package/lib/components/dataframe.d.ts +0 -110
- package/lib/components/dataframe.d.ts.map +0 -1
- package/lib/components/dataframe.js +0 -470
- package/lib/components/datepicker.d.ts +0 -40
- package/lib/components/datepicker.d.ts.map +0 -1
- package/lib/components/datepicker.js +0 -193
- package/lib/components/datepicker.ts +0 -251
- package/lib/components/dialog.d.ts +0 -39
- package/lib/components/dialog.d.ts.map +0 -1
- package/lib/components/dialog.js +0 -131
- package/lib/components/dialog.ts +0 -178
- package/lib/components/divider.d.ts +0 -31
- package/lib/components/divider.d.ts.map +0 -1
- package/lib/components/divider.js +0 -72
- package/lib/components/divider.ts +0 -104
- package/lib/components/dropdown-menu.d.ts +0 -42
- package/lib/components/dropdown-menu.d.ts.map +0 -1
- package/lib/components/dropdown-menu.js +0 -177
- package/lib/components/dropdown-menu.ts +0 -214
- package/lib/components/dropdown.d.ts +0 -41
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -136
- package/lib/components/dropdown.ts +0 -188
- package/lib/components/element.d.ts +0 -51
- package/lib/components/element.d.ts.map +0 -1
- package/lib/components/element.js +0 -209
- package/lib/components/element.ts +0 -271
- package/lib/components/event-chain.d.ts +0 -9
- package/lib/components/event-chain.d.ts.map +0 -1
- package/lib/components/event-chain.js +0 -33
- package/lib/components/fileupload.d.ts +0 -98
- package/lib/components/fileupload.d.ts.map +0 -1
- package/lib/components/fileupload.js +0 -351
- package/lib/components/fileupload.ts +0 -449
- package/lib/components/grid.d.ts +0 -88
- package/lib/components/grid.d.ts.map +0 -1
- package/lib/components/grid.js +0 -208
- package/lib/components/grid.ts +0 -295
- package/lib/components/heading.d.ts +0 -25
- package/lib/components/heading.d.ts.map +0 -1
- package/lib/components/heading.js +0 -83
- package/lib/components/heading.ts +0 -113
- package/lib/components/helpers.d.ts +0 -9
- package/lib/components/helpers.d.ts.map +0 -1
- package/lib/components/helpers.js +0 -30
- package/lib/components/helpers.ts +0 -41
- package/lib/components/hero.d.ts +0 -60
- package/lib/components/hero.d.ts.map +0 -1
- package/lib/components/hero.js +0 -239
- package/lib/components/hero.ts +0 -302
- package/lib/components/history/StateHistory.d.ts +0 -91
- package/lib/components/history/StateHistory.d.ts.map +0 -1
- package/lib/components/history/StateHistory.js +0 -154
- package/lib/components/history/StateHistory.ts +0 -200
- package/lib/components/icon.d.ts +0 -36
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js +0 -135
- package/lib/components/icon.ts +0 -182
- package/lib/components/icons.d.ts +0 -25
- package/lib/components/icons.d.ts.map +0 -1
- package/lib/components/icons.js +0 -440
- package/lib/components/icons.ts +0 -464
- package/lib/components/image.d.ts +0 -42
- package/lib/components/image.d.ts.map +0 -1
- package/lib/components/image.js +0 -204
- package/lib/components/image.ts +0 -260
- package/lib/components/include.d.ts +0 -86
- package/lib/components/include.d.ts.map +0 -1
- package/lib/components/include.js +0 -238
- package/lib/components/include.ts +0 -281
- package/lib/components/input.d.ts +0 -85
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js +0 -362
- package/lib/components/input.ts +0 -473
- package/lib/components/layer.d.ts +0 -72
- package/lib/components/layer.d.ts.map +0 -1
- package/lib/components/layer.js +0 -219
- package/lib/components/layer.ts +0 -304
- package/lib/components/link.d.ts +0 -41
- package/lib/components/link.d.ts.map +0 -1
- package/lib/components/link.js +0 -216
- package/lib/components/link.ts +0 -268
- package/lib/components/list.d.ts +0 -83
- package/lib/components/list.d.ts.map +0 -1
- package/lib/components/list.js +0 -314
- package/lib/components/list.ts +0 -423
- package/lib/components/loading.d.ts +0 -25
- package/lib/components/loading.d.ts.map +0 -1
- package/lib/components/loading.js +0 -76
- package/lib/components/loading.ts +0 -104
- package/lib/components/menu.d.ts +0 -38
- package/lib/components/menu.d.ts.map +0 -1
- package/lib/components/menu.js +0 -205
- package/lib/components/menu.ts +0 -279
- package/lib/components/modal.d.ts +0 -97
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js +0 -463
- package/lib/components/modal.ts +0 -576
- package/lib/components/nav.d.ts +0 -46
- package/lib/components/nav.d.ts.map +0 -1
- package/lib/components/nav.js +0 -193
- package/lib/components/nav.ts +0 -261
- package/lib/components/paragraph.d.ts +0 -30
- package/lib/components/paragraph.d.ts.map +0 -1
- package/lib/components/paragraph.js +0 -93
- package/lib/components/paragraph.ts +0 -123
- package/lib/components/pen.d.ts +0 -125
- package/lib/components/pen.d.ts.map +0 -1
- package/lib/components/pen.js +0 -443
- package/lib/components/pen.ts +0 -567
- package/lib/components/progress.d.ts +0 -40
- package/lib/components/progress.d.ts.map +0 -1
- package/lib/components/progress.js +0 -116
- package/lib/components/progress.ts +0 -163
- package/lib/components/radio.d.ts +0 -43
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js +0 -226
- package/lib/components/radio.ts +0 -303
- package/lib/components/registry.d.ts +0 -34
- package/lib/components/registry.d.ts.map +0 -1
- package/lib/components/registry.js +0 -163
- package/lib/components/registry.ts +0 -193
- package/lib/components/req.d.ts +0 -155
- package/lib/components/req.d.ts.map +0 -1
- package/lib/components/req.js +0 -253
- package/lib/components/req.ts +0 -303
- package/lib/components/script.d.ts +0 -14
- package/lib/components/script.d.ts.map +0 -1
- package/lib/components/script.js +0 -33
- package/lib/components/script.ts +0 -41
- package/lib/components/select.d.ts +0 -42
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js +0 -209
- package/lib/components/select.ts +0 -281
- package/lib/components/sidebar.d.ts +0 -59
- package/lib/components/sidebar.d.ts.map +0 -1
- package/lib/components/sidebar.js +0 -298
- package/lib/components/sidebar.ts +0 -395
- package/lib/components/stack/BaseStack.d.ts +0 -65
- package/lib/components/stack/BaseStack.d.ts.map +0 -1
- package/lib/components/stack/BaseStack.js +0 -274
- package/lib/components/stack/BaseStack.ts +0 -328
- package/lib/components/stack/HStack.d.ts +0 -18
- package/lib/components/stack/HStack.d.ts.map +0 -1
- package/lib/components/stack/HStack.js +0 -22
- package/lib/components/stack/HStack.ts +0 -25
- package/lib/components/stack/VStack.d.ts +0 -19
- package/lib/components/stack/VStack.d.ts.map +0 -1
- package/lib/components/stack/VStack.js +0 -23
- package/lib/components/stack/VStack.ts +0 -26
- package/lib/components/stack/ZStack.d.ts +0 -18
- package/lib/components/stack/ZStack.d.ts.map +0 -1
- package/lib/components/stack/ZStack.js +0 -22
- package/lib/components/stack/ZStack.ts +0 -25
- package/lib/components/style.d.ts +0 -14
- package/lib/components/style.d.ts.map +0 -1
- package/lib/components/style.js +0 -33
- package/lib/components/style.ts +0 -41
- package/lib/components/switch.d.ts +0 -34
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js +0 -209
- package/lib/components/switch.ts +0 -272
- package/lib/components/table.d.ts +0 -137
- package/lib/components/table.d.ts.map +0 -1
- package/lib/components/table.js +0 -1019
- package/lib/components/table.ts +0 -1225
- package/lib/components/tabs.d.ts +0 -53
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js +0 -275
- package/lib/components/tabs.ts +0 -349
- package/lib/components/theme-toggle.d.ts +0 -45
- package/lib/components/theme-toggle.d.ts.map +0 -1
- package/lib/components/theme-toggle.js +0 -218
- package/lib/components/theme-toggle.ts +0 -297
- package/lib/components/tooltip.d.ts +0 -31
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js +0 -112
- package/lib/components/tooltip.ts +0 -148
- package/lib/components/watcher.d.ts +0 -195
- package/lib/components/watcher.d.ts.map +0 -1
- package/lib/components/watcher.js +0 -241
- package/lib/components/watcher.ts +0 -261
- package/lib/components/write.d.ts +0 -107
- package/lib/components/write.d.ts.map +0 -1
- package/lib/components/write.js +0 -222
- package/lib/components/write.ts +0 -272
- package/lib/data/DataPipeline.d.ts +0 -113
- package/lib/data/DataPipeline.d.ts.map +0 -1
- package/lib/data/DataPipeline.js +0 -359
- package/lib/data/DataPipeline.ts +0 -452
- package/lib/facades/dataframe.jux +0 -0
- package/lib/globals.d.ts +0 -21
- package/lib/reactivity/state.d.ts +0 -36
- package/lib/reactivity/state.d.ts.map +0 -1
- package/lib/reactivity/state.js +0 -67
- package/lib/reactivity/state.ts +0 -78
- package/lib/storage/DataFrame.d.ts +0 -284
- package/lib/storage/DataFrame.d.ts.map +0 -1
- package/lib/storage/DataFrame.js +0 -1022
- package/lib/storage/DataFrame.ts +0 -1195
- package/lib/storage/DataFrameSource.d.ts +0 -158
- package/lib/storage/DataFrameSource.d.ts.map +0 -1
- package/lib/storage/DataFrameSource.js +0 -409
- package/lib/storage/DataFrameSource.ts +0 -556
- package/lib/storage/FileStorage.d.ts +0 -53
- package/lib/storage/FileStorage.d.ts.map +0 -1
- package/lib/storage/FileStorage.js +0 -80
- package/lib/storage/FileStorage.ts +0 -95
- package/lib/storage/IndexedDBDriver.d.ts +0 -75
- package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
- package/lib/storage/IndexedDBDriver.js +0 -177
- package/lib/storage/IndexedDBDriver.ts +0 -226
- package/lib/storage/TabularDriver.d.ts +0 -118
- package/lib/storage/TabularDriver.d.ts.map +0 -1
- package/lib/storage/TabularDriver.js +0 -731
- package/lib/storage/TabularDriver.ts +0 -874
- package/lib/utils/codeparser.d.ts +0 -29
- package/lib/utils/codeparser.d.ts.map +0 -1
- package/lib/utils/codeparser.js +0 -409
- package/lib/utils/fetch.d.ts +0 -176
- package/lib/utils/fetch.d.ts.map +0 -1
- package/lib/utils/fetch.js +0 -427
- package/lib/utils/formatId.d.ts +0 -16
- package/lib/utils/formatId.d.ts.map +0 -1
- package/lib/utils/formatId.js +0 -27
- package/lib/utils/path-resolver.js +0 -23
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
// Event definitions
|
|
3
|
-
const TRIGGER_EVENTS = [];
|
|
4
|
-
const CALLBACK_EVENTS = [];
|
|
5
|
-
export class Tooltip extends BaseComponent {
|
|
6
|
-
constructor(id, options = {}) {
|
|
7
|
-
super(id, {
|
|
8
|
-
text: options.text ?? '',
|
|
9
|
-
position: options.position ?? 'top',
|
|
10
|
-
style: options.style ?? '',
|
|
11
|
-
class: options.class ?? ''
|
|
12
|
-
});
|
|
13
|
-
this._tooltip = null;
|
|
14
|
-
this._target = null;
|
|
15
|
-
}
|
|
16
|
-
getTriggerEvents() {
|
|
17
|
-
return TRIGGER_EVENTS;
|
|
18
|
-
}
|
|
19
|
-
getCallbackEvents() {
|
|
20
|
-
return CALLBACK_EVENTS;
|
|
21
|
-
}
|
|
22
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
23
|
-
* FLUENT API
|
|
24
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
25
|
-
text(value) {
|
|
26
|
-
this.state.text = value;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
position(value) {
|
|
30
|
-
this.state.position = value;
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
attachTo(target) {
|
|
34
|
-
if (!target)
|
|
35
|
-
return this;
|
|
36
|
-
this._target = target;
|
|
37
|
-
this._setupTooltip();
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
41
|
-
* RENDER
|
|
42
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
43
|
-
_setupTooltip() {
|
|
44
|
-
if (!this._target)
|
|
45
|
-
return;
|
|
46
|
-
const { text, position, style, class: className } = this.state;
|
|
47
|
-
// Create tooltip element
|
|
48
|
-
const tooltip = document.createElement('div');
|
|
49
|
-
tooltip.className = `jux-tooltip jux-tooltip-${position}`;
|
|
50
|
-
tooltip.id = this._id;
|
|
51
|
-
if (className)
|
|
52
|
-
tooltip.className += ` ${className}`;
|
|
53
|
-
if (style)
|
|
54
|
-
tooltip.setAttribute('style', style);
|
|
55
|
-
tooltip.textContent = text;
|
|
56
|
-
tooltip.style.display = 'none';
|
|
57
|
-
this._tooltip = tooltip;
|
|
58
|
-
document.body.appendChild(tooltip);
|
|
59
|
-
// Show on hover
|
|
60
|
-
this._target.addEventListener('mouseenter', () => {
|
|
61
|
-
this._show();
|
|
62
|
-
});
|
|
63
|
-
this._target.addEventListener('mouseleave', () => {
|
|
64
|
-
this._hide();
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
_show() {
|
|
68
|
-
if (!this._tooltip || !this._target)
|
|
69
|
-
return;
|
|
70
|
-
const targetRect = this._target.getBoundingClientRect();
|
|
71
|
-
const tooltipRect = this._tooltip.getBoundingClientRect();
|
|
72
|
-
let top = 0;
|
|
73
|
-
let left = 0;
|
|
74
|
-
switch (this.state.position) {
|
|
75
|
-
case 'top':
|
|
76
|
-
top = targetRect.top - tooltipRect.height - 8;
|
|
77
|
-
left = targetRect.left + (targetRect.width - tooltipRect.width) / 2;
|
|
78
|
-
break;
|
|
79
|
-
case 'bottom':
|
|
80
|
-
top = targetRect.bottom + 8;
|
|
81
|
-
left = targetRect.left + (targetRect.width - tooltipRect.width) / 2;
|
|
82
|
-
break;
|
|
83
|
-
case 'left':
|
|
84
|
-
top = targetRect.top + (targetRect.height - tooltipRect.height) / 2;
|
|
85
|
-
left = targetRect.left - tooltipRect.width - 8;
|
|
86
|
-
break;
|
|
87
|
-
case 'right':
|
|
88
|
-
top = targetRect.top + (targetRect.height - tooltipRect.height) / 2;
|
|
89
|
-
left = targetRect.right + 8;
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
this._tooltip.style.top = `${top}px`;
|
|
93
|
-
this._tooltip.style.left = `${left}px`;
|
|
94
|
-
this._tooltip.style.display = 'block';
|
|
95
|
-
}
|
|
96
|
-
_hide() {
|
|
97
|
-
if (this._tooltip) {
|
|
98
|
-
this._tooltip.style.display = 'none';
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
render(targetId) {
|
|
102
|
-
// Tooltips don't render to containers, they attach to targets
|
|
103
|
-
console.warn('Tooltip: Use .attachTo(element) instead of .render()');
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
update(prop, value) {
|
|
107
|
-
// No reactive updates needed
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export function tooltip(id, options = {}) {
|
|
111
|
-
return new Tooltip(id, options);
|
|
112
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [] as const;
|
|
5
|
-
const CALLBACK_EVENTS = [] as const;
|
|
6
|
-
|
|
7
|
-
export interface TooltipOptions {
|
|
8
|
-
text?: string;
|
|
9
|
-
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
10
|
-
style?: string;
|
|
11
|
-
class?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
type TooltipState = {
|
|
15
|
-
text: string;
|
|
16
|
-
position: string;
|
|
17
|
-
style: string;
|
|
18
|
-
class: string;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export class Tooltip extends BaseComponent<TooltipState> {
|
|
22
|
-
private _tooltip: HTMLElement | null = null;
|
|
23
|
-
private _target: HTMLElement | null = null;
|
|
24
|
-
|
|
25
|
-
constructor(id: string, options: TooltipOptions = {}) {
|
|
26
|
-
super(id, {
|
|
27
|
-
text: options.text ?? '',
|
|
28
|
-
position: options.position ?? 'top',
|
|
29
|
-
style: options.style ?? '',
|
|
30
|
-
class: options.class ?? ''
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
protected getTriggerEvents(): readonly string[] {
|
|
35
|
-
return TRIGGER_EVENTS;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected getCallbackEvents(): readonly string[] {
|
|
39
|
-
return CALLBACK_EVENTS;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
43
|
-
* FLUENT API
|
|
44
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
45
|
-
|
|
46
|
-
text(value: string): this {
|
|
47
|
-
this.state.text = value;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
position(value: 'top' | 'bottom' | 'left' | 'right'): this {
|
|
52
|
-
this.state.position = value;
|
|
53
|
-
return this;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
attachTo(target: HTMLElement | null): this {
|
|
57
|
-
if (!target) return this;
|
|
58
|
-
|
|
59
|
-
this._target = target;
|
|
60
|
-
this._setupTooltip();
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
65
|
-
* RENDER
|
|
66
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
67
|
-
|
|
68
|
-
private _setupTooltip(): void {
|
|
69
|
-
if (!this._target) return;
|
|
70
|
-
|
|
71
|
-
const { text, position, style, class: className } = this.state;
|
|
72
|
-
|
|
73
|
-
// Create tooltip element
|
|
74
|
-
const tooltip = document.createElement('div');
|
|
75
|
-
tooltip.className = `jux-tooltip jux-tooltip-${position}`;
|
|
76
|
-
tooltip.id = this._id;
|
|
77
|
-
if (className) tooltip.className += ` ${className}`;
|
|
78
|
-
if (style) tooltip.setAttribute('style', style);
|
|
79
|
-
tooltip.textContent = text;
|
|
80
|
-
tooltip.style.display = 'none';
|
|
81
|
-
this._tooltip = tooltip;
|
|
82
|
-
|
|
83
|
-
document.body.appendChild(tooltip);
|
|
84
|
-
|
|
85
|
-
// Show on hover
|
|
86
|
-
this._target.addEventListener('mouseenter', () => {
|
|
87
|
-
this._show();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this._target.addEventListener('mouseleave', () => {
|
|
91
|
-
this._hide();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
private _show(): void {
|
|
97
|
-
if (!this._tooltip || !this._target) return;
|
|
98
|
-
|
|
99
|
-
const targetRect = this._target.getBoundingClientRect();
|
|
100
|
-
const tooltipRect = this._tooltip.getBoundingClientRect();
|
|
101
|
-
|
|
102
|
-
let top = 0;
|
|
103
|
-
let left = 0;
|
|
104
|
-
|
|
105
|
-
switch (this.state.position) {
|
|
106
|
-
case 'top':
|
|
107
|
-
top = targetRect.top - tooltipRect.height - 8;
|
|
108
|
-
left = targetRect.left + (targetRect.width - tooltipRect.width) / 2;
|
|
109
|
-
break;
|
|
110
|
-
case 'bottom':
|
|
111
|
-
top = targetRect.bottom + 8;
|
|
112
|
-
left = targetRect.left + (targetRect.width - tooltipRect.width) / 2;
|
|
113
|
-
break;
|
|
114
|
-
case 'left':
|
|
115
|
-
top = targetRect.top + (targetRect.height - tooltipRect.height) / 2;
|
|
116
|
-
left = targetRect.left - tooltipRect.width - 8;
|
|
117
|
-
break;
|
|
118
|
-
case 'right':
|
|
119
|
-
top = targetRect.top + (targetRect.height - tooltipRect.height) / 2;
|
|
120
|
-
left = targetRect.right + 8;
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
this._tooltip.style.top = `${top}px`;
|
|
125
|
-
this._tooltip.style.left = `${left}px`;
|
|
126
|
-
this._tooltip.style.display = 'block';
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
private _hide(): void {
|
|
130
|
-
if (this._tooltip) {
|
|
131
|
-
this._tooltip.style.display = 'none';
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this {
|
|
136
|
-
// Tooltips don't render to containers, they attach to targets
|
|
137
|
-
console.warn('Tooltip: Use .attachTo(element) instead of .render()');
|
|
138
|
-
return this;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
update(prop: string, value: any): void {
|
|
142
|
-
// No reactive updates needed
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export function tooltip(id: string, options: TooltipOptions = {}): Tooltip {
|
|
147
|
-
return new Tooltip(id, options);
|
|
148
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from "./base/BaseComponent.js";
|
|
2
|
-
/**
|
|
3
|
-
* 🔍 WATCHER - Simple Component Observer
|
|
4
|
-
*
|
|
5
|
-
* Watches JUX components and fires callbacks when their state changes.
|
|
6
|
-
* Think of it as a "subscribe to component updates" utility.
|
|
7
|
-
*
|
|
8
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
9
|
-
* BASIC USAGE
|
|
10
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
11
|
-
*
|
|
12
|
-
* ```javascript
|
|
13
|
-
* import { input, paragraph, watcher } from 'juxscript';
|
|
14
|
-
*
|
|
15
|
-
* const nameInput = input('name').render('app');
|
|
16
|
-
* const greeting = paragraph('greeting').render('app');
|
|
17
|
-
*
|
|
18
|
-
* // Watch nameInput and update greeting whenever it changes
|
|
19
|
-
* watcher('name-watcher')
|
|
20
|
-
* .watch(nameInput, () => {
|
|
21
|
-
* greeting.text(`Hello, ${nameInput.getValue()}!`);
|
|
22
|
-
* });
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
26
|
-
* MULTIPLE COMPONENTS
|
|
27
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
28
|
-
*
|
|
29
|
-
* ```javascript
|
|
30
|
-
* const firstNameInput = input('firstName').render();
|
|
31
|
-
* const lastNameInput = input('lastName').render();
|
|
32
|
-
* const fullName = paragraph('fullName').render();
|
|
33
|
-
*
|
|
34
|
-
* const formWatcher = watcher('form');
|
|
35
|
-
*
|
|
36
|
-
* // Watch both inputs, same callback
|
|
37
|
-
* formWatcher
|
|
38
|
-
* .watch(firstNameInput, updateFullName)
|
|
39
|
-
* .watch(lastNameInput, updateFullName);
|
|
40
|
-
*
|
|
41
|
-
* function updateFullName() {
|
|
42
|
-
* const first = firstNameInput.getValue();
|
|
43
|
-
* const last = lastNameInput.getValue();
|
|
44
|
-
* fullName.text(`${first} ${last}`.trim());
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
49
|
-
* DECLARATIVE STYLE - Watch Many, Do One Thing
|
|
50
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
51
|
-
*
|
|
52
|
-
* ```javascript
|
|
53
|
-
* const price = input('price').render();
|
|
54
|
-
* const quantity = input('quantity').render();
|
|
55
|
-
* const discount = input('discount').render();
|
|
56
|
-
* const total = paragraph('total').render();
|
|
57
|
-
*
|
|
58
|
-
* // Update total whenever ANY input changes
|
|
59
|
-
* watcher('calculator')
|
|
60
|
-
* .watchMany([price, quantity, discount], () => {
|
|
61
|
-
* const p = parseFloat(price.getValue()) || 0;
|
|
62
|
-
* const q = parseInt(quantity.getValue()) || 0;
|
|
63
|
-
* const d = parseFloat(discount.getValue()) || 0;
|
|
64
|
-
*
|
|
65
|
-
* const subtotal = p * q;
|
|
66
|
-
* const finalTotal = subtotal - (subtotal * d / 100);
|
|
67
|
-
*
|
|
68
|
-
* total.text(`Total: $${finalTotal.toFixed(2)}`);
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
73
|
-
* STOP WATCHING
|
|
74
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
75
|
-
*
|
|
76
|
-
* ```javascript
|
|
77
|
-
* const myWatcher = watcher('temp');
|
|
78
|
-
* const myInput = input('field').render();
|
|
79
|
-
*
|
|
80
|
-
* const myCallback = () => console.log('Changed!');
|
|
81
|
-
*
|
|
82
|
-
* myWatcher.watch(myInput, myCallback);
|
|
83
|
-
*
|
|
84
|
-
* // Later: stop watching
|
|
85
|
-
* myWatcher.unwatch(myInput, myCallback);
|
|
86
|
-
*
|
|
87
|
-
* // Or stop watching ALL callbacks for this component
|
|
88
|
-
* myWatcher.unwatchAll(myInput);
|
|
89
|
-
*
|
|
90
|
-
* // Or clear everything
|
|
91
|
-
* myWatcher.clear();
|
|
92
|
-
* ```
|
|
93
|
-
*
|
|
94
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
95
|
-
* HOW IT WORKS
|
|
96
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
97
|
-
*
|
|
98
|
-
* 1. Watcher stores callbacks keyed by component._id
|
|
99
|
-
* 2. Component's Proxy detects state changes
|
|
100
|
-
* 3. Component calls watcher.notify(component) [if integrated]
|
|
101
|
-
* 4. Watcher runs all registered callbacks for that component
|
|
102
|
-
*
|
|
103
|
-
* Current limitation: Manual notification required. To auto-notify:
|
|
104
|
-
*
|
|
105
|
-
* ```javascript
|
|
106
|
-
* // In your component after state change:
|
|
107
|
-
* this._notifyWatchers();
|
|
108
|
-
* ```
|
|
109
|
-
*
|
|
110
|
-
* Or integrate into BaseComponent.update():
|
|
111
|
-
*
|
|
112
|
-
* ```typescript
|
|
113
|
-
* update(prop: string, value: any): void {
|
|
114
|
-
* // ...existing update logic...
|
|
115
|
-
* this._watchers.forEach(w => w.notify(this));
|
|
116
|
-
* }
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
export declare class Watcher {
|
|
120
|
-
private _id;
|
|
121
|
-
private _callbacks;
|
|
122
|
-
constructor(id: string);
|
|
123
|
-
/**
|
|
124
|
-
* Watch a component and run callback when it changes
|
|
125
|
-
*
|
|
126
|
-
* @param component - Component to watch
|
|
127
|
-
* @param callback - Function to run on change
|
|
128
|
-
* @returns this (for chaining)
|
|
129
|
-
*/
|
|
130
|
-
watch(component: BaseComponent<any>, callback: Function): this;
|
|
131
|
-
/**
|
|
132
|
-
* Watch multiple components with the same callback
|
|
133
|
-
*
|
|
134
|
-
* @param components - Array of components to watch
|
|
135
|
-
* @param callback - Function to run when ANY of them change
|
|
136
|
-
* @returns this (for chaining)
|
|
137
|
-
*/
|
|
138
|
-
watchMany(components: BaseComponent<any>[], callback: Function): this;
|
|
139
|
-
/**
|
|
140
|
-
* Stop watching a component (remove specific callback)
|
|
141
|
-
*
|
|
142
|
-
* @param component - Component to stop watching
|
|
143
|
-
* @param callback - Specific callback to remove
|
|
144
|
-
* @returns this (for chaining)
|
|
145
|
-
*/
|
|
146
|
-
unwatch(component: BaseComponent<any>, callback: Function): this;
|
|
147
|
-
/**
|
|
148
|
-
* Stop watching a component (remove ALL callbacks)
|
|
149
|
-
*
|
|
150
|
-
* @param component - Component to stop watching completely
|
|
151
|
-
* @returns this (for chaining)
|
|
152
|
-
*/
|
|
153
|
-
unwatchAll(component: BaseComponent<any>): this;
|
|
154
|
-
/**
|
|
155
|
-
* Notify all callbacks for a component (call this when component changes)
|
|
156
|
-
*
|
|
157
|
-
* @param component - Component that changed
|
|
158
|
-
* @param args - Optional arguments to pass to callbacks
|
|
159
|
-
*/
|
|
160
|
-
notify(component: BaseComponent<any>, ...args: any[]): void;
|
|
161
|
-
/**
|
|
162
|
-
* Clear all watched components and callbacks
|
|
163
|
-
*
|
|
164
|
-
* @returns this (for chaining)
|
|
165
|
-
*/
|
|
166
|
-
clear(): this;
|
|
167
|
-
/**
|
|
168
|
-
* Get list of component IDs being watched
|
|
169
|
-
*
|
|
170
|
-
* @returns Array of component IDs
|
|
171
|
-
*/
|
|
172
|
-
getWatchedIds(): string[];
|
|
173
|
-
/**
|
|
174
|
-
* Get count of callbacks for a component
|
|
175
|
-
*
|
|
176
|
-
* @param component - Component to check
|
|
177
|
-
* @returns Number of callbacks registered
|
|
178
|
-
*/
|
|
179
|
-
getCallbackCount(component: BaseComponent<any>): number;
|
|
180
|
-
/**
|
|
181
|
-
* Check if watching a component
|
|
182
|
-
*
|
|
183
|
-
* @param component - Component to check
|
|
184
|
-
* @returns true if watching this component
|
|
185
|
-
*/
|
|
186
|
-
isWatching(component: BaseComponent<any>): boolean;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Create a new watcher instance
|
|
190
|
-
*
|
|
191
|
-
* @param id - Unique identifier for this watcher
|
|
192
|
-
* @returns New Watcher instance
|
|
193
|
-
*/
|
|
194
|
-
export declare function watcher(id: string): Watcher;
|
|
195
|
-
//# sourceMappingURL=watcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["watcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoHG;AAEH,qBAAa,OAAO;IAChB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,UAAU,CAAyC;gBAE/C,EAAE,EAAE,MAAM;IAItB;;;;;;OAMG;IACH,KAAK,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAW9D;;;;;;OAMG;IACH,SAAS,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAKrE;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAgBhE;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IAK/C;;;;;OAKG;IACH,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAc3D;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAKb;;;;OAIG;IACH,aAAa,IAAI,MAAM,EAAE;IAIzB;;;;;OAKG;IACH,gBAAgB,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,MAAM;IAIvD;;;;;OAKG;IACH,UAAU,CAAC,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,GAAG,OAAO;CAGrD;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE3C"}
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🔍 WATCHER - Simple Component Observer
|
|
3
|
-
*
|
|
4
|
-
* Watches JUX components and fires callbacks when their state changes.
|
|
5
|
-
* Think of it as a "subscribe to component updates" utility.
|
|
6
|
-
*
|
|
7
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
8
|
-
* BASIC USAGE
|
|
9
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
10
|
-
*
|
|
11
|
-
* ```javascript
|
|
12
|
-
* import { input, paragraph, watcher } from 'juxscript';
|
|
13
|
-
*
|
|
14
|
-
* const nameInput = input('name').render('app');
|
|
15
|
-
* const greeting = paragraph('greeting').render('app');
|
|
16
|
-
*
|
|
17
|
-
* // Watch nameInput and update greeting whenever it changes
|
|
18
|
-
* watcher('name-watcher')
|
|
19
|
-
* .watch(nameInput, () => {
|
|
20
|
-
* greeting.text(`Hello, ${nameInput.getValue()}!`);
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
25
|
-
* MULTIPLE COMPONENTS
|
|
26
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
27
|
-
*
|
|
28
|
-
* ```javascript
|
|
29
|
-
* const firstNameInput = input('firstName').render();
|
|
30
|
-
* const lastNameInput = input('lastName').render();
|
|
31
|
-
* const fullName = paragraph('fullName').render();
|
|
32
|
-
*
|
|
33
|
-
* const formWatcher = watcher('form');
|
|
34
|
-
*
|
|
35
|
-
* // Watch both inputs, same callback
|
|
36
|
-
* formWatcher
|
|
37
|
-
* .watch(firstNameInput, updateFullName)
|
|
38
|
-
* .watch(lastNameInput, updateFullName);
|
|
39
|
-
*
|
|
40
|
-
* function updateFullName() {
|
|
41
|
-
* const first = firstNameInput.getValue();
|
|
42
|
-
* const last = lastNameInput.getValue();
|
|
43
|
-
* fullName.text(`${first} ${last}`.trim());
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
48
|
-
* DECLARATIVE STYLE - Watch Many, Do One Thing
|
|
49
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
50
|
-
*
|
|
51
|
-
* ```javascript
|
|
52
|
-
* const price = input('price').render();
|
|
53
|
-
* const quantity = input('quantity').render();
|
|
54
|
-
* const discount = input('discount').render();
|
|
55
|
-
* const total = paragraph('total').render();
|
|
56
|
-
*
|
|
57
|
-
* // Update total whenever ANY input changes
|
|
58
|
-
* watcher('calculator')
|
|
59
|
-
* .watchMany([price, quantity, discount], () => {
|
|
60
|
-
* const p = parseFloat(price.getValue()) || 0;
|
|
61
|
-
* const q = parseInt(quantity.getValue()) || 0;
|
|
62
|
-
* const d = parseFloat(discount.getValue()) || 0;
|
|
63
|
-
*
|
|
64
|
-
* const subtotal = p * q;
|
|
65
|
-
* const finalTotal = subtotal - (subtotal * d / 100);
|
|
66
|
-
*
|
|
67
|
-
* total.text(`Total: $${finalTotal.toFixed(2)}`);
|
|
68
|
-
* });
|
|
69
|
-
* ```
|
|
70
|
-
*
|
|
71
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
72
|
-
* STOP WATCHING
|
|
73
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
74
|
-
*
|
|
75
|
-
* ```javascript
|
|
76
|
-
* const myWatcher = watcher('temp');
|
|
77
|
-
* const myInput = input('field').render();
|
|
78
|
-
*
|
|
79
|
-
* const myCallback = () => console.log('Changed!');
|
|
80
|
-
*
|
|
81
|
-
* myWatcher.watch(myInput, myCallback);
|
|
82
|
-
*
|
|
83
|
-
* // Later: stop watching
|
|
84
|
-
* myWatcher.unwatch(myInput, myCallback);
|
|
85
|
-
*
|
|
86
|
-
* // Or stop watching ALL callbacks for this component
|
|
87
|
-
* myWatcher.unwatchAll(myInput);
|
|
88
|
-
*
|
|
89
|
-
* // Or clear everything
|
|
90
|
-
* myWatcher.clear();
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
94
|
-
* HOW IT WORKS
|
|
95
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
96
|
-
*
|
|
97
|
-
* 1. Watcher stores callbacks keyed by component._id
|
|
98
|
-
* 2. Component's Proxy detects state changes
|
|
99
|
-
* 3. Component calls watcher.notify(component) [if integrated]
|
|
100
|
-
* 4. Watcher runs all registered callbacks for that component
|
|
101
|
-
*
|
|
102
|
-
* Current limitation: Manual notification required. To auto-notify:
|
|
103
|
-
*
|
|
104
|
-
* ```javascript
|
|
105
|
-
* // In your component after state change:
|
|
106
|
-
* this._notifyWatchers();
|
|
107
|
-
* ```
|
|
108
|
-
*
|
|
109
|
-
* Or integrate into BaseComponent.update():
|
|
110
|
-
*
|
|
111
|
-
* ```typescript
|
|
112
|
-
* update(prop: string, value: any): void {
|
|
113
|
-
* // ...existing update logic...
|
|
114
|
-
* this._watchers.forEach(w => w.notify(this));
|
|
115
|
-
* }
|
|
116
|
-
* ```
|
|
117
|
-
*/
|
|
118
|
-
export class Watcher {
|
|
119
|
-
constructor(id) {
|
|
120
|
-
this._callbacks = new Map();
|
|
121
|
-
this._id = id;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Watch a component and run callback when it changes
|
|
125
|
-
*
|
|
126
|
-
* @param component - Component to watch
|
|
127
|
-
* @param callback - Function to run on change
|
|
128
|
-
* @returns this (for chaining)
|
|
129
|
-
*/
|
|
130
|
-
watch(component, callback) {
|
|
131
|
-
const id = component._id;
|
|
132
|
-
if (!this._callbacks.has(id)) {
|
|
133
|
-
this._callbacks.set(id, new Set());
|
|
134
|
-
}
|
|
135
|
-
this._callbacks.get(id).add(callback);
|
|
136
|
-
return this;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Watch multiple components with the same callback
|
|
140
|
-
*
|
|
141
|
-
* @param components - Array of components to watch
|
|
142
|
-
* @param callback - Function to run when ANY of them change
|
|
143
|
-
* @returns this (for chaining)
|
|
144
|
-
*/
|
|
145
|
-
watchMany(components, callback) {
|
|
146
|
-
components.forEach(component => this.watch(component, callback));
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Stop watching a component (remove specific callback)
|
|
151
|
-
*
|
|
152
|
-
* @param component - Component to stop watching
|
|
153
|
-
* @param callback - Specific callback to remove
|
|
154
|
-
* @returns this (for chaining)
|
|
155
|
-
*/
|
|
156
|
-
unwatch(component, callback) {
|
|
157
|
-
const id = component._id;
|
|
158
|
-
const callbacks = this._callbacks.get(id);
|
|
159
|
-
if (callbacks) {
|
|
160
|
-
callbacks.delete(callback);
|
|
161
|
-
// Clean up empty sets
|
|
162
|
-
if (callbacks.size === 0) {
|
|
163
|
-
this._callbacks.delete(id);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Stop watching a component (remove ALL callbacks)
|
|
170
|
-
*
|
|
171
|
-
* @param component - Component to stop watching completely
|
|
172
|
-
* @returns this (for chaining)
|
|
173
|
-
*/
|
|
174
|
-
unwatchAll(component) {
|
|
175
|
-
this._callbacks.delete(component._id);
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Notify all callbacks for a component (call this when component changes)
|
|
180
|
-
*
|
|
181
|
-
* @param component - Component that changed
|
|
182
|
-
* @param args - Optional arguments to pass to callbacks
|
|
183
|
-
*/
|
|
184
|
-
notify(component, ...args) {
|
|
185
|
-
const callbacks = this._callbacks.get(component._id);
|
|
186
|
-
if (callbacks && callbacks.size > 0) {
|
|
187
|
-
callbacks.forEach(callback => {
|
|
188
|
-
try {
|
|
189
|
-
callback(...args);
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
console.error(`[Watcher ${this._id}] Callback error:`, error);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Clear all watched components and callbacks
|
|
199
|
-
*
|
|
200
|
-
* @returns this (for chaining)
|
|
201
|
-
*/
|
|
202
|
-
clear() {
|
|
203
|
-
this._callbacks.clear();
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Get list of component IDs being watched
|
|
208
|
-
*
|
|
209
|
-
* @returns Array of component IDs
|
|
210
|
-
*/
|
|
211
|
-
getWatchedIds() {
|
|
212
|
-
return Array.from(this._callbacks.keys());
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Get count of callbacks for a component
|
|
216
|
-
*
|
|
217
|
-
* @param component - Component to check
|
|
218
|
-
* @returns Number of callbacks registered
|
|
219
|
-
*/
|
|
220
|
-
getCallbackCount(component) {
|
|
221
|
-
return this._callbacks.get(component._id)?.size || 0;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Check if watching a component
|
|
225
|
-
*
|
|
226
|
-
* @param component - Component to check
|
|
227
|
-
* @returns true if watching this component
|
|
228
|
-
*/
|
|
229
|
-
isWatching(component) {
|
|
230
|
-
return this._callbacks.has(component._id);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Create a new watcher instance
|
|
235
|
-
*
|
|
236
|
-
* @param id - Unique identifier for this watcher
|
|
237
|
-
* @returns New Watcher instance
|
|
238
|
-
*/
|
|
239
|
-
export function watcher(id) {
|
|
240
|
-
return new Watcher(id);
|
|
241
|
-
}
|