juxscript 1.0.62 → 1.0.63

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 (141) hide show
  1. package/bin/cli.js +161 -293
  2. package/docs/v2comps/HEADLESS.md +83 -0
  3. package/docs/v2comps/ISOMORPHISM.md +10 -0
  4. package/juxconfig.example.js +63 -58
  5. package/lib/componentsv2/base/BaseEngine.js +258 -0
  6. package/lib/componentsv2/base/BaseEngine.js.map +1 -0
  7. package/lib/componentsv2/base/BaseEngine.ts +303 -0
  8. package/lib/componentsv2/base/BaseSkin.js +108 -0
  9. package/lib/componentsv2/base/BaseSkin.js.map +1 -0
  10. package/lib/componentsv2/base/BaseSkin.ts +137 -0
  11. package/lib/componentsv2/base/GlobalBus.js +56 -0
  12. package/lib/componentsv2/base/GlobalBus.js.map +1 -0
  13. package/lib/componentsv2/base/GlobalBus.ts +60 -0
  14. package/lib/componentsv2/base/State.js +68 -0
  15. package/lib/componentsv2/base/State.js.map +1 -0
  16. package/lib/componentsv2/base/State.ts +62 -0
  17. package/lib/componentsv2/grid/component.js +41 -0
  18. package/lib/componentsv2/grid/component.js.map +1 -0
  19. package/lib/componentsv2/grid/component.ts +67 -0
  20. package/lib/componentsv2/grid/engine.js +73 -0
  21. package/lib/componentsv2/grid/engine.js.map +1 -0
  22. package/lib/componentsv2/grid/engine.ts +110 -0
  23. package/lib/componentsv2/grid/skin.js +95 -0
  24. package/lib/componentsv2/grid/skin.js.map +1 -0
  25. package/lib/componentsv2/grid/skin.ts +105 -0
  26. package/lib/componentsv2/grid/structure.css +58 -0
  27. package/lib/componentsv2/index.js +218 -0
  28. package/lib/componentsv2/index.js.map +1 -0
  29. package/lib/componentsv2/index.ts +253 -0
  30. package/lib/componentsv2/input/component.js +21 -0
  31. package/lib/componentsv2/input/component.js.map +1 -0
  32. package/lib/componentsv2/input/component.ts +28 -0
  33. package/lib/componentsv2/input/engine.js +50 -0
  34. package/lib/componentsv2/input/engine.js.map +1 -0
  35. package/lib/componentsv2/input/engine.ts +76 -0
  36. package/lib/componentsv2/input/skin.js +91 -0
  37. package/lib/componentsv2/input/skin.js.map +1 -0
  38. package/lib/componentsv2/input/skin.ts +91 -0
  39. package/lib/componentsv2/input/structure.css +47 -0
  40. package/lib/componentsv2/list/component.js +83 -0
  41. package/lib/componentsv2/list/component.js.map +1 -0
  42. package/lib/componentsv2/list/component.ts +97 -0
  43. package/lib/componentsv2/list/engine.js +261 -0
  44. package/lib/componentsv2/list/engine.js.map +1 -0
  45. package/lib/componentsv2/list/engine.ts +345 -0
  46. package/lib/componentsv2/list/skin.js +343 -0
  47. package/lib/componentsv2/list/skin.js.map +1 -0
  48. package/lib/componentsv2/list/skin.ts +367 -0
  49. package/lib/componentsv2/list/structure.css +359 -0
  50. package/lib/componentsv2/plugins/ClientSQLitePlugin.js +130 -0
  51. package/lib/componentsv2/plugins/ClientSQLitePlugin.js.map +1 -0
  52. package/lib/componentsv2/plugins/ClientSQLitePlugin.ts +154 -0
  53. package/lib/componentsv2/plugins/IndexedDBPlugin.js +75 -0
  54. package/lib/componentsv2/plugins/IndexedDBPlugin.js.map +1 -0
  55. package/lib/componentsv2/plugins/IndexedDBPlugin.ts +96 -0
  56. package/lib/componentsv2/plugins/LocalStoragePlugin.js +65 -0
  57. package/lib/componentsv2/plugins/LocalStoragePlugin.js.map +1 -0
  58. package/lib/componentsv2/plugins/LocalStoragePlugin.ts +86 -0
  59. package/lib/componentsv2/plugins/ServerSQLitePlugin.js +70 -0
  60. package/lib/componentsv2/plugins/ServerSQLitePlugin.js.map +1 -0
  61. package/lib/componentsv2/plugins/ServerSQLitePlugin.ts +99 -0
  62. package/lib/componentsv2/stubs/ComponentComposition.ts.stub +32 -0
  63. package/lib/componentsv2/stubs/ComponentEngine.ts.stub +36 -0
  64. package/lib/componentsv2/stubs/ComponentSkin.ts.stub +34 -0
  65. package/lib/componentsv2/stubs/ComponentStructure.css.stub +13 -0
  66. package/lib/componentsv2/tools/CreateSkin.js +62 -0
  67. package/lib/componentsv2/tools/DocSpam.js +134 -0
  68. package/lib/componentsv2/tools/FluencyAudit.js +141 -0
  69. package/lib/componentsv2/tools/OptionsAudit.js +177 -0
  70. package/lib/componentsv2/tools/Scaffold.js +140 -0
  71. package/lib/utils/fetch.js +428 -0
  72. package/lib/utils/fetch.js.map +1 -0
  73. package/machinery/build.js +2 -1
  74. package/machinery/compiler.js +200 -37
  75. package/machinery/config.js +93 -6
  76. package/machinery/diagnose.js +72 -0
  77. package/machinery/jux-module-pattern.md +118 -0
  78. package/machinery/server.js +23 -7
  79. package/machinery/verifier.js +143 -0
  80. package/machinery/watcher.js +53 -64
  81. package/package.json +11 -2
  82. package/lib/components/alert.ts +0 -200
  83. package/lib/components/app.ts +0 -258
  84. package/lib/components/badge.ts +0 -101
  85. package/lib/components/base/BaseComponent.ts +0 -417
  86. package/lib/components/base/FormInput.ts +0 -227
  87. package/lib/components/button.ts +0 -178
  88. package/lib/components/card.ts +0 -173
  89. package/lib/components/chart.ts +0 -231
  90. package/lib/components/checkbox.ts +0 -242
  91. package/lib/components/code.ts +0 -123
  92. package/lib/components/container.ts +0 -140
  93. package/lib/components/data.ts +0 -135
  94. package/lib/components/datepicker.ts +0 -234
  95. package/lib/components/dialog.ts +0 -172
  96. package/lib/components/divider.ts +0 -100
  97. package/lib/components/dropdown.ts +0 -186
  98. package/lib/components/element.ts +0 -267
  99. package/lib/components/error-handler.ts +0 -285
  100. package/lib/components/fileupload.ts +0 -309
  101. package/lib/components/grid.ts +0 -291
  102. package/lib/components/guard.ts +0 -92
  103. package/lib/components/heading.ts +0 -96
  104. package/lib/components/helpers.ts +0 -41
  105. package/lib/components/hero.ts +0 -224
  106. package/lib/components/icon.ts +0 -160
  107. package/lib/components/icons.ts +0 -175
  108. package/lib/components/include.ts +0 -440
  109. package/lib/components/input.ts +0 -457
  110. package/lib/components/list.ts +0 -419
  111. package/lib/components/loading.ts +0 -100
  112. package/lib/components/menu.ts +0 -260
  113. package/lib/components/modal.ts +0 -239
  114. package/lib/components/nav.ts +0 -257
  115. package/lib/components/paragraph.ts +0 -97
  116. package/lib/components/progress.ts +0 -139
  117. package/lib/components/radio.ts +0 -278
  118. package/lib/components/req.ts +0 -302
  119. package/lib/components/script.ts +0 -43
  120. package/lib/components/select.ts +0 -252
  121. package/lib/components/sidebar.ts +0 -167
  122. package/lib/components/style.ts +0 -43
  123. package/lib/components/switch.ts +0 -246
  124. package/lib/components/table.ts +0 -1249
  125. package/lib/components/tabs.ts +0 -250
  126. package/lib/components/theme-toggle.ts +0 -300
  127. package/lib/components/token-calculator.ts +0 -313
  128. package/lib/components/tooltip.ts +0 -144
  129. package/lib/components/view.ts +0 -190
  130. package/lib/components/write.ts +0 -272
  131. package/lib/jux.ts +0 -365
  132. package/lib/layouts/default.css +0 -260
  133. package/lib/layouts/figma.css +0 -334
  134. package/lib/reactivity/state.ts +0 -78
  135. package/machinery/bundleAssets.js +0 -0
  136. package/machinery/bundleJux.js +0 -0
  137. package/machinery/bundleVendors.js +0 -0
  138. package/presets/default/all.jux +0 -343
  139. package/presets/default/index.jux +0 -90
  140. package/presets/default/layout.jux +0 -57
  141. package/presets/default/style.css +0 -1612
@@ -1,260 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- import { renderIcon } from './icons.js';
3
- import { req } from './req.js';
4
-
5
- // Event definitions
6
- const TRIGGER_EVENTS = [] as const;
7
- const CALLBACK_EVENTS = ['itemClick'] as const; // ✅ Fire when menu item is clicked
8
-
9
- export interface MenuItem {
10
- label: string;
11
- href?: string;
12
- click?: () => void;
13
- icon?: string;
14
- items?: MenuItem[];
15
- active?: boolean;
16
- itemClass?: string;
17
- }
18
-
19
- export interface MenuOptions {
20
- items?: MenuItem[];
21
- orientation?: 'vertical' | 'horizontal';
22
- style?: string;
23
- class?: string;
24
- }
25
-
26
- type MenuState = {
27
- items: MenuItem[];
28
- orientation: string;
29
- style: string;
30
- class: string;
31
- };
32
-
33
- export class Menu extends BaseComponent<MenuState> {
34
- constructor(id: string, options: MenuOptions = {}) {
35
- super(id, {
36
- items: options.items ?? [],
37
- orientation: options.orientation ?? 'vertical',
38
- style: options.style ?? '',
39
- class: options.class ?? ''
40
- });
41
-
42
- this._setActiveStates();
43
- }
44
-
45
- protected getTriggerEvents(): readonly string[] {
46
- return TRIGGER_EVENTS;
47
- }
48
-
49
- protected getCallbackEvents(): readonly string[] {
50
- return CALLBACK_EVENTS;
51
- }
52
-
53
- private _setActiveStates(): void {
54
- this.state.items = this.state.items.map(item => ({
55
- ...item,
56
- active: item.href ? req.isActiveNavItem(item.href) : false,
57
- items: item.items?.map(subItem => ({
58
- ...subItem,
59
- active: subItem.href ? req.isActiveNavItem(subItem.href) : false
60
- }))
61
- }));
62
- }
63
-
64
- /* ═════════════════════════════════════════════════════════════════
65
- * FLUENT API
66
- * ═════════════════════════════════════════════════════════════════ */
67
-
68
- // ✅ Inherited from BaseComponent
69
-
70
- items(value: MenuItem[]): this {
71
- this.state.items = value;
72
- this._setActiveStates();
73
- return this;
74
- }
75
-
76
- addItem(item: MenuItem): this {
77
- this.state.items = [...this.state.items, item];
78
- this._setActiveStates();
79
- return this;
80
- }
81
-
82
- itemClass(className: string): this {
83
- this.state.items = this.state.items.map(item => ({
84
- ...item,
85
- itemClass: className,
86
- items: item.items?.map(subItem => ({
87
- ...subItem,
88
- itemClass: className
89
- }))
90
- }));
91
- return this;
92
- }
93
-
94
- orientation(value: 'vertical' | 'horizontal'): this {
95
- this.state.orientation = value;
96
- return this;
97
- }
98
-
99
- /* ═════════════════════════════════════════════════════════════════
100
- * HELPERS
101
- * ═════════════════════════════════════════════════════════════════ */
102
-
103
- private _renderMenuItem(item: MenuItem): HTMLElement {
104
- const menuItem = document.createElement('div');
105
- menuItem.className = 'jux-menu-item';
106
-
107
- if (item.itemClass) {
108
- menuItem.className += ` ${item.itemClass}`;
109
- }
110
-
111
- if (item.active) {
112
- menuItem.classList.add('jux-menu-item-active');
113
- }
114
-
115
- if (item.href) {
116
- const link = document.createElement('a');
117
- link.className = 'jux-menu-link';
118
- link.href = item.href;
119
-
120
- if (item.active) {
121
- link.classList.add('jux-menu-link-active');
122
- }
123
-
124
- if (item.icon) {
125
- const icon = document.createElement('span');
126
- icon.className = 'jux-menu-icon';
127
- icon.appendChild(renderIcon(item.icon));
128
- link.appendChild(icon);
129
- }
130
-
131
- const label = document.createElement('span');
132
- label.className = 'jux-menu-label';
133
- label.textContent = item.label;
134
- link.appendChild(label);
135
-
136
- // ✅ Fire itemClick callback when link is clicked
137
- link.addEventListener('click', (e) => {
138
- this._triggerCallback('itemClick', { item, event: e });
139
- });
140
-
141
- menuItem.appendChild(link);
142
- } else {
143
- const button = document.createElement('button');
144
- button.className = 'jux-menu-button';
145
-
146
- if (item.icon) {
147
- const icon = document.createElement('span');
148
- icon.className = 'jux-menu-icon';
149
- icon.appendChild(renderIcon(item.icon));
150
- button.appendChild(icon);
151
- }
152
-
153
- const label = document.createElement('span');
154
- label.className = 'jux-menu-label';
155
- label.textContent = item.label;
156
- button.appendChild(label);
157
-
158
- menuItem.appendChild(button);
159
-
160
- // ✅ Fire both the item's click handler AND the callback event
161
- button.addEventListener('click', (e) => {
162
- if (item.click) {
163
- item.click();
164
- }
165
- this._triggerCallback('itemClick', { item, event: e });
166
- });
167
- }
168
-
169
- if (item.items && item.items.length > 0) {
170
- const submenu = document.createElement('div');
171
- submenu.className = 'jux-menu-submenu';
172
-
173
- item.items.forEach(subItem => {
174
- submenu.appendChild(this._renderMenuItem(subItem));
175
- });
176
-
177
- menuItem.appendChild(submenu);
178
- }
179
-
180
- return menuItem;
181
- }
182
-
183
- /* ═════════════════════════════════════════════════════════════════
184
- * RENDER
185
- * ═════════════════════════════════════════════════════════════════ */
186
-
187
- render(targetId?: string): this {
188
- const container = this._setupContainer(targetId);
189
-
190
- const { items, orientation, style, class: className } = this.state;
191
-
192
- const menu = document.createElement('nav');
193
- menu.className = `jux-menu jux-menu-${orientation}`;
194
- menu.id = this._id;
195
-
196
- if (className) {
197
- menu.className += ` ${className}`;
198
- }
199
-
200
- if (style) {
201
- menu.setAttribute('style', style);
202
- }
203
-
204
- items.forEach(item => {
205
- menu.appendChild(this._renderMenuItem(item));
206
- });
207
-
208
- this._wireStandardEvents(menu);
209
-
210
- // Wire sync bindings
211
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
212
- if (property === 'items') {
213
- const transform = toComponent || ((v: any) => v);
214
-
215
- stateObj.subscribe((val: any) => {
216
- const transformed = transform(val);
217
- this.state.items = transformed;
218
- this._setActiveStates();
219
-
220
- const existingItems = menu.querySelectorAll('.jux-menu-item');
221
- existingItems.forEach(item => item.remove());
222
-
223
- this.state.items.forEach(item => {
224
- menu.appendChild(this._renderMenuItem(item));
225
- });
226
-
227
- requestAnimationFrame(() => {
228
- if ((window as any).lucide) {
229
- (window as any).lucide.createIcons();
230
- }
231
- });
232
- });
233
- }
234
- else if (property === 'orientation') {
235
- const transform = toComponent || ((v: any) => String(v));
236
-
237
- stateObj.subscribe((val: any) => {
238
- const transformed = transform(val);
239
- menu.classList.remove(`jux-menu-${this.state.orientation}`);
240
- this.state.orientation = transformed;
241
- menu.classList.add(`jux-menu-${transformed}`);
242
- });
243
- }
244
- });
245
-
246
- container.appendChild(menu);
247
-
248
- requestAnimationFrame(() => {
249
- if ((window as any).lucide) {
250
- (window as any).lucide.createIcons();
251
- }
252
- });
253
-
254
- return this;
255
- }
256
- }
257
-
258
- export function menu(id: string, options: MenuOptions = {}): Menu {
259
- return new Menu(id, options);
260
- }
@@ -1,239 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = ['open', 'close'] as const;
6
-
7
- export interface ModalOptions {
8
- title?: string;
9
- content?: string;
10
- showCloseButton?: boolean;
11
- closeOnBackdropClick?: boolean;
12
- size?: 'small' | 'medium' | 'large';
13
- style?: string;
14
- class?: string;
15
- }
16
-
17
- type ModalState = {
18
- title: string;
19
- content: string;
20
- showCloseButton: boolean;
21
- closeOnBackdropClick: boolean;
22
- size: string;
23
- open: boolean;
24
- style: string;
25
- class: string;
26
- };
27
-
28
- export class Modal extends BaseComponent<ModalState> {
29
- private _overlay: HTMLElement | null = null;
30
-
31
- constructor(id: string, options: ModalOptions = {}) {
32
- super(id, {
33
- title: options.title ?? '',
34
- content: options.content ?? '',
35
- showCloseButton: options.showCloseButton ?? true,
36
- closeOnBackdropClick: options.closeOnBackdropClick ?? true,
37
- size: options.size ?? 'medium',
38
- open: false,
39
- style: options.style ?? '',
40
- class: options.class ?? ''
41
- });
42
- }
43
-
44
- protected getTriggerEvents(): readonly string[] {
45
- return TRIGGER_EVENTS;
46
- }
47
-
48
- protected getCallbackEvents(): readonly string[] {
49
- return CALLBACK_EVENTS;
50
- }
51
-
52
- /* ═════════════════════════════════════════════════════════════════
53
- * FLUENT API
54
- * ═════════════════════════════════════════════════════════════════ */
55
-
56
- // ✅ Inherited from BaseComponent
57
-
58
- title(value: string): this {
59
- this.state.title = value;
60
- return this;
61
- }
62
-
63
- content(value: string): this {
64
- this.state.content = value;
65
- return this;
66
- }
67
-
68
- showCloseButton(value: boolean): this {
69
- this.state.showCloseButton = value;
70
- return this;
71
- }
72
-
73
- closeOnBackdropClick(value: boolean): this {
74
- this.state.closeOnBackdropClick = value;
75
- return this;
76
- }
77
-
78
- size(value: 'small' | 'medium' | 'large'): this {
79
- this.state.size = value;
80
- return this;
81
- }
82
-
83
- open(): this {
84
- this.state.open = true;
85
- if (this._overlay) {
86
- this._overlay.style.display = 'flex';
87
- }
88
- // 🎯 Fire the open callback event
89
- this._triggerCallback('open');
90
- return this;
91
- }
92
-
93
- close(): this {
94
- this.state.open = false;
95
- if (this._overlay) {
96
- this._overlay.style.display = 'none';
97
- }
98
- // 🎯 Fire the close callback event
99
- this._triggerCallback('close');
100
- return this;
101
- }
102
-
103
- /* ═════════════════════════════════════════════════════════════════
104
- * RENDER
105
- * ═════════════════════════════════════════════════════════════════ */
106
-
107
- render(targetId?: string): this {
108
- const container = this._setupContainer(targetId);
109
-
110
- const { open, title, content, size, closeOnBackdropClick: closeOnBackdrop, showCloseButton: showClose, style, class: className } = this.state;
111
- const hasOpenSync = this._syncBindings.some(b => b.property === 'open');
112
-
113
- const overlay = document.createElement('div');
114
- overlay.className = 'jux-modal-overlay';
115
- overlay.id = this._id;
116
- overlay.style.display = open ? 'flex' : 'none';
117
- if (className) overlay.className += ` ${className}`;
118
- if (style) overlay.setAttribute('style', style);
119
- this._overlay = overlay;
120
-
121
- const modal = document.createElement('div');
122
- modal.className = `jux-modal jux-modal-${size}`;
123
-
124
- if (showClose) {
125
- const closeButton = document.createElement('button');
126
- closeButton.className = 'jux-modal-close';
127
- closeButton.innerHTML = '×';
128
- modal.appendChild(closeButton);
129
- }
130
-
131
- if (title) {
132
- const header = document.createElement('div');
133
- header.className = 'jux-modal-header';
134
- header.textContent = title;
135
- modal.appendChild(header);
136
- }
137
-
138
- const body = document.createElement('div');
139
- body.className = 'jux-modal-body';
140
- body.innerHTML = content;
141
- modal.appendChild(body);
142
-
143
- overlay.appendChild(modal);
144
-
145
- if (!hasOpenSync) {
146
- if (showClose) {
147
- const closeButton = modal.querySelector('.jux-modal-close');
148
- closeButton?.addEventListener('click', () => {
149
- this.state.open = false;
150
- overlay.style.display = 'none';
151
- });
152
- }
153
-
154
- if (closeOnBackdrop) {
155
- overlay.addEventListener('click', (e) => {
156
- if (e.target === overlay) {
157
- this.state.open = false;
158
- overlay.style.display = 'none';
159
- }
160
- });
161
- }
162
- }
163
-
164
- this._wireStandardEvents(overlay);
165
-
166
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
167
- if (property === 'open') {
168
- const transformToState = toState || ((v: any) => Boolean(v));
169
- const transformToComponent = toComponent || ((v: any) => Boolean(v));
170
-
171
- let isUpdating = false;
172
-
173
- stateObj.subscribe((val: any) => {
174
- if (isUpdating) return;
175
- const transformed = transformToComponent(val);
176
- this.state.open = transformed;
177
- overlay.style.display = transformed ? 'flex' : 'none';
178
- });
179
-
180
- if (showClose) {
181
- const closeButton = modal.querySelector('.jux-modal-close');
182
- closeButton?.addEventListener('click', () => {
183
- if (isUpdating) return;
184
- isUpdating = true;
185
-
186
- this.state.open = false;
187
- overlay.style.display = 'none';
188
- stateObj.set(transformToState(false));
189
-
190
- setTimeout(() => { isUpdating = false; }, 0);
191
- });
192
- }
193
-
194
- if (closeOnBackdrop) {
195
- overlay.addEventListener('click', (e) => {
196
- if (e.target === overlay) {
197
- if (isUpdating) return;
198
- isUpdating = true;
199
-
200
- this.state.open = false;
201
- overlay.style.display = 'none';
202
- stateObj.set(transformToState(false));
203
-
204
- setTimeout(() => { isUpdating = false; }, 0);
205
- }
206
- });
207
- }
208
- }
209
- else if (property === 'content') {
210
- const transform = toComponent || ((v: any) => String(v));
211
-
212
- stateObj.subscribe((val: any) => {
213
- const transformed = transform(val);
214
- body.innerHTML = transformed;
215
- this.state.content = transformed;
216
- });
217
- }
218
- else if (property === 'title') {
219
- const transform = toComponent || ((v: any) => String(v));
220
-
221
- stateObj.subscribe((val: any) => {
222
- const transformed = transform(val);
223
- const header = modal.querySelector('.jux-modal-header');
224
- if (header) {
225
- header.textContent = transformed;
226
- }
227
- this.state.title = transformed;
228
- });
229
- }
230
- });
231
-
232
- container.appendChild(overlay);
233
- return this;
234
- }
235
- }
236
-
237
- export function modal(id: string, options: ModalOptions = {}): Modal {
238
- return new Modal(id, options);
239
- }