juxscript 1.0.132 → 1.1.2

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.
Files changed (133) hide show
  1. package/README.md +1 -32
  2. package/bin/cli.js +4 -2
  3. package/index.d.ts +200 -0
  4. package/index.js +96 -22
  5. package/juxconfig.example.js +58 -63
  6. package/lib/components/alert.ts +200 -0
  7. package/lib/components/app.ts +247 -0
  8. package/lib/components/badge.ts +101 -0
  9. package/lib/components/base/BaseComponent.ts +421 -0
  10. package/lib/components/base/FormInput.ts +227 -0
  11. package/lib/components/button.ts +178 -0
  12. package/lib/components/card.ts +173 -0
  13. package/lib/components/chart.ts +231 -0
  14. package/lib/components/checkbox.ts +242 -0
  15. package/lib/components/code.ts +123 -0
  16. package/lib/components/container.ts +140 -0
  17. package/lib/components/data.ts +135 -0
  18. package/lib/components/datepicker.ts +234 -0
  19. package/lib/components/dialog.ts +172 -0
  20. package/lib/components/divider.ts +100 -0
  21. package/lib/components/dropdown.ts +186 -0
  22. package/lib/components/element.ts +267 -0
  23. package/lib/components/fileupload.ts +309 -0
  24. package/lib/components/grid.ts +291 -0
  25. package/lib/components/guard.ts +92 -0
  26. package/lib/components/heading.ts +96 -0
  27. package/lib/components/helpers.ts +41 -0
  28. package/lib/components/hero.ts +224 -0
  29. package/lib/components/icon.ts +178 -0
  30. package/lib/components/icons.ts +464 -0
  31. package/lib/components/include.ts +410 -0
  32. package/lib/components/input.ts +457 -0
  33. package/lib/components/list.ts +419 -0
  34. package/lib/components/loading.ts +100 -0
  35. package/lib/components/menu.ts +275 -0
  36. package/lib/components/modal.ts +284 -0
  37. package/lib/components/nav.ts +257 -0
  38. package/lib/components/paragraph.ts +97 -0
  39. package/lib/components/progress.ts +159 -0
  40. package/lib/components/radio.ts +278 -0
  41. package/lib/components/req.ts +303 -0
  42. package/lib/components/script.ts +41 -0
  43. package/lib/components/select.ts +252 -0
  44. package/lib/components/sidebar.ts +275 -0
  45. package/lib/components/style.ts +41 -0
  46. package/lib/components/switch.ts +246 -0
  47. package/lib/components/table.ts +1249 -0
  48. package/lib/components/tabs.ts +250 -0
  49. package/lib/components/theme-toggle.ts +293 -0
  50. package/lib/components/tooltip.ts +144 -0
  51. package/lib/components/view.ts +190 -0
  52. package/lib/components/write.ts +272 -0
  53. package/lib/globals.d.ts +19 -5
  54. package/lib/layouts/default.css +260 -0
  55. package/lib/layouts/figma.css +334 -0
  56. package/lib/reactivity/state.ts +78 -0
  57. package/lib/utils/{fetch.js → fetch.ts} +206 -81
  58. package/machinery/ast.js +347 -0
  59. package/machinery/build.js +466 -0
  60. package/machinery/compiler3.js +6 -66
  61. package/machinery/config.js +6 -93
  62. package/machinery/doc-generator.js +136 -0
  63. package/machinery/imports.js +155 -0
  64. package/machinery/server.js +166 -0
  65. package/machinery/ts-shim.js +46 -0
  66. package/machinery/watcher.js +162 -50
  67. package/package.json +9 -30
  68. package/create/index.jux +0 -77
  69. package/create/layout.jux +0 -18
  70. package/create/style.css +0 -57
  71. package/create/themes/assets/jux.svg +0 -34
  72. package/create/themes/base.css +0 -197
  73. package/create/themes/base2.css +0 -54
  74. package/create/themes/layouts/base.jux +0 -16
  75. package/create/themes/layouts/base_marketing.jux +0 -0
  76. package/create/themes/layouts/base_saas.jux +0 -0
  77. package/lib/componentsv2/base/BaseEngine.d.ts +0 -112
  78. package/lib/componentsv2/base/BaseEngine.js +0 -279
  79. package/lib/componentsv2/base/BaseSkin.d.ts +0 -74
  80. package/lib/componentsv2/base/BaseSkin.js +0 -130
  81. package/lib/componentsv2/base/Neighborhood.d.ts +0 -22
  82. package/lib/componentsv2/base/Neighborhood.js +0 -56
  83. package/lib/componentsv2/base/OptionsContract.d.ts +0 -20
  84. package/lib/componentsv2/base/OptionsContract.js +0 -107
  85. package/lib/componentsv2/base/State.d.ts +0 -18
  86. package/lib/componentsv2/base/State.js +0 -68
  87. package/lib/componentsv2/element/Element.d.ts +0 -30
  88. package/lib/componentsv2/element/Element.js +0 -50
  89. package/lib/componentsv2/element/ElementEngine.d.ts +0 -59
  90. package/lib/componentsv2/element/ElementEngine.js +0 -118
  91. package/lib/componentsv2/element/ElementSkin.d.ts +0 -10
  92. package/lib/componentsv2/element/ElementSkin.js +0 -56
  93. package/lib/componentsv2/element/structure.css +0 -261
  94. package/lib/componentsv2/grid/Grid.d.ts +0 -13
  95. package/lib/componentsv2/grid/Grid.js +0 -27
  96. package/lib/componentsv2/grid/GridEngine.d.ts +0 -77
  97. package/lib/componentsv2/grid/GridEngine.js +0 -153
  98. package/lib/componentsv2/grid/GridSkin.d.ts +0 -11
  99. package/lib/componentsv2/grid/GridSkin.js +0 -84
  100. package/lib/componentsv2/grid/structure.css +0 -27
  101. package/lib/componentsv2/input/Input.d.ts +0 -6
  102. package/lib/componentsv2/input/Input.js +0 -21
  103. package/lib/componentsv2/input/InputEngine.d.ts +0 -70
  104. package/lib/componentsv2/input/InputEngine.js +0 -143
  105. package/lib/componentsv2/input/InputSkin.d.ts +0 -11
  106. package/lib/componentsv2/input/InputSkin.js +0 -89
  107. package/lib/componentsv2/input/structure.css +0 -47
  108. package/lib/componentsv2/list/List.d.ts +0 -49
  109. package/lib/componentsv2/list/List.js +0 -105
  110. package/lib/componentsv2/list/ListEngine.d.ts +0 -121
  111. package/lib/componentsv2/list/ListEngine.js +0 -322
  112. package/lib/componentsv2/list/ListSkin.d.ts +0 -20
  113. package/lib/componentsv2/list/ListSkin.js +0 -345
  114. package/lib/componentsv2/list/structure.css +0 -359
  115. package/lib/componentsv2/plugins/ClientSQLitePlugin.d.ts +0 -21
  116. package/lib/componentsv2/plugins/ClientSQLitePlugin.js +0 -130
  117. package/lib/componentsv2/plugins/IndexedDBPlugin.d.ts +0 -18
  118. package/lib/componentsv2/plugins/IndexedDBPlugin.js +0 -75
  119. package/lib/componentsv2/plugins/LocalStoragePlugin.d.ts +0 -20
  120. package/lib/componentsv2/plugins/LocalStoragePlugin.js +0 -65
  121. package/lib/componentsv2/plugins/ServerSQLitePlugin.d.ts +0 -25
  122. package/lib/componentsv2/plugins/ServerSQLitePlugin.js +0 -70
  123. package/lib/componentsv2/stubs/ComponentComposition.ts.stub +0 -32
  124. package/lib/componentsv2/stubs/ComponentEngine.ts.stub +0 -36
  125. package/lib/componentsv2/stubs/ComponentSkin.ts.stub +0 -35
  126. package/lib/componentsv2/stubs/ComponentStructure.css.d.ts.stub +0 -2
  127. package/lib/componentsv2/stubs/ComponentStructure.css.stub +0 -13
  128. package/lib/utils/fetch.d.ts +0 -176
  129. package/machinery/serve.js +0 -255
  130. package/types/css.d.ts +0 -10
  131. /package/{create/themes/layouts/base_blog.jux → machinery/bundleAssets.js} +0 -0
  132. /package/{create/themes/layouts/base_docs.jux → machinery/bundleJux.js} +0 -0
  133. /package/{create/themes/layouts/base_login.jux → machinery/bundleVendors.js} +0 -0
@@ -0,0 +1,252 @@
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
+ }
@@ -0,0 +1,275 @@
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
+ }
@@ -0,0 +1,41 @@
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
+ }