@taiga-ui/kit
Version:
Taiga UI Angular main components kit
152 lines (147 loc) • 7.39 kB
JavaScript
import { __extends, __decorate, __param } from 'tslib';
import { Optional, Self, Inject, ChangeDetectorRef, Input, ViewChild, Component, forwardRef, ChangeDetectionStrategy, NgModule } from '@angular/core';
import { NgControl } from '@angular/forms';
import { TUI_FIRST_DAY, TUI_LAST_DAY, ALWAYS_FALSE_HANDLER, tuiDefaultProp, TUI_FOCUSABLE_ITEM_ACCESSOR, AbstractTuiNullableControl, TuiPreventDefaultModule } from '@taiga-ui/cdk';
import { sizeBigger, TuiTextfieldSizeDirective, TUI_TEXTFIELD_SIZE, TuiPrimitiveTextfieldComponent, TuiHostedDropdownModule, TuiPrimitiveTextfieldModule, TuiSvgModule, TuiMonthPipeModule } from '@taiga-ui/core';
import { LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER } from '@taiga-ui/kit/providers';
import { CommonModule } from '@angular/common';
import { TuiCalendarMonthModule } from '@taiga-ui/kit/components/calendar-month';
// @dynamic
var TuiInputMonthComponent = /** @class */ (function (_super) {
__extends(TuiInputMonthComponent, _super);
function TuiInputMonthComponent(control, changeDetectorRef, textfieldSize) {
var _this = _super.call(this, control, changeDetectorRef) || this;
_this.textfieldSize = textfieldSize;
_this.min = TUI_FIRST_DAY;
_this.max = TUI_LAST_DAY;
_this.disabledItemHandler = ALWAYS_FALSE_HANDLER;
_this.open = false;
return _this;
}
TuiInputMonthComponent_1 = TuiInputMonthComponent;
Object.defineProperty(TuiInputMonthComponent.prototype, "nativeFocusableElement", {
get: function () {
return this.textfield ? this.textfield.nativeFocusableElement : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputMonthComponent.prototype, "focused", {
get: function () {
return !!this.textfield && this.textfield.focused;
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputMonthComponent.prototype, "calendarIcon", {
get: function () {
return sizeBigger(this.textfieldSize.size)
? 'tuiIconCalendarLarge'
: 'tuiIconCalendar';
},
enumerable: true,
configurable: true
});
Object.defineProperty(TuiInputMonthComponent.prototype, "canOpen", {
get: function () {
return !this.computedDisabled && !this.readOnly;
},
enumerable: true,
configurable: true
});
TuiInputMonthComponent.prototype.onValueChange = function (value) {
if (value === '') {
this.updateValue(null);
}
};
TuiInputMonthComponent.prototype.onMonthClick = function (month) {
this.updateValue(month);
this.close();
};
TuiInputMonthComponent.prototype.onHovered = function (hovered) {
this.updateHovered(hovered);
};
TuiInputMonthComponent.prototype.onFocused = function (focused) {
this.updateFocused(focused);
};
TuiInputMonthComponent.prototype.onOpenChange = function (open) {
this.open = open;
};
TuiInputMonthComponent.prototype.toggle = function () {
this.open = !this.open;
};
TuiInputMonthComponent.prototype.setDisabledState = function () {
_super.prototype.setDisabledState.call(this);
this.close();
};
TuiInputMonthComponent.prototype.close = function () {
this.open = false;
};
var TuiInputMonthComponent_1;
TuiInputMonthComponent.ctorParameters = function () { return [
{ type: NgControl, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NgControl,] }] },
{ type: ChangeDetectorRef, decorators: [{ type: Inject, args: [ChangeDetectorRef,] }] },
{ type: TuiTextfieldSizeDirective, decorators: [{ type: Inject, args: [TUI_TEXTFIELD_SIZE,] }] }
]; };
__decorate([
Input(),
tuiDefaultProp()
], TuiInputMonthComponent.prototype, "min", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiInputMonthComponent.prototype, "max", void 0);
__decorate([
Input(),
tuiDefaultProp()
], TuiInputMonthComponent.prototype, "disabledItemHandler", void 0);
__decorate([
ViewChild(TuiPrimitiveTextfieldComponent)
], TuiInputMonthComponent.prototype, "textfield", void 0);
TuiInputMonthComponent = TuiInputMonthComponent_1 = __decorate([
Component({
selector: 'tui-input-month',
template: "<tui-hosted-dropdown\n class=\"hosted\"\n [canOpen]=\"canOpen\"\n [content]=\"dropdown\"\n [open]=\"open && canOpen\"\n (openChange)=\"onOpenChange($event)\"\n>\n <tui-primitive-textfield\n class=\"textfield\"\n [editable]=\"false\"\n [disabled]=\"disabled\"\n [nativeId]=\"nativeId\"\n [readOnly]=\"readOnly\"\n [iconContent]=\"calendarIcon\"\n [pseudoFocused]=\"pseudoFocused\"\n [pseudoHovered]=\"pseudoHovered\"\n [invalid]=\"computedInvalid\"\n [value]=\"value === null ? '' : (value | tuiMonth | async) + ' ' + value.formattedYear\"\n (valueChange)=\"onValueChange($event)\"\n (hoveredChange)=\"onHovered($event)\"\n (focusedChange)=\"onFocused($event)\"\n >\n <ng-content></ng-content>\n </tui-primitive-textfield>\n\n <ng-template #dropdown>\n <tui-calendar-month\n tuiPreventDefault=\"mousedown\"\n [disabledItemHandler]=\"disabledItemHandler\"\n [min]=\"min\"\n [max]=\"max\"\n [value]=\"value\"\n (monthClick)=\"onMonthClick($event)\"\n ></tui-calendar-month>\n </ng-template>\n</tui-hosted-dropdown>\n",
providers: [
{
provide: TUI_FOCUSABLE_ITEM_ACCESSOR,
useExisting: forwardRef(function () { return TuiInputMonthComponent_1; }),
},
LEFT_ALIGNED_DROPDOWN_CONTROLLER_PROVIDER,
],
changeDetection: ChangeDetectionStrategy.OnPush,
styles: [":host{display:block;border-radius:var(--tui-radius-m)}.hosted{display:block;border-radius:inherit}.textfield{border-radius:inherit}.icon{position:relative;cursor:pointer}"]
}),
__param(0, Optional()),
__param(0, Self()),
__param(0, Inject(NgControl)),
__param(1, Inject(ChangeDetectorRef)),
__param(2, Inject(TUI_TEXTFIELD_SIZE))
], TuiInputMonthComponent);
return TuiInputMonthComponent;
}(AbstractTuiNullableControl));
var TuiInputMonthModule = /** @class */ (function () {
function TuiInputMonthModule() {
}
TuiInputMonthModule = __decorate([
NgModule({
imports: [
CommonModule,
TuiCalendarMonthModule,
TuiHostedDropdownModule,
TuiPrimitiveTextfieldModule,
TuiSvgModule,
TuiPreventDefaultModule,
TuiMonthPipeModule,
],
declarations: [TuiInputMonthComponent],
exports: [TuiInputMonthComponent],
})
], TuiInputMonthModule);
return TuiInputMonthModule;
}());
/**
* Generated bundle index. Do not edit.
*/
export { TuiInputMonthComponent, TuiInputMonthModule };
//# sourceMappingURL=taiga-ui-kit-components-input-month.js.map