@zeedhi/zd-calendar-common 1.7.4 → 1.9.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.
|
@@ -221,11 +221,51 @@ class Calendar extends ComponentRender {
|
|
|
221
221
|
moved(element, event) {
|
|
222
222
|
this.callEvent('moved', { event, element, component: this });
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Filters all events that happen on a specific date
|
|
226
|
+
* @param date
|
|
227
|
+
* @returns array of events
|
|
228
|
+
*/
|
|
229
|
+
getEventsByDate(date) {
|
|
230
|
+
if (!this.calendarEvents || this.calendarEvents.length === 0) {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const targetDate = this.normalizeToDateString(date);
|
|
234
|
+
if (!targetDate)
|
|
235
|
+
return [];
|
|
236
|
+
return this.calendarEvents.filter((event) => {
|
|
237
|
+
const eventStart = event[this.eventStart];
|
|
238
|
+
const eventEnd = event[this.eventEnd];
|
|
239
|
+
if (!eventStart || !eventEnd)
|
|
240
|
+
return false;
|
|
241
|
+
const start = this.normalizeToDateString(eventStart);
|
|
242
|
+
const end = this.normalizeToDateString(eventEnd);
|
|
243
|
+
if (!start || !end) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
return start <= targetDate && end >= targetDate;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
normalizeToDateString(value) {
|
|
250
|
+
if (value instanceof Date) {
|
|
251
|
+
return value.toISOString().slice(0, 10);
|
|
252
|
+
}
|
|
253
|
+
if (typeof value === 'number') {
|
|
254
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
255
|
+
}
|
|
256
|
+
// Expecting formats like 'YYYY-MM-DD' or 'YYYY-MM-DD HH:mm:ss'.
|
|
257
|
+
// In any case, the date portion is represented by the first 10 characters.
|
|
258
|
+
if (value.length >= 10) {
|
|
259
|
+
return value.slice(0, 10);
|
|
260
|
+
}
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
224
263
|
}
|
|
225
264
|
|
|
226
265
|
Messages.add({
|
|
227
266
|
'pt-BR': {
|
|
228
267
|
translation: {
|
|
268
|
+
CALENDAR_YEAR: 'Ano',
|
|
229
269
|
CALENDAR_MONTH: 'Mês',
|
|
230
270
|
CALENDAR_DAY: 'Dia',
|
|
231
271
|
CALENDAR_WEEK: 'Semana',
|
|
@@ -238,6 +278,7 @@ Messages.add({
|
|
|
238
278
|
},
|
|
239
279
|
'en-US': {
|
|
240
280
|
translation: {
|
|
281
|
+
CALENDAR_YEAR: 'Year',
|
|
241
282
|
CALENDAR_MONTH: 'Month',
|
|
242
283
|
CALENDAR_DAY: 'Day',
|
|
243
284
|
CALENDAR_WEEK: 'Week',
|
|
@@ -250,6 +291,7 @@ Messages.add({
|
|
|
250
291
|
},
|
|
251
292
|
'es-CL': {
|
|
252
293
|
translation: {
|
|
294
|
+
CALENDAR_YEAR: 'Año',
|
|
253
295
|
CALENDAR_MONTH: 'Mes',
|
|
254
296
|
CALENDAR_DAY: 'Día',
|
|
255
297
|
CALENDAR_WEEK: 'Semana',
|
|
@@ -224,11 +224,51 @@
|
|
|
224
224
|
moved(element, event) {
|
|
225
225
|
this.callEvent('moved', { event, element, component: this });
|
|
226
226
|
}
|
|
227
|
+
/**
|
|
228
|
+
* Filters all events that happen on a specific date
|
|
229
|
+
* @param date
|
|
230
|
+
* @returns array of events
|
|
231
|
+
*/
|
|
232
|
+
getEventsByDate(date) {
|
|
233
|
+
if (!this.calendarEvents || this.calendarEvents.length === 0) {
|
|
234
|
+
return [];
|
|
235
|
+
}
|
|
236
|
+
const targetDate = this.normalizeToDateString(date);
|
|
237
|
+
if (!targetDate)
|
|
238
|
+
return [];
|
|
239
|
+
return this.calendarEvents.filter((event) => {
|
|
240
|
+
const eventStart = event[this.eventStart];
|
|
241
|
+
const eventEnd = event[this.eventEnd];
|
|
242
|
+
if (!eventStart || !eventEnd)
|
|
243
|
+
return false;
|
|
244
|
+
const start = this.normalizeToDateString(eventStart);
|
|
245
|
+
const end = this.normalizeToDateString(eventEnd);
|
|
246
|
+
if (!start || !end) {
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
return start <= targetDate && end >= targetDate;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
normalizeToDateString(value) {
|
|
253
|
+
if (value instanceof Date) {
|
|
254
|
+
return value.toISOString().slice(0, 10);
|
|
255
|
+
}
|
|
256
|
+
if (typeof value === 'number') {
|
|
257
|
+
return new Date(value).toISOString().slice(0, 10);
|
|
258
|
+
}
|
|
259
|
+
// Expecting formats like 'YYYY-MM-DD' or 'YYYY-MM-DD HH:mm:ss'.
|
|
260
|
+
// In any case, the date portion is represented by the first 10 characters.
|
|
261
|
+
if (value.length >= 10) {
|
|
262
|
+
return value.slice(0, 10);
|
|
263
|
+
}
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
227
266
|
}
|
|
228
267
|
|
|
229
268
|
core.Messages.add({
|
|
230
269
|
'pt-BR': {
|
|
231
270
|
translation: {
|
|
271
|
+
CALENDAR_YEAR: 'Ano',
|
|
232
272
|
CALENDAR_MONTH: 'Mês',
|
|
233
273
|
CALENDAR_DAY: 'Dia',
|
|
234
274
|
CALENDAR_WEEK: 'Semana',
|
|
@@ -241,6 +281,7 @@
|
|
|
241
281
|
},
|
|
242
282
|
'en-US': {
|
|
243
283
|
translation: {
|
|
284
|
+
CALENDAR_YEAR: 'Year',
|
|
244
285
|
CALENDAR_MONTH: 'Month',
|
|
245
286
|
CALENDAR_DAY: 'Day',
|
|
246
287
|
CALENDAR_WEEK: 'Week',
|
|
@@ -253,6 +294,7 @@
|
|
|
253
294
|
},
|
|
254
295
|
'es-CL': {
|
|
255
296
|
translation: {
|
|
297
|
+
CALENDAR_YEAR: 'Año',
|
|
256
298
|
CALENDAR_MONTH: 'Mes',
|
|
257
299
|
CALENDAR_DAY: 'Día',
|
|
258
300
|
CALENDAR_WEEK: 'Semana',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/zd-calendar-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Powered by Zeedhi",
|
|
5
5
|
"main": "dist/calendar-common.umd.js",
|
|
6
6
|
"module": "dist/calendar-common.esm.js",
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@zeedhi/common": "^1.57.0",
|
|
24
24
|
"@zeedhi/core": "^1.57.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "25673dad39b7ff95d94c2dbef246f4249a51e916"
|
|
27
27
|
}
|
package/types/calendar.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class Calendar extends ComponentRender implements ICalendar {
|
|
|
15
15
|
end?: string | number | Date;
|
|
16
16
|
eventCategory?: string | Function;
|
|
17
17
|
eventColor?: string | Function;
|
|
18
|
-
eventEnd
|
|
18
|
+
eventEnd: string;
|
|
19
19
|
eventHeight?: number;
|
|
20
20
|
eventMarginBottom?: number;
|
|
21
21
|
eventMore?: boolean;
|
|
@@ -23,7 +23,7 @@ export declare class Calendar extends ComponentRender implements ICalendar {
|
|
|
23
23
|
eventName?: string | Function;
|
|
24
24
|
eventOverlapMode?: string | Function;
|
|
25
25
|
eventOverlapThreshold?: string | number;
|
|
26
|
-
eventStart
|
|
26
|
+
eventStart: string;
|
|
27
27
|
eventTextColor?: string | Function;
|
|
28
28
|
eventTimed?: string | Function;
|
|
29
29
|
calendarEvents?: CalendarEvents[];
|
|
@@ -94,4 +94,11 @@ export declare class Calendar extends ComponentRender implements ICalendar {
|
|
|
94
94
|
clickTime(element: any, event: Event): void;
|
|
95
95
|
clickTimeCategory(element: any, event: Event): void;
|
|
96
96
|
moved(element: any, event: Event): void;
|
|
97
|
+
/**
|
|
98
|
+
* Filters all events that happen on a specific date
|
|
99
|
+
* @param date
|
|
100
|
+
* @returns array of events
|
|
101
|
+
*/
|
|
102
|
+
getEventsByDate(date: string | Date | number): CalendarEvents[];
|
|
103
|
+
private normalizeToDateString;
|
|
97
104
|
}
|