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 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,WAAW,CAgC5D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component helper utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get or create a container element for a component
|
|
6
|
+
* Auto-creates if it doesn't exist and appends to appropriate parent
|
|
7
|
+
*/
|
|
8
|
+
export function getOrCreateContainer(id) {
|
|
9
|
+
if (typeof document === 'undefined') {
|
|
10
|
+
throw new Error('Document is not available');
|
|
11
|
+
}
|
|
12
|
+
let container = document.getElementById(id);
|
|
13
|
+
// Container already exists, return it
|
|
14
|
+
if (container) {
|
|
15
|
+
return container;
|
|
16
|
+
}
|
|
17
|
+
// Auto-create container if it doesn't exist
|
|
18
|
+
container = document.createElement('div');
|
|
19
|
+
container.id = id;
|
|
20
|
+
// Find appropriate parent - [data-jux-page] takes precedence, then #app, then body
|
|
21
|
+
const dataJuxPage = document.querySelector('[data-jux-page]');
|
|
22
|
+
const app = document.getElementById('app');
|
|
23
|
+
const parent = (dataJuxPage || app || document.body);
|
|
24
|
+
// Log warning if falling back to body
|
|
25
|
+
if (!dataJuxPage && !app) {
|
|
26
|
+
console.warn(`[Jux] Preferred container targets "[data-jux-page]" or "#app" not found. Creating container "#${id}" in fallback parent: body`);
|
|
27
|
+
}
|
|
28
|
+
parent.appendChild(container);
|
|
29
|
+
return container;
|
|
30
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component helper utilities
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get or create a container element for a component
|
|
7
|
+
* Auto-creates if it doesn't exist and appends to appropriate parent
|
|
8
|
+
*/
|
|
9
|
+
export function getOrCreateContainer(id: string): HTMLElement {
|
|
10
|
+
if (typeof document === 'undefined') {
|
|
11
|
+
throw new Error('Document is not available');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let container = document.getElementById(id);
|
|
15
|
+
|
|
16
|
+
// Container already exists, return it
|
|
17
|
+
if (container) {
|
|
18
|
+
return container;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Auto-create container if it doesn't exist
|
|
22
|
+
container = document.createElement('div');
|
|
23
|
+
container.id = id;
|
|
24
|
+
|
|
25
|
+
// Find appropriate parent - [data-jux-page] takes precedence, then #app, then body
|
|
26
|
+
const dataJuxPage = document.querySelector('[data-jux-page]') as HTMLElement;
|
|
27
|
+
const app = document.getElementById('app');
|
|
28
|
+
|
|
29
|
+
const parent: HTMLElement = (dataJuxPage || app || document.body) as HTMLElement;
|
|
30
|
+
|
|
31
|
+
// Log warning if falling back to body
|
|
32
|
+
if (!dataJuxPage && !app) {
|
|
33
|
+
console.warn(
|
|
34
|
+
`[Jux] Preferred container targets "[data-jux-page]" or "#app" not found. Creating container "#${id}" in fallback parent: body`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
parent.appendChild(container);
|
|
39
|
+
|
|
40
|
+
return container;
|
|
41
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
export interface HeroOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
content?: string;
|
|
6
|
+
cta?: string;
|
|
7
|
+
ctaLink?: string;
|
|
8
|
+
backgroundImage?: string;
|
|
9
|
+
backgroundOverlay?: boolean;
|
|
10
|
+
variant?: 'default' | 'centered' | 'split';
|
|
11
|
+
centered?: boolean;
|
|
12
|
+
style?: string;
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
15
|
+
type HeroState = {
|
|
16
|
+
title: string;
|
|
17
|
+
subtitle: string;
|
|
18
|
+
content: string;
|
|
19
|
+
cta: string;
|
|
20
|
+
ctaLink: string;
|
|
21
|
+
backgroundImage: string;
|
|
22
|
+
backgroundOverlay: boolean;
|
|
23
|
+
variant: string;
|
|
24
|
+
centered: boolean;
|
|
25
|
+
style: string;
|
|
26
|
+
class: string;
|
|
27
|
+
};
|
|
28
|
+
export declare class Hero extends BaseComponent<HeroState> {
|
|
29
|
+
constructor(id: string, options?: HeroOptions);
|
|
30
|
+
protected getTriggerEvents(): readonly string[];
|
|
31
|
+
protected getCallbackEvents(): readonly string[];
|
|
32
|
+
title(value: string): this;
|
|
33
|
+
subtitle(value: string): this;
|
|
34
|
+
content(value: string): this;
|
|
35
|
+
cta(value: string): this;
|
|
36
|
+
ctaLink(value: string): this;
|
|
37
|
+
backgroundImage(value: string): this;
|
|
38
|
+
backgroundOverlay(value: boolean): this;
|
|
39
|
+
variant(value: string): this;
|
|
40
|
+
centered(value: boolean): this;
|
|
41
|
+
render(targetId?: string): this;
|
|
42
|
+
}
|
|
43
|
+
export declare function hero(id: string, options?: HeroOptions): Hero;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=hero.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hero.d.ts","sourceRoot":"","sources":["hero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,OAAO,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,CAAC;IAC3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,SAAS,GAAG;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;gBACpC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAgBjD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKxB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKpC,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKvC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAS9B,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CA2GhC;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
// Event definitions - Hero is display-only, but CTA button can trigger actions
|
|
3
|
+
const TRIGGER_EVENTS = [];
|
|
4
|
+
const CALLBACK_EVENTS = ['ctaClick']; // ✅ When CTA button is clicked
|
|
5
|
+
export class Hero extends BaseComponent {
|
|
6
|
+
constructor(id, options = {}) {
|
|
7
|
+
super(id, {
|
|
8
|
+
title: options.title ?? '',
|
|
9
|
+
subtitle: options.subtitle ?? '',
|
|
10
|
+
content: options.content ?? '', // ✅ ADD
|
|
11
|
+
cta: options.cta ?? '',
|
|
12
|
+
ctaLink: options.ctaLink ?? '#',
|
|
13
|
+
backgroundImage: options.backgroundImage ?? '',
|
|
14
|
+
backgroundOverlay: options.backgroundOverlay ?? false, // ✅ ADD
|
|
15
|
+
variant: options.variant ?? 'default',
|
|
16
|
+
centered: options.centered ?? false, // ✅ ADD
|
|
17
|
+
style: options.style ?? '',
|
|
18
|
+
class: options.class ?? ''
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getTriggerEvents() {
|
|
22
|
+
return TRIGGER_EVENTS;
|
|
23
|
+
}
|
|
24
|
+
getCallbackEvents() {
|
|
25
|
+
return CALLBACK_EVENTS;
|
|
26
|
+
}
|
|
27
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
28
|
+
* FLUENT API
|
|
29
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
30
|
+
title(value) {
|
|
31
|
+
this.state.title = value;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
subtitle(value) {
|
|
35
|
+
this.state.subtitle = value;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
content(value) {
|
|
39
|
+
this.state.content = value;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
cta(value) {
|
|
43
|
+
this.state.cta = value;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
ctaLink(value) {
|
|
47
|
+
this.state.ctaLink = value;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
backgroundImage(value) {
|
|
51
|
+
this.state.backgroundImage = value;
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
backgroundOverlay(value) {
|
|
55
|
+
this.state.backgroundOverlay = value;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
variant(value) {
|
|
59
|
+
this.state.variant = value;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
centered(value) {
|
|
63
|
+
this.state.centered = value;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
67
|
+
* RENDER
|
|
68
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
69
|
+
render(targetId) {
|
|
70
|
+
const container = this._setupContainer(targetId);
|
|
71
|
+
const { title, subtitle, content, backgroundImage, backgroundOverlay, centered, style, class: className } = this.state;
|
|
72
|
+
const hero = document.createElement('section');
|
|
73
|
+
hero.className = 'jux-hero';
|
|
74
|
+
hero.id = this._id;
|
|
75
|
+
if (centered)
|
|
76
|
+
hero.classList.add('jux-hero-centered');
|
|
77
|
+
if (className)
|
|
78
|
+
hero.className += ` ${className}`;
|
|
79
|
+
if (style)
|
|
80
|
+
hero.setAttribute('style', style);
|
|
81
|
+
if (backgroundImage) {
|
|
82
|
+
hero.style.backgroundImage = `url(${backgroundImage})`;
|
|
83
|
+
if (backgroundOverlay) {
|
|
84
|
+
const overlay = document.createElement('div');
|
|
85
|
+
overlay.className = 'jux-hero-overlay';
|
|
86
|
+
hero.appendChild(overlay);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const contentContainer = document.createElement('div');
|
|
90
|
+
contentContainer.className = 'jux-hero-content';
|
|
91
|
+
if (title) {
|
|
92
|
+
const titleEl = document.createElement('h1');
|
|
93
|
+
titleEl.className = 'jux-hero-title';
|
|
94
|
+
titleEl.id = `${this._id}-title`;
|
|
95
|
+
titleEl.textContent = title;
|
|
96
|
+
contentContainer.appendChild(titleEl);
|
|
97
|
+
}
|
|
98
|
+
if (subtitle) {
|
|
99
|
+
const subtitleEl = document.createElement('p');
|
|
100
|
+
subtitleEl.className = 'jux-hero-subtitle';
|
|
101
|
+
subtitleEl.id = `${this._id}-subtitle`;
|
|
102
|
+
subtitleEl.textContent = subtitle;
|
|
103
|
+
contentContainer.appendChild(subtitleEl);
|
|
104
|
+
}
|
|
105
|
+
if (content) {
|
|
106
|
+
const contentEl = document.createElement('div');
|
|
107
|
+
contentEl.className = 'jux-hero-body';
|
|
108
|
+
contentEl.innerHTML = content;
|
|
109
|
+
contentContainer.appendChild(contentEl);
|
|
110
|
+
}
|
|
111
|
+
if (this.state.cta) {
|
|
112
|
+
const ctaButton = document.createElement('a');
|
|
113
|
+
ctaButton.className = 'jux-hero-cta';
|
|
114
|
+
ctaButton.href = this.state.ctaLink;
|
|
115
|
+
ctaButton.textContent = this.state.cta;
|
|
116
|
+
// ✅ Fire callback when CTA is clicked
|
|
117
|
+
ctaButton.addEventListener('click', (e) => {
|
|
118
|
+
this._triggerCallback('ctaClick', e);
|
|
119
|
+
});
|
|
120
|
+
contentContainer.appendChild(ctaButton);
|
|
121
|
+
}
|
|
122
|
+
hero.appendChild(contentContainer);
|
|
123
|
+
this._wireStandardEvents(hero);
|
|
124
|
+
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
125
|
+
if (property === 'title') {
|
|
126
|
+
const transform = toComponent || ((v) => String(v));
|
|
127
|
+
stateObj.subscribe((val) => {
|
|
128
|
+
const transformed = transform(val);
|
|
129
|
+
const titleEl = document.getElementById(`${this._id}-title`);
|
|
130
|
+
if (titleEl) {
|
|
131
|
+
titleEl.textContent = transformed;
|
|
132
|
+
}
|
|
133
|
+
this.state.title = transformed;
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
else if (property === 'subtitle') {
|
|
137
|
+
const transform = toComponent || ((v) => String(v));
|
|
138
|
+
stateObj.subscribe((val) => {
|
|
139
|
+
const transformed = transform(val);
|
|
140
|
+
const subtitleEl = document.getElementById(`${this._id}-subtitle`);
|
|
141
|
+
if (subtitleEl) {
|
|
142
|
+
subtitleEl.textContent = transformed;
|
|
143
|
+
}
|
|
144
|
+
this.state.subtitle = transformed;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else if (property === 'content') {
|
|
148
|
+
const transform = toComponent || ((v) => String(v));
|
|
149
|
+
stateObj.subscribe((val) => {
|
|
150
|
+
const transformed = transform(val);
|
|
151
|
+
const contentEl = hero.querySelector('.jux-hero-body');
|
|
152
|
+
if (contentEl) {
|
|
153
|
+
contentEl.innerHTML = transformed;
|
|
154
|
+
}
|
|
155
|
+
this.state.content = transformed;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
container.appendChild(hero);
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export function hero(id, options = {}) {
|
|
164
|
+
return new Hero(id, options);
|
|
165
|
+
}
|
|
@@ -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,35 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
export interface IconOptions {
|
|
3
|
+
value?: string;
|
|
4
|
+
size?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
useEmoji?: boolean;
|
|
7
|
+
iconCollection?: string;
|
|
8
|
+
style?: string;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
type IconState = {
|
|
12
|
+
value: string;
|
|
13
|
+
size: string;
|
|
14
|
+
color: string;
|
|
15
|
+
useEmoji: boolean;
|
|
16
|
+
iconCollection: string;
|
|
17
|
+
style: string;
|
|
18
|
+
class: string;
|
|
19
|
+
};
|
|
20
|
+
export declare class Icon extends BaseComponent<IconState> {
|
|
21
|
+
constructor(id: string, options?: IconOptions);
|
|
22
|
+
protected getTriggerEvents(): readonly string[];
|
|
23
|
+
protected getCallbackEvents(): readonly string[];
|
|
24
|
+
value(value: string): this;
|
|
25
|
+
size(value: string): this;
|
|
26
|
+
color(value: string): this;
|
|
27
|
+
useEmoji(value: boolean): this;
|
|
28
|
+
iconCollection(value: string): this;
|
|
29
|
+
style(value: string): this;
|
|
30
|
+
class(value: string): this;
|
|
31
|
+
render(targetId?: string): this;
|
|
32
|
+
}
|
|
33
|
+
export declare function icon(id: string, options: IconOptions): Icon;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOxD,MAAM,WAAW,WAAW;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,SAAS,GAAG;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,IAAK,SAAQ,aAAa,CAAC,SAAS,CAAC;gBAClC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB;IAYjD,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,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKzB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKnC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK1B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAS1B,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;CAgFlC;AAED,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAE3D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
import { renderIcon, renderEmoji } from './icons.js';
|
|
3
|
+
// Event definitions
|
|
4
|
+
const TRIGGER_EVENTS = [];
|
|
5
|
+
const CALLBACK_EVENTS = [];
|
|
6
|
+
export class Icon extends BaseComponent {
|
|
7
|
+
constructor(id, options = {}) {
|
|
8
|
+
super(id, {
|
|
9
|
+
value: options.value ?? '',
|
|
10
|
+
size: options.size ?? '24px',
|
|
11
|
+
color: options.color ?? '',
|
|
12
|
+
useEmoji: options.useEmoji ?? false,
|
|
13
|
+
iconCollection: options.iconCollection ?? '',
|
|
14
|
+
style: options.style ?? '',
|
|
15
|
+
class: options.class ?? ''
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
getTriggerEvents() {
|
|
19
|
+
return TRIGGER_EVENTS;
|
|
20
|
+
}
|
|
21
|
+
getCallbackEvents() {
|
|
22
|
+
return CALLBACK_EVENTS;
|
|
23
|
+
}
|
|
24
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
25
|
+
* FLUENT API
|
|
26
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
27
|
+
// ✅ Inherited from BaseComponent
|
|
28
|
+
value(value) {
|
|
29
|
+
this.state.value = value;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
size(value) {
|
|
33
|
+
this.state.size = value;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
color(value) {
|
|
37
|
+
this.state.color = value;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
useEmoji(value) {
|
|
41
|
+
this.state.useEmoji = value;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
iconCollection(value) {
|
|
45
|
+
this.state.iconCollection = value;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
style(value) {
|
|
49
|
+
this.state.style = value;
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
class(value) {
|
|
53
|
+
this.state.class = value;
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
57
|
+
* RENDER
|
|
58
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
59
|
+
render(targetId) {
|
|
60
|
+
const container = this._setupContainer(targetId);
|
|
61
|
+
const { value, size, color, useEmoji, iconCollection, style, class: className } = this.state;
|
|
62
|
+
const wrapper = document.createElement('span');
|
|
63
|
+
wrapper.className = 'jux-icon';
|
|
64
|
+
wrapper.id = this._id;
|
|
65
|
+
if (className)
|
|
66
|
+
wrapper.className += ` ${className}`;
|
|
67
|
+
if (style)
|
|
68
|
+
wrapper.setAttribute('style', style);
|
|
69
|
+
const iconElement = useEmoji ? renderEmoji(value) : renderIcon(value, iconCollection);
|
|
70
|
+
iconElement.style.width = size;
|
|
71
|
+
iconElement.style.height = size;
|
|
72
|
+
if (color)
|
|
73
|
+
iconElement.style.color = color;
|
|
74
|
+
wrapper.appendChild(iconElement);
|
|
75
|
+
this._wireStandardEvents(wrapper);
|
|
76
|
+
// Wire sync bindings
|
|
77
|
+
this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
|
|
78
|
+
if (property === 'value') {
|
|
79
|
+
const transform = toComponent || ((v) => String(v));
|
|
80
|
+
stateObj.subscribe((val) => {
|
|
81
|
+
const transformed = transform(val);
|
|
82
|
+
this.state.value = transformed;
|
|
83
|
+
wrapper.innerHTML = '';
|
|
84
|
+
const newIcon = this.state.useEmoji ? renderEmoji(transformed) : renderIcon(transformed, this.state.iconCollection);
|
|
85
|
+
newIcon.style.width = this.state.size;
|
|
86
|
+
newIcon.style.height = this.state.size;
|
|
87
|
+
if (this.state.color)
|
|
88
|
+
newIcon.style.color = this.state.color;
|
|
89
|
+
wrapper.appendChild(newIcon);
|
|
90
|
+
requestAnimationFrame(() => {
|
|
91
|
+
if (window.Iconify) {
|
|
92
|
+
window.Iconify.scan();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else if (property === 'size') {
|
|
98
|
+
const transform = toComponent || ((v) => String(v));
|
|
99
|
+
stateObj.subscribe((val) => {
|
|
100
|
+
const transformed = transform(val);
|
|
101
|
+
const icon = wrapper.querySelector('img, svg, span');
|
|
102
|
+
if (icon instanceof HTMLElement) {
|
|
103
|
+
icon.style.width = transformed;
|
|
104
|
+
icon.style.height = transformed;
|
|
105
|
+
}
|
|
106
|
+
this.state.size = transformed;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
else if (property === 'color') {
|
|
110
|
+
const transform = toComponent || ((v) => String(v));
|
|
111
|
+
stateObj.subscribe((val) => {
|
|
112
|
+
const transformed = transform(val);
|
|
113
|
+
const icon = wrapper.querySelector('img, svg, span');
|
|
114
|
+
if (icon instanceof HTMLElement) {
|
|
115
|
+
icon.style.color = transformed;
|
|
116
|
+
}
|
|
117
|
+
this.state.color = transformed;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
container.appendChild(wrapper);
|
|
122
|
+
requestAnimationFrame(() => {
|
|
123
|
+
if (window.lucide) {
|
|
124
|
+
window.lucide.createIcons();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function icon(id, options) {
|
|
131
|
+
return new Icon(id, options);
|
|
132
|
+
}
|