@natec/mef-dev-ui-kit 16.2.0 → 16.2.2

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.
@@ -0,0 +1,421 @@
1
+ import { ElementRef, OnChanges, OnInit, EventEmitter } from '@angular/core';
2
+ import { DatePipe } from '@angular/common';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * Datepicker Component for selecting dates.
6
+ *
7
+ * This component allows users to pick a date from a calendar interface.
8
+ * It supports various configuration options such as language, date format, and date range.
9
+ *
10
+ * @example
11
+ * <mefdev-datepicker
12
+ * [lang]="'uk'"
13
+ * [dateFormat]="'dd/MM/yyyy'"
14
+ * [range]="{startYear: 1900, toYear: 300}"
15
+ * [disabled]="false"
16
+ * (dateChanged)="onDateChanged($event)"
17
+ * [topOffset]="'20'"
18
+ * [leftOffset]="'10'">
19
+ * </mefdev-datepicker>
20
+ *
21
+ * <example-url>https://mef.dev/ui_kit_demo/view/utils/datepicker</example-url>
22
+ */
23
+ export declare class DatepickerComponent implements OnChanges, OnInit {
24
+ private datePipe;
25
+ private elementRef;
26
+ /**
27
+ * Flag to determine if the calendar is open or closed.
28
+ * Default value: false (closed).
29
+ */
30
+ isCalendarOpen: boolean;
31
+ /**
32
+ * Flag to determine if the component is in editing mode.
33
+ * Default value: false (not in editing mode).
34
+ */
35
+ isEditing: boolean;
36
+ /**
37
+ * The currently selected date.
38
+ * Default value: Today's date.
39
+ */
40
+ selectedDate: Date;
41
+ /**
42
+ * The formatted date for display in the input.
43
+ * Default value: Formatted representation of the selected date.
44
+ */
45
+ formattedDate: any;
46
+ /**
47
+ * Track the edited date separately when in editing mode.
48
+ * Default value: An empty string.
49
+ */
50
+ editedDate: string;
51
+ /**
52
+ * Flag to determine if the month dropdown is open or closed.
53
+ * Default value: true (open).
54
+ */
55
+ isMonthDropdownOpen: boolean;
56
+ /**
57
+ * Flag to determine if the year dropdown is open or closed.
58
+ * Default value: true (open).
59
+ */
60
+ isYearDropdownOpen: boolean;
61
+ /**
62
+ * The selected month (0-11).
63
+ * Default value: The month of the selected date.
64
+ */
65
+ selectedDateMonth: number;
66
+ /**
67
+ * The selected year.
68
+ * Default value: The year of the selected date.
69
+ */
70
+ selectedDateYear: number;
71
+ /**
72
+ * An array of years for the year dropdown.
73
+ * Default value: An array of years within the specified range.
74
+ */
75
+ years: number[];
76
+ /**
77
+ * The language/locale for the datepicker.
78
+ * Default value: 'en' (English).
79
+ * @example
80
+ * <mefdev-datepicker
81
+ * [lang] = "'uk'">
82
+ * </mefdev-datepicker>
83
+ */
84
+ lang: string;
85
+ /**
86
+ * The date format for displaying the selected date.
87
+ * Default value: 'EEE MMM dd yyyy'.
88
+ * @example
89
+ * <mefdev-datepicker
90
+ * [dateFormat]="'dd/MM/yyyy'">
91
+ * </mefdev-datepicker>
92
+ */
93
+ dateFormat: string;
94
+ /**
95
+ * The range of years available in the year dropdown.
96
+ * Default value: { startYear: 1900, toYear: 300 }.
97
+ * @example
98
+ * <mefdev-datepicker
99
+ * [range]="{startYear: 1900, toYear: 300}">
100
+ * </mefdev-datepicker>
101
+ */
102
+ yearsRange: {
103
+ startYear: number;
104
+ toYear: number;
105
+ };
106
+ /**
107
+ * Whether the datepicker is disabled or not.
108
+ * Default value: false (enabled).
109
+ * @example
110
+ * <mefdev-datepicker
111
+ * [disabled]="false">
112
+ * </mefdev-datepicker>
113
+ */
114
+ disabled: boolean;
115
+ /**
116
+ * The top offset for positioning the datepicker.
117
+ * Default value: '20'.
118
+ * @example
119
+ * <mefdev-datepicker
120
+ * [topOffset]="'20'">
121
+ * </mefdev-datepicker>
122
+ */
123
+ topOffset: string;
124
+ /**
125
+ * The left offset for positioning the datepicker.
126
+ * Default value: '10'.
127
+ * @example
128
+ * <mefdev-datepicker
129
+ * [leftOffset]="'10'">
130
+ * </mefdev-datepicker>
131
+ */
132
+ leftOffset: string;
133
+ /**
134
+ * Event emitted when the selected date in the datepicker changes.
135
+ * It emits a `Date` object representing the selected date.
136
+ * @example
137
+ * <mefdev-datepicker
138
+ * (dateChanged)="onDateChanged($event)">
139
+ * </mefdev-datepicker>
140
+ */
141
+ dateChanged: EventEmitter<Date>;
142
+ /**
143
+ * Regular expression to validate user input for date in the format "dd/MM/yyyy".
144
+ * - The day (dd) should be between 01 and 31.
145
+ * - The month (MM) should be between 01 and 12.
146
+ * - The year (yyyy) should be a 4-digit number.
147
+ */
148
+ private dateRegExp;
149
+ /**
150
+ * The string entered by the user for date input.
151
+ * This variable stores the user's input as they type in the date field.
152
+ */
153
+ userInput: string;
154
+ /**
155
+ * Host listener for document click events to handle calendar interaction.
156
+ * This function checks if a click event occurred within the calendar or input elements.
157
+ * - If the click occurred within the calendar, no action is taken.
158
+ * - If the click occurred within the input element and the component is not in editing mode,
159
+ * it opens the calendar.
160
+ * - If the click occurred outside the calendar and input, it closes the calendar.
161
+ * @param event The MouseEvent object representing the click event.
162
+ */
163
+ onClick(event: MouseEvent): void;
164
+ /**
165
+ * Constructor for the DatepickerComponent class.
166
+ * @param datePipe A service for formatting and parsing dates.
167
+ * @param elementRef A reference to the element on which this component is attached.
168
+ * It is used to access DOM elements.
169
+ */
170
+ constructor(datePipe: DatePipe, elementRef: ElementRef);
171
+ /**
172
+ * Lifecycle hook called after the component is initialized.
173
+ * It initializes the years for the year select dropdown.
174
+ */
175
+ ngOnInit(): void;
176
+ /**
177
+ * Lifecycle hook called whenever the input properties of the component change.
178
+ * It updates the input value.
179
+ */
180
+ ngOnChanges(): void;
181
+ /**
182
+ * An array of month names based on the selected language.
183
+ * It provides localized month names for display in the datepicker.
184
+ */
185
+ private get months();
186
+ /**
187
+ * An array of weekday names based on the selected language.
188
+ * It provides localized weekday names for display in the datepicker.
189
+ */
190
+ private get weekdays();
191
+ /**
192
+ * Initialize the list of years to be displayed in the year dropdown.
193
+ * This method populates the 'years' array with a range of years based on the provided 'yearsRange' configuration.
194
+ * @example
195
+ * ```
196
+ * // Assuming 'yearsRange' is { startYear: 1900, toYear: 300 }
197
+ * // After calling initializeYears(), 'years' might contain [1900, 1901, ..., 300]
198
+ * this.initializeYears();
199
+ * ```
200
+ */
201
+ private initializeYears;
202
+ /**
203
+ * Toggle the editing mode for the date input. When enabled, the user can edit the date directly in the input field.
204
+ * This method sets the 'isEditing' flag to true and stores the current formatted date for editing.
205
+ */
206
+ toggleEdit(): void;
207
+ /**
208
+ * Get a list of month names in the specified language and format.
209
+ * @param locales - An optional parameter specifying the locale or locales to use for formatting.
210
+ * @param format - The format for month names, either "long" (default) or "short".
211
+ * @returns An array of month names based on the provided format and locale.
212
+ * ```
213
+ * // Get a list of month names in the default language and long format
214
+ * const months = this.getMonthList(this.lang);
215
+ * ```
216
+ */
217
+ private getMonthList;
218
+ /**
219
+ * Get a list of weekday names in the specified language and format.
220
+ * @param locales - An optional parameter specifying the locale or locales to use for formatting.
221
+ * @param format - The format for weekday names, either "short" (default) or "long".
222
+ * @returns An array of weekday names based on the provided format and locale.
223
+ * ```
224
+ * // Get a list of weekday names in the default language and short format
225
+ * const weekdays = this.getWeekdayList();
226
+ * ```
227
+ */
228
+ private getWeekdayList;
229
+ /**
230
+ * Toggle the visibility of the calendar component. When called, this method changes the 'isCalendarOpen' flag
231
+ * to show or hide the calendar interface.
232
+ * ```
233
+ * // Toggle the visibility of the calendar
234
+ * this.toggleCalendar();
235
+ * ```
236
+ */
237
+ private toggleCalendar;
238
+ /**
239
+ * Save the edited date input by the user, provided it matches the specified date format.
240
+ * This method checks if the entered date is in a valid format, disables the editing mode, and applies
241
+ * the edited date to the 'selectedDate'. It then reformats the selected date and closes the calendar.
242
+ * ```
243
+ * // Save the edited date and update the selected date
244
+ * this.saveEditedDate();
245
+ * ```
246
+ */
247
+ private saveEditedDate;
248
+ /**
249
+ * Handle user input in the editable input field for date editing. This method captures the input value
250
+ * and stores it in the 'editedDate' variable. If the input matches the valid date format, it updates
251
+ * 'selectedDateMonth' and 'selectedDateYear' accordingly.
252
+ * @param event - The input event containing the user's input.
253
+ * ```
254
+ * // Handle user input in the editable input field
255
+ * this.onDateInput(event);
256
+ * ```
257
+ */
258
+ private onDateInput;
259
+ /**
260
+ * Toggle the visibility of the month dropdown in the calendar interface.
261
+ * This method is used to open or close the dropdown for selecting months.
262
+ * @param event - The event triggering the toggle action (e.g., a click event).
263
+ * ```
264
+ * // Toggle the visibility of the month dropdown
265
+ * this.toggleMonthDropdown(event);
266
+ * ```
267
+ */
268
+ private toggleMonthDropdown;
269
+ /**
270
+ * Toggle the visibility of the year dropdown in the calendar interface.
271
+ * This method is used to open or close the dropdown for selecting years.
272
+ * @param event - The event triggering the toggle action (e.g., a click event).
273
+ * ```
274
+ * // Toggle the visibility of the year dropdown
275
+ * this.toggleYearDropdown(event);
276
+ * ```
277
+ */
278
+ private toggleYearDropdown;
279
+ /**
280
+ * Handle the change of the selected month in the calendar interface.
281
+ * This method updates the input value, sets the selected date to the first day of the chosen month,
282
+ * and recalculates the calendar display accordingly.
283
+ * ```
284
+ * // Handle the change of the selected month
285
+ * this.onMonthChange();
286
+ * ```
287
+ */
288
+ private onMonthChange;
289
+ /**
290
+ * Handle the change of the selected year in the calendar interface.
291
+ * This method updates the input value, sets the selected date to the first day of the chosen year,
292
+ * reformats the selected date, and recalculates the calendar display.
293
+ * ```
294
+ * // Handle the change of the selected year
295
+ * this.onYearChange();
296
+ * ```
297
+ */
298
+ private onYearChange;
299
+ /**
300
+ * Select a date in the calendar interface and perform necessary updates.
301
+ * This method sets the selected date, formats it, closes the calendar, and emits a dateChanged event.
302
+ * It also updates the selected month and year dropdown values.
303
+ * @param date - The date to be selected in the calendar.
304
+ */
305
+ selectDate(date: Date): void;
306
+ /**
307
+ * Format the selected date based on the chosen date format and language.
308
+ * This method uses the Angular DatePipe to format the selected date and updates the formattedDate variable.
309
+ * ```
310
+ * // Format the selected date
311
+ * this.formatDate();
312
+ * ```
313
+ */
314
+ private formatDate;
315
+ /**
316
+ * Format the selected date based on the chosen date format, language, and locale.
317
+ * This method uses the Angular DatePipe to format the selected date with the specified language and updates the formatted date as a string.
318
+ * @returns A formatted date string.
319
+ * ```
320
+ * // Format the selected date with language
321
+ * const formatted = this.formatSelectedDate();
322
+ * ```
323
+ */
324
+ private formatSelectedDate;
325
+ /**
326
+ * Update the input value displayed in the calendar interface.
327
+ * This method updates the input value to either the edited date or the formatted selected date,
328
+ * depending on whether the user is in edit mode or not.
329
+ * ```
330
+ * // Update the input value
331
+ * this.updateInputValue();
332
+ * ```
333
+ */
334
+ private updateInputValue;
335
+ /**
336
+ * Get an array of arrays representing the days of the current month.
337
+ * Each sub-array contains the day data for a week, and each day data object includes the date and whether it belongs to the current month.
338
+ * @returns An array of arrays representing the days of the current month.
339
+ * ```
340
+ * // Get an array of arrays representing the days of the current month
341
+ * const calendar = this.calendarDays;
342
+ * ```
343
+ */
344
+ private get calendarDays();
345
+ /**
346
+ * Get the date of the previous month to display in empty cells of the current month.
347
+ * This method returns the date of the previous month if the provided date is not in the current month.
348
+ * If the provided date is in the current month, it returns the date's day as a string.
349
+ * @param date - The date to evaluate.
350
+ * @returns The date of the previous month or a day string.
351
+ * ```
352
+ * // Get the previous month's date to display in empty cells
353
+ * const previousMonthDate = this.getPreviousMonthDate(new Date(2023, 8, 1));
354
+ * ```
355
+ */
356
+ private getPreviousMonthDate;
357
+ /**
358
+ * Navigate to the previous month in the calendar interface.
359
+ * This method updates the selectedDate, formats it, and recalculates the first day of the calendar.
360
+ * ```
361
+ * // Navigate to the previous month
362
+ * this.getPreviousMonth();
363
+ * ```
364
+ */
365
+ private getPreviousMonth;
366
+ /**
367
+ * Navigate to the next month in the calendar interface.
368
+ * This method updates the selectedDate, formats it, and recalculates the first day of the calendar.
369
+ * ```
370
+ * // Navigate to the next month
371
+ * this.getNextMonth();
372
+ * ```
373
+ */
374
+ private getNextMonth;
375
+ /**
376
+ * Get the number of days in a given month of a specific year.
377
+ * @param year - The year for which you want to determine the number of days.
378
+ * @param month - The month (0-based index) for which you want to determine the number of days.
379
+ * @returns The number of days in the specified month of the given year.
380
+ */
381
+ private daysInMonth;
382
+ /**
383
+ * Calculate the structure of days in a month for the calendar display.
384
+ * This method generates a matrix of day data objects representing the days in the calendar.
385
+ * Each day data object contains the date and whether it belongs to the current month.
386
+ * @returns A matrix of day data objects for the calendar display.
387
+ */
388
+ private calculateFirstDayOfCalendar;
389
+ /**
390
+ * Check if a given date is the currently selected date in the calendar.
391
+ * @param date - The date to check.
392
+ * @returns `true` if the provided date matches the selected date, otherwise `false`.
393
+ * ```
394
+ * // Check if a date is selected
395
+ * const isSelected = this.isDateSelected(someDate);
396
+ * ```
397
+ */
398
+ private isDateSelected;
399
+ /**
400
+ * Check if a date string is valid based on the specified date format.
401
+ * @param inputDate - The date string to validate.
402
+ * @returns `true` if the input date string is valid, otherwise `false`.
403
+ * ```
404
+ * // Check if a date string is valid
405
+ * const isValidDate = this.isDateValid('05/25/2023');
406
+ * ```
407
+ */
408
+ private isDateValid;
409
+ /**
410
+ * Check if a given date is today's date.
411
+ * @param date - The date to check.
412
+ * @returns `true` if the provided date is today's date, otherwise `false`.
413
+ * ```
414
+ * // Check if a date is today's date
415
+ * const isToday = this.isDateToday(someDate);
416
+ * ```
417
+ */
418
+ private isDateToday;
419
+ static ɵfac: i0.ɵɵFactoryDeclaration<DatepickerComponent, never>;
420
+ static ɵcmp: i0.ɵɵComponentDeclaration<DatepickerComponent, "mefdev-datepicker", never, { "lang": { "alias": "lang"; "required": false; }; "dateFormat": { "alias": "dateFormat"; "required": false; }; "yearsRange": { "alias": "range"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "topOffset": { "alias": "topOffset"; "required": false; }; "leftOffset": { "alias": "leftOffset"; "required": false; }; }, { "dateChanged": "dateChanged"; }, never, never, false, never>;
421
+ }
@@ -0,0 +1,10 @@
1
+ import * as i0 from "@angular/core";
2
+ import * as i1 from "./datepicker/datepicker.component";
3
+ import * as i2 from "@angular/common";
4
+ import * as i3 from "@angular/forms";
5
+ import * as i4 from "../../../pg-components/select/select.module";
6
+ export declare class MefDevDatepickerModule {
7
+ static ɵfac: i0.ɵɵFactoryDeclaration<MefDevDatepickerModule, never>;
8
+ static ɵmod: i0.ɵɵNgModuleDeclaration<MefDevDatepickerModule, [typeof i1.DatepickerComponent], [typeof i2.CommonModule, typeof i3.FormsModule, typeof i2.DatePipe, typeof i4.MefDevSelectModule], [typeof i1.DatepickerComponent]>;
9
+ static ɵinj: i0.ɵɵInjectorDeclaration<MefDevDatepickerModule>;
10
+ }
@@ -0,0 +1,2 @@
1
+ export * from './datepicker/datepicker.component';
2
+ export * from './datepicker.module';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@natec/mef-dev-ui-kit",
3
- "version": "16.2.0",
3
+ "version": "16.2.2",
4
4
  "description": "MEF.DEV UI Kit Library",
5
5
  "author": {
6
6
  "name": "NATEC"
@@ -33,8 +33,8 @@
33
33
  "peerDependencies": {
34
34
  "@angular/cdk": "^16.1.5",
35
35
  "@angular/common": "^16.1.5",
36
- "@angular/forms": "^16.1.5",
37
- "@angular/core": "^16.1.5"
36
+ "@angular/core": "^16.1.5",
37
+ "@angular/forms": "^16.1.5"
38
38
  },
39
39
  "dependencies": {
40
40
  "tslib": "^2.3.0"
package/public-api.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './lib/markup-kit/collapse/index';
2
2
  export * from './lib/markup-kit/utils/filtered-field/index';
3
3
  export * from './lib/markup-kit/utils/help-block/index';
4
+ export * from './lib/markup-kit/utils/datepicker/index';
4
5
  export * from './lib/markup-kit/card/index';
5
6
  export * from './lib/markup-kit/modals/index';
6
7
  export * from './lib/markup-kit/page-layouts/index';