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.
- package/components/EzBaseComponent.ts +648 -0
- package/components/EzComponent.ts +89 -0
- package/components/EzInput.module.scss +183 -0
- package/components/EzInput.ts +104 -0
- package/components/EzLabel.ts +22 -0
- package/components/EzOutlet.ts +181 -0
- package/components/HtmlWrapper.ts +305 -0
- package/components/avatar/EzAvatar.module.scss +200 -0
- package/components/avatar/EzAvatar.ts +130 -0
- package/components/badge/EzBadge.module.scss +202 -0
- package/components/badge/EzBadge.ts +77 -0
- package/components/button/EzButton.module.scss +402 -0
- package/components/button/EzButton.ts +175 -0
- package/components/button/EzButtonGroup.ts +48 -0
- package/components/card/EzCard.module.scss +71 -0
- package/components/card/EzCard.ts +120 -0
- package/components/chart/EzBarChart.ts +47 -0
- package/components/chart/EzChart.module.scss +14 -0
- package/components/chart/EzChart.ts +279 -0
- package/components/chart/EzDoughnutChart.ts +47 -0
- package/components/chart/EzLineChart.ts +53 -0
- package/components/checkbox/EzCheckbox.module.scss +145 -0
- package/components/checkbox/EzCheckbox.ts +115 -0
- package/components/dataview/EzDataView.module.scss +115 -0
- package/components/dataview/EzDataView.ts +355 -0
- package/components/dataview/modes/EzDataViewCards.ts +322 -0
- package/components/dataview/modes/EzDataViewGrid.ts +76 -0
- package/components/datepicker/EzDatePicker.module.scss +348 -0
- package/components/datepicker/EzDatePicker.ts +519 -0
- package/components/dialog/EzDialog.module.scss +180 -0
- package/components/dropdown/EzDropdown.module.scss +107 -0
- package/components/dropdown/EzDropdown.ts +235 -0
- package/components/feed/EzActivityFeed.module.scss +90 -0
- package/components/feed/EzActivityFeed.ts +78 -0
- package/components/form/EzForm.ts +364 -0
- package/components/form/EzValidators.test.js +421 -0
- package/components/form/EzValidators.ts +202 -0
- package/components/grid/EzGrid.scss +88 -0
- package/components/grid/EzGrid.ts +1085 -0
- package/components/grid/EzGridContainer.ts +104 -0
- package/components/grid/body/EzGridBody.scss +283 -0
- package/components/grid/body/EzGridBody.ts +549 -0
- package/components/grid/body/EzGridCell.ts +211 -0
- package/components/grid/body/EzGridRow.ts +196 -0
- package/components/grid/filter/EzGridFilters.scss +78 -0
- package/components/grid/filter/EzGridFilters.ts +285 -0
- package/components/grid/footer/EzGridFooter.scss +136 -0
- package/components/grid/footer/EzGridFooter.ts +448 -0
- package/components/grid/header/EzGridHeader.scss +199 -0
- package/components/grid/header/EzGridHeader.ts +430 -0
- package/components/grid/query/EzGridQuery.ts +81 -0
- package/components/grid/state/EzGridColumns.ts +155 -0
- package/components/grid/state/EzGridController.ts +470 -0
- package/components/grid/state/EzGridLifecycle.ts +136 -0
- package/components/grid/state/EzGridNormalizers.test.js +273 -0
- package/components/grid/state/EzGridNormalizers.ts +162 -0
- package/components/grid/state/EzGridParts.ts +233 -0
- package/components/grid/state/EzGridPersistence.ts +140 -0
- package/components/grid/state/EzGridRemote.test.js +573 -0
- package/components/grid/state/EzGridRemote.ts +335 -0
- package/components/grid/state/EzGridSelection.ts +231 -0
- package/components/grid/state/EzGridSort.ts +286 -0
- package/components/grid/title/EzGridActionBar.ts +98 -0
- package/components/grid/title/EzGridTitle.ts +114 -0
- package/components/grid/title/EzGridTitleBar.scss +65 -0
- package/components/grid/title/EzGridTitleBar.ts +87 -0
- package/components/grid/types.ts +607 -0
- package/components/panel/EzPanel.module.scss +133 -0
- package/components/panel/EzPanel.ts +147 -0
- package/components/radio/EzRadio.module.scss +190 -0
- package/components/radio/EzRadio.ts +149 -0
- package/components/select/EzSelect.module.scss +153 -0
- package/components/select/EzSelect.ts +238 -0
- package/components/skeleton/EzSkeleton.module.scss +95 -0
- package/components/skeleton/EzSkeleton.ts +70 -0
- package/components/store/EzStore.ts +344 -0
- package/components/switch/EzSwitch.module.scss +164 -0
- package/components/switch/EzSwitch.ts +117 -0
- package/components/tabs/EzTabPanel.module.scss +181 -0
- package/components/tabs/EzTabPanel.ts +402 -0
- package/components/textarea/EzTextarea.module.scss +131 -0
- package/components/textarea/EzTextarea.ts +161 -0
- package/components/timepicker/EzTimePicker.module.scss +282 -0
- package/components/timepicker/EzTimePicker.ts +540 -0
- package/components/toast/EzToast.module.scss +291 -0
- package/components/tooltip/EzTooltip.module.scss +124 -0
- package/components/tooltip/EzTooltip.ts +153 -0
- package/core/EzComponentTypes.ts +693 -0
- package/core/EzError.ts +63 -0
- package/core/EzModel.ts +268 -0
- package/core/EzTypes.ts +328 -0
- package/core/eventBus.ts +284 -0
- package/core/ez.ts +617 -0
- package/core/loader.ts +725 -0
- package/core/renderer.ts +1010 -0
- package/core/router.ts +490 -0
- package/core/services.ts +124 -0
- package/core/state.ts +142 -0
- package/core/utils.ts +81 -0
- package/package.json +51 -0
- package/services/RouteUI.js +17 -0
- package/services/crypto.js +64 -0
- package/services/dialog.js +222 -0
- package/services/fetchApi.js +63 -0
- package/services/firebase.js +30 -0
- package/services/toast.js +214 -0
- package/template/doc/EzDocs.js +15 -0
- package/template/doc/EzDocs.module.scss +627 -0
- package/template/doc/EzDocsController.js +164 -0
- package/template/doc/data/activityfeed/EzActivityFeedDoc.js +42 -0
- package/template/doc/data/avatar/EzAvatarDoc.js +71 -0
- package/template/doc/data/badge/EzBadgeDoc.js +92 -0
- package/template/doc/data/button/EzButtonDoc.js +77 -0
- package/template/doc/data/buttongroup/EzButtonGroupDoc.js +102 -0
- package/template/doc/data/card/EzCardDoc.js +39 -0
- package/template/doc/data/chart/EzChartDoc.js +60 -0
- package/template/doc/data/checkbox/EzCheckboxDoc.js +67 -0
- package/template/doc/data/component/EzComponentDoc.js +34 -0
- package/template/doc/data/cssmodules/CSSModulesDoc.js +70 -0
- package/template/doc/data/datepicker/EzDatePickerDoc.js +126 -0
- package/template/doc/data/dialog/EzDialogDoc.js +217 -0
- package/template/doc/data/dropdown/EzDropdownDoc.js +178 -0
- package/template/doc/data/form/EzFormDoc.js +90 -0
- package/template/doc/data/grid/EzGridDoc.js +99 -0
- package/template/doc/data/input/EzInputDoc.js +92 -0
- package/template/doc/data/label/EzLabelDoc.js +40 -0
- package/template/doc/data/model/EzModelDoc.js +53 -0
- package/template/doc/data/outlet/EzOutletDoc.js +63 -0
- package/template/doc/data/panel/EzPanelDoc.js +214 -0
- package/template/doc/data/radio/EzRadioDoc.js +174 -0
- package/template/doc/data/router/EzRouterDoc.js +75 -0
- package/template/doc/data/select/EzSelectDoc.js +37 -0
- package/template/doc/data/skeleton/EzSkeletonDoc.js +149 -0
- package/template/doc/data/switch/EzSwitchDoc.js +82 -0
- package/template/doc/data/tabpanel/EzTabPanelDoc.js +44 -0
- package/template/doc/data/textarea/EzTextareaDoc.js +131 -0
- package/template/doc/data/timepicker/EzTimePickerDoc.js +107 -0
- package/template/doc/data/tooltip/EzTooltipDoc.js +193 -0
- package/template/doc/data/validators/EzValidatorsDoc.js +37 -0
- package/template/doc/sidebar/EzDocsSidebar.js +32 -0
- package/template/doc/sidebar/category/EzDocsCategory.js +33 -0
- package/template/doc/sidebar/item/EzDocsComponentItem.js +24 -0
- package/template/doc/viewer/EzDocsViewer.js +18 -0
- package/template/doc/viewer/codepanel/EzDocsCodePanel.js +51 -0
- package/template/doc/viewer/content/EzDocsContent.js +315 -0
- package/template/doc/viewer/header/EzDocsViewerHeader.js +46 -0
- package/template/doc/viewer/showcase/EzDocsShowcase.js +59 -0
- package/template/doc/viewer/showcase/EzDocsShowcaseSection.js +25 -0
- package/template/doc/viewer/showcase/EzDocsVariantItem.js +29 -0
- package/template/doc/welcome/EzDocsWelcome.js +48 -0
- package/themes/ez-theme.scss +179 -0
- package/themes/nature-fresh.scss +169 -0
- package/types/global.d.ts +21 -0
- package/utils/cssModules.js +81 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import styles from '../components/toast/EzToast.module.scss';
|
|
2
|
+
import { cx } from '../utils/cssModules.js';
|
|
3
|
+
|
|
4
|
+
const cls = cx(styles);
|
|
5
|
+
|
|
6
|
+
const POSITION_MAP = {
|
|
7
|
+
'top-right': 'topRight',
|
|
8
|
+
'top-left': 'topLeft',
|
|
9
|
+
'top-center': 'topCenter',
|
|
10
|
+
'bottom-right': 'bottomRight',
|
|
11
|
+
'bottom-left': 'bottomLeft',
|
|
12
|
+
'bottom-center': 'bottomCenter'
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class EzToastService {
|
|
16
|
+
constructor() {
|
|
17
|
+
this._container = null;
|
|
18
|
+
this._toasts = [];
|
|
19
|
+
this._position = 'top-right';
|
|
20
|
+
this._defaultDuration = 4000;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
_getPositionClass() {
|
|
24
|
+
return POSITION_MAP[this._position] || 'topRight';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_ensureContainer() {
|
|
28
|
+
if (this._container) return;
|
|
29
|
+
|
|
30
|
+
this._container = document.createElement('div');
|
|
31
|
+
this._container.className = cls('toastContainer', this._getPositionClass());
|
|
32
|
+
document.body.appendChild(this._container);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
configure(options = {}) {
|
|
36
|
+
if (options.position) {
|
|
37
|
+
this._position = options.position;
|
|
38
|
+
if (this._container) {
|
|
39
|
+
this._container.className = cls('toastContainer', this._getPositionClass());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (options.duration !== undefined) {
|
|
43
|
+
this._defaultDuration = options.duration;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
show(options) {
|
|
48
|
+
const config = typeof options === 'string'
|
|
49
|
+
? { message: options }
|
|
50
|
+
: options;
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
message,
|
|
54
|
+
title,
|
|
55
|
+
variant = 'info',
|
|
56
|
+
duration = this._defaultDuration,
|
|
57
|
+
position = null,
|
|
58
|
+
closable = true,
|
|
59
|
+
icon = null,
|
|
60
|
+
action = null
|
|
61
|
+
} = config;
|
|
62
|
+
|
|
63
|
+
// Use custom position or default
|
|
64
|
+
const activePosition = position || this._position;
|
|
65
|
+
const positionClass = POSITION_MAP[activePosition] || 'topRight';
|
|
66
|
+
|
|
67
|
+
// Ensure container exists and update position if needed
|
|
68
|
+
this._ensureContainer();
|
|
69
|
+
if (position && position !== this._position) {
|
|
70
|
+
this._container.className = cls('toastContainer', positionClass);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const toast = document.createElement('div');
|
|
74
|
+
toast.className = cls('toast', variant);
|
|
75
|
+
|
|
76
|
+
// Icon
|
|
77
|
+
const iconEl = document.createElement('div');
|
|
78
|
+
iconEl.className = cls('toastIcon');
|
|
79
|
+
iconEl.innerHTML = this._getIcon(variant, icon);
|
|
80
|
+
toast.appendChild(iconEl);
|
|
81
|
+
|
|
82
|
+
// Content
|
|
83
|
+
const content = document.createElement('div');
|
|
84
|
+
content.className = cls('toastContent');
|
|
85
|
+
|
|
86
|
+
if (title) {
|
|
87
|
+
const titleEl = document.createElement('div');
|
|
88
|
+
titleEl.className = cls('toastTitle');
|
|
89
|
+
titleEl.textContent = title;
|
|
90
|
+
content.appendChild(titleEl);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const messageEl = document.createElement('div');
|
|
94
|
+
messageEl.className = cls('toastMessage');
|
|
95
|
+
messageEl.textContent = message;
|
|
96
|
+
content.appendChild(messageEl);
|
|
97
|
+
|
|
98
|
+
toast.appendChild(content);
|
|
99
|
+
|
|
100
|
+
// Action button (optional)
|
|
101
|
+
if (action) {
|
|
102
|
+
const actionBtn = document.createElement('button');
|
|
103
|
+
actionBtn.type = 'button';
|
|
104
|
+
actionBtn.className = cls('toastAction');
|
|
105
|
+
actionBtn.textContent = action.text;
|
|
106
|
+
actionBtn.addEventListener('click', () => {
|
|
107
|
+
action.onClick?.();
|
|
108
|
+
this._dismiss(toast);
|
|
109
|
+
});
|
|
110
|
+
toast.appendChild(actionBtn);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Close button
|
|
114
|
+
if (closable) {
|
|
115
|
+
const closeBtn = document.createElement('button');
|
|
116
|
+
closeBtn.type = 'button';
|
|
117
|
+
closeBtn.className = cls('toastClose');
|
|
118
|
+
closeBtn.innerHTML = '<i class="fa-solid fa-xmark"></i>';
|
|
119
|
+
closeBtn.addEventListener('click', () => this._dismiss(toast));
|
|
120
|
+
toast.appendChild(closeBtn);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Progress bar for auto-dismiss
|
|
124
|
+
if (duration > 0) {
|
|
125
|
+
const progress = document.createElement('div');
|
|
126
|
+
progress.className = cls('toastProgress');
|
|
127
|
+
progress.style.animationDuration = `${duration}ms`;
|
|
128
|
+
toast.appendChild(progress);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Add to container
|
|
132
|
+
this._container.appendChild(toast);
|
|
133
|
+
this._toasts.push(toast);
|
|
134
|
+
|
|
135
|
+
// Trigger enter animation
|
|
136
|
+
requestAnimationFrame(() => {
|
|
137
|
+
toast.classList.add(cls('toastVisible'));
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// Auto dismiss
|
|
141
|
+
if (duration > 0) {
|
|
142
|
+
toast._timeout = setTimeout(() => {
|
|
143
|
+
this._dismiss(toast);
|
|
144
|
+
}, duration);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
dismiss: () => this._dismiss(toast)
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
_dismiss(toast) {
|
|
153
|
+
if (!toast || !toast.parentNode) return;
|
|
154
|
+
|
|
155
|
+
if (toast._timeout) {
|
|
156
|
+
clearTimeout(toast._timeout);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
toast.classList.remove(cls('toastVisible'));
|
|
160
|
+
toast.classList.add(cls('toastExiting'));
|
|
161
|
+
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
if (toast.parentNode) {
|
|
164
|
+
toast.parentNode.removeChild(toast);
|
|
165
|
+
}
|
|
166
|
+
this._toasts = this._toasts.filter(t => t !== toast);
|
|
167
|
+
}, 300);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_getIcon(variant, customIcon) {
|
|
171
|
+
if (customIcon) return `<i class="${customIcon}"></i>`;
|
|
172
|
+
|
|
173
|
+
const icons = {
|
|
174
|
+
success: '<i class="fa-solid fa-circle-check"></i>',
|
|
175
|
+
error: '<i class="fa-solid fa-circle-xmark"></i>',
|
|
176
|
+
warning: '<i class="fa-solid fa-triangle-exclamation"></i>',
|
|
177
|
+
info: '<i class="fa-solid fa-circle-info"></i>'
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return icons[variant] || icons.info;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
success(messageOrConfig, options = {}) {
|
|
184
|
+
const config = typeof messageOrConfig === 'string'
|
|
185
|
+
? { message: messageOrConfig, ...options }
|
|
186
|
+
: messageOrConfig;
|
|
187
|
+
return this.show({ ...config, variant: 'success' });
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
error(messageOrConfig, options = {}) {
|
|
191
|
+
const config = typeof messageOrConfig === 'string'
|
|
192
|
+
? { message: messageOrConfig, ...options }
|
|
193
|
+
: messageOrConfig;
|
|
194
|
+
return this.show({ ...config, variant: 'error' });
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
warning(messageOrConfig, options = {}) {
|
|
198
|
+
const config = typeof messageOrConfig === 'string'
|
|
199
|
+
? { message: messageOrConfig, ...options }
|
|
200
|
+
: messageOrConfig;
|
|
201
|
+
return this.show({ ...config, variant: 'warning' });
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
info(messageOrConfig, options = {}) {
|
|
205
|
+
const config = typeof messageOrConfig === 'string'
|
|
206
|
+
? { message: messageOrConfig, ...options }
|
|
207
|
+
: messageOrConfig;
|
|
208
|
+
return this.show({ ...config, variant: 'info' });
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
dismissAll() {
|
|
212
|
+
[...this._toasts].forEach(toast => this._dismiss(toast));
|
|
213
|
+
}
|
|
214
|
+
}
|