1 | import { MenuSurface } from '@material/mwc-menu/mwc-menu-surface.js';
|
2 | import { appDatePickerName } from '../date-picker/constants.js';
|
3 | import { appDatePickerInputName } from '../date-picker-input/constants.js';
|
4 | import { ElementMixin } from '../mixins/element-mixin.js';
|
5 | import { baseStyling, resetShadowRoot } from '../stylings.js';
|
6 | import { DatePickerInputSurfaceStyling } from './stylings.js';
|
7 | const alwaysOpenElementSet = new Set([
|
8 | appDatePickerInputName,
|
9 | appDatePickerName,
|
10 | ]);
|
11 | export class DatePickerInputSurface extends ElementMixin(MenuSurface) {
|
12 | static { this.styles = [
|
13 | ...MenuSurface.styles,
|
14 | baseStyling,
|
15 | resetShadowRoot,
|
16 | DatePickerInputSurfaceStyling,
|
17 | ]; }
|
18 | onBodyClick(ev) {
|
19 | const elements = ev.composedPath()
|
20 | .filter(({ nodeType }) => nodeType === Node.ELEMENT_NODE);
|
21 | const shouldClose = elements.some(n => n.classList.contains('calendar-day') && !n.hasAttribute('aria-hidden')) ||
|
22 | !elements.some(n => alwaysOpenElementSet.has(n.localName));
|
23 | shouldClose && this.close();
|
24 | }
|
25 | }
|