ezfw-core 1.0.58 → 1.0.61
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/islands/ssrShim.js +73 -2
- package/package.json +1 -1
package/islands/ssrShim.js
CHANGED
|
@@ -18,6 +18,72 @@ if (!globalThis.__ezSSRControllers) {
|
|
|
18
18
|
const ssrRegistry = globalThis.__ezSSRRegistry;
|
|
19
19
|
const ssrControllers = globalThis.__ezSSRControllers;
|
|
20
20
|
|
|
21
|
+
// Framework components for SSR (declarative versions of class-based Ez components)
|
|
22
|
+
function registerFrameworkComponents() {
|
|
23
|
+
ssrRegistry['EzIcon'] = {
|
|
24
|
+
template(props) {
|
|
25
|
+
const type = props.type || 'solid';
|
|
26
|
+
const classes = [`fa-${type}`];
|
|
27
|
+
if (props.fa) classes.push(`fa-${props.fa}`);
|
|
28
|
+
if (props.spin) classes.push('fa-spin');
|
|
29
|
+
if (props.pulse) classes.push('fa-pulse');
|
|
30
|
+
if (props.bounce) classes.push('fa-bounce');
|
|
31
|
+
|
|
32
|
+
const sizeMap = {
|
|
33
|
+
xxs: '0.65em', xs: '0.75em', sm: '0.875em',
|
|
34
|
+
lg: '1.25em', xl: '1.5em', '2x': '2em',
|
|
35
|
+
'3x': '3em', '4x': '4em', '5x': '5em'
|
|
36
|
+
};
|
|
37
|
+
const semanticColors = {
|
|
38
|
+
primary: 'var(--ez-primary)', secondary: 'var(--ez-secondary)',
|
|
39
|
+
success: 'var(--ez-success)', danger: 'var(--ez-danger)',
|
|
40
|
+
warning: 'var(--ez-warning)', info: 'var(--ez-info)',
|
|
41
|
+
muted: 'var(--ez-muted)', light: 'var(--ez-light)', dark: 'var(--ez-dark)'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
eztype: 'i',
|
|
46
|
+
cls: classes.join(' '),
|
|
47
|
+
style: {
|
|
48
|
+
fontSize: props.size ? (sizeMap[props.size] || props.size) : undefined,
|
|
49
|
+
color: props.color ? (semanticColors[props.color] || props.color) : undefined
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
ssrRegistry['EzLabel'] = {
|
|
56
|
+
template(props) {
|
|
57
|
+
return {
|
|
58
|
+
eztype: 'span',
|
|
59
|
+
text: props.text || '',
|
|
60
|
+
cls: props.cls,
|
|
61
|
+
style: props.style
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
ssrRegistry['EzButton'] = {
|
|
67
|
+
template(props) {
|
|
68
|
+
const items = [];
|
|
69
|
+
if (props.iconCls) {
|
|
70
|
+
items.push({ eztype: 'i', cls: props.iconCls });
|
|
71
|
+
}
|
|
72
|
+
if (props.text) {
|
|
73
|
+
items.push({ eztype: 'span', text: props.text });
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
eztype: 'button',
|
|
77
|
+
cls: props.cls,
|
|
78
|
+
style: props.style,
|
|
79
|
+
attr: { type: props.type || 'button', disabled: props.disabled },
|
|
80
|
+
items: items.length > 0 ? items : undefined,
|
|
81
|
+
text: items.length === 0 ? props.text : undefined
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
21
87
|
const ezSSR = {
|
|
22
88
|
_registry: ssrRegistry,
|
|
23
89
|
_controllers: ssrControllers,
|
|
@@ -66,21 +132,26 @@ const ezSSR = {
|
|
|
66
132
|
return ssrRegistry[name];
|
|
67
133
|
},
|
|
68
134
|
|
|
69
|
-
// Clear registry (useful between renders)
|
|
135
|
+
// Clear registry (useful between renders) - preserves framework components
|
|
70
136
|
_clear() {
|
|
71
137
|
Object.keys(ssrRegistry).forEach(k => delete ssrRegistry[k]);
|
|
72
138
|
Object.keys(ssrControllers).forEach(k => delete ssrControllers[k]);
|
|
139
|
+
// Re-register framework components after clear
|
|
140
|
+
registerFrameworkComponents();
|
|
73
141
|
}
|
|
74
142
|
};
|
|
75
143
|
|
|
76
144
|
// Make available globally for SSR context
|
|
77
|
-
// Always set/update the global ez reference
|
|
78
145
|
globalThis.ez = ezSSR;
|
|
79
146
|
if (typeof global !== 'undefined') {
|
|
80
147
|
global.ez = ezSSR;
|
|
81
148
|
}
|
|
82
149
|
|
|
150
|
+
// Register framework components on init
|
|
151
|
+
registerFrameworkComponents();
|
|
152
|
+
|
|
83
153
|
console.log('[SSR Shim] Initialized - ez is now available globally');
|
|
154
|
+
console.log('[SSR Shim] Framework components registered: EzIcon, EzLabel, EzButton');
|
|
84
155
|
|
|
85
156
|
export { ezSSR as ez };
|
|
86
157
|
export default ezSSR;
|