@tetacom/ng-components 1.1.6 → 1.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component/date-picker/base-picker.d.ts +9 -8
- package/component/date-picker/date-range/date-range.component.d.ts +10 -9
- package/esm2022/component/date-picker/base-picker.mjs +21 -15
- package/esm2022/component/date-picker/date-range/date-range.component.mjs +39 -28
- package/fesm2022/tetacom-ng-components.mjs +48 -31
- package/fesm2022/tetacom-ng-components.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1170,10 +1170,11 @@ class BasePicker {
|
|
|
1170
1170
|
val.splice(i, 1, value[i]);
|
|
1171
1171
|
}
|
|
1172
1172
|
this.placeholder = val.join('');
|
|
1173
|
-
this._cdr.detectChanges();
|
|
1174
1173
|
}
|
|
1175
1174
|
openChange(e) {
|
|
1176
|
-
|
|
1175
|
+
if (!e) {
|
|
1176
|
+
this.onBlur();
|
|
1177
|
+
}
|
|
1177
1178
|
this.open = e;
|
|
1178
1179
|
}
|
|
1179
1180
|
checkNull() {
|
|
@@ -1195,12 +1196,17 @@ class BasePicker {
|
|
|
1195
1196
|
this.open = false;
|
|
1196
1197
|
}
|
|
1197
1198
|
emitValue(value) {
|
|
1198
|
-
this.
|
|
1199
|
-
|
|
1200
|
-
|
|
1199
|
+
if (this.isValueChange(value)) {
|
|
1200
|
+
this.date = value;
|
|
1201
|
+
this.selectDate.emit(value);
|
|
1202
|
+
this.onChange(value);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
isValueChange(value) {
|
|
1206
|
+
return new Date(value).getTime() !== new Date(this.date).getTime();
|
|
1201
1207
|
}
|
|
1202
1208
|
checkEnter(e) {
|
|
1203
|
-
if (e.key ===
|
|
1209
|
+
if (e.key === 'Enter') {
|
|
1204
1210
|
this.inputText = e.target.value;
|
|
1205
1211
|
this.onBlur();
|
|
1206
1212
|
}
|
|
@@ -1217,15 +1223,15 @@ class BasePicker {
|
|
|
1217
1223
|
}
|
|
1218
1224
|
getDateFromStr(str, separator = '.') {
|
|
1219
1225
|
const date = str?.split(separator);
|
|
1220
|
-
const day = this.isAvailableLength(
|
|
1221
|
-
const month = this.isAvailableLength(
|
|
1222
|
-
const year = this.isAvailableLength(
|
|
1226
|
+
const day = this.isAvailableLength(date?.[0], 2) ? Number(date[0]) : null;
|
|
1227
|
+
const month = this.isAvailableLength(date?.[1], 2) ? Number(date[1]) : null;
|
|
1228
|
+
const year = this.isAvailableLength(date?.[2], 4) ? Number(date[2]) : null;
|
|
1223
1229
|
return { day, month, year };
|
|
1224
1230
|
}
|
|
1225
1231
|
getTimeFromStr(str, separator = ':') {
|
|
1226
1232
|
const time = str?.trim().split(separator);
|
|
1227
|
-
const hours = this.isAvailableLength(
|
|
1228
|
-
const mins = this.isAvailableLength(
|
|
1233
|
+
const hours = this.isAvailableLength(time?.[0], 2) ? Number(time[0]) : null;
|
|
1234
|
+
const mins = this.isAvailableLength(time?.[1], 2) ? Number(time[1]) : null;
|
|
1229
1235
|
return { hours, mins };
|
|
1230
1236
|
}
|
|
1231
1237
|
focus() {
|
|
@@ -1241,8 +1247,8 @@ class BasePicker {
|
|
|
1241
1247
|
});
|
|
1242
1248
|
}
|
|
1243
1249
|
getAvailableDate(min, max, date) {
|
|
1244
|
-
let minDate = dayjs(new Date(min)).startOf(
|
|
1245
|
-
let maxDate = dayjs(new Date(max)).endOf(
|
|
1250
|
+
let minDate = dayjs(new Date(min)).startOf('day').toDate();
|
|
1251
|
+
let maxDate = dayjs(new Date(max)).endOf('day').toDate();
|
|
1246
1252
|
if (min && minDate.getTime() >= new Date(date).getTime()) {
|
|
1247
1253
|
return new Date();
|
|
1248
1254
|
}
|
|
@@ -3215,16 +3221,15 @@ class DateRangeComponent extends BasePicker {
|
|
|
3215
3221
|
this._cdr = _cdr;
|
|
3216
3222
|
this._elementRef = _elementRef;
|
|
3217
3223
|
this.datePipe = datePipe;
|
|
3218
|
-
console.log('dateRange', datePipe);
|
|
3219
3224
|
}
|
|
3220
3225
|
changeSelectedDate(date, selectedDate) {
|
|
3221
3226
|
if (selectedDate.from) {
|
|
3222
3227
|
const from = new Date(Math.min(new Date(selectedDate.from).getTime(), date.getTime()));
|
|
3223
3228
|
const to = new Date(Math.max(new Date(selectedDate.from).getTime(), date.getTime()));
|
|
3224
3229
|
this.setDate({ from, to });
|
|
3225
|
-
this.emitValue({ from, to });
|
|
3226
3230
|
this.selectedDate.next({ from: null, to: null });
|
|
3227
3231
|
this.open = false;
|
|
3232
|
+
this._cdr.detectChanges();
|
|
3228
3233
|
}
|
|
3229
3234
|
else {
|
|
3230
3235
|
this.setDate({ from: date, to: null });
|
|
@@ -3235,12 +3240,20 @@ class DateRangeComponent extends BasePicker {
|
|
|
3235
3240
|
if (this.allowNull) {
|
|
3236
3241
|
return null;
|
|
3237
3242
|
}
|
|
3238
|
-
return this.datePipe.transform(new Date(), 'dd.MM.yyyy') +
|
|
3243
|
+
return (this.datePipe.transform(new Date(), 'dd.MM.yyyy') +
|
|
3244
|
+
' - ' +
|
|
3245
|
+
this.datePipe.transform(new Date(), 'dd.MM.yyyy'));
|
|
3239
3246
|
}
|
|
3240
3247
|
prepareInput() {
|
|
3241
|
-
let str = this.getLocaleString(this.date.from) +
|
|
3248
|
+
let str = this.getLocaleString(this.date.from) +
|
|
3249
|
+
' - ' +
|
|
3250
|
+
this.getLocaleString(this.date.to);
|
|
3242
3251
|
if (!this.date?.from) {
|
|
3243
|
-
str = this.allowNull
|
|
3252
|
+
str = this.allowNull
|
|
3253
|
+
? ''
|
|
3254
|
+
: this.getLocaleString(new Date()) +
|
|
3255
|
+
' - ' +
|
|
3256
|
+
this.getLocaleString(new Date());
|
|
3244
3257
|
}
|
|
3245
3258
|
let option = {
|
|
3246
3259
|
mode: 'dd/mm/yyyy',
|
|
@@ -3291,23 +3304,25 @@ class DateRangeComponent extends BasePicker {
|
|
|
3291
3304
|
this.changePlaceholder('');
|
|
3292
3305
|
this.selectedDate.next({
|
|
3293
3306
|
from: range?.from || null,
|
|
3294
|
-
to: range?.to || null
|
|
3307
|
+
to: range?.to || null,
|
|
3295
3308
|
});
|
|
3296
3309
|
}
|
|
3297
3310
|
else {
|
|
3298
|
-
|
|
3299
|
-
|
|
3311
|
+
const from = this.getLocaleString(range.from);
|
|
3312
|
+
const to = range.from && !range.to ? '' : this.getLocaleString(range.to);
|
|
3313
|
+
this.inputText = from + ' - ' + to;
|
|
3314
|
+
this.changePlaceholder(from + ' - ' + to);
|
|
3300
3315
|
}
|
|
3301
3316
|
}
|
|
3302
3317
|
writeValue(obj) {
|
|
3303
3318
|
if (obj?.from) {
|
|
3304
3319
|
this.date = {
|
|
3305
3320
|
from: new Date(obj.from),
|
|
3306
|
-
to: new Date(obj.to)
|
|
3321
|
+
to: new Date(obj.to),
|
|
3307
3322
|
};
|
|
3308
3323
|
this.setDate({
|
|
3309
3324
|
from: new Date(obj.from),
|
|
3310
|
-
to: new Date(obj.to)
|
|
3325
|
+
to: new Date(obj.to),
|
|
3311
3326
|
});
|
|
3312
3327
|
}
|
|
3313
3328
|
else {
|
|
@@ -3315,35 +3330,37 @@ class DateRangeComponent extends BasePicker {
|
|
|
3315
3330
|
}
|
|
3316
3331
|
this.selectedDate.next({
|
|
3317
3332
|
from: null,
|
|
3318
|
-
to: null
|
|
3333
|
+
to: null,
|
|
3319
3334
|
});
|
|
3320
3335
|
}
|
|
3336
|
+
isValueChange(value) {
|
|
3337
|
+
return !(new Date(value.from).getTime() === new Date(this.date.from).getTime() &&
|
|
3338
|
+
new Date(value.to).getTime() === new Date(this.date.to).getTime());
|
|
3339
|
+
}
|
|
3321
3340
|
registerOnChange(fn) {
|
|
3322
3341
|
this.onChange = fn;
|
|
3323
3342
|
}
|
|
3324
|
-
registerOnTouched(fn) {
|
|
3325
|
-
}
|
|
3343
|
+
registerOnTouched(fn) { }
|
|
3326
3344
|
ngOnInit() {
|
|
3327
3345
|
if (this.date?.from) {
|
|
3328
3346
|
this.setDate({
|
|
3329
3347
|
from: this.allowNull ? null : new Date(this.date?.from),
|
|
3330
|
-
to: this.allowNull ? null : new Date(this.date?.to)
|
|
3348
|
+
to: this.allowNull ? null : new Date(this.date?.to),
|
|
3331
3349
|
});
|
|
3332
3350
|
}
|
|
3333
3351
|
else {
|
|
3334
3352
|
this.setDate({
|
|
3335
3353
|
from: this.allowNull ? null : new Date(),
|
|
3336
|
-
to: this.allowNull ? null : new Date()
|
|
3354
|
+
to: this.allowNull ? null : new Date(),
|
|
3337
3355
|
});
|
|
3338
3356
|
}
|
|
3339
3357
|
this.selectedDate.next({
|
|
3340
3358
|
from: null,
|
|
3341
|
-
to: null
|
|
3359
|
+
to: null,
|
|
3342
3360
|
});
|
|
3343
3361
|
this.prepareInput();
|
|
3344
3362
|
}
|
|
3345
|
-
onChange(date) {
|
|
3346
|
-
}
|
|
3363
|
+
onChange(date) { }
|
|
3347
3364
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.4", ngImport: i0, type: DateRangeComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i1.DatePipe }], target: i0.ɵɵFactoryTarget.Component });
|
|
3348
3365
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.1.4", type: DateRangeComponent, selector: "teta-date-range", inputs: { date: "date", locale: "locale", showTime: "showTime", minDate: "minDate", maxDate: "maxDate", invalid: "invalid", disabled: "disabled", align: "align", verticalAlign: "verticalAlign", viewType: "viewType", appendToBody: "appendToBody", backdrop: "backdrop", allowNull: "allowNull" }, outputs: { selectDate: "selectDate" }, providers: [DATE_Range_CONTROL_VALUE_ACCESSOR, DatePipe], viewQueries: [{ propertyName: "input", first: true, predicate: ["input"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<teta-dropdown *ngIf=\"{selectedDate:selectedDate|async}as data\" [appendToBody]=\"appendToBody\" [backdrop]=\"backdrop\"\n [(open)]=\"open\" (openChange)=\"openChange($event)\" [viewType]=\"viewType\"\n [disabled]=\"disabled\" [verticalAlign]=\"verticalAlign\" [align]=\"align\"\n [autoCloseIgnore]=\"['esc', 'inside','enter']\">\n <div tetaDropdownHead\n [class]=\"'datepicker-head font-body-3 gap-8 datepicker_'+viewType\"\n [ngClass]=\"{'datepicker-head_invalid':invalid,'datepicker-head_disabled':disabled}\">\n <teta-input class=\"row row_auto flex\">\n <div [class]=\"'row_auto row datepicker_'+viewType\">\n <div class=\"row position-relative font-body-3 align-center\">\n <input [ngClass]=\"{'color-text-90':!disabled}\" [disabled]=\"disabled\" #input style=\"z-index: 1\"\n class=\"border-0 color-text-90\" (keydown)=\"checkEnter($event)\"\n [(ngModel)]=\"inputText\" (ngModelChange)=\"changeInput($event)\"\n [maskito]=\"maskitoOptions\">\n <div (click)=\"input.focus()\" *ngIf=\"data.selectedDate||allowNull\" class=\"position-absolute color-text-10\"\n style=\"top:-0.3px;cursor: text;user-select: none\">{{placeholder}}</div>\n </div>\n <teta-icon [name]=\"'calendar'\"></teta-icon>\n </div>\n </teta-input>\n </div>\n <div tetaDropdownContent class=\"scrollable\" (click)=\"$event.preventDefault()\">\n <ng-container *ngIf=\"open\">\n <div class=\"row\">\n <teta-range-calendar [isDateNull]=\"date===null||(date?.from===null&&date?.to===null)\" [open]=\"open\"\n [max]=\"maxDate\"\n [allowNull]=\"allowNull\"\n [min]=\"minDate\"\n (setDate)=\"changeSelectedDate($event,data.selectedDate)\"\n [selectedDate]=\"data.selectedDate\"\n [date]=\"date\"\n [viewType]=\"viewType\" [locale]=\"locale\"></teta-range-calendar>\n </div>\n </ng-container>\n </div>\n</teta-dropdown>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: DropdownComponent, selector: "teta-dropdown", exportAs: ["dropdown"] }, { kind: "directive", type: DropdownHeadDirective, selector: "[tetaDropdownHead]" }, { kind: "directive", type: DropdownContentDirective, selector: "[tetaDropdownContent]" }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i6.MaskitoDirective, selector: "[maskito]", inputs: ["maskito", "maskitoElement"] }, { kind: "directive", type: i6.MaskitoCva, selector: "input[maskito], textarea[maskito]", inputs: ["maskito"] }, { kind: "component", type: IconComponent, selector: "teta-icon", inputs: ["name", "size", "palette", "class"] }, { kind: "component", type: InputComponent, selector: "teta-input", inputs: ["label", "hint", "viewType", "horizontal", "required"] }, { kind: "component", type: RangeCalendarComponent, selector: "teta-range-calendar", inputs: ["locale", "open", "date", "viewType", "allowNull", "selectedDate", "min", "isDateNull", "max"], outputs: ["hoveredDateChange", "setDate"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3349
3366
|
}
|