@florid-kit/components 0.10.26 → 0.10.27
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/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -375,7 +375,7 @@
|
|
|
375
375
|
.sr-only {
|
|
376
376
|
display: none;
|
|
377
377
|
}
|
|
378
|
-
`;R([a({type:String,reflect:!0})],B.prototype,"bgstyle",2);R([a({type:String,reflect:!0})],B.prototype,"size",2);R([a({type:String,reflect:!0})],B.prototype,"status",2);R([a({type:String,reflect:!0})],B.prototype,"type",2);R([a({type:String})],B.prototype,"strokewidth",2);R([a({type:String})],B.prototype,"icon",2);R([a({type:Boolean,reflect:!0})],B.prototype,"disabled",2);R([a({type:Boolean})],B.prototype,"showSrLabel",2);R([a({type:String})],B.prototype,"srLabel",2);B=R([b("o-icon-button")],B);var Ro=Object.defineProperty,Uo=Object.getOwnPropertyDescriptor,y=(o,t,e,n)=>{for(var i=n>1?void 0:n?Uo(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ro(t,e,i),i};let p=class extends u{constructor(){super(...arguments),this.open=!1,this.showHeader=!0,this.showFooter=!1,this.showHeaderStartIcon=!1,this.headerTitle="",this.headerTitleClassName="panel-title",this.labelDialog="",this.addToBagProductCount="",this.closeButtonLabel="Close the modal",this.goBackButtonLabel="Go back to",this.firstButtonLabel="Close",this.firstButtonVariant="primary",this.firstButtonProps={},this.onFirstButtonClickClose=!1,this.secondButtonLabel="",this.secondButtonVariant="secondary",this.secondButtonProps={},this.onSecondButtonClickClose=!1,this.disablePortal=!1,this.zIndex=99,this.initialized=!1,this.showDetail=!1,this.isHidingDetail=!1,this.previousFocusedElement=null,this.previousFocusedSelector=null,this._onOpenDetail=async o=>{var e,n;const t=((e=o.detail)==null?void 0:e.origin)??document.activeElement;if(this._detailOriginEl=t,this._detailOriginClass=(t==null?void 0:t.className)??"",this.showDetail=!0,this.showHeaderStartIcon=!0,await this.updateComplete,this._detailOriginClass){const i=(n=this.shadowRoot)==null?void 0:n.querySelector(".detail-view");i&&i.setAttribute("fromelement",this._detailOriginClass)}await this.focusDetailReturnBtn()},this._detailOriginEl=null,this._detailOriginClass="",this.handleKeyDown=o=>{this.open&&(o.key==="Escape"?this.closePanel():o.key==="Tab"&&this.trapFocus(o))},this.handleClosePanel=o=>{if(o instanceof KeyboardEvent&&o.key!=="Enter"&&o.key!==" ")return;o.preventDefault(),o.stopPropagation();const t=o.currentTarget,e=(t==null?void 0:t.getAttribute("data-role"))==="back";if(this.showDetail&&e){this.isHidingDetail=!0;const n=this.renderRoot.querySelector(".content"),i=async()=>{this.showDetail=!1,this.isHidingDetail=!1,this.showHeaderStartIcon=!1,await this.updateComplete,this._restoreFocusToOrigin()};if(n){this.showHeaderStartIcon=!1;const r=()=>{this.showDetail=!1,this.isHidingDetail=!1,n.removeEventListener("animationend",r),i()};n.addEventListener("animationend",r)}else this.showDetail=!1,this.isHidingDetail=!1,this.showHeaderStartIcon=!1;return}this.closePanel()}}focusFirstInPanel(){var t,e,n;(n=this.getFocusableElements().map(i=>this.resolveFocusable(i)).filter(i=>!!i&&!i.hasAttribute("disabled"))[0]??((t=this.shadowRoot)==null?void 0:t.querySelector(".close-btn"))??((e=this.shadowRoot)==null?void 0:e.querySelector(".panel")))==null||n.focus({preventScroll:!0})}resolveFocusable(o){var e;const t=o.tagName.toLowerCase();return t==="o-icon-button"||t==="o-button"?((e=o.shadowRoot)==null?void 0:e.querySelector("button, .button"))??o:o}connectedCallback(){super.connectedCallback(),!this.disablePortal&&this.parentElement!==document.body&&document.body.appendChild(this),this.addEventListener("keydown",this.handleKeyDown),this.updateComplete.then(()=>{this.initialized=!0}),this.addEventListener("open-detail",this._onOpenDetail),this.addEventListener("focusin",o=>{o.composedPath()[0]===this&&this.focusFirstInPanel()})}disconnectedCallback(){document.body.style.overflow="",document.body.removeAttribute("data-side-panel"),this.removeEventListener("keydown",this.handleKeyDown),super.disconnectedCallback(),this.removeEventListener("open-detail",this._onOpenDetail)}async focusDetailReturnBtn(){var i,r,s,c,h;await this.updateComplete;const o=this.getDeepActiveElement(document);if(o&&o!==document.body)try{o.blur()}catch{}await new Promise(requestAnimationFrame);const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".detail-view .return-btn");if(!t)return;t.updateComplete&&await t.updateComplete,(c=(s=((r=t.shadowRoot)==null?void 0:r.querySelector("button"))??t)==null?void 0:s.focus)==null||c.call(s,{preventScroll:!0});const n=(h=this.shadowRoot)==null?void 0:h.querySelector('.panel[role="dialog"]');n&&n.setAttribute("aria-label",this.headerTitle)}_restoreFocusToOrigin(){var t,e;const o=this._detailOriginEl;!o||!document.contains(o)||((e=(t=document.activeElement)==null?void 0:t.blur)==null||e.call(t),requestAnimationFrame(()=>{var i;o.classList.add("a--tabfocus"),(((i=o.shadowRoot)==null?void 0:i.querySelector('button, .button, [tabindex]:not([tabindex="-1"])'))??null??o).focus({preventScroll:!0})}))}getDeepActiveElement(o=this.shadowRoot){let t=o.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}trapFocus(o){var r;if(o.key!=="Tab")return;const t=this.shadowRoot;if(!t)return;const e=this.getDeepActiveElement();if(this.showDetail){const s=t.querySelector(".detail-view .return-btn"),c=t.querySelector(".detail-view .close-btn"),h=s?this.resolveFocusable(s):null,f=c?this.resolveFocusable(c):null;if(o.shiftKey&&h&&e===h&&f){o.preventDefault(),o.stopPropagation(),f.focus({preventScroll:!0});return}if(!o.shiftKey&&f&&e===f){o.preventDefault(),o.stopPropagation(),(((r=t.querySelector(".detail-scroller"))==null?void 0:r.querySelector(p.focusablesSelector))??h??f).focus({preventScroll:!0});return}}if(document.querySelector("#refineandsortpopin")){const s=t.querySelector(".close-btn"),c=s?this.resolveFocusable(s):null,h=t.querySelector(".js-clear-refinements"),f=h?this.resolveFocusable(h):null,x=g=>{o.preventDefault(),o.stopPropagation(),g.focus(
|
|
378
|
+
`;R([a({type:String,reflect:!0})],B.prototype,"bgstyle",2);R([a({type:String,reflect:!0})],B.prototype,"size",2);R([a({type:String,reflect:!0})],B.prototype,"status",2);R([a({type:String,reflect:!0})],B.prototype,"type",2);R([a({type:String})],B.prototype,"strokewidth",2);R([a({type:String})],B.prototype,"icon",2);R([a({type:Boolean,reflect:!0})],B.prototype,"disabled",2);R([a({type:Boolean})],B.prototype,"showSrLabel",2);R([a({type:String})],B.prototype,"srLabel",2);B=R([b("o-icon-button")],B);var Ro=Object.defineProperty,Uo=Object.getOwnPropertyDescriptor,y=(o,t,e,n)=>{for(var i=n>1?void 0:n?Uo(t,e):t,r=o.length-1,s;r>=0;r--)(s=o[r])&&(i=(n?s(t,e,i):s(i))||i);return n&&i&&Ro(t,e,i),i};let p=class extends u{constructor(){super(...arguments),this.open=!1,this.showHeader=!0,this.showFooter=!1,this.showHeaderStartIcon=!1,this.headerTitle="",this.headerTitleClassName="panel-title",this.labelDialog="",this.addToBagProductCount="",this.closeButtonLabel="Close the modal",this.goBackButtonLabel="Go back to",this.firstButtonLabel="Close",this.firstButtonVariant="primary",this.firstButtonProps={},this.onFirstButtonClickClose=!1,this.secondButtonLabel="",this.secondButtonVariant="secondary",this.secondButtonProps={},this.onSecondButtonClickClose=!1,this.disablePortal=!1,this.zIndex=99,this.initialized=!1,this.showDetail=!1,this.isHidingDetail=!1,this.previousFocusedElement=null,this.previousFocusedSelector=null,this._onOpenDetail=async o=>{var e,n;const t=((e=o.detail)==null?void 0:e.origin)??document.activeElement;if(this._detailOriginEl=t,this._detailOriginClass=(t==null?void 0:t.className)??"",this.showDetail=!0,this.showHeaderStartIcon=!0,await this.updateComplete,this._detailOriginClass){const i=(n=this.shadowRoot)==null?void 0:n.querySelector(".detail-view");i&&i.setAttribute("fromelement",this._detailOriginClass)}await this.focusDetailReturnBtn()},this._detailOriginEl=null,this._detailOriginClass="",this.handleKeyDown=o=>{this.open&&(o.key==="Escape"?this.closePanel():o.key==="Tab"&&this.trapFocus(o))},this.handleClosePanel=o=>{if(o instanceof KeyboardEvent&&o.key!=="Enter"&&o.key!==" ")return;o.preventDefault(),o.stopPropagation();const t=o.currentTarget,e=(t==null?void 0:t.getAttribute("data-role"))==="back";if(this.showDetail&&e){this.isHidingDetail=!0;const n=this.renderRoot.querySelector(".content"),i=async()=>{this.showDetail=!1,this.isHidingDetail=!1,this.showHeaderStartIcon=!1,await this.updateComplete,this._restoreFocusToOrigin()};if(n){this.showHeaderStartIcon=!1;const r=()=>{this.showDetail=!1,this.isHidingDetail=!1,n.removeEventListener("animationend",r),i()};n.addEventListener("animationend",r)}else this.showDetail=!1,this.isHidingDetail=!1,this.showHeaderStartIcon=!1;return}this.closePanel()}}focusFirstInPanel(){var t,e,n;(n=this.getFocusableElements().map(i=>this.resolveFocusable(i)).filter(i=>!!i&&!i.hasAttribute("disabled"))[0]??((t=this.shadowRoot)==null?void 0:t.querySelector(".close-btn"))??((e=this.shadowRoot)==null?void 0:e.querySelector(".panel")))==null||n.focus({preventScroll:!0})}resolveFocusable(o){var e;const t=o.tagName.toLowerCase();return t==="o-icon-button"||t==="o-button"?((e=o.shadowRoot)==null?void 0:e.querySelector("button, .button"))??o:o}connectedCallback(){super.connectedCallback(),!this.disablePortal&&this.parentElement!==document.body&&document.body.appendChild(this),this.addEventListener("keydown",this.handleKeyDown),this.updateComplete.then(()=>{this.initialized=!0}),this.addEventListener("open-detail",this._onOpenDetail),this.addEventListener("focusin",o=>{o.composedPath()[0]===this&&this.focusFirstInPanel()})}disconnectedCallback(){document.body.style.overflow="",document.body.removeAttribute("data-side-panel"),this.removeEventListener("keydown",this.handleKeyDown),super.disconnectedCallback(),this.removeEventListener("open-detail",this._onOpenDetail)}async focusDetailReturnBtn(){var i,r,s,c,h;await this.updateComplete;const o=this.getDeepActiveElement(document);if(o&&o!==document.body)try{o.blur()}catch{}await new Promise(requestAnimationFrame);const t=(i=this.shadowRoot)==null?void 0:i.querySelector(".detail-view .return-btn");if(!t)return;t.updateComplete&&await t.updateComplete,(c=(s=((r=t.shadowRoot)==null?void 0:r.querySelector("button"))??t)==null?void 0:s.focus)==null||c.call(s,{preventScroll:!0});const n=(h=this.shadowRoot)==null?void 0:h.querySelector('.panel[role="dialog"]');n&&n.setAttribute("aria-label",this.headerTitle)}_restoreFocusToOrigin(){var t,e;const o=this._detailOriginEl;!o||!document.contains(o)||((e=(t=document.activeElement)==null?void 0:t.blur)==null||e.call(t),requestAnimationFrame(()=>{var i;o.classList.add("a--tabfocus"),(((i=o.shadowRoot)==null?void 0:i.querySelector('button, .button, [tabindex]:not([tabindex="-1"])'))??null??o).focus({preventScroll:!0})}))}getDeepActiveElement(o=this.shadowRoot){let t=o.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}trapFocus(o){var r;if(o.key!=="Tab")return;const t=this.shadowRoot;if(!t)return;const e=this.getDeepActiveElement();if(this.showDetail){const s=t.querySelector(".detail-view .return-btn"),c=t.querySelector(".detail-view .close-btn"),h=s?this.resolveFocusable(s):null,f=c?this.resolveFocusable(c):null;if(o.shiftKey&&h&&e===h&&f){o.preventDefault(),o.stopPropagation(),f.focus({preventScroll:!0});return}if(!o.shiftKey&&f&&e===f){o.preventDefault(),o.stopPropagation(),(((r=t.querySelector(".detail-scroller"))==null?void 0:r.querySelector(p.focusablesSelector))??h??f).focus({preventScroll:!0});return}}if(document.querySelector("#refineandsortpopin")){const s=t.querySelector(".close-btn"),c=s?this.resolveFocusable(s):null,h=t.querySelector(".js-clear-refinements"),f=h?this.resolveFocusable(h):null,x=g=>{o.preventDefault(),o.stopPropagation(),g.focus()};if(c&&f){if(!o.shiftKey&&e===f)return x(c);if(o.shiftKey&&e===c)return x(f)}}const i=this.renderRoot.querySelector(".close-btn");if(!o.shiftKey&&i&&i.contains(e)){o.preventDefault();const s=this.renderRoot.querySelector(".o-whats-inside--content p");s==null||s.focus()}}getFocusableElements(){const o=this.renderRoot.querySelector(".panel");if(!o)return[];function t(i){return!(i.disabled||i.hasAttribute("disabled")||i.hasAttribute("tabindex")&&i.getAttribute("tabindex")==="-1")}function e(i){var s;const r=[i.matches(p.focusablesSelector)?i:[]];if(!["o-icon-button","o-button"].includes(i.tagName.toLowerCase())){const c=Array.from(i instanceof HTMLSlotElement?i.assignedElements({flatten:!0}):[]).filter(t).flatMap(e),h=Array.from(((s=i.shadowRoot)==null?void 0:s.querySelectorAll("*"))||[]).filter(t).flatMap(e);r.push(...c,...h)}return r.flat()}return Array.from(o.querySelectorAll("*")).filter(t).flatMap(e)}openPanel(){var t;this.removeAttribute("hidden"),this.getBoundingClientRect(),this.previousFocusedElement=document.activeElement,this.previousFocusedSelector=(t=this.previousFocusedElement)==null?void 0:t.getAttribute("paneltarget"),this.open=!0,document.body.style.overflow="hidden",document.body.setAttribute("data-side-panel","open");const o=this.renderRoot.querySelector(".panel");o&&o.setAttribute("aria-modal","true"),this.updateComplete.then(()=>{var e,n;if(this.showHeader){const i=(e=this.shadowRoot)==null?void 0:e.querySelector(".panel .close-btn"),r=this.resolveFocusable(i);(n=r==null?void 0:r.focus)==null||n.call(r,{preventScroll:!0})}else this.focusFirstInPanel()}),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0}))}closePanel(){var e,n,i;this.open=!1,this.showDetail=!1,document.body.style.overflow="",document.body.removeAttribute("data-side-panel");let o=this.previousFocusedElement;o!=null&&o.isConnected||(o=document.querySelector(`[paneltarget="${this.previousFocusedSelector}"]`)),(o==null?void 0:o.tagName.toLowerCase())==="o-button"?(i=(n=(e=o.shadowRoot)==null?void 0:e.querySelector(".button"))==null?void 0:n.focus)==null||i.call(n):o==null||o.focus();const t=this.renderRoot.querySelector(".panel");t&&t.removeAttribute("aria-modal"),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}handleFirstClick(o){o instanceof KeyboardEvent&&o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),this.onFirstButtonClickClose&&this.closePanel(),this.dispatchEvent(new CustomEvent("firstbuttonclick",{bubbles:!0,composed:!0,cancelable:!0,detail:{button:"first",target:o.target}})))}handleSecondClick(o){o instanceof KeyboardEvent&&o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),this.onSecondButtonClickClose&&this.closePanel(),this.dispatchEvent(new CustomEvent("secondbuttonclick",{bubbles:!0,composed:!0,cancelable:!0,detail:{button:"second",target:o.target}})))}updated(){this.style.setProperty("--z-overlay",`${this.zIndex||99}`),this.style.setProperty("--z-panel",`${this.zIndex?this.zIndex+1:99}`),this.open||setTimeout(()=>{this.setAttribute("hidden","hidden")},500)}render(){const o=this.showHeader?l`
|
|
379
379
|
<div tabindex="-1" class="header ${this.showDetail?"detail-view-header":""}">
|
|
380
380
|
${this.showHeaderStartIcon?l`
|
|
381
381
|
<o-icon-button
|
package/index.mjs
CHANGED
|
@@ -1414,7 +1414,7 @@ let p = class extends u {
|
|
|
1414
1414
|
}
|
|
1415
1415
|
if (document.querySelector("#refineandsortpopin")) {
|
|
1416
1416
|
const s = t.querySelector(".close-btn"), c = s ? this.resolveFocusable(s) : null, h = t.querySelector(".js-clear-refinements"), f = h ? this.resolveFocusable(h) : null, x = (g) => {
|
|
1417
|
-
o.preventDefault(), o.stopPropagation(), g.focus(
|
|
1417
|
+
o.preventDefault(), o.stopPropagation(), g.focus();
|
|
1418
1418
|
};
|
|
1419
1419
|
if (c && f) {
|
|
1420
1420
|
if (!o.shiftKey && e === f) return x(c);
|