@luftborn/custom-elements 2.5.2 → 2.5.4
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 +11 -7
- package/demo/index.min.js +10 -6
- package/demo/index.min.js.map +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.d.ts +1 -1
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js +10 -6
- package/dist/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.ts +26 -17
|
@@ -12,5 +12,5 @@ export declare class CustomFormatDateFieldElement extends CustomInputElement {
|
|
|
12
12
|
change($event: any): void;
|
|
13
13
|
validate(): void;
|
|
14
14
|
private formatDate;
|
|
15
|
-
|
|
15
|
+
private showDatePicker;
|
|
16
16
|
}
|
|
@@ -61,10 +61,10 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
61
61
|
_this.change(null);
|
|
62
62
|
});
|
|
63
63
|
this.datepicker.addEventListener('click', function () {
|
|
64
|
-
_this.
|
|
64
|
+
_this.showDatePicker();
|
|
65
65
|
});
|
|
66
66
|
this.display.addEventListener('click', function () {
|
|
67
|
-
_this.
|
|
67
|
+
_this.showDatePicker();
|
|
68
68
|
});
|
|
69
69
|
if (this.required) {
|
|
70
70
|
this.date.setAttribute('required', '');
|
|
@@ -113,10 +113,14 @@ var CustomFormatDateFieldElement = /** @class */ (function (_super) {
|
|
|
113
113
|
};
|
|
114
114
|
return (_a = dateFormats[this.dateFormat]) !== null && _a !== void 0 ? _a : null;
|
|
115
115
|
};
|
|
116
|
-
CustomFormatDateFieldElement.prototype.
|
|
117
|
-
if (
|
|
118
|
-
this.
|
|
119
|
-
|
|
116
|
+
CustomFormatDateFieldElement.prototype.showDatePicker = function () {
|
|
117
|
+
if ((!!window.ApplePaySetupFeature || !!window.safari)) {
|
|
118
|
+
this.date.click();
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
if (this.date.showPicker) {
|
|
122
|
+
this.date.showPicker();
|
|
123
|
+
}
|
|
120
124
|
}
|
|
121
125
|
};
|
|
122
126
|
CustomFormatDateFieldElement = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomFormatDateFieldElement.js","sourceRoot":"","sources":["../../../src/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;
|
|
1
|
+
{"version":3,"file":"CustomFormatDateFieldElement.js","sourceRoot":"","sources":["../../../src/elements/CustomFormatDateFieldElement/CustomFormatDateFieldElement.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,qFAAqE;AACrE,yEAAwE;AACxE,6DAAsE;AAuDtE;IAAkD,gDAAkB;IAKnE;eACC,iBAAO;IACR,CAAC;IAED,sBAAI,+CAAK;aAAT;YACC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3B,CAAC;aAED,UAAU,KAAa;YACtB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;QAC5B,CAAC;;;OALA;IAOD,sBAAI,+CAAK;aAAT;YACC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACjC,CAAC;;;OAAA;IAED,wDAAiB,GAAjB;QACC,iBAAM,iBAAiB,WAAE,CAAC;IAC3B,CAAC;IAED,sDAAe,GAAf;QAAA,iBA8BC;QA7BA,IAAI,CAAC,IAAI,GAAG,iBAAM,aAAa,YAAC,aAAa,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,iBAAM,aAAa,YAAC,gBAAgB,CAAC,CAAC;QACrD,IAAI,CAAC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YAAY,EAAK,IAAI,SAAI,GAAG,SAAI,KAAO;YACvC,gBAAgB,EAAK,SAAS,SAAI,GAAG,UAAK,IAAM;YAChD,UAAU,EAAK,KAAK,SAAI,GAAG,SAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAG;YAC1D,UAAU,EAAK,GAAG,SAAI,KAAK,SAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAG;SAC1D,CAAA;QAED,OAAO,MAAA,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,mCAAI,IAAI,CAAC;IAC7C,CAAC;IAGO,qDAAc,GAAtB;QACC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,oBAAoB,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACvD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SAClB;aAAM;YACN,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAC;gBACxB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;aACvB;SACD;IACF,CAAC;IA3GW,4BAA4B;QAhDxC,IAAA,kCAAa,EAAC;YACd,QAAQ,EAAE,4BAA4B;YACtC,QAAQ,EAAE,qpBAKF;YACR,KAAK,EAAE,mwBAqCJ;YACH,SAAS,EAAE,IAAI;SACf,CAAC;OACW,4BAA4B,CA4GxC;IAAD,mCAAC;CAAA,AA5GD,CAAkD,uCAAkB,GA4GnE;AA5GY,oEAA4B"}
|
package/package.json
CHANGED
|
@@ -2,15 +2,20 @@ import CustomElement from '../../framework/custom-element.decorator';
|
|
|
2
2
|
import { CustomInputElement } from '../../framework/CustomInputElement';
|
|
3
3
|
import { CustomElementEventArgs } from '../../framework/CustomEvents';
|
|
4
4
|
|
|
5
|
+
declare const window: {
|
|
6
|
+
ApplePaySetupFeature: any;
|
|
7
|
+
safari: any;
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
@CustomElement({
|
|
6
11
|
selector: 'custom-format-date-element',
|
|
7
|
-
|
|
12
|
+
template: `
|
|
8
13
|
<div class="wrapper">
|
|
9
14
|
<input type="text" id="display-field" readonly />
|
|
10
15
|
<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>
|
|
11
16
|
<input type="date" id="date-field" />
|
|
12
17
|
</div>`,
|
|
13
|
-
|
|
18
|
+
style: `
|
|
14
19
|
:host{
|
|
15
20
|
width:100%;
|
|
16
21
|
}
|
|
@@ -78,20 +83,20 @@ export class CustomFormatDateFieldElement extends CustomInputElement {
|
|
|
78
83
|
|
|
79
84
|
initChildInputs() {
|
|
80
85
|
this.date = super.getChildInput('#date-field');
|
|
81
|
-
|
|
86
|
+
this.display = super.getChildInput('#display-field');
|
|
82
87
|
this.datepicker = super.getChildInput('#picker-trigger');
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
this.date.addEventListener('change', () => {
|
|
90
|
+
this.display.value = this.formatDate();
|
|
91
|
+
this.change(null);
|
|
92
|
+
});
|
|
88
93
|
|
|
89
94
|
this.datepicker.addEventListener('click', () => {
|
|
90
|
-
this.
|
|
95
|
+
this.showDatePicker();
|
|
91
96
|
});
|
|
92
97
|
|
|
93
98
|
this.display.addEventListener('click', () => {
|
|
94
|
-
this.
|
|
99
|
+
this.showDatePicker();
|
|
95
100
|
});
|
|
96
101
|
|
|
97
102
|
if (this.required) {
|
|
@@ -103,7 +108,7 @@ export class CustomFormatDateFieldElement extends CustomInputElement {
|
|
|
103
108
|
if (this.min) {
|
|
104
109
|
this.date.setAttribute('min', this.min);
|
|
105
110
|
}
|
|
106
|
-
if (this.dateFormat){
|
|
111
|
+
if (this.dateFormat) {
|
|
107
112
|
this.display.placeholder = this.dateFormat;
|
|
108
113
|
}
|
|
109
114
|
}
|
|
@@ -130,7 +135,7 @@ export class CustomFormatDateFieldElement extends CustomInputElement {
|
|
|
130
135
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
131
136
|
const day = date.getDate().toString().padStart(2, '0');
|
|
132
137
|
const monthName = date.toLocaleString('default', { month: 'long' });
|
|
133
|
-
|
|
138
|
+
|
|
134
139
|
const dateFormats = {
|
|
135
140
|
'ddmmyyyy': `${day}${month}${year}`,
|
|
136
141
|
'mmddyyyy': `${month}${day}${year}`,
|
|
@@ -148,10 +153,14 @@ export class CustomFormatDateFieldElement extends CustomInputElement {
|
|
|
148
153
|
return dateFormats[this.dateFormat] ?? null;
|
|
149
154
|
}
|
|
150
155
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
|
|
157
|
+
private showDatePicker(): void {
|
|
158
|
+
if ((!!window.ApplePaySetupFeature || !!window.safari)) {
|
|
159
|
+
this.date.click();
|
|
160
|
+
} else {
|
|
161
|
+
if (this.date.showPicker){
|
|
162
|
+
this.date.showPicker();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
157
166
|
}
|