vrembem 3.0.3 → 3.0.6

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.
@@ -308,12 +308,14 @@ function localStore(key, enable = true) {
308
308
 
309
309
  return new Proxy(getStore(), {
310
310
  set: (target, property, value) => {
311
- target[property] = value;
312
- if (enable) setStore(target);
313
- return true;
314
- },
315
- deleteProperty: (target, property) => {
316
- delete target[property];
311
+ console.log('localStore() => set');
312
+
313
+ if (value === undefined) {
314
+ delete target[property];
315
+ } else {
316
+ target[property] = value;
317
+ }
318
+
317
319
  if (enable) setStore(target);
318
320
  return true;
319
321
  }
@@ -631,7 +633,7 @@ async function deregister$2(obj, close = true) {
631
633
  } // Remove entry from local store.
632
634
 
633
635
 
634
- delete this.store[entry.id]; // Unmount the MatchMedia functionality.
636
+ this.store[entry.id] = undefined; // Unmount the MatchMedia functionality.
635
637
 
636
638
  entry.unmountBreakpoint(); // Delete properties from collection entry.
637
639
 
@@ -646,12 +648,12 @@ async function deregister$2(obj, close = true) {
646
648
  return this.collection;
647
649
  }
648
650
 
649
- function L() {
651
+ function g() {
650
652
  return getComputedStyle(document.body).getPropertyValue("--vrembem-variable-prefix").trim();
651
653
  }
652
654
 
653
655
  function getBreakpoint(drawer) {
654
- const prefix = L();
656
+ const prefix = g();
655
657
  const bp = drawer.getAttribute(`data-${this.settings.dataBreakpoint}`);
656
658
 
657
659
  if (this.settings.breakpoints && this.settings.breakpoints[bp]) {
@@ -1697,7 +1699,7 @@ function getConfig(el, settings) {
1697
1699
 
1698
1700
  for (const prop in config) {
1699
1701
  // Get the CSS variable property values.
1700
- const prefix = L();
1702
+ const prefix = g();
1701
1703
  const value = styles.getPropertyValue(`--${prefix}popover-${prop}`).trim(); // If a value was found, replace the default in config obj.
1702
1704
 
1703
1705
  if (value) {
@@ -1899,7 +1901,7 @@ function closeCheck(popover) {
1899
1901
  // Check if trigger or element are being hovered.
1900
1902
  const isHovered = popover.el.closest(':hover') === popover.el || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or element are being focused.
1901
1903
 
1902
- const isFocused = document.activeElement.closest(`#${popover.id}, [aria-controls="${popover.id}"]`); // Close if the trigger and element are not currently hovered or focused.
1904
+ const isFocused = document.activeElement.closest(`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`); // Close if the trigger and element are not currently hovered or focused.
1903
1905
 
1904
1906
  if (!isHovered && !isFocused) {
1905
1907
  popover.close();
@@ -1942,21 +1944,21 @@ function handleKeydown(event) {
1942
1944
  function handleDocumentClick(popover) {
1943
1945
  const root = this;
1944
1946
  document.addEventListener('click', function _f(event) {
1945
- // Check if a popover was clicked.
1946
- const result = event.target.closest(`#${popover.id}, [aria-controls="${popover.id}"]`);
1947
+ // Check if a popover or its trigger was clicked.
1948
+ const wasClicked = event.target.closest(`#${popover.id}, [aria-controls="${popover.id}"], [aria-describedby="${popover.id}"]`); // If popover or popover trigger was clicked...
1947
1949
 
1948
- if (!result) {
1949
- // If it doesn't match and popover is open, close it and remove event listener.
1950
+ if (wasClicked) {
1951
+ // If popover element exists and is not active...
1952
+ if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
1953
+ this.removeEventListener('click', _f);
1954
+ }
1955
+ } else {
1956
+ // If popover element exists and is active...
1950
1957
  if (popover.el && popover.el.classList.contains(root.settings.stateActive)) {
1951
1958
  popover.close();
1952
1959
  }
1953
1960
 
1954
1961
  this.removeEventListener('click', _f);
1955
- } else {
1956
- // If it does match and popover isn't currently active, remove event listener.
1957
- if (popover.el && !popover.el.classList.contains(root.settings.stateActive)) {
1958
- this.removeEventListener('click', _f);
1959
- }
1960
1962
  }
1961
1963
  });
1962
1964
  }