ezfw-core 1.0.0

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.
Files changed (154) hide show
  1. package/components/EzBaseComponent.ts +648 -0
  2. package/components/EzComponent.ts +89 -0
  3. package/components/EzInput.module.scss +183 -0
  4. package/components/EzInput.ts +104 -0
  5. package/components/EzLabel.ts +22 -0
  6. package/components/EzOutlet.ts +181 -0
  7. package/components/HtmlWrapper.ts +305 -0
  8. package/components/avatar/EzAvatar.module.scss +200 -0
  9. package/components/avatar/EzAvatar.ts +130 -0
  10. package/components/badge/EzBadge.module.scss +202 -0
  11. package/components/badge/EzBadge.ts +77 -0
  12. package/components/button/EzButton.module.scss +402 -0
  13. package/components/button/EzButton.ts +175 -0
  14. package/components/button/EzButtonGroup.ts +48 -0
  15. package/components/card/EzCard.module.scss +71 -0
  16. package/components/card/EzCard.ts +120 -0
  17. package/components/chart/EzBarChart.ts +47 -0
  18. package/components/chart/EzChart.module.scss +14 -0
  19. package/components/chart/EzChart.ts +279 -0
  20. package/components/chart/EzDoughnutChart.ts +47 -0
  21. package/components/chart/EzLineChart.ts +53 -0
  22. package/components/checkbox/EzCheckbox.module.scss +145 -0
  23. package/components/checkbox/EzCheckbox.ts +115 -0
  24. package/components/dataview/EzDataView.module.scss +115 -0
  25. package/components/dataview/EzDataView.ts +355 -0
  26. package/components/dataview/modes/EzDataViewCards.ts +322 -0
  27. package/components/dataview/modes/EzDataViewGrid.ts +76 -0
  28. package/components/datepicker/EzDatePicker.module.scss +348 -0
  29. package/components/datepicker/EzDatePicker.ts +519 -0
  30. package/components/dialog/EzDialog.module.scss +180 -0
  31. package/components/dropdown/EzDropdown.module.scss +107 -0
  32. package/components/dropdown/EzDropdown.ts +235 -0
  33. package/components/feed/EzActivityFeed.module.scss +90 -0
  34. package/components/feed/EzActivityFeed.ts +78 -0
  35. package/components/form/EzForm.ts +364 -0
  36. package/components/form/EzValidators.test.js +421 -0
  37. package/components/form/EzValidators.ts +202 -0
  38. package/components/grid/EzGrid.scss +88 -0
  39. package/components/grid/EzGrid.ts +1085 -0
  40. package/components/grid/EzGridContainer.ts +104 -0
  41. package/components/grid/body/EzGridBody.scss +283 -0
  42. package/components/grid/body/EzGridBody.ts +549 -0
  43. package/components/grid/body/EzGridCell.ts +211 -0
  44. package/components/grid/body/EzGridRow.ts +196 -0
  45. package/components/grid/filter/EzGridFilters.scss +78 -0
  46. package/components/grid/filter/EzGridFilters.ts +285 -0
  47. package/components/grid/footer/EzGridFooter.scss +136 -0
  48. package/components/grid/footer/EzGridFooter.ts +448 -0
  49. package/components/grid/header/EzGridHeader.scss +199 -0
  50. package/components/grid/header/EzGridHeader.ts +430 -0
  51. package/components/grid/query/EzGridQuery.ts +81 -0
  52. package/components/grid/state/EzGridColumns.ts +155 -0
  53. package/components/grid/state/EzGridController.ts +470 -0
  54. package/components/grid/state/EzGridLifecycle.ts +136 -0
  55. package/components/grid/state/EzGridNormalizers.test.js +273 -0
  56. package/components/grid/state/EzGridNormalizers.ts +162 -0
  57. package/components/grid/state/EzGridParts.ts +233 -0
  58. package/components/grid/state/EzGridPersistence.ts +140 -0
  59. package/components/grid/state/EzGridRemote.test.js +573 -0
  60. package/components/grid/state/EzGridRemote.ts +335 -0
  61. package/components/grid/state/EzGridSelection.ts +231 -0
  62. package/components/grid/state/EzGridSort.ts +286 -0
  63. package/components/grid/title/EzGridActionBar.ts +98 -0
  64. package/components/grid/title/EzGridTitle.ts +114 -0
  65. package/components/grid/title/EzGridTitleBar.scss +65 -0
  66. package/components/grid/title/EzGridTitleBar.ts +87 -0
  67. package/components/grid/types.ts +607 -0
  68. package/components/panel/EzPanel.module.scss +133 -0
  69. package/components/panel/EzPanel.ts +147 -0
  70. package/components/radio/EzRadio.module.scss +190 -0
  71. package/components/radio/EzRadio.ts +149 -0
  72. package/components/select/EzSelect.module.scss +153 -0
  73. package/components/select/EzSelect.ts +238 -0
  74. package/components/skeleton/EzSkeleton.module.scss +95 -0
  75. package/components/skeleton/EzSkeleton.ts +70 -0
  76. package/components/store/EzStore.ts +344 -0
  77. package/components/switch/EzSwitch.module.scss +164 -0
  78. package/components/switch/EzSwitch.ts +117 -0
  79. package/components/tabs/EzTabPanel.module.scss +181 -0
  80. package/components/tabs/EzTabPanel.ts +402 -0
  81. package/components/textarea/EzTextarea.module.scss +131 -0
  82. package/components/textarea/EzTextarea.ts +161 -0
  83. package/components/timepicker/EzTimePicker.module.scss +282 -0
  84. package/components/timepicker/EzTimePicker.ts +540 -0
  85. package/components/toast/EzToast.module.scss +291 -0
  86. package/components/tooltip/EzTooltip.module.scss +124 -0
  87. package/components/tooltip/EzTooltip.ts +153 -0
  88. package/core/EzComponentTypes.ts +693 -0
  89. package/core/EzError.ts +63 -0
  90. package/core/EzModel.ts +268 -0
  91. package/core/EzTypes.ts +328 -0
  92. package/core/eventBus.ts +284 -0
  93. package/core/ez.ts +617 -0
  94. package/core/loader.ts +725 -0
  95. package/core/renderer.ts +1010 -0
  96. package/core/router.ts +490 -0
  97. package/core/services.ts +124 -0
  98. package/core/state.ts +142 -0
  99. package/core/utils.ts +81 -0
  100. package/package.json +51 -0
  101. package/services/RouteUI.js +17 -0
  102. package/services/crypto.js +64 -0
  103. package/services/dialog.js +222 -0
  104. package/services/fetchApi.js +63 -0
  105. package/services/firebase.js +30 -0
  106. package/services/toast.js +214 -0
  107. package/template/doc/EzDocs.js +15 -0
  108. package/template/doc/EzDocs.module.scss +627 -0
  109. package/template/doc/EzDocsController.js +164 -0
  110. package/template/doc/data/activityfeed/EzActivityFeedDoc.js +42 -0
  111. package/template/doc/data/avatar/EzAvatarDoc.js +71 -0
  112. package/template/doc/data/badge/EzBadgeDoc.js +92 -0
  113. package/template/doc/data/button/EzButtonDoc.js +77 -0
  114. package/template/doc/data/buttongroup/EzButtonGroupDoc.js +102 -0
  115. package/template/doc/data/card/EzCardDoc.js +39 -0
  116. package/template/doc/data/chart/EzChartDoc.js +60 -0
  117. package/template/doc/data/checkbox/EzCheckboxDoc.js +67 -0
  118. package/template/doc/data/component/EzComponentDoc.js +34 -0
  119. package/template/doc/data/cssmodules/CSSModulesDoc.js +70 -0
  120. package/template/doc/data/datepicker/EzDatePickerDoc.js +126 -0
  121. package/template/doc/data/dialog/EzDialogDoc.js +217 -0
  122. package/template/doc/data/dropdown/EzDropdownDoc.js +178 -0
  123. package/template/doc/data/form/EzFormDoc.js +90 -0
  124. package/template/doc/data/grid/EzGridDoc.js +99 -0
  125. package/template/doc/data/input/EzInputDoc.js +92 -0
  126. package/template/doc/data/label/EzLabelDoc.js +40 -0
  127. package/template/doc/data/model/EzModelDoc.js +53 -0
  128. package/template/doc/data/outlet/EzOutletDoc.js +63 -0
  129. package/template/doc/data/panel/EzPanelDoc.js +214 -0
  130. package/template/doc/data/radio/EzRadioDoc.js +174 -0
  131. package/template/doc/data/router/EzRouterDoc.js +75 -0
  132. package/template/doc/data/select/EzSelectDoc.js +37 -0
  133. package/template/doc/data/skeleton/EzSkeletonDoc.js +149 -0
  134. package/template/doc/data/switch/EzSwitchDoc.js +82 -0
  135. package/template/doc/data/tabpanel/EzTabPanelDoc.js +44 -0
  136. package/template/doc/data/textarea/EzTextareaDoc.js +131 -0
  137. package/template/doc/data/timepicker/EzTimePickerDoc.js +107 -0
  138. package/template/doc/data/tooltip/EzTooltipDoc.js +193 -0
  139. package/template/doc/data/validators/EzValidatorsDoc.js +37 -0
  140. package/template/doc/sidebar/EzDocsSidebar.js +32 -0
  141. package/template/doc/sidebar/category/EzDocsCategory.js +33 -0
  142. package/template/doc/sidebar/item/EzDocsComponentItem.js +24 -0
  143. package/template/doc/viewer/EzDocsViewer.js +18 -0
  144. package/template/doc/viewer/codepanel/EzDocsCodePanel.js +51 -0
  145. package/template/doc/viewer/content/EzDocsContent.js +315 -0
  146. package/template/doc/viewer/header/EzDocsViewerHeader.js +46 -0
  147. package/template/doc/viewer/showcase/EzDocsShowcase.js +59 -0
  148. package/template/doc/viewer/showcase/EzDocsShowcaseSection.js +25 -0
  149. package/template/doc/viewer/showcase/EzDocsVariantItem.js +29 -0
  150. package/template/doc/welcome/EzDocsWelcome.js +48 -0
  151. package/themes/ez-theme.scss +179 -0
  152. package/themes/nature-fresh.scss +169 -0
  153. package/types/global.d.ts +21 -0
  154. package/utils/cssModules.js +81 -0
@@ -0,0 +1,89 @@
1
+ import { EzBaseComponent, EzComponentConfig } from "./EzBaseComponent.js";
2
+
3
+ declare const ez: {
4
+ _createChildElements(
5
+ items: EzComponentConfig[],
6
+ controller: string | null,
7
+ state: unknown,
8
+ css: string | null
9
+ ): Promise<Node[]>;
10
+ };
11
+
12
+ export type LayoutType = 'hbox' | 'vbox';
13
+
14
+ export interface EzComponentExtendedConfig extends EzComponentConfig {
15
+ layout?: LayoutType;
16
+ flex?: string | number;
17
+ items?: EzComponentConfig[];
18
+ formData?: Record<string, unknown> | string;
19
+ onClick?: (e: MouseEvent, component: EzComponent) => void;
20
+ }
21
+
22
+ export class EzComponent extends EzBaseComponent {
23
+ declare config: EzComponentExtendedConfig;
24
+
25
+ constructor(config: EzComponentExtendedConfig = {}) {
26
+ super(config);
27
+ this.config = config;
28
+ }
29
+
30
+ async render(): Promise<HTMLElement> {
31
+ const el = document.createElement('div');
32
+ const { layout, style = {} } = this.config;
33
+
34
+ // 📦 Predefined layouts
35
+ if (layout === 'hbox') {
36
+ el.style.display = 'flex';
37
+ el.style.flexDirection = 'row';
38
+ }
39
+
40
+ if (layout === 'vbox') {
41
+ el.style.display = 'flex';
42
+ el.style.flexDirection = 'column';
43
+ }
44
+
45
+ // 🎨 Additional inline styles
46
+ Object.assign(el.style, style);
47
+
48
+ if (this.config.flex) {
49
+ el.style.flex = String(this.config.flex);
50
+ }
51
+
52
+ this.applyCls(el);
53
+ this.applyCommonBindings(el);
54
+
55
+ if (this.config.onClick) {
56
+ el.addEventListener('click', (e: MouseEvent) => {
57
+ this.config.onClick!(e, this);
58
+ });
59
+ }
60
+
61
+ // 🧩 Render children (async)
62
+ if (this.config.items) {
63
+ const items = this.config.items.map(item => {
64
+ if (!item.formData && this.config.formData) {
65
+ return {
66
+ ...item,
67
+ formData: this.config.formData
68
+ };
69
+ }
70
+ return item;
71
+ });
72
+
73
+ const children = await ez._createChildElements(
74
+ items,
75
+ this.config.controller || null,
76
+ null,
77
+ (typeof this.config.css === 'string' ? this.config.css : null) as string | null
78
+ );
79
+
80
+ for (const child of children) {
81
+ if (child instanceof Node) {
82
+ el.appendChild(child);
83
+ }
84
+ }
85
+ }
86
+
87
+ return el;
88
+ }
89
+ }
@@ -0,0 +1,183 @@
1
+ // ==========================================================
2
+ // EzInput - CSS Module
3
+ // ==========================================================
4
+
5
+ .inputGroup {
6
+ display: flex;
7
+ flex-direction: column;
8
+ gap: 4px;
9
+ width: 100%;
10
+ }
11
+
12
+ .inputRow {
13
+ display: flex;
14
+ align-items: center;
15
+ gap: 8px;
16
+
17
+ background: var(--ez-input-bg, #ffffff);
18
+ border: 1px solid var(--ez-input-border, #e2e8f0);
19
+ border-radius: var(--ez-radius-md, 6px);
20
+
21
+ padding: 0 12px;
22
+ height: 36px;
23
+
24
+ transition: border-color 0.15s ease, box-shadow 0.15s ease;
25
+
26
+ &:hover {
27
+ border-color: var(--ez-text-tertiary, #94a3b8);
28
+ }
29
+
30
+ &:focus-within {
31
+ border-color: var(--ez-input-border-focus, #005871);
32
+ box-shadow: 0 0 0 2px var(--ez-primary-light, rgba(0, 88, 113, 0.15));
33
+ }
34
+ }
35
+
36
+ .icon {
37
+ color: var(--ez-text-tertiary, #94a3b8);
38
+ font-size: 14px;
39
+ flex-shrink: 0;
40
+ }
41
+
42
+ .input {
43
+ flex: 1;
44
+ min-width: 0;
45
+
46
+ height: 100%;
47
+ padding: 0;
48
+
49
+ font-family: inherit;
50
+ font-size: 13px;
51
+ color: var(--ez-input-text, #1e293b);
52
+
53
+ background: transparent;
54
+ border: none;
55
+ outline: none;
56
+
57
+ &::placeholder {
58
+ color: var(--ez-input-placeholder, #94a3b8);
59
+ }
60
+
61
+ &:disabled {
62
+ color: var(--ez-text-tertiary, #94a3b8);
63
+ cursor: not-allowed;
64
+ }
65
+
66
+ &[readonly] {
67
+ color: var(--ez-text-secondary, #64748b);
68
+ }
69
+ }
70
+
71
+ // ----------------------------------------------------------
72
+ // Disabled state
73
+ // ----------------------------------------------------------
74
+ .disabled {
75
+ background: var(--ez-surface-primary, #f8fafc);
76
+ cursor: not-allowed;
77
+
78
+ &:hover {
79
+ border-color: var(--ez-input-border, #e2e8f0);
80
+ }
81
+
82
+ .icon {
83
+ opacity: 0.5;
84
+ }
85
+ }
86
+
87
+ // ----------------------------------------------------------
88
+ // Error state
89
+ // ----------------------------------------------------------
90
+ .hasError {
91
+ .inputRow {
92
+ border-color: var(--ez-danger, #dc2626);
93
+
94
+ &:focus-within {
95
+ border-color: var(--ez-danger, #dc2626);
96
+ box-shadow: 0 0 0 2px var(--ez-danger-light, rgba(220, 38, 38, 0.15));
97
+ }
98
+ }
99
+ }
100
+
101
+ .fieldError {
102
+ display: none;
103
+ font-size: 12px;
104
+ color: var(--ez-danger, #dc2626);
105
+ padding-left: 2px;
106
+ }
107
+
108
+ .fieldErrorVisible {
109
+ display: block;
110
+ }
111
+
112
+ // ----------------------------------------------------------
113
+ // Sizes
114
+ // ----------------------------------------------------------
115
+ .sm {
116
+ .inputRow {
117
+ height: 30px;
118
+ padding: 0 10px;
119
+ }
120
+
121
+ .input {
122
+ font-size: 12px;
123
+ }
124
+
125
+ .icon {
126
+ font-size: 12px;
127
+ }
128
+ }
129
+
130
+ .lg {
131
+ .inputRow {
132
+ height: 44px;
133
+ padding: 0 14px;
134
+ }
135
+
136
+ .input {
137
+ font-size: 14px;
138
+ }
139
+
140
+ .icon {
141
+ font-size: 16px;
142
+ }
143
+ }
144
+
145
+ // ----------------------------------------------------------
146
+ // Variants
147
+ // ----------------------------------------------------------
148
+ .filled {
149
+ .inputRow {
150
+ background: var(--ez-surface-primary, #f1f5f9);
151
+ border-color: transparent;
152
+
153
+ &:hover {
154
+ background: var(--ez-surface-tertiary, #e2e8f0);
155
+ }
156
+
157
+ &:focus-within {
158
+ background: var(--ez-input-bg, #ffffff);
159
+ border-color: var(--ez-input-border-focus, #005871);
160
+ }
161
+ }
162
+ }
163
+
164
+ .underline {
165
+ .inputRow {
166
+ border-radius: 0;
167
+ border: none;
168
+ border-bottom: 1px solid var(--ez-input-border, #e2e8f0);
169
+ padding: 0 4px;
170
+
171
+ &:focus-within {
172
+ border-color: var(--ez-input-border-focus, #005871);
173
+ box-shadow: 0 1px 0 0 var(--ez-input-border-focus, #005871);
174
+ }
175
+ }
176
+ }
177
+
178
+ // ----------------------------------------------------------
179
+ // Block mode (full width)
180
+ // ----------------------------------------------------------
181
+ .block {
182
+ width: 100%;
183
+ }
@@ -0,0 +1,104 @@
1
+ import styles from './EzInput.module.scss';
2
+ import { cx } from '../utils/cssModules.js';
3
+ import { EzBaseComponent, EzBaseComponentConfig } from './EzBaseComponent.js';
4
+
5
+ const cls = cx(styles);
6
+
7
+ export interface EzInputConfig extends EzBaseComponentConfig {
8
+ size?: 'sm' | 'lg';
9
+ variant?: 'filled' | 'underline';
10
+ block?: boolean;
11
+ disabled?: boolean;
12
+ readonly?: boolean;
13
+ icon?: string;
14
+ inputType?: string;
15
+ placeholder?: string;
16
+ value?: string | number;
17
+ name?: string;
18
+ formData?: string;
19
+ }
20
+
21
+ export class EzInput extends EzBaseComponent {
22
+ declare config: EzInputConfig;
23
+
24
+ private _wrapper: HTMLDivElement | null = null;
25
+ private _error: HTMLDivElement | null = null;
26
+
27
+ render(): HTMLDivElement {
28
+ const cfg = this.config;
29
+
30
+ const wrapper = document.createElement('div');
31
+ wrapper.className = cls(
32
+ 'inputGroup',
33
+ cfg.size,
34
+ cfg.variant,
35
+ cfg.block && 'block',
36
+ cfg.disabled && 'disabled'
37
+ );
38
+
39
+ const error = document.createElement('div');
40
+ error.className = cls('fieldError');
41
+ wrapper.appendChild(error);
42
+
43
+ const row = document.createElement('div');
44
+ row.className = cls('inputRow');
45
+
46
+ if (cfg.icon) {
47
+ const icon = document.createElement('i');
48
+ icon.className = cls('icon', `fa fa-${cfg.icon}`);
49
+ row.appendChild(icon);
50
+ }
51
+
52
+ const input = document.createElement('input');
53
+ input.className = cls('input');
54
+ input.type = cfg.inputType || 'text';
55
+ input.placeholder = cfg.placeholder || '';
56
+ if (cfg.value !== undefined) input.value = String(cfg.value);
57
+
58
+ if (cfg.name && cfg.formData) {
59
+ this.config.bind = `${cfg.formData}.${cfg.name}`;
60
+ }
61
+
62
+ if (cfg.name) {
63
+ input.setAttribute('data-ez-field', cfg.name);
64
+ }
65
+
66
+ if (cfg.disabled) input.disabled = true;
67
+ if (cfg.readonly) input.readOnly = true;
68
+
69
+ this.applyCommonBindings(input);
70
+ this.applyStyles(input);
71
+
72
+ const onChange = this._createOnChangeHandler();
73
+
74
+ input.addEventListener('input', e => {
75
+ if (onChange) {
76
+ onChange((e.target as HTMLInputElement).value);
77
+ }
78
+ });
79
+
80
+ row.appendChild(input);
81
+ wrapper.appendChild(row);
82
+
83
+ this._wrapper = wrapper;
84
+ this._error = error;
85
+
86
+ return wrapper;
87
+ }
88
+
89
+ showError(message: string): void {
90
+ if (this._wrapper && this._error) {
91
+ this._wrapper.classList.add(cls('hasError'));
92
+ this._error.classList.add(cls('fieldErrorVisible'));
93
+ this._error.textContent = message;
94
+ }
95
+ }
96
+
97
+ clearError(): void {
98
+ if (this._wrapper && this._error) {
99
+ this._wrapper.classList.remove(cls('hasError'));
100
+ this._error.classList.remove(cls('fieldErrorVisible'));
101
+ this._error.textContent = '';
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,22 @@
1
+ import { EzBaseComponent, EzBaseComponentConfig } from './EzBaseComponent.js';
2
+
3
+ export interface EzLabelConfig extends EzBaseComponentConfig {
4
+ text?: string;
5
+ }
6
+
7
+ export class EzLabel extends EzBaseComponent {
8
+ declare config: EzLabelConfig;
9
+
10
+ constructor(config: EzLabelConfig = {}) {
11
+ super(config);
12
+ this.config = config;
13
+ }
14
+
15
+ render(): HTMLSpanElement {
16
+ const el = document.createElement('span');
17
+ this.applyCommonBindings(el);
18
+ this.applyStyles(el);
19
+
20
+ return el;
21
+ }
22
+ }
@@ -0,0 +1,181 @@
1
+ import { EzBaseComponent, EzBaseComponentConfig } from './EzBaseComponent.js';
2
+
3
+ declare const ez: {
4
+ get(name: string): ViewDefinition | null;
5
+ getController(name: string): Promise<EzController | null>;
6
+ _createElement(config: unknown, controller?: string | null, parent?: unknown): Promise<HTMLElement & { __ezInstance?: EzBaseComponent }>;
7
+ };
8
+
9
+ interface ViewDefinition {
10
+ template?: (props: unknown) => unknown;
11
+ controller?: string;
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ interface EzController {
16
+ onRouteChange?: (route: RouteInfo) => Promise<void>;
17
+ [key: string]: unknown;
18
+ }
19
+
20
+ interface RouteInfo {
21
+ fullPath: string;
22
+ params: Record<string, string>;
23
+ chain: unknown[];
24
+ }
25
+
26
+ export interface EzOutletConfig extends EzBaseComponentConfig {
27
+ name?: string;
28
+ stretch?: boolean;
29
+ layout?: 'vbox' | 'hbox';
30
+ flex?: number | string;
31
+ }
32
+
33
+ export class EzOutlet extends EzBaseComponent {
34
+ declare config: EzOutletConfig;
35
+ declare el: HTMLElement;
36
+
37
+ name: string;
38
+ private _currentInstance: EzBaseComponent | null = null;
39
+ private _currentView: string | null = null;
40
+ private _currentParams: Record<string, string> | null = null;
41
+
42
+ constructor(config: EzOutletConfig = {}) {
43
+ super(config);
44
+ this.name = config.name || 'default';
45
+ }
46
+
47
+ async render(): Promise<HTMLElement> {
48
+ const el = document.createElement('div');
49
+
50
+ const classes: string[] = [];
51
+ if (this.config.cls) {
52
+ classes.push(this.config.cls as string);
53
+ }
54
+ if (this.config.stretch) {
55
+ classes.push('ez-outlet');
56
+ }
57
+ if (classes.length) {
58
+ el.className = classes.join(' ');
59
+ }
60
+
61
+ if (this.config.stretch || this.config.layout === 'vbox') {
62
+ el.style.display = 'flex';
63
+ el.style.flexDirection = 'column';
64
+ }
65
+
66
+ if (this.config.stretch || this.config.flex) {
67
+ el.style.flex = String(this.config.flex ?? 1);
68
+ el.style.minHeight = '0';
69
+ el.style.overflow = 'auto';
70
+ }
71
+
72
+ this.el = el;
73
+ return el;
74
+ }
75
+
76
+ async open(view: string | null, params: Record<string, string> = {}, chain: unknown[] = []): Promise<void> {
77
+ if (!view) {
78
+ this.close();
79
+ return;
80
+ }
81
+
82
+ if (this._currentView === view && this._currentInstance) {
83
+ const def = ez.get(view);
84
+ const paramsChanged = JSON.stringify(this._currentParams) !== JSON.stringify(params);
85
+
86
+ const isTemplateBased = typeof def?.template === 'function';
87
+
88
+ if (isTemplateBased) {
89
+ if (!paramsChanged) {
90
+ return;
91
+ }
92
+ } else if (def?.controller) {
93
+ const ctrl = await ez.getController(def.controller);
94
+ if (ctrl?.onRouteChange) {
95
+ this._currentParams = params;
96
+ await ctrl.onRouteChange({
97
+ fullPath: window.location.pathname,
98
+ params,
99
+ chain
100
+ });
101
+ return;
102
+ }
103
+ }
104
+
105
+ if (!paramsChanged) {
106
+ return;
107
+ }
108
+ }
109
+
110
+ if (this._currentInstance) {
111
+ this._currentInstance.destroy?.();
112
+ this.el.innerHTML = '';
113
+ this._currentInstance = null;
114
+ }
115
+
116
+ const el = await ez._createElement(
117
+ {
118
+ eztype: view,
119
+ routeParams: params,
120
+ props: { routeParams: params }
121
+ },
122
+ null,
123
+ this
124
+ );
125
+
126
+ this.el.appendChild(el);
127
+
128
+ this._currentInstance = el.__ezInstance || null;
129
+ this._currentView = view;
130
+ this._currentParams = params;
131
+
132
+ const def = ez.get(view);
133
+ if (def?.controller) {
134
+ const ctrl = await ez.getController(def.controller);
135
+ if (ctrl?.onRouteChange) {
136
+ await ctrl.onRouteChange({
137
+ fullPath: window.location.pathname,
138
+ params,
139
+ chain
140
+ });
141
+ }
142
+ }
143
+ }
144
+
145
+ close(): void {
146
+ if (this._currentInstance) {
147
+ this._currentInstance.destroy?.();
148
+ this.el.innerHTML = '';
149
+ this._currentInstance = null;
150
+ }
151
+ this._currentView = null;
152
+ this._currentParams = null;
153
+ }
154
+
155
+ getCurrentView(): string | null {
156
+ return this._currentView;
157
+ }
158
+
159
+ getCurrentParams(): Record<string, string> | null {
160
+ return this._currentParams;
161
+ }
162
+
163
+ isOpen(): boolean {
164
+ return this._currentInstance !== null;
165
+ }
166
+
167
+ getInstance(): EzBaseComponent | null {
168
+ return this._currentInstance;
169
+ }
170
+
171
+ destroy(): void {
172
+ if (this._currentInstance) {
173
+ this._currentInstance.destroy?.();
174
+ this._currentInstance = null;
175
+ }
176
+ this._currentView = null;
177
+ this._currentParams = null;
178
+
179
+ super.destroy();
180
+ }
181
+ }