@taprootio/espalier 6.9.1 → 6.11.0

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.
@@ -4,6 +4,32 @@ import { LitElement } from "lit";
4
4
  * [esp-breadcrumbs](/components/breadcrumbs/) to show breadcrumb
5
5
  * navigation.
6
6
  *
7
+ * A crumb with a `url` renders as a link. A crumb without one is the current
8
+ * page: it renders as italic text marked `aria-current="page"` and wraps onto
9
+ * further lines when it is longer than the trail.
10
+ *
11
+ * To give readers that run no JavaScript a real link, write a plain
12
+ * `<a slot="link">` inside a linked crumb, with the same `href` and label text:
13
+ *
14
+ * ```html
15
+ * <esp-breadcrumbs>
16
+ * <esp-breadcrumb label="Code" url="/code">
17
+ * <a slot="link" href="/code">Code</a>
18
+ * </esp-breadcrumb>
19
+ * <esp-breadcrumb label="This page"></esp-breadcrumb>
20
+ * </esp-breadcrumbs>
21
+ * ```
22
+ *
23
+ * @slot link - Optional plain `<a href>` copy of the crumb's link for HTML-only
24
+ * readers such as crawlers, link previews and readers without JavaScript. The
25
+ * crumb has no `<slot>` for it, so once the crumb upgrades the copy is never
26
+ * rendered, takes no focus and is hidden from assistive technology; the crumb
27
+ * renders only from `label` and `url`, so keep the copy equal to them. Until
28
+ * the crumb upgrades, the copy is an ordinary visible child. A page that shows
29
+ * content before components load and wants no flash can hide it, at the cost of
30
+ * those readers:
31
+ * `:not(:defined) > [slot="link"], :not(:defined) > [slot="brand-link"] { display: none; }`.
32
+ *
7
33
  * @cssprop --esp-breadcrumb-color - The text color of the breadcrumb link. Defaults to
8
34
  * `var(--esp-color-link)`, so a trail reads as navigation in the same ink as the links in
9
35
  * the surrounding content.
@@ -1,13 +1,26 @@
1
- var a=function(l,t,o,s){var i=arguments.length,e=i<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,o):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(l,t,o,s);else for(var p=l.length-1;p>=0;p--)(n=l[p])&&(e=(i<3?n(e):i>3?n(t,o,e):n(t,o))||e);return i>3&&e&&Object.defineProperty(t,o,e),e};import{LitElement as d,css as m,html as h}from"lit";import{customElement as u,property as c}from"lit/decorators.js";import{unsafeSVG as b}from"lit/directives/unsafe-svg.js";let r=class extends d{constructor(){super(...arguments),this.label="",this.url="",this.separator="",this.isLastElement=!1}_renderLink(){return this.url?h`<a href=${this.url}>${this.label}</a>`:h`<label>${this.label}</label>`}render(){return h`${this._renderLink()}${this.separator?b(this.separator):""}`}};r.styles=m`
1
+ var a=function(n,e,o,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,o):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,o,s);else for(var p=n.length-1;p>=0;p--)(l=n[p])&&(r=(i<3?l(r):i>3?l(e,o,r):l(e,o))||r);return i>3&&r&&Object.defineProperty(e,o,r),r};import{LitElement as m,css as d,html as h}from"lit";import{customElement as u,property as c}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{unsafeSVG as v}from"lit/directives/unsafe-svg.js";let t=class extends m{constructor(){super(...arguments),this.label="",this.url="",this.separator="",this.isLastElement=!1}_renderLink(){return this.url?h`<a href=${this.url}>${this.label}</a>`:h`<span aria-current="page">${this.label}</span>`}render(){const e={crumb:!0,"is-current":!this.url};return h`<div class=${b(e)}>
2
+ ${this._renderLink()}${this.separator?v(this.separator):""}
3
+ </div>`}};t.styles=d`
4
+
2
5
  :host {
6
+ display: block;
7
+ min-width: 0;
8
+ }
9
+
10
+
11
+ .crumb {
3
12
  display: grid;
4
13
  grid-template-columns: min-content min-content;
5
14
  gap: var(--esp-size-tiny-to-small);
6
15
  align-items: center;
7
16
  }
8
17
 
18
+ .crumb.is-current {
19
+ grid-template-columns: minmax(0, auto) min-content;
20
+ }
21
+
9
22
 
10
- :is(a, label) {
23
+ :is(a, span[aria-current="page"]) {
11
24
  font-weight: bold;
12
25
  width: min-content;
13
26
  text-decoration: none;
@@ -26,12 +39,15 @@ var a=function(l,t,o,s){var i=arguments.length,e=i<3?t:s===null?s=Object.getOwnP
26
39
  }
27
40
 
28
41
 
29
- label {
42
+ span[aria-current="page"] {
30
43
  color: var(
31
44
  --esp-breadcrumb-current-color,
32
45
  var(--esp-breadcrumb-color, var(--esp-color-headings))
33
46
  );
34
47
  font-style: italic;
48
+ white-space: normal;
49
+ width: auto;
50
+ overflow-wrap: anywhere;
35
51
  }
36
52
 
37
53
 
@@ -43,4 +59,4 @@ var a=function(l,t,o,s){var i=arguments.length,e=i<3?t:s===null?s=Object.getOwnP
43
59
  height: var(--esp-size-normal-to-medium);
44
60
  width: var(--esp-size-normal-to-medium);
45
61
  }
46
- `,a([c({type:String})],r.prototype,"label",void 0),a([c({type:String})],r.prototype,"url",void 0),a([c({type:String})],r.prototype,"separator",void 0),a([c({attribute:"is-last-element",type:Boolean})],r.prototype,"isLastElement",void 0),r=a([u("esp-breadcrumb")],r);export{r as EspalierBreadcrumb};
62
+ `,a([c({type:String})],t.prototype,"label",void 0),a([c({type:String})],t.prototype,"url",void 0),a([c({type:String})],t.prototype,"separator",void 0),a([c({attribute:"is-last-element",type:Boolean})],t.prototype,"isLastElement",void 0),t=a([u("esp-breadcrumb")],t);export{t as EspalierBreadcrumb};
@@ -16,9 +16,14 @@ export * from "./esp-breadcrumb.js";
16
16
  * </esp-breadcrumbs>
17
17
  * ```
18
18
  *
19
+ * The trail is a `nav` landmark named `Breadcrumb`; set `aria-label` to
20
+ * rename it. A trail wider than its container wraps between crumbs, so do not
21
+ * wrap `esp-breadcrumbs` in a `nav` of your own.
22
+ *
19
23
  * Every crumb with a `url` is a link, including the last one — a trail
20
24
  * may end at the deepest folder rather than at the current page. Leave
21
- * `url` off a crumb to render it as the italic current-page label:
25
+ * `url` off a crumb to render it as the italic current-page label, which
26
+ * wraps onto further lines when it is longer than the trail:
22
27
  *
23
28
  * ```html
24
29
  * <esp-breadcrumbs>
@@ -27,6 +32,22 @@ export * from "./esp-breadcrumb.js";
27
32
  * </esp-breadcrumbs>
28
33
  * ```
29
34
  *
35
+ * To give readers that run no JavaScript real links, write a plain
36
+ * `<a slot="link">` inside each linked crumb, with the same `href` and label
37
+ * text. The copy is never rendered once the crumb upgrades:
38
+ *
39
+ * ```html
40
+ * <esp-breadcrumbs>
41
+ * <esp-breadcrumb label="Code" url="/code">
42
+ * <a slot="link" href="/code">Code</a>
43
+ * </esp-breadcrumb>
44
+ * <esp-breadcrumb label="Guides" url="/code/guides">
45
+ * <a slot="link" href="/code/guides">Guides</a>
46
+ * </esp-breadcrumb>
47
+ * <esp-breadcrumb label="This page"></esp-breadcrumb>
48
+ * </esp-breadcrumbs>
49
+ * ```
50
+ *
30
51
  * Custom separators can be specified in the `<esp-breadcrumb>`:
31
52
  *
32
53
  * ```html
@@ -77,6 +98,12 @@ export * from "./esp-breadcrumb.js";
77
98
  * @menuIcon directions
78
99
  */
79
100
  export declare class EspalierBreadcrumbs extends EspalierElementBase {
101
+ /**
102
+ * Accessible name of the breadcrumb navigation landmark. Defaults to
103
+ * `Breadcrumb`; set it to translate the name for a non-English site.
104
+ * Removing the attribute returns the name to `Breadcrumb`.
105
+ */
106
+ ariaLabel: string | null;
80
107
  protected firstUpdated(changedProperties: PropertyValues): void;
81
108
  protected render(): import("lit-html").TemplateResult<1>;
82
109
  static styles: import("lit").CSSResult[];
@@ -1,21 +1,22 @@
1
- var f=function(l,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(l,e,t,s);else for(var i=l.length-1;i>=0;i--)(a=l[i])&&(r=(o<3?a(r):o>3?a(e,t,r):a(e,t))||r);return o>3&&r&&Object.defineProperty(e,t,r),r};import{css as h,html as u}from"lit";import{customElement as v}from"lit/decorators.js";import{EspalierElementBase as m}from"../shared/esp-element-base.js";import{createRef as d,ref as g}from"lit/directives/ref.js";export*from"./esp-breadcrumb.js";const p=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
1
+ var p=function(o,e,t,r){var a=arguments.length,s=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,r);else for(var i=o.length-1;i>=0;i--)(n=o[i])&&(s=(a<3?n(s):a>3?n(e,t,s):n(e,t))||s);return a>3&&s&&Object.defineProperty(e,t,s),s};import{css as h,html as u}from"lit";import{customElement as v,property as d}from"lit/decorators.js";import{EspalierElementBase as m}from"../shared/esp-element-base.js";import{createRef as g,ref as w}from"lit/directives/ref.js";export*from"./esp-breadcrumb.js";const c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
2
2
  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
3
3
  <path
4
4
  d="M12.089 3.634a2 2 0 0 0 -1.089 1.78l-.001 2.586h-6.999a2 2 0 0 0 -2 2v4l.005 .15a2 2 0 0 0 1.995 1.85l6.999 -.001l.001 2.587a2 2 0 0 0 3.414 1.414l6.586 -6.586a2 2 0 0 0 0 -2.828l-6.586 -6.586a2 2 0 0 0 -2.18 -.434l-.145 .068z" />
5
- </svg>`,c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
5
+ </svg>`,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
6
  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
7
7
  <path
8
8
  d="M10 2l-.15 .005a2 2 0 0 0 -1.85 1.995v6.999l-2.586 .001a2 2 0 0 0 -1.414 3.414l6.586 6.586a2 2 0 0 0 2.828 0l6.586 -6.586a2 2 0 0 0 .434 -2.18l-.068 -.145a2 2 0 0 0 -1.78 -1.089l-2.586 -.001v-6.999a2 2 0 0 0 -2 -2h-4z"
9
9
  />
10
- </svg>`;let n=class extends m{constructor(){super(...arguments),this.itemsSlot=d()}firstUpdated(e){if(super.firstUpdated(e),!this.itemsSlot.value){console.warn("No items slot found for breadcrumbs.");return}this.assignSeparators()}assignSeparators(){const e=this.itemsSlot.value?.assignedElements()??[];for(let t=0;t<e.length;t++){const s=e[t],o=t===e.length-1;s.isLastElement=o;const r=s.separator===p||s.separator===c;s.separator&&!r||(s.separator=o?c:p)}}render(){return u`
11
- <div class="crumbs">
12
- <slot ${g(this.itemsSlot)} @slotchange=${this.assignSeparators}></slot>
13
- </div>
14
- `}};n.styles=[...m.styles,h`
15
- div.crumbs {
10
+ </svg>`;let l=class extends m{constructor(){super(...arguments),this.itemsSlot=g(),this.ariaLabel=null}firstUpdated(e){if(super.firstUpdated(e),!this.itemsSlot.value){console.warn("No items slot found for breadcrumbs.");return}this.assignSeparators()}assignSeparators(){const e=this.itemsSlot.value?.assignedElements()??[];for(let t=0;t<e.length;t++){const r=e[t],a=t===e.length-1;r.isLastElement=a;const s=r.separator===c||r.separator===f;r.separator&&!s||(r.separator=a?f:c)}}render(){return u`
11
+ <nav aria-label=${this.ariaLabel??"Breadcrumb"}>
12
+ <slot ${w(this.itemsSlot)} @slotchange=${this.assignSeparators}></slot>
13
+ </nav>
14
+ `}};l.styles=[...m.styles,h`
15
+ nav {
16
16
  display: flex;
17
+ flex-wrap: wrap;
17
18
  align-items: center;
18
19
  gap: var(--esp-size-tiny-to-small);
19
20
  font-size: var(--esp-size-small-to-normal);
20
21
  }
21
- `],n=f([v("esp-breadcrumbs")],n);export{n as EspalierBreadcrumbs};
22
+ `],p([d({attribute:"aria-label",type:String})],l.prototype,"ariaLabel",void 0),l=p([v("esp-breadcrumbs")],l);export{l as EspalierBreadcrumbs};
@@ -142,6 +142,30 @@ export type FooterColumns = "auto" | "1" | "2" | "3" | "4" | "5" | "6";
142
142
  * preferably responsive `<picture>` markup or an `esp-image` with appropriate
143
143
  * alternative text.
144
144
  * @slot brand - Custom brand identity. Overrides configured brand properties.
145
+ * @slot brand-link - Optional plain `<a href>` copy of the configured brand link
146
+ * (`brand-href`) for HTML-only readers such as crawlers, link previews and
147
+ * readers without JavaScript. Give it the same `href` and the text the
148
+ * configured brand renders: the logo's alt text (`brand-alt`, nothing when
149
+ * there is `brand-text`, or "Site logo" when there is neither) followed by
150
+ * `brand-text`. The brand links only when it has a logo or text and
151
+ * `brand-href` is set. The copy carries no `target` or `rel`. Once the footer upgrades, the copy is never
152
+ * rendered, takes no focus and is hidden from assistive technology; the footer
153
+ * renders only from the `brand-*` attributes, so keep the copy equal to them.
154
+ * Filling the `brand` slot still replaces the configured brand. Until the
155
+ * footer upgrades, the copy is an ordinary visible child. A page that shows
156
+ * content before components load and wants no flash can hide it, at the cost of
157
+ * those readers:
158
+ * `:not(:defined) > [slot="link"], :not(:defined) > [slot="brand-link"] { display: none; }`.
159
+ *
160
+ * ```html
161
+ * <esp-footer brand-text="Taproot" brand-href="/">
162
+ * <a slot="brand-link" href="/">Taproot</a>
163
+ * <esp-footer-link-group heading="Product">
164
+ * <a href="/features">Features</a>
165
+ * </esp-footer-link-group>
166
+ * </esp-footer>
167
+ * ```
168
+ *
145
169
  * @slot - Bare `esp-footer-link-group` children for automatic flow, or
146
170
  * `esp-footer-column` children for creator-controlled group stacks.
147
171
  * @slot aside - Supporting content such as a newsletter, call to action,
@@ -63,6 +63,32 @@ export interface EspThemeToggleEventDetail {
63
63
  * </esp-header>
64
64
  * ```
65
65
  *
66
+ * @slot brand-link - Optional plain `<a href>` copy of the configured brand
67
+ * link (`brand-href`) for HTML-only readers such as crawlers, link previews and
68
+ * readers without JavaScript. Give it the same `href` and the text the
69
+ * configured brand renders: the logo's alt text (`brand-alt`, nothing when
70
+ * there is `brand-text`, or "Site logo" when there is neither) followed by
71
+ * `brand-text`. The brand links only when it has a logo or text and
72
+ * `brand-href` is set. The copy carries no `target` or `rel`. Once the header upgrades, the copy is never
73
+ * rendered, takes no focus and is hidden from assistive technology; the header
74
+ * renders only from the `brand-*` attributes, so keep the copy equal to them.
75
+ * Filling the `brand` slot still replaces the configured brand. Until the
76
+ * header upgrades, the copy is an ordinary visible child. A page that shows
77
+ * content before components load and wants no flash can hide it, at the cost of
78
+ * those readers:
79
+ * `:not(:defined) > [slot="link"], :not(:defined) > [slot="brand-link"] { display: none; }`.
80
+ *
81
+ * ```html
82
+ * <esp-header brand-text="Taproot" brand-href="/">
83
+ * <a slot="brand-link" href="/">Taproot</a>
84
+ * <esp-menu slot="menu" mode="horizontal">
85
+ * <esp-menu-item label="Docs" url="/docs">
86
+ * <a slot="link" href="/docs">Docs</a>
87
+ * </esp-menu-item>
88
+ * </esp-menu>
89
+ * </esp-header>
90
+ * ```
91
+ *
66
92
  * @slot menu - Place site navigation here. The `menu` slot
67
93
  * should be populated with an [`<esp-menu>`](/components/menu/)
68
94
  * containing [`<esp-menu-item>`](/components/menu/item/) children:
@@ -9,9 +9,29 @@ import type { EspalierMenuMode } from "./esp-menu.js";
9
9
  * accessible panel; inside that panel, deeper levels render as
10
10
  * vertical disclosure navigation.
11
11
  *
12
+ * To give readers that run no JavaScript a real link for a linked group,
13
+ * write a plain `<a slot="link">` beside the attributes, with the same
14
+ * `href`, `target`, `rel` and label text:
15
+ *
16
+ * ```html
17
+ * <esp-menu-group label="Guides" url="/guides" target="_blank" rel="noopener">
18
+ * <a slot="link" href="/guides" target="_blank" rel="noopener">Guides</a>
19
+ * <esp-menu-item label="Start here" url="/guides/start"></esp-menu-item>
20
+ * </esp-menu-group>
21
+ * ```
22
+ *
12
23
  * @customElement esp-menu-group
13
24
  * @slot - Menu items or nested menu groups.
14
25
  * @slot icon - Optional SVG or image icon for the group.
26
+ * @slot link - Optional plain `<a href>` copy of a linked group's link for
27
+ * HTML-only readers such as crawlers, link previews and readers without
28
+ * JavaScript. Once the group upgrades, the copy is never rendered, takes no
29
+ * focus and is hidden from assistive technology; the group renders only from
30
+ * `label`, `url`, `target` and `rel`, so keep the copy equal to them. Until the
31
+ * group upgrades, the copy is an ordinary visible child. A page that shows
32
+ * content before components load and wants no flash can hide it, at the cost of
33
+ * those readers:
34
+ * `:not(:defined) > [slot="link"], :not(:defined) > [slot="brand-link"] { display: none; }`.
15
35
  *
16
36
  * @event {CustomEvent<{ open: boolean }>} esp-menu-group-toggle - Fired when the group opens or closes.
17
37
  *
@@ -60,8 +80,7 @@ export declare class EspalierMenuGroup extends EspalierElementBase {
60
80
  touchDevice: boolean;
61
81
  /**
62
82
  * Set by `esp-menu` for groups rendered in its full-screen drawer: the
63
- * label centers across the row and the disclosure control keeps the
64
- * inline end, so a linked group reads like the centered items around it.
83
+ * label and adjacent disclosure control center together across the row.
65
84
  */
66
85
  fullScreenPresentation: boolean;
67
86
  /**
@@ -1,10 +1,10 @@
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`
1
+ var i=function(l,e,o,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,o):a,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(l,e,o,a);else for(var c=l.length-1;c>=0;c--)(d=l[c])&&(s=(p<3?d(s):p>3?d(e,o,s):d(e,o))||s);return p>3&&s&&Object.defineProperty(e,o,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 L}from"../shared/path-matching.js";import{SlottedIconController as S}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 S(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=L(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(e){this.mode==="drawer"&&!e.composedPath().some(o=>o instanceof HTMLElement&&o.classList.contains("group-icon"))||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),o=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
- ${!i&&e?$(e):h}
7
+ ${!o&&e?$(e):h}
8
8
  `}renderToggle(e){return n`<button
9
9
  ${g(this.toggleButton)}
10
10
  class="group-toggle"
@@ -14,8 +14,8 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
14
14
  @click=${this.handleToggleClick}
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()},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>
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()},o=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">${o}</span>
19
19
  ${this.renderToggle(n`<span class="sr-only">Toggle ${this.label}</span>`)}
20
20
  `:n`
21
21
  <a
@@ -24,10 +24,10 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
24
24
  target=${this.target||h}
25
25
  rel=${this.rel||h}
26
26
  @click=${this.handleLinkClick}
27
- >${i}${T(this.target,this.newTabLabel)}</a
27
+ >${o}${T(this.target,this.newTabLabel)}</a
28
28
  >
29
29
  ${this.renderToggle(n`<span class="sr-only">Toggle ${this.label}</span>`)}
30
- `:this.renderToggle(i);return n`
30
+ `:this.renderToggle(o);return n`
31
31
  <div class=${k(e)} @keydown=${this.handleGroupKeydown}>
32
32
  <div class="group-header" @click=${this.handleHeaderClick}>
33
33
  <span class="group-label">${a}</span>
@@ -153,32 +153,30 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
153
153
  text-decoration: underline;
154
154
  }
155
155
 
156
-
157
- :host([full-screen-presentation]) .group-label {
158
- position: relative;
156
+ .is-drawer .group-label > .group-toggle:only-child,
157
+ .is-drawer .group-link + .group-toggle,
158
+ .is-drawer .current-page + .group-toggle {
159
+ flex: 0 0 auto;
160
+ width: auto;
159
161
  }
160
162
 
161
- :host([full-screen-presentation]) .group-toggle:only-child .indicator {
162
- position: absolute;
163
- inset-inline-end: var(--esp-size-small);
163
+ .is-drawer .group-label > .group-toggle:only-child {
164
+ flex-shrink: 1;
165
+ max-width: 100%;
164
166
  }
165
167
 
166
- :host([full-screen-presentation]) .group-link,
167
- :host([full-screen-presentation]) .current-page {
168
- flex: 1 1 auto;
169
- width: 100%;
168
+ .is-drawer .group-items-inner {
169
+ min-width: 0;
170
+ }
171
+
172
+
173
+ :host([full-screen-presentation]) .group-label {
170
174
  justify-content: center;
171
- padding: var(--esp-menu-item-padding, var(--esp-size-small) var(--esp-size-padding));
172
175
  }
173
176
 
174
- :host([full-screen-presentation]) .group-link + .group-toggle,
175
- :host([full-screen-presentation]) .current-page + .group-toggle {
176
- position: absolute;
177
- inset-block: 0;
178
- inset-inline-end: 0;
179
- flex: none;
180
- width: auto;
181
- padding-inline: var(--esp-size-small);
177
+ :host([full-screen-presentation]) .group-link,
178
+ :host([full-screen-presentation]) .current-page {
179
+ padding-inline-start: var(--esp-size-normal);
182
180
  }
183
181
 
184
182
  .group-toggle:focus-visible,
@@ -292,4 +290,4 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
292
290
  transition: none;
293
291
  }
294
292
  }
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};
293
+ `],i([r({type:String})],t.prototype,"label",void 0),i([r({type:String})],t.prototype,"url",void 0),i([r({type:String})],t.prototype,"target",void 0),i([r({type:String})],t.prototype,"rel",void 0),i([r({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),i([r({type:String})],t.prototype,"icon",void 0),i([r({type:Boolean,reflect:!0})],t.prototype,"open",void 0),i([r({attribute:!1,type:String})],t.prototype,"mode",void 0),i([r({attribute:!1,type:Number})],t.prototype,"depth",void 0),i([r({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),i([r({attribute:"full-screen-presentation",type:Boolean,reflect:!0})],t.prototype,"fullScreenPresentation",void 0),i([w()],t.prototype,"active",void 0),i([r({type:String,attribute:"url-prefix"})],t.prototype,"urlPrefix",void 0),t=u=i([y("esp-menu-group")],t);export{t as EspalierMenuGroup};
@@ -7,9 +7,28 @@ import type { EspalierMenuMode } from "./esp-menu.js";
7
7
  * Items render as links when `url` is provided and as buttons when
8
8
  * no URL is present. Button-style items dispatch `esp-clicked`.
9
9
  *
10
+ * To give readers that run no JavaScript a real link, write a plain
11
+ * `<a slot="link">` beside the attributes, with the same `href`, `target`,
12
+ * `rel` and label text. A new-tab link adds its "(opens in a new tab)" cue
13
+ * to the rendered link only, so a copy may add its own hidden cue:
14
+ *
15
+ * ```html
16
+ * <esp-menu-item label="Docs" url="/docs" target="_blank" rel="noopener">
17
+ * <a slot="link" href="/docs" target="_blank" rel="noopener">Docs</a>
18
+ * </esp-menu-item>
19
+ * ```
20
+ *
10
21
  * @customElement esp-menu-item
11
22
  * @slot - Optional SVG or image icon. Slotted content overrides the
12
23
  * generated sprite icon from the `icon` attribute.
24
+ * @slot link - Optional plain `<a href>` copy of the item's link for HTML-only
25
+ * readers such as crawlers, link previews and readers without JavaScript. Once
26
+ * the item upgrades, the copy is never rendered, takes no focus and is hidden
27
+ * from assistive technology; the item renders only from `label`, `url`,
28
+ * `target` and `rel`, so keep the copy equal to them. Until the item upgrades,
29
+ * the copy is an ordinary visible child. A page that shows content before
30
+ * components load and wants no flash can hide it, at the cost of those readers:
31
+ * `:not(:defined) > [slot="link"], :not(:defined) > [slot="brand-link"] { display: none; }`.
13
32
  *
14
33
  * @event {CustomEvent} esp-clicked - Fired when the item is rendered as a button (no `url`) and activated.
15
34
  *
@@ -1,7 +1,7 @@
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}>
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 b}from"lit/decorators.js";import{classMap as f}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 w}from"../shared/events.js";import{pathsMatch as k}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=k(this.url)}handleButtonClick(){this.dispatchEvent(new CustomEvent(w.CLICKED,{detail:{},bubbles:!0,composed:!0}))}render(){const t=y(this.icon,this),a=this.iconSlot.hasSlottedIcon(":scope > :not([slot]), :scope > [slot='']"),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
3
  ${!a&&t?x(t):d}
4
- </span>`;return l`<div class=${b(c)}>
4
+ </span>`;return l`<div class=${f(c)}>
5
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
6
  >${o}${n}${$(this.target,this.newTabLabel)}</a
7
7
  >`:l`<button type="button" @click=${this.handleButtonClick}>${o}${n}</button>`}
@@ -87,6 +87,20 @@ var r=function(p,t,a,s){var c=arguments.length,o=c<3?t:s===null?s=Object.getOwnP
87
87
  text-overflow: ellipsis;
88
88
  }
89
89
 
90
+ .is-drawer {
91
+ text-align: inherit;
92
+ }
93
+
94
+ .is-drawer > a,
95
+ .is-drawer > button,
96
+ .is-drawer > .current-page {
97
+ display: inline-flex;
98
+ width: fit-content;
99
+ max-width: 100%;
100
+ box-sizing: border-box;
101
+ vertical-align: top;
102
+ }
103
+
90
104
  .is-horizontal > a,
91
105
  .is-horizontal > button,
92
106
  .is-horizontal > .current-page {
@@ -192,4 +206,4 @@ var r=function(p,t,a,s){var c=arguments.length,o=c<3?t:s===null?s=Object.getOwnP
192
206
  width: var(--esp-menu-item-icon-size, calc(1 * var(--esp-size-font)));
193
207
  object-fit: contain;
194
208
  }
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};
209
+ `],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([b()],e.prototype,"active",void 0),e=r([v("esp-menu-item")],e);export{e as EspalierMenuItem};
@@ -329,6 +329,10 @@ var l=function(v,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnP
329
329
  --esp-menu-group-hover-background: transparent;
330
330
  }
331
331
 
332
+ .drawer.full-screen esp-menu-item {
333
+ text-align: center;
334
+ }
335
+
332
336
  .drawer.full-screen esp-menu-item::part(menu-text),
333
337
  .drawer.full-screen esp-menu-group::part(menu-text) {
334
338
  display: flex;
@@ -0,0 +1 @@
1
+ const e=':is(esp-menu-item, esp-menu-group, esp-breadcrumb) > a[slot="link"], :is(esp-header, esp-footer) > a[slot="brand-link"]';export{e as LINK_COPY_SELECTOR};
@@ -1 +1 @@
1
- const c=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", "),l="[autofocus]:not([disabled])";class o{static lock(t,e={}){const s=e.preserveScrollPosition===!0,n=o.owners.get(t);n===!0||n===s||(o.owners.size===0&&(o.snapshot={x:window.scrollX,y:window.scrollY,html:o.capture(document.documentElement,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y"]),body:o.capture(document.body,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","position","top","left","width"])}),o.owners.set(t,s),o.applyCurrentTreatment())}static unlock(t){if(!(!o.owners.delete(t)||!o.snapshot)){if(o.owners.size===0){o.restoreSnapshot(),o.snapshot=null;return}o.applyCurrentTreatment()}}static capture(t,e){return e.map(s=>({name:s,value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}))}static restore(t,e){for(const{name:s}of e)t.style.removeProperty(s);for(const{name:s,value:n,priority:i}of e)n&&t.style.setProperty(s,n,i)}static applyCurrentTreatment(){const t=o.snapshot;if(!t)return;const e=[...o.owners.values()].some(Boolean);!e&&o.positionFrozen&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.restoreViewport(t),o.positionFrozen=!1),document.body.style.overflow="hidden",e&&(o.positionFrozen||(t.x=window.scrollX,t.y=window.scrollY),document.documentElement.style.overflow="hidden",document.documentElement.style.overscrollBehavior="contain",document.body.style.overscrollBehavior="contain",document.body.style.position="fixed",document.body.style.top=`${-t.y}px`,document.body.style.left=`${-t.x}px`,document.body.style.width="100%",o.positionFrozen=!0)}static restoreSnapshot(){const t=o.snapshot;t&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.positionFrozen&&o.restoreViewport(t),o.positionFrozen=!1)}static restoreViewport(t){window.scrollTo?.({top:t.y,left:t.x,behavior:"instant"})}static _reset(){o.restoreSnapshot(),o.owners.clear(),o.snapshot=null,o.positionFrozen=!1}}o.owners=new Map,o.snapshot=null,o.positionFrozen=!1;function f(){o._reset()}class r{static lock(t){const e=r._counts.get(t);return e!==void 0?(r._counts.set(t,e+1),!0):t.inert?!1:(r._counts.set(t,1),t.inert=!0,!0)}static unlock(t){const e=r._counts.get(t)??0;if(e<=0)return;const s=e-1;s===0?(t.inert=!1,r._counts.delete(t)):r._counts.set(t,s)}static _reset(){r._counts.clear()}}r._counts=new Map;function d(){r._reset()}class u{get isPromoting(){return this._promoting}constructor(t){this._isOpen=!1,this._previouslyFocused=null,this._inertElements=[],this._promoted=!1,this._pendingReactivation=!1,this._dropZone=null,this._promoting=!1,this._host=t.host,this._opts=t,t.host.addController(this)}static addOpenListener(t){u.openListeners.add(t)}static removeOpenListener(t){u.openListeners.delete(t)}redirectFocusRestore(t){this._isOpen&&(this._previouslyFocused=t)}get isOpen(){return this._isOpen}open(){if(!this._isOpen){this._pendingReactivation?this._pendingReactivation=!1:this._previouslyFocused=document.activeElement??null,this._isOpen=!0;for(const t of u.openListeners)t(this);o.lock(this,this._opts.scrollLock),this._opts.promote!==!1&&this._promoteToDropZone(),this._setInert(!0)}}close(){if(this._pendingReactivation=!1,!this._isOpen){this._previouslyFocused?.focus(),this._previouslyFocused=null;return}this._isOpen=!1,o.unlock(this),this._setInert(!1),this._previouslyFocused?.focus(),this._previouslyFocused=null}trapFocus(t){const e=this.getFocusableElements();if(e.length===0)return;const s=e[0],n=e[e.length-1],i=this._getDeepActiveElement();t.shiftKey?(i===s||this._isOrContains(s,i))&&(t.preventDefault(),n.focus()):(i===n||this._isOrContains(n,i))&&(t.preventDefault(),s.focus())}moveFocusInto(){const t=this._getAutofocusElement();if(t&&(t.focus(),this._autofocusLanded(t)))return;const e=this.getFocusableElements();if(e.length>0){e[0].focus();return}const s=this._opts.getFocusFallback?.();if(s){s.focus();return}this._opts.getFocusTrapContainer()?.focus()}_getAutofocusElement(){return this._getMatchingElements(l)[0]??null}getFocusableElements(){return this._getMatchingElements(c)}_getMatchingElements(t){if(t===c&&this._opts.getFocusScope)return this._opts.getFocusScope();const e=this._opts.getFocusTrapContainer();if(!e)return[];const s=[];for(const n of Array.from(e.querySelectorAll("*")))if(n instanceof HTMLElement){if(n.matches(t)&&s.push(n),n.shadowRoot){const i=n.shadowRoot.querySelectorAll(t);s.push(...Array.from(i))}if(n instanceof HTMLSlotElement)for(const i of n.assignedElements({flatten:!0})){if(!(i instanceof HTMLElement))continue;i.matches(t)&&s.push(i);const a=i.querySelectorAll(t);if(s.push(...Array.from(a)),i.shadowRoot){const h=i.shadowRoot.querySelectorAll(t);s.push(...Array.from(h))}}}for(const n of Array.from(this._host.children)){if(!(n instanceof HTMLElement))continue;n.matches(t)&&(s.includes(n)||s.push(n));const i=n.querySelectorAll(t);for(const a of Array.from(i))s.includes(a)||s.push(a);if(n.shadowRoot){const a=n.shadowRoot.querySelectorAll(t);for(const h of Array.from(a))s.includes(h)||s.push(h)}}return s}hostConnected(){}hostDisconnected(){this._promoting||this._isOpen&&(this._setInert(!1),o.unlock(this),this._isOpen=!1,this._pendingReactivation=!0)}_setInert(t){if(t){this._inertElements=[];const e=this._resolveInertAnchor(),s=e.parentElement??document.body;for(const n of s.children)n instanceof HTMLElement&&n!==e&&r.lock(n)&&this._inertElements.push(n)}else{for(const e of this._inertElements)r.unlock(e);this._inertElements=[]}}_resolveInertAnchor(){if(this._dropZone)return this._dropZone;const t=this._opts.getInertAnchor?.();if(t)return t;let e=this._host;for(;!e.parentElement;){const s=e.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement)e=s.host;else break}return e}_getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}_isOrContains(t,e){return e?t===e?!0:t.contains(e):!1}_autofocusLanded(t){const e=this._getActiveElementChain(),s=e[0];return e.some(n=>this._isOrContains(t,n)?!0:n!==s&&n instanceof HTMLElement&&this._isOrContains(n,t))}_getActiveElementChain(){const t=[];let e=document.activeElement;for(;e;){t.push(e);const s=e.shadowRoot?.activeElement??null;if(!s||s===e)break;e=s}return t}_promoteToDropZone(){if(this._promoted&&this._dropZone){this._promoting=!0;try{this._dropZone.appendChild(this._host)}finally{this._promoting=!1}return}const t=this._host,e=t.closest("esp-page");if(e){if(customElements.get("esp-page")){this._tryPromote(e);return}customElements.whenDefined("esp-page").then(()=>{if(!this._isOpen||!t.isConnected)return;const s=t.closest("esp-page");this._tryPromote(s)&&(this._setInert(!1),this._setInert(!0))})}}_tryPromote(t){if(!t||this._promoted)return!1;const e=t.AddDialog;if(typeof e=="function"){this._promoting=!0;try{e.call(t,this._host)}finally{this._promoting=!1}return this._promoted=!0,this._dropZone=this._host.parentElement,!0}return!1}}u.openListeners=new Set;export{c as FOCUSABLE_SELECTOR,u as OverlayController,o as ScrollLock,d as _resetInertLock,f as _resetScrollLock};
1
+ import{LINK_COPY_SELECTOR as l}from"./link-copy.js";const c=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", "),f="[autofocus]:not([disabled])";class o{static lock(t,e={}){const s=e.preserveScrollPosition===!0,n=o.owners.get(t);n===!0||n===s||(o.owners.size===0&&(o.snapshot={x:window.scrollX,y:window.scrollY,html:o.capture(document.documentElement,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y"]),body:o.capture(document.body,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","position","top","left","width"])}),o.owners.set(t,s),o.applyCurrentTreatment())}static unlock(t){if(!(!o.owners.delete(t)||!o.snapshot)){if(o.owners.size===0){o.restoreSnapshot(),o.snapshot=null;return}o.applyCurrentTreatment()}}static capture(t,e){return e.map(s=>({name:s,value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}))}static restore(t,e){for(const{name:s}of e)t.style.removeProperty(s);for(const{name:s,value:n,priority:i}of e)n&&t.style.setProperty(s,n,i)}static applyCurrentTreatment(){const t=o.snapshot;if(!t)return;const e=[...o.owners.values()].some(Boolean);!e&&o.positionFrozen&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.restoreViewport(t),o.positionFrozen=!1),document.body.style.overflow="hidden",e&&(o.positionFrozen||(t.x=window.scrollX,t.y=window.scrollY),document.documentElement.style.overflow="hidden",document.documentElement.style.overscrollBehavior="contain",document.body.style.overscrollBehavior="contain",document.body.style.position="fixed",document.body.style.top=`${-t.y}px`,document.body.style.left=`${-t.x}px`,document.body.style.width="100%",o.positionFrozen=!0)}static restoreSnapshot(){const t=o.snapshot;t&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.positionFrozen&&o.restoreViewport(t),o.positionFrozen=!1)}static restoreViewport(t){window.scrollTo?.({top:t.y,left:t.x,behavior:"instant"})}static _reset(){o.restoreSnapshot(),o.owners.clear(),o.snapshot=null,o.positionFrozen=!1}}o.owners=new Map,o.snapshot=null,o.positionFrozen=!1;function p(){o._reset()}class r{static lock(t){const e=r._counts.get(t);return e!==void 0?(r._counts.set(t,e+1),!0):t.inert?!1:(r._counts.set(t,1),t.inert=!0,!0)}static unlock(t){const e=r._counts.get(t)??0;if(e<=0)return;const s=e-1;s===0?(t.inert=!1,r._counts.delete(t)):r._counts.set(t,s)}static _reset(){r._counts.clear()}}r._counts=new Map;function m(){r._reset()}class u{get isPromoting(){return this._promoting}constructor(t){this._isOpen=!1,this._previouslyFocused=null,this._inertElements=[],this._promoted=!1,this._pendingReactivation=!1,this._dropZone=null,this._promoting=!1,this._host=t.host,this._opts=t,t.host.addController(this)}static addOpenListener(t){u.openListeners.add(t)}static removeOpenListener(t){u.openListeners.delete(t)}redirectFocusRestore(t){this._isOpen&&(this._previouslyFocused=t)}get isOpen(){return this._isOpen}open(){if(!this._isOpen){this._pendingReactivation?this._pendingReactivation=!1:this._previouslyFocused=document.activeElement??null,this._isOpen=!0;for(const t of u.openListeners)t(this);o.lock(this,this._opts.scrollLock),this._opts.promote!==!1&&this._promoteToDropZone(),this._setInert(!0)}}close(){if(this._pendingReactivation=!1,!this._isOpen){this._previouslyFocused?.focus(),this._previouslyFocused=null;return}this._isOpen=!1,o.unlock(this),this._setInert(!1),this._previouslyFocused?.focus(),this._previouslyFocused=null}trapFocus(t){const e=this.getFocusableElements();if(e.length===0)return;const s=e[0],n=e[e.length-1],i=this._getDeepActiveElement();t.shiftKey?(i===s||this._isOrContains(s,i))&&(t.preventDefault(),n.focus()):(i===n||this._isOrContains(n,i))&&(t.preventDefault(),s.focus())}moveFocusInto(){const t=this._getAutofocusElement();if(t&&(t.focus(),this._autofocusLanded(t)))return;const e=this.getFocusableElements();if(e.length>0){e[0].focus();return}const s=this._opts.getFocusFallback?.();if(s){s.focus();return}this._opts.getFocusTrapContainer()?.focus()}_getAutofocusElement(){return this._getMatchingElements(f)[0]??null}getFocusableElements(){return this._getMatchingElements(c)}_getMatchingElements(t){if(t===c&&this._opts.getFocusScope)return this._opts.getFocusScope();const e=this._opts.getFocusTrapContainer();if(!e)return[];const s=[];for(const n of Array.from(e.querySelectorAll("*")))if(n instanceof HTMLElement){if(n.matches(t)&&s.push(n),n.shadowRoot){const i=n.shadowRoot.querySelectorAll(t);s.push(...Array.from(i))}if(n instanceof HTMLSlotElement)for(const i of n.assignedElements({flatten:!0})){if(!(i instanceof HTMLElement))continue;i.matches(t)&&s.push(i);const a=i.querySelectorAll(t);if(s.push(...Array.from(a)),i.shadowRoot){const h=i.shadowRoot.querySelectorAll(t);s.push(...Array.from(h))}}}for(const n of Array.from(this._host.children)){if(!(n instanceof HTMLElement))continue;n.matches(t)&&(s.includes(n)||s.push(n));const i=n.querySelectorAll(t);for(const a of Array.from(i))s.includes(a)||s.push(a);if(n.shadowRoot){const a=n.shadowRoot.querySelectorAll(t);for(const h of Array.from(a))s.includes(h)||s.push(h)}}return s.filter(n=>!(n.matches(l)&&n.parentElement?.shadowRoot))}hostConnected(){}hostDisconnected(){this._promoting||this._isOpen&&(this._setInert(!1),o.unlock(this),this._isOpen=!1,this._pendingReactivation=!0)}_setInert(t){if(t){this._inertElements=[];const e=this._resolveInertAnchor(),s=e.parentElement??document.body;for(const n of s.children)n instanceof HTMLElement&&n!==e&&r.lock(n)&&this._inertElements.push(n)}else{for(const e of this._inertElements)r.unlock(e);this._inertElements=[]}}_resolveInertAnchor(){if(this._dropZone)return this._dropZone;const t=this._opts.getInertAnchor?.();if(t)return t;let e=this._host;for(;!e.parentElement;){const s=e.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement)e=s.host;else break}return e}_getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}_isOrContains(t,e){return e?t===e?!0:t.contains(e):!1}_autofocusLanded(t){const e=this._getActiveElementChain(),s=e[0];return e.some(n=>this._isOrContains(t,n)?!0:n!==s&&n instanceof HTMLElement&&this._isOrContains(n,t))}_getActiveElementChain(){const t=[];let e=document.activeElement;for(;e;){t.push(e);const s=e.shadowRoot?.activeElement??null;if(!s||s===e)break;e=s}return t}_promoteToDropZone(){if(this._promoted&&this._dropZone){this._promoting=!0;try{this._dropZone.appendChild(this._host)}finally{this._promoting=!1}return}const t=this._host,e=t.closest("esp-page");if(e){if(customElements.get("esp-page")){this._tryPromote(e);return}customElements.whenDefined("esp-page").then(()=>{if(!this._isOpen||!t.isConnected)return;const s=t.closest("esp-page");this._tryPromote(s)&&(this._setInert(!1),this._setInert(!0))})}}_tryPromote(t){if(!t||this._promoted)return!1;const e=t.AddDialog;if(typeof e=="function"){this._promoting=!0;try{e.call(t,this._host)}finally{this._promoting=!1}return this._promoted=!0,this._dropZone=this._host.parentElement,!0}return!1}}u.openListeners=new Set;export{c as FOCUSABLE_SELECTOR,u as OverlayController,o as ScrollLock,m as _resetInertLock,p as _resetScrollLock};
@@ -42,6 +42,8 @@ export interface EspTreeNode {
42
42
  cuttable?: boolean;
43
43
  /** Whether the node can receive a paste-as-child action. Defaults to `false`. */
44
44
  pasteChildTarget?: boolean;
45
+ /** Whether this node can receive a graft when `allow-graft` is set. Defaults to `true`. */
46
+ graftTarget?: boolean;
45
47
  /** Eagerly-provided children. */
46
48
  children?: EspTreeNode[];
47
49
  /** Marks a branch whose children load lazily via `loadChildren`. */