-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: move date-picker scrollers to light DOM (#4770)
- Loading branch information
1 parent
20c505e
commit 60a83fb
Showing
25 changed files
with
691 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/date-picker/src/vaadin-date-picker-month-scroller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2016 - 2022 Vaadin Ltd. | ||
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/ | ||
*/ | ||
import { html } from '@polymer/polymer/lib/utils/html-tag.js'; | ||
import { dateAfterXMonths } from './vaadin-date-picker-helper.js'; | ||
import { InfiniteScroller } from './vaadin-infinite-scroller.js'; | ||
|
||
const stylesTemplate = html` | ||
<style> | ||
:host { | ||
--vaadin-infinite-scroller-item-height: 270px; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
height: 100%; | ||
} | ||
</style> | ||
`; | ||
|
||
let memoizedTemplate; | ||
|
||
/** | ||
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately. | ||
* | ||
* @extends InfiniteScroller | ||
* @private | ||
*/ | ||
class DatePickerMonthScroller extends InfiniteScroller { | ||
static get is() { | ||
return 'vaadin-date-picker-month-scroller'; | ||
} | ||
|
||
static get template() { | ||
if (!memoizedTemplate) { | ||
memoizedTemplate = super.template.cloneNode(true); | ||
memoizedTemplate.content.appendChild(stylesTemplate.content.cloneNode(true)); | ||
} | ||
|
||
return memoizedTemplate; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
bufferSize: { | ||
type: Number, | ||
value: 3, | ||
}, | ||
}; | ||
} | ||
|
||
/** | ||
* @protected | ||
* @override | ||
*/ | ||
_createElement() { | ||
return document.createElement('vaadin-month-calendar'); | ||
} | ||
|
||
/** | ||
* @param {HTMLElement} element | ||
* @param {number} index | ||
* @protected | ||
* @override | ||
*/ | ||
_updateElement(element, index) { | ||
element.month = dateAfterXMonths(index); | ||
} | ||
} | ||
|
||
customElements.define(DatePickerMonthScroller.is, DatePickerMonthScroller); |
Oops, something went wrong.