vrembem 1.40.2 → 1.42.0
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/LICENSE +1 -1
- package/dev/scripts.esm.js +310 -219
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +310 -219
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +269 -198
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +310 -219
- package/dev/scripts.umd.js.map +1 -1
- package/dist/scripts.esm.js +1 -1
- package/dist/scripts.esm.js.map +1 -1
- package/dist/scripts.js +1 -1
- package/dist/scripts.js.map +1 -1
- package/dist/scripts.modern.js +1 -1
- package/dist/scripts.modern.js.map +1 -1
- package/dist/scripts.umd.js +1 -1
- package/dist/scripts.umd.js.map +1 -1
- package/package.json +26 -26
package/dev/scripts.umd.js
CHANGED
|
@@ -39,10 +39,9 @@
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
|
-
* Adds a class or classes to
|
|
43
|
-
*
|
|
44
|
-
* @param
|
|
45
|
-
* @param {String || Array} cl - Class(es) to add
|
|
42
|
+
* Adds a class or classes to a Node or NodeList.
|
|
43
|
+
* @param {Node || NodeList} el - Element(s) to add class(es) to.
|
|
44
|
+
* @param {String || Array} cl - Class(es) to add.
|
|
46
45
|
*/
|
|
47
46
|
var addClass = function addClass(el) {
|
|
48
47
|
var _arguments = arguments;
|
|
@@ -55,10 +54,9 @@
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
/**
|
|
58
|
-
* Takes a hyphen cased string and converts it to camel case
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @returns {Boolean} - returns a camel cased string
|
|
57
|
+
* Takes a hyphen cased string and converts it to camel case.
|
|
58
|
+
* @param {String } str - the string to convert to camel case.
|
|
59
|
+
* @returns {Boolean} - returns a camel cased string.
|
|
62
60
|
*/
|
|
63
61
|
var camelCase = function camelCase(str) {
|
|
64
62
|
return str.replace(/-([a-z])/g, function (g) {
|
|
@@ -184,27 +182,25 @@
|
|
|
184
182
|
}();
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
|
-
* Get an element(s) from a selector or return value if not a string
|
|
188
|
-
*
|
|
189
|
-
* @param {
|
|
190
|
-
* @param {Boolean} single - Whether to return a single or all matches
|
|
185
|
+
* Get an element(s) from a selector or return value if not a string.
|
|
186
|
+
* @param {String} selector - Selector to query.
|
|
187
|
+
* @param {Boolean} single - Whether to return a single or all matches.
|
|
191
188
|
*/
|
|
192
189
|
var getElement = function getElement(selector, single) {
|
|
193
190
|
if (single === void 0) {
|
|
194
191
|
single = 0;
|
|
195
192
|
}
|
|
196
193
|
|
|
197
|
-
if (typeof selector
|
|
194
|
+
if (typeof selector !== 'string') return selector;
|
|
198
195
|
return single ? document.querySelector(selector) : document.querySelectorAll(selector);
|
|
199
196
|
};
|
|
200
197
|
|
|
201
198
|
/**
|
|
202
|
-
* Checks an element or NodeList whether they contain a class or classes
|
|
199
|
+
* Checks an element or NodeList whether they contain a class or classes.
|
|
203
200
|
* Ref: https://davidwalsh.name/nodelist-array
|
|
204
|
-
*
|
|
205
|
-
* @param {
|
|
206
|
-
* @
|
|
207
|
-
* @returns {Boolean} - Returns true if class exists, otherwise false
|
|
201
|
+
* @param {Node} el - Element(s) to check class(es) on.
|
|
202
|
+
* @param {String || Array} c - Class(es) to check.
|
|
203
|
+
* @returns {Boolean} - Returns true if class exists, otherwise false.
|
|
208
204
|
*/
|
|
209
205
|
var hasClass = function hasClass(el) {
|
|
210
206
|
el = el.forEach ? el : [el];
|
|
@@ -217,10 +213,9 @@
|
|
|
217
213
|
};
|
|
218
214
|
|
|
219
215
|
/**
|
|
220
|
-
* Takes a camel cased string and converts it to hyphen case
|
|
221
|
-
*
|
|
222
|
-
* @
|
|
223
|
-
* @returns {Boolean} - returns a hyphen cased string
|
|
216
|
+
* Takes a camel cased string and converts it to hyphen case.
|
|
217
|
+
* @param {String } str - the string to convert to hyphen case.
|
|
218
|
+
* @returns {Boolean} - returns a hyphen cased string.
|
|
224
219
|
*/
|
|
225
220
|
var hyphenCase = function hyphenCase(str) {
|
|
226
221
|
return str.replace(/([a-z][A-Z])/g, function (g) {
|
|
@@ -229,11 +224,10 @@
|
|
|
229
224
|
};
|
|
230
225
|
|
|
231
226
|
/**
|
|
232
|
-
* Moves element(s) in the DOM based on a reference and move type
|
|
233
|
-
*
|
|
234
|
-
* @param {String}
|
|
235
|
-
* @param {String}
|
|
236
|
-
* @param {String} reference - The reference element the move is relative to
|
|
227
|
+
* Moves element(s) in the DOM based on a reference and move type.
|
|
228
|
+
* @param {String} target - The element(s) to move.
|
|
229
|
+
* @param {String} type - Move type can be 'after', 'before', 'append' or 'prepend'.
|
|
230
|
+
* @param {String} reference - The reference element the move is relative to.
|
|
237
231
|
*/
|
|
238
232
|
|
|
239
233
|
function moveElement(target, type, reference) {
|
|
@@ -288,10 +282,9 @@
|
|
|
288
282
|
}
|
|
289
283
|
|
|
290
284
|
/**
|
|
291
|
-
* Remove a class or classes from an element or NodeList
|
|
292
|
-
*
|
|
293
|
-
* @param {
|
|
294
|
-
* @param {String || Array} cl - Class(es) to remove
|
|
285
|
+
* Remove a class or classes from an element or NodeList.
|
|
286
|
+
* @param {Node || NodeList} el - Element(s) to remove class(es) from.
|
|
287
|
+
* @param {String || Array} cl - Class(es) to remove.
|
|
295
288
|
*/
|
|
296
289
|
var removeClass = function removeClass(el) {
|
|
297
290
|
var _arguments = arguments;
|
|
@@ -304,10 +297,9 @@
|
|
|
304
297
|
};
|
|
305
298
|
|
|
306
299
|
/**
|
|
307
|
-
* Toggle a class or classes on an element or NodeList
|
|
308
|
-
*
|
|
309
|
-
* @param {
|
|
310
|
-
* @param {String || Array} cl - Class(es) to toggle
|
|
300
|
+
* Toggle a class or classes on an element or NodeList.
|
|
301
|
+
* @param {Node || NodeList} el - Element(s) to toggle class(es) on.
|
|
302
|
+
* @param {String || Array} cl - Class(es) to toggle.
|
|
311
303
|
*/
|
|
312
304
|
var toggleClass = function toggleClass(el) {
|
|
313
305
|
var _arguments = arguments;
|
|
@@ -394,13 +386,39 @@
|
|
|
394
386
|
return _extends.apply(this, arguments);
|
|
395
387
|
}
|
|
396
388
|
|
|
389
|
+
function _inheritsLoose(subClass, superClass) {
|
|
390
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
391
|
+
subClass.prototype.constructor = subClass;
|
|
392
|
+
|
|
393
|
+
_setPrototypeOf(subClass, superClass);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function _setPrototypeOf(o, p) {
|
|
397
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
398
|
+
o.__proto__ = p;
|
|
399
|
+
return o;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
return _setPrototypeOf(o, p);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function _assertThisInitialized(self) {
|
|
406
|
+
if (self === void 0) {
|
|
407
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return self;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
var defaults$3 = {
|
|
414
|
+
autoInit: false,
|
|
415
|
+
stateAttr: 'aria-checked',
|
|
416
|
+
stateValue: 'mixed'
|
|
417
|
+
};
|
|
418
|
+
|
|
397
419
|
var Checkbox = /*#__PURE__*/function () {
|
|
398
420
|
function Checkbox(options) {
|
|
399
|
-
this.defaults =
|
|
400
|
-
autoInit: false,
|
|
401
|
-
stateAttr: 'aria-checked',
|
|
402
|
-
stateValue: 'mixed'
|
|
403
|
-
};
|
|
421
|
+
this.defaults = defaults$3;
|
|
404
422
|
this.settings = _extends({}, this.defaults, options);
|
|
405
423
|
this.__handlerClick = this.handlerClick.bind(this);
|
|
406
424
|
if (this.settings.autoInit) this.init();
|
|
@@ -515,16 +533,23 @@
|
|
|
515
533
|
|
|
516
534
|
var drawers = document.querySelectorAll("[data-" + this.parent.settings.dataBreakpoint + "]");
|
|
517
535
|
drawers.forEach(function (drawer) {
|
|
536
|
+
// Setup mediaQueryList object
|
|
518
537
|
var id = drawer.getAttribute("data-" + _this.parent.settings.dataDrawer);
|
|
519
538
|
var key = drawer.getAttribute("data-" + _this.parent.settings.dataBreakpoint);
|
|
520
539
|
|
|
521
540
|
var bp = _this.getBreakpoint(key);
|
|
522
541
|
|
|
523
|
-
var mql = window.matchMedia('(min-width:' + bp + ')');
|
|
542
|
+
var mql = window.matchMedia('(min-width:' + bp + ')'); // Run match check
|
|
543
|
+
|
|
544
|
+
_this.match(mql, drawer); // Conditionally use addListner() for IE11 support
|
|
524
545
|
|
|
525
|
-
_this.match(mql, drawer);
|
|
526
546
|
|
|
527
|
-
mql.addEventListener
|
|
547
|
+
if (typeof mql.addEventListener === 'function') {
|
|
548
|
+
mql.addEventListener('change', _this.__check);
|
|
549
|
+
} else {
|
|
550
|
+
mql.addListener(_this.__check);
|
|
551
|
+
} // Push to mediaQueryLists array along with drawer ID
|
|
552
|
+
|
|
528
553
|
|
|
529
554
|
_this.mediaQueryLists.push({
|
|
530
555
|
'mql': mql,
|
|
@@ -1277,39 +1302,96 @@
|
|
|
1277
1302
|
return Modal;
|
|
1278
1303
|
}();
|
|
1279
1304
|
|
|
1305
|
+
var Collection = /*#__PURE__*/function () {
|
|
1306
|
+
function Collection() {
|
|
1307
|
+
this.collection = [];
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
var _proto = Collection.prototype;
|
|
1311
|
+
|
|
1312
|
+
_proto.register = function register(item) {
|
|
1313
|
+
this.deregister(item);
|
|
1314
|
+
this.collection.push(item);
|
|
1315
|
+
return this.collection;
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1318
|
+
_proto.deregister = function deregister(ref) {
|
|
1319
|
+
var index = this.collection.findIndex(function (entry) {
|
|
1320
|
+
return entry === ref;
|
|
1321
|
+
});
|
|
1322
|
+
|
|
1323
|
+
if (index >= 0) {
|
|
1324
|
+
var entry = this.collection[index];
|
|
1325
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
1326
|
+
delete entry[prop];
|
|
1327
|
+
});
|
|
1328
|
+
this.collection.splice(index, 1);
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
return this.collection;
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
_proto.registerCollection = function registerCollection(items) {
|
|
1335
|
+
var _this = this;
|
|
1336
|
+
|
|
1337
|
+
items.forEach(function (item) {
|
|
1338
|
+
_this.register(item);
|
|
1339
|
+
});
|
|
1340
|
+
return this.collection;
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
_proto.deregisterCollection = function deregisterCollection() {
|
|
1344
|
+
while (this.collection.length > 0) {
|
|
1345
|
+
this.deregister(this.collection[0]);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
return this.collection;
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
_proto.get = function get(query, key) {
|
|
1352
|
+
if (key === void 0) {
|
|
1353
|
+
key = 'id';
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
var result = this.collection.find(function (item) {
|
|
1357
|
+
return item[key] === query;
|
|
1358
|
+
});
|
|
1359
|
+
return result || null;
|
|
1360
|
+
};
|
|
1361
|
+
|
|
1362
|
+
return Collection;
|
|
1363
|
+
}();
|
|
1364
|
+
|
|
1280
1365
|
var defaults = {
|
|
1281
1366
|
autoInit: false,
|
|
1282
|
-
//
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
dataArrow: 'popover-arrow',
|
|
1286
|
-
dataEventType: 'popover-event',
|
|
1287
|
-
dataPlacement: 'popover-placement',
|
|
1367
|
+
// Selectors
|
|
1368
|
+
selectorPopover: '.popover',
|
|
1369
|
+
selectorArrow: '.popover__arrow',
|
|
1288
1370
|
// State classes
|
|
1289
1371
|
stateActive: 'is-active',
|
|
1290
1372
|
// Feature toggles
|
|
1291
|
-
eventType: 'click',
|
|
1292
1373
|
eventListeners: true,
|
|
1293
|
-
|
|
1374
|
+
eventType: 'click',
|
|
1375
|
+
placement: 'bottom'
|
|
1294
1376
|
};
|
|
1295
1377
|
|
|
1296
1378
|
function close(popover) {
|
|
1297
1379
|
// Update state class
|
|
1298
1380
|
popover.target.classList.remove(this.settings.stateActive); // Update a11y attributes
|
|
1299
1381
|
|
|
1300
|
-
popover.trigger.
|
|
1382
|
+
if (popover.trigger.hasAttribute('aria-controls')) {
|
|
1383
|
+
popover.trigger.setAttribute('aria-expanded', 'false');
|
|
1384
|
+
} // Disable popper event listeners
|
|
1385
|
+
|
|
1301
1386
|
|
|
1302
1387
|
popover.popper.setOptions({
|
|
1303
1388
|
modifiers: [{
|
|
1304
1389
|
name: 'eventListeners',
|
|
1305
1390
|
enabled: false
|
|
1306
1391
|
}]
|
|
1307
|
-
}); // Update
|
|
1392
|
+
}); // Update popover state
|
|
1308
1393
|
|
|
1309
|
-
|
|
1310
|
-
return item.target === popover.target;
|
|
1311
|
-
});
|
|
1312
|
-
this.collection[index].state = 'closed'; // Clear the memory if popover trigger matches the ones saved in memory
|
|
1394
|
+
popover.state = 'closed'; // Clear memory if popover trigger matches the one saved in memory
|
|
1313
1395
|
|
|
1314
1396
|
if (popover.trigger === this.memory.trigger) {
|
|
1315
1397
|
this.memory.trigger = null;
|
|
@@ -1319,19 +1401,15 @@
|
|
|
1319
1401
|
return popover;
|
|
1320
1402
|
}
|
|
1321
1403
|
function closeAll() {
|
|
1322
|
-
var _this = this;
|
|
1323
|
-
|
|
1324
1404
|
this.collection.forEach(function (popover) {
|
|
1325
1405
|
if (popover.state === 'opened') {
|
|
1326
|
-
|
|
1406
|
+
popover.close();
|
|
1327
1407
|
}
|
|
1328
1408
|
}); // Return the collection
|
|
1329
1409
|
|
|
1330
1410
|
return this.collection;
|
|
1331
1411
|
}
|
|
1332
1412
|
function closeCheck(popover) {
|
|
1333
|
-
var _this2 = this;
|
|
1334
|
-
|
|
1335
1413
|
// Only run closeCheck if provided popover is currently open
|
|
1336
1414
|
if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
|
|
1337
1415
|
|
|
@@ -1339,10 +1417,10 @@
|
|
|
1339
1417
|
// Check if trigger or target are being hovered
|
|
1340
1418
|
var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
|
|
1341
1419
|
|
|
1342
|
-
var isFocused = document.activeElement.closest("
|
|
1420
|
+
var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]"); // Close if the trigger and target are not currently hovered or focused
|
|
1343
1421
|
|
|
1344
1422
|
if (!isHovered && !isFocused) {
|
|
1345
|
-
|
|
1423
|
+
popover.close();
|
|
1346
1424
|
} // Return the popover
|
|
1347
1425
|
|
|
1348
1426
|
|
|
@@ -1352,10 +1430,10 @@
|
|
|
1352
1430
|
|
|
1353
1431
|
function handlerClick(popover) {
|
|
1354
1432
|
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1355
|
-
|
|
1433
|
+
popover.close();
|
|
1356
1434
|
} else {
|
|
1357
1435
|
this.memory.trigger = popover.trigger;
|
|
1358
|
-
|
|
1436
|
+
popover.open();
|
|
1359
1437
|
documentClick.call(this, popover);
|
|
1360
1438
|
}
|
|
1361
1439
|
}
|
|
@@ -1368,7 +1446,7 @@
|
|
|
1368
1446
|
this.memory.trigger.focus();
|
|
1369
1447
|
}
|
|
1370
1448
|
|
|
1371
|
-
|
|
1449
|
+
closeAll.call(this);
|
|
1372
1450
|
return;
|
|
1373
1451
|
|
|
1374
1452
|
case 'Tab':
|
|
@@ -1382,19 +1460,21 @@
|
|
|
1382
1460
|
}
|
|
1383
1461
|
}
|
|
1384
1462
|
function documentClick(popover) {
|
|
1385
|
-
var
|
|
1463
|
+
var root = this;
|
|
1386
1464
|
document.addEventListener('click', function _f(event) {
|
|
1387
|
-
|
|
1388
|
-
var
|
|
1465
|
+
// Check if a popover was clicked
|
|
1466
|
+
var result = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]");
|
|
1389
1467
|
|
|
1390
|
-
if (!
|
|
1391
|
-
|
|
1392
|
-
|
|
1468
|
+
if (!result) {
|
|
1469
|
+
// If it doesn't match and popover is open, close it and remove event listener
|
|
1470
|
+
if (popover.target && popover.target.classList.contains(root.settings.stateActive)) {
|
|
1471
|
+
popover.close();
|
|
1393
1472
|
}
|
|
1394
1473
|
|
|
1395
1474
|
this.removeEventListener('click', _f);
|
|
1396
1475
|
} else {
|
|
1397
|
-
|
|
1476
|
+
// If it does match and popover isn't currently active, remove event listener
|
|
1477
|
+
if (popover.target && !popover.target.classList.contains(root.settings.stateActive)) {
|
|
1398
1478
|
this.removeEventListener('click', _f);
|
|
1399
1479
|
}
|
|
1400
1480
|
}
|
|
@@ -1411,30 +1491,23 @@
|
|
|
1411
1491
|
'offset': 0,
|
|
1412
1492
|
'overflow-padding': 0,
|
|
1413
1493
|
'flip-padding': 0,
|
|
1414
|
-
'arrow-element':
|
|
1494
|
+
'arrow-element': settings.selectorArrow,
|
|
1415
1495
|
'arrow-padding': 0
|
|
1416
1496
|
}; // Loop through config obj
|
|
1417
1497
|
|
|
1418
1498
|
for (var prop in config) {
|
|
1419
1499
|
// Get the CSS variable property values
|
|
1420
1500
|
var prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
|
|
1421
|
-
var
|
|
1501
|
+
var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj
|
|
1422
1502
|
|
|
1423
|
-
if (
|
|
1424
|
-
config[prop] =
|
|
1503
|
+
if (value) {
|
|
1504
|
+
config[prop] = value;
|
|
1425
1505
|
}
|
|
1426
1506
|
} // Return the config obj
|
|
1427
1507
|
|
|
1428
1508
|
|
|
1429
1509
|
return config;
|
|
1430
1510
|
}
|
|
1431
|
-
function getData(el, attr, fallback) {
|
|
1432
|
-
if (fallback === void 0) {
|
|
1433
|
-
fallback = false;
|
|
1434
|
-
}
|
|
1435
|
-
|
|
1436
|
-
return el.hasAttribute("data-" + attr) ? el.getAttribute("data-" + attr) : fallback;
|
|
1437
|
-
}
|
|
1438
1511
|
function getPadding(value) {
|
|
1439
1512
|
var padding; // Split the value by spaces if it's a string
|
|
1440
1513
|
|
|
@@ -1508,47 +1581,56 @@
|
|
|
1508
1581
|
}
|
|
1509
1582
|
}];
|
|
1510
1583
|
}
|
|
1511
|
-
function
|
|
1512
|
-
//
|
|
1513
|
-
|
|
1584
|
+
function getPopoverID(obj) {
|
|
1585
|
+
// If it's a string
|
|
1586
|
+
if (typeof obj === 'string') {
|
|
1587
|
+
return obj;
|
|
1588
|
+
} // If it's an HTML element
|
|
1589
|
+
else if (typeof obj.hasAttribute === 'function') {
|
|
1590
|
+
// If it's a popover trigger
|
|
1591
|
+
if (obj.hasAttribute('aria-controls')) {
|
|
1592
|
+
return obj.getAttribute('aria-controls');
|
|
1593
|
+
} // If it's a popover tooltip trigger
|
|
1594
|
+
else if (obj.hasAttribute('aria-describedby')) {
|
|
1595
|
+
return obj.getAttribute('aria-describedby');
|
|
1596
|
+
} // If it's a popover target
|
|
1597
|
+
else if (obj.closest(this.settings.selectorPopover)) {
|
|
1598
|
+
return obj.id;
|
|
1599
|
+
} // Return false if no id was found
|
|
1600
|
+
else return false;
|
|
1601
|
+
} // If it has an ID property
|
|
1602
|
+
else if (obj.id) {
|
|
1603
|
+
return obj.id;
|
|
1604
|
+
} // Return false if no id was found
|
|
1605
|
+
else return false;
|
|
1606
|
+
}
|
|
1607
|
+
function getPopoverElements(query) {
|
|
1608
|
+
var id = getPopoverID.call(this, query);
|
|
1514
1609
|
|
|
1515
1610
|
if (id) {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
return document.querySelector("[data-" + settings.dataPopover + "=\"" + id + "\"]");
|
|
1519
|
-
} else {
|
|
1520
|
-
// If trigger attribute value doesn't exist, check if
|
|
1521
|
-
// - There is a nextElementSibling relative to the trigger
|
|
1522
|
-
// - And it has the popover data attribute.
|
|
1523
|
-
return trigger.nextElementSibling && trigger.nextElementSibling.hasAttribute("data-" + settings.dataPopover) ? // Return the element or false if the two checks fail
|
|
1524
|
-
trigger.nextElementSibling : false;
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
function open(popover) {
|
|
1529
|
-
// Update state class
|
|
1530
|
-
popover.target.classList.add(this.settings.stateActive); // Update a11y attributes
|
|
1531
|
-
|
|
1532
|
-
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
1533
|
-
|
|
1534
|
-
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
1535
|
-
|
|
1536
|
-
popover.popper.setOptions({
|
|
1537
|
-
placement: getData(popover.target, this.settings.dataPlacement, popover.config['placement']),
|
|
1538
|
-
modifiers: [{
|
|
1539
|
-
name: 'eventListeners',
|
|
1540
|
-
enabled: true
|
|
1541
|
-
}].concat(getModifiers(popover.config))
|
|
1542
|
-
}); // Update popover's position
|
|
1543
|
-
|
|
1544
|
-
popover.popper.update(); // Update collection status with new state
|
|
1611
|
+
var trigger = document.querySelector("[aria-controls=\"" + id + "\"]") || document.querySelector("[aria-describedby=\"" + id + "\"]");
|
|
1612
|
+
var target = document.querySelector("#" + id);
|
|
1545
1613
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1614
|
+
if (!trigger && !target) {
|
|
1615
|
+
console.error('No popover elements found using the provided ID:', id);
|
|
1616
|
+
} else if (!trigger) {
|
|
1617
|
+
console.error('No popover trigger associated with the provided popover:', target);
|
|
1618
|
+
} else if (!target) {
|
|
1619
|
+
console.error('No popover associated with the provided popover trigger:', trigger);
|
|
1620
|
+
}
|
|
1550
1621
|
|
|
1551
|
-
|
|
1622
|
+
if (!trigger || !target) {
|
|
1623
|
+
return false;
|
|
1624
|
+
} else {
|
|
1625
|
+
return {
|
|
1626
|
+
trigger: trigger,
|
|
1627
|
+
target: target
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
} else {
|
|
1631
|
+
console.error('Could not resolve the popover ID:', query);
|
|
1632
|
+
return false;
|
|
1633
|
+
}
|
|
1552
1634
|
}
|
|
1553
1635
|
|
|
1554
1636
|
var top = 'top';
|
|
@@ -3334,72 +3416,98 @@
|
|
|
3334
3416
|
defaultModifiers: defaultModifiers
|
|
3335
3417
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
3336
3418
|
|
|
3337
|
-
function
|
|
3338
|
-
//
|
|
3339
|
-
|
|
3340
|
-
// Try and get the target
|
|
3341
|
-
target = getPopover(trigger, this.settings); // If still no target is returned, log an error and return false
|
|
3419
|
+
function open(popover) {
|
|
3420
|
+
// Update state class
|
|
3421
|
+
popover.target.classList.add(this.settings.stateActive); // Update a11y attribute
|
|
3342
3422
|
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
}
|
|
3347
|
-
} // Check if this item has already been registered in the collection
|
|
3423
|
+
if (popover.trigger.hasAttribute('aria-controls')) {
|
|
3424
|
+
popover.trigger.setAttribute('aria-expanded', 'true');
|
|
3425
|
+
} // Update popover config
|
|
3348
3426
|
|
|
3349
3427
|
|
|
3350
|
-
|
|
3351
|
-
return item.trigger === trigger && item.target === target;
|
|
3352
|
-
}); // Initiate popover variable
|
|
3428
|
+
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
3353
3429
|
|
|
3354
|
-
|
|
3430
|
+
popover.popper.setOptions({
|
|
3431
|
+
placement: popover.config['placement'],
|
|
3432
|
+
modifiers: [{
|
|
3433
|
+
name: 'eventListeners',
|
|
3434
|
+
enabled: true
|
|
3435
|
+
}].concat(getModifiers(popover.config))
|
|
3436
|
+
}); // Update popover position
|
|
3355
3437
|
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3438
|
+
popover.popper.update(); // Update popover state
|
|
3439
|
+
|
|
3440
|
+
popover.state = 'opened'; // Return the popover
|
|
3441
|
+
|
|
3442
|
+
return popover;
|
|
3443
|
+
}
|
|
3444
|
+
|
|
3445
|
+
function register(trigger, target) {
|
|
3446
|
+
// Deregister popover if it already exists in the collection
|
|
3447
|
+
this.deregister(target.id); // Create popper instance
|
|
3448
|
+
|
|
3449
|
+
var popperInstance = createPopper(trigger, target); // Save root this for use inside object & create methods API
|
|
3362
3450
|
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3451
|
+
var root = this;
|
|
3452
|
+
var methods = {
|
|
3453
|
+
open: function open$1() {
|
|
3454
|
+
open.call(root, this);
|
|
3455
|
+
},
|
|
3456
|
+
close: function close$1() {
|
|
3457
|
+
close.call(root, this);
|
|
3458
|
+
},
|
|
3459
|
+
deregister: function deregister() {
|
|
3460
|
+
_deregister.call(root, this);
|
|
3461
|
+
}
|
|
3462
|
+
}; // Build popover object and push to collection array
|
|
3370
3463
|
|
|
3371
|
-
|
|
3372
|
-
|
|
3464
|
+
var popover = _extends({
|
|
3465
|
+
id: target.id,
|
|
3466
|
+
state: 'closed',
|
|
3467
|
+
trigger: trigger,
|
|
3468
|
+
target: target,
|
|
3469
|
+
popper: popperInstance,
|
|
3470
|
+
config: getConfig(target, this.settings)
|
|
3471
|
+
}, methods); // Setup event listeners
|
|
3373
3472
|
|
|
3374
3473
|
|
|
3375
3474
|
registerEventListeners.call(this, popover); // Set initial state of popover
|
|
3376
3475
|
|
|
3377
3476
|
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
3378
|
-
|
|
3477
|
+
popover.open();
|
|
3379
3478
|
documentClick.call(this, popover);
|
|
3380
3479
|
} else {
|
|
3381
|
-
|
|
3382
|
-
} //
|
|
3480
|
+
popover.close();
|
|
3481
|
+
} // Add item to collection
|
|
3482
|
+
|
|
3383
3483
|
|
|
3484
|
+
this.collection.push(popover); // Return the popover object
|
|
3384
3485
|
|
|
3385
3486
|
return popover;
|
|
3386
3487
|
}
|
|
3387
|
-
|
|
3488
|
+
|
|
3489
|
+
function _deregister(popover) {
|
|
3388
3490
|
// Check if this item has been registered in the collection
|
|
3389
|
-
var index = this.collection.findIndex(function (
|
|
3390
|
-
return
|
|
3391
|
-
}); // If the
|
|
3491
|
+
var index = this.collection.findIndex(function (entry) {
|
|
3492
|
+
return entry.id === popover.id;
|
|
3493
|
+
}); // If the entry exists in the collection
|
|
3392
3494
|
|
|
3393
3495
|
if (index >= 0) {
|
|
3394
|
-
//
|
|
3395
|
-
|
|
3396
|
-
|
|
3496
|
+
// Get the collection entry
|
|
3497
|
+
var entry = this.collection[index]; // Close the collection entry if it's open
|
|
3498
|
+
|
|
3499
|
+
if (entry.state === 'opened') {
|
|
3500
|
+
entry.close();
|
|
3397
3501
|
} // Clean up the popper instance
|
|
3398
3502
|
|
|
3399
3503
|
|
|
3400
|
-
|
|
3504
|
+
entry.popper.destroy(); // Remove event listeners
|
|
3505
|
+
|
|
3506
|
+
deregisterEventListeners(entry); // Delete properties from collection entry
|
|
3401
3507
|
|
|
3402
|
-
|
|
3508
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
3509
|
+
delete entry[prop];
|
|
3510
|
+
}); // Remove entry from collection
|
|
3403
3511
|
|
|
3404
3512
|
this.collection.splice(index, 1);
|
|
3405
3513
|
} // Return the new collection
|
|
@@ -3411,7 +3519,7 @@
|
|
|
3411
3519
|
// If event listeners aren't already setup
|
|
3412
3520
|
if (!popover.__eventListeners) {
|
|
3413
3521
|
// Add event listeners based on event type
|
|
3414
|
-
var eventType =
|
|
3522
|
+
var eventType = popover.config['event'];
|
|
3415
3523
|
|
|
3416
3524
|
if (eventType === 'hover') {
|
|
3417
3525
|
// Setup event listeners object for hover
|
|
@@ -3472,38 +3580,23 @@
|
|
|
3472
3580
|
|
|
3473
3581
|
return popover;
|
|
3474
3582
|
}
|
|
3475
|
-
function registerCollection() {
|
|
3476
|
-
var _this = this;
|
|
3477
3583
|
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
triggers.forEach(function (trigger) {
|
|
3481
|
-
// Register the popover and save to collection array
|
|
3482
|
-
_this.register(trigger, false);
|
|
3483
|
-
}); // Return the popover collection
|
|
3584
|
+
var Popover = /*#__PURE__*/function (_Collection) {
|
|
3585
|
+
_inheritsLoose(Popover, _Collection);
|
|
3484
3586
|
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
function deregisterCollection() {
|
|
3488
|
-
// Loop through all items within the collection and pass them to deregister()
|
|
3489
|
-
while (this.collection.length > 0) {
|
|
3490
|
-
this.deregister(this.collection[0]);
|
|
3491
|
-
} // Return the popover collection
|
|
3587
|
+
function Popover(options) {
|
|
3588
|
+
var _this;
|
|
3492
3589
|
|
|
3590
|
+
_this = _Collection.call(this) || this;
|
|
3591
|
+
_this.defaults = defaults;
|
|
3592
|
+
_this.settings = _extends({}, _this.defaults, options); // this.collection = [];
|
|
3493
3593
|
|
|
3494
|
-
|
|
3495
|
-
}
|
|
3496
|
-
|
|
3497
|
-
var Popover = /*#__PURE__*/function () {
|
|
3498
|
-
function Popover(options) {
|
|
3499
|
-
this.defaults = defaults;
|
|
3500
|
-
this.settings = _extends({}, this.defaults, options);
|
|
3501
|
-
this.collection = [];
|
|
3502
|
-
this.memory = {
|
|
3594
|
+
_this.memory = {
|
|
3503
3595
|
trigger: null
|
|
3504
3596
|
};
|
|
3505
|
-
|
|
3506
|
-
if (
|
|
3597
|
+
_this.__handlerKeydown = handlerKeydown.bind(_assertThisInitialized(_this));
|
|
3598
|
+
if (_this.settings.autoInit) _this.init();
|
|
3599
|
+
return _this;
|
|
3507
3600
|
}
|
|
3508
3601
|
|
|
3509
3602
|
var _proto = Popover.prototype;
|
|
@@ -3514,9 +3607,11 @@
|
|
|
3514
3607
|
}
|
|
3515
3608
|
|
|
3516
3609
|
// Update settings with passed options
|
|
3517
|
-
if (options) this.settings = _extends({}, this.settings, options); //
|
|
3610
|
+
if (options) this.settings = _extends({}, this.settings, options); // Get all the popovers
|
|
3611
|
+
|
|
3612
|
+
var popovers = document.querySelectorAll(this.settings.selectorPopover); // Build the collections array with popover instances
|
|
3518
3613
|
|
|
3519
|
-
this.registerCollection(); // If eventListeners is enabled
|
|
3614
|
+
this.registerCollection(popovers); // If eventListeners is enabled
|
|
3520
3615
|
|
|
3521
3616
|
if (this.settings.eventListeners) {
|
|
3522
3617
|
// Pass false to initEventListeners() since registerCollection()
|
|
@@ -3541,7 +3636,7 @@
|
|
|
3541
3636
|
;
|
|
3542
3637
|
|
|
3543
3638
|
_proto.initEventListeners = function initEventListeners(processCollection) {
|
|
3544
|
-
var
|
|
3639
|
+
var _this2 = this;
|
|
3545
3640
|
|
|
3546
3641
|
if (processCollection === void 0) {
|
|
3547
3642
|
processCollection = true;
|
|
@@ -3550,7 +3645,7 @@
|
|
|
3550
3645
|
if (processCollection) {
|
|
3551
3646
|
// Loop through collection and setup event listeners
|
|
3552
3647
|
this.collection.forEach(function (popover) {
|
|
3553
|
-
registerEventListeners.call(
|
|
3648
|
+
registerEventListeners.call(_this2, popover);
|
|
3554
3649
|
});
|
|
3555
3650
|
} // Add keydown global event listener
|
|
3556
3651
|
|
|
@@ -3578,44 +3673,40 @@
|
|
|
3578
3673
|
*/
|
|
3579
3674
|
;
|
|
3580
3675
|
|
|
3581
|
-
_proto.register = function register$1(
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
return register.call(this, trigger, target);
|
|
3676
|
+
_proto.register = function register$1(query) {
|
|
3677
|
+
var els = getPopoverElements.call(this, query);
|
|
3678
|
+
if (!els) return false;
|
|
3679
|
+
return register.call(this, els.trigger, els.target);
|
|
3587
3680
|
};
|
|
3588
3681
|
|
|
3589
|
-
_proto.deregister = function deregister
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
_proto.registerCollection = function registerCollection$1() {
|
|
3594
|
-
return registerCollection.call(this);
|
|
3595
|
-
};
|
|
3596
|
-
|
|
3597
|
-
_proto.deregisterCollection = function deregisterCollection$1() {
|
|
3598
|
-
return deregisterCollection.call(this);
|
|
3682
|
+
_proto.deregister = function deregister(query) {
|
|
3683
|
+
var popover = this.get(getPopoverID(query));
|
|
3684
|
+
if (!popover) return false;
|
|
3685
|
+
return _deregister.call(this, popover);
|
|
3599
3686
|
}
|
|
3600
3687
|
/**
|
|
3601
3688
|
* Change state functionality
|
|
3602
3689
|
*/
|
|
3603
3690
|
;
|
|
3604
3691
|
|
|
3605
|
-
_proto.open = function open
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
_proto.close = function close$1(popover) {
|
|
3610
|
-
return close.call(this, popover);
|
|
3692
|
+
_proto.open = function open(id) {
|
|
3693
|
+
var popover = this.get(id);
|
|
3694
|
+
if (!popover) return false;
|
|
3695
|
+
return popover.open();
|
|
3611
3696
|
};
|
|
3612
3697
|
|
|
3613
|
-
_proto.
|
|
3614
|
-
|
|
3698
|
+
_proto.close = function close(id) {
|
|
3699
|
+
if (id) {
|
|
3700
|
+
var popover = this.get(id);
|
|
3701
|
+
if (!popover) return false;
|
|
3702
|
+
return popover.close();
|
|
3703
|
+
} else {
|
|
3704
|
+
return closeAll.call(this);
|
|
3705
|
+
}
|
|
3615
3706
|
};
|
|
3616
3707
|
|
|
3617
3708
|
return Popover;
|
|
3618
|
-
}();
|
|
3709
|
+
}(Collection);
|
|
3619
3710
|
|
|
3620
3711
|
exports.Checkbox = Checkbox;
|
|
3621
3712
|
exports.Drawer = Drawer;
|