@taprootio/espalier 6.8.0 → 6.9.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/CHANGELOG.md +16 -0
- package/custom-elements.json +5276 -5031
- package/dist/button/esp-button.d.ts +6 -0
- package/dist/button/esp-button.js +11 -10
- package/dist/menu/esp-menu-group.d.ts +12 -1
- package/dist/menu/esp-menu-group.js +47 -34
- package/dist/menu/esp-menu-item.d.ts +10 -0
- package/dist/menu/esp-menu-item.js +8 -6
- package/dist/menu/esp-menu.js +19 -12
- package/dist/shared/new-tab-cue.js +1 -0
- package/espalier.css-data.json +1 -1
- package/espalier.token-manifest.json +2 -2
- package/package.json +1 -1
|
@@ -268,6 +268,12 @@ export declare class EspalierButton extends EspalierElementBase {
|
|
|
268
268
|
* @type {string}
|
|
269
269
|
*/
|
|
270
270
|
rel: string;
|
|
271
|
+
/**
|
|
272
|
+
* Hidden phrase appended to the accessible name of a `target="_blank"` link.
|
|
273
|
+
* Replace for non-English sites. Empty or whitespace text falls back to English.
|
|
274
|
+
* @default "opens in a new tab"
|
|
275
|
+
*/
|
|
276
|
+
newTabLabel: string;
|
|
271
277
|
/**
|
|
272
278
|
* When true and `button-type` is `"submit"`, the enclosing
|
|
273
279
|
* form is submitted without running constraint validation.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=function(h,t,s,i){var a=arguments.length,n=a<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,s):i,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(h,t,s,i);else for(var c=h.length-1;c>=0;c--)(d=h[c])&&(n=(a<3?d(n):a>3?d(t,s,n):d(t,s))||n);return a>3&&n&&Object.defineProperty(t,s,n),n};import{css as g,html as p,nothing as l}from"lit";import{customElement as f,eventOptions as m,property as r,state as v}from"lit/decorators.js";import{classMap as u}from"lit/directives/class-map.js";import{EspalierElementBase as b}from"../shared/esp-element-base.js";import{ESP_EVENTS as y}from"../shared/events.js";import{ref as w}from"lit/directives/ref.js";import{getIconHrefForHost as T}from"../shared/intent-values.js";import{SlottedIconController as k}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as x}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as S,newTabSuffix as $,renderNewTabCue as E}from"../shared/new-tab-cue.js";import{srOnly as C}from"../shared/style-fragments.js";import{BUTTON_INTERACTION_LIGHTNESS_FACTOR as N}from"./action-state-lightness.js";const z=p`<svg
|
|
2
2
|
xmlns="http://www.w3.org/2000/svg"
|
|
3
3
|
viewBox="0 0 24 24"
|
|
4
4
|
fill="none"
|
|
@@ -10,23 +10,24 @@ var n=function(h,t,s,i){var a=arguments.length,o=a<3?t:i===null?i=Object.getOwnP
|
|
|
10
10
|
>
|
|
11
11
|
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
|
12
12
|
<path d="M4.05 11a8 8 0 1 1 .5 4m-.5 5v-5h5" />
|
|
13
|
-
</svg>`;let e=class extends b{constructor(){super(...arguments),this.iconSlot=new
|
|
13
|
+
</svg>`;let e=class extends b{constructor(){super(...arguments),this.iconSlot=new k(this),this.innerTabindex=null,this.neutralizingTabindex=!1,this.buttonType="button",this.collapsed=!1,this.disabled=!1,this.href="",this.iconOnly=!1,this.incognito=!1,this.icon="",this.iconPosition="right",this.label="",this.loading=!1,this.target="",this.rel="",this.newTabLabel=S,this.formNoValidate=!1,this.buildIcon=t=>this.loading?p` <span>${z}</span> `:p`
|
|
14
14
|
<span>
|
|
15
15
|
<slot ${w(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot>
|
|
16
|
-
${!this.iconSlot.hasSlottedIcon(":scope > *")&&t?
|
|
16
|
+
${!this.iconSlot.hasSlottedIcon(":scope > *")&&t?x(t):l}
|
|
17
17
|
</span>
|
|
18
|
-
`}static get observedAttributes(){return[...super.observedAttributes,"tabindex","aria-pressed"]}attributeChangedCallback(t,s,i){if(super.attributeChangedCallback(t,s,i),t==="aria-pressed"){this.requestUpdate();return}if(t!=="tabindex"||this.neutralizingTabindex)return;const a=i===null?null:Number(i),
|
|
18
|
+
`}static get observedAttributes(){return[...super.observedAttributes,"tabindex","aria-pressed"]}attributeChangedCallback(t,s,i){if(super.attributeChangedCallback(t,s,i),t==="aria-pressed"){this.requestUpdate();return}if(t!=="tabindex"||this.neutralizingTabindex)return;const a=i===null?null:Number(i),n=a===null||Number.isNaN(a)?null:a;n!==null&&n>=0?(this.innerTabindex=n,this.writeHostTabindex(null)):n===null&&i!==null?(this.innerTabindex=null,this.writeHostTabindex(null)):this.innerTabindex=n}writeHostTabindex(t){this.getAttribute("tabindex")!==t&&(this.neutralizingTabindex=!0,t===null?this.removeAttribute("tabindex"):this.setAttribute("tabindex",t),this.neutralizingTabindex=!1)}removeAttribute(t){super.removeAttribute(t),t==="tabindex"&&!this.neutralizingTabindex&&(this.innerTabindex=null)}focus(t){this.focusShadowElementAfterUpdate("button, a",t)}handleClick(t){if(this.dispatchEvent(new CustomEvent(y.CLICKED,{detail:{},bubbles:!0,composed:!0})),this.buttonType==="submit"){const s=this.closest("form");if(s){const i=document.createElement("button");i.type="submit",i.hidden=!0,this.formNoValidate&&(i.formNoValidate=!0),s.appendChild(i),s.requestSubmit(i),i.remove()}}else this.buttonType==="reset"&&this.closest("form")?.reset()}render(){const t=T(this.icon,this),s=this.loading||this.iconSlot.hasSlottedIcon(":scope > *")||t.length>0,{collapsed:i,iconOnly:a}=this,n=a?this.getAttribute("aria-label")||this.label||l:l,d=this.getAttribute("aria-pressed")||l,c={"esp-field":!0,"icon-only":a,incognito:this.incognito,"is-collapsed":i,"has-icon":s,"icon-left":s&&!a&&this.iconPosition==="left"};return this.href.length?p`
|
|
19
19
|
<div part="wrapper" class=${u(c)}>
|
|
20
20
|
<a
|
|
21
21
|
?disabled=${this.disabled}
|
|
22
22
|
href=${this.href}
|
|
23
|
-
target=${this.target}
|
|
23
|
+
target=${this.target||l}
|
|
24
24
|
rel=${this.rel||l}
|
|
25
25
|
tabindex=${this.innerTabindex??l}
|
|
26
|
-
aria-label=${
|
|
26
|
+
aria-label=${n===l?l:`${n}${$(this.target,this.newTabLabel)}`}
|
|
27
27
|
>
|
|
28
28
|
<span>${this.label??""}</span>
|
|
29
29
|
${this.buildIcon(t)}
|
|
30
|
+
${a?l:E(this.target,this.newTabLabel)}
|
|
30
31
|
</a>
|
|
31
32
|
</div>
|
|
32
33
|
`:p`
|
|
@@ -36,14 +37,14 @@ var n=function(h,t,s,i){var a=arguments.length,o=a<3?t:i===null?i=Object.getOwnP
|
|
|
36
37
|
@click=${this.handleClick}
|
|
37
38
|
type=${this.buttonType}
|
|
38
39
|
tabindex=${this.innerTabindex??l}
|
|
39
|
-
aria-label=${
|
|
40
|
+
aria-label=${n}
|
|
40
41
|
aria-pressed=${d}
|
|
41
42
|
>
|
|
42
43
|
<span>${this.label??""}</span>
|
|
43
44
|
${this.buildIcon(t)}
|
|
44
45
|
</button>
|
|
45
46
|
</div>
|
|
46
|
-
`}};e.styles=[...b.styles,g`
|
|
47
|
+
`}};e.styles=[...b.styles,C,g`
|
|
47
48
|
:host {
|
|
48
49
|
--_esp-button-radius: var(--esp-size-border-radius);
|
|
49
50
|
}
|
|
@@ -158,7 +159,7 @@ var n=function(h,t,s,i){var a=arguments.length,o=a<3?t:i===null?i=Object.getOwnP
|
|
|
158
159
|
&:hover,
|
|
159
160
|
&:focus-within {
|
|
160
161
|
background-color: oklch(
|
|
161
|
-
from var(--esp-color-action-background) calc(l * ${
|
|
162
|
+
from var(--esp-color-action-background) calc(l * ${N})
|
|
162
163
|
c h
|
|
163
164
|
);
|
|
164
165
|
}
|
|
@@ -232,4 +233,4 @@ var n=function(h,t,s,i){var a=arguments.length,o=a<3?t:i===null?i=Object.getOwnP
|
|
|
232
233
|
transform: rotate(360deg);
|
|
233
234
|
}
|
|
234
235
|
}
|
|
235
|
-
`],
|
|
236
|
+
`],o([v()],e.prototype,"innerTabindex",void 0),o([r({attribute:"button-type",type:String})],e.prototype,"buttonType",void 0),o([r({type:Boolean})],e.prototype,"collapsed",void 0),o([r({type:Boolean,reflect:!0})],e.prototype,"disabled",void 0),o([r({type:String})],e.prototype,"href",void 0),o([r({attribute:"icon-only",type:Boolean})],e.prototype,"iconOnly",void 0),o([r({type:Boolean,reflect:!0})],e.prototype,"incognito",void 0),o([r({type:String})],e.prototype,"icon",void 0),o([r({attribute:"icon-position",type:String})],e.prototype,"iconPosition",void 0),o([r({type:String})],e.prototype,"label",void 0),o([r({type:Boolean,reflect:!0})],e.prototype,"loading",void 0),o([r({type:String})],e.prototype,"target",void 0),o([r({type:String})],e.prototype,"rel",void 0),o([r({type:String,attribute:"new-tab-label"})],e.prototype,"newTabLabel",void 0),o([r({attribute:"formnovalidate",type:Boolean})],e.prototype,"formNoValidate",void 0),o([m({capture:!1,passive:!0})],e.prototype,"handleClick",null),e=o([f("esp-button")],e);export{e as EspalierButton};
|
|
@@ -15,7 +15,7 @@ import type { EspalierMenuMode } from "./esp-menu.js";
|
|
|
15
15
|
*
|
|
16
16
|
* @event {CustomEvent<{ open: boolean }>} esp-menu-group-toggle - Fired when the group opens or closes.
|
|
17
17
|
*
|
|
18
|
-
* @cssprop --esp-menu-group-color - Text color of the group header.
|
|
18
|
+
* @cssprop --esp-menu-group-color - Text color of the group header. Defaults to `--esp-menu-item-color`, then `--esp-color-text`.
|
|
19
19
|
* @cssprop --esp-menu-group-background - Background color of the group header.
|
|
20
20
|
* @cssprop --esp-menu-group-hover-background - Hover background color of the group header.
|
|
21
21
|
* @cssprop --esp-menu-group-indicator-color - Color of the expand/collapse indicator.
|
|
@@ -27,6 +27,7 @@ import type { EspalierMenuMode } from "./esp-menu.js";
|
|
|
27
27
|
* @cssprop --esp-menu-group-icon-background - Background color of the icon rail.
|
|
28
28
|
* @cssprop --esp-menu-group-icon-size - Size of generated and slotted group icons.
|
|
29
29
|
* @cssprop --esp-menu-item-font-family - Font family of the group label, shared with menu items. Defaults to the theme's `--esp-font-menu`, then `--esp-font-body`.
|
|
30
|
+
* @cssprop --esp-menu-item-font-weight - Font weight of horizontal group labels, shared with menu items. Defaults to `--esp-font-weight-menu`, then `700`.
|
|
30
31
|
* @docPageTitle Menu Group
|
|
31
32
|
* @docUrl /components/menu/group
|
|
32
33
|
* @menuGroup Navigation
|
|
@@ -37,6 +38,16 @@ export declare class EspalierMenuGroup extends EspalierElementBase {
|
|
|
37
38
|
label: string;
|
|
38
39
|
/** Optional URL for the group label. */
|
|
39
40
|
url: string;
|
|
41
|
+
/** Target browsing context for the link. Empty omits the attribute. */
|
|
42
|
+
target: string;
|
|
43
|
+
/** Link relationship, passed through unchanged. Empty omits the attribute. */
|
|
44
|
+
rel: string;
|
|
45
|
+
/**
|
|
46
|
+
* Hidden phrase appended to the accessible name of a `target="_blank"` link.
|
|
47
|
+
* Replace for non-English sites. Empty or whitespace text falls back to English.
|
|
48
|
+
* @default "opens in a new tab"
|
|
49
|
+
*/
|
|
50
|
+
newTabLabel: string;
|
|
40
51
|
/** Optional icon name from the configured Espalier SVG sprite. */
|
|
41
52
|
icon: string;
|
|
42
53
|
/** Whether the group's children are visible. */
|
|
@@ -1,67 +1,63 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,i):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(l,e,i,a);else for(var c=l.length-1;c>=0;c--)(d=l[c])&&(s=(p<3?d(s):p>3?d(e,i,s):d(e,i))||s);return p>3&&s&&Object.defineProperty(e,i,s),s},u;import{css as b,html as n,nothing as h}from"lit";import{customElement as y,property as r,state as w}from"lit/decorators.js";import{classMap as k}from"lit/directives/class-map.js";import{createRef as m,ref as g}from"lit/directives/ref.js";import{EspalierElementBase as f}from"../shared/esp-element-base.js";import{ESP_EVENTS as x}from"../shared/events.js";import{getIconHrefForHost as z}from"../shared/intent-values.js";import{pathStartsWithSegment as v,pathsMatch as S}from"../shared/path-matching.js";import{SlottedIconController as L}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as $}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as E,renderNewTabCue as T}from"../shared/new-tab-cue.js";import{srOnly as C}from"../shared/style-fragments.js";import{EspalierMenuItem as D}from"./esp-menu-item.js";let t=u=class extends f{constructor(){super(...arguments),this.itemsSlot=m(),this.toggleButton=m(),this.iconSlot=new L(this),this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!1,this.label="",this.url="",this.target="",this.rel="",this.newTabLabel=E,this.icon="",this.open=!1,this.mode="vertical",this.depth=0,this.touchDevice=!1,this.fullScreenPresentation=!1,this.active=!1,this.urlPrefix="",this.globalListenersActive=!1,this.handleDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this.setOpen(!1))},this.handleDocumentKeydown=e=>{!this.open||e.key!=="Escape"||(e.preventDefault(),this.setOpen(!1),this.toggleButton.value?.focus())}}connectedCallback(){super.connectedCallback(),this.checkActive()}disconnectedCallback(){super.disconnectedCallback(),this.removeGlobalDismissListeners()}firstUpdated(e){super.firstUpdated(e),this.propagateToChildren()}updated(e){super.updated(e),(e.has("mode")||e.has("depth")||e.has("touchDevice"))&&this.propagateToChildren(),(e.has("mode")||e.has("depth")||e.has("urlPrefix"))&&this.syncUrlPrefixExpansion(),e.has("url")&&this.checkActive(),e.has("open")&&!this.open&&(this.openedByUrlPrefix=!1),(e.has("open")||e.has("mode"))&&(this.open&&this.isHorizontalTopLevel?this.addGlobalDismissListeners():this.removeGlobalDismissListeners())}checkActive(){if(!this.url){this.active=!1;return}this.active=S(this.url)}get isHorizontalTopLevel(){return this.mode==="horizontal"&&this.depth===0}get childMode(){return this.mode==="horizontal"?"vertical":this.mode}syncUrlPrefixExpansion(){const e=v(location.pathname,this.urlPrefix);if(e||(this.dismissedUrlPrefix=!1),e&&!this.dismissedUrlPrefix&&!this.isHorizontalTopLevel){this.open||(this.open=!0,this.openedByUrlPrefix=!0);return}this.openedByUrlPrefix&&(this.open=!1,this.openedByUrlPrefix=!1)}getChildren(){return this.itemsSlot.value?Array.from(this.itemsSlot.value.assignedElements()):[]}propagateToChildren(){for(const e of this.getChildren())e instanceof D?(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice):e instanceof u&&(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice)}handleSlotChange(){this.propagateToChildren()}setOpen(e){this.open!==e&&(this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!e&&v(location.pathname,this.urlPrefix),this.open=e,this.dispatchEvent(new CustomEvent(x.MENU_GROUP_TOGGLE,{detail:{open:this.open},bubbles:!0,composed:!0})))}handleHeaderClick(){this.toggleOpen()}handleLinkClick(e){e.stopPropagation()}handleToggleClick(e){e.stopPropagation(),this.toggleOpen()}toggleOpen(){this.setOpen(!this.open)}handleGroupKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),e.stopPropagation(),this.setOpen(!1),this.toggleButton.value?.focus())}addGlobalDismissListeners(){this.globalListenersActive||(document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!0)}removeGlobalDismissListeners(){this.globalListenersActive&&(document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!1)}renderIcon(){const e=z(this.icon,this),i=this.iconSlot.hasSlottedIcon();return n`
|
|
2
2
|
<slot
|
|
3
3
|
name="icon"
|
|
4
|
-
${
|
|
4
|
+
${g(this.iconSlot.slotRef)}
|
|
5
5
|
@slotchange=${this.iconSlot.handleSlotChange}
|
|
6
6
|
></slot>
|
|
7
|
-
${!
|
|
7
|
+
${!i&&e?$(e):h}
|
|
8
8
|
`}renderToggle(e){return n`<button
|
|
9
|
-
${
|
|
9
|
+
${g(this.toggleButton)}
|
|
10
10
|
class="group-toggle"
|
|
11
11
|
type="button"
|
|
12
12
|
aria-expanded=${this.open?"true":"false"}
|
|
13
|
+
aria-controls="group-items"
|
|
13
14
|
@click=${this.handleToggleClick}
|
|
14
|
-
@keydown=${this.handleToggleKeydown}
|
|
15
15
|
>
|
|
16
16
|
${e}<span class="indicator" aria-hidden="true"></span>
|
|
17
|
-
</button>`}render(){const e={group:!0,"is-horizontal":this.isHorizontalTopLevel,"is-vertical":!this.isHorizontalTopLevel,"is-nested":this.depth>0,"is-drawer":this.mode==="drawer","is-open":this.open,"is-active":this.active,"has-icon":this.icon.length>0||this.iconSlot.hasSlottedIcon()},
|
|
18
|
-
<span class="current-page" aria-current="page">${
|
|
17
|
+
</button>`}render(){const e={group:!0,"is-horizontal":this.isHorizontalTopLevel,"is-vertical":!this.isHorizontalTopLevel,"is-nested":this.depth>0,"is-drawer":this.mode==="drawer","is-open":this.open,"is-active":this.active,"has-icon":this.icon.length>0||this.iconSlot.hasSlottedIcon()},i=n`<span class="group-label-text" part="menu-text">${this.label}</span>`,a=this.url?this.active?n`
|
|
18
|
+
<span class="current-page" aria-current="page">${i}</span>
|
|
19
19
|
${this.renderToggle(n`<span class="sr-only">Toggle ${this.label}</span>`)}
|
|
20
20
|
`:n`
|
|
21
|
-
<a
|
|
21
|
+
<a
|
|
22
|
+
class="group-link"
|
|
23
|
+
href=${this.url}
|
|
24
|
+
target=${this.target||h}
|
|
25
|
+
rel=${this.rel||h}
|
|
26
|
+
@click=${this.handleLinkClick}
|
|
27
|
+
>${i}${T(this.target,this.newTabLabel)}</a
|
|
28
|
+
>
|
|
22
29
|
${this.renderToggle(n`<span class="sr-only">Toggle ${this.label}</span>`)}
|
|
23
|
-
`:this.renderToggle(
|
|
24
|
-
<div class=${k(e)}>
|
|
30
|
+
`:this.renderToggle(i);return n`
|
|
31
|
+
<div class=${k(e)} @keydown=${this.handleGroupKeydown}>
|
|
25
32
|
<div class="group-header" @click=${this.handleHeaderClick}>
|
|
26
33
|
<span class="group-label">${a}</span>
|
|
27
34
|
<span class="group-icon" aria-hidden="true">${this.renderIcon()}</span>
|
|
28
35
|
</div>
|
|
29
36
|
<div
|
|
37
|
+
id="group-items"
|
|
30
38
|
class="group-items"
|
|
31
39
|
?hidden=${this.isHorizontalTopLevel&&!this.open}
|
|
32
40
|
?inert=${!this.open}
|
|
33
|
-
aria-hidden=${this.open?
|
|
41
|
+
aria-hidden=${this.open?h:"true"}
|
|
34
42
|
>
|
|
35
43
|
<div class="group-items-inner">
|
|
36
|
-
<slot ${
|
|
44
|
+
<slot ${g(this.itemsSlot)} @slotchange=${this.handleSlotChange}></slot>
|
|
37
45
|
</div>
|
|
38
46
|
</div>
|
|
39
47
|
</div>
|
|
40
|
-
`}};t.styles=[...
|
|
48
|
+
`}};t.styles=[...f.styles,C,b`
|
|
41
49
|
:host {
|
|
42
50
|
display: block;
|
|
43
51
|
position: relative;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
.sr-only {
|
|
47
|
-
position: absolute;
|
|
48
|
-
width: 1px;
|
|
49
|
-
height: 1px;
|
|
50
|
-
padding: 0;
|
|
51
|
-
margin: -1px;
|
|
52
|
-
overflow: hidden;
|
|
53
|
-
clip: rect(0, 0, 0, 0);
|
|
54
|
-
white-space: nowrap;
|
|
55
|
-
border: 0;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
54
|
.group-header {
|
|
59
55
|
--_esp-surface-layer: 1;
|
|
60
56
|
position: relative;
|
|
61
57
|
display: grid;
|
|
62
58
|
grid-template-columns: minmax(0, 1fr) min-content;
|
|
63
59
|
align-items: stretch;
|
|
64
|
-
color: var(--esp-menu-group-color, var(--esp-color-
|
|
60
|
+
color: var(--esp-menu-group-color, var(--esp-menu-item-color, var(--esp-color-text)));
|
|
65
61
|
background-color: var(--esp-menu-group-background, var(--esp-color-layer-1));
|
|
66
62
|
border-right: 1px solid var(--esp-menu-group-border-color, var(--esp-color-border));
|
|
67
63
|
border-bottom: 1px solid var(--esp-menu-group-border-color, var(--esp-color-border));
|
|
@@ -87,6 +83,8 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
87
83
|
display: flex;
|
|
88
84
|
width: 100%;
|
|
89
85
|
min-width: 0;
|
|
86
|
+
|
|
87
|
+
min-height: 0;
|
|
90
88
|
}
|
|
91
89
|
|
|
92
90
|
.group-link,
|
|
@@ -113,12 +111,17 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
113
111
|
)
|
|
114
112
|
)
|
|
115
113
|
);
|
|
116
|
-
font-weight: 600;
|
|
117
114
|
text-align: left;
|
|
118
115
|
text-decoration: none;
|
|
119
116
|
cursor: pointer;
|
|
120
117
|
}
|
|
121
118
|
|
|
119
|
+
.is-horizontal .group-link,
|
|
120
|
+
.is-horizontal .current-page,
|
|
121
|
+
.is-horizontal .group-toggle {
|
|
122
|
+
font-weight: var(--esp-menu-item-font-weight, var(--esp-font-weight-menu, 700));
|
|
123
|
+
}
|
|
124
|
+
|
|
122
125
|
.group-link,
|
|
123
126
|
.current-page {
|
|
124
127
|
flex: 0 1 auto;
|
|
@@ -127,7 +130,7 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
127
130
|
background: none;
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
.current-page {
|
|
133
|
+
.is-active .current-page {
|
|
131
134
|
color: var(--esp-menu-item-active-color, var(--esp-color-link));
|
|
132
135
|
font-weight: var(--esp-menu-item-active-font-weight, var(--esp-font-weight-headings));
|
|
133
136
|
}
|
|
@@ -155,6 +158,11 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
155
158
|
position: relative;
|
|
156
159
|
}
|
|
157
160
|
|
|
161
|
+
:host([full-screen-presentation]) .group-toggle:only-child .indicator {
|
|
162
|
+
position: absolute;
|
|
163
|
+
inset-inline-end: var(--esp-size-small);
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
:host([full-screen-presentation]) .group-link,
|
|
159
167
|
:host([full-screen-presentation]) .current-page {
|
|
160
168
|
flex: 1 1 auto;
|
|
@@ -215,14 +223,19 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
215
223
|
.indicator {
|
|
216
224
|
display: inline-block;
|
|
217
225
|
flex: 0 0 auto;
|
|
218
|
-
width: 0;
|
|
219
|
-
height: 0;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
border-left: 4.5px solid var(--esp-menu-group-indicator-color, var(--esp-color-headings));
|
|
226
|
+
width: 0.3em;
|
|
227
|
+
height: 0.45em;
|
|
228
|
+
background: var(--esp-menu-group-indicator-color, currentColor);
|
|
229
|
+
clip-path: polygon(0 0, 100% 50%, 0 100%);
|
|
223
230
|
transition: transform 0.2s ease;
|
|
224
231
|
}
|
|
225
232
|
|
|
233
|
+
@media (forced-colors: active) {
|
|
234
|
+
.indicator {
|
|
235
|
+
background: ButtonText;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
226
239
|
.is-open .indicator {
|
|
227
240
|
transform: rotate(90deg);
|
|
228
241
|
}
|
|
@@ -279,4 +292,4 @@ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
279
292
|
transition: none;
|
|
280
293
|
}
|
|
281
294
|
}
|
|
282
|
-
`],
|
|
295
|
+
`],o([r({type:String})],t.prototype,"label",void 0),o([r({type:String})],t.prototype,"url",void 0),o([r({type:String})],t.prototype,"target",void 0),o([r({type:String})],t.prototype,"rel",void 0),o([r({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),o([r({type:String})],t.prototype,"icon",void 0),o([r({type:Boolean,reflect:!0})],t.prototype,"open",void 0),o([r({attribute:!1,type:String})],t.prototype,"mode",void 0),o([r({attribute:!1,type:Number})],t.prototype,"depth",void 0),o([r({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),o([r({attribute:"full-screen-presentation",type:Boolean,reflect:!0})],t.prototype,"fullScreenPresentation",void 0),o([w()],t.prototype,"active",void 0),o([r({type:String,attribute:"url-prefix"})],t.prototype,"urlPrefix",void 0),t=u=o([y("esp-menu-group")],t);export{t as EspalierMenuGroup};
|
|
@@ -43,6 +43,16 @@ export declare class EspalierMenuItem extends EspalierElementBase {
|
|
|
43
43
|
label: string;
|
|
44
44
|
/** Resource to link to. When empty, the item renders as a button. */
|
|
45
45
|
url: string;
|
|
46
|
+
/** Target browsing context for the link. Empty omits the attribute. */
|
|
47
|
+
target: string;
|
|
48
|
+
/** Link relationship, passed through unchanged. Empty omits the attribute. */
|
|
49
|
+
rel: string;
|
|
50
|
+
/**
|
|
51
|
+
* Hidden phrase appended to the accessible name of a `target="_blank"` link.
|
|
52
|
+
* Replace for non-English sites. Empty or whitespace text falls back to English.
|
|
53
|
+
* @default "opens in a new tab"
|
|
54
|
+
*/
|
|
55
|
+
newTabLabel: string;
|
|
46
56
|
/** Optional icon name from the configured Espalier SVG sprite. */
|
|
47
57
|
icon: string;
|
|
48
58
|
/** Render mode supplied by the parent `esp-menu` or `esp-menu-group`. */
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var r=function(p,t,a,s){var c=arguments.length,o=c<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,a):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(p,t,a,s);else for(var h=p.length-1;h>=0;h--)(n=p[h])&&(o=(c<3?n(o):c>3?n(t,a,o):n(t,a))||o);return c>3&&o&&Object.defineProperty(t,a,o),o};import{css as m,html as l,nothing as d}from"lit";import{customElement as v,property as i,state as f}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{ref as g}from"lit/directives/ref.js";import{getIconHrefForHost as y}from"../shared/intent-values.js";import{EspalierElementBase as u}from"../shared/esp-element-base.js";import{ESP_EVENTS as k}from"../shared/events.js";import{pathsMatch as w}from"../shared/path-matching.js";import{SlottedIconController as z}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as x}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as S,renderNewTabCue as $}from"../shared/new-tab-cue.js";import{srOnly as _}from"../shared/style-fragments.js";let e=class extends u{constructor(){super(...arguments),this.iconSlot=new z(this),this.label="",this.url="",this.target="",this.rel="",this.newTabLabel=S,this.icon="",this.mode="vertical",this.depth=0,this.touchDevice=!1,this.active=!1}connectedCallback(){super.connectedCallback(),this.checkActive()}updated(t){super.updated(t),t.has("url")&&this.checkActive()}checkActive(){if(!this.url){this.active=!1;return}this.active=w(this.url)}handleButtonClick(){this.dispatchEvent(new CustomEvent(k.CLICKED,{detail:{},bubbles:!0,composed:!0}))}render(){const t=y(this.icon,this),a=this.iconSlot.hasSlottedIcon(":scope > *"),s=a||t.length>0,c={item:!0,"is-horizontal":this.mode==="horizontal"&&this.depth===0,"is-vertical":this.mode!=="horizontal"||this.depth>0,"is-drawer":this.mode==="drawer","is-nested":this.depth>0,"has-icon":s,"is-active":this.active},o=l`<span part="menu-text">${this.label}</span>`,n=l`<span class="icon-area" aria-hidden=${s?"true":d}>
|
|
2
2
|
<slot ${g(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot>
|
|
3
|
-
${!
|
|
4
|
-
</span>`;return
|
|
5
|
-
${this.active?
|
|
6
|
-
|
|
3
|
+
${!a&&t?x(t):d}
|
|
4
|
+
</span>`;return l`<div class=${b(c)}>
|
|
5
|
+
${this.active?l`<span class="current-page" aria-current="page">${o}${n}</span>`:this.url?l`<a href=${this.url} target=${this.target||d} rel=${this.rel||d}
|
|
6
|
+
>${o}${n}${$(this.target,this.newTabLabel)}</a
|
|
7
|
+
>`:l`<button type="button" @click=${this.handleButtonClick}>${o}${n}</button>`}
|
|
8
|
+
</div>`}};e.styles=[...u.styles,_,m`
|
|
7
9
|
:host {
|
|
8
10
|
display: block;
|
|
9
11
|
}
|
|
@@ -190,4 +192,4 @@ var a=function(p,e,r,n){var s=arguments.length,t=s<3?e:n===null?n=Object.getOwnP
|
|
|
190
192
|
width: var(--esp-menu-item-icon-size, calc(1 * var(--esp-size-font)));
|
|
191
193
|
object-fit: contain;
|
|
192
194
|
}
|
|
193
|
-
`],
|
|
195
|
+
`],r([i({type:String})],e.prototype,"label",void 0),r([i({type:String})],e.prototype,"url",void 0),r([i({type:String})],e.prototype,"target",void 0),r([i({type:String})],e.prototype,"rel",void 0),r([i({type:String,attribute:"new-tab-label"})],e.prototype,"newTabLabel",void 0),r([i({type:String})],e.prototype,"icon",void 0),r([i({attribute:!1,type:String})],e.prototype,"mode",void 0),r([i({attribute:!1,type:Number})],e.prototype,"depth",void 0),r([i({attribute:!1,type:Boolean})],e.prototype,"touchDevice",void 0),r([f()],e.prototype,"active",void 0),e=r([v("esp-menu-item")],e);export{e as EspalierMenuItem};
|
package/dist/menu/esp-menu.js
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
var l=function(g,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(g,e,t,i);else for(var o=g.length-1;o>=0;o--)(n=g[o])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},y;import{css as N,html as f,nothing as w}from"lit";import{customElement as M,property as c,state as F}from"lit/decorators.js";import{classMap as x}from"lit/directives/class-map.js";import{unsafeHTML as z}from"lit/directives/unsafe-html.js";import{createRef as p,ref as u}from"lit/directives/ref.js";import{styleMap as k}from"lit/directives/style-map.js";import{EspalierElementBase as P}from"../shared/esp-element-base.js";import{ESP_EVENTS as S}from"../shared/events.js";import{getEspBus as I}from"../shared/bus-events.js";import{normalizePath as $,pathStartsWithSegment as R,pathsMatch as O}from"../shared/path-matching.js";import{renderConfiguredBrand as _}from"../shared/configured-brand.js";import{FOCUSABLE_SELECTOR as A,OverlayController as T}from"../shared/overlay-controller.js";import{SwipeRevealController as L}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import"../burger/esp-burger.js";import{EspalierMenuItem as E}from"./esp-menu-item.js";import{EspalierMenuGroup as v}from"./esp-menu-group.js";import{COMPACT_VIEWPORT_MEDIA_QUERY as G}from"../shared/responsive.js";import{RafThrottle as H}from"../shared/raf-throttle.js";import{viewportSize as q}from"../shared/viewport.js";import{solveDrawerNestedFit as B}from"./drawer-nested-fit.js";const K=new Set(["panel","full-screen"]),U=new Set(["fade","slide-down","slide-up","slide-left","slide-right"]);let a=y=class extends P{ownsDrawerLock(){return this.isFullScreenDrawer}fullScreenInertAnchor(){return y.inertAnchorFor(this)}static inertAnchorFor(e){let t=e,i=e;for(;;){const r=i.parentElement;if(r){if(r.localName==="esp-page"||r.localName==="esp-root")return i;r===document.body&&(t=i),i=r;continue}const s=i.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement){i=s.host;continue}return t}}constructor(){super(),this.itemsSlot=p(),this.railRef=p(),this.scrimRef=p(),this.drawerRef=p(),this.bus=I(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this.overlay=new T({host:this,getFocusTrapContainer:()=>this.drawerRef.value??null,getFocusScope:()=>this.fullScreenFocusScope(),getInertAnchor:()=>this.fullScreenInertAnchor(),promote:!1,scrollLock:{preserveScrollPosition:!0}}),this.fullScreenSession=!1,this.openedFullScreen=!1,this.drawerKeydownAttached=!1,this.nestedFitProbe=p(),this.nestedFitCapProbe=p(),this.nestedFitFloorProbe=p(),this.nestedFitPadProbe=p(),this.nestedFitTextProbe=p(),this.nestedFit=null,this.nestedFitMeasured=!1,this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.nestedFitResize=new H(()=>this.measureNestedFit()),this.nestedFitObserver=null,this.onNestedFitResize=()=>{this.drawerPresentation==="full-screen"&&this.nestedFitResize.schedule()},this.onNestedFitFontsLoaded=()=>this.scheduleNestedFit(!0),this.onOverlayOpened=e=>{if(e===this.overlay||!this.drawerOpen)return;const t=this.drawerTrigger;this.drawerTrigger=null,t&&e.redirectFocusRestore(t),this.swipeController.closeForHandoff(),this.onDrawerTransitionEnd()},this._sliding=!1,this._mobileCollapsed=!1,this.verticalDrawerQuery=null,this.onVerticalDrawerChange=e=>this.setMobileCollapsed(e.matches),this.mode="horizontal",this.overflow="auto",this.side="left",this.drawerPresentation="panel",this.fullScreenTransition="fade",this.drawerBrand=null,this.liftedCloseControl=null,this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerShown=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.hasExternalDrawerControl=!1,this.previewCollapseRequested=!1,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerKeydown=e=>{!this.drawerOpen||!this.openedFullScreen||e.key==="Tab"&&this.overlay.trapFocus(e)},this.onDrawerTransitionEnd=e=>{e&&e.target!==this.drawerRef.value||(this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear()))},this.handleDrawerCloseClick=()=>{this.closeDrawer()},this.swipeController=new L(this,this.side),this.swipeController.enabled=!1}get isFullScreenDrawer(){return K.has(this.drawerPresentation)?this.drawerPresentation==="full-screen":!1}get resolvedFullScreenTransition(){return U.has(this.fullScreenTransition)?this.fullScreenTransition:"fade"}get sliding(){return this._sliding}set sliding(e){const t=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",t)}get drawerSide(){return this.overflow==="right-drawer"?"right":this.overflow==="left-drawer"?"left":this.side}get drawerActive(){return this.mode==="drawer"||this._sliding||this.overflow==="left-drawer"||this.overflow==="right-drawer"||this.mode==="vertical"&&(this._mobileCollapsed||this.previewCollapseRequested)&&this.hasExternalDrawerControl}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.getAttribute("slot")==="right"&&(this.side="right"),!this.verticalDrawerQuery&&typeof window<"u"&&"matchMedia"in window&&(this.verticalDrawerQuery=window.matchMedia(G),this._mobileCollapsed=this.verticalDrawerQuery.matches,this.verticalDrawerQuery.addEventListener("change",this.onVerticalDrawerChange)),this.syncSwipeEnabled(),T.addOpenListener(this.onOverlayOpened),window.addEventListener("resize",this.onNestedFitResize),typeof document<"u"&&document.fonts&&(document.fonts.addEventListener("loadingdone",this.onNestedFitFontsLoaded),document.fonts.ready.then(()=>{this.isConnected&&this.scheduleNestedFit(!0)})),!this.nestedFitObserver&&typeof MutationObserver<"u"&&(this.nestedFitObserver=new MutationObserver(()=>this.scheduleNestedFit(!0)),this.nestedFitObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label"]}))}disconnectedCallback(){T.removeOpenListener(this.onOverlayOpened),window.removeEventListener("resize",this.onNestedFitResize),document.fonts?.removeEventListener("loadingdone",this.onNestedFitFontsLoaded),this.nestedFitObserver?.disconnect(),this.nestedFitObserver=null,this.nestedFitResize.cancel(),this.cancelNestedFitIdle(),this.nestedFitMeasured=!1,this.verticalDrawerQuery?.removeEventListener("change",this.onVerticalDrawerChange),this.verticalDrawerQuery=null,this.detachDrawerKeydown(),this.fullScreenSession=!1,super.disconnectedCallback()}setMobileCollapsed(e){e!==this._mobileCollapsed&&(this._mobileCollapsed=e,this.mode==="vertical"&&this.applyMobileCollapse())}applyMobileCollapse(){this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)}firstUpdated(e){super.firstUpdated(e),this.propagateToItems(),this.scheduleNestedFit()}updated(e){super.updated(e),(e.has("mode")||e.has("overflow")||e.has("side")||e.has("hasExternalDrawerControl")||e.has("previewCollapseRequested"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),e.has("drawerPresentation")&&(this.nestedFitMeasured=!1,this.scheduleNestedFit()),this.drawerOpen&&this.openedFullScreen!==this.isFullScreenDrawer&&this.swipeController.close(!0),this.autoExpand&&(e.has("autoExpand")||e.has("mode")&&this.mode!=="horizontal")?this.expandToCurrentPage():this.mode==="horizontal"&&e.has("mode")&&this.closeHorizontalTopLevelGroups()}openDrawer(e){this.drawerActive&&(e?this.drawerTrigger=e:this.drawerOpen||(this.drawerTrigger=null),this.swipeController.open())}closeDrawer(){this.swipeController.close(!0)}toggleDrawer(e){this.drawerOpen?this.closeDrawer():this.openDrawer(e)}get isDrawerOpen(){return this.drawerOpen}syncSwipeEnabled(){this.swipeController.direction=this.drawerSide,this.swipeController.enabled=this.drawerActive}getAssignedChildren(){return this.itemsSlot.value?.assignedElements()??[]}propagateToItems(){const e=this.railMode;for(const t of this.getAssignedChildren())t instanceof E?(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch):t instanceof v&&(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch)}handleSlotChange(){this.propagateToItems(),this.scheduleNestedFit(!0)}scheduleNestedFit(e=!1){if(this.drawerPresentation!=="full-screen"){this.cancelNestedFitIdle(),this.nestedFit!==null&&(this.nestedFit=null);return}if(e&&(this.nestedFitMeasured=!1),e&&this.drawerShown){this.cancelNestedFitIdle(),this.nestedFitResize.schedule();return}if(this.nestedFitIdleHandle!==null||this.nestedFitFallback!==null)return;const t=()=>{this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.isConnected&&this.measureNestedFit()};typeof requestIdleCallback=="function"?this.nestedFitIdleHandle=requestIdleCallback(t,{timeout:2e3}):this.nestedFitFallback={stage:"frame",handle:requestAnimationFrame(()=>{this.nestedFitFallback={stage:"timeout",handle:window.setTimeout(t,0)}})}}cancelNestedFitIdle(){this.nestedFitIdleHandle!==null&&(cancelIdleCallback(this.nestedFitIdleHandle),this.nestedFitIdleHandle=null),this.nestedFitFallback!==null&&(this.nestedFitFallback.stage==="frame"?cancelAnimationFrame(this.nestedFitFallback.handle):window.clearTimeout(this.nestedFitFallback.handle),this.nestedFitFallback=null)}ensureNestedFitMeasured(){this.nestedFitMeasured||(this.cancelNestedFitIdle(),this.measureNestedFit())}collectNestedLabels(){const e=[];let t=!1;const i=(r,s)=>{for(const n of r){const o=s>0;n instanceof E?o&&e.push(n.label):n instanceof v&&(o&&(e.push(n.label),n.url&&(t=!0)),i(Array.from(n.children),s+1))}};return i(this.getAssignedChildren(),0),{labels:e,linkedGroup:t}}readNestedFitMetrics(e){const t=this.nestedFitCapProbe.value,i=this.nestedFitFloorProbe.value,r=this.nestedFitPadProbe.value,s=this.nestedFitTextProbe.value;if(!t||!i||!r||!s)return null;const n=parseFloat(getComputedStyle(t).fontSize),o=parseFloat(getComputedStyle(i).fontSize),d=getComputedStyle(r),h=parseFloat(d.paddingInlineStart),b=parseFloat(d.paddingInlineEnd);if(![n,o,h,b].every(m=>Number.isFinite(m)))return null;s.replaceChildren(...e.map(m=>{const D=document.createElement("span");return D.textContent=m,D}));const C=Array.from(s.children,m=>m.getBoundingClientRect().width);return s.replaceChildren(),{capPx:n,floorPx:o,paddingPx:h,smallPx:b,widths:C}}measureNestedFit(){if(!this.isConnected||this.drawerPresentation!=="full-screen")return;const{labels:e,linkedGroup:t}=this.collectNestedLabels();if(this.nestedFitMeasured=!0,e.length===0){this.nestedFit!==null&&(this.nestedFit=null);return}const i=this.readNestedFitMetrics(e);if(!i)return;const r=this.drawerRef.value,s=r&&this.drawerShown?r.getBoundingClientRect().width:0,n=s>0?s:q().width,o=t?2*(2*i.smallPx+4.5):0,d=n-2*i.paddingPx-o,h=B({capPx:i.capPx,floorPx:i.floorPx,availablePx:d,widestAtCapPx:Math.max(0,...i.widths)});this.nestedFit&&this.nestedFit.fontSizePx===h.fontSizePx&&this.nestedFit.wrap===h.wrap||(this.nestedFit=h)}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.openedFullScreen=this.isFullScreenDrawer,this.openedFullScreen&&this.ensureNestedFitMeasured(),this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.detachDrawerKeydown(),this.fullScreenSession&&(this.fullScreenSession=!1,this.overlay.close()),this.drawerShown=!1,this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?S.MENU_DRAWER_OPENED:S.MENU_DRAWER_CLOSED,{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;if(!(!e||!t||!this.isConnected)){this.swipeController.drawerElement=t;try{this.openedFullScreen||e.showPopover(),t.showPopover()}catch{}this.dispatchEvent(new CustomEvent(S.MENU_DRAWER_PRESENTED,{bubbles:!0,composed:!0})),t.getBoundingClientRect(),requestAnimationFrame(()=>{!this.drawerOpen||!this.isConnected||(this.drawerTransitioning=!0,this.drawerShown=!0,this.openedFullScreen&&(this.fullScreenSession=!0,this.overlay.open(),this.attachDrawerKeydown(),this.updateComplete.then(()=>{this.drawerOpen&&this.overlay.moveFocusInto()})))})}}attachDrawerKeydown(){this.drawerKeydownAttached||(document.addEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!0)}detachDrawerKeydown(){this.drawerKeydownAttached&&(document.removeEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!1)}fullScreenFocusScope(){const e=this.drawerRef.value;if(!e)return[];const t=n=>n instanceof HTMLElement&&n.getClientRects().length>0,i=[],r=n=>{if(n.matches(A)&&t(n)&&i.push(n),n.shadowRoot)for(const o of n.shadowRoot.querySelectorAll(A))t(o)&&i.push(o)};for(const n of e.querySelectorAll("*"))if(r(n),n instanceof HTMLSlotElement)for(const o of n.assignedElements({flatten:!0})){r(o);for(const d of o.querySelectorAll("*"))r(d)}const s=this.liftedCloseControl;if(s?.isConnected){const n=s.shadowRoot?.querySelector("button")??s;t(n)&&i.push(n)}return i}static drawerTransitionMs(e){const t=getComputedStyle(e),i=o=>o.split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const h=Number.parseFloat(d);return Number.isFinite(h)?d.endsWith("ms")?h:h*1e3:0}),r=i(t.transitionDuration),s=i(t.transitionDelay);let n=0;return r.forEach((o,d)=>{n=Math.max(n,o+(s[d%Math.max(s.length,1)]??0))}),n}startCloseTransition(){const e=this.drawerRef.value;if(!e){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer);const t=y.drawerTransitionMs(e);if(t===0){this.onDrawerTransitionEnd();return}this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},t+50)}hideDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;this.swipeController.drawerElement=null,t&&(t.style.cssText="");try{t?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const t=new Set;let i=null;for(const s of this.querySelectorAll("esp-menu-item")){const n=s.url||s.getAttribute("url");if(n&&O(n)){i=s;break}}if(!i)for(const s of this.querySelectorAll("esp-menu-group")){const n=s.url||s.getAttribute("url");if(n&&O(n)){i=s;break}}if(!i&&e){for(const s of this.querySelectorAll("esp-menu-group"))s.parentElement===this&&t.add(s);return t}if(!i)return t;i instanceof v&&t.add(i);let r=i.parentElement;for(;r&&r!==this;)r instanceof v&&t.add(r),r=r.parentElement;return t}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return R(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const t=e.url||e.getAttribute("url");return t?R(location.pathname,$(t)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),t=this.querySelectorAll("esp-menu-group");for(const i of t)i.open=e.has(i)&&!this.isHorizontalTopLevelGroup(i)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e,t=this.getDrawerAutoExpandedGroups()){const i=[];for(const r of e)if(r instanceof E){const s=r.querySelector(":scope > svg, :scope > img");i.push({kind:"item",label:r.label,url:r.url,open:!1,icon:r.icon,iconHtml:s?.outerHTML||"",children:[],originalItem:r,originalGroup:null})}else if(r instanceof v){const s=r.querySelector(':scope > [slot="icon"]'),n=t.has(r)||this.groupPathMatches(r),o=this.drawerGroupOpenOverrides.get(r)??(r.open||n);i.push({kind:"group",label:r.label,url:r.url||"",open:o,icon:r.icon,iconHtml:s?.outerHTML||"",children:this.collectDrawerNodes(Array.from(r.children),t),originalItem:null,originalGroup:r})}return i}renderDrawerNode(e){return e.kind==="item"?f`<esp-menu-item
|
|
1
|
+
var l=function(v,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(v,e,t,i);else for(var o=v.length-1;o>=0;o--)(n=v[o])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},y;import{css as M,html as f,nothing as w}from"lit";import{customElement as N,eventOptions as L,property as c,state as F}from"lit/decorators.js";import{classMap as T}from"lit/directives/class-map.js";import{unsafeHTML as k}from"lit/directives/unsafe-html.js";import{createRef as p,ref as u}from"lit/directives/ref.js";import{styleMap as z}from"lit/directives/style-map.js";import{EspalierElementBase as P}from"../shared/esp-element-base.js";import{ESP_EVENTS as C}from"../shared/events.js";import{getEspBus as $}from"../shared/bus-events.js";import{normalizePath as I,pathStartsWithSegment as A,pathsMatch as O}from"../shared/path-matching.js";import{renderConfiguredBrand as _}from"../shared/configured-brand.js";import{FOCUSABLE_SELECTOR as R,OverlayController as x}from"../shared/overlay-controller.js";import{SwipeRevealController as H}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import"../burger/esp-burger.js";import{EspalierMenuItem as E}from"./esp-menu-item.js";import{EspalierMenuGroup as g}from"./esp-menu-group.js";import{COMPACT_VIEWPORT_MEDIA_QUERY as G}from"../shared/responsive.js";import{RafThrottle as q}from"../shared/raf-throttle.js";import{viewportSize as B}from"../shared/viewport.js";import{solveDrawerNestedFit as K}from"./drawer-nested-fit.js";const U=new Set(["panel","full-screen"]),W=new Set(["fade","slide-down","slide-up","slide-left","slide-right"]);let a=y=class extends P{ownsDrawerLock(){return this.isFullScreenDrawer}fullScreenInertAnchor(){return y.inertAnchorFor(this)}static inertAnchorFor(e){let t=e,i=e;for(;;){const r=i.parentElement;if(r){if(r.localName==="esp-page"||r.localName==="esp-root")return i;r===document.body&&(t=i),i=r;continue}const s=i.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement){i=s.host;continue}return t}}constructor(){super(),this.itemsSlot=p(),this.railRef=p(),this.scrimRef=p(),this.drawerRef=p(),this.bus=$(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this.overlay=new x({host:this,getFocusTrapContainer:()=>this.drawerRef.value??null,getFocusScope:()=>this.fullScreenFocusScope(),getInertAnchor:()=>this.fullScreenInertAnchor(),promote:!1,scrollLock:{preserveScrollPosition:!0}}),this.fullScreenSession=!1,this.openedFullScreen=!1,this.drawerKeydownAttached=!1,this.nestedFitProbe=p(),this.nestedFitCapProbe=p(),this.nestedFitFloorProbe=p(),this.nestedFitPadProbe=p(),this.nestedFitTextProbe=p(),this.nestedFit=null,this.nestedFitMeasured=!1,this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.nestedFitResize=new q(()=>this.measureNestedFit()),this.nestedFitObserver=null,this.onNestedFitResize=()=>{this.drawerPresentation==="full-screen"&&this.nestedFitResize.schedule()},this.onNestedFitFontsLoaded=()=>this.scheduleNestedFit(!0),this.onOverlayOpened=e=>{if(e===this.overlay||!this.drawerOpen)return;const t=this.drawerTrigger;this.drawerTrigger=null,t&&e.redirectFocusRestore(t),this.swipeController.closeForHandoff(),this.onDrawerTransitionEnd()},this._sliding=!1,this._mobileCollapsed=!1,this.verticalDrawerQuery=null,this.onVerticalDrawerChange=e=>this.setMobileCollapsed(e.matches),this.mode="horizontal",this.overflow="auto",this.side="left",this.drawerPresentation="panel",this.fullScreenTransition="fade",this.drawerBrand=null,this.liftedCloseControl=null,this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerShown=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.hasExternalDrawerControl=!1,this.previewCollapseRequested=!1,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerKeydown=e=>{!this.drawerOpen||!this.openedFullScreen||e.key==="Tab"&&this.overlay.trapFocus(e)},this.onDrawerTransitionEnd=e=>{e&&e.target!==this.drawerRef.value||(this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear()))},this.handleDrawerCloseClick=()=>{this.closeDrawer()},this.swipeController=new H(this,this.side),this.swipeController.enabled=!1}get isFullScreenDrawer(){return U.has(this.drawerPresentation)?this.drawerPresentation==="full-screen":!1}get resolvedFullScreenTransition(){return W.has(this.fullScreenTransition)?this.fullScreenTransition:"fade"}get sliding(){return this._sliding}set sliding(e){const t=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",t)}get drawerSide(){return this.overflow==="right-drawer"?"right":this.overflow==="left-drawer"?"left":this.side}get drawerActive(){return this.mode==="drawer"||this._sliding||this.overflow==="left-drawer"||this.overflow==="right-drawer"||this.mode==="vertical"&&(this._mobileCollapsed||this.previewCollapseRequested)&&this.hasExternalDrawerControl}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.getAttribute("slot")==="right"&&(this.side="right"),!this.verticalDrawerQuery&&typeof window<"u"&&"matchMedia"in window&&(this.verticalDrawerQuery=window.matchMedia(G),this._mobileCollapsed=this.verticalDrawerQuery.matches,this.verticalDrawerQuery.addEventListener("change",this.onVerticalDrawerChange)),this.syncSwipeEnabled(),x.addOpenListener(this.onOverlayOpened),window.addEventListener("resize",this.onNestedFitResize),typeof document<"u"&&document.fonts&&(document.fonts.addEventListener("loadingdone",this.onNestedFitFontsLoaded),document.fonts.ready.then(()=>{this.isConnected&&this.scheduleNestedFit(!0)})),!this.nestedFitObserver&&typeof MutationObserver<"u"&&(this.nestedFitObserver=new MutationObserver(()=>this.scheduleNestedFit(!0)),this.nestedFitObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label"]}))}disconnectedCallback(){x.removeOpenListener(this.onOverlayOpened),window.removeEventListener("resize",this.onNestedFitResize),document.fonts?.removeEventListener("loadingdone",this.onNestedFitFontsLoaded),this.nestedFitObserver?.disconnect(),this.nestedFitObserver=null,this.nestedFitResize.cancel(),this.cancelNestedFitIdle(),this.nestedFitMeasured=!1,this.verticalDrawerQuery?.removeEventListener("change",this.onVerticalDrawerChange),this.verticalDrawerQuery=null,this.detachDrawerKeydown(),this.fullScreenSession=!1,super.disconnectedCallback()}setMobileCollapsed(e){e!==this._mobileCollapsed&&(this._mobileCollapsed=e,this.mode==="vertical"&&this.applyMobileCollapse())}applyMobileCollapse(){this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)}firstUpdated(e){super.firstUpdated(e),this.propagateToItems(),this.scheduleNestedFit()}updated(e){super.updated(e),(e.has("mode")||e.has("overflow")||e.has("side")||e.has("hasExternalDrawerControl")||e.has("previewCollapseRequested"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),e.has("drawerPresentation")&&(this.nestedFitMeasured=!1,this.scheduleNestedFit()),this.drawerOpen&&this.openedFullScreen!==this.isFullScreenDrawer&&this.swipeController.close(!0),this.autoExpand&&(e.has("autoExpand")||e.has("mode")&&this.mode!=="horizontal")?this.expandToCurrentPage():this.mode==="horizontal"&&e.has("mode")&&this.closeHorizontalTopLevelGroups()}openDrawer(e){this.drawerActive&&(e?this.drawerTrigger=e:this.drawerOpen||(this.drawerTrigger=null),this.swipeController.open())}closeDrawer(){this.swipeController.close(!0)}toggleDrawer(e){this.drawerOpen?this.closeDrawer():this.openDrawer(e)}get isDrawerOpen(){return this.drawerOpen}syncSwipeEnabled(){this.swipeController.direction=this.drawerSide,this.swipeController.enabled=this.drawerActive}getAssignedChildren(){return this.itemsSlot.value?.assignedElements()??[]}propagateToItems(){const e=this.railMode;for(const t of this.getAssignedChildren())t instanceof E?(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch):t instanceof g&&(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch)}handleSlotChange(){this.propagateToItems(),this.scheduleNestedFit(!0)}scheduleNestedFit(e=!1){if(this.drawerPresentation!=="full-screen"){this.cancelNestedFitIdle(),this.nestedFit!==null&&(this.nestedFit=null);return}if(e&&(this.nestedFitMeasured=!1),e&&this.drawerShown){this.cancelNestedFitIdle(),this.nestedFitResize.schedule();return}if(this.nestedFitIdleHandle!==null||this.nestedFitFallback!==null)return;const t=()=>{this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.isConnected&&this.measureNestedFit()};typeof requestIdleCallback=="function"?this.nestedFitIdleHandle=requestIdleCallback(t,{timeout:2e3}):this.nestedFitFallback={stage:"frame",handle:requestAnimationFrame(()=>{this.nestedFitFallback={stage:"timeout",handle:window.setTimeout(t,0)}})}}cancelNestedFitIdle(){this.nestedFitIdleHandle!==null&&(cancelIdleCallback(this.nestedFitIdleHandle),this.nestedFitIdleHandle=null),this.nestedFitFallback!==null&&(this.nestedFitFallback.stage==="frame"?cancelAnimationFrame(this.nestedFitFallback.handle):window.clearTimeout(this.nestedFitFallback.handle),this.nestedFitFallback=null)}ensureNestedFitMeasured(){this.nestedFitMeasured||(this.cancelNestedFitIdle(),this.measureNestedFit())}collectNestedLabels(){const e=[];let t=!1;const i=(r,s)=>{for(const n of r){const o=s>0;n instanceof E?o&&e.push(n.label):n instanceof g&&(o&&(e.push(n.label),n.url&&(t=!0)),i(Array.from(n.children),s+1))}};return i(this.getAssignedChildren(),0),{labels:e,linkedGroup:t}}readNestedFitMetrics(e){const t=this.nestedFitCapProbe.value,i=this.nestedFitFloorProbe.value,r=this.nestedFitPadProbe.value,s=this.nestedFitTextProbe.value;if(!t||!i||!r||!s)return null;const n=parseFloat(getComputedStyle(t).fontSize),o=parseFloat(getComputedStyle(i).fontSize),d=getComputedStyle(r),h=parseFloat(d.paddingInlineStart),b=parseFloat(d.paddingInlineEnd);if(![n,o,h,b].every(m=>Number.isFinite(m)))return null;s.replaceChildren(...e.map(m=>{const D=document.createElement("span");return D.textContent=m,D}));const S=Array.from(s.children,m=>m.getBoundingClientRect().width);return s.replaceChildren(),{capPx:n,floorPx:o,paddingPx:h,smallPx:b,widths:S}}measureNestedFit(){if(!this.isConnected||this.drawerPresentation!=="full-screen")return;const{labels:e,linkedGroup:t}=this.collectNestedLabels();if(this.nestedFitMeasured=!0,e.length===0){this.nestedFit!==null&&(this.nestedFit=null);return}const i=this.readNestedFitMetrics(e);if(!i)return;const r=this.drawerRef.value,s=r&&this.drawerShown?r.getBoundingClientRect().width:0,n=s>0?s:B().width,o=t?2*(2*i.smallPx+4.5):0,d=n-2*i.paddingPx-o,h=K({capPx:i.capPx,floorPx:i.floorPx,availablePx:d,widestAtCapPx:Math.max(0,...i.widths)});this.nestedFit&&this.nestedFit.fontSizePx===h.fontSizePx&&this.nestedFit.wrap===h.wrap||(this.nestedFit=h)}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.openedFullScreen=this.isFullScreenDrawer,this.openedFullScreen&&this.ensureNestedFitMeasured(),this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.detachDrawerKeydown(),this.fullScreenSession&&(this.fullScreenSession=!1,this.overlay.close()),this.drawerShown=!1,this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?C.MENU_DRAWER_OPENED:C.MENU_DRAWER_CLOSED,{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;if(!(!e||!t||!this.isConnected)){this.swipeController.drawerElement=t;try{this.openedFullScreen||e.showPopover(),t.showPopover()}catch{}this.dispatchEvent(new CustomEvent(C.MENU_DRAWER_PRESENTED,{bubbles:!0,composed:!0})),t.getBoundingClientRect(),requestAnimationFrame(()=>{!this.drawerOpen||!this.isConnected||(this.drawerTransitioning=!0,this.drawerShown=!0,this.openedFullScreen&&(this.fullScreenSession=!0,this.overlay.open(),this.attachDrawerKeydown(),this.updateComplete.then(()=>{this.drawerOpen&&this.overlay.moveFocusInto()})))})}}attachDrawerKeydown(){this.drawerKeydownAttached||(document.addEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!0)}detachDrawerKeydown(){this.drawerKeydownAttached&&(document.removeEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!1)}fullScreenFocusScope(){const e=this.drawerRef.value;if(!e)return[];const t=n=>n instanceof HTMLElement&&n.getClientRects().length>0,i=[],r=n=>{if(n.matches(R)&&t(n)&&i.push(n),n.shadowRoot)for(const o of n.shadowRoot.querySelectorAll(R))t(o)&&i.push(o)};for(const n of e.querySelectorAll("*"))if(r(n),n instanceof HTMLSlotElement)for(const o of n.assignedElements({flatten:!0})){r(o);for(const d of o.querySelectorAll("*"))r(d)}const s=this.liftedCloseControl;if(s?.isConnected){const n=s.shadowRoot?.querySelector("button")??s;t(n)&&i.push(n)}return i}static drawerTransitionMs(e){const t=getComputedStyle(e),i=o=>o.split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const h=Number.parseFloat(d);return Number.isFinite(h)?d.endsWith("ms")?h:h*1e3:0}),r=i(t.transitionDuration),s=i(t.transitionDelay);let n=0;return r.forEach((o,d)=>{n=Math.max(n,o+(s[d%Math.max(s.length,1)]??0))}),n}startCloseTransition(){const e=this.drawerRef.value;if(!e){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer);const t=y.drawerTransitionMs(e);if(t===0){this.onDrawerTransitionEnd();return}this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},t+50)}hideDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;this.swipeController.drawerElement=null,t&&(t.style.cssText="");try{t?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const t=new Set;let i=null;for(const s of this.querySelectorAll("esp-menu-item")){const n=s.url||s.getAttribute("url");if(n&&O(n)){i=s;break}}if(!i)for(const s of this.querySelectorAll("esp-menu-group")){const n=s.url||s.getAttribute("url");if(n&&O(n)){i=s;break}}if(!i&&e){for(const s of this.querySelectorAll("esp-menu-group"))s.parentElement===this&&t.add(s);return t}if(!i)return t;i instanceof g&&t.add(i);let r=i.parentElement;for(;r&&r!==this;)r instanceof g&&t.add(r),r=r.parentElement;return t}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return A(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const t=e.url||e.getAttribute("url");return t?A(location.pathname,I(t)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),t=this.querySelectorAll("esp-menu-group");for(const i of t)i.open=e.has(i)&&!this.isHorizontalTopLevelGroup(i)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e,t=this.getDrawerAutoExpandedGroups()){const i=[];for(const r of e)if(r instanceof E){const s=r.querySelector(":scope > svg, :scope > img");i.push({kind:"item",label:r.label,target:r.target,rel:r.rel,newTabLabel:r.newTabLabel,url:r.url,open:!1,icon:r.icon,iconHtml:s?.outerHTML||"",children:[],originalItem:r,originalGroup:null})}else if(r instanceof g){const s=r.querySelector(':scope > [slot="icon"]'),n=t.has(r)||this.groupPathMatches(r),o=this.drawerGroupOpenOverrides.get(r)??(r.open||n);i.push({kind:"group",label:r.label,target:r.target,rel:r.rel,newTabLabel:r.newTabLabel,url:r.url||"",open:o,icon:r.icon,iconHtml:s?.outerHTML||"",children:this.collectDrawerNodes(Array.from(r.children),t),originalItem:null,originalGroup:r})}return i}renderDrawerNode(e){return e.kind==="item"?f`<esp-menu-item
|
|
2
2
|
label=${e.label}
|
|
3
3
|
.url=${e.url}
|
|
4
|
+
.target=${e.target}
|
|
5
|
+
.rel=${e.rel}
|
|
6
|
+
.newTabLabel=${e.newTabLabel}
|
|
4
7
|
.icon=${e.icon}
|
|
5
8
|
.mode=${"drawer"}
|
|
6
9
|
@esp-clicked=${()=>!e.url&&e.originalItem?this.handleDrawerItemClick(e.originalItem):void 0}
|
|
7
|
-
>${
|
|
10
|
+
>${k(e.iconHtml)}</esp-menu-item
|
|
8
11
|
>`:f`<esp-menu-group
|
|
9
12
|
label=${e.label}
|
|
10
13
|
.url=${e.url}
|
|
14
|
+
.target=${e.target}
|
|
15
|
+
.rel=${e.rel}
|
|
16
|
+
.newTabLabel=${e.newTabLabel}
|
|
11
17
|
.icon=${e.icon}
|
|
12
18
|
.mode=${"drawer"}
|
|
13
19
|
.fullScreenPresentation=${this.openedFullScreen}
|
|
14
20
|
?open=${e.open}
|
|
15
21
|
@esp-menu-group-toggle=${t=>{e.originalGroup&&(this.drawerGroupOpenOverrides.set(e.originalGroup,t.detail.open),this.isHorizontalTopLevelGroup(e.originalGroup)||(e.originalGroup.open=t.detail.open))}}
|
|
16
22
|
>
|
|
17
|
-
${e.iconHtml?
|
|
23
|
+
${e.iconHtml?k(e.iconHtml):w}
|
|
18
24
|
${e.children.map(t=>this.renderDrawerNode(t))}
|
|
19
|
-
</esp-menu-group>`}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent(
|
|
20
|
-
<div class="drawer-brand" style=${
|
|
25
|
+
</esp-menu-group>`}handleDrawerLinkClick(e){const t=e.composedPath().find(i=>i instanceof HTMLAnchorElement);!(t instanceof HTMLAnchorElement)||t.target.toLowerCase()!=="_blank"||setTimeout(()=>{e.defaultPrevented||this.closeDrawer()},0)}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent(C.CLICKED,{detail:{},bubbles:!0,composed:!0})),this.swipeController.close(!0)}render(){const e=this.drawerOpen||this.drawerTransitioning,t=this.drawerActive,i={rail:!0,horizontal:this.railMode==="horizontal",vertical:this.railMode==="vertical",wrap:this.overflow==="wrap",scroll:this.overflow==="scroll","drawer-forced":this.drawerActive},r=e?this.openedFullScreen:this.isFullScreenDrawer,s={drawer:!0,"drawer-left":this.drawerSide==="left","drawer-right":this.drawerSide==="right","full-screen":r,[`transition-${this.resolvedFullScreenTransition}`]:r,transitioning:this.drawerTransitioning,open:this.drawerShown,"nested-wrap":r&&this.nestedFit?.wrap===!0},n={"--_esp-menu-drawer-nested-font-size":r&&this.nestedFit?`${this.nestedFit.fontSizePx}px`:null},o=e?this.collectDrawerNodes(this.getAssignedChildren()):[],d=this.ariaLabel??"Navigation",h={"--_esp-menu-drawer-brand-color":this.drawerBrand?.brandColor||null},b=r&&e?f`<div class="drawer-chrome">
|
|
26
|
+
<div class="drawer-brand" style=${z(h)}>
|
|
21
27
|
<slot name="drawer-brand"
|
|
22
28
|
>${this.drawerBrand?_(this.drawerBrand):w}</slot
|
|
23
29
|
>
|
|
@@ -34,7 +40,7 @@ var l=function(g,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnP
|
|
|
34
40
|
</div>`:w;return f`
|
|
35
41
|
<nav
|
|
36
42
|
${u(this.railRef)}
|
|
37
|
-
class=${
|
|
43
|
+
class=${T(i)}
|
|
38
44
|
aria-label=${d}
|
|
39
45
|
?hidden=${t}
|
|
40
46
|
>
|
|
@@ -42,19 +48,20 @@ var l=function(g,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnP
|
|
|
42
48
|
</nav>
|
|
43
49
|
<div
|
|
44
50
|
${u(this.scrimRef)}
|
|
45
|
-
class=${
|
|
51
|
+
class=${T({scrim:!0,"full-screen":r,open:this.drawerShown,transitioning:this.drawerTransitioning})}
|
|
46
52
|
popover="manual"
|
|
47
53
|
></div>
|
|
48
54
|
<nav
|
|
49
55
|
${u(this.drawerRef)}
|
|
50
|
-
class=${
|
|
51
|
-
style=${
|
|
56
|
+
class=${T(s)}
|
|
57
|
+
style=${z(n)}
|
|
52
58
|
aria-label=${d}
|
|
53
59
|
popover="manual"
|
|
54
60
|
?data-no-swipe=${r}
|
|
61
|
+
@click=${this.handleDrawerLinkClick}
|
|
55
62
|
@transitionend=${this.onDrawerTransitionEnd}
|
|
56
63
|
>
|
|
57
|
-
${b} ${e?o.map(
|
|
64
|
+
${b} ${e?o.map(S=>this.renderDrawerNode(S)):w}
|
|
58
65
|
</nav>
|
|
59
66
|
${this.drawerPresentation==="full-screen"?f`<div class="nested-fit-probe" aria-hidden="true" ${u(this.nestedFitProbe)}>
|
|
60
67
|
<span class="nested-fit-cap" ${u(this.nestedFitCapProbe)}>​</span>
|
|
@@ -62,7 +69,7 @@ var l=function(g,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnP
|
|
|
62
69
|
<span class="nested-fit-pad" ${u(this.nestedFitPadProbe)}>​</span>
|
|
63
70
|
<div class="nested-fit-text" ${u(this.nestedFitTextProbe)}></div>
|
|
64
71
|
</div>`:w}
|
|
65
|
-
`}};a.styles=[...P.styles,
|
|
72
|
+
`}};a.styles=[...P.styles,M`
|
|
66
73
|
:host {
|
|
67
74
|
display: block;
|
|
68
75
|
min-width: 0;
|
|
@@ -404,4 +411,4 @@ var l=function(g,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnP
|
|
|
404
411
|
transition: none;
|
|
405
412
|
}
|
|
406
413
|
}
|
|
407
|
-
`],l([F()],a.prototype,"nestedFit",void 0),l([c({type:String,reflect:!0})],a.prototype,"mode",void 0),l([c({type:String,reflect:!0})],a.prototype,"overflow",void 0),l([c({type:String,reflect:!0})],a.prototype,"side",void 0),l([c({attribute:"drawer-presentation",type:String,reflect:!0})],a.prototype,"drawerPresentation",void 0),l([c({attribute:"full-screen-transition",type:String,reflect:!0})],a.prototype,"fullScreenTransition",void 0),l([c({attribute:!1})],a.prototype,"drawerBrand",void 0),l([c({attribute:!1})],a.prototype,"liftedCloseControl",void 0),l([c({attribute:"aria-label",type:String})],a.prototype,"ariaLabel",void 0),l([c({type:Boolean,attribute:"auto-expand"})],a.prototype,"autoExpand",void 0),l([c({type:Boolean})],a.prototype,"sliding",null),l([F()],a.prototype,"drawerOpen",void 0),l([F()],a.prototype,"drawerShown",void 0),l([F()],a.prototype,"drawerTransitioning",void 0),l([c({attribute:!1})],a.prototype,"hasExternalDrawerControl",void 0),l([c({attribute:!1})],a.prototype,"previewCollapseRequested",void 0),a=y=l([
|
|
414
|
+
`],l([F()],a.prototype,"nestedFit",void 0),l([c({type:String,reflect:!0})],a.prototype,"mode",void 0),l([c({type:String,reflect:!0})],a.prototype,"overflow",void 0),l([c({type:String,reflect:!0})],a.prototype,"side",void 0),l([c({attribute:"drawer-presentation",type:String,reflect:!0})],a.prototype,"drawerPresentation",void 0),l([c({attribute:"full-screen-transition",type:String,reflect:!0})],a.prototype,"fullScreenTransition",void 0),l([c({attribute:!1})],a.prototype,"drawerBrand",void 0),l([c({attribute:!1})],a.prototype,"liftedCloseControl",void 0),l([c({attribute:"aria-label",type:String})],a.prototype,"ariaLabel",void 0),l([c({type:Boolean,attribute:"auto-expand"})],a.prototype,"autoExpand",void 0),l([c({type:Boolean})],a.prototype,"sliding",null),l([F()],a.prototype,"drawerOpen",void 0),l([F()],a.prototype,"drawerShown",void 0),l([F()],a.prototype,"drawerTransitioning",void 0),l([c({attribute:!1})],a.prototype,"hasExternalDrawerControl",void 0),l([c({attribute:!1})],a.prototype,"previewCollapseRequested",void 0),l([L({capture:!0})],a.prototype,"handleDrawerLinkClick",null),a=y=l([N("esp-menu")],a);export{a as EspalierMenu};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{html as o,nothing as r}from"lit";const s="opens in a new tab";function a(n,t){return(n??"").toLowerCase()==="_blank"?` (${(t??"").trim()||s})`:""}function f(n,t){const e=a(n,t);return e?o`<span class="sr-only">${e}</span>`:r}export{s as DEFAULT_NEW_TAB_LABEL,a as newTabSuffix,f as renderNewTabCue};
|
package/espalier.css-data.json
CHANGED
|
@@ -1271,7 +1271,7 @@
|
|
|
1271
1271
|
},
|
|
1272
1272
|
{
|
|
1273
1273
|
"name": "--esp-menu-group-color",
|
|
1274
|
-
"description": "Text color of the group header."
|
|
1274
|
+
"description": "Text color of the group header. Defaults to `--esp-menu-item-color`, then `--esp-color-text`."
|
|
1275
1275
|
},
|
|
1276
1276
|
{
|
|
1277
1277
|
"name": "--esp-menu-group-hover-background",
|
|
@@ -1809,7 +1809,7 @@
|
|
|
1809
1809
|
"name": "--esp-menu-group-color",
|
|
1810
1810
|
"category": "component",
|
|
1811
1811
|
"component": "esp-menu-group",
|
|
1812
|
-
"description": "Text color of the group header."
|
|
1812
|
+
"description": "Text color of the group header. Defaults to `--esp-menu-item-color`, then `--esp-color-text`."
|
|
1813
1813
|
},
|
|
1814
1814
|
{
|
|
1815
1815
|
"name": "--esp-menu-group-hover-background",
|
|
@@ -1922,7 +1922,7 @@
|
|
|
1922
1922
|
{
|
|
1923
1923
|
"name": "--esp-menu-item-font-weight",
|
|
1924
1924
|
"category": "component",
|
|
1925
|
-
"component": "esp-menu-
|
|
1925
|
+
"component": "esp-menu-group",
|
|
1926
1926
|
"description": "Font weight of horizontal item labels. Defaults to `--esp-font-weight-menu`, then `700`."
|
|
1927
1927
|
},
|
|
1928
1928
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taprootio/espalier",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.9.1",
|
|
4
4
|
"packageManager": "bun@1.3.12",
|
|
5
5
|
"description": "Espalier — a themeable, accessible, framework-agnostic, enterprise-grade design system built on web standards and love.",
|
|
6
6
|
"customElements": "custom-elements.json",
|