juxscript 1.0.19 → 1.0.21

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 (77) hide show
  1. package/bin/cli.js +121 -72
  2. package/lib/components/alert.ts +212 -165
  3. package/lib/components/badge.ts +93 -103
  4. package/lib/components/base/BaseComponent.ts +397 -0
  5. package/lib/components/base/FormInput.ts +322 -0
  6. package/lib/components/button.ts +63 -122
  7. package/lib/components/card.ts +109 -155
  8. package/lib/components/charts/areachart.ts +315 -0
  9. package/lib/components/charts/barchart.ts +421 -0
  10. package/lib/components/charts/doughnutchart.ts +263 -0
  11. package/lib/components/charts/lib/BaseChart.ts +402 -0
  12. package/lib/components/charts/lib/chart-types.ts +159 -0
  13. package/lib/components/charts/lib/chart-utils.ts +160 -0
  14. package/lib/components/charts/lib/chart.ts +707 -0
  15. package/lib/components/checkbox.ts +264 -127
  16. package/lib/components/code.ts +75 -108
  17. package/lib/components/container.ts +113 -130
  18. package/lib/components/data.ts +37 -5
  19. package/lib/components/datepicker.ts +195 -147
  20. package/lib/components/dialog.ts +187 -157
  21. package/lib/components/divider.ts +85 -191
  22. package/lib/components/docs-data.json +544 -2027
  23. package/lib/components/dropdown.ts +178 -136
  24. package/lib/components/element.ts +227 -171
  25. package/lib/components/fileupload.ts +285 -228
  26. package/lib/components/guard.ts +92 -0
  27. package/lib/components/heading.ts +46 -69
  28. package/lib/components/helpers.ts +13 -6
  29. package/lib/components/hero.ts +107 -95
  30. package/lib/components/icon.ts +160 -0
  31. package/lib/components/icons.ts +175 -0
  32. package/lib/components/include.ts +153 -5
  33. package/lib/components/input.ts +174 -374
  34. package/lib/components/kpicard.ts +16 -16
  35. package/lib/components/list.ts +378 -240
  36. package/lib/components/loading.ts +142 -211
  37. package/lib/components/menu.ts +103 -97
  38. package/lib/components/modal.ts +138 -144
  39. package/lib/components/nav.ts +169 -90
  40. package/lib/components/paragraph.ts +49 -150
  41. package/lib/components/progress.ts +118 -200
  42. package/lib/components/radio.ts +297 -149
  43. package/lib/components/script.ts +19 -87
  44. package/lib/components/select.ts +184 -186
  45. package/lib/components/sidebar.ts +152 -140
  46. package/lib/components/style.ts +19 -82
  47. package/lib/components/switch.ts +258 -188
  48. package/lib/components/table.ts +1117 -170
  49. package/lib/components/tabs.ts +162 -145
  50. package/lib/components/theme-toggle.ts +108 -169
  51. package/lib/components/tooltip.ts +86 -157
  52. package/lib/components/write.ts +108 -127
  53. package/lib/jux.ts +86 -41
  54. package/machinery/build.js +466 -0
  55. package/machinery/compiler.js +354 -105
  56. package/machinery/server.js +23 -100
  57. package/machinery/watcher.js +153 -130
  58. package/package.json +1 -2
  59. package/presets/base.css +1166 -0
  60. package/presets/notion.css +2 -1975
  61. package/lib/adapters/base-adapter.js +0 -35
  62. package/lib/adapters/index.js +0 -33
  63. package/lib/adapters/mysql-adapter.js +0 -65
  64. package/lib/adapters/postgres-adapter.js +0 -70
  65. package/lib/adapters/sqlite-adapter.js +0 -56
  66. package/lib/components/areachart.ts +0 -1246
  67. package/lib/components/areachartsmooth.ts +0 -1380
  68. package/lib/components/barchart.ts +0 -1250
  69. package/lib/components/chart.ts +0 -127
  70. package/lib/components/doughnutchart.ts +0 -1191
  71. package/lib/components/footer.ts +0 -165
  72. package/lib/components/header.ts +0 -187
  73. package/lib/components/layout.ts +0 -239
  74. package/lib/components/main.ts +0 -137
  75. package/lib/layouts/default.jux +0 -8
  76. package/lib/layouts/figma.jux +0 -0
  77. /package/lib/{themes → components/charts/lib}/charts.js +0 -0
@@ -1,233 +1,127 @@
1
- /**
2
- * Divider - Simple horizontal or vertical divider line
3
- */
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+
3
+ // Event definitions
4
+ const TRIGGER_EVENTS = [] as const;
5
+ const CALLBACK_EVENTS = [] as const;
4
6
 
5
7
  export interface DividerOptions {
6
- orientation?: 'horizontal' | 'vertical';
7
- thickness?: number;
8
- color?: string;
8
+ text?: string;
9
+ variant?: 'default' | 'dashed' | 'dotted';
9
10
  margin?: string;
10
11
  style?: string;
11
- className?: string;
12
+ class?: string;
12
13
  }
13
14
 
14
- /**
15
- * Divider component for visual separation
16
- *
17
- * Usage:
18
- * // Simple horizontal divider
19
- * jux.divider().render('#container');
20
- *
21
- * // Vertical divider
22
- * jux.divider({ orientation: 'vertical' }).render('#container');
23
- *
24
- * // Custom styling
25
- * jux.divider({
26
- * thickness: 2,
27
- * color: '#3b82f6',
28
- * margin: '24px 0'
29
- * }).render('#container');
30
- *
31
- * // With custom class
32
- * jux.divider({ className: 'my-divider' }).render('#container');
33
- */
34
- export class Divider {
35
- private options: Required<DividerOptions>;
36
-
37
- constructor(options: DividerOptions = {}) {
38
- this.options = {
39
- orientation: 'horizontal',
40
- thickness: 1,
41
- color: '#e5e7eb',
42
- margin: '16px 0',
43
- style: '',
44
- className: '',
45
- ...options
46
- };
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
+ });
47
34
  }
48
35
 
49
- /**
50
- * Set orientation
51
- */
52
- orientation(value: 'horizontal' | 'vertical'): this {
53
- this.options.orientation = value;
54
- return this;
36
+ protected getTriggerEvents(): readonly string[] {
37
+ return TRIGGER_EVENTS;
55
38
  }
56
39
 
57
- /**
58
- * Set thickness in pixels
59
- */
60
- thickness(value: number): this {
61
- this.options.thickness = value;
62
- return this;
40
+ protected getCallbackEvents(): readonly string[] {
41
+ return CALLBACK_EVENTS;
63
42
  }
64
43
 
65
- /**
66
- * Set color
67
- */
68
- color(value: string): this {
69
- this.options.color = value;
44
+ text(value: string): this {
45
+ this.state.text = value;
70
46
  return this;
71
47
  }
72
48
 
73
- /**
74
- * Set margin
75
- */
76
- margin(value: string): this {
77
- this.options.margin = value;
49
+ orientation(value: 'horizontal' | 'vertical'): this {
50
+ this.state.orientation = value;
78
51
  return this;
79
52
  }
80
53
 
81
- /**
82
- * Set custom styles
83
- */
84
54
  style(value: string): this {
85
- this.options.style = value;
55
+ this.state.style = value;
86
56
  return this;
87
57
  }
88
58
 
89
- /**
90
- * Set class name
91
- */
92
- className(value: string): this {
93
- this.options.className = value;
59
+ class(value: string): this {
60
+ this.state.class = value;
94
61
  return this;
95
62
  }
96
63
 
97
- /**
98
- * Render divider to target element
99
- */
100
- render(targetSelector: string): this {
101
- const target = document.querySelector(targetSelector);
102
-
103
- if (!target || !(target instanceof HTMLElement)) {
104
- console.warn(`Divider: Target element "${targetSelector}" not found`);
105
- return this;
106
- }
64
+ render(targetId?: string): this {
65
+ const container = this._setupContainer(targetId);
107
66
 
108
- const divider = document.createElement('hr');
109
- divider.className = `jux-divider ${this.options.className}`.trim();
110
-
111
- const isVertical = this.options.orientation === 'vertical';
112
-
113
- const baseStyles = `
114
- border: none;
115
- background-color: ${this.options.color};
116
- margin: ${this.options.margin};
117
- ${isVertical ? `
118
- width: ${this.options.thickness}px;
119
- height: 100%;
120
- display: inline-block;
121
- vertical-align: middle;
122
- ` : `
123
- width: 100%;
124
- height: ${this.options.thickness}px;
125
- `}
126
- ${this.options.style}
127
- `;
128
-
129
- divider.setAttribute('style', baseStyles);
130
-
131
- target.appendChild(divider);
132
-
133
- return this;
134
- }
67
+ const { text, variant, margin, style, class: className } = this.state;
135
68
 
136
- /**
137
- * Replace target content with divider
138
- */
139
- replace(targetSelector: string): this {
140
- const target = document.querySelector(targetSelector);
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}`);
141
75
 
142
- if (!target || !(target instanceof HTMLElement)) {
143
- console.warn(`Divider: Target element "${targetSelector}" not found`);
144
- return this;
76
+ if (text) {
77
+ const textEl = document.createElement('span');
78
+ textEl.className = 'jux-divider-text';
79
+ textEl.textContent = text;
80
+ divider.appendChild(textEl);
145
81
  }
146
82
 
147
- target.innerHTML = '';
148
- return this.render(targetSelector);
149
- }
150
-
151
- /**
152
- * Render before target element
153
- */
154
- before(targetSelector: string): this {
155
- const target = document.querySelector(targetSelector);
156
-
157
- if (!target || !(target instanceof HTMLElement)) {
158
- console.warn(`Divider: Target element "${targetSelector}" not found`);
159
- return this;
160
- }
161
-
162
- const divider = document.createElement('hr');
163
- divider.className = `jux-divider ${this.options.className}`.trim();
164
-
165
- const isVertical = this.options.orientation === 'vertical';
166
-
167
- const baseStyles = `
168
- border: none;
169
- background-color: ${this.options.color};
170
- margin: ${this.options.margin};
171
- ${isVertical ? `
172
- width: ${this.options.thickness}px;
173
- height: 100%;
174
- display: inline-block;
175
- vertical-align: middle;
176
- ` : `
177
- width: 100%;
178
- height: ${this.options.thickness}px;
179
- `}
180
- ${this.options.style}
181
- `;
182
-
183
- divider.setAttribute('style', baseStyles);
184
- target.parentNode?.insertBefore(divider, target);
83
+ this._wireStandardEvents(divider);
84
+ container.appendChild(divider);
85
+ this._injectDividerStyles();
185
86
 
186
87
  return this;
187
88
  }
188
89
 
189
- /**
190
- * Render after target element
191
- */
192
- after(targetSelector: string): this {
193
- const target = document.querySelector(targetSelector);
194
-
195
- if (!target || !(target instanceof HTMLElement)) {
196
- console.warn(`Divider: Target element "${targetSelector}" not found`);
197
- return this;
90
+ renderTo(juxComponent: any): this {
91
+ if (!juxComponent?._id) {
92
+ throw new Error('Divider.renderTo: Invalid component');
198
93
  }
94
+ return this.render(`#${juxComponent._id}`);
95
+ }
199
96
 
200
- const divider = document.createElement('hr');
201
- divider.className = `jux-divider ${this.options.className}`.trim();
202
-
203
- const isVertical = this.options.orientation === 'vertical';
204
-
205
- const baseStyles = `
206
- border: none;
207
- background-color: ${this.options.color};
208
- margin: ${this.options.margin};
209
- ${isVertical ? `
210
- width: ${this.options.thickness}px;
211
- height: 100%;
212
- display: inline-block;
213
- vertical-align: middle;
214
- ` : `
215
- width: 100%;
216
- height: ${this.options.thickness}px;
217
- `}
218
- ${this.options.style}
97
+ private _injectDividerStyles(): void {
98
+ if (document.getElementById('jux-divider-styles')) return;
99
+
100
+ const style = document.createElement('style');
101
+ style.id = 'jux-divider-styles';
102
+ style.textContent = `
103
+ .jux-divider {
104
+ display: flex;
105
+ align-items: center;
106
+ border-top: 1px solid #e0e0e0;
107
+ }
108
+ .jux-divider-dashed {
109
+ border-top-style: dashed;
110
+ }
111
+ .jux-divider-dotted {
112
+ border-top-style: dotted;
113
+ }
114
+ .jux-divider-text {
115
+ padding: 0 1rem;
116
+ background: white;
117
+ position: relative;
118
+ }
219
119
  `;
220
-
221
- divider.setAttribute('style', baseStyles);
222
- target.parentNode?.insertBefore(divider, target.nextSibling);
223
-
224
- return this;
120
+ document.head.appendChild(style);
225
121
  }
226
122
  }
227
123
 
228
- /**
229
- * Factory function for quick divider creation
230
- */
124
+ // ✅ ID is now optional - auto-generated if not provided
231
125
  export function divider(options: DividerOptions = {}): Divider {
232
- return new Divider(options);
126
+ return new Divider(undefined, options);
233
127
  }