@nanoporetech-digital/components 8.23.1 → 8.23.2
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/dist/cjs/nano-dropdown_2.cjs.entry.js +12 -7
- package/dist/collection/components/breadcrumb/breadcrumb.js +1 -1
- package/dist/collection/components/menu/menu.js +12 -7
- package/dist/components/menu.js +12 -7
- package/dist/esm/nano-dropdown_2.entry.js +12 -7
- package/dist/nano-components/nano-dropdown_2.entry.js +1 -1
- package/docs-json.json +2 -2
- package/hydrate/index.js +12 -7
- package/hydrate/index.mjs +12 -7
- package/package.json +2 -2
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/generate-vue-component.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/index.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/output-vue.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/plugin.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/types.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/plugins/stencil/vue-output/utils.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/stencil.config.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/stencil.config.prod.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/testing/mocks/intersection-observer.d.ts +0 -0
- /package/dist/types/builds/{8qhywLzS → nxMX84kt}/0/Digital/nano-components/packages/components/.stencil/wdio.conf.d.ts +0 -0
|
@@ -463,7 +463,7 @@ const Menu = class {
|
|
|
463
463
|
get selectedItem() {
|
|
464
464
|
return this.getItems.find((i) => i.selected);
|
|
465
465
|
}
|
|
466
|
-
async setActiveFocusItem(item, focus = true) {
|
|
466
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
467
467
|
const items = this.getItems;
|
|
468
468
|
const activeItem = !item
|
|
469
469
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -474,13 +474,18 @@ const Menu = class {
|
|
|
474
474
|
if (!focus)
|
|
475
475
|
return;
|
|
476
476
|
if (activeItem) {
|
|
477
|
-
if (
|
|
477
|
+
if (preventScroll) {
|
|
478
|
+
activeItem.focus({ preventScroll: true });
|
|
479
|
+
}
|
|
480
|
+
else if (activeItem.setFocus) {
|
|
478
481
|
activeItem.setFocus();
|
|
479
|
-
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
480
484
|
activeItem.focus();
|
|
485
|
+
}
|
|
481
486
|
}
|
|
482
487
|
else if (!this.hasFocus) {
|
|
483
|
-
this.menu.focus();
|
|
488
|
+
this.menu.focus({ preventScroll });
|
|
484
489
|
}
|
|
485
490
|
}
|
|
486
491
|
// Event Handlers
|
|
@@ -591,7 +596,7 @@ const Menu = class {
|
|
|
591
596
|
target.closest(renderer.transformTag('nano-option')) ||
|
|
592
597
|
target.closest('a');
|
|
593
598
|
if (item && !this.ignoreMouseEvents) {
|
|
594
|
-
this.setActiveFocusItem(item);
|
|
599
|
+
this.setActiveFocusItem(item, true, true);
|
|
595
600
|
}
|
|
596
601
|
};
|
|
597
602
|
handleSlotContent = () => {
|
|
@@ -635,11 +640,11 @@ const Menu = class {
|
|
|
635
640
|
this.handleSlotContent();
|
|
636
641
|
}
|
|
637
642
|
render() {
|
|
638
|
-
return (renderer.h(index.Host, { key: '
|
|
643
|
+
return (renderer.h(index.Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, renderer.h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
639
644
|
menu: true,
|
|
640
645
|
['menu--' + this._type]: true,
|
|
641
646
|
'menu--has-focus': this.hasFocus,
|
|
642
|
-
}, tabIndex: -1, role: "group" }, renderer.h("slot", { key: '
|
|
647
|
+
}, tabIndex: -1, role: "group" }, renderer.h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
643
648
|
}
|
|
644
649
|
};
|
|
645
650
|
Menu.style = menuCss;
|
|
@@ -89,7 +89,7 @@ export class NanoBreadcrumb {
|
|
|
89
89
|
"references": {
|
|
90
90
|
"Breadcrumb": {
|
|
91
91
|
"location": "local",
|
|
92
|
-
"path": "/builds/
|
|
92
|
+
"path": "/builds/nxMX84kt/0/Digital/nano-components/packages/components/src/components/breadcrumb/breadcrumb.tsx",
|
|
93
93
|
"id": "src/components/breadcrumb/breadcrumb.tsx::Breadcrumb"
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -89,7 +89,7 @@ export class Menu {
|
|
|
89
89
|
get selectedItem() {
|
|
90
90
|
return this.getItems.find((i) => i.selected);
|
|
91
91
|
}
|
|
92
|
-
async setActiveFocusItem(item, focus = true) {
|
|
92
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
93
93
|
const items = this.getItems;
|
|
94
94
|
const activeItem = !item
|
|
95
95
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -100,13 +100,18 @@ export class Menu {
|
|
|
100
100
|
if (!focus)
|
|
101
101
|
return;
|
|
102
102
|
if (activeItem) {
|
|
103
|
-
if (
|
|
103
|
+
if (preventScroll) {
|
|
104
|
+
activeItem.focus({ preventScroll: true });
|
|
105
|
+
}
|
|
106
|
+
else if (activeItem.setFocus) {
|
|
104
107
|
activeItem.setFocus();
|
|
105
|
-
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
106
110
|
activeItem.focus();
|
|
111
|
+
}
|
|
107
112
|
}
|
|
108
113
|
else if (!this.hasFocus) {
|
|
109
|
-
this.menu.focus();
|
|
114
|
+
this.menu.focus({ preventScroll });
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
// Event Handlers
|
|
@@ -217,7 +222,7 @@ export class Menu {
|
|
|
217
222
|
target.closest(transformTag('nano-option')) ||
|
|
218
223
|
target.closest('a');
|
|
219
224
|
if (item && !this.ignoreMouseEvents) {
|
|
220
|
-
this.setActiveFocusItem(item);
|
|
225
|
+
this.setActiveFocusItem(item, true, true);
|
|
221
226
|
}
|
|
222
227
|
};
|
|
223
228
|
handleSlotContent = () => {
|
|
@@ -261,11 +266,11 @@ export class Menu {
|
|
|
261
266
|
this.handleSlotContent();
|
|
262
267
|
}
|
|
263
268
|
render() {
|
|
264
|
-
return (h(Host, { key: '
|
|
269
|
+
return (h(Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
265
270
|
menu: true,
|
|
266
271
|
['menu--' + this._type]: true,
|
|
267
272
|
'menu--has-focus': this.hasFocus,
|
|
268
|
-
}, tabIndex: -1, role: "group" }, h("slot", { key: '
|
|
273
|
+
}, tabIndex: -1, role: "group" }, h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
269
274
|
}
|
|
270
275
|
static get is() { return "nano-menu"; }
|
|
271
276
|
static get encapsulation() { return "shadow"; }
|
package/dist/components/menu.js
CHANGED
|
@@ -90,7 +90,7 @@ const Menu = /*@__PURE__*/ proxyCustomElement(class Menu extends HTMLElement {
|
|
|
90
90
|
get selectedItem() {
|
|
91
91
|
return this.getItems.find((i) => i.selected);
|
|
92
92
|
}
|
|
93
|
-
async setActiveFocusItem(item, focus = true) {
|
|
93
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
94
94
|
const items = this.getItems;
|
|
95
95
|
const activeItem = !item
|
|
96
96
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -101,13 +101,18 @@ const Menu = /*@__PURE__*/ proxyCustomElement(class Menu extends HTMLElement {
|
|
|
101
101
|
if (!focus)
|
|
102
102
|
return;
|
|
103
103
|
if (activeItem) {
|
|
104
|
-
if (
|
|
104
|
+
if (preventScroll) {
|
|
105
|
+
activeItem.focus({ preventScroll: true });
|
|
106
|
+
}
|
|
107
|
+
else if (activeItem.setFocus) {
|
|
105
108
|
activeItem.setFocus();
|
|
106
|
-
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
107
111
|
activeItem.focus();
|
|
112
|
+
}
|
|
108
113
|
}
|
|
109
114
|
else if (!this.hasFocus) {
|
|
110
|
-
this.menu.focus();
|
|
115
|
+
this.menu.focus({ preventScroll });
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
118
|
// Event Handlers
|
|
@@ -218,7 +223,7 @@ const Menu = /*@__PURE__*/ proxyCustomElement(class Menu extends HTMLElement {
|
|
|
218
223
|
target.closest(transformTag('nano-option')) ||
|
|
219
224
|
target.closest('a');
|
|
220
225
|
if (item && !this.ignoreMouseEvents) {
|
|
221
|
-
this.setActiveFocusItem(item);
|
|
226
|
+
this.setActiveFocusItem(item, true, true);
|
|
222
227
|
}
|
|
223
228
|
};
|
|
224
229
|
handleSlotContent = () => {
|
|
@@ -262,11 +267,11 @@ const Menu = /*@__PURE__*/ proxyCustomElement(class Menu extends HTMLElement {
|
|
|
262
267
|
this.handleSlotContent();
|
|
263
268
|
}
|
|
264
269
|
render() {
|
|
265
|
-
return (h(Host, { key: '
|
|
270
|
+
return (h(Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
266
271
|
menu: true,
|
|
267
272
|
['menu--' + this._type]: true,
|
|
268
273
|
'menu--has-focus': this.hasFocus,
|
|
269
|
-
}, tabIndex: -1, role: "group" }, h("slot", { key: '
|
|
274
|
+
}, tabIndex: -1, role: "group" }, h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
270
275
|
}
|
|
271
276
|
static get style() { return menuCss; }
|
|
272
277
|
}, [257, "nano-menu", {
|
|
@@ -461,7 +461,7 @@ const Menu = class {
|
|
|
461
461
|
get selectedItem() {
|
|
462
462
|
return this.getItems.find((i) => i.selected);
|
|
463
463
|
}
|
|
464
|
-
async setActiveFocusItem(item, focus = true) {
|
|
464
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
465
465
|
const items = this.getItems;
|
|
466
466
|
const activeItem = !item
|
|
467
467
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -472,13 +472,18 @@ const Menu = class {
|
|
|
472
472
|
if (!focus)
|
|
473
473
|
return;
|
|
474
474
|
if (activeItem) {
|
|
475
|
-
if (
|
|
475
|
+
if (preventScroll) {
|
|
476
|
+
activeItem.focus({ preventScroll: true });
|
|
477
|
+
}
|
|
478
|
+
else if (activeItem.setFocus) {
|
|
476
479
|
activeItem.setFocus();
|
|
477
|
-
|
|
480
|
+
}
|
|
481
|
+
else {
|
|
478
482
|
activeItem.focus();
|
|
483
|
+
}
|
|
479
484
|
}
|
|
480
485
|
else if (!this.hasFocus) {
|
|
481
|
-
this.menu.focus();
|
|
486
|
+
this.menu.focus({ preventScroll });
|
|
482
487
|
}
|
|
483
488
|
}
|
|
484
489
|
// Event Handlers
|
|
@@ -589,7 +594,7 @@ const Menu = class {
|
|
|
589
594
|
target.closest(transformTag('nano-option')) ||
|
|
590
595
|
target.closest('a');
|
|
591
596
|
if (item && !this.ignoreMouseEvents) {
|
|
592
|
-
this.setActiveFocusItem(item);
|
|
597
|
+
this.setActiveFocusItem(item, true, true);
|
|
593
598
|
}
|
|
594
599
|
};
|
|
595
600
|
handleSlotContent = () => {
|
|
@@ -633,11 +638,11 @@ const Menu = class {
|
|
|
633
638
|
this.handleSlotContent();
|
|
634
639
|
}
|
|
635
640
|
render() {
|
|
636
|
-
return (h(Host, { key: '
|
|
641
|
+
return (h(Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
637
642
|
menu: true,
|
|
638
643
|
['menu--' + this._type]: true,
|
|
639
644
|
'menu--has-focus': this.hasFocus,
|
|
640
|
-
}, tabIndex: -1, role: "group" }, h("slot", { key: '
|
|
645
|
+
}, tabIndex: -1, role: "group" }, h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
641
646
|
}
|
|
642
647
|
};
|
|
643
648
|
Menu.style = menuCss;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Custom elements for Nanopore-Digital Web applications
|
|
3
3
|
*/
|
|
4
|
-
import{r as t,c as i,g as o,a as e}from"./index-BM3Om9WE.js";import{f as n,g as s}from"./active-element-CKJIkX0R.js";import{P as a}from"./popover-DNdFZ1hX.js";import{a as r,g as h}from"./tabbable-BgopY-vd.js";import{t as d,h as l}from"./renderer-DpNDfhNy.js";import{g as p}from"./dom-dlicJTEJ.js";import{g as c}from"./slot-Crs4khNK.js";let m=0;const u=class{constructor(o){t(this,o),this.nanoShow=i(this,"nanoShow",7),this.nanoAfterShow=i(this,"nanoAfterShow",7),this.nanoHide=i(this,"nanoHide",7),this.nanoAfterHide=i(this,"nanoAfterHide",7)}dropdownId="dropdown-"+m++;labelId=this.dropdownId+"-title";ignoreOpenWatcher=!1;panel;popover;trigger;positioner;accessibleTrigger;didLoad=!1;focusFirstEle=!0;get menu(){return this.host.querySelector(d("nano-menu"))}get host(){return o(this)}autoOpen=!0;open=!1;handleOpenChange(){this.ignoreOpenWatcher||(this.open?this.show():this.hide(),this.accessibleTrigger?this.accessibleTrigger.setAttribute("aria-expanded",this.open.toString()):this.updateAccessibleTrigger())}closeOnSelect=!0;containingElement;tetherTo=null;handleTetherToChange(){this.createPopover(),this.updateAccessibleTrigger()}placement="bottom-start";distance=5;skidding=0;hoist=!1;handlePopoverOptionsChange(){this.popover&&this.popover.setOptions({strategy:this.hoist?"fixed":"absolute",placement:this.placement,skidding:this.skidding,distance:this.distance})}dialogTitle;nanoShow;nanoAfterShow;nanoHide;nanoAfterHide;eventType;secondaryOpen(t){t.detail.secondaryMenu&&(t.stopPropagation(),this.panel.classList.add("loading"),this.panel.addEventListener("transitionend",(()=>{this.panel.classList.remove("loading")}),{once:!0}),this.panel.style.minHeight=t.detail.secondaryMenu.scrollHeight+"px")}secondaryClose(t){t.detail.secondaryMenu&&(t.stopPropagation(),t.target.parentElement&&(this.panel.style.minHeight=t.target.parentElement.scrollHeight+"px"))}handlePanelSelect(t){this.closeOnSelect&&t.target.tagName.toLowerCase()===d("nano-menu")&&this.hide()}async show(){if(this.ignoreOpenWatcher=!0,this.open=!0,this.nanoShow.emit().defaultPrevented)return this.open=!1,void(this.ignoreOpenWatcher=!1);"function"==typeof this.positioner?.showPopover?(this.hoist=!0,this.popover.show(),this.positioner.showPopover()):this.popover.show(),this.ignoreOpenWatcher=!1,document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("keydown",this.handleDocumentKeyDown)}async hide(){if(this.ignoreOpenWatcher=!0,this.open=!1,this.nanoHide.emit().defaultPrevented)return this.open=!0,void(this.ignoreOpenWatcher=!1);this.popover&&this.popover.hide(),this.ignoreOpenWatcher=!1,document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("keydown",this.handleDocumentKeyDown)}afterHide(){"function"==typeof this.positioner?.hidePopover&&this.positioner.hidePopover(),this.panel.scrollTop=0,this.accessibleTrigger&&n(this.containingElement,this.trigger)&&this.accessibleTrigger.focus()}togglePanel=()=>{this.autoOpen&&(this.open?this.hide():this.show())};updateAccessibleTrigger(){if(!this.didLoad)return;let t;this.accessibleTrigger=null,t=this.tetherTo?r(this.tetherTo):Array.from(this.host.querySelectorAll('[slot="trigger"]')).map(r)[0],t&&!t.getAttribute("aria-haspopup")&&(t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded",this.open?"true":"false"),this.accessibleTrigger=t)}handleDocumentKeyDown(t){if("Escape"!==t.key)if("Tab"===t.key)setTimeout((()=>{n(this.containingElement,this.trigger,t)||this.hide()}));else{if(this.menu&&(this.placement.match(/bottom|top/)&&["ArrowDown","ArrowUp"].includes(t.key)||this.placement.match(/right|left/)&&["ArrowRight","ArrowLeft"].includes(t.key)))return!this.open||n(this.containingElement,this.trigger,t)?"NANO-DROPDOWN"===this.containingElement.tagName&&this.containingElement.placement.match(/right|left/)&&"NANO-DROPDOWN"===this.trigger.getRootNode()?.host?.tagName?void this.hide():void 0:(t.preventDefault(),this.menu.setFocus(),void(this.focusFirstEle=!0));const i=t.composedPath();if(this.menu&&i.length&&!i.find((t=>t!==this.menu)))return void this.menu.dispatchEvent(new KeyboardEvent(t.type,t))}else this.hide()}handleDocumentMouseDown(t){n(this.containingElement,this.trigger,t)||this.hide()}handleTriggerKeyDown=t=>{(this.placement.match(/bottom|top/)&&["ArrowDown","ArrowUp"," ","Enter"].includes(t.key)||this.placement.match(/right|left/)&&["ArrowRight","ArrowLeft"," ","Enter"].includes(t.key))&&(this.show(),t.preventDefault(),t.stopPropagation(),this.menu&&(this.menu.setFocus(),this.focusFirstEle=!0))};handleTriggerSlotChange=()=>{this.updateAccessibleTrigger()};createPopover(){(this.tetherTo||this.trigger)&&this.positioner&&(this.popover&&(this.open&&this.hide(),this.popover.destroy(),this.popover=null),this.popover=new a(this.tetherTo||this.trigger,this.positioner,{strategy:this.hoist?"fixed":"absolute",placement:this.placement,distance:this.distance,skidding:this.skidding,transitionElement:this.panel,onAfterHide:()=>{this.nanoAfterHide.emit()},onAfterShow:()=>{this.nanoAfterShow.emit()},onTransitionEnd:()=>{this.open?this.menu&&(this.menu.showActiveElement(),this.focusFirstEle&&(this.menu.setFocus(),this.focusFirstEle=!1)):this.afterHide()}}),this.open&&this.show())}isOverflowing(){return["auto","scroll"].includes(window.getComputedStyle(this.host).getPropertyValue("--overflow"))}connectedCallback(){this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this.host)}componentDidLoad(){this.didLoad=!0,this.createPopover(),setTimeout((()=>this.updateAccessibleTrigger()),100)}disconnectedCallback(){this.host.isConnected&&this.hide(),this.popover&&this.popover.destroy()}render(){return l(e,{key:"c0ed4b8b03d27f7437c148c8df305886c6cf29d9",class:"nano-dropdown"},l("div",{key:"27165586e2caa99ba746e7db3aa1574f0e9d1576",part:"base",id:this.dropdownId,class:{dropdown:!0,"dropdown--open":this.open}},l("span",{key:"b401a4d341e786ae4fe8c54adf06f8da1be4f531",part:"trigger",class:"dropdown__trigger",ref:t=>this.trigger=t,onKeyDown:this.handleTriggerKeyDown,onClick:this.togglePanel},l("slot",{key:"bd61e0f2d5e164b21d3ecba81c63ec72b0b7cc6f",name:"trigger",onSlotchange:this.handleTriggerSlotChange})),l("div",{key:"e0cb2a8823490b70f6aa01073d3873fa785fd763",ref:t=>this.positioner=t,class:"dropdown__positioner",popover:"manual",id:this.dropdownId+"-positioner"},l("div",{key:"3f1b7e3911cd7616ff85d042fc0d1e3e358f36c2",ref:t=>this.panel=t,part:"panel",class:`dropdown__panel ${this.placement.split("-").join(" ")}`,"aria-hidden":!this.open,role:"group"===this.host.getAttribute("role")?"group":"dialog","aria-modal":"group"===this.host.getAttribute("role")?void 0:"true","aria-labelledby":this.dialogTitle?this.labelId:void 0,tabIndex:this.isOverflowing()?0:void 0},this.dialogTitle&&l("span",{key:"19cc4dd331a4c2cbdc73a05687681cb2830fff0c",id:this.labelId,class:"dropdown__accessible-title","aria-live":"group"===this.host.getAttribute("role")?void 0:"polite"},this.dialogTitle),l("slot",{key:"5da1881086c31481463b3b7244552e17ee66d997"})))))}static get watchers(){return{open:["handleOpenChange"],tetherTo:["handleTetherToChange"],placement:["handlePopoverOptionsChange"],distance:["handlePopoverOptionsChange"],skidding:["handlePopoverOptionsChange"],hoist:["handlePopoverOptionsChange"]}}};u.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{--width:auto;--border:none;--border-radius:0px;--background:var(--nano-color-neutral-75);--padding:0 0;--overflow:auto;--dropdown-z-index:var(--nano-z-index-dropdown);--min-width:0;--max-height:none;--box-shadow:var(--nano-shadow-l2);--menu-height:calc(100vh - 200px);display:inline-block}.dropdown{position:relative}.dropdown__trigger{display:block}.dropdown__positioner{position:absolute;z-index:var(--dropdown-z-index);min-inline-size:var(--min-width);border:0;background:none;padding:0;overflow:visible;color:unset}.dropdown__positioner::backdrop{display:none}.dropdown__positioner[popover],.dropdown__positioner:popover-open{inset:unset}@media (width <= 35.9375em){.dropdown__positioner{z-index:100}}.dropdown__panel{padding:var(--padding);background:var(--background);min-inline-size:var(--min-width);inline-size:var(--width);border:var(--border);border-radius:var(--border-radius);color:currentcolor;box-shadow:var(--box-shadow);opacity:0;transition:var(--nano-transition-x-fast) ease opacity, var(--nano-transition-x-fast) ease transform, var(--nano-transition-fast) ease min-block-size;min-block-size:20px;overflow:var(--overflow);max-block-size:var(--max-height);box-sizing:content-box !important}.dropdown__panel.loading{overflow-y:hidden}.dropdown__panel.top{transform:translateY(-20px) translateZ(0)}.dropdown__panel.bottom{transform:translateY(20px) translateZ(0)}.dropdown__positioner.popover-visible .dropdown__panel{opacity:1;transform:translateY(0) translateZ(0)}.dropdown__panel ::slotted(.nano-menu){max-block-size:var(--menu-height)}.dropdown__accessible-title{clip-path:inset(50%);block-size:1px;overflow:hidden;position:absolute;white-space:nowrap;inline-size:1px}";const b=class{constructor(o){t(this,o),this.nanoFocus=i(this,"nanoFocus",7),this.nanoBlur=i(this,"nanoBlur",7),this.nanoSelect=i(this,"nanoSelect",7)}ignoreMouseEvents=!1;ignoreMouseTimeout;menu;typeToSelect="";typeToSelectTimeout;get el(){return o(this)}get hasFocus(){return this._hasFocus}_hasFocus=!1;type;_type;label;nanoFocus;nanoBlur;nanoSelect;async setFocus(){this.menu?.focus&&this.menu.focus({preventScroll:!0})}async removeFocus(){this.menu?.blur&&this.menu.blur()}async showActiveElement(){this.selectedItem&&this.selectedItem.scrollIntoView({block:"nearest"})}async resetActiveItem(){this.getItems.filter((t=>t.tagName.toLowerCase()===d("nano-option"))).map((t=>t.setAttribute("tabindex","-1")))}get getItems(){let t;if("listbox"===this._type)t=p(this.el,`${d("nano-nav-item")}, ${d("nano-option")}`,"slot");else{const i=this.el.querySelectorAll("[open]");t=h(i[i.length-1]||this.el)}return t.filter((t=>!t.disabled&&!t.hidden))}get activeItem(){const t=s();return this.getItems.find((i=>"0"===i.getAttribute("tabindex")||i===t||i===document.activeElement||i.classList.contains("has-focus")))}get selectedItem(){return this.getItems.find((t=>t.selected))}async setActiveFocusItem(t,i=!0){const o=this.getItems,e=t||o.find((t=>t.selected))||o[0];o.filter((t=>t.tagName.toLowerCase()===d("nano-option"))).map((t=>t.setAttribute("tabindex",t===e?"0":"-1"))),i&&(e?e.setFocus?e.setFocus():e.focus():this.hasFocus||this.menu.focus())}handleBlur(t){if(!this.hasFocus)return;let i;if(t.key){if("Tab"!==t.key)return;i=s()&&s().closest(this.el.tagName.toLowerCase())===this.el}else i=!!t.composedPath().find((t=>t===this.el));i||(this.resetActiveItem(),this._hasFocus=!1,this.nanoBlur.emit())}handleFocus=()=>{this._hasFocus=!0,this.setActiveFocusItem(this.selectedItem||this.getItems[0]),this.nanoFocus.emit()};handleClick=t=>{const i=t.target.closest(d("nano-nav-item"));i&&!i.disabled&&this.nanoSelect.emit(i)};handleKeyDown=t=>{switch(clearTimeout(this.ignoreMouseTimeout),this.ignoreMouseTimeout=setTimeout((()=>this.ignoreMouseEvents=!1),500),this.ignoreMouseEvents=!0,t.key){case" ":this.activeItem&&(t.stopPropagation(),"BUTTON"!==this.activeItem.nodeName&&this.activeItem.click());break;case"ArrowDown":case"ArrowUp":case"PageDown":case"PageUp":case"Home":case"End":{const i=this.getItems;let o=i.indexOf(this.activeItem);if(i.length)return t.preventDefault(),"ArrowDown"===t.key?o++:"ArrowUp"===t.key?o--:"Home"===t.key||"PageUp"===t.key?o=0:"End"!==t.key&&"PageDown"!==t.key||(o=i.length-1),o<0&&(o=i.length-1),o>i.length-1&&(o=0),this.setActiveFocusItem(i[o]),void(i[o]&&i[o].scrollIntoView({block:"nearest"}));break}}if(" "===t.key||/^[a-z0-9]+$/i.test(t.key)){clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=setTimeout((()=>this.typeToSelect=""),750),this.typeToSelect+=t.key;const i=this.getItems;for(const t of i)if(c(t).toLowerCase().trim().substring(0,this.typeToSelect.length)===this.typeToSelect){this.setActiveFocusItem(t);break}}};handleMouseOver=t=>{const i=t.target,o=i.closest(d("nano-nav-item"))||i.closest(d("nano-option"))||i.closest("a");o&&!this.ignoreMouseEvents&&this.setActiveFocusItem(o)};handleSlotContent=()=>{if(this._type=this.type||null,!this._type){let t,i=0;h(this.el).forEach((o=>{"A"===o.tagName||"link"===o.role?t++:i++})),this._type=t>i?"nav":"menu"}"nav"!==this._type&&(p(this.el,`*:not(${d("nano-nav-item")}, a, ${d("nano-option")}, ${d("nano-dropdown")})`,!0).forEach((t=>{this.getItems.indexOf(t)<0&&t.setAttribute("role","none")})),this.el.querySelectorAll(`a, ${d("nano-dropdown")}`).forEach((t=>{t.setAttribute("role","A"===t.tagName?"menuitem":"group")})))};componentWillLoad(){this.handleSlotContent()}render(){return l(e,{key:"584081bb33462feb595037c47abd68aa3db1105a",role:"listbox"===this._type?"group":this._type,class:"nano-menu"},l("div",{key:"3847f51ea7fb4b0a80fe527d98e2af79468ed4bb",onClick:this.handleClick,onKeyDown:this.handleKeyDown,onMouseOver:this.handleMouseOver,onFocus:this.handleFocus,"aria-label":this.label?this.label:void 0,ref:t=>this.menu=t,part:"base",class:{menu:!0,["menu--"+this._type]:!0,"menu--has-focus":this.hasFocus},tabIndex:-1,role:"group"},l("slot",{key:"213d89d4ce752d7fa07e0f145d939679d6cb82ab",onSlotchange:this.handleSlotContent})))}};b.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{--padding:var(--nano-spacing-sm) var(--nano-spacing-sm);--font-size:1rem;--background:var(--nano-color-neutral-75);--nav-item-padding:var(--padding);display:block;background:var(--background);color:var(--nano-color-neutral-1400);overflow-x:clip}.menu{font-size:var(--font-size);overscroll-behavior:none;min-inline-size:var(--width);position:relative}.menu:focus{outline:none}::slotted(*:not(.nano-nav-item,.nano-option,hr,slot)){padding:var(--padding);display:block}";export{u as nano_dropdown,b as nano_menu}
|
|
4
|
+
import{r as t,c as i,g as o,a as e}from"./index-BM3Om9WE.js";import{f as n,g as s}from"./active-element-CKJIkX0R.js";import{P as a}from"./popover-DNdFZ1hX.js";import{a as r,g as h}from"./tabbable-BgopY-vd.js";import{t as d,h as l}from"./renderer-DpNDfhNy.js";import{g as p}from"./dom-dlicJTEJ.js";import{g as c}from"./slot-Crs4khNK.js";let m=0;const u=class{constructor(o){t(this,o),this.nanoShow=i(this,"nanoShow",7),this.nanoAfterShow=i(this,"nanoAfterShow",7),this.nanoHide=i(this,"nanoHide",7),this.nanoAfterHide=i(this,"nanoAfterHide",7)}dropdownId="dropdown-"+m++;labelId=this.dropdownId+"-title";ignoreOpenWatcher=!1;panel;popover;trigger;positioner;accessibleTrigger;didLoad=!1;focusFirstEle=!0;get menu(){return this.host.querySelector(d("nano-menu"))}get host(){return o(this)}autoOpen=!0;open=!1;handleOpenChange(){this.ignoreOpenWatcher||(this.open?this.show():this.hide(),this.accessibleTrigger?this.accessibleTrigger.setAttribute("aria-expanded",this.open.toString()):this.updateAccessibleTrigger())}closeOnSelect=!0;containingElement;tetherTo=null;handleTetherToChange(){this.createPopover(),this.updateAccessibleTrigger()}placement="bottom-start";distance=5;skidding=0;hoist=!1;handlePopoverOptionsChange(){this.popover&&this.popover.setOptions({strategy:this.hoist?"fixed":"absolute",placement:this.placement,skidding:this.skidding,distance:this.distance})}dialogTitle;nanoShow;nanoAfterShow;nanoHide;nanoAfterHide;eventType;secondaryOpen(t){t.detail.secondaryMenu&&(t.stopPropagation(),this.panel.classList.add("loading"),this.panel.addEventListener("transitionend",(()=>{this.panel.classList.remove("loading")}),{once:!0}),this.panel.style.minHeight=t.detail.secondaryMenu.scrollHeight+"px")}secondaryClose(t){t.detail.secondaryMenu&&(t.stopPropagation(),t.target.parentElement&&(this.panel.style.minHeight=t.target.parentElement.scrollHeight+"px"))}handlePanelSelect(t){this.closeOnSelect&&t.target.tagName.toLowerCase()===d("nano-menu")&&this.hide()}async show(){if(this.ignoreOpenWatcher=!0,this.open=!0,this.nanoShow.emit().defaultPrevented)return this.open=!1,void(this.ignoreOpenWatcher=!1);"function"==typeof this.positioner?.showPopover?(this.hoist=!0,this.popover.show(),this.positioner.showPopover()):this.popover.show(),this.ignoreOpenWatcher=!1,document.addEventListener("mousedown",this.handleDocumentMouseDown),document.addEventListener("keydown",this.handleDocumentKeyDown)}async hide(){if(this.ignoreOpenWatcher=!0,this.open=!1,this.nanoHide.emit().defaultPrevented)return this.open=!0,void(this.ignoreOpenWatcher=!1);this.popover&&this.popover.hide(),this.ignoreOpenWatcher=!1,document.removeEventListener("mousedown",this.handleDocumentMouseDown),document.removeEventListener("keydown",this.handleDocumentKeyDown)}afterHide(){"function"==typeof this.positioner?.hidePopover&&this.positioner.hidePopover(),this.panel.scrollTop=0,this.accessibleTrigger&&n(this.containingElement,this.trigger)&&this.accessibleTrigger.focus()}togglePanel=()=>{this.autoOpen&&(this.open?this.hide():this.show())};updateAccessibleTrigger(){if(!this.didLoad)return;let t;this.accessibleTrigger=null,t=this.tetherTo?r(this.tetherTo):Array.from(this.host.querySelectorAll('[slot="trigger"]')).map(r)[0],t&&!t.getAttribute("aria-haspopup")&&(t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded",this.open?"true":"false"),this.accessibleTrigger=t)}handleDocumentKeyDown(t){if("Escape"!==t.key)if("Tab"===t.key)setTimeout((()=>{n(this.containingElement,this.trigger,t)||this.hide()}));else{if(this.menu&&(this.placement.match(/bottom|top/)&&["ArrowDown","ArrowUp"].includes(t.key)||this.placement.match(/right|left/)&&["ArrowRight","ArrowLeft"].includes(t.key)))return!this.open||n(this.containingElement,this.trigger,t)?"NANO-DROPDOWN"===this.containingElement.tagName&&this.containingElement.placement.match(/right|left/)&&"NANO-DROPDOWN"===this.trigger.getRootNode()?.host?.tagName?void this.hide():void 0:(t.preventDefault(),this.menu.setFocus(),void(this.focusFirstEle=!0));const i=t.composedPath();if(this.menu&&i.length&&!i.find((t=>t!==this.menu)))return void this.menu.dispatchEvent(new KeyboardEvent(t.type,t))}else this.hide()}handleDocumentMouseDown(t){n(this.containingElement,this.trigger,t)||this.hide()}handleTriggerKeyDown=t=>{(this.placement.match(/bottom|top/)&&["ArrowDown","ArrowUp"," ","Enter"].includes(t.key)||this.placement.match(/right|left/)&&["ArrowRight","ArrowLeft"," ","Enter"].includes(t.key))&&(this.show(),t.preventDefault(),t.stopPropagation(),this.menu&&(this.menu.setFocus(),this.focusFirstEle=!0))};handleTriggerSlotChange=()=>{this.updateAccessibleTrigger()};createPopover(){(this.tetherTo||this.trigger)&&this.positioner&&(this.popover&&(this.open&&this.hide(),this.popover.destroy(),this.popover=null),this.popover=new a(this.tetherTo||this.trigger,this.positioner,{strategy:this.hoist?"fixed":"absolute",placement:this.placement,distance:this.distance,skidding:this.skidding,transitionElement:this.panel,onAfterHide:()=>{this.nanoAfterHide.emit()},onAfterShow:()=>{this.nanoAfterShow.emit()},onTransitionEnd:()=>{this.open?this.menu&&(this.menu.showActiveElement(),this.focusFirstEle&&(this.menu.setFocus(),this.focusFirstEle=!1)):this.afterHide()}}),this.open&&this.show())}isOverflowing(){return["auto","scroll"].includes(window.getComputedStyle(this.host).getPropertyValue("--overflow"))}connectedCallback(){this.handleDocumentKeyDown=this.handleDocumentKeyDown.bind(this),this.handleDocumentMouseDown=this.handleDocumentMouseDown.bind(this),this.containingElement||(this.containingElement=this.host)}componentDidLoad(){this.didLoad=!0,this.createPopover(),setTimeout((()=>this.updateAccessibleTrigger()),100)}disconnectedCallback(){this.host.isConnected&&this.hide(),this.popover&&this.popover.destroy()}render(){return l(e,{key:"c0ed4b8b03d27f7437c148c8df305886c6cf29d9",class:"nano-dropdown"},l("div",{key:"27165586e2caa99ba746e7db3aa1574f0e9d1576",part:"base",id:this.dropdownId,class:{dropdown:!0,"dropdown--open":this.open}},l("span",{key:"b401a4d341e786ae4fe8c54adf06f8da1be4f531",part:"trigger",class:"dropdown__trigger",ref:t=>this.trigger=t,onKeyDown:this.handleTriggerKeyDown,onClick:this.togglePanel},l("slot",{key:"bd61e0f2d5e164b21d3ecba81c63ec72b0b7cc6f",name:"trigger",onSlotchange:this.handleTriggerSlotChange})),l("div",{key:"e0cb2a8823490b70f6aa01073d3873fa785fd763",ref:t=>this.positioner=t,class:"dropdown__positioner",popover:"manual",id:this.dropdownId+"-positioner"},l("div",{key:"3f1b7e3911cd7616ff85d042fc0d1e3e358f36c2",ref:t=>this.panel=t,part:"panel",class:`dropdown__panel ${this.placement.split("-").join(" ")}`,"aria-hidden":!this.open,role:"group"===this.host.getAttribute("role")?"group":"dialog","aria-modal":"group"===this.host.getAttribute("role")?void 0:"true","aria-labelledby":this.dialogTitle?this.labelId:void 0,tabIndex:this.isOverflowing()?0:void 0},this.dialogTitle&&l("span",{key:"19cc4dd331a4c2cbdc73a05687681cb2830fff0c",id:this.labelId,class:"dropdown__accessible-title","aria-live":"group"===this.host.getAttribute("role")?void 0:"polite"},this.dialogTitle),l("slot",{key:"5da1881086c31481463b3b7244552e17ee66d997"})))))}static get watchers(){return{open:["handleOpenChange"],tetherTo:["handleTetherToChange"],placement:["handlePopoverOptionsChange"],distance:["handlePopoverOptionsChange"],skidding:["handlePopoverOptionsChange"],hoist:["handlePopoverOptionsChange"]}}};u.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{--width:auto;--border:none;--border-radius:0px;--background:var(--nano-color-neutral-75);--padding:0 0;--overflow:auto;--dropdown-z-index:var(--nano-z-index-dropdown);--min-width:0;--max-height:none;--box-shadow:var(--nano-shadow-l2);--menu-height:calc(100vh - 200px);display:inline-block}.dropdown{position:relative}.dropdown__trigger{display:block}.dropdown__positioner{position:absolute;z-index:var(--dropdown-z-index);min-inline-size:var(--min-width);border:0;background:none;padding:0;overflow:visible;color:unset}.dropdown__positioner::backdrop{display:none}.dropdown__positioner[popover],.dropdown__positioner:popover-open{inset:unset}@media (width <= 35.9375em){.dropdown__positioner{z-index:100}}.dropdown__panel{padding:var(--padding);background:var(--background);min-inline-size:var(--min-width);inline-size:var(--width);border:var(--border);border-radius:var(--border-radius);color:currentcolor;box-shadow:var(--box-shadow);opacity:0;transition:var(--nano-transition-x-fast) ease opacity, var(--nano-transition-x-fast) ease transform, var(--nano-transition-fast) ease min-block-size;min-block-size:20px;overflow:var(--overflow);max-block-size:var(--max-height);box-sizing:content-box !important}.dropdown__panel.loading{overflow-y:hidden}.dropdown__panel.top{transform:translateY(-20px) translateZ(0)}.dropdown__panel.bottom{transform:translateY(20px) translateZ(0)}.dropdown__positioner.popover-visible .dropdown__panel{opacity:1;transform:translateY(0) translateZ(0)}.dropdown__panel ::slotted(.nano-menu){max-block-size:var(--menu-height)}.dropdown__accessible-title{clip-path:inset(50%);block-size:1px;overflow:hidden;position:absolute;white-space:nowrap;inline-size:1px}";const f=class{constructor(o){t(this,o),this.nanoFocus=i(this,"nanoFocus",7),this.nanoBlur=i(this,"nanoBlur",7),this.nanoSelect=i(this,"nanoSelect",7)}ignoreMouseEvents=!1;ignoreMouseTimeout;menu;typeToSelect="";typeToSelectTimeout;get el(){return o(this)}get hasFocus(){return this._hasFocus}_hasFocus=!1;type;_type;label;nanoFocus;nanoBlur;nanoSelect;async setFocus(){this.menu?.focus&&this.menu.focus({preventScroll:!0})}async removeFocus(){this.menu?.blur&&this.menu.blur()}async showActiveElement(){this.selectedItem&&this.selectedItem.scrollIntoView({block:"nearest"})}async resetActiveItem(){this.getItems.filter((t=>t.tagName.toLowerCase()===d("nano-option"))).map((t=>t.setAttribute("tabindex","-1")))}get getItems(){let t;if("listbox"===this._type)t=p(this.el,`${d("nano-nav-item")}, ${d("nano-option")}`,"slot");else{const i=this.el.querySelectorAll("[open]");t=h(i[i.length-1]||this.el)}return t.filter((t=>!t.disabled&&!t.hidden))}get activeItem(){const t=s();return this.getItems.find((i=>"0"===i.getAttribute("tabindex")||i===t||i===document.activeElement||i.classList.contains("has-focus")))}get selectedItem(){return this.getItems.find((t=>t.selected))}async setActiveFocusItem(t,i=!0,o=!1){const e=this.getItems,n=t||e.find((t=>t.selected))||e[0];e.filter((t=>t.tagName.toLowerCase()===d("nano-option"))).map((t=>t.setAttribute("tabindex",t===n?"0":"-1"))),i&&(n?o?n.focus({preventScroll:!0}):n.setFocus?n.setFocus():n.focus():this.hasFocus||this.menu.focus({preventScroll:o}))}handleBlur(t){if(!this.hasFocus)return;let i;if(t.key){if("Tab"!==t.key)return;i=s()&&s().closest(this.el.tagName.toLowerCase())===this.el}else i=!!t.composedPath().find((t=>t===this.el));i||(this.resetActiveItem(),this._hasFocus=!1,this.nanoBlur.emit())}handleFocus=()=>{this._hasFocus=!0,this.setActiveFocusItem(this.selectedItem||this.getItems[0]),this.nanoFocus.emit()};handleClick=t=>{const i=t.target.closest(d("nano-nav-item"));i&&!i.disabled&&this.nanoSelect.emit(i)};handleKeyDown=t=>{switch(clearTimeout(this.ignoreMouseTimeout),this.ignoreMouseTimeout=setTimeout((()=>this.ignoreMouseEvents=!1),500),this.ignoreMouseEvents=!0,t.key){case" ":this.activeItem&&(t.stopPropagation(),"BUTTON"!==this.activeItem.nodeName&&this.activeItem.click());break;case"ArrowDown":case"ArrowUp":case"PageDown":case"PageUp":case"Home":case"End":{const i=this.getItems;let o=i.indexOf(this.activeItem);if(i.length)return t.preventDefault(),"ArrowDown"===t.key?o++:"ArrowUp"===t.key?o--:"Home"===t.key||"PageUp"===t.key?o=0:"End"!==t.key&&"PageDown"!==t.key||(o=i.length-1),o<0&&(o=i.length-1),o>i.length-1&&(o=0),this.setActiveFocusItem(i[o]),void(i[o]&&i[o].scrollIntoView({block:"nearest"}));break}}if(" "===t.key||/^[a-z0-9]+$/i.test(t.key)){clearTimeout(this.typeToSelectTimeout),this.typeToSelectTimeout=setTimeout((()=>this.typeToSelect=""),750),this.typeToSelect+=t.key;const i=this.getItems;for(const t of i)if(c(t).toLowerCase().trim().substring(0,this.typeToSelect.length)===this.typeToSelect){this.setActiveFocusItem(t);break}}};handleMouseOver=t=>{const i=t.target,o=i.closest(d("nano-nav-item"))||i.closest(d("nano-option"))||i.closest("a");o&&!this.ignoreMouseEvents&&this.setActiveFocusItem(o,!0,!0)};handleSlotContent=()=>{if(this._type=this.type||null,!this._type){let t,i=0;h(this.el).forEach((o=>{"A"===o.tagName||"link"===o.role?t++:i++})),this._type=t>i?"nav":"menu"}"nav"!==this._type&&(p(this.el,`*:not(${d("nano-nav-item")}, a, ${d("nano-option")}, ${d("nano-dropdown")})`,!0).forEach((t=>{this.getItems.indexOf(t)<0&&t.setAttribute("role","none")})),this.el.querySelectorAll(`a, ${d("nano-dropdown")}`).forEach((t=>{t.setAttribute("role","A"===t.tagName?"menuitem":"group")})))};componentWillLoad(){this.handleSlotContent()}render(){return l(e,{key:"40403e7a4f942f8fa8594edc9ceb24f33aba6979",role:"listbox"===this._type?"group":this._type,class:"nano-menu"},l("div",{key:"561716ed34aa038cebacb31dc3b8562829f062e4",onClick:this.handleClick,onKeyDown:this.handleKeyDown,onMouseOver:this.handleMouseOver,onFocus:this.handleFocus,"aria-label":this.label?this.label:void 0,ref:t=>this.menu=t,part:"base",class:{menu:!0,["menu--"+this._type]:!0,"menu--has-focus":this.hasFocus},tabIndex:-1,role:"group"},l("slot",{key:"e36d4071433a6e7ddd700aee284868856cbd82ff",onSlotchange:this.handleSlotContent})))}};f.style=":host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host,*,*::before,*::after{box-sizing:border-box}[hidden]{display:none !important}@media (prefers-reduced-motion: reduce){:host,*,*::before,*::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}}:host{--padding:var(--nano-spacing-sm) var(--nano-spacing-sm);--font-size:1rem;--background:var(--nano-color-neutral-75);--nav-item-padding:var(--padding);display:block;background:var(--background);color:var(--nano-color-neutral-1400);overflow-x:clip}.menu{font-size:var(--font-size);overscroll-behavior:none;min-inline-size:var(--width);position:relative}.menu:focus{outline:none}::slotted(*:not(.nano-nav-item,.nano-option,hr,slot)){padding:var(--padding);display:block}";export{u as nano_dropdown,f as nano_menu}
|
package/docs-json.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2026-03-
|
|
2
|
+
"timestamp": "2026-03-04T16:37:46",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.36.1",
|
|
@@ -3369,7 +3369,7 @@
|
|
|
3369
3369
|
"references": {
|
|
3370
3370
|
"Breadcrumb": {
|
|
3371
3371
|
"location": "local",
|
|
3372
|
-
"path": "/builds/
|
|
3372
|
+
"path": "/builds/nxMX84kt/0/Digital/nano-components/packages/components/src/components/breadcrumb/breadcrumb.tsx",
|
|
3373
3373
|
"id": "src/components/breadcrumb/breadcrumb.tsx::Breadcrumb"
|
|
3374
3374
|
}
|
|
3375
3375
|
}
|
package/hydrate/index.js
CHANGED
|
@@ -19155,7 +19155,7 @@ class Menu {
|
|
|
19155
19155
|
get selectedItem() {
|
|
19156
19156
|
return this.getItems.find((i) => i.selected);
|
|
19157
19157
|
}
|
|
19158
|
-
async setActiveFocusItem(item, focus = true) {
|
|
19158
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
19159
19159
|
const items = this.getItems;
|
|
19160
19160
|
const activeItem = !item
|
|
19161
19161
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -19166,13 +19166,18 @@ class Menu {
|
|
|
19166
19166
|
if (!focus)
|
|
19167
19167
|
return;
|
|
19168
19168
|
if (activeItem) {
|
|
19169
|
-
if (
|
|
19169
|
+
if (preventScroll) {
|
|
19170
|
+
activeItem.focus({ preventScroll: true });
|
|
19171
|
+
}
|
|
19172
|
+
else if (activeItem.setFocus) {
|
|
19170
19173
|
activeItem.setFocus();
|
|
19171
|
-
|
|
19174
|
+
}
|
|
19175
|
+
else {
|
|
19172
19176
|
activeItem.focus();
|
|
19177
|
+
}
|
|
19173
19178
|
}
|
|
19174
19179
|
else if (!this.hasFocus) {
|
|
19175
|
-
this.menu.focus();
|
|
19180
|
+
this.menu.focus({ preventScroll });
|
|
19176
19181
|
}
|
|
19177
19182
|
}
|
|
19178
19183
|
// Event Handlers
|
|
@@ -19283,7 +19288,7 @@ class Menu {
|
|
|
19283
19288
|
target.closest(transformTag('nano-option')) ||
|
|
19284
19289
|
target.closest('a');
|
|
19285
19290
|
if (item && !this.ignoreMouseEvents) {
|
|
19286
|
-
this.setActiveFocusItem(item);
|
|
19291
|
+
this.setActiveFocusItem(item, true, true);
|
|
19287
19292
|
}
|
|
19288
19293
|
};
|
|
19289
19294
|
handleSlotContent = () => {
|
|
@@ -19327,11 +19332,11 @@ class Menu {
|
|
|
19327
19332
|
this.handleSlotContent();
|
|
19328
19333
|
}
|
|
19329
19334
|
render() {
|
|
19330
|
-
return (h(Host, { key: '
|
|
19335
|
+
return (h(Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
19331
19336
|
menu: true,
|
|
19332
19337
|
['menu--' + this._type]: true,
|
|
19333
19338
|
'menu--has-focus': this.hasFocus,
|
|
19334
|
-
}, tabIndex: -1, role: "group" }, h("slot", { key: '
|
|
19339
|
+
}, tabIndex: -1, role: "group" }, h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
19335
19340
|
}
|
|
19336
19341
|
static get style() { return menuCss; }
|
|
19337
19342
|
static get cmpMeta() { return {
|
package/hydrate/index.mjs
CHANGED
|
@@ -19153,7 +19153,7 @@ class Menu {
|
|
|
19153
19153
|
get selectedItem() {
|
|
19154
19154
|
return this.getItems.find((i) => i.selected);
|
|
19155
19155
|
}
|
|
19156
|
-
async setActiveFocusItem(item, focus = true) {
|
|
19156
|
+
async setActiveFocusItem(item, focus = true, preventScroll = false) {
|
|
19157
19157
|
const items = this.getItems;
|
|
19158
19158
|
const activeItem = !item
|
|
19159
19159
|
? items.find((i) => i.selected) || items[0]
|
|
@@ -19164,13 +19164,18 @@ class Menu {
|
|
|
19164
19164
|
if (!focus)
|
|
19165
19165
|
return;
|
|
19166
19166
|
if (activeItem) {
|
|
19167
|
-
if (
|
|
19167
|
+
if (preventScroll) {
|
|
19168
|
+
activeItem.focus({ preventScroll: true });
|
|
19169
|
+
}
|
|
19170
|
+
else if (activeItem.setFocus) {
|
|
19168
19171
|
activeItem.setFocus();
|
|
19169
|
-
|
|
19172
|
+
}
|
|
19173
|
+
else {
|
|
19170
19174
|
activeItem.focus();
|
|
19175
|
+
}
|
|
19171
19176
|
}
|
|
19172
19177
|
else if (!this.hasFocus) {
|
|
19173
|
-
this.menu.focus();
|
|
19178
|
+
this.menu.focus({ preventScroll });
|
|
19174
19179
|
}
|
|
19175
19180
|
}
|
|
19176
19181
|
// Event Handlers
|
|
@@ -19281,7 +19286,7 @@ class Menu {
|
|
|
19281
19286
|
target.closest(transformTag('nano-option')) ||
|
|
19282
19287
|
target.closest('a');
|
|
19283
19288
|
if (item && !this.ignoreMouseEvents) {
|
|
19284
|
-
this.setActiveFocusItem(item);
|
|
19289
|
+
this.setActiveFocusItem(item, true, true);
|
|
19285
19290
|
}
|
|
19286
19291
|
};
|
|
19287
19292
|
handleSlotContent = () => {
|
|
@@ -19325,11 +19330,11 @@ class Menu {
|
|
|
19325
19330
|
this.handleSlotContent();
|
|
19326
19331
|
}
|
|
19327
19332
|
render() {
|
|
19328
|
-
return (h(Host, { key: '
|
|
19333
|
+
return (h(Host, { key: '40403e7a4f942f8fa8594edc9ceb24f33aba6979', role: this._type === 'listbox' ? 'group' : this._type, class: "nano-menu" }, h("div", { key: '561716ed34aa038cebacb31dc3b8562829f062e4', onClick: this.handleClick, onKeyDown: this.handleKeyDown, onMouseOver: this.handleMouseOver, onFocus: this.handleFocus, "aria-label": this.label ? this.label : undefined, ref: (el) => (this.menu = el), part: "base", class: {
|
|
19329
19334
|
menu: true,
|
|
19330
19335
|
['menu--' + this._type]: true,
|
|
19331
19336
|
'menu--has-focus': this.hasFocus,
|
|
19332
|
-
}, tabIndex: -1, role: "group" }, h("slot", { key: '
|
|
19337
|
+
}, tabIndex: -1, role: "group" }, h("slot", { key: 'e36d4071433a6e7ddd700aee284868856cbd82ff', onSlotchange: this.handleSlotContent }))));
|
|
19333
19338
|
}
|
|
19334
19339
|
static get style() { return menuCss; }
|
|
19335
19340
|
static get cmpMeta() { return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanoporetech-digital/components",
|
|
3
|
-
"version": "8.23.
|
|
3
|
+
"version": "8.23.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "A collection of Oxford Nanopore corporate / digital webcomponents",
|
|
6
6
|
"type": "module",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"smart-array-filter": "^4.0.2",
|
|
57
57
|
"stencil-wormhole": "3.2.1",
|
|
58
58
|
"tyqs": "^0.1.3",
|
|
59
|
-
"@nanoporetech-digital/style": "8.23.
|
|
59
|
+
"@nanoporetech-digital/style": "8.23.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@algolia/client-search": "^4.22.1",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|