igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
87 lines (85 loc) • 3.13 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { html, LitElement } from 'lit';
import { property } from 'lit/decorators.js';
import { addThemingController } from '../../theming/theming-controller.js';
import { addSlotController, setSlots } from '../common/controllers/slot.js';
import { registerComponent } from '../common/definitions/register.js';
import { partMap } from '../common/part-map.js';
import IgcNavDrawerHeaderItemComponent from './nav-drawer-header-item.js';
import IgcNavDrawerItemComponent from './nav-drawer-item.js';
import { styles } from './themes/container.base.css.js';
import { all } from './themes/container.js';
import { styles as shared } from './themes/shared/container/nav-drawer.common.css.js';
class IgcNavDrawerComponent extends LitElement {
static register() {
registerComponent(IgcNavDrawerComponent, IgcNavDrawerHeaderItemComponent, IgcNavDrawerItemComponent);
}
constructor() {
super();
this._slots = addSlotController(this, {
slots: setSlots('mini'),
});
this.position = 'start';
this.open = false;
addThemingController(this, all);
}
_waitTransitions() {
return new Promise((resolve) => {
this.renderRoot.addEventListener('transitionend', resolve, {
once: true,
});
});
}
async show() {
if (this.open) {
return false;
}
this.open = true;
await this._waitTransitions();
return true;
}
async hide() {
if (!this.open) {
return false;
}
this.open = false;
await this._waitTransitions();
return true;
}
async toggle() {
return this.open ? this.hide() : this.show();
}
render() {
return html `
<div part="overlay" =${this.hide}></div>
<div part="base" .inert=${!this.open}>
<div part="main">
<slot></slot>
</div>
</div>
<div
part=${partMap({
mini: true,
hidden: !this._slots.hasAssignedElements('mini'),
})}
>
<slot name="mini"></slot>
</div>
`;
}
}
IgcNavDrawerComponent.tagName = 'igc-nav-drawer';
IgcNavDrawerComponent.styles = [styles, shared];
export default IgcNavDrawerComponent;
__decorate([
property({ reflect: true })
], IgcNavDrawerComponent.prototype, "position", void 0);
__decorate([
property({ type: Boolean, reflect: true })
], IgcNavDrawerComponent.prototype, "open", void 0);
//# sourceMappingURL=nav-drawer.js.map