@obliczeniowo/elementary
Version:
Library made in Angular version 20
116 lines (111 loc) • 5.66 kB
JavaScript
import * as i1 from '@obliczeniowo/elementary/value-picker';
import { ValuePickerModule } from '@obliczeniowo/elementary/value-picker';
import * as i0 from '@angular/core';
import { EventEmitter, Output, Input, Component, NgModule } from '@angular/core';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
const months = new Array(12).fill(0).map((_, index) => ({
value: new Date(1970, index, 1)
}));
class MonthPickerComponent {
current;
placeholder;
/**
* disable the whole things
*/
disabled = false;
display = {
nextPrevious: true
};
picker = {};
changed = new EventEmitter();
touched = false;
onChange = (value) => { };
onTouched = () => { };
registerOnValidatorChange(fn) { this.onChange = fn; }
writeValue(set) {
this.current = set;
}
registerOnChange(onChange) {
this.onChange = onChange;
}
registerOnTouched(onTouched) {
this.onTouched = onTouched;
}
setDisabledState(disabled) {
this.disabled = disabled;
}
markAsTouched() {
if (this.disabled) {
return;
}
if (!this.touched) {
this.onTouched();
this.touched = true;
}
}
itemChanged(item) {
this.current = item.value.getMonth();
this.onChange(this.current);
this.changed.emit(this.current);
}
months = months;
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.4", type: MonthPickerComponent, isStandalone: false, selector: "obl-month-picker", inputs: { current: "current", placeholder: "placeholder", disabled: "disabled", display: "display", picker: "picker" }, outputs: { changed: "changed" }, providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: MonthPickerComponent
},
], ngImport: i0, template: "<obl-value-picker\n [items]=\"months\"\n [current]=\"(current !== undefined && months[current]) || undefined\"\n [disabled]=\"disabled\"\n [display]=\"display\"\n [picker]=\"picker\"\n [placeholder]=\"placeholder\"\n (changed)=\"itemChanged($event)\"\n>\n <ng-template let-value #valueRef>\n {{ value?.value | date : 'LLLL' }}\n </ng-template>\n <ng-template let-item #itemRef>\n {{ item?.value | date : 'LLLL' }}\n </ng-template>\n</obl-value-picker>\n", styles: [""], dependencies: [{ kind: "component", type: i1.ValuePickerComponent, selector: "obl-value-picker", inputs: ["current", "items", "disabled", "placeholder", "model", "display", "picker"], outputs: ["changed"] }, { kind: "pipe", type: i2.DatePipe, name: "date" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerComponent, decorators: [{
type: Component,
args: [{ selector: 'obl-month-picker', providers: [
{
provide: NG_VALUE_ACCESSOR,
multi: true,
useExisting: MonthPickerComponent
},
], standalone: false, template: "<obl-value-picker\n [items]=\"months\"\n [current]=\"(current !== undefined && months[current]) || undefined\"\n [disabled]=\"disabled\"\n [display]=\"display\"\n [picker]=\"picker\"\n [placeholder]=\"placeholder\"\n (changed)=\"itemChanged($event)\"\n>\n <ng-template let-value #valueRef>\n {{ value?.value | date : 'LLLL' }}\n </ng-template>\n <ng-template let-item #itemRef>\n {{ item?.value | date : 'LLLL' }}\n </ng-template>\n</obl-value-picker>\n" }]
}], propDecorators: { current: [{
type: Input
}], placeholder: [{
type: Input
}], disabled: [{
type: Input
}], display: [{
type: Input
}], picker: [{
type: Input
}], changed: [{
type: Output
}] } });
class MonthPickerModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerModule, declarations: [MonthPickerComponent], imports: [CommonModule,
ValuePickerModule], exports: [MonthPickerComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerModule, imports: [CommonModule,
ValuePickerModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: MonthPickerModule, decorators: [{
type: NgModule,
args: [{
declarations: [
MonthPickerComponent
],
imports: [
CommonModule,
ValuePickerModule
],
exports: [
MonthPickerComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { MonthPickerComponent, MonthPickerModule };
//# sourceMappingURL=obliczeniowo-elementary-month-picker.mjs.map