UNPKG

@ngx-uk-frontend/core

Version:

Core utilities and shared functionality for ngx-uk-frontend libraries

41 lines 3.08 kB
import { Directive, inject, input } from '@angular/core'; import { CommonFormInputDirective, injectNgControl, } from '@ngx-uk-frontend/core/form-utils'; import * as i0 from "@angular/core"; /** * Core checkbox directive that provides common functionality * for checkbox components across different design systems. * * This directive handles: * - Form control integration * - Basic checkbox configuration * - Accessibility attributes * - Common checkbox functionality */ export class CheckboxDirective { // Form control integration ngControl = injectNgControl(); commonFormInput = inject(CommonFormInputDirective); // Basic checkbox configuration label = input.required(...(ngDevMode ? [{ debugName: "label" }] : [])); inputId = input.required(...(ngDevMode ? [{ debugName: "inputId" }] : [])); hint = input(...(ngDevMode ? [undefined, { debugName: "hint" }] : [])); disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled" }] : [])); checked = input(false, ...(ngDevMode ? [{ debugName: "checked" }] : [])); /** * Toggles the checkbox state between checked and unchecked. */ toggle() { if (this.ngControl.control && !this.disabled()) { this.ngControl.control.setValue(!this.ngControl.control.value); } } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: CheckboxDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.6", type: CheckboxDirective, isStandalone: true, selector: "[libCheckbox]", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, inputId: { classPropertyName: "inputId", publicName: "inputId", isSignal: true, isRequired: true, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.6", ngImport: i0, type: CheckboxDirective, decorators: [{ type: Directive, args: [{ selector: '[libCheckbox]', }] }], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: true }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], checked: [{ type: i0.Input, args: [{ isSignal: true, alias: "checked", required: false }] }] } }); //# sourceMappingURL=checkbox.directive.js.map