@progressive-development/pd-calendar 0.2.6 → 0.2.8
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/package.json +1 -1
- package/src/PdCalendar.js +27 -1
- package/src/PdCalendarCell.js +3 -11
- package/src/stories/index.stories.js +7 -0
package/package.json
CHANGED
package/src/PdCalendar.js
CHANGED
|
@@ -71,6 +71,16 @@ export class PdCalendar extends LitElement {
|
|
|
71
71
|
* @event select-date
|
|
72
72
|
*/
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Fired when mouse entered date cell, detail contains date (Date) and dateKey(string).
|
|
76
|
+
* @event mouse-enter-date
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Fired when date leaves date cell
|
|
81
|
+
* @event mouse-leave-date
|
|
82
|
+
*/
|
|
83
|
+
|
|
74
84
|
static get properties() {
|
|
75
85
|
return {
|
|
76
86
|
refDate: { type: Object },
|
|
@@ -289,6 +299,8 @@ export class PdCalendar extends LitElement {
|
|
|
289
299
|
?special="${special}"
|
|
290
300
|
numberClass="${this.numberClass}"
|
|
291
301
|
@select-date="${this._forwardEvent}"
|
|
302
|
+
@mouse-enter-date="${this._forwardEnterEvent}"
|
|
303
|
+
@mouse-leave-date="${this._forwardLeaveEvent}"
|
|
292
304
|
?today="${this.selectableDates && isToday(tmpDate)}"
|
|
293
305
|
?selected="${this.showSelection && isSelected(this.refDate, tmpDate)}"
|
|
294
306
|
></pd-calendar-cell>
|
|
@@ -423,7 +435,7 @@ export class PdCalendar extends LitElement {
|
|
|
423
435
|
|
|
424
436
|
}
|
|
425
437
|
|
|
426
|
-
// Forward Event from Calendar Cell,
|
|
438
|
+
// Forward Event from Calendar Cell, should be refactored (events not bubbles up here)
|
|
427
439
|
_forwardEvent(e) {
|
|
428
440
|
this.dispatchEvent(
|
|
429
441
|
new CustomEvent('select-date', {
|
|
@@ -431,4 +443,18 @@ export class PdCalendar extends LitElement {
|
|
|
431
443
|
})
|
|
432
444
|
);
|
|
433
445
|
}
|
|
446
|
+
|
|
447
|
+
_forwardEnterEvent(e) {
|
|
448
|
+
this.dispatchEvent(
|
|
449
|
+
new CustomEvent('mouse-enter-date', {
|
|
450
|
+
detail: e.detail
|
|
451
|
+
})
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
_forwardLeaveEvent() {
|
|
456
|
+
this.dispatchEvent(
|
|
457
|
+
new CustomEvent('mouse-leave-date')
|
|
458
|
+
);
|
|
459
|
+
}
|
|
434
460
|
}
|
package/src/PdCalendarCell.js
CHANGED
|
@@ -223,7 +223,7 @@ class PdCalendarCell extends LitElement {
|
|
|
223
223
|
_renderEmptyCell() {
|
|
224
224
|
return html`<div
|
|
225
225
|
class="cell cell-day ${this.numberClass} ${this.weekDayNumber === 6 ||
|
|
226
|
-
this.weekDayNumber === 0
|
|
226
|
+
this.weekDayNumber === 0 && !this.special
|
|
227
227
|
? 'we'
|
|
228
228
|
: ''}"
|
|
229
229
|
>
|
|
@@ -257,16 +257,13 @@ class PdCalendarCell extends LitElement {
|
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
_mouseEnter(
|
|
261
|
-
// convert back to date
|
|
260
|
+
_mouseEnter() {
|
|
262
261
|
const userSelectedDate = parse(this.key, 'YYYY-MM-DD');
|
|
263
262
|
this.dispatchEvent(
|
|
264
263
|
new CustomEvent('mouse-enter-date', {
|
|
265
264
|
detail: {
|
|
266
265
|
dateKey: this.key,
|
|
267
266
|
date: userSelectedDate,
|
|
268
|
-
bubbles: true,
|
|
269
|
-
composed: true
|
|
270
267
|
},
|
|
271
268
|
})
|
|
272
269
|
);
|
|
@@ -274,12 +271,7 @@ class PdCalendarCell extends LitElement {
|
|
|
274
271
|
|
|
275
272
|
_mouseLeave() {
|
|
276
273
|
this.dispatchEvent(
|
|
277
|
-
new CustomEvent('mouse-leave-date'
|
|
278
|
-
detail: {
|
|
279
|
-
bubbles: true,
|
|
280
|
-
composed: true
|
|
281
|
-
},
|
|
282
|
-
})
|
|
274
|
+
new CustomEvent('mouse-leave-date')
|
|
283
275
|
);
|
|
284
276
|
}
|
|
285
277
|
|
|
@@ -7,7 +7,11 @@ import { format } from 'fecha';
|
|
|
7
7
|
export default {
|
|
8
8
|
title: 'PdCalendar/Calendar',
|
|
9
9
|
component: 'pd-calendar',
|
|
10
|
+
parameters: {
|
|
11
|
+
actions: { argTypesRegex: '^on.*' },
|
|
12
|
+
},
|
|
10
13
|
argTypes: {
|
|
14
|
+
|
|
11
15
|
},
|
|
12
16
|
};
|
|
13
17
|
|
|
@@ -41,6 +45,9 @@ function CalendarSmallTemplate({ refDate, hideWeekend, width, cellHeight, prevMo
|
|
|
41
45
|
</style>
|
|
42
46
|
<pd-calendar .refDate="${refDate}" selectableDates showSelection ?hideWeekend="${hideWeekend}" class="calendar-small" prevMonthConstraint="${prevMonthConstraint}"
|
|
43
47
|
nextMonthConstraint="${nextMonthConstraint}" numberClass="center"
|
|
48
|
+
@mouse-enter-date="${(e) => {
|
|
49
|
+
console.log("Mouse Enter Event: ", e);
|
|
50
|
+
}}"
|
|
44
51
|
>
|
|
45
52
|
</pd-calendar>`;
|
|
46
53
|
}
|