juxscript 1.1.240 → 1.1.244
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/include.ts +229 -229
- package/lib/components/tag.ts +68 -0
- package/lib/styles/shadcn.css +17 -5
- 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/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,238 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Include - Simplified resource injection for bundled and external resources
|
|
3
|
-
* Supports page-specific scoping and cleanup
|
|
4
|
-
*/
|
|
5
|
-
// Global registry for page-scoped resources
|
|
6
|
-
const scopedResources = new Map();
|
|
7
|
-
export class Include {
|
|
8
|
-
constructor(url, options = {}) {
|
|
9
|
-
this.element = null;
|
|
10
|
-
this.pageId = null;
|
|
11
|
-
this.url = url;
|
|
12
|
-
this.options = options;
|
|
13
|
-
// Auto-detect type from extension if not provided
|
|
14
|
-
if (!options.type) {
|
|
15
|
-
if (url.endsWith('.css')) {
|
|
16
|
-
this.options.type = 'css';
|
|
17
|
-
}
|
|
18
|
-
else if (url.endsWith('.mjs') || url.endsWith('.module.js')) {
|
|
19
|
-
this.options.type = 'module';
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.options.type = 'js';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
/* -------------------------
|
|
27
|
-
* Fluent API
|
|
28
|
-
* ------------------------- */
|
|
29
|
-
css() {
|
|
30
|
-
this.options.type = 'css';
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
33
|
-
js() {
|
|
34
|
-
this.options.type = 'js';
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
module() {
|
|
38
|
-
this.options.type = 'module';
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
async() {
|
|
42
|
-
this.options.async = true;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
defer() {
|
|
46
|
-
this.options.defer = true;
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Inject into specific container instead of <head>
|
|
51
|
-
* Useful for page-specific styles
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* jux.include('/css/page1.css').into('#page1-container');
|
|
55
|
-
*/
|
|
56
|
-
into(selector) {
|
|
57
|
-
this.options.target = selector;
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Mark as page-scoped for automatic cleanup
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* jux.include('/css/dashboard.css').forPage('dashboard');
|
|
65
|
-
* // Later: Include.cleanupPage('dashboard');
|
|
66
|
-
*/
|
|
67
|
-
forPage(pageId) {
|
|
68
|
-
this.pageId = pageId;
|
|
69
|
-
this.options.pageScoped = true;
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
/* -------------------------
|
|
73
|
-
* Render
|
|
74
|
-
* ------------------------- */
|
|
75
|
-
render() {
|
|
76
|
-
if (typeof document === 'undefined')
|
|
77
|
-
return this;
|
|
78
|
-
try {
|
|
79
|
-
// Check if already loaded
|
|
80
|
-
if (this.isAlreadyLoaded()) {
|
|
81
|
-
console.log(`⚠️ Resource already loaded: ${this.url}`);
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
// Create element based on type
|
|
85
|
-
let element;
|
|
86
|
-
switch (this.options.type) {
|
|
87
|
-
case 'css':
|
|
88
|
-
element = this.createStylesheet();
|
|
89
|
-
break;
|
|
90
|
-
case 'js':
|
|
91
|
-
case 'module':
|
|
92
|
-
element = this.createScript();
|
|
93
|
-
break;
|
|
94
|
-
default:
|
|
95
|
-
throw new Error(`Unknown resource type: ${this.options.type}`);
|
|
96
|
-
}
|
|
97
|
-
// Get target container
|
|
98
|
-
const container = this.getContainer();
|
|
99
|
-
container.appendChild(element);
|
|
100
|
-
this.element = element;
|
|
101
|
-
// Register for page cleanup if needed
|
|
102
|
-
if (this.options.pageScoped && this.pageId) {
|
|
103
|
-
if (!scopedResources.has(this.pageId)) {
|
|
104
|
-
scopedResources.set(this.pageId, new Set());
|
|
105
|
-
}
|
|
106
|
-
scopedResources.get(this.pageId).add(element);
|
|
107
|
-
}
|
|
108
|
-
console.log(`✓ Loaded ${this.options.type}: ${this.url}`);
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
console.error(`✗ Failed to load ${this.options.type}: ${this.url}`, error);
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
/* -------------------------
|
|
117
|
-
* Element Creation
|
|
118
|
-
* ------------------------- */
|
|
119
|
-
createStylesheet() {
|
|
120
|
-
const link = document.createElement('link');
|
|
121
|
-
link.rel = 'stylesheet';
|
|
122
|
-
link.href = this.url;
|
|
123
|
-
link.dataset.juxInclude = this.url;
|
|
124
|
-
if (this.options.crossOrigin)
|
|
125
|
-
link.crossOrigin = this.options.crossOrigin;
|
|
126
|
-
if (this.options.integrity)
|
|
127
|
-
link.integrity = this.options.integrity;
|
|
128
|
-
link.onload = () => console.log(`✓ Stylesheet loaded: ${this.url}`);
|
|
129
|
-
link.onerror = () => {
|
|
130
|
-
throw new Error(`Failed to load stylesheet: ${this.url}`);
|
|
131
|
-
};
|
|
132
|
-
return link;
|
|
133
|
-
}
|
|
134
|
-
createScript() {
|
|
135
|
-
const script = document.createElement('script');
|
|
136
|
-
script.src = this.url;
|
|
137
|
-
script.dataset.juxInclude = this.url;
|
|
138
|
-
if (this.options.type === 'module')
|
|
139
|
-
script.type = 'module';
|
|
140
|
-
if (this.options.async)
|
|
141
|
-
script.async = true;
|
|
142
|
-
if (this.options.defer)
|
|
143
|
-
script.defer = true;
|
|
144
|
-
if (this.options.crossOrigin)
|
|
145
|
-
script.crossOrigin = this.options.crossOrigin;
|
|
146
|
-
if (this.options.integrity)
|
|
147
|
-
script.integrity = this.options.integrity;
|
|
148
|
-
script.onload = () => console.log(`✓ Script loaded: ${this.url}`);
|
|
149
|
-
script.onerror = () => {
|
|
150
|
-
throw new Error(`Failed to load script: ${this.url}`);
|
|
151
|
-
};
|
|
152
|
-
return script;
|
|
153
|
-
}
|
|
154
|
-
/* -------------------------
|
|
155
|
-
* Helpers
|
|
156
|
-
* ------------------------- */
|
|
157
|
-
getContainer() {
|
|
158
|
-
if (this.options.target) {
|
|
159
|
-
const container = document.querySelector(this.options.target);
|
|
160
|
-
if (!container) {
|
|
161
|
-
throw new Error(`Target container not found: ${this.options.target}`);
|
|
162
|
-
}
|
|
163
|
-
return container;
|
|
164
|
-
}
|
|
165
|
-
return document.head;
|
|
166
|
-
}
|
|
167
|
-
isAlreadyLoaded() {
|
|
168
|
-
const selector = `[data-jux-include="${this.url}"]`;
|
|
169
|
-
return document.querySelector(selector) !== null;
|
|
170
|
-
}
|
|
171
|
-
remove() {
|
|
172
|
-
if (this.element?.parentNode) {
|
|
173
|
-
this.element.parentNode.removeChild(this.element);
|
|
174
|
-
this.element = null;
|
|
175
|
-
}
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
/* -------------------------
|
|
179
|
-
* Static Page Cleanup
|
|
180
|
-
* ------------------------- */
|
|
181
|
-
/**
|
|
182
|
-
* Remove all resources for a specific page
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* Include.cleanupPage('dashboard');
|
|
186
|
-
*/
|
|
187
|
-
static cleanupPage(pageId) {
|
|
188
|
-
const resources = scopedResources.get(pageId);
|
|
189
|
-
if (!resources)
|
|
190
|
-
return;
|
|
191
|
-
resources.forEach(element => {
|
|
192
|
-
element.parentNode?.removeChild(element);
|
|
193
|
-
});
|
|
194
|
-
scopedResources.delete(pageId);
|
|
195
|
-
console.log(`✓ Cleaned up page resources: ${pageId}`);
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Remove all page-scoped resources
|
|
199
|
-
*/
|
|
200
|
-
static cleanupAll() {
|
|
201
|
-
scopedResources.forEach((resources, pageId) => {
|
|
202
|
-
resources.forEach(element => {
|
|
203
|
-
element.parentNode?.removeChild(element);
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
scopedResources.clear();
|
|
207
|
-
console.log('✓ Cleaned up all page-scoped resources');
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Factory function - simplified usage
|
|
212
|
-
*
|
|
213
|
-
* Usage:
|
|
214
|
-
* // Basic (auto-detects from extension)
|
|
215
|
-
* jux.include('/css/styles.css');
|
|
216
|
-
* jux.include('/js/app.js');
|
|
217
|
-
*
|
|
218
|
-
* // Page-specific with cleanup
|
|
219
|
-
* jux.include('/css/dashboard.css').forPage('dashboard');
|
|
220
|
-
* jux.include('/js/dashboard.js').forPage('dashboard');
|
|
221
|
-
*
|
|
222
|
-
* // Later cleanup:
|
|
223
|
-
* Include.cleanupPage('dashboard');
|
|
224
|
-
*
|
|
225
|
-
* // Inject into specific container
|
|
226
|
-
* jux.include('/css/widget.css').into('#widget-container');
|
|
227
|
-
*
|
|
228
|
-
* // External CDN
|
|
229
|
-
* jux.include('https://cdn.tailwindcss.com').js();
|
|
230
|
-
*
|
|
231
|
-
* // Module
|
|
232
|
-
* jux.include('/js/app.mjs').module();
|
|
233
|
-
*/
|
|
234
|
-
export function include(url, options) {
|
|
235
|
-
const inc = new Include(url, options);
|
|
236
|
-
inc.render();
|
|
237
|
-
return inc;
|
|
238
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
2
|
-
export interface InputOptions {
|
|
3
|
-
type?: string;
|
|
4
|
-
value?: string;
|
|
5
|
-
placeholder?: string;
|
|
6
|
-
label?: string;
|
|
7
|
-
icon?: string;
|
|
8
|
-
required?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
name?: string;
|
|
11
|
-
rows?: number;
|
|
12
|
-
min?: number;
|
|
13
|
-
max?: number;
|
|
14
|
-
step?: number;
|
|
15
|
-
minLength?: number;
|
|
16
|
-
maxLength?: number;
|
|
17
|
-
pattern?: string;
|
|
18
|
-
onValidate?: (value: string) => boolean | string;
|
|
19
|
-
style?: string;
|
|
20
|
-
class?: string;
|
|
21
|
-
}
|
|
22
|
-
interface InputState extends BaseState {
|
|
23
|
-
type: string;
|
|
24
|
-
value: string;
|
|
25
|
-
placeholder: string;
|
|
26
|
-
icon: string;
|
|
27
|
-
rows: number;
|
|
28
|
-
min?: number;
|
|
29
|
-
max?: number;
|
|
30
|
-
step?: number;
|
|
31
|
-
minLength?: number;
|
|
32
|
-
maxLength?: number;
|
|
33
|
-
pattern?: string;
|
|
34
|
-
}
|
|
35
|
-
export declare class Input extends BaseComponent<InputState> {
|
|
36
|
-
constructor(id: string, options?: InputOptions);
|
|
37
|
-
protected getTriggerEvents(): readonly string[];
|
|
38
|
-
protected getCallbackEvents(): readonly string[];
|
|
39
|
-
type(value: string): this;
|
|
40
|
-
value(value: string | number): this;
|
|
41
|
-
placeholder(value: string): this;
|
|
42
|
-
icon(value: string): this;
|
|
43
|
-
rows(value: number): this;
|
|
44
|
-
min(value: number): this;
|
|
45
|
-
max(value: number): this;
|
|
46
|
-
step(value: number): this;
|
|
47
|
-
minLength(value: number): this;
|
|
48
|
-
maxLength(value: number): this;
|
|
49
|
-
pattern(value: string): this;
|
|
50
|
-
getValue(): string;
|
|
51
|
-
setValue(value: string): this;
|
|
52
|
-
getNumericValue(): number | null;
|
|
53
|
-
validate(): boolean;
|
|
54
|
-
isValid(): boolean;
|
|
55
|
-
protected _validateValue(value: string): boolean | string;
|
|
56
|
-
protected _buildInputElement(): HTMLElement;
|
|
57
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
58
|
-
}
|
|
59
|
-
export declare function input(id: string, options?: InputOptions): Input;
|
|
60
|
-
export declare function text(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
61
|
-
export declare function textRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
62
|
-
export declare function number(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
63
|
-
export declare function numberRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
64
|
-
export declare function email(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
65
|
-
export declare function emailRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
66
|
-
export declare function password(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
67
|
-
export declare function passwordRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
68
|
-
export declare function tel(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
69
|
-
export declare function telRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
70
|
-
export declare function phone(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
71
|
-
export declare function phoneRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
72
|
-
export declare function url(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
73
|
-
export declare function urlRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
74
|
-
export declare function textarea(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
75
|
-
export declare function textareaRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
76
|
-
export declare function range(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
77
|
-
export declare function rangeRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
78
|
-
export declare function date(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
79
|
-
export declare function dateRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
80
|
-
export declare function time(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
81
|
-
export declare function timeRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
82
|
-
export declare function color(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
83
|
-
export declare function colorRequired(id: string, options?: Omit<InputOptions, 'type'>): Input;
|
|
84
|
-
export {};
|
|
85
|
-
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAW,SAAQ,SAAS;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE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C,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAErF;AAGD,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAE5E;AAGD,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAEpF;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAE5E;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAEpF;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAE7E;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,KAAK,CAErF"}
|
package/lib/components/input.js
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { renderIcon } from './icons.js';
|
|
3
|
-
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
4
|
-
// Event definitions
|
|
5
|
-
const TRIGGER_EVENTS = [];
|
|
6
|
-
const CALLBACK_EVENTS = ['change', 'input'];
|
|
7
|
-
export class Input extends BaseComponent {
|
|
8
|
-
constructor(id, options = {}) {
|
|
9
|
-
super(id, {
|
|
10
|
-
// ✅ BaseState properties
|
|
11
|
-
visible: true,
|
|
12
|
-
disabled: options.disabled ?? false,
|
|
13
|
-
loading: false,
|
|
14
|
-
class: options.class ?? '',
|
|
15
|
-
style: options.style ?? '',
|
|
16
|
-
attributes: {},
|
|
17
|
-
// ✅ Form-specific BaseState properties
|
|
18
|
-
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate if not provided
|
|
19
|
-
required: options.required ?? false,
|
|
20
|
-
name: options.name ?? id,
|
|
21
|
-
errorMessage: undefined,
|
|
22
|
-
// ✅ Input-specific properties
|
|
23
|
-
type: options.type ?? 'text',
|
|
24
|
-
value: options.value ?? '',
|
|
25
|
-
placeholder: options.placeholder ?? '',
|
|
26
|
-
icon: options.icon ?? '',
|
|
27
|
-
rows: options.rows ?? 3,
|
|
28
|
-
min: options.min,
|
|
29
|
-
max: options.max,
|
|
30
|
-
step: options.step,
|
|
31
|
-
minLength: options.minLength,
|
|
32
|
-
maxLength: options.maxLength,
|
|
33
|
-
pattern: options.pattern
|
|
34
|
-
});
|
|
35
|
-
if (options.onValidate) {
|
|
36
|
-
this._onValidate = options.onValidate;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
getTriggerEvents() {
|
|
40
|
-
return TRIGGER_EVENTS;
|
|
41
|
-
}
|
|
42
|
-
getCallbackEvents() {
|
|
43
|
-
return CALLBACK_EVENTS;
|
|
44
|
-
}
|
|
45
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
46
|
-
* FLUENT API
|
|
47
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
48
|
-
type(value) {
|
|
49
|
-
this.state.type = value;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
value(value) {
|
|
53
|
-
return this.setValue(String(value));
|
|
54
|
-
}
|
|
55
|
-
placeholder(value) {
|
|
56
|
-
this.state.placeholder = value;
|
|
57
|
-
return this;
|
|
58
|
-
}
|
|
59
|
-
icon(value) {
|
|
60
|
-
this.state.icon = value;
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
rows(value) {
|
|
64
|
-
this.state.rows = value;
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
min(value) {
|
|
68
|
-
this.state.min = value;
|
|
69
|
-
return this;
|
|
70
|
-
}
|
|
71
|
-
max(value) {
|
|
72
|
-
this.state.max = value;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
step(value) {
|
|
76
|
-
this.state.step = value;
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
minLength(value) {
|
|
80
|
-
this.state.minLength = value;
|
|
81
|
-
return this;
|
|
82
|
-
}
|
|
83
|
-
maxLength(value) {
|
|
84
|
-
this.state.maxLength = value;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
pattern(value) {
|
|
88
|
-
this.state.pattern = value;
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
92
|
-
* FORM INPUT IMPLEMENTATION (Override BaseComponent methods)
|
|
93
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
94
|
-
getValue() {
|
|
95
|
-
return this.state.value;
|
|
96
|
-
}
|
|
97
|
-
setValue(value) {
|
|
98
|
-
this.state.value = value;
|
|
99
|
-
if (this._inputElement) {
|
|
100
|
-
this._inputElement.value = value;
|
|
101
|
-
}
|
|
102
|
-
return this;
|
|
103
|
-
}
|
|
104
|
-
getNumericValue() {
|
|
105
|
-
const num = Number(this.state.value);
|
|
106
|
-
return isNaN(num) ? null : num;
|
|
107
|
-
}
|
|
108
|
-
validate() {
|
|
109
|
-
this._hasBeenValidated = true;
|
|
110
|
-
const value = this.getValue();
|
|
111
|
-
const result = this._validateValue(value);
|
|
112
|
-
if (result === true) {
|
|
113
|
-
this._clearError();
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
this._showError(result);
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
isValid() {
|
|
122
|
-
const value = this.getValue();
|
|
123
|
-
return this._validateValue(value) === true;
|
|
124
|
-
}
|
|
125
|
-
_validateValue(value) {
|
|
126
|
-
const { required, type, min, max, minLength, maxLength, pattern } = this.state;
|
|
127
|
-
if (required && !value.trim()) {
|
|
128
|
-
return 'This field is required';
|
|
129
|
-
}
|
|
130
|
-
if (type === 'number' && value) {
|
|
131
|
-
const numValue = Number(value);
|
|
132
|
-
if (isNaN(numValue)) {
|
|
133
|
-
return 'Must be a valid number';
|
|
134
|
-
}
|
|
135
|
-
if (min !== undefined && numValue < min) {
|
|
136
|
-
return `Must be at least ${min}`;
|
|
137
|
-
}
|
|
138
|
-
if (max !== undefined && numValue > max) {
|
|
139
|
-
return `Must be at most ${max}`;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
if ((type === 'text' || type === 'textarea') && value) {
|
|
143
|
-
if (minLength !== undefined && value.length < minLength) {
|
|
144
|
-
return `Must be at least ${minLength} characters`;
|
|
145
|
-
}
|
|
146
|
-
if (maxLength !== undefined && value.length > maxLength) {
|
|
147
|
-
return `Must be at most ${maxLength} characters`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (pattern && value) {
|
|
151
|
-
const regex = new RegExp(pattern);
|
|
152
|
-
if (!regex.test(value)) {
|
|
153
|
-
return 'Invalid format';
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
if (this._onValidate) {
|
|
157
|
-
const result = this._onValidate(value);
|
|
158
|
-
if (result !== true) {
|
|
159
|
-
return result || 'Invalid value';
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return true;
|
|
163
|
-
}
|
|
164
|
-
_buildInputElement() {
|
|
165
|
-
const { type, value, placeholder, required, disabled, name, rows, min, max, step, minLength, maxLength, pattern } = this.state;
|
|
166
|
-
let inputEl;
|
|
167
|
-
if (type === 'textarea') {
|
|
168
|
-
inputEl = document.createElement('textarea');
|
|
169
|
-
inputEl.rows = rows;
|
|
170
|
-
if (minLength !== undefined)
|
|
171
|
-
inputEl.minLength = minLength;
|
|
172
|
-
if (maxLength !== undefined)
|
|
173
|
-
inputEl.maxLength = maxLength;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
inputEl = document.createElement('input');
|
|
177
|
-
inputEl.type = type;
|
|
178
|
-
if (type === 'number') {
|
|
179
|
-
if (min !== undefined)
|
|
180
|
-
inputEl.min = String(min);
|
|
181
|
-
if (max !== undefined)
|
|
182
|
-
inputEl.max = String(max);
|
|
183
|
-
if (step !== undefined)
|
|
184
|
-
inputEl.step = String(step);
|
|
185
|
-
}
|
|
186
|
-
if (type === 'text' || type === 'email' || type === 'tel' || type === 'url') {
|
|
187
|
-
if (minLength !== undefined)
|
|
188
|
-
inputEl.minLength = minLength;
|
|
189
|
-
if (maxLength !== undefined)
|
|
190
|
-
inputEl.maxLength = maxLength;
|
|
191
|
-
if (pattern)
|
|
192
|
-
inputEl.pattern = pattern;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
inputEl.className = 'jux-input-element';
|
|
196
|
-
inputEl.id = `${this._id}-input`;
|
|
197
|
-
inputEl.name = name;
|
|
198
|
-
inputEl.value = value;
|
|
199
|
-
inputEl.placeholder = placeholder;
|
|
200
|
-
inputEl.required = required;
|
|
201
|
-
inputEl.disabled = disabled;
|
|
202
|
-
return inputEl;
|
|
203
|
-
}
|
|
204
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
205
|
-
* RENDER
|
|
206
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
207
|
-
render(targetId) {
|
|
208
|
-
const container = this._setupContainer(targetId);
|
|
209
|
-
const { icon, maxLength, type, style, class: className, label } = this.state;
|
|
210
|
-
// Build wrapper
|
|
211
|
-
const wrapper = document.createElement('div');
|
|
212
|
-
wrapper.className = 'jux-input';
|
|
213
|
-
wrapper.id = this._id;
|
|
214
|
-
if (className)
|
|
215
|
-
wrapper.className += ` ${className}`;
|
|
216
|
-
if (style)
|
|
217
|
-
wrapper.setAttribute('style', style);
|
|
218
|
-
// ✅ Label - always render if exists or can be auto-generated
|
|
219
|
-
if (label || !label) { // Always render label
|
|
220
|
-
wrapper.appendChild(this._renderLabel());
|
|
221
|
-
}
|
|
222
|
-
// Input container
|
|
223
|
-
const inputContainer = document.createElement('div');
|
|
224
|
-
inputContainer.className = 'jux-input-container';
|
|
225
|
-
if (icon)
|
|
226
|
-
inputContainer.classList.add('jux-input-with-icon');
|
|
227
|
-
// Icon
|
|
228
|
-
if (icon) {
|
|
229
|
-
const iconEl = document.createElement('span');
|
|
230
|
-
iconEl.className = 'jux-input-icon';
|
|
231
|
-
iconEl.appendChild(renderIcon(icon));
|
|
232
|
-
inputContainer.appendChild(iconEl);
|
|
233
|
-
}
|
|
234
|
-
// Input element
|
|
235
|
-
const inputEl = this._buildInputElement();
|
|
236
|
-
this._inputElement = inputEl;
|
|
237
|
-
inputContainer.appendChild(inputEl);
|
|
238
|
-
wrapper.appendChild(inputContainer);
|
|
239
|
-
// Error element
|
|
240
|
-
wrapper.appendChild(this._renderError());
|
|
241
|
-
// Character counter
|
|
242
|
-
if (maxLength && (type === 'text' || type === 'textarea')) {
|
|
243
|
-
const counterEl = document.createElement('div');
|
|
244
|
-
counterEl.className = 'jux-input-counter';
|
|
245
|
-
counterEl.id = `${this._id}-counter`;
|
|
246
|
-
counterEl.textContent = `${this.state.value.length}/${maxLength}`;
|
|
247
|
-
wrapper.appendChild(counterEl);
|
|
248
|
-
inputEl.addEventListener('input', (e) => {
|
|
249
|
-
const input = inputEl;
|
|
250
|
-
counterEl.textContent = `${input.value.length}/${maxLength}`;
|
|
251
|
-
this.state.value = input.value;
|
|
252
|
-
this._triggerCallback('input', input.value, e, this);
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
inputEl.addEventListener('input', (e) => {
|
|
257
|
-
const input = inputEl;
|
|
258
|
-
this.state.value = input.value;
|
|
259
|
-
this._triggerCallback('input', input.value, e, this);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
// Fire change event on blur
|
|
263
|
-
inputEl.addEventListener('change', (e) => {
|
|
264
|
-
const input = inputEl;
|
|
265
|
-
this._triggerCallback('change', input.value, e, this);
|
|
266
|
-
});
|
|
267
|
-
// Wire events
|
|
268
|
-
this._wireStandardEvents(wrapper);
|
|
269
|
-
this._wireFormSync(inputEl, 'input');
|
|
270
|
-
// Sync label changes
|
|
271
|
-
const labelSync = this._syncBindings.find(b => b.property === 'label');
|
|
272
|
-
if (labelSync) {
|
|
273
|
-
const transform = labelSync.toComponent || ((v) => String(v));
|
|
274
|
-
labelSync.stateObj.subscribe((val) => {
|
|
275
|
-
this.label(transform(val));
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
container.appendChild(wrapper);
|
|
279
|
-
requestAnimationFrame(() => {
|
|
280
|
-
if (window.lucide) {
|
|
281
|
-
window.lucide.createIcons();
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
return this;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
export function input(id, options = {}) {
|
|
288
|
-
return new Input(id, options);
|
|
289
|
-
}
|
|
290
|
-
// Shorter, consistent naming
|
|
291
|
-
export function text(id, options) {
|
|
292
|
-
return new Input(id, { ...options, type: 'text' });
|
|
293
|
-
}
|
|
294
|
-
export function textRequired(id, options) {
|
|
295
|
-
return new Input(id, { ...options, type: 'text', required: true });
|
|
296
|
-
}
|
|
297
|
-
export function number(id, options) {
|
|
298
|
-
return new Input(id, { ...options, type: 'number' });
|
|
299
|
-
}
|
|
300
|
-
export function numberRequired(id, options) {
|
|
301
|
-
return new Input(id, { ...options, type: 'number', required: true });
|
|
302
|
-
}
|
|
303
|
-
export function email(id, options) {
|
|
304
|
-
return new Input(id, { ...options, type: 'email' });
|
|
305
|
-
}
|
|
306
|
-
export function emailRequired(id, options) {
|
|
307
|
-
return new Input(id, { ...options, type: 'email', required: true });
|
|
308
|
-
}
|
|
309
|
-
export function password(id, options) {
|
|
310
|
-
return new Input(id, { ...options, type: 'password' });
|
|
311
|
-
}
|
|
312
|
-
export function passwordRequired(id, options) {
|
|
313
|
-
return new Input(id, { ...options, type: 'password', required: true });
|
|
314
|
-
}
|
|
315
|
-
export function tel(id, options) {
|
|
316
|
-
return new Input(id, { ...options, type: 'tel' });
|
|
317
|
-
}
|
|
318
|
-
export function telRequired(id, options) {
|
|
319
|
-
return new Input(id, { ...options, type: 'tel', required: true });
|
|
320
|
-
}
|
|
321
|
-
export function phone(id, options) {
|
|
322
|
-
return new Input(id, { ...options, type: 'tel' });
|
|
323
|
-
}
|
|
324
|
-
export function phoneRequired(id, options) {
|
|
325
|
-
return new Input(id, { ...options, type: 'tel', required: true });
|
|
326
|
-
}
|
|
327
|
-
export function url(id, options) {
|
|
328
|
-
return new Input(id, { ...options, type: 'url' });
|
|
329
|
-
}
|
|
330
|
-
export function urlRequired(id, options) {
|
|
331
|
-
return new Input(id, { ...options, type: 'url', required: true });
|
|
332
|
-
}
|
|
333
|
-
export function textarea(id, options) {
|
|
334
|
-
return new Input(id, { ...options, type: 'textarea' });
|
|
335
|
-
}
|
|
336
|
-
export function textareaRequired(id, options) {
|
|
337
|
-
return new Input(id, { ...options, type: 'textarea', required: true });
|
|
338
|
-
}
|
|
339
|
-
export function range(id, options) {
|
|
340
|
-
return new Input(id, { ...options, type: 'range' });
|
|
341
|
-
}
|
|
342
|
-
export function rangeRequired(id, options) {
|
|
343
|
-
return new Input(id, { ...options, type: 'range', required: true });
|
|
344
|
-
}
|
|
345
|
-
export function date(id, options) {
|
|
346
|
-
return new Input(id, { ...options, type: 'date' });
|
|
347
|
-
}
|
|
348
|
-
export function dateRequired(id, options) {
|
|
349
|
-
return new Input(id, { ...options, type: 'date', required: true });
|
|
350
|
-
}
|
|
351
|
-
export function time(id, options) {
|
|
352
|
-
return new Input(id, { ...options, type: 'time' });
|
|
353
|
-
}
|
|
354
|
-
export function timeRequired(id, options) {
|
|
355
|
-
return new Input(id, { ...options, type: 'time', required: true });
|
|
356
|
-
}
|
|
357
|
-
export function color(id, options) {
|
|
358
|
-
return new Input(id, { ...options, type: 'color' });
|
|
359
|
-
}
|
|
360
|
-
export function colorRequired(id, options) {
|
|
361
|
-
return new Input(id, { ...options, type: 'color', required: true });
|
|
362
|
-
}
|