juxscript 1.1.4 → 1.1.6
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/index.d.ts +10 -10
- package/index.d.ts.map +1 -0
- package/lib/components/alert.d.ts +32 -0
- package/lib/components/alert.d.ts.map +1 -0
- package/lib/components/alert.js +153 -0
- package/lib/components/alert.ts +200 -0
- package/lib/components/app.d.ts +89 -0
- package/lib/components/app.d.ts.map +1 -0
- package/lib/components/app.js +175 -0
- package/lib/components/app.ts +247 -0
- package/lib/components/badge.d.ts +27 -0
- package/lib/components/badge.d.ts.map +1 -0
- package/lib/components/badge.js +70 -0
- package/lib/components/badge.ts +101 -0
- package/lib/components/base/BaseComponent.d.ts +142 -0
- package/lib/components/base/BaseComponent.d.ts.map +1 -0
- package/lib/components/base/BaseComponent.js +363 -0
- package/lib/components/base/BaseComponent.ts +421 -0
- package/lib/components/base/FormInput.d.ts +73 -0
- package/lib/components/base/FormInput.d.ts.map +1 -0
- package/lib/components/base/FormInput.js +163 -0
- package/lib/components/base/FormInput.ts +227 -0
- package/lib/components/button.d.ts +48 -0
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.js +121 -0
- package/lib/components/button.ts +178 -0
- package/lib/components/card.d.ts +34 -0
- package/lib/components/card.d.ts.map +1 -0
- package/lib/components/card.js +127 -0
- package/lib/components/card.ts +173 -0
- package/lib/components/chart.d.ts +45 -0
- package/lib/components/chart.d.ts.map +1 -0
- package/lib/components/chart.js +186 -0
- package/lib/components/chart.ts +231 -0
- package/lib/components/checkbox.d.ts +31 -0
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.js +185 -0
- package/lib/components/checkbox.ts +242 -0
- package/lib/components/code.d.ts +24 -0
- package/lib/components/code.d.ts.map +1 -0
- package/lib/components/code.js +88 -0
- package/lib/components/code.ts +123 -0
- package/lib/components/container.d.ts +42 -0
- package/lib/components/container.d.ts.map +1 -0
- package/lib/components/container.js +93 -0
- package/lib/components/container.ts +140 -0
- package/lib/components/data.d.ts +36 -0
- package/lib/components/data.d.ts.map +1 -0
- package/lib/components/data.js +110 -0
- package/lib/components/data.ts +135 -0
- package/lib/components/datepicker.d.ts +38 -0
- package/lib/components/datepicker.d.ts.map +1 -0
- package/lib/components/datepicker.js +177 -0
- package/lib/components/datepicker.ts +234 -0
- package/lib/components/dialog.d.ts +38 -0
- package/lib/components/dialog.d.ts.map +1 -0
- package/lib/components/dialog.js +126 -0
- package/lib/components/dialog.ts +172 -0
- package/lib/components/divider.d.ts +30 -0
- package/lib/components/divider.d.ts.map +1 -0
- package/lib/components/divider.js +69 -0
- package/lib/components/divider.ts +100 -0
- package/lib/components/dropdown.d.ts +39 -0
- package/lib/components/dropdown.d.ts.map +1 -0
- package/lib/components/dropdown.js +133 -0
- package/lib/components/dropdown.ts +186 -0
- package/lib/components/element.d.ts +50 -0
- package/lib/components/element.d.ts.map +1 -0
- package/lib/components/element.js +206 -0
- package/lib/components/element.ts +267 -0
- package/lib/components/fileupload.d.ts +40 -0
- package/lib/components/fileupload.d.ts.map +1 -0
- package/lib/components/fileupload.js +241 -0
- package/lib/components/fileupload.ts +309 -0
- package/lib/components/grid.d.ts +87 -0
- package/lib/components/grid.d.ts.map +1 -0
- package/lib/components/grid.js +205 -0
- package/lib/components/grid.ts +291 -0
- package/lib/components/guard.d.ts +41 -0
- package/lib/components/guard.d.ts.map +1 -0
- package/lib/components/guard.js +56 -0
- package/lib/components/guard.ts +92 -0
- package/lib/components/heading.d.ts +24 -0
- package/lib/components/heading.d.ts.map +1 -0
- package/lib/components/heading.js +67 -0
- package/lib/components/heading.ts +96 -0
- package/lib/components/helpers.d.ts +9 -0
- package/lib/components/helpers.d.ts.map +1 -0
- package/lib/components/helpers.js +30 -0
- package/lib/components/helpers.ts +41 -0
- package/lib/components/hero.d.ts +45 -0
- package/lib/components/hero.d.ts.map +1 -0
- package/lib/components/hero.js +165 -0
- package/lib/components/hero.ts +224 -0
- package/lib/components/icon.d.ts +35 -0
- package/lib/components/icon.d.ts.map +1 -0
- package/lib/components/icon.js +132 -0
- package/lib/components/icon.ts +178 -0
- package/lib/components/icons.d.ts +25 -0
- package/lib/components/icons.d.ts.map +1 -0
- package/lib/components/icons.js +440 -0
- package/lib/components/icons.ts +464 -0
- package/lib/components/include.d.ts +120 -0
- package/lib/components/include.d.ts.map +1 -0
- package/lib/components/include.js +350 -0
- package/lib/components/include.ts +410 -0
- package/lib/components/input.d.ts +83 -0
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.js +348 -0
- package/lib/components/input.ts +457 -0
- package/lib/components/list.d.ts +82 -0
- package/lib/components/list.d.ts.map +1 -0
- package/lib/components/list.js +311 -0
- package/lib/components/list.ts +419 -0
- package/lib/components/loading.d.ts +24 -0
- package/lib/components/loading.d.ts.map +1 -0
- package/lib/components/loading.js +73 -0
- package/lib/components/loading.ts +100 -0
- package/lib/components/menu.d.ts +37 -0
- package/lib/components/menu.d.ts.map +1 -0
- package/lib/components/menu.js +202 -0
- package/lib/components/menu.ts +275 -0
- package/lib/components/modal.d.ts +51 -0
- package/lib/components/modal.d.ts.map +1 -0
- package/lib/components/modal.js +227 -0
- package/lib/components/modal.ts +284 -0
- package/lib/components/nav.d.ts +45 -0
- package/lib/components/nav.d.ts.map +1 -0
- package/lib/components/nav.js +190 -0
- package/lib/components/nav.ts +257 -0
- package/lib/components/paragraph.d.ts +21 -0
- package/lib/components/paragraph.d.ts.map +1 -0
- package/lib/components/paragraph.js +70 -0
- package/lib/components/paragraph.ts +97 -0
- package/lib/components/progress.d.ts +39 -0
- package/lib/components/progress.d.ts.map +1 -0
- package/lib/components/progress.js +113 -0
- package/lib/components/progress.ts +159 -0
- package/lib/components/radio.d.ts +41 -0
- package/lib/components/radio.d.ts.map +1 -0
- package/lib/components/radio.js +203 -0
- package/lib/components/radio.ts +278 -0
- package/lib/components/req.d.ts +155 -0
- package/lib/components/req.d.ts.map +1 -0
- package/lib/components/req.js +253 -0
- package/lib/components/req.ts +303 -0
- package/lib/components/script.d.ts +14 -0
- package/lib/components/script.d.ts.map +1 -0
- package/lib/components/script.js +33 -0
- package/lib/components/script.ts +41 -0
- package/lib/components/select.d.ts +40 -0
- package/lib/components/select.d.ts.map +1 -0
- package/lib/components/select.js +183 -0
- package/lib/components/select.ts +252 -0
- package/lib/components/sidebar.d.ts +48 -0
- package/lib/components/sidebar.d.ts.map +1 -0
- package/lib/components/sidebar.js +207 -0
- package/lib/components/sidebar.ts +275 -0
- package/lib/components/style.d.ts +14 -0
- package/lib/components/style.d.ts.map +1 -0
- package/lib/components/style.js +33 -0
- package/lib/components/style.ts +41 -0
- package/lib/components/switch.d.ts +32 -0
- package/lib/components/switch.d.ts.map +1 -0
- package/lib/components/switch.js +186 -0
- package/lib/components/switch.ts +246 -0
- package/lib/components/table.d.ts +137 -0
- package/lib/components/table.d.ts.map +1 -0
- package/lib/components/table.js +1045 -0
- package/lib/components/table.ts +1249 -0
- package/lib/components/tabs.d.ts +36 -0
- package/lib/components/tabs.d.ts.map +1 -0
- package/lib/components/tabs.js +198 -0
- package/lib/components/tabs.ts +250 -0
- package/lib/components/theme-toggle.d.ts +44 -0
- package/lib/components/theme-toggle.d.ts.map +1 -0
- package/lib/components/theme-toggle.js +215 -0
- package/lib/components/theme-toggle.ts +293 -0
- package/lib/components/tooltip.d.ts +30 -0
- package/lib/components/tooltip.d.ts.map +1 -0
- package/lib/components/tooltip.js +109 -0
- package/lib/components/tooltip.ts +144 -0
- package/lib/components/view.d.ts +48 -0
- package/lib/components/view.d.ts.map +1 -0
- package/lib/components/view.js +149 -0
- package/lib/components/view.ts +190 -0
- package/lib/components/write.d.ts +107 -0
- package/lib/components/write.d.ts.map +1 -0
- package/lib/components/write.js +222 -0
- package/lib/components/write.ts +272 -0
- package/lib/layouts/default.css +260 -0
- package/lib/layouts/figma.css +334 -0
- package/lib/reactivity/state.d.ts +36 -0
- package/lib/reactivity/state.d.ts.map +1 -0
- package/lib/reactivity/state.js +67 -0
- package/lib/reactivity/state.ts +78 -0
- package/lib/utils/fetch.d.ts +176 -0
- package/lib/utils/fetch.d.ts.map +1 -0
- package/lib/utils/fetch.js +427 -0
- package/lib/utils/fetch.ts +553 -0
- package/machinery/compiler3.js +78 -0
- package/machinery/doc-generator.js +136 -0
- package/machinery/imports.js +155 -0
- package/machinery/ts-shim.js +46 -0
- package/package.json +9 -15
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App - Configure application-level settings
|
|
3
|
+
* Manages document metadata, theme, and global configuration
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* jux.app('myApp').setup({
|
|
7
|
+
* title: 'My App',
|
|
8
|
+
* theme: 'dark',
|
|
9
|
+
* favicon: '/favicon.ico',
|
|
10
|
+
* stylesheets: [
|
|
11
|
+
* '/lib/layouts/notion.css',
|
|
12
|
+
* '/lib/presets/light.css'
|
|
13
|
+
* ],
|
|
14
|
+
* layout: {
|
|
15
|
+
* header: true,
|
|
16
|
+
* sidebar: true,
|
|
17
|
+
* main: true,
|
|
18
|
+
* footer: true
|
|
19
|
+
* }
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* // Or fluent
|
|
23
|
+
* jux.app('myApp')
|
|
24
|
+
* .title('My App')
|
|
25
|
+
* .theme('dark')
|
|
26
|
+
* .addStylesheet('/presets/main.css')
|
|
27
|
+
* .render();
|
|
28
|
+
*/
|
|
29
|
+
export class App {
|
|
30
|
+
constructor(id, options) {
|
|
31
|
+
this._componentId = id;
|
|
32
|
+
this.id = id;
|
|
33
|
+
const opts = options || {};
|
|
34
|
+
this.state = {
|
|
35
|
+
title: opts.title ?? '',
|
|
36
|
+
theme: opts.theme ?? 'auto',
|
|
37
|
+
favicon: opts.favicon ?? '',
|
|
38
|
+
meta: new Map(Object.entries(opts.meta || {})),
|
|
39
|
+
stylesheets: opts.stylesheets || [],
|
|
40
|
+
scripts: opts.scripts || [],
|
|
41
|
+
layout: {
|
|
42
|
+
header: opts.layout?.header ?? false,
|
|
43
|
+
subheader: opts.layout?.subheader ?? false,
|
|
44
|
+
sidebar: opts.layout?.sidebar ?? false,
|
|
45
|
+
main: opts.layout?.main ?? true,
|
|
46
|
+
aside: opts.layout?.aside ?? false,
|
|
47
|
+
footer: opts.layout?.footer ?? false
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/* -------------------------
|
|
52
|
+
* Fluent API
|
|
53
|
+
* ------------------------- */
|
|
54
|
+
title(value) {
|
|
55
|
+
this.state.title = value;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
theme(value) {
|
|
59
|
+
this.state.theme = value;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
favicon(value) {
|
|
63
|
+
this.state.favicon = value;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
meta(name, content) {
|
|
67
|
+
this.state.meta.set(name, content);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
addStylesheet(url) {
|
|
71
|
+
if (!this.state.stylesheets.includes(url)) {
|
|
72
|
+
this.state.stylesheets.push(url);
|
|
73
|
+
}
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
addScript(url) {
|
|
77
|
+
if (!this.state.scripts.includes(url)) {
|
|
78
|
+
this.state.scripts.push(url);
|
|
79
|
+
}
|
|
80
|
+
return this;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Setup app with comprehensive configuration
|
|
84
|
+
*/
|
|
85
|
+
setup(options) {
|
|
86
|
+
if (options.title)
|
|
87
|
+
this.state.title = options.title;
|
|
88
|
+
if (options.theme)
|
|
89
|
+
this.state.theme = options.theme;
|
|
90
|
+
if (options.favicon)
|
|
91
|
+
this.state.favicon = options.favicon;
|
|
92
|
+
if (options.meta) {
|
|
93
|
+
Object.entries(options.meta).forEach(([name, content]) => {
|
|
94
|
+
this.state.meta.set(name, content);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (options.stylesheets) {
|
|
98
|
+
options.stylesheets.forEach(url => this.addStylesheet(url));
|
|
99
|
+
}
|
|
100
|
+
if (options.scripts) {
|
|
101
|
+
options.scripts.forEach(url => this.addScript(url));
|
|
102
|
+
}
|
|
103
|
+
if (options.layout) {
|
|
104
|
+
this.state.layout = { ...this.state.layout, ...options.layout };
|
|
105
|
+
}
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/* -------------------------
|
|
109
|
+
* Render
|
|
110
|
+
* ------------------------- */
|
|
111
|
+
render() {
|
|
112
|
+
if (typeof document === 'undefined')
|
|
113
|
+
return this;
|
|
114
|
+
try {
|
|
115
|
+
const { title, theme, favicon, meta, stylesheets, scripts } = this.state;
|
|
116
|
+
// Apply title
|
|
117
|
+
if (title) {
|
|
118
|
+
document.title = title;
|
|
119
|
+
}
|
|
120
|
+
// Apply theme
|
|
121
|
+
if (theme) {
|
|
122
|
+
document.body.setAttribute('data-theme', theme);
|
|
123
|
+
document.body.classList.remove('theme-light', 'theme-dark', 'theme-auto');
|
|
124
|
+
document.body.classList.add(`theme-${theme}`);
|
|
125
|
+
}
|
|
126
|
+
// Apply favicon
|
|
127
|
+
if (favicon) {
|
|
128
|
+
let link = document.querySelector('link[rel="icon"]');
|
|
129
|
+
if (!link) {
|
|
130
|
+
link = document.createElement('link');
|
|
131
|
+
link.rel = 'icon';
|
|
132
|
+
document.head.appendChild(link);
|
|
133
|
+
}
|
|
134
|
+
link.href = favicon;
|
|
135
|
+
}
|
|
136
|
+
// Apply meta tags
|
|
137
|
+
meta.forEach((content, name) => {
|
|
138
|
+
let metaEl = document.querySelector(`meta[name="${name}"]`);
|
|
139
|
+
if (!metaEl) {
|
|
140
|
+
metaEl = document.createElement('meta');
|
|
141
|
+
metaEl.name = name;
|
|
142
|
+
document.head.appendChild(metaEl);
|
|
143
|
+
}
|
|
144
|
+
metaEl.content = content;
|
|
145
|
+
});
|
|
146
|
+
// Load stylesheets
|
|
147
|
+
stylesheets.forEach(url => {
|
|
148
|
+
if (!document.querySelector(`link[href="${url}"]`)) {
|
|
149
|
+
const link = document.createElement('link');
|
|
150
|
+
link.rel = 'stylesheet';
|
|
151
|
+
link.href = url;
|
|
152
|
+
document.head.appendChild(link);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Load scripts
|
|
156
|
+
scripts.forEach(url => {
|
|
157
|
+
if (!document.querySelector(`script[src="${url}"]`)) {
|
|
158
|
+
const script = document.createElement('script');
|
|
159
|
+
script.src = url;
|
|
160
|
+
document.head.appendChild(script);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
catch (error) {
|
|
165
|
+
throw new Error(`App render failed: ${error.message}`);
|
|
166
|
+
}
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Factory helper
|
|
172
|
+
*/
|
|
173
|
+
export function app(id, options) {
|
|
174
|
+
return new App(id, options);
|
|
175
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* App component options
|
|
5
|
+
*/
|
|
6
|
+
export interface AppOptions {
|
|
7
|
+
title?: string;
|
|
8
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
9
|
+
favicon?: string;
|
|
10
|
+
meta?: Record<string, string>;
|
|
11
|
+
stylesheets?: string[];
|
|
12
|
+
scripts?: string[];
|
|
13
|
+
layout?: {
|
|
14
|
+
header?: boolean | string;
|
|
15
|
+
subheader?: boolean | string;
|
|
16
|
+
sidebar?: boolean | string;
|
|
17
|
+
main?: boolean | string;
|
|
18
|
+
aside?: boolean | string;
|
|
19
|
+
footer?: boolean | string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* App component state
|
|
25
|
+
*/
|
|
26
|
+
type AppState = {
|
|
27
|
+
title: string;
|
|
28
|
+
theme: string;
|
|
29
|
+
favicon: string;
|
|
30
|
+
meta: Map<string, string>;
|
|
31
|
+
stylesheets: string[];
|
|
32
|
+
scripts: string[];
|
|
33
|
+
layout: {
|
|
34
|
+
header: boolean | string;
|
|
35
|
+
subheader: boolean | string;
|
|
36
|
+
sidebar: boolean | string;
|
|
37
|
+
main: boolean | string;
|
|
38
|
+
aside: boolean | string;
|
|
39
|
+
footer: boolean | string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* App - Configure application-level settings
|
|
45
|
+
* Manages document metadata, theme, and global configuration
|
|
46
|
+
*
|
|
47
|
+
* Usage:
|
|
48
|
+
* jux.app('myApp').setup({
|
|
49
|
+
* title: 'My App',
|
|
50
|
+
* theme: 'dark',
|
|
51
|
+
* favicon: '/favicon.ico',
|
|
52
|
+
* stylesheets: [
|
|
53
|
+
* '/lib/layouts/notion.css',
|
|
54
|
+
* '/lib/presets/light.css'
|
|
55
|
+
* ],
|
|
56
|
+
* layout: {
|
|
57
|
+
* header: true,
|
|
58
|
+
* sidebar: true,
|
|
59
|
+
* main: true,
|
|
60
|
+
* footer: true
|
|
61
|
+
* }
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Or fluent
|
|
65
|
+
* jux.app('myApp')
|
|
66
|
+
* .title('My App')
|
|
67
|
+
* .theme('dark')
|
|
68
|
+
* .addStylesheet('/presets/main.css')
|
|
69
|
+
* .render();
|
|
70
|
+
*/
|
|
71
|
+
export class App {
|
|
72
|
+
state: AppState;
|
|
73
|
+
_componentId: string;
|
|
74
|
+
id: string;
|
|
75
|
+
|
|
76
|
+
constructor(id: string, options?: AppOptions) {
|
|
77
|
+
this._componentId = id;
|
|
78
|
+
this.id = id;
|
|
79
|
+
|
|
80
|
+
const opts = options || {};
|
|
81
|
+
|
|
82
|
+
this.state = {
|
|
83
|
+
title: opts.title ?? '',
|
|
84
|
+
theme: opts.theme ?? 'auto',
|
|
85
|
+
favicon: opts.favicon ?? '',
|
|
86
|
+
meta: new Map(Object.entries(opts.meta || {})),
|
|
87
|
+
stylesheets: opts.stylesheets || [],
|
|
88
|
+
scripts: opts.scripts || [],
|
|
89
|
+
layout: {
|
|
90
|
+
header: opts.layout?.header ?? false,
|
|
91
|
+
subheader: opts.layout?.subheader ?? false,
|
|
92
|
+
sidebar: opts.layout?.sidebar ?? false,
|
|
93
|
+
main: opts.layout?.main ?? true,
|
|
94
|
+
aside: opts.layout?.aside ?? false,
|
|
95
|
+
footer: opts.layout?.footer ?? false
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* -------------------------
|
|
101
|
+
* Fluent API
|
|
102
|
+
* ------------------------- */
|
|
103
|
+
|
|
104
|
+
title(value: string): this {
|
|
105
|
+
this.state.title = value;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
theme(value: 'light' | 'dark' | 'auto'): this {
|
|
110
|
+
this.state.theme = value;
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
favicon(value: string): this {
|
|
115
|
+
this.state.favicon = value;
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
meta(name: string, content: string): this {
|
|
120
|
+
this.state.meta.set(name, content);
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
addStylesheet(url: string): this {
|
|
125
|
+
if (!this.state.stylesheets.includes(url)) {
|
|
126
|
+
this.state.stylesheets.push(url);
|
|
127
|
+
}
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
addScript(url: string): this {
|
|
132
|
+
if (!this.state.scripts.includes(url)) {
|
|
133
|
+
this.state.scripts.push(url);
|
|
134
|
+
}
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Setup app with comprehensive configuration
|
|
140
|
+
*/
|
|
141
|
+
setup(options: AppOptions): this {
|
|
142
|
+
if (options.title) this.state.title = options.title;
|
|
143
|
+
if (options.theme) this.state.theme = options.theme;
|
|
144
|
+
if (options.favicon) this.state.favicon = options.favicon;
|
|
145
|
+
|
|
146
|
+
if (options.meta) {
|
|
147
|
+
Object.entries(options.meta).forEach(([name, content]) => {
|
|
148
|
+
this.state.meta.set(name, content);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (options.stylesheets) {
|
|
153
|
+
options.stylesheets.forEach(url => this.addStylesheet(url));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (options.scripts) {
|
|
157
|
+
options.scripts.forEach(url => this.addScript(url));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (options.layout) {
|
|
161
|
+
this.state.layout = { ...this.state.layout, ...options.layout };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/* -------------------------
|
|
168
|
+
* Render
|
|
169
|
+
* ------------------------- */
|
|
170
|
+
|
|
171
|
+
render(): this {
|
|
172
|
+
if (typeof document === 'undefined') return this;
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
const { title, theme, favicon, meta, stylesheets, scripts } = this.state;
|
|
176
|
+
|
|
177
|
+
// Apply title
|
|
178
|
+
if (title) {
|
|
179
|
+
document.title = title;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Apply theme
|
|
183
|
+
if (theme) {
|
|
184
|
+
document.body.setAttribute('data-theme', theme);
|
|
185
|
+
document.body.classList.remove('theme-light', 'theme-dark', 'theme-auto');
|
|
186
|
+
document.body.classList.add(`theme-${theme}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// Apply favicon
|
|
190
|
+
if (favicon) {
|
|
191
|
+
let link = document.querySelector<HTMLLinkElement>('link[rel="icon"]');
|
|
192
|
+
|
|
193
|
+
if (!link) {
|
|
194
|
+
link = document.createElement('link');
|
|
195
|
+
link.rel = 'icon';
|
|
196
|
+
document.head.appendChild(link);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
link.href = favicon;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Apply meta tags
|
|
203
|
+
meta.forEach((content, name) => {
|
|
204
|
+
let metaEl = document.querySelector<HTMLMetaElement>(`meta[name="${name}"]`);
|
|
205
|
+
|
|
206
|
+
if (!metaEl) {
|
|
207
|
+
metaEl = document.createElement('meta');
|
|
208
|
+
metaEl.name = name;
|
|
209
|
+
document.head.appendChild(metaEl);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
metaEl.content = content;
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Load stylesheets
|
|
216
|
+
stylesheets.forEach(url => {
|
|
217
|
+
if (!document.querySelector(`link[href="${url}"]`)) {
|
|
218
|
+
const link = document.createElement('link');
|
|
219
|
+
link.rel = 'stylesheet';
|
|
220
|
+
link.href = url;
|
|
221
|
+
document.head.appendChild(link);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// Load scripts
|
|
226
|
+
scripts.forEach(url => {
|
|
227
|
+
if (!document.querySelector(`script[src="${url}"]`)) {
|
|
228
|
+
const script = document.createElement('script');
|
|
229
|
+
script.src = url;
|
|
230
|
+
document.head.appendChild(script);
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
} catch (error: any) {
|
|
235
|
+
throw new Error(`App render failed: ${error.message}`);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Factory helper
|
|
244
|
+
*/
|
|
245
|
+
export function app(id: string, options?: AppOptions): App {
|
|
246
|
+
return new App(id, options);
|
|
247
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
export interface BadgeOptions {
|
|
3
|
+
label?: string;
|
|
4
|
+
variant?: 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
5
|
+
pill?: boolean;
|
|
6
|
+
style?: string;
|
|
7
|
+
class?: string;
|
|
8
|
+
}
|
|
9
|
+
type BadgeState = {
|
|
10
|
+
label: string;
|
|
11
|
+
variant: string;
|
|
12
|
+
pill: boolean;
|
|
13
|
+
style: string;
|
|
14
|
+
class: string;
|
|
15
|
+
};
|
|
16
|
+
export declare class Badge extends BaseComponent<BadgeState> {
|
|
17
|
+
constructor(id: string, options?: BadgeOptions);
|
|
18
|
+
protected getTriggerEvents(): readonly string[];
|
|
19
|
+
protected getCallbackEvents(): readonly string[];
|
|
20
|
+
label(value: string): this;
|
|
21
|
+
variant(value: 'default' | 'success' | 'warning' | 'error' | 'info'): this;
|
|
22
|
+
pill(value: boolean): this;
|
|
23
|
+
render(targetId?: string): this;
|
|
24
|
+
}
|
|
25
|
+
export declare function badge(id: string, options?: BadgeOptions): Badge;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IAC/D,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,UAAU,GAAG;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAAU,CAAC;gBACpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;IAUlD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAUhD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI;IAK1E,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAS1B,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CA8BlC;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,KAAK,CAEnE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
// Event definitions
|
|
3
|
+
const TRIGGER_EVENTS = [];
|
|
4
|
+
const CALLBACK_EVENTS = [];
|
|
5
|
+
export class Badge extends BaseComponent {
|
|
6
|
+
constructor(id, options = {}) {
|
|
7
|
+
super(id, {
|
|
8
|
+
label: options.label ?? '',
|
|
9
|
+
variant: options.variant ?? 'default',
|
|
10
|
+
pill: options.pill ?? false,
|
|
11
|
+
style: options.style ?? '',
|
|
12
|
+
class: options.class ?? ''
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
getTriggerEvents() {
|
|
16
|
+
return TRIGGER_EVENTS;
|
|
17
|
+
}
|
|
18
|
+
getCallbackEvents() {
|
|
19
|
+
return CALLBACK_EVENTS;
|
|
20
|
+
}
|
|
21
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
22
|
+
* FLUENT API
|
|
23
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
24
|
+
// ✅ Inherited from BaseComponent
|
|
25
|
+
label(value) {
|
|
26
|
+
this.state.label = value;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
variant(value) {
|
|
30
|
+
this.state.variant = value;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
pill(value) {
|
|
34
|
+
this.state.pill = value;
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
38
|
+
* RENDER
|
|
39
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
40
|
+
render(targetId) {
|
|
41
|
+
const container = this._setupContainer(targetId);
|
|
42
|
+
const { label, variant, pill, style, class: className } = this.state;
|
|
43
|
+
const badge = document.createElement('span');
|
|
44
|
+
badge.className = `jux-badge jux-badge-${variant}`;
|
|
45
|
+
if (pill)
|
|
46
|
+
badge.classList.add('jux-badge-pill');
|
|
47
|
+
badge.id = this._id;
|
|
48
|
+
if (className)
|
|
49
|
+
badge.className += ` ${className}`;
|
|
50
|
+
if (style)
|
|
51
|
+
badge.setAttribute('style', style);
|
|
52
|
+
badge.textContent = label;
|
|
53
|
+
this._wireStandardEvents(badge);
|
|
54
|
+
// Wire sync for label
|
|
55
|
+
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
56
|
+
if (property === 'label') {
|
|
57
|
+
const transform = toComponent || ((v) => String(v));
|
|
58
|
+
stateObj.subscribe((val) => {
|
|
59
|
+
badge.textContent = transform(val);
|
|
60
|
+
this.state.label = transform(val);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
container.appendChild(badge);
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function badge(id, options = {}) {
|
|
69
|
+
return new Badge(id, options);
|
|
70
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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 BadgeOptions {
|
|
8
|
+
label?: string;
|
|
9
|
+
variant?: 'default' | 'success' | 'warning' | 'error' | 'info';
|
|
10
|
+
pill?: boolean;
|
|
11
|
+
style?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type BadgeState = {
|
|
16
|
+
label: string;
|
|
17
|
+
variant: string;
|
|
18
|
+
pill: boolean;
|
|
19
|
+
style: string;
|
|
20
|
+
class: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export class Badge extends BaseComponent<BadgeState> {
|
|
24
|
+
constructor(id: string, options: BadgeOptions = {}) {
|
|
25
|
+
super(id, {
|
|
26
|
+
label: options.label ?? '',
|
|
27
|
+
variant: options.variant ?? 'default',
|
|
28
|
+
pill: options.pill ?? false,
|
|
29
|
+
style: options.style ?? '',
|
|
30
|
+
class: options.class ?? ''
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected getTriggerEvents(): readonly string[] {
|
|
35
|
+
return TRIGGER_EVENTS;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected getCallbackEvents(): readonly string[] {
|
|
39
|
+
return CALLBACK_EVENTS;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
43
|
+
* FLUENT API
|
|
44
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
45
|
+
|
|
46
|
+
// ✅ Inherited from BaseComponent
|
|
47
|
+
|
|
48
|
+
label(value: string): this {
|
|
49
|
+
this.state.label = value;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
variant(value: 'default' | 'success' | 'warning' | 'error' | 'info'): this {
|
|
54
|
+
this.state.variant = value;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pill(value: boolean): this {
|
|
59
|
+
this.state.pill = value;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
64
|
+
* RENDER
|
|
65
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
66
|
+
|
|
67
|
+
render(targetId?: string): this {
|
|
68
|
+
const container = this._setupContainer(targetId);
|
|
69
|
+
|
|
70
|
+
const { label, variant, pill, style, class: className } = this.state;
|
|
71
|
+
|
|
72
|
+
const badge = document.createElement('span');
|
|
73
|
+
badge.className = `jux-badge jux-badge-${variant}`;
|
|
74
|
+
if (pill) badge.classList.add('jux-badge-pill');
|
|
75
|
+
badge.id = this._id;
|
|
76
|
+
if (className) badge.className += ` ${className}`;
|
|
77
|
+
if (style) badge.setAttribute('style', style);
|
|
78
|
+
badge.textContent = label;
|
|
79
|
+
|
|
80
|
+
this._wireStandardEvents(badge);
|
|
81
|
+
|
|
82
|
+
// Wire sync for label
|
|
83
|
+
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
84
|
+
if (property === 'label') {
|
|
85
|
+
const transform = toComponent || ((v: any) => String(v));
|
|
86
|
+
stateObj.subscribe((val: any) => {
|
|
87
|
+
badge.textContent = transform(val);
|
|
88
|
+
this.state.label = transform(val);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
container.appendChild(badge);
|
|
94
|
+
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function badge(id: string, options: BadgeOptions = {}): Badge {
|
|
100
|
+
return new Badge(id, options);
|
|
101
|
+
}
|