vrembem 1.40.3 → 1.41.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/dev/scripts.esm.js +256 -175
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +256 -175
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +213 -154
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +256 -175
- 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.esm.js
CHANGED
|
@@ -381,6 +381,30 @@ function _extends() {
|
|
|
381
381
|
return _extends.apply(this, arguments);
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
+
function _inheritsLoose(subClass, superClass) {
|
|
385
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
386
|
+
subClass.prototype.constructor = subClass;
|
|
387
|
+
|
|
388
|
+
_setPrototypeOf(subClass, superClass);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function _setPrototypeOf(o, p) {
|
|
392
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
393
|
+
o.__proto__ = p;
|
|
394
|
+
return o;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
return _setPrototypeOf(o, p);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function _assertThisInitialized(self) {
|
|
401
|
+
if (self === void 0) {
|
|
402
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return self;
|
|
406
|
+
}
|
|
407
|
+
|
|
384
408
|
var defaults$3 = {
|
|
385
409
|
autoInit: false,
|
|
386
410
|
stateAttr: 'aria-checked',
|
|
@@ -1273,20 +1297,77 @@ var Modal = /*#__PURE__*/function () {
|
|
|
1273
1297
|
return Modal;
|
|
1274
1298
|
}();
|
|
1275
1299
|
|
|
1300
|
+
var Collection = /*#__PURE__*/function () {
|
|
1301
|
+
function Collection() {
|
|
1302
|
+
this.collection = [];
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
var _proto = Collection.prototype;
|
|
1306
|
+
|
|
1307
|
+
_proto.register = function register(item) {
|
|
1308
|
+
this.deregister(item);
|
|
1309
|
+
this.collection.push(item);
|
|
1310
|
+
return this.collection;
|
|
1311
|
+
};
|
|
1312
|
+
|
|
1313
|
+
_proto.deregister = function deregister(ref) {
|
|
1314
|
+
var index = this.collection.findIndex(function (entry) {
|
|
1315
|
+
return entry === ref;
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
if (index >= 0) {
|
|
1319
|
+
var entry = this.collection[index];
|
|
1320
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
1321
|
+
delete entry[prop];
|
|
1322
|
+
});
|
|
1323
|
+
this.collection.splice(index, 1);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
return this.collection;
|
|
1327
|
+
};
|
|
1328
|
+
|
|
1329
|
+
_proto.registerCollection = function registerCollection(items) {
|
|
1330
|
+
var _this = this;
|
|
1331
|
+
|
|
1332
|
+
items.forEach(function (item) {
|
|
1333
|
+
_this.register(item);
|
|
1334
|
+
});
|
|
1335
|
+
return this.collection;
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
_proto.deregisterCollection = function deregisterCollection() {
|
|
1339
|
+
while (this.collection.length > 0) {
|
|
1340
|
+
this.deregister(this.collection[0]);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
return this.collection;
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
_proto.get = function get(query, key) {
|
|
1347
|
+
if (key === void 0) {
|
|
1348
|
+
key = 'id';
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
var result = this.collection.find(function (item) {
|
|
1352
|
+
return item[key] === query;
|
|
1353
|
+
});
|
|
1354
|
+
return result || null;
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
return Collection;
|
|
1358
|
+
}();
|
|
1359
|
+
|
|
1276
1360
|
var defaults = {
|
|
1277
1361
|
autoInit: false,
|
|
1278
|
-
//
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
dataArrow: 'popover-arrow',
|
|
1282
|
-
dataEventType: 'popover-event',
|
|
1283
|
-
dataPlacement: 'popover-placement',
|
|
1362
|
+
// Selectors
|
|
1363
|
+
selectorPopover: '.popover',
|
|
1364
|
+
selectorArrow: '.popover__arrow',
|
|
1284
1365
|
// State classes
|
|
1285
1366
|
stateActive: 'is-active',
|
|
1286
1367
|
// Feature toggles
|
|
1287
|
-
eventType: 'click',
|
|
1288
1368
|
eventListeners: true,
|
|
1289
|
-
|
|
1369
|
+
eventType: 'click',
|
|
1370
|
+
placement: 'bottom'
|
|
1290
1371
|
};
|
|
1291
1372
|
|
|
1292
1373
|
function close(popover) {
|
|
@@ -1300,12 +1381,9 @@ function close(popover) {
|
|
|
1300
1381
|
name: 'eventListeners',
|
|
1301
1382
|
enabled: false
|
|
1302
1383
|
}]
|
|
1303
|
-
}); // Update
|
|
1384
|
+
}); // Update popover state
|
|
1304
1385
|
|
|
1305
|
-
|
|
1306
|
-
return item.target === popover.target;
|
|
1307
|
-
});
|
|
1308
|
-
this.collection[index].state = 'closed'; // Clear the memory if popover trigger matches the ones saved in memory
|
|
1386
|
+
popover.state = 'closed'; // Clear memory if popover trigger matches the one saved in memory
|
|
1309
1387
|
|
|
1310
1388
|
if (popover.trigger === this.memory.trigger) {
|
|
1311
1389
|
this.memory.trigger = null;
|
|
@@ -1315,19 +1393,15 @@ function close(popover) {
|
|
|
1315
1393
|
return popover;
|
|
1316
1394
|
}
|
|
1317
1395
|
function closeAll() {
|
|
1318
|
-
var _this = this;
|
|
1319
|
-
|
|
1320
1396
|
this.collection.forEach(function (popover) {
|
|
1321
1397
|
if (popover.state === 'opened') {
|
|
1322
|
-
|
|
1398
|
+
popover.close();
|
|
1323
1399
|
}
|
|
1324
1400
|
}); // Return the collection
|
|
1325
1401
|
|
|
1326
1402
|
return this.collection;
|
|
1327
1403
|
}
|
|
1328
1404
|
function closeCheck(popover) {
|
|
1329
|
-
var _this2 = this;
|
|
1330
|
-
|
|
1331
1405
|
// Only run closeCheck if provided popover is currently open
|
|
1332
1406
|
if (popover.state != 'opened') return; // Needed to correctly check which element is currently being focused
|
|
1333
1407
|
|
|
@@ -1335,10 +1409,10 @@ function closeCheck(popover) {
|
|
|
1335
1409
|
// Check if trigger or target are being hovered
|
|
1336
1410
|
var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
|
|
1337
1411
|
|
|
1338
|
-
var isFocused = document.activeElement.closest("
|
|
1412
|
+
var isFocused = document.activeElement.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]"); // Close if the trigger and target are not currently hovered or focused
|
|
1339
1413
|
|
|
1340
1414
|
if (!isHovered && !isFocused) {
|
|
1341
|
-
|
|
1415
|
+
popover.close();
|
|
1342
1416
|
} // Return the popover
|
|
1343
1417
|
|
|
1344
1418
|
|
|
@@ -1348,10 +1422,10 @@ function closeCheck(popover) {
|
|
|
1348
1422
|
|
|
1349
1423
|
function handlerClick(popover) {
|
|
1350
1424
|
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
1351
|
-
|
|
1425
|
+
popover.close();
|
|
1352
1426
|
} else {
|
|
1353
1427
|
this.memory.trigger = popover.trigger;
|
|
1354
|
-
|
|
1428
|
+
popover.open();
|
|
1355
1429
|
documentClick.call(this, popover);
|
|
1356
1430
|
}
|
|
1357
1431
|
}
|
|
@@ -1364,7 +1438,7 @@ function handlerKeydown(event) {
|
|
|
1364
1438
|
this.memory.trigger.focus();
|
|
1365
1439
|
}
|
|
1366
1440
|
|
|
1367
|
-
|
|
1441
|
+
closeAll.call(this);
|
|
1368
1442
|
return;
|
|
1369
1443
|
|
|
1370
1444
|
case 'Tab':
|
|
@@ -1378,19 +1452,21 @@ function handlerKeydown(event) {
|
|
|
1378
1452
|
}
|
|
1379
1453
|
}
|
|
1380
1454
|
function documentClick(popover) {
|
|
1381
|
-
var
|
|
1455
|
+
var root = this;
|
|
1382
1456
|
document.addEventListener('click', function _f(event) {
|
|
1383
|
-
|
|
1384
|
-
var
|
|
1457
|
+
// Check if a popover was clicked
|
|
1458
|
+
var result = event.target.closest("#" + popover.id + ", [aria-controls=\"" + popover.id + "\"]");
|
|
1385
1459
|
|
|
1386
|
-
if (!
|
|
1387
|
-
|
|
1388
|
-
|
|
1460
|
+
if (!result) {
|
|
1461
|
+
// If it doesn't match and popover is open, close it and remove event listener
|
|
1462
|
+
if (popover.target && popover.target.classList.contains(root.settings.stateActive)) {
|
|
1463
|
+
popover.close();
|
|
1389
1464
|
}
|
|
1390
1465
|
|
|
1391
1466
|
this.removeEventListener('click', _f);
|
|
1392
1467
|
} else {
|
|
1393
|
-
|
|
1468
|
+
// If it does match and popover isn't currently active, remove event listener
|
|
1469
|
+
if (popover.target && !popover.target.classList.contains(root.settings.stateActive)) {
|
|
1394
1470
|
this.removeEventListener('click', _f);
|
|
1395
1471
|
}
|
|
1396
1472
|
}
|
|
@@ -1407,30 +1483,23 @@ function getConfig(el, settings) {
|
|
|
1407
1483
|
'offset': 0,
|
|
1408
1484
|
'overflow-padding': 0,
|
|
1409
1485
|
'flip-padding': 0,
|
|
1410
|
-
'arrow-element':
|
|
1486
|
+
'arrow-element': settings.selectorArrow,
|
|
1411
1487
|
'arrow-padding': 0
|
|
1412
1488
|
}; // Loop through config obj
|
|
1413
1489
|
|
|
1414
1490
|
for (var prop in config) {
|
|
1415
1491
|
// Get the CSS variable property values
|
|
1416
1492
|
var prefix = getComputedStyle(document.body).getPropertyValue('--vrembem-variable-prefix');
|
|
1417
|
-
var
|
|
1493
|
+
var value = styles.getPropertyValue("--" + prefix + "popover-" + prop).trim(); // If a value was found, replace the default in config obj
|
|
1418
1494
|
|
|
1419
|
-
if (
|
|
1420
|
-
config[prop] =
|
|
1495
|
+
if (value) {
|
|
1496
|
+
config[prop] = value;
|
|
1421
1497
|
}
|
|
1422
1498
|
} // Return the config obj
|
|
1423
1499
|
|
|
1424
1500
|
|
|
1425
1501
|
return config;
|
|
1426
1502
|
}
|
|
1427
|
-
function getData(el, attr, fallback) {
|
|
1428
|
-
if (fallback === void 0) {
|
|
1429
|
-
fallback = false;
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
return el.hasAttribute("data-" + attr) ? el.getAttribute("data-" + attr) : fallback;
|
|
1433
|
-
}
|
|
1434
1503
|
function getPadding(value) {
|
|
1435
1504
|
var padding; // Split the value by spaces if it's a string
|
|
1436
1505
|
|
|
@@ -1504,47 +1573,53 @@ function getModifiers(options) {
|
|
|
1504
1573
|
}
|
|
1505
1574
|
}];
|
|
1506
1575
|
}
|
|
1507
|
-
function
|
|
1508
|
-
//
|
|
1509
|
-
|
|
1576
|
+
function getPopoverID(obj) {
|
|
1577
|
+
// If it's a string
|
|
1578
|
+
if (typeof obj === 'string') {
|
|
1579
|
+
return obj;
|
|
1580
|
+
} // If it's an HTML element
|
|
1581
|
+
else if (typeof obj.hasAttribute === 'function') {
|
|
1582
|
+
// If it's a popover trigger
|
|
1583
|
+
if (obj.hasAttribute('aria-controls')) {
|
|
1584
|
+
return obj.getAttribute('aria-controls');
|
|
1585
|
+
} // If it's a popover target
|
|
1586
|
+
else if (obj.closest(this.settings.selectorPopover)) {
|
|
1587
|
+
return obj.id;
|
|
1588
|
+
} // Return false if no id was found
|
|
1589
|
+
else return false;
|
|
1590
|
+
} // If it has an ID property
|
|
1591
|
+
else if (obj.id) {
|
|
1592
|
+
return obj.id;
|
|
1593
|
+
} // Return false if no id was found
|
|
1594
|
+
else return false;
|
|
1595
|
+
}
|
|
1596
|
+
function getPopoverElements(query) {
|
|
1597
|
+
var id = getPopoverID.call(this, query);
|
|
1510
1598
|
|
|
1511
1599
|
if (id) {
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
return document.querySelector("[data-" + settings.dataPopover + "=\"" + id + "\"]");
|
|
1515
|
-
} else {
|
|
1516
|
-
// If trigger attribute value doesn't exist, check if
|
|
1517
|
-
// - There is a nextElementSibling relative to the trigger
|
|
1518
|
-
// - And it has the popover data attribute.
|
|
1519
|
-
return trigger.nextElementSibling && trigger.nextElementSibling.hasAttribute("data-" + settings.dataPopover) ? // Return the element or false if the two checks fail
|
|
1520
|
-
trigger.nextElementSibling : false;
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
|
|
1524
|
-
function open(popover) {
|
|
1525
|
-
// Update state class
|
|
1526
|
-
popover.target.classList.add(this.settings.stateActive); // Update a11y attributes
|
|
1527
|
-
|
|
1528
|
-
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
1529
|
-
|
|
1530
|
-
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
1531
|
-
|
|
1532
|
-
popover.popper.setOptions({
|
|
1533
|
-
placement: getData(popover.target, this.settings.dataPlacement, popover.config['placement']),
|
|
1534
|
-
modifiers: [{
|
|
1535
|
-
name: 'eventListeners',
|
|
1536
|
-
enabled: true
|
|
1537
|
-
}].concat(getModifiers(popover.config))
|
|
1538
|
-
}); // Update popover's position
|
|
1600
|
+
var trigger = document.querySelector("[aria-controls=\"" + id + "\"]");
|
|
1601
|
+
var target = document.querySelector("#" + id);
|
|
1539
1602
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1603
|
+
if (!trigger && !target) {
|
|
1604
|
+
console.error('No popover elements found using the provided ID:', id);
|
|
1605
|
+
} else if (!trigger) {
|
|
1606
|
+
console.error('No popover trigger associated with the provided popover:', target);
|
|
1607
|
+
} else if (!target) {
|
|
1608
|
+
console.error('No popover associated with the provided popover trigger:', trigger);
|
|
1609
|
+
}
|
|
1546
1610
|
|
|
1547
|
-
|
|
1611
|
+
if (!trigger || !target) {
|
|
1612
|
+
return false;
|
|
1613
|
+
} else {
|
|
1614
|
+
return {
|
|
1615
|
+
trigger: trigger,
|
|
1616
|
+
target: target
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
} else {
|
|
1620
|
+
console.error('Could not resolve the popover ID:', query);
|
|
1621
|
+
return false;
|
|
1622
|
+
}
|
|
1548
1623
|
}
|
|
1549
1624
|
|
|
1550
1625
|
var top = 'top';
|
|
@@ -3330,72 +3405,95 @@ var createPopper = /*#__PURE__*/popperGenerator({
|
|
|
3330
3405
|
defaultModifiers: defaultModifiers
|
|
3331
3406
|
}); // eslint-disable-next-line import/no-unused-modules
|
|
3332
3407
|
|
|
3333
|
-
function
|
|
3334
|
-
//
|
|
3335
|
-
|
|
3336
|
-
// Try and get the target
|
|
3337
|
-
target = getPopover(trigger, this.settings); // If still no target is returned, log an error and return false
|
|
3408
|
+
function open(popover) {
|
|
3409
|
+
// Update state class
|
|
3410
|
+
popover.target.classList.add(this.settings.stateActive); // Update a11y attribute
|
|
3338
3411
|
|
|
3339
|
-
|
|
3340
|
-
console.error('No popover associated with the provided trigger:', trigger);
|
|
3341
|
-
return false;
|
|
3342
|
-
}
|
|
3343
|
-
} // Check if this item has already been registered in the collection
|
|
3412
|
+
popover.trigger.setAttribute('aria-expanded', 'true'); // Update popover config
|
|
3344
3413
|
|
|
3414
|
+
popover.config = getConfig(popover.target, this.settings); // Enable popper event listeners and set placement/modifiers
|
|
3345
3415
|
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3416
|
+
popover.popper.setOptions({
|
|
3417
|
+
placement: popover.config['placement'],
|
|
3418
|
+
modifiers: [{
|
|
3419
|
+
name: 'eventListeners',
|
|
3420
|
+
enabled: true
|
|
3421
|
+
}].concat(getModifiers(popover.config))
|
|
3422
|
+
}); // Update popover position
|
|
3349
3423
|
|
|
3350
|
-
|
|
3424
|
+
popover.popper.update(); // Update popover state
|
|
3351
3425
|
|
|
3352
|
-
|
|
3353
|
-
// Set popover as item from collection
|
|
3354
|
-
popover = this.collection[index];
|
|
3355
|
-
} else {
|
|
3356
|
-
// Create popper instance
|
|
3357
|
-
var popperInstance = createPopper(trigger, target); // Build popover object and push to collection array
|
|
3426
|
+
popover.state = 'opened'; // Return the popover
|
|
3358
3427
|
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3428
|
+
return popover;
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3431
|
+
function register(trigger, target) {
|
|
3432
|
+
// Deregister popover if it already exists in the collection
|
|
3433
|
+
this.deregister(target.id); // Create popper instance
|
|
3434
|
+
|
|
3435
|
+
var popperInstance = createPopper(trigger, target); // Save root this for use inside object & create methods API
|
|
3436
|
+
|
|
3437
|
+
var root = this;
|
|
3438
|
+
var methods = {
|
|
3439
|
+
open: function open$1() {
|
|
3440
|
+
open.call(root, this);
|
|
3441
|
+
},
|
|
3442
|
+
close: function close$1() {
|
|
3443
|
+
close.call(root, this);
|
|
3444
|
+
},
|
|
3445
|
+
deregister: function deregister() {
|
|
3446
|
+
_deregister.call(root, this);
|
|
3447
|
+
}
|
|
3448
|
+
}; // Build popover object and push to collection array
|
|
3366
3449
|
|
|
3367
|
-
|
|
3368
|
-
|
|
3450
|
+
var popover = _extends({
|
|
3451
|
+
id: target.id,
|
|
3452
|
+
state: 'closed',
|
|
3453
|
+
trigger: trigger,
|
|
3454
|
+
target: target,
|
|
3455
|
+
popper: popperInstance,
|
|
3456
|
+
config: getConfig(target, this.settings)
|
|
3457
|
+
}, methods); // Setup event listeners
|
|
3369
3458
|
|
|
3370
3459
|
|
|
3371
3460
|
registerEventListeners.call(this, popover); // Set initial state of popover
|
|
3372
3461
|
|
|
3373
3462
|
if (popover.target.classList.contains(this.settings.stateActive)) {
|
|
3374
|
-
|
|
3463
|
+
popover.open();
|
|
3375
3464
|
documentClick.call(this, popover);
|
|
3376
3465
|
} else {
|
|
3377
|
-
|
|
3378
|
-
} //
|
|
3466
|
+
popover.close();
|
|
3467
|
+
} // Add item to collection
|
|
3468
|
+
|
|
3379
3469
|
|
|
3470
|
+
this.collection.push(popover); // Return the popover object
|
|
3380
3471
|
|
|
3381
3472
|
return popover;
|
|
3382
3473
|
}
|
|
3383
|
-
|
|
3474
|
+
|
|
3475
|
+
function _deregister(popover) {
|
|
3384
3476
|
// Check if this item has been registered in the collection
|
|
3385
|
-
var index = this.collection.findIndex(function (
|
|
3386
|
-
return
|
|
3387
|
-
}); // If the
|
|
3477
|
+
var index = this.collection.findIndex(function (entry) {
|
|
3478
|
+
return entry.id === popover.id;
|
|
3479
|
+
}); // If the entry exists in the collection
|
|
3388
3480
|
|
|
3389
3481
|
if (index >= 0) {
|
|
3390
|
-
//
|
|
3391
|
-
|
|
3392
|
-
|
|
3482
|
+
// Get the collection entry
|
|
3483
|
+
var entry = this.collection[index]; // Close the collection entry if it's open
|
|
3484
|
+
|
|
3485
|
+
if (entry.state === 'opened') {
|
|
3486
|
+
entry.close();
|
|
3393
3487
|
} // Clean up the popper instance
|
|
3394
3488
|
|
|
3395
3489
|
|
|
3396
|
-
|
|
3490
|
+
entry.popper.destroy(); // Remove event listeners
|
|
3491
|
+
|
|
3492
|
+
deregisterEventListeners(entry); // Delete properties from collection entry
|
|
3397
3493
|
|
|
3398
|
-
|
|
3494
|
+
Object.getOwnPropertyNames(entry).forEach(function (prop) {
|
|
3495
|
+
delete entry[prop];
|
|
3496
|
+
}); // Remove entry from collection
|
|
3399
3497
|
|
|
3400
3498
|
this.collection.splice(index, 1);
|
|
3401
3499
|
} // Return the new collection
|
|
@@ -3407,7 +3505,7 @@ function registerEventListeners(popover) {
|
|
|
3407
3505
|
// If event listeners aren't already setup
|
|
3408
3506
|
if (!popover.__eventListeners) {
|
|
3409
3507
|
// Add event listeners based on event type
|
|
3410
|
-
var eventType =
|
|
3508
|
+
var eventType = popover.config['event'];
|
|
3411
3509
|
|
|
3412
3510
|
if (eventType === 'hover') {
|
|
3413
3511
|
// Setup event listeners object for hover
|
|
@@ -3468,38 +3566,23 @@ function deregisterEventListeners(popover) {
|
|
|
3468
3566
|
|
|
3469
3567
|
return popover;
|
|
3470
3568
|
}
|
|
3471
|
-
function registerCollection() {
|
|
3472
|
-
var _this = this;
|
|
3473
3569
|
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
triggers.forEach(function (trigger) {
|
|
3477
|
-
// Register the popover and save to collection array
|
|
3478
|
-
_this.register(trigger, false);
|
|
3479
|
-
}); // Return the popover collection
|
|
3480
|
-
|
|
3481
|
-
return this.collection;
|
|
3482
|
-
}
|
|
3483
|
-
function deregisterCollection() {
|
|
3484
|
-
// Loop through all items within the collection and pass them to deregister()
|
|
3485
|
-
while (this.collection.length > 0) {
|
|
3486
|
-
this.deregister(this.collection[0]);
|
|
3487
|
-
} // Return the popover collection
|
|
3570
|
+
var Popover = /*#__PURE__*/function (_Collection) {
|
|
3571
|
+
_inheritsLoose(Popover, _Collection);
|
|
3488
3572
|
|
|
3573
|
+
function Popover(options) {
|
|
3574
|
+
var _this;
|
|
3489
3575
|
|
|
3490
|
-
|
|
3491
|
-
|
|
3576
|
+
_this = _Collection.call(this) || this;
|
|
3577
|
+
_this.defaults = defaults;
|
|
3578
|
+
_this.settings = _extends({}, _this.defaults, options); // this.collection = [];
|
|
3492
3579
|
|
|
3493
|
-
|
|
3494
|
-
function Popover(options) {
|
|
3495
|
-
this.defaults = defaults;
|
|
3496
|
-
this.settings = _extends({}, this.defaults, options);
|
|
3497
|
-
this.collection = [];
|
|
3498
|
-
this.memory = {
|
|
3580
|
+
_this.memory = {
|
|
3499
3581
|
trigger: null
|
|
3500
3582
|
};
|
|
3501
|
-
|
|
3502
|
-
if (
|
|
3583
|
+
_this.__handlerKeydown = handlerKeydown.bind(_assertThisInitialized(_this));
|
|
3584
|
+
if (_this.settings.autoInit) _this.init();
|
|
3585
|
+
return _this;
|
|
3503
3586
|
}
|
|
3504
3587
|
|
|
3505
3588
|
var _proto = Popover.prototype;
|
|
@@ -3510,9 +3593,11 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3510
3593
|
}
|
|
3511
3594
|
|
|
3512
3595
|
// Update settings with passed options
|
|
3513
|
-
if (options) this.settings = _extends({}, this.settings, options); //
|
|
3596
|
+
if (options) this.settings = _extends({}, this.settings, options); // Get all the popovers
|
|
3597
|
+
|
|
3598
|
+
var popovers = document.querySelectorAll(this.settings.selectorPopover); // Build the collections array with popover instances
|
|
3514
3599
|
|
|
3515
|
-
this.registerCollection(); // If eventListeners is enabled
|
|
3600
|
+
this.registerCollection(popovers); // If eventListeners is enabled
|
|
3516
3601
|
|
|
3517
3602
|
if (this.settings.eventListeners) {
|
|
3518
3603
|
// Pass false to initEventListeners() since registerCollection()
|
|
@@ -3537,7 +3622,7 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3537
3622
|
;
|
|
3538
3623
|
|
|
3539
3624
|
_proto.initEventListeners = function initEventListeners(processCollection) {
|
|
3540
|
-
var
|
|
3625
|
+
var _this2 = this;
|
|
3541
3626
|
|
|
3542
3627
|
if (processCollection === void 0) {
|
|
3543
3628
|
processCollection = true;
|
|
@@ -3546,7 +3631,7 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3546
3631
|
if (processCollection) {
|
|
3547
3632
|
// Loop through collection and setup event listeners
|
|
3548
3633
|
this.collection.forEach(function (popover) {
|
|
3549
|
-
registerEventListeners.call(
|
|
3634
|
+
registerEventListeners.call(_this2, popover);
|
|
3550
3635
|
});
|
|
3551
3636
|
} // Add keydown global event listener
|
|
3552
3637
|
|
|
@@ -3574,44 +3659,40 @@ var Popover = /*#__PURE__*/function () {
|
|
|
3574
3659
|
*/
|
|
3575
3660
|
;
|
|
3576
3661
|
|
|
3577
|
-
_proto.register = function register$1(
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
return register.call(this, trigger, target);
|
|
3583
|
-
};
|
|
3584
|
-
|
|
3585
|
-
_proto.deregister = function deregister$1(popover) {
|
|
3586
|
-
return deregister.call(this, popover);
|
|
3587
|
-
};
|
|
3588
|
-
|
|
3589
|
-
_proto.registerCollection = function registerCollection$1() {
|
|
3590
|
-
return registerCollection.call(this);
|
|
3662
|
+
_proto.register = function register$1(query) {
|
|
3663
|
+
var els = getPopoverElements.call(this, query);
|
|
3664
|
+
if (!els) return false;
|
|
3665
|
+
return register.call(this, els.trigger, els.target);
|
|
3591
3666
|
};
|
|
3592
3667
|
|
|
3593
|
-
_proto.
|
|
3594
|
-
|
|
3668
|
+
_proto.deregister = function deregister(query) {
|
|
3669
|
+
var popover = this.get(getPopoverID(query));
|
|
3670
|
+
if (!popover) return false;
|
|
3671
|
+
return _deregister.call(this, popover);
|
|
3595
3672
|
}
|
|
3596
3673
|
/**
|
|
3597
3674
|
* Change state functionality
|
|
3598
3675
|
*/
|
|
3599
3676
|
;
|
|
3600
3677
|
|
|
3601
|
-
_proto.open = function open
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
_proto.close = function close$1(popover) {
|
|
3606
|
-
return close.call(this, popover);
|
|
3678
|
+
_proto.open = function open(id) {
|
|
3679
|
+
var popover = this.get(id);
|
|
3680
|
+
if (!popover) return false;
|
|
3681
|
+
return popover.open();
|
|
3607
3682
|
};
|
|
3608
3683
|
|
|
3609
|
-
_proto.
|
|
3610
|
-
|
|
3684
|
+
_proto.close = function close(id) {
|
|
3685
|
+
if (id) {
|
|
3686
|
+
var popover = this.get(id);
|
|
3687
|
+
if (!popover) return false;
|
|
3688
|
+
return popover.close();
|
|
3689
|
+
} else {
|
|
3690
|
+
return closeAll.call(this);
|
|
3691
|
+
}
|
|
3611
3692
|
};
|
|
3612
3693
|
|
|
3613
3694
|
return Popover;
|
|
3614
|
-
}();
|
|
3695
|
+
}(Collection);
|
|
3615
3696
|
|
|
3616
3697
|
export { Checkbox, Drawer, Modal, Popover, index as core };
|
|
3617
3698
|
//# sourceMappingURL=scripts.esm.js.map
|