ezfw-core 1.0.38 → 1.0.39

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.
@@ -366,12 +366,7 @@ export class EzBaseComponent {
366
366
  result = left == right;
367
367
  break;
368
368
  }
369
- if (result) {
370
- el.removeAttribute('data-ez-hidden');
371
- }
372
- else {
373
- el.setAttribute('data-ez-hidden', '');
374
- }
369
+ el.style.display = result ? '' : 'none';
375
370
  });
376
371
  this._effects.push(stop);
377
372
  }
@@ -397,12 +392,7 @@ export class EzBaseComponent {
397
392
  }
398
393
  const stop = effect(() => {
399
394
  const result = !!ez.getDeepValue(ez._controllers[activeCtrl]?.state, props);
400
- if (result) {
401
- el.removeAttribute('data-ez-hidden');
402
- }
403
- else {
404
- el.setAttribute('data-ez-hidden', '');
405
- }
395
+ el.style.display = result ? '' : 'none';
406
396
  });
407
397
  this._effects.push(stop);
408
398
  }
@@ -558,12 +558,12 @@ export class EzBaseComponent {
558
558
  const state = ez._controllers[controllerName]?.state;
559
559
  const left = ez.getDeepValue(state, props) as number | string;
560
560
 
561
- // Parse boolean, null, undefined literals
562
- let right: string | number | boolean | null | undefined = rightExpr;
563
- if (rightExpr === 'true') right = true;
564
- else if (rightExpr === 'false') right = false;
565
- else if (rightExpr === 'null') right = null;
566
- else if (rightExpr === 'undefined') right = undefined;
561
+ // Parse boolean, null, undefined literals
562
+ let right: string | number | boolean | null | undefined = rightExpr;
563
+ if (rightExpr === 'true') right = true;
564
+ else if (rightExpr === 'false') right = false;
565
+ else if (rightExpr === 'null') right = null;
566
+ else if (rightExpr === 'undefined') right = undefined;
567
567
  else if (!isNaN(Number(rightExpr))) right = Number(rightExpr);
568
568
 
569
569
  let result = true;
@@ -576,11 +576,7 @@ export class EzBaseComponent {
576
576
  case '==': result = left == right; break;
577
577
  }
578
578
 
579
- if (result) {
580
- el.removeAttribute('data-ez-hidden');
581
- } else {
582
- el.setAttribute('data-ez-hidden', '');
583
- }
579
+ el.style.display = result ? '' : 'none';
584
580
  });
585
581
  this._effects!.push(stop);
586
582
  } else {
@@ -606,11 +602,7 @@ export class EzBaseComponent {
606
602
 
607
603
  const stop = effect(() => {
608
604
  const result = !!ez.getDeepValue(ez._controllers[activeCtrl!]?.state, props);
609
- if (result) {
610
- el.removeAttribute('data-ez-hidden');
611
- } else {
612
- el.setAttribute('data-ez-hidden', '');
613
- }
605
+ el.style.display = result ? '' : 'none';
614
606
  });
615
607
  this._effects!.push(stop);
616
608
  }
@@ -0,0 +1,177 @@
1
+ import { EzStyleShortcuts } from '../core/styleShortcuts.js';
2
+ interface EzController {
3
+ state: Record<string, unknown>;
4
+ _computed?: Record<string, {
5
+ value: unknown;
6
+ }>;
7
+ [key: string]: unknown;
8
+ }
9
+ interface StyleModule {
10
+ [className: string]: string;
11
+ }
12
+ type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
13
+ type TooltipVariant = 'dark' | 'light';
14
+ interface TooltipConfig {
15
+ text?: string;
16
+ component?: EzComponentConfig;
17
+ position?: TooltipPosition;
18
+ variant?: TooltipVariant;
19
+ delay?: number;
20
+ }
21
+ interface BindConfig {
22
+ value?: string;
23
+ data?: string;
24
+ visible?: string;
25
+ cls?: string | (() => string);
26
+ html?: string | (() => string);
27
+ sanitizeHtml?: boolean;
28
+ style?: Record<string, string> | (() => Record<string, string>);
29
+ text?: string | (() => string);
30
+ [key: string]: unknown;
31
+ }
32
+ type StyleValue = string | number | undefined;
33
+ export interface EzComponentConfig {
34
+ controller?: string | null;
35
+ bind?: string | BindConfig;
36
+ text?: string | number;
37
+ cls?: string | string[];
38
+ style?: Partial<CSSStyleDeclaration>;
39
+ tooltip?: string | TooltipConfig;
40
+ props?: Record<string, unknown>;
41
+ css?: string | unknown;
42
+ _styleModule?: StyleModule;
43
+ onChange?: string | ((value: unknown) => void);
44
+ itemRender?: (item: unknown, index: number, meta: ItemRenderMeta) => EzComponentConfig | null;
45
+ p?: StyleValue;
46
+ pt?: StyleValue;
47
+ pr?: StyleValue;
48
+ pb?: StyleValue;
49
+ pl?: StyleValue;
50
+ px?: StyleValue;
51
+ py?: StyleValue;
52
+ m?: StyleValue;
53
+ mt?: StyleValue;
54
+ mr?: StyleValue;
55
+ mb?: StyleValue;
56
+ ml?: StyleValue;
57
+ mx?: StyleValue;
58
+ my?: StyleValue;
59
+ gap?: StyleValue;
60
+ w?: StyleValue;
61
+ h?: StyleValue;
62
+ minW?: StyleValue;
63
+ maxW?: StyleValue;
64
+ minH?: StyleValue;
65
+ maxH?: StyleValue;
66
+ justify?: string;
67
+ align?: string;
68
+ alignSelf?: string;
69
+ wrap?: string | boolean;
70
+ fs?: StyleValue;
71
+ fw?: StyleValue;
72
+ ta?: string;
73
+ lh?: StyleValue;
74
+ bg?: string;
75
+ color?: string;
76
+ rounded?: StyleValue | boolean;
77
+ br?: StyleValue | boolean;
78
+ brt?: StyleValue;
79
+ brb?: StyleValue;
80
+ brl?: StyleValue;
81
+ brr?: StyleValue;
82
+ brtl?: StyleValue;
83
+ brtr?: StyleValue;
84
+ brbl?: StyleValue;
85
+ brbr?: StyleValue;
86
+ shadow?: string;
87
+ opacity?: number;
88
+ d?: string;
89
+ pos?: string;
90
+ z?: number;
91
+ overflow?: string;
92
+ top?: StyleValue;
93
+ right?: StyleValue;
94
+ bottom?: StyleValue;
95
+ left?: StyleValue;
96
+ ezStyle?: EzStyleShortcuts;
97
+ showOnHover?: boolean;
98
+ [key: string]: unknown;
99
+ }
100
+ export type EzBaseComponentConfig = EzComponentConfig;
101
+ interface ItemRenderMeta {
102
+ isFirst: boolean;
103
+ isLast: boolean;
104
+ isEven: boolean;
105
+ }
106
+ interface ResolvedBinding {
107
+ controller: EzController;
108
+ path: string[];
109
+ }
110
+ type EffectCleanup = () => void;
111
+ type DomListenerCleanup = () => void;
112
+ export declare class EzBaseComponent {
113
+ config: EzComponentConfig;
114
+ props: Record<string, unknown>;
115
+ el: HTMLElement | null;
116
+ controller: EzController | null;
117
+ protected _effects?: EffectCleanup[];
118
+ protected _domListeners?: DomListenerCleanup[];
119
+ protected _children?: EzBaseComponent[];
120
+ protected _tooltip?: HTMLDivElement;
121
+ protected _tooltipCleanup?: () => void;
122
+ protected _activateHandler?: (e: Event) => void;
123
+ protected _showOnHoverCleanup?: () => void;
124
+ constructor(config?: EzComponentConfig);
125
+ /**
126
+ * Lifecycle method called when component becomes active/visible.
127
+ * Override in subclasses to handle activation (e.g., reload data).
128
+ * Triggered by parent containers like EzTabPanel via 'ez-activate' event.
129
+ */
130
+ onActivate(): void;
131
+ /**
132
+ * Setup activation listener on element.
133
+ * Call this in render() after element is created.
134
+ */
135
+ protected _setupActivateListener(el: HTMLElement): void;
136
+ protected _resolveController(): Promise<void>;
137
+ /**
138
+ * Resolve binding configuration to get controller and path.
139
+ * Supports:
140
+ * - String: "form.username" or "ControllerName:form.username"
141
+ * - Object: { value: "form.username" }
142
+ */
143
+ protected _resolveBinding(): ResolvedBinding | null;
144
+ /**
145
+ * Create onChange handler from config or binding.
146
+ * Priority: function > string method name > auto from binding
147
+ */
148
+ protected _createOnChangeHandler(): ((value: unknown) => void) | null;
149
+ applyCommonBindings(el: HTMLElement): void;
150
+ private _applyValueBind;
151
+ private _applyDataBind;
152
+ private _applyVisibleBind;
153
+ private _applyClsBind;
154
+ private _applyHtmlBind;
155
+ private _applyStyleBind;
156
+ private _applyTextBind;
157
+ applyStyles(el: HTMLElement): void;
158
+ /**
159
+ * Apply static cls with CSS module resolution
160
+ */
161
+ applyCls(el: HTMLElement): void;
162
+ /**
163
+ * Apply tooltip if configured.
164
+ * Tooltip is created lazily on first hover to avoid DOM pollution.
165
+ * Supports text tooltips: tooltip: "Hello" or tooltip: { text: "Hello" }
166
+ * Supports component tooltips: tooltip: { component: { eztype: 'MyCard', props: {...} } }
167
+ */
168
+ applyTooltip(el: HTMLElement): void;
169
+ /**
170
+ * Apply showOnHover behavior.
171
+ * Element is hidden by default and revealed when parent is hovered.
172
+ * Must be called AFTER element is added to DOM (needs parentElement).
173
+ */
174
+ applyShowOnHover(el: HTMLElement): void;
175
+ destroy(): void;
176
+ }
177
+ export {};