juxscript 1.1.2 → 1.1.4
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/machinery/build3.js +7 -91
- package/machinery/compiler3.js +3 -209
- package/machinery/config.js +93 -6
- package/machinery/serve.js +255 -0
- package/machinery/watcher.js +49 -161
- package/package.json +19 -5
- package/lib/components/alert.ts +0 -200
- package/lib/components/app.ts +0 -247
- package/lib/components/badge.ts +0 -101
- package/lib/components/base/BaseComponent.ts +0 -421
- package/lib/components/base/FormInput.ts +0 -227
- package/lib/components/button.ts +0 -178
- package/lib/components/card.ts +0 -173
- package/lib/components/chart.ts +0 -231
- package/lib/components/checkbox.ts +0 -242
- package/lib/components/code.ts +0 -123
- package/lib/components/container.ts +0 -140
- package/lib/components/data.ts +0 -135
- package/lib/components/datepicker.ts +0 -234
- package/lib/components/dialog.ts +0 -172
- package/lib/components/divider.ts +0 -100
- package/lib/components/dropdown.ts +0 -186
- package/lib/components/element.ts +0 -267
- package/lib/components/fileupload.ts +0 -309
- package/lib/components/grid.ts +0 -291
- package/lib/components/guard.ts +0 -92
- package/lib/components/heading.ts +0 -96
- package/lib/components/helpers.ts +0 -41
- package/lib/components/hero.ts +0 -224
- package/lib/components/icon.ts +0 -178
- package/lib/components/icons.ts +0 -464
- package/lib/components/include.ts +0 -410
- package/lib/components/input.ts +0 -457
- package/lib/components/list.ts +0 -419
- package/lib/components/loading.ts +0 -100
- package/lib/components/menu.ts +0 -275
- package/lib/components/modal.ts +0 -284
- package/lib/components/nav.ts +0 -257
- package/lib/components/paragraph.ts +0 -97
- package/lib/components/progress.ts +0 -159
- package/lib/components/radio.ts +0 -278
- package/lib/components/req.ts +0 -303
- package/lib/components/script.ts +0 -41
- package/lib/components/select.ts +0 -252
- package/lib/components/sidebar.ts +0 -275
- package/lib/components/style.ts +0 -41
- package/lib/components/switch.ts +0 -246
- package/lib/components/table.ts +0 -1249
- package/lib/components/tabs.ts +0 -250
- package/lib/components/theme-toggle.ts +0 -293
- package/lib/components/tooltip.ts +0 -144
- package/lib/components/view.ts +0 -190
- package/lib/components/write.ts +0 -272
- package/lib/layouts/default.css +0 -260
- package/lib/layouts/figma.css +0 -334
- package/lib/reactivity/state.ts +0 -78
- package/lib/utils/fetch.ts +0 -553
- package/machinery/ast.js +0 -347
- package/machinery/build.js +0 -466
- package/machinery/bundleAssets.js +0 -0
- package/machinery/bundleJux.js +0 -0
- package/machinery/bundleVendors.js +0 -0
- package/machinery/doc-generator.js +0 -136
- package/machinery/imports.js +0 -155
- package/machinery/server.js +0 -166
- package/machinery/ts-shim.js +0 -46
- package/machinery/validators/file-validator.js +0 -123
package/lib/components/select.ts
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { FormInput, FormInputState } from './base/FormInput.js';
|
|
2
|
-
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [] as const;
|
|
5
|
-
const CALLBACK_EVENTS = ['change'] as const;
|
|
6
|
-
|
|
7
|
-
export interface SelectOption {
|
|
8
|
-
label: string;
|
|
9
|
-
value: string;
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface SelectOptions {
|
|
14
|
-
options?: SelectOption[];
|
|
15
|
-
value?: string;
|
|
16
|
-
label?: string;
|
|
17
|
-
placeholder?: string;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
name?: string;
|
|
21
|
-
style?: string;
|
|
22
|
-
class?: string;
|
|
23
|
-
onValidate?: (value: string) => boolean | string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface SelectState extends FormInputState {
|
|
27
|
-
options: SelectOption[];
|
|
28
|
-
value: string;
|
|
29
|
-
placeholder: string;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export class Select extends FormInput<SelectState> {
|
|
33
|
-
constructor(id: string, options: SelectOptions = {}) {
|
|
34
|
-
super(id, {
|
|
35
|
-
options: options.options ?? [],
|
|
36
|
-
value: options.value ?? '',
|
|
37
|
-
placeholder: options.placeholder ?? 'Select an option',
|
|
38
|
-
label: options.label ?? '',
|
|
39
|
-
required: options.required ?? false,
|
|
40
|
-
disabled: options.disabled ?? false,
|
|
41
|
-
name: options.name ?? id,
|
|
42
|
-
style: options.style ?? '',
|
|
43
|
-
class: options.class ?? '',
|
|
44
|
-
errorMessage: undefined
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
if (options.onValidate) {
|
|
48
|
-
this._onValidate = options.onValidate;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
protected getTriggerEvents(): readonly string[] {
|
|
53
|
-
return TRIGGER_EVENTS;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
protected getCallbackEvents(): readonly string[] {
|
|
57
|
-
return CALLBACK_EVENTS;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
61
|
-
* FLUENT API
|
|
62
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
63
|
-
|
|
64
|
-
// ✅ Inherited from FormInput/BaseComponent:
|
|
65
|
-
// - label(), required(), name(), onValidate()
|
|
66
|
-
// - validate(), isValid()
|
|
67
|
-
// - style(), class()
|
|
68
|
-
// - bind(), sync(), renderTo()
|
|
69
|
-
// - disabled(), enable(), disable()
|
|
70
|
-
|
|
71
|
-
options(value: SelectOption[]): this {
|
|
72
|
-
this.state.options = value;
|
|
73
|
-
return this;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
value(value: string): this {
|
|
77
|
-
return this.setValue(value);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
placeholder(value: string): this {
|
|
81
|
-
this.state.placeholder = value;
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
addOption(option: SelectOption): this {
|
|
86
|
-
this.state.options = [...this.state.options, option];
|
|
87
|
-
return this;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
91
|
-
* FORM INPUT IMPLEMENTATION
|
|
92
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
93
|
-
|
|
94
|
-
getValue(): string {
|
|
95
|
-
return this.state.value;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
setValue(value: string): this {
|
|
99
|
-
this.state.value = value;
|
|
100
|
-
|
|
101
|
-
if (this._inputElement) {
|
|
102
|
-
(this._inputElement as HTMLSelectElement).value = value;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
protected _validateValue(value: string): boolean | string {
|
|
109
|
-
const { required, options } = this.state;
|
|
110
|
-
|
|
111
|
-
if (required && !value) {
|
|
112
|
-
return 'Please select an option';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Validate that value is one of the options
|
|
116
|
-
if (value && !options.some(opt => opt.value === value)) {
|
|
117
|
-
return 'Invalid option selected';
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (this._onValidate) {
|
|
121
|
-
const result = this._onValidate(value);
|
|
122
|
-
if (result !== true) {
|
|
123
|
-
return result || 'Invalid value';
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
protected _buildInputElement(): HTMLElement {
|
|
131
|
-
const { options, value, placeholder, required, disabled, name } = this.state;
|
|
132
|
-
|
|
133
|
-
const select = document.createElement('select');
|
|
134
|
-
select.className = 'jux-input-element jux-select-element';
|
|
135
|
-
select.id = `${this._id}-input`;
|
|
136
|
-
select.name = name;
|
|
137
|
-
select.required = required;
|
|
138
|
-
select.disabled = disabled;
|
|
139
|
-
|
|
140
|
-
// Placeholder option
|
|
141
|
-
if (placeholder) {
|
|
142
|
-
const placeholderOption = document.createElement('option');
|
|
143
|
-
placeholderOption.value = '';
|
|
144
|
-
placeholderOption.textContent = placeholder;
|
|
145
|
-
placeholderOption.disabled = true;
|
|
146
|
-
placeholderOption.selected = !value;
|
|
147
|
-
select.appendChild(placeholderOption);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Options
|
|
151
|
-
options.forEach(option => {
|
|
152
|
-
const optionEl = document.createElement('option');
|
|
153
|
-
optionEl.value = option.value;
|
|
154
|
-
optionEl.textContent = option.label;
|
|
155
|
-
optionEl.disabled = option.disabled || false;
|
|
156
|
-
optionEl.selected = option.value === value;
|
|
157
|
-
select.appendChild(optionEl);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return select;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
164
|
-
* RENDER
|
|
165
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
166
|
-
|
|
167
|
-
render(targetId?: string): this {
|
|
168
|
-
const container = this._setupContainer(targetId);
|
|
169
|
-
|
|
170
|
-
const { style, class: className } = this.state;
|
|
171
|
-
|
|
172
|
-
// Build wrapper
|
|
173
|
-
const wrapper = document.createElement('div');
|
|
174
|
-
wrapper.className = 'jux-input jux-select';
|
|
175
|
-
wrapper.id = this._id;
|
|
176
|
-
if (className) wrapper.className += ` ${className}`;
|
|
177
|
-
if (style) wrapper.setAttribute('style', style);
|
|
178
|
-
|
|
179
|
-
// Label
|
|
180
|
-
if (this.state.label) {
|
|
181
|
-
wrapper.appendChild(this._renderLabel());
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// Select container
|
|
185
|
-
const selectContainer = document.createElement('div');
|
|
186
|
-
selectContainer.className = 'jux-input-container jux-select-container';
|
|
187
|
-
|
|
188
|
-
// Select element
|
|
189
|
-
const selectEl = this._buildInputElement() as HTMLSelectElement;
|
|
190
|
-
this._inputElement = selectEl;
|
|
191
|
-
selectContainer.appendChild(selectEl);
|
|
192
|
-
wrapper.appendChild(selectContainer);
|
|
193
|
-
|
|
194
|
-
// Error element
|
|
195
|
-
wrapper.appendChild(this._renderError());
|
|
196
|
-
|
|
197
|
-
// Wire events
|
|
198
|
-
this._wireStandardEvents(wrapper);
|
|
199
|
-
this._wireFormSync(selectEl, 'change');
|
|
200
|
-
|
|
201
|
-
// Sync label changes
|
|
202
|
-
const labelSync = this._syncBindings.find(b => b.property === 'label');
|
|
203
|
-
if (labelSync) {
|
|
204
|
-
const transform = labelSync.toComponent || ((v: any) => String(v));
|
|
205
|
-
labelSync.stateObj.subscribe((val: any) => {
|
|
206
|
-
this.label(transform(val));
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Sync options changes
|
|
211
|
-
const optionsSync = this._syncBindings.find(b => b.property === 'options');
|
|
212
|
-
if (optionsSync) {
|
|
213
|
-
const transform = optionsSync.toComponent || ((v: any) => v);
|
|
214
|
-
optionsSync.stateObj.subscribe((val: any) => {
|
|
215
|
-
const transformed = transform(val);
|
|
216
|
-
this.state.options = transformed;
|
|
217
|
-
|
|
218
|
-
// Rebuild select options
|
|
219
|
-
selectEl.innerHTML = '';
|
|
220
|
-
|
|
221
|
-
if (this.state.placeholder) {
|
|
222
|
-
const placeholderOption = document.createElement('option');
|
|
223
|
-
placeholderOption.value = '';
|
|
224
|
-
placeholderOption.textContent = this.state.placeholder;
|
|
225
|
-
placeholderOption.disabled = true;
|
|
226
|
-
placeholderOption.selected = !this.state.value;
|
|
227
|
-
selectEl.appendChild(placeholderOption);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
transformed.forEach((option: SelectOption) => {
|
|
231
|
-
const optionEl = document.createElement('option');
|
|
232
|
-
optionEl.value = option.value;
|
|
233
|
-
optionEl.textContent = option.label;
|
|
234
|
-
optionEl.disabled = option.disabled || false;
|
|
235
|
-
optionEl.selected = option.value === this.state.value;
|
|
236
|
-
selectEl.appendChild(optionEl);
|
|
237
|
-
});
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
container.appendChild(wrapper);
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
return this;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export function select(id: string, options: SelectOptions = {}): Select {
|
|
251
|
-
return new Select(id, options);
|
|
252
|
-
}
|
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
import { renderIcon } from './icons.js';
|
|
3
|
-
import { Menu, MenuOptions } from './menu.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// Event definitions
|
|
7
|
-
const TRIGGER_EVENTS = [] as const;
|
|
8
|
-
const CALLBACK_EVENTS = ['toggle'] as const;
|
|
9
|
-
|
|
10
|
-
export interface SidebarOptions {
|
|
11
|
-
position?: 'left' | 'right';
|
|
12
|
-
width?: string;
|
|
13
|
-
collapsible?: boolean;
|
|
14
|
-
showToggle?: boolean;
|
|
15
|
-
expandOnHover?: boolean;
|
|
16
|
-
collapsed?: boolean;
|
|
17
|
-
menu?: MenuOptions;
|
|
18
|
-
style?: string;
|
|
19
|
-
class?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type SidebarState = {
|
|
23
|
-
position: 'left' | 'right';
|
|
24
|
-
width: string;
|
|
25
|
-
collapsible: boolean;
|
|
26
|
-
showToggle: boolean;
|
|
27
|
-
expandOnHover: boolean;
|
|
28
|
-
collapsed: boolean;
|
|
29
|
-
menu: MenuOptions | null;
|
|
30
|
-
style: string;
|
|
31
|
-
class: string;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
export class Sidebar extends BaseComponent<SidebarState> {
|
|
35
|
-
private _sidebar: HTMLElement | null = null;
|
|
36
|
-
private _menu: Menu | null = null;
|
|
37
|
-
|
|
38
|
-
constructor(id: string, options: SidebarOptions = {}) {
|
|
39
|
-
// Restore collapsed state from localStorage if available
|
|
40
|
-
const storageKey = `jux-sidebar-${id}-collapsed`;
|
|
41
|
-
const savedCollapsed = localStorage.getItem(storageKey);
|
|
42
|
-
const initialCollapsed = savedCollapsed !== null ? savedCollapsed === 'true' : (options.collapsed ?? false);
|
|
43
|
-
|
|
44
|
-
super(id, {
|
|
45
|
-
position: options.position ?? 'left',
|
|
46
|
-
width: options.width ?? '',
|
|
47
|
-
collapsible: options.collapsible ?? true,
|
|
48
|
-
showToggle: options.showToggle ?? false,
|
|
49
|
-
expandOnHover: options.expandOnHover ?? false,
|
|
50
|
-
collapsed: initialCollapsed,
|
|
51
|
-
menu: options.menu ?? null,
|
|
52
|
-
style: options.style ?? '',
|
|
53
|
-
class: options.class ?? ''
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Listen for URL changes to update menu active states
|
|
57
|
-
if (typeof window !== 'undefined') {
|
|
58
|
-
window.addEventListener('popstate', () => this.refreshMenu());
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected getTriggerEvents(): readonly string[] {
|
|
63
|
-
return TRIGGER_EVENTS;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected getCallbackEvents(): readonly string[] {
|
|
67
|
-
return CALLBACK_EVENTS;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
71
|
-
* FLUENT API
|
|
72
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
73
|
-
|
|
74
|
-
// ✅ Inherited from BaseComponent:
|
|
75
|
-
// - style(), class()
|
|
76
|
-
// - bind(), sync(), renderTo()
|
|
77
|
-
// - addClass(), removeClass(), toggleClass()
|
|
78
|
-
// - visible(), show(), hide()
|
|
79
|
-
// - attr(), attrs(), removeAttr()
|
|
80
|
-
// - disabled(), enable(), disable()
|
|
81
|
-
// - loading(), focus(), blur(), remove()
|
|
82
|
-
|
|
83
|
-
width(value: string): this {
|
|
84
|
-
this.state.width = value;
|
|
85
|
-
return this;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
position(value: 'left' | 'right'): this {
|
|
89
|
-
this.state.position = value;
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
collapsible(value: boolean): this {
|
|
94
|
-
this.state.collapsible = value;
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
showToggle(value: boolean): this {
|
|
99
|
-
this.state.showToggle = value;
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
expandOnHover(value: boolean): this {
|
|
104
|
-
this.state.expandOnHover = value;
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
collapsed(value: boolean): this {
|
|
109
|
-
this.state.collapsed = value;
|
|
110
|
-
this._updateCollapsedState();
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
menu(value: MenuOptions): this {
|
|
115
|
-
this.state.menu = value;
|
|
116
|
-
return this;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
toggle(): void {
|
|
120
|
-
this.state.collapsed = !this.state.collapsed;
|
|
121
|
-
this._updateCollapsedState();
|
|
122
|
-
|
|
123
|
-
// Save to localStorage
|
|
124
|
-
const storageKey = `jux-sidebar-${this._id}-collapsed`;
|
|
125
|
-
localStorage.setItem(storageKey, String(this.state.collapsed));
|
|
126
|
-
|
|
127
|
-
// 🎯 Fire the toggle callback event
|
|
128
|
-
this._triggerCallback('toggle', this.state.collapsed);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Refresh menu active states (called automatically on URL changes)
|
|
133
|
-
*/
|
|
134
|
-
refreshMenu(): this {
|
|
135
|
-
if (this._menu && this.state.menu) {
|
|
136
|
-
// Re-evaluate and update menu items with current active states
|
|
137
|
-
this._menu.items(this.state.menu.items || []);
|
|
138
|
-
}
|
|
139
|
-
return this;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
private _updateCollapsedState(): void {
|
|
143
|
-
if (this._sidebar) {
|
|
144
|
-
this._sidebar.classList.toggle('jux-sidebar-collapsed', this.state.collapsed);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
149
|
-
* RENDER
|
|
150
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
151
|
-
|
|
152
|
-
render(targetId?: string): this {
|
|
153
|
-
const container = this._setupContainer(targetId);
|
|
154
|
-
|
|
155
|
-
const { position, collapsed, expandOnHover, menu, style, class: className } = this.state;
|
|
156
|
-
|
|
157
|
-
// Build sidebar element
|
|
158
|
-
const sidebar = document.createElement('aside');
|
|
159
|
-
sidebar.id = this._id;
|
|
160
|
-
if (className) sidebar.className = className;
|
|
161
|
-
if (style) sidebar.setAttribute('style', style);
|
|
162
|
-
|
|
163
|
-
// Apply initial collapsed state
|
|
164
|
-
if (collapsed) {
|
|
165
|
-
sidebar.classList.add('jux-sidebar-collapsed');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Menu container (append first so toggle appears at bottom)
|
|
169
|
-
const menuContainer = document.createElement('div');
|
|
170
|
-
menuContainer.className = 'jux-sidebar-menu';
|
|
171
|
-
menuContainer.id = `${this._id}-menu`;
|
|
172
|
-
sidebar.appendChild(menuContainer);
|
|
173
|
-
|
|
174
|
-
// Toggle button (append last so it appears at bottom)
|
|
175
|
-
if (this.state.collapsible || this.state.showToggle) {
|
|
176
|
-
const toggleBtn = document.createElement('button');
|
|
177
|
-
toggleBtn.className = 'jux-sidebar-toggle';
|
|
178
|
-
toggleBtn.type = 'button';
|
|
179
|
-
|
|
180
|
-
const toggleIcon = document.createElement('span');
|
|
181
|
-
toggleIcon.className = 'jux-sidebar-toggle-icon';
|
|
182
|
-
const chevronIcon = renderIcon(position === 'left' ? '➡️' : '⬅️');
|
|
183
|
-
toggleIcon.appendChild(chevronIcon);
|
|
184
|
-
toggleBtn.appendChild(toggleIcon);
|
|
185
|
-
|
|
186
|
-
if (collapsed) {
|
|
187
|
-
toggleBtn.classList.add('jux-sidebar-toggle-collapsed');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
toggleBtn.addEventListener('click', () => {
|
|
191
|
-
this.toggle();
|
|
192
|
-
toggleBtn.classList.toggle('jux-sidebar-toggle-collapsed', this.state.collapsed);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
sidebar.appendChild(toggleBtn);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
// Handle expand on hover
|
|
199
|
-
if (expandOnHover) {
|
|
200
|
-
sidebar.addEventListener('mouseenter', () => {
|
|
201
|
-
if (this.state.collapsed) {
|
|
202
|
-
sidebar.classList.add('jux-sidebar-hover-expanded');
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
sidebar.addEventListener('mouseleave', () => {
|
|
207
|
-
if (this.state.collapsed) {
|
|
208
|
-
sidebar.classList.remove('jux-sidebar-hover-expanded');
|
|
209
|
-
}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// Wire events using inherited method
|
|
214
|
-
this._wireStandardEvents(sidebar);
|
|
215
|
-
|
|
216
|
-
// Wire sync bindings for 'collapsed' property
|
|
217
|
-
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
218
|
-
if (property === 'collapsed') {
|
|
219
|
-
const transform = toComponent || ((v: any) => v);
|
|
220
|
-
|
|
221
|
-
stateObj.subscribe((val: any) => {
|
|
222
|
-
const transformed = transform(val);
|
|
223
|
-
const isCollapsed = Boolean(transformed);
|
|
224
|
-
this.state.collapsed = isCollapsed;
|
|
225
|
-
this._updateCollapsedState();
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
else if (property === 'menu') {
|
|
229
|
-
const transform = toComponent || ((v: any) => v);
|
|
230
|
-
|
|
231
|
-
stateObj.subscribe((val: any) => {
|
|
232
|
-
const transformed = transform(val);
|
|
233
|
-
this.state.menu = transformed;
|
|
234
|
-
|
|
235
|
-
// Update menu items if menu instance exists
|
|
236
|
-
if (this._menu) {
|
|
237
|
-
this._menu.items(transformed.items || []);
|
|
238
|
-
|
|
239
|
-
// Re-render the menu
|
|
240
|
-
const menuEl = menuContainer.querySelector(`#${this._id}-menu-instance`);
|
|
241
|
-
if (menuEl) {
|
|
242
|
-
menuEl.remove();
|
|
243
|
-
}
|
|
244
|
-
this._menu.render(`#${menuContainer.id}`);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
container.appendChild(sidebar);
|
|
251
|
-
this._sidebar = sidebar;
|
|
252
|
-
|
|
253
|
-
// Create and render menu (after sidebar is in DOM)
|
|
254
|
-
if (menu) {
|
|
255
|
-
this._menu = new Menu(`${this._id}-menu-instance`, {
|
|
256
|
-
...menu,
|
|
257
|
-
orientation: 'vertical'
|
|
258
|
-
});
|
|
259
|
-
this._menu.render(`#${menuContainer.id}`);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Trigger Iconify icon rendering
|
|
263
|
-
requestAnimationFrame(() => {
|
|
264
|
-
if ((window as any).Iconify) {
|
|
265
|
-
(window as any).Iconify.scan();
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
return this;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
export function sidebar(id: string, options: SidebarOptions = {}): Sidebar {
|
|
274
|
-
return new Sidebar(id, options);
|
|
275
|
-
}
|
package/lib/components/style.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Style - Inject inline CSS into the document
|
|
3
|
-
* For external stylesheets, use Import component instead
|
|
4
|
-
* Auto-renders when created or modified
|
|
5
|
-
*/
|
|
6
|
-
export class Style {
|
|
7
|
-
private _id: string;
|
|
8
|
-
private css: string;
|
|
9
|
-
|
|
10
|
-
constructor(css: string, id?: string) {
|
|
11
|
-
// ID only for deduplication, auto-generate if not provided
|
|
12
|
-
this._id = id || `jux-style-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
13
|
-
this.css = css;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
render(): this {
|
|
17
|
-
// Check if style with this ID already exists
|
|
18
|
-
if (document.getElementById(this._id)) {
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const style = document.createElement('style');
|
|
23
|
-
style.id = this._id;
|
|
24
|
-
style.textContent = this.css;
|
|
25
|
-
document.head.appendChild(style);
|
|
26
|
-
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
remove(): void {
|
|
31
|
-
const existing = document.getElementById(this._id);
|
|
32
|
-
if (existing) {
|
|
33
|
-
existing.remove();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ✅ ID is optional
|
|
39
|
-
export function style(css: string, id?: string): Style {
|
|
40
|
-
return new Style(css, id);
|
|
41
|
-
}
|