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.
- package/bin/cli.js +121 -72
- package/lib/components/alert.ts +212 -165
- package/lib/components/badge.ts +93 -103
- package/lib/components/base/BaseComponent.ts +397 -0
- package/lib/components/base/FormInput.ts +322 -0
- package/lib/components/button.ts +63 -122
- package/lib/components/card.ts +109 -155
- package/lib/components/charts/areachart.ts +315 -0
- package/lib/components/charts/barchart.ts +421 -0
- package/lib/components/charts/doughnutchart.ts +263 -0
- package/lib/components/charts/lib/BaseChart.ts +402 -0
- package/lib/components/charts/lib/chart-types.ts +159 -0
- package/lib/components/charts/lib/chart-utils.ts +160 -0
- package/lib/components/charts/lib/chart.ts +707 -0
- package/lib/components/checkbox.ts +264 -127
- package/lib/components/code.ts +75 -108
- package/lib/components/container.ts +113 -130
- package/lib/components/data.ts +37 -5
- package/lib/components/datepicker.ts +195 -147
- package/lib/components/dialog.ts +187 -157
- package/lib/components/divider.ts +85 -191
- package/lib/components/docs-data.json +544 -2027
- package/lib/components/dropdown.ts +178 -136
- package/lib/components/element.ts +227 -171
- package/lib/components/fileupload.ts +285 -228
- package/lib/components/guard.ts +92 -0
- package/lib/components/heading.ts +46 -69
- package/lib/components/helpers.ts +13 -6
- package/lib/components/hero.ts +107 -95
- package/lib/components/icon.ts +160 -0
- package/lib/components/icons.ts +175 -0
- package/lib/components/include.ts +153 -5
- package/lib/components/input.ts +174 -374
- package/lib/components/kpicard.ts +16 -16
- package/lib/components/list.ts +378 -240
- package/lib/components/loading.ts +142 -211
- package/lib/components/menu.ts +103 -97
- package/lib/components/modal.ts +138 -144
- package/lib/components/nav.ts +169 -90
- package/lib/components/paragraph.ts +49 -150
- package/lib/components/progress.ts +118 -200
- package/lib/components/radio.ts +297 -149
- package/lib/components/script.ts +19 -87
- package/lib/components/select.ts +184 -186
- package/lib/components/sidebar.ts +152 -140
- package/lib/components/style.ts +19 -82
- package/lib/components/switch.ts +258 -188
- package/lib/components/table.ts +1117 -170
- package/lib/components/tabs.ts +162 -145
- package/lib/components/theme-toggle.ts +108 -169
- package/lib/components/tooltip.ts +86 -157
- package/lib/components/write.ts +108 -127
- package/lib/jux.ts +86 -41
- package/machinery/build.js +466 -0
- package/machinery/compiler.js +354 -105
- package/machinery/server.js +23 -100
- package/machinery/watcher.js +153 -130
- package/package.json +1 -2
- package/presets/base.css +1166 -0
- package/presets/notion.css +2 -1975
- package/lib/adapters/base-adapter.js +0 -35
- package/lib/adapters/index.js +0 -33
- package/lib/adapters/mysql-adapter.js +0 -65
- package/lib/adapters/postgres-adapter.js +0 -70
- package/lib/adapters/sqlite-adapter.js +0 -56
- package/lib/components/areachart.ts +0 -1246
- package/lib/components/areachartsmooth.ts +0 -1380
- package/lib/components/barchart.ts +0 -1250
- package/lib/components/chart.ts +0 -127
- package/lib/components/doughnutchart.ts +0 -1191
- package/lib/components/footer.ts +0 -165
- package/lib/components/header.ts +0 -187
- package/lib/components/layout.ts +0 -239
- package/lib/components/main.ts +0 -137
- package/lib/layouts/default.jux +0 -8
- package/lib/layouts/figma.jux +0 -0
- /package/lib/{themes → components/charts/lib}/charts.js +0 -0
|
@@ -1,233 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
color?: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
variant?: 'default' | 'dashed' | 'dotted';
|
|
9
10
|
margin?: string;
|
|
10
11
|
style?: string;
|
|
11
|
-
|
|
12
|
+
class?: string;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
55
|
+
this.state.style = value;
|
|
86
56
|
return this;
|
|
87
57
|
}
|
|
88
58
|
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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 (
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
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
|
}
|