@turquoisehealth/pit-viper 2.109.0 → 2.109.1
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/_site/assets/js/pit-viper.js +45 -25
- package/package.json +1 -1
|
@@ -179,7 +179,7 @@ class PVAutoClose extends HTMLElement {
|
|
|
179
179
|
}
|
|
180
180
|
customElements.define('pv-data-grid', PVDataGrid);
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
class PvGlobalNav extends HTMLElement {
|
|
183
183
|
constructor() {
|
|
184
184
|
super();
|
|
185
185
|
this.hoverTimeout = null;
|
|
@@ -191,7 +191,7 @@ class PVAutoClose extends HTMLElement {
|
|
|
191
191
|
this.minimizeButton?.addEventListener('click', (e) => this.toggleSidebar(e.currentTarget));
|
|
192
192
|
this.addEventListener('mouseenter', () => this.handleHoverIn());
|
|
193
193
|
this.addEventListener('mouseleave', () => this.handleHoverOut());
|
|
194
|
-
document.addEventListener('click', (e) => this.
|
|
194
|
+
document.addEventListener('click', (e) => this.globalNavClickHandler(e));
|
|
195
195
|
// if data-collapsed is not set, add data-expanded by default
|
|
196
196
|
if (!this.layout.hasAttribute('data-collapsed') && !this.layout.hasAttribute('data-expanded')) {
|
|
197
197
|
this.setState({ 'data-collapsed': false, 'data-expanded': true });
|
|
@@ -260,23 +260,20 @@ class PVAutoClose extends HTMLElement {
|
|
|
260
260
|
|
|
261
261
|
handleHoverIn() {
|
|
262
262
|
clearTimeout(this.hoverTimeout);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}, 200);
|
|
272
|
-
}
|
|
263
|
+
this.hoverTimeout = setTimeout(() => {
|
|
264
|
+
if (window.innerWidth < 768) {
|
|
265
|
+
this.layout.removeAttribute('data-collapsed');
|
|
266
|
+
this.layout.setAttribute('data-floating', '');
|
|
267
|
+
} else if (this.layout.hasAttribute('data-collapsed')) {
|
|
268
|
+
this.hoverExpandState();
|
|
269
|
+
}
|
|
270
|
+
}, 200);
|
|
273
271
|
}
|
|
274
272
|
|
|
275
273
|
handleHoverOut() {
|
|
276
274
|
clearTimeout(this.hoverTimeout);
|
|
277
275
|
if (this.layout.hasAttribute('data-floating') && !this.hasOpenMenu()) {
|
|
278
276
|
this.layout.removeAttribute('data-floating');
|
|
279
|
-
this.layout.setAttribute('data-collapsed', '');
|
|
280
277
|
} else if (!this.layout.hasAttribute('data-collapsed') && !this.layout.hasAttribute('data-expanded') && !this.hasOpenMenu()) {
|
|
281
278
|
this.hoverCollapseState();
|
|
282
279
|
}
|
|
@@ -286,27 +283,50 @@ class PVAutoClose extends HTMLElement {
|
|
|
286
283
|
return this.querySelector('.pv-popover-menu[data-active]') !== null;
|
|
287
284
|
}
|
|
288
285
|
|
|
289
|
-
|
|
286
|
+
toggleMenu(menu) {
|
|
287
|
+
const isActive = menu.hasAttribute('data-active');
|
|
288
|
+
if (isActive) {
|
|
289
|
+
menu.removeAttribute('data-active');
|
|
290
|
+
} else {
|
|
291
|
+
menu.setAttribute('data-active', '');
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
globalNavClickHandler(event) {
|
|
296
|
+
const inSidebar = this.contains(event.target);
|
|
297
|
+
const insideMenu = event.target.closest('.pv-popover');
|
|
290
298
|
const clickedMenu = event.target.closest('.pv-popover-menu');
|
|
291
299
|
const allMenus = this.querySelectorAll('.pv-popover-menu');
|
|
292
300
|
|
|
301
|
+
// if we are inside a menu (not the trigger), do nothing
|
|
302
|
+
if (insideMenu) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// if we clicked on a menu trigger, toggle that menu and close others
|
|
293
307
|
if (clickedMenu && this.contains(clickedMenu)) {
|
|
294
|
-
allMenus.forEach(menu =>
|
|
295
|
-
|
|
296
|
-
|
|
308
|
+
allMenus.forEach(menu => {
|
|
309
|
+
if (menu !== clickedMenu) {
|
|
310
|
+
menu.removeAttribute('data-active');
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
this.toggleMenu(clickedMenu);
|
|
314
|
+
this.style.overflowX = 'initial';
|
|
297
315
|
if (!this.layout.hasAttribute('data-expanded')) {
|
|
298
|
-
|
|
316
|
+
this.hoverExpandState();
|
|
299
317
|
}
|
|
300
318
|
return;
|
|
301
319
|
}
|
|
320
|
+
// if outside sidebar, remove 'data-floating;
|
|
321
|
+
if (!inSidebar) {
|
|
322
|
+
this.layout.removeAttribute('data-floating');
|
|
323
|
+
}
|
|
302
324
|
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
this.hoverCollapseState();
|
|
309
|
-
}
|
|
325
|
+
// clicked outside any menu, close all menus
|
|
326
|
+
allMenus.forEach(menu => menu.removeAttribute('data-active'));
|
|
327
|
+
this.style.overflowX = 'hidden';
|
|
328
|
+
if (!this.layout.hasAttribute('data-collapsed') && !this.layout.hasAttribute('data-expanded')) {
|
|
329
|
+
this.hoverCollapseState();
|
|
310
330
|
}
|
|
311
331
|
}
|
|
312
332
|
}
|