| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- import { forwardRef, Directive, Input, HostBinding, HostListener, ChangeDetectorRef, ElementRef, Optional, Renderer2, NgModule } from '@angular/core';
- import { NG_VALUE_ACCESSOR } from '@angular/forms';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- // TODO: config: activeClass - Class to apply to the checked buttons
- /** @type {?} */
- var CHECKBOX_CONTROL_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- function () { return ButtonCheckboxDirective; })),
- multi: true
- };
- /**
- * Add checkbox functionality to any element
- */
- var ButtonCheckboxDirective = /** @class */ (function () {
- function ButtonCheckboxDirective() {
- /**
- * Truthy value, will be set to ngModel
- */
- this.btnCheckboxTrue = true;
- /**
- * Falsy value, will be set to ngModel
- */
- this.btnCheckboxFalse = false;
- this.state = false;
- this.onChange = Function.prototype;
- this.onTouched = Function.prototype;
- }
- // view -> model
- // view -> model
- /**
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.onClick =
- // view -> model
- /**
- * @return {?}
- */
- function () {
- if (this.isDisabled) {
- return;
- }
- this.toggle(!this.state);
- this.onChange(this.value);
- };
- /**
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- this.toggle(this.trueValue === this.value);
- };
- Object.defineProperty(ButtonCheckboxDirective.prototype, "trueValue", {
- get: /**
- * @protected
- * @return {?}
- */
- function () {
- return typeof this.btnCheckboxTrue !== 'undefined'
- ? this.btnCheckboxTrue
- : true;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ButtonCheckboxDirective.prototype, "falseValue", {
- get: /**
- * @protected
- * @return {?}
- */
- function () {
- return typeof this.btnCheckboxFalse !== 'undefined'
- ? this.btnCheckboxFalse
- : false;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} state
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.toggle = /**
- * @param {?} state
- * @return {?}
- */
- function (state) {
- this.state = state;
- this.value = this.state ? this.trueValue : this.falseValue;
- };
- // ControlValueAccessor
- // model -> view
- // ControlValueAccessor
- // model -> view
- /**
- * @param {?} value
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.writeValue =
- // ControlValueAccessor
- // model -> view
- /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this.state = this.trueValue === value;
- this.value = value ? this.trueValue : this.falseValue;
- };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.setDisabledState = /**
- * @param {?} isDisabled
- * @return {?}
- */
- function (isDisabled) {
- this.isDisabled = isDisabled;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.registerOnChange = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onChange = fn;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonCheckboxDirective.prototype.registerOnTouched = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onTouched = fn;
- };
- ButtonCheckboxDirective.decorators = [
- { type: Directive, args: [{
- selector: '[btnCheckbox]',
- providers: [CHECKBOX_CONTROL_VALUE_ACCESSOR]
- },] }
- ];
- ButtonCheckboxDirective.propDecorators = {
- btnCheckboxTrue: [{ type: Input }],
- btnCheckboxFalse: [{ type: Input }],
- state: [{ type: HostBinding, args: ['class.active',] }, { type: HostBinding, args: ['attr.aria-pressed',] }],
- onClick: [{ type: HostListener, args: ['click',] }]
- };
- return ButtonCheckboxDirective;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var RADIO_CONTROL_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- function () { return ButtonRadioGroupDirective; })),
- multi: true
- };
- /**
- * A group of radio buttons.
- * A value of a selected button is bound to a variable specified via ngModel.
- */
- var ButtonRadioGroupDirective = /** @class */ (function () {
- function ButtonRadioGroupDirective(cdr) {
- this.cdr = cdr;
- this.onChange = Function.prototype;
- this.onTouched = Function.prototype;
- }
- Object.defineProperty(ButtonRadioGroupDirective.prototype, "value", {
- get: /**
- * @return {?}
- */
- function () {
- return this._value;
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._value = value;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} value
- * @return {?}
- */
- ButtonRadioGroupDirective.prototype.writeValue = /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this._value = value;
- this.cdr.markForCheck();
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonRadioGroupDirective.prototype.registerOnChange = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onChange = fn;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonRadioGroupDirective.prototype.registerOnTouched = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onTouched = fn;
- };
- ButtonRadioGroupDirective.decorators = [
- { type: Directive, args: [{
- selector: '[btnRadioGroup]',
- providers: [RADIO_CONTROL_VALUE_ACCESSOR]
- },] }
- ];
- /** @nocollapse */
- ButtonRadioGroupDirective.ctorParameters = function () { return [
- { type: ChangeDetectorRef }
- ]; };
- return ButtonRadioGroupDirective;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /** @type {?} */
- var RADIO_CONTROL_VALUE_ACCESSOR$1 = {
- provide: NG_VALUE_ACCESSOR,
- /* tslint:disable-next-line: no-use-before-declare */
- useExisting: forwardRef((/**
- * @return {?}
- */
- function () { return ButtonRadioDirective; })),
- multi: true
- };
- /**
- * Create radio buttons or groups of buttons.
- * A value of a selected button is bound to a variable specified via ngModel.
- */
- var ButtonRadioDirective = /** @class */ (function () {
- function ButtonRadioDirective(el, cdr, group, renderer) {
- this.el = el;
- this.cdr = cdr;
- this.group = group;
- this.renderer = renderer;
- this.onChange = Function.prototype;
- this.onTouched = Function.prototype;
- }
- Object.defineProperty(ButtonRadioDirective.prototype, "value", {
- /** Current value of radio component or group */
- get: /**
- * Current value of radio component or group
- * @return {?}
- */
- function () {
- return this.group ? this.group.value : this._value;
- },
- set: /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (this.group) {
- this.group.value = value;
- return;
- }
- this._value = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ButtonRadioDirective.prototype, "disabled", {
- /** If `true` — radio button is disabled */
- get: /**
- * If `true` — radio button is disabled
- * @return {?}
- */
- function () {
- return this._disabled;
- },
- set: /**
- * @param {?} disabled
- * @return {?}
- */
- function (disabled) {
- this._disabled = disabled;
- this.setDisabledState(disabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ButtonRadioDirective.prototype, "isActive", {
- get: /**
- * @return {?}
- */
- function () {
- return this.btnRadio === this.value;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- ButtonRadioDirective.prototype.onClick = /**
- * @return {?}
- */
- function () {
- if (this.el.nativeElement.attributes.disabled || !this.uncheckable && this.btnRadio === this.value) {
- return;
- }
- this.value = this.uncheckable && this.btnRadio === this.value ? undefined : this.btnRadio;
- this._onChange(this.value);
- };
- /**
- * @return {?}
- */
- ButtonRadioDirective.prototype.ngOnInit = /**
- * @return {?}
- */
- function () {
- this.uncheckable = typeof this.uncheckable !== 'undefined';
- };
- /**
- * @return {?}
- */
- ButtonRadioDirective.prototype.onBlur = /**
- * @return {?}
- */
- function () {
- this.onTouched();
- };
- /**
- * @param {?} value
- * @return {?}
- */
- ButtonRadioDirective.prototype._onChange = /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- if (this.group) {
- this.group.onTouched();
- this.group.onChange(value);
- return;
- }
- this.onTouched();
- this.onChange(value);
- };
- // ControlValueAccessor
- // model -> view
- // ControlValueAccessor
- // model -> view
- /**
- * @param {?} value
- * @return {?}
- */
- ButtonRadioDirective.prototype.writeValue =
- // ControlValueAccessor
- // model -> view
- /**
- * @param {?} value
- * @return {?}
- */
- function (value) {
- this.value = value;
- this.cdr.markForCheck();
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonRadioDirective.prototype.registerOnChange = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onChange = fn;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- ButtonRadioDirective.prototype.registerOnTouched = /**
- * @param {?} fn
- * @return {?}
- */
- function (fn) {
- this.onTouched = fn;
- };
- /**
- * @param {?} disabled
- * @return {?}
- */
- ButtonRadioDirective.prototype.setDisabledState = /**
- * @param {?} disabled
- * @return {?}
- */
- function (disabled) {
- if (disabled) {
- this.renderer.setAttribute(this.el.nativeElement, 'disabled', 'disabled');
- return;
- }
- this.renderer.removeAttribute(this.el.nativeElement, 'disabled');
- };
- ButtonRadioDirective.decorators = [
- { type: Directive, args: [{
- selector: '[btnRadio]',
- providers: [RADIO_CONTROL_VALUE_ACCESSOR$1]
- },] }
- ];
- /** @nocollapse */
- ButtonRadioDirective.ctorParameters = function () { return [
- { type: ElementRef },
- { type: ChangeDetectorRef },
- { type: ButtonRadioGroupDirective, decorators: [{ type: Optional }] },
- { type: Renderer2 }
- ]; };
- ButtonRadioDirective.propDecorators = {
- btnRadio: [{ type: Input }],
- uncheckable: [{ type: Input }],
- value: [{ type: Input }],
- disabled: [{ type: Input }],
- isActive: [{ type: HostBinding, args: ['class.active',] }, { type: HostBinding, args: ['attr.aria-pressed',] }],
- onClick: [{ type: HostListener, args: ['click',] }]
- };
- return ButtonRadioDirective;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var ButtonsModule = /** @class */ (function () {
- function ButtonsModule() {
- }
- /**
- * @return {?}
- */
- ButtonsModule.forRoot = /**
- * @return {?}
- */
- function () {
- return { ngModule: ButtonsModule, providers: [] };
- };
- ButtonsModule.decorators = [
- { type: NgModule, args: [{
- declarations: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective],
- exports: [ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective]
- },] }
- ];
- return ButtonsModule;
- }());
- export { ButtonCheckboxDirective, ButtonRadioDirective, ButtonRadioGroupDirective, ButtonsModule, CHECKBOX_CONTROL_VALUE_ACCESSOR as ɵa, RADIO_CONTROL_VALUE_ACCESSOR as ɵb, RADIO_CONTROL_VALUE_ACCESSOR$1 as ɵc };
- //# sourceMappingURL=ngx-bootstrap-buttons.js.map
|