@taprootio/espalier 6.9.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.
@@ -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
@@ -1,4 +1,4 @@
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 x}from"lit/decorators.js";import{classMap as w}from"lit/directives/class-map.js";import{createRef as f,ref as g}from"lit/directives/ref.js";import{EspalierElementBase as m}from"../shared/esp-element-base.js";import{ESP_EVENTS as k}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 T,renderNewTabCue as E}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 m{constructor(){super(...arguments),this.itemsSlot=f(),this.toggleButton=f(),this.iconSlot=new L(this),this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!1,this.label="",this.url="",this.target="",this.rel="",this.newTabLabel=T,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(k.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)}handleToggleKeydown(e){e.key==="Escape"&&(e.preventDefault(),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 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)}
@@ -10,8 +10,8 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
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
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`
@@ -24,16 +24,17 @@ 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}${E(this.target,this.newTabLabel)}</a
27
+ >${i}${T(this.target,this.newTabLabel)}</a
28
28
  >
29
29
  ${this.renderToggle(n`<span class="sr-only">Toggle ${this.label}</span>`)}
30
30
  `:this.renderToggle(i);return n`
31
- <div class=${w(e)}>
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>
34
34
  <span class="group-icon" aria-hidden="true">${this.renderIcon()}</span>
35
35
  </div>
36
36
  <div
37
+ id="group-items"
37
38
  class="group-items"
38
39
  ?hidden=${this.isHorizontalTopLevel&&!this.open}
39
40
  ?inert=${!this.open}
@@ -44,7 +45,7 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
44
45
  </div>
45
46
  </div>
46
47
  </div>
47
- `}};t.styles=[...m.styles,C,b`
48
+ `}};t.styles=[...f.styles,C,b`
48
49
  :host {
49
50
  display: block;
50
51
  position: relative;
@@ -56,7 +57,7 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
56
57
  display: grid;
57
58
  grid-template-columns: minmax(0, 1fr) min-content;
58
59
  align-items: stretch;
59
- color: var(--esp-menu-group-color, var(--esp-color-headings));
60
+ color: var(--esp-menu-group-color, var(--esp-menu-item-color, var(--esp-color-text)));
60
61
  background-color: var(--esp-menu-group-background, var(--esp-color-layer-1));
61
62
  border-right: 1px solid var(--esp-menu-group-border-color, var(--esp-color-border));
62
63
  border-bottom: 1px solid var(--esp-menu-group-border-color, var(--esp-color-border));
@@ -82,6 +83,8 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
82
83
  display: flex;
83
84
  width: 100%;
84
85
  min-width: 0;
86
+
87
+ min-height: 0;
85
88
  }
86
89
 
87
90
  .group-link,
@@ -108,12 +111,17 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
108
111
  )
109
112
  )
110
113
  );
111
- font-weight: 600;
112
114
  text-align: left;
113
115
  text-decoration: none;
114
116
  cursor: pointer;
115
117
  }
116
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
+
117
125
  .group-link,
118
126
  .current-page {
119
127
  flex: 0 1 auto;
@@ -122,7 +130,7 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
122
130
  background: none;
123
131
  }
124
132
 
125
- .current-page {
133
+ .is-active .current-page {
126
134
  color: var(--esp-menu-item-active-color, var(--esp-color-link));
127
135
  font-weight: var(--esp-menu-item-active-font-weight, var(--esp-font-weight-headings));
128
136
  }
@@ -150,6 +158,11 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
150
158
  position: relative;
151
159
  }
152
160
 
161
+ :host([full-screen-presentation]) .group-toggle:only-child .indicator {
162
+ position: absolute;
163
+ inset-inline-end: var(--esp-size-small);
164
+ }
165
+
153
166
  :host([full-screen-presentation]) .group-link,
154
167
  :host([full-screen-presentation]) .current-page {
155
168
  flex: 1 1 auto;
@@ -210,14 +223,19 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
210
223
  .indicator {
211
224
  display: inline-block;
212
225
  flex: 0 0 auto;
213
- width: 0;
214
- height: 0;
215
- border-top: 3.5px solid transparent;
216
- border-bottom: 3.5px solid transparent;
217
- 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%);
218
230
  transition: transform 0.2s ease;
219
231
  }
220
232
 
233
+ @media (forced-colors: active) {
234
+ .indicator {
235
+ background: ButtonText;
236
+ }
237
+ }
238
+
221
239
  .is-open .indicator {
222
240
  transform: rotate(90deg);
223
241
  }
@@ -274,4 +292,4 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
274
292
  transition: none;
275
293
  }
276
294
  }
277
- `],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([x()],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};
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};
@@ -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-item",
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.9.0",
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",