igniteui-webcomponents
Version:
Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.
157 lines • 5.63 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { LitElement } from 'lit';
import { property, state } from 'lit/decorators.js';
import { blazorDeepImport } from '../common/decorators/blazorDeepImport.js';
import { blazorIndirectRender } from '../common/decorators/blazorIndirectRender.js';
import { watch } from '../common/decorators/watch.js';
import { first } from '../common/util.js';
import { convertToDate, convertToDates, getWeekDayNumber } from './helpers.js';
import { CalendarDay } from './model.js';
let IgcCalendarBaseComponent = class IgcCalendarBaseComponent extends LitElement {
constructor() {
super(...arguments);
this._initialActiveDateSet = false;
this._firstDayOfWeek = 0;
this._activeDate = CalendarDay.today;
this._value = null;
this._values = [];
this._specialDates = [];
this._disabledDates = [];
this.selection = 'single';
this.showWeekNumbers = false;
this.weekStart = 'sunday';
this.locale = 'en';
}
get _hasValues() {
return this._values && this._values.length > 0;
}
get _isSingle() {
return this.selection === 'single';
}
get _isMultiple() {
return this.selection === 'multiple';
}
get _isRange() {
return this.selection === 'range';
}
set value(value) {
const converted = convertToDate(value);
this._value = converted ? CalendarDay.from(converted) : null;
}
get value() {
return this._value ? this._value.native : null;
}
set values(values) {
const converted = convertToDates(values);
this._values = converted ? converted.map((v) => CalendarDay.from(v)) : [];
}
get values() {
return this._values ? this._values.map((v) => v.native) : [];
}
set activeDate(value) {
this._initialActiveDateSet = true;
const converted = convertToDate(value);
this._activeDate = converted
? CalendarDay.from(converted)
: CalendarDay.today;
}
get activeDate() {
return this._activeDate.native;
}
set specialDates(value) {
this._specialDates = value ?? [];
}
get specialDates() {
return this._specialDates.length ? this._specialDates : undefined;
}
set disabledDates(value) {
this._disabledDates = value ?? [];
}
get disabledDates() {
return this._disabledDates.length ? this._disabledDates : undefined;
}
weekStartChanged() {
this._firstDayOfWeek = getWeekDayNumber(this.weekStart);
}
selectionChanged() {
this._rangePreviewDate = undefined;
this._value = null;
this._values = [];
}
firstUpdated() {
if (this._initialActiveDateSet) {
return;
}
if (this._isSingle) {
this.activeDate = this.value ?? this.activeDate;
}
else {
this.activeDate = first(this.values) ?? this.activeDate;
}
}
};
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_rangePreviewDate", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_firstDayOfWeek", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_activeDate", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_value", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_values", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_specialDates", void 0);
__decorate([
state()
], IgcCalendarBaseComponent.prototype, "_disabledDates", void 0);
__decorate([
property({ converter: convertToDate })
], IgcCalendarBaseComponent.prototype, "value", null);
__decorate([
property({ converter: convertToDates })
], IgcCalendarBaseComponent.prototype, "values", null);
__decorate([
property({ attribute: 'active-date', converter: convertToDate })
], IgcCalendarBaseComponent.prototype, "activeDate", null);
__decorate([
property()
], IgcCalendarBaseComponent.prototype, "selection", void 0);
__decorate([
property({ type: Boolean, reflect: true, attribute: 'show-week-numbers' })
], IgcCalendarBaseComponent.prototype, "showWeekNumbers", void 0);
__decorate([
property({ attribute: 'week-start' })
], IgcCalendarBaseComponent.prototype, "weekStart", void 0);
__decorate([
property()
], IgcCalendarBaseComponent.prototype, "locale", void 0);
__decorate([
property({ attribute: false })
], IgcCalendarBaseComponent.prototype, "specialDates", null);
__decorate([
property({ attribute: false })
], IgcCalendarBaseComponent.prototype, "disabledDates", null);
__decorate([
watch('weekStart')
], IgcCalendarBaseComponent.prototype, "weekStartChanged", null);
__decorate([
watch('selection', { waitUntilFirstUpdate: true })
], IgcCalendarBaseComponent.prototype, "selectionChanged", null);
IgcCalendarBaseComponent = __decorate([
blazorIndirectRender,
blazorDeepImport
], IgcCalendarBaseComponent);
export { IgcCalendarBaseComponent };
//# sourceMappingURL=base.js.map