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,260 +0,0 @@
|
|
|
1
|
-
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
2
|
-
import { renderIcon } from './icons.js';
|
|
3
|
-
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
4
|
-
|
|
5
|
-
// Event definitions
|
|
6
|
-
const TRIGGER_EVENTS = [] as const;
|
|
7
|
-
const CALLBACK_EVENTS = ['change'] as const;
|
|
8
|
-
|
|
9
|
-
export interface CheckboxOptions {
|
|
10
|
-
checked?: boolean;
|
|
11
|
-
label?: string;
|
|
12
|
-
required?: boolean;
|
|
13
|
-
disabled?: boolean;
|
|
14
|
-
name?: string;
|
|
15
|
-
value?: string;
|
|
16
|
-
style?: string;
|
|
17
|
-
class?: string;
|
|
18
|
-
onValidate?: (checked: boolean) => boolean | string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface CheckboxState extends BaseState {
|
|
22
|
-
checked: boolean;
|
|
23
|
-
value: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export class Checkbox extends BaseComponent<CheckboxState> {
|
|
27
|
-
constructor(id: string, options: CheckboxOptions = {}) {
|
|
28
|
-
super(id, {
|
|
29
|
-
visible: true,
|
|
30
|
-
disabled: options.disabled ?? false,
|
|
31
|
-
loading: false,
|
|
32
|
-
class: options.class ?? '',
|
|
33
|
-
style: options.style ?? '',
|
|
34
|
-
attributes: {},
|
|
35
|
-
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
36
|
-
required: options.required ?? false,
|
|
37
|
-
name: options.name ?? id,
|
|
38
|
-
errorMessage: undefined,
|
|
39
|
-
checked: options.checked ?? false,
|
|
40
|
-
value: options.value ?? 'on'
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (options.onValidate) {
|
|
44
|
-
this._onValidate = options.onValidate;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
protected getTriggerEvents(): readonly string[] {
|
|
49
|
-
return TRIGGER_EVENTS;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected getCallbackEvents(): readonly string[] {
|
|
53
|
-
return CALLBACK_EVENTS;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
57
|
-
* FLUENT API
|
|
58
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
59
|
-
|
|
60
|
-
checked(value: boolean): this {
|
|
61
|
-
return this.setValue(value);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
value(value: string): this {
|
|
65
|
-
this.state.value = value;
|
|
66
|
-
return this;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
70
|
-
* FORM INPUT IMPLEMENTATION
|
|
71
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
72
|
-
|
|
73
|
-
getValue(): boolean {
|
|
74
|
-
return this.state.checked;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
setValue(value: boolean): this {
|
|
78
|
-
this.state.checked = value;
|
|
79
|
-
if (this._inputElement) {
|
|
80
|
-
(this._inputElement as HTMLInputElement).checked = value;
|
|
81
|
-
}
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
validate(): boolean {
|
|
86
|
-
this._hasBeenValidated = true;
|
|
87
|
-
const value = this.getValue();
|
|
88
|
-
const result = this._validateValue(value);
|
|
89
|
-
|
|
90
|
-
if (result === true) {
|
|
91
|
-
this._clearError();
|
|
92
|
-
return true;
|
|
93
|
-
} else {
|
|
94
|
-
this._showError(result as string);
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
isValid(): boolean {
|
|
100
|
-
const value = this.getValue();
|
|
101
|
-
return this._validateValue(value) === true;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
protected _validateValue(checked: boolean): boolean | string {
|
|
105
|
-
const { required } = this.state;
|
|
106
|
-
|
|
107
|
-
if (required && !checked) {
|
|
108
|
-
return 'This field must be checked';
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (this._onValidate) {
|
|
112
|
-
const result = this._onValidate(checked);
|
|
113
|
-
if (result !== true) {
|
|
114
|
-
return result || 'Invalid value';
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
protected _buildInputElement(): HTMLElement {
|
|
122
|
-
const { checked, value, required, disabled, name } = this.state;
|
|
123
|
-
|
|
124
|
-
const input = document.createElement('input');
|
|
125
|
-
input.type = 'checkbox';
|
|
126
|
-
input.className = 'jux-checkbox-input';
|
|
127
|
-
input.id = `${this._id}-input`;
|
|
128
|
-
input.name = name!;
|
|
129
|
-
input.value = value;
|
|
130
|
-
input.checked = checked;
|
|
131
|
-
input.required = required!;
|
|
132
|
-
input.disabled = disabled!;
|
|
133
|
-
|
|
134
|
-
return input;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
138
|
-
* RENDER
|
|
139
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
140
|
-
|
|
141
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this {
|
|
142
|
-
const container = this._setupContainer(targetId);
|
|
143
|
-
|
|
144
|
-
const { style, class: className } = this.state;
|
|
145
|
-
|
|
146
|
-
// Build wrapper
|
|
147
|
-
const wrapper = document.createElement('div');
|
|
148
|
-
wrapper.className = 'jux-checkbox';
|
|
149
|
-
wrapper.id = this._id;
|
|
150
|
-
if (className) wrapper.className += ` ${className}`;
|
|
151
|
-
if (style) wrapper.setAttribute('style', style);
|
|
152
|
-
|
|
153
|
-
// Checkbox container
|
|
154
|
-
const checkboxContainer = document.createElement('label');
|
|
155
|
-
checkboxContainer.className = 'jux-checkbox-container';
|
|
156
|
-
checkboxContainer.htmlFor = `${this._id}-input`;
|
|
157
|
-
|
|
158
|
-
// Input element
|
|
159
|
-
const inputEl = this._buildInputElement() as HTMLInputElement;
|
|
160
|
-
this._inputElement = inputEl;
|
|
161
|
-
checkboxContainer.appendChild(inputEl);
|
|
162
|
-
|
|
163
|
-
// Checkmark (custom styled)
|
|
164
|
-
const checkmark = document.createElement('span');
|
|
165
|
-
checkmark.className = 'jux-checkbox-checkmark';
|
|
166
|
-
checkmark.appendChild(renderIcon('check'));
|
|
167
|
-
checkboxContainer.appendChild(checkmark);
|
|
168
|
-
|
|
169
|
-
// Label text
|
|
170
|
-
if (this.state.label) {
|
|
171
|
-
const labelText = document.createElement('span');
|
|
172
|
-
labelText.className = 'jux-checkbox-label-text';
|
|
173
|
-
labelText.textContent = this.state.label;
|
|
174
|
-
if (this.state.required) {
|
|
175
|
-
const requiredSpan = document.createElement('span');
|
|
176
|
-
requiredSpan.className = 'jux-input-required';
|
|
177
|
-
requiredSpan.textContent = ' *';
|
|
178
|
-
labelText.appendChild(requiredSpan);
|
|
179
|
-
}
|
|
180
|
-
checkboxContainer.appendChild(labelText);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
wrapper.appendChild(checkboxContainer);
|
|
184
|
-
|
|
185
|
-
// Error element
|
|
186
|
-
wrapper.appendChild(this._renderError());
|
|
187
|
-
|
|
188
|
-
// Wire events
|
|
189
|
-
this._wireStandardEvents(wrapper);
|
|
190
|
-
|
|
191
|
-
// Wire checkbox-specific sync (maps 'checked' to 'value' property for consistency)
|
|
192
|
-
const valueSync = this._syncBindings.find(b => b.property === 'value' || b.property === 'checked');
|
|
193
|
-
|
|
194
|
-
if (valueSync) {
|
|
195
|
-
const { stateObj, toState, toComponent } = valueSync;
|
|
196
|
-
|
|
197
|
-
const transformToState = toState || ((v: boolean) => v);
|
|
198
|
-
const transformToComponent = toComponent || ((v: any) => Boolean(v));
|
|
199
|
-
|
|
200
|
-
let isUpdating = false;
|
|
201
|
-
|
|
202
|
-
// State → Component
|
|
203
|
-
stateObj.subscribe((val: any) => {
|
|
204
|
-
if (isUpdating) return;
|
|
205
|
-
const transformed = transformToComponent(val);
|
|
206
|
-
this.setValue(transformed);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
// Component → State
|
|
210
|
-
inputEl.addEventListener('change', (e) => {
|
|
211
|
-
if (isUpdating) return;
|
|
212
|
-
isUpdating = true;
|
|
213
|
-
|
|
214
|
-
const checked = (inputEl as HTMLInputElement).checked;
|
|
215
|
-
this.state.checked = checked;
|
|
216
|
-
this._clearError();
|
|
217
|
-
|
|
218
|
-
const transformed = transformToState(checked);
|
|
219
|
-
stateObj.set(transformed);
|
|
220
|
-
|
|
221
|
-
// 🎯 Fire the change callback event
|
|
222
|
-
this._triggerCallback('change', checked, e, this);
|
|
223
|
-
|
|
224
|
-
setTimeout(() => { isUpdating = false; }, 0);
|
|
225
|
-
});
|
|
226
|
-
} else {
|
|
227
|
-
// Default behavior without sync
|
|
228
|
-
inputEl.addEventListener('change', (e) => {
|
|
229
|
-
this.state.checked = inputEl.checked;
|
|
230
|
-
this._clearError();
|
|
231
|
-
|
|
232
|
-
// 🎯 Fire the change callback event
|
|
233
|
-
this._triggerCallback('change', inputEl.checked, e, this);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Always add blur validation
|
|
238
|
-
inputEl.addEventListener('blur', () => {
|
|
239
|
-
if (this._hasBeenValidated) {
|
|
240
|
-
this.validate();
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// Sync label changes
|
|
245
|
-
const labelSync = this._syncBindings.find(b => b.property === 'label');
|
|
246
|
-
if (labelSync) {
|
|
247
|
-
const transform = labelSync.toComponent || ((v: any) => String(v));
|
|
248
|
-
labelSync.stateObj.subscribe((val: any) => {
|
|
249
|
-
this.label(transform(val));
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
container.appendChild(wrapper);
|
|
254
|
-
return this;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export function checkbox(id: string, options: CheckboxOptions = {}): Checkbox {
|
|
259
|
-
return new Checkbox(id, options);
|
|
260
|
-
}
|
package/lib/components/code.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
export interface CodeOptions {
|
|
3
|
-
content?: string;
|
|
4
|
-
language?: string;
|
|
5
|
-
showLineNumbers?: boolean;
|
|
6
|
-
startLine?: number;
|
|
7
|
-
highlightLines?: number[];
|
|
8
|
-
style?: string;
|
|
9
|
-
class?: string;
|
|
10
|
-
}
|
|
11
|
-
type CodeState = {
|
|
12
|
-
content: string;
|
|
13
|
-
language: string;
|
|
14
|
-
showLineNumbers: boolean;
|
|
15
|
-
startLine: number;
|
|
16
|
-
highlightLines: number[];
|
|
17
|
-
style: string;
|
|
18
|
-
class: string;
|
|
19
|
-
};
|
|
20
|
-
export declare class Code extends BaseComponent<CodeState> {
|
|
21
|
-
private _codeContainer;
|
|
22
|
-
private static _syntaxCSSInjected;
|
|
23
|
-
constructor(id: string, options?: CodeOptions);
|
|
24
|
-
protected getTriggerEvents(): readonly string[];
|
|
25
|
-
protected getCallbackEvents(): readonly string[];
|
|
26
|
-
update(prop: string, value: any): void;
|
|
27
|
-
content(value: string): this;
|
|
28
|
-
language(value: string): this;
|
|
29
|
-
showLineNumbers(value: boolean): this;
|
|
30
|
-
startLine(value: number): this;
|
|
31
|
-
highlightLines(lines: number[]): this;
|
|
32
|
-
/**
|
|
33
|
-
* Parse code content into individual lines with tokens
|
|
34
|
-
*/
|
|
35
|
-
private _parseLines;
|
|
36
|
-
/**
|
|
37
|
-
* Rebuild all line elements
|
|
38
|
-
*/
|
|
39
|
-
private _rebuildLines;
|
|
40
|
-
/**
|
|
41
|
-
* Create a single line element with parsed tokens
|
|
42
|
-
*/
|
|
43
|
-
private _createLineElement;
|
|
44
|
-
/**
|
|
45
|
-
* Update highlighted lines without full rebuild
|
|
46
|
-
*/
|
|
47
|
-
private _updateHighlights;
|
|
48
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
49
|
-
}
|
|
50
|
-
export declare function code(id: string, options?: CodeOptions): Code;
|
|
51
|
-
export {};
|
|
52
|
-
//# sourceMappingURL=code.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;IAChD,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAS;gBAE9B,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAYjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAIhD,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;IAsBtC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKrC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IASrC;;OAEG;IACH,OAAO,CAAC,WAAW;IAInB;;OAEG;IACH,OAAO,CAAC,aAAa;IAoBrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA0B1B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAezB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA4EnE;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
|
package/lib/components/code.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { parseCode, renderLineWithTokens, getSyntaxHighlightCSS } from '../utils/codeparser.js';
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [];
|
|
5
|
-
const CALLBACK_EVENTS = [];
|
|
6
|
-
export class Code extends BaseComponent {
|
|
7
|
-
constructor(id, options = {}) {
|
|
8
|
-
super(id, {
|
|
9
|
-
content: options.content ?? '',
|
|
10
|
-
language: options.language ?? 'javascript',
|
|
11
|
-
showLineNumbers: options.showLineNumbers ?? true,
|
|
12
|
-
startLine: options.startLine ?? 1,
|
|
13
|
-
highlightLines: options.highlightLines ?? [],
|
|
14
|
-
style: options.style ?? '',
|
|
15
|
-
class: options.class ?? ''
|
|
16
|
-
});
|
|
17
|
-
this._codeContainer = null;
|
|
18
|
-
}
|
|
19
|
-
getTriggerEvents() {
|
|
20
|
-
return TRIGGER_EVENTS;
|
|
21
|
-
}
|
|
22
|
-
getCallbackEvents() {
|
|
23
|
-
return CALLBACK_EVENTS;
|
|
24
|
-
}
|
|
25
|
-
update(prop, value) {
|
|
26
|
-
super.update(prop, value);
|
|
27
|
-
if (!this._codeContainer)
|
|
28
|
-
return;
|
|
29
|
-
switch (prop) {
|
|
30
|
-
case 'content':
|
|
31
|
-
this._rebuildLines();
|
|
32
|
-
break;
|
|
33
|
-
case 'showLineNumbers':
|
|
34
|
-
this._codeContainer.classList.toggle('jux-code-no-numbers', !value);
|
|
35
|
-
break;
|
|
36
|
-
case 'highlightLines':
|
|
37
|
-
this._updateHighlights();
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
42
|
-
* FLUENT API
|
|
43
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
44
|
-
content(value) {
|
|
45
|
-
this.state.content = value;
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
language(value) {
|
|
49
|
-
this.state.language = value;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
showLineNumbers(value) {
|
|
53
|
-
this.state.showLineNumbers = value;
|
|
54
|
-
return this;
|
|
55
|
-
}
|
|
56
|
-
startLine(value) {
|
|
57
|
-
this.state.startLine = value;
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
highlightLines(lines) {
|
|
61
|
-
this.state.highlightLines = lines;
|
|
62
|
-
return this;
|
|
63
|
-
}
|
|
64
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
65
|
-
* PARSING & RENDERING
|
|
66
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
67
|
-
/**
|
|
68
|
-
* Parse code content into individual lines with tokens
|
|
69
|
-
*/
|
|
70
|
-
_parseLines() {
|
|
71
|
-
return parseCode(this.state.content, this.state.language);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Rebuild all line elements
|
|
75
|
-
*/
|
|
76
|
-
_rebuildLines() {
|
|
77
|
-
if (!this._codeContainer)
|
|
78
|
-
return;
|
|
79
|
-
const codeEl = this._codeContainer.querySelector('.jux-code-lines');
|
|
80
|
-
if (!codeEl)
|
|
81
|
-
return;
|
|
82
|
-
codeEl.innerHTML = '';
|
|
83
|
-
const parsedLines = this._parseLines();
|
|
84
|
-
const { startLine, highlightLines } = this.state;
|
|
85
|
-
parsedLines.forEach((parsedLine, index) => {
|
|
86
|
-
const lineNumber = startLine + index;
|
|
87
|
-
const isHighlighted = highlightLines.includes(lineNumber);
|
|
88
|
-
const lineEl = this._createLineElement(parsedLine, lineNumber, isHighlighted);
|
|
89
|
-
codeEl.appendChild(lineEl);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Create a single line element with parsed tokens
|
|
94
|
-
*/
|
|
95
|
-
_createLineElement(parsedLine, lineNumber, highlighted) {
|
|
96
|
-
const lineEl = document.createElement('div');
|
|
97
|
-
lineEl.className = 'jux-code-line';
|
|
98
|
-
lineEl.setAttribute('data-line', String(lineNumber));
|
|
99
|
-
if (highlighted) {
|
|
100
|
-
lineEl.classList.add('jux-code-line-highlight');
|
|
101
|
-
}
|
|
102
|
-
// Line number
|
|
103
|
-
if (this.state.showLineNumbers) {
|
|
104
|
-
const lineNum = document.createElement('span');
|
|
105
|
-
lineNum.className = 'jux-code-line-number';
|
|
106
|
-
lineNum.textContent = String(lineNumber);
|
|
107
|
-
lineEl.appendChild(lineNum);
|
|
108
|
-
}
|
|
109
|
-
// Line content with syntax highlighting
|
|
110
|
-
const lineCode = document.createElement('span');
|
|
111
|
-
lineCode.className = 'jux-code-line-content';
|
|
112
|
-
lineCode.innerHTML = renderLineWithTokens(parsedLine);
|
|
113
|
-
lineEl.appendChild(lineCode);
|
|
114
|
-
return lineEl;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Update highlighted lines without full rebuild
|
|
118
|
-
*/
|
|
119
|
-
_updateHighlights() {
|
|
120
|
-
if (!this._codeContainer)
|
|
121
|
-
return;
|
|
122
|
-
const lines = this._codeContainer.querySelectorAll('.jux-code-line');
|
|
123
|
-
lines.forEach((line) => {
|
|
124
|
-
const lineNum = parseInt(line.getAttribute('data-line') || '0', 10);
|
|
125
|
-
const isHighlighted = this.state.highlightLines.includes(lineNum);
|
|
126
|
-
line.classList.toggle('jux-code-line-highlight', isHighlighted);
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
130
|
-
* RENDER
|
|
131
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
132
|
-
render(targetId) {
|
|
133
|
-
const container = this._setupContainer(targetId);
|
|
134
|
-
// ✅ Inject syntax CSS once globally
|
|
135
|
-
if (!Code._syntaxCSSInjected) {
|
|
136
|
-
const style = document.createElement('style');
|
|
137
|
-
style.id = 'jux-code-syntax-css';
|
|
138
|
-
style.textContent = getSyntaxHighlightCSS();
|
|
139
|
-
document.head.appendChild(style);
|
|
140
|
-
Code._syntaxCSSInjected = true;
|
|
141
|
-
}
|
|
142
|
-
const { language, showLineNumbers, style, class: className } = this.state;
|
|
143
|
-
const wrapper = document.createElement('div');
|
|
144
|
-
wrapper.className = 'jux-code';
|
|
145
|
-
wrapper.id = this._id;
|
|
146
|
-
if (!showLineNumbers)
|
|
147
|
-
wrapper.classList.add('jux-code-no-numbers');
|
|
148
|
-
if (className)
|
|
149
|
-
wrapper.className += ` ${className}`;
|
|
150
|
-
if (style)
|
|
151
|
-
wrapper.setAttribute('style', style);
|
|
152
|
-
// ✅ Remove <pre>, just use a div with code styling
|
|
153
|
-
const codeEl = document.createElement('div');
|
|
154
|
-
codeEl.className = 'jux-code-lines';
|
|
155
|
-
// Build initial lines with parsed tokens
|
|
156
|
-
const parsedLines = this._parseLines();
|
|
157
|
-
const { startLine, highlightLines } = this.state;
|
|
158
|
-
parsedLines.forEach((parsedLine, index) => {
|
|
159
|
-
const lineNumber = startLine + index;
|
|
160
|
-
const isHighlighted = highlightLines.includes(lineNumber);
|
|
161
|
-
const lineEl = this._createLineElement(parsedLine, lineNumber, isHighlighted);
|
|
162
|
-
codeEl.appendChild(lineEl);
|
|
163
|
-
});
|
|
164
|
-
wrapper.appendChild(codeEl);
|
|
165
|
-
this._wireStandardEvents(wrapper);
|
|
166
|
-
// Wire sync bindings
|
|
167
|
-
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
168
|
-
if (property === 'content') {
|
|
169
|
-
const transform = toComponent || ((v) => String(v));
|
|
170
|
-
stateObj.subscribe((val) => {
|
|
171
|
-
const transformed = transform(val);
|
|
172
|
-
this.state.content = transformed;
|
|
173
|
-
this._rebuildLines();
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
else if (property === 'language') {
|
|
177
|
-
const transform = toComponent || ((v) => String(v));
|
|
178
|
-
stateObj.subscribe((val) => {
|
|
179
|
-
const transformed = transform(val);
|
|
180
|
-
this.state.language = transformed;
|
|
181
|
-
this._rebuildLines();
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
else if (property === 'highlightLines') {
|
|
185
|
-
const transform = toComponent || ((v) => (Array.isArray(v) ? v : []));
|
|
186
|
-
stateObj.subscribe((val) => {
|
|
187
|
-
const transformed = transform(val);
|
|
188
|
-
this.state.highlightLines = transformed;
|
|
189
|
-
this._updateHighlights();
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
container.appendChild(wrapper);
|
|
194
|
-
this._codeContainer = wrapper;
|
|
195
|
-
return this;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
Code._syntaxCSSInjected = false;
|
|
199
|
-
export function code(id, options = {}) {
|
|
200
|
-
return new Code(id, options);
|
|
201
|
-
}
|