@taprootio/espalier 2.2.0 → 2.3.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.
@@ -1,37 +1,43 @@
1
- var c=function(d,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(d,e,t,i);else for(var p=d.length-1;p>=0;p--)(l=d[p])&&(r=(s<3?l(r):s>3?l(e,t,r):l(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},n;import{LitElement as f,css as b,html as a,nothing as h}from"lit";import{customElement as _,property as u,state as m}from"lit/decorators.js";import{classMap as g}from"lit/directives/class-map.js";import{keyed as v}from"lit/directives/keyed.js";import{cancelSVG as x}from"../shared/svgs/cancel.js";import{commentSVG as w}from"../shared/svgs/comment.js";import{leftArrow as y}from"../shared/svgs/left-arrow.js";import{rightArrow as k}from"../shared/svgs/right-arrow.js";import{OverlayController as $}from"../shared/overlay-controller.js";import"../image/esp-image.js";import"../image/esp-image-option.js";import"../button/esp-button.js";let o=n=class extends f{constructor(){super(...arguments),this.isOpen=!1,this.currentIndex=0,this.drawerOpen=!1,this._images=[],this._clickHandlers=new Map,this._pendingRaf=null,this._overlay=new $({host:this,getFocusTrapContainer:()=>this.shadowRoot?.querySelector(".lightbox")??null}),this._touchStartX=0,this._touchStartY=0,this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1,this.for="",this.commentCount=0}get _commentLabel(){return this.commentCount<=0?"No comments. Add yours!":this.commentCount===1?"1 comment":`${this.commentCount} comments`}open(e){if(this._collectImages(),this._images.length===0)return;const t=Math.max(0,Math.min(e,this._images.length-1));if(this.isOpen){this._goTo(t);return}this.currentIndex=t,this.isOpen=!0,this.drawerOpen=!1,this._overlay.open(),this._emitChanged(),this.updateComplete.then(()=>{this.shadowRoot?.querySelector(".lightbox")?.focus()})}close(){this.isOpen&&(this.isOpen=!1,this.drawerOpen=!1,this._overlay.close())}_collectImages(){if(!this.for){this._images=[];return}let e;try{e=document.querySelector(this.for)}catch{this._images=[];return}if(!e){this._images=[];return}this._images=Array.from(e.querySelectorAll("esp-image"))}_attachClickHandlers(){this._detachClickHandlers(),this._collectImages(),this._images.forEach((e,t)=>{const i=()=>this.open(t);e.addEventListener("click",i),e.classList.add(n._CLICKABLE_CLASS),this._clickHandlers.set(e,i)})}_detachClickHandlers(){for(const[e,t]of this._clickHandlers)e.removeEventListener("click",t),e.classList.remove(n._CLICKABLE_CLASS);this._clickHandlers.clear()}_goTo(e){const t=this._images.length;if(t===0)return;const i=(e%t+t)%t;i!==this.currentIndex&&(this.currentIndex=i,this._emitChanged())}_emitChanged(){this.dispatchEvent(new CustomEvent("esp-lightbox-changed",{detail:{index:this.currentIndex},bubbles:!0,composed:!0}))}_prev(){this._goTo(this.currentIndex-1)}_next(){this._goTo(this.currentIndex+1)}_handleKeyDown(e){if(this.isOpen)switch(e.key){case"Escape":e.preventDefault(),this.close();break;case"ArrowLeft":e.preventDefault(),this._prev();break;case"ArrowRight":e.preventDefault(),this._next();break;case"ArrowUp":e.preventDefault(),this.drawerOpen||this._toggleDrawer();break;case"ArrowDown":e.preventDefault(),this.drawerOpen&&this._toggleDrawer();break;case"Tab":this._overlay.trapFocus(e);break}}_handleTouchStart(e){e.touches.length===1&&(this._touchStartX=e.touches[0].clientX,this._touchStartY=e.touches[0].clientY,this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1)}_handleTouchMove(e){if(e.touches.length!==1)return;const t=e.touches[0].clientX-this._touchStartX,i=e.touches[0].clientY-this._touchStartY;!this._swiping&&!this._swipingVertical&&(Math.abs(t)>10||Math.abs(i)>10)&&(Math.abs(t)>Math.abs(i)?this._swiping=!0:this._swipingVertical=!0),this._swiping?(e.preventDefault(),this._touchDeltaX=t):this._swipingVertical&&(e.preventDefault(),this._touchDeltaY=i)}_handleTouchEnd(){this._swiping?this._touchDeltaX>50?this._prev():this._touchDeltaX<-50&&this._next():this._swipingVertical&&(this._touchDeltaY<-50&&!this.drawerOpen?this._toggleDrawer():this._touchDeltaY>50&&this.drawerOpen&&this._toggleDrawer()),this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1}_handleLightboxClick(e){if(!this.drawerOpen)return;const t=this.shadowRoot?.querySelector(".comment-panel");t&&e.composedPath().includes(t)||(this.drawerOpen=!1)}_toggleDrawer(){this.drawerOpen=!this.drawerOpen}_handleBarKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleDrawer())}connectedCallback(){super.connectedCallback(),!this._overlay.isPromoting&&(n._ensureGlobalStyles(),this._pendingRaf=requestAnimationFrame(()=>{this._pendingRaf=null,this.isConnected&&this._attachClickHandlers()}))}static _ensureGlobalStyles(){if(n._globalStylesInjected)return;n._globalStylesInjected=!0;const e=document.createElement("style");e.textContent=`.${n._CLICKABLE_CLASS} { cursor: pointer; }`,document.head.appendChild(e)}updated(e){super.updated(e),e.has("for")&&this._attachClickHandlers()}disconnectedCallback(){super.disconnectedCallback(),!this._overlay.isPromoting&&(this._pendingRaf!==null&&(cancelAnimationFrame(this._pendingRaf),this._pendingRaf=null),this._detachClickHandlers())}_renderCurrentImage(){const e=this._images[this.currentIndex];if(!e)return h;if(e.localImage)return a`
1
+ var c=function(l,e,t,i){var a=arguments.length,s=a<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(l,e,t,i);else for(var n=l.length-1;n>=0;n--)(r=l[n])&&(s=(a<3?r(s):a>3?r(e,t,s):r(e,t))||s);return a>3&&s&&Object.defineProperty(e,t,s),s},d;import{css as I,html as h,nothing as m}from"lit";import{customElement as C,property as y,state as _}from"lit/decorators.js";import{classMap as f}from"lit/directives/class-map.js";import{keyed as D}from"lit/directives/keyed.js";import{styleMap as b}from"lit/directives/style-map.js";import{cancelSVG as k}from"../shared/svgs/cancel.js";import{commentSVG as R}from"../shared/svgs/comment.js";import{leftArrow as O}from"../shared/svgs/left-arrow.js";import{rightArrow as $}from"../shared/svgs/right-arrow.js";import{validImageDimensions as g}from"../image/image-dimensions.js";import{EspalierElementBase as w}from"../shared/esp-element-base.js";import{OverlayController as S}from"../shared/overlay-controller.js";import"../image/esp-image.js";import"../image/esp-image-option.js";import"../button/esp-button.js";function z(l,e){if(!l)return e;const t=Math.min(e.width/l.width,e.height/l.height);return!Number.isFinite(t)||t<=0?e:{width:Math.min(e.width,l.width*t),height:Math.min(e.height,l.height*t)}}let o=d=class extends w{constructor(){super(...arguments),this.isOpen=!1,this.currentIndex=0,this.drawerOpen=!1,this._images=[],this._clickHandlers=new Map,this._clickSetupRaf=null,this._imageMeasureRaf=null,this._galleryObserver=null,this._galleryRefreshRaf=null,this._galleryRefreshInvalidatesDimensions=!1,this._observedGallery=null,this._imageContainerObserver=null,this._observedImageContainer=null,this._observedRenderedImage=null,this._loadedIntrinsicDimensions=null,this._imageDimensions=null,this._overlay=new S({host:this,getFocusTrapContainer:()=>this.shadowRoot?.querySelector(".lightbox")??null}),this._touchStartX=0,this._touchStartY=0,this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1,this.for="",this.commentCount=0,this._scheduleImageMeasurement=()=>{!this.isOpen||this._imageMeasureRaf!==null||(this._imageMeasureRaf=requestAnimationFrame(()=>{this._imageMeasureRaf=null,!(!this.isOpen||!this.isConnected)&&(this._observeRenderedImage(),this._prepareImageDimensions())}))},this._handleViewportChange=()=>{this._prepareImageDimensions(),this._scheduleImageMeasurement()},this._handleRenderedImageLoad=()=>{const e=this._observedRenderedImage;if(!e)return;const t=g(e.naturalWidth,e.naturalHeight);t&&(this._loadedIntrinsicDimensions=t,this._prepareImageDimensions())}}get _commentLabel(){return this.commentCount<=0?"No comments. Add yours!":this.commentCount===1?"1 comment":`${this.commentCount} comments`}open(e){if(this._collectImages(),this._images.length===0)return;const t=Number.isFinite(e)?Math.trunc(e):0,i=Math.max(0,Math.min(t,this._images.length-1));if(this.isOpen){i===this.currentIndex?(this._prepareImageDimensions(),this._scheduleImageMeasurement()):this._goTo(i);return}this.currentIndex=i,this._loadedIntrinsicDimensions=null,this._prepareImageDimensions(),this.isOpen=!0,this.drawerOpen=!1,this._startImageSizing(),this._overlay.open(),this._emitChanged(),this.updateComplete.then(()=>{this.isOpen&&this._overlay.moveFocusInto()})}close(){this.isOpen&&(this.isOpen=!1,this.drawerOpen=!1,this._stopImageSizing(),this._overlay.close())}_viewportDimensions(){const e=document.documentElement.clientWidth||window.innerWidth,t=document.documentElement.clientHeight||window.innerHeight;return g(e,t)??{width:1,height:1}}_availableImageDimensions(){const e=this.shadowRoot?.querySelector(".image-container");if(e){const t=e.getBoundingClientRect(),i=g(t.width,t.height);if(i)return i}return this._viewportDimensions()}_sourceIntrinsicDimensions(e){if(!e)return null;const t=g(e.originalWidth,e.originalHeight);if(t)return t;const i=Array.from(e.children).find(r=>r.tagName==="PICTURE"||r.tagName==="IMG"),s=(i?.tagName==="IMG"?i:i?.querySelector("img"))??e.shadowRoot?.querySelector("img");return s?g(s.naturalWidth,s.naturalHeight)??g(Number(s.getAttribute("width")),Number(s.getAttribute("height"))):null}_prepareImageDimensions(){const e=this._loadedIntrinsicDimensions??this._sourceIntrinsicDimensions(this._images[this.currentIndex]);this._setImageDimensions(z(e,this._availableImageDimensions()))}_setImageDimensions(e){const t=Math.max(1,e.width),i=Math.max(1,e.height);this._imageDimensions&&Math.abs(this._imageDimensions.width-t)<.5&&Math.abs(this._imageDimensions.height-i)<.5||(this._imageDimensions={width:t,height:i})}_responsiveSizes(){return`${Math.max(1,Math.ceil(this._imageDimensions?.width??1))}px`}_startImageSizing(){window.addEventListener("resize",this._handleViewportChange),window.addEventListener("orientationchange",this._handleViewportChange),window.visualViewport?.addEventListener("resize",this._handleViewportChange)}_observeImageContainer(){const e=this.shadowRoot?.querySelector(".image-container")??null;e!==this._observedImageContainer&&(this._imageContainerObserver?.disconnect(),this._imageContainerObserver=null,this._observedImageContainer=e,!(!e||typeof ResizeObserver>"u")&&(this._imageContainerObserver=new ResizeObserver(this._scheduleImageMeasurement),this._imageContainerObserver.observe(e)))}_stopImageSizing(){window.removeEventListener("resize",this._handleViewportChange),window.removeEventListener("orientationchange",this._handleViewportChange),window.visualViewport?.removeEventListener("resize",this._handleViewportChange),this._imageContainerObserver?.disconnect(),this._imageContainerObserver=null,this._observedImageContainer=null,this._stopObservingRenderedImage(),this._imageMeasureRaf!==null&&(cancelAnimationFrame(this._imageMeasureRaf),this._imageMeasureRaf=null)}_observeRenderedImage(){const e=this.shadowRoot?.querySelector(".image-container esp-image"),i=e?.querySelector("img")??null??e?.shadowRoot?.querySelector("img")??null;i!==this._observedRenderedImage&&(this._stopObservingRenderedImage(),this._observedRenderedImage=i,i?.addEventListener("load",this._handleRenderedImageLoad)),i?.complete&&this._handleRenderedImageLoad()}_stopObservingRenderedImage(){this._observedRenderedImage?.removeEventListener("load",this._handleRenderedImageLoad),this._observedRenderedImage=null}_collectImages(){if(!this.for)return this._images=[],null;let e;try{e=document.querySelector(this.for)}catch{return this._images=[],null}return e?(this._images=Array.from(e.querySelectorAll("esp-image")),e):(this._images=[],null)}_attachClickHandlers(e=!1){const t=this._images[this.currentIndex],i=this.currentIndex;this._detachClickHandlers();const a=this._collectImages();if(this._images.forEach((p,x)=>{const v=()=>this.open(x);p.addEventListener("click",v),p.classList.add(d._CLICKABLE_CLASS),this._clickHandlers.set(p,v)}),this._observeGallery(a),!this.isOpen)return;if(this._images.length===0){this.close();return}const s=t?this._images.indexOf(t):-1,r=s>=0?s:Math.min(i,this._images.length-1),n=this._images[r]!==t,u=r!==this.currentIndex;this.currentIndex=r,(n||e)&&(this._loadedIntrinsicDimensions=null),this._prepareImageDimensions(),this.requestUpdate(),(n||u)&&this._emitChanged()}_detachClickHandlers(){for(const[e,t]of this._clickHandlers)e.removeEventListener("click",t),e.classList.remove(d._CLICKABLE_CLASS);this._clickHandlers.clear()}_observeGallery(e){e!==this._observedGallery&&(this._cancelGalleryRefresh(),this._galleryObserver?.disconnect(),this._galleryObserver=null,this._observedGallery=e,!(!e||typeof MutationObserver>"u")&&(this._galleryObserver=new MutationObserver(t=>this._scheduleGalleryRefresh(t)),this._galleryObserver.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["caption","height","local-image","low-res","media","original-height","original-width","src","srcset","type","url","width"]})))}_scheduleGalleryRefresh(e){const t=this._images[this.currentIndex];t&&(this._galleryRefreshInvalidatesDimensions||=e.some(i=>i.type==="attributes"&&i.attributeName==="caption"?!1:i.target===t||t.contains(i.target))),this._galleryRefreshRaf===null&&(this._galleryRefreshRaf=requestAnimationFrame(()=>{if(this._galleryRefreshRaf=null,!this.isConnected)return;const i=this._galleryRefreshInvalidatesDimensions;this._galleryRefreshInvalidatesDimensions=!1,this._attachClickHandlers(i)}))}_cancelGalleryRefresh(){this._galleryRefreshRaf!==null&&(cancelAnimationFrame(this._galleryRefreshRaf),this._galleryRefreshRaf=null),this._galleryRefreshInvalidatesDimensions=!1}_stopObservingGallery(){this._cancelGalleryRefresh(),this._galleryObserver?.disconnect(),this._galleryObserver=null,this._observedGallery=null}_goTo(e){const t=this._images.length;if(t===0)return;const i=(e%t+t)%t;i!==this.currentIndex&&(this.currentIndex=i,this._loadedIntrinsicDimensions=null,this._prepareImageDimensions(),this._scheduleImageMeasurement(),this._emitChanged())}_emitChanged(){this.dispatchEvent(new CustomEvent("esp-lightbox-changed",{detail:{index:this.currentIndex},bubbles:!0,composed:!0}))}_prev(){this._goTo(this.currentIndex-1)}_next(){this._goTo(this.currentIndex+1)}_handleKeyDown(e){if(this.isOpen)switch(e.key){case"Escape":e.preventDefault(),this.close();break;case"ArrowLeft":e.preventDefault(),this._prev();break;case"ArrowRight":e.preventDefault(),this._next();break;case"ArrowUp":e.preventDefault(),this.drawerOpen||this._toggleDrawer();break;case"ArrowDown":e.preventDefault(),this.drawerOpen&&this._toggleDrawer();break;case"Tab":this._overlay.trapFocus(e);break}}_handleTouchStart(e){e.touches.length===1&&(this._touchStartX=e.touches[0].clientX,this._touchStartY=e.touches[0].clientY,this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1)}_handleTouchMove(e){if(e.touches.length!==1)return;const t=e.touches[0].clientX-this._touchStartX,i=e.touches[0].clientY-this._touchStartY;!this._swiping&&!this._swipingVertical&&(Math.abs(t)>10||Math.abs(i)>10)&&(Math.abs(t)>Math.abs(i)?this._swiping=!0:this._swipingVertical=!0),this._swiping?(e.preventDefault(),this._touchDeltaX=t):this._swipingVertical&&(e.preventDefault(),this._touchDeltaY=i)}_handleTouchEnd(){this._swiping?this._touchDeltaX>50?this._prev():this._touchDeltaX<-50&&this._next():this._swipingVertical&&(this._touchDeltaY<-50&&!this.drawerOpen?this._toggleDrawer():this._touchDeltaY>50&&this.drawerOpen&&this._toggleDrawer()),this._touchDeltaX=0,this._touchDeltaY=0,this._swiping=!1,this._swipingVertical=!1}_handleLightboxClick(e){if(!this.drawerOpen)return;const t=this.shadowRoot?.querySelector(".comment-panel");t&&e.composedPath().includes(t)||(this.drawerOpen=!1)}_handleImageContainerClick(e){if(e.target===e.currentTarget){if(this.drawerOpen){this.drawerOpen=!1;return}this.close()}}_toggleDrawer(){this.drawerOpen=!this.drawerOpen}_handleBarKeyDown(e){(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._toggleDrawer())}connectedCallback(){super.connectedCallback(),!this._overlay.isPromoting&&(d._ensureGlobalStyles(),this._clickSetupRaf=requestAnimationFrame(()=>{this._clickSetupRaf=null,this.isConnected&&this._attachClickHandlers()}))}static _ensureGlobalStyles(){if(document.head.querySelector("style[data-esp-lightbox-global-styles]"))return;const e=document.createElement("style");e.dataset.espLightboxGlobalStyles="",e.textContent=`.${d._CLICKABLE_CLASS} { cursor: pointer; }`,document.head.appendChild(e)}updated(e){super.updated(e),e.has("for")&&this._attachClickHandlers(),this.isOpen?(this._observeImageContainer(),this._scheduleImageMeasurement()):this._stopImageSizing()}disconnectedCallback(){if(super.disconnectedCallback(),this._overlay.isPromoting)return;this._clickSetupRaf!==null&&(cancelAnimationFrame(this._clickSetupRaf),this._clickSetupRaf=null);const e=this.isOpen;this._stopImageSizing(),this._stopObservingGallery(),this._detachClickHandlers(),e&&(this.isOpen=!1,this.drawerOpen=!1,this._overlay.close())}_renderCurrentImage(){const e=this._images[this.currentIndex];if(!e)return m;const t=this._responsiveSizes(),i=this._imageDimensions??this._viewportDimensions(),a={width:`${i.width}px`,height:`${i.height}px`};if(e.localImage)return h`
2
2
  <esp-image
3
3
  class="lightbox-image"
4
4
  original-width=${e.originalWidth}
5
5
  original-height=${e.originalHeight}
6
6
  caption=${e.caption}
7
7
  .localImage=${e.localImage}
8
+ .sizes=${t}
9
+ style=${b(a)}
8
10
  ></esp-image>
9
- `;const t=Array.from(e.children).find(s=>s.tagName==="PICTURE"||s.tagName==="IMG");if(t){const s=t.cloneNode(!0);s.querySelectorAll("source").forEach(l=>l.setAttribute("sizes","100vw"));const r=s.tagName==="IMG"?s:s.querySelector("img");return r?.hasAttribute("srcset")&&r.setAttribute("sizes","100vw"),a`
11
+ `;const s=Array.from(e.children).find(n=>n.tagName==="PICTURE"||n.tagName==="IMG");if(s){const n=s.cloneNode(!0);n.querySelectorAll("source").forEach(p=>p.setAttribute("sizes",t));const u=n.tagName==="IMG"?n:n.querySelector("img");return u?.hasAttribute("srcset")&&u.setAttribute("sizes",t),h`
10
12
  <esp-image
11
13
  class="lightbox-image"
12
14
  original-width=${e.originalWidth}
13
15
  original-height=${e.originalHeight}
14
16
  caption=${e.caption}
17
+ .sizes=${t}
18
+ style=${b(a)}
15
19
  >
16
- ${s}
20
+ ${n}
17
21
  </esp-image>
18
- `}const i=Array.from(e.querySelectorAll("esp-image-option"));return a`
22
+ `}const r=Array.from(e.querySelectorAll("esp-image-option"));return h`
19
23
  <esp-image
20
24
  class="lightbox-image"
21
25
  original-width=${e.originalWidth}
22
26
  original-height=${e.originalHeight}
23
27
  low-res=${e.imageUrl}
24
28
  caption=${e.caption}
29
+ .sizes=${t}
30
+ style=${b(a)}
25
31
  >
26
- ${i.map(s=>a`
32
+ ${r.map(n=>h`
27
33
  <esp-image-option
28
- width=${s.width}
29
- url=${s.imageUrl}
30
- type=${s.type||h}
34
+ width=${n.width}
35
+ url=${n.imageUrl}
36
+ type=${n.type||m}
31
37
  ></esp-image-option>
32
38
  `)}
33
39
  </esp-image>
34
- `}render(){if(!this.isOpen)return h;const t=this._images[this.currentIndex]?.caption??"",i=this._images.length;return a`
40
+ `}render(){if(!this.isOpen)return m;const e=this._images[this.currentIndex],t=e?.caption??"",i=this._images.length;return h`
35
41
  <div
36
42
  class="lightbox"
37
43
  role="dialog"
@@ -55,10 +61,10 @@ var c=function(d,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnP
55
61
  label="Close lightbox"
56
62
  @clicked=${this.close}
57
63
  >
58
- ${x}
64
+ ${k}
59
65
  </esp-button>
60
66
 
61
- ${i>1?a`
67
+ ${i>1?h`
62
68
  <esp-button
63
69
  class="prev-btn"
64
70
  icon-only
@@ -66,7 +72,7 @@ var c=function(d,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnP
66
72
  label="Previous image"
67
73
  @clicked=${this._prev}
68
74
  >
69
- ${y}
75
+ ${O}
70
76
  </esp-button>
71
77
  <esp-button
72
78
  class="next-btn"
@@ -75,29 +81,31 @@ var c=function(d,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnP
75
81
  label="Next image"
76
82
  @clicked=${this._next}
77
83
  >
78
- ${k}
84
+ ${$}
79
85
  </esp-button>
80
- `:h}
86
+ `:m}
81
87
 
82
88
 
83
- <div class="image-container">${v(this.currentIndex,this._renderCurrentImage())}</div>
89
+ <div class="image-container" @click=${this._handleImageContainerClick}>
90
+ ${D(e,this._renderCurrentImage())}
91
+ </div>
84
92
 
85
- <div class=${g({"comment-panel":!0,open:this.drawerOpen})}>
93
+ <div class=${f({"comment-panel":!0,open:this.drawerOpen})}>
86
94
  <div class="comment-bar">
87
- ${i>1?a`
95
+ ${i>1?h`
88
96
 
89
97
  <nav class="dots" aria-label="Image navigation">
90
- ${this._images.map((s,r)=>a`
98
+ ${this._images.map((a,s)=>h`
91
99
  <button
92
100
  type="button"
93
- class=${g({dot:!0,active:r===this.currentIndex})}
94
- aria-label="Image ${r+1} of ${i}"
95
- aria-current=${r===this.currentIndex?"true":"false"}
96
- @click=${()=>this._goTo(r)}
101
+ class=${f({dot:!0,active:s===this.currentIndex})}
102
+ aria-label="Image ${s+1} of ${i}"
103
+ aria-current=${s===this.currentIndex?"true":"false"}
104
+ @click=${()=>this._goTo(s)}
97
105
  ></button>
98
106
  `)}
99
107
  </nav>
100
- `:h}
108
+ `:m}
101
109
  <div
102
110
  class="comment-bar-toggle"
103
111
  role="button"
@@ -107,252 +115,259 @@ var c=function(d,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnP
107
115
  @click=${this._toggleDrawer}
108
116
  @keydown=${this._handleBarKeyDown}
109
117
  >
110
- <span class="comment-bar-icon">${w}</span>
118
+ <span class="comment-bar-icon">${R}</span>
111
119
  <span class="comment-bar-label">${this._commentLabel}</span>
112
- <span class=${g({"comment-bar-caret":!0,open:this.drawerOpen})}>
113
- ${C}
120
+ <span class=${f({"comment-bar-caret":!0,open:this.drawerOpen})}>
121
+ ${M}
114
122
  </span>
115
123
  </div>
116
124
  </div>
117
125
  <div class="drawer-body" id="drawer-body">
118
- ${t?a`<div class="caption">${t}</div>`:h}
126
+ ${t?h`<div class="caption">${t}</div>`:m}
119
127
  <slot name="comments"></slot>
120
128
  </div>
121
129
  </div>
122
130
  </div>
123
- `}};o._CLICKABLE_CLASS="esp-lightbox-clickable",o._globalStylesInjected=!1,o.styles=b`
124
- :host {
125
- display: contents;
126
- }
127
-
128
- .lightbox {
129
- position: fixed;
130
- inset: 0;
131
- z-index: 10000;
132
- display: flex;
133
- align-items: center;
134
- justify-content: center;
135
- outline: none;
136
- overflow: hidden;
137
- }
138
-
139
- .backdrop {
140
- position: fixed;
141
- inset: 0;
142
- background: var(--esp-lightbox-bg, var(--esp-vellum-background, var(--esp-color-layer-3)));
143
- opacity: var(--esp-lightbox-bg-opacity, var(--esp-vellum-opacity, 0.85));
144
- z-index: 0;
145
- }
146
-
147
- .backdrop-image {
148
- position: fixed;
149
- inset: 0;
150
- background-image: var(--esp-vellum-background-image, none);
151
- background-repeat: repeat;
152
- opacity: var(--esp-vellum-background-image-opacity, 0.3);
153
- z-index: 0;
154
- pointer-events: none;
155
- }
156
-
157
-
158
-
159
- .close-btn,
160
- .prev-btn,
161
- .next-btn {
162
- position: absolute;
163
- z-index: 2;
164
- opacity: 0.7;
165
- transition: opacity 0.2s;
166
-
167
- &:hover,
168
- &:focus-within {
169
- opacity: 1;
131
+ `}};o._CLICKABLE_CLASS="esp-lightbox-clickable",o.styles=[...w.styles,I`
132
+ :host {
133
+ display: contents;
170
134
  }
171
- }
172
-
173
- .close-btn {
174
- top: var(--esp-size-small);
175
- right: var(--esp-size-small);
176
- }
177
-
178
- .prev-btn {
179
- left: var(--esp-size-small);
180
- top: 50%;
181
- transform: translateY(-50%);
182
- }
183
-
184
- .next-btn {
185
- right: var(--esp-size-small);
186
- top: 50%;
187
- transform: translateY(-50%);
188
- }
189
-
190
-
191
-
192
- .image-container {
193
- width: 100%;
194
- height: 100%;
195
- display: flex;
196
- align-items: center;
197
- justify-content: center;
198
- z-index: 1;
199
- }
200
-
201
- .image-container esp-image {
202
- --esp-image-border: none;
203
- max-width: 100%;
204
- max-height: 100%;
205
- width: auto;
206
- height: auto;
207
- border-radius: 0;
208
- }
209
-
210
-
211
-
212
- .comment-panel {
213
- position: fixed;
214
- bottom: 0;
215
- left: 0;
216
- right: 0;
217
- z-index: 3;
218
- display: flex;
219
- flex-direction: column;
220
-
221
- transform: translateY(calc(100% - var(--_bar-height)));
222
- transition: transform 0.3s ease;
223
135
 
224
- --_bar-height: calc(3 * var(--esp-size-small));
136
+ .lightbox {
137
+ position: fixed;
138
+ inset: 0;
139
+ z-index: 10000;
140
+ display: flex;
141
+ align-items: center;
142
+ justify-content: center;
143
+ outline: none;
144
+ overflow: hidden;
145
+ }
225
146
 
226
- &:has(.dots) {
227
- --_bar-height: calc(4.875 * var(--esp-size-small));
147
+ .backdrop {
148
+ position: fixed;
149
+ inset: 0;
150
+ background: var(--esp-lightbox-bg, var(--esp-vellum-background, var(--esp-color-layer-3)));
151
+ opacity: var(--esp-lightbox-bg-opacity, var(--esp-vellum-opacity, 0.85));
152
+ z-index: 0;
228
153
  }
229
154
 
230
- &.open {
231
- transform: translateY(0);
155
+ .backdrop-image {
156
+ position: fixed;
157
+ inset: 0;
158
+ background-image: var(--esp-vellum-background-image, none);
159
+ background-repeat: repeat;
160
+ opacity: var(--esp-vellum-background-image-opacity, 0.3);
161
+ z-index: 0;
162
+ pointer-events: none;
232
163
  }
233
- }
234
-
235
- .comment-bar {
236
- display: flex;
237
- flex-direction: column;
238
- width: 100%;
239
- background: oklch(from var(--esp-color-layer-3) l c h / 0.85);
240
- color: var(--esp-color-text);
241
- border-top: 1px solid var(--esp-color-border);
242
- box-shadow: 0 -2px 6px var(--esp-color-shadow);
243
- box-sizing: border-box;
244
- }
245
-
246
-
247
-
248
- .dots {
249
- display: flex;
250
- gap: var(--esp-size-tiny);
251
- align-items: center;
252
- justify-content: center;
253
- padding: var(--esp-size-tiny) 0;
254
- }
255
-
256
- .dot {
257
- width: 10px;
258
- height: 10px;
259
- border-radius: 50%;
260
- border: 2px solid oklch(from var(--esp-color-text) l c h / 0.6);
261
- background: transparent;
262
- padding: 0;
263
- cursor: pointer;
264
- transition:
265
- background 0.2s,
266
- border-color 0.2s;
267
-
268
- &.active {
269
- background: var(--esp-color-text);
270
- border-color: var(--esp-color-text);
164
+
165
+
166
+
167
+ .close-btn,
168
+ .prev-btn,
169
+ .next-btn {
170
+ position: absolute;
171
+ z-index: 2;
172
+ opacity: 0.7;
173
+ transition: opacity 0.2s;
174
+
175
+ &:hover,
176
+ &:focus-within {
177
+ opacity: 1;
178
+ }
271
179
  }
272
180
 
273
- &:hover {
274
- border-color: var(--esp-color-text);
181
+ .close-btn {
182
+ top: var(--esp-size-small);
183
+ right: var(--esp-size-small);
275
184
  }
276
185
 
277
- &:focus-visible {
278
- outline: 2px solid var(--esp-color-text);
279
- outline-offset: 2px;
186
+ .prev-btn {
187
+ left: var(--esp-size-small);
188
+ top: 50%;
189
+ transform: translateY(-50%);
280
190
  }
281
- }
282
-
283
- .comment-bar-toggle {
284
- display: flex;
285
- align-items: center;
286
- justify-content: center;
287
- gap: var(--esp-size-tiny);
288
- height: calc(3 * var(--esp-size-small));
289
- padding: 0 var(--esp-size-small);
290
- font-size: var(--esp-type-small);
291
- cursor: pointer;
292
-
293
- &:focus-visible {
294
- outline: 2px solid var(--esp-color-text);
295
- outline-offset: -2px;
191
+
192
+ .next-btn {
193
+ right: var(--esp-size-small);
194
+ top: 50%;
195
+ transform: translateY(-50%);
296
196
  }
297
- }
298
197
 
299
- .comment-bar-icon {
300
- display: flex;
301
- width: var(--esp-size-font);
302
- height: var(--esp-size-font);
198
+
303
199
 
304
- & svg {
200
+ .image-container {
305
201
  width: 100%;
306
202
  height: 100%;
203
+ display: flex;
204
+ align-items: center;
205
+ justify-content: center;
206
+ z-index: 1;
307
207
  }
308
- }
309
-
310
- .comment-bar-label {
311
- font-weight: 500;
312
- }
313
208
 
314
- .comment-bar-caret {
315
- display: flex;
316
- width: var(--esp-size-small);
317
- height: var(--esp-size-small);
318
- transition: transform 0.3s ease;
209
+ .image-container esp-image {
210
+ --esp-image-border: none;
211
+ --_esp-image-object-fit: contain;
212
+ flex: none;
213
+ border-radius: 0;
214
+ }
319
215
 
320
- & svg {
216
+ .image-container esp-image > picture,
217
+ .image-container esp-image > img,
218
+ .image-container esp-image > picture > img {
219
+ display: block;
321
220
  width: 100%;
322
221
  height: 100%;
222
+ object-fit: contain;
223
+ }
224
+
225
+
226
+
227
+ .comment-panel {
228
+ position: fixed;
229
+ bottom: 0;
230
+ left: 0;
231
+ right: 0;
232
+ z-index: 3;
233
+ display: flex;
234
+ flex-direction: column;
235
+
236
+ transform: translateY(calc(100% - var(--_bar-height)));
237
+ transition: transform 0.3s ease;
238
+
239
+ --_bar-height: calc(3 * var(--esp-size-small));
240
+
241
+ &:has(.dots) {
242
+ --_bar-height: calc(4.875 * var(--esp-size-small));
243
+ }
244
+
245
+ &.open {
246
+ transform: translateY(0);
247
+ }
323
248
  }
324
249
 
325
- &.open {
326
- transform: rotate(180deg);
250
+ .comment-bar {
251
+ display: flex;
252
+ flex-direction: column;
253
+ width: 100%;
254
+ background: oklch(from var(--esp-color-layer-3) l c h / 0.85);
255
+ color: var(--esp-color-text);
256
+ border-top: 1px solid var(--esp-color-border);
257
+ box-shadow: 0 -2px 6px var(--esp-color-shadow);
258
+ box-sizing: border-box;
327
259
  }
328
- }
329
-
330
- .drawer-body {
331
- background: oklch(from var(--esp-color-layer-3) l c h / 0.85);
332
- color: var(--esp-color-text);
333
- overflow-y: auto;
334
- max-height: 40vh;
335
- padding: var(--esp-size-small);
336
- box-sizing: border-box;
337
- }
338
-
339
- .caption {
340
- color: var(--esp-color-text);
341
- font-size: var(--esp-type-small);
342
- line-height: 1.4;
343
- margin-bottom: var(--esp-size-tiny);
344
- text-align: center;
345
- }
346
-
347
-
348
-
349
- @media screen and (max-width: 600px) {
350
- .prev-btn,
351
- .next-btn {
352
- display: none;
260
+
261
+
262
+
263
+ .dots {
264
+ display: flex;
265
+ gap: var(--esp-size-tiny);
266
+ align-items: center;
267
+ justify-content: center;
268
+ padding: var(--esp-size-tiny) 0;
269
+ }
270
+
271
+ .dot {
272
+ width: 10px;
273
+ height: 10px;
274
+ border-radius: 50%;
275
+ border: 2px solid oklch(from var(--esp-color-text) l c h / 0.6);
276
+ background: transparent;
277
+ padding: 0;
278
+ cursor: pointer;
279
+ transition:
280
+ background 0.2s,
281
+ border-color 0.2s;
282
+
283
+ &.active {
284
+ background: var(--esp-color-text);
285
+ border-color: var(--esp-color-text);
286
+ }
287
+
288
+ &:hover {
289
+ border-color: var(--esp-color-text);
290
+ }
291
+
292
+ &:focus-visible {
293
+ outline: 2px solid var(--esp-color-text);
294
+ outline-offset: 2px;
295
+ }
296
+ }
297
+
298
+ .comment-bar-toggle {
299
+ display: flex;
300
+ align-items: center;
301
+ justify-content: center;
302
+ gap: var(--esp-size-tiny);
303
+ height: calc(3 * var(--esp-size-small));
304
+ padding: 0 var(--esp-size-small);
305
+ font-size: var(--esp-type-small);
306
+ cursor: pointer;
307
+
308
+ &:focus-visible {
309
+ outline: 2px solid var(--esp-color-text);
310
+ outline-offset: -2px;
311
+ }
312
+ }
313
+
314
+ .comment-bar-icon {
315
+ display: flex;
316
+ width: var(--esp-size-font);
317
+ height: var(--esp-size-font);
318
+
319
+ & svg {
320
+ width: 100%;
321
+ height: 100%;
322
+ }
323
+ }
324
+
325
+ .comment-bar-label {
326
+ font-weight: 500;
327
+ }
328
+
329
+ .comment-bar-caret {
330
+ display: flex;
331
+ width: var(--esp-size-small);
332
+ height: var(--esp-size-small);
333
+ transition: transform 0.3s ease;
334
+
335
+ & svg {
336
+ width: 100%;
337
+ height: 100%;
338
+ }
339
+
340
+ &.open {
341
+ transform: rotate(180deg);
342
+ }
343
+ }
344
+
345
+ .drawer-body {
346
+ background: oklch(from var(--esp-color-layer-3) l c h / 0.85);
347
+ color: var(--esp-color-text);
348
+ overflow-y: auto;
349
+ max-height: 40vh;
350
+ padding: var(--esp-size-small);
351
+ box-sizing: border-box;
352
+ }
353
+
354
+ .caption {
355
+ color: var(--esp-color-text);
356
+ font-size: var(--esp-type-small);
357
+ line-height: 1.4;
358
+ margin-bottom: var(--esp-size-tiny);
359
+ text-align: center;
360
+ }
361
+
362
+
363
+
364
+ @media screen and (max-width: 600px) {
365
+ .prev-btn,
366
+ .next-btn {
367
+ display: none;
368
+ }
353
369
  }
354
- }
355
- `,c([m()],o.prototype,"isOpen",void 0),c([m()],o.prototype,"currentIndex",void 0),c([m()],o.prototype,"drawerOpen",void 0),c([u({type:String})],o.prototype,"for",void 0),c([u({attribute:"comment-count",type:Number})],o.prototype,"commentCount",void 0),o=n=c([_("esp-lightbox")],o);const C=a` <svg
370
+ `],c([_()],o.prototype,"isOpen",void 0),c([_()],o.prototype,"currentIndex",void 0),c([_()],o.prototype,"drawerOpen",void 0),c([_()],o.prototype,"_imageDimensions",void 0),c([y({type:String})],o.prototype,"for",void 0),c([y({attribute:"comment-count",type:Number})],o.prototype,"commentCount",void 0),o=d=c([C("esp-lightbox")],o);const M=h` <svg
356
371
  xmlns="http://www.w3.org/2000/svg"
357
372
  viewBox="0 0 24 24"
358
373
  fill="none"
@@ -1 +1 @@
1
- var a=function(c,t,e,s){var o=arguments.length,i=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,t,e,s);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(i=(o<3?n(i):o>3?n(t,e,i):n(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i};import{createRef as u}from"lit/directives/ref.js";import{EspalierElementBase as d}from"../shared/esp-element-base.js";import{property as h,state as m}from"lit/decorators.js";import{EspalierPickerItem as f}from"./esp-picker-item.js";import{PopoverController as g}from"../shared/popover-controller.js";import{FormFieldController as v}from"../shared/form-field-controller.js";class r extends d{constructor(){super(...arguments),this.internals=this.attachInternals(),this.formCtrl=new v({host:this,internals:this.internals,getFormValue:()=>this.getPickerFormValue(),getValidity:()=>this.getPickerValidity(),onReset:()=>this.handlePickerReset(),onRestore:t=>this.handlePickerRestore(t),onDisabled:t=>{this.disabled=t}}),this._showOptions=!1,this.itemsSlot=u(),this.pickerMenu=u(),this.theInput=u(),this._lastViewportHeight=0,this.popoverCtrl=new g({host:this,closeStrategy:"source-identity",isOpen:()=>this._showOptions,onShouldClose:()=>{this.showOptions=!1},onPositionUpdate:()=>{this.pickerMenu.value?.updatePosition(this);const t=window.innerHeight||document.documentElement.clientHeight;if(this._lastViewportHeight!==0&&t!==this._lastViewportHeight){const e=this._lastViewportHeight-t;e>=r.KEYBOARD_THRESHOLD?(this._scrollToContainPopover(),this._lastViewportHeight=t):e<0&&(this._lastViewportHeight=t)}},getInsideElements:()=>[this.pickerMenu.value??null],onOutsideClick:()=>{this.showOptions=!1}}),this.name="",this.required=!1,this.requiredMessage="",this.disabled=!1,this.pickerItems=[],this.placeholder="Choose...",this.width="",this._slotExtractPending=!1}getPickerFormValue(){return null}getPickerValidity(){return null}handlePickerReset(){}handlePickerRestore(t){}formResetCallback(){this.formCtrl.handleFormReset()}formStateRestoreCallback(t){this.formCtrl.handleFormStateRestore(t)}formDisabledCallback(t){this.formCtrl.handleFormDisabled(t)}get showOptions(){return this._showOptions}set showOptions(t){if(t&&this.disabled)return;this._showOptions=t;const e=this.theInput.value;e&&(e.ariaExpanded=String(t)),t&&this.pickerMenu.value?(this.popoverCtrl.publishCloseOthers(),this.pickerMenu.value.positionSelf(this),this._lastViewportHeight=window.innerHeight||document.documentElement.clientHeight,this.clearActiveDescendant(),this.popoverCtrl.startTracking(),this.popoverCtrl.startOutsideClick()):!t&&this.pickerMenu.value&&(this.popoverCtrl.stopTracking(),this.popoverCtrl.stopOutsideClick(),this.pickerMenu.value.hideMenu(),this.clearActiveDescendant(),this._lastViewportHeight=0)}focus(){this.theInput.value?.focus()}validate(){this.formCtrl.validate()}checkValidity(){return this.formCtrl.checkValidity()}updateActiveDescendant(){const t=this.theInput.value;if(!t||!this.pickerMenu.value)return;const e=this.pickerMenu.value.getHighlightedElement();t.ariaActiveDescendantElement=e}clearActiveDescendant(){const t=this.theInput.value;t&&(t.ariaActiveDescendantElement=null)}_scrollToContainPopover(){const t=this.pickerMenu.value;if(!t)return;const e=t.getBoundingClientRect(),s=this.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,i=Math.min(s.top,e.top),n=Math.max(s.bottom,e.bottom),l=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";if(n>o){const p=n-o;window.scrollBy({top:p+8,behavior:l}),requestAnimationFrame(()=>{this.pickerMenu.value?.updatePosition(this)})}else i<0&&(window.scrollBy({top:i-8,behavior:l}),requestAnimationFrame(()=>{this.pickerMenu.value?.updatePosition(this)}))}updated(t){super.updated(t),t.has("width")&&(this.width?this.style.width=this.width:this.style.removeProperty("width"))}firstUpdated(t){super.firstUpdated(t);const e=this.theInput.value;if(e&&(e.role="combobox",e.ariaHasPopup="listbox",e.ariaExpanded="false",e.ariaAutoComplete="none",this.pickerMenu.value)){const o=e;o.ariaControlsElements=[this.pickerMenu.value]}const s=this.itemsSlot.value;s&&(this.extractSlotItems(s),s.addEventListener("slotchange",()=>this.extractSlotItems(s)))}extractSlotItems(t){this._slotExtractPending||(this._slotExtractPending=!0,queueMicrotask(()=>{this._slotExtractPending=!1;const e=t.assignedElements();if(e.length===0)return;const s=[];for(const o of e){if(!(o instanceof f))throw new Error(`Picker items must be of type esp-picker-item, but got <${o.tagName.toLowerCase()}>`);const i=o,n=Array.from(i.childNodes),l=n.length>0?n.map(p=>p.cloneNode(!0)):void 0;s.push({text:i.text||i.getAttribute("text")||i.textContent?.trim()||"",value:i.value||i.getAttribute("value")||"",selected:i.selected||i.hasAttribute("selected"),icon:i.icon||i.getAttribute("icon")||"",styles:i.styles,slotNodes:l})}this.pickerItems=s;for(const o of e)o.remove()}))}}r.formAssociated=!0,r.KEYBOARD_THRESHOLD=150,a([m()],r.prototype,"showOptions",null),a([h({type:String,reflect:!0})],r.prototype,"name",void 0),a([h({type:Boolean,reflect:!0})],r.prototype,"required",void 0),a([h({attribute:"required-message"})],r.prototype,"requiredMessage",void 0),a([h({type:Boolean,reflect:!0})],r.prototype,"disabled",void 0),a([h({type:Array})],r.prototype,"pickerItems",void 0),a([h({type:String})],r.prototype,"placeholder",void 0),a([h({type:String})],r.prototype,"width",void 0);export{r as EspalierPickerBase};
1
+ var a=function(c,t,e,s){var o=arguments.length,i=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,t,e,s);else for(var l=c.length-1;l>=0;l--)(n=c[l])&&(i=(o<3?n(i):o>3?n(t,e,i):n(t,e))||i);return o>3&&i&&Object.defineProperty(t,e,i),i};import{createRef as u}from"lit/directives/ref.js";import{EspalierElementBase as d}from"../shared/esp-element-base.js";import{property as h,state as m}from"lit/decorators.js";import{EspalierPickerItem as f}from"./esp-picker-item.js";import{PopoverController as g}from"../shared/popover-controller.js";import{FormFieldController as v}from"../shared/form-field-controller.js";import{FormFieldDescriptionController as w}from"../shared/form-field-description-controller.js";class r extends d{constructor(){super(...arguments),this.internals=this.attachInternals(),this.formCtrl=new v({host:this,internals:this.internals,getFormValue:()=>this.getPickerFormValue(),getValidity:()=>this.getPickerValidity(),onReset:()=>this.handlePickerReset(),onRestore:t=>this.handlePickerRestore(t),onDisabled:t=>{this.disabled=t}}),this.formItemDescription=new w({host:this,getTarget:()=>this.theInput.value}),this._showOptions=!1,this.itemsSlot=u(),this.pickerMenu=u(),this.theInput=u(),this._lastViewportHeight=0,this.popoverCtrl=new g({host:this,closeStrategy:"source-identity",isOpen:()=>this._showOptions,onShouldClose:()=>{this.showOptions=!1},onPositionUpdate:()=>{this.pickerMenu.value?.updatePosition(this);const t=window.innerHeight||document.documentElement.clientHeight;if(this._lastViewportHeight!==0&&t!==this._lastViewportHeight){const e=this._lastViewportHeight-t;e>=r.KEYBOARD_THRESHOLD?(this._scrollToContainPopover(),this._lastViewportHeight=t):e<0&&(this._lastViewportHeight=t)}},getInsideElements:()=>[this.pickerMenu.value??null],onOutsideClick:()=>{this.showOptions=!1}}),this.name="",this.required=!1,this.requiredMessage="",this.disabled=!1,this.pickerItems=[],this.placeholder="Choose...",this.width="",this._slotExtractPending=!1}getPickerFormValue(){return null}getPickerValidity(){return null}handlePickerReset(){}handlePickerRestore(t){}formResetCallback(){this.formCtrl.handleFormReset()}formStateRestoreCallback(t){this.formCtrl.handleFormStateRestore(t)}formDisabledCallback(t){this.formCtrl.handleFormDisabled(t)}get showOptions(){return this._showOptions}set showOptions(t){if(t&&this.disabled)return;this._showOptions=t;const e=this.theInput.value;e&&(e.ariaExpanded=String(t)),t&&this.pickerMenu.value?(this.popoverCtrl.publishCloseOthers(),this.pickerMenu.value.positionSelf(this),this._lastViewportHeight=window.innerHeight||document.documentElement.clientHeight,this.clearActiveDescendant(),this.popoverCtrl.startTracking(),this.popoverCtrl.startOutsideClick()):!t&&this.pickerMenu.value&&(this.popoverCtrl.stopTracking(),this.popoverCtrl.stopOutsideClick(),this.pickerMenu.value.hideMenu(),this.clearActiveDescendant(),this._lastViewportHeight=0)}focus(){this.theInput.value?.focus()}setFormItemDescription(t){this.formItemDescription.setDescription(t)}validate(){this.formCtrl.validate()}checkValidity(){return this.formCtrl.checkValidity()}updateActiveDescendant(){const t=this.theInput.value;if(!t||!this.pickerMenu.value)return;const e=this.pickerMenu.value.getHighlightedElement();t.ariaActiveDescendantElement=e}clearActiveDescendant(){const t=this.theInput.value;t&&(t.ariaActiveDescendantElement=null)}_scrollToContainPopover(){const t=this.pickerMenu.value;if(!t)return;const e=t.getBoundingClientRect(),s=this.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,i=Math.min(s.top,e.top),n=Math.max(s.bottom,e.bottom),l=window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth";if(n>o){const p=n-o;window.scrollBy({top:p+8,behavior:l}),requestAnimationFrame(()=>{this.pickerMenu.value?.updatePosition(this)})}else i<0&&(window.scrollBy({top:i-8,behavior:l}),requestAnimationFrame(()=>{this.pickerMenu.value?.updatePosition(this)}))}updated(t){super.updated(t),t.has("width")&&(this.width?this.style.width=this.width:this.style.removeProperty("width"))}firstUpdated(t){super.firstUpdated(t);const e=this.theInput.value;if(e&&(e.role="combobox",e.ariaHasPopup="listbox",e.ariaExpanded="false",e.ariaAutoComplete="none",this.pickerMenu.value)){const o=e;o.ariaControlsElements=[this.pickerMenu.value]}const s=this.itemsSlot.value;s&&(this.extractSlotItems(s),s.addEventListener("slotchange",()=>this.extractSlotItems(s)))}extractSlotItems(t){this._slotExtractPending||(this._slotExtractPending=!0,queueMicrotask(()=>{this._slotExtractPending=!1;const e=t.assignedElements();if(e.length===0)return;const s=[];for(const o of e){if(!(o instanceof f))throw new Error(`Picker items must be of type esp-picker-item, but got <${o.tagName.toLowerCase()}>`);const i=o,n=Array.from(i.childNodes),l=n.length>0?n.map(p=>p.cloneNode(!0)):void 0;s.push({text:i.text||i.getAttribute("text")||i.textContent?.trim()||"",value:i.value||i.getAttribute("value")||"",selected:i.selected||i.hasAttribute("selected"),icon:i.icon||i.getAttribute("icon")||"",styles:i.styles,slotNodes:l})}this.pickerItems=s;for(const o of e)o.remove()}))}}r.formAssociated=!0,r.KEYBOARD_THRESHOLD=150,a([m()],r.prototype,"showOptions",null),a([h({type:String,reflect:!0})],r.prototype,"name",void 0),a([h({type:Boolean,reflect:!0})],r.prototype,"required",void 0),a([h({attribute:"required-message"})],r.prototype,"requiredMessage",void 0),a([h({type:Boolean,reflect:!0})],r.prototype,"disabled",void 0),a([h({type:Array})],r.prototype,"pickerItems",void 0),a([h({type:String})],r.prototype,"placeholder",void 0),a([h({type:String})],r.prototype,"width",void 0);export{r as EspalierPickerBase};
@@ -172,7 +172,8 @@ import { EspalierElementBase } from "../shared/esp-element-base.js";
172
172
  * progress ring in circle mode. Automatically set by the `size`
173
173
  * attribute.
174
174
  * @cssprop --esp-progress-fill-color - Color of the progress fill.
175
- * Defaults to `var(--esp-color-action-background)`.
175
+ * Defaults to the active action hue at the semantic muted lightness so the
176
+ * filled and unfilled portions remain distinguishable in light and dark themes.
176
177
  * @cssprop --esp-progress-font-size - Font size for the value
177
178
  * text. Defaults to `var(--esp-type-small)`.
178
179
  * @cssprop --esp-progress-height - Height of the progress bar track.