@ncino/web-components 13.12.1 → 13.12.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.
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import"../../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";import{html as
|
|
2
|
-
<div class="gator-dropdown-trigger"
|
|
1
|
+
import"../../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/reactive-element.js";import{html as p}from"../../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/lit-html.js";import"../../../../node_modules/.pnpm/lit-element@4.2.2/node_modules/lit-element/lit-element.js";import{customElement as c}from"../../../../utils/decorators/custom-element-decorator.js";import{autoUpdate as m,computePosition as f}from"../../../../node_modules/.pnpm/@floating-ui_dom@1.7.5/node_modules/@floating-ui/dom/dist/floating-ui.dom.js";import{ref as l}from"../../../../node_modules/.pnpm/lit-html@3.3.2/node_modules/lit-html/directives/ref.js";import{handleDataTestid as u}from"../../../../utils/datatestid-utils.js";import{NjcMenu as g}from"../menu.js";import w from"../../../../packages/styles/dist/tokens/primitive.tokens.css.js";import _ from"../../../../packages/styles/dist/tokens/semantic.tokens.css.js";import b from"../../../../packages/web-components/src/components/menu/base/gator/menu.gator.scss.js";import"../../menu-item/gator/menu-item.gator.js";import{unsafeCSS as d}from"../../../../node_modules/.pnpm/@lit_reactive-element@2.1.1/node_modules/@lit/reactive-element/css-tag.js";var v=Object.getOwnPropertyDescriptor,A=(t,e,n,i)=>{for(var o=i>1?void 0:i?v(e,n):e,s=t.length-1,r;s>=0;s--)(r=t[s])&&(o=r(o)||o);return o};let h=class extends g{constructor(){super(...arguments),this._dropdownRef=l(),this._wasOpenAtPointerDown=!1,this._handlePopoverToggle=t=>{const e=t.newState==="open";this.open=e,this._button?.setAttribute("aria-expanded",e?"true":"false"),e?this.assignPosition():(this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=void 0,this._dropdownRef.value?.removeAttribute("data-positioned"))}}render(){return p`
|
|
2
|
+
<div class="gator-dropdown-trigger">
|
|
3
3
|
<slot @slotchange="${this.handleTriggerSlotChange}" name="trigger"></slot>
|
|
4
|
-
<div
|
|
4
|
+
<div
|
|
5
|
+
class="gator-dropdown"
|
|
6
|
+
popover="auto"
|
|
7
|
+
${l(this._dropdownRef)}
|
|
8
|
+
@toggle=${this._handlePopoverToggle}
|
|
9
|
+
>
|
|
5
10
|
<ul class="gator_dropdown__list" role="menu" aria-label="${this.menuAriaLabel}" @keydown=${this.handleMenuKeydown}>
|
|
6
11
|
<slot @slotchange="${this.handleItemSlotChange}"></slot>
|
|
7
12
|
</ul>
|
|
8
13
|
</div>
|
|
9
14
|
</div>
|
|
10
|
-
`}updated(){const t=this.shadowRoot?.querySelector("[role=menu]");u(t,this.dataTestid,"dropdown")
|
|
15
|
+
`}updated(){const t=this.shadowRoot?.querySelector("[role=menu]");u(t,this.dataTestid,"dropdown");const e=this._dropdownRef.value;if(!e)return;const n=e.matches(":popover-open");this.open&&!n?e.showPopover():!this.open&&n&&e.hidePopover()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=void 0}_openPopover(){const t=this._dropdownRef.value;!t||t.matches(":popover-open")||(t.showPopover(),this.focusFirstMenuItem())}handleTriggerSlotChange(t){const n=t.target.assignedElements(),i='button, [role="button"]';n.forEach(o=>{const s=o.shadowRoot??o;this._button=s.querySelector(i),this._button||(o.matches(i)?this._button=o:(this._button=s.firstElementChild,this._button||(this._button=o),this._button.role="button")),this._button?.getAttribute("tabindex")||this._button?.setAttribute("tabindex","0"),this._button?.setAttribute("aria-haspopup","true"),this._button?.setAttribute("aria-expanded",this.open?"true":"false"),u(this._button,this.dataTestid,"button"),this._button?.addEventListener("pointerdown",()=>{this._wasOpenAtPointerDown=!!this._dropdownRef.value?.matches(":popover-open")}),this._button?.addEventListener("click",()=>{this._wasOpenAtPointerDown||this._openPopover()});const r=this._button.tagName.toLowerCase()==="button";this._button?.addEventListener("keydown",a=>{(a.key==="ArrowDown"||!r&&(a.key==="Enter"||a.key===" "))&&this._openPopover()})})}focusFirstMenuItem(){setTimeout(()=>{this.menuItems[0]?.focus()})}focusTriggerButton(){requestAnimationFrame(()=>{this._button?.focus()})}handleItemSlotChange(t){const n=t.target.assignedElements();for(let[i,o]of n.entries()){const s=o.tagName.toLowerCase();(s==="ngc-menu-item"||s==="ngc-submenu")&&(o.addEventListener("menuitemclick",()=>{this.handleClose()}),i===0?o.setAttribute("tabindex","0"):o.setAttribute("tabindex","-1"),u(o,this.dataTestid,`menu-item-${i}`))}}handleMenuKeydown(t){t.key==="ArrowDown"||t.key==="ArrowRight"?this.handleArrowDown(t):t.key==="ArrowUp"||t.key==="ArrowLeft"?this.handleArrowUp(t):t.key==="Tab"?this.handleClose():t.key==="Escape"&&(this.handleClose(),this._button?.focus())}handleArrowDown(t){t.preventDefault();const e=this.menuItems;let n=this.activeMenuItemIndex+1;n>e.length-1&&(n=0),e[n].focus()}handleArrowUp(t){t.preventDefault();const e=this.menuItems;let n=this.activeMenuItemIndex-1;n<0&&(n=e.length-1),e[n].focus()}get activeMenuItemIndex(){const t=this.querySelector(":focus-within");return Array.from(this.menuItems).indexOf(t)}get menuItems(){return this.querySelectorAll("ngc-menu-item")}handleClose(){this._dropdownRef.value?.matches(":popover-open")&&this._dropdownRef.value.hidePopover(),this.focusTriggerButton()}assignPosition(){const t=this._button,e=this._dropdownRef.value;!e||!t||(this._cleanupAutoUpdate?.(),this._cleanupAutoUpdate=m(t,e,async()=>{const{x:n,y:i,placement:o}=await f(t,e,{placement:this.placement,strategy:"fixed"}),s=4,r=o.startsWith("bottom")?s:o.startsWith("top")?-s:0;Object.assign(e.style,{left:`${n}px`,top:`${i+r}px`}),e.setAttribute("data-positioned","")}))}};h.styles=[d(b),d(w),d(_)];h=A([c("ngc-menu")],h);export{h as NgcMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const o=".gator-dropdown-trigger{position:relative;display:inline-block}.gator-dropdown{max-width:var(--ngc-menu-dropdown-max-width, 16rem);min-width:var(--ngc-menu-dropdown-min-width, 10rem);width:max-content;padding:var(--spacing-5) 0;border-radius:var(--border-radius-medium);box-shadow:var(--shadow-3-dropdown);
|
|
1
|
+
const o=".gator-dropdown-trigger{position:relative;display:inline-block}.gator-dropdown{max-width:var(--ngc-menu-dropdown-max-width, 16rem);min-width:var(--ngc-menu-dropdown-min-width, 10rem);width:max-content;height:max-content;padding:var(--spacing-5) 0;border:none;border-radius:var(--border-radius-medium);box-shadow:var(--shadow-3-dropdown);background-color:var(--ngc-menu-dropdown-background-color, var(--color-surface-primary));position:fixed;inset:0 auto auto 0;margin:0;opacity:0}.gator-dropdown[data-positioned]{opacity:1}ul{padding:0;margin:0;list-style-type:none}";export{o as default};
|
|
@@ -4,8 +4,13 @@ export declare class NgcMenu extends NjcMenu {
|
|
|
4
4
|
static styles: import('lit').CSSResult[];
|
|
5
5
|
private _button;
|
|
6
6
|
private _dropdownRef;
|
|
7
|
+
private _cleanupAutoUpdate;
|
|
7
8
|
render(): import('lit').TemplateResult<1>;
|
|
8
9
|
updated(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
private _wasOpenAtPointerDown;
|
|
12
|
+
private _handlePopoverToggle;
|
|
13
|
+
private _openPopover;
|
|
9
14
|
handleTriggerSlotChange(e: Event): void;
|
|
10
15
|
focusFirstMenuItem(): void;
|
|
11
16
|
focusTriggerButton(): void;
|
|
@@ -16,6 +21,5 @@ export declare class NgcMenu extends NjcMenu {
|
|
|
16
21
|
get activeMenuItemIndex(): number;
|
|
17
22
|
get menuItems(): NodeListOf<NgcMenuItem>;
|
|
18
23
|
handleClose(): void;
|
|
19
|
-
private _topLevelFocusOut;
|
|
20
24
|
assignPosition(): void;
|
|
21
25
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncino/web-components",
|
|
3
3
|
"author": "nCino",
|
|
4
|
-
"version": "13.12.
|
|
4
|
+
"version": "13.12.2",
|
|
5
5
|
"license": "(c) Copyright 2023 nCino, Inc., all rights reserved",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -100,10 +100,10 @@
|
|
|
100
100
|
"vite-plugin-static-copy": "^3.3.0",
|
|
101
101
|
"vitest": "^4.1.0",
|
|
102
102
|
"yaml-eslint-parser": "^2.0.0",
|
|
103
|
-
"@ncino/styles": "13.12.
|
|
103
|
+
"@ncino/styles": "13.12.2"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@ncino/styles": "13.12.
|
|
106
|
+
"@ncino/styles": "13.12.2"
|
|
107
107
|
},
|
|
108
108
|
"bugs": {
|
|
109
109
|
"url": "https://github.com/ncino/force-sdk-web-components/issues"
|
package/web-types.json
CHANGED