ezfw-core 1.0.50 → 1.0.51
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/components/EzComponent.ts +9 -0
- package/core/renderer.ts +3 -0
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export interface EzComponentExtendedConfig extends EzComponentConfig {
|
|
|
18
18
|
items?: EzComponentConfig[];
|
|
19
19
|
formData?: Record<string, unknown> | string;
|
|
20
20
|
onClick?: (e: MouseEvent, component: EzComponent) => void;
|
|
21
|
+
attrs?: Record<string, string | number | boolean | null | undefined>;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
export class EzComponent extends EzBaseComponent {
|
|
@@ -53,6 +54,14 @@ export class EzComponent extends EzBaseComponent {
|
|
|
53
54
|
this.applyCls(el);
|
|
54
55
|
this.applyCommonBindings(el);
|
|
55
56
|
|
|
57
|
+
// Apply custom attributes
|
|
58
|
+
if (this.config.attrs && typeof this.config.attrs === 'object') {
|
|
59
|
+
Object.entries(this.config.attrs).forEach(([key, value]) => {
|
|
60
|
+
if (value === false || value === null || value === undefined) return;
|
|
61
|
+
el.setAttribute(key, String(value));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
if (this.config.onClick) {
|
|
57
66
|
el.addEventListener('click', (e: MouseEvent) => {
|
|
58
67
|
this.config.onClick!(e, this);
|
package/core/renderer.ts
CHANGED
|
@@ -111,6 +111,9 @@ export interface ComponentConfig extends EzBaseComponentConfig {
|
|
|
111
111
|
|
|
112
112
|
// Behavior shortcuts
|
|
113
113
|
showOnHover?: boolean;
|
|
114
|
+
|
|
115
|
+
// Custom HTML attributes
|
|
116
|
+
attrs?: Record<string, string | number | boolean | null | undefined>;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
119
|
interface TooltipConfig {
|