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,224 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+
3
+ // Event definitions - Hero is display-only, but CTA button can trigger actions
4
+ const TRIGGER_EVENTS = [] as const;
5
+ const CALLBACK_EVENTS = ['ctaClick'] as const; // ✅ When CTA button is clicked
6
+
7
+ export interface HeroOptions {
8
+ title?: string;
9
+ subtitle?: string;
10
+ content?: string; // ✅ ADD: Generates jux-hero-body div
11
+ cta?: string; // ✅ KEEP: Generates jux-hero-cta anchor
12
+ ctaLink?: string;
13
+ backgroundImage?: string;
14
+ backgroundOverlay?: boolean; // ✅ ADD: Generates jux-hero-overlay div
15
+ variant?: 'default' | 'centered' | 'split';
16
+ centered?: boolean; // ✅ ADD: Affects container class
17
+ style?: string;
18
+ class?: string;
19
+ }
20
+
21
+ type HeroState = {
22
+ title: string;
23
+ subtitle: string;
24
+ content: string; // ✅ ADD: For jux-hero-body
25
+ cta: string;
26
+ ctaLink: string;
27
+ backgroundImage: string;
28
+ backgroundOverlay: boolean; // ✅ ADD: For overlay div
29
+ variant: string;
30
+ centered: boolean; // ✅ ADD: For layout variant
31
+ style: string;
32
+ class: string;
33
+ };
34
+
35
+ export class Hero extends BaseComponent<HeroState> {
36
+ constructor(id: string, options: HeroOptions = {}) {
37
+ super(id, {
38
+ title: options.title ?? '',
39
+ subtitle: options.subtitle ?? '',
40
+ content: options.content ?? '', // ✅ ADD
41
+ cta: options.cta ?? '',
42
+ ctaLink: options.ctaLink ?? '#',
43
+ backgroundImage: options.backgroundImage ?? '',
44
+ backgroundOverlay: options.backgroundOverlay ?? false, // ✅ ADD
45
+ variant: options.variant ?? 'default',
46
+ centered: options.centered ?? false, // ✅ ADD
47
+ style: options.style ?? '',
48
+ class: options.class ?? ''
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
+ title(value: string): this {
65
+ this.state.title = value;
66
+ return this;
67
+ }
68
+
69
+ subtitle(value: string): this {
70
+ this.state.subtitle = value;
71
+ return this;
72
+ }
73
+
74
+ content(value: string): this { // ✅ ADD: Fluent method for content
75
+ this.state.content = value;
76
+ return this;
77
+ }
78
+
79
+ cta(value: string): this {
80
+ this.state.cta = value;
81
+ return this;
82
+ }
83
+
84
+ ctaLink(value: string): this {
85
+ this.state.ctaLink = value;
86
+ return this;
87
+ }
88
+
89
+ backgroundImage(value: string): this {
90
+ this.state.backgroundImage = value;
91
+ return this;
92
+ }
93
+
94
+ backgroundOverlay(value: boolean): this { // ✅ ADD: Fluent method for overlay
95
+ this.state.backgroundOverlay = value;
96
+ return this;
97
+ }
98
+
99
+ variant(value: string): this {
100
+ this.state.variant = value;
101
+ return this;
102
+ }
103
+
104
+ centered(value: boolean): this { // ✅ ADD: Fluent method for centered
105
+ this.state.centered = value;
106
+ return this;
107
+ }
108
+
109
+ /* ═════════════════════════════════════════════════════════════════
110
+ * RENDER
111
+ * ═════════════════════════════════════════════════════════════════ */
112
+
113
+ render(targetId?: string): this {
114
+ const container = this._setupContainer(targetId);
115
+
116
+ const { title, subtitle, content, backgroundImage, backgroundOverlay, centered, style, class: className } = this.state;
117
+
118
+ const hero = document.createElement('section');
119
+ hero.className = 'jux-hero';
120
+ hero.id = this._id;
121
+ if (centered) hero.classList.add('jux-hero-centered');
122
+ if (className) hero.className += ` ${className}`;
123
+ if (style) hero.setAttribute('style', style);
124
+
125
+ if (backgroundImage) {
126
+ hero.style.backgroundImage = `url(${backgroundImage})`;
127
+ if (backgroundOverlay) {
128
+ const overlay = document.createElement('div');
129
+ overlay.className = 'jux-hero-overlay';
130
+ hero.appendChild(overlay);
131
+ }
132
+ }
133
+
134
+ const contentContainer = document.createElement('div');
135
+ contentContainer.className = 'jux-hero-content';
136
+
137
+ if (title) {
138
+ const titleEl = document.createElement('h1');
139
+ titleEl.className = 'jux-hero-title';
140
+ titleEl.id = `${this._id}-title`;
141
+ titleEl.textContent = title;
142
+ contentContainer.appendChild(titleEl);
143
+ }
144
+
145
+ if (subtitle) {
146
+ const subtitleEl = document.createElement('p');
147
+ subtitleEl.className = 'jux-hero-subtitle';
148
+ subtitleEl.id = `${this._id}-subtitle`;
149
+ subtitleEl.textContent = subtitle;
150
+ contentContainer.appendChild(subtitleEl);
151
+ }
152
+
153
+ if (content) {
154
+ const contentEl = document.createElement('div');
155
+ contentEl.className = 'jux-hero-body';
156
+ contentEl.innerHTML = content;
157
+ contentContainer.appendChild(contentEl);
158
+ }
159
+
160
+ if (this.state.cta) {
161
+ const ctaButton = document.createElement('a');
162
+ ctaButton.className = 'jux-hero-cta';
163
+ ctaButton.href = this.state.ctaLink;
164
+ ctaButton.textContent = this.state.cta;
165
+
166
+ // ✅ Fire callback when CTA is clicked
167
+ ctaButton.addEventListener('click', (e) => {
168
+ this._triggerCallback('ctaClick', e);
169
+ });
170
+
171
+ contentContainer.appendChild(ctaButton);
172
+ }
173
+
174
+ hero.appendChild(contentContainer);
175
+
176
+ this._wireStandardEvents(hero);
177
+
178
+ this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
179
+ if (property === 'title') {
180
+ const transform = toComponent || ((v: any) => String(v));
181
+
182
+ stateObj.subscribe((val: any) => {
183
+ const transformed = transform(val);
184
+ const titleEl = document.getElementById(`${this._id}-title`);
185
+ if (titleEl) {
186
+ titleEl.textContent = transformed;
187
+ }
188
+ this.state.title = transformed;
189
+ });
190
+ }
191
+ else if (property === 'subtitle') {
192
+ const transform = toComponent || ((v: any) => String(v));
193
+
194
+ stateObj.subscribe((val: any) => {
195
+ const transformed = transform(val);
196
+ const subtitleEl = document.getElementById(`${this._id}-subtitle`);
197
+ if (subtitleEl) {
198
+ subtitleEl.textContent = transformed;
199
+ }
200
+ this.state.subtitle = transformed;
201
+ });
202
+ }
203
+ else if (property === 'content') {
204
+ const transform = toComponent || ((v: any) => String(v));
205
+
206
+ stateObj.subscribe((val: any) => {
207
+ const transformed = transform(val);
208
+ const contentEl = hero.querySelector('.jux-hero-body');
209
+ if (contentEl) {
210
+ contentEl.innerHTML = transformed;
211
+ }
212
+ this.state.content = transformed;
213
+ });
214
+ }
215
+ });
216
+
217
+ container.appendChild(hero);
218
+ return this;
219
+ }
220
+ }
221
+
222
+ export function hero(id: string, options: HeroOptions = {}): Hero {
223
+ return new Hero(id, options);
224
+ }
@@ -0,0 +1,178 @@
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+ import { renderIcon, renderEmoji } from './icons.js';
3
+
4
+ // Event definitions
5
+ const TRIGGER_EVENTS = [] as const;
6
+ const CALLBACK_EVENTS = [] as const;
7
+
8
+ export interface IconOptions {
9
+ value?: string;
10
+ size?: string;
11
+ color?: string;
12
+ useEmoji?: boolean;
13
+ iconCollection?: string;
14
+ style?: string;
15
+ class?: string;
16
+ }
17
+
18
+ type IconState = {
19
+ value: string;
20
+ size: string;
21
+ color: string;
22
+ useEmoji: boolean;
23
+ iconCollection: string;
24
+ style: string;
25
+ class: string;
26
+ };
27
+
28
+ export class Icon extends BaseComponent<IconState> {
29
+ constructor(id: string, options: IconOptions = {}) {
30
+ super(id, {
31
+ value: options.value ?? '',
32
+ size: options.size ?? '24px',
33
+ color: options.color ?? '',
34
+ useEmoji: options.useEmoji ?? false,
35
+ iconCollection: options.iconCollection ?? '',
36
+ style: options.style ?? '',
37
+ class: options.class ?? ''
38
+ });
39
+ }
40
+
41
+ protected getTriggerEvents(): readonly string[] {
42
+ return TRIGGER_EVENTS;
43
+ }
44
+
45
+ protected getCallbackEvents(): readonly string[] {
46
+ return CALLBACK_EVENTS;
47
+ }
48
+
49
+ /* ═════════════════════════════════════════════════════════════════
50
+ * FLUENT API
51
+ * ═════════════════════════════════════════════════════════════════ */
52
+
53
+ // ✅ Inherited from BaseComponent
54
+
55
+ value(value: string): this {
56
+ this.state.value = value;
57
+ return this;
58
+ }
59
+
60
+ size(value: string): this {
61
+ this.state.size = value;
62
+ return this;
63
+ }
64
+
65
+ color(value: string): this {
66
+ this.state.color = value;
67
+ return this;
68
+ }
69
+
70
+ useEmoji(value: boolean): this {
71
+ this.state.useEmoji = value;
72
+ return this;
73
+ }
74
+
75
+ iconCollection(value: string): this {
76
+ this.state.iconCollection = value;
77
+ return this;
78
+ }
79
+
80
+ style(value: string): this {
81
+ this.state.style = value;
82
+ return this;
83
+ }
84
+
85
+ class(value: string): this {
86
+ this.state.class = value;
87
+ return this;
88
+ }
89
+
90
+ /* ═════════════════════════════════════════════════════════════════
91
+ * RENDER
92
+ * ═════════════════════════════════════════════════════════════════ */
93
+
94
+ render(targetId?: string): this {
95
+ const container = this._setupContainer(targetId);
96
+
97
+ const { value, size, color, useEmoji, iconCollection, style, class: className } = this.state;
98
+
99
+ const wrapper = document.createElement('span');
100
+ wrapper.className = 'jux-icon';
101
+ wrapper.id = this._id;
102
+ if (className) wrapper.className += ` ${className}`;
103
+ if (style) wrapper.setAttribute('style', style);
104
+
105
+ const iconElement = useEmoji ? renderEmoji(value) : renderIcon(value, iconCollection);
106
+ iconElement.style.width = size;
107
+ iconElement.style.height = size;
108
+ if (color) iconElement.style.color = color;
109
+
110
+ wrapper.appendChild(iconElement);
111
+
112
+ this._wireStandardEvents(wrapper);
113
+
114
+ // Wire sync bindings
115
+ this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
116
+ if (property === 'value') {
117
+ const transform = toComponent || ((v: any) => String(v));
118
+
119
+ stateObj.subscribe((val: any) => {
120
+ const transformed = transform(val);
121
+ this.state.value = transformed;
122
+
123
+ wrapper.innerHTML = '';
124
+ const newIcon = this.state.useEmoji ? renderEmoji(transformed) : renderIcon(transformed, this.state.iconCollection);
125
+ newIcon.style.width = this.state.size;
126
+ newIcon.style.height = this.state.size;
127
+ if (this.state.color) newIcon.style.color = this.state.color;
128
+ wrapper.appendChild(newIcon);
129
+
130
+ requestAnimationFrame(() => {
131
+ if ((window as any).Iconify) {
132
+ (window as any).Iconify.scan();
133
+ }
134
+ });
135
+ });
136
+ }
137
+ else if (property === 'size') {
138
+ const transform = toComponent || ((v: any) => String(v));
139
+
140
+ stateObj.subscribe((val: any) => {
141
+ const transformed = transform(val);
142
+ const icon = wrapper.querySelector('img, svg, span');
143
+ if (icon instanceof HTMLElement) {
144
+ icon.style.width = transformed;
145
+ icon.style.height = transformed;
146
+ }
147
+ this.state.size = transformed;
148
+ });
149
+ }
150
+ else if (property === 'color') {
151
+ const transform = toComponent || ((v: any) => String(v));
152
+
153
+ stateObj.subscribe((val: any) => {
154
+ const transformed = transform(val);
155
+ const icon = wrapper.querySelector('img, svg, span');
156
+ if (icon instanceof HTMLElement) {
157
+ icon.style.color = transformed;
158
+ }
159
+ this.state.color = transformed;
160
+ });
161
+ }
162
+ });
163
+
164
+ container.appendChild(wrapper);
165
+
166
+ requestAnimationFrame(() => {
167
+ if ((window as any).lucide) {
168
+ (window as any).lucide.createIcons();
169
+ }
170
+ });
171
+
172
+ return this;
173
+ }
174
+ }
175
+
176
+ export function icon(id: string, options: IconOptions): Icon {
177
+ return new Icon(id, options);
178
+ }