vrembem 3.0.7 → 3.0.8
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 +96 -85
- package/dev/scripts.esm.js.map +1 -1
- package/dev/scripts.js +96 -85
- package/dev/scripts.js.map +1 -1
- package/dev/scripts.modern.js +100 -81
- package/dev/scripts.modern.js.map +1 -1
- package/dev/scripts.umd.js +96 -85
- 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.modern.js
CHANGED
|
@@ -297,29 +297,25 @@ function getPrefix() {
|
|
|
297
297
|
}
|
|
298
298
|
|
|
299
299
|
function localStore(key, enable = true) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
localStorage.setItem(key, JSON.stringify(obj));
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return new Proxy(getStore(), {
|
|
310
|
-
set: (target, property, value) => {
|
|
311
|
-
console.log('localStore() => set');
|
|
300
|
+
const local = localStorage.getItem(key);
|
|
301
|
+
const store = local ? JSON.parse(local) : {};
|
|
302
|
+
return {
|
|
303
|
+
get(prop) {
|
|
304
|
+
return prop ? store[prop] : store;
|
|
305
|
+
},
|
|
312
306
|
|
|
313
|
-
|
|
314
|
-
|
|
307
|
+
set(prop, value) {
|
|
308
|
+
if (value) {
|
|
309
|
+
store[prop] = value;
|
|
315
310
|
} else {
|
|
316
|
-
|
|
311
|
+
delete store[prop];
|
|
317
312
|
}
|
|
318
313
|
|
|
319
|
-
if (enable)
|
|
320
|
-
return
|
|
314
|
+
if (enable) localStorage.setItem(key, JSON.stringify(store));
|
|
315
|
+
return store;
|
|
321
316
|
}
|
|
322
|
-
|
|
317
|
+
|
|
318
|
+
};
|
|
323
319
|
}
|
|
324
320
|
|
|
325
321
|
/**
|
|
@@ -633,7 +629,7 @@ async function deregister$2(obj, close = true) {
|
|
|
633
629
|
} // Remove entry from local store.
|
|
634
630
|
|
|
635
631
|
|
|
636
|
-
this.store
|
|
632
|
+
this.store.set(entry.id); // Unmount the MatchMedia functionality.
|
|
637
633
|
|
|
638
634
|
entry.unmountBreakpoint(); // Delete properties from collection entry.
|
|
639
635
|
|
|
@@ -737,9 +733,9 @@ async function initialState(entry) {
|
|
|
737
733
|
// 1. If a store state is available, restore from local store.
|
|
738
734
|
// 2. If opened state class is set, set state to opened.
|
|
739
735
|
// 3. Else, initialize default state.
|
|
740
|
-
if (this.store
|
|
736
|
+
if (this.store.get(entry.id)) {
|
|
741
737
|
// Restore drawers to saved inline state.
|
|
742
|
-
if (this.store
|
|
738
|
+
if (this.store.get(entry.id) === 'opened') {
|
|
743
739
|
await entry.open(false, false);
|
|
744
740
|
} else {
|
|
745
741
|
await entry.close(false, false);
|
|
@@ -897,9 +893,9 @@ async function toModal(entry) {
|
|
|
897
893
|
|
|
898
894
|
entry.dialog.setAttribute('aria-modal', 'true'); // If there isn't a stored state but also has the opened state class...
|
|
899
895
|
|
|
900
|
-
if (!this.store
|
|
896
|
+
if (!this.store.get(entry.id) && entry.el.classList.contains(entry.getSetting('stateOpened'))) {
|
|
901
897
|
// Save the opened state in local store.
|
|
902
|
-
this.store
|
|
898
|
+
this.store.set(entry.id, 'opened');
|
|
903
899
|
} // Modal drawer defaults to closed state.
|
|
904
900
|
|
|
905
901
|
|
|
@@ -980,7 +976,7 @@ async function register$2(el, dialog) {
|
|
|
980
976
|
__state = value; // Save 'opened' and 'closed' states to store if mode is inline.
|
|
981
977
|
|
|
982
978
|
if (value === 'opened' || value === 'closed') {
|
|
983
|
-
if (this.mode === 'inline') root.store
|
|
979
|
+
if (this.mode === 'inline') root.store.set(this.id, this.state);
|
|
984
980
|
}
|
|
985
981
|
},
|
|
986
982
|
|
|
@@ -1235,14 +1231,6 @@ function updateFocusState() {
|
|
|
1235
1231
|
}
|
|
1236
1232
|
}
|
|
1237
1233
|
|
|
1238
|
-
function updateStackIndex(stack) {
|
|
1239
|
-
stack.forEach((entry, index) => {
|
|
1240
|
-
entry.el.style.zIndex = null;
|
|
1241
|
-
const value = getComputedStyle(entry.el)['z-index'];
|
|
1242
|
-
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
1234
|
async function handleClick$1(event) {
|
|
1247
1235
|
// If an open or replace button was clicked, open or replace the modal.
|
|
1248
1236
|
let trigger = event.target.closest(`[data-${this.settings.dataOpen}], [data-${this.settings.dataReplace}]`);
|
|
@@ -1299,14 +1287,8 @@ async function deregister$1(obj, close = true) {
|
|
|
1299
1287
|
if (close && entry.state === 'opened') {
|
|
1300
1288
|
await entry.close(false);
|
|
1301
1289
|
} else {
|
|
1302
|
-
//
|
|
1303
|
-
|
|
1304
|
-
return item.id === entry.id;
|
|
1305
|
-
}); // Remove modal from stack array.
|
|
1306
|
-
|
|
1307
|
-
if (stackIndex >= 0) {
|
|
1308
|
-
this.stack.splice(stackIndex, 1);
|
|
1309
|
-
}
|
|
1290
|
+
// Remove modal from stack.
|
|
1291
|
+
this.stack.remove(entry);
|
|
1310
1292
|
} // Return teleported modal if a reference has been set.
|
|
1311
1293
|
|
|
1312
1294
|
|
|
@@ -1333,29 +1315,15 @@ async function open$1(query, transition, focus = true) {
|
|
|
1333
1315
|
const config = _extends({}, this.settings, modal.settings); // Add transition parameter to configuration.
|
|
1334
1316
|
|
|
1335
1317
|
|
|
1336
|
-
if (transition !== undefined) config.transition = transition; //
|
|
1337
|
-
|
|
1338
|
-
const index = this.stack.findIndex(entry => {
|
|
1339
|
-
return entry.id === modal.id;
|
|
1340
|
-
}); // If modal is already open.
|
|
1341
|
-
|
|
1342
|
-
if (index >= 0) {
|
|
1343
|
-
// Remove modal from stack array.
|
|
1344
|
-
this.stack.splice(index, 1); // Move back to end of stack.
|
|
1345
|
-
|
|
1346
|
-
this.stack.push(modal);
|
|
1347
|
-
} // If modal is closed.
|
|
1318
|
+
if (transition !== undefined) config.transition = transition; // Maybe add modal to top of stack.
|
|
1348
1319
|
|
|
1320
|
+
this.stack.moveToTop(modal); // If modal is closed.
|
|
1349
1321
|
|
|
1350
1322
|
if (modal.state === 'closed') {
|
|
1351
1323
|
// Update modal state.
|
|
1352
|
-
modal.state = 'opening'; //
|
|
1324
|
+
modal.state = 'opening'; // Add modal to stack.
|
|
1353
1325
|
|
|
1354
|
-
|
|
1355
|
-
const value = getComputedStyle(modal.el)['z-index'];
|
|
1356
|
-
modal.el.style.zIndex = parseInt(value) + this.stack.length + 1; // Store modal in stack array.
|
|
1357
|
-
|
|
1358
|
-
this.stack.push(modal); // Run the open transition.
|
|
1326
|
+
this.stack.add(modal); // Run the open transition.
|
|
1359
1327
|
|
|
1360
1328
|
await openTransition(modal.el, config); // Update modal state.
|
|
1361
1329
|
|
|
@@ -1391,15 +1359,9 @@ async function close$1(query, transition, focus = true) {
|
|
|
1391
1359
|
|
|
1392
1360
|
document.activeElement.blur(); // Run the close transition.
|
|
1393
1361
|
|
|
1394
|
-
await closeTransition(modal.el, config); // Remove
|
|
1395
|
-
|
|
1396
|
-
modal.el.style.zIndex = null; // Get index of modal in stack array.
|
|
1397
|
-
|
|
1398
|
-
const index = this.stack.findIndex(entry => {
|
|
1399
|
-
return entry.id === modal.id;
|
|
1400
|
-
}); // Remove modal from stack array.
|
|
1362
|
+
await closeTransition(modal.el, config); // Remove modal from stack.
|
|
1401
1363
|
|
|
1402
|
-
this.stack.
|
|
1364
|
+
this.stack.remove(modal); // Update focus if the focus param is true.
|
|
1403
1365
|
|
|
1404
1366
|
if (focus) {
|
|
1405
1367
|
updateFocusState.call(this);
|
|
@@ -1420,7 +1382,7 @@ async function close$1(query, transition, focus = true) {
|
|
|
1420
1382
|
|
|
1421
1383
|
async function closeAll$1(exclude, transition) {
|
|
1422
1384
|
const result = [];
|
|
1423
|
-
await Promise.all(this.stack.map(async modal => {
|
|
1385
|
+
await Promise.all(this.stack.value.map(async modal => {
|
|
1424
1386
|
if (exclude && exclude === modal.id) {
|
|
1425
1387
|
Promise.resolve();
|
|
1426
1388
|
} else {
|
|
@@ -1554,6 +1516,74 @@ async function register$1(el, dialog) {
|
|
|
1554
1516
|
return entry;
|
|
1555
1517
|
}
|
|
1556
1518
|
|
|
1519
|
+
function stack(settings) {
|
|
1520
|
+
const stackArray = [];
|
|
1521
|
+
return {
|
|
1522
|
+
get value() {
|
|
1523
|
+
return [...stackArray];
|
|
1524
|
+
},
|
|
1525
|
+
|
|
1526
|
+
get top() {
|
|
1527
|
+
return stackArray[stackArray.length - 1];
|
|
1528
|
+
},
|
|
1529
|
+
|
|
1530
|
+
updateIndex() {
|
|
1531
|
+
stackArray.forEach((entry, index) => {
|
|
1532
|
+
entry.el.style.zIndex = null;
|
|
1533
|
+
const value = getComputedStyle(entry.el)['z-index'];
|
|
1534
|
+
entry.el.style.zIndex = parseInt(value) + index + 1;
|
|
1535
|
+
});
|
|
1536
|
+
},
|
|
1537
|
+
|
|
1538
|
+
updateGlobalState() {
|
|
1539
|
+
updateGlobalState(this.top, settings);
|
|
1540
|
+
this.updateIndex();
|
|
1541
|
+
},
|
|
1542
|
+
|
|
1543
|
+
add(entry) {
|
|
1544
|
+
// Apply z-index styles based on stack length.
|
|
1545
|
+
entry.el.style.zIndex = null;
|
|
1546
|
+
const value = getComputedStyle(entry.el)['z-index'];
|
|
1547
|
+
entry.el.style.zIndex = parseInt(value) + stackArray.length + 1; // Move back to end of stack.
|
|
1548
|
+
|
|
1549
|
+
stackArray.push(entry); // Update the global state.
|
|
1550
|
+
|
|
1551
|
+
this.updateGlobalState();
|
|
1552
|
+
},
|
|
1553
|
+
|
|
1554
|
+
remove(entry) {
|
|
1555
|
+
// Get the index of the entry.
|
|
1556
|
+
const index = stackArray.findIndex(item => {
|
|
1557
|
+
return item.id === entry.id;
|
|
1558
|
+
}); // If entry is in stack...
|
|
1559
|
+
|
|
1560
|
+
if (index >= 0) {
|
|
1561
|
+
// Remove z-index styles.
|
|
1562
|
+
entry.el.style.zIndex = null; // Remove entry from stack array.
|
|
1563
|
+
|
|
1564
|
+
stackArray.splice(index, 1); // Update the global state.
|
|
1565
|
+
|
|
1566
|
+
this.updateGlobalState();
|
|
1567
|
+
}
|
|
1568
|
+
},
|
|
1569
|
+
|
|
1570
|
+
moveToTop(entry) {
|
|
1571
|
+
// Get the index of the entry.
|
|
1572
|
+
const index = stackArray.findIndex(item => {
|
|
1573
|
+
return item.id === entry.id;
|
|
1574
|
+
}); // If entry is in stack...
|
|
1575
|
+
|
|
1576
|
+
if (index >= 0) {
|
|
1577
|
+
// Remove entry from stack array.
|
|
1578
|
+
stackArray.splice(index, 1); // Add entry back to top of stack.
|
|
1579
|
+
|
|
1580
|
+
this.add(entry);
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1557
1587
|
var _handleClick = /*#__PURE__*/_classPrivateFieldLooseKey("handleClick");
|
|
1558
1588
|
|
|
1559
1589
|
var _handleKeydown$1 = /*#__PURE__*/_classPrivateFieldLooseKey("handleKeydown");
|
|
@@ -1572,27 +1602,16 @@ class Modal extends Collection {
|
|
|
1572
1602
|
this.defaults = defaults$1;
|
|
1573
1603
|
this.settings = _extends({}, this.defaults, options);
|
|
1574
1604
|
this.trigger = null;
|
|
1575
|
-
this.focusTrap = new FocusTrap(); // Setup
|
|
1576
|
-
|
|
1577
|
-
this.stack = new Proxy([], {
|
|
1578
|
-
set: (target, property, value) => {
|
|
1579
|
-
target[property] = value; // Update global state if stack length changed.
|
|
1580
|
-
|
|
1581
|
-
if (property === 'length') {
|
|
1582
|
-
updateGlobalState(this.active, this.settings);
|
|
1583
|
-
updateStackIndex(this.stack);
|
|
1584
|
-
}
|
|
1605
|
+
this.focusTrap = new FocusTrap(); // Setup stack module.
|
|
1585
1606
|
|
|
1586
|
-
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1607
|
+
this.stack = stack(this.settings);
|
|
1589
1608
|
_classPrivateFieldLooseBase(this, _handleClick)[_handleClick] = handleClick$1.bind(this);
|
|
1590
1609
|
_classPrivateFieldLooseBase(this, _handleKeydown$1)[_handleKeydown$1] = handleKeydown$1.bind(this);
|
|
1591
1610
|
if (this.settings.autoInit) this.init();
|
|
1592
1611
|
}
|
|
1593
1612
|
|
|
1594
1613
|
get active() {
|
|
1595
|
-
return this.stack
|
|
1614
|
+
return this.stack.top;
|
|
1596
1615
|
}
|
|
1597
1616
|
|
|
1598
1617
|
async init(options) {
|