@taprootio/espalier 6.9.1 → 6.10.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.
- package/CHANGELOG.md +12 -0
- package/custom-elements.json +10369 -10303
- package/dist/breadcrumbs/esp-breadcrumb.d.ts +26 -0
- package/dist/breadcrumbs/esp-breadcrumb.js +20 -4
- package/dist/breadcrumbs/esp-breadcrumbs.d.ts +28 -1
- package/dist/breadcrumbs/esp-breadcrumbs.js +10 -9
- package/dist/footer/esp-footer.d.ts +24 -0
- package/dist/header/esp-header.d.ts +26 -0
- package/dist/menu/esp-menu-group.d.ts +20 -0
- package/dist/menu/esp-menu-item.d.ts +19 -0
- package/dist/menu/esp-menu-item.js +1 -1
- package/dist/shared/link-copy.js +1 -0
- package/dist/shared/overlay-controller.js +1 -1
- package/package.json +1 -1
|
@@ -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(
|
|
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,
|
|
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
|
-
|
|
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})],
|
|
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
|
|
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>`,
|
|
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
|
|
11
|
-
<
|
|
12
|
-
<slot ${
|
|
13
|
-
</
|
|
14
|
-
`}};
|
|
15
|
-
|
|
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
|
-
`],
|
|
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
|
*
|
|
@@ -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,4 +1,4 @@
|
|
|
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 >
|
|
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 > :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
4
|
</span>`;return l`<div class=${b(c)}>
|
|
@@ -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(", "),
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taprootio/espalier",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
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",
|