ng-custom-checkbox-values
Version:
Custom checkbox values like strings or numbers other than default boolean
194 lines (186 loc) • 6.53 kB
JavaScript
import { Injectable, ɵɵdefineInjectable, Component, Directive, forwardRef, ElementRef, Renderer2, Input, HostListener, NgModule } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
/**
* @fileoverview added by tsickle
* Generated from: lib/custom-checkbox-values.service.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CustomCheckboxValuesService {
constructor() { }
}
CustomCheckboxValuesService.decorators = [
{ type: Injectable, args: [{
providedIn: 'root'
},] }
];
/** @nocollapse */
CustomCheckboxValuesService.ctorParameters = () => [];
/** @nocollapse */ CustomCheckboxValuesService.ngInjectableDef = ɵɵdefineInjectable({ factory: function CustomCheckboxValuesService_Factory() { return new CustomCheckboxValuesService(); }, token: CustomCheckboxValuesService, providedIn: "root" });
/**
* @fileoverview added by tsickle
* Generated from: lib/custom-checkbox-values.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CustomCheckboxValuesComponent {
constructor() { }
/**
* @return {?}
*/
ngOnInit() {
}
}
CustomCheckboxValuesComponent.decorators = [
{ type: Component, args: [{
selector: 'lib-CustomCheckboxValues',
template: `
<p>
custom-checkbox-values works!
</p>
`
}] }
];
/** @nocollapse */
CustomCheckboxValuesComponent.ctorParameters = () => [];
/**
* @fileoverview added by tsickle
* Generated from: lib/custom-checkbox-values.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CustomCheckboxValuesDirective {
/**
* @param {?} elementRef
* @param {?} renderer
*/
constructor(elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
this.propagateChange = (/**
* @param {?} _
* @return {?}
*/
(_) => { });
this.checkedValue = true;
this.uncheckedValue = false;
this.indeterminateValue = false;
}
/**
* @param {?} ev
* @return {?}
*/
onHostChange(ev) {
this.propagateChange(ev.target.checked ? this.checkedValue : this.uncheckedValue);
}
/**
* @param {?} obj
* @return {?}
*/
writeValue(obj) {
if (obj === this.checkedValue) {
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', true);
this.renderer.setProperty(this.elementRef.nativeElement, 'indeterminate', false);
}
else if (obj === this.indeterminateValue) {
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', false);
this.renderer.setProperty(this.elementRef.nativeElement, 'indeterminate', true);
}
else {
this.renderer.setProperty(this.elementRef.nativeElement, 'checked', false);
this.renderer.setProperty(this.elementRef.nativeElement, 'indeterminate', false);
}
}
/**
* @param {?} fn
* @return {?}
*/
registerOnChange(fn) {
this.propagateChange = fn;
}
/**
* @param {?} fn
* @return {?}
*/
registerOnTouched(fn) { }
/**
* @param {?} isDisabled
* @return {?}
*/
setDisabledState(isDisabled) { }
}
CustomCheckboxValuesDirective.decorators = [
{ type: Directive, args: [{
selector: '[customCheckboxValues]',
providers: [
{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef((/**
* @return {?}
*/
() => CustomCheckboxValuesDirective)),
multi: true
}
]
},] }
];
/** @nocollapse */
CustomCheckboxValuesDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: Renderer2 }
];
CustomCheckboxValuesDirective.propDecorators = {
customCheckboxValues: [{ type: Input }],
checkedValue: [{ type: Input }],
uncheckedValue: [{ type: Input }],
indeterminateValue: [{ type: Input }],
onHostChange: [{ type: HostListener, args: ['change', ['$event'],] }]
};
if (false) {
/**
* @type {?}
* @private
*/
CustomCheckboxValuesDirective.prototype.propagateChange;
/** @type {?} */
CustomCheckboxValuesDirective.prototype.customCheckboxValues;
/** @type {?} */
CustomCheckboxValuesDirective.prototype.checkedValue;
/** @type {?} */
CustomCheckboxValuesDirective.prototype.uncheckedValue;
/** @type {?} */
CustomCheckboxValuesDirective.prototype.indeterminateValue;
/**
* @type {?}
* @private
*/
CustomCheckboxValuesDirective.prototype.elementRef;
/**
* @type {?}
* @private
*/
CustomCheckboxValuesDirective.prototype.renderer;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/custom-checkbox-values.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class CustomCheckboxValuesModule {
}
CustomCheckboxValuesModule.decorators = [
{ type: NgModule, args: [{
declarations: [CustomCheckboxValuesComponent, CustomCheckboxValuesDirective],
imports: [],
exports: [CustomCheckboxValuesComponent, CustomCheckboxValuesDirective]
},] }
];
/**
* @fileoverview added by tsickle
* Generated from: public-api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: ng-custom-checkbox-values.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { CustomCheckboxValuesComponent, CustomCheckboxValuesDirective, CustomCheckboxValuesModule, CustomCheckboxValuesService };
//# sourceMappingURL=ng-custom-checkbox-values.js.map