@taprootio/espalier 6.2.0 → 6.4.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 +16 -0
- package/README.md +5 -5
- package/custom-elements.json +1498 -778
- package/dist/action-menu/esp-action-menu-item.js +1 -0
- package/dist/action-menu/esp-action-menu.js +4 -3
- package/dist/box/esp-box.d.ts +49 -3
- package/dist/box/esp-box.js +26 -11
- package/dist/button/esp-button.d.ts +4 -4
- package/dist/date-picker/helpers/styles.js +1 -0
- package/dist/details/esp-details.d.ts +3 -0
- package/dist/details/esp-details.js +13 -6
- package/dist/dialog/esp-dialog.d.ts +82 -2
- package/dist/dialog/esp-dialog.js +71 -59
- package/dist/flyout/esp-flyout.d.ts +2 -2
- package/dist/flyout/esp-flyout.js +6 -5
- package/dist/focus-picker/esp-focus-picker.js +3 -2
- package/dist/footer/esp-footer.d.ts +3 -3
- package/dist/footer/esp-footer.js +10 -10
- package/dist/grid/esp-grid.d.ts +3 -0
- package/dist/grid/esp-grid.js +25 -17
- package/dist/header/esp-header-button.d.ts +6 -15
- package/dist/header/esp-header.d.ts +4 -2
- package/dist/header/esp-header.js +8 -7
- package/dist/image-picker/esp-image-picker.js +1 -0
- package/dist/image-upload/esp-image-upload.js +1 -0
- package/dist/info/esp-info.d.ts +3 -1
- package/dist/info/esp-info.js +8 -8
- package/dist/lightbox/esp-lightbox.d.ts +3 -0
- package/dist/lightbox/esp-lightbox.js +12 -9
- package/dist/menu/esp-menu-group.js +6 -2
- package/dist/menu/esp-menu-item.js +7 -3
- package/dist/menu/esp-menu.js +4 -2
- package/dist/page/esp-page.d.ts +1 -1
- package/dist/page/esp-page.styles.js +1 -0
- package/dist/pickers/esp-pick-one.d.ts +1 -2
- package/dist/pickers/esp-pick-some.d.ts +1 -1
- package/dist/pickers/esp-picker-item.js +9 -5
- package/dist/pickers/esp-picker-menu.js +2 -0
- package/dist/popover/esp-popover.d.ts +2 -4
- package/dist/repeater/esp-repeater.js +1 -0
- package/dist/root/esp-root.d.ts +4 -4
- package/dist/root/esp-root.js +5 -3
- package/dist/row/esp-row.d.ts +1 -2
- package/dist/search/esp-search.js +2 -0
- package/dist/section/esp-section.d.ts +1 -1
- package/dist/section/esp-section.js +2 -1
- package/dist/shared/configured-brand.d.ts +11 -37
- package/dist/shared/esp-element-base.d.ts +4 -1
- package/dist/shared/esp-element-base.js +27 -30
- package/dist/shared/justified-layout.d.ts +6 -18
- package/dist/shared/surface-layer.d.ts +12 -0
- package/dist/shared/surface-layer.js +10 -0
- package/dist/shared/theme.d.ts +7 -18
- package/dist/slider/esp-slider.d.ts +2 -4
- package/dist/stack/esp-stack.d.ts +1 -2
- package/dist/switch/esp-switch.d.ts +2 -4
- package/dist/tabs/esp-tab-group.d.ts +3 -0
- package/dist/tabs/esp-tab-group.js +7 -7
- package/dist/tooltip/esp-tooltip.js +1 -0
- package/dist/tree/esp-tree.d.ts +0 -5
- package/dist/tree/esp-tree.js +3 -0
- package/espalier.css-data.json +17 -1
- package/espalier.token-manifest.json +25 -1
- package/licenses/README.md +18 -15
- package/package.json +5 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(u,e,t,s);else for(var i=u.length-1;i>=0;i--)(n=u[i])&&(r=(o<3?n(r):o>3?n(e,t,r):n(e,t))||r);return o>3&&r&&Object.defineProperty(e,t,r),r};import{css as p,html as w,nothing as S,unsafeCSS as F}from"lit";import{customElement as L,property as h}from"lit/decorators.js";import{classMap as G}from"lit/directives/class-map.js";import{createRef as M,ref as q}from"lit/directives/ref.js";import{EspalierElementBase as A}from"../shared/esp-element-base.js";import{ESP_EVENTS as f}from"../shared/events.js";import{getEspBus as
|
|
1
|
+
var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(u,e,t,s);else for(var i=u.length-1;i>=0;i--)(n=u[i])&&(r=(o<3?n(r):o>3?n(e,t,r):n(e,t))||r);return o>3&&r&&Object.defineProperty(e,t,r),r};import{css as p,html as w,nothing as S,unsafeCSS as F}from"lit";import{customElement as L,property as h}from"lit/decorators.js";import{classMap as G}from"lit/directives/class-map.js";import{createRef as M,ref as q}from"lit/directives/ref.js";import{EspalierElementBase as A}from"../shared/esp-element-base.js";import{ESP_EVENTS as f}from"../shared/events.js";import{getEspBus as y}from"../shared/bus-events.js";import{FLYOUT_FULL_HEIGHT_REQUEST_EVENT as k,markFlyoutRequestServiced as H}from"../shared/flyout-events.js";import{OverlayController as B}from"../shared/overlay-controller.js";import{cancelSVG as V}from"../shared/svgs/cancel.js";import{traverseToClosest as v}from"../shared/utilities.js";import{RafThrottle as $}from"../shared/raf-throttle.js";import{COMPACT_VIEWPORT_MEDIA_QUERY as R}from"../shared/responsive.js";import{focusRing as I,quietCloseButton as Y}from"../shared/style-fragments.js";const D=R,U="Flyout",E=p`
|
|
2
2
|
position: fixed;
|
|
3
3
|
inset: 0;
|
|
4
4
|
margin-block-start: 0;
|
|
@@ -13,7 +13,7 @@ var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnP
|
|
|
13
13
|
inset: 0;
|
|
14
14
|
background-color: var(--esp-vellum-background, var(--esp-color-layer-3));
|
|
15
15
|
opacity: var(--esp-vellum-opacity, 0.85);
|
|
16
|
-
`,
|
|
16
|
+
`,_=p`
|
|
17
17
|
position: absolute;
|
|
18
18
|
inset-block: 0;
|
|
19
19
|
inset-inline-end: 0;
|
|
@@ -31,7 +31,7 @@ var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnP
|
|
|
31
31
|
@starting-style {
|
|
32
32
|
translate: 100% 0;
|
|
33
33
|
}
|
|
34
|
-
`;let a=class extends A{constructor(){super(...arguments),this.open=!1,this.heading="",this.mode="auto",this.pageOverlayRequested=!1,this.fullHeight=!1,this.matchSurface=!1,this.standalone=!1,this.scope="outermost",this.lastGeneratedAriaLabel=null,this.boundKeydown=e=>this.handleKeydown(e),this.boundShowRequest=e=>this.handleShowRequest(e),this.boundCloseRequest=()=>this.close(),this.boundOverlayMediaChange=()=>{this.syncOverlayModal(),this.syncAnchorTracking(),this.syncAnchorGeometry(),this.dispatchEvent(new CustomEvent(f.FLYOUT_STATE_CHANGED,{detail:{},bubbles:!0,composed:!0}))},this.boundAnchorViewportChange=()=>this.scheduleAnchorGeometrySync(),this.boundFullHeightRequest=e=>{e.stopPropagation(),this.fullHeight=!0},this.anchorGeometryFrame=new $(()=>this.syncAnchorGeometry()),this.trackingAnchorPosition=!1,this.busSubscribed=!1,this.panelRef=M(),this.overlay=new B({host:this,getFocusTrapContainer:()=>this.panelRef.value??null,getFocusFallback:()=>this.panelRef.value??null,promote:!1}),this.overlayActive=!1,this.baseRole="complementary"}get effectiveOverlay(){return this.mode==="overlay"||this.pageOverlayRequested||(this.overlayMediaQuery?.matches??!1)}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","complementary"),this.baseRole=this.getAttribute("role")??"complementary",!this.overlayMediaQuery&&typeof window<"u"&&"matchMedia"in window&&(this.overlayMediaQuery=window.matchMedia(D)),this.overlayMediaQuery?.addEventListener("change",this.boundOverlayMediaChange),this.syncBusSubscription(),document.addEventListener("keydown",this.boundKeydown),this.addEventListener(k,this.boundFullHeightRequest),this.syncOverlayModal(),this.syncAnchorTracking(),this.syncAnchorGeometry()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeBus(),this.overlayMediaQuery?.removeEventListener("change",this.boundOverlayMediaChange),document.removeEventListener("keydown",this.boundKeydown),this.removeEventListener(k,this.boundFullHeightRequest),this.stopAnchorTracking(),this.overlayActive&&(this.overlayActive=!1,this.setAttribute("role",this.baseRole),this.removeAttribute("aria-modal"),this.updateGeneratedAriaLabel()),this.overlayReturnFocusTo=void 0}syncBusSubscription(){if(this.standalone||!this.isConnected){this.unsubscribeBus();return}this.busSubscribed||(
|
|
34
|
+
`;let a=class extends A{constructor(){super(...arguments),this.open=!1,this.heading="",this.mode="auto",this.pageOverlayRequested=!1,this.fullHeight=!1,this.matchSurface=!1,this.standalone=!1,this.scope="outermost",this.lastGeneratedAriaLabel=null,this.boundKeydown=e=>this.handleKeydown(e),this.boundShowRequest=e=>this.handleShowRequest(e),this.boundCloseRequest=()=>this.close(),this.boundOverlayMediaChange=()=>{this.syncOverlayModal(),this.syncAnchorTracking(),this.syncAnchorGeometry(),this.dispatchEvent(new CustomEvent(f.FLYOUT_STATE_CHANGED,{detail:{},bubbles:!0,composed:!0}))},this.boundAnchorViewportChange=()=>this.scheduleAnchorGeometrySync(),this.boundFullHeightRequest=e=>{e.stopPropagation(),this.fullHeight=!0},this.anchorGeometryFrame=new $(()=>this.syncAnchorGeometry()),this.trackingAnchorPosition=!1,this.busSubscribed=!1,this.panelRef=M(),this.overlay=new B({host:this,getFocusTrapContainer:()=>this.panelRef.value??null,getFocusFallback:()=>this.panelRef.value??null,promote:!1}),this.overlayActive=!1,this.baseRole="complementary"}get effectiveOverlay(){return this.mode==="overlay"||this.pageOverlayRequested||(this.overlayMediaQuery?.matches??!1)}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","complementary"),this.baseRole=this.getAttribute("role")??"complementary",!this.overlayMediaQuery&&typeof window<"u"&&"matchMedia"in window&&(this.overlayMediaQuery=window.matchMedia(D)),this.overlayMediaQuery?.addEventListener("change",this.boundOverlayMediaChange),this.syncBusSubscription(),document.addEventListener("keydown",this.boundKeydown),this.addEventListener(k,this.boundFullHeightRequest),this.syncOverlayModal(),this.syncAnchorTracking(),this.syncAnchorGeometry()}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeBus(),this.overlayMediaQuery?.removeEventListener("change",this.boundOverlayMediaChange),document.removeEventListener("keydown",this.boundKeydown),this.removeEventListener(k,this.boundFullHeightRequest),this.stopAnchorTracking(),this.overlayActive&&(this.overlayActive=!1,this.setAttribute("role",this.baseRole),this.removeAttribute("aria-modal"),this.updateGeneratedAriaLabel()),this.overlayReturnFocusTo=void 0}syncBusSubscription(){if(this.standalone||!this.isConnected){this.unsubscribeBus();return}this.busSubscribed||(y().subscribe("show-flyout",this.boundShowRequest),y().subscribe("close-flyout",this.boundCloseRequest),this.busSubscribed=!0)}unsubscribeBus(){this.busSubscribed&&(y().unsubscribe("show-flyout",this.boundShowRequest),y().unsubscribe("close-flyout",this.boundCloseRequest),this.busSubscribed=!1)}show(){this.open||(this.open=!0,this.dispatchEvent(new CustomEvent(f.FLYOUT_OPENED,{detail:{},bubbles:!0,composed:!0})))}close(e="programmatic"){if(this.open){if(this.open=!1,this.overlayActive)this.overlayReturnFocusTo=this.returnFocusTo;else{const t=this.focusIsInside();this.overlay.close(),t&&this.returnFocusTo?.focus()}this.returnFocusTo=void 0,this.dispatchEvent(new CustomEvent(f.FLYOUT_CLOSED,{detail:{reason:e},bubbles:!0,composed:!0}))}}toggle(){this.open?this.close():this.show()}handleShowRequest(e){this.shouldHandleShowRequest(e)&&(H(e),e.heading!==void 0&&(this.heading=e.heading),e.content!==void 0&&this.replaceChildren(typeof e.content=="string"?document.createTextNode(e.content):e.content),this.anchor=e.anchor,this.fullHeight=e.fullHeight??!1,this.returnFocusTo=e.returnFocusTo,this.show())}shouldHandleShowRequest(e){const t=v(this,"esp-page"),s=e.anchor??e.returnFocusTo;if(!s){if(!t)return!0;const i=this.getPageChain(t);return this.scope==="outermost"&&i[i.length-1]===t}const o=this.getPageChain(s);if(o.length===0)return t===null;const r=o.find(i=>this.hasNearestScopeFlyout(i)),n=r??o[o.length-1];return t!==n?!1:r?this.scope==="nearest":this.scope==="outermost"}getPageChain(e){const t=[];let s=e;for(;s;){const o=v(s,"esp-page");if(!o||t.includes(o))break;t.push(o),s=this.composedParent(o)}return t}hasNearestScopeFlyout(e){return Array.from(e.querySelectorAll("esp-flyout")).some(t=>!t.standalone&&t.scope==="nearest"&&v(t,"esp-page")===e)}handleKeydown(e){if(this.open){if(this.overlayActive&&e.key==="Tab"){this.overlay.trapFocus(e);return}e.key!=="Escape"||e.defaultPrevented||(e.preventDefault(),this.close("escape"))}}focusIsInside(){const e=document.activeElement;return e&&this.contains(e)?!0:this.shadowRoot?.activeElement!=null}updated(e){super.updated(e),e.has("standalone")&&this.syncBusSubscription(),e.has("heading")&&this.updateGeneratedAriaLabel(),(e.has("anchor")||e.has("fullHeight")||e.has("open")||e.has("mode")||e.has("pageOverlayRequested"))&&(this.syncAnchorTracking(),this.syncAnchorGeometry()),(e.has("open")||e.has("mode")||e.has("pageOverlayRequested"))&&this.syncOverlayModal(),(e.has("open")||e.has("mode")||e.has("anchor")||e.has("fullHeight")||e.has("pageOverlayRequested"))&&this.dispatchEvent(new CustomEvent(f.FLYOUT_STATE_CHANGED,{detail:{},bubbles:!0,composed:!0}))}syncAnchorGeometry(){const e=v(this,"esp-page"),t=this.anchor?this.getPageChain(this.anchor):[],s=e?.shadowRoot?.querySelector(".esp-page-main"),o=this.panelRef.value;if(!this.open||this.effectiveOverlay||!o){this.clearAnchorGeometry();return}const r=this.getVisibleBlockBounds(),n=Math.max(0,r.bottom-r.top);if(this.setGeometryProperty("--_esp-flyout-max-block-size",`${n}px`),this.fullHeight){this.clearAnchorPlacementGeometry();return}if(!this.anchor||!e||!t.includes(e)||!s){this.clearAnchorGeometry();return}const i=this.anchor.getBoundingClientRect(),d=Math.max(0,i.top-s.getBoundingClientRect().top),c=Number.isFinite(i.height)?i.height:0;this.setGeometryProperty("--_esp-flyout-anchor-offset",`${d}px`),this.setGeometryProperty("--_esp-flyout-anchor-block-size",`${c}px`);const m=o.getBoundingClientRect().height||n,C=Math.max(0,i.top+m-r.bottom),T=Math.max(0,m-c),g=Math.min(C,T);this.setGeometryProperty("--_esp-flyout-viewport-shift",`${g}px`);const P=i.top-g,b=8,O=i.top+c/2,z=Math.min(Math.max(b,m-b),Math.max(b,O-P));this.setGeometryProperty("--_esp-flyout-anchor-marker-offset",`${z}px`)}getVisibleBlockBounds(){const e=window.visualViewport;let t=e?.offsetTop??0,s=t+(e?.height??window.innerHeight);for(let o=this.composedParent(this);o;o=this.composedParent(o)){const r=getComputedStyle(o).overflowY;if(r!=="auto"&&r!=="scroll")continue;const n=o.getBoundingClientRect(),i=o instanceof HTMLElement?o.clientTop:0,d=o instanceof HTMLElement?o.clientHeight:n.height;if(d<=0)continue;const c=n.top+i;t=Math.max(t,c),s=Math.min(s,c+d)}return{top:t,bottom:Math.max(t,s)}}composedParent(e){if(e.parentElement)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}setGeometryProperty(e,t){this.style.getPropertyValue(e)!==t&&this.style.setProperty(e,t)}clearAnchorGeometry(){this.clearAnchorPlacementGeometry(),this.style.removeProperty("--_esp-flyout-max-block-size")}clearAnchorPlacementGeometry(){this.style.removeProperty("--_esp-flyout-anchor-offset"),this.style.removeProperty("--_esp-flyout-viewport-shift"),this.style.removeProperty("--_esp-flyout-anchor-block-size"),this.style.removeProperty("--_esp-flyout-anchor-marker-offset")}scheduleAnchorGeometrySync(){this.isConnected&&this.anchorGeometryFrame.schedule()}syncAnchorTracking(){if(!(this.isConnected&&this.open&&(!!this.anchor||this.fullHeight)&&!this.effectiveOverlay)){this.stopAnchorTracking();return}this.trackingAnchorPosition||(this.trackingAnchorPosition=!0,window.addEventListener("scroll",this.boundAnchorViewportChange,{capture:!0,passive:!0}),window.addEventListener("resize",this.boundAnchorViewportChange,{passive:!0}));const t=this.panelRef.value;t&&t!==this.observedAnchorPanel&&typeof ResizeObserver<"u"&&(this.anchorResizeObserver??=new ResizeObserver(this.boundAnchorViewportChange),this.anchorResizeObserver.disconnect(),this.anchorResizeObserver.observe(t),this.observedAnchorPanel=t)}stopAnchorTracking(){this.trackingAnchorPosition&&(window.removeEventListener("scroll",this.boundAnchorViewportChange,{capture:!0}),window.removeEventListener("resize",this.boundAnchorViewportChange),this.trackingAnchorPosition=!1),this.anchorGeometryFrame.cancel(),this.anchorResizeObserver?.disconnect(),this.observedAnchorPanel=void 0}syncOverlayModal(){const e=this.isConnected&&this.open&&this.effectiveOverlay;if(e===this.overlayActive){!e&&!this.open&&this.overlay.close();return}e?(this.overlayActive=!0,this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.updateGeneratedAriaLabel(),this.overlay.open(),this.updateComplete.then(()=>{this.overlayActive&&this.overlay.moveFocusInto()})):(this.overlayActive=!1,this.overlay.close(),this.overlayReturnFocusTo&&(this.overlayReturnFocusTo.focus(),this.overlayReturnFocusTo=void 0),this.setAttribute("role",this.baseRole),this.removeAttribute("aria-modal"),this.updateGeneratedAriaLabel())}updateGeneratedAriaLabel(){const e=this.getAttribute("aria-label");if(e!==null&&e!==this.lastGeneratedAriaLabel)return;const t=this.heading||(this.overlayActive?U:"");t?(this.setAttribute("aria-label",t),this.lastGeneratedAriaLabel=t):(this.removeAttribute("aria-label"),this.lastGeneratedAriaLabel=null)}render(){return w`
|
|
35
35
|
<div class="vellum" aria-hidden="true" @click=${()=>this.close("vellum")}></div>
|
|
36
36
|
<div
|
|
37
37
|
class=${G({panel:!0,anchored:!!this.anchor,"full-height":this.fullHeight})}
|
|
@@ -53,6 +53,7 @@ var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnP
|
|
|
53
53
|
`}};a.styles=[...A.styles,...Y(".panel > header > .close","1.25em"),I(".panel > header > .close:focus-visible","--esp-color-link","0 0 0 3px","inset"),p`
|
|
54
54
|
:host {
|
|
55
55
|
display: none;
|
|
56
|
+
--_esp-surface-layer: initial;
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
:host([open]) {
|
|
@@ -197,7 +198,7 @@ var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnP
|
|
|
197
198
|
|
|
198
199
|
:host([open][mode="overlay"]) .panel,
|
|
199
200
|
:host([open][data-page-overlay]) .panel {
|
|
200
|
-
${
|
|
201
|
+
${_}
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
:host([open][mode="overlay"]) .panel.anchored::before,
|
|
@@ -220,7 +221,7 @@ var l=function(u,e,t,s){var o=arguments.length,r=o<3?e:s===null?s=Object.getOwnP
|
|
|
220
221
|
}
|
|
221
222
|
|
|
222
223
|
.panel {
|
|
223
|
-
${
|
|
224
|
+
${_}
|
|
224
225
|
}
|
|
225
226
|
|
|
226
227
|
.panel.anchored::before,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var s=function(n,e,r,i){var c=arguments.length,o=c<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,r,i);else for(var l=n.length-1;l>=0;l--)(p=n[l])&&(o=(c<3?p(o):c>3?p(e,r,o):p(e,r))||o);return c>3&&o&&Object.defineProperty(e,r,o),o};import{css as f,html as m}from"lit";import{customElement as h,property as a}from"lit/decorators.js";import{styleMap as g}from"lit/directives/style-map.js";import{EspalierElementBase as u}from"../shared/esp-element-base.js";import{clampFocus as v,focusConverter as b,normalizeFocus as y}from"../image/image-focus.js";import"../image/esp-image.js";import{ESP_EVENTS as d}from"../shared/events.js";const
|
|
1
|
+
var s=function(n,e,r,i){var c=arguments.length,o=c<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(n,e,r,i);else for(var l=n.length-1;l>=0;l--)(p=n[l])&&(o=(c<3?p(o):c>3?p(e,r,o):p(e,r))||o);return c>3&&o&&Object.defineProperty(e,r,o),o};import{css as f,html as m}from"lit";import{customElement as h,property as a}from"lit/decorators.js";import{styleMap as g}from"lit/directives/style-map.js";import{EspalierElementBase as u}from"../shared/esp-element-base.js";import{clampFocus as v,focusConverter as b,normalizeFocus as y}from"../image/image-focus.js";import"../image/esp-image.js";import{ESP_EVENTS as d}from"../shared/events.js";const _=d.FOCUS_PICKER_CHANGED;let t=class extends u{constructor(){super(...arguments),this.src="",this.alt="",this.focusPoint={x:.5,y:.5},this.ratio="3/1",this.compactRatio="3/2",this.activePointer=null,this.handlePointerDown=e=>{e.button===0&&(e.preventDefault(),this.activePointer=e.pointerId,e.currentTarget.setPointerCapture?.(e.pointerId),this.updateFromPointer(e))},this.handlePointerMove=e=>{e.pointerId===this.activePointer&&this.updateFromPointer(e)},this.handlePointerEnd=e=>{e.pointerId===this.activePointer&&(e.currentTarget.releasePointerCapture?.(e.pointerId),this.activePointer=null)},this.handleKeyDown=e=>{const r=e.shiftKey?.01:.05,i={};if(e.key==="ArrowLeft")i.x=-r;else if(e.key==="ArrowRight")i.x=r;else if(e.key==="ArrowUp")i.y=-r;else if(e.key==="ArrowDown")i.y=r;else return;e.preventDefault(),this.updateFocus({x:this.focusPoint.x+(i.x??0),y:this.focusPoint.y+(i.y??0)})}}willUpdate(e){if(super.willUpdate(e),e.has("focusPoint")){const r=this.focusPoint,i=y(r);(i.x!==r?.x||i.y!==r?.y)&&(this.focusPoint=i)}}updateFocus(e){const r=v(e),i={x:Number(r.x.toFixed(4)),y:Number(r.y.toFixed(4))};i.x===this.focusPoint.x&&i.y===this.focusPoint.y||(this.focusPoint=i,this.dispatchEvent(new CustomEvent(d.FOCUS_PICKER_CHANGED,{detail:{...i},bubbles:!0,composed:!0})))}updateFromPointer(e){const i=e.currentTarget.getBoundingClientRect();i.width<=0||i.height<=0||this.updateFocus({x:(e.clientX-i.left)/i.width,y:(e.clientY-i.top)/i.height})}render(){const e=Math.round(this.focusPoint.x*100),r=Math.round(this.focusPoint.y*100),i={"--_esp-focus-picker-x":`${this.focusPoint.x*100}%`,"--_esp-focus-picker-y":`${this.focusPoint.y*100}%`};return m`
|
|
2
2
|
<div part="picker" class="picker">
|
|
3
3
|
<div
|
|
4
4
|
part="stage"
|
|
@@ -63,6 +63,7 @@ var s=function(n,e,r,i){var c=arguments.length,o=c<3?e:i===null?i=Object.getOwnP
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
.stage {
|
|
66
|
+
--_esp-surface-layer: 2;
|
|
66
67
|
position: relative;
|
|
67
68
|
overflow: hidden;
|
|
68
69
|
min-block-size: var(--esp-size-big);
|
|
@@ -126,4 +127,4 @@ var s=function(n,e,r,i){var c=arguments.length,o=c<3?e:i===null?i=Object.getOwnP
|
|
|
126
127
|
transition: none;
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
`],s([a({type:String})],t.prototype,"src",void 0),s([a({type:String})],t.prototype,"alt",void 0),s([a({attribute:"focus",converter:b,reflect:!0})],t.prototype,"focusPoint",void 0),s([a({type:String})],t.prototype,"ratio",void 0),s([a({attribute:"compact-ratio",type:String})],t.prototype,"compactRatio",void 0),t=s([h("esp-focus-picker")],t);export{t as EspalierFocusPicker,
|
|
130
|
+
`],s([a({type:String})],t.prototype,"src",void 0),s([a({type:String})],t.prototype,"alt",void 0),s([a({attribute:"focus",converter:b,reflect:!0})],t.prototype,"focusPoint",void 0),s([a({type:String})],t.prototype,"ratio",void 0),s([a({attribute:"compact-ratio",type:String})],t.prototype,"compactRatio",void 0),t=s([h("esp-focus-picker")],t);export{t as EspalierFocusPicker,_ as FOCUS_CHANGED_EVENT};
|
|
@@ -8,13 +8,13 @@ export type FooterColumns = "auto" | "1" | "2" | "3" | "4" | "5" | "6";
|
|
|
8
8
|
* artwork, link groups, supporting actions, and legal or utility content.
|
|
9
9
|
* Its background remains full-bleed while its content automatically aligns
|
|
10
10
|
* to the surface of a containing [`<esp-page>`](/components/page/).
|
|
11
|
-
* The decorative background uses the same internal visual-layer primitive as
|
|
12
|
-
* `esp-image` banners; the footer's public background tokens are unchanged.
|
|
13
|
-
*
|
|
14
11
|
* Use bare [`<esp-footer-link-group>`](/components/footer/link-group/) children
|
|
15
12
|
* when navigation groups should auto-flow independently through the grid.
|
|
16
13
|
* `columns` is a maximum: the grid always drops columns when they no longer fit.
|
|
17
14
|
*
|
|
15
|
+
* A field fills one layer above the surface it sits on.
|
|
16
|
+
* Use `surface-layer="1|2|3|4"` to select the default painted layer.
|
|
17
|
+
*
|
|
18
18
|
* ```html
|
|
19
19
|
* <esp-footer
|
|
20
20
|
* light-brand-logo="/assets/logo-light.svg"
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,a):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(i,e,a,r);else for(var p=i.length-1;p>=0;p--)(l=i[p])&&(d=(s<3?l(d):s>3?l(e,a,d):l(e,a))||d);return s>3&&d&&Object.defineProperty(e,a,d),d};import{css as
|
|
1
|
+
var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,a):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(i,e,a,r);else for(var p=i.length-1;p>=0;p--)(l=i[p])&&(d=(s<3?l(d):s>3?l(e,a,d):l(e,a))||d);return s>3&&d&&Object.defineProperty(e,a,d),d};import{paintedSurface as b}from"../shared/surface-layer.js";import{css as v,html as y,nothing as _}from"lit";import{customElement as x,property as n,state as C}from"lit/decorators.js";import{classMap as k}from"lit/directives/class-map.js";import{styleMap as z}from"lit/directives/style-map.js";import{CONFIGURED_BRAND_LOGO_ASPECT_RATIO as B,configuredBrandLogoGeometry as S,renderConfiguredBrand as L,resolveConfiguredBrand as w}from"../shared/configured-brand.js";import{EspalierElementBase as g}from"../shared/esp-element-base.js";import{slotHasContent as h}from"../shared/slot-content.js";import{renderVisualOverlay as $,visualOverlayStyles as O}from"../shared/visual-overlay.js";import"./esp-footer-column.js";import"./esp-footer-link-group.js";const m=new Set(["auto","1","2","3","4","5","6"]),c={media:!1,brand:!1,groups:!1,aside:!1,bottom:!1},T={fromAttribute(i){return i&&m.has(i)?i:"auto"},toAttribute(i){return m.has(i)?i:"auto"}};let o=class extends g{constructor(){super(...arguments),this.slotContent={...c},this.brandText="",this.brandLogo="",this.lightBrandLogo="",this.darkBrandLogo="",this.brandHref="",this.brandAlt="",this.brandColor="",this.lightBrandColor="",this.darkBrandColor="",this.columns="auto",this.fullBleedContent=!1,this.landmarkLabel="",this.handleSlotChange=e=>{if(!(e.target instanceof HTMLSlotElement))return;const a=this.slotRegion(e.target);if(!a)return;const r=h(e.target);this.slotContent[a]!==r&&(this.slotContent={...this.slotContent,[a]:r})}}willUpdate(e){super.willUpdate(e),e.has("columns")&&!m.has(this.columns)&&(this.columns="auto")}slotRegion(e){return e.name?["media","brand","aside","bottom"].includes(e.name)?e.name:null:"groups"}firstUpdated(e){super.firstUpdated(e);const a={...c};for(const r of this.shadowRoot?.querySelectorAll("slot")??[]){const s=this.slotRegion(r);s&&(a[s]=h(r))}Object.entries(a).some(([r,s])=>this.slotContent[r]!==s)&&(this.slotContent=a)}render(){const{media:e,brand:a,groups:r,aside:s,bottom:d}=this.slotContent,l=w({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor}),p=a||!!(l.brandLogo||this.brandText),u=p||r||s,f={primary:!0,"has-brand":p,"has-groups":r,"has-aside":s};return y`
|
|
2
2
|
<footer
|
|
3
3
|
part="footer"
|
|
4
|
-
aria-label=${this.landmarkLabel||
|
|
5
|
-
style=${
|
|
4
|
+
aria-label=${this.landmarkLabel||_}
|
|
5
|
+
style=${z({"--_esp-footer-brand-color":l.brandColor||null})}
|
|
6
6
|
>
|
|
7
|
-
${
|
|
7
|
+
${$({className:"background",rootPart:"background"})}
|
|
8
8
|
<div part="content" class="content-frame">
|
|
9
9
|
<div class="content">
|
|
10
10
|
<div part="media" class="media" ?hidden=${!e}>
|
|
11
11
|
<slot name="media" @slotchange=${this.handleSlotChange}></slot>
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
-
<div part="primary" class=${
|
|
14
|
+
<div part="primary" class=${k(f)} ?hidden=${!u}>
|
|
15
15
|
<div part="brand" class="brand" ?hidden=${!p}>
|
|
16
16
|
<slot name="brand" @slotchange=${this.handleSlotChange}
|
|
17
|
-
>${
|
|
17
|
+
>${L({brandLogo:l.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt})}</slot
|
|
18
18
|
>
|
|
19
19
|
</div>
|
|
20
20
|
|
|
@@ -33,7 +33,7 @@ var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnP
|
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
</footer>
|
|
36
|
-
`}};o.styles=[...g.styles,
|
|
36
|
+
`}};o.styles=[...g.styles,b(2),S,v`
|
|
37
37
|
:host {
|
|
38
38
|
display: block;
|
|
39
39
|
min-inline-size: 0;
|
|
@@ -44,7 +44,7 @@ var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnP
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
footer {
|
|
47
|
-
--_esp-overlay-base-color: var(--esp-footer-background, var(--
|
|
47
|
+
--_esp-overlay-base-color: var(--esp-footer-background, var(--_esp-surface-background));
|
|
48
48
|
--_esp-overlay-image: var(--esp-footer-background-image, none);
|
|
49
49
|
--_esp-overlay-image-opacity: var(--esp-footer-background-image-opacity, 1);
|
|
50
50
|
--_esp-overlay-image-repeat: var(--esp-footer-background-repeat, repeat);
|
|
@@ -257,7 +257,7 @@ var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnP
|
|
|
257
257
|
.brand-logo {
|
|
258
258
|
|
|
259
259
|
aspect-ratio: auto
|
|
260
|
-
var(--esp-footer-brand-logo-aspect-ratio, ${
|
|
260
|
+
var(--esp-footer-brand-logo-aspect-ratio, ${B});
|
|
261
261
|
display: block;
|
|
262
262
|
inline-size: auto;
|
|
263
263
|
max-inline-size: min(var(--esp-footer-brand-logo-max-width, 12rem), 100%);
|
|
@@ -321,4 +321,4 @@ var t=function(i,e,a,r){var s=arguments.length,d=s<3?e:r===null?r=Object.getOwnP
|
|
|
321
321
|
grid-template-areas: "aside";
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
|
|
324
|
+
`,O],t([C()],o.prototype,"slotContent",void 0),t([n({attribute:"brand-text",type:String})],o.prototype,"brandText",void 0),t([n({attribute:"brand-logo",type:String})],o.prototype,"brandLogo",void 0),t([n({attribute:"light-brand-logo",type:String})],o.prototype,"lightBrandLogo",void 0),t([n({attribute:"dark-brand-logo",type:String})],o.prototype,"darkBrandLogo",void 0),t([n({attribute:"brand-href",type:String})],o.prototype,"brandHref",void 0),t([n({attribute:"brand-alt",type:String})],o.prototype,"brandAlt",void 0),t([n({attribute:"brand-color",type:String})],o.prototype,"brandColor",void 0),t([n({attribute:"light-brand-color",type:String})],o.prototype,"lightBrandColor",void 0),t([n({attribute:"dark-brand-color",type:String})],o.prototype,"darkBrandColor",void 0),t([n({converter:T,reflect:!0})],o.prototype,"columns",void 0),t([n({attribute:"full-bleed-content",type:Boolean,reflect:!0})],o.prototype,"fullBleedContent",void 0),t([n({attribute:"landmark-label",type:String})],o.prototype,"landmarkLabel",void 0),o=t([x("esp-footer")],o);export{o as EspalierFooter};
|
package/dist/grid/esp-grid.d.ts
CHANGED
|
@@ -67,6 +67,9 @@ export type GridLoadErrorEventDetail<T = GridRow> = GridDataStateEventDetail<T>
|
|
|
67
67
|
* adding [esp-grid-column](/components/grid/grid-column) elements to
|
|
68
68
|
* the default slot.
|
|
69
69
|
*
|
|
70
|
+
* A field fills one layer above the surface it sits on.
|
|
71
|
+
* Use `surface-layer="1|2|3|4"` to select the default painted layer.
|
|
72
|
+
*
|
|
70
73
|
* @slot - Grid has a default slot that expects `<esp-grid-column>`
|
|
71
74
|
* elements to define the columns in the grid:
|
|
72
75
|
*
|
package/dist/grid/esp-grid.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(C,e,t,i);else for(var n=C.length-1;n>=0;n--)(r=C[n])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};import{css as F,html as c}from"lit";import{customElement as T,property as m,state as u}from"lit/decorators.js";import"../input/esp-input.js";import"../button/esp-button.js";import{EspalierElementBase as L}from"../shared/esp-element-base.js";import{accumulatePage as G,RequestVersionGuard as N}from"../shared/cursor-pagination.js";import{ref as y,createRef as w}from"lit/directives/ref.js";import"./esp-grid-column.js";import{classMap as x}from"lit/directives/class-map.js";import{styleMap as k}from"lit/directives/style-map.js";import{leftArrow as _}from"../shared/svgs/left-arrow.js";import{rightArrow as j}from"../shared/svgs/right-arrow.js";import{filter as V}from"../shared/svgs/filter.js";import"../shared/virtualizer/lit-virtualizer.js";import{ESP_EVENTS as I}from"../shared/events.js";const M=I.GRID_LOAD_START,z=I.GRID_LOAD_SUCCESS,O=I.GRID_LOAD_ERROR,B=I.GRID_ITEMS_CHANGED;let d=class extends L{constructor(){super(...arguments),this.columnDefinitionsSlot=w(),this.headerButtonsSlot=w(),this.filteredItems=[],this.sortColumn=void 0,this.itemsBacker=[],this.virtualizerRef=w(),this.gridHeaderRowRef=w(),this.infiniteContainerRef=w(),this.pageLoads=new N,this.nextCursor=null,this.searchTerm="",this.allowNext=!1,this.allowPrevious=!1,this.columnDefinitions=new Array,this.displayedItems=[],this.pageNumber=1,this.footerMessage="",this.allLoadedItems=[],this.hasMoreData=!1,this.isLoadingFirstPage=!1,this.isLoadingPage=!1,this.effectiveGridHeight="",this.pendingHeightRetry=!1,this.wheelHandlerAttached=!1,this.dataField="",this.dataUrl="",this.pageSize=10,this.gridHeight="60vh",this.searchFields=[],this.fetchPageBacker=null,this.isAdjustingHeight=!1,this.heightRetryObserver=null,this.pinnedOffsets=new Map,this.handleGridClick=e=>{const t=e.target,i=t.hasAttribute("grid-event")?t:t.closest("[grid-event]");if(!i)return;const s=i.closest("tr")??i.closest(".grid-row"),o=Number(s?.dataset.rowIndex),r=this.isInfiniteMode?this.allLoadedItems:this.displayedItems,n=Number.isInteger(o)&&o>=0?r[o]:void 0;this.dispatchEvent(new CustomEvent(I.GRID_EVENT,{detail:{grid:this,target:i,event:i.getAttribute("grid-event")??"",data:n??{}},bubbles:!1,composed:!0})),e.stopPropagation()},this.syncHeaderScroll=()=>{const e=this.virtualizerRef.value,t=this.gridHeaderRowRef.value;e&&t&&(t.scrollLeft=e.scrollLeft)},this.handleVirtualizerWheel=e=>{const t=this.infiniteContainerRef.value;if(!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight,o=i.top>=0&&i.bottom<=s,r=i.top<=0&&i.bottom>=s;!o&&!r&&(e.preventDefault(),window.scrollBy(0,e.deltaY))},this.handleSearch=e=>{const t=e.detail.toLowerCase();this.isInfiniteMode?(this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(async()=>{this.searchTerm=t,await this.resetAndReload().catch(()=>{})},300)):(this.searchTerm=t,this.filteredItems=this.applySearchTerm(this.items),this.sortColumn?this.sort({emitItemsChanged:!1,pageNumber:1}):this.setPage(1),this.dispatchItemsChanged())}}get items(){return this.itemsBacker}set items(e){this.applyPagedItems(e)}applyPagedItems(e,t={}){const i=t.emitItemsChanged??!0,s=t.pageNumber??this.pageNumber??1;this.itemsBacker=e,this.filteredItems=this.applySearchTerm(this.itemsBacker),this.sortColumn?this.sort({emitItemsChanged:!1,pageNumber:s}):this.setPage(s),i&&this.dispatchItemsChanged()}get fetchPage(){return this.fetchPageBacker}set fetchPage(e){this.fetchPageBacker=e,e&&this.hasUpdated&&this.loadPage(null).then(async()=>{await this.updateComplete,this.measurePinnedOffsets()}).catch(()=>{})}get isInfiniteMode(){return this.fetchPage!==null}get currentDataStateItems(){return this.isInfiniteMode?this.allLoadedItems:this.filteredItems}getCurrentSortField(){return this.sortColumn?this.sortColumn.sortField.length>0?this.sortColumn.sortField:this.sortColumn.fieldName:""}createDataStateDetail(e={}){const t=[...this.currentDataStateItems],i=e.cursor??null,s=e.isFirstPage??(this.isInfiniteMode?i===null:this.pageNumber<=1);return{items:t,itemCount:t.length,isFirstPage:s,cursor:i,nextCursor:this.nextCursor,hasRows:t.length>0,isEmpty:t.length===0,search:this.searchTerm,sortField:this.getCurrentSortField(),sortOrder:this.sortColumn?.sortOrder??""}}dispatchGridDataEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}dispatchItemsChanged(e={}){this.dispatchGridDataEvent(B,this.createDataStateDetail(e))}setPage(e){const t=Math.ceil(this.filteredItems.length/this.pageSize);e>t&&(e=t),e<1&&(e=1),this.pageNumber=e;const i=(this.pageNumber-1)*this.pageSize;switch(this.displayedItems=this.filteredItems.slice(i,i+this.pageSize),this.allowPrevious=this.pageNumber>1,this.allowNext=t>this.pageNumber,t){case 0:this.footerMessage="No matching items";break;case 1:this.footerMessage=this.filteredItems.length<this.items.length?"Showing all filtered items":"Showing all items";break;default:this.footerMessage=`Showing page ${this.pageNumber} of ${t} pages`}}async loadPage(e){const t=this.fetchPage;if(!t||e!==null&&this.isLoadingPage)return;const i=this.pageLoads.begin(),s=e===null;let o=!1;this.isLoadingPage=!0,this.isLoadingFirstPage=s,s&&(this.nextCursor=null,this.hasMoreData=!1);const r={cursor:e,limit:this.pageSize,search:this.searchTerm,sortField:this.getCurrentSortField(),sortOrder:this.sortColumn?.sortOrder??""};this.dispatchGridDataEvent(M,this.createDataStateDetail({cursor:e,isFirstPage:s}));try{const n=await t(r);if(!this.pageLoads.isCurrent(i))return;this.allLoadedItems=G(this.allLoadedItems,n.items,e),this.nextCursor=n.nextCursor,this.hasMoreData=n.nextCursor!==null,o=!0,this.dispatchGridDataEvent(z,this.createDataStateDetail({cursor:e,isFirstPage:s})),this.dispatchItemsChanged({cursor:e,isFirstPage:s})}catch(n){throw this.pageLoads.isCurrent(i)&&this.dispatchGridDataEvent(O,{...this.createDataStateDetail({cursor:e,isFirstPage:s}),error:n}),n}finally{if(this.pageLoads.isCurrent(i)){if(this.isLoadingPage=!1,this.isLoadingFirstPage=!1,s&&o){const n=this.virtualizerRef.value;if(n&&n.scrollTop>0)try{n.scrollTo({top:0})}catch{n.scrollTop=0}}await this.adjustInfiniteHeight()}}}async resetAndReload(){await this.loadPage(null)}onRangeChanged(e){this.isLoadingFirstPage||e.last>=this.allLoadedItems.length-5&&this.hasMoreData&&!this.isLoadingPage&&this.loadPage(this.nextCursor).catch(()=>{})}async adjustInfiniteHeight(){if(!this.isAdjustingHeight){this.isAdjustingHeight=!0;try{const e=this.virtualizerRef.value;e&&(e.style.minHeight=""),this.effectiveGridHeight=this.gridHeight,await this.updateComplete;const t=this.infiniteContainerRef.value,i=this.virtualizerRef.value;if(!t||this.hasMoreData)return;const o=this.gridHeaderRowRef.value?.offsetHeight??0;if(!i){const p=t.querySelector(".no-results");let f=0;p?f=o+p.offsetHeight:t.querySelectorAll(":scope > *").forEach(D=>f+=D.offsetHeight),f<t.offsetHeight&&(this.effectiveGridHeight=`${f}px`);return}const r=i.querySelectorAll(".grid-row");let n=0,a=!1;if(r.forEach(p=>{const f=p.offsetHeight;f===0&&(a=!0),n+=f}),r.length===0||a||n===0){this.pendingHeightRetry||(this.pendingHeightRetry=!0,this.observeForHeightRetry(i));return}const l=i.querySelectorAll(".grid-row :defined"),g=[];l.forEach(p=>{"updateComplete"in p&&g.push(p.updateComplete)}),g.length>0&&(await Promise.all(g),n=0,r.forEach(p=>{n+=p.offsetHeight}));const v=n+o,b=t.offsetHeight;v<b&&r.length>=this.allLoadedItems.length&&(i.style.minHeight=`${n}px`,this.effectiveGridHeight=`${v}px`),!this.hasMoreData&&!this.pendingHeightRetry&&(this.pendingHeightRetry=!0,setTimeout(()=>{this.pendingHeightRetry=!1;const p=this.infiniteContainerRef.value,f=this.virtualizerRef.value;if(!p||!f||this.hasMoreData)return;const E=this.gridHeaderRowRef.value?.offsetHeight??0,R=f.querySelectorAll(".grid-row");let P=0,$=!1;if(R.forEach(A=>{const H=A.offsetHeight;H===0&&($=!0),P+=H}),R.length===0||$||P===0)return;const S=P+E;S<p.offsetHeight&&R.length>=this.allLoadedItems.length&&(f.style.minHeight=`${P}px`,this.effectiveGridHeight=`${S}px`)},100))}finally{this.isAdjustingHeight=!1}}}observeForHeightRetry(e){this.heightRetryObserver?.disconnect(),this.heightRetryObserver=new IntersectionObserver(t=>{if(!t.some(r=>r.isIntersecting))return;this.heightRetryObserver?.disconnect(),this.heightRetryObserver=null;let s=0;const o=()=>{this.pendingHeightRetry=!1,this.adjustInfiniteHeight(),this.pendingHeightRetry&&++s<5&&setTimeout(o,100)};requestAnimationFrame(()=>setTimeout(o,50))},{threshold:0}),this.heightRetryObserver.observe(e)}async sortOn(e){this.sortColumn===e?this.sortColumn.sortOrder=this.sortColumn.sortOrder=="asc"?"desc":"asc":(this.sortColumn=e,this.sortColumn.sortOrder="asc"),this.isInfiniteMode?await this.resetAndReload():this.sort()}sort(e={}){if(!this.sortColumn)return;const t=this.getCurrentSortField(),i=this.sortColumn.sortOrder==="asc"?1:-1,s=this.sortColumn.sortType,o=this.filteredItems.map((r,n)=>{const a=r[t]??"",l=s==="number"?Number(a):a.toString().toLowerCase();return{item:r,index:n,sortValue:l}});o.sort((r,n)=>r.sortValue<n.sortValue?-1*i:r.sortValue>n.sortValue?1*i:r.index-n.index),this.filteredItems=o.map(({item:r})=>r),this.setPage(e.pageNumber??1),(e.emitItemsChanged??!0)&&this.dispatchItemsChanged()}delete(e){if(this.isInfiniteMode){const t=this.allLoadedItems.filter(i=>!e(i));if(t.length===this.allLoadedItems.length)return;this.allLoadedItems=t,this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else{const t=this.items.filter(i=>!e(i));if(t.length===this.items.length)return;this.items=t}}addOrReplace(e,t){if(this.isInfiniteMode){const i=this.allLoadedItems.findIndex(e);if(i>=0){const s=[...this.allLoadedItems];s[i]={...s[i],...t},this.allLoadedItems=s}else this.allLoadedItems=[...this.allLoadedItems,t];this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else this.items.find(e)?this.items=this.items.map(s=>e(s)?{...s,...t}:s):this.items=[...this.items,t]}addInOrder(e,t,i){if(this.isInfiniteMode){const a=this.allLoadedItems.findIndex(e),l=[...this.allLoadedItems];if(a>=0)return l[a]={...l[a],...t},this.allLoadedItems=l,this.dispatchItemsChanged(),a;let g=0,v=l.length;for(;g<v;){const b=g+v>>>1;i(l[b],t)<0?g=b+1:v=b}return l.splice(g,0,t),this.allLoadedItems=l,this.dispatchItemsChanged(),this.adjustInfiniteHeight(),g}const s=this.items.findIndex(e),o=[...this.items];if(s>=0)return o[s]={...o[s],...t},this.items=o,s;let r=0,n=o.length;for(;r<n;){const a=r+n>>>1;i(o[a],t)<0?r=a+1:n=a}return o.splice(r,0,t),this.items=o,r}async scrollToIndex(e,t="center"){if(this.isInfiniteMode){await this.updateComplete;const i=this.virtualizerRef.value;if(!i)return;await i.updateComplete,await new Promise(s=>requestAnimationFrame(s)),await i.layoutComplete,i.scrollToIndex(e,t)}else{const i=Math.floor(e/this.pageSize)+1;this.setPage(i)}}clear(){if(this.isInfiniteMode){if(this.allLoadedItems.length===0&&this.nextCursor===null&&!this.hasMoreData)return;this.allLoadedItems=[],this.nextCursor=null,this.hasMoreData=!1,this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else{if(this.items.length===0)return;this.items=[]}}async reload(){this.isInfiniteMode&&await this.resetAndReload()}computePinnedStyles(){return this.pinnedOffsets}measurePinnedOffsets(){this.pinnedOffsets=new Map,this.isInfiniteMode?this.computePinnedOffsetsFromWidths():this.measurePinnedOffsetsFromCells(),this.requestUpdate()}computePinnedOffsetsFromWidths(){const e=this.columnDefinitions.filter(r=>r.pin==="left"),t=this.columnDefinitions.filter(r=>r.pin==="right"),i=[];for(let r=0;r<e.length;r++){const n=e[r],a=i.length===0?"0px":`calc(${i.join(" + ")})`;this.pinnedOffsets.set(n,{position:"sticky",left:a,zIndex:`${e.length-r+1}`}),i.push(n.width||"0px")}const s=[],o=[...t].reverse();for(let r=0;r<o.length;r++){const n=o[r],a=s.length===0?"0px":`calc(${s.join(" + ")})`;this.pinnedOffsets.set(n,{position:"sticky",right:a,zIndex:`${o.length-r+1}`}),s.push(n.width||"0px")}}measurePinnedOffsetsFromCells(){const e=this.shadowRoot?.querySelectorAll("thead th");if(!e)return;const t=this.columnDefinitions.filter(a=>a.pin==="left"),i=this.columnDefinitions.filter(a=>a.pin==="right"),s=new Map;this.columnDefinitions.forEach((a,l)=>{e[l]&&s.set(a,e[l])});let o=0;for(let a=0;a<t.length;a++){const l=t[a];this.pinnedOffsets.set(l,{position:"sticky",left:`${o}px`,zIndex:`${t.length-a+1}`});const g=s.get(l);g&&(o+=g.offsetWidth)}let r=0;const n=[...i].reverse();for(let a=0;a<n.length;a++){const l=n[a];this.pinnedOffsets.set(l,{position:"sticky",right:`${r}px`,zIndex:`${n.length-a+1}`});const g=s.get(l);g&&(r+=g.offsetWidth)}}computeGridTemplateColumns(){return this.columnDefinitions.map(e=>e.width?e.grow?`minmax(${e.width}, 1fr)`:e.width:e.grow?"minmax(0, 1fr)":"auto").join(" ")}get hasGrowableColumns(){return this.columnDefinitions.some(e=>e.grow)}computePinnedColumnFlags(){const e=new Map,t=this.columnDefinitions.filter(r=>r.pin==="left"),i=this.columnDefinitions.filter(r=>r.pin==="right"),s=t[t.length-1],o=i[0];return this.columnDefinitions.forEach((r,n)=>{e.set(r,{beforePinnedRight:this.columnDefinitions[n+1]?.pin==="right",firstPinnedRight:o===r,lastPinnedLeft:s===r})}),e}renderCell(e,t){if(!e.fieldName)return c`<span></span>`;const i=e.textAlign??"left";return c`<span style="text-align: ${i};"> ${t[e.fieldName]} </span>`}attachWheelHandler(){const e=this.virtualizerRef.value;e&&!this.wheelHandlerAttached?(e.addEventListener("wheel",this.handleVirtualizerWheel,{passive:!1}),this.wheelHandlerAttached=!0):!e&&this.wheelHandlerAttached&&(this.wheelHandlerAttached=!1)}applySearchTerm(e){return this.searchTerm.length===0?e:e.filter(t=>{let i;return this.searchFields.length>0?i=this.searchFields.map(s=>t[s]):i=Object.values(t),i.some(s=>String(s).toLowerCase().includes(this.searchTerm))})}async firstUpdated(e){super.firstUpdated(e),this.headerButtonsSlot.value.assignedElements().length===0&&this.headerButtonsSlot.value.remove();for(const i of this.columnDefinitionsSlot.value.assignedElements())i.localName==="esp-grid-column"&&this.columnDefinitions.push(i);const t=this.columnDefinitions.find(i=>i.sortOrder!=="");t&&(this.sortColumn=t),this.isInfiniteMode?await this.loadPage(null).catch(()=>{}):this.dataUrl.length&&await this.loadDataUrl().catch(()=>{}),await this.updateComplete,this.measurePinnedOffsets()}updated(e){super.updated(e),this.isInfiniteMode&&this.attachWheelHandler()}async loadDataUrl(){this.dispatchGridDataEvent(M,this.createDataStateDetail({cursor:null,isFirstPage:!0}));try{const t=await fetch(this.dataUrl).then(i=>i.json());this.applyPagedItems(this.dataField?t[this.dataField]:t,{emitItemsChanged:!1}),this.dispatchGridDataEvent(z,this.createDataStateDetail({cursor:null,isFirstPage:!0})),this.dispatchItemsChanged({cursor:null,isFirstPage:!0})}catch(t){throw this.dispatchGridDataEvent(O,{...this.createDataStateDetail({cursor:null,isFirstPage:!0}),error:t}),t}}disconnectedCallback(){super.disconnectedCallback();const e=this.virtualizerRef.value;e&&e.removeEventListener("wheel",this.handleVirtualizerWheel),this.wheelHandlerAttached=!1,this.heightRetryObserver?.disconnect(),this.heightRetryObserver=null}renderSortIcons(){return c`
|
|
1
|
+
var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(C,e,t,i);else for(var a=C.length-1;a>=0;a--)(r=C[a])&&(o=(s<3?r(o):s>3?r(e,t,o):r(e,t))||o);return s>3&&o&&Object.defineProperty(e,t,o),o};import{paintedSurface as F}from"../shared/surface-layer.js";import{css as T,html as c}from"lit";import{customElement as G,property as m,state as u}from"lit/decorators.js";import"../input/esp-input.js";import"../button/esp-button.js";import{EspalierElementBase as L}from"../shared/esp-element-base.js";import{accumulatePage as _,RequestVersionGuard as N}from"../shared/cursor-pagination.js";import{ref as y,createRef as w}from"lit/directives/ref.js";import"./esp-grid-column.js";import{classMap as x}from"lit/directives/class-map.js";import{styleMap as k}from"lit/directives/style-map.js";import{leftArrow as j}from"../shared/svgs/left-arrow.js";import{rightArrow as V}from"../shared/svgs/right-arrow.js";import{filter as B}from"../shared/svgs/filter.js";import"../shared/virtualizer/lit-virtualizer.js";import{ESP_EVENTS as I}from"../shared/events.js";const M=I.GRID_LOAD_START,z=I.GRID_LOAD_SUCCESS,O=I.GRID_LOAD_ERROR,W=I.GRID_ITEMS_CHANGED;let d=class extends L{constructor(){super(...arguments),this.columnDefinitionsSlot=w(),this.headerButtonsSlot=w(),this.filteredItems=[],this.sortColumn=void 0,this.itemsBacker=[],this.virtualizerRef=w(),this.gridHeaderRowRef=w(),this.infiniteContainerRef=w(),this.pageLoads=new N,this.nextCursor=null,this.searchTerm="",this.allowNext=!1,this.allowPrevious=!1,this.columnDefinitions=new Array,this.displayedItems=[],this.pageNumber=1,this.footerMessage="",this.allLoadedItems=[],this.hasMoreData=!1,this.isLoadingFirstPage=!1,this.isLoadingPage=!1,this.effectiveGridHeight="",this.pendingHeightRetry=!1,this.wheelHandlerAttached=!1,this.dataField="",this.dataUrl="",this.pageSize=10,this.gridHeight="60vh",this.searchFields=[],this.fetchPageBacker=null,this.isAdjustingHeight=!1,this.heightRetryObserver=null,this.pinnedOffsets=new Map,this.handleGridClick=e=>{const t=e.target,i=t.hasAttribute("grid-event")?t:t.closest("[grid-event]");if(!i)return;const s=i.closest("tr")??i.closest(".grid-row"),o=Number(s?.dataset.rowIndex),r=this.isInfiniteMode?this.allLoadedItems:this.displayedItems,a=Number.isInteger(o)&&o>=0?r[o]:void 0;this.dispatchEvent(new CustomEvent(I.GRID_EVENT,{detail:{grid:this,target:i,event:i.getAttribute("grid-event")??"",data:a??{}},bubbles:!1,composed:!0})),e.stopPropagation()},this.syncHeaderScroll=()=>{const e=this.virtualizerRef.value,t=this.gridHeaderRowRef.value;e&&t&&(t.scrollLeft=e.scrollLeft)},this.handleVirtualizerWheel=e=>{const t=this.infiniteContainerRef.value;if(!t)return;const i=t.getBoundingClientRect(),s=window.innerHeight,o=i.top>=0&&i.bottom<=s,r=i.top<=0&&i.bottom>=s;!o&&!r&&(e.preventDefault(),window.scrollBy(0,e.deltaY))},this.handleSearch=e=>{const t=e.detail.toLowerCase();this.isInfiniteMode?(this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(async()=>{this.searchTerm=t,await this.resetAndReload().catch(()=>{})},300)):(this.searchTerm=t,this.filteredItems=this.applySearchTerm(this.items),this.sortColumn?this.sort({emitItemsChanged:!1,pageNumber:1}):this.setPage(1),this.dispatchItemsChanged())}}get items(){return this.itemsBacker}set items(e){this.applyPagedItems(e)}applyPagedItems(e,t={}){const i=t.emitItemsChanged??!0,s=t.pageNumber??this.pageNumber??1;this.itemsBacker=e,this.filteredItems=this.applySearchTerm(this.itemsBacker),this.sortColumn?this.sort({emitItemsChanged:!1,pageNumber:s}):this.setPage(s),i&&this.dispatchItemsChanged()}get fetchPage(){return this.fetchPageBacker}set fetchPage(e){this.fetchPageBacker=e,e&&this.hasUpdated&&this.loadPage(null).then(async()=>{await this.updateComplete,this.measurePinnedOffsets()}).catch(()=>{})}get isInfiniteMode(){return this.fetchPage!==null}get currentDataStateItems(){return this.isInfiniteMode?this.allLoadedItems:this.filteredItems}getCurrentSortField(){return this.sortColumn?this.sortColumn.sortField.length>0?this.sortColumn.sortField:this.sortColumn.fieldName:""}createDataStateDetail(e={}){const t=[...this.currentDataStateItems],i=e.cursor??null,s=e.isFirstPage??(this.isInfiniteMode?i===null:this.pageNumber<=1);return{items:t,itemCount:t.length,isFirstPage:s,cursor:i,nextCursor:this.nextCursor,hasRows:t.length>0,isEmpty:t.length===0,search:this.searchTerm,sortField:this.getCurrentSortField(),sortOrder:this.sortColumn?.sortOrder??""}}dispatchGridDataEvent(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}dispatchItemsChanged(e={}){this.dispatchGridDataEvent(W,this.createDataStateDetail(e))}setPage(e){const t=Math.ceil(this.filteredItems.length/this.pageSize);e>t&&(e=t),e<1&&(e=1),this.pageNumber=e;const i=(this.pageNumber-1)*this.pageSize;switch(this.displayedItems=this.filteredItems.slice(i,i+this.pageSize),this.allowPrevious=this.pageNumber>1,this.allowNext=t>this.pageNumber,t){case 0:this.footerMessage="No matching items";break;case 1:this.footerMessage=this.filteredItems.length<this.items.length?"Showing all filtered items":"Showing all items";break;default:this.footerMessage=`Showing page ${this.pageNumber} of ${t} pages`}}async loadPage(e){const t=this.fetchPage;if(!t||e!==null&&this.isLoadingPage)return;const i=this.pageLoads.begin(),s=e===null;let o=!1;this.isLoadingPage=!0,this.isLoadingFirstPage=s,s&&(this.nextCursor=null,this.hasMoreData=!1);const r={cursor:e,limit:this.pageSize,search:this.searchTerm,sortField:this.getCurrentSortField(),sortOrder:this.sortColumn?.sortOrder??""};this.dispatchGridDataEvent(M,this.createDataStateDetail({cursor:e,isFirstPage:s}));try{const a=await t(r);if(!this.pageLoads.isCurrent(i))return;this.allLoadedItems=_(this.allLoadedItems,a.items,e),this.nextCursor=a.nextCursor,this.hasMoreData=a.nextCursor!==null,o=!0,this.dispatchGridDataEvent(z,this.createDataStateDetail({cursor:e,isFirstPage:s})),this.dispatchItemsChanged({cursor:e,isFirstPage:s})}catch(a){throw this.pageLoads.isCurrent(i)&&this.dispatchGridDataEvent(O,{...this.createDataStateDetail({cursor:e,isFirstPage:s}),error:a}),a}finally{if(this.pageLoads.isCurrent(i)){if(this.isLoadingPage=!1,this.isLoadingFirstPage=!1,s&&o){const a=this.virtualizerRef.value;if(a&&a.scrollTop>0)try{a.scrollTo({top:0})}catch{a.scrollTop=0}}await this.adjustInfiniteHeight()}}}async resetAndReload(){await this.loadPage(null)}onRangeChanged(e){this.isLoadingFirstPage||e.last>=this.allLoadedItems.length-5&&this.hasMoreData&&!this.isLoadingPage&&this.loadPage(this.nextCursor).catch(()=>{})}async adjustInfiniteHeight(){if(!this.isAdjustingHeight){this.isAdjustingHeight=!0;try{const e=this.virtualizerRef.value;e&&(e.style.minHeight=""),this.effectiveGridHeight=this.gridHeight,await this.updateComplete;const t=this.infiniteContainerRef.value,i=this.virtualizerRef.value;if(!t||this.hasMoreData)return;const o=this.gridHeaderRowRef.value?.offsetHeight??0;if(!i){const p=t.querySelector(".no-results");let f=0;p?f=o+p.offsetHeight:t.querySelectorAll(":scope > *").forEach(D=>f+=D.offsetHeight),f<t.offsetHeight&&(this.effectiveGridHeight=`${f}px`);return}const r=i.querySelectorAll(".grid-row");let a=0,n=!1;if(r.forEach(p=>{const f=p.offsetHeight;f===0&&(n=!0),a+=f}),r.length===0||n||a===0){this.pendingHeightRetry||(this.pendingHeightRetry=!0,this.observeForHeightRetry(i));return}const l=i.querySelectorAll(".grid-row :defined"),g=[];l.forEach(p=>{"updateComplete"in p&&g.push(p.updateComplete)}),g.length>0&&(await Promise.all(g),a=0,r.forEach(p=>{a+=p.offsetHeight}));const v=a+o,b=t.offsetHeight;v<b&&r.length>=this.allLoadedItems.length&&(i.style.minHeight=`${a}px`,this.effectiveGridHeight=`${v}px`),!this.hasMoreData&&!this.pendingHeightRetry&&(this.pendingHeightRetry=!0,setTimeout(()=>{this.pendingHeightRetry=!1;const p=this.infiniteContainerRef.value,f=this.virtualizerRef.value;if(!p||!f||this.hasMoreData)return;const E=this.gridHeaderRowRef.value?.offsetHeight??0,R=f.querySelectorAll(".grid-row");let P=0,S=!1;if(R.forEach(A=>{const H=A.offsetHeight;H===0&&(S=!0),P+=H}),R.length===0||S||P===0)return;const $=P+E;$<p.offsetHeight&&R.length>=this.allLoadedItems.length&&(f.style.minHeight=`${P}px`,this.effectiveGridHeight=`${$}px`)},100))}finally{this.isAdjustingHeight=!1}}}observeForHeightRetry(e){this.heightRetryObserver?.disconnect(),this.heightRetryObserver=new IntersectionObserver(t=>{if(!t.some(r=>r.isIntersecting))return;this.heightRetryObserver?.disconnect(),this.heightRetryObserver=null;let s=0;const o=()=>{this.pendingHeightRetry=!1,this.adjustInfiniteHeight(),this.pendingHeightRetry&&++s<5&&setTimeout(o,100)};requestAnimationFrame(()=>setTimeout(o,50))},{threshold:0}),this.heightRetryObserver.observe(e)}async sortOn(e){this.sortColumn===e?this.sortColumn.sortOrder=this.sortColumn.sortOrder=="asc"?"desc":"asc":(this.sortColumn=e,this.sortColumn.sortOrder="asc"),this.isInfiniteMode?await this.resetAndReload():this.sort()}sort(e={}){if(!this.sortColumn)return;const t=this.getCurrentSortField(),i=this.sortColumn.sortOrder==="asc"?1:-1,s=this.sortColumn.sortType,o=this.filteredItems.map((r,a)=>{const n=r[t]??"",l=s==="number"?Number(n):n.toString().toLowerCase();return{item:r,index:a,sortValue:l}});o.sort((r,a)=>r.sortValue<a.sortValue?-1*i:r.sortValue>a.sortValue?1*i:r.index-a.index),this.filteredItems=o.map(({item:r})=>r),this.setPage(e.pageNumber??1),(e.emitItemsChanged??!0)&&this.dispatchItemsChanged()}delete(e){if(this.isInfiniteMode){const t=this.allLoadedItems.filter(i=>!e(i));if(t.length===this.allLoadedItems.length)return;this.allLoadedItems=t,this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else{const t=this.items.filter(i=>!e(i));if(t.length===this.items.length)return;this.items=t}}addOrReplace(e,t){if(this.isInfiniteMode){const i=this.allLoadedItems.findIndex(e);if(i>=0){const s=[...this.allLoadedItems];s[i]={...s[i],...t},this.allLoadedItems=s}else this.allLoadedItems=[...this.allLoadedItems,t];this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else this.items.find(e)?this.items=this.items.map(s=>e(s)?{...s,...t}:s):this.items=[...this.items,t]}addInOrder(e,t,i){if(this.isInfiniteMode){const n=this.allLoadedItems.findIndex(e),l=[...this.allLoadedItems];if(n>=0)return l[n]={...l[n],...t},this.allLoadedItems=l,this.dispatchItemsChanged(),n;let g=0,v=l.length;for(;g<v;){const b=g+v>>>1;i(l[b],t)<0?g=b+1:v=b}return l.splice(g,0,t),this.allLoadedItems=l,this.dispatchItemsChanged(),this.adjustInfiniteHeight(),g}const s=this.items.findIndex(e),o=[...this.items];if(s>=0)return o[s]={...o[s],...t},this.items=o,s;let r=0,a=o.length;for(;r<a;){const n=r+a>>>1;i(o[n],t)<0?r=n+1:a=n}return o.splice(r,0,t),this.items=o,r}async scrollToIndex(e,t="center"){if(this.isInfiniteMode){await this.updateComplete;const i=this.virtualizerRef.value;if(!i)return;await i.updateComplete,await new Promise(s=>requestAnimationFrame(s)),await i.layoutComplete,i.scrollToIndex(e,t)}else{const i=Math.floor(e/this.pageSize)+1;this.setPage(i)}}clear(){if(this.isInfiniteMode){if(this.allLoadedItems.length===0&&this.nextCursor===null&&!this.hasMoreData)return;this.allLoadedItems=[],this.nextCursor=null,this.hasMoreData=!1,this.dispatchItemsChanged(),this.adjustInfiniteHeight()}else{if(this.items.length===0)return;this.items=[]}}async reload(){this.isInfiniteMode&&await this.resetAndReload()}computePinnedStyles(){return this.pinnedOffsets}measurePinnedOffsets(){this.pinnedOffsets=new Map,this.isInfiniteMode?this.computePinnedOffsetsFromWidths():this.measurePinnedOffsetsFromCells(),this.requestUpdate()}computePinnedOffsetsFromWidths(){const e=this.columnDefinitions.filter(r=>r.pin==="left"),t=this.columnDefinitions.filter(r=>r.pin==="right"),i=[];for(let r=0;r<e.length;r++){const a=e[r],n=i.length===0?"0px":`calc(${i.join(" + ")})`;this.pinnedOffsets.set(a,{position:"sticky",left:n,zIndex:`${e.length-r+1}`}),i.push(a.width||"0px")}const s=[],o=[...t].reverse();for(let r=0;r<o.length;r++){const a=o[r],n=s.length===0?"0px":`calc(${s.join(" + ")})`;this.pinnedOffsets.set(a,{position:"sticky",right:n,zIndex:`${o.length-r+1}`}),s.push(a.width||"0px")}}measurePinnedOffsetsFromCells(){const e=this.shadowRoot?.querySelectorAll("thead th");if(!e)return;const t=this.columnDefinitions.filter(n=>n.pin==="left"),i=this.columnDefinitions.filter(n=>n.pin==="right"),s=new Map;this.columnDefinitions.forEach((n,l)=>{e[l]&&s.set(n,e[l])});let o=0;for(let n=0;n<t.length;n++){const l=t[n];this.pinnedOffsets.set(l,{position:"sticky",left:`${o}px`,zIndex:`${t.length-n+1}`});const g=s.get(l);g&&(o+=g.offsetWidth)}let r=0;const a=[...i].reverse();for(let n=0;n<a.length;n++){const l=a[n];this.pinnedOffsets.set(l,{position:"sticky",right:`${r}px`,zIndex:`${a.length-n+1}`});const g=s.get(l);g&&(r+=g.offsetWidth)}}computeGridTemplateColumns(){return this.columnDefinitions.map(e=>e.width?e.grow?`minmax(${e.width}, 1fr)`:e.width:e.grow?"minmax(0, 1fr)":"auto").join(" ")}get hasGrowableColumns(){return this.columnDefinitions.some(e=>e.grow)}computePinnedColumnFlags(){const e=new Map,t=this.columnDefinitions.filter(r=>r.pin==="left"),i=this.columnDefinitions.filter(r=>r.pin==="right"),s=t[t.length-1],o=i[0];return this.columnDefinitions.forEach((r,a)=>{e.set(r,{beforePinnedRight:this.columnDefinitions[a+1]?.pin==="right",firstPinnedRight:o===r,lastPinnedLeft:s===r})}),e}renderCell(e,t){if(!e.fieldName)return c`<span></span>`;const i=e.textAlign??"left";return c`<span style="text-align: ${i};"> ${t[e.fieldName]} </span>`}attachWheelHandler(){const e=this.virtualizerRef.value;e&&!this.wheelHandlerAttached?(e.addEventListener("wheel",this.handleVirtualizerWheel,{passive:!1}),this.wheelHandlerAttached=!0):!e&&this.wheelHandlerAttached&&(this.wheelHandlerAttached=!1)}applySearchTerm(e){return this.searchTerm.length===0?e:e.filter(t=>{let i;return this.searchFields.length>0?i=this.searchFields.map(s=>t[s]):i=Object.values(t),i.some(s=>String(s).toLowerCase().includes(this.searchTerm))})}async firstUpdated(e){super.firstUpdated(e),this.headerButtonsSlot.value.assignedElements().length===0&&this.headerButtonsSlot.value.remove();for(const i of this.columnDefinitionsSlot.value.assignedElements())i.localName==="esp-grid-column"&&this.columnDefinitions.push(i);const t=this.columnDefinitions.find(i=>i.sortOrder!=="");t&&(this.sortColumn=t),this.isInfiniteMode?await this.loadPage(null).catch(()=>{}):this.dataUrl.length&&await this.loadDataUrl().catch(()=>{}),await this.updateComplete,this.measurePinnedOffsets()}updated(e){super.updated(e),this.isInfiniteMode&&this.attachWheelHandler()}async loadDataUrl(){this.dispatchGridDataEvent(M,this.createDataStateDetail({cursor:null,isFirstPage:!0}));try{const t=await fetch(this.dataUrl).then(i=>i.json());this.applyPagedItems(this.dataField?t[this.dataField]:t,{emitItemsChanged:!1}),this.dispatchGridDataEvent(z,this.createDataStateDetail({cursor:null,isFirstPage:!0})),this.dispatchItemsChanged({cursor:null,isFirstPage:!0})}catch(t){throw this.dispatchGridDataEvent(O,{...this.createDataStateDetail({cursor:null,isFirstPage:!0}),error:t}),t}}disconnectedCallback(){super.disconnectedCallback();const e=this.virtualizerRef.value;e&&e.removeEventListener("wheel",this.handleVirtualizerWheel),this.wheelHandlerAttached=!1,this.heightRetryObserver?.disconnect(),this.heightRetryObserver=null}renderSortIcons(){return c`
|
|
2
2
|
<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
4
|
viewBox="0 0 24 24"
|
|
@@ -38,7 +38,7 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
38
38
|
|
|
39
39
|
<div class="header-controls">
|
|
40
40
|
<esp-input fieldName="filter" @esp-value-changed=${this.handleSearch}>
|
|
41
|
-
${
|
|
41
|
+
${B}
|
|
42
42
|
</esp-input>
|
|
43
43
|
<slot name="header-buttons" ${y(this.headerButtonsSlot)}></slot>
|
|
44
44
|
</div>
|
|
@@ -81,7 +81,7 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
81
81
|
.disabled=${!this.allowPrevious}
|
|
82
82
|
@esp-clicked=${i=>{this.setPage(this.pageNumber-1),i.stopPropagation()}}
|
|
83
83
|
>
|
|
84
|
-
${
|
|
84
|
+
${j}
|
|
85
85
|
</esp-button>
|
|
86
86
|
<h4>${this.footerMessage}</h4>
|
|
87
87
|
<esp-button
|
|
@@ -89,10 +89,10 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
89
89
|
.disabled=${!this.allowNext}
|
|
90
90
|
@esp-clicked=${i=>{this.setPage(this.pageNumber+1),i.stopPropagation()}}
|
|
91
91
|
>
|
|
92
|
-
${
|
|
92
|
+
${V}
|
|
93
93
|
</esp-button>
|
|
94
94
|
</div>
|
|
95
|
-
`}renderInfiniteMode(e,t){const i=this.computeGridTemplateColumns(),s=this.hasGrowableColumns?"":"width: max-content; min-width: 100%;",o=(r,
|
|
95
|
+
`}renderInfiniteMode(e,t){const i=this.computeGridTemplateColumns(),s=this.hasGrowableColumns?"":"width: max-content; min-width: 100%;",o=(r,a)=>this.renderVirtualRow(r,a,e,t,i);return c`
|
|
96
96
|
<div
|
|
97
97
|
class="infinite-scroll-container"
|
|
98
98
|
${y(this.infiniteContainerRef)}
|
|
@@ -104,10 +104,10 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
104
104
|
${y(this.gridHeaderRowRef)}
|
|
105
105
|
style="${s} grid-template-columns: ${i}"
|
|
106
106
|
>
|
|
107
|
-
${this.columnDefinitions.map(r=>{const
|
|
107
|
+
${this.columnDefinitions.map(r=>{const a=e.get(r)??{};return c`<div
|
|
108
108
|
class=${x({"grid-header-cell":!0,...this.headerClasses(r,t)})}
|
|
109
|
-
style=${k(
|
|
110
|
-
@click=${
|
|
109
|
+
style=${k(a)}
|
|
110
|
+
@click=${n=>{r.sortable&&this.sortOn(r).catch(()=>{}),n.preventDefault()}}
|
|
111
111
|
>
|
|
112
112
|
<div>
|
|
113
113
|
<span>${r.header}</span>
|
|
@@ -132,24 +132,24 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
132
132
|
</div>`:c``}
|
|
133
133
|
</div>
|
|
134
134
|
</div>
|
|
135
|
-
`}renderVirtualRow(e,t,i,s,o){if(!e)return c``;const r={"grid-row":!0,"grid-row-odd":t%2===0,"grid-row-even":t%2!==0},
|
|
135
|
+
`}renderVirtualRow(e,t,i,s,o){if(!e)return c``;const r={"grid-row":!0,"grid-row-odd":t%2===0,"grid-row-even":t%2!==0},a=this.hasGrowableColumns?"":"width: max-content;";return c`<div
|
|
136
136
|
class=${x(r)}
|
|
137
|
-
style="${
|
|
137
|
+
style="${a} grid-template-columns: ${o}"
|
|
138
138
|
data-row-index=${t}
|
|
139
139
|
>
|
|
140
|
-
${this.columnDefinitions.map(
|
|
141
|
-
class=${x({"grid-cell":!0,...this.cellClasses(
|
|
142
|
-
style=${k({textAlign:
|
|
140
|
+
${this.columnDefinitions.map(n=>{const l=i.get(n)??{};return c`<div
|
|
141
|
+
class=${x({"grid-cell":!0,...this.cellClasses(n,s)})}
|
|
142
|
+
style=${k({textAlign:n.textAlign||"left",...l})}
|
|
143
143
|
>
|
|
144
|
-
${
|
|
144
|
+
${n.template?n.template(e):c`${this.renderCell(n,e)}`}
|
|
145
145
|
</div>`})}
|
|
146
|
-
</div>`}};d.styles=[...L.styles,F`
|
|
146
|
+
</div>`}};d.styles=[...L.styles,F(1),T`
|
|
147
147
|
:host {
|
|
148
148
|
display: block;
|
|
149
149
|
overflow: hidden;
|
|
150
150
|
border: var(--esp-grid-border-outer, 2px solid var(--esp-color-border));
|
|
151
151
|
border-radius: var(--esp-size-border-radius);
|
|
152
|
-
background-color: var(--esp-grid-background, var(--
|
|
152
|
+
background-color: var(--esp-grid-background, var(--_esp-surface-background));
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
.header-controls {
|
|
@@ -184,6 +184,7 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
184
184
|
|
|
185
185
|
|
|
186
186
|
.esp-grid {
|
|
187
|
+
--_esp-surface-layer: 4;
|
|
187
188
|
color: var(--esp-grid-text-color, var(--esp-color-text));
|
|
188
189
|
width: 100%;
|
|
189
190
|
border-spacing: 0;
|
|
@@ -326,14 +327,17 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
326
327
|
}
|
|
327
328
|
|
|
328
329
|
tr:nth-child(odd) {
|
|
330
|
+
--_esp-surface-layer: 1;
|
|
329
331
|
background-color: var(--esp-grid-row-background-odd, var(--esp-color-layer-1));
|
|
330
332
|
}
|
|
331
333
|
|
|
332
334
|
tr:nth-child(even) {
|
|
335
|
+
--_esp-surface-layer: 2;
|
|
333
336
|
background-color: var(--esp-grid-row-background-even, var(--esp-color-layer-2));
|
|
334
337
|
}
|
|
335
338
|
|
|
336
339
|
tr:hover {
|
|
340
|
+
--_esp-surface-layer: 3;
|
|
337
341
|
background-color: var(--esp-grid-row-hover-background, var(--esp-color-layer-3));
|
|
338
342
|
|
|
339
343
|
td {
|
|
@@ -366,6 +370,7 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
366
370
|
}
|
|
367
371
|
|
|
368
372
|
.grid-header-row {
|
|
373
|
+
--_esp-surface-layer: 4;
|
|
369
374
|
display: grid;
|
|
370
375
|
background-color: var(--esp-grid-header-background, var(--esp-color-layer-4));
|
|
371
376
|
border-bottom: var(--esp-grid-border-inner, 2px solid var(--esp-color-border));
|
|
@@ -554,14 +559,17 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
554
559
|
|
|
555
560
|
|
|
556
561
|
.grid-row-odd > & {
|
|
562
|
+
--_esp-surface-layer: 1;
|
|
557
563
|
background-color: var(--esp-grid-row-background-odd, var(--esp-color-layer-1));
|
|
558
564
|
}
|
|
559
565
|
|
|
560
566
|
.grid-row-even > & {
|
|
567
|
+
--_esp-surface-layer: 2;
|
|
561
568
|
background-color: var(--esp-grid-row-background-even, var(--esp-color-layer-2));
|
|
562
569
|
}
|
|
563
570
|
|
|
564
571
|
.grid-row:hover > & {
|
|
572
|
+
--_esp-surface-layer: 3;
|
|
565
573
|
background-color: var(--esp-grid-row-hover-background, var(--esp-color-layer-3));
|
|
566
574
|
border-color: var(--esp-grid-row-hover-border-color, var(--esp-color-layer-4));
|
|
567
575
|
}
|
|
@@ -599,4 +607,4 @@ var h=function(C,e,t,i){var s=arguments.length,o=s<3?e:i===null?i=Object.getOwnP
|
|
|
599
607
|
box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
|
|
600
608
|
}
|
|
601
609
|
}
|
|
602
|
-
`],h([u()],d.prototype,"allowNext",void 0),h([u()],d.prototype,"allowPrevious",void 0),h([u()],d.prototype,"columnDefinitions",void 0),h([u()],d.prototype,"displayedItems",void 0),h([u()],d.prototype,"pageNumber",void 0),h([u()],d.prototype,"footerMessage",void 0),h([u()],d.prototype,"allLoadedItems",void 0),h([u()],d.prototype,"hasMoreData",void 0),h([u()],d.prototype,"isLoadingFirstPage",void 0),h([u()],d.prototype,"isLoadingPage",void 0),h([u()],d.prototype,"effectiveGridHeight",void 0),h([m({attribute:"data-field",type:String})],d.prototype,"dataField",void 0),h([m({attribute:"data-url",type:String})],d.prototype,"dataUrl",void 0),h([m({type:Array})],d.prototype,"items",null),h([m({attribute:"page-size",type:Number})],d.prototype,"pageSize",void 0),h([m({attribute:"grid-height",type:String})],d.prototype,"gridHeight",void 0),h([m({attribute:"search-fields",type:Array})],d.prototype,"searchFields",void 0),h([m({attribute:!1})],d.prototype,"fetchPage",null),d=h([
|
|
610
|
+
`],h([u()],d.prototype,"allowNext",void 0),h([u()],d.prototype,"allowPrevious",void 0),h([u()],d.prototype,"columnDefinitions",void 0),h([u()],d.prototype,"displayedItems",void 0),h([u()],d.prototype,"pageNumber",void 0),h([u()],d.prototype,"footerMessage",void 0),h([u()],d.prototype,"allLoadedItems",void 0),h([u()],d.prototype,"hasMoreData",void 0),h([u()],d.prototype,"isLoadingFirstPage",void 0),h([u()],d.prototype,"isLoadingPage",void 0),h([u()],d.prototype,"effectiveGridHeight",void 0),h([m({attribute:"data-field",type:String})],d.prototype,"dataField",void 0),h([m({attribute:"data-url",type:String})],d.prototype,"dataUrl",void 0),h([m({type:Array})],d.prototype,"items",null),h([m({attribute:"page-size",type:Number})],d.prototype,"pageSize",void 0),h([m({attribute:"grid-height",type:String})],d.prototype,"gridHeight",void 0),h([m({attribute:"search-fields",type:Array})],d.prototype,"searchFields",void 0),h([m({attribute:!1})],d.prototype,"fetchPage",null),d=h([G("esp-grid")],d);export{d as EspalierGrid,W as GRID_ITEMS_CHANGED_EVENT,O as GRID_LOAD_ERROR_EVENT,M as GRID_LOAD_START_EVENT,z as GRID_LOAD_SUCCESS_EVENT};
|
|
@@ -63,23 +63,14 @@ export declare class EspalierHeaderButton extends LitElement {
|
|
|
63
63
|
*/
|
|
64
64
|
ariaLabel: string | null;
|
|
65
65
|
/**
|
|
66
|
-
* Id of the region
|
|
67
|
-
* `<button>`.
|
|
66
|
+
* Id of the controlled region, forwarded to the inner native button.
|
|
68
67
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* unless the component carries it across, which is what this does.
|
|
68
|
+
* Assistive technology and role locators target that button, so host state must
|
|
69
|
+
* be forwarded. A string id reference still cannot resolve a target outside
|
|
70
|
+
* its shadow root; ESP0222 tracks forwarding a resolved element reference.
|
|
73
71
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* target outside this button's shadow root stays unresolved. ESP0222 tracks
|
|
77
|
-
* carrying a resolved element reference instead.
|
|
78
|
-
*
|
|
79
|
-
* `ariaControls` is deliberately not an `override`: `ARIAMixin` carries
|
|
80
|
-
* `ariaControlsElements`, not a string reflection, so there is no base
|
|
81
|
-
* member to override. If a future lib adds one, `noImplicitOverride` will
|
|
82
|
-
* say so here.
|
|
72
|
+
* `ariaControls` has no base string member in the current DOM types. Keep it
|
|
73
|
+
* without `override`; `noImplicitOverride` will flag a future base declaration.
|
|
83
74
|
*/
|
|
84
75
|
ariaControls: string | null;
|
|
85
76
|
/**
|
|
@@ -16,10 +16,12 @@ export interface EspThemeToggleEventDetail {
|
|
|
16
16
|
scheme: "light" | "dark";
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
* displays a bar. It has three slots for populating header content:
|
|
19
|
+
* Builds a site's top navigation bar. Use its four slots to add content:
|
|
21
20
|
* `topbar`, `brand`, `menu`, and `buttons`.
|
|
22
21
|
*
|
|
22
|
+
* A field fills one layer above the surface it sits on.
|
|
23
|
+
* Use `surface-layer="1|2|3|4"` to select the default painted layer.
|
|
24
|
+
*
|
|
23
25
|
* The header works together with several companion components:
|
|
24
26
|
* [`<esp-menu>`](/components/menu/) provides the navigation
|
|
25
27
|
* container, [`<esp-menu-item>`](/components/menu/item/)
|