juxscript 1.1.85 → 1.1.88
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/dom-structure-map.json +1 -1
- package/index.d.ts +7 -0
- package/index.d.ts.map +1 -1
- package/index.js +10 -0
- package/lib/components/base/BaseComponent.js +1 -1
- package/lib/components/base/BaseComponent.ts +1 -1
- package/lib/components/dropdown.js +1 -1
- package/lib/components/dropdown.ts +1 -1
- package/lib/components/stack/BaseStack.d.ts +112 -0
- package/lib/components/stack/BaseStack.d.ts.map +1 -0
- package/lib/components/stack/BaseStack.js +374 -0
- package/lib/components/stack/BaseStack.ts +484 -0
- package/lib/components/stack/HStack.d.ts +11 -0
- package/lib/components/stack/HStack.d.ts.map +1 -0
- package/lib/components/stack/HStack.js +14 -0
- package/lib/components/stack/HStack.ts +17 -0
- package/lib/components/stack/VStack.d.ts +11 -0
- package/lib/components/stack/VStack.d.ts.map +1 -0
- package/lib/components/stack/VStack.js +14 -0
- package/lib/components/stack/VStack.ts +17 -0
- package/lib/components/stack/ZStack.d.ts +11 -0
- package/lib/components/stack/ZStack.d.ts.map +1 -0
- package/lib/components/stack/ZStack.js +14 -0
- package/lib/components/stack/ZStack.ts +17 -0
- package/lib/styles/stack.css +133 -0
- package/package.json +1 -1
package/dom-structure-map.json
CHANGED
package/index.d.ts
CHANGED
|
@@ -46,6 +46,9 @@ import { registry } from './lib/components/registry.js';
|
|
|
46
46
|
import { stateHistory } from './lib/components/history/StateHistory.js';
|
|
47
47
|
import { watcher } from './lib/components/watcher.js';
|
|
48
48
|
export { state, registry, stateHistory };
|
|
49
|
+
import { vstack } from './lib/components/stack/VStack.js';
|
|
50
|
+
import { hstack } from './lib/components/stack/HStack.js';
|
|
51
|
+
import { zstack } from './lib/components/stack/ZStack.js';
|
|
49
52
|
export declare const jux: {
|
|
50
53
|
alert: typeof alert;
|
|
51
54
|
app: typeof app;
|
|
@@ -89,6 +92,9 @@ export declare const jux: {
|
|
|
89
92
|
themeToggle: typeof themeToggle;
|
|
90
93
|
tooltip: typeof tooltip;
|
|
91
94
|
write: typeof write;
|
|
95
|
+
vstack: typeof vstack;
|
|
96
|
+
hstack: typeof hstack;
|
|
97
|
+
zstack: typeof zstack;
|
|
92
98
|
fetch: typeof import("./lib/utils/fetch.js").juxFetch & {
|
|
93
99
|
all: typeof import("./lib/utils/fetch.js").fetchAll;
|
|
94
100
|
get: <T = any>(url: string, options?: Omit<import("./lib/utils/fetch.js").FetchOptions, "method">) => {
|
|
@@ -201,4 +207,5 @@ export declare const jux: {
|
|
|
201
207
|
getOrCreateContainer: typeof getOrCreateContainer;
|
|
202
208
|
watcher: typeof watcher;
|
|
203
209
|
};
|
|
210
|
+
export { vstack, hstack, zstack };
|
|
204
211
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,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import registry
|
|
|
48
48
|
import { stateHistory } from './lib/components/history/StateHistory.js'; // ✅ Import history
|
|
49
49
|
import { watcher } from './lib/components/watcher.js';
|
|
50
50
|
export { state, registry, stateHistory }; // ✅ Export history
|
|
51
|
+
// ✅ Import Stack components
|
|
52
|
+
import { vstack } from './lib/components/stack/VStack.js';
|
|
53
|
+
import { hstack } from './lib/components/stack/HStack.js';
|
|
54
|
+
import { zstack } from './lib/components/stack/ZStack.js';
|
|
51
55
|
// Utilities
|
|
52
56
|
export const jux = {
|
|
53
57
|
alert,
|
|
@@ -92,6 +96,10 @@ export const jux = {
|
|
|
92
96
|
themeToggle,
|
|
93
97
|
tooltip,
|
|
94
98
|
write,
|
|
99
|
+
// ✅ Stack components
|
|
100
|
+
vstack,
|
|
101
|
+
hstack,
|
|
102
|
+
zstack,
|
|
95
103
|
// Utilities
|
|
96
104
|
fetch: fetchAPI,
|
|
97
105
|
renderIcon,
|
|
@@ -99,3 +107,5 @@ export const jux = {
|
|
|
99
107
|
getOrCreateContainer,
|
|
100
108
|
watcher
|
|
101
109
|
};
|
|
110
|
+
// ✅ Export Stack components directly
|
|
111
|
+
export { vstack, hstack, zstack };
|
|
@@ -565,7 +565,7 @@ export class BaseComponent {
|
|
|
565
565
|
* Build label element for form inputs
|
|
566
566
|
*/
|
|
567
567
|
_renderLabel() {
|
|
568
|
-
const label = this.state.label || formatIdAsLabel(this._id);
|
|
568
|
+
const label = this.state.label || formatIdAsLabel(this._id); // ✅ Auto-generate
|
|
569
569
|
const required = this.state.required || false;
|
|
570
570
|
const labelEl = document.createElement('label');
|
|
571
571
|
labelEl.className = 'jux-input-label';
|
|
@@ -683,7 +683,7 @@ export abstract class BaseComponent<TState extends BaseState = BaseState> {
|
|
|
683
683
|
* Build label element for form inputs
|
|
684
684
|
*/
|
|
685
685
|
protected _renderLabel(): HTMLLabelElement {
|
|
686
|
-
const label = (this.state as any).label || formatIdAsLabel(this._id);
|
|
686
|
+
const label = (this.state as any).label || formatIdAsLabel(this._id); // ✅ Auto-generate
|
|
687
687
|
const required = (this.state as any).required || false;
|
|
688
688
|
|
|
689
689
|
const labelEl = document.createElement('label');
|
|
@@ -6,7 +6,7 @@ const CALLBACK_EVENTS = ['select'];
|
|
|
6
6
|
export class Dropdown extends BaseComponent {
|
|
7
7
|
constructor(id, options = {}) {
|
|
8
8
|
super(id, {
|
|
9
|
-
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
9
|
+
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
10
10
|
items: options.items ?? [],
|
|
11
11
|
position: options.position ?? 'bottom-left',
|
|
12
12
|
open: false,
|
|
@@ -35,7 +35,7 @@ export class Dropdown extends BaseComponent<DropdownState> {
|
|
|
35
35
|
|
|
36
36
|
constructor(id: string, options: DropdownOptions = {}) {
|
|
37
37
|
super(id, {
|
|
38
|
-
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
38
|
+
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅
|
|
39
39
|
items: options.items ?? [],
|
|
40
40
|
position: options.position ?? 'bottom-left',
|
|
41
41
|
open: false,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { BaseComponent, BaseState } from '../base/BaseComponent.js';
|
|
2
|
+
export interface StackOptions {
|
|
3
|
+
spacing?: 'none' | 'tight' | 'default' | 'loose';
|
|
4
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
5
|
+
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
|
|
6
|
+
divider?: boolean;
|
|
7
|
+
responsive?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
style?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ChildStyleFunction {
|
|
12
|
+
(index: number): string;
|
|
13
|
+
}
|
|
14
|
+
interface StackState extends BaseState {
|
|
15
|
+
spacing: string;
|
|
16
|
+
align?: string;
|
|
17
|
+
justify?: string;
|
|
18
|
+
divider: boolean;
|
|
19
|
+
responsive: boolean;
|
|
20
|
+
children: Array<any>;
|
|
21
|
+
childStyles?: ChildStyleFunction | string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* BaseStack - Foundation for all stack layout components
|
|
25
|
+
* Provides common styling, child management, and progressive effects
|
|
26
|
+
*/
|
|
27
|
+
export declare abstract class BaseStack extends BaseComponent<StackState> {
|
|
28
|
+
protected abstract baseClassName: string;
|
|
29
|
+
private _inlineStyles;
|
|
30
|
+
constructor(id: string, children: Record<string, any> | any[], options?: StackOptions);
|
|
31
|
+
protected getTriggerEvents(): readonly string[];
|
|
32
|
+
protected getCallbackEvents(): readonly string[];
|
|
33
|
+
spacing(value: 'none' | 'tight' | 'default' | 'loose'): this;
|
|
34
|
+
align(value: 'start' | 'center' | 'end' | 'stretch'): this;
|
|
35
|
+
justify(value: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'): this;
|
|
36
|
+
divider(value?: boolean): this;
|
|
37
|
+
responsive(value?: boolean): this;
|
|
38
|
+
/**
|
|
39
|
+
* Internal helper to add individual CSS properties
|
|
40
|
+
*/
|
|
41
|
+
private _addStyle;
|
|
42
|
+
/**
|
|
43
|
+
* Build and apply the complete style attribute
|
|
44
|
+
*/
|
|
45
|
+
private _updateStyleAttribute;
|
|
46
|
+
padding(value: string): this;
|
|
47
|
+
margin(value: string): this;
|
|
48
|
+
border(value: string): this;
|
|
49
|
+
borderRadius(value: string): this;
|
|
50
|
+
width(value: string): this;
|
|
51
|
+
height(value: string): this;
|
|
52
|
+
minWidth(value: string): this;
|
|
53
|
+
maxWidth(value: string): this;
|
|
54
|
+
minHeight(value: string): this;
|
|
55
|
+
maxHeight(value: string): this;
|
|
56
|
+
background(value: string): this;
|
|
57
|
+
backgroundColor(value: string): this;
|
|
58
|
+
boxShadow(value: string): this;
|
|
59
|
+
opacity(value: string | number): this;
|
|
60
|
+
position(value: 'static' | 'relative' | 'absolute' | 'fixed' | 'sticky'): this;
|
|
61
|
+
top(value: string): this;
|
|
62
|
+
right(value: string): this;
|
|
63
|
+
bottom(value: string): this;
|
|
64
|
+
left(value: string): this;
|
|
65
|
+
zIndex(value: string | number): this;
|
|
66
|
+
overflow(value: 'visible' | 'hidden' | 'scroll' | 'auto'): this;
|
|
67
|
+
overflowX(value: 'visible' | 'hidden' | 'scroll' | 'auto'): this;
|
|
68
|
+
overflowY(value: 'visible' | 'hidden' | 'scroll' | 'auto'): this;
|
|
69
|
+
display(value: string): this;
|
|
70
|
+
cursor(value: string): this;
|
|
71
|
+
transform(value: string): this;
|
|
72
|
+
transformOrigin(value: string): this;
|
|
73
|
+
transition(value: string): this;
|
|
74
|
+
animation(value: string): this;
|
|
75
|
+
/**
|
|
76
|
+
* Apply custom styles to each child progressively
|
|
77
|
+
*/
|
|
78
|
+
childStyle(stylesOrFunction: string[] | ChildStyleFunction): this;
|
|
79
|
+
/**
|
|
80
|
+
* Cascade effect - offset children progressively
|
|
81
|
+
*/
|
|
82
|
+
cascade(baseOffset?: number, axis?: 'x' | 'y' | 'both' | 'horizontal' | 'vertical' | 'xy'): this;
|
|
83
|
+
/**
|
|
84
|
+
* Fan effect - rotate children progressively
|
|
85
|
+
*/
|
|
86
|
+
fan(angle?: number, origin?: string): this;
|
|
87
|
+
/**
|
|
88
|
+
* Scale progression - shrink/grow children
|
|
89
|
+
*/
|
|
90
|
+
scaleProgressive(startScale?: number, step?: number, origin?: string): this;
|
|
91
|
+
/**
|
|
92
|
+
* Fade effect - progressive opacity
|
|
93
|
+
*/
|
|
94
|
+
fade(startOpacity?: number, step?: number): this;
|
|
95
|
+
/**
|
|
96
|
+
* Blur effect - progressive blur
|
|
97
|
+
*/
|
|
98
|
+
blur(startBlur?: number, step?: number): this;
|
|
99
|
+
/**
|
|
100
|
+
* Stagger animation delays
|
|
101
|
+
*/
|
|
102
|
+
stagger(baseDelay?: number): this;
|
|
103
|
+
protected buildClasses(): string;
|
|
104
|
+
protected renderChild(child: any, index: number): string;
|
|
105
|
+
private wrapChildWithStyle;
|
|
106
|
+
private injectChildStyle;
|
|
107
|
+
private getChildStyle;
|
|
108
|
+
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
109
|
+
update(prop: string, value: any): void;
|
|
110
|
+
}
|
|
111
|
+
export {};
|
|
112
|
+
//# sourceMappingURL=BaseStack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseStack.d.ts","sourceRoot":"","sources":["BaseStack.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAMpE,MAAM,WAAW,YAAY;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACjD,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IAC/B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B;AAED,UAAU,UAAW,SAAQ,SAAS;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,WAAW,CAAC,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAAC;CAC/C;AAED;;;GAGG;AACH,8BAAsB,SAAU,SAAQ,aAAa,CAAC,UAAU,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AE,GAAG,kBAAkB,GAAG,IAAI;IAKjE;;OAEG;IACH,OAAO,CAAC,UAAU,GAAE,MAAW,EAAE,IAAI,GAAE,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,IAAa,GAAG,IAAI;IAe5G;;OAEG;IACH,GAAG,CAAC,KAAK,GAAE,MAAU,EAAE,MAAM,GAAE,MAAwB,GAAG,IAAI;IAQ9D;;OAEG;IACH,gBAAgB,CAAC,UAAU,GAAE,MAAU,EAAE,IAAI,GAAE,MAAa,EAAE,MAAM,GAAE,MAAiB,GAAG,IAAI;IAQ9F;;OAEG;IACH,IAAI,CAAC,YAAY,GAAE,MAAU,EAAE,IAAI,GAAE,MAAa,GAAG,IAAI;IAQzD;;OAEG;IACH,IAAI,CAAC,SAAS,GAAE,MAAU,EAAE,IAAI,GAAE,MAAU,GAAG,IAAI;IAQnD;;OAEG;IACH,OAAO,CAAC,SAAS,GAAE,MAAY,GAAG,IAAI;IAYtC,SAAS,CAAC,YAAY,IAAI,MAAM;IAsChC,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IAyCxD,OAAO,CAAC,kBAAkB;IAQ1B,OAAO,CAAC,gBAAgB;IAQxB,OAAO,CAAC,aAAa;IAoBrB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IA6BlE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;CAGzC"}
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { BaseComponent } from '../base/BaseComponent.js';
|
|
2
|
+
// Event definitions
|
|
3
|
+
const TRIGGER_EVENTS = [];
|
|
4
|
+
const CALLBACK_EVENTS = [];
|
|
5
|
+
/**
|
|
6
|
+
* BaseStack - Foundation for all stack layout components
|
|
7
|
+
* Provides common styling, child management, and progressive effects
|
|
8
|
+
*/
|
|
9
|
+
export class BaseStack extends BaseComponent {
|
|
10
|
+
constructor(id, children, options = {}) {
|
|
11
|
+
// Convert children object to array, preserving order
|
|
12
|
+
const childArray = Array.isArray(children)
|
|
13
|
+
? children
|
|
14
|
+
: Object.values(children);
|
|
15
|
+
super(id, {
|
|
16
|
+
visible: true,
|
|
17
|
+
disabled: false,
|
|
18
|
+
loading: false,
|
|
19
|
+
class: options.class ?? '',
|
|
20
|
+
style: options.style ?? '',
|
|
21
|
+
attributes: {},
|
|
22
|
+
spacing: options.spacing ?? 'default',
|
|
23
|
+
align: options.align,
|
|
24
|
+
justify: options.justify,
|
|
25
|
+
divider: options.divider ?? false,
|
|
26
|
+
responsive: options.responsive ?? false,
|
|
27
|
+
children: childArray,
|
|
28
|
+
childStyles: undefined
|
|
29
|
+
});
|
|
30
|
+
this._inlineStyles = new Map(); // ✅ Stores individual CSS properties
|
|
31
|
+
}
|
|
32
|
+
getTriggerEvents() {
|
|
33
|
+
return TRIGGER_EVENTS;
|
|
34
|
+
}
|
|
35
|
+
getCallbackEvents() {
|
|
36
|
+
return CALLBACK_EVENTS;
|
|
37
|
+
}
|
|
38
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
39
|
+
* FLUENT LAYOUT API
|
|
40
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
41
|
+
spacing(value) {
|
|
42
|
+
this.state.spacing = value;
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
align(value) {
|
|
46
|
+
this.state.align = value;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
justify(value) {
|
|
50
|
+
this.state.justify = value;
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
divider(value = true) {
|
|
54
|
+
this.state.divider = value;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
responsive(value = true) {
|
|
58
|
+
this.state.responsive = value;
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
62
|
+
* FLUENT STYLE API - Comprehensive CSS properties
|
|
63
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
64
|
+
/**
|
|
65
|
+
* Internal helper to add individual CSS properties
|
|
66
|
+
*/
|
|
67
|
+
_addStyle(property, value) {
|
|
68
|
+
this._inlineStyles.set(property, value); // ✅ Store in Map
|
|
69
|
+
this._updateStyleAttribute(); // ✅ Rebuild style string
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build and apply the complete style attribute
|
|
74
|
+
*/
|
|
75
|
+
_updateStyleAttribute() {
|
|
76
|
+
const styleString = Array.from(this._inlineStyles.entries()) // ✅ Convert Map to array
|
|
77
|
+
.map(([prop, val]) => `${prop}: ${val}`) // ✅ Format each entry
|
|
78
|
+
.join('; '); // ✅ Join with semicolons
|
|
79
|
+
this.state.style = styleString;
|
|
80
|
+
}
|
|
81
|
+
// Box Model
|
|
82
|
+
padding(value) {
|
|
83
|
+
return this._addStyle('padding', value);
|
|
84
|
+
}
|
|
85
|
+
margin(value) {
|
|
86
|
+
return this._addStyle('margin', value);
|
|
87
|
+
}
|
|
88
|
+
border(value) {
|
|
89
|
+
return this._addStyle('border', value);
|
|
90
|
+
}
|
|
91
|
+
borderRadius(value) {
|
|
92
|
+
return this._addStyle('border-radius', value);
|
|
93
|
+
}
|
|
94
|
+
// Sizing
|
|
95
|
+
width(value) {
|
|
96
|
+
return this._addStyle('width', value);
|
|
97
|
+
}
|
|
98
|
+
height(value) {
|
|
99
|
+
return this._addStyle('height', value);
|
|
100
|
+
}
|
|
101
|
+
minWidth(value) {
|
|
102
|
+
return this._addStyle('min-width', value);
|
|
103
|
+
}
|
|
104
|
+
maxWidth(value) {
|
|
105
|
+
return this._addStyle('max-width', value);
|
|
106
|
+
}
|
|
107
|
+
minHeight(value) {
|
|
108
|
+
return this._addStyle('min-height', value);
|
|
109
|
+
}
|
|
110
|
+
maxHeight(value) {
|
|
111
|
+
return this._addStyle('max-height', value);
|
|
112
|
+
}
|
|
113
|
+
// Visual
|
|
114
|
+
background(value) {
|
|
115
|
+
return this._addStyle('background', value);
|
|
116
|
+
}
|
|
117
|
+
backgroundColor(value) {
|
|
118
|
+
return this._addStyle('background-color', value);
|
|
119
|
+
}
|
|
120
|
+
boxShadow(value) {
|
|
121
|
+
return this._addStyle('box-shadow', value);
|
|
122
|
+
}
|
|
123
|
+
opacity(value) {
|
|
124
|
+
return this._addStyle('opacity', String(value));
|
|
125
|
+
}
|
|
126
|
+
// Positioning
|
|
127
|
+
position(value) {
|
|
128
|
+
return this._addStyle('position', value);
|
|
129
|
+
}
|
|
130
|
+
top(value) {
|
|
131
|
+
return this._addStyle('top', value);
|
|
132
|
+
}
|
|
133
|
+
right(value) {
|
|
134
|
+
return this._addStyle('right', value);
|
|
135
|
+
}
|
|
136
|
+
bottom(value) {
|
|
137
|
+
return this._addStyle('bottom', value);
|
|
138
|
+
}
|
|
139
|
+
left(value) {
|
|
140
|
+
return this._addStyle('left', value);
|
|
141
|
+
}
|
|
142
|
+
zIndex(value) {
|
|
143
|
+
return this._addStyle('z-index', String(value));
|
|
144
|
+
}
|
|
145
|
+
// Overflow
|
|
146
|
+
overflow(value) {
|
|
147
|
+
return this._addStyle('overflow', value);
|
|
148
|
+
}
|
|
149
|
+
overflowX(value) {
|
|
150
|
+
return this._addStyle('overflow-x', value);
|
|
151
|
+
}
|
|
152
|
+
overflowY(value) {
|
|
153
|
+
return this._addStyle('overflow-y', value);
|
|
154
|
+
}
|
|
155
|
+
// Display
|
|
156
|
+
display(value) {
|
|
157
|
+
return this._addStyle('display', value);
|
|
158
|
+
}
|
|
159
|
+
// Cursor
|
|
160
|
+
cursor(value) {
|
|
161
|
+
return this._addStyle('cursor', value);
|
|
162
|
+
}
|
|
163
|
+
// Transform
|
|
164
|
+
transform(value) {
|
|
165
|
+
return this._addStyle('transform', value);
|
|
166
|
+
}
|
|
167
|
+
transformOrigin(value) {
|
|
168
|
+
return this._addStyle('transform-origin', value);
|
|
169
|
+
}
|
|
170
|
+
// Transition & Animation
|
|
171
|
+
transition(value) {
|
|
172
|
+
return this._addStyle('transition', value);
|
|
173
|
+
}
|
|
174
|
+
animation(value) {
|
|
175
|
+
return this._addStyle('animation', value);
|
|
176
|
+
}
|
|
177
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
178
|
+
* PROGRESSIVE CHILD STYLING
|
|
179
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
180
|
+
/**
|
|
181
|
+
* Apply custom styles to each child progressively
|
|
182
|
+
*/
|
|
183
|
+
childStyle(stylesOrFunction) {
|
|
184
|
+
this.state.childStyles = stylesOrFunction;
|
|
185
|
+
return this;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Cascade effect - offset children progressively
|
|
189
|
+
*/
|
|
190
|
+
cascade(baseOffset = 20, axis = 'both') {
|
|
191
|
+
this.state.childStyles = (index) => {
|
|
192
|
+
const offset = baseOffset * index;
|
|
193
|
+
if (axis === 'horizontal' || axis === 'x') {
|
|
194
|
+
return `margin-left: ${offset}px;`;
|
|
195
|
+
}
|
|
196
|
+
else if (axis === 'vertical' || axis === 'y') {
|
|
197
|
+
return `margin-top: ${offset}px;`;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
return `margin-left: ${offset}px; margin-top: ${offset}px;`;
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Fan effect - rotate children progressively
|
|
207
|
+
*/
|
|
208
|
+
fan(angle = 5, origin = 'bottom center') {
|
|
209
|
+
this.state.childStyles = (index) => {
|
|
210
|
+
const rotation = angle * index;
|
|
211
|
+
return `transform: rotate(${rotation}deg); transform-origin: ${origin};`;
|
|
212
|
+
};
|
|
213
|
+
return this;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Scale progression - shrink/grow children
|
|
217
|
+
*/
|
|
218
|
+
scaleProgressive(startScale = 1, step = 0.05, origin = 'center') {
|
|
219
|
+
this.state.childStyles = (index) => {
|
|
220
|
+
const scale = startScale - (step * index);
|
|
221
|
+
return `transform: scale(${scale}); transform-origin: ${origin};`;
|
|
222
|
+
};
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Fade effect - progressive opacity
|
|
227
|
+
*/
|
|
228
|
+
fade(startOpacity = 1, step = 0.15) {
|
|
229
|
+
this.state.childStyles = (index) => {
|
|
230
|
+
const opacity = Math.max(0.1, startOpacity - (step * index));
|
|
231
|
+
return `opacity: ${opacity};`;
|
|
232
|
+
};
|
|
233
|
+
return this;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Blur effect - progressive blur
|
|
237
|
+
*/
|
|
238
|
+
blur(startBlur = 0, step = 2) {
|
|
239
|
+
this.state.childStyles = (index) => {
|
|
240
|
+
const blur = startBlur + (step * index);
|
|
241
|
+
return `filter: blur(${blur}px);`;
|
|
242
|
+
};
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Stagger animation delays
|
|
247
|
+
*/
|
|
248
|
+
stagger(baseDelay = 100) {
|
|
249
|
+
this.state.childStyles = (index) => {
|
|
250
|
+
const delay = baseDelay * index;
|
|
251
|
+
return `animation-delay: ${delay}ms;`;
|
|
252
|
+
};
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
255
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
256
|
+
* RENDER HELPERS
|
|
257
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
258
|
+
buildClasses() {
|
|
259
|
+
const { spacing, align, justify, divider, responsive } = this.state;
|
|
260
|
+
const classes = [this.baseClassName];
|
|
261
|
+
// Spacing modifier
|
|
262
|
+
if (spacing !== 'default') {
|
|
263
|
+
classes.push(`${this.baseClassName}-${spacing}`);
|
|
264
|
+
}
|
|
265
|
+
// Alignment
|
|
266
|
+
if (align) {
|
|
267
|
+
classes.push(`jux-stack-${align}`);
|
|
268
|
+
}
|
|
269
|
+
// Justification
|
|
270
|
+
if (justify) {
|
|
271
|
+
classes.push(`jux-stack-justify-${justify}`);
|
|
272
|
+
}
|
|
273
|
+
// Divider
|
|
274
|
+
if (divider) {
|
|
275
|
+
classes.push(`${this.baseClassName}-divider`);
|
|
276
|
+
}
|
|
277
|
+
// Responsive
|
|
278
|
+
if (responsive) {
|
|
279
|
+
classes.push(`${this.baseClassName}-responsive`);
|
|
280
|
+
}
|
|
281
|
+
// Custom classes
|
|
282
|
+
if (this.state.class) {
|
|
283
|
+
classes.push(this.state.class);
|
|
284
|
+
}
|
|
285
|
+
return classes.join(' ');
|
|
286
|
+
}
|
|
287
|
+
renderChild(child, index) {
|
|
288
|
+
// Already a string
|
|
289
|
+
if (typeof child === 'string') {
|
|
290
|
+
return this.wrapChildWithStyle(child, index);
|
|
291
|
+
}
|
|
292
|
+
// JUX component with render method
|
|
293
|
+
if (child && typeof child.render === 'function') {
|
|
294
|
+
// Create temporary container
|
|
295
|
+
const temp = document.createElement('div');
|
|
296
|
+
child.render(temp);
|
|
297
|
+
if (child.container) {
|
|
298
|
+
let html = child.container.outerHTML;
|
|
299
|
+
child.container = null; // Reset for reuse
|
|
300
|
+
return this.injectChildStyle(html, index);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// DOM element
|
|
304
|
+
if (child && child.outerHTML) {
|
|
305
|
+
return this.injectChildStyle(child.outerHTML, index);
|
|
306
|
+
}
|
|
307
|
+
// Object with render method that returns string/element
|
|
308
|
+
if (child && typeof child.render === 'function') {
|
|
309
|
+
const rendered = child.render();
|
|
310
|
+
if (typeof rendered === 'string') {
|
|
311
|
+
return this.wrapChildWithStyle(rendered, index);
|
|
312
|
+
}
|
|
313
|
+
if (rendered && rendered.outerHTML) {
|
|
314
|
+
return this.injectChildStyle(rendered.outerHTML, index);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
// Fallback to string
|
|
318
|
+
return this.wrapChildWithStyle(String(child), index);
|
|
319
|
+
}
|
|
320
|
+
wrapChildWithStyle(html, index) {
|
|
321
|
+
const style = this.getChildStyle(index);
|
|
322
|
+
if (style) {
|
|
323
|
+
return `<div style="${style}">${html}</div>`;
|
|
324
|
+
}
|
|
325
|
+
return html;
|
|
326
|
+
}
|
|
327
|
+
injectChildStyle(html, index) {
|
|
328
|
+
const style = this.getChildStyle(index);
|
|
329
|
+
if (style) {
|
|
330
|
+
return html.replace(/^<(\w+)/, `<$1 style="${style}"`);
|
|
331
|
+
}
|
|
332
|
+
return html;
|
|
333
|
+
}
|
|
334
|
+
getChildStyle(index) {
|
|
335
|
+
const { childStyles } = this.state;
|
|
336
|
+
if (!childStyles)
|
|
337
|
+
return '';
|
|
338
|
+
if (typeof childStyles === 'function') {
|
|
339
|
+
return childStyles(index);
|
|
340
|
+
}
|
|
341
|
+
if (Array.isArray(childStyles)) {
|
|
342
|
+
return childStyles[index] || '';
|
|
343
|
+
}
|
|
344
|
+
return '';
|
|
345
|
+
}
|
|
346
|
+
/* ═════════════════════════════════════════════════════════════════
|
|
347
|
+
* RENDER
|
|
348
|
+
* ═════════════════════════════════════════════════════════════════ */
|
|
349
|
+
render(targetId) {
|
|
350
|
+
const container = this._setupContainer(targetId);
|
|
351
|
+
const wrapper = document.createElement('div');
|
|
352
|
+
wrapper.className = this.buildClasses();
|
|
353
|
+
wrapper.id = this._id;
|
|
354
|
+
// ✅ Apply the built style string
|
|
355
|
+
if (this.state.style) {
|
|
356
|
+
wrapper.setAttribute('style', this.state.style);
|
|
357
|
+
}
|
|
358
|
+
// Render all children
|
|
359
|
+
this.state.children.forEach((child, index) => {
|
|
360
|
+
const childHtml = this.renderChild(child, index);
|
|
361
|
+
const tempDiv = document.createElement('div');
|
|
362
|
+
tempDiv.innerHTML = childHtml;
|
|
363
|
+
if (tempDiv.firstChild) {
|
|
364
|
+
wrapper.appendChild(tempDiv.firstChild);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
this._wireStandardEvents(wrapper);
|
|
368
|
+
container.appendChild(wrapper);
|
|
369
|
+
return this;
|
|
370
|
+
}
|
|
371
|
+
update(prop, value) {
|
|
372
|
+
// Stack components are typically static
|
|
373
|
+
}
|
|
374
|
+
}
|