@luftborn/custom-elements 2.5.6 → 2.5.8
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 +37 -10
- package/demo/index.min.js +36 -9
- package/demo/index.min.js.map +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.d.ts +3 -0
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js +36 -9
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.ts +34 -9
package/demo/index.min.js
CHANGED
|
@@ -3001,7 +3001,22 @@ var CustomEvents_1 = require("../../framework/CustomEvents");
|
|
|
3001
3001
|
var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
3002
3002
|
__extends(CustomFormatDateFieldElement, _super);
|
|
3003
3003
|
function CustomFormatDateFieldElement() {
|
|
3004
|
-
|
|
3004
|
+
var _this = _super.call(this) || this;
|
|
3005
|
+
_this.defaultDateFormat = 'yyyy-mm-dd';
|
|
3006
|
+
_this.supportedDateFormats = [
|
|
3007
|
+
'ddmmyyyy',
|
|
3008
|
+
'mmddyyyy',
|
|
3009
|
+
'dd/mm/yyyy',
|
|
3010
|
+
'mm/dd/yyyy',
|
|
3011
|
+
'dd-mm-yyyy',
|
|
3012
|
+
'mm-dd-yyyy',
|
|
3013
|
+
'yyyy-mm-dd',
|
|
3014
|
+
'yyyy-dd-mm',
|
|
3015
|
+
'Month dd, yyyy',
|
|
3016
|
+
'mm/dd/yy',
|
|
3017
|
+
'dd/mm/yy',
|
|
3018
|
+
];
|
|
3019
|
+
return _this;
|
|
3005
3020
|
}
|
|
3006
3021
|
Object.defineProperty(CustomFormatDateFieldElement.prototype, "value", {
|
|
3007
3022
|
get: function () {
|
|
@@ -3032,10 +3047,7 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3032
3047
|
this.date.addEventListener('change', function () {
|
|
3033
3048
|
_this.display.value = _this.formatDate();
|
|
3034
3049
|
_this.change(null);
|
|
3035
|
-
_this.
|
|
3036
|
-
setTimeout(function () {
|
|
3037
|
-
_this.date.hidden = false;
|
|
3038
|
-
}, 0);
|
|
3050
|
+
_this.closeDatePicker();
|
|
3039
3051
|
});
|
|
3040
3052
|
this.datepicker.addEventListener('click', function () {
|
|
3041
3053
|
_this.showDatePicker();
|
|
@@ -3043,6 +3055,11 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3043
3055
|
this.display.addEventListener('click', function () {
|
|
3044
3056
|
_this.showDatePicker();
|
|
3045
3057
|
});
|
|
3058
|
+
document.addEventListener('click', function (event) {
|
|
3059
|
+
if (!_this.contains(event.target)) {
|
|
3060
|
+
_this.closeDatePicker();
|
|
3061
|
+
}
|
|
3062
|
+
});
|
|
3046
3063
|
if (this.required) {
|
|
3047
3064
|
this.date.setAttribute('required', '');
|
|
3048
3065
|
}
|
|
@@ -3052,9 +3069,13 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3052
3069
|
if (this.min) {
|
|
3053
3070
|
this.date.setAttribute('min', this.min);
|
|
3054
3071
|
}
|
|
3055
|
-
if (this.dateFormat) {
|
|
3072
|
+
if (this.dateFormat && this.supportedDateFormats.includes(this.dateFormat)) {
|
|
3056
3073
|
this.display.placeholder = this.dateFormat;
|
|
3057
3074
|
}
|
|
3075
|
+
else {
|
|
3076
|
+
this.display.placeholder = this.defaultDateFormat;
|
|
3077
|
+
this.dateFormat = this.defaultDateFormat;
|
|
3078
|
+
}
|
|
3058
3079
|
};
|
|
3059
3080
|
CustomFormatDateFieldElement.prototype.change = function ($event) {
|
|
3060
3081
|
var _a;
|
|
@@ -3069,7 +3090,6 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3069
3090
|
this.onValidate.emit(new CustomEvents_1.CustomElementEventArgs(this.value, 'validate'));
|
|
3070
3091
|
};
|
|
3071
3092
|
CustomFormatDateFieldElement.prototype.formatDate = function () {
|
|
3072
|
-
var _a;
|
|
3073
3093
|
var date = this.date.valueAsDate;
|
|
3074
3094
|
var year = date.getFullYear();
|
|
3075
3095
|
var month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
@@ -3088,7 +3108,7 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3088
3108
|
'mm/dd/yy': month + "/" + day + "/" + year.toString().slice(-2),
|
|
3089
3109
|
'dd/mm/yy': day + "/" + month + "/" + year.toString().slice(-2),
|
|
3090
3110
|
};
|
|
3091
|
-
return
|
|
3111
|
+
return dateFormats[this.dateFormat];
|
|
3092
3112
|
};
|
|
3093
3113
|
CustomFormatDateFieldElement.prototype.showDatePicker = function () {
|
|
3094
3114
|
if ((!!window.ApplePaySetupFeature || !!window.safari)) {
|
|
@@ -3100,11 +3120,18 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
3100
3120
|
}
|
|
3101
3121
|
}
|
|
3102
3122
|
};
|
|
3123
|
+
CustomFormatDateFieldElement.prototype.closeDatePicker = function () {
|
|
3124
|
+
var _this = this;
|
|
3125
|
+
this.date.hidden = true;
|
|
3126
|
+
setTimeout(function () {
|
|
3127
|
+
_this.date.hidden = false;
|
|
3128
|
+
}, 0);
|
|
3129
|
+
};
|
|
3103
3130
|
CustomFormatDateFieldElement = __decorate([
|
|
3104
3131
|
(0, custom_element_decorator_1.default)({
|
|
3105
3132
|
selector: 'custom-format-date-element',
|
|
3106
3133
|
template: "\n\t\t<div class=\"wrapper\">\n\t\t\t<input type=\"text\" id=\"display-field\" readonly />\n\t\t\t<svg id=\"picker-trigger\" 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\t<input type=\"date\" id=\"date-field\" />\n\t\t</div>",
|
|
3107
|
-
style: "\n\t\t:host{\n\t\t\twidth:100%;\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 {\n\t\t\topacity: 0;\n\t\t\tposition: absolute;\n\t\t\tz-index: -1;\n\t\t\tpointer-events: none;\n\t\t}\n\t\t#display-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
|
|
3134
|
+
style: "\n\t\t:host{\n\t\t\twidth:100%;\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 {\n\t\t\topacity: 0;\n\t\t\tposition: absolute;\n\t\t\tz-index: -1;\n\t\t\tpointer-events: none;\n\t\t}\n\t\t#display-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",
|
|
3108
3135
|
useShadow: true,
|
|
3109
3136
|
})
|
|
3110
3137
|
], CustomFormatDateFieldElement);
|