@materializecss/materialize 2.2.1 → 2.2.2
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/README.md +8 -11
- package/dist/css/materialize.css +2790 -2140
- package/dist/css/materialize.min.css +3 -5
- package/dist/css/materialize.min.css.map +1 -1
- package/dist/js/materialize.cjs.js +528 -215
- package/dist/js/materialize.d.ts +115 -13
- package/dist/js/materialize.js +528 -215
- package/dist/js/materialize.min.js +3 -3
- package/dist/js/materialize.mjs +528 -215
- package/package.json +5 -3
- package/sass/components/_badges.scss +1 -1
- package/sass/components/_breadcrumb.scss +27 -0
- package/sass/components/_buttons.scss +60 -167
- package/sass/components/_cards.scss +36 -17
- package/sass/components/_carousel.scss +16 -18
- package/sass/components/_chips.scss +6 -14
- package/sass/components/_collapsible.scss +8 -5
- package/sass/components/_collection.scss +2 -3
- package/sass/components/_color-variables.scss +35 -3
- package/sass/components/_datepicker.scss +95 -48
- package/sass/components/_dropdown.scss +11 -7
- package/sass/components/_global.scss +22 -111
- package/sass/components/_grid.scss +3 -1
- package/sass/components/_materialbox.scss +5 -6
- package/sass/components/_modal.scss +11 -4
- package/sass/components/_navbar.scss +17 -16
- package/sass/components/_pagination.scss +47 -0
- package/sass/components/_preloader.scss +3 -1
- package/sass/components/_pulse.scss +3 -3
- package/sass/components/_sidenav.scss +15 -17
- package/sass/components/_slider.scss +2 -4
- package/sass/components/_tabs.scss +45 -33
- package/sass/components/_tapTarget.scss +10 -11
- package/sass/components/_timepicker.scss +62 -47
- package/sass/components/_toast.scss +3 -0
- package/sass/components/_tooltip.scss +0 -8
- package/sass/components/_transitions.scss +2 -3
- package/sass/components/_typography.scss +5 -5
- package/sass/components/_variables.scss +3 -2
- package/sass/components/forms/_checkboxes.scss +1 -2
- package/sass/components/forms/_file-input.scss +7 -9
- package/sass/components/forms/_forms.scss +8 -14
- package/sass/components/forms/_input-fields.scss +17 -11
- package/sass/components/forms/_range.scss +6 -1
- package/sass/components/forms/_select.scss +11 -103
- package/sass/components/forms/_switches.scss +2 -0
- package/sass/components/mixins.module.scss +159 -0
- package/sass/materialize.scss +39 -43
- package/sass/components/_color-classes.scss +0 -32
package/dist/js/materialize.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Materialize v2.2.
|
|
3
|
-
* Copyright 2014-
|
|
2
|
+
* Materialize v2.2.2 (https://materializeweb.com)
|
|
3
|
+
* Copyright 2014-2025 Materialize
|
|
4
4
|
* MIT License (https://raw.githubusercontent.com/materializecss/materialize/master/LICENSE)
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
@@ -216,13 +216,11 @@ class Utils {
|
|
|
216
216
|
if (!previous && options.leading === false)
|
|
217
217
|
previous = now;
|
|
218
218
|
const remaining = wait - (now - previous);
|
|
219
|
-
context = this;
|
|
220
219
|
if (remaining <= 0) {
|
|
221
220
|
clearTimeout(timeout);
|
|
222
221
|
timeout = null;
|
|
223
222
|
previous = now;
|
|
224
|
-
result = func.apply(
|
|
225
|
-
context = args = null;
|
|
223
|
+
result = func.apply(this, args);
|
|
226
224
|
}
|
|
227
225
|
else if (!timeout && options.trailing !== false) {
|
|
228
226
|
timeout = setTimeout(later, remaining);
|
|
@@ -230,6 +228,105 @@ class Utils {
|
|
|
230
228
|
return result;
|
|
231
229
|
};
|
|
232
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Renders confirm/close buttons with callback function
|
|
233
|
+
*/
|
|
234
|
+
static createConfirmationContainer(container, confirmText, cancelText, onConfirm, onCancel) {
|
|
235
|
+
const confirmationButtonsContainer = document.createElement('div');
|
|
236
|
+
confirmationButtonsContainer.classList.add('confirmation-btns');
|
|
237
|
+
container.append(confirmationButtonsContainer);
|
|
238
|
+
this.createButton(confirmationButtonsContainer, cancelText, ['btn-cancel'], true, onCancel);
|
|
239
|
+
this.createButton(confirmationButtonsContainer, confirmText, ['btn-confirm'], true, onConfirm);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Renders a button with optional callback function
|
|
243
|
+
*/
|
|
244
|
+
static createButton(container, text, className = [], visibility = true, callback = null) {
|
|
245
|
+
className = className.concat(['btn', 'waves-effect', 'text']);
|
|
246
|
+
const button = document.createElement('button');
|
|
247
|
+
button.className = className.join(' ');
|
|
248
|
+
button.style.visibility = visibility ? 'visible' : 'hidden';
|
|
249
|
+
button.type = 'button';
|
|
250
|
+
button.tabIndex = !!visibility ? 0 : -1;
|
|
251
|
+
button.innerText = text;
|
|
252
|
+
button.addEventListener('click', callback);
|
|
253
|
+
button.addEventListener('keypress', (e) => {
|
|
254
|
+
if (Utils.keys.ENTER.includes(e.key))
|
|
255
|
+
callback(e);
|
|
256
|
+
});
|
|
257
|
+
container.append(button);
|
|
258
|
+
}
|
|
259
|
+
static _setAbsolutePosition(origin, container, position, margin, transitionMovement, align = 'center') {
|
|
260
|
+
const originHeight = origin.offsetHeight, originWidth = origin.offsetWidth, containerHeight = container.offsetHeight, containerWidth = container.offsetWidth;
|
|
261
|
+
let xMovement = 0, yMovement = 0, targetTop = origin.getBoundingClientRect().top + Utils.getDocumentScrollTop(), targetLeft = origin.getBoundingClientRect().left + Utils.getDocumentScrollLeft();
|
|
262
|
+
if (position === 'top') {
|
|
263
|
+
targetTop += -containerHeight - margin;
|
|
264
|
+
if (align === 'center') {
|
|
265
|
+
targetLeft += originWidth / 2 - containerWidth / 2; // This is center align
|
|
266
|
+
}
|
|
267
|
+
yMovement = -transitionMovement;
|
|
268
|
+
}
|
|
269
|
+
else if (position === 'right') {
|
|
270
|
+
targetTop += originHeight / 2 - containerHeight / 2;
|
|
271
|
+
targetLeft = originWidth + margin;
|
|
272
|
+
xMovement = transitionMovement;
|
|
273
|
+
}
|
|
274
|
+
else if (position === 'left') {
|
|
275
|
+
targetTop += originHeight / 2 - containerHeight / 2;
|
|
276
|
+
targetLeft = -containerWidth - margin;
|
|
277
|
+
xMovement = -transitionMovement;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
targetTop += originHeight + margin;
|
|
281
|
+
if (align === 'center') {
|
|
282
|
+
targetLeft += originWidth / 2 - containerWidth / 2; // This is center align
|
|
283
|
+
}
|
|
284
|
+
yMovement = transitionMovement;
|
|
285
|
+
}
|
|
286
|
+
if (align === 'right') {
|
|
287
|
+
targetLeft += originWidth - containerWidth - margin;
|
|
288
|
+
}
|
|
289
|
+
const newCoordinates = Utils._repositionWithinScreen(targetLeft, targetTop, containerWidth, containerHeight, margin, transitionMovement, align);
|
|
290
|
+
container.style.top = newCoordinates.y + 'px';
|
|
291
|
+
container.style.left = newCoordinates.x + 'px';
|
|
292
|
+
return { x: xMovement, y: yMovement };
|
|
293
|
+
}
|
|
294
|
+
static _repositionWithinScreen(x, y, width, height, margin, transitionMovement, align) {
|
|
295
|
+
const scrollLeft = Utils.getDocumentScrollLeft();
|
|
296
|
+
const scrollTop = Utils.getDocumentScrollTop();
|
|
297
|
+
let newX = x - scrollLeft;
|
|
298
|
+
let newY = y - scrollTop;
|
|
299
|
+
const bounding = {
|
|
300
|
+
left: newX,
|
|
301
|
+
top: newY,
|
|
302
|
+
width: width,
|
|
303
|
+
height: height
|
|
304
|
+
};
|
|
305
|
+
let offset;
|
|
306
|
+
if (align === 'left' || align == 'center') {
|
|
307
|
+
offset = margin + transitionMovement;
|
|
308
|
+
}
|
|
309
|
+
else if (align === 'right') {
|
|
310
|
+
offset = margin - transitionMovement;
|
|
311
|
+
}
|
|
312
|
+
const edges = Utils.checkWithinContainer(document.body, bounding, offset);
|
|
313
|
+
if (edges.left) {
|
|
314
|
+
newX = offset;
|
|
315
|
+
}
|
|
316
|
+
else if (edges.right) {
|
|
317
|
+
newX -= newX + width - window.innerWidth;
|
|
318
|
+
}
|
|
319
|
+
if (edges.top) {
|
|
320
|
+
newY = offset;
|
|
321
|
+
}
|
|
322
|
+
else if (edges.bottom) {
|
|
323
|
+
newY -= newY + height - window.innerHeight;
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
x: newX + scrollLeft,
|
|
327
|
+
y: newY + scrollTop
|
|
328
|
+
};
|
|
329
|
+
}
|
|
233
330
|
}
|
|
234
331
|
|
|
235
332
|
/**
|
|
@@ -300,7 +397,7 @@ class Component {
|
|
|
300
397
|
}
|
|
301
398
|
}
|
|
302
399
|
|
|
303
|
-
const _defaults$
|
|
400
|
+
const _defaults$n = {
|
|
304
401
|
alignment: 'left',
|
|
305
402
|
autoFocus: true,
|
|
306
403
|
constrainWidth: true,
|
|
@@ -348,12 +445,12 @@ class Dropdown extends Component {
|
|
|
348
445
|
this.filterQuery = [];
|
|
349
446
|
this.el.ariaExpanded = 'false';
|
|
350
447
|
// Move dropdown-content after dropdown-trigger
|
|
351
|
-
this.
|
|
448
|
+
this._moveDropdownToElement();
|
|
352
449
|
this._makeDropdownFocusable();
|
|
353
450
|
this._setupEventHandlers();
|
|
354
451
|
}
|
|
355
452
|
static get defaults() {
|
|
356
|
-
return _defaults$
|
|
453
|
+
return _defaults$n;
|
|
357
454
|
}
|
|
358
455
|
/**
|
|
359
456
|
* Initializes instances of Dropdown.
|
|
@@ -414,7 +511,7 @@ class Dropdown extends Component {
|
|
|
414
511
|
}
|
|
415
512
|
_handleClick = (e) => {
|
|
416
513
|
e.preventDefault();
|
|
417
|
-
this._moveDropdown(e.target.closest('li'));
|
|
514
|
+
//this._moveDropdown((<HTMLElement>e.target).closest('li'));
|
|
418
515
|
if (this.isOpen) {
|
|
419
516
|
this.close();
|
|
420
517
|
}
|
|
@@ -422,8 +519,8 @@ class Dropdown extends Component {
|
|
|
422
519
|
this.open();
|
|
423
520
|
}
|
|
424
521
|
};
|
|
425
|
-
_handleMouseEnter = (
|
|
426
|
-
this._moveDropdown(e.target.closest('li'));
|
|
522
|
+
_handleMouseEnter = () => {
|
|
523
|
+
//this._moveDropdown((<HTMLElement>e.target).closest('li'));
|
|
427
524
|
this.open();
|
|
428
525
|
};
|
|
429
526
|
_handleMouseLeave = (e) => {
|
|
@@ -509,7 +606,7 @@ class Dropdown extends Component {
|
|
|
509
606
|
else if (Utils.keys.ENTER.includes(e.key) && this.isOpen) {
|
|
510
607
|
// Search for <a> and <button>
|
|
511
608
|
const focusedElement = this.dropdownEl.children[this.focusedIndex];
|
|
512
|
-
const activatableElement = focusedElement
|
|
609
|
+
const activatableElement = focusedElement?.querySelector('a, button');
|
|
513
610
|
// Click a or button tag if exists, otherwise click li tag
|
|
514
611
|
if (!!activatableElement) {
|
|
515
612
|
activatableElement.click();
|
|
@@ -569,19 +666,17 @@ class Dropdown extends Component {
|
|
|
569
666
|
this.dropdownEl.style.top = '';
|
|
570
667
|
this.dropdownEl.style.transformOrigin = '';
|
|
571
668
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
if (!!this.options.container) {
|
|
669
|
+
_moveDropdownToElement(containerEl = null) {
|
|
670
|
+
if (this.options.container) {
|
|
575
671
|
this.options.container.append(this.dropdownEl);
|
|
672
|
+
return;
|
|
576
673
|
}
|
|
577
|
-
|
|
578
|
-
if (!containerEl.contains(this.dropdownEl))
|
|
674
|
+
if (containerEl) {
|
|
675
|
+
if (!containerEl.contains(this.dropdownEl))
|
|
579
676
|
containerEl.append(this.dropdownEl);
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
this.el.after(this.dropdownEl);
|
|
677
|
+
return;
|
|
584
678
|
}
|
|
679
|
+
this.el.after(this.dropdownEl);
|
|
585
680
|
}
|
|
586
681
|
_makeDropdownFocusable() {
|
|
587
682
|
if (!this.dropdownEl)
|
|
@@ -742,7 +837,7 @@ class Dropdown extends Component {
|
|
|
742
837
|
}
|
|
743
838
|
if (getComputedStyle(closestOverflowParent).position === 'static')
|
|
744
839
|
closestOverflowParent.style.position = 'relative';
|
|
745
|
-
this._moveDropdown(closestOverflowParent);
|
|
840
|
+
//this._moveDropdown(closestOverflowParent);
|
|
746
841
|
// Set width before calculating positionInfo
|
|
747
842
|
const idealWidth = this.options.constrainWidth
|
|
748
843
|
? this.el.getBoundingClientRect().width
|
|
@@ -806,7 +901,7 @@ class Dropdown extends Component {
|
|
|
806
901
|
};
|
|
807
902
|
}
|
|
808
903
|
|
|
809
|
-
const _defaults$
|
|
904
|
+
const _defaults$m = {
|
|
810
905
|
data: [], // Autocomplete data set
|
|
811
906
|
onAutocomplete: null, // Callback for when autocompleted
|
|
812
907
|
dropdownOptions: {
|
|
@@ -819,11 +914,12 @@ const _defaults$l = {
|
|
|
819
914
|
isMultiSelect: false,
|
|
820
915
|
onSearch: (text, autocomplete) => {
|
|
821
916
|
const normSearch = text.toLocaleLowerCase();
|
|
822
|
-
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch)
|
|
823
|
-
option.text?.toLocaleLowerCase().includes(normSearch)));
|
|
917
|
+
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch)
|
|
918
|
+
|| option.text?.toLocaleLowerCase().includes(normSearch)));
|
|
824
919
|
},
|
|
825
920
|
maxDropDownHeight: '300px',
|
|
826
|
-
allowUnsafeHTML: false
|
|
921
|
+
allowUnsafeHTML: false,
|
|
922
|
+
selected: []
|
|
827
923
|
};
|
|
828
924
|
class Autocomplete extends Component {
|
|
829
925
|
/** If the autocomplete is open. */
|
|
@@ -852,7 +948,7 @@ class Autocomplete extends Component {
|
|
|
852
948
|
this.count = 0;
|
|
853
949
|
this.activeIndex = -1;
|
|
854
950
|
this.oldVal = '';
|
|
855
|
-
this.selectedValues = [];
|
|
951
|
+
this.selectedValues = this.selectedValues || this.options.selected.map((value) => ({ id: value })) || [];
|
|
856
952
|
this.menuItems = this.options.data || [];
|
|
857
953
|
this.$active = null;
|
|
858
954
|
this._mousedown = false;
|
|
@@ -860,7 +956,7 @@ class Autocomplete extends Component {
|
|
|
860
956
|
this._setupEventHandlers();
|
|
861
957
|
}
|
|
862
958
|
static get defaults() {
|
|
863
|
-
return _defaults$
|
|
959
|
+
return _defaults$m;
|
|
864
960
|
}
|
|
865
961
|
/**
|
|
866
962
|
* Initializes instances of Autocomplete.
|
|
@@ -909,6 +1005,7 @@ class Autocomplete extends Component {
|
|
|
909
1005
|
this.container.style.maxHeight = this.options.maxDropDownHeight;
|
|
910
1006
|
this.container.id = `autocomplete-options-${Utils.guid()}`;
|
|
911
1007
|
this.container.classList.add('autocomplete-content', 'dropdown-content');
|
|
1008
|
+
this.container.ariaExpanded = 'true';
|
|
912
1009
|
this.el.setAttribute('data-target', this.container.id);
|
|
913
1010
|
this.menuItems.forEach((menuItem) => {
|
|
914
1011
|
const itemElement = this._createDropdownItem(menuItem);
|
|
@@ -941,6 +1038,10 @@ class Autocomplete extends Component {
|
|
|
941
1038
|
this.el.after(label);
|
|
942
1039
|
// Sketchy removal of dropdown click handler
|
|
943
1040
|
this.el.removeEventListener('click', this.dropdown._handleClick);
|
|
1041
|
+
if (!this.options.isMultiSelect && !(this.options.selected.length === 0)) {
|
|
1042
|
+
const selectedValue = this.menuItems.filter((value) => value.id === this.selectedValues[0].id);
|
|
1043
|
+
this.el.value = selectedValue[0].text;
|
|
1044
|
+
}
|
|
944
1045
|
// Set Value if already set in HTML
|
|
945
1046
|
if (this.el.value)
|
|
946
1047
|
this.selectOption(this.el.value);
|
|
@@ -952,6 +1053,7 @@ class Autocomplete extends Component {
|
|
|
952
1053
|
this._updateSelectedInfo();
|
|
953
1054
|
}
|
|
954
1055
|
_removeDropdown() {
|
|
1056
|
+
this.container.ariaExpanded = 'false';
|
|
955
1057
|
this.container.parentNode.removeChild(this.container);
|
|
956
1058
|
}
|
|
957
1059
|
_handleInputBlur = () => {
|
|
@@ -1061,6 +1163,7 @@ class Autocomplete extends Component {
|
|
|
1061
1163
|
const item = document.createElement('li');
|
|
1062
1164
|
item.setAttribute('data-id', entry.id);
|
|
1063
1165
|
item.setAttribute('style', 'display:grid; grid-auto-flow: column; user-select: none; align-items: center;');
|
|
1166
|
+
item.tabIndex = 0;
|
|
1064
1167
|
// Checkbox
|
|
1065
1168
|
if (this.options.isMultiSelect) {
|
|
1066
1169
|
item.innerHTML = `
|
|
@@ -1188,14 +1291,29 @@ class Autocomplete extends Component {
|
|
|
1188
1291
|
/**
|
|
1189
1292
|
* Updates the visible or selectable items shown in the menu.
|
|
1190
1293
|
* @param menuItems Items to be available.
|
|
1294
|
+
* @param selected Selected item ids
|
|
1295
|
+
* @param open Option to conditionally open dropdown
|
|
1191
1296
|
*/
|
|
1192
|
-
setMenuItems(menuItems) {
|
|
1297
|
+
setMenuItems(menuItems, selected = null, open = true) {
|
|
1193
1298
|
this.menuItems = menuItems;
|
|
1194
|
-
this.
|
|
1299
|
+
this.options.data = menuItems;
|
|
1300
|
+
if (selected) {
|
|
1301
|
+
this.selectedValues = this.menuItems.filter((item) => !(selected.indexOf(item.id) === -1));
|
|
1302
|
+
}
|
|
1303
|
+
if (this.options.isMultiSelect) {
|
|
1304
|
+
this._renderDropdown();
|
|
1305
|
+
}
|
|
1306
|
+
else {
|
|
1307
|
+
this._refreshInputText();
|
|
1308
|
+
}
|
|
1309
|
+
if (open)
|
|
1310
|
+
this.open();
|
|
1195
1311
|
this._updateSelectedInfo();
|
|
1312
|
+
this._triggerChanged();
|
|
1196
1313
|
}
|
|
1197
1314
|
/**
|
|
1198
1315
|
* Sets selected values.
|
|
1316
|
+
* @deprecated @see https://github.com/materializecss/materialize/issues/552
|
|
1199
1317
|
* @param entries
|
|
1200
1318
|
*/
|
|
1201
1319
|
setValues(entries) {
|
|
@@ -1215,16 +1333,16 @@ class Autocomplete extends Component {
|
|
|
1215
1333
|
if (!entry)
|
|
1216
1334
|
return;
|
|
1217
1335
|
// Toggle Checkbox
|
|
1218
|
-
const li = this.container.querySelector('li[data-id="' + id + '"]');
|
|
1219
|
-
if (!li)
|
|
1220
|
-
return;
|
|
1336
|
+
/* const li = this.container.querySelector('li[data-id="' + id + '"]');
|
|
1337
|
+
if (!li) return;*/
|
|
1221
1338
|
if (this.options.isMultiSelect) {
|
|
1222
|
-
const checkbox = li.querySelector('input[type="checkbox"]');
|
|
1223
|
-
checkbox.checked = !checkbox.checked
|
|
1224
|
-
if (
|
|
1339
|
+
/* const checkbox = <HTMLInputElement | null>li.querySelector('input[type="checkbox"]');
|
|
1340
|
+
checkbox.checked = !checkbox.checked;*/
|
|
1341
|
+
if (!(this.selectedValues.filter((selectedEntry) => selectedEntry.id === entry.id).length >= 1))
|
|
1225
1342
|
this.selectedValues.push(entry);
|
|
1226
1343
|
else
|
|
1227
1344
|
this.selectedValues = this.selectedValues.filter((selectedEntry) => selectedEntry.id !== entry.id);
|
|
1345
|
+
this._renderDropdown();
|
|
1228
1346
|
this.el.focus();
|
|
1229
1347
|
}
|
|
1230
1348
|
else {
|
|
@@ -1237,9 +1355,16 @@ class Autocomplete extends Component {
|
|
|
1237
1355
|
this._updateSelectedInfo();
|
|
1238
1356
|
this._triggerChanged();
|
|
1239
1357
|
}
|
|
1358
|
+
selectOptions(ids) {
|
|
1359
|
+
const entries = this.menuItems.filter((item) => !(ids.indexOf(item.id) === -1));
|
|
1360
|
+
if (!entries)
|
|
1361
|
+
return;
|
|
1362
|
+
this.selectedValues = entries;
|
|
1363
|
+
this._renderDropdown();
|
|
1364
|
+
}
|
|
1240
1365
|
}
|
|
1241
1366
|
|
|
1242
|
-
const _defaults$
|
|
1367
|
+
const _defaults$l = {
|
|
1243
1368
|
direction: 'top',
|
|
1244
1369
|
hoverEnabled: true,
|
|
1245
1370
|
toolbarEnabled: false
|
|
@@ -1273,6 +1398,8 @@ class FloatingActionButton extends Component {
|
|
|
1273
1398
|
this.offsetY = 0;
|
|
1274
1399
|
this.offsetX = 0;
|
|
1275
1400
|
this.el.classList.add(`direction-${this.options.direction}`);
|
|
1401
|
+
this._anchor.tabIndex = 0;
|
|
1402
|
+
this._menu.ariaExpanded = 'false';
|
|
1276
1403
|
if (this.options.direction === 'top')
|
|
1277
1404
|
this.offsetY = 40;
|
|
1278
1405
|
else if (this.options.direction === 'right')
|
|
@@ -1284,7 +1411,7 @@ class FloatingActionButton extends Component {
|
|
|
1284
1411
|
this._setupEventHandlers();
|
|
1285
1412
|
}
|
|
1286
1413
|
static get defaults() {
|
|
1287
|
-
return _defaults$
|
|
1414
|
+
return _defaults$l;
|
|
1288
1415
|
}
|
|
1289
1416
|
/**
|
|
1290
1417
|
* Initializes instances of FloatingActionButton.
|
|
@@ -1309,6 +1436,7 @@ class FloatingActionButton extends Component {
|
|
|
1309
1436
|
else {
|
|
1310
1437
|
this.el.addEventListener('click', this._handleFABClick);
|
|
1311
1438
|
}
|
|
1439
|
+
this.el.addEventListener('keypress', this._handleFABKeyPress);
|
|
1312
1440
|
}
|
|
1313
1441
|
_removeEventHandlers() {
|
|
1314
1442
|
if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
|
|
@@ -1318,8 +1446,17 @@ class FloatingActionButton extends Component {
|
|
|
1318
1446
|
else {
|
|
1319
1447
|
this.el.removeEventListener('click', this._handleFABClick);
|
|
1320
1448
|
}
|
|
1449
|
+
this.el.removeEventListener('keypress', this._handleFABKeyPress);
|
|
1321
1450
|
}
|
|
1322
1451
|
_handleFABClick = () => {
|
|
1452
|
+
this._handleFABToggle();
|
|
1453
|
+
};
|
|
1454
|
+
_handleFABKeyPress = (e) => {
|
|
1455
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
1456
|
+
this._handleFABToggle();
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
_handleFABToggle = () => {
|
|
1323
1460
|
if (this.isOpen) {
|
|
1324
1461
|
this.close();
|
|
1325
1462
|
}
|
|
@@ -1361,6 +1498,7 @@ class FloatingActionButton extends Component {
|
|
|
1361
1498
|
};
|
|
1362
1499
|
_animateInFAB() {
|
|
1363
1500
|
this.el.classList.add('active');
|
|
1501
|
+
this._menu.ariaExpanded = 'true';
|
|
1364
1502
|
const delayIncrement = 40;
|
|
1365
1503
|
const duration = 275;
|
|
1366
1504
|
this._floatingBtnsReverse.forEach((el, index) => {
|
|
@@ -1377,18 +1515,23 @@ class FloatingActionButton extends Component {
|
|
|
1377
1515
|
el.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
1378
1516
|
el.style.opacity = '1';
|
|
1379
1517
|
el.style.transform = 'translate(0, 0) scale(1)';
|
|
1518
|
+
el.tabIndex = 0;
|
|
1380
1519
|
}, 1);
|
|
1381
1520
|
}, delay);
|
|
1382
1521
|
});
|
|
1383
1522
|
}
|
|
1384
1523
|
_animateOutFAB() {
|
|
1385
1524
|
const duration = 175;
|
|
1386
|
-
setTimeout(() =>
|
|
1525
|
+
setTimeout(() => {
|
|
1526
|
+
this.el.classList.remove('active');
|
|
1527
|
+
this._menu.ariaExpanded = 'false';
|
|
1528
|
+
}, duration);
|
|
1387
1529
|
this._floatingBtnsReverse.forEach((el) => {
|
|
1388
1530
|
el.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
1389
1531
|
// to
|
|
1390
1532
|
el.style.opacity = '0';
|
|
1391
1533
|
el.style.transform = `translate(${this.offsetX}px, ${this.offsetY}px) scale(0.4)`;
|
|
1534
|
+
el.tabIndex = -1;
|
|
1392
1535
|
});
|
|
1393
1536
|
}
|
|
1394
1537
|
_animateInToolbar() {
|
|
@@ -1412,6 +1555,7 @@ class FloatingActionButton extends Component {
|
|
|
1412
1555
|
this.el.style.left = '0';
|
|
1413
1556
|
this.el.style.transform = 'translateX(' + this.offsetX + 'px)';
|
|
1414
1557
|
this.el.style.transition = 'none';
|
|
1558
|
+
this._menu.ariaExpanded = 'true';
|
|
1415
1559
|
this._anchor.style.transform = `translateY(${this.offsetY}px`;
|
|
1416
1560
|
this._anchor.style.transition = 'none';
|
|
1417
1561
|
setTimeout(() => {
|
|
@@ -1426,9 +1570,10 @@ class FloatingActionButton extends Component {
|
|
|
1426
1570
|
this.el.style.backgroundColor = fabColor;
|
|
1427
1571
|
backdrop.style.transform = 'scale(' + scaleFactor + ')';
|
|
1428
1572
|
backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
|
|
1429
|
-
this._menu
|
|
1430
|
-
.
|
|
1431
|
-
|
|
1573
|
+
this._menu.querySelectorAll('li > a').forEach((a) => {
|
|
1574
|
+
a.style.opacity = '1';
|
|
1575
|
+
a.tabIndex = 0;
|
|
1576
|
+
});
|
|
1432
1577
|
// Scroll to close.
|
|
1433
1578
|
window.addEventListener('scroll', this.close, true);
|
|
1434
1579
|
document.body.addEventListener('click', this._handleDocumentClick, true);
|
|
@@ -1437,7 +1582,7 @@ class FloatingActionButton extends Component {
|
|
|
1437
1582
|
}
|
|
1438
1583
|
}
|
|
1439
1584
|
|
|
1440
|
-
const _defaults$
|
|
1585
|
+
const _defaults$k = {
|
|
1441
1586
|
onOpen: null,
|
|
1442
1587
|
onClose: null,
|
|
1443
1588
|
inDuration: 225,
|
|
@@ -1456,6 +1601,7 @@ class Cards extends Component {
|
|
|
1456
1601
|
...Cards.defaults,
|
|
1457
1602
|
...options
|
|
1458
1603
|
};
|
|
1604
|
+
this._activators = [];
|
|
1459
1605
|
this.cardReveal = this.el.querySelector('.card-reveal');
|
|
1460
1606
|
if (this.cardReveal) {
|
|
1461
1607
|
this.initialOverflow = getComputedStyle(this.el).overflow;
|
|
@@ -1472,7 +1618,7 @@ class Cards extends Component {
|
|
|
1472
1618
|
}
|
|
1473
1619
|
}
|
|
1474
1620
|
static get defaults() {
|
|
1475
|
-
return _defaults$
|
|
1621
|
+
return _defaults$k;
|
|
1476
1622
|
}
|
|
1477
1623
|
/**
|
|
1478
1624
|
* Initializes instances of Cards.
|
|
@@ -1571,9 +1717,20 @@ class Cards extends Component {
|
|
|
1571
1717
|
}
|
|
1572
1718
|
this._removeRevealCloseEventHandlers();
|
|
1573
1719
|
};
|
|
1720
|
+
static Init() {
|
|
1721
|
+
if (typeof document !== 'undefined')
|
|
1722
|
+
// Handle initialization of static cards.
|
|
1723
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
1724
|
+
const cards = document.querySelectorAll('.card');
|
|
1725
|
+
cards.forEach((el) => {
|
|
1726
|
+
if (el && (el['M_Card'] == undefined))
|
|
1727
|
+
this.init(el);
|
|
1728
|
+
});
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1574
1731
|
}
|
|
1575
1732
|
|
|
1576
|
-
const _defaults$
|
|
1733
|
+
const _defaults$j = {
|
|
1577
1734
|
duration: 200, // ms
|
|
1578
1735
|
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
|
1579
1736
|
shift: 0, // spacing for center image
|
|
@@ -1675,7 +1832,7 @@ class Carousel extends Component {
|
|
|
1675
1832
|
this._scroll(this.offset);
|
|
1676
1833
|
}
|
|
1677
1834
|
static get defaults() {
|
|
1678
|
-
return _defaults$
|
|
1835
|
+
return _defaults$j;
|
|
1679
1836
|
}
|
|
1680
1837
|
/**
|
|
1681
1838
|
* Initializes instances of Carousel.
|
|
@@ -1730,9 +1887,7 @@ class Carousel extends Component {
|
|
|
1730
1887
|
}
|
|
1731
1888
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
1732
1889
|
}
|
|
1733
|
-
_handleThrottledResize = Utils.throttle(
|
|
1734
|
-
this._handleResize();
|
|
1735
|
-
}, 200, null).bind(this);
|
|
1890
|
+
_handleThrottledResize = () => Utils.throttle(this._handleResize, 200, null).bind(this);
|
|
1736
1891
|
_handleCarouselTap = (e) => {
|
|
1737
1892
|
// Fixes firefox draggable image bug
|
|
1738
1893
|
if (e.type === 'mousedown' && e.target.tagName === 'IMG') {
|
|
@@ -2147,7 +2302,7 @@ class Carousel extends Component {
|
|
|
2147
2302
|
}
|
|
2148
2303
|
}
|
|
2149
2304
|
|
|
2150
|
-
const _defaults$
|
|
2305
|
+
const _defaults$i = {
|
|
2151
2306
|
data: [],
|
|
2152
2307
|
placeholder: '',
|
|
2153
2308
|
secondaryPlaceholder: '',
|
|
@@ -2201,7 +2356,7 @@ class Chips extends Component {
|
|
|
2201
2356
|
}
|
|
2202
2357
|
}
|
|
2203
2358
|
static get defaults() {
|
|
2204
|
-
return _defaults$
|
|
2359
|
+
return _defaults$i;
|
|
2205
2360
|
}
|
|
2206
2361
|
/**
|
|
2207
2362
|
* Initializes instances of Chips.
|
|
@@ -2485,7 +2640,7 @@ class Chips extends Component {
|
|
|
2485
2640
|
}
|
|
2486
2641
|
}
|
|
2487
2642
|
|
|
2488
|
-
const _defaults$
|
|
2643
|
+
const _defaults$h = {
|
|
2489
2644
|
accordion: true,
|
|
2490
2645
|
onOpenStart: null,
|
|
2491
2646
|
onOpenEnd: null,
|
|
@@ -2521,7 +2676,7 @@ class Collapsible extends Component {
|
|
|
2521
2676
|
}
|
|
2522
2677
|
}
|
|
2523
2678
|
static get defaults() {
|
|
2524
|
-
return _defaults$
|
|
2679
|
+
return _defaults$h;
|
|
2525
2680
|
}
|
|
2526
2681
|
/**
|
|
2527
2682
|
* Initializes instances of Collapsible.
|
|
@@ -2640,7 +2795,7 @@ class Collapsible extends Component {
|
|
|
2640
2795
|
};
|
|
2641
2796
|
}
|
|
2642
2797
|
|
|
2643
|
-
const _defaults$
|
|
2798
|
+
const _defaults$g = {
|
|
2644
2799
|
classes: '',
|
|
2645
2800
|
dropdownOptions: {}
|
|
2646
2801
|
};
|
|
@@ -2662,6 +2817,7 @@ class FormSelect extends Component {
|
|
|
2662
2817
|
wrapper;
|
|
2663
2818
|
selectOptions;
|
|
2664
2819
|
_values;
|
|
2820
|
+
nativeTabIndex;
|
|
2665
2821
|
constructor(el, options) {
|
|
2666
2822
|
super(el, options, FormSelect);
|
|
2667
2823
|
if (this.el.classList.contains('browser-default'))
|
|
@@ -2672,13 +2828,14 @@ class FormSelect extends Component {
|
|
|
2672
2828
|
...options
|
|
2673
2829
|
};
|
|
2674
2830
|
this.isMultiple = this.el.multiple;
|
|
2831
|
+
this.nativeTabIndex = this.el.tabIndex ?? -1;
|
|
2675
2832
|
this.el.tabIndex = -1;
|
|
2676
2833
|
this._values = [];
|
|
2677
2834
|
this._setupDropdown();
|
|
2678
2835
|
this._setupEventHandlers();
|
|
2679
2836
|
}
|
|
2680
2837
|
static get defaults() {
|
|
2681
|
-
return _defaults$
|
|
2838
|
+
return _defaults$g;
|
|
2682
2839
|
}
|
|
2683
2840
|
/**
|
|
2684
2841
|
* Initializes instances of FormSelect.
|
|
@@ -2768,8 +2925,6 @@ class FormSelect extends Component {
|
|
|
2768
2925
|
};
|
|
2769
2926
|
_setupDropdown() {
|
|
2770
2927
|
this.labelEl = document.querySelector('[for="' + this.el.id + '"]');
|
|
2771
|
-
if (this.labelEl)
|
|
2772
|
-
this.labelEl.style.display = 'none';
|
|
2773
2928
|
this.wrapper = document.createElement('div');
|
|
2774
2929
|
this.wrapper.classList.add('select-wrapper', 'input-field');
|
|
2775
2930
|
if (this.options.classes.length > 0) {
|
|
@@ -2787,6 +2942,7 @@ class FormSelect extends Component {
|
|
|
2787
2942
|
// Create dropdown
|
|
2788
2943
|
this.dropdownOptions = document.createElement('ul');
|
|
2789
2944
|
this.dropdownOptions.id = `select-options-${Utils.guid()}`;
|
|
2945
|
+
this.dropdownOptions.setAttribute('popover', 'auto');
|
|
2790
2946
|
this.dropdownOptions.classList.add('dropdown-content', 'select-dropdown');
|
|
2791
2947
|
this.dropdownOptions.setAttribute('role', 'listbox');
|
|
2792
2948
|
this.dropdownOptions.ariaMultiSelectable = this.isMultiple.toString();
|
|
@@ -2835,6 +2991,7 @@ class FormSelect extends Component {
|
|
|
2835
2991
|
this.input.ariaRequired = this.el.hasAttribute('required').toString(); //setAttribute("aria-required", this.el.hasAttribute("required"));
|
|
2836
2992
|
if (this.el.disabled)
|
|
2837
2993
|
this.input.disabled = true; // 'true');
|
|
2994
|
+
this.input.setAttribute('tabindex', this.nativeTabIndex.toString());
|
|
2838
2995
|
const attrs = this.el.attributes;
|
|
2839
2996
|
for (let i = 0; i < attrs.length; ++i) {
|
|
2840
2997
|
const attr = attrs[i];
|
|
@@ -2860,7 +3017,7 @@ class FormSelect extends Component {
|
|
|
2860
3017
|
this.wrapper.prepend(dropdownIcon);
|
|
2861
3018
|
// Initialize dropdown
|
|
2862
3019
|
if (!this.el.disabled) {
|
|
2863
|
-
const dropdownOptions = { ...this.options.dropdownOptions };
|
|
3020
|
+
const dropdownOptions = { ...this.options.dropdownOptions };
|
|
2864
3021
|
dropdownOptions.coverTrigger = false;
|
|
2865
3022
|
const userOnOpenEnd = dropdownOptions.onOpenEnd;
|
|
2866
3023
|
const userOnCloseEnd = dropdownOptions.onCloseEnd;
|
|
@@ -2899,13 +3056,9 @@ class FormSelect extends Component {
|
|
|
2899
3056
|
}
|
|
2900
3057
|
// Add initial selections
|
|
2901
3058
|
this._setSelectedStates();
|
|
2902
|
-
//
|
|
2903
|
-
if (this.labelEl)
|
|
2904
|
-
|
|
2905
|
-
label.htmlFor = this.input.id;
|
|
2906
|
-
label.innerText = this.labelEl.innerText;
|
|
2907
|
-
this.input.after(label);
|
|
2908
|
-
}
|
|
3059
|
+
// move label
|
|
3060
|
+
if (this.labelEl)
|
|
3061
|
+
this.input.after(this.labelEl);
|
|
2909
3062
|
}
|
|
2910
3063
|
_addOptionToValues(realOption, virtualOption) {
|
|
2911
3064
|
this._values.push({ el: realOption, optionEl: virtualOption });
|
|
@@ -3025,6 +3178,74 @@ class FormSelect extends Component {
|
|
|
3025
3178
|
}
|
|
3026
3179
|
}
|
|
3027
3180
|
|
|
3181
|
+
const _defaults$f = {
|
|
3182
|
+
margin: 5,
|
|
3183
|
+
transition: 10,
|
|
3184
|
+
duration: 250,
|
|
3185
|
+
align: 'left'
|
|
3186
|
+
};
|
|
3187
|
+
class DockedDisplayPlugin {
|
|
3188
|
+
el;
|
|
3189
|
+
container;
|
|
3190
|
+
options;
|
|
3191
|
+
visible;
|
|
3192
|
+
constructor(el, container, options) {
|
|
3193
|
+
this.el = el;
|
|
3194
|
+
this.options = {
|
|
3195
|
+
..._defaults$f,
|
|
3196
|
+
...options
|
|
3197
|
+
};
|
|
3198
|
+
this.container = document.createElement('div');
|
|
3199
|
+
this.container.classList.add('display-docked');
|
|
3200
|
+
this.container.append(container);
|
|
3201
|
+
el.parentElement.append(this.container);
|
|
3202
|
+
document.addEventListener('click', (e) => {
|
|
3203
|
+
if (this.visible && !(this.el === e.target) && !(e.target.closest('.display-docked'))) {
|
|
3204
|
+
this.hide();
|
|
3205
|
+
}
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
/**
|
|
3209
|
+
* Initializes instance of DockedDisplayPlugin
|
|
3210
|
+
* @param el HTMLElement to position to
|
|
3211
|
+
* @param container HTMLElement to be positioned
|
|
3212
|
+
* @param options Plugin options
|
|
3213
|
+
*/
|
|
3214
|
+
static init(el, container, options) {
|
|
3215
|
+
return new DockedDisplayPlugin(el, container, options);
|
|
3216
|
+
}
|
|
3217
|
+
show = () => {
|
|
3218
|
+
if (this.visible)
|
|
3219
|
+
return;
|
|
3220
|
+
this.visible = true;
|
|
3221
|
+
const coordinates = Utils._setAbsolutePosition(this.el, this.container, 'bottom', this.options.margin, this.options.transition, this.options.align);
|
|
3222
|
+
// @todo move to Util? -> duplicate code fragment with tooltip
|
|
3223
|
+
// easeOutCubic
|
|
3224
|
+
this.container.style.visibility = 'visible';
|
|
3225
|
+
this.container.style.transition = `
|
|
3226
|
+
transform ${this.options.duration}ms ease-out,
|
|
3227
|
+
opacity ${this.options.duration}ms ease-out`;
|
|
3228
|
+
setTimeout(() => {
|
|
3229
|
+
this.container.style.transform = `translateX(${coordinates.x}px) translateY(${coordinates.y}px)`;
|
|
3230
|
+
this.container.style.opacity = (1).toString();
|
|
3231
|
+
}, 1);
|
|
3232
|
+
};
|
|
3233
|
+
hide = () => {
|
|
3234
|
+
if (!this.visible)
|
|
3235
|
+
return;
|
|
3236
|
+
this.visible = false;
|
|
3237
|
+
// @todo move to Util? -> duplicate code fragment with tooltip
|
|
3238
|
+
this.container.removeAttribute('style');
|
|
3239
|
+
this.container.style.transition = `
|
|
3240
|
+
transform ${this.options.duration}ms ease-out,
|
|
3241
|
+
opacity ${this.options.duration}ms ease-out`;
|
|
3242
|
+
setTimeout(() => {
|
|
3243
|
+
this.container.style.transform = `translateX(0px) translateY(0px)`;
|
|
3244
|
+
this.container.style.opacity = '0';
|
|
3245
|
+
}, 1);
|
|
3246
|
+
};
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3028
3249
|
const _defaults$e = {
|
|
3029
3250
|
// the default output format for the input field value
|
|
3030
3251
|
format: 'mmm dd, yyyy',
|
|
@@ -3032,6 +3253,8 @@ const _defaults$e = {
|
|
|
3032
3253
|
parse: null,
|
|
3033
3254
|
// The initial condition if the datepicker is based on date range
|
|
3034
3255
|
isDateRange: false,
|
|
3256
|
+
// The selector of the user specified date range end element
|
|
3257
|
+
dateRangeEndEl: null,
|
|
3035
3258
|
// The initial condition if the datepicker is based on multiple date selection
|
|
3036
3259
|
isMultipleSelection: false,
|
|
3037
3260
|
// The initial date to view when first opened
|
|
@@ -3065,10 +3288,14 @@ const _defaults$e = {
|
|
|
3065
3288
|
showMonthAfterYear: false,
|
|
3066
3289
|
// Render days of the calendar grid that fall in the next or previous month
|
|
3067
3290
|
showDaysInNextAndPreviousMonths: false,
|
|
3291
|
+
// Specify if docked picker is in open state by default
|
|
3292
|
+
openByDefault: false,
|
|
3068
3293
|
// Specify a DOM element to render the calendar in
|
|
3069
3294
|
container: null,
|
|
3070
3295
|
// Show clear button
|
|
3071
3296
|
showClearBtn: false,
|
|
3297
|
+
// Autosubmit
|
|
3298
|
+
autoSubmit: true,
|
|
3072
3299
|
// internationalization
|
|
3073
3300
|
i18n: {
|
|
3074
3301
|
cancel: 'Cancel',
|
|
@@ -3112,18 +3339,23 @@ const _defaults$e = {
|
|
|
3112
3339
|
events: [],
|
|
3113
3340
|
// callback function
|
|
3114
3341
|
onSelect: null,
|
|
3115
|
-
onDraw: null
|
|
3342
|
+
onDraw: null,
|
|
3343
|
+
onInputInteraction: null,
|
|
3344
|
+
displayPlugin: null,
|
|
3345
|
+
displayPluginOptions: null,
|
|
3346
|
+
onConfirm: null,
|
|
3347
|
+
onCancel: null,
|
|
3116
3348
|
};
|
|
3117
3349
|
class Datepicker extends Component {
|
|
3118
3350
|
id;
|
|
3119
3351
|
multiple = false;
|
|
3120
3352
|
calendarEl;
|
|
3121
3353
|
/** CLEAR button instance. */
|
|
3122
|
-
clearBtn;
|
|
3354
|
+
// clearBtn: HTMLElement;
|
|
3123
3355
|
/** DONE button instance */
|
|
3124
|
-
doneBtn;
|
|
3125
|
-
cancelBtn
|
|
3126
|
-
|
|
3356
|
+
/*doneBtn: HTMLElement;
|
|
3357
|
+
cancelBtn: HTMLElement;*/
|
|
3358
|
+
containerEl;
|
|
3127
3359
|
yearTextEl;
|
|
3128
3360
|
dateTextEl;
|
|
3129
3361
|
endDateEl;
|
|
@@ -3136,6 +3368,8 @@ class Datepicker extends Component {
|
|
|
3136
3368
|
calendars;
|
|
3137
3369
|
_y;
|
|
3138
3370
|
_m;
|
|
3371
|
+
displayPlugin;
|
|
3372
|
+
footer;
|
|
3139
3373
|
static _template;
|
|
3140
3374
|
constructor(el, options) {
|
|
3141
3375
|
super(el, options, Datepicker);
|
|
@@ -3189,6 +3423,10 @@ class Datepicker extends Component {
|
|
|
3189
3423
|
this.dateEls = [];
|
|
3190
3424
|
this.dateEls.push(el);
|
|
3191
3425
|
}
|
|
3426
|
+
if (this.options.displayPlugin) {
|
|
3427
|
+
if (this.options.displayPlugin === 'docked')
|
|
3428
|
+
this.displayPlugin = DockedDisplayPlugin.init(this.el, this.containerEl, this.options.displayPluginOptions);
|
|
3429
|
+
}
|
|
3192
3430
|
}
|
|
3193
3431
|
static get defaults() {
|
|
3194
3432
|
return _defaults$e;
|
|
@@ -3237,7 +3475,7 @@ class Datepicker extends Component {
|
|
|
3237
3475
|
}
|
|
3238
3476
|
destroy() {
|
|
3239
3477
|
this._removeEventHandlers();
|
|
3240
|
-
this.
|
|
3478
|
+
this.containerEl.remove();
|
|
3241
3479
|
this.destroySelects();
|
|
3242
3480
|
this.el['M_Datepicker'] = undefined;
|
|
3243
3481
|
}
|
|
@@ -3256,27 +3494,55 @@ class Datepicker extends Component {
|
|
|
3256
3494
|
if (this.el.type == 'date') {
|
|
3257
3495
|
this.el.classList.add('datepicker-date-input');
|
|
3258
3496
|
}
|
|
3497
|
+
if (!this.el.parentElement.querySelector('.datepicker-format') === null) {
|
|
3498
|
+
this._renderDateInputFormat(this.el);
|
|
3499
|
+
}
|
|
3259
3500
|
if (this.options.isDateRange) {
|
|
3260
|
-
this.
|
|
3261
|
-
this.
|
|
3501
|
+
this.containerEl.classList.add('daterange');
|
|
3502
|
+
if (!this.options.dateRangeEndEl) {
|
|
3503
|
+
this.endDateEl = this.createDateInput();
|
|
3504
|
+
this.endDateEl.classList.add('datepicker-end-date');
|
|
3505
|
+
}
|
|
3506
|
+
else if (document.querySelector(this.options.dateRangeEndEl) === undefined) {
|
|
3507
|
+
console.warn('Specified date range end input element in dateRangeEndEl not found');
|
|
3508
|
+
}
|
|
3509
|
+
else {
|
|
3510
|
+
this.endDateEl = document.querySelector(this.options.dateRangeEndEl);
|
|
3511
|
+
if (!this.endDateEl.parentElement.querySelector('.datepicker-format') === null) {
|
|
3512
|
+
this._renderDateInputFormat(this.endDateEl);
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3262
3515
|
}
|
|
3263
|
-
if (this.options.showClearBtn) {
|
|
3264
|
-
|
|
3265
|
-
|
|
3516
|
+
/*if (this.options.showClearBtn) {
|
|
3517
|
+
this.clearBtn.style.visibility = '';
|
|
3518
|
+
this.clearBtn.innerText = this.options.i18n.clear;
|
|
3266
3519
|
}
|
|
3267
3520
|
this.doneBtn.innerText = this.options.i18n.done;
|
|
3268
|
-
this.cancelBtn.innerText = this.options.i18n.cancel
|
|
3521
|
+
this.cancelBtn.innerText = this.options.i18n.cancel;*/
|
|
3522
|
+
Utils.createButton(this.footer, this.options.i18n.clear, ['datepicker-clear'], this.options.showClearBtn, this._handleClearClick);
|
|
3523
|
+
if (!this.options.autoSubmit) {
|
|
3524
|
+
Utils.createConfirmationContainer(this.footer, this.options.i18n.done, this.options.i18n.cancel, this._confirm, this._cancel);
|
|
3525
|
+
}
|
|
3269
3526
|
if (this.options.container) {
|
|
3270
3527
|
const optEl = this.options.container;
|
|
3271
3528
|
this.options.container =
|
|
3272
3529
|
optEl instanceof HTMLElement ? optEl : document.querySelector(optEl);
|
|
3273
|
-
this.options.container.append(this.
|
|
3530
|
+
this.options.container.append(this.containerEl);
|
|
3274
3531
|
}
|
|
3275
3532
|
else {
|
|
3276
|
-
//this.
|
|
3277
|
-
this.el
|
|
3533
|
+
//this.containerEl.before(this.el);
|
|
3534
|
+
const appendTo = !this.endDateEl ? this.el : this.endDateEl;
|
|
3535
|
+
if (!this.options.openByDefault)
|
|
3536
|
+
this.containerEl.setAttribute('style', 'display: none; visibility: hidden;');
|
|
3537
|
+
appendTo.parentElement.after(this.containerEl);
|
|
3278
3538
|
}
|
|
3279
3539
|
}
|
|
3540
|
+
/**
|
|
3541
|
+
* Renders the date input format
|
|
3542
|
+
*/
|
|
3543
|
+
_renderDateInputFormat(el) {
|
|
3544
|
+
el.parentElement.querySelector('.datepicker-format').innerHTML = this.options.format.toString();
|
|
3545
|
+
}
|
|
3280
3546
|
/**
|
|
3281
3547
|
* Gets a string representation of the given date.
|
|
3282
3548
|
*/
|
|
@@ -3417,7 +3683,6 @@ class Datepicker extends Component {
|
|
|
3417
3683
|
* Sets given date as the input value on the given element.
|
|
3418
3684
|
*/
|
|
3419
3685
|
setInputValue(el, date) {
|
|
3420
|
-
console.log('setinputvalue');
|
|
3421
3686
|
if (el.type == 'date') {
|
|
3422
3687
|
this.setDataDate(el, date);
|
|
3423
3688
|
el.value = this.formatDate(date, 'yyyy-mm-dd');
|
|
@@ -3521,7 +3786,7 @@ class Datepicker extends Component {
|
|
|
3521
3786
|
day < this.options.endRange, isDisabled = (this.options.minDate && day < this.options.minDate) ||
|
|
3522
3787
|
(this.options.maxDate && day > this.options.maxDate) ||
|
|
3523
3788
|
(this.options.disableWeekends && Datepicker._isWeekend(day)) ||
|
|
3524
|
-
(this.options.disableDayFn && this.options.disableDayFn(day)), isDateRange = this.options.isDateRange &&
|
|
3789
|
+
(this.options.disableDayFn && this.options.disableDayFn(day)), isDateRangeStart = this.options.isDateRange && this.date && this.endDate && Datepicker._compareDates(this.date, day), isDateRangeEnd = this.options.isDateRange && this.endDate && Datepicker._compareDates(this.endDate, day), isDateRange = this.options.isDateRange &&
|
|
3525
3790
|
Datepicker._isDate(this.endDate) &&
|
|
3526
3791
|
Datepicker._compareWithinRange(day, this.date, this.endDate);
|
|
3527
3792
|
let dayNumber = 1 + (i - before), monthNumber = month, yearNumber = year;
|
|
@@ -3561,6 +3826,8 @@ class Datepicker extends Component {
|
|
|
3561
3826
|
isEndRange: isEndRange,
|
|
3562
3827
|
isInRange: isInRange,
|
|
3563
3828
|
showDaysInNextAndPreviousMonths: this.options.showDaysInNextAndPreviousMonths,
|
|
3829
|
+
isDateRangeStart: isDateRangeStart,
|
|
3830
|
+
isDateRangeEnd: isDateRangeEnd,
|
|
3564
3831
|
isDateRange: isDateRange
|
|
3565
3832
|
};
|
|
3566
3833
|
row.push(this.renderDay(dayConfig));
|
|
@@ -3574,8 +3841,18 @@ class Datepicker extends Component {
|
|
|
3574
3841
|
return this.renderTable(this.options, data, randId);
|
|
3575
3842
|
}
|
|
3576
3843
|
renderDay(opts) {
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3844
|
+
const classMap = {
|
|
3845
|
+
isDisabled: 'is-disabled',
|
|
3846
|
+
isToday: 'is-today',
|
|
3847
|
+
isSelected: 'is-selected',
|
|
3848
|
+
hasEvent: 'has-event',
|
|
3849
|
+
isInRange: 'is-inrange',
|
|
3850
|
+
isStartRange: 'is-startrange',
|
|
3851
|
+
isEndRange: 'is-endrange',
|
|
3852
|
+
isDateRangeStart: 'is-daterange-start',
|
|
3853
|
+
isDateRangeEnd: 'is-daterange-end',
|
|
3854
|
+
isDateRange: 'is-daterange'
|
|
3855
|
+
}, ariaSelected = !(['isSelected', 'isDateRange'].filter((prop) => !!(opts.hasOwnProperty(prop) && opts[prop] === true)).length === 0), arr = ['datepicker-day'];
|
|
3579
3856
|
if (opts.isEmpty) {
|
|
3580
3857
|
if (opts.showDaysInNextAndPreviousMonths) {
|
|
3581
3858
|
arr.push('is-outside-current-month');
|
|
@@ -3585,36 +3862,10 @@ class Datepicker extends Component {
|
|
|
3585
3862
|
return '<td class="is-empty"></td>';
|
|
3586
3863
|
}
|
|
3587
3864
|
}
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
if (opts.isToday) {
|
|
3593
|
-
arr.push('is-today');
|
|
3594
|
-
}
|
|
3595
|
-
if (opts.isSelected) {
|
|
3596
|
-
arr.push('is-selected');
|
|
3597
|
-
ariaSelected = 'true';
|
|
3598
|
-
}
|
|
3599
|
-
// @todo should we create this additional css class?
|
|
3600
|
-
if (opts.hasEvent) {
|
|
3601
|
-
arr.push('has-event');
|
|
3602
|
-
}
|
|
3603
|
-
// @todo should we create this additional css class?
|
|
3604
|
-
if (opts.isInRange) {
|
|
3605
|
-
arr.push('is-inrange');
|
|
3606
|
-
}
|
|
3607
|
-
// @todo should we create this additional css class?
|
|
3608
|
-
if (opts.isStartRange) {
|
|
3609
|
-
arr.push('is-startrange');
|
|
3610
|
-
}
|
|
3611
|
-
// @todo should we create this additional css class?
|
|
3612
|
-
if (opts.isEndRange) {
|
|
3613
|
-
arr.push('is-endrange');
|
|
3614
|
-
}
|
|
3615
|
-
// @todo create additional css class
|
|
3616
|
-
if (opts.isDateRange) {
|
|
3617
|
-
arr.push('is-daterange');
|
|
3865
|
+
for (const [property, className] of Object.entries(classMap)) {
|
|
3866
|
+
if (opts.hasOwnProperty(property) && opts[property]) {
|
|
3867
|
+
arr.push(className);
|
|
3868
|
+
}
|
|
3618
3869
|
}
|
|
3619
3870
|
return (`<td data-day="${opts.day}" class="${arr.join(' ')}" aria-selected="${ariaSelected}">` +
|
|
3620
3871
|
`<button class="datepicker-day-button" type="button" data-year="${opts.year}" data-month="${opts.month}" data-day="${opts.day}">${opts.day}</button>` +
|
|
@@ -3683,7 +3934,9 @@ class Datepicker extends Component {
|
|
|
3683
3934
|
arr.reverse();
|
|
3684
3935
|
const yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join('')}</select>`;
|
|
3685
3936
|
const leftArrow = '<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z"/><path d="M0-.5h24v24H0z" fill="none"/></svg>';
|
|
3686
|
-
html += `<button class="month-prev${prev ? '' : ' is-disabled'
|
|
3937
|
+
html += `<button class="month-prev${prev ? '' : ' is-disabled'
|
|
3938
|
+
// @todo remove button class and add scss mixin, current implementation temporary for focus states, @see https://github.com/materializecss/materialize/issues/566
|
|
3939
|
+
} btn" type="button">${leftArrow}</button>`;
|
|
3687
3940
|
html += '<div class="selects-container">';
|
|
3688
3941
|
if (opts.showMonthAfterYear) {
|
|
3689
3942
|
html += yearHtml + monthHtml;
|
|
@@ -3699,7 +3952,9 @@ class Datepicker extends Component {
|
|
|
3699
3952
|
next = false;
|
|
3700
3953
|
}
|
|
3701
3954
|
const rightArrow = '<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z"/><path d="M0-.25h24v24H0z" fill="none"/></svg>';
|
|
3702
|
-
html += `<button class="month-next${next ? '' : ' is-disabled'
|
|
3955
|
+
html += `<button class="month-next${next ? '' : ' is-disabled'
|
|
3956
|
+
// @todo remove button class and add scss mixin, current implementation temporary for focus states, @see https://github.com/materializecss/materialize/issues/566
|
|
3957
|
+
} btn" type="button">${rightArrow}</button>`;
|
|
3703
3958
|
return (html += '</div>');
|
|
3704
3959
|
}
|
|
3705
3960
|
// refresh HTML
|
|
@@ -3738,6 +3993,7 @@ class Datepicker extends Component {
|
|
|
3738
3993
|
// Init Materialize Select
|
|
3739
3994
|
const yearSelect = this.calendarEl.querySelector('.orig-select-year');
|
|
3740
3995
|
const monthSelect = this.calendarEl.querySelector('.orig-select-month');
|
|
3996
|
+
// @todo fix accessibility @see https://github.com/materializecss/materialize/issues/522
|
|
3741
3997
|
FormSelect.init(yearSelect, {
|
|
3742
3998
|
classes: 'select-year',
|
|
3743
3999
|
dropdownOptions: { container: document.body, constrainWidth: false }
|
|
@@ -3758,25 +4014,26 @@ class Datepicker extends Component {
|
|
|
3758
4014
|
this.el.addEventListener('keydown', this._handleInputKeydown);
|
|
3759
4015
|
this.el.addEventListener('change', this._handleInputChange);
|
|
3760
4016
|
this.calendarEl.addEventListener('click', this._handleCalendarClick);
|
|
3761
|
-
this.doneBtn.addEventListener('click',
|
|
3762
|
-
this.cancelBtn.addEventListener('click', this.
|
|
4017
|
+
/* this.doneBtn.addEventListener('click', this._confirm);
|
|
4018
|
+
this.cancelBtn.addEventListener('click', this._cancel);
|
|
4019
|
+
|
|
3763
4020
|
if (this.options.showClearBtn) {
|
|
3764
|
-
|
|
3765
|
-
}
|
|
4021
|
+
this.clearBtn.addEventListener('click', this._handleClearClick);
|
|
4022
|
+
}*/
|
|
3766
4023
|
}
|
|
3767
4024
|
_setupVariables() {
|
|
3768
4025
|
const template = document.createElement('template');
|
|
3769
4026
|
template.innerHTML = Datepicker._template.trim();
|
|
3770
|
-
this.
|
|
3771
|
-
this.calendarEl = this.
|
|
3772
|
-
this.yearTextEl = this.
|
|
3773
|
-
this.dateTextEl = this.
|
|
3774
|
-
if (this.options.showClearBtn) {
|
|
3775
|
-
|
|
3776
|
-
}
|
|
3777
|
-
|
|
3778
|
-
this.
|
|
3779
|
-
this.
|
|
4027
|
+
this.containerEl = template.content.firstChild;
|
|
4028
|
+
this.calendarEl = this.containerEl.querySelector('.datepicker-calendar');
|
|
4029
|
+
this.yearTextEl = this.containerEl.querySelector('.year-text');
|
|
4030
|
+
this.dateTextEl = this.containerEl.querySelector('.date-text');
|
|
4031
|
+
/* if (this.options.showClearBtn) {
|
|
4032
|
+
this.clearBtn = this.containerEl.querySelector('.datepicker-clear');
|
|
4033
|
+
}
|
|
4034
|
+
this.doneBtn = this.containerEl.querySelector('.datepicker-done');
|
|
4035
|
+
this.cancelBtn = this.containerEl.querySelector('.datepicker-cancel');*/
|
|
4036
|
+
this.footer = this.containerEl.querySelector('.datepicker-footer');
|
|
3780
4037
|
this.formats = {
|
|
3781
4038
|
d: (date) => {
|
|
3782
4039
|
return date.getDate();
|
|
@@ -3831,12 +4088,20 @@ class Datepicker extends Component {
|
|
|
3831
4088
|
this.setDateFromInput(e.target);
|
|
3832
4089
|
this.draw();
|
|
3833
4090
|
this.gotoDate(e.target === this.el ? this.date : this.endDate);
|
|
4091
|
+
if (this.displayPlugin)
|
|
4092
|
+
this.displayPlugin.show();
|
|
4093
|
+
if (this.options.onInputInteraction)
|
|
4094
|
+
this.options.onInputInteraction.call(this);
|
|
3834
4095
|
};
|
|
3835
4096
|
_handleInputKeydown = (e) => {
|
|
3836
4097
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
3837
4098
|
e.preventDefault();
|
|
3838
4099
|
this.setDateFromInput(e.target);
|
|
3839
4100
|
this.draw();
|
|
4101
|
+
if (this.displayPlugin)
|
|
4102
|
+
this.displayPlugin.show();
|
|
4103
|
+
if (this.options.onInputInteraction)
|
|
4104
|
+
this.options.onInputInteraction.call(this);
|
|
3840
4105
|
}
|
|
3841
4106
|
};
|
|
3842
4107
|
_handleCalendarClick = (e) => {
|
|
@@ -3852,7 +4117,8 @@ class Datepicker extends Component {
|
|
|
3852
4117
|
if (this.options.isDateRange) {
|
|
3853
4118
|
this._handleDateRangeCalendarClick(selectedDate);
|
|
3854
4119
|
}
|
|
3855
|
-
this.
|
|
4120
|
+
if (this.options.autoSubmit)
|
|
4121
|
+
this._finishSelection();
|
|
3856
4122
|
}
|
|
3857
4123
|
else if (target.closest('.month-prev')) {
|
|
3858
4124
|
this.prevMonth();
|
|
@@ -3880,6 +4146,7 @@ class Datepicker extends Component {
|
|
|
3880
4146
|
_clearDates = () => {
|
|
3881
4147
|
this.date = null;
|
|
3882
4148
|
this.endDate = null;
|
|
4149
|
+
this.draw();
|
|
3883
4150
|
};
|
|
3884
4151
|
_handleMonthChange = (e) => {
|
|
3885
4152
|
this.gotoMonth(e.target.value);
|
|
@@ -3944,7 +4211,17 @@ class Datepicker extends Component {
|
|
|
3944
4211
|
// Set input value to the selected date and close Datepicker
|
|
3945
4212
|
_finishSelection = () => {
|
|
3946
4213
|
this.setInputValues();
|
|
3947
|
-
|
|
4214
|
+
// Commented out because of function deprecations
|
|
4215
|
+
// this.close();
|
|
4216
|
+
};
|
|
4217
|
+
_confirm = () => {
|
|
4218
|
+
this._finishSelection();
|
|
4219
|
+
if (typeof this.options.onConfirm === 'function')
|
|
4220
|
+
this.options.onConfirm.call(this);
|
|
4221
|
+
};
|
|
4222
|
+
_cancel = () => {
|
|
4223
|
+
if (typeof this.options.onCancel === 'function')
|
|
4224
|
+
this.options.onCancel.call(this);
|
|
3948
4225
|
};
|
|
3949
4226
|
// deprecated
|
|
3950
4227
|
open() {
|
|
@@ -3957,8 +4234,7 @@ class Datepicker extends Component {
|
|
|
3957
4234
|
}
|
|
3958
4235
|
static {
|
|
3959
4236
|
Datepicker._template = `
|
|
3960
|
-
|
|
3961
|
-
<div class="modal-content datepicker-container">
|
|
4237
|
+
<div class="datepicker-container">
|
|
3962
4238
|
<div class="datepicker-date-display">
|
|
3963
4239
|
<span class="year-text"></span>
|
|
3964
4240
|
<span class="date-text"></span>
|
|
@@ -3966,15 +4242,14 @@ class Datepicker extends Component {
|
|
|
3966
4242
|
<div class="datepicker-calendar-container">
|
|
3967
4243
|
<div class="datepicker-calendar"></div>
|
|
3968
4244
|
<div class="datepicker-footer">
|
|
3969
|
-
|
|
4245
|
+
<!--<button class="btn-flat datepicker-clear waves-effect" style="visibility: hidden;" type="button"></button>
|
|
3970
4246
|
<div class="confirmation-btns">
|
|
3971
4247
|
<button class="btn-flat datepicker-cancel waves-effect" type="button"></button>
|
|
3972
4248
|
<button class="btn-flat datepicker-done waves-effect" type="button"></button>
|
|
3973
|
-
</div
|
|
4249
|
+
</div>-->
|
|
3974
4250
|
</div>
|
|
3975
4251
|
</div>
|
|
3976
|
-
</div
|
|
3977
|
-
</div>`;
|
|
4252
|
+
</div>`;
|
|
3978
4253
|
}
|
|
3979
4254
|
}
|
|
3980
4255
|
|
|
@@ -4083,7 +4358,7 @@ class Forms {
|
|
|
4083
4358
|
// So we set the height to the original one
|
|
4084
4359
|
textarea.style.height = originalHeight + 'px';
|
|
4085
4360
|
}
|
|
4086
|
-
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
4361
|
+
textarea.setAttribute('previous-length', (textarea.value || '').length.toString());
|
|
4087
4362
|
}
|
|
4088
4363
|
static Init() {
|
|
4089
4364
|
if (typeof document !== 'undefined')
|
|
@@ -4130,7 +4405,7 @@ class Forms {
|
|
|
4130
4405
|
static InitTextarea(textarea) {
|
|
4131
4406
|
// Save Data in Element
|
|
4132
4407
|
textarea.setAttribute('original-height', textarea.getBoundingClientRect().height.toString());
|
|
4133
|
-
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
4408
|
+
textarea.setAttribute('previous-length', (textarea.value || '').length.toString());
|
|
4134
4409
|
Forms.textareaAutoResize(textarea);
|
|
4135
4410
|
textarea.addEventListener('keyup', (e) => Forms.textareaAutoResize(e.target));
|
|
4136
4411
|
textarea.addEventListener('keydown', (e) => Forms.textareaAutoResize(e.target));
|
|
@@ -4879,9 +5154,7 @@ class ScrollSpy extends Component {
|
|
|
4879
5154
|
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
4880
5155
|
}
|
|
4881
5156
|
}
|
|
4882
|
-
_handleThrottledResize = Utils.throttle(
|
|
4883
|
-
this._handleWindowScroll();
|
|
4884
|
-
}, 200).bind(this);
|
|
5157
|
+
_handleThrottledResize = () => Utils.throttle(this._handleWindowScroll, 200).bind(this);
|
|
4885
5158
|
_handleTriggerClick = (e) => {
|
|
4886
5159
|
const trigger = e.target;
|
|
4887
5160
|
for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
|
|
@@ -5851,9 +6124,7 @@ class TapTarget extends Component {
|
|
|
5851
6124
|
// this.originEl.removeEventListener('click', this._handleOriginClick);
|
|
5852
6125
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
5853
6126
|
}
|
|
5854
|
-
_handleThrottledResize = Utils.throttle(
|
|
5855
|
-
this._handleResize();
|
|
5856
|
-
}, 200).bind(this);
|
|
6127
|
+
_handleThrottledResize = () => Utils.throttle(this._handleResize, 200).bind(this);
|
|
5857
6128
|
_handleKeyboardInteraction = (e) => {
|
|
5858
6129
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
5859
6130
|
this._handleTargetToggle();
|
|
@@ -6052,6 +6323,7 @@ const _defaults$5 = {
|
|
|
6052
6323
|
defaultTime: 'now', // default time, 'now' or '13:14' e.g.
|
|
6053
6324
|
fromNow: 0, // Millisecond offset from the defaultTime
|
|
6054
6325
|
showClearBtn: false,
|
|
6326
|
+
autoSubmit: true,
|
|
6055
6327
|
// internationalization
|
|
6056
6328
|
i18n: {
|
|
6057
6329
|
cancel: 'Cancel',
|
|
@@ -6061,11 +6333,16 @@ const _defaults$5 = {
|
|
|
6061
6333
|
twelveHour: true, // change to 12 hour AM/PM clock from 24 hour
|
|
6062
6334
|
vibrate: true, // vibrate the device when dragging clock hand
|
|
6063
6335
|
// Callbacks
|
|
6064
|
-
onSelect: null
|
|
6336
|
+
onSelect: null,
|
|
6337
|
+
onInputInteraction: null,
|
|
6338
|
+
onDone: null,
|
|
6339
|
+
onCancel: null,
|
|
6340
|
+
displayPlugin: null,
|
|
6341
|
+
displayPluginOptions: null,
|
|
6065
6342
|
};
|
|
6066
6343
|
class Timepicker extends Component {
|
|
6067
6344
|
id;
|
|
6068
|
-
|
|
6345
|
+
containerEl;
|
|
6069
6346
|
plate;
|
|
6070
6347
|
digitalClock;
|
|
6071
6348
|
inputHours;
|
|
@@ -6105,6 +6382,7 @@ class Timepicker extends Component {
|
|
|
6105
6382
|
g;
|
|
6106
6383
|
toggleViewTimer;
|
|
6107
6384
|
vibrateTimer;
|
|
6385
|
+
displayPlugin;
|
|
6108
6386
|
constructor(el, options) {
|
|
6109
6387
|
super(el, options, Timepicker);
|
|
6110
6388
|
this.el['M_Timepicker'] = this;
|
|
@@ -6118,6 +6396,10 @@ class Timepicker extends Component {
|
|
|
6118
6396
|
this._setupEventHandlers();
|
|
6119
6397
|
this._clockSetup();
|
|
6120
6398
|
this._pickerSetup();
|
|
6399
|
+
if (this.options.displayPlugin) {
|
|
6400
|
+
if (this.options.displayPlugin === 'docked')
|
|
6401
|
+
this.displayPlugin = DockedDisplayPlugin.init(this.el, this.containerEl, this.options.displayPluginOptions);
|
|
6402
|
+
}
|
|
6121
6403
|
}
|
|
6122
6404
|
static get defaults() {
|
|
6123
6405
|
return _defaults$5;
|
|
@@ -6152,7 +6434,7 @@ class Timepicker extends Component {
|
|
|
6152
6434
|
}
|
|
6153
6435
|
destroy() {
|
|
6154
6436
|
this._removeEventHandlers();
|
|
6155
|
-
this.
|
|
6437
|
+
this.containerEl.remove();
|
|
6156
6438
|
this.el['M_Timepicker'] = undefined;
|
|
6157
6439
|
}
|
|
6158
6440
|
_setupEventHandlers() {
|
|
@@ -6171,12 +6453,20 @@ class Timepicker extends Component {
|
|
|
6171
6453
|
this.el.removeEventListener('keydown', this._handleInputKeydown);
|
|
6172
6454
|
}
|
|
6173
6455
|
_handleInputClick = () => {
|
|
6174
|
-
this.
|
|
6456
|
+
this.inputHours.focus();
|
|
6457
|
+
if (typeof this.options.onInputInteraction === 'function')
|
|
6458
|
+
this.options.onInputInteraction.call(this);
|
|
6459
|
+
if (this.displayPlugin)
|
|
6460
|
+
this.displayPlugin.show();
|
|
6175
6461
|
};
|
|
6176
6462
|
_handleInputKeydown = (e) => {
|
|
6177
6463
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
6178
6464
|
e.preventDefault();
|
|
6179
|
-
this.
|
|
6465
|
+
this.inputHours.focus();
|
|
6466
|
+
if (typeof this.options.onInputInteraction === 'function')
|
|
6467
|
+
this.options.onInputInteraction.call(this);
|
|
6468
|
+
if (this.displayPlugin)
|
|
6469
|
+
this.displayPlugin.show();
|
|
6180
6470
|
}
|
|
6181
6471
|
};
|
|
6182
6472
|
_handleTimeInputEnterKey = (e) => {
|
|
@@ -6223,12 +6513,14 @@ class Timepicker extends Component {
|
|
|
6223
6513
|
this.setHand(x, y);
|
|
6224
6514
|
}
|
|
6225
6515
|
if (this.currentView === 'hours') {
|
|
6516
|
+
this.inputMinutes.focus();
|
|
6226
6517
|
this.showView('minutes', this.options.duration / 2);
|
|
6227
6518
|
}
|
|
6228
6519
|
else {
|
|
6229
|
-
this.minutesView.classList.add('timepicker-dial-out');
|
|
6520
|
+
// this.minutesView.classList.add('timepicker-dial-out');
|
|
6230
6521
|
setTimeout(() => {
|
|
6231
|
-
this.
|
|
6522
|
+
if (this.options.autoSubmit)
|
|
6523
|
+
this.done();
|
|
6232
6524
|
}, this.options.duration / 2);
|
|
6233
6525
|
}
|
|
6234
6526
|
if (typeof this.options.onSelect === 'function') {
|
|
@@ -6241,16 +6533,16 @@ class Timepicker extends Component {
|
|
|
6241
6533
|
_insertHTMLIntoDOM() {
|
|
6242
6534
|
const template = document.createElement('template');
|
|
6243
6535
|
template.innerHTML = Timepicker._template.trim();
|
|
6244
|
-
this.
|
|
6245
|
-
this.
|
|
6536
|
+
this.containerEl = template.content.firstChild;
|
|
6537
|
+
this.containerEl.id = 'container-' + this.id;
|
|
6246
6538
|
// Append popover to input by default
|
|
6247
6539
|
const optEl = this.options.container;
|
|
6248
6540
|
const containerEl = optEl instanceof HTMLElement ? optEl : document.querySelector(optEl);
|
|
6249
6541
|
if (this.options.container && !!containerEl) {
|
|
6250
|
-
containerEl.append(this.
|
|
6542
|
+
containerEl.append(this.containerEl);
|
|
6251
6543
|
}
|
|
6252
6544
|
else {
|
|
6253
|
-
this.el.parentElement.appendChild(this.
|
|
6545
|
+
this.el.parentElement.appendChild(this.containerEl);
|
|
6254
6546
|
}
|
|
6255
6547
|
}
|
|
6256
6548
|
_setupVariables() {
|
|
@@ -6260,42 +6552,49 @@ class Timepicker extends Component {
|
|
|
6260
6552
|
: navigator['webkitVibrate']
|
|
6261
6553
|
? 'webkitVibrate'
|
|
6262
6554
|
: null;
|
|
6263
|
-
this._canvas = this.
|
|
6264
|
-
this.plate = this.
|
|
6265
|
-
this.digitalClock = this.
|
|
6266
|
-
this.hoursView = this.
|
|
6267
|
-
this.minutesView = this.
|
|
6268
|
-
this.inputHours = this.
|
|
6269
|
-
this.inputMinutes = this.
|
|
6270
|
-
this.spanAmPm = this.
|
|
6271
|
-
this.footer = this.
|
|
6555
|
+
this._canvas = this.containerEl.querySelector('.timepicker-canvas');
|
|
6556
|
+
this.plate = this.containerEl.querySelector('.timepicker-plate');
|
|
6557
|
+
this.digitalClock = this.containerEl.querySelector('.timepicker-display-column');
|
|
6558
|
+
this.hoursView = this.containerEl.querySelector('.timepicker-hours');
|
|
6559
|
+
this.minutesView = this.containerEl.querySelector('.timepicker-minutes');
|
|
6560
|
+
this.inputHours = this.containerEl.querySelector('.timepicker-input-hours');
|
|
6561
|
+
this.inputMinutes = this.containerEl.querySelector('.timepicker-input-minutes');
|
|
6562
|
+
this.spanAmPm = this.containerEl.querySelector('.timepicker-span-am-pm');
|
|
6563
|
+
this.footer = this.containerEl.querySelector('.timepicker-footer');
|
|
6272
6564
|
this.amOrPm = 'PM';
|
|
6273
6565
|
}
|
|
6274
|
-
_createButton(text, visibility) {
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
}
|
|
6566
|
+
/*private _createButton(text: string, visibility: string): HTMLButtonElement {
|
|
6567
|
+
const button = document.createElement('button');
|
|
6568
|
+
button.classList.add('btn', 'waves-effect', 'text');
|
|
6569
|
+
button.style.visibility = visibility;
|
|
6570
|
+
button.type = 'button';
|
|
6571
|
+
button.tabIndex = -1;
|
|
6572
|
+
button.innerText = text;
|
|
6573
|
+
return button;
|
|
6574
|
+
}*/
|
|
6283
6575
|
_pickerSetup() {
|
|
6284
|
-
|
|
6285
|
-
clearButton.
|
|
6286
|
-
|
|
6287
|
-
this.footer.
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6576
|
+
// clearButton.classList.add('timepicker-clear');
|
|
6577
|
+
// clearButton.addEventListener('click', this.clear);
|
|
6578
|
+
// this.footer.appendChild(clearButton);
|
|
6579
|
+
Utils.createButton(this.footer, this.options.i18n.clear, ['timepicker-clear'], this.options.showClearBtn, this.clear);
|
|
6580
|
+
if (!this.options.autoSubmit) {
|
|
6581
|
+
/*const confirmationBtnsContainer = document.createElement('div');
|
|
6582
|
+
confirmationBtnsContainer.classList.add('confirmation-btns');
|
|
6583
|
+
this.footer.append(confirmationBtnsContainer);
|
|
6584
|
+
|
|
6585
|
+
const cancelButton = this._createButton(this.options.i18n.cancel, '');
|
|
6586
|
+
cancelButton.classList.add('timepicker-close');
|
|
6587
|
+
cancelButton.addEventListener('click', this.close);
|
|
6588
|
+
confirmationBtnsContainer.appendChild(cancelButton);
|
|
6589
|
+
|
|
6590
|
+
const doneButton = this._createButton(this.options.i18n.done, '');
|
|
6591
|
+
doneButton.classList.add('timepicker-close');
|
|
6592
|
+
//doneButton.addEventListener('click', this._finishSelection);
|
|
6593
|
+
confirmationBtnsContainer.appendChild(doneButton);*/
|
|
6594
|
+
Utils.createConfirmationContainer(this.footer, this.options.i18n.done, this.options.i18n.cancel, this.confirm, this.cancel);
|
|
6595
|
+
}
|
|
6596
|
+
this._updateTimeFromInput();
|
|
6597
|
+
this.showView('hours');
|
|
6299
6598
|
}
|
|
6300
6599
|
_clockSetup() {
|
|
6301
6600
|
if (this.options.twelveHour) {
|
|
@@ -6303,13 +6602,17 @@ class Timepicker extends Component {
|
|
|
6303
6602
|
this._amBtn = document.createElement('div');
|
|
6304
6603
|
this._amBtn.classList.add('am-btn', 'btn');
|
|
6305
6604
|
this._amBtn.innerText = 'AM';
|
|
6605
|
+
this._amBtn.tabIndex = 0;
|
|
6306
6606
|
this._amBtn.addEventListener('click', this._handleAmPmClick);
|
|
6607
|
+
this._amBtn.addEventListener('keypress', this._handleAmPmKeypress);
|
|
6307
6608
|
this.spanAmPm.appendChild(this._amBtn);
|
|
6308
6609
|
// PM Button
|
|
6309
6610
|
this._pmBtn = document.createElement('div');
|
|
6310
6611
|
this._pmBtn.classList.add('pm-btn', 'btn');
|
|
6311
6612
|
this._pmBtn.innerText = 'PM';
|
|
6613
|
+
this._pmBtn.tabIndex = 0;
|
|
6312
6614
|
this._pmBtn.addEventListener('click', this._handleAmPmClick);
|
|
6615
|
+
this._pmBtn.addEventListener('keypress', this._handleAmPmKeypress);
|
|
6313
6616
|
this.spanAmPm.appendChild(this._pmBtn);
|
|
6314
6617
|
}
|
|
6315
6618
|
this._buildHoursView();
|
|
@@ -6402,8 +6705,15 @@ class Timepicker extends Component {
|
|
|
6402
6705
|
}
|
|
6403
6706
|
}
|
|
6404
6707
|
_handleAmPmClick = (e) => {
|
|
6405
|
-
|
|
6406
|
-
|
|
6708
|
+
this._handleAmPmInteraction(e.target);
|
|
6709
|
+
};
|
|
6710
|
+
_handleAmPmKeypress = (e) => {
|
|
6711
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
6712
|
+
this._handleAmPmInteraction(e.target);
|
|
6713
|
+
}
|
|
6714
|
+
};
|
|
6715
|
+
_handleAmPmInteraction = (e) => {
|
|
6716
|
+
this.amOrPm = e.classList.contains('am-btn') ? 'AM' : 'PM';
|
|
6407
6717
|
this._updateAmPmView();
|
|
6408
6718
|
};
|
|
6409
6719
|
_updateAmPmView() {
|
|
@@ -6452,14 +6762,13 @@ class Timepicker extends Component {
|
|
|
6452
6762
|
if (view === 'minutes' && getComputedStyle(this.hoursView).visibility === 'visible') ;
|
|
6453
6763
|
const isHours = view === 'hours', nextView = isHours ? this.hoursView : this.minutesView, hideView = isHours ? this.minutesView : this.hoursView;
|
|
6454
6764
|
this.currentView = view;
|
|
6455
|
-
if (isHours) {
|
|
6456
|
-
|
|
6457
|
-
|
|
6458
|
-
}
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
}
|
|
6765
|
+
/*if (isHours) {
|
|
6766
|
+
this.inputHours.classList.add('text-primary');
|
|
6767
|
+
this.inputMinutes.classList.remove('text-primary');
|
|
6768
|
+
} else {
|
|
6769
|
+
this.inputHours.classList.remove('text-primary');
|
|
6770
|
+
this.inputMinutes.classList.add('text-primary');
|
|
6771
|
+
}*/
|
|
6463
6772
|
// Transition view
|
|
6464
6773
|
hideView.classList.add('timepicker-dial-out');
|
|
6465
6774
|
nextView.style.visibility = 'visible';
|
|
@@ -6608,8 +6917,7 @@ class Timepicker extends Component {
|
|
|
6608
6917
|
this.hours = new Date().getHours();
|
|
6609
6918
|
this.inputHours.value = (this.hours % (this.options.twelveHour ? 12 : 24)).toString();
|
|
6610
6919
|
}
|
|
6611
|
-
|
|
6612
|
-
done = (e = null, clearValue = null) => {
|
|
6920
|
+
done = (clearValue = null) => {
|
|
6613
6921
|
// Set input value
|
|
6614
6922
|
const last = this.el.value;
|
|
6615
6923
|
let value = clearValue
|
|
@@ -6624,16 +6932,23 @@ class Timepicker extends Component {
|
|
|
6624
6932
|
if (value !== last) {
|
|
6625
6933
|
this.el.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));
|
|
6626
6934
|
}
|
|
6627
|
-
|
|
6628
|
-
|
|
6935
|
+
};
|
|
6936
|
+
confirm = () => {
|
|
6937
|
+
this.done();
|
|
6938
|
+
if (typeof this.options.onDone === 'function')
|
|
6939
|
+
this.options.onDone.call(this);
|
|
6940
|
+
};
|
|
6941
|
+
cancel = () => {
|
|
6942
|
+
// not logical clearing the input field on cancel, since the end user might want to make use of the previously submitted value
|
|
6943
|
+
// this.clear();
|
|
6944
|
+
if (typeof this.options.onCancel === 'function')
|
|
6945
|
+
this.options.onCancel.call(this);
|
|
6629
6946
|
};
|
|
6630
6947
|
clear = () => {
|
|
6631
|
-
this.done(
|
|
6948
|
+
this.done(true);
|
|
6632
6949
|
};
|
|
6633
6950
|
// deprecated
|
|
6634
6951
|
open() {
|
|
6635
|
-
// this._updateTimeFromInput();
|
|
6636
|
-
// this.showView('hours');
|
|
6637
6952
|
console.warn('Timepicker.close() is deprecated. Remove this method and wrap in modal yourself.');
|
|
6638
6953
|
return this;
|
|
6639
6954
|
}
|
|
@@ -6642,14 +6957,12 @@ class Timepicker extends Component {
|
|
|
6642
6957
|
return this;
|
|
6643
6958
|
}
|
|
6644
6959
|
static {
|
|
6645
|
-
Timepicker._template =
|
|
6646
|
-
<div class="modal timepicker-modal">
|
|
6647
|
-
<div class="modal-content timepicker-container">
|
|
6960
|
+
Timepicker._template = `<div class="timepicker-container">
|
|
6648
6961
|
<div class="timepicker-digital-display">
|
|
6649
6962
|
<div class="timepicker-text-container">
|
|
6650
|
-
<div class="timepicker-display-column">
|
|
6963
|
+
<div class="timepicker-display-column timepicker-display-digital-clock">
|
|
6651
6964
|
<div class="timepicker-input-hours-wrapper">
|
|
6652
|
-
<input type="text" maxlength="2"
|
|
6965
|
+
<input type="text" maxlength="2" class="timepicker-input-hours text-primary" />
|
|
6653
6966
|
</div>
|
|
6654
6967
|
<div class="timepicker-input-divider-wrapper">
|
|
6655
6968
|
<span class="timepicker-input-divider">:</span>
|
|
@@ -6671,8 +6984,7 @@ class Timepicker extends Component {
|
|
|
6671
6984
|
</div>
|
|
6672
6985
|
<div class="timepicker-footer"></div>
|
|
6673
6986
|
</div>
|
|
6674
|
-
</div
|
|
6675
|
-
</div>`;
|
|
6987
|
+
</div>`;
|
|
6676
6988
|
}
|
|
6677
6989
|
}
|
|
6678
6990
|
|
|
@@ -7835,7 +8147,7 @@ class Toast {
|
|
|
7835
8147
|
}
|
|
7836
8148
|
|
|
7837
8149
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7838
|
-
const version = '2.2.
|
|
8150
|
+
const version = '2.2.2';
|
|
7839
8151
|
/**
|
|
7840
8152
|
* Automatically initialize components.
|
|
7841
8153
|
* @param context Root element to initialize. Defaults to `document.body`.
|
|
@@ -7894,5 +8206,6 @@ Forms.Init();
|
|
|
7894
8206
|
Chips.Init();
|
|
7895
8207
|
Waves.Init();
|
|
7896
8208
|
Range.Init();
|
|
8209
|
+
Cards.Init();
|
|
7897
8210
|
|
|
7898
8211
|
export { AutoInit, Autocomplete, Cards, Carousel, CharacterCounter, Chips, Collapsible, Datepicker, Dropdown, FloatingActionButton, FormSelect, Forms, Materialbox, Modal, Parallax, Pushpin, Range, ScrollSpy, Sidenav, Slider, Tabs, TapTarget, Timepicker, Toast, Tooltip, Waves, version };
|