@luftborn/custom-elements 2.8.3 → 2.8.5
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/demo/index.js +188 -52
- package/demo/index.min.js +187 -51
- package/demo/index.min.js.map +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepicker.d.ts +5 -0
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepicker.js +87 -33
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepicker.js.map +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepickerUtils.d.ts +2 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepickerUtils.js +97 -16
- package/dist/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepickerUtils.js.map +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js +2 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepicker.ts +97 -36
- package/src/elements/CustomFormatDateFieldElement/CustomDatepicker/CustomDatepickerUtils.ts +102 -17
- package/src/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.ts +3 -1
package/demo/index.min.js
CHANGED
|
@@ -2995,7 +2995,8 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
2995
2995
|
this.lastDayOfMonth = new Date(this.currentYear, this.currentMonth + 1, 0);
|
|
2996
2996
|
this.firstDay = this.firstDayOfMonth.getDay();
|
|
2997
2997
|
this.lastDay = this.lastDayOfMonth.getDate();
|
|
2998
|
-
this.
|
|
2998
|
+
this.language = options.language || 'en';
|
|
2999
|
+
this.months = (0, DatepickerTranslations_1.GetMonths)(this.language);
|
|
2999
3000
|
this.daysOfWeek = (0, DatepickerTranslations_1.GetWeekdays)(options.language, 'short');
|
|
3000
3001
|
this.createDatePickerElements();
|
|
3001
3002
|
this.renderCalendar();
|
|
@@ -3005,6 +3006,7 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3005
3006
|
CustomDatepicker.prototype.createDatePickerElements = function () {
|
|
3006
3007
|
var _this = this;
|
|
3007
3008
|
this.datepicker = document.createElement('div');
|
|
3009
|
+
this.datepicker.id = this.input.id + '-datepicker';
|
|
3008
3010
|
this.datepicker.classList.add('datepicker');
|
|
3009
3011
|
this.header = document.createElement('div');
|
|
3010
3012
|
this.header.classList.add('header');
|
|
@@ -3048,12 +3050,7 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3048
3050
|
today.value = 'Today';
|
|
3049
3051
|
today.onclick = function () { return _this.setDateForToday(); };
|
|
3050
3052
|
actions.appendChild(today);
|
|
3051
|
-
|
|
3052
|
-
this.input.parentElement.appendChild(this.datepicker);
|
|
3053
|
-
}
|
|
3054
|
-
else {
|
|
3055
|
-
document.body.appendChild(this.datepicker);
|
|
3056
|
-
}
|
|
3053
|
+
document.body.appendChild(this.datepicker);
|
|
3057
3054
|
this.applyStyles();
|
|
3058
3055
|
};
|
|
3059
3056
|
CustomDatepicker.prototype.applyStyles = function () {
|
|
@@ -3082,7 +3079,8 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3082
3079
|
};
|
|
3083
3080
|
CustomDatepicker.prototype.renderCalendar = function () {
|
|
3084
3081
|
var _this = this;
|
|
3085
|
-
|
|
3082
|
+
var monthName = this.months[this.currentMonth];
|
|
3083
|
+
this.monthYear.innerHTML = monthName.charAt(0).toUpperCase() + monthName.slice(1) + ' ' + this.currentYear;
|
|
3086
3084
|
this.weekdays.innerHTML = '';
|
|
3087
3085
|
for (var i = 0; i < this.daysOfWeek.length; i++) {
|
|
3088
3086
|
var span = document.createElement('span');
|
|
@@ -3127,15 +3125,7 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3127
3125
|
_this.selectedYear = _this.currentYear;
|
|
3128
3126
|
moveMonthSteps = 1;
|
|
3129
3127
|
}
|
|
3130
|
-
_this.
|
|
3131
|
-
var selectedDayElement = _this.days.querySelector('.selected-day');
|
|
3132
|
-
if (selectedDayElement) {
|
|
3133
|
-
selectedDayElement.classList.remove('selected-day');
|
|
3134
|
-
}
|
|
3135
|
-
span.classList.add('selected-day');
|
|
3136
|
-
var formattedDate = (0, CustomDatepickerUtils_1.formatDate)(_this.selectedDate, _this.dateFormat);
|
|
3137
|
-
_this.input.value = formattedDate;
|
|
3138
|
-
_this.showPicker(false);
|
|
3128
|
+
_this.setSelectedDate(moveMonthSteps, span);
|
|
3139
3129
|
};
|
|
3140
3130
|
this_1.days.appendChild(span);
|
|
3141
3131
|
};
|
|
@@ -3145,8 +3135,24 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3145
3135
|
}
|
|
3146
3136
|
this.positionPicker();
|
|
3147
3137
|
};
|
|
3138
|
+
CustomDatepicker.prototype.setSelectedDate = function (moveMonthSteps, span) {
|
|
3139
|
+
if (moveMonthSteps === void 0) { moveMonthSteps = 0; }
|
|
3140
|
+
this.selectedDate = new Date(this.selectedYear, this.selectedMonth, this.selectedDay);
|
|
3141
|
+
var selectedDayElement = this.days.querySelector('.selected-day');
|
|
3142
|
+
if (selectedDayElement) {
|
|
3143
|
+
selectedDayElement.classList.remove('selected-day');
|
|
3144
|
+
}
|
|
3145
|
+
span.classList.add('selected-day');
|
|
3146
|
+
var formattedDate = (0, CustomDatepickerUtils_1.formatDate)(this.selectedDate, this.dateFormat, this.language);
|
|
3147
|
+
this.input.value = formattedDate;
|
|
3148
|
+
this.showPicker(false);
|
|
3149
|
+
if (moveMonthSteps !== 0) {
|
|
3150
|
+
this.moveMonth(moveMonthSteps);
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3148
3153
|
CustomDatepicker.prototype.initSelectMonthYear = function () {
|
|
3149
3154
|
var _this = this;
|
|
3155
|
+
var tempCurrentYear = this.currentYear;
|
|
3150
3156
|
this.selectMonthYear.style.display = 'none';
|
|
3151
3157
|
this.selectMonthYear.style.height = '200px';
|
|
3152
3158
|
if ((0, CustomDatepickerUtils_1.isMobileDevice)()) {
|
|
@@ -3161,8 +3167,8 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3161
3167
|
span.classList.add('select-month');
|
|
3162
3168
|
monthsContainer.appendChild(span);
|
|
3163
3169
|
span.onclick = function () {
|
|
3164
|
-
|
|
3165
|
-
var moveMonthSteps = (
|
|
3170
|
+
var tempCurrentMonth = _this.months.findIndex(function (month) { return month.substring(0, 3) === span.innerHTML; });
|
|
3171
|
+
var moveMonthSteps = (tempCurrentYear - _this.currentYear) * 12 + tempCurrentMonth - _this.currentMonth;
|
|
3166
3172
|
_this.moveMonth(moveMonthSteps);
|
|
3167
3173
|
_this.hideSelectMonthYear();
|
|
3168
3174
|
};
|
|
@@ -3181,16 +3187,14 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3181
3187
|
}
|
|
3182
3188
|
}
|
|
3183
3189
|
var years = this.selectMonthYear.querySelectorAll('.year');
|
|
3184
|
-
var tempSelectedYear = this.selectedYear;
|
|
3185
3190
|
var _loop_3 = function (i) {
|
|
3186
3191
|
years[i].addEventListener('click', function () {
|
|
3187
3192
|
var year = parseInt(years[i].innerHTML);
|
|
3188
|
-
if (year ===
|
|
3193
|
+
if (year === tempCurrentYear) {
|
|
3189
3194
|
return;
|
|
3190
3195
|
}
|
|
3191
3196
|
else {
|
|
3192
|
-
|
|
3193
|
-
_this.selectedYear = year;
|
|
3197
|
+
tempCurrentYear = year;
|
|
3194
3198
|
var monthsContainers = _this.selectMonthYear.querySelectorAll('.months');
|
|
3195
3199
|
for (var i_1 = 0; i_1 < monthsContainers.length; i_1++) {
|
|
3196
3200
|
monthsContainers[i_1].remove();
|
|
@@ -3228,15 +3232,36 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3228
3232
|
CustomDatepicker.prototype.showPicker = function (showpicker) {
|
|
3229
3233
|
if (showpicker === void 0) { showpicker = true; }
|
|
3230
3234
|
if (showpicker) {
|
|
3235
|
+
this.closeOtherDatepickers();
|
|
3236
|
+
localStorage.setItem('shownDatepicker', this.datepicker.id);
|
|
3237
|
+
localStorage.setItem('focusedInput', this.input.id);
|
|
3231
3238
|
this.positionPicker();
|
|
3232
3239
|
this.datepicker.style.display = 'block';
|
|
3240
|
+
this.navigateToSelectedMonth();
|
|
3233
3241
|
}
|
|
3234
3242
|
else {
|
|
3235
3243
|
this.datepicker.style.display = 'none';
|
|
3244
|
+
this.closeOtherDatepickers();
|
|
3236
3245
|
this.hideSelectMonthYear();
|
|
3246
|
+
this.input.placeholder = this.dateFormat;
|
|
3237
3247
|
return;
|
|
3238
3248
|
}
|
|
3239
3249
|
};
|
|
3250
|
+
CustomDatepicker.prototype.closeOtherDatepickers = function () {
|
|
3251
|
+
var shownDatepickerId = localStorage.getItem('shownDatepicker');
|
|
3252
|
+
if (shownDatepickerId) {
|
|
3253
|
+
var shownDatepicker = document.getElementById(shownDatepickerId);
|
|
3254
|
+
if (shownDatepicker) {
|
|
3255
|
+
shownDatepicker.style.display = 'none';
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
localStorage.removeItem('shownDatepicker');
|
|
3259
|
+
localStorage.removeItem('focusedInput');
|
|
3260
|
+
};
|
|
3261
|
+
CustomDatepicker.prototype.navigateToSelectedMonth = function () {
|
|
3262
|
+
var moveMonthSteps = (this.selectedYear - this.currentYear) * 12 + this.selectedMonth - this.currentMonth;
|
|
3263
|
+
this.moveMonth(moveMonthSteps);
|
|
3264
|
+
};
|
|
3240
3265
|
CustomDatepicker.prototype.positionPicker = function () {
|
|
3241
3266
|
this.datepicker.style.position = 'fixed';
|
|
3242
3267
|
var datepickerHeight = 250;
|
|
@@ -3271,7 +3296,27 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3271
3296
|
}
|
|
3272
3297
|
};
|
|
3273
3298
|
CustomDatepicker.prototype.setDateForToday = function () {
|
|
3274
|
-
this.input.value = (0, CustomDatepickerUtils_1.formatDate)(this.selectedDate, this.dateFormat);
|
|
3299
|
+
this.input.value = (0, CustomDatepickerUtils_1.formatDate)(this.selectedDate, this.dateFormat, this.language);
|
|
3300
|
+
this.showPicker(false);
|
|
3301
|
+
};
|
|
3302
|
+
CustomDatepicker.prototype.setDateUsingInputValue = function () {
|
|
3303
|
+
var _this = this;
|
|
3304
|
+
var date = (0, CustomDatepickerUtils_1.convertStringToDate)(this.input.value, this.dateFormat, this.language);
|
|
3305
|
+
if (date) {
|
|
3306
|
+
this.selectedDate = date;
|
|
3307
|
+
this.selectedMonth = date.getMonth();
|
|
3308
|
+
this.selectedYear = date.getFullYear();
|
|
3309
|
+
this.selectedDay = date.getDate();
|
|
3310
|
+
this.renderCalendar();
|
|
3311
|
+
this.input.value = (0, CustomDatepickerUtils_1.formatDate)(this.selectedDate, this.dateFormat, this.language);
|
|
3312
|
+
this.input.blur();
|
|
3313
|
+
}
|
|
3314
|
+
else {
|
|
3315
|
+
this.input.value = 'Invalid Date';
|
|
3316
|
+
setTimeout(function () {
|
|
3317
|
+
_this.input.value = '';
|
|
3318
|
+
}, 300);
|
|
3319
|
+
}
|
|
3275
3320
|
this.showPicker(false);
|
|
3276
3321
|
};
|
|
3277
3322
|
CustomDatepicker.prototype.addEventListeners = function () {
|
|
@@ -3279,22 +3324,31 @@ var CustomDatepicker = /** @class */ (function () {
|
|
|
3279
3324
|
this.input.addEventListener('click', function () { return _this.showPicker(true); });
|
|
3280
3325
|
this.input.addEventListener('focus', function () { return _this.showPicker(true); });
|
|
3281
3326
|
this.input.addEventListener('change', function () {
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
_this.
|
|
3287
|
-
_this.selectedDay = date.getDate();
|
|
3288
|
-
_this.renderCalendar();
|
|
3327
|
+
_this.setDateUsingInputValue();
|
|
3328
|
+
});
|
|
3329
|
+
this.input.addEventListener('keydown', function (event) {
|
|
3330
|
+
if (event.key === 'Enter') {
|
|
3331
|
+
_this.setDateUsingInputValue();
|
|
3289
3332
|
}
|
|
3290
3333
|
});
|
|
3291
3334
|
this.otherTriggers.forEach(function (trigger) {
|
|
3292
3335
|
trigger.addEventListener('click', function () { return _this.showPicker(true); });
|
|
3293
3336
|
});
|
|
3294
3337
|
document.onclick = function (event) {
|
|
3295
|
-
var elementsToNeglect = [_this.input, _this.datepicker, _this.monthYear, _this.weekdays, _this.days, _this.header, _this.selectMonthYear];
|
|
3296
3338
|
var element = event.target;
|
|
3297
|
-
var
|
|
3339
|
+
var shownDatepicker = document.getElementById(localStorage.getItem('shownDatepicker'));
|
|
3340
|
+
if (shownDatepicker) {
|
|
3341
|
+
var elementInsideDatepicker = shownDatepicker.querySelector(element.tagName);
|
|
3342
|
+
if (elementInsideDatepicker) {
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
var elementsToNeglect = [_this.input, _this.datepicker, _this.monthYear, _this.weekdays, _this.days, _this.header, _this.selectMonthYear];
|
|
3347
|
+
var isNeglected = elementsToNeglect.includes(element)
|
|
3348
|
+
|| elementsToNeglect.includes(element.parentElement)
|
|
3349
|
+
|| (element).classList.contains('select-month')
|
|
3350
|
+
|| element === _this.parentElement
|
|
3351
|
+
|| element.tagName === 'CUSTOM-FORMAT-DATE-ELEMENT';
|
|
3298
3352
|
if (!isNeglected) {
|
|
3299
3353
|
_this.showPicker(false);
|
|
3300
3354
|
}
|
|
@@ -3313,7 +3367,8 @@ exports.CustomDatepickerStyles = "\n .datepicker {\n position: fixed;\
|
|
|
3313
3367
|
},{}],17:[function(require,module,exports){
|
|
3314
3368
|
"use strict";
|
|
3315
3369
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3316
|
-
exports.isMobileDevice = exports.formatDate = exports.supportedDateFormats = exports.defaultDateFormat = exports.daysOfWeek = exports.months = void 0;
|
|
3370
|
+
exports.convertStringToDate = exports.isMobileDevice = exports.formatDate = exports.supportedDateFormats = exports.defaultDateFormat = exports.daysOfWeek = exports.months = void 0;
|
|
3371
|
+
var DatepickerTranslations_1 = require("./DatepickerTranslations");
|
|
3317
3372
|
exports.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
|
3318
3373
|
exports.daysOfWeek = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
3319
3374
|
exports.defaultDateFormat = 'yyyy-mm-dd';
|
|
@@ -3330,24 +3385,22 @@ exports.supportedDateFormats = [
|
|
|
3330
3385
|
'mm/dd/yy',
|
|
3331
3386
|
'dd/mm/yy',
|
|
3332
3387
|
];
|
|
3333
|
-
function formatDate(date, dateFormat) {
|
|
3388
|
+
function formatDate(date, dateFormat, language) {
|
|
3389
|
+
if (language === void 0) { language = 'en'; }
|
|
3390
|
+
debugger;
|
|
3334
3391
|
var year = date.getFullYear();
|
|
3335
3392
|
var month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
3336
3393
|
var day = date.getDate().toString().padStart(2, '0');
|
|
3337
|
-
var monthName =
|
|
3338
|
-
var
|
|
3339
|
-
|
|
3340
|
-
'
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
'Month dd, yyyy': monthName + " " + day + ", " + year,
|
|
3348
|
-
'mm/dd/yy': month + "/" + day + "/" + year.toString().slice(-2),
|
|
3349
|
-
'dd/mm/yy': day + "/" + month + "/" + year.toString().slice(-2),
|
|
3350
|
-
};
|
|
3394
|
+
var monthName = (0, DatepickerTranslations_1.GetMonths)(language)[date.getMonth()];
|
|
3395
|
+
var capitalizedMonthName = monthName.charAt(0).toUpperCase() + monthName.slice(1);
|
|
3396
|
+
var dateFormats = exports.supportedDateFormats.reduce(function (acc, format) {
|
|
3397
|
+
acc[format] = format.replace('yyyy', year.toString())
|
|
3398
|
+
.replace('yy', year.toString().slice(-2))
|
|
3399
|
+
.replace('mm', month)
|
|
3400
|
+
.replace('dd', day)
|
|
3401
|
+
.replace('Month', capitalizedMonthName);
|
|
3402
|
+
return acc;
|
|
3403
|
+
}, {});
|
|
3351
3404
|
return dateFormats[dateFormat];
|
|
3352
3405
|
}
|
|
3353
3406
|
exports.formatDate = formatDate;
|
|
@@ -3355,8 +3408,90 @@ function isMobileDevice() {
|
|
|
3355
3408
|
return /Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth < 480;
|
|
3356
3409
|
}
|
|
3357
3410
|
exports.isMobileDevice = isMobileDevice;
|
|
3411
|
+
function convertStringToDate(dateString, dateFormat, language) {
|
|
3412
|
+
var _a, _b, _c;
|
|
3413
|
+
if (language === void 0) { language = 'en'; }
|
|
3414
|
+
debugger;
|
|
3415
|
+
var year, month, day;
|
|
3416
|
+
if (!validateDateString(dateString, dateFormat, language)) {
|
|
3417
|
+
return null;
|
|
3418
|
+
}
|
|
3419
|
+
var getMonthIndex = function (monthName) {
|
|
3420
|
+
var months = (0, DatepickerTranslations_1.GetMonths)(language).map(function (month) { return month.toLowerCase(); });
|
|
3421
|
+
var englishMonths = (0, DatepickerTranslations_1.GetMonths)('en').map(function (month) { return month.toLowerCase(); });
|
|
3422
|
+
var index = months.indexOf(monthName.toLowerCase());
|
|
3423
|
+
if (index === -1) {
|
|
3424
|
+
var englishMonthIndex = englishMonths.indexOf(monthName.toLowerCase());
|
|
3425
|
+
return englishMonthIndex === -1 ? NaN : englishMonthIndex;
|
|
3426
|
+
}
|
|
3427
|
+
return index + 1;
|
|
3428
|
+
};
|
|
3429
|
+
switch (dateFormat) {
|
|
3430
|
+
case 'ddmmyyyy':
|
|
3431
|
+
day = parseInt(dateString.substring(0, 2));
|
|
3432
|
+
month = parseInt(dateString.substring(2, 4));
|
|
3433
|
+
year = parseInt(dateString.substring(4, 8));
|
|
3434
|
+
break;
|
|
3435
|
+
case 'mmddyyyy':
|
|
3436
|
+
month = parseInt(dateString.substring(0, 2));
|
|
3437
|
+
day = parseInt(dateString.substring(2, 4));
|
|
3438
|
+
year = parseInt(dateString.substring(4, 8));
|
|
3439
|
+
break;
|
|
3440
|
+
case 'dd/mm/yyyy':
|
|
3441
|
+
case 'dd-mm-yyyy':
|
|
3442
|
+
_a = dateString.split(/\/|-/).map(Number), day = _a[0], month = _a[1], year = _a[2];
|
|
3443
|
+
break;
|
|
3444
|
+
case 'mm/dd/yyyy':
|
|
3445
|
+
case 'mm-dd-yyyy':
|
|
3446
|
+
_b = dateString.split(/\/|-/).map(Number), month = _b[0], day = _b[1], year = _b[2];
|
|
3447
|
+
break;
|
|
3448
|
+
case 'yyyy-mm-dd':
|
|
3449
|
+
case 'yyyy-dd-mm':
|
|
3450
|
+
_c = dateFormat === 'yyyy-mm-dd' ? dateString.split('-').map(Number) : [dateString.slice(0, 4), dateString.slice(8, 10), dateString.slice(5, 7)].map(Number), year = _c[0], month = _c[1], day = _c[2];
|
|
3451
|
+
break;
|
|
3452
|
+
case 'Month dd, yyyy':
|
|
3453
|
+
var parts = dateString.split(' ');
|
|
3454
|
+
year = parseInt(parts[2]);
|
|
3455
|
+
month = getMonthIndex(parts[0]);
|
|
3456
|
+
day = parseInt(parts[1].replace(',', ''));
|
|
3457
|
+
break;
|
|
3458
|
+
case 'mm/dd/yy':
|
|
3459
|
+
var _d = dateString.split('/'), monthSt = _d[0], daySt = _d[1], yearSt = _d[2];
|
|
3460
|
+
month = parseInt(monthSt);
|
|
3461
|
+
day = parseInt(daySt);
|
|
3462
|
+
year = parseInt(yearSt) + 2000;
|
|
3463
|
+
break;
|
|
3464
|
+
case 'dd/mm/yy':
|
|
3465
|
+
var _e = dateString.split('/'), dayStr = _e[0], monthStr = _e[1], yearStr = _e[2];
|
|
3466
|
+
day = parseInt(dayStr);
|
|
3467
|
+
month = parseInt(monthStr);
|
|
3468
|
+
year = parseInt(yearStr) + 2000;
|
|
3469
|
+
break;
|
|
3470
|
+
default:
|
|
3471
|
+
return null;
|
|
3472
|
+
}
|
|
3473
|
+
if (!isNaN(year) && !isNaN(month) && !isNaN(day)) {
|
|
3474
|
+
return new Date(year, month - 1, day);
|
|
3475
|
+
}
|
|
3476
|
+
else {
|
|
3477
|
+
return null;
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
exports.convertStringToDate = convertStringToDate;
|
|
3481
|
+
function validateDateString(dateString, dateFormat, language) {
|
|
3482
|
+
if (language === void 0) { language = 'en'; }
|
|
3483
|
+
var dateFormatsRegex = exports.supportedDateFormats.reduce(function (acc, format) {
|
|
3484
|
+
acc[format] = new RegExp("^" + format.replace('yyyy', '\\d{4}')
|
|
3485
|
+
.replace('yy', '\\d{2}')
|
|
3486
|
+
.replace('mm', '(0[1-9]|1[0-2])')
|
|
3487
|
+
.replace('dd', '(0[1-9]|[12][0-9]|3[01])')
|
|
3488
|
+
.replace('Month', (0, DatepickerTranslations_1.GetMonths)(language).join('|') + '|' + (0, DatepickerTranslations_1.GetMonths)('en').join('|')) + "$", 'i');
|
|
3489
|
+
return acc;
|
|
3490
|
+
}, {});
|
|
3491
|
+
return dateFormatsRegex[dateFormat].test(dateString);
|
|
3492
|
+
}
|
|
3358
3493
|
|
|
3359
|
-
},{}],18:[function(require,module,exports){
|
|
3494
|
+
},{"./DatepickerTranslations":18}],18:[function(require,module,exports){
|
|
3360
3495
|
"use strict";
|
|
3361
3496
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3362
3497
|
exports.GetMonths = exports.GetWeekdays = void 0;
|
|
@@ -3609,6 +3744,7 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3609
3744
|
CustomFormatDateFieldElement.prototype.initChildInputs = function () {
|
|
3610
3745
|
var _a;
|
|
3611
3746
|
this.date = _super.prototype.getChildInput.call(this, '#date-field');
|
|
3747
|
+
this.date.id = "date-field-" + Date.now();
|
|
3612
3748
|
this.pickerTrigger = this.getChildElement('#picker-trigger');
|
|
3613
3749
|
this.dateFormat = CustomDatepickerUtils_1.supportedDateFormats.includes(this.dateFormat) ? this.dateFormat : CustomDatepickerUtils_1.defaultDateFormat;
|
|
3614
3750
|
this.date.placeholder = this.dateFormat;
|
|
@@ -3657,7 +3793,7 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3657
3793
|
CustomFormatDateFieldElement = __decorate([
|
|
3658
3794
|
(0, custom_element_decorator_1.default)({
|
|
3659
3795
|
selector: 'custom-format-date-element',
|
|
3660
|
-
template: "\n\t\t<div class=\"wrapper\">\n\t\t\t<input type=\"text\" id=\"date-field\"
|
|
3796
|
+
template: "\n\t\t<div class=\"wrapper\">\n\t\t\t<input type=\"text\" id=\"date-field\" />\n\t\t\t<svg id=\"picker-trigger\" data-toggle viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"18\" rx=\"1\" fill=\"#000\"/><rect x=\"4\" y=\"8\" width=\"16\" height=\"12\" fill=\"white\"/><path d=\"M4 10H20\" stroke=\"#000\" stroke-width=\"1\"/><circle cx=\"16\" cy=\"14\" r=\"2\" fill=\"#F44336\"/><rect x=\"6\" y=\"2\" width=\"3\" height=\"4\" rx=\".5\" fill=\"#000\"/><rect x=\"15\" y=\"2\" width=\"3\" height=\"4\" rx=\".5\" fill=\"#000\"/></svg>\n\t\t</div>",
|
|
3661
3797
|
style: "\n\t\t:host{\n\t\t\twidth:100%;\n\t\t}\n\t\t* {\n\t\t\tbox-sizing: border-box;\n\t\t}\n\t\t.wrapper{\n\t\t\tdisplay:flex;\n\t\t\tposition: relative;\n\t\t}\n\t\tinput{\n\t\t\tbox-sizing: border-box;\n\t\t\twidth: 100% !important;\n\t\t\tborder: none;\n\t\t\tbackground-color: #f1f4ff;\n\t\t\tmargin: 2px;\n\t\t\tresize: none;\n\t\t}\n\t\t#date-field::after {\n\t\t\tcontent: url('path/to/datepicker-icon.png'); /* Path to your datepicker icon */\n\t\t\tcursor: pointer;\n\t\t\tright: 10px;\n\t\t}\n\t\t#picker-trigger {\n\t\t\tcursor: pointer;\n\t\t\twidth: 15px;\n\t\t\theight: 15px;\n\t\t\tposition:absolute;\n\t\t\tright: 2px;\n\t\t\ttop: 15%;\n\t\t}\n\t",
|
|
3662
3798
|
useShadow: true,
|
|
3663
3799
|
})
|