juxscript 1.1.18 → 1.1.19
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/lib/components/base/BaseComponent.d.ts +5 -21
- package/lib/components/base/BaseComponent.d.ts.map +1 -1
- package/lib/components/base/BaseComponent.js +38 -0
- package/lib/components/base/BaseComponent.ts +40 -21
- package/lib/components/hero.d.ts.map +1 -1
- package/lib/components/hero.js +62 -14
- package/lib/components/hero.ts +64 -10
- package/package.json +1 -1
|
@@ -42,28 +42,12 @@ export declare abstract class BaseComponent<TState extends BaseState = BaseState
|
|
|
42
42
|
protected abstract getCallbackEvents(): readonly string[];
|
|
43
43
|
abstract render(targetId?: string): this;
|
|
44
44
|
/**
|
|
45
|
-
* REACTIVE UPDATE HOOK (
|
|
46
|
-
* Called automatically when this.state[prop] changes via
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* This is PUBLIC because:
|
|
50
|
-
* - Components may need to call it manually
|
|
51
|
-
* - Allows external updates without full re-render
|
|
52
|
-
* - Part of the component's public API
|
|
53
|
-
*
|
|
54
|
-
* @param prop - The state property that changed
|
|
55
|
-
* @param value - The new value
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* update(prop: string, value: any): void {
|
|
59
|
-
* const el = document.getElementById(this._id);
|
|
60
|
-
* if (!el) return;
|
|
61
|
-
*
|
|
62
|
-
* if (prop === 'label') el.textContent = value;
|
|
63
|
-
* if (prop === 'visible') el.style.display = value ? '' : 'none';
|
|
64
|
-
* }
|
|
45
|
+
* REACTIVE UPDATE HOOK (PUBLIC, CONCRETE)
|
|
46
|
+
* Called automatically when this.state[prop] changes via Proxy.
|
|
47
|
+
* Default implementation handles base properties.
|
|
48
|
+
* Children can override to add component-specific logic.
|
|
65
49
|
*/
|
|
66
|
-
|
|
50
|
+
update(prop: string, value: any): void;
|
|
67
51
|
/**
|
|
68
52
|
* Set component style
|
|
69
53
|
*/
|
|
@@ -1 +1 @@
|
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AEG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAS7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAQb;;OAEG;IACH,IAAI,IAAI,IAAI;IAYZ;;OAEG;IACH,MAAM,IAAI,IAAI;IAYd,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI;IAW5C;;;;;;OAMG;IACH,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,kBAAkB,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,EAAE,QAAQ,GAAG,IAAI;IAkBzG,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIjD,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIlD,SAAS,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAcnE,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW;IAwBzD,SAAS,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAMzD;;;OAGG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI;IA0B/B,QAAQ,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI;IAWjC;;;;;;OAMG;IACH,IAAI,KAAK,IAAI,QAAQ,CAAC,MAAM,CAAC,CAE5B;CACJ"}
|
|
@@ -40,6 +40,44 @@ export class BaseComponent {
|
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* REACTIVE UPDATE HOOK (PUBLIC, CONCRETE)
|
|
45
|
+
* Called automatically when this.state[prop] changes via Proxy.
|
|
46
|
+
* Default implementation handles base properties.
|
|
47
|
+
* Children can override to add component-specific logic.
|
|
48
|
+
*/
|
|
49
|
+
update(prop, value) {
|
|
50
|
+
if (!this.container)
|
|
51
|
+
return;
|
|
52
|
+
const el = this.container.querySelector(`#${this._id}`);
|
|
53
|
+
if (!el)
|
|
54
|
+
return;
|
|
55
|
+
// Handle base properties
|
|
56
|
+
switch (prop) {
|
|
57
|
+
case 'visible':
|
|
58
|
+
el.style.display = value ? '' : 'none';
|
|
59
|
+
break;
|
|
60
|
+
case 'class':
|
|
61
|
+
const baseClasses = el.className.split(' ').filter(c => c.startsWith('jux-'));
|
|
62
|
+
const userClasses = value.split(' ').filter((c) => c);
|
|
63
|
+
el.className = [...baseClasses, ...userClasses].join(' ');
|
|
64
|
+
break;
|
|
65
|
+
case 'style':
|
|
66
|
+
el.setAttribute('style', value);
|
|
67
|
+
break;
|
|
68
|
+
case 'disabled':
|
|
69
|
+
el.setAttribute('aria-disabled', String(value));
|
|
70
|
+
const inputs = el.querySelectorAll('input, button, select, textarea');
|
|
71
|
+
inputs.forEach(input => {
|
|
72
|
+
input.disabled = value;
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case 'loading':
|
|
76
|
+
el.classList.toggle('jux-loading', value);
|
|
77
|
+
el.setAttribute('aria-busy', String(value));
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
43
81
|
/* ═════════════════════════════════════════════════════════════════
|
|
44
82
|
* COMMON FLUENT API (Inherited by all components)
|
|
45
83
|
* ═════════════════════════════════════════════════════════════════ */
|
|
@@ -78,28 +78,47 @@ export abstract class BaseComponent<TState extends BaseState = BaseState> {
|
|
|
78
78
|
abstract render(targetId?: string): this;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* REACTIVE UPDATE HOOK (
|
|
82
|
-
* Called automatically when this.state[prop] changes via
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* This is PUBLIC because:
|
|
86
|
-
* - Components may need to call it manually
|
|
87
|
-
* - Allows external updates without full re-render
|
|
88
|
-
* - Part of the component's public API
|
|
89
|
-
*
|
|
90
|
-
* @param prop - The state property that changed
|
|
91
|
-
* @param value - The new value
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* update(prop: string, value: any): void {
|
|
95
|
-
* const el = document.getElementById(this._id);
|
|
96
|
-
* if (!el) return;
|
|
97
|
-
*
|
|
98
|
-
* if (prop === 'label') el.textContent = value;
|
|
99
|
-
* if (prop === 'visible') el.style.display = value ? '' : 'none';
|
|
100
|
-
* }
|
|
81
|
+
* REACTIVE UPDATE HOOK (PUBLIC, CONCRETE)
|
|
82
|
+
* Called automatically when this.state[prop] changes via Proxy.
|
|
83
|
+
* Default implementation handles base properties.
|
|
84
|
+
* Children can override to add component-specific logic.
|
|
101
85
|
*/
|
|
102
|
-
|
|
86
|
+
update(prop: string, value: any): void {
|
|
87
|
+
if (!this.container) return;
|
|
88
|
+
|
|
89
|
+
const el = this.container.querySelector(`#${this._id}`) as HTMLElement;
|
|
90
|
+
if (!el) return;
|
|
91
|
+
|
|
92
|
+
// Handle base properties
|
|
93
|
+
switch (prop) {
|
|
94
|
+
case 'visible':
|
|
95
|
+
el.style.display = value ? '' : 'none';
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case 'class':
|
|
99
|
+
const baseClasses = el.className.split(' ').filter(c => c.startsWith('jux-'));
|
|
100
|
+
const userClasses = value.split(' ').filter((c: string) => c);
|
|
101
|
+
el.className = [...baseClasses, ...userClasses].join(' ');
|
|
102
|
+
break;
|
|
103
|
+
|
|
104
|
+
case 'style':
|
|
105
|
+
el.setAttribute('style', value);
|
|
106
|
+
break;
|
|
107
|
+
|
|
108
|
+
case 'disabled':
|
|
109
|
+
el.setAttribute('aria-disabled', String(value));
|
|
110
|
+
const inputs = el.querySelectorAll('input, button, select, textarea');
|
|
111
|
+
inputs.forEach(input => {
|
|
112
|
+
(input as HTMLInputElement).disabled = value;
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case 'loading':
|
|
117
|
+
el.classList.toggle('jux-loading', value);
|
|
118
|
+
el.setAttribute('aria-busy', String(value));
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
103
122
|
|
|
104
123
|
/* ═════════════════════════════════════════════════════════════════
|
|
105
124
|
* COMMON FLUENT API (Inherited by all components)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hero.d.ts","sourceRoot":"","sources":["hero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMnE,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,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3E,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,SAAS,GAAG;IAC3B,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;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,iBAAiB,EAAE,OAAO,CAA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AO,GAAE,WAAgB,GAAG,IAAI,CAEhE"}
|
package/lib/components/hero.js
CHANGED
|
@@ -35,32 +35,80 @@ export class Hero extends BaseComponent {
|
|
|
35
35
|
* Centralizes DOM manipulation so setters don't have to drill/repeat logic.
|
|
36
36
|
*/
|
|
37
37
|
update(prop, value) {
|
|
38
|
+
super.update(prop, value); // Handle base properties
|
|
38
39
|
const hero = document.getElementById(this._id);
|
|
39
40
|
if (!hero)
|
|
40
41
|
return;
|
|
42
|
+
const contentContainer = hero.querySelector('.jux-hero-content');
|
|
43
|
+
if (!contentContainer)
|
|
44
|
+
return;
|
|
41
45
|
switch (prop) {
|
|
42
46
|
case 'title':
|
|
43
|
-
|
|
44
|
-
if (titleEl)
|
|
45
|
-
|
|
47
|
+
let titleEl = document.getElementById(`${this._id}-title`);
|
|
48
|
+
if (!titleEl) {
|
|
49
|
+
// ✅ Create title element if it doesn't exist
|
|
50
|
+
titleEl = document.createElement('h1');
|
|
51
|
+
titleEl.className = 'jux-hero-title';
|
|
52
|
+
titleEl.id = `${this._id}-title`;
|
|
53
|
+
contentContainer.insertBefore(titleEl, contentContainer.firstChild);
|
|
54
|
+
}
|
|
55
|
+
titleEl.textContent = value;
|
|
46
56
|
break;
|
|
47
57
|
case 'subtitle':
|
|
48
|
-
|
|
49
|
-
if (subtitleEl)
|
|
50
|
-
|
|
58
|
+
let subtitleEl = document.getElementById(`${this._id}-subtitle`);
|
|
59
|
+
if (!subtitleEl) {
|
|
60
|
+
// ✅ Create subtitle element if it doesn't exist
|
|
61
|
+
subtitleEl = document.createElement('p');
|
|
62
|
+
subtitleEl.className = 'jux-hero-subtitle';
|
|
63
|
+
subtitleEl.id = `${this._id}-subtitle`;
|
|
64
|
+
// Insert after title if exists, otherwise at start
|
|
65
|
+
const titleEl = document.getElementById(`${this._id}-title`);
|
|
66
|
+
if (titleEl) {
|
|
67
|
+
titleEl.after(subtitleEl);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
contentContainer.insertBefore(subtitleEl, contentContainer.firstChild);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
subtitleEl.textContent = value;
|
|
51
74
|
break;
|
|
52
75
|
case 'content':
|
|
53
|
-
|
|
54
|
-
if (contentEl)
|
|
55
|
-
|
|
76
|
+
let contentEl = hero.querySelector('.jux-hero-body');
|
|
77
|
+
if (!contentEl) {
|
|
78
|
+
// ✅ Create content element if it doesn't exist
|
|
79
|
+
contentEl = document.createElement('div');
|
|
80
|
+
contentEl.className = 'jux-hero-body';
|
|
81
|
+
// Insert after subtitle if exists, otherwise after title, otherwise at start
|
|
82
|
+
const subtitleEl = document.getElementById(`${this._id}-subtitle`);
|
|
83
|
+
const titleEl = document.getElementById(`${this._id}-title`);
|
|
84
|
+
if (subtitleEl) {
|
|
85
|
+
subtitleEl.after(contentEl);
|
|
86
|
+
}
|
|
87
|
+
else if (titleEl) {
|
|
88
|
+
titleEl.after(contentEl);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
contentContainer.insertBefore(contentEl, contentContainer.firstChild);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
contentEl.innerHTML = value;
|
|
56
95
|
break;
|
|
57
96
|
case 'cta':
|
|
58
|
-
|
|
59
|
-
if (ctaEl)
|
|
60
|
-
|
|
97
|
+
let ctaEl = hero.querySelector('.jux-hero-cta');
|
|
98
|
+
if (!ctaEl) {
|
|
99
|
+
// ✅ Create CTA element if it doesn't exist
|
|
100
|
+
ctaEl = document.createElement('a');
|
|
101
|
+
ctaEl.className = 'jux-hero-cta';
|
|
102
|
+
ctaEl.href = this.state.ctaLink;
|
|
103
|
+
ctaEl.addEventListener('click', (e) => {
|
|
104
|
+
this._triggerCallback('ctaClick', e);
|
|
105
|
+
});
|
|
106
|
+
contentContainer.appendChild(ctaEl);
|
|
107
|
+
}
|
|
108
|
+
ctaEl.textContent = value;
|
|
61
109
|
break;
|
|
62
110
|
case 'ctaLink':
|
|
63
|
-
const ctaLinkEl = hero.querySelector('.jux-hero-cta');
|
|
111
|
+
const ctaLinkEl = hero.querySelector('.jux-hero-cta');
|
|
64
112
|
if (ctaLinkEl)
|
|
65
113
|
ctaLinkEl.href = value;
|
|
66
114
|
break;
|
|
@@ -70,7 +118,7 @@ export class Hero extends BaseComponent {
|
|
|
70
118
|
hero.style.backgroundRepeat = value.repeat;
|
|
71
119
|
break;
|
|
72
120
|
case 'centered':
|
|
73
|
-
hero.classList.toggle('jux-hero-centered', value);
|
|
121
|
+
hero.classList.toggle('jux-hero-centered', value);
|
|
74
122
|
break;
|
|
75
123
|
}
|
|
76
124
|
}
|
package/lib/components/hero.ts
CHANGED
|
@@ -68,32 +68,86 @@ export class Hero extends BaseComponent<HeroState> {
|
|
|
68
68
|
* Centralizes DOM manipulation so setters don't have to drill/repeat logic.
|
|
69
69
|
*/
|
|
70
70
|
update(prop: string, value: any): void {
|
|
71
|
+
super.update(prop, value); // Handle base properties
|
|
72
|
+
|
|
71
73
|
const hero = document.getElementById(this._id);
|
|
72
74
|
if (!hero) return;
|
|
73
75
|
|
|
76
|
+
const contentContainer = hero.querySelector('.jux-hero-content');
|
|
77
|
+
if (!contentContainer) return;
|
|
78
|
+
|
|
74
79
|
switch (prop) {
|
|
75
80
|
case 'title':
|
|
76
|
-
|
|
77
|
-
if (titleEl)
|
|
81
|
+
let titleEl = document.getElementById(`${this._id}-title`);
|
|
82
|
+
if (!titleEl) {
|
|
83
|
+
// ✅ Create title element if it doesn't exist
|
|
84
|
+
titleEl = document.createElement('h1');
|
|
85
|
+
titleEl.className = 'jux-hero-title';
|
|
86
|
+
titleEl.id = `${this._id}-title`;
|
|
87
|
+
contentContainer.insertBefore(titleEl, contentContainer.firstChild);
|
|
88
|
+
}
|
|
89
|
+
titleEl.textContent = value;
|
|
78
90
|
break;
|
|
79
91
|
|
|
80
92
|
case 'subtitle':
|
|
81
|
-
|
|
82
|
-
if (subtitleEl)
|
|
93
|
+
let subtitleEl = document.getElementById(`${this._id}-subtitle`);
|
|
94
|
+
if (!subtitleEl) {
|
|
95
|
+
// ✅ Create subtitle element if it doesn't exist
|
|
96
|
+
subtitleEl = document.createElement('p');
|
|
97
|
+
subtitleEl.className = 'jux-hero-subtitle';
|
|
98
|
+
subtitleEl.id = `${this._id}-subtitle`;
|
|
99
|
+
|
|
100
|
+
// Insert after title if exists, otherwise at start
|
|
101
|
+
const titleEl = document.getElementById(`${this._id}-title`);
|
|
102
|
+
if (titleEl) {
|
|
103
|
+
titleEl.after(subtitleEl);
|
|
104
|
+
} else {
|
|
105
|
+
contentContainer.insertBefore(subtitleEl, contentContainer.firstChild);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
subtitleEl.textContent = value;
|
|
83
109
|
break;
|
|
84
110
|
|
|
85
111
|
case 'content':
|
|
86
|
-
|
|
87
|
-
if (contentEl)
|
|
112
|
+
let contentEl = hero.querySelector('.jux-hero-body');
|
|
113
|
+
if (!contentEl) {
|
|
114
|
+
// ✅ Create content element if it doesn't exist
|
|
115
|
+
contentEl = document.createElement('div');
|
|
116
|
+
contentEl.className = 'jux-hero-body';
|
|
117
|
+
|
|
118
|
+
// Insert after subtitle if exists, otherwise after title, otherwise at start
|
|
119
|
+
const subtitleEl = document.getElementById(`${this._id}-subtitle`);
|
|
120
|
+
const titleEl = document.getElementById(`${this._id}-title`);
|
|
121
|
+
if (subtitleEl) {
|
|
122
|
+
subtitleEl.after(contentEl);
|
|
123
|
+
} else if (titleEl) {
|
|
124
|
+
titleEl.after(contentEl);
|
|
125
|
+
} else {
|
|
126
|
+
contentContainer.insertBefore(contentEl, contentContainer.firstChild);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
contentEl.innerHTML = value;
|
|
88
130
|
break;
|
|
89
131
|
|
|
90
132
|
case 'cta':
|
|
91
|
-
|
|
92
|
-
if (ctaEl)
|
|
133
|
+
let ctaEl = hero.querySelector('.jux-hero-cta') as HTMLAnchorElement;
|
|
134
|
+
if (!ctaEl) {
|
|
135
|
+
// ✅ Create CTA element if it doesn't exist
|
|
136
|
+
ctaEl = document.createElement('a');
|
|
137
|
+
ctaEl.className = 'jux-hero-cta';
|
|
138
|
+
ctaEl.href = this.state.ctaLink;
|
|
139
|
+
|
|
140
|
+
ctaEl.addEventListener('click', (e) => {
|
|
141
|
+
this._triggerCallback('ctaClick', e);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
contentContainer.appendChild(ctaEl);
|
|
145
|
+
}
|
|
146
|
+
ctaEl.textContent = value;
|
|
93
147
|
break;
|
|
94
148
|
|
|
95
149
|
case 'ctaLink':
|
|
96
|
-
const ctaLinkEl = hero.querySelector('.jux-hero-cta') as HTMLAnchorElement;
|
|
150
|
+
const ctaLinkEl = hero.querySelector('.jux-hero-cta') as HTMLAnchorElement;
|
|
97
151
|
if (ctaLinkEl) ctaLinkEl.href = value;
|
|
98
152
|
break;
|
|
99
153
|
|
|
@@ -104,7 +158,7 @@ export class Hero extends BaseComponent<HeroState> {
|
|
|
104
158
|
break;
|
|
105
159
|
|
|
106
160
|
case 'centered':
|
|
107
|
-
hero.classList.toggle('jux-hero-centered', value);
|
|
161
|
+
hero.classList.toggle('jux-hero-centered', value);
|
|
108
162
|
break;
|
|
109
163
|
}
|
|
110
164
|
}
|