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,519 @@
1
+ import styles from './EzDatePicker.module.scss';
2
+ import { cx } from '../../utils/cssModules.js';
3
+ import { EzBaseComponent, EzBaseComponentConfig } from '../EzBaseComponent.js';
4
+
5
+ interface MomentInstance {
6
+ format(pattern: string): string;
7
+ clone(): MomentInstance;
8
+ startOf(unit: string): MomentInstance;
9
+ endOf(unit: string): MomentInstance;
10
+ add(amount: number, unit: string): MomentInstance;
11
+ subtract(amount: number, unit: string): MomentInstance;
12
+ date(day?: number): MomentInstance | number;
13
+ day(): number;
14
+ isSame(other: MomentInstance, unit: string): boolean;
15
+ isBefore(other: MomentInstance, unit: string): boolean;
16
+ isAfter(other: MomentInstance, unit: string): boolean;
17
+ isValid(): boolean;
18
+ }
19
+
20
+ declare const ez: {
21
+ moment(input?: string | Date | null): MomentInstance;
22
+ };
23
+
24
+ const cls = cx(styles);
25
+
26
+ interface DateRange {
27
+ startDate: string | null;
28
+ endDate: string | null;
29
+ }
30
+
31
+ type OnChangeHandler = (value: unknown) => void;
32
+
33
+ export interface EzDatePickerConfig extends EzBaseComponentConfig {
34
+ range?: boolean;
35
+ placeholder?: string;
36
+ format?: string;
37
+ displayFormat?: string;
38
+ min?: string | Date;
39
+ max?: string | Date;
40
+ onDateChange?: (value: string | null | DateRange) => void;
41
+ value?: string | null;
42
+ startDate?: string | null;
43
+ endDate?: string | null;
44
+ size?: 'sm' | 'lg';
45
+ disabled?: boolean;
46
+ name?: string;
47
+ formData?: string;
48
+ }
49
+
50
+ export class EzDatePicker extends EzBaseComponent {
51
+ declare config: EzDatePickerConfig;
52
+ declare el: HTMLElement;
53
+
54
+ range: boolean;
55
+ placeholder: string;
56
+ format: string;
57
+ displayFormat: string;
58
+ min: MomentInstance | null;
59
+ max: MomentInstance | null;
60
+ onDateChange: ((value: string | null | DateRange) => void) | null;
61
+ value: string | null;
62
+ startDate: string | null;
63
+ endDate: string | null;
64
+
65
+ private _selectingEnd: boolean = false;
66
+ private _isOpen: boolean = false;
67
+ private _viewDate: MomentInstance;
68
+ private _trigger: HTMLElement | null = null;
69
+ private _input: HTMLInputElement | null = null;
70
+ private _error: HTMLElement | null = null;
71
+ private _dropdown: HTMLElement | null = null;
72
+ private _outsideClickHandler: ((e: MouseEvent) => void) | null = null;
73
+
74
+ constructor(config: EzDatePickerConfig = {}) {
75
+ super(config);
76
+
77
+ this.range = config.range || false;
78
+ this.placeholder = config.placeholder || (this.range ? 'Select date range...' : 'Select date...');
79
+ this.format = config.format || 'YYYY-MM-DD';
80
+ this.displayFormat = config.displayFormat || 'MMM D, YYYY';
81
+ this.min = config.min ? ez.moment(config.min as string) : null;
82
+ this.max = config.max ? ez.moment(config.max as string) : null;
83
+ this.onDateChange = config.onDateChange || null;
84
+
85
+ this.value = config.value ?? null;
86
+ this.startDate = config.startDate ?? null;
87
+ this.endDate = config.endDate ?? null;
88
+
89
+ this._viewDate = this._getInitialViewDate();
90
+ }
91
+
92
+ private _getInitialViewDate(): MomentInstance {
93
+ if (this.range && this.startDate) {
94
+ return ez.moment(this.startDate);
95
+ }
96
+ if (this.value) {
97
+ return ez.moment(this.value);
98
+ }
99
+ return ez.moment();
100
+ }
101
+
102
+ render(): HTMLElement {
103
+ const cfg = this.config;
104
+
105
+ if (cfg.name && cfg.formData) {
106
+ this.config.bind = `${cfg.formData}.${cfg.name}`;
107
+ }
108
+
109
+ this.el = document.createElement('div');
110
+ this.el.className = cls('datepicker', cfg.size, cfg.disabled && 'disabled');
111
+
112
+ this._trigger = document.createElement('div');
113
+ this._trigger.className = cls('trigger');
114
+
115
+ this._input = document.createElement('input');
116
+ this._input.type = 'text';
117
+ this._input.className = cls('input');
118
+ this._input.placeholder = this.placeholder;
119
+ this._input.readOnly = true;
120
+
121
+ if (cfg.name) {
122
+ this._input.setAttribute('data-ez-field', cfg.name);
123
+ }
124
+ if (cfg.disabled) {
125
+ this._input.disabled = true;
126
+ }
127
+
128
+ const icon = document.createElement('i');
129
+ icon.className = cls('icon') + ' fa-solid fa-calendar';
130
+
131
+ this._trigger.appendChild(this._input);
132
+ this._trigger.appendChild(icon);
133
+ this.el.appendChild(this._trigger);
134
+
135
+ this._error = document.createElement('div');
136
+ this._error.className = cls('fieldError');
137
+ this.el.appendChild(this._error);
138
+
139
+ this._dropdown = document.createElement('div');
140
+ this._dropdown.className = cls('dropdown');
141
+ this._dropdown.style.opacity = '0';
142
+ this._dropdown.style.visibility = 'hidden';
143
+ document.body.appendChild(this._dropdown);
144
+
145
+ this._updateDisplay();
146
+ this._bindEvents();
147
+
148
+ return this.el;
149
+ }
150
+
151
+ private _updateDisplay(): void {
152
+ if (!this._input) return;
153
+
154
+ if (this.range) {
155
+ if (this.startDate && this.endDate) {
156
+ const start = ez.moment(this.startDate);
157
+ const end = ez.moment(this.endDate);
158
+ this._input.value = `${start.format(this.displayFormat)} - ${end.format(this.displayFormat)}`;
159
+ } else if (this.startDate) {
160
+ const start = ez.moment(this.startDate);
161
+ this._input.value = `${start.format(this.displayFormat)} - ...`;
162
+ } else {
163
+ this._input.value = '';
164
+ }
165
+ } else {
166
+ if (this.value) {
167
+ const m = ez.moment(this.value);
168
+ this._input.value = m.isValid() ? m.format(this.displayFormat) : '';
169
+ } else {
170
+ this._input.value = '';
171
+ }
172
+ }
173
+ }
174
+
175
+ private _buildCalendar(): void {
176
+ if (!this._dropdown) return;
177
+ this._dropdown.innerHTML = '';
178
+
179
+ const header = document.createElement('div');
180
+ header.className = cls('header');
181
+
182
+ const prevBtn = document.createElement('button');
183
+ prevBtn.type = 'button';
184
+ prevBtn.className = cls('navBtn');
185
+ prevBtn.innerHTML = '<i class="fa-solid fa-chevron-left"></i>';
186
+ prevBtn.addEventListener('click', (e) => {
187
+ e.stopPropagation();
188
+ this._viewDate.subtract(1, 'month');
189
+ this._buildCalendar();
190
+ });
191
+
192
+ const title = document.createElement('span');
193
+ title.className = cls('title');
194
+ title.textContent = this._viewDate.format('MMMM YYYY');
195
+
196
+ const nextBtn = document.createElement('button');
197
+ nextBtn.type = 'button';
198
+ nextBtn.className = cls('navBtn');
199
+ nextBtn.innerHTML = '<i class="fa-solid fa-chevron-right"></i>';
200
+ nextBtn.addEventListener('click', (e) => {
201
+ e.stopPropagation();
202
+ this._viewDate.add(1, 'month');
203
+ this._buildCalendar();
204
+ });
205
+
206
+ header.appendChild(prevBtn);
207
+ header.appendChild(title);
208
+ header.appendChild(nextBtn);
209
+ this._dropdown.appendChild(header);
210
+
211
+ const weekdays = document.createElement('div');
212
+ weekdays.className = cls('weekdays');
213
+ ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'].forEach(day => {
214
+ const d = document.createElement('span');
215
+ d.className = cls('weekday');
216
+ d.textContent = day;
217
+ weekdays.appendChild(d);
218
+ });
219
+ this._dropdown.appendChild(weekdays);
220
+
221
+ const grid = document.createElement('div');
222
+ grid.className = cls('grid');
223
+
224
+ const startOfMonth = this._viewDate.clone().startOf('month');
225
+ const endOfMonth = this._viewDate.clone().endOf('month');
226
+ const startDay = startOfMonth.day();
227
+ const daysInMonth = Number(endOfMonth.date());
228
+
229
+ const today = ez.moment().startOf('day');
230
+
231
+ const rangeStart = this.range && this.startDate ? ez.moment(this.startDate).startOf('day') : null;
232
+ const rangeEnd = this.range && this.endDate ? ez.moment(this.endDate).startOf('day') : null;
233
+ const selectedDate = !this.range && this.value ? ez.moment(this.value).startOf('day') : null;
234
+
235
+ for (let i = 0; i < startDay; i++) {
236
+ const empty = document.createElement('span');
237
+ empty.className = cls('day', 'empty');
238
+ grid.appendChild(empty);
239
+ }
240
+
241
+ for (let day = 1; day <= daysInMonth; day++) {
242
+ const date = (this._viewDate.clone().date(day) as MomentInstance).startOf('day');
243
+ const dayEl = document.createElement('button');
244
+ dayEl.type = 'button';
245
+ dayEl.className = cls('day');
246
+ dayEl.textContent = String(day);
247
+
248
+ let isDisabled = false;
249
+ if (this.min && date.isBefore(this.min, 'day')) isDisabled = true;
250
+ if (this.max && date.isAfter(this.max, 'day')) isDisabled = true;
251
+
252
+ if (isDisabled) {
253
+ dayEl.classList.add(cls('disabled'));
254
+ dayEl.disabled = true;
255
+ }
256
+
257
+ if (date.isSame(today, 'day')) {
258
+ dayEl.classList.add(cls('today'));
259
+ }
260
+
261
+ if (this.range) {
262
+ if (rangeStart && date.isSame(rangeStart, 'day')) {
263
+ dayEl.classList.add(cls('rangeStart'));
264
+ dayEl.classList.add(cls('selected'));
265
+ }
266
+ if (rangeEnd && date.isSame(rangeEnd, 'day')) {
267
+ dayEl.classList.add(cls('rangeEnd'));
268
+ dayEl.classList.add(cls('selected'));
269
+ }
270
+ if (rangeStart && rangeEnd && date.isAfter(rangeStart, 'day') && date.isBefore(rangeEnd, 'day')) {
271
+ dayEl.classList.add(cls('inRange'));
272
+ }
273
+ } else {
274
+ if (selectedDate && date.isSame(selectedDate, 'day')) {
275
+ dayEl.classList.add(cls('selected'));
276
+ }
277
+ }
278
+
279
+ if (!isDisabled) {
280
+ dayEl.addEventListener('click', (e) => {
281
+ e.stopPropagation();
282
+ this._selectDate(date);
283
+ });
284
+ }
285
+
286
+ grid.appendChild(dayEl);
287
+ }
288
+
289
+ this._dropdown.appendChild(grid);
290
+
291
+ const footer = document.createElement('div');
292
+ footer.className = cls('footer');
293
+
294
+ const todayBtn = document.createElement('button');
295
+ todayBtn.type = 'button';
296
+ todayBtn.className = cls('todayBtn');
297
+ todayBtn.textContent = 'Today';
298
+ todayBtn.addEventListener('click', (e) => {
299
+ e.stopPropagation();
300
+ this._selectDate(ez.moment());
301
+ });
302
+
303
+ const clearBtn = document.createElement('button');
304
+ clearBtn.type = 'button';
305
+ clearBtn.className = cls('clearBtn');
306
+ clearBtn.textContent = 'Clear';
307
+ clearBtn.addEventListener('click', (e) => {
308
+ e.stopPropagation();
309
+ this._selectDate(null);
310
+ });
311
+
312
+ footer.appendChild(clearBtn);
313
+ footer.appendChild(todayBtn);
314
+ this._dropdown.appendChild(footer);
315
+ }
316
+
317
+ private _selectDate(date: MomentInstance | null): void {
318
+ if (this.range) {
319
+ this._selectRangeDate(date);
320
+ } else {
321
+ this._selectSingleDate(date);
322
+ }
323
+ }
324
+
325
+ private _selectSingleDate(date: MomentInstance | null): void {
326
+ if (date) {
327
+ this.value = date.format(this.format);
328
+ this._viewDate = date.clone();
329
+ } else {
330
+ this.value = null;
331
+ }
332
+
333
+ this._updateDisplay();
334
+ this._close();
335
+
336
+ if (this.onDateChange) {
337
+ this.onDateChange(this.value);
338
+ }
339
+ }
340
+
341
+ private _selectRangeDate(date: MomentInstance | null): void {
342
+ if (!date) {
343
+ this.startDate = null;
344
+ this.endDate = null;
345
+ this._selectingEnd = false;
346
+ this._updateDisplay();
347
+ this._buildCalendar();
348
+ this._fireRangeChange();
349
+ return;
350
+ }
351
+
352
+ const dateStr = date.format(this.format);
353
+
354
+ if (!this.startDate || this._selectingEnd === false) {
355
+ this.startDate = dateStr;
356
+ this.endDate = null;
357
+ this._selectingEnd = true;
358
+ this._updateDisplay();
359
+ this._buildCalendar();
360
+ } else {
361
+ const start = ez.moment(this.startDate);
362
+
363
+ if (date.isBefore(start, 'day')) {
364
+ this.endDate = this.startDate;
365
+ this.startDate = dateStr;
366
+ } else {
367
+ this.endDate = dateStr;
368
+ }
369
+
370
+ this._selectingEnd = false;
371
+ this._updateDisplay();
372
+ this._close();
373
+ this._fireRangeChange();
374
+ }
375
+ }
376
+
377
+ private _fireRangeChange(): void {
378
+ if (this.onDateChange) {
379
+ this.onDateChange({
380
+ startDate: this.startDate,
381
+ endDate: this.endDate
382
+ });
383
+ }
384
+ }
385
+
386
+ private _bindEvents(): void {
387
+ if (!this._trigger || !this._input) return;
388
+
389
+ this._trigger.addEventListener('click', (e) => {
390
+ if (this.config.disabled) return;
391
+ e.stopPropagation();
392
+ this._isOpen ? this._close() : this._open();
393
+ });
394
+
395
+ this._outsideClickHandler = (e: MouseEvent) => {
396
+ if (!this.el.contains(e.target as Node) && !this._dropdown?.contains(e.target as Node)) {
397
+ this._close();
398
+ }
399
+ };
400
+ document.addEventListener('click', this._outsideClickHandler);
401
+
402
+ this._input.addEventListener('keydown', (e) => {
403
+ if (e.key === 'Escape') {
404
+ this._close();
405
+ } else if (e.key === 'Enter' || e.key === ' ') {
406
+ e.preventDefault();
407
+ this._isOpen ? this._close() : this._open();
408
+ }
409
+ });
410
+ }
411
+
412
+ private _open(): void {
413
+ if (this._isOpen) return;
414
+ this._isOpen = true;
415
+
416
+ if (this.value) {
417
+ this._viewDate = ez.moment(this.value);
418
+ } else {
419
+ this._viewDate = ez.moment();
420
+ }
421
+
422
+ this._buildCalendar();
423
+ this.el.classList.add(cls('isOpen'));
424
+ this._positionDropdown();
425
+
426
+ if (this._dropdown) {
427
+ this._dropdown.style.opacity = '1';
428
+ this._dropdown.style.visibility = 'visible';
429
+ }
430
+ }
431
+
432
+ private _positionDropdown(): void {
433
+ if (!this._trigger || !this._dropdown) return;
434
+
435
+ const rect = this._trigger.getBoundingClientRect();
436
+ const dropdownHeight = 300;
437
+ const viewportHeight = window.innerHeight;
438
+ const spaceBelow = viewportHeight - rect.bottom;
439
+
440
+ this._dropdown.style.position = 'fixed';
441
+ this._dropdown.style.left = `${rect.left}px`;
442
+ this._dropdown.style.width = `${Math.max(rect.width, 280)}px`;
443
+ this._dropdown.style.zIndex = '9999';
444
+
445
+ if (spaceBelow < dropdownHeight && rect.top > spaceBelow) {
446
+ this._dropdown.style.bottom = `${viewportHeight - rect.top + 4}px`;
447
+ this._dropdown.style.top = 'auto';
448
+ this.el.classList.add(cls('isDropup'));
449
+ } else {
450
+ this._dropdown.style.top = `${rect.bottom + 4}px`;
451
+ this._dropdown.style.bottom = 'auto';
452
+ this.el.classList.remove(cls('isDropup'));
453
+ }
454
+ }
455
+
456
+ private _close(): void {
457
+ if (!this._isOpen) return;
458
+ this._isOpen = false;
459
+ this.el.classList.remove(cls('isOpen'));
460
+ this.el.classList.remove(cls('isDropup'));
461
+
462
+ if (this._dropdown) {
463
+ this._dropdown.style.opacity = '0';
464
+ this._dropdown.style.visibility = 'hidden';
465
+ }
466
+ }
467
+
468
+ setValue(value: string | DateRange | null): void {
469
+ if (this.range && typeof value === 'object' && value !== null) {
470
+ this.startDate = value.startDate ?? null;
471
+ this.endDate = value.endDate ?? null;
472
+ if (this.startDate) {
473
+ this._viewDate = ez.moment(this.startDate);
474
+ }
475
+ } else {
476
+ this.value = value as string | null;
477
+ if (this.value) {
478
+ this._viewDate = ez.moment(this.value);
479
+ }
480
+ }
481
+ this._updateDisplay();
482
+ }
483
+
484
+ getValue(): string | DateRange | null {
485
+ if (this.range) {
486
+ return {
487
+ startDate: this.startDate,
488
+ endDate: this.endDate
489
+ };
490
+ }
491
+ return this.value;
492
+ }
493
+
494
+ showError(message: string): void {
495
+ this.el.classList.add(cls('hasError'));
496
+ if (this._error) {
497
+ this._error.classList.add(cls('fieldErrorVisible'));
498
+ this._error.textContent = message;
499
+ }
500
+ }
501
+
502
+ clearError(): void {
503
+ this.el.classList.remove(cls('hasError'));
504
+ if (this._error) {
505
+ this._error.classList.remove(cls('fieldErrorVisible'));
506
+ this._error.textContent = '';
507
+ }
508
+ }
509
+
510
+ destroy(): void {
511
+ if (this._outsideClickHandler) {
512
+ document.removeEventListener('click', this._outsideClickHandler);
513
+ }
514
+ if (this._dropdown && this._dropdown.parentNode) {
515
+ this._dropdown.parentNode.removeChild(this._dropdown);
516
+ }
517
+ super.destroy();
518
+ }
519
+ }
@@ -0,0 +1,180 @@
1
+ .overlay {
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background: rgba(0, 0, 0, 0.5);
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ padding: 24px;
12
+ opacity: 0;
13
+ transition: opacity 0.2s ease;
14
+
15
+ // Global classes added by EzDialogService
16
+ &:global(.visible) {
17
+ opacity: 1;
18
+
19
+ .dialog {
20
+ transform: scale(1);
21
+ opacity: 1;
22
+ }
23
+ }
24
+
25
+ &:global(.closing) {
26
+ opacity: 0;
27
+
28
+ .dialog {
29
+ transform: scale(0.95);
30
+ opacity: 0;
31
+ }
32
+ }
33
+
34
+ &:global(.hidden) {
35
+ opacity: 0;
36
+ pointer-events: none;
37
+
38
+ .dialog {
39
+ transform: scale(0.95);
40
+ opacity: 0;
41
+ }
42
+ }
43
+ }
44
+
45
+ .dialog {
46
+ background: var(--ez-surface-secondary, #ffffff);
47
+ border-radius: 12px;
48
+ box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
49
+ max-height: calc(100vh - 48px);
50
+ display: flex;
51
+ flex-direction: column;
52
+ overflow: hidden;
53
+ transform: scale(0.95);
54
+ opacity: 0;
55
+ transition: transform 0.2s ease, opacity 0.2s ease;
56
+ }
57
+
58
+ .header {
59
+ display: flex;
60
+ align-items: center;
61
+ gap: 12px;
62
+ padding: 16px 20px;
63
+ border-bottom: 1px solid var(--ez-border, #e2e8f0);
64
+ }
65
+
66
+ .headerIcon {
67
+ width: 40px;
68
+ height: 40px;
69
+ border-radius: 10px;
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: center;
73
+ font-size: 18px;
74
+ flex-shrink: 0;
75
+
76
+ &.info {
77
+ background: var(--ez-primary-light, #dbeafe);
78
+ color: var(--ez-primary, #2563eb);
79
+ }
80
+
81
+ &.success {
82
+ background: #dcfce7;
83
+ color: #16a34a;
84
+ }
85
+
86
+ &.warning {
87
+ background: #fef3c7;
88
+ color: #d97706;
89
+ }
90
+
91
+ &.danger {
92
+ background: #fee2e2;
93
+ color: #dc2626;
94
+ }
95
+ }
96
+
97
+ .title {
98
+ font-size: 16px;
99
+ font-weight: 600;
100
+ color: var(--ez-text-primary, #1e293b);
101
+ margin: 0;
102
+ line-height: 1.4;
103
+ }
104
+
105
+ .headerBtn {
106
+ width: 32px;
107
+ height: 32px;
108
+ border: none;
109
+ background: transparent;
110
+ border-radius: 8px;
111
+ cursor: pointer;
112
+ display: flex;
113
+ align-items: center;
114
+ justify-content: center;
115
+ color: var(--ez-text-tertiary, #94a3b8);
116
+ transition: all 0.15s ease;
117
+ flex-shrink: 0;
118
+
119
+ &:hover {
120
+ background: var(--ez-surface-primary, #f1f5f9);
121
+ color: var(--ez-text-primary, #1e293b);
122
+ }
123
+ }
124
+
125
+ .body {
126
+ padding: 20px;
127
+ overflow-y: auto;
128
+ flex: 1;
129
+ min-height: 0;
130
+ }
131
+
132
+ .message {
133
+ margin: 0;
134
+ font-size: 14px;
135
+ color: var(--ez-text-secondary, #64748b);
136
+ line-height: 1.6;
137
+ }
138
+
139
+ .footer {
140
+ display: flex;
141
+ justify-content: flex-end;
142
+ gap: 12px;
143
+ padding: 16px 20px;
144
+ border-top: 1px solid var(--ez-border, #e2e8f0);
145
+ background: var(--ez-surface-primary, #f8fafc);
146
+ }
147
+
148
+ .sm {
149
+ width: 400px;
150
+ }
151
+
152
+ .md {
153
+ width: 500px;
154
+ }
155
+
156
+ .lg {
157
+ width: 700px;
158
+ }
159
+
160
+ .xl {
161
+ width: 900px;
162
+ }
163
+
164
+ .full {
165
+ width: 90vw;
166
+ }
167
+
168
+ .auto {
169
+ width: auto;
170
+ min-width: 300px;
171
+ }
172
+
173
+ // Applied via JS toggleMaximize
174
+ .dialog:global(.maximized) {
175
+ width: calc(100vw - 48px);
176
+ height: calc(100vh - 48px);
177
+ max-height: calc(100vh - 48px);
178
+ border-radius: 8px;
179
+ transition: all 0.2s ease;
180
+ }