UNPKG

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.

99 lines 3.65 kB
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 } from 'lit'; import { property, query, queryAssignedNodes, state } from 'lit/decorators.js'; import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js'; import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js'; import { EventEmitterMixin } from '../common/mixins/event-emitter.js'; import { FormAssociatedCheckboxRequiredMixin } from '../common/mixins/forms/associated-required.js'; import { createFormValueState, defaultBooleanTransformers, } from '../common/mixins/forms/form-value.js'; import { isEmpty } from '../common/util.js'; import { checkBoxValidators } from './validators.js'; let IgcCheckboxBaseComponent = class IgcCheckboxBaseComponent extends FormAssociatedCheckboxRequiredMixin(EventEmitterMixin(LitElement)) { get __validators() { return checkBoxValidators; } set value(value) { this._value = value; if (this.checked) { this._setFormValue(this._value || 'on'); } } get value() { return this._value; } set checked(value) { this._formValue.setValueAndFormState(value); this._validate(); } get checked() { return this._formValue.value; } constructor() { super(); this._kbFocus = addKeyboardFocusRing(this); this.hideLabel = false; this.labelPosition = 'after'; this._formValue = createFormValueState(this, { initialValue: false, transformers: defaultBooleanTransformers, }); } createRenderRoot() { const root = super.createRenderRoot(); this.hideLabel = isEmpty(this.label); root.addEventListener('slotchange', () => { this.hideLabel = isEmpty(this.label); }); return root; } click() { this.input.click(); } focus(options) { this.input.focus(options); } blur() { this.input.blur(); } handleClick(event) { event.stopPropagation(); this.checked = !this.checked; this.emitEvent('igcChange', { detail: { checked: this.checked, value: this.value }, }); } handleBlur() { this._kbFocus.reset(); } handleFocus() { this._dirty = true; } }; __decorate([ query('input', true) ], IgcCheckboxBaseComponent.prototype, "input", void 0); __decorate([ queryAssignedNodes({ flatten: true }) ], IgcCheckboxBaseComponent.prototype, "label", void 0); __decorate([ state() ], IgcCheckboxBaseComponent.prototype, "hideLabel", void 0); __decorate([ property() ], IgcCheckboxBaseComponent.prototype, "value", null); __decorate([ property({ type: Boolean }) ], IgcCheckboxBaseComponent.prototype, "checked", null); __decorate([ property({ reflect: true, attribute: 'label-position' }) ], IgcCheckboxBaseComponent.prototype, "labelPosition", void 0); IgcCheckboxBaseComponent = __decorate([ blazorDeepImport ], IgcCheckboxBaseComponent); export { IgcCheckboxBaseComponent }; //# sourceMappingURL=checkbox-base.js.map