juxscript 1.0.132 → 1.1.0

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 (129) 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/package.json +9 -31
  59. package/create/index.jux +0 -77
  60. package/create/layout.jux +0 -18
  61. package/create/style.css +0 -57
  62. package/create/themes/assets/jux.svg +0 -34
  63. package/create/themes/base.css +0 -197
  64. package/create/themes/base2.css +0 -54
  65. package/create/themes/layouts/base.jux +0 -16
  66. package/create/themes/layouts/base_blog.jux +0 -0
  67. package/create/themes/layouts/base_docs.jux +0 -0
  68. package/create/themes/layouts/base_login.jux +0 -0
  69. package/create/themes/layouts/base_marketing.jux +0 -0
  70. package/create/themes/layouts/base_saas.jux +0 -0
  71. package/lib/componentsv2/base/BaseEngine.d.ts +0 -112
  72. package/lib/componentsv2/base/BaseEngine.js +0 -279
  73. package/lib/componentsv2/base/BaseSkin.d.ts +0 -74
  74. package/lib/componentsv2/base/BaseSkin.js +0 -130
  75. package/lib/componentsv2/base/Neighborhood.d.ts +0 -22
  76. package/lib/componentsv2/base/Neighborhood.js +0 -56
  77. package/lib/componentsv2/base/OptionsContract.d.ts +0 -20
  78. package/lib/componentsv2/base/OptionsContract.js +0 -107
  79. package/lib/componentsv2/base/State.d.ts +0 -18
  80. package/lib/componentsv2/base/State.js +0 -68
  81. package/lib/componentsv2/element/Element.d.ts +0 -30
  82. package/lib/componentsv2/element/Element.js +0 -50
  83. package/lib/componentsv2/element/ElementEngine.d.ts +0 -59
  84. package/lib/componentsv2/element/ElementEngine.js +0 -118
  85. package/lib/componentsv2/element/ElementSkin.d.ts +0 -10
  86. package/lib/componentsv2/element/ElementSkin.js +0 -56
  87. package/lib/componentsv2/element/structure.css +0 -261
  88. package/lib/componentsv2/grid/Grid.d.ts +0 -13
  89. package/lib/componentsv2/grid/Grid.js +0 -27
  90. package/lib/componentsv2/grid/GridEngine.d.ts +0 -77
  91. package/lib/componentsv2/grid/GridEngine.js +0 -153
  92. package/lib/componentsv2/grid/GridSkin.d.ts +0 -11
  93. package/lib/componentsv2/grid/GridSkin.js +0 -84
  94. package/lib/componentsv2/grid/structure.css +0 -27
  95. package/lib/componentsv2/input/Input.d.ts +0 -6
  96. package/lib/componentsv2/input/Input.js +0 -21
  97. package/lib/componentsv2/input/InputEngine.d.ts +0 -70
  98. package/lib/componentsv2/input/InputEngine.js +0 -143
  99. package/lib/componentsv2/input/InputSkin.d.ts +0 -11
  100. package/lib/componentsv2/input/InputSkin.js +0 -89
  101. package/lib/componentsv2/input/structure.css +0 -47
  102. package/lib/componentsv2/list/List.d.ts +0 -49
  103. package/lib/componentsv2/list/List.js +0 -105
  104. package/lib/componentsv2/list/ListEngine.d.ts +0 -121
  105. package/lib/componentsv2/list/ListEngine.js +0 -322
  106. package/lib/componentsv2/list/ListSkin.d.ts +0 -20
  107. package/lib/componentsv2/list/ListSkin.js +0 -345
  108. package/lib/componentsv2/list/structure.css +0 -359
  109. package/lib/componentsv2/plugins/ClientSQLitePlugin.d.ts +0 -21
  110. package/lib/componentsv2/plugins/ClientSQLitePlugin.js +0 -130
  111. package/lib/componentsv2/plugins/IndexedDBPlugin.d.ts +0 -18
  112. package/lib/componentsv2/plugins/IndexedDBPlugin.js +0 -75
  113. package/lib/componentsv2/plugins/LocalStoragePlugin.d.ts +0 -20
  114. package/lib/componentsv2/plugins/LocalStoragePlugin.js +0 -65
  115. package/lib/componentsv2/plugins/ServerSQLitePlugin.d.ts +0 -25
  116. package/lib/componentsv2/plugins/ServerSQLitePlugin.js +0 -70
  117. package/lib/componentsv2/stubs/ComponentComposition.ts.stub +0 -32
  118. package/lib/componentsv2/stubs/ComponentEngine.ts.stub +0 -36
  119. package/lib/componentsv2/stubs/ComponentSkin.ts.stub +0 -35
  120. package/lib/componentsv2/stubs/ComponentStructure.css.d.ts.stub +0 -2
  121. package/lib/componentsv2/stubs/ComponentStructure.css.stub +0 -13
  122. package/lib/utils/fetch.d.ts +0 -176
  123. package/machinery/build3.js +0 -159
  124. package/machinery/compiler3.js +0 -688
  125. package/machinery/config.js +0 -155
  126. package/machinery/serve.js +0 -255
  127. package/machinery/validators/file-validator.js +0 -123
  128. package/machinery/watcher.js +0 -59
  129. package/types/css.d.ts +0 -10
@@ -0,0 +1,190 @@
1
+ import { getOrCreateContainer } from './helpers.js';
2
+
3
+ /**
4
+ * View component options
5
+ */
6
+ export interface ViewOptions {
7
+ title?: string;
8
+ description?: string;
9
+ children?: any[];
10
+ }
11
+
12
+ /**
13
+ * View component state
14
+ */
15
+ type ViewState = {
16
+ title: string;
17
+ description: string;
18
+ children: any[];
19
+ };
20
+
21
+ /**
22
+ * View component - container for organizing page content
23
+ *
24
+ * Usage:
25
+ * const view = jux.view('myView', {
26
+ * title: 'Dashboard',
27
+ * description: 'Main dashboard view'
28
+ * });
29
+ * view.add(component1);
30
+ * await view.render();
31
+ */
32
+ export class View {
33
+ state: ViewState;
34
+ container: HTMLElement | null = null;
35
+ _id: string;
36
+ id: string;
37
+
38
+ constructor(id: string, options: ViewOptions = {}) {
39
+ this._id = id;
40
+ this.id = id;
41
+
42
+ this.state = {
43
+ title: options.title ?? '',
44
+ description: options.description ?? '',
45
+ children: Array.isArray(options.children) ? [...options.children] : []
46
+ };
47
+ }
48
+
49
+ /* -------------------------
50
+ * Fluent API
51
+ * ------------------------- */
52
+
53
+ title(value: string): this {
54
+ this.state.title = value;
55
+ return this;
56
+ }
57
+
58
+ description(value: string): this {
59
+ this.state.description = value;
60
+ return this;
61
+ }
62
+
63
+ add(component: any | any[]): this {
64
+ if (Array.isArray(component)) {
65
+ this.state.children.push(...component);
66
+ } else {
67
+ this.state.children.push(component);
68
+ }
69
+ return this;
70
+ }
71
+
72
+ /* -------------------------
73
+ * Render
74
+ * ------------------------- */
75
+
76
+ async render(targetId?: string): Promise<this> {
77
+ let container: HTMLElement;
78
+
79
+ if (targetId) {
80
+ const target = document.querySelector(targetId);
81
+ if (!target || !(target instanceof HTMLElement)) {
82
+ throw new Error(`View: Target element "${targetId}" not found`);
83
+ }
84
+ container = target;
85
+ } else {
86
+ container = getOrCreateContainer(this._id);
87
+ }
88
+
89
+ this.container = container;
90
+ const { title, description, children } = this.state;
91
+
92
+ const view = document.createElement('div');
93
+ view.className = 'jux-view';
94
+ view.id = this._id;
95
+
96
+ // View header
97
+ if (title || description) {
98
+ const header = document.createElement('div');
99
+ header.className = 'jux-view-header';
100
+
101
+ if (title) {
102
+ const titleEl = document.createElement('h1');
103
+ titleEl.className = 'jux-view-title';
104
+ titleEl.textContent = title;
105
+ header.appendChild(titleEl);
106
+ }
107
+
108
+ if (description) {
109
+ const descEl = document.createElement('p');
110
+ descEl.className = 'jux-view-description';
111
+ descEl.textContent = description;
112
+ header.appendChild(descEl);
113
+ }
114
+
115
+ view.appendChild(header);
116
+ }
117
+
118
+ // View content
119
+ const content = document.createElement('div');
120
+ content.className = 'jux-view-content';
121
+
122
+ // Render children
123
+ for (let i = 0; i < children.length; i++) {
124
+ const child = children[i];
125
+ if (!child) continue;
126
+
127
+ // Get child ID
128
+ let childId: string | null = null;
129
+ if ((child as any).id) {
130
+ childId = (child as any).id;
131
+ } else if ((child as any)._id) {
132
+ childId = (child as any)._id;
133
+ } else {
134
+ childId = `${this._id}-child-${i}`;
135
+ }
136
+
137
+ // Create wrapper for child
138
+ const childWrapper = document.createElement('div');
139
+ childWrapper.className = 'jux-view-item';
140
+ childWrapper.id = `${childId}-wrapper`;
141
+ content.appendChild(childWrapper);
142
+
143
+ // Render child INTO the wrapper
144
+ if (typeof (child as any).render === 'function') {
145
+ try {
146
+ // Pass the wrapper element directly
147
+ const result = (child as any).render(childWrapper);
148
+ if (result && typeof (result as any).then === 'function') {
149
+ await result;
150
+ }
151
+ } catch (err) {
152
+ console.error(`View: Error rendering child ${i}:`, err);
153
+ childWrapper.innerHTML = `<div style="color: #ff6b6b; padding: 1rem;">Error: ${(err as Error).message}</div>`;
154
+ }
155
+ } else {
156
+ // If no render method, try to append directly
157
+ if (child instanceof HTMLElement) {
158
+ childWrapper.appendChild(child);
159
+ }
160
+ }
161
+ }
162
+
163
+ view.appendChild(content);
164
+ container.appendChild(view);
165
+
166
+ return this;
167
+ }
168
+
169
+ /**
170
+ * Render to another Jux component's container
171
+ */
172
+ async renderTo(juxComponent: any): Promise<this> {
173
+ if (!juxComponent || typeof juxComponent !== 'object') {
174
+ throw new Error('View.renderTo: Invalid component - not an object');
175
+ }
176
+
177
+ if (!juxComponent._id || typeof juxComponent._id !== 'string') {
178
+ throw new Error('View.renderTo: Invalid component - missing _id (not a Jux component)');
179
+ }
180
+
181
+ return this.render(`#${juxComponent._id}`);
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Factory helper
187
+ */
188
+ export function view(id: string, options: ViewOptions = {}): View {
189
+ return new View(id, options);
190
+ }
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Write - Simple content writer with no component tracking
3
+ * Perfect for quick HTML output without ID management
4
+ */
5
+
6
+ export interface WriteOptions {
7
+ tagType?: string;
8
+ className?: string;
9
+ style?: string;
10
+ attributes?: Record<string, string>;
11
+ html?: boolean; // If true, treat content as HTML; if false, treat as text
12
+ }
13
+
14
+ /**
15
+ * Write content directly to a target element
16
+ *
17
+ * Usage:
18
+ * // Write text (defaults to body)
19
+ * jux.write('Hello World!').render();
20
+ *
21
+ * // Write to specific target
22
+ * jux.write('Content').render('#container');
23
+ *
24
+ * // Write HTML
25
+ * jux.write('<strong>Bold text</strong>').html(true).render('#container');
26
+ *
27
+ * // Write with styling
28
+ * jux.write('Styled text').style('color: red;').render('#container');
29
+ */
30
+ export class Write {
31
+ private content: string;
32
+ private options: WriteOptions;
33
+
34
+ constructor(content: string, options: WriteOptions = {}) {
35
+ this.content = content;
36
+ this.options = {
37
+ tagType: 'div',
38
+ className: '',
39
+ style: '',
40
+ attributes: {},
41
+ html: false,
42
+ ...options
43
+ };
44
+ }
45
+
46
+ /* ═════════════════════════════════════════════════════════════════
47
+ * FLUENT API
48
+ * ═════════════════════════════════════════════════════════════════ */
49
+
50
+ /**
51
+ * Set HTML mode (treat content as HTML)
52
+ */
53
+ html(enabled: boolean = true): this {
54
+ this.options.html = enabled;
55
+ return this;
56
+ }
57
+
58
+ /**
59
+ * Set tag type
60
+ */
61
+ tagType(value: string): this {
62
+ this.options.tagType = value;
63
+ return this;
64
+ }
65
+
66
+ /**
67
+ * Set CSS class
68
+ */
69
+ className(value: string): this {
70
+ this.options.className = value;
71
+ return this;
72
+ }
73
+
74
+ /**
75
+ * Set inline styles
76
+ */
77
+ style(value: string): this {
78
+ this.options.style = value;
79
+ return this;
80
+ }
81
+
82
+ /**
83
+ * Set custom attributes
84
+ */
85
+ attrs(attributes: Record<string, string>): this {
86
+ this.options.attributes = attributes;
87
+ return this;
88
+ }
89
+
90
+ /* ═════════════════════════════════════════════════════════════════
91
+ * RENDER METHODS
92
+ * ═════════════════════════════════════════════════════════════════ */
93
+
94
+ /**
95
+ * Render content to target element
96
+ */
97
+ render(targetSelector?: string): this {
98
+ const target = this._getTarget(targetSelector);
99
+ if (!target) return this;
100
+
101
+ const element = this._createElement();
102
+ target.appendChild(element);
103
+
104
+ return this;
105
+ }
106
+
107
+ /**
108
+ * Replace target content (clear first, then render)
109
+ */
110
+ replace(targetSelector?: string): this {
111
+ const target = this._getTarget(targetSelector);
112
+ if (!target) return this;
113
+
114
+ target.innerHTML = '';
115
+ const element = this._createElement();
116
+ target.appendChild(element);
117
+
118
+ return this;
119
+ }
120
+
121
+ /**
122
+ * Render before target element
123
+ */
124
+ before(targetSelector: string): this {
125
+ const target = document.querySelector(targetSelector);
126
+ if (!target || !(target instanceof HTMLElement)) {
127
+ console.warn(`Write: Target element "${targetSelector}" not found`);
128
+ return this;
129
+ }
130
+
131
+ const element = this._createElement();
132
+ target.parentNode?.insertBefore(element, target);
133
+
134
+ return this;
135
+ }
136
+
137
+ /**
138
+ * Render after target element
139
+ */
140
+ after(targetSelector: string): this {
141
+ const target = document.querySelector(targetSelector);
142
+ if (!target || !(target instanceof HTMLElement)) {
143
+ console.warn(`Write: Target element "${targetSelector}" not found`);
144
+ return this;
145
+ }
146
+
147
+ const element = this._createElement();
148
+ target.parentNode?.insertBefore(element, target.nextSibling);
149
+
150
+ return this;
151
+ }
152
+
153
+ /**
154
+ * Prepend to target (insert as first child)
155
+ */
156
+ prepend(targetSelector?: string): this {
157
+ const target = this._getTarget(targetSelector);
158
+ if (!target) return this;
159
+
160
+ const element = this._createElement();
161
+ target.insertBefore(element, target.firstChild);
162
+
163
+ return this;
164
+ }
165
+
166
+ /**
167
+ * Append to target (alias for render)
168
+ */
169
+ append(targetSelector?: string): this {
170
+ return this.render(targetSelector);
171
+ }
172
+
173
+ /* ═════════════════════════════════════════════════════════════════
174
+ * PRIVATE HELPERS
175
+ * ═════════════════════════════════════════════════════════════════ */
176
+
177
+ private _getTarget(selector?: string): HTMLElement | null {
178
+ const targetSelector = selector || 'body';
179
+ const target = document.querySelector(targetSelector);
180
+
181
+ if (!target || !(target instanceof HTMLElement)) {
182
+ console.warn(`Write: Target element "${targetSelector}" not found`);
183
+ return null;
184
+ }
185
+
186
+ return target;
187
+ }
188
+
189
+ private _createElement(): HTMLElement {
190
+ const element = document.createElement(this.options.tagType!);
191
+
192
+ // Set content (text or HTML)
193
+ if (this.options.html) {
194
+ element.innerHTML = this.content;
195
+ } else {
196
+ element.textContent = this.content;
197
+ }
198
+
199
+ // Apply className
200
+ if (this.options.className) {
201
+ element.className = this.options.className;
202
+ }
203
+
204
+ // Apply inline styles
205
+ if (this.options.style) {
206
+ element.setAttribute('style', this.options.style);
207
+ }
208
+
209
+ // Apply custom attributes
210
+ if (this.options.attributes) {
211
+ Object.entries(this.options.attributes).forEach(([key, value]) => {
212
+ element.setAttribute(key, value);
213
+ });
214
+ }
215
+
216
+ return element;
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Factory function - simple, no overloads
222
+ */
223
+ export function write(content: string, options: WriteOptions = {}): Write {
224
+ return new Write(content, options);
225
+ }
226
+
227
+ /* ═════════════════════════════════════════════════════════════════
228
+ * SHORTHAND HELPERS
229
+ * ═════════════════════════════════════════════════════════════════ */
230
+
231
+ /**
232
+ * Write text (explicit)
233
+ */
234
+ export function writeText(content: string, options: Omit<WriteOptions, 'html'> = {}): Write {
235
+ return new Write(content, { ...options, html: false });
236
+ }
237
+
238
+ /**
239
+ * Write HTML (explicit)
240
+ */
241
+ export function writeHtml(content: string, options: Omit<WriteOptions, 'html'> = {}): Write {
242
+ return new Write(content, { ...options, html: true });
243
+ }
244
+
245
+ /**
246
+ * Write paragraph
247
+ */
248
+ export function writeParagraph(content: string, options: Omit<WriteOptions, 'tagType'> = {}): Write {
249
+ return new Write(content, { ...options, tagType: 'p' });
250
+ }
251
+
252
+ /**
253
+ * Write heading
254
+ */
255
+ export function writeHeading(content: string, level: 1 | 2 | 3 | 4 | 5 | 6 = 2, options: Omit<WriteOptions, 'tagType'> = {}): Write {
256
+ return new Write(content, { ...options, tagType: `h${level}` });
257
+ }
258
+
259
+ /**
260
+ * Write span
261
+ */
262
+ export function writeSpan(content: string, options: Omit<WriteOptions, 'tagType'> = {}): Write {
263
+ return new Write(content, { ...options, tagType: 'span' });
264
+ }
265
+
266
+ /**
267
+ * Write div (explicit)
268
+ */
269
+ export function writeDiv(content: string, options: Omit<WriteOptions, 'tagType'> = {}): Write {
270
+ return new Write(content, { ...options, tagType: 'div' });
271
+ }
272
+
package/lib/globals.d.ts CHANGED
@@ -1,7 +1,21 @@
1
1
  /**
2
- * JUX Type Exports
3
- * Re-export types for TypeScript consumers
2
+ * Global types for JUX projects
3
+ * This file provides IntelliSense in all .jux files
4
4
  */
5
- export type { BaseState } from './componentsv2/base/BaseEngine.js';
6
- export type { JuxServiceContract } from './componentsv2/base/BaseEngine.js';
7
- export type { OptionsContractSchema, OptionDefinition, ValidationResult } from './componentsv2/base/OptionsContract.js';
5
+
6
+ import type { JuxAPI } from '../index.js';
7
+ import type { code } from './components/code.js';
8
+
9
+ declare global {
10
+ /**
11
+ * The main JUX API - available in all .jux files
12
+ */
13
+ const jux: JuxAPI;
14
+
15
+ /**
16
+ * Code component factory - available globally
17
+ */
18
+ const code: typeof code;
19
+ }
20
+
21
+ export { };