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.
81 lines • 2.74 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 { LitElement, html } from 'lit';
import { property, queryAssignedNodes } from 'lit/decorators.js';
export class IgcBaseOptionLikeComponent extends LitElement {
get _contentSlotText() {
return this._content.map((node) => node.textContent).join('');
}
set active(value) {
this._active = Boolean(value);
}
get active() {
return this._active;
}
set disabled(value) {
this._disabled = Boolean(value);
this._internals.ariaDisabled = `${this._disabled}`;
}
get disabled() {
return this._disabled;
}
set selected(value) {
this._selected = Boolean(value);
this._internals.ariaSelected = `${this._selected}`;
this.active = this.selected;
}
get selected() {
return this._selected;
}
set value(value) {
this._value = value;
}
get value() {
return this._value ? this._value : this._contentSlotText;
}
constructor() {
super();
this._active = false;
this._disabled = false;
this._selected = false;
this._internals = this.attachInternals();
this._internals.role = 'option';
}
connectedCallback() {
super.connectedCallback();
this.role = 'option';
}
render() {
return html `
<section part="prefix">
<slot name="prefix"></slot>
</section>
<section part="content">
<slot></slot>
</section>
<section part="suffix">
<slot name="suffix"></slot>
</section>
`;
}
}
__decorate([
queryAssignedNodes({ flatten: true })
], IgcBaseOptionLikeComponent.prototype, "_content", void 0);
__decorate([
property({ type: Boolean, reflect: true })
], IgcBaseOptionLikeComponent.prototype, "active", null);
__decorate([
property({ type: Boolean, reflect: true })
], IgcBaseOptionLikeComponent.prototype, "disabled", null);
__decorate([
property({ type: Boolean, reflect: true })
], IgcBaseOptionLikeComponent.prototype, "selected", null);
__decorate([
property()
], IgcBaseOptionLikeComponent.prototype, "value", null);
//# sourceMappingURL=option.js.map