@progressive-development/pd-calendar 0.2.3 → 0.2.5

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "progressive development calendar web component",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "author": "PD Progressive Development",
6
- "version": "0.2.3",
6
+ "version": "0.2.5",
7
7
  "main": "index.js",
8
8
  "module": "index.js",
9
9
  "scripts": {
package/src/PdCalendar.js CHANGED
@@ -272,8 +272,9 @@ export class PdCalendar extends LitElement {
272
272
  if (!this.hideWeekend || ((day !== 6) && (day !== 0))) {
273
273
  const key = format(tmpDate, 'YYYY-MM-DD');
274
274
  // TODO => Array / Unit Thema... hier fest auf 0 zugegriffen zunächst
275
- const infoTxt = this.data[key] ? this.data[key][0].info : undefined;
276
- const special = this.data[key]
275
+
276
+ const infoTxt = this.data && this.data[key] ? this.data[key][0].info : undefined;
277
+ const special = this.data && this.data[key]
277
278
  ? this.data[key][0].special || false
278
279
  : false;
279
280
 
@@ -195,6 +195,8 @@ class PdCalendarCell extends LitElement {
195
195
  return html` <div
196
196
  @keypress="${this._selectableCellClicked}"
197
197
  @click="${this._selectableCellClicked}"
198
+ @mouseenter="${this._mouseEnter}"
199
+ @mouseleave="${this._mouseLeave}"
198
200
  data-date="${this.key}"
199
201
  class="cell cell-day ${this.numberClass} ${this.special ? 'special' : 'free'}
200
202
  ${this.weekDayNumber === 6 ||
@@ -254,6 +256,36 @@ class PdCalendarCell extends LitElement {
254
256
  );
255
257
  }
256
258
  }
259
+
260
+ _mouseEnter(e) {
261
+ const dateKey = e.target.dataset.date;
262
+ if (dateKey) {
263
+ // convert back to date
264
+ const userSelectedDate = parse(dateKey, 'YYYY-MM-DD');
265
+ this.dispatchEvent(
266
+ new CustomEvent('mouse-enter-date', {
267
+ detail: {
268
+ dateKey,
269
+ date: userSelectedDate,
270
+ bubbles: true,
271
+ composed: true
272
+ },
273
+ })
274
+ );
275
+ }
276
+ }
277
+
278
+ _mouseLeave() {
279
+ this.dispatchEvent(
280
+ new CustomEvent('mouse-leave-date', {
281
+ detail: {
282
+ bubbles: true,
283
+ composed: true
284
+ },
285
+ })
286
+ );
287
+ }
288
+
257
289
  }
258
290
 
259
291
  window.customElements.define('pd-calendar-cell', PdCalendarCell);