@taiga-ui/kit
Version:
Taiga UI Angular main components kit
117 lines (112 loc) • 5.42 kB
JavaScript
import { __extends, __decorate, __param } from 'tslib';
import { Optional, Self, Inject, ChangeDetectorRef, Input, ViewChild, HostBinding, Component, ChangeDetectionStrategy, forwardRef, NgModule } from '@angular/core';
import { NgControl, FormsModule } from '@angular/forms';
import { isNativeFocused, tuiDefaultProp, TUI_FOCUSABLE_ITEM_ACCESSOR, AbstractTuiControl, TuiFocusableModule, TuiFocusedModule } from '@taiga-ui/cdk';
import { TUI_VALUE_ACCESSOR_PROVIDER, TuiMaskAccessorModule } from '@taiga-ui/core';
import { CommonModule } from '@angular/common';
var TuiInputInlineComponent = /** @class */ (function (_super) {
__extends(TuiInputInlineComponent, _super);
function TuiInputInlineComponent(control, changeDetectorRef) {
var _this = _super.call(this, control, changeDetectorRef) || this;
_this.maxLength = null;
return _this;
}
TuiInputInlineComponent_1 = TuiInputInlineComponent;
Object.defineProperty(TuiInputInlineComponent.prototype, "nativeFocusableElement", {
get: function () {
return !this.native ? null : this.native.nativeElement;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputInlineComponent.prototype, "focused", {
get: function () {
return isNativeFocused(this.nativeFocusableElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputInlineComponent.prototype, "hasValue", {
get: function () {
return this.value !== '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputInlineComponent.prototype, "maskedValue", {
get: function () {
return this.native && this.value
? this.native.nativeElement.value
: String(this.value);
},
enumerable: true,
configurable: true
});
TuiInputInlineComponent.prototype.onValueChange = function (value) {
this.updateValue(value);
};
TuiInputInlineComponent.prototype.onFocused = function (focused) {
this.updateFocused(focused);
};
TuiInputInlineComponent.prototype.getFallbackValue = function () {
return '';
};
var TuiInputInlineComponent_1;
TuiInputInlineComponent.ctorParameters = function () { return [
{ type: NgControl, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NgControl,] }] },
{ type: ChangeDetectorRef, decorators: [{ type: Inject, args: [ChangeDetectorRef,] }] }
]; };
__decorate([
Input(),
tuiDefaultProp()
], TuiInputInlineComponent.prototype, "maxLength", void 0);
__decorate([
ViewChild('native')
], TuiInputInlineComponent.prototype, "native", void 0);
__decorate([
HostBinding('attr.data-value')
], TuiInputInlineComponent.prototype, "maskedValue", null);
TuiInputInlineComponent = TuiInputInlineComponent_1 = __decorate([
Component({
selector: 'tui-input-inline',
template: "<span *ngIf=\"!hasValue\" automation-id=\"tui-input-inline__placeholder\">\n <ng-content></ng-content>\n</span>\n\n<input\n #native\n automation-id=\"tui-input-inline__native\"\n class=\"native\"\n type=\"text\"\n tuiMaskAccessor\n [attr.maxLength]=\"maxLength\"\n [id]=\"id\"\n [disabled]=\"computedDisabled\"\n [readOnly]=\"readOnly\"\n [tuiFocusable]=\"focusable\"\n [ngModel]=\"value\"\n (ngModelChange)=\"onValueChange($event)\"\n (tuiFocusedChange)=\"onFocused($event)\"\n/>\n",
changeDetection: ChangeDetectionStrategy.OnPush,
providers: [
TUI_VALUE_ACCESSOR_PROVIDER,
{
provide: TUI_FOCUSABLE_ITEM_ACCESSOR,
useExisting: forwardRef(function () { return TuiInputInlineComponent_1; }),
},
],
styles: [":host{position:relative;display:inline-block;overflow:hidden;white-space:nowrap;box-sizing:border-box}:host:before{content:attr(data-value);padding-right:.02em;visibility:hidden;white-space:pre}.native{position:absolute;top:0;left:0;background-color:transparent;padding:inherit;font:inherit;color:inherit;box-sizing:border-box;width:100%;height:100%;border-width:0;text-align:inherit;letter-spacing:inherit;text-indent:inherit;text-transform:inherit;outline:0}"]
}),
__param(0, Optional()),
__param(0, Self()),
__param(0, Inject(NgControl)),
__param(1, Inject(ChangeDetectorRef))
], TuiInputInlineComponent);
return TuiInputInlineComponent;
}(AbstractTuiControl));
var TuiInputInlineModule = /** @class */ (function () {
function TuiInputInlineModule() {
}
TuiInputInlineModule = __decorate([
NgModule({
imports: [
CommonModule,
FormsModule,
TuiFocusableModule,
TuiFocusedModule,
TuiMaskAccessorModule
],
declarations: [TuiInputInlineComponent],
exports: [TuiInputInlineComponent],
})
], TuiInputInlineModule);
return TuiInputInlineModule;
}());
/**
* Generated bundle index. Do not edit.
*/
export { TuiInputInlineComponent, TuiInputInlineModule };
//# sourceMappingURL=taiga-ui-kit-components-input-inline.js.map