juxscript 1.0.112 → 1.0.113
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BaseEngine, BaseState } from '../base/BaseEngine.js';
|
|
2
2
|
import { OptionsContractSchema } from '../base/OptionsContract.js';
|
|
3
3
|
export interface ElementState extends BaseState {
|
|
4
|
-
|
|
4
|
+
tag: string;
|
|
5
5
|
content: string | null;
|
|
6
6
|
contentType: 'text' | 'html';
|
|
7
7
|
inlineStyle: string;
|
|
8
8
|
}
|
|
9
9
|
export interface ElementOptions {
|
|
10
|
-
|
|
10
|
+
tag?: string;
|
|
11
11
|
content?: string;
|
|
12
12
|
contentType?: 'text' | 'html';
|
|
13
13
|
inlineStyle?: string;
|
|
@@ -22,9 +22,9 @@ export declare class ElementEngine extends BaseEngine<ElementState, ElementOptio
|
|
|
22
22
|
protected prepareState(id: string, options: ElementOptions): ElementState;
|
|
23
23
|
/**
|
|
24
24
|
* Set the HTML tag name (e.g., 'div', 'span', 'h1', 'section')
|
|
25
|
-
* Method name matches state property:
|
|
25
|
+
* Method name matches state property: tag
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
tag(value: string): this;
|
|
28
28
|
/**
|
|
29
29
|
* Set content with explicit type
|
|
30
30
|
* Method name matches state property: content
|
|
@@ -40,10 +40,6 @@ export declare class ElementEngine extends BaseEngine<ElementState, ElementOptio
|
|
|
40
40
|
* Method name matches state property: inlineStyle
|
|
41
41
|
*/
|
|
42
42
|
inlineStyle(cssText: string): this;
|
|
43
|
-
/** @alias for tagName() */
|
|
44
|
-
tag(value: string): this;
|
|
45
|
-
/** @alias for content(value, 'text') */
|
|
46
|
-
text(value: string): this;
|
|
47
43
|
/** @alias for content(value, 'html') */
|
|
48
44
|
html(value: string): this;
|
|
49
45
|
/** @alias for inlineStyle() */
|
|
@@ -9,7 +9,7 @@ export class ElementEngine extends BaseEngine {
|
|
|
9
9
|
*/
|
|
10
10
|
get optionsSchema() {
|
|
11
11
|
return {
|
|
12
|
-
|
|
12
|
+
tag: {
|
|
13
13
|
type: 'string',
|
|
14
14
|
default: 'div',
|
|
15
15
|
description: 'HTML tag name (e.g., "div", "span", "h1")',
|
|
@@ -43,7 +43,7 @@ export class ElementEngine extends BaseEngine {
|
|
|
43
43
|
disabled: false,
|
|
44
44
|
loading: false,
|
|
45
45
|
attributes: {},
|
|
46
|
-
|
|
46
|
+
tag: options.tag || 'div',
|
|
47
47
|
content: options.content || '',
|
|
48
48
|
contentType: options.contentType || 'text',
|
|
49
49
|
inlineStyle: options.inlineStyle || ''
|
|
@@ -51,11 +51,11 @@ export class ElementEngine extends BaseEngine {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Set the HTML tag name (e.g., 'div', 'span', 'h1', 'section')
|
|
54
|
-
* Method name matches state property:
|
|
54
|
+
* Method name matches state property: tag
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
this.updateState({
|
|
58
|
-
this.emit('config', {
|
|
56
|
+
tag(value) {
|
|
57
|
+
this.updateState({ tag: value });
|
|
58
|
+
this.emit('config', { tag: value });
|
|
59
59
|
return this;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
@@ -82,15 +82,6 @@ export class ElementEngine extends BaseEngine {
|
|
|
82
82
|
this.updateState({ inlineStyle: cssText });
|
|
83
83
|
return this;
|
|
84
84
|
}
|
|
85
|
-
// --- Convenience Aliases (documented as such) ---
|
|
86
|
-
/** @alias for tagName() */
|
|
87
|
-
tag(value) {
|
|
88
|
-
return this.tagName(value);
|
|
89
|
-
}
|
|
90
|
-
/** @alias for content(value, 'text') */
|
|
91
|
-
text(value) {
|
|
92
|
-
return this.content(value, 'text');
|
|
93
|
-
}
|
|
94
85
|
/** @alias for content(value, 'html') */
|
|
95
86
|
html(value) {
|
|
96
87
|
return this.content(value, 'html');
|
|
@@ -8,9 +8,9 @@ export class ElementSkin extends BaseSkin {
|
|
|
8
8
|
return structureCss;
|
|
9
9
|
}
|
|
10
10
|
createRoot() {
|
|
11
|
-
// Use state.
|
|
12
|
-
const
|
|
13
|
-
return document.createElement(
|
|
11
|
+
// Use state.tag (consistent naming)
|
|
12
|
+
const tag = this.engine.state.tag || 'div';
|
|
13
|
+
return document.createElement(tag);
|
|
14
14
|
}
|
|
15
15
|
bindEvents(root) {
|
|
16
16
|
// ✅ Forward common events to the engine via public handler
|
|
@@ -23,9 +23,9 @@ export class ElementSkin extends BaseSkin {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
updateSkin(state) {
|
|
26
|
-
// 1. Tag Replacement Logic (uses state.
|
|
27
|
-
if (this.root
|
|
28
|
-
const newRoot = document.createElement(state.
|
|
26
|
+
// 1. Tag Replacement Logic (uses state.tag)
|
|
27
|
+
if (this.root) {
|
|
28
|
+
const newRoot = document.createElement(state.tag.toLowerCase());
|
|
29
29
|
if (this.root.parentNode) {
|
|
30
30
|
this.root.parentNode.replaceChild(newRoot, this.root);
|
|
31
31
|
}
|