@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
|
@@ -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
|
'use strict';
|
|
@@ -218,13 +218,11 @@ class Utils {
|
|
|
218
218
|
if (!previous && options.leading === false)
|
|
219
219
|
previous = now;
|
|
220
220
|
const remaining = wait - (now - previous);
|
|
221
|
-
context = this;
|
|
222
221
|
if (remaining <= 0) {
|
|
223
222
|
clearTimeout(timeout);
|
|
224
223
|
timeout = null;
|
|
225
224
|
previous = now;
|
|
226
|
-
result = func.apply(
|
|
227
|
-
context = args = null;
|
|
225
|
+
result = func.apply(this, args);
|
|
228
226
|
}
|
|
229
227
|
else if (!timeout && options.trailing !== false) {
|
|
230
228
|
timeout = setTimeout(later, remaining);
|
|
@@ -232,6 +230,105 @@ class Utils {
|
|
|
232
230
|
return result;
|
|
233
231
|
};
|
|
234
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Renders confirm/close buttons with callback function
|
|
235
|
+
*/
|
|
236
|
+
static createConfirmationContainer(container, confirmText, cancelText, onConfirm, onCancel) {
|
|
237
|
+
const confirmationButtonsContainer = document.createElement('div');
|
|
238
|
+
confirmationButtonsContainer.classList.add('confirmation-btns');
|
|
239
|
+
container.append(confirmationButtonsContainer);
|
|
240
|
+
this.createButton(confirmationButtonsContainer, cancelText, ['btn-cancel'], true, onCancel);
|
|
241
|
+
this.createButton(confirmationButtonsContainer, confirmText, ['btn-confirm'], true, onConfirm);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Renders a button with optional callback function
|
|
245
|
+
*/
|
|
246
|
+
static createButton(container, text, className = [], visibility = true, callback = null) {
|
|
247
|
+
className = className.concat(['btn', 'waves-effect', 'text']);
|
|
248
|
+
const button = document.createElement('button');
|
|
249
|
+
button.className = className.join(' ');
|
|
250
|
+
button.style.visibility = visibility ? 'visible' : 'hidden';
|
|
251
|
+
button.type = 'button';
|
|
252
|
+
button.tabIndex = !!visibility ? 0 : -1;
|
|
253
|
+
button.innerText = text;
|
|
254
|
+
button.addEventListener('click', callback);
|
|
255
|
+
button.addEventListener('keypress', (e) => {
|
|
256
|
+
if (Utils.keys.ENTER.includes(e.key))
|
|
257
|
+
callback(e);
|
|
258
|
+
});
|
|
259
|
+
container.append(button);
|
|
260
|
+
}
|
|
261
|
+
static _setAbsolutePosition(origin, container, position, margin, transitionMovement, align = 'center') {
|
|
262
|
+
const originHeight = origin.offsetHeight, originWidth = origin.offsetWidth, containerHeight = container.offsetHeight, containerWidth = container.offsetWidth;
|
|
263
|
+
let xMovement = 0, yMovement = 0, targetTop = origin.getBoundingClientRect().top + Utils.getDocumentScrollTop(), targetLeft = origin.getBoundingClientRect().left + Utils.getDocumentScrollLeft();
|
|
264
|
+
if (position === 'top') {
|
|
265
|
+
targetTop += -containerHeight - margin;
|
|
266
|
+
if (align === 'center') {
|
|
267
|
+
targetLeft += originWidth / 2 - containerWidth / 2; // This is center align
|
|
268
|
+
}
|
|
269
|
+
yMovement = -transitionMovement;
|
|
270
|
+
}
|
|
271
|
+
else if (position === 'right') {
|
|
272
|
+
targetTop += originHeight / 2 - containerHeight / 2;
|
|
273
|
+
targetLeft = originWidth + margin;
|
|
274
|
+
xMovement = transitionMovement;
|
|
275
|
+
}
|
|
276
|
+
else if (position === 'left') {
|
|
277
|
+
targetTop += originHeight / 2 - containerHeight / 2;
|
|
278
|
+
targetLeft = -containerWidth - margin;
|
|
279
|
+
xMovement = -transitionMovement;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
targetTop += originHeight + margin;
|
|
283
|
+
if (align === 'center') {
|
|
284
|
+
targetLeft += originWidth / 2 - containerWidth / 2; // This is center align
|
|
285
|
+
}
|
|
286
|
+
yMovement = transitionMovement;
|
|
287
|
+
}
|
|
288
|
+
if (align === 'right') {
|
|
289
|
+
targetLeft += originWidth - containerWidth - margin;
|
|
290
|
+
}
|
|
291
|
+
const newCoordinates = Utils._repositionWithinScreen(targetLeft, targetTop, containerWidth, containerHeight, margin, transitionMovement, align);
|
|
292
|
+
container.style.top = newCoordinates.y + 'px';
|
|
293
|
+
container.style.left = newCoordinates.x + 'px';
|
|
294
|
+
return { x: xMovement, y: yMovement };
|
|
295
|
+
}
|
|
296
|
+
static _repositionWithinScreen(x, y, width, height, margin, transitionMovement, align) {
|
|
297
|
+
const scrollLeft = Utils.getDocumentScrollLeft();
|
|
298
|
+
const scrollTop = Utils.getDocumentScrollTop();
|
|
299
|
+
let newX = x - scrollLeft;
|
|
300
|
+
let newY = y - scrollTop;
|
|
301
|
+
const bounding = {
|
|
302
|
+
left: newX,
|
|
303
|
+
top: newY,
|
|
304
|
+
width: width,
|
|
305
|
+
height: height
|
|
306
|
+
};
|
|
307
|
+
let offset;
|
|
308
|
+
if (align === 'left' || align == 'center') {
|
|
309
|
+
offset = margin + transitionMovement;
|
|
310
|
+
}
|
|
311
|
+
else if (align === 'right') {
|
|
312
|
+
offset = margin - transitionMovement;
|
|
313
|
+
}
|
|
314
|
+
const edges = Utils.checkWithinContainer(document.body, bounding, offset);
|
|
315
|
+
if (edges.left) {
|
|
316
|
+
newX = offset;
|
|
317
|
+
}
|
|
318
|
+
else if (edges.right) {
|
|
319
|
+
newX -= newX + width - window.innerWidth;
|
|
320
|
+
}
|
|
321
|
+
if (edges.top) {
|
|
322
|
+
newY = offset;
|
|
323
|
+
}
|
|
324
|
+
else if (edges.bottom) {
|
|
325
|
+
newY -= newY + height - window.innerHeight;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
x: newX + scrollLeft,
|
|
329
|
+
y: newY + scrollTop
|
|
330
|
+
};
|
|
331
|
+
}
|
|
235
332
|
}
|
|
236
333
|
|
|
237
334
|
/**
|
|
@@ -302,7 +399,7 @@ class Component {
|
|
|
302
399
|
}
|
|
303
400
|
}
|
|
304
401
|
|
|
305
|
-
const _defaults$
|
|
402
|
+
const _defaults$n = {
|
|
306
403
|
alignment: 'left',
|
|
307
404
|
autoFocus: true,
|
|
308
405
|
constrainWidth: true,
|
|
@@ -350,12 +447,12 @@ class Dropdown extends Component {
|
|
|
350
447
|
this.filterQuery = [];
|
|
351
448
|
this.el.ariaExpanded = 'false';
|
|
352
449
|
// Move dropdown-content after dropdown-trigger
|
|
353
|
-
this.
|
|
450
|
+
this._moveDropdownToElement();
|
|
354
451
|
this._makeDropdownFocusable();
|
|
355
452
|
this._setupEventHandlers();
|
|
356
453
|
}
|
|
357
454
|
static get defaults() {
|
|
358
|
-
return _defaults$
|
|
455
|
+
return _defaults$n;
|
|
359
456
|
}
|
|
360
457
|
/**
|
|
361
458
|
* Initializes instances of Dropdown.
|
|
@@ -416,7 +513,7 @@ class Dropdown extends Component {
|
|
|
416
513
|
}
|
|
417
514
|
_handleClick = (e) => {
|
|
418
515
|
e.preventDefault();
|
|
419
|
-
this._moveDropdown(e.target.closest('li'));
|
|
516
|
+
//this._moveDropdown((<HTMLElement>e.target).closest('li'));
|
|
420
517
|
if (this.isOpen) {
|
|
421
518
|
this.close();
|
|
422
519
|
}
|
|
@@ -424,8 +521,8 @@ class Dropdown extends Component {
|
|
|
424
521
|
this.open();
|
|
425
522
|
}
|
|
426
523
|
};
|
|
427
|
-
_handleMouseEnter = (
|
|
428
|
-
this._moveDropdown(e.target.closest('li'));
|
|
524
|
+
_handleMouseEnter = () => {
|
|
525
|
+
//this._moveDropdown((<HTMLElement>e.target).closest('li'));
|
|
429
526
|
this.open();
|
|
430
527
|
};
|
|
431
528
|
_handleMouseLeave = (e) => {
|
|
@@ -511,7 +608,7 @@ class Dropdown extends Component {
|
|
|
511
608
|
else if (Utils.keys.ENTER.includes(e.key) && this.isOpen) {
|
|
512
609
|
// Search for <a> and <button>
|
|
513
610
|
const focusedElement = this.dropdownEl.children[this.focusedIndex];
|
|
514
|
-
const activatableElement = focusedElement
|
|
611
|
+
const activatableElement = focusedElement?.querySelector('a, button');
|
|
515
612
|
// Click a or button tag if exists, otherwise click li tag
|
|
516
613
|
if (!!activatableElement) {
|
|
517
614
|
activatableElement.click();
|
|
@@ -571,19 +668,17 @@ class Dropdown extends Component {
|
|
|
571
668
|
this.dropdownEl.style.top = '';
|
|
572
669
|
this.dropdownEl.style.transformOrigin = '';
|
|
573
670
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
if (!!this.options.container) {
|
|
671
|
+
_moveDropdownToElement(containerEl = null) {
|
|
672
|
+
if (this.options.container) {
|
|
577
673
|
this.options.container.append(this.dropdownEl);
|
|
674
|
+
return;
|
|
578
675
|
}
|
|
579
|
-
|
|
580
|
-
if (!containerEl.contains(this.dropdownEl))
|
|
676
|
+
if (containerEl) {
|
|
677
|
+
if (!containerEl.contains(this.dropdownEl))
|
|
581
678
|
containerEl.append(this.dropdownEl);
|
|
582
|
-
|
|
583
|
-
}
|
|
584
|
-
else {
|
|
585
|
-
this.el.after(this.dropdownEl);
|
|
679
|
+
return;
|
|
586
680
|
}
|
|
681
|
+
this.el.after(this.dropdownEl);
|
|
587
682
|
}
|
|
588
683
|
_makeDropdownFocusable() {
|
|
589
684
|
if (!this.dropdownEl)
|
|
@@ -744,7 +839,7 @@ class Dropdown extends Component {
|
|
|
744
839
|
}
|
|
745
840
|
if (getComputedStyle(closestOverflowParent).position === 'static')
|
|
746
841
|
closestOverflowParent.style.position = 'relative';
|
|
747
|
-
this._moveDropdown(closestOverflowParent);
|
|
842
|
+
//this._moveDropdown(closestOverflowParent);
|
|
748
843
|
// Set width before calculating positionInfo
|
|
749
844
|
const idealWidth = this.options.constrainWidth
|
|
750
845
|
? this.el.getBoundingClientRect().width
|
|
@@ -808,7 +903,7 @@ class Dropdown extends Component {
|
|
|
808
903
|
};
|
|
809
904
|
}
|
|
810
905
|
|
|
811
|
-
const _defaults$
|
|
906
|
+
const _defaults$m = {
|
|
812
907
|
data: [], // Autocomplete data set
|
|
813
908
|
onAutocomplete: null, // Callback for when autocompleted
|
|
814
909
|
dropdownOptions: {
|
|
@@ -821,11 +916,12 @@ const _defaults$l = {
|
|
|
821
916
|
isMultiSelect: false,
|
|
822
917
|
onSearch: (text, autocomplete) => {
|
|
823
918
|
const normSearch = text.toLocaleLowerCase();
|
|
824
|
-
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch)
|
|
825
|
-
option.text?.toLocaleLowerCase().includes(normSearch)));
|
|
919
|
+
autocomplete.setMenuItems(autocomplete.options.data.filter((option) => option.id.toString().toLocaleLowerCase().includes(normSearch)
|
|
920
|
+
|| option.text?.toLocaleLowerCase().includes(normSearch)));
|
|
826
921
|
},
|
|
827
922
|
maxDropDownHeight: '300px',
|
|
828
|
-
allowUnsafeHTML: false
|
|
923
|
+
allowUnsafeHTML: false,
|
|
924
|
+
selected: []
|
|
829
925
|
};
|
|
830
926
|
class Autocomplete extends Component {
|
|
831
927
|
/** If the autocomplete is open. */
|
|
@@ -854,7 +950,7 @@ class Autocomplete extends Component {
|
|
|
854
950
|
this.count = 0;
|
|
855
951
|
this.activeIndex = -1;
|
|
856
952
|
this.oldVal = '';
|
|
857
|
-
this.selectedValues = [];
|
|
953
|
+
this.selectedValues = this.selectedValues || this.options.selected.map((value) => ({ id: value })) || [];
|
|
858
954
|
this.menuItems = this.options.data || [];
|
|
859
955
|
this.$active = null;
|
|
860
956
|
this._mousedown = false;
|
|
@@ -862,7 +958,7 @@ class Autocomplete extends Component {
|
|
|
862
958
|
this._setupEventHandlers();
|
|
863
959
|
}
|
|
864
960
|
static get defaults() {
|
|
865
|
-
return _defaults$
|
|
961
|
+
return _defaults$m;
|
|
866
962
|
}
|
|
867
963
|
/**
|
|
868
964
|
* Initializes instances of Autocomplete.
|
|
@@ -911,6 +1007,7 @@ class Autocomplete extends Component {
|
|
|
911
1007
|
this.container.style.maxHeight = this.options.maxDropDownHeight;
|
|
912
1008
|
this.container.id = `autocomplete-options-${Utils.guid()}`;
|
|
913
1009
|
this.container.classList.add('autocomplete-content', 'dropdown-content');
|
|
1010
|
+
this.container.ariaExpanded = 'true';
|
|
914
1011
|
this.el.setAttribute('data-target', this.container.id);
|
|
915
1012
|
this.menuItems.forEach((menuItem) => {
|
|
916
1013
|
const itemElement = this._createDropdownItem(menuItem);
|
|
@@ -943,6 +1040,10 @@ class Autocomplete extends Component {
|
|
|
943
1040
|
this.el.after(label);
|
|
944
1041
|
// Sketchy removal of dropdown click handler
|
|
945
1042
|
this.el.removeEventListener('click', this.dropdown._handleClick);
|
|
1043
|
+
if (!this.options.isMultiSelect && !(this.options.selected.length === 0)) {
|
|
1044
|
+
const selectedValue = this.menuItems.filter((value) => value.id === this.selectedValues[0].id);
|
|
1045
|
+
this.el.value = selectedValue[0].text;
|
|
1046
|
+
}
|
|
946
1047
|
// Set Value if already set in HTML
|
|
947
1048
|
if (this.el.value)
|
|
948
1049
|
this.selectOption(this.el.value);
|
|
@@ -954,6 +1055,7 @@ class Autocomplete extends Component {
|
|
|
954
1055
|
this._updateSelectedInfo();
|
|
955
1056
|
}
|
|
956
1057
|
_removeDropdown() {
|
|
1058
|
+
this.container.ariaExpanded = 'false';
|
|
957
1059
|
this.container.parentNode.removeChild(this.container);
|
|
958
1060
|
}
|
|
959
1061
|
_handleInputBlur = () => {
|
|
@@ -1063,6 +1165,7 @@ class Autocomplete extends Component {
|
|
|
1063
1165
|
const item = document.createElement('li');
|
|
1064
1166
|
item.setAttribute('data-id', entry.id);
|
|
1065
1167
|
item.setAttribute('style', 'display:grid; grid-auto-flow: column; user-select: none; align-items: center;');
|
|
1168
|
+
item.tabIndex = 0;
|
|
1066
1169
|
// Checkbox
|
|
1067
1170
|
if (this.options.isMultiSelect) {
|
|
1068
1171
|
item.innerHTML = `
|
|
@@ -1190,14 +1293,29 @@ class Autocomplete extends Component {
|
|
|
1190
1293
|
/**
|
|
1191
1294
|
* Updates the visible or selectable items shown in the menu.
|
|
1192
1295
|
* @param menuItems Items to be available.
|
|
1296
|
+
* @param selected Selected item ids
|
|
1297
|
+
* @param open Option to conditionally open dropdown
|
|
1193
1298
|
*/
|
|
1194
|
-
setMenuItems(menuItems) {
|
|
1299
|
+
setMenuItems(menuItems, selected = null, open = true) {
|
|
1195
1300
|
this.menuItems = menuItems;
|
|
1196
|
-
this.
|
|
1301
|
+
this.options.data = menuItems;
|
|
1302
|
+
if (selected) {
|
|
1303
|
+
this.selectedValues = this.menuItems.filter((item) => !(selected.indexOf(item.id) === -1));
|
|
1304
|
+
}
|
|
1305
|
+
if (this.options.isMultiSelect) {
|
|
1306
|
+
this._renderDropdown();
|
|
1307
|
+
}
|
|
1308
|
+
else {
|
|
1309
|
+
this._refreshInputText();
|
|
1310
|
+
}
|
|
1311
|
+
if (open)
|
|
1312
|
+
this.open();
|
|
1197
1313
|
this._updateSelectedInfo();
|
|
1314
|
+
this._triggerChanged();
|
|
1198
1315
|
}
|
|
1199
1316
|
/**
|
|
1200
1317
|
* Sets selected values.
|
|
1318
|
+
* @deprecated @see https://github.com/materializecss/materialize/issues/552
|
|
1201
1319
|
* @param entries
|
|
1202
1320
|
*/
|
|
1203
1321
|
setValues(entries) {
|
|
@@ -1217,16 +1335,16 @@ class Autocomplete extends Component {
|
|
|
1217
1335
|
if (!entry)
|
|
1218
1336
|
return;
|
|
1219
1337
|
// Toggle Checkbox
|
|
1220
|
-
const li = this.container.querySelector('li[data-id="' + id + '"]');
|
|
1221
|
-
if (!li)
|
|
1222
|
-
return;
|
|
1338
|
+
/* const li = this.container.querySelector('li[data-id="' + id + '"]');
|
|
1339
|
+
if (!li) return;*/
|
|
1223
1340
|
if (this.options.isMultiSelect) {
|
|
1224
|
-
const checkbox = li.querySelector('input[type="checkbox"]');
|
|
1225
|
-
checkbox.checked = !checkbox.checked
|
|
1226
|
-
if (
|
|
1341
|
+
/* const checkbox = <HTMLInputElement | null>li.querySelector('input[type="checkbox"]');
|
|
1342
|
+
checkbox.checked = !checkbox.checked;*/
|
|
1343
|
+
if (!(this.selectedValues.filter((selectedEntry) => selectedEntry.id === entry.id).length >= 1))
|
|
1227
1344
|
this.selectedValues.push(entry);
|
|
1228
1345
|
else
|
|
1229
1346
|
this.selectedValues = this.selectedValues.filter((selectedEntry) => selectedEntry.id !== entry.id);
|
|
1347
|
+
this._renderDropdown();
|
|
1230
1348
|
this.el.focus();
|
|
1231
1349
|
}
|
|
1232
1350
|
else {
|
|
@@ -1239,9 +1357,16 @@ class Autocomplete extends Component {
|
|
|
1239
1357
|
this._updateSelectedInfo();
|
|
1240
1358
|
this._triggerChanged();
|
|
1241
1359
|
}
|
|
1360
|
+
selectOptions(ids) {
|
|
1361
|
+
const entries = this.menuItems.filter((item) => !(ids.indexOf(item.id) === -1));
|
|
1362
|
+
if (!entries)
|
|
1363
|
+
return;
|
|
1364
|
+
this.selectedValues = entries;
|
|
1365
|
+
this._renderDropdown();
|
|
1366
|
+
}
|
|
1242
1367
|
}
|
|
1243
1368
|
|
|
1244
|
-
const _defaults$
|
|
1369
|
+
const _defaults$l = {
|
|
1245
1370
|
direction: 'top',
|
|
1246
1371
|
hoverEnabled: true,
|
|
1247
1372
|
toolbarEnabled: false
|
|
@@ -1275,6 +1400,8 @@ class FloatingActionButton extends Component {
|
|
|
1275
1400
|
this.offsetY = 0;
|
|
1276
1401
|
this.offsetX = 0;
|
|
1277
1402
|
this.el.classList.add(`direction-${this.options.direction}`);
|
|
1403
|
+
this._anchor.tabIndex = 0;
|
|
1404
|
+
this._menu.ariaExpanded = 'false';
|
|
1278
1405
|
if (this.options.direction === 'top')
|
|
1279
1406
|
this.offsetY = 40;
|
|
1280
1407
|
else if (this.options.direction === 'right')
|
|
@@ -1286,7 +1413,7 @@ class FloatingActionButton extends Component {
|
|
|
1286
1413
|
this._setupEventHandlers();
|
|
1287
1414
|
}
|
|
1288
1415
|
static get defaults() {
|
|
1289
|
-
return _defaults$
|
|
1416
|
+
return _defaults$l;
|
|
1290
1417
|
}
|
|
1291
1418
|
/**
|
|
1292
1419
|
* Initializes instances of FloatingActionButton.
|
|
@@ -1311,6 +1438,7 @@ class FloatingActionButton extends Component {
|
|
|
1311
1438
|
else {
|
|
1312
1439
|
this.el.addEventListener('click', this._handleFABClick);
|
|
1313
1440
|
}
|
|
1441
|
+
this.el.addEventListener('keypress', this._handleFABKeyPress);
|
|
1314
1442
|
}
|
|
1315
1443
|
_removeEventHandlers() {
|
|
1316
1444
|
if (this.options.hoverEnabled && !this.options.toolbarEnabled) {
|
|
@@ -1320,8 +1448,17 @@ class FloatingActionButton extends Component {
|
|
|
1320
1448
|
else {
|
|
1321
1449
|
this.el.removeEventListener('click', this._handleFABClick);
|
|
1322
1450
|
}
|
|
1451
|
+
this.el.removeEventListener('keypress', this._handleFABKeyPress);
|
|
1323
1452
|
}
|
|
1324
1453
|
_handleFABClick = () => {
|
|
1454
|
+
this._handleFABToggle();
|
|
1455
|
+
};
|
|
1456
|
+
_handleFABKeyPress = (e) => {
|
|
1457
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
1458
|
+
this._handleFABToggle();
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
_handleFABToggle = () => {
|
|
1325
1462
|
if (this.isOpen) {
|
|
1326
1463
|
this.close();
|
|
1327
1464
|
}
|
|
@@ -1363,6 +1500,7 @@ class FloatingActionButton extends Component {
|
|
|
1363
1500
|
};
|
|
1364
1501
|
_animateInFAB() {
|
|
1365
1502
|
this.el.classList.add('active');
|
|
1503
|
+
this._menu.ariaExpanded = 'true';
|
|
1366
1504
|
const delayIncrement = 40;
|
|
1367
1505
|
const duration = 275;
|
|
1368
1506
|
this._floatingBtnsReverse.forEach((el, index) => {
|
|
@@ -1379,18 +1517,23 @@ class FloatingActionButton extends Component {
|
|
|
1379
1517
|
el.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
1380
1518
|
el.style.opacity = '1';
|
|
1381
1519
|
el.style.transform = 'translate(0, 0) scale(1)';
|
|
1520
|
+
el.tabIndex = 0;
|
|
1382
1521
|
}, 1);
|
|
1383
1522
|
}, delay);
|
|
1384
1523
|
});
|
|
1385
1524
|
}
|
|
1386
1525
|
_animateOutFAB() {
|
|
1387
1526
|
const duration = 175;
|
|
1388
|
-
setTimeout(() =>
|
|
1527
|
+
setTimeout(() => {
|
|
1528
|
+
this.el.classList.remove('active');
|
|
1529
|
+
this._menu.ariaExpanded = 'false';
|
|
1530
|
+
}, duration);
|
|
1389
1531
|
this._floatingBtnsReverse.forEach((el) => {
|
|
1390
1532
|
el.style.transition = `opacity ${duration}ms ease, transform ${duration}ms ease`;
|
|
1391
1533
|
// to
|
|
1392
1534
|
el.style.opacity = '0';
|
|
1393
1535
|
el.style.transform = `translate(${this.offsetX}px, ${this.offsetY}px) scale(0.4)`;
|
|
1536
|
+
el.tabIndex = -1;
|
|
1394
1537
|
});
|
|
1395
1538
|
}
|
|
1396
1539
|
_animateInToolbar() {
|
|
@@ -1414,6 +1557,7 @@ class FloatingActionButton extends Component {
|
|
|
1414
1557
|
this.el.style.left = '0';
|
|
1415
1558
|
this.el.style.transform = 'translateX(' + this.offsetX + 'px)';
|
|
1416
1559
|
this.el.style.transition = 'none';
|
|
1560
|
+
this._menu.ariaExpanded = 'true';
|
|
1417
1561
|
this._anchor.style.transform = `translateY(${this.offsetY}px`;
|
|
1418
1562
|
this._anchor.style.transition = 'none';
|
|
1419
1563
|
setTimeout(() => {
|
|
@@ -1428,9 +1572,10 @@ class FloatingActionButton extends Component {
|
|
|
1428
1572
|
this.el.style.backgroundColor = fabColor;
|
|
1429
1573
|
backdrop.style.transform = 'scale(' + scaleFactor + ')';
|
|
1430
1574
|
backdrop.style.transition = 'transform .2s cubic-bezier(0.550, 0.055, 0.675, 0.190)';
|
|
1431
|
-
this._menu
|
|
1432
|
-
.
|
|
1433
|
-
|
|
1575
|
+
this._menu.querySelectorAll('li > a').forEach((a) => {
|
|
1576
|
+
a.style.opacity = '1';
|
|
1577
|
+
a.tabIndex = 0;
|
|
1578
|
+
});
|
|
1434
1579
|
// Scroll to close.
|
|
1435
1580
|
window.addEventListener('scroll', this.close, true);
|
|
1436
1581
|
document.body.addEventListener('click', this._handleDocumentClick, true);
|
|
@@ -1439,7 +1584,7 @@ class FloatingActionButton extends Component {
|
|
|
1439
1584
|
}
|
|
1440
1585
|
}
|
|
1441
1586
|
|
|
1442
|
-
const _defaults$
|
|
1587
|
+
const _defaults$k = {
|
|
1443
1588
|
onOpen: null,
|
|
1444
1589
|
onClose: null,
|
|
1445
1590
|
inDuration: 225,
|
|
@@ -1458,6 +1603,7 @@ class Cards extends Component {
|
|
|
1458
1603
|
...Cards.defaults,
|
|
1459
1604
|
...options
|
|
1460
1605
|
};
|
|
1606
|
+
this._activators = [];
|
|
1461
1607
|
this.cardReveal = this.el.querySelector('.card-reveal');
|
|
1462
1608
|
if (this.cardReveal) {
|
|
1463
1609
|
this.initialOverflow = getComputedStyle(this.el).overflow;
|
|
@@ -1474,7 +1620,7 @@ class Cards extends Component {
|
|
|
1474
1620
|
}
|
|
1475
1621
|
}
|
|
1476
1622
|
static get defaults() {
|
|
1477
|
-
return _defaults$
|
|
1623
|
+
return _defaults$k;
|
|
1478
1624
|
}
|
|
1479
1625
|
/**
|
|
1480
1626
|
* Initializes instances of Cards.
|
|
@@ -1573,9 +1719,20 @@ class Cards extends Component {
|
|
|
1573
1719
|
}
|
|
1574
1720
|
this._removeRevealCloseEventHandlers();
|
|
1575
1721
|
};
|
|
1722
|
+
static Init() {
|
|
1723
|
+
if (typeof document !== 'undefined')
|
|
1724
|
+
// Handle initialization of static cards.
|
|
1725
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
1726
|
+
const cards = document.querySelectorAll('.card');
|
|
1727
|
+
cards.forEach((el) => {
|
|
1728
|
+
if (el && (el['M_Card'] == undefined))
|
|
1729
|
+
this.init(el);
|
|
1730
|
+
});
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1576
1733
|
}
|
|
1577
1734
|
|
|
1578
|
-
const _defaults$
|
|
1735
|
+
const _defaults$j = {
|
|
1579
1736
|
duration: 200, // ms
|
|
1580
1737
|
dist: -100, // zoom scale TODO: make this more intuitive as an option
|
|
1581
1738
|
shift: 0, // spacing for center image
|
|
@@ -1677,7 +1834,7 @@ class Carousel extends Component {
|
|
|
1677
1834
|
this._scroll(this.offset);
|
|
1678
1835
|
}
|
|
1679
1836
|
static get defaults() {
|
|
1680
|
-
return _defaults$
|
|
1837
|
+
return _defaults$j;
|
|
1681
1838
|
}
|
|
1682
1839
|
/**
|
|
1683
1840
|
* Initializes instances of Carousel.
|
|
@@ -1732,9 +1889,7 @@ class Carousel extends Component {
|
|
|
1732
1889
|
}
|
|
1733
1890
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
1734
1891
|
}
|
|
1735
|
-
_handleThrottledResize = Utils.throttle(
|
|
1736
|
-
this._handleResize();
|
|
1737
|
-
}, 200, null).bind(this);
|
|
1892
|
+
_handleThrottledResize = () => Utils.throttle(this._handleResize, 200, null).bind(this);
|
|
1738
1893
|
_handleCarouselTap = (e) => {
|
|
1739
1894
|
// Fixes firefox draggable image bug
|
|
1740
1895
|
if (e.type === 'mousedown' && e.target.tagName === 'IMG') {
|
|
@@ -2149,7 +2304,7 @@ class Carousel extends Component {
|
|
|
2149
2304
|
}
|
|
2150
2305
|
}
|
|
2151
2306
|
|
|
2152
|
-
const _defaults$
|
|
2307
|
+
const _defaults$i = {
|
|
2153
2308
|
data: [],
|
|
2154
2309
|
placeholder: '',
|
|
2155
2310
|
secondaryPlaceholder: '',
|
|
@@ -2203,7 +2358,7 @@ class Chips extends Component {
|
|
|
2203
2358
|
}
|
|
2204
2359
|
}
|
|
2205
2360
|
static get defaults() {
|
|
2206
|
-
return _defaults$
|
|
2361
|
+
return _defaults$i;
|
|
2207
2362
|
}
|
|
2208
2363
|
/**
|
|
2209
2364
|
* Initializes instances of Chips.
|
|
@@ -2487,7 +2642,7 @@ class Chips extends Component {
|
|
|
2487
2642
|
}
|
|
2488
2643
|
}
|
|
2489
2644
|
|
|
2490
|
-
const _defaults$
|
|
2645
|
+
const _defaults$h = {
|
|
2491
2646
|
accordion: true,
|
|
2492
2647
|
onOpenStart: null,
|
|
2493
2648
|
onOpenEnd: null,
|
|
@@ -2523,7 +2678,7 @@ class Collapsible extends Component {
|
|
|
2523
2678
|
}
|
|
2524
2679
|
}
|
|
2525
2680
|
static get defaults() {
|
|
2526
|
-
return _defaults$
|
|
2681
|
+
return _defaults$h;
|
|
2527
2682
|
}
|
|
2528
2683
|
/**
|
|
2529
2684
|
* Initializes instances of Collapsible.
|
|
@@ -2642,7 +2797,7 @@ class Collapsible extends Component {
|
|
|
2642
2797
|
};
|
|
2643
2798
|
}
|
|
2644
2799
|
|
|
2645
|
-
const _defaults$
|
|
2800
|
+
const _defaults$g = {
|
|
2646
2801
|
classes: '',
|
|
2647
2802
|
dropdownOptions: {}
|
|
2648
2803
|
};
|
|
@@ -2664,6 +2819,7 @@ class FormSelect extends Component {
|
|
|
2664
2819
|
wrapper;
|
|
2665
2820
|
selectOptions;
|
|
2666
2821
|
_values;
|
|
2822
|
+
nativeTabIndex;
|
|
2667
2823
|
constructor(el, options) {
|
|
2668
2824
|
super(el, options, FormSelect);
|
|
2669
2825
|
if (this.el.classList.contains('browser-default'))
|
|
@@ -2674,13 +2830,14 @@ class FormSelect extends Component {
|
|
|
2674
2830
|
...options
|
|
2675
2831
|
};
|
|
2676
2832
|
this.isMultiple = this.el.multiple;
|
|
2833
|
+
this.nativeTabIndex = this.el.tabIndex ?? -1;
|
|
2677
2834
|
this.el.tabIndex = -1;
|
|
2678
2835
|
this._values = [];
|
|
2679
2836
|
this._setupDropdown();
|
|
2680
2837
|
this._setupEventHandlers();
|
|
2681
2838
|
}
|
|
2682
2839
|
static get defaults() {
|
|
2683
|
-
return _defaults$
|
|
2840
|
+
return _defaults$g;
|
|
2684
2841
|
}
|
|
2685
2842
|
/**
|
|
2686
2843
|
* Initializes instances of FormSelect.
|
|
@@ -2770,8 +2927,6 @@ class FormSelect extends Component {
|
|
|
2770
2927
|
};
|
|
2771
2928
|
_setupDropdown() {
|
|
2772
2929
|
this.labelEl = document.querySelector('[for="' + this.el.id + '"]');
|
|
2773
|
-
if (this.labelEl)
|
|
2774
|
-
this.labelEl.style.display = 'none';
|
|
2775
2930
|
this.wrapper = document.createElement('div');
|
|
2776
2931
|
this.wrapper.classList.add('select-wrapper', 'input-field');
|
|
2777
2932
|
if (this.options.classes.length > 0) {
|
|
@@ -2789,6 +2944,7 @@ class FormSelect extends Component {
|
|
|
2789
2944
|
// Create dropdown
|
|
2790
2945
|
this.dropdownOptions = document.createElement('ul');
|
|
2791
2946
|
this.dropdownOptions.id = `select-options-${Utils.guid()}`;
|
|
2947
|
+
this.dropdownOptions.setAttribute('popover', 'auto');
|
|
2792
2948
|
this.dropdownOptions.classList.add('dropdown-content', 'select-dropdown');
|
|
2793
2949
|
this.dropdownOptions.setAttribute('role', 'listbox');
|
|
2794
2950
|
this.dropdownOptions.ariaMultiSelectable = this.isMultiple.toString();
|
|
@@ -2837,6 +2993,7 @@ class FormSelect extends Component {
|
|
|
2837
2993
|
this.input.ariaRequired = this.el.hasAttribute('required').toString(); //setAttribute("aria-required", this.el.hasAttribute("required"));
|
|
2838
2994
|
if (this.el.disabled)
|
|
2839
2995
|
this.input.disabled = true; // 'true');
|
|
2996
|
+
this.input.setAttribute('tabindex', this.nativeTabIndex.toString());
|
|
2840
2997
|
const attrs = this.el.attributes;
|
|
2841
2998
|
for (let i = 0; i < attrs.length; ++i) {
|
|
2842
2999
|
const attr = attrs[i];
|
|
@@ -2862,7 +3019,7 @@ class FormSelect extends Component {
|
|
|
2862
3019
|
this.wrapper.prepend(dropdownIcon);
|
|
2863
3020
|
// Initialize dropdown
|
|
2864
3021
|
if (!this.el.disabled) {
|
|
2865
|
-
const dropdownOptions = { ...this.options.dropdownOptions };
|
|
3022
|
+
const dropdownOptions = { ...this.options.dropdownOptions };
|
|
2866
3023
|
dropdownOptions.coverTrigger = false;
|
|
2867
3024
|
const userOnOpenEnd = dropdownOptions.onOpenEnd;
|
|
2868
3025
|
const userOnCloseEnd = dropdownOptions.onCloseEnd;
|
|
@@ -2901,13 +3058,9 @@ class FormSelect extends Component {
|
|
|
2901
3058
|
}
|
|
2902
3059
|
// Add initial selections
|
|
2903
3060
|
this._setSelectedStates();
|
|
2904
|
-
//
|
|
2905
|
-
if (this.labelEl)
|
|
2906
|
-
|
|
2907
|
-
label.htmlFor = this.input.id;
|
|
2908
|
-
label.innerText = this.labelEl.innerText;
|
|
2909
|
-
this.input.after(label);
|
|
2910
|
-
}
|
|
3061
|
+
// move label
|
|
3062
|
+
if (this.labelEl)
|
|
3063
|
+
this.input.after(this.labelEl);
|
|
2911
3064
|
}
|
|
2912
3065
|
_addOptionToValues(realOption, virtualOption) {
|
|
2913
3066
|
this._values.push({ el: realOption, optionEl: virtualOption });
|
|
@@ -3027,6 +3180,74 @@ class FormSelect extends Component {
|
|
|
3027
3180
|
}
|
|
3028
3181
|
}
|
|
3029
3182
|
|
|
3183
|
+
const _defaults$f = {
|
|
3184
|
+
margin: 5,
|
|
3185
|
+
transition: 10,
|
|
3186
|
+
duration: 250,
|
|
3187
|
+
align: 'left'
|
|
3188
|
+
};
|
|
3189
|
+
class DockedDisplayPlugin {
|
|
3190
|
+
el;
|
|
3191
|
+
container;
|
|
3192
|
+
options;
|
|
3193
|
+
visible;
|
|
3194
|
+
constructor(el, container, options) {
|
|
3195
|
+
this.el = el;
|
|
3196
|
+
this.options = {
|
|
3197
|
+
..._defaults$f,
|
|
3198
|
+
...options
|
|
3199
|
+
};
|
|
3200
|
+
this.container = document.createElement('div');
|
|
3201
|
+
this.container.classList.add('display-docked');
|
|
3202
|
+
this.container.append(container);
|
|
3203
|
+
el.parentElement.append(this.container);
|
|
3204
|
+
document.addEventListener('click', (e) => {
|
|
3205
|
+
if (this.visible && !(this.el === e.target) && !(e.target.closest('.display-docked'))) {
|
|
3206
|
+
this.hide();
|
|
3207
|
+
}
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
/**
|
|
3211
|
+
* Initializes instance of DockedDisplayPlugin
|
|
3212
|
+
* @param el HTMLElement to position to
|
|
3213
|
+
* @param container HTMLElement to be positioned
|
|
3214
|
+
* @param options Plugin options
|
|
3215
|
+
*/
|
|
3216
|
+
static init(el, container, options) {
|
|
3217
|
+
return new DockedDisplayPlugin(el, container, options);
|
|
3218
|
+
}
|
|
3219
|
+
show = () => {
|
|
3220
|
+
if (this.visible)
|
|
3221
|
+
return;
|
|
3222
|
+
this.visible = true;
|
|
3223
|
+
const coordinates = Utils._setAbsolutePosition(this.el, this.container, 'bottom', this.options.margin, this.options.transition, this.options.align);
|
|
3224
|
+
// @todo move to Util? -> duplicate code fragment with tooltip
|
|
3225
|
+
// easeOutCubic
|
|
3226
|
+
this.container.style.visibility = 'visible';
|
|
3227
|
+
this.container.style.transition = `
|
|
3228
|
+
transform ${this.options.duration}ms ease-out,
|
|
3229
|
+
opacity ${this.options.duration}ms ease-out`;
|
|
3230
|
+
setTimeout(() => {
|
|
3231
|
+
this.container.style.transform = `translateX(${coordinates.x}px) translateY(${coordinates.y}px)`;
|
|
3232
|
+
this.container.style.opacity = (1).toString();
|
|
3233
|
+
}, 1);
|
|
3234
|
+
};
|
|
3235
|
+
hide = () => {
|
|
3236
|
+
if (!this.visible)
|
|
3237
|
+
return;
|
|
3238
|
+
this.visible = false;
|
|
3239
|
+
// @todo move to Util? -> duplicate code fragment with tooltip
|
|
3240
|
+
this.container.removeAttribute('style');
|
|
3241
|
+
this.container.style.transition = `
|
|
3242
|
+
transform ${this.options.duration}ms ease-out,
|
|
3243
|
+
opacity ${this.options.duration}ms ease-out`;
|
|
3244
|
+
setTimeout(() => {
|
|
3245
|
+
this.container.style.transform = `translateX(0px) translateY(0px)`;
|
|
3246
|
+
this.container.style.opacity = '0';
|
|
3247
|
+
}, 1);
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3030
3251
|
const _defaults$e = {
|
|
3031
3252
|
// the default output format for the input field value
|
|
3032
3253
|
format: 'mmm dd, yyyy',
|
|
@@ -3034,6 +3255,8 @@ const _defaults$e = {
|
|
|
3034
3255
|
parse: null,
|
|
3035
3256
|
// The initial condition if the datepicker is based on date range
|
|
3036
3257
|
isDateRange: false,
|
|
3258
|
+
// The selector of the user specified date range end element
|
|
3259
|
+
dateRangeEndEl: null,
|
|
3037
3260
|
// The initial condition if the datepicker is based on multiple date selection
|
|
3038
3261
|
isMultipleSelection: false,
|
|
3039
3262
|
// The initial date to view when first opened
|
|
@@ -3067,10 +3290,14 @@ const _defaults$e = {
|
|
|
3067
3290
|
showMonthAfterYear: false,
|
|
3068
3291
|
// Render days of the calendar grid that fall in the next or previous month
|
|
3069
3292
|
showDaysInNextAndPreviousMonths: false,
|
|
3293
|
+
// Specify if docked picker is in open state by default
|
|
3294
|
+
openByDefault: false,
|
|
3070
3295
|
// Specify a DOM element to render the calendar in
|
|
3071
3296
|
container: null,
|
|
3072
3297
|
// Show clear button
|
|
3073
3298
|
showClearBtn: false,
|
|
3299
|
+
// Autosubmit
|
|
3300
|
+
autoSubmit: true,
|
|
3074
3301
|
// internationalization
|
|
3075
3302
|
i18n: {
|
|
3076
3303
|
cancel: 'Cancel',
|
|
@@ -3114,18 +3341,23 @@ const _defaults$e = {
|
|
|
3114
3341
|
events: [],
|
|
3115
3342
|
// callback function
|
|
3116
3343
|
onSelect: null,
|
|
3117
|
-
onDraw: null
|
|
3344
|
+
onDraw: null,
|
|
3345
|
+
onInputInteraction: null,
|
|
3346
|
+
displayPlugin: null,
|
|
3347
|
+
displayPluginOptions: null,
|
|
3348
|
+
onConfirm: null,
|
|
3349
|
+
onCancel: null,
|
|
3118
3350
|
};
|
|
3119
3351
|
class Datepicker extends Component {
|
|
3120
3352
|
id;
|
|
3121
3353
|
multiple = false;
|
|
3122
3354
|
calendarEl;
|
|
3123
3355
|
/** CLEAR button instance. */
|
|
3124
|
-
clearBtn;
|
|
3356
|
+
// clearBtn: HTMLElement;
|
|
3125
3357
|
/** DONE button instance */
|
|
3126
|
-
doneBtn;
|
|
3127
|
-
cancelBtn
|
|
3128
|
-
|
|
3358
|
+
/*doneBtn: HTMLElement;
|
|
3359
|
+
cancelBtn: HTMLElement;*/
|
|
3360
|
+
containerEl;
|
|
3129
3361
|
yearTextEl;
|
|
3130
3362
|
dateTextEl;
|
|
3131
3363
|
endDateEl;
|
|
@@ -3138,6 +3370,8 @@ class Datepicker extends Component {
|
|
|
3138
3370
|
calendars;
|
|
3139
3371
|
_y;
|
|
3140
3372
|
_m;
|
|
3373
|
+
displayPlugin;
|
|
3374
|
+
footer;
|
|
3141
3375
|
static _template;
|
|
3142
3376
|
constructor(el, options) {
|
|
3143
3377
|
super(el, options, Datepicker);
|
|
@@ -3191,6 +3425,10 @@ class Datepicker extends Component {
|
|
|
3191
3425
|
this.dateEls = [];
|
|
3192
3426
|
this.dateEls.push(el);
|
|
3193
3427
|
}
|
|
3428
|
+
if (this.options.displayPlugin) {
|
|
3429
|
+
if (this.options.displayPlugin === 'docked')
|
|
3430
|
+
this.displayPlugin = DockedDisplayPlugin.init(this.el, this.containerEl, this.options.displayPluginOptions);
|
|
3431
|
+
}
|
|
3194
3432
|
}
|
|
3195
3433
|
static get defaults() {
|
|
3196
3434
|
return _defaults$e;
|
|
@@ -3239,7 +3477,7 @@ class Datepicker extends Component {
|
|
|
3239
3477
|
}
|
|
3240
3478
|
destroy() {
|
|
3241
3479
|
this._removeEventHandlers();
|
|
3242
|
-
this.
|
|
3480
|
+
this.containerEl.remove();
|
|
3243
3481
|
this.destroySelects();
|
|
3244
3482
|
this.el['M_Datepicker'] = undefined;
|
|
3245
3483
|
}
|
|
@@ -3258,27 +3496,55 @@ class Datepicker extends Component {
|
|
|
3258
3496
|
if (this.el.type == 'date') {
|
|
3259
3497
|
this.el.classList.add('datepicker-date-input');
|
|
3260
3498
|
}
|
|
3499
|
+
if (!this.el.parentElement.querySelector('.datepicker-format') === null) {
|
|
3500
|
+
this._renderDateInputFormat(this.el);
|
|
3501
|
+
}
|
|
3261
3502
|
if (this.options.isDateRange) {
|
|
3262
|
-
this.
|
|
3263
|
-
this.
|
|
3503
|
+
this.containerEl.classList.add('daterange');
|
|
3504
|
+
if (!this.options.dateRangeEndEl) {
|
|
3505
|
+
this.endDateEl = this.createDateInput();
|
|
3506
|
+
this.endDateEl.classList.add('datepicker-end-date');
|
|
3507
|
+
}
|
|
3508
|
+
else if (document.querySelector(this.options.dateRangeEndEl) === undefined) {
|
|
3509
|
+
console.warn('Specified date range end input element in dateRangeEndEl not found');
|
|
3510
|
+
}
|
|
3511
|
+
else {
|
|
3512
|
+
this.endDateEl = document.querySelector(this.options.dateRangeEndEl);
|
|
3513
|
+
if (!this.endDateEl.parentElement.querySelector('.datepicker-format') === null) {
|
|
3514
|
+
this._renderDateInputFormat(this.endDateEl);
|
|
3515
|
+
}
|
|
3516
|
+
}
|
|
3264
3517
|
}
|
|
3265
|
-
if (this.options.showClearBtn) {
|
|
3266
|
-
|
|
3267
|
-
|
|
3518
|
+
/*if (this.options.showClearBtn) {
|
|
3519
|
+
this.clearBtn.style.visibility = '';
|
|
3520
|
+
this.clearBtn.innerText = this.options.i18n.clear;
|
|
3268
3521
|
}
|
|
3269
3522
|
this.doneBtn.innerText = this.options.i18n.done;
|
|
3270
|
-
this.cancelBtn.innerText = this.options.i18n.cancel
|
|
3523
|
+
this.cancelBtn.innerText = this.options.i18n.cancel;*/
|
|
3524
|
+
Utils.createButton(this.footer, this.options.i18n.clear, ['datepicker-clear'], this.options.showClearBtn, this._handleClearClick);
|
|
3525
|
+
if (!this.options.autoSubmit) {
|
|
3526
|
+
Utils.createConfirmationContainer(this.footer, this.options.i18n.done, this.options.i18n.cancel, this._confirm, this._cancel);
|
|
3527
|
+
}
|
|
3271
3528
|
if (this.options.container) {
|
|
3272
3529
|
const optEl = this.options.container;
|
|
3273
3530
|
this.options.container =
|
|
3274
3531
|
optEl instanceof HTMLElement ? optEl : document.querySelector(optEl);
|
|
3275
|
-
this.options.container.append(this.
|
|
3532
|
+
this.options.container.append(this.containerEl);
|
|
3276
3533
|
}
|
|
3277
3534
|
else {
|
|
3278
|
-
//this.
|
|
3279
|
-
this.el
|
|
3535
|
+
//this.containerEl.before(this.el);
|
|
3536
|
+
const appendTo = !this.endDateEl ? this.el : this.endDateEl;
|
|
3537
|
+
if (!this.options.openByDefault)
|
|
3538
|
+
this.containerEl.setAttribute('style', 'display: none; visibility: hidden;');
|
|
3539
|
+
appendTo.parentElement.after(this.containerEl);
|
|
3280
3540
|
}
|
|
3281
3541
|
}
|
|
3542
|
+
/**
|
|
3543
|
+
* Renders the date input format
|
|
3544
|
+
*/
|
|
3545
|
+
_renderDateInputFormat(el) {
|
|
3546
|
+
el.parentElement.querySelector('.datepicker-format').innerHTML = this.options.format.toString();
|
|
3547
|
+
}
|
|
3282
3548
|
/**
|
|
3283
3549
|
* Gets a string representation of the given date.
|
|
3284
3550
|
*/
|
|
@@ -3419,7 +3685,6 @@ class Datepicker extends Component {
|
|
|
3419
3685
|
* Sets given date as the input value on the given element.
|
|
3420
3686
|
*/
|
|
3421
3687
|
setInputValue(el, date) {
|
|
3422
|
-
console.log('setinputvalue');
|
|
3423
3688
|
if (el.type == 'date') {
|
|
3424
3689
|
this.setDataDate(el, date);
|
|
3425
3690
|
el.value = this.formatDate(date, 'yyyy-mm-dd');
|
|
@@ -3523,7 +3788,7 @@ class Datepicker extends Component {
|
|
|
3523
3788
|
day < this.options.endRange, isDisabled = (this.options.minDate && day < this.options.minDate) ||
|
|
3524
3789
|
(this.options.maxDate && day > this.options.maxDate) ||
|
|
3525
3790
|
(this.options.disableWeekends && Datepicker._isWeekend(day)) ||
|
|
3526
|
-
(this.options.disableDayFn && this.options.disableDayFn(day)), isDateRange = this.options.isDateRange &&
|
|
3791
|
+
(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 &&
|
|
3527
3792
|
Datepicker._isDate(this.endDate) &&
|
|
3528
3793
|
Datepicker._compareWithinRange(day, this.date, this.endDate);
|
|
3529
3794
|
let dayNumber = 1 + (i - before), monthNumber = month, yearNumber = year;
|
|
@@ -3563,6 +3828,8 @@ class Datepicker extends Component {
|
|
|
3563
3828
|
isEndRange: isEndRange,
|
|
3564
3829
|
isInRange: isInRange,
|
|
3565
3830
|
showDaysInNextAndPreviousMonths: this.options.showDaysInNextAndPreviousMonths,
|
|
3831
|
+
isDateRangeStart: isDateRangeStart,
|
|
3832
|
+
isDateRangeEnd: isDateRangeEnd,
|
|
3566
3833
|
isDateRange: isDateRange
|
|
3567
3834
|
};
|
|
3568
3835
|
row.push(this.renderDay(dayConfig));
|
|
@@ -3576,8 +3843,18 @@ class Datepicker extends Component {
|
|
|
3576
3843
|
return this.renderTable(this.options, data, randId);
|
|
3577
3844
|
}
|
|
3578
3845
|
renderDay(opts) {
|
|
3579
|
-
const
|
|
3580
|
-
|
|
3846
|
+
const classMap = {
|
|
3847
|
+
isDisabled: 'is-disabled',
|
|
3848
|
+
isToday: 'is-today',
|
|
3849
|
+
isSelected: 'is-selected',
|
|
3850
|
+
hasEvent: 'has-event',
|
|
3851
|
+
isInRange: 'is-inrange',
|
|
3852
|
+
isStartRange: 'is-startrange',
|
|
3853
|
+
isEndRange: 'is-endrange',
|
|
3854
|
+
isDateRangeStart: 'is-daterange-start',
|
|
3855
|
+
isDateRangeEnd: 'is-daterange-end',
|
|
3856
|
+
isDateRange: 'is-daterange'
|
|
3857
|
+
}, ariaSelected = !(['isSelected', 'isDateRange'].filter((prop) => !!(opts.hasOwnProperty(prop) && opts[prop] === true)).length === 0), arr = ['datepicker-day'];
|
|
3581
3858
|
if (opts.isEmpty) {
|
|
3582
3859
|
if (opts.showDaysInNextAndPreviousMonths) {
|
|
3583
3860
|
arr.push('is-outside-current-month');
|
|
@@ -3587,36 +3864,10 @@ class Datepicker extends Component {
|
|
|
3587
3864
|
return '<td class="is-empty"></td>';
|
|
3588
3865
|
}
|
|
3589
3866
|
}
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
if (opts.isToday) {
|
|
3595
|
-
arr.push('is-today');
|
|
3596
|
-
}
|
|
3597
|
-
if (opts.isSelected) {
|
|
3598
|
-
arr.push('is-selected');
|
|
3599
|
-
ariaSelected = 'true';
|
|
3600
|
-
}
|
|
3601
|
-
// @todo should we create this additional css class?
|
|
3602
|
-
if (opts.hasEvent) {
|
|
3603
|
-
arr.push('has-event');
|
|
3604
|
-
}
|
|
3605
|
-
// @todo should we create this additional css class?
|
|
3606
|
-
if (opts.isInRange) {
|
|
3607
|
-
arr.push('is-inrange');
|
|
3608
|
-
}
|
|
3609
|
-
// @todo should we create this additional css class?
|
|
3610
|
-
if (opts.isStartRange) {
|
|
3611
|
-
arr.push('is-startrange');
|
|
3612
|
-
}
|
|
3613
|
-
// @todo should we create this additional css class?
|
|
3614
|
-
if (opts.isEndRange) {
|
|
3615
|
-
arr.push('is-endrange');
|
|
3616
|
-
}
|
|
3617
|
-
// @todo create additional css class
|
|
3618
|
-
if (opts.isDateRange) {
|
|
3619
|
-
arr.push('is-daterange');
|
|
3867
|
+
for (const [property, className] of Object.entries(classMap)) {
|
|
3868
|
+
if (opts.hasOwnProperty(property) && opts[property]) {
|
|
3869
|
+
arr.push(className);
|
|
3870
|
+
}
|
|
3620
3871
|
}
|
|
3621
3872
|
return (`<td data-day="${opts.day}" class="${arr.join(' ')}" aria-selected="${ariaSelected}">` +
|
|
3622
3873
|
`<button class="datepicker-day-button" type="button" data-year="${opts.year}" data-month="${opts.month}" data-day="${opts.day}">${opts.day}</button>` +
|
|
@@ -3685,7 +3936,9 @@ class Datepicker extends Component {
|
|
|
3685
3936
|
arr.reverse();
|
|
3686
3937
|
const yearHtml = `<select class="datepicker-select orig-select-year" tabindex="-1">${arr.join('')}</select>`;
|
|
3687
3938
|
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>';
|
|
3688
|
-
html += `<button class="month-prev${prev ? '' : ' is-disabled'
|
|
3939
|
+
html += `<button class="month-prev${prev ? '' : ' is-disabled'
|
|
3940
|
+
// @todo remove button class and add scss mixin, current implementation temporary for focus states, @see https://github.com/materializecss/materialize/issues/566
|
|
3941
|
+
} btn" type="button">${leftArrow}</button>`;
|
|
3689
3942
|
html += '<div class="selects-container">';
|
|
3690
3943
|
if (opts.showMonthAfterYear) {
|
|
3691
3944
|
html += yearHtml + monthHtml;
|
|
@@ -3701,7 +3954,9 @@ class Datepicker extends Component {
|
|
|
3701
3954
|
next = false;
|
|
3702
3955
|
}
|
|
3703
3956
|
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>';
|
|
3704
|
-
html += `<button class="month-next${next ? '' : ' is-disabled'
|
|
3957
|
+
html += `<button class="month-next${next ? '' : ' is-disabled'
|
|
3958
|
+
// @todo remove button class and add scss mixin, current implementation temporary for focus states, @see https://github.com/materializecss/materialize/issues/566
|
|
3959
|
+
} btn" type="button">${rightArrow}</button>`;
|
|
3705
3960
|
return (html += '</div>');
|
|
3706
3961
|
}
|
|
3707
3962
|
// refresh HTML
|
|
@@ -3740,6 +3995,7 @@ class Datepicker extends Component {
|
|
|
3740
3995
|
// Init Materialize Select
|
|
3741
3996
|
const yearSelect = this.calendarEl.querySelector('.orig-select-year');
|
|
3742
3997
|
const monthSelect = this.calendarEl.querySelector('.orig-select-month');
|
|
3998
|
+
// @todo fix accessibility @see https://github.com/materializecss/materialize/issues/522
|
|
3743
3999
|
FormSelect.init(yearSelect, {
|
|
3744
4000
|
classes: 'select-year',
|
|
3745
4001
|
dropdownOptions: { container: document.body, constrainWidth: false }
|
|
@@ -3760,25 +4016,26 @@ class Datepicker extends Component {
|
|
|
3760
4016
|
this.el.addEventListener('keydown', this._handleInputKeydown);
|
|
3761
4017
|
this.el.addEventListener('change', this._handleInputChange);
|
|
3762
4018
|
this.calendarEl.addEventListener('click', this._handleCalendarClick);
|
|
3763
|
-
this.doneBtn.addEventListener('click',
|
|
3764
|
-
this.cancelBtn.addEventListener('click', this.
|
|
4019
|
+
/* this.doneBtn.addEventListener('click', this._confirm);
|
|
4020
|
+
this.cancelBtn.addEventListener('click', this._cancel);
|
|
4021
|
+
|
|
3765
4022
|
if (this.options.showClearBtn) {
|
|
3766
|
-
|
|
3767
|
-
}
|
|
4023
|
+
this.clearBtn.addEventListener('click', this._handleClearClick);
|
|
4024
|
+
}*/
|
|
3768
4025
|
}
|
|
3769
4026
|
_setupVariables() {
|
|
3770
4027
|
const template = document.createElement('template');
|
|
3771
4028
|
template.innerHTML = Datepicker._template.trim();
|
|
3772
|
-
this.
|
|
3773
|
-
this.calendarEl = this.
|
|
3774
|
-
this.yearTextEl = this.
|
|
3775
|
-
this.dateTextEl = this.
|
|
3776
|
-
if (this.options.showClearBtn) {
|
|
3777
|
-
|
|
3778
|
-
}
|
|
3779
|
-
|
|
3780
|
-
this.
|
|
3781
|
-
this.
|
|
4029
|
+
this.containerEl = template.content.firstChild;
|
|
4030
|
+
this.calendarEl = this.containerEl.querySelector('.datepicker-calendar');
|
|
4031
|
+
this.yearTextEl = this.containerEl.querySelector('.year-text');
|
|
4032
|
+
this.dateTextEl = this.containerEl.querySelector('.date-text');
|
|
4033
|
+
/* if (this.options.showClearBtn) {
|
|
4034
|
+
this.clearBtn = this.containerEl.querySelector('.datepicker-clear');
|
|
4035
|
+
}
|
|
4036
|
+
this.doneBtn = this.containerEl.querySelector('.datepicker-done');
|
|
4037
|
+
this.cancelBtn = this.containerEl.querySelector('.datepicker-cancel');*/
|
|
4038
|
+
this.footer = this.containerEl.querySelector('.datepicker-footer');
|
|
3782
4039
|
this.formats = {
|
|
3783
4040
|
d: (date) => {
|
|
3784
4041
|
return date.getDate();
|
|
@@ -3833,12 +4090,20 @@ class Datepicker extends Component {
|
|
|
3833
4090
|
this.setDateFromInput(e.target);
|
|
3834
4091
|
this.draw();
|
|
3835
4092
|
this.gotoDate(e.target === this.el ? this.date : this.endDate);
|
|
4093
|
+
if (this.displayPlugin)
|
|
4094
|
+
this.displayPlugin.show();
|
|
4095
|
+
if (this.options.onInputInteraction)
|
|
4096
|
+
this.options.onInputInteraction.call(this);
|
|
3836
4097
|
};
|
|
3837
4098
|
_handleInputKeydown = (e) => {
|
|
3838
4099
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
3839
4100
|
e.preventDefault();
|
|
3840
4101
|
this.setDateFromInput(e.target);
|
|
3841
4102
|
this.draw();
|
|
4103
|
+
if (this.displayPlugin)
|
|
4104
|
+
this.displayPlugin.show();
|
|
4105
|
+
if (this.options.onInputInteraction)
|
|
4106
|
+
this.options.onInputInteraction.call(this);
|
|
3842
4107
|
}
|
|
3843
4108
|
};
|
|
3844
4109
|
_handleCalendarClick = (e) => {
|
|
@@ -3854,7 +4119,8 @@ class Datepicker extends Component {
|
|
|
3854
4119
|
if (this.options.isDateRange) {
|
|
3855
4120
|
this._handleDateRangeCalendarClick(selectedDate);
|
|
3856
4121
|
}
|
|
3857
|
-
this.
|
|
4122
|
+
if (this.options.autoSubmit)
|
|
4123
|
+
this._finishSelection();
|
|
3858
4124
|
}
|
|
3859
4125
|
else if (target.closest('.month-prev')) {
|
|
3860
4126
|
this.prevMonth();
|
|
@@ -3882,6 +4148,7 @@ class Datepicker extends Component {
|
|
|
3882
4148
|
_clearDates = () => {
|
|
3883
4149
|
this.date = null;
|
|
3884
4150
|
this.endDate = null;
|
|
4151
|
+
this.draw();
|
|
3885
4152
|
};
|
|
3886
4153
|
_handleMonthChange = (e) => {
|
|
3887
4154
|
this.gotoMonth(e.target.value);
|
|
@@ -3946,7 +4213,17 @@ class Datepicker extends Component {
|
|
|
3946
4213
|
// Set input value to the selected date and close Datepicker
|
|
3947
4214
|
_finishSelection = () => {
|
|
3948
4215
|
this.setInputValues();
|
|
3949
|
-
|
|
4216
|
+
// Commented out because of function deprecations
|
|
4217
|
+
// this.close();
|
|
4218
|
+
};
|
|
4219
|
+
_confirm = () => {
|
|
4220
|
+
this._finishSelection();
|
|
4221
|
+
if (typeof this.options.onConfirm === 'function')
|
|
4222
|
+
this.options.onConfirm.call(this);
|
|
4223
|
+
};
|
|
4224
|
+
_cancel = () => {
|
|
4225
|
+
if (typeof this.options.onCancel === 'function')
|
|
4226
|
+
this.options.onCancel.call(this);
|
|
3950
4227
|
};
|
|
3951
4228
|
// deprecated
|
|
3952
4229
|
open() {
|
|
@@ -3959,8 +4236,7 @@ class Datepicker extends Component {
|
|
|
3959
4236
|
}
|
|
3960
4237
|
static {
|
|
3961
4238
|
Datepicker._template = `
|
|
3962
|
-
|
|
3963
|
-
<div class="modal-content datepicker-container">
|
|
4239
|
+
<div class="datepicker-container">
|
|
3964
4240
|
<div class="datepicker-date-display">
|
|
3965
4241
|
<span class="year-text"></span>
|
|
3966
4242
|
<span class="date-text"></span>
|
|
@@ -3968,15 +4244,14 @@ class Datepicker extends Component {
|
|
|
3968
4244
|
<div class="datepicker-calendar-container">
|
|
3969
4245
|
<div class="datepicker-calendar"></div>
|
|
3970
4246
|
<div class="datepicker-footer">
|
|
3971
|
-
|
|
4247
|
+
<!--<button class="btn-flat datepicker-clear waves-effect" style="visibility: hidden;" type="button"></button>
|
|
3972
4248
|
<div class="confirmation-btns">
|
|
3973
4249
|
<button class="btn-flat datepicker-cancel waves-effect" type="button"></button>
|
|
3974
4250
|
<button class="btn-flat datepicker-done waves-effect" type="button"></button>
|
|
3975
|
-
</div
|
|
4251
|
+
</div>-->
|
|
3976
4252
|
</div>
|
|
3977
4253
|
</div>
|
|
3978
|
-
</div
|
|
3979
|
-
</div>`;
|
|
4254
|
+
</div>`;
|
|
3980
4255
|
}
|
|
3981
4256
|
}
|
|
3982
4257
|
|
|
@@ -4085,7 +4360,7 @@ class Forms {
|
|
|
4085
4360
|
// So we set the height to the original one
|
|
4086
4361
|
textarea.style.height = originalHeight + 'px';
|
|
4087
4362
|
}
|
|
4088
|
-
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
4363
|
+
textarea.setAttribute('previous-length', (textarea.value || '').length.toString());
|
|
4089
4364
|
}
|
|
4090
4365
|
static Init() {
|
|
4091
4366
|
if (typeof document !== 'undefined')
|
|
@@ -4132,7 +4407,7 @@ class Forms {
|
|
|
4132
4407
|
static InitTextarea(textarea) {
|
|
4133
4408
|
// Save Data in Element
|
|
4134
4409
|
textarea.setAttribute('original-height', textarea.getBoundingClientRect().height.toString());
|
|
4135
|
-
textarea.setAttribute('previous-length', textarea.value.length.toString());
|
|
4410
|
+
textarea.setAttribute('previous-length', (textarea.value || '').length.toString());
|
|
4136
4411
|
Forms.textareaAutoResize(textarea);
|
|
4137
4412
|
textarea.addEventListener('keyup', (e) => Forms.textareaAutoResize(e.target));
|
|
4138
4413
|
textarea.addEventListener('keydown', (e) => Forms.textareaAutoResize(e.target));
|
|
@@ -4881,9 +5156,7 @@ class ScrollSpy extends Component {
|
|
|
4881
5156
|
document.body.removeEventListener('click', this._handleTriggerClick);
|
|
4882
5157
|
}
|
|
4883
5158
|
}
|
|
4884
|
-
_handleThrottledResize = Utils.throttle(
|
|
4885
|
-
this._handleWindowScroll();
|
|
4886
|
-
}, 200).bind(this);
|
|
5159
|
+
_handleThrottledResize = () => Utils.throttle(this._handleWindowScroll, 200).bind(this);
|
|
4887
5160
|
_handleTriggerClick = (e) => {
|
|
4888
5161
|
const trigger = e.target;
|
|
4889
5162
|
for (let i = ScrollSpy._elements.length - 1; i >= 0; i--) {
|
|
@@ -5853,9 +6126,7 @@ class TapTarget extends Component {
|
|
|
5853
6126
|
// this.originEl.removeEventListener('click', this._handleOriginClick);
|
|
5854
6127
|
window.removeEventListener('resize', this._handleThrottledResize);
|
|
5855
6128
|
}
|
|
5856
|
-
_handleThrottledResize = Utils.throttle(
|
|
5857
|
-
this._handleResize();
|
|
5858
|
-
}, 200).bind(this);
|
|
6129
|
+
_handleThrottledResize = () => Utils.throttle(this._handleResize, 200).bind(this);
|
|
5859
6130
|
_handleKeyboardInteraction = (e) => {
|
|
5860
6131
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
5861
6132
|
this._handleTargetToggle();
|
|
@@ -6054,6 +6325,7 @@ const _defaults$5 = {
|
|
|
6054
6325
|
defaultTime: 'now', // default time, 'now' or '13:14' e.g.
|
|
6055
6326
|
fromNow: 0, // Millisecond offset from the defaultTime
|
|
6056
6327
|
showClearBtn: false,
|
|
6328
|
+
autoSubmit: true,
|
|
6057
6329
|
// internationalization
|
|
6058
6330
|
i18n: {
|
|
6059
6331
|
cancel: 'Cancel',
|
|
@@ -6063,11 +6335,16 @@ const _defaults$5 = {
|
|
|
6063
6335
|
twelveHour: true, // change to 12 hour AM/PM clock from 24 hour
|
|
6064
6336
|
vibrate: true, // vibrate the device when dragging clock hand
|
|
6065
6337
|
// Callbacks
|
|
6066
|
-
onSelect: null
|
|
6338
|
+
onSelect: null,
|
|
6339
|
+
onInputInteraction: null,
|
|
6340
|
+
onDone: null,
|
|
6341
|
+
onCancel: null,
|
|
6342
|
+
displayPlugin: null,
|
|
6343
|
+
displayPluginOptions: null,
|
|
6067
6344
|
};
|
|
6068
6345
|
class Timepicker extends Component {
|
|
6069
6346
|
id;
|
|
6070
|
-
|
|
6347
|
+
containerEl;
|
|
6071
6348
|
plate;
|
|
6072
6349
|
digitalClock;
|
|
6073
6350
|
inputHours;
|
|
@@ -6107,6 +6384,7 @@ class Timepicker extends Component {
|
|
|
6107
6384
|
g;
|
|
6108
6385
|
toggleViewTimer;
|
|
6109
6386
|
vibrateTimer;
|
|
6387
|
+
displayPlugin;
|
|
6110
6388
|
constructor(el, options) {
|
|
6111
6389
|
super(el, options, Timepicker);
|
|
6112
6390
|
this.el['M_Timepicker'] = this;
|
|
@@ -6120,6 +6398,10 @@ class Timepicker extends Component {
|
|
|
6120
6398
|
this._setupEventHandlers();
|
|
6121
6399
|
this._clockSetup();
|
|
6122
6400
|
this._pickerSetup();
|
|
6401
|
+
if (this.options.displayPlugin) {
|
|
6402
|
+
if (this.options.displayPlugin === 'docked')
|
|
6403
|
+
this.displayPlugin = DockedDisplayPlugin.init(this.el, this.containerEl, this.options.displayPluginOptions);
|
|
6404
|
+
}
|
|
6123
6405
|
}
|
|
6124
6406
|
static get defaults() {
|
|
6125
6407
|
return _defaults$5;
|
|
@@ -6154,7 +6436,7 @@ class Timepicker extends Component {
|
|
|
6154
6436
|
}
|
|
6155
6437
|
destroy() {
|
|
6156
6438
|
this._removeEventHandlers();
|
|
6157
|
-
this.
|
|
6439
|
+
this.containerEl.remove();
|
|
6158
6440
|
this.el['M_Timepicker'] = undefined;
|
|
6159
6441
|
}
|
|
6160
6442
|
_setupEventHandlers() {
|
|
@@ -6173,12 +6455,20 @@ class Timepicker extends Component {
|
|
|
6173
6455
|
this.el.removeEventListener('keydown', this._handleInputKeydown);
|
|
6174
6456
|
}
|
|
6175
6457
|
_handleInputClick = () => {
|
|
6176
|
-
this.
|
|
6458
|
+
this.inputHours.focus();
|
|
6459
|
+
if (typeof this.options.onInputInteraction === 'function')
|
|
6460
|
+
this.options.onInputInteraction.call(this);
|
|
6461
|
+
if (this.displayPlugin)
|
|
6462
|
+
this.displayPlugin.show();
|
|
6177
6463
|
};
|
|
6178
6464
|
_handleInputKeydown = (e) => {
|
|
6179
6465
|
if (Utils.keys.ENTER.includes(e.key)) {
|
|
6180
6466
|
e.preventDefault();
|
|
6181
|
-
this.
|
|
6467
|
+
this.inputHours.focus();
|
|
6468
|
+
if (typeof this.options.onInputInteraction === 'function')
|
|
6469
|
+
this.options.onInputInteraction.call(this);
|
|
6470
|
+
if (this.displayPlugin)
|
|
6471
|
+
this.displayPlugin.show();
|
|
6182
6472
|
}
|
|
6183
6473
|
};
|
|
6184
6474
|
_handleTimeInputEnterKey = (e) => {
|
|
@@ -6225,12 +6515,14 @@ class Timepicker extends Component {
|
|
|
6225
6515
|
this.setHand(x, y);
|
|
6226
6516
|
}
|
|
6227
6517
|
if (this.currentView === 'hours') {
|
|
6518
|
+
this.inputMinutes.focus();
|
|
6228
6519
|
this.showView('minutes', this.options.duration / 2);
|
|
6229
6520
|
}
|
|
6230
6521
|
else {
|
|
6231
|
-
this.minutesView.classList.add('timepicker-dial-out');
|
|
6522
|
+
// this.minutesView.classList.add('timepicker-dial-out');
|
|
6232
6523
|
setTimeout(() => {
|
|
6233
|
-
this.
|
|
6524
|
+
if (this.options.autoSubmit)
|
|
6525
|
+
this.done();
|
|
6234
6526
|
}, this.options.duration / 2);
|
|
6235
6527
|
}
|
|
6236
6528
|
if (typeof this.options.onSelect === 'function') {
|
|
@@ -6243,16 +6535,16 @@ class Timepicker extends Component {
|
|
|
6243
6535
|
_insertHTMLIntoDOM() {
|
|
6244
6536
|
const template = document.createElement('template');
|
|
6245
6537
|
template.innerHTML = Timepicker._template.trim();
|
|
6246
|
-
this.
|
|
6247
|
-
this.
|
|
6538
|
+
this.containerEl = template.content.firstChild;
|
|
6539
|
+
this.containerEl.id = 'container-' + this.id;
|
|
6248
6540
|
// Append popover to input by default
|
|
6249
6541
|
const optEl = this.options.container;
|
|
6250
6542
|
const containerEl = optEl instanceof HTMLElement ? optEl : document.querySelector(optEl);
|
|
6251
6543
|
if (this.options.container && !!containerEl) {
|
|
6252
|
-
containerEl.append(this.
|
|
6544
|
+
containerEl.append(this.containerEl);
|
|
6253
6545
|
}
|
|
6254
6546
|
else {
|
|
6255
|
-
this.el.parentElement.appendChild(this.
|
|
6547
|
+
this.el.parentElement.appendChild(this.containerEl);
|
|
6256
6548
|
}
|
|
6257
6549
|
}
|
|
6258
6550
|
_setupVariables() {
|
|
@@ -6262,42 +6554,49 @@ class Timepicker extends Component {
|
|
|
6262
6554
|
: navigator['webkitVibrate']
|
|
6263
6555
|
? 'webkitVibrate'
|
|
6264
6556
|
: null;
|
|
6265
|
-
this._canvas = this.
|
|
6266
|
-
this.plate = this.
|
|
6267
|
-
this.digitalClock = this.
|
|
6268
|
-
this.hoursView = this.
|
|
6269
|
-
this.minutesView = this.
|
|
6270
|
-
this.inputHours = this.
|
|
6271
|
-
this.inputMinutes = this.
|
|
6272
|
-
this.spanAmPm = this.
|
|
6273
|
-
this.footer = this.
|
|
6557
|
+
this._canvas = this.containerEl.querySelector('.timepicker-canvas');
|
|
6558
|
+
this.plate = this.containerEl.querySelector('.timepicker-plate');
|
|
6559
|
+
this.digitalClock = this.containerEl.querySelector('.timepicker-display-column');
|
|
6560
|
+
this.hoursView = this.containerEl.querySelector('.timepicker-hours');
|
|
6561
|
+
this.minutesView = this.containerEl.querySelector('.timepicker-minutes');
|
|
6562
|
+
this.inputHours = this.containerEl.querySelector('.timepicker-input-hours');
|
|
6563
|
+
this.inputMinutes = this.containerEl.querySelector('.timepicker-input-minutes');
|
|
6564
|
+
this.spanAmPm = this.containerEl.querySelector('.timepicker-span-am-pm');
|
|
6565
|
+
this.footer = this.containerEl.querySelector('.timepicker-footer');
|
|
6274
6566
|
this.amOrPm = 'PM';
|
|
6275
6567
|
}
|
|
6276
|
-
_createButton(text, visibility) {
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
}
|
|
6568
|
+
/*private _createButton(text: string, visibility: string): HTMLButtonElement {
|
|
6569
|
+
const button = document.createElement('button');
|
|
6570
|
+
button.classList.add('btn', 'waves-effect', 'text');
|
|
6571
|
+
button.style.visibility = visibility;
|
|
6572
|
+
button.type = 'button';
|
|
6573
|
+
button.tabIndex = -1;
|
|
6574
|
+
button.innerText = text;
|
|
6575
|
+
return button;
|
|
6576
|
+
}*/
|
|
6285
6577
|
_pickerSetup() {
|
|
6286
|
-
|
|
6287
|
-
clearButton.
|
|
6288
|
-
|
|
6289
|
-
this.footer.
|
|
6290
|
-
|
|
6291
|
-
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6578
|
+
// clearButton.classList.add('timepicker-clear');
|
|
6579
|
+
// clearButton.addEventListener('click', this.clear);
|
|
6580
|
+
// this.footer.appendChild(clearButton);
|
|
6581
|
+
Utils.createButton(this.footer, this.options.i18n.clear, ['timepicker-clear'], this.options.showClearBtn, this.clear);
|
|
6582
|
+
if (!this.options.autoSubmit) {
|
|
6583
|
+
/*const confirmationBtnsContainer = document.createElement('div');
|
|
6584
|
+
confirmationBtnsContainer.classList.add('confirmation-btns');
|
|
6585
|
+
this.footer.append(confirmationBtnsContainer);
|
|
6586
|
+
|
|
6587
|
+
const cancelButton = this._createButton(this.options.i18n.cancel, '');
|
|
6588
|
+
cancelButton.classList.add('timepicker-close');
|
|
6589
|
+
cancelButton.addEventListener('click', this.close);
|
|
6590
|
+
confirmationBtnsContainer.appendChild(cancelButton);
|
|
6591
|
+
|
|
6592
|
+
const doneButton = this._createButton(this.options.i18n.done, '');
|
|
6593
|
+
doneButton.classList.add('timepicker-close');
|
|
6594
|
+
//doneButton.addEventListener('click', this._finishSelection);
|
|
6595
|
+
confirmationBtnsContainer.appendChild(doneButton);*/
|
|
6596
|
+
Utils.createConfirmationContainer(this.footer, this.options.i18n.done, this.options.i18n.cancel, this.confirm, this.cancel);
|
|
6597
|
+
}
|
|
6598
|
+
this._updateTimeFromInput();
|
|
6599
|
+
this.showView('hours');
|
|
6301
6600
|
}
|
|
6302
6601
|
_clockSetup() {
|
|
6303
6602
|
if (this.options.twelveHour) {
|
|
@@ -6305,13 +6604,17 @@ class Timepicker extends Component {
|
|
|
6305
6604
|
this._amBtn = document.createElement('div');
|
|
6306
6605
|
this._amBtn.classList.add('am-btn', 'btn');
|
|
6307
6606
|
this._amBtn.innerText = 'AM';
|
|
6607
|
+
this._amBtn.tabIndex = 0;
|
|
6308
6608
|
this._amBtn.addEventListener('click', this._handleAmPmClick);
|
|
6609
|
+
this._amBtn.addEventListener('keypress', this._handleAmPmKeypress);
|
|
6309
6610
|
this.spanAmPm.appendChild(this._amBtn);
|
|
6310
6611
|
// PM Button
|
|
6311
6612
|
this._pmBtn = document.createElement('div');
|
|
6312
6613
|
this._pmBtn.classList.add('pm-btn', 'btn');
|
|
6313
6614
|
this._pmBtn.innerText = 'PM';
|
|
6615
|
+
this._pmBtn.tabIndex = 0;
|
|
6314
6616
|
this._pmBtn.addEventListener('click', this._handleAmPmClick);
|
|
6617
|
+
this._pmBtn.addEventListener('keypress', this._handleAmPmKeypress);
|
|
6315
6618
|
this.spanAmPm.appendChild(this._pmBtn);
|
|
6316
6619
|
}
|
|
6317
6620
|
this._buildHoursView();
|
|
@@ -6404,8 +6707,15 @@ class Timepicker extends Component {
|
|
|
6404
6707
|
}
|
|
6405
6708
|
}
|
|
6406
6709
|
_handleAmPmClick = (e) => {
|
|
6407
|
-
|
|
6408
|
-
|
|
6710
|
+
this._handleAmPmInteraction(e.target);
|
|
6711
|
+
};
|
|
6712
|
+
_handleAmPmKeypress = (e) => {
|
|
6713
|
+
if (Utils.keys.ENTER.includes(e.key)) {
|
|
6714
|
+
this._handleAmPmInteraction(e.target);
|
|
6715
|
+
}
|
|
6716
|
+
};
|
|
6717
|
+
_handleAmPmInteraction = (e) => {
|
|
6718
|
+
this.amOrPm = e.classList.contains('am-btn') ? 'AM' : 'PM';
|
|
6409
6719
|
this._updateAmPmView();
|
|
6410
6720
|
};
|
|
6411
6721
|
_updateAmPmView() {
|
|
@@ -6454,14 +6764,13 @@ class Timepicker extends Component {
|
|
|
6454
6764
|
if (view === 'minutes' && getComputedStyle(this.hoursView).visibility === 'visible') ;
|
|
6455
6765
|
const isHours = view === 'hours', nextView = isHours ? this.hoursView : this.minutesView, hideView = isHours ? this.minutesView : this.hoursView;
|
|
6456
6766
|
this.currentView = view;
|
|
6457
|
-
if (isHours) {
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
}
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
}
|
|
6767
|
+
/*if (isHours) {
|
|
6768
|
+
this.inputHours.classList.add('text-primary');
|
|
6769
|
+
this.inputMinutes.classList.remove('text-primary');
|
|
6770
|
+
} else {
|
|
6771
|
+
this.inputHours.classList.remove('text-primary');
|
|
6772
|
+
this.inputMinutes.classList.add('text-primary');
|
|
6773
|
+
}*/
|
|
6465
6774
|
// Transition view
|
|
6466
6775
|
hideView.classList.add('timepicker-dial-out');
|
|
6467
6776
|
nextView.style.visibility = 'visible';
|
|
@@ -6610,8 +6919,7 @@ class Timepicker extends Component {
|
|
|
6610
6919
|
this.hours = new Date().getHours();
|
|
6611
6920
|
this.inputHours.value = (this.hours % (this.options.twelveHour ? 12 : 24)).toString();
|
|
6612
6921
|
}
|
|
6613
|
-
|
|
6614
|
-
done = (e = null, clearValue = null) => {
|
|
6922
|
+
done = (clearValue = null) => {
|
|
6615
6923
|
// Set input value
|
|
6616
6924
|
const last = this.el.value;
|
|
6617
6925
|
let value = clearValue
|
|
@@ -6626,16 +6934,23 @@ class Timepicker extends Component {
|
|
|
6626
6934
|
if (value !== last) {
|
|
6627
6935
|
this.el.dispatchEvent(new Event('change', { bubbles: true, cancelable: true, composed: true }));
|
|
6628
6936
|
}
|
|
6629
|
-
|
|
6630
|
-
|
|
6937
|
+
};
|
|
6938
|
+
confirm = () => {
|
|
6939
|
+
this.done();
|
|
6940
|
+
if (typeof this.options.onDone === 'function')
|
|
6941
|
+
this.options.onDone.call(this);
|
|
6942
|
+
};
|
|
6943
|
+
cancel = () => {
|
|
6944
|
+
// not logical clearing the input field on cancel, since the end user might want to make use of the previously submitted value
|
|
6945
|
+
// this.clear();
|
|
6946
|
+
if (typeof this.options.onCancel === 'function')
|
|
6947
|
+
this.options.onCancel.call(this);
|
|
6631
6948
|
};
|
|
6632
6949
|
clear = () => {
|
|
6633
|
-
this.done(
|
|
6950
|
+
this.done(true);
|
|
6634
6951
|
};
|
|
6635
6952
|
// deprecated
|
|
6636
6953
|
open() {
|
|
6637
|
-
// this._updateTimeFromInput();
|
|
6638
|
-
// this.showView('hours');
|
|
6639
6954
|
console.warn('Timepicker.close() is deprecated. Remove this method and wrap in modal yourself.');
|
|
6640
6955
|
return this;
|
|
6641
6956
|
}
|
|
@@ -6644,14 +6959,12 @@ class Timepicker extends Component {
|
|
|
6644
6959
|
return this;
|
|
6645
6960
|
}
|
|
6646
6961
|
static {
|
|
6647
|
-
Timepicker._template =
|
|
6648
|
-
<div class="modal timepicker-modal">
|
|
6649
|
-
<div class="modal-content timepicker-container">
|
|
6962
|
+
Timepicker._template = `<div class="timepicker-container">
|
|
6650
6963
|
<div class="timepicker-digital-display">
|
|
6651
6964
|
<div class="timepicker-text-container">
|
|
6652
|
-
<div class="timepicker-display-column">
|
|
6965
|
+
<div class="timepicker-display-column timepicker-display-digital-clock">
|
|
6653
6966
|
<div class="timepicker-input-hours-wrapper">
|
|
6654
|
-
<input type="text" maxlength="2"
|
|
6967
|
+
<input type="text" maxlength="2" class="timepicker-input-hours text-primary" />
|
|
6655
6968
|
</div>
|
|
6656
6969
|
<div class="timepicker-input-divider-wrapper">
|
|
6657
6970
|
<span class="timepicker-input-divider">:</span>
|
|
@@ -6673,8 +6986,7 @@ class Timepicker extends Component {
|
|
|
6673
6986
|
</div>
|
|
6674
6987
|
<div class="timepicker-footer"></div>
|
|
6675
6988
|
</div>
|
|
6676
|
-
</div
|
|
6677
|
-
</div>`;
|
|
6989
|
+
</div>`;
|
|
6678
6990
|
}
|
|
6679
6991
|
}
|
|
6680
6992
|
|
|
@@ -7837,7 +8149,7 @@ class Toast {
|
|
|
7837
8149
|
}
|
|
7838
8150
|
|
|
7839
8151
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
7840
|
-
const version = '2.2.
|
|
8152
|
+
const version = '2.2.2';
|
|
7841
8153
|
/**
|
|
7842
8154
|
* Automatically initialize components.
|
|
7843
8155
|
* @param context Root element to initialize. Defaults to `document.body`.
|
|
@@ -7896,6 +8208,7 @@ Forms.Init();
|
|
|
7896
8208
|
Chips.Init();
|
|
7897
8209
|
Waves.Init();
|
|
7898
8210
|
Range.Init();
|
|
8211
|
+
Cards.Init();
|
|
7899
8212
|
|
|
7900
8213
|
exports.AutoInit = AutoInit;
|
|
7901
8214
|
exports.Autocomplete = Autocomplete;
|