@getflip/swirl-components 0.340.1 → 0.341.1
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/components.json +1 -1
- package/dist/cjs/{maska-BX2QG_K8.js → index-BOqO2Grl.js} +3593 -17
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/swirl-components.cjs.js +1 -1
- package/dist/cjs/swirl-date-input.cjs.entry.js +92 -37
- package/dist/cjs/swirl-file-viewer_8.cjs.entry.js +10 -3
- package/dist/cjs/swirl-time-input.cjs.entry.js +78 -49
- package/dist/collection/components/swirl-date-input/swirl-date-input.js +88 -33
- package/dist/collection/components/swirl-date-input/swirl-date-input.stories.js +1 -1
- package/dist/collection/components/swirl-file-viewer/viewers/swirl-file-viewer-pdf/swirl-file-viewer-pdf.js +10 -3
- package/dist/collection/components/swirl-time-input/swirl-time-input.js +77 -46
- package/dist/collection/components/swirl-time-input/swirl-time-input.stories.js +1 -1
- package/dist/components/assets/pdfjs/pdf.worker.min.mjs +4 -1
- package/dist/components/{maska.js → index3.js} +3593 -17
- package/dist/components/swirl-date-input.js +88 -33
- package/dist/components/swirl-file-viewer-pdf2.js +10 -3
- package/dist/components/swirl-time-input.js +78 -48
- package/dist/esm/{maska-CSSJQ9ZE.js → index-D3UoejeY.js} +3593 -17
- package/dist/esm/loader.js +1 -1
- package/dist/esm/swirl-components.js +1 -1
- package/dist/esm/swirl-date-input.entry.js +88 -33
- package/dist/esm/swirl-file-viewer_8.entry.js +10 -3
- package/dist/esm/swirl-time-input.entry.js +76 -47
- package/dist/swirl-components/{p-ca695458.entry.js → p-01748667.entry.js} +1 -1
- package/dist/swirl-components/p-1bbb3a4b.entry.js +1 -0
- package/dist/swirl-components/p-96441b7e.entry.js +1 -0
- package/dist/swirl-components/p-D3UoejeY.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-date-input/swirl-date-input.d.ts +2 -2
- package/dist/types/components/swirl-file-viewer/viewers/swirl-file-viewer-pdf/swirl-file-viewer-pdf.d.ts +1 -0
- package/dist/types/components/swirl-time-input/swirl-time-input.d.ts +1 -2
- package/package.json +2 -2
- package/dist/swirl-components/p-1217fdca.entry.js +0 -1
- package/dist/swirl-components/p-CSSJQ9ZE.js +0 -6
- package/dist/swirl-components/p-b96b8029.entry.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Cks2WRVX.js');
|
|
4
|
-
var index$
|
|
5
|
-
var
|
|
4
|
+
var index$2 = require('./index-DcAhLZUH.js');
|
|
5
|
+
var index$1 = require('./index-BOqO2Grl.js');
|
|
6
6
|
var mediaQuery_service = require('./media-query.service-DRPgROAV.js');
|
|
7
7
|
var utils = require('./utils-Br2wWntR.js');
|
|
8
8
|
|
|
@@ -25,29 +25,6 @@ const SwirlDateInput = class {
|
|
|
25
25
|
this.iconSize = 24;
|
|
26
26
|
this.readonly = false;
|
|
27
27
|
this.mediaQueryUnsubscribe = () => { };
|
|
28
|
-
this.onChange = (event) => {
|
|
29
|
-
const value = event.target.value;
|
|
30
|
-
if (value === "") {
|
|
31
|
-
this.value = undefined;
|
|
32
|
-
}
|
|
33
|
-
const newDate = maska.parse(value, this.format, new Date());
|
|
34
|
-
// First, escape any backslashes in the format string
|
|
35
|
-
const escapedFormat = this.format.replace(/\\/g, "\\\\");
|
|
36
|
-
// Then construct the RegExp using the escaped format string
|
|
37
|
-
const formatRegExp = new RegExp(`^${escapedFormat.replace(/[ydM]/g, "\\d")}$`);
|
|
38
|
-
if (!Boolean(value.match(formatRegExp))) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!maska.isValid(newDate)) {
|
|
42
|
-
this.invalidInput.emit(value);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const newValue = maska.format(newDate, internalDateFormat);
|
|
46
|
-
this.value = newValue;
|
|
47
|
-
};
|
|
48
|
-
this.onInput = (event) => {
|
|
49
|
-
this.onChange(event);
|
|
50
|
-
};
|
|
51
28
|
this.onClick = (event) => {
|
|
52
29
|
event.preventDefault();
|
|
53
30
|
if (this.preferredInputMode === "pick") {
|
|
@@ -71,8 +48,10 @@ const SwirlDateInput = class {
|
|
|
71
48
|
};
|
|
72
49
|
this.onPickDate = (event) => {
|
|
73
50
|
const newDateValue = event.detail;
|
|
74
|
-
const newValue =
|
|
51
|
+
const newValue = index$1.format(newDateValue, internalDateFormat);
|
|
75
52
|
this.value = newValue;
|
|
53
|
+
this.inputEl.value = index$1.format(newDateValue, this.pattern);
|
|
54
|
+
this.mask.updateValue();
|
|
76
55
|
this.setReadOnly(true);
|
|
77
56
|
this.pickerPopover.close();
|
|
78
57
|
};
|
|
@@ -101,7 +80,7 @@ const SwirlDateInput = class {
|
|
|
101
80
|
}
|
|
102
81
|
watchValue(newValue, oldValue) {
|
|
103
82
|
if (newValue !== oldValue) {
|
|
104
|
-
this.
|
|
83
|
+
this.updateValue();
|
|
105
84
|
}
|
|
106
85
|
}
|
|
107
86
|
focus() {
|
|
@@ -114,9 +93,18 @@ const SwirlDateInput = class {
|
|
|
114
93
|
}
|
|
115
94
|
handleAutoSelect(event) {
|
|
116
95
|
if (!this.autoSelect) {
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
if (event.target &&
|
|
98
|
+
event.target instanceof HTMLInputElement &&
|
|
99
|
+
event.target.setSelectionRange) {
|
|
100
|
+
event.target.setSelectionRange(0, 0);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
117
103
|
return;
|
|
118
104
|
}
|
|
119
|
-
event.target.
|
|
105
|
+
if (event.target && event.target instanceof HTMLInputElement) {
|
|
106
|
+
event.target.select();
|
|
107
|
+
}
|
|
120
108
|
}
|
|
121
109
|
setReadOnly(readOnly) {
|
|
122
110
|
if (this.preferredInputMode === "pick" && utils.isMobileViewport()) {
|
|
@@ -128,24 +116,91 @@ const SwirlDateInput = class {
|
|
|
128
116
|
}
|
|
129
117
|
setupMask() {
|
|
130
118
|
this.mask?.destroy();
|
|
131
|
-
|
|
132
|
-
|
|
119
|
+
// Due to automatic padding with 0s, we need to replace single characters with full length blocks.
|
|
120
|
+
this.pattern = this.format
|
|
121
|
+
.replace(/(?<!d)d(?!d)/g, "dd")
|
|
122
|
+
.replace(/(?<!M)M(?!M)/g, "MM")
|
|
123
|
+
.replace(/(?<!y)y(?!y)/g, "yyyy")
|
|
124
|
+
.replace(/(?<!y)yyy(?!y)/g, "yyyy");
|
|
125
|
+
if (!this.pattern) {
|
|
126
|
+
this.pattern = internalDateFormat;
|
|
127
|
+
}
|
|
128
|
+
this.mask = index$1.IMask(this.inputEl, {
|
|
129
|
+
mask: Date,
|
|
130
|
+
pattern: this.pattern.replace(/([^A-Za-z0-9])/g, "$1`"), // Add backticks to separators to prevent symbols from shifting back
|
|
131
|
+
autofix: "pad",
|
|
132
|
+
lazy: true,
|
|
133
|
+
overwrite: true,
|
|
134
|
+
eager: "append",
|
|
135
|
+
blocks: {
|
|
136
|
+
dd: {
|
|
137
|
+
mask: index$1.IMask.MaskedRange,
|
|
138
|
+
from: 1,
|
|
139
|
+
to: 31,
|
|
140
|
+
maxLength: 2,
|
|
141
|
+
},
|
|
142
|
+
MM: {
|
|
143
|
+
mask: index$1.IMask.MaskedRange,
|
|
144
|
+
from: 1,
|
|
145
|
+
to: 12,
|
|
146
|
+
maxLength: 2,
|
|
147
|
+
},
|
|
148
|
+
yy: {
|
|
149
|
+
mask: index$1.IMask.MaskedRange,
|
|
150
|
+
from: 0,
|
|
151
|
+
to: 99,
|
|
152
|
+
maxLength: 2,
|
|
153
|
+
},
|
|
154
|
+
yyyy: {
|
|
155
|
+
mask: index$1.IMask.MaskedRange,
|
|
156
|
+
from: 1000,
|
|
157
|
+
to: 9999,
|
|
158
|
+
maxLength: 4,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
// define date -> str conversion
|
|
162
|
+
format: (date) => {
|
|
163
|
+
const newDate = index$1.format(date, this.pattern);
|
|
164
|
+
if (!index$1.isValid(date)) {
|
|
165
|
+
this.invalidInput.emit(date.toString());
|
|
166
|
+
return "";
|
|
167
|
+
}
|
|
168
|
+
this.value = index$1.format(date, internalDateFormat);
|
|
169
|
+
return newDate;
|
|
170
|
+
},
|
|
171
|
+
// define str -> date conversion
|
|
172
|
+
parse: (str) => {
|
|
173
|
+
const newString = index$1.parse(str, this.pattern, new Date());
|
|
174
|
+
return newString;
|
|
175
|
+
},
|
|
133
176
|
});
|
|
177
|
+
this.updateValue();
|
|
178
|
+
}
|
|
179
|
+
updateValue() {
|
|
180
|
+
if (this.value) {
|
|
181
|
+
const dateValue = index$1.parse(this.value, internalDateFormat, new Date());
|
|
182
|
+
if (index$1.isValid(dateValue)) {
|
|
183
|
+
const formattedValue = index$1.format(dateValue, this.pattern);
|
|
184
|
+
this.mask.value = formattedValue;
|
|
185
|
+
this.valueChange.emit(this.value);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this.invalidInput.emit(this.value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
134
191
|
}
|
|
135
192
|
render() {
|
|
136
193
|
const ariaInvalid = this.invalid === true || this.invalid === false
|
|
137
194
|
? String(this.invalid)
|
|
138
195
|
: undefined;
|
|
139
|
-
const
|
|
140
|
-
?
|
|
141
|
-
: undefined;
|
|
142
|
-
const displayValue = maska.isValid(dateValue)
|
|
143
|
-
? maska.format(dateValue, this.format)
|
|
196
|
+
const newDate = Boolean(this.value)
|
|
197
|
+
? index$1.parse(this.value, internalDateFormat, new Date())
|
|
144
198
|
: undefined;
|
|
145
|
-
const
|
|
199
|
+
const dateValue = index$1.isValid(newDate) ? newDate : undefined;
|
|
200
|
+
const className = index$2.classnames("date-input", {
|
|
146
201
|
"date-input--inline": this.inline,
|
|
147
202
|
});
|
|
148
|
-
return (index.h(index.Host, { key: '
|
|
203
|
+
return (index.h(index.Host, { key: '9f3d225dc75468cdddff1c0446234abfd9ca09e0' }, index.h("div", { key: '977ea02e1a0a599f2b32e5c382210efb913d0463', class: className }, index.h("input", { key: '5da50a63dcc55d88abccb1dd51fef4d28e66a5ee', "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "date-input__input", disabled: this.disabled, readonly: this.readonly, id: this.id, inputmode: "numeric", onClick: this.onClick, onMouseDown: this.onMouseDown, onFocus: this.onFocus, onBlur: this.onBlur, placeholder: this.placeholder, ref: (el) => (this.inputEl = el), required: this.required, type: "text" }), index.h("swirl-popover-trigger", { key: '556f13ed495626e32a6436f0ab172820cd9066c7', swirlPopover: `popover-${this.id}` }, index.h("button", { key: 'e6dddc6e1cabe9c1e632dbe0f15834b0ab17fa2b', "aria-label": this.datePickerTriggerLabel, class: "date-input__date-picker-button", disabled: this.disabled, type: "button" }, index.h("swirl-icon-today", { key: 'a2ef423472b1db8429c44ad717847e600fb20cb8', size: this.iconSize })))), !this.disabled && (index.h("swirl-popover", { key: '84a3e021ac7d946171347de0e627233abc25e493', animation: "scale-in-y", class: "date-input__date-picker-popover", id: `popover-${this.id}`, label: this.datePickerLabel, placement: "bottom-end", ref: (el) => (this.pickerPopover = el) }, index.h("swirl-date-picker", { key: '7edd4e96694530a7f49bc273d8fe36961c4b9e25', disableDate: this.datePickerDisableDate, firstDayOfWeek: this.firstDayOfWeek, labels: this.labels, locale: this.locale, onValueChange: this.onPickDate, value: dateValue, startDate: dateValue })))));
|
|
149
204
|
}
|
|
150
205
|
get el() { return index.getElement(this); }
|
|
151
206
|
static get watchers() { return {
|
|
@@ -28444,7 +28444,7 @@ const SwirlFileViewerPdf = class {
|
|
|
28444
28444
|
const container = canvas.closest(".file-viewer-pdf__page");
|
|
28445
28445
|
const textContainer = container?.querySelector(".file-viewer-pdf__text-container");
|
|
28446
28446
|
this.renderingPageNumbers = [...this.renderingPageNumbers, page.pageNumber];
|
|
28447
|
-
const scale = forPrint ?
|
|
28447
|
+
const scale = forPrint ? this.getPrintScale(page) : this.getScale(page);
|
|
28448
28448
|
const outputScale = window.devicePixelRatio || 1;
|
|
28449
28449
|
const transform = outputScale !== 1 ? [outputScale, 0, 0, outputScale, 0, 0] : null;
|
|
28450
28450
|
const viewport = page.getViewport({ scale });
|
|
@@ -28582,6 +28582,13 @@ const SwirlFileViewerPdf = class {
|
|
|
28582
28582
|
}
|
|
28583
28583
|
return this.zoom;
|
|
28584
28584
|
}
|
|
28585
|
+
getPrintScale(page) {
|
|
28586
|
+
// For performance reasons we have to limit the print scale. The resulting
|
|
28587
|
+
// width of a page should not exceed 2480px in width, and 3508px in height.
|
|
28588
|
+
// This relates to the maximum resolution of an A4 page at 300 DPI, which
|
|
28589
|
+
// should be sufficient for a decent print quality.
|
|
28590
|
+
return Math.min(Math.min(2480 / page.view[2], 3508 / page.view[3]), 2);
|
|
28591
|
+
}
|
|
28585
28592
|
restoreScrollPosition() {
|
|
28586
28593
|
this.scrollContainer.scrollTop =
|
|
28587
28594
|
this.recentScrollPosition.y * this.scrollContainer?.scrollHeight;
|
|
@@ -28592,7 +28599,7 @@ const SwirlFileViewerPdf = class {
|
|
|
28592
28599
|
const showPagination = !this.error && !this.loading && this.visiblePages.length > 0;
|
|
28593
28600
|
const showSpinner = this.loading;
|
|
28594
28601
|
const className = index$1.classnames("file-viewer-pdf", `file-viewer-pdf--view-mode-${this.viewMode}`);
|
|
28595
|
-
return (index.h(index.Host, { key: '
|
|
28602
|
+
return (index.h(index.Host, { key: '2ded55b2086732d53df416af38f42482be6cc13c', class: className, exportparts: "file-viewer-pdf__pagination" }, this.error && (index.h("swirl-inline-error", { key: '24d19e9b92a95d83a72538a4a4c8130539e46bfc', class: "file-viewer-pdf__error", message: this.errorMessage })), index.h("div", { key: '36905878660cdd696960fc3c18894f86cba07252', "aria-describedby": "pagination", class: "file-viewer-pdf__pages", onScroll: this.onScroll, ref: (el) => (this.scrollContainer = el) }, this.pages.map((page) => {
|
|
28596
28603
|
const viewport = page.getViewport({
|
|
28597
28604
|
scale: this.getScale(page),
|
|
28598
28605
|
});
|
|
@@ -28606,7 +28613,7 @@ const SwirlFileViewerPdf = class {
|
|
|
28606
28613
|
width: `${width}px`,
|
|
28607
28614
|
height: `${height}px`,
|
|
28608
28615
|
}, tabIndex: 0 }, !rendered && (index.h("swirl-spinner", { class: "file-viewer-pdf__page-spinner" })), index.h("canvas", { class: "file-viewer-pdf__canvas", style: { opacity: rendered ? "1" : "0" } }), index.h("div", { class: "file-viewer-pdf__text-container" })));
|
|
28609
|
-
})), showPagination && (index.h("span", { key: '
|
|
28616
|
+
})), showPagination && (index.h("span", { key: '615531f5e13c34c842e68f492c8c0fcae9021815', class: "file-viewer-pdf__pagination", id: "pagination", part: "file-viewer-pdf__pagination" }, index.h("span", { key: '945d4421b1ea9a50b01f05ea4a0ed6a95d470264', "aria-current": "page" }, this.currentPage), " /", " ", this.doc.numPages)), showSpinner && (index.h("div", { key: 'fe0ae9b54994d4f8533d733df09e2921ccf4fd83', class: "file-viewer-pdf__spinner" }, index.h("swirl-spinner", { key: 'b923c9b716042e0b8e71552eeac25238d8037c57' })))));
|
|
28610
28617
|
}
|
|
28611
28618
|
get el() { return index.getElement(this); }
|
|
28612
28619
|
static get watchers() { return {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var index = require('./index-Cks2WRVX.js');
|
|
4
|
-
var index$
|
|
5
|
-
var
|
|
4
|
+
var index$2 = require('./index-DcAhLZUH.js');
|
|
5
|
+
var index$1 = require('./index-BOqO2Grl.js');
|
|
6
6
|
var mediaQuery_service = require('./media-query.service-DRPgROAV.js');
|
|
7
7
|
require('./utils-Br2wWntR.js');
|
|
8
8
|
|
|
@@ -19,43 +19,8 @@ const SwirlTimeInput = class {
|
|
|
19
19
|
this.placeholder = "hh:mm";
|
|
20
20
|
this.iconSize = 24;
|
|
21
21
|
this.mediaQueryUnsubscribe = () => { };
|
|
22
|
-
this.onChange = (event) => {
|
|
23
|
-
const value = event.target.value;
|
|
24
|
-
let newValue;
|
|
25
|
-
if (value === "") {
|
|
26
|
-
this.value = undefined;
|
|
27
|
-
this.valueChange.emit(undefined);
|
|
28
|
-
}
|
|
29
|
-
const newDate = maska.parse(value, this.format, new Date());
|
|
30
|
-
const formatRegExp = new RegExp(`^${this.format.replace(/[Hhms]/g, "\\d")}$`);
|
|
31
|
-
if (!Boolean(value.match(formatRegExp))) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!maska.isValid(newDate)) {
|
|
35
|
-
newValue = maska.format(new Date(), internalTimeFormat);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
newValue = maska.format(newDate, internalTimeFormat);
|
|
39
|
-
}
|
|
40
|
-
this.value = newValue;
|
|
41
|
-
this.valueChange.emit(newValue);
|
|
42
|
-
};
|
|
43
22
|
this.onBlur = (event) => {
|
|
44
23
|
this.inputBlur.emit(event);
|
|
45
|
-
const input = event.target;
|
|
46
|
-
const dateValue = maska.parse(input.value, this.format, new Date());
|
|
47
|
-
if (!maska.isValid(dateValue) && Boolean(this.value)) {
|
|
48
|
-
const currentDateValue = Boolean(this.value)
|
|
49
|
-
? maska.parse(this.value, internalTimeFormat, new Date())
|
|
50
|
-
: undefined;
|
|
51
|
-
if (!Boolean(currentDateValue) || !maska.isValid(currentDateValue)) {
|
|
52
|
-
this.value = "";
|
|
53
|
-
}
|
|
54
|
-
input.value = maska.format(currentDateValue, this.format);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.onInput = (event) => {
|
|
58
|
-
this.onChange(event);
|
|
59
24
|
};
|
|
60
25
|
this.onClick = (event) => {
|
|
61
26
|
event.preventDefault();
|
|
@@ -88,39 +53,103 @@ const SwirlTimeInput = class {
|
|
|
88
53
|
watchFormat() {
|
|
89
54
|
this.setupMask();
|
|
90
55
|
}
|
|
56
|
+
watchValue(newValue, oldValue) {
|
|
57
|
+
if (newValue !== oldValue) {
|
|
58
|
+
this.valueChange.emit(newValue);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
91
61
|
updateIconSize(smallIcon) {
|
|
92
62
|
this.iconSize = smallIcon ? 20 : 24;
|
|
93
63
|
}
|
|
94
64
|
handleAutoSelect(event) {
|
|
95
65
|
if (!this.autoSelect) {
|
|
66
|
+
setTimeout(() => {
|
|
67
|
+
if (event.target &&
|
|
68
|
+
event.target instanceof HTMLInputElement &&
|
|
69
|
+
event.target.setSelectionRange) {
|
|
70
|
+
event.target.setSelectionRange(0, 0);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
96
73
|
return;
|
|
97
74
|
}
|
|
98
|
-
event.target.
|
|
75
|
+
if (event.target && event.target instanceof HTMLInputElement) {
|
|
76
|
+
event.target.select();
|
|
77
|
+
}
|
|
99
78
|
}
|
|
100
79
|
setupMask() {
|
|
101
80
|
this.mask?.destroy();
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
// Due to automatic padding with 0s, we need to replace single characters with full length blocks.
|
|
82
|
+
const pattern = this.format
|
|
83
|
+
.replace(/(?<!H)H(?!H)/g, "HH")
|
|
84
|
+
.replace(/(?<!h)h(?!h)/g, "hh")
|
|
85
|
+
.replace(/(?<!m)m(?!m)/g, "mm")
|
|
86
|
+
.replace(/(?<!s)s(?!s)/g, "ss");
|
|
87
|
+
this.mask = index$1.IMask(this.inputEl, {
|
|
88
|
+
mask: Date,
|
|
89
|
+
pattern: pattern.replace(/([^A-Za-z0-9])/g, "$1`"), // Add backticks to separators to prevent symbols from shifting back
|
|
90
|
+
autofix: "pad",
|
|
91
|
+
lazy: true,
|
|
92
|
+
overwrite: true,
|
|
93
|
+
eager: "append",
|
|
94
|
+
blocks: {
|
|
95
|
+
HH: {
|
|
96
|
+
mask: index$1.IMask.MaskedRange,
|
|
97
|
+
from: 0,
|
|
98
|
+
to: 23,
|
|
99
|
+
maxLength: 2,
|
|
100
|
+
},
|
|
101
|
+
hh: {
|
|
102
|
+
mask: index$1.IMask.MaskedRange,
|
|
103
|
+
from: 1,
|
|
104
|
+
to: 12,
|
|
105
|
+
maxLength: 2,
|
|
106
|
+
},
|
|
107
|
+
mm: {
|
|
108
|
+
mask: index$1.IMask.MaskedRange,
|
|
109
|
+
from: 0,
|
|
110
|
+
to: 59,
|
|
111
|
+
maxLength: 2,
|
|
112
|
+
},
|
|
113
|
+
ss: {
|
|
114
|
+
mask: index$1.IMask.MaskedRange,
|
|
115
|
+
from: 0,
|
|
116
|
+
to: 59,
|
|
117
|
+
maxLength: 2,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
format: (date) => {
|
|
121
|
+
if (!index$1.isValid(date)) {
|
|
122
|
+
return "";
|
|
123
|
+
}
|
|
124
|
+
this.value = index$1.format(date, internalTimeFormat);
|
|
125
|
+
return index$1.format(date, pattern);
|
|
126
|
+
},
|
|
127
|
+
parse: (str) => {
|
|
128
|
+
return index$1.parse(str, pattern, new Date());
|
|
129
|
+
},
|
|
104
130
|
});
|
|
131
|
+
// Set the initial value if it exists
|
|
132
|
+
if (this.value) {
|
|
133
|
+
const dateValue = index$1.parse(this.value, internalTimeFormat, new Date());
|
|
134
|
+
if (index$1.isValid(dateValue)) {
|
|
135
|
+
const formattedValue = index$1.format(dateValue, pattern);
|
|
136
|
+
this.mask.value = formattedValue;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
105
139
|
}
|
|
106
140
|
render() {
|
|
107
141
|
const ariaInvalid = this.invalid === true || this.invalid === false
|
|
108
142
|
? String(this.invalid)
|
|
109
143
|
: undefined;
|
|
110
|
-
const
|
|
111
|
-
? maska.parse(this.value, internalTimeFormat, new Date())
|
|
112
|
-
: undefined;
|
|
113
|
-
const displayValue = maska.isValid(dateValue)
|
|
114
|
-
? maska.format(dateValue, this.format)
|
|
115
|
-
: undefined;
|
|
116
|
-
const className = index$1.classnames("time-input", {
|
|
144
|
+
const className = index$2.classnames("time-input", {
|
|
117
145
|
"time-input--inline": this.inline,
|
|
118
146
|
});
|
|
119
|
-
return (index.h(index.Host, { key: '
|
|
147
|
+
return (index.h(index.Host, { key: '8947322735a4ce58217aff86dcc3b5132905b82a' }, index.h("div", { key: '1368952e9638f3337d3b67b3ce6a22ce9c736dfd', class: className }, index.h("input", { key: '23299e8dce3200618853f2bc319fdfc741f215e1', "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "time-input__input", disabled: this.disabled, id: this.id, inputmode: "numeric", onBlur: this.onBlur, onClick: this.onClick, onFocus: this.onFocus, placeholder: this.placeholder, ref: (el) => (this.inputEl = el), required: this.required, type: "text" }), index.h("span", { key: 'd793539f7f1b7027a97d02649f1f89a5251ceb33', class: "time-input__icon" }, index.h("swirl-icon-time-outlined", { key: '3fe2d103178eb908b82fa0fed4918253de760618', size: this.iconSize })))));
|
|
120
148
|
}
|
|
121
149
|
get el() { return index.getElement(this); }
|
|
122
150
|
static get watchers() { return {
|
|
123
|
-
"format": ["watchFormat"]
|
|
151
|
+
"format": ["watchFormat"],
|
|
152
|
+
"value": ["watchValue"]
|
|
124
153
|
}; }
|
|
125
154
|
};
|
|
126
155
|
SwirlTimeInput.style = swirlTimeInputCss;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { h, Host, } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
import { format, isValid, parse } from "date-fns";
|
|
4
|
-
import
|
|
4
|
+
import IMask from "imask";
|
|
5
5
|
import { DesktopMediaQuery } from "../../services/media-query.service";
|
|
6
6
|
import { isMobileViewport } from "../../utils";
|
|
7
7
|
const internalDateFormat = "yyyy-MM-dd";
|
|
@@ -18,29 +18,6 @@ export class SwirlDateInput {
|
|
|
18
18
|
this.iconSize = 24;
|
|
19
19
|
this.readonly = false;
|
|
20
20
|
this.mediaQueryUnsubscribe = () => { };
|
|
21
|
-
this.onChange = (event) => {
|
|
22
|
-
const value = event.target.value;
|
|
23
|
-
if (value === "") {
|
|
24
|
-
this.value = undefined;
|
|
25
|
-
}
|
|
26
|
-
const newDate = parse(value, this.format, new Date());
|
|
27
|
-
// First, escape any backslashes in the format string
|
|
28
|
-
const escapedFormat = this.format.replace(/\\/g, "\\\\");
|
|
29
|
-
// Then construct the RegExp using the escaped format string
|
|
30
|
-
const formatRegExp = new RegExp(`^${escapedFormat.replace(/[ydM]/g, "\\d")}$`);
|
|
31
|
-
if (!Boolean(value.match(formatRegExp))) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
if (!isValid(newDate)) {
|
|
35
|
-
this.invalidInput.emit(value);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const newValue = format(newDate, internalDateFormat);
|
|
39
|
-
this.value = newValue;
|
|
40
|
-
};
|
|
41
|
-
this.onInput = (event) => {
|
|
42
|
-
this.onChange(event);
|
|
43
|
-
};
|
|
44
21
|
this.onClick = (event) => {
|
|
45
22
|
event.preventDefault();
|
|
46
23
|
if (this.preferredInputMode === "pick") {
|
|
@@ -66,6 +43,8 @@ export class SwirlDateInput {
|
|
|
66
43
|
const newDateValue = event.detail;
|
|
67
44
|
const newValue = format(newDateValue, internalDateFormat);
|
|
68
45
|
this.value = newValue;
|
|
46
|
+
this.inputEl.value = format(newDateValue, this.pattern);
|
|
47
|
+
this.mask.updateValue();
|
|
69
48
|
this.setReadOnly(true);
|
|
70
49
|
this.pickerPopover.close();
|
|
71
50
|
};
|
|
@@ -94,7 +73,7 @@ export class SwirlDateInput {
|
|
|
94
73
|
}
|
|
95
74
|
watchValue(newValue, oldValue) {
|
|
96
75
|
if (newValue !== oldValue) {
|
|
97
|
-
this.
|
|
76
|
+
this.updateValue();
|
|
98
77
|
}
|
|
99
78
|
}
|
|
100
79
|
focus() {
|
|
@@ -107,9 +86,18 @@ export class SwirlDateInput {
|
|
|
107
86
|
}
|
|
108
87
|
handleAutoSelect(event) {
|
|
109
88
|
if (!this.autoSelect) {
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
if (event.target &&
|
|
91
|
+
event.target instanceof HTMLInputElement &&
|
|
92
|
+
event.target.setSelectionRange) {
|
|
93
|
+
event.target.setSelectionRange(0, 0);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
110
96
|
return;
|
|
111
97
|
}
|
|
112
|
-
event.target.
|
|
98
|
+
if (event.target && event.target instanceof HTMLInputElement) {
|
|
99
|
+
event.target.select();
|
|
100
|
+
}
|
|
113
101
|
}
|
|
114
102
|
setReadOnly(readOnly) {
|
|
115
103
|
if (this.preferredInputMode === "pick" && isMobileViewport()) {
|
|
@@ -121,24 +109,91 @@ export class SwirlDateInput {
|
|
|
121
109
|
}
|
|
122
110
|
setupMask() {
|
|
123
111
|
this.mask?.destroy();
|
|
124
|
-
|
|
125
|
-
|
|
112
|
+
// Due to automatic padding with 0s, we need to replace single characters with full length blocks.
|
|
113
|
+
this.pattern = this.format
|
|
114
|
+
.replace(/(?<!d)d(?!d)/g, "dd")
|
|
115
|
+
.replace(/(?<!M)M(?!M)/g, "MM")
|
|
116
|
+
.replace(/(?<!y)y(?!y)/g, "yyyy")
|
|
117
|
+
.replace(/(?<!y)yyy(?!y)/g, "yyyy");
|
|
118
|
+
if (!this.pattern) {
|
|
119
|
+
this.pattern = internalDateFormat;
|
|
120
|
+
}
|
|
121
|
+
this.mask = IMask(this.inputEl, {
|
|
122
|
+
mask: Date,
|
|
123
|
+
pattern: this.pattern.replace(/([^A-Za-z0-9])/g, "$1`"), // Add backticks to separators to prevent symbols from shifting back
|
|
124
|
+
autofix: "pad",
|
|
125
|
+
lazy: true,
|
|
126
|
+
overwrite: true,
|
|
127
|
+
eager: "append",
|
|
128
|
+
blocks: {
|
|
129
|
+
dd: {
|
|
130
|
+
mask: IMask.MaskedRange,
|
|
131
|
+
from: 1,
|
|
132
|
+
to: 31,
|
|
133
|
+
maxLength: 2,
|
|
134
|
+
},
|
|
135
|
+
MM: {
|
|
136
|
+
mask: IMask.MaskedRange,
|
|
137
|
+
from: 1,
|
|
138
|
+
to: 12,
|
|
139
|
+
maxLength: 2,
|
|
140
|
+
},
|
|
141
|
+
yy: {
|
|
142
|
+
mask: IMask.MaskedRange,
|
|
143
|
+
from: 0,
|
|
144
|
+
to: 99,
|
|
145
|
+
maxLength: 2,
|
|
146
|
+
},
|
|
147
|
+
yyyy: {
|
|
148
|
+
mask: IMask.MaskedRange,
|
|
149
|
+
from: 1000,
|
|
150
|
+
to: 9999,
|
|
151
|
+
maxLength: 4,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
// define date -> str conversion
|
|
155
|
+
format: (date) => {
|
|
156
|
+
const newDate = format(date, this.pattern);
|
|
157
|
+
if (!isValid(date)) {
|
|
158
|
+
this.invalidInput.emit(date.toString());
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
this.value = format(date, internalDateFormat);
|
|
162
|
+
return newDate;
|
|
163
|
+
},
|
|
164
|
+
// define str -> date conversion
|
|
165
|
+
parse: (str) => {
|
|
166
|
+
const newString = parse(str, this.pattern, new Date());
|
|
167
|
+
return newString;
|
|
168
|
+
},
|
|
126
169
|
});
|
|
170
|
+
this.updateValue();
|
|
171
|
+
}
|
|
172
|
+
updateValue() {
|
|
173
|
+
if (this.value) {
|
|
174
|
+
const dateValue = parse(this.value, internalDateFormat, new Date());
|
|
175
|
+
if (isValid(dateValue)) {
|
|
176
|
+
const formattedValue = format(dateValue, this.pattern);
|
|
177
|
+
this.mask.value = formattedValue;
|
|
178
|
+
this.valueChange.emit(this.value);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
this.invalidInput.emit(this.value);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
127
184
|
}
|
|
128
185
|
render() {
|
|
129
186
|
const ariaInvalid = this.invalid === true || this.invalid === false
|
|
130
187
|
? String(this.invalid)
|
|
131
188
|
: undefined;
|
|
132
|
-
const
|
|
189
|
+
const newDate = Boolean(this.value)
|
|
133
190
|
? parse(this.value, internalDateFormat, new Date())
|
|
134
191
|
: undefined;
|
|
135
|
-
const
|
|
136
|
-
? format(dateValue, this.format)
|
|
137
|
-
: undefined;
|
|
192
|
+
const dateValue = isValid(newDate) ? newDate : undefined;
|
|
138
193
|
const className = classnames("date-input", {
|
|
139
194
|
"date-input--inline": this.inline,
|
|
140
195
|
});
|
|
141
|
-
return (h(Host, { key: '
|
|
196
|
+
return (h(Host, { key: '9f3d225dc75468cdddff1c0446234abfd9ca09e0' }, h("div", { key: '977ea02e1a0a599f2b32e5c382210efb913d0463', class: className }, h("input", { key: '5da50a63dcc55d88abccb1dd51fef4d28e66a5ee', "aria-describedby": this.swirlAriaDescribedby, "aria-disabled": this.disabled ? "true" : undefined, "aria-invalid": ariaInvalid, autoFocus: this.autoFocus, class: "date-input__input", disabled: this.disabled, readonly: this.readonly, id: this.id, inputmode: "numeric", onClick: this.onClick, onMouseDown: this.onMouseDown, onFocus: this.onFocus, onBlur: this.onBlur, placeholder: this.placeholder, ref: (el) => (this.inputEl = el), required: this.required, type: "text" }), h("swirl-popover-trigger", { key: '556f13ed495626e32a6436f0ab172820cd9066c7', swirlPopover: `popover-${this.id}` }, h("button", { key: 'e6dddc6e1cabe9c1e632dbe0f15834b0ab17fa2b', "aria-label": this.datePickerTriggerLabel, class: "date-input__date-picker-button", disabled: this.disabled, type: "button" }, h("swirl-icon-today", { key: 'a2ef423472b1db8429c44ad717847e600fb20cb8', size: this.iconSize })))), !this.disabled && (h("swirl-popover", { key: '84a3e021ac7d946171347de0e627233abc25e493', animation: "scale-in-y", class: "date-input__date-picker-popover", id: `popover-${this.id}`, label: this.datePickerLabel, placement: "bottom-end", ref: (el) => (this.pickerPopover = el) }, h("swirl-date-picker", { key: '7edd4e96694530a7f49bc273d8fe36961c4b9e25', disableDate: this.datePickerDisableDate, firstDayOfWeek: this.firstDayOfWeek, labels: this.labels, locale: this.locale, onValueChange: this.onPickDate, value: dateValue, startDate: dateValue })))));
|
|
142
197
|
}
|
|
143
198
|
static get is() { return "swirl-date-input"; }
|
|
144
199
|
static get encapsulation() { return "scoped"; }
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
description: "See https://date-fns.org/v2.29.3/docs/format.",
|
|
7
7
|
table: {
|
|
8
8
|
type: {
|
|
9
|
-
detail: '"
|
|
9
|
+
detail: '"dd", "MM", "yy", "yyyy" and separators (e.g. ".", "-", "/", " ")',
|
|
10
10
|
summary: "Allowed patterns",
|
|
11
11
|
},
|
|
12
12
|
},
|
|
@@ -170,7 +170,7 @@ export class SwirlFileViewerPdf {
|
|
|
170
170
|
const container = canvas.closest(".file-viewer-pdf__page");
|
|
171
171
|
const textContainer = container?.querySelector(".file-viewer-pdf__text-container");
|
|
172
172
|
this.renderingPageNumbers = [...this.renderingPageNumbers, page.pageNumber];
|
|
173
|
-
const scale = forPrint ?
|
|
173
|
+
const scale = forPrint ? this.getPrintScale(page) : this.getScale(page);
|
|
174
174
|
const outputScale = window.devicePixelRatio || 1;
|
|
175
175
|
const transform = outputScale !== 1 ? [outputScale, 0, 0, outputScale, 0, 0] : null;
|
|
176
176
|
const viewport = page.getViewport({ scale });
|
|
@@ -308,6 +308,13 @@ export class SwirlFileViewerPdf {
|
|
|
308
308
|
}
|
|
309
309
|
return this.zoom;
|
|
310
310
|
}
|
|
311
|
+
getPrintScale(page) {
|
|
312
|
+
// For performance reasons we have to limit the print scale. The resulting
|
|
313
|
+
// width of a page should not exceed 2480px in width, and 3508px in height.
|
|
314
|
+
// This relates to the maximum resolution of an A4 page at 300 DPI, which
|
|
315
|
+
// should be sufficient for a decent print quality.
|
|
316
|
+
return Math.min(Math.min(2480 / page.view[2], 3508 / page.view[3]), 2);
|
|
317
|
+
}
|
|
311
318
|
restoreScrollPosition() {
|
|
312
319
|
this.scrollContainer.scrollTop =
|
|
313
320
|
this.recentScrollPosition.y * this.scrollContainer?.scrollHeight;
|
|
@@ -318,7 +325,7 @@ export class SwirlFileViewerPdf {
|
|
|
318
325
|
const showPagination = !this.error && !this.loading && this.visiblePages.length > 0;
|
|
319
326
|
const showSpinner = this.loading;
|
|
320
327
|
const className = classnames("file-viewer-pdf", `file-viewer-pdf--view-mode-${this.viewMode}`);
|
|
321
|
-
return (h(Host, { key: '
|
|
328
|
+
return (h(Host, { key: '2ded55b2086732d53df416af38f42482be6cc13c', class: className, exportparts: "file-viewer-pdf__pagination" }, this.error && (h("swirl-inline-error", { key: '24d19e9b92a95d83a72538a4a4c8130539e46bfc', class: "file-viewer-pdf__error", message: this.errorMessage })), h("div", { key: '36905878660cdd696960fc3c18894f86cba07252', "aria-describedby": "pagination", class: "file-viewer-pdf__pages", onScroll: this.onScroll, ref: (el) => (this.scrollContainer = el) }, this.pages.map((page) => {
|
|
322
329
|
const viewport = page.getViewport({
|
|
323
330
|
scale: this.getScale(page),
|
|
324
331
|
});
|
|
@@ -332,7 +339,7 @@ export class SwirlFileViewerPdf {
|
|
|
332
339
|
width: `${width}px`,
|
|
333
340
|
height: `${height}px`,
|
|
334
341
|
}, tabIndex: 0 }, !rendered && (h("swirl-spinner", { class: "file-viewer-pdf__page-spinner" })), h("canvas", { class: "file-viewer-pdf__canvas", style: { opacity: rendered ? "1" : "0" } }), h("div", { class: "file-viewer-pdf__text-container" })));
|
|
335
|
-
})), showPagination && (h("span", { key: '
|
|
342
|
+
})), showPagination && (h("span", { key: '615531f5e13c34c842e68f492c8c0fcae9021815', class: "file-viewer-pdf__pagination", id: "pagination", part: "file-viewer-pdf__pagination" }, h("span", { key: '945d4421b1ea9a50b01f05ea4a0ed6a95d470264', "aria-current": "page" }, this.currentPage), " /", " ", this.doc.numPages)), showSpinner && (h("div", { key: 'fe0ae9b54994d4f8533d733df09e2921ccf4fd83', class: "file-viewer-pdf__spinner" }, h("swirl-spinner", { key: 'b923c9b716042e0b8e71552eeac25238d8037c57' })))));
|
|
336
343
|
}
|
|
337
344
|
static get is() { return "swirl-file-viewer-pdf"; }
|
|
338
345
|
static get encapsulation() { return "shadow"; }
|