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.
77 lines • 3.08 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, nothing } from 'lit';
import { property } from 'lit/decorators.js';
import { addThemingController } from '../../theming/theming-controller.js';
import IgcCheckboxComponent from '../checkbox/checkbox.js';
import { addInternalsController } from '../common/controllers/internals.js';
import { registerComponent } from '../common/definitions/register.js';
import { all } from '../dropdown/themes/item.js';
import { styles as shared } from '../dropdown/themes/shared/item/dropdown-item.common.css.js';
import { styles } from './themes/combo-item.base.css.js';
class IgcComboItemComponent extends LitElement {
static register() {
registerComponent(IgcComboItemComponent, IgcCheckboxComponent);
}
constructor() {
super();
this._internals = addInternalsController(this, {
initialARIA: {
role: 'option',
ariaSelected: 'false',
},
});
this.selected = false;
this.active = false;
this.hideCheckbox = false;
addThemingController(this, all);
}
connectedCallback() {
super.connectedCallback();
this.role = 'option';
}
willUpdate(changedProperties) {
if (changedProperties.has('selected')) {
this._internals.setARIA({ ariaSelected: this.selected.toString() });
}
}
renderCheckbox() {
return html `
<section part="prefix">
<igc-checkbox
.inert=${true}
?checked=${this.selected}
exportparts="control: checkbox, indicator: checkbox-indicator, checked"
></igc-checkbox>
</section>
`;
}
render() {
return html `
${!this.hideCheckbox ? this.renderCheckbox() : nothing}
<section id="content" part="content">
<slot></slot>
</section>
`;
}
}
IgcComboItemComponent.tagName = 'igc-combo-item';
IgcComboItemComponent.styles = [styles, shared];
export default IgcComboItemComponent;
__decorate([
property({ attribute: false })
], IgcComboItemComponent.prototype, "index", void 0);
__decorate([
property({ type: Boolean, reflect: true })
], IgcComboItemComponent.prototype, "selected", void 0);
__decorate([
property({ type: Boolean, reflect: true })
], IgcComboItemComponent.prototype, "active", void 0);
__decorate([
property({ type: Boolean, attribute: 'hide-checkbox' })
], IgcComboItemComponent.prototype, "hideCheckbox", void 0);
//# sourceMappingURL=combo-item.js.map