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,261 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from "./base/BaseComponent.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 🔍 WATCHER - Simple Component Observer
|
|
5
|
-
*
|
|
6
|
-
* Watches JUX components and fires callbacks when their state changes.
|
|
7
|
-
* Think of it as a "subscribe to component updates" utility.
|
|
8
|
-
*
|
|
9
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
10
|
-
* BASIC USAGE
|
|
11
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
12
|
-
*
|
|
13
|
-
* ```javascript
|
|
14
|
-
* import { input, paragraph, watcher } from 'juxscript';
|
|
15
|
-
*
|
|
16
|
-
* const nameInput = input('name').render('app');
|
|
17
|
-
* const greeting = paragraph('greeting').render('app');
|
|
18
|
-
*
|
|
19
|
-
* // Watch nameInput and update greeting whenever it changes
|
|
20
|
-
* watcher('name-watcher')
|
|
21
|
-
* .watch(nameInput, () => {
|
|
22
|
-
* greeting.text(`Hello, ${nameInput.getValue()}!`);
|
|
23
|
-
* });
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
27
|
-
* MULTIPLE COMPONENTS
|
|
28
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
29
|
-
*
|
|
30
|
-
* ```javascript
|
|
31
|
-
* const firstNameInput = input('firstName').render();
|
|
32
|
-
* const lastNameInput = input('lastName').render();
|
|
33
|
-
* const fullName = paragraph('fullName').render();
|
|
34
|
-
*
|
|
35
|
-
* const formWatcher = watcher('form');
|
|
36
|
-
*
|
|
37
|
-
* // Watch both inputs, same callback
|
|
38
|
-
* formWatcher
|
|
39
|
-
* .watch(firstNameInput, updateFullName)
|
|
40
|
-
* .watch(lastNameInput, updateFullName);
|
|
41
|
-
*
|
|
42
|
-
* function updateFullName() {
|
|
43
|
-
* const first = firstNameInput.getValue();
|
|
44
|
-
* const last = lastNameInput.getValue();
|
|
45
|
-
* fullName.text(`${first} ${last}`.trim());
|
|
46
|
-
* }
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
50
|
-
* DECLARATIVE STYLE - Watch Many, Do One Thing
|
|
51
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
52
|
-
*
|
|
53
|
-
* ```javascript
|
|
54
|
-
* const price = input('price').render();
|
|
55
|
-
* const quantity = input('quantity').render();
|
|
56
|
-
* const discount = input('discount').render();
|
|
57
|
-
* const total = paragraph('total').render();
|
|
58
|
-
*
|
|
59
|
-
* // Update total whenever ANY input changes
|
|
60
|
-
* watcher('calculator')
|
|
61
|
-
* .watchMany([price, quantity, discount], () => {
|
|
62
|
-
* const p = parseFloat(price.getValue()) || 0;
|
|
63
|
-
* const q = parseInt(quantity.getValue()) || 0;
|
|
64
|
-
* const d = parseFloat(discount.getValue()) || 0;
|
|
65
|
-
*
|
|
66
|
-
* const subtotal = p * q;
|
|
67
|
-
* const finalTotal = subtotal - (subtotal * d / 100);
|
|
68
|
-
*
|
|
69
|
-
* total.text(`Total: $${finalTotal.toFixed(2)}`);
|
|
70
|
-
* });
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
74
|
-
* STOP WATCHING
|
|
75
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
76
|
-
*
|
|
77
|
-
* ```javascript
|
|
78
|
-
* const myWatcher = watcher('temp');
|
|
79
|
-
* const myInput = input('field').render();
|
|
80
|
-
*
|
|
81
|
-
* const myCallback = () => console.log('Changed!');
|
|
82
|
-
*
|
|
83
|
-
* myWatcher.watch(myInput, myCallback);
|
|
84
|
-
*
|
|
85
|
-
* // Later: stop watching
|
|
86
|
-
* myWatcher.unwatch(myInput, myCallback);
|
|
87
|
-
*
|
|
88
|
-
* // Or stop watching ALL callbacks for this component
|
|
89
|
-
* myWatcher.unwatchAll(myInput);
|
|
90
|
-
*
|
|
91
|
-
* // Or clear everything
|
|
92
|
-
* myWatcher.clear();
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
96
|
-
* HOW IT WORKS
|
|
97
|
-
* ═══════════════════════════════════════════════════════════════════════════════
|
|
98
|
-
*
|
|
99
|
-
* 1. Watcher stores callbacks keyed by component._id
|
|
100
|
-
* 2. Component's Proxy detects state changes
|
|
101
|
-
* 3. Component calls watcher.notify(component) [if integrated]
|
|
102
|
-
* 4. Watcher runs all registered callbacks for that component
|
|
103
|
-
*
|
|
104
|
-
* Current limitation: Manual notification required. To auto-notify:
|
|
105
|
-
*
|
|
106
|
-
* ```javascript
|
|
107
|
-
* // In your component after state change:
|
|
108
|
-
* this._notifyWatchers();
|
|
109
|
-
* ```
|
|
110
|
-
*
|
|
111
|
-
* Or integrate into BaseComponent.update():
|
|
112
|
-
*
|
|
113
|
-
* ```typescript
|
|
114
|
-
* update(prop: string, value: any): void {
|
|
115
|
-
* // ...existing update logic...
|
|
116
|
-
* this._watchers.forEach(w => w.notify(this));
|
|
117
|
-
* }
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
|
|
121
|
-
export class Watcher {
|
|
122
|
-
private _id: string;
|
|
123
|
-
private _callbacks: Map<string, Set<Function>> = new Map();
|
|
124
|
-
|
|
125
|
-
constructor(id: string) {
|
|
126
|
-
this._id = id;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Watch a component and run callback when it changes
|
|
131
|
-
*
|
|
132
|
-
* @param component - Component to watch
|
|
133
|
-
* @param callback - Function to run on change
|
|
134
|
-
* @returns this (for chaining)
|
|
135
|
-
*/
|
|
136
|
-
watch(component: BaseComponent<any>, callback: Function): this {
|
|
137
|
-
const id = component._id;
|
|
138
|
-
|
|
139
|
-
if (!this._callbacks.has(id)) {
|
|
140
|
-
this._callbacks.set(id, new Set());
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this._callbacks.get(id)!.add(callback);
|
|
144
|
-
return this;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Watch multiple components with the same callback
|
|
149
|
-
*
|
|
150
|
-
* @param components - Array of components to watch
|
|
151
|
-
* @param callback - Function to run when ANY of them change
|
|
152
|
-
* @returns this (for chaining)
|
|
153
|
-
*/
|
|
154
|
-
watchMany(components: BaseComponent<any>[], callback: Function): this {
|
|
155
|
-
components.forEach(component => this.watch(component, callback));
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Stop watching a component (remove specific callback)
|
|
161
|
-
*
|
|
162
|
-
* @param component - Component to stop watching
|
|
163
|
-
* @param callback - Specific callback to remove
|
|
164
|
-
* @returns this (for chaining)
|
|
165
|
-
*/
|
|
166
|
-
unwatch(component: BaseComponent<any>, callback: Function): this {
|
|
167
|
-
const id = component._id;
|
|
168
|
-
const callbacks = this._callbacks.get(id);
|
|
169
|
-
|
|
170
|
-
if (callbacks) {
|
|
171
|
-
callbacks.delete(callback);
|
|
172
|
-
|
|
173
|
-
// Clean up empty sets
|
|
174
|
-
if (callbacks.size === 0) {
|
|
175
|
-
this._callbacks.delete(id);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return this;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Stop watching a component (remove ALL callbacks)
|
|
184
|
-
*
|
|
185
|
-
* @param component - Component to stop watching completely
|
|
186
|
-
* @returns this (for chaining)
|
|
187
|
-
*/
|
|
188
|
-
unwatchAll(component: BaseComponent<any>): this {
|
|
189
|
-
this._callbacks.delete(component._id);
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Notify all callbacks for a component (call this when component changes)
|
|
195
|
-
*
|
|
196
|
-
* @param component - Component that changed
|
|
197
|
-
* @param args - Optional arguments to pass to callbacks
|
|
198
|
-
*/
|
|
199
|
-
notify(component: BaseComponent<any>, ...args: any[]): void {
|
|
200
|
-
const callbacks = this._callbacks.get(component._id);
|
|
201
|
-
|
|
202
|
-
if (callbacks && callbacks.size > 0) {
|
|
203
|
-
callbacks.forEach(callback => {
|
|
204
|
-
try {
|
|
205
|
-
callback(...args);
|
|
206
|
-
} catch (error) {
|
|
207
|
-
console.error(`[Watcher ${this._id}] Callback error:`, error);
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Clear all watched components and callbacks
|
|
215
|
-
*
|
|
216
|
-
* @returns this (for chaining)
|
|
217
|
-
*/
|
|
218
|
-
clear(): this {
|
|
219
|
-
this._callbacks.clear();
|
|
220
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* Get list of component IDs being watched
|
|
225
|
-
*
|
|
226
|
-
* @returns Array of component IDs
|
|
227
|
-
*/
|
|
228
|
-
getWatchedIds(): string[] {
|
|
229
|
-
return Array.from(this._callbacks.keys());
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Get count of callbacks for a component
|
|
234
|
-
*
|
|
235
|
-
* @param component - Component to check
|
|
236
|
-
* @returns Number of callbacks registered
|
|
237
|
-
*/
|
|
238
|
-
getCallbackCount(component: BaseComponent<any>): number {
|
|
239
|
-
return this._callbacks.get(component._id)?.size || 0;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Check if watching a component
|
|
244
|
-
*
|
|
245
|
-
* @param component - Component to check
|
|
246
|
-
* @returns true if watching this component
|
|
247
|
-
*/
|
|
248
|
-
isWatching(component: BaseComponent<any>): boolean {
|
|
249
|
-
return this._callbacks.has(component._id);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* Create a new watcher instance
|
|
255
|
-
*
|
|
256
|
-
* @param id - Unique identifier for this watcher
|
|
257
|
-
* @returns New Watcher instance
|
|
258
|
-
*/
|
|
259
|
-
export function watcher(id: string): Watcher {
|
|
260
|
-
return new Watcher(id);
|
|
261
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Write - Simple content writer with no component tracking
|
|
3
|
-
* Perfect for quick HTML output without ID management
|
|
4
|
-
*/
|
|
5
|
-
export interface WriteOptions {
|
|
6
|
-
tagType?: string;
|
|
7
|
-
className?: string;
|
|
8
|
-
style?: string;
|
|
9
|
-
attributes?: Record<string, string>;
|
|
10
|
-
html?: boolean;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Write content directly to a target element
|
|
14
|
-
*
|
|
15
|
-
* Usage:
|
|
16
|
-
* // Write text (defaults to body)
|
|
17
|
-
* jux.write('Hello World!').render();
|
|
18
|
-
*
|
|
19
|
-
* // Write to specific target
|
|
20
|
-
* jux.write('Content').render('#container');
|
|
21
|
-
*
|
|
22
|
-
* // Write HTML
|
|
23
|
-
* jux.write('<strong>Bold text</strong>').html(true).render('#container');
|
|
24
|
-
*
|
|
25
|
-
* // Write with styling
|
|
26
|
-
* jux.write('Styled text').style('color: red;').render('#container');
|
|
27
|
-
*/
|
|
28
|
-
export declare class Write {
|
|
29
|
-
private content;
|
|
30
|
-
private options;
|
|
31
|
-
constructor(content: string, options?: WriteOptions);
|
|
32
|
-
/**
|
|
33
|
-
* Set HTML mode (treat content as HTML)
|
|
34
|
-
*/
|
|
35
|
-
html(enabled?: boolean): this;
|
|
36
|
-
/**
|
|
37
|
-
* Set tag type
|
|
38
|
-
*/
|
|
39
|
-
tagType(value: string): this;
|
|
40
|
-
/**
|
|
41
|
-
* Set CSS class
|
|
42
|
-
*/
|
|
43
|
-
className(value: string): this;
|
|
44
|
-
/**
|
|
45
|
-
* Set inline styles
|
|
46
|
-
*/
|
|
47
|
-
style(value: string): this;
|
|
48
|
-
/**
|
|
49
|
-
* Set custom attributes
|
|
50
|
-
*/
|
|
51
|
-
attrs(attributes: Record<string, string>): this;
|
|
52
|
-
/**
|
|
53
|
-
* Render content to target element
|
|
54
|
-
*/
|
|
55
|
-
render(targetSelector?: string): this;
|
|
56
|
-
/**
|
|
57
|
-
* Replace target content (clear first, then render)
|
|
58
|
-
*/
|
|
59
|
-
replace(targetSelector?: string): this;
|
|
60
|
-
/**
|
|
61
|
-
* Render before target element
|
|
62
|
-
*/
|
|
63
|
-
before(targetSelector: string): this;
|
|
64
|
-
/**
|
|
65
|
-
* Render after target element
|
|
66
|
-
*/
|
|
67
|
-
after(targetSelector: string): this;
|
|
68
|
-
/**
|
|
69
|
-
* Prepend to target (insert as first child)
|
|
70
|
-
*/
|
|
71
|
-
prepend(targetSelector?: string): this;
|
|
72
|
-
/**
|
|
73
|
-
* Append to target (alias for render)
|
|
74
|
-
*/
|
|
75
|
-
append(targetSelector?: string): this;
|
|
76
|
-
private _getTarget;
|
|
77
|
-
private _createElement;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Factory function - simple, no overloads
|
|
81
|
-
*/
|
|
82
|
-
export declare function write(content: string, options?: WriteOptions): Write;
|
|
83
|
-
/**
|
|
84
|
-
* Write text (explicit)
|
|
85
|
-
*/
|
|
86
|
-
export declare function writeText(content: string, options?: Omit<WriteOptions, 'html'>): Write;
|
|
87
|
-
/**
|
|
88
|
-
* Write HTML (explicit)
|
|
89
|
-
*/
|
|
90
|
-
export declare function writeHtml(content: string, options?: Omit<WriteOptions, 'html'>): Write;
|
|
91
|
-
/**
|
|
92
|
-
* Write paragraph
|
|
93
|
-
*/
|
|
94
|
-
export declare function writeParagraph(content: string, options?: Omit<WriteOptions, 'tagType'>): Write;
|
|
95
|
-
/**
|
|
96
|
-
* Write heading
|
|
97
|
-
*/
|
|
98
|
-
export declare function writeHeading(content: string, level?: 1 | 2 | 3 | 4 | 5 | 6, options?: Omit<WriteOptions, 'tagType'>): Write;
|
|
99
|
-
/**
|
|
100
|
-
* Write span
|
|
101
|
-
*/
|
|
102
|
-
export declare function writeSpan(content: string, options?: Omit<WriteOptions, 'tagType'>): Write;
|
|
103
|
-
/**
|
|
104
|
-
* Write div (explicit)
|
|
105
|
-
*/
|
|
106
|
-
export declare function writeDiv(content: string, options?: Omit<WriteOptions, 'tagType'>): Write;
|
|
107
|
-
//# sourceMappingURL=write.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["write.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,KAAK;IACd,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,OAAO,CAAe;gBAElB,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;IAgBvD;;OAEG;IACH,IAAI,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAKnC;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B;;OAEG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAS/C;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAUrC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAWtC;;OAEG;IACH,MAAM,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAapC;;OAEG;IACH,KAAK,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI;IAanC;;OAEG;IACH,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAUtC;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAQrC,OAAO,CAAC,UAAU;IAYlB,OAAO,CAAC,cAAc;CA6BzB;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAExE;AAMD;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAM,GAAG,KAAK,CAE1F;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAM,GAAG,KAAK,CAE1F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAM,GAAG,KAAK,CAElG;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,GAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAK,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAM,GAAG,KAAK,CAElI;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAM,GAAG,KAAK,CAE7F;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,IAAI,CAAC,YAAY,EAAE,SAAS,CAAM,GAAG,KAAK,CAE5F"}
|
package/lib/components/write.js
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Write - Simple content writer with no component tracking
|
|
3
|
-
* Perfect for quick HTML output without ID management
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Write content directly to a target element
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* // Write text (defaults to body)
|
|
10
|
-
* jux.write('Hello World!').render();
|
|
11
|
-
*
|
|
12
|
-
* // Write to specific target
|
|
13
|
-
* jux.write('Content').render('#container');
|
|
14
|
-
*
|
|
15
|
-
* // Write HTML
|
|
16
|
-
* jux.write('<strong>Bold text</strong>').html(true).render('#container');
|
|
17
|
-
*
|
|
18
|
-
* // Write with styling
|
|
19
|
-
* jux.write('Styled text').style('color: red;').render('#container');
|
|
20
|
-
*/
|
|
21
|
-
export class Write {
|
|
22
|
-
constructor(content, options = {}) {
|
|
23
|
-
this.content = content;
|
|
24
|
-
this.options = {
|
|
25
|
-
tagType: 'div',
|
|
26
|
-
className: '',
|
|
27
|
-
style: '',
|
|
28
|
-
attributes: {},
|
|
29
|
-
html: false,
|
|
30
|
-
...options
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
34
|
-
* FLUENT API
|
|
35
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
36
|
-
/**
|
|
37
|
-
* Set HTML mode (treat content as HTML)
|
|
38
|
-
*/
|
|
39
|
-
html(enabled = true) {
|
|
40
|
-
this.options.html = enabled;
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Set tag type
|
|
45
|
-
*/
|
|
46
|
-
tagType(value) {
|
|
47
|
-
this.options.tagType = value;
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Set CSS class
|
|
52
|
-
*/
|
|
53
|
-
className(value) {
|
|
54
|
-
this.options.className = value;
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Set inline styles
|
|
59
|
-
*/
|
|
60
|
-
style(value) {
|
|
61
|
-
this.options.style = value;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Set custom attributes
|
|
66
|
-
*/
|
|
67
|
-
attrs(attributes) {
|
|
68
|
-
this.options.attributes = attributes;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
72
|
-
* RENDER METHODS
|
|
73
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
74
|
-
/**
|
|
75
|
-
* Render content to target element
|
|
76
|
-
*/
|
|
77
|
-
render(targetSelector) {
|
|
78
|
-
const target = this._getTarget(targetSelector);
|
|
79
|
-
if (!target)
|
|
80
|
-
return this;
|
|
81
|
-
const element = this._createElement();
|
|
82
|
-
target.appendChild(element);
|
|
83
|
-
return this;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Replace target content (clear first, then render)
|
|
87
|
-
*/
|
|
88
|
-
replace(targetSelector) {
|
|
89
|
-
const target = this._getTarget(targetSelector);
|
|
90
|
-
if (!target)
|
|
91
|
-
return this;
|
|
92
|
-
target.innerHTML = '';
|
|
93
|
-
const element = this._createElement();
|
|
94
|
-
target.appendChild(element);
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Render before target element
|
|
99
|
-
*/
|
|
100
|
-
before(targetSelector) {
|
|
101
|
-
const target = document.querySelector(targetSelector);
|
|
102
|
-
if (!target || !(target instanceof HTMLElement)) {
|
|
103
|
-
console.warn(`Write: Target element "${targetSelector}" not found`);
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
const element = this._createElement();
|
|
107
|
-
target.parentNode?.insertBefore(element, target);
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Render after target element
|
|
112
|
-
*/
|
|
113
|
-
after(targetSelector) {
|
|
114
|
-
const target = document.querySelector(targetSelector);
|
|
115
|
-
if (!target || !(target instanceof HTMLElement)) {
|
|
116
|
-
console.warn(`Write: Target element "${targetSelector}" not found`);
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
const element = this._createElement();
|
|
120
|
-
target.parentNode?.insertBefore(element, target.nextSibling);
|
|
121
|
-
return this;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Prepend to target (insert as first child)
|
|
125
|
-
*/
|
|
126
|
-
prepend(targetSelector) {
|
|
127
|
-
const target = this._getTarget(targetSelector);
|
|
128
|
-
if (!target)
|
|
129
|
-
return this;
|
|
130
|
-
const element = this._createElement();
|
|
131
|
-
target.insertBefore(element, target.firstChild);
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Append to target (alias for render)
|
|
136
|
-
*/
|
|
137
|
-
append(targetSelector) {
|
|
138
|
-
return this.render(targetSelector);
|
|
139
|
-
}
|
|
140
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
141
|
-
* PRIVATE HELPERS
|
|
142
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
143
|
-
_getTarget(selector) {
|
|
144
|
-
const targetSelector = selector || 'body';
|
|
145
|
-
const target = document.querySelector(targetSelector);
|
|
146
|
-
if (!target || !(target instanceof HTMLElement)) {
|
|
147
|
-
console.warn(`Write: Target element "${targetSelector}" not found`);
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
return target;
|
|
151
|
-
}
|
|
152
|
-
_createElement() {
|
|
153
|
-
const element = document.createElement(this.options.tagType);
|
|
154
|
-
// Set content (text or HTML)
|
|
155
|
-
if (this.options.html) {
|
|
156
|
-
element.innerHTML = this.content;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
element.textContent = this.content;
|
|
160
|
-
}
|
|
161
|
-
// Apply className
|
|
162
|
-
if (this.options.className) {
|
|
163
|
-
element.className = this.options.className;
|
|
164
|
-
}
|
|
165
|
-
// Apply inline styles
|
|
166
|
-
if (this.options.style) {
|
|
167
|
-
element.setAttribute('style', this.options.style);
|
|
168
|
-
}
|
|
169
|
-
// Apply custom attributes
|
|
170
|
-
if (this.options.attributes) {
|
|
171
|
-
Object.entries(this.options.attributes).forEach(([key, value]) => {
|
|
172
|
-
element.setAttribute(key, value);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return element;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Factory function - simple, no overloads
|
|
180
|
-
*/
|
|
181
|
-
export function write(content, options = {}) {
|
|
182
|
-
return new Write(content, options);
|
|
183
|
-
}
|
|
184
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
185
|
-
* SHORTHAND HELPERS
|
|
186
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
187
|
-
/**
|
|
188
|
-
* Write text (explicit)
|
|
189
|
-
*/
|
|
190
|
-
export function writeText(content, options = {}) {
|
|
191
|
-
return new Write(content, { ...options, html: false });
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Write HTML (explicit)
|
|
195
|
-
*/
|
|
196
|
-
export function writeHtml(content, options = {}) {
|
|
197
|
-
return new Write(content, { ...options, html: true });
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* Write paragraph
|
|
201
|
-
*/
|
|
202
|
-
export function writeParagraph(content, options = {}) {
|
|
203
|
-
return new Write(content, { ...options, tagType: 'p' });
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Write heading
|
|
207
|
-
*/
|
|
208
|
-
export function writeHeading(content, level = 2, options = {}) {
|
|
209
|
-
return new Write(content, { ...options, tagType: `h${level}` });
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Write span
|
|
213
|
-
*/
|
|
214
|
-
export function writeSpan(content, options = {}) {
|
|
215
|
-
return new Write(content, { ...options, tagType: 'span' });
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Write div (explicit)
|
|
219
|
-
*/
|
|
220
|
-
export function writeDiv(content, options = {}) {
|
|
221
|
-
return new Write(content, { ...options, tagType: 'div' });
|
|
222
|
-
}
|