juxscript 1.1.3 → 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.
Files changed (63) hide show
  1. package/machinery/build3.js +7 -91
  2. package/machinery/compiler3.js +3 -209
  3. package/package.json +19 -5
  4. package/lib/components/alert.ts +0 -200
  5. package/lib/components/app.ts +0 -247
  6. package/lib/components/badge.ts +0 -101
  7. package/lib/components/base/BaseComponent.ts +0 -421
  8. package/lib/components/base/FormInput.ts +0 -227
  9. package/lib/components/button.ts +0 -178
  10. package/lib/components/card.ts +0 -173
  11. package/lib/components/chart.ts +0 -231
  12. package/lib/components/checkbox.ts +0 -242
  13. package/lib/components/code.ts +0 -123
  14. package/lib/components/container.ts +0 -140
  15. package/lib/components/data.ts +0 -135
  16. package/lib/components/datepicker.ts +0 -234
  17. package/lib/components/dialog.ts +0 -172
  18. package/lib/components/divider.ts +0 -100
  19. package/lib/components/dropdown.ts +0 -186
  20. package/lib/components/element.ts +0 -267
  21. package/lib/components/fileupload.ts +0 -309
  22. package/lib/components/grid.ts +0 -291
  23. package/lib/components/guard.ts +0 -92
  24. package/lib/components/heading.ts +0 -96
  25. package/lib/components/helpers.ts +0 -41
  26. package/lib/components/hero.ts +0 -224
  27. package/lib/components/icon.ts +0 -178
  28. package/lib/components/icons.ts +0 -464
  29. package/lib/components/include.ts +0 -410
  30. package/lib/components/input.ts +0 -457
  31. package/lib/components/list.ts +0 -419
  32. package/lib/components/loading.ts +0 -100
  33. package/lib/components/menu.ts +0 -275
  34. package/lib/components/modal.ts +0 -284
  35. package/lib/components/nav.ts +0 -257
  36. package/lib/components/paragraph.ts +0 -97
  37. package/lib/components/progress.ts +0 -159
  38. package/lib/components/radio.ts +0 -278
  39. package/lib/components/req.ts +0 -303
  40. package/lib/components/script.ts +0 -41
  41. package/lib/components/select.ts +0 -252
  42. package/lib/components/sidebar.ts +0 -275
  43. package/lib/components/style.ts +0 -41
  44. package/lib/components/switch.ts +0 -246
  45. package/lib/components/table.ts +0 -1249
  46. package/lib/components/tabs.ts +0 -250
  47. package/lib/components/theme-toggle.ts +0 -293
  48. package/lib/components/tooltip.ts +0 -144
  49. package/lib/components/view.ts +0 -190
  50. package/lib/components/write.ts +0 -272
  51. package/lib/layouts/default.css +0 -260
  52. package/lib/layouts/figma.css +0 -334
  53. package/lib/reactivity/state.ts +0 -78
  54. package/lib/utils/fetch.ts +0 -553
  55. package/machinery/ast.js +0 -347
  56. package/machinery/build.js +0 -466
  57. package/machinery/bundleAssets.js +0 -0
  58. package/machinery/bundleJux.js +0 -0
  59. package/machinery/bundleVendors.js +0 -0
  60. package/machinery/doc-generator.js +0 -136
  61. package/machinery/imports.js +0 -155
  62. package/machinery/ts-shim.js +0 -46
  63. package/machinery/validators/file-validator.js +0 -123
@@ -1,234 +0,0 @@
1
- import { FormInput, FormInputState } from './base/FormInput.js';
2
- import { renderIcon } from './icons.js';
3
-
4
- // Event definitions
5
- const TRIGGER_EVENTS = [] as const;
6
- const CALLBACK_EVENTS = ['change'] as const;
7
-
8
- export interface DatePickerOptions {
9
- value?: string;
10
- label?: string;
11
- placeholder?: string;
12
- required?: boolean;
13
- disabled?: boolean;
14
- name?: string;
15
- min?: string;
16
- max?: string;
17
- style?: string;
18
- class?: string;
19
- onValidate?: (value: string) => boolean | string;
20
- }
21
-
22
- interface DatePickerState extends FormInputState {
23
- value: string;
24
- placeholder: string;
25
- min?: string;
26
- max?: string;
27
- }
28
-
29
- export class DatePicker extends FormInput<DatePickerState> {
30
- constructor(id: string, options: DatePickerOptions = {}) {
31
- super(id, {
32
- value: options.value ?? '',
33
- placeholder: options.placeholder ?? 'Select a date',
34
- label: options.label ?? '',
35
- required: options.required ?? false,
36
- disabled: options.disabled ?? false,
37
- name: options.name ?? id,
38
- min: options.min,
39
- max: options.max,
40
- style: options.style ?? '',
41
- class: options.class ?? '',
42
- errorMessage: undefined
43
- });
44
-
45
- if (options.onValidate) {
46
- this._onValidate = options.onValidate;
47
- }
48
- }
49
-
50
- protected getTriggerEvents(): readonly string[] {
51
- return TRIGGER_EVENTS;
52
- }
53
-
54
- protected getCallbackEvents(): readonly string[] {
55
- return CALLBACK_EVENTS;
56
- }
57
-
58
- /* ═════════════════════════════════════════════════════════════════
59
- * FLUENT API
60
- * ═════════════════════════════════════════════════════════════════ */
61
-
62
- // ✅ Inherited from FormInput/BaseComponent:
63
- // - label(), required(), name(), onValidate()
64
- // - validate(), isValid()
65
- // - style(), class()
66
- // - bind(), sync(), renderTo()
67
- // - disabled(), enable(), disable()
68
-
69
- value(value: string): this {
70
- return this.setValue(value);
71
- }
72
-
73
- placeholder(value: string): this {
74
- this.state.placeholder = value;
75
- return this;
76
- }
77
-
78
- min(value: string): this {
79
- this.state.min = value;
80
- return this;
81
- }
82
-
83
- max(value: string): this {
84
- this.state.max = value;
85
- return this;
86
- }
87
-
88
- /* ═════════════════════════════════════════════════════════════════
89
- * FORM INPUT IMPLEMENTATION
90
- * ═════════════════════════════════════════════════════════════════ */
91
-
92
- getValue(): string {
93
- return this.state.value;
94
- }
95
-
96
- setValue(value: string): this {
97
- this.state.value = value;
98
- if (this._inputElement) {
99
- (this._inputElement as HTMLInputElement).value = value;
100
- }
101
- return this;
102
- }
103
-
104
- getDate(): Date | null {
105
- if (!this.state.value) return null;
106
- const date = new Date(this.state.value);
107
- return isNaN(date.getTime()) ? null : date;
108
- }
109
-
110
- protected _validateValue(value: string): boolean | string {
111
- const { required, min, max } = this.state;
112
-
113
- if (required && !value) {
114
- return 'Please select a date';
115
- }
116
-
117
- if (value) {
118
- const date = new Date(value);
119
-
120
- if (isNaN(date.getTime())) {
121
- return 'Invalid date';
122
- }
123
-
124
- if (min) {
125
- const minDate = new Date(min);
126
- if (date < minDate) {
127
- return `Date must be on or after ${min}`;
128
- }
129
- }
130
-
131
- if (max) {
132
- const maxDate = new Date(max);
133
- if (date > maxDate) {
134
- return `Date must be on or before ${max}`;
135
- }
136
- }
137
- }
138
-
139
- if (this._onValidate) {
140
- const result = this._onValidate(value);
141
- if (result !== true) {
142
- return result || 'Invalid date';
143
- }
144
- }
145
-
146
- return true;
147
- }
148
-
149
- protected _buildInputElement(): HTMLElement {
150
- const { value, placeholder, required, disabled, name, min, max } = this.state;
151
-
152
- const input = document.createElement('input');
153
- input.type = 'date';
154
- input.className = 'jux-input-element jux-datepicker-input';
155
- input.id = `${this._id}-input`;
156
- input.name = name;
157
- input.value = value;
158
- input.placeholder = placeholder;
159
- input.required = required;
160
- input.disabled = disabled;
161
-
162
- if (min) input.min = min;
163
- if (max) input.max = max;
164
-
165
- return input;
166
- }
167
-
168
- /* ═════════════════════════════════════════════════════════════════
169
- * RENDER
170
- * ═════════════════════════════════════════════════════════════════ */
171
-
172
- render(targetId?: string): this {
173
- const container = this._setupContainer(targetId);
174
-
175
- const { style, class: className } = this.state;
176
-
177
- // Build wrapper
178
- const wrapper = document.createElement('div');
179
- wrapper.className = 'jux-input jux-datepicker';
180
- wrapper.id = this._id;
181
- if (className) wrapper.className += ` ${className}`;
182
- if (style) wrapper.setAttribute('style', style);
183
-
184
- // Label
185
- if (this.state.label) {
186
- wrapper.appendChild(this._renderLabel());
187
- }
188
-
189
- // Input container
190
- const inputContainer = document.createElement('div');
191
- inputContainer.className = 'jux-input-container jux-datepicker-container';
192
-
193
- // Calendar icon
194
- const iconEl = document.createElement('span');
195
- iconEl.className = 'jux-input-icon';
196
- iconEl.appendChild(renderIcon('calendar'));
197
- inputContainer.appendChild(iconEl);
198
-
199
- // Date input
200
- const inputEl = this._buildInputElement();
201
- this._inputElement = inputEl;
202
- inputContainer.appendChild(inputEl);
203
- wrapper.appendChild(inputContainer);
204
-
205
- // Error element
206
- wrapper.appendChild(this._renderError());
207
-
208
- // Wire events
209
- this._wireStandardEvents(wrapper);
210
- this._wireFormSync(inputEl, 'change');
211
-
212
- // 🎯 Fire change event when date changes
213
- inputEl.addEventListener('change', () => {
214
- const input = inputEl as HTMLInputElement;
215
- this._triggerCallback('change', input.value);
216
- });
217
-
218
- // Sync label changes
219
- const labelSync = this._syncBindings.find(b => b.property === 'label');
220
- if (labelSync) {
221
- const transform = labelSync.toComponent || ((v: any) => String(v));
222
- labelSync.stateObj.subscribe((val: any) => {
223
- this.label(transform(val));
224
- });
225
- }
226
-
227
- container.appendChild(wrapper);
228
- return this;
229
- }
230
- }
231
-
232
- export function datepicker(id: string, options: DatePickerOptions = {}): DatePicker {
233
- return new DatePicker(id, options);
234
- }
@@ -1,172 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = ['confirm', 'cancel'] as const;
6
-
7
- export interface DialogOptions {
8
- title?: string;
9
- message?: string;
10
- confirmText?: string;
11
- cancelText?: string;
12
- variant?: 'default' | 'danger' | 'warning';
13
- style?: string;
14
- class?: string;
15
- }
16
-
17
- type DialogState = {
18
- title: string;
19
- message: string;
20
- confirmText: string;
21
- cancelText: string;
22
- variant: string;
23
- open: boolean;
24
- style: string;
25
- class: string;
26
- };
27
-
28
- export class Dialog extends BaseComponent<DialogState> {
29
- private _dialog: HTMLElement | null = null;
30
- private _overlay: HTMLElement | null = null;
31
-
32
- constructor(id: string, options: DialogOptions = {}) {
33
- super(id, {
34
- title: options.title ?? 'Confirm',
35
- message: options.message ?? 'Are you sure?',
36
- confirmText: options.confirmText ?? 'Confirm',
37
- cancelText: options.cancelText ?? 'Cancel',
38
- variant: options.variant ?? 'default',
39
- open: false,
40
- style: options.style ?? '',
41
- class: options.class ?? ''
42
- });
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
- /* ═════════════════════════════════════════════════════════════════
54
- * FLUENT API
55
- * ═════════════════════════════════════════════════════════════════ */
56
-
57
- title(value: string): this {
58
- this.state.title = value;
59
- return this;
60
- }
61
-
62
- message(value: string): this {
63
- this.state.message = value;
64
- return this;
65
- }
66
-
67
- confirmText(value: string): this {
68
- this.state.confirmText = value;
69
- return this;
70
- }
71
-
72
- cancelText(value: string): this {
73
- this.state.cancelText = value;
74
- return this;
75
- }
76
-
77
- variant(value: 'default' | 'danger' | 'warning'): this {
78
- this.state.variant = value;
79
- return this;
80
- }
81
-
82
- open(): this {
83
- this.state.open = true;
84
- if (this._overlay) {
85
- this._overlay.style.display = 'flex';
86
- }
87
- return this;
88
- }
89
-
90
- close(): this {
91
- this.state.open = false;
92
- if (this._overlay) {
93
- this._overlay.style.display = 'none';
94
- }
95
- return this;
96
- }
97
-
98
- /* ═════════════════════════════════════════════════════════════════
99
- * RENDER
100
- * ═════════════════════════════════════════════════════════════════ */
101
-
102
- render(targetId?: string): this {
103
- const { title, message, confirmText, cancelText, variant, style, class: className } = this.state;
104
-
105
- // Overlay
106
- const overlay = document.createElement('div');
107
- overlay.className = 'jux-dialog-overlay';
108
- overlay.style.display = 'none';
109
- this._overlay = overlay;
110
-
111
- // Dialog
112
- const dialog = document.createElement('div');
113
- dialog.className = `jux-dialog jux-dialog-${variant}`;
114
- dialog.id = this._id;
115
- if (className) dialog.className += ` ${className}`;
116
- if (style) dialog.setAttribute('style', style);
117
- this._dialog = dialog;
118
-
119
- // Title
120
- const titleEl = document.createElement('div');
121
- titleEl.className = 'jux-dialog-title';
122
- titleEl.textContent = title;
123
- dialog.appendChild(titleEl);
124
-
125
- // Message
126
- const messageEl = document.createElement('div');
127
- messageEl.className = 'jux-dialog-message';
128
- messageEl.textContent = message;
129
- dialog.appendChild(messageEl);
130
-
131
- // Actions
132
- const actions = document.createElement('div');
133
- actions.className = 'jux-dialog-actions';
134
-
135
- const cancelBtn = document.createElement('button');
136
- cancelBtn.className = 'jux-dialog-button jux-dialog-button-cancel';
137
- cancelBtn.textContent = cancelText;
138
- cancelBtn.addEventListener('click', () => {
139
- this._triggerCallback('cancel');
140
- this.close();
141
- });
142
-
143
- const confirmBtn = document.createElement('button');
144
- confirmBtn.className = `jux-dialog-button jux-dialog-button-confirm jux-dialog-button-${variant}`;
145
- confirmBtn.textContent = confirmText;
146
- confirmBtn.addEventListener('click', () => {
147
- this._triggerCallback('confirm');
148
- this.close();
149
- });
150
-
151
- actions.appendChild(cancelBtn);
152
- actions.appendChild(confirmBtn);
153
- dialog.appendChild(actions);
154
-
155
- // Close on overlay click
156
- overlay.addEventListener('click', (e) => {
157
- if (e.target === overlay) {
158
- this._triggerCallback('cancel');
159
- this.close();
160
- }
161
- });
162
-
163
- overlay.appendChild(dialog);
164
- document.body.appendChild(overlay);
165
-
166
- return this;
167
- }
168
- }
169
-
170
- export function dialog(id: string, options: DialogOptions = {}): Dialog {
171
- return new Dialog(id, options);
172
- }
@@ -1,100 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = [] as const;
6
-
7
- export interface DividerOptions {
8
- text?: string;
9
- variant?: 'default' | 'dashed' | 'dotted';
10
- margin?: string;
11
- style?: string;
12
- class?: string;
13
- }
14
-
15
- type DividerState = {
16
- text: string;
17
- variant: string;
18
- margin: string;
19
- style: string;
20
- class: string;
21
- orientation: string;
22
- };
23
-
24
- export class Divider extends BaseComponent<DividerState> {
25
- constructor(id: string = `divider-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, options: DividerOptions = {}) {
26
- super(id, {
27
- text: options.text ?? '',
28
- variant: options.variant ?? 'default',
29
- margin: options.margin ?? '1rem 0',
30
- style: options.style ?? '',
31
- class: options.class ?? '',
32
- orientation: 'horizontal'
33
- });
34
- }
35
-
36
- protected getTriggerEvents(): readonly string[] {
37
- return TRIGGER_EVENTS;
38
- }
39
-
40
- protected getCallbackEvents(): readonly string[] {
41
- return CALLBACK_EVENTS;
42
- }
43
-
44
- text(value: string): this {
45
- this.state.text = value;
46
- return this;
47
- }
48
-
49
- orientation(value: 'horizontal' | 'vertical'): this {
50
- this.state.orientation = value;
51
- return this;
52
- }
53
-
54
- style(value: string): this {
55
- this.state.style = value;
56
- return this;
57
- }
58
-
59
- class(value: string): this {
60
- this.state.class = value;
61
- return this;
62
- }
63
-
64
- render(targetId?: string): this {
65
- const container = this._setupContainer(targetId);
66
-
67
- const { text, variant, margin, style, class: className } = this.state;
68
-
69
- const divider = document.createElement('div');
70
- divider.className = `jux-divider jux-divider-${variant}`;
71
- divider.id = this._id;
72
- divider.style.margin = margin;
73
- if (className) divider.className += ` ${className}`;
74
- if (style) divider.setAttribute('style', `${divider.getAttribute('style')}; ${style}`);
75
-
76
- if (text) {
77
- const textEl = document.createElement('span');
78
- textEl.className = 'jux-divider-text';
79
- textEl.textContent = text;
80
- divider.appendChild(textEl);
81
- }
82
-
83
- this._wireStandardEvents(divider);
84
- container.appendChild(divider);
85
-
86
- return this;
87
- }
88
-
89
- renderTo(juxComponent: any): this {
90
- if (!juxComponent?._id) {
91
- throw new Error('Divider.renderTo: Invalid component');
92
- }
93
- return this.render(`#${juxComponent._id}`);
94
- }
95
- }
96
-
97
- // ✅ ID is now optional - auto-generated if not provided
98
- export function divider(options: DividerOptions = {}): Divider {
99
- return new Divider(undefined, options);
100
- }
@@ -1,186 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = ['select'] as const;
6
-
7
- export interface DropdownItem {
8
- label?: string;
9
- icon?: string;
10
- divider?: boolean;
11
- click?: () => void;
12
- }
13
-
14
- export interface DropdownOptions {
15
- triggerLabel?: string;
16
- items?: DropdownItem[];
17
- position?: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right';
18
- style?: string;
19
- class?: string;
20
- }
21
-
22
- type DropdownState = {
23
- triggerLabel: string;
24
- items: DropdownItem[];
25
- position: string;
26
- open: boolean;
27
- style: string;
28
- class: string;
29
- };
30
-
31
- export class Dropdown extends BaseComponent<DropdownState> {
32
- private _dropdown: HTMLElement | null = null;
33
- private _menu: HTMLElement | null = null;
34
-
35
- constructor(id: string, options: DropdownOptions = {}) {
36
- super(id, {
37
- triggerLabel: options.triggerLabel ?? 'Menu',
38
- items: options.items ?? [],
39
- position: options.position ?? 'bottom-left',
40
- open: false,
41
- style: options.style ?? '',
42
- class: options.class ?? ''
43
- });
44
- }
45
-
46
- protected getTriggerEvents(): readonly string[] {
47
- return TRIGGER_EVENTS;
48
- }
49
-
50
- protected getCallbackEvents(): readonly string[] {
51
- return CALLBACK_EVENTS;
52
- }
53
-
54
- /* ═════════════════════════════════════════════════════════════════
55
- * FLUENT API
56
- * ═════════════════════════════════════════════════════════════════ */
57
-
58
- triggerLabel(value: string): this {
59
- this.state.triggerLabel = value;
60
- return this;
61
- }
62
-
63
- items(value: DropdownItem[]): this {
64
- this.state.items = value;
65
- return this;
66
- }
67
-
68
- position(value: 'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'): this {
69
- this.state.position = value;
70
- return this;
71
- }
72
-
73
- open(): this {
74
- this.state.open = true;
75
- if (this._menu) {
76
- this._menu.style.display = 'block';
77
- }
78
- return this;
79
- }
80
-
81
- close(): this {
82
- this.state.open = false;
83
- if (this._menu) {
84
- this._menu.style.display = 'none';
85
- }
86
- return this;
87
- }
88
-
89
- toggle(): this {
90
- return this.state.open ? this.close() : this.open();
91
- }
92
-
93
- /* ═════════════════════════════════════════════════════════════════
94
- * RENDER
95
- * ═════════════════════════════════════════════════════════════════ */
96
-
97
- render(targetId?: string): this {
98
- const container = this._setupContainer(targetId);
99
-
100
- const { triggerLabel, items, position, style, class: className } = this.state;
101
-
102
- const wrapper = document.createElement('div');
103
- wrapper.className = 'jux-dropdown';
104
- wrapper.id = this._id;
105
- if (className) wrapper.className += ` ${className}`;
106
- if (style) wrapper.setAttribute('style', style);
107
-
108
- // Trigger button
109
- const triggerBtn = document.createElement('button');
110
- triggerBtn.className = 'jux-dropdown-trigger';
111
- triggerBtn.textContent = triggerLabel;
112
- triggerBtn.type = 'button';
113
-
114
- // Dropdown menu
115
- const menu = document.createElement('div');
116
- menu.className = `jux-dropdown-menu jux-dropdown-${position}`;
117
- menu.style.display = 'none';
118
- this._menu = menu;
119
-
120
- items.forEach(item => {
121
- if (item.divider) {
122
- const divider = document.createElement('div');
123
- divider.className = 'jux-dropdown-divider';
124
- menu.appendChild(divider);
125
- } else {
126
- const menuItem = document.createElement('button');
127
- menuItem.className = 'jux-dropdown-item';
128
- menuItem.type = 'button';
129
-
130
- if (item.icon) {
131
- const icon = document.createElement('span');
132
- icon.className = 'jux-dropdown-icon';
133
- icon.textContent = item.icon;
134
- menuItem.appendChild(icon);
135
- }
136
-
137
- if (item.label) {
138
- const label = document.createElement('span');
139
- label.textContent = item.label;
140
- menuItem.appendChild(label);
141
- }
142
-
143
- menuItem.addEventListener('click', () => {
144
- // 🎯 Fire the select callback event
145
- this._triggerCallback('select', item);
146
-
147
- // Then fire item-specific click handler
148
- if (item.click) {
149
- item.click();
150
- }
151
-
152
- this.close();
153
- });
154
-
155
- menu.appendChild(menuItem);
156
- }
157
- });
158
-
159
- // Toggle on trigger click
160
- triggerBtn.addEventListener('click', (e) => {
161
- e.stopPropagation();
162
- this.toggle();
163
- });
164
-
165
- // Close on outside click
166
- document.addEventListener('click', (e) => {
167
- if (this._dropdown && !this._dropdown.contains(e.target as Node)) {
168
- this.close();
169
- }
170
- });
171
-
172
- wrapper.appendChild(triggerBtn);
173
- wrapper.appendChild(menu);
174
-
175
- this._wireStandardEvents(wrapper);
176
-
177
- container.appendChild(wrapper);
178
- this._dropdown = wrapper;
179
-
180
- return this;
181
- }
182
- }
183
-
184
- export function dropdown(id: string, options: DropdownOptions = {}): Dropdown {
185
- return new Dropdown(id, options);
186
- }