monobill-mintui 0.6.720 → 0.6.722
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/dist/components/chunks/{confirm-action-Q-Y57Rp-.js → confirm-action-BW1UwJNu.js} +1 -1
- package/dist/components/chunks/{confirm-action-BN2-jao1.js → confirm-action-sovGys0x.js} +1 -1
- package/dist/components/chunks/{modal-DDnUbaov.js → modal-BixpSAyU.js} +7 -27
- package/dist/components/chunks/{modal-BlF1riUK.js → modal-BrIOYE1W.js} +1 -1
- package/dist/components/confirm-action/browser.js +1 -1
- package/dist/components/confirm-action/index.cjs +1 -1
- package/dist/components/confirm-action/index.js +1 -1
- package/dist/components/modal/Modal.d.ts +0 -1
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/browser.js +1 -1
- package/dist/components/modal/index.cjs +1 -1
- package/dist/components/modal/index.js +1 -1
- package/dist/components/off-canvas/OffCanvas.d.ts +2 -3
- package/dist/components/off-canvas/OffCanvas.d.ts.map +1 -1
- package/dist/components/off-canvas/browser.js +45 -57
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +45 -57
- package/dist/components/tree/browser.js +1 -1
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.css +2 -2
- package/dist/index.js +52 -84
- package/dist/modal.css +1 -1
- package/dist/off-canvas.css +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./register-element-BFYmIynH.js";
|
|
2
2
|
import "./text-C-6UCBp-.js";
|
|
3
3
|
import "./button-BTQHrE0x.js";
|
|
4
|
-
import "./modal-
|
|
4
|
+
import "./modal-BixpSAyU.js";
|
|
5
5
|
//#region src/components/confirm-action/ConfirmAction.ts
|
|
6
6
|
var t = class extends HTMLElement {
|
|
7
7
|
constructor(...e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-B4BMYTk1.js`),require(`./modal-
|
|
1
|
+
const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-B4BMYTk1.js`),require(`./modal-BrIOYE1W.js`);var t=class extends HTMLElement{constructor(...e){super(...e),this._modal=null,this._actionsFooter=null,this._confirmButton=null,this._cancelButton=null,this._pendingResolve=null,this._modalObserver=null,this._lastAction=null,this._onConfirmClick=null,this._onCancelClick=null}connectedCallback(){this._ensureModal(),this._observeModalOpenState()}disconnectedCallback(){this._modalObserver&&=(this._modalObserver.disconnect(),null),this._pendingResolve=null}async showConfirm(e){if(this._ensureModal(),!this._modal||!this._confirmButton||!this._cancelButton)return!1;let t=e.question?.trim()||`Are you sure?`,n=e.tone||`action`,r=e.confirmLabel?.trim()||`Confirm`,i=e.cancelLabel?.trim()||`Cancel`;this._lastAction=null,this._modal.setAttribute(`heading`,t),this._cancelButton.className=`mint-button-core mint-button-ghost mint-button-tone-neutral mint-confirm-action-cancel`,this._confirmButton.className=`mint-button-core mint-button-solid mint-button-tone-${n} mint-confirm-action-confirm`,this._confirmButton.textContent=r,this._cancelButton.textContent=i;let a=new Promise(e=>{this._pendingResolve=e});return requestAnimationFrame(()=>{this._modal.open?.(),this._mountActionsFooter()}),a}_ensureModal(){this._modal||(this._modal=document.createElement(`mint-modal`),this._modal.setAttribute(`heading`,`Are you sure?`),this._modal.setAttribute(`size`,`small`),this._modal.setAttribute(`hide-close-button`,``),this._cancelButton=document.createElement(`button`),this._cancelButton.type=`button`,this._cancelButton.className=`mint-button-core mint-button-ghost mint-button-tone-neutral mint-confirm-action-cancel`,this._cancelButton.textContent=`Cancel`,this._confirmButton=document.createElement(`button`),this._confirmButton.type=`button`,this._confirmButton.className=`mint-button-core mint-button-solid mint-button-tone-action mint-confirm-action-confirm`,this._confirmButton.textContent=`Confirm`,this._actionsFooter=document.createElement(`div`),this._actionsFooter.className=`mint-confirm-action-footer`,this._actionsFooter.append(this._cancelButton,this._confirmButton),this._onCancelClick=()=>{this._lastAction=`cancel`,this._modal?.close?.()},this._onConfirmClick=()=>{this._lastAction=`confirm`,this._modal?.close?.()},this._cancelButton.addEventListener(`click`,this._onCancelClick),this._confirmButton.addEventListener(`click`,this._onConfirmClick),this.appendChild(this._modal))}_mountActionsFooter(){let e=this._modal?.querySelector(`.modal-content`);!e||!this._actionsFooter||(e.querySelectorAll(`:scope > [slot="body"], :scope > [slot="actions"]`).forEach(e=>{!e.textContent?.trim()&&!e.querySelector(`button, mint-button, a, input, select, textarea`)&&e.remove()}),this._actionsFooter.parentElement!==e&&e.appendChild(this._actionsFooter))}_observeModalOpenState(){!this._modal||this._modalObserver||(this._modalObserver=new MutationObserver(()=>{if((this._modal?.hasAttribute(`open`)??!1)||!this._pendingResolve)return;let e=this._pendingResolve;this._pendingResolve=null;let t=this._lastAction===`confirm`;this._lastAction=null,e(t)}),this._modalObserver.observe(this._modal,{attributes:!0,attributeFilter:[`open`]}))}};customElements.get(`mint-confirm-action`)||e.t(`mint-confirm-action`,t);var n=[],r=!1;function i(){return typeof document>`u`||document.body?Promise.resolve():new Promise(e=>{if(typeof window>`u`){e();return}window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})})}async function a(){if(await i(),typeof document>`u`)throw Error(`mintui.confirm is only available in browser environments.`);let e=document.querySelector(`mint-confirm-action[data-mint-confirm-action-root="true"]`);if(e)return e;let t=document.createElement(`mint-confirm-action`);return t.setAttribute(`data-mint-confirm-action-root`,`true`),document.body.appendChild(t),t}function o(e){let t=(e||`action`).toString().trim().toLowerCase().replace(/^tone:\s*/,``);return t===`action`||t===`info`||t===`warning`||t===`danger`?t:`action`}async function s(){if(!r){r=!0;try{for(;n.length>0;){let e=n.shift();e&&(await(await a()).showConfirm({question:e.question,tone:o(e.tone),confirmLabel:e.confirmLabel||`Confirm`,cancelLabel:e.cancelLabel||`Cancel`})?e.confirmed?.():e.cancelled?.())}}finally{r=!1}}}function c(e,t,r,i=`action`,a=`Confirm`,o=`Cancel`){typeof window>`u`||(n.push({question:e,confirmed:t,cancelled:r,tone:i,confirmLabel:a,cancelLabel:o}),s())}if(typeof window<`u`){let e=window.mintui||{};e.confirm=c,window.mintui=e}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
@@ -121,14 +121,10 @@ var a = class extends HTMLElement {
|
|
|
121
121
|
}
|
|
122
122
|
_animateEnter() {
|
|
123
123
|
let e = this._modal?.querySelector(".modal-content");
|
|
124
|
-
e && (this._exitTimer &&= (clearTimeout(this._exitTimer), null), this._backdropTimer &&= (clearTimeout(this._backdropTimer), null), this.classList.remove("mint-modal-closing"), this.classList.remove("mint-modal-open"), this.classList.add("mint-modal-open"), this.classList.remove("mint-hidden"), e.style.transform = "none", e.style.opacity = "0", e.style.transition = "none", requestAnimationFrame(() => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.isOpen() && (e.style.transform = "scale(1)", e.style.opacity = "1", e.style.borderRadius = t, window.setTimeout(() => {
|
|
129
|
-
this.isOpen() && (e.style.transition = "", e.style.transform = "none");
|
|
130
|
-
}, 380));
|
|
131
|
-
});
|
|
124
|
+
e && (this._exitTimer &&= (clearTimeout(this._exitTimer), null), this._backdropTimer &&= (clearTimeout(this._backdropTimer), null), this.classList.remove("mint-modal-closing"), this.classList.remove("mint-modal-open"), this.classList.add("mint-modal-open"), this.classList.remove("mint-hidden"), e.style.transform = "none", e.style.opacity = "0", e.style.transition = "none", e.getBoundingClientRect(), requestAnimationFrame(() => {
|
|
125
|
+
this.isOpen() && (e.style.transition = "opacity 200ms ease-out", e.style.opacity = "1", this._backdropTimer = window.setTimeout(() => {
|
|
126
|
+
e.style.transition = "", e.style.opacity = "", e.style.transform = "", this._backdropTimer = null;
|
|
127
|
+
}, 220));
|
|
132
128
|
}));
|
|
133
129
|
}
|
|
134
130
|
_findTriggerElement(e) {
|
|
@@ -155,22 +151,6 @@ var a = class extends HTMLElement {
|
|
|
155
151
|
y: t.y
|
|
156
152
|
} : null;
|
|
157
153
|
}
|
|
158
|
-
_setTransformOrigin(e) {
|
|
159
|
-
let t = this._findTriggerElement(this._triggerElement);
|
|
160
|
-
this._triggerElement = t;
|
|
161
|
-
let n = this._findTriggerPoint(t);
|
|
162
|
-
if (n) {
|
|
163
|
-
let t = e.getBoundingClientRect();
|
|
164
|
-
e.style.transformOrigin = `${n.x - t.left}px ${n.y - t.top}px`, this._triggerPoint = n;
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
this._triggerPoint = {
|
|
168
|
-
x: window.innerWidth / 2,
|
|
169
|
-
y: 0
|
|
170
|
-
};
|
|
171
|
-
let r = e.getBoundingClientRect();
|
|
172
|
-
e.style.transformOrigin = `${this._triggerPoint.x - r.left}px ${this._triggerPoint.y - r.top}px`;
|
|
173
|
-
}
|
|
174
154
|
_animateExit() {
|
|
175
155
|
this.classList.remove("mint-modal-open"), this._backdropTimer &&= (clearTimeout(this._backdropTimer), null);
|
|
176
156
|
let e = this._modal?.querySelector(".modal-content");
|
|
@@ -178,9 +158,9 @@ var a = class extends HTMLElement {
|
|
|
178
158
|
this.classList.add("mint-hidden"), this.classList.remove("mint-modal-closing"), i(this);
|
|
179
159
|
return;
|
|
180
160
|
}
|
|
181
|
-
this._exitTimer && clearTimeout(this._exitTimer), this.classList.add("mint-modal-closing"), e.style.transition = "opacity
|
|
182
|
-
this._exitTimer = null, !this.isOpen() && (this.classList.add("mint-hidden"), this.classList.remove("mint-modal-closing"), e.style.transform = "", e.style.opacity = "", e.style.
|
|
183
|
-
},
|
|
161
|
+
this._exitTimer && clearTimeout(this._exitTimer), this.classList.add("mint-modal-closing"), e.style.transition = "opacity 200ms ease-in", e.style.opacity = "0", this._exitTimer = setTimeout(() => {
|
|
162
|
+
this._exitTimer = null, !this.isOpen() && (this.classList.add("mint-hidden"), this.classList.remove("mint-modal-closing"), e.style.transform = "", e.style.opacity = "", e.style.transition = "", i(this));
|
|
163
|
+
}, 200);
|
|
184
164
|
}
|
|
185
165
|
};
|
|
186
166
|
typeof customElements < "u" && !customElements.get("mint-modal") && e("mint-modal", a);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./icon-B9P0jyS2.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-B4BMYTk1.js`),require(`./stack-CK2o4-As.js`);var t=new Set,n=null;function r(e){if(!t.has(e)){if(t.size===0){let e=document.documentElement;n={scrollY:window.scrollY||window.pageYOffset||0,rootOverflow:e.style.overflow,rootOverscrollBehavior:e.style.overscrollBehavior},e.style.overflow=`hidden`,e.style.overscrollBehavior=`none`}t.add(e)}}function i(e){if(!t.delete(e)||t.size>0||!n)return;let r=n;n=null;let i=document.documentElement;i.style.overflow=r.rootOverflow,i.style.overscrollBehavior=r.rootOverscrollBehavior,window.scrollTo({left:0,top:r.scrollY,behavior:`instant`})}var a=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`size`]}constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._triggerElement=null,this._triggerPoint=null,this._renderedOpen=!1,this._lastPointerPoint=null,this._pointerDownHandler=null,this._darkModeObserver=null,this._exitTimer=null,this._backdropTimer=null}connectedCallback(){this.isOpen()||this.classList.add(`mint-hidden`),this.render(),this._observeDarkMode(),this._pointerDownHandler=e=>{this._lastPointerPoint={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()}},document.addEventListener(`pointerdown`,this._pointerDownHandler,!0)}disconnectedCallback(){i(this),this._pointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._pointerDownHandler,!0),null),this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&(e===`open`&&n!==null&&!this._triggerElement&&(this._triggerElement=this._findTriggerElement(),this._triggerPoint=this._findTriggerPoint(this._triggerElement)),this.render())}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getSize(){let e=this.getAttribute(`size`);return e===`small`||e===`large`?e:`default`}isOpen(){return this.hasAttribute(`open`)}open(e){this._triggerElement=this._findTriggerElement(e),this._triggerPoint=this._findTriggerPoint(this._triggerElement),this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),i=this.getSize();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-modal-overlay`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`mint-modal-shell`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content`,this._modal.appendChild(e)),this._renderedOpen||(this._renderedOpen=!0,r(this),this._animateEnter())}else this._renderedOpen&&(this._renderedOpen=!1,this._animateExit());let a=this._modal.querySelector(`.modal-content`);a||(a=document.createElement(`div`),a.className=`modal-content`,this._modal.appendChild(a)),a.classList.remove(`modal-content--small`,`modal-content--large`),i!==`default`&&a.classList.add(`modal-content--${i}`),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-modal-header`,a.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-modal-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let o=this._headingSlot.querySelector(`mint-text`);t?(o||(o=document.createElement(`mint-text`),o.setAttribute(`size`,`sub-heading`),o.setAttribute(`bold`,``),this._headingSlot.appendChild(o)),o.textContent=t):o&&o.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.classList.add(`mint-modal-close-button`),this._closeButton.setAttribute(`variant`,`ghost`),this._closeButton.setAttribute(`icon`,`close`),this._closeButton.addEventListener(`click`,()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._bodySlot.className=`mint-modal-body`,this._bodySlot.setAttribute(`slot`,`body`),a.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)});let s=Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`),c=this._actionsSlot?.querySelector(`mint-stack`),l=!!c&&c.children.length>0;if(s.length||l){this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),a.appendChild(this._actionsSlot));let e=this._actionsSlot.querySelector(`mint-stack`);e||(e=document.createElement(`mint-stack`),e.setAttribute(`direction`,`horizontal`),e.setAttribute(`align-content`,`right`),e.className=`mint-actions-stack`,this._actionsSlot.appendChild(e)),s.forEach(t=>{Array.from(t.children).forEach(t=>e.appendChild(t)),t.remove()})}else this._actionsSlot&&=(this._actionsSlot.remove(),null);Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;document.documentElement?.classList.contains(`dark`)||document.documentElement?.dataset.mintTheme;let e=this._modal.querySelector(`.modal-content`);e&&(e.style.background=`var(--mint-color-surface-raised)`)}_observeDarkMode(){if(!this._darkModeObserver){if(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),!document.documentElement)return;this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-mint-theme`]})}}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this.classList.remove(`mint-modal-closing`),this.classList.remove(`mint-modal-open`),this.classList.add(`mint-modal-open`),this.classList.remove(`mint-hidden`),e.style.transform=`none`,e.style.opacity=`0`,e.style.transition=`none`,requestAnimationFrame(()=>{
|
|
1
|
+
require(`./icon-B9P0jyS2.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./text-CfvRRKGZ.js`),require(`./button-B4BMYTk1.js`),require(`./stack-CK2o4-As.js`);var t=new Set,n=null;function r(e){if(!t.has(e)){if(t.size===0){let e=document.documentElement;n={scrollY:window.scrollY||window.pageYOffset||0,rootOverflow:e.style.overflow,rootOverscrollBehavior:e.style.overscrollBehavior},e.style.overflow=`hidden`,e.style.overscrollBehavior=`none`}t.add(e)}}function i(e){if(!t.delete(e)||t.size>0||!n)return;let r=n;n=null;let i=document.documentElement;i.style.overflow=r.rootOverflow,i.style.overscrollBehavior=r.rootOverscrollBehavior,window.scrollTo({left:0,top:r.scrollY,behavior:`instant`})}var a=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`size`]}constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._triggerElement=null,this._triggerPoint=null,this._renderedOpen=!1,this._lastPointerPoint=null,this._pointerDownHandler=null,this._darkModeObserver=null,this._exitTimer=null,this._backdropTimer=null}connectedCallback(){this.isOpen()||this.classList.add(`mint-hidden`),this.render(),this._observeDarkMode(),this._pointerDownHandler=e=>{this._lastPointerPoint={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()}},document.addEventListener(`pointerdown`,this._pointerDownHandler,!0)}disconnectedCallback(){i(this),this._pointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._pointerDownHandler,!0),null),this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&(e===`open`&&n!==null&&!this._triggerElement&&(this._triggerElement=this._findTriggerElement(),this._triggerPoint=this._findTriggerPoint(this._triggerElement)),this.render())}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getSize(){let e=this.getAttribute(`size`);return e===`small`||e===`large`?e:`default`}isOpen(){return this.hasAttribute(`open`)}open(e){this._triggerElement=this._findTriggerElement(e),this._triggerPoint=this._findTriggerPoint(this._triggerElement),this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),i=this.getSize();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-modal-overlay`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`mint-modal-shell`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content`,this._modal.appendChild(e)),this._renderedOpen||(this._renderedOpen=!0,r(this),this._animateEnter())}else this._renderedOpen&&(this._renderedOpen=!1,this._animateExit());let a=this._modal.querySelector(`.modal-content`);a||(a=document.createElement(`div`),a.className=`modal-content`,this._modal.appendChild(a)),a.classList.remove(`modal-content--small`,`modal-content--large`),i!==`default`&&a.classList.add(`modal-content--${i}`),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-modal-header`,a.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-modal-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let o=this._headingSlot.querySelector(`mint-text`);t?(o||(o=document.createElement(`mint-text`),o.setAttribute(`size`,`sub-heading`),o.setAttribute(`bold`,``),this._headingSlot.appendChild(o)),o.textContent=t):o&&o.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.classList.add(`mint-modal-close-button`),this._closeButton.setAttribute(`variant`,`ghost`),this._closeButton.setAttribute(`icon`,`close`),this._closeButton.addEventListener(`click`,()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._bodySlot.className=`mint-modal-body`,this._bodySlot.setAttribute(`slot`,`body`),a.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)});let s=Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`),c=this._actionsSlot?.querySelector(`mint-stack`),l=!!c&&c.children.length>0;if(s.length||l){this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),a.appendChild(this._actionsSlot));let e=this._actionsSlot.querySelector(`mint-stack`);e||(e=document.createElement(`mint-stack`),e.setAttribute(`direction`,`horizontal`),e.setAttribute(`align-content`,`right`),e.className=`mint-actions-stack`,this._actionsSlot.appendChild(e)),s.forEach(t=>{Array.from(t.children).forEach(t=>e.appendChild(t)),t.remove()})}else this._actionsSlot&&=(this._actionsSlot.remove(),null);Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;document.documentElement?.classList.contains(`dark`)||document.documentElement?.dataset.mintTheme;let e=this._modal.querySelector(`.modal-content`);e&&(e.style.background=`var(--mint-color-surface-raised)`)}_observeDarkMode(){if(!this._darkModeObserver){if(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),!document.documentElement)return;this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`data-mint-theme`]})}}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(this._exitTimer&&=(clearTimeout(this._exitTimer),null),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null),this.classList.remove(`mint-modal-closing`),this.classList.remove(`mint-modal-open`),this.classList.add(`mint-modal-open`),this.classList.remove(`mint-hidden`),e.style.transform=`none`,e.style.opacity=`0`,e.style.transition=`none`,e.getBoundingClientRect(),requestAnimationFrame(()=>{this.isOpen()&&(e.style.transition=`opacity 200ms ease-out`,e.style.opacity=`1`,this._backdropTimer=window.setTimeout(()=>{e.style.transition=``,e.style.opacity=``,e.style.transform=``,this._backdropTimer=null},220))}))}_findTriggerElement(e){if(typeof e==`string`){let t=document.getElementById(e);return t&&!this.contains(t)?t:null}if(e instanceof HTMLElement)return e.isConnected&&!this.contains(e)?e:null;let t=this.getAttribute(`trigger-id`);if(t){let e=document.getElementById(t);if(e&&!this.contains(e))return e}let n=document.activeElement;return n instanceof HTMLElement&&n.isConnected&&n!==document.body&&!this.contains(n)?n:null}_findTriggerPoint(e){if(!e)return null;let t=this._lastPointerPoint;if(!t||Date.now()-t.time>1e3)return null;let n=t.target instanceof Node?t.target:null;return n===e||n&&e.contains(n)?{x:t.x,y:t.y}:null}_animateExit(){this.classList.remove(`mint-modal-open`),this._backdropTimer&&=(clearTimeout(this._backdropTimer),null);let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),i(this);return}this._exitTimer&&clearTimeout(this._exitTimer),this.classList.add(`mint-modal-closing`),e.style.transition=`opacity 200ms ease-in`,e.style.opacity=`0`,this._exitTimer=setTimeout(()=>{this._exitTimer=null,!this.isOpen()&&(this.classList.add(`mint-hidden`),this.classList.remove(`mint-modal-closing`),e.style.transform=``,e.style.opacity=``,e.style.transition=``,i(this))},200)}};typeof customElements<`u`&&!customElements.get(`mint-modal`)&&e.t(`mint-modal`,a),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
@@ -18,5 +18,5 @@ __mintLoadStyle('icon', '../../icon.css')
|
|
|
18
18
|
__mintLoadStyle('text', '../../text.css')
|
|
19
19
|
__mintLoadStyle('stack', '../../stack.css')
|
|
20
20
|
__mintLoadStyle('confirm-action', '../../confirm-action.css')
|
|
21
|
-
import { n as e, t } from "../chunks/confirm-action-
|
|
21
|
+
import { n as e, t } from "../chunks/confirm-action-BW1UwJNu.js";
|
|
22
22
|
export { t as confirm, e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`../chunks/confirm-action-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`../chunks/confirm-action-sovGys0x.js`);exports.confirm=e.t,exports.default=e.n;
|
|
@@ -6,5 +6,5 @@ import '../../icon.css'
|
|
|
6
6
|
import '../../text.css'
|
|
7
7
|
import '../../stack.css'
|
|
8
8
|
import '../../confirm-action.css'
|
|
9
|
-
import { n as e, t } from "../chunks/confirm-action-
|
|
9
|
+
import { n as e, t } from "../chunks/confirm-action-BW1UwJNu.js";
|
|
10
10
|
export { t as confirm, e as default };
|
|
@@ -1 +1 @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zB,oBAAoB,IAAI,IAAI;IAiC5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAY9F,OAAO,CAAC,eAAe;IAQvB,KAAK,IAAI,MAAM;IAIf,UAAU,IAAI,MAAM;IAIpB,OAAO,IAAI,OAAO,GAAG,SAAS,GAAG,OAAO;IAOxC,MAAM,IAAI,OAAO;IAKjB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAM1C,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAuSd,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,wBAAwB;IAyChC,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,YAAY;CAiCrB;AAOD,eAAe,SAAS,CAAA"}
|
|
@@ -17,5 +17,5 @@ __mintLoadStyle('icon', '../../icon.css')
|
|
|
17
17
|
__mintLoadStyle('text', '../../text.css')
|
|
18
18
|
__mintLoadStyle('stack', '../../stack.css')
|
|
19
19
|
__mintLoadStyle('modal', '../../modal.css')
|
|
20
|
-
import { t as e } from "../chunks/modal-
|
|
20
|
+
import { t as e } from "../chunks/modal-BixpSAyU.js";
|
|
21
21
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/modal-
|
|
1
|
+
const e=require(`../chunks/modal-BrIOYE1W.js`);module.exports=e.t;
|
|
@@ -15,9 +15,8 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
15
15
|
private _closeButton;
|
|
16
16
|
private _contentObserver;
|
|
17
17
|
private _renderFrame;
|
|
18
|
+
private _enterFrame;
|
|
18
19
|
private _exitTimer;
|
|
19
|
-
private _enterPending;
|
|
20
|
-
private _exitPending;
|
|
21
20
|
private _previousFocus;
|
|
22
21
|
private _dialogWasOpen;
|
|
23
22
|
private _dialogKeydownHandler;
|
|
@@ -37,11 +36,11 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
37
36
|
open(): void;
|
|
38
37
|
close(): void;
|
|
39
38
|
render(): void;
|
|
40
|
-
private _getTransformValue;
|
|
41
39
|
private _observeContentMutations;
|
|
42
40
|
private _getDialogFocusableElements;
|
|
43
41
|
private _animateEnter;
|
|
44
42
|
private _animateExit;
|
|
43
|
+
private _finishExit;
|
|
45
44
|
}
|
|
46
45
|
export default MintOffCanvas;
|
|
47
46
|
//# sourceMappingURL=OffCanvas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OffCanvas.d.ts","sourceRoot":"","sources":["../../../src/components/off-canvas/OffCanvas.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,eAAe,CAAA;AACtB,OAAO,gBAAgB,CAAA;AAEvB,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAE5D,cAAM,aAAc,SAAQ,WAAW;IACrC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"OffCanvas.d.ts","sourceRoot":"","sources":["../../../src/components/off-canvas/OffCanvas.ts"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AAM,IAAI,IAAI;IA0Md,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,aAAa;IAsCrB,OAAO,CAAC,YAAY;IAkCpB,OAAO,CAAC,WAAW;CAcpB;AAOD,eAAe,aAAa,CAAA"}
|
|
@@ -36,10 +36,10 @@ var t = class extends HTMLElement {
|
|
|
36
36
|
];
|
|
37
37
|
}
|
|
38
38
|
constructor() {
|
|
39
|
-
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this.
|
|
39
|
+
super(), this._overlay = null, this._offCanvas = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._contentObserver = null, this._renderFrame = null, this._enterFrame = null, this._exitTimer = null, this._previousFocus = null, this._dialogWasOpen = !1, this._dialogKeydownHandler = null;
|
|
40
40
|
}
|
|
41
41
|
connectedCallback() {
|
|
42
|
-
this.classList.add("mint-off-canvas-host"), this.
|
|
42
|
+
this.classList.add("mint-off-canvas-host"), this.style.display = "none", this.render(), this._observeContentMutations(), this._dialogKeydownHandler = (e) => {
|
|
43
43
|
if (!this.isOpen()) return;
|
|
44
44
|
if (e.key === "Escape") {
|
|
45
45
|
e.preventDefault(), e.stopPropagation(), this.close();
|
|
@@ -58,7 +58,7 @@ var t = class extends HTMLElement {
|
|
|
58
58
|
}, document.addEventListener("keydown", this._dialogKeydownHandler, !0);
|
|
59
59
|
}
|
|
60
60
|
disconnectedCallback() {
|
|
61
|
-
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null), this.
|
|
61
|
+
this._dialogKeydownHandler &&= (document.removeEventListener("keydown", this._dialogKeydownHandler, !0), null), this._contentObserver &&= (this._contentObserver.disconnect(), null), this._renderFrame !== null && (cancelAnimationFrame(this._renderFrame), this._renderFrame = null), this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null), this._enterFrame !== null && (cancelAnimationFrame(this._enterFrame), this._enterFrame = null), this._overlay?.remove(), this._offCanvas?.remove();
|
|
62
62
|
}
|
|
63
63
|
attributeChangedCallback(e, t, n) {
|
|
64
64
|
t !== n && this.isConnected && this.render();
|
|
@@ -101,43 +101,29 @@ var t = class extends HTMLElement {
|
|
|
101
101
|
}
|
|
102
102
|
render() {
|
|
103
103
|
let e = this.getId(), t = this.getHeading(), n = this.isOpen(), r = this.getPosition(), i = this.isFullPage(), a = this.getHeight();
|
|
104
|
-
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())
|
|
105
|
-
let o =
|
|
106
|
-
|
|
107
|
-
let s = this.
|
|
108
|
-
|
|
104
|
+
e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "mint-off-canvas-overlay mint-off-canvas-hidden", this._overlay.setAttribute("aria-hidden", "true"), this._overlay.addEventListener("click", () => this.close())), this._offCanvas || (this._offCanvas = document.createElement("div"), this._offCanvas.className = "mint-off-canvas-shell mint-off-canvas-hidden");
|
|
105
|
+
let o = document.body ?? document.documentElement;
|
|
106
|
+
this._overlay.parentElement !== o && o.appendChild(this._overlay), this._offCanvas.parentElement !== o && o.appendChild(this._offCanvas), this._offCanvas.classList.add("mint-off-canvas-shell"), this._offCanvas.dataset.position = r, this._offCanvas.dataset.fullPage = String(i);
|
|
107
|
+
let s = this._offCanvas.querySelector(".mint-off-canvas-panel");
|
|
108
|
+
s || (s = document.createElement("div"), s.className = "mint-off-canvas-panel", this._offCanvas.appendChild(s)), s.setAttribute("role", "dialog"), s.setAttribute("aria-modal", "true"), s.hasAttribute("tabindex") || (s.tabIndex = -1), s.style.removeProperty("--off-canvas-width"), s.style.removeProperty("--off-canvas-height"), r === "top" || r === "bottom" ? a && s.style.setProperty("--off-canvas-height", this._normalizeCssValue(a)) : s.style.setProperty("--off-canvas-width", this._normalizeCssValue(this.getWidth())), this._header || (this._header = document.createElement("div"), this._header.className = "mint-off-canvas-header", s.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "mint-off-canvas-heading", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
109
|
+
let c = this._headingSlot.querySelector("mint-text");
|
|
110
|
+
if (t ? (c || (c = document.createElement("mint-text"), c.setAttribute("size", "sub-heading"), c.setAttribute("bold", "true"), this._headingSlot.appendChild(c)), c.textContent = t, c.id = `${e || "mint-off-canvas"}-heading`, s.setAttribute("aria-labelledby", c.id), s.removeAttribute("aria-label")) : c && c.remove(), !t) {
|
|
109
111
|
let e = this.getAttribute("aria-label")?.trim();
|
|
110
|
-
e ?
|
|
112
|
+
e ? s.setAttribute("aria-label", e) : s.hasAttribute("aria-label") || s.setAttribute("aria-label", "Dialog");
|
|
111
113
|
}
|
|
112
114
|
Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._headingSlot && e.getAttribute("slot") === "heading").forEach((e) => {
|
|
113
115
|
this._headingSlot && e.parentElement !== this._headingSlot && this._headingSlot.appendChild(e);
|
|
114
|
-
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"),
|
|
116
|
+
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.setAttribute("aria-label", "Close panel"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "mint-off-canvas-body", this._bodySlot.setAttribute("slot", "body"), s.appendChild(this._bodySlot)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._bodySlot && e.getAttribute("slot") === "body").forEach((e) => {
|
|
115
117
|
this._bodySlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
116
|
-
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"),
|
|
117
|
-
let
|
|
118
|
-
|
|
118
|
+
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "mint-off-canvas-actions", this._actionsSlot.setAttribute("slot", "actions"), s.appendChild(this._actionsSlot));
|
|
119
|
+
let l = this._actionsSlot.querySelector("mint-stack");
|
|
120
|
+
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "mint-off-canvas-actions-stack", this._actionsSlot.appendChild(l)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._offCanvas && e !== this._actionsSlot && e.getAttribute("slot") === "actions").forEach((e) => {
|
|
119
121
|
Array.from(e.children).forEach((e) => {
|
|
120
|
-
e.parentElement !==
|
|
122
|
+
e.parentElement !== l && l.appendChild(e);
|
|
121
123
|
}), e.parentElement && e.remove();
|
|
122
124
|
}), Array.from(this.children).forEach((e) => {
|
|
123
125
|
e !== this._overlay && e !== this._offCanvas && e.getAttribute("slot") !== "heading" && e.getAttribute("slot") !== "body" && e.getAttribute("slot") !== "actions" && e !== this._headingSlot && e !== this._bodySlot && e !== this._actionsSlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
_getTransformValue(e, t) {
|
|
127
|
-
if (t) switch (e) {
|
|
128
|
-
case "top": return "translateY(0)";
|
|
129
|
-
case "bottom": return "translateY(0)";
|
|
130
|
-
case "left": return "translateX(0)";
|
|
131
|
-
case "right": return "translateX(0)";
|
|
132
|
-
default: return "translateX(0)";
|
|
133
|
-
}
|
|
134
|
-
else switch (e) {
|
|
135
|
-
case "top": return "translateY(-100%)";
|
|
136
|
-
case "bottom": return "translateY(100%)";
|
|
137
|
-
case "left": return "translateX(-100%)";
|
|
138
|
-
case "right": return "translateX(100%)";
|
|
139
|
-
default: return "translateX(100%)";
|
|
140
|
-
}
|
|
126
|
+
}), n ? this._animateEnter() : this._animateExit();
|
|
141
127
|
}
|
|
142
128
|
_observeContentMutations() {
|
|
143
129
|
this._contentObserver ||= new MutationObserver(() => {
|
|
@@ -156,40 +142,42 @@ var t = class extends HTMLElement {
|
|
|
156
142
|
});
|
|
157
143
|
}
|
|
158
144
|
_animateEnter() {
|
|
159
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
160
|
-
if (!e ||
|
|
161
|
-
this.
|
|
162
|
-
let
|
|
163
|
-
if (
|
|
145
|
+
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel"), t = this._offCanvas, n = this._overlay;
|
|
146
|
+
if (!e || !t || !n || this._enterFrame !== null || t.classList.contains("mint-off-canvas-open")) return;
|
|
147
|
+
this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null);
|
|
148
|
+
let r = !this._dialogWasOpen;
|
|
149
|
+
if (r) {
|
|
164
150
|
this._dialogWasOpen = !0;
|
|
165
151
|
let e = document.activeElement;
|
|
166
152
|
this._previousFocus = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
167
153
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
if (!this.isOpen()) {
|
|
171
|
-
this._enterPending = !1;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
this.classList.add("mint-off-canvas-open"), e.style.transform = this._getTransformValue(t, !0), this._enterPending = !1, n && (this._getDialogFocusableElements(e)[0] ?? e).focus();
|
|
175
|
-
});
|
|
154
|
+
n.classList.remove("mint-off-canvas-hidden", "mint-off-canvas-open"), t.classList.remove("mint-off-canvas-hidden", "mint-off-canvas-open"), e.getBoundingClientRect(), this._enterFrame = requestAnimationFrame(() => {
|
|
155
|
+
this._enterFrame = null, this.isOpen() && (n.classList.add("mint-off-canvas-open"), t.classList.add("mint-off-canvas-open"), r && (this._getDialogFocusableElements(e)[0] ?? e).focus());
|
|
176
156
|
});
|
|
177
157
|
}
|
|
178
158
|
_animateExit() {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
159
|
+
let e = this._offCanvas, t = this._overlay;
|
|
160
|
+
if (!(!e || !t || e.classList.contains("mint-off-canvas-hidden"))) {
|
|
161
|
+
if (!this._offCanvas?.querySelector(".mint-off-canvas-panel")) {
|
|
162
|
+
t.classList.add("mint-off-canvas-hidden"), e.classList.add("mint-off-canvas-hidden"), this._dialogWasOpen = !1;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
if (this._enterFrame !== null) {
|
|
166
|
+
cancelAnimationFrame(this._enterFrame), this._enterFrame = null, t.classList.add("mint-off-canvas-hidden"), e.classList.add("mint-off-canvas-hidden"), this._dialogWasOpen = !1;
|
|
167
|
+
let n = this._previousFocus;
|
|
168
|
+
this._previousFocus = null, n?.isConnected && n.focus();
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
e.classList.contains("mint-off-canvas-open") && (t.classList.remove("mint-off-canvas-open"), e.classList.remove("mint-off-canvas-open"), this._exitTimer !== null && clearTimeout(this._exitTimer), this._exitTimer = window.setTimeout(() => {
|
|
172
|
+
this._finishExit();
|
|
173
|
+
}, 220));
|
|
185
174
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}, 200);
|
|
175
|
+
}
|
|
176
|
+
_finishExit() {
|
|
177
|
+
if (this.isOpen()) return;
|
|
178
|
+
this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null), this._overlay?.classList.add("mint-off-canvas-hidden"), this._offCanvas?.classList.add("mint-off-canvas-hidden"), this._dialogWasOpen = !1;
|
|
179
|
+
let e = this._previousFocus;
|
|
180
|
+
this._previousFocus = null, e?.isConnected && e.focus();
|
|
193
181
|
}
|
|
194
182
|
};
|
|
195
183
|
customElements.get("mint-off-canvas") || e("mint-off-canvas", t);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../chunks/icon-B9P0jyS2.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-CfvRRKGZ.js`),require(`../chunks/button-B4BMYTk1.js`),require(`../chunks/stack-CK2o4-As.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._contentObserver=null,this._renderFrame=null,this.
|
|
1
|
+
require(`../chunks/icon-B9P0jyS2.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-CfvRRKGZ.js`),require(`../chunks/button-B4BMYTk1.js`),require(`../chunks/stack-CK2o4-As.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._contentObserver=null,this._renderFrame=null,this._enterFrame=null,this._exitTimer=null,this._previousFocus=null,this._dialogWasOpen=!1,this._dialogKeydownHandler=null}connectedCallback(){this.classList.add(`mint-off-canvas-host`),this.style.display=`none`,this.render(),this._observeContentMutations(),this._dialogKeydownHandler=e=>{if(!this.isOpen())return;if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),this.close();return}if(e.key!==`Tab`)return;let t=this._offCanvas?.querySelector(`.mint-off-canvas-panel`);if(!t)return;let n=this._getDialogFocusableElements(t);if(!n.length){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):!e.shiftKey&&(a===i||!t.contains(a))&&(e.preventDefault(),r.focus())},document.addEventListener(`keydown`,this._dialogKeydownHandler,!0)}disconnectedCallback(){this._dialogKeydownHandler&&=(document.removeEventListener(`keydown`,this._dialogKeydownHandler,!0),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._exitTimer!==null&&(clearTimeout(this._exitTimer),this._exitTimer=null),this._enterFrame!==null&&(cancelAnimationFrame(this._enterFrame),this._enterFrame=null),this._overlay?.remove(),this._offCanvas?.remove()}attributeChangedCallback(e,t,n){t!==n&&this.isConnected&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getPosition(){let e=this.getAttribute(`position`)?.toLowerCase();return e===`top`||e===`bottom`||e===`left`||e===`right`?e:`right`}isFullPage(){return this.getAttribute(`full-page`)===`true`}getWidth(){return this.getAttribute(`width`)||`320px`}getHeight(){return this.getAttribute(`height`)||``}_normalizeCssValue(e){return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:e.trim()}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),r=this.getPosition(),i=this.isFullPage(),a=this.getHeight();e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`mint-off-canvas-overlay mint-off-canvas-hidden`,this._overlay.setAttribute(`aria-hidden`,`true`),this._overlay.addEventListener(`click`,()=>this.close())),this._offCanvas||(this._offCanvas=document.createElement(`div`),this._offCanvas.className=`mint-off-canvas-shell mint-off-canvas-hidden`);let o=document.body??document.documentElement;this._overlay.parentElement!==o&&o.appendChild(this._overlay),this._offCanvas.parentElement!==o&&o.appendChild(this._offCanvas),this._offCanvas.classList.add(`mint-off-canvas-shell`),this._offCanvas.dataset.position=r,this._offCanvas.dataset.fullPage=String(i);let s=this._offCanvas.querySelector(`.mint-off-canvas-panel`);s||(s=document.createElement(`div`),s.className=`mint-off-canvas-panel`,this._offCanvas.appendChild(s)),s.setAttribute(`role`,`dialog`),s.setAttribute(`aria-modal`,`true`),s.hasAttribute(`tabindex`)||(s.tabIndex=-1),s.style.removeProperty(`--off-canvas-width`),s.style.removeProperty(`--off-canvas-height`),r===`top`||r===`bottom`?a&&s.style.setProperty(`--off-canvas-height`,this._normalizeCssValue(a)):s.style.setProperty(`--off-canvas-width`,this._normalizeCssValue(this.getWidth())),this._header||(this._header=document.createElement(`div`),this._header.className=`mint-off-canvas-header`,s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`mint-off-canvas-heading`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let c=this._headingSlot.querySelector(`mint-text`);if(t?(c||(c=document.createElement(`mint-text`),c.setAttribute(`size`,`sub-heading`),c.setAttribute(`bold`,`true`),this._headingSlot.appendChild(c)),c.textContent=t,c.id=`${e||`mint-off-canvas`}-heading`,s.setAttribute(`aria-labelledby`,c.id),s.removeAttribute(`aria-label`)):c&&c.remove(),!t){let e=this.getAttribute(`aria-label`)?.trim();e?s.setAttribute(`aria-label`,e):s.hasAttribute(`aria-label`)||s.setAttribute(`aria-label`,`Dialog`)}Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.setAttribute(`variant`,`ghost`),this._closeButton.setAttribute(`icon`,`close`),this._closeButton.setAttribute(`aria-label`,`Close panel`),this._closeButton.addEventListener(`click`,()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._bodySlot.className=`mint-off-canvas-body`,this._bodySlot.setAttribute(`slot`,`body`),s.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`mint-off-canvas-actions`,this._actionsSlot.setAttribute(`slot`,`actions`),s.appendChild(this._actionsSlot));let l=this._actionsSlot.querySelector(`mint-stack`);l||(l=document.createElement(`mint-stack`),l.setAttribute(`direction`,`horizontal`),l.className=`mint-off-canvas-actions-stack`,this._actionsSlot.appendChild(l)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==l&&l.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._offCanvas&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),n?this._animateEnter():this._animateExit()}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getDialogFocusableElements(e){return Array.from(e.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>{if(e.closest(`[hidden], [aria-hidden="true"]`))return!1;let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_animateEnter(){let e=this._offCanvas?.querySelector(`.mint-off-canvas-panel`),t=this._offCanvas,n=this._overlay;if(!e||!t||!n||this._enterFrame!==null||t.classList.contains(`mint-off-canvas-open`))return;this._exitTimer!==null&&(clearTimeout(this._exitTimer),this._exitTimer=null);let r=!this._dialogWasOpen;if(r){this._dialogWasOpen=!0;let e=document.activeElement;this._previousFocus=e instanceof HTMLElement&&e!==document.body?e:null}n.classList.remove(`mint-off-canvas-hidden`,`mint-off-canvas-open`),t.classList.remove(`mint-off-canvas-hidden`,`mint-off-canvas-open`),e.getBoundingClientRect(),this._enterFrame=requestAnimationFrame(()=>{this._enterFrame=null,this.isOpen()&&(n.classList.add(`mint-off-canvas-open`),t.classList.add(`mint-off-canvas-open`),r&&(this._getDialogFocusableElements(e)[0]??e).focus())})}_animateExit(){let e=this._offCanvas,t=this._overlay;if(!(!e||!t||e.classList.contains(`mint-off-canvas-hidden`))){if(!this._offCanvas?.querySelector(`.mint-off-canvas-panel`)){t.classList.add(`mint-off-canvas-hidden`),e.classList.add(`mint-off-canvas-hidden`),this._dialogWasOpen=!1;return}if(this._enterFrame!==null){cancelAnimationFrame(this._enterFrame),this._enterFrame=null,t.classList.add(`mint-off-canvas-hidden`),e.classList.add(`mint-off-canvas-hidden`),this._dialogWasOpen=!1;let n=this._previousFocus;this._previousFocus=null,n?.isConnected&&n.focus();return}e.classList.contains(`mint-off-canvas-open`)&&(t.classList.remove(`mint-off-canvas-open`),e.classList.remove(`mint-off-canvas-open`),this._exitTimer!==null&&clearTimeout(this._exitTimer),this._exitTimer=window.setTimeout(()=>{this._finishExit()},220))}}_finishExit(){if(this.isOpen())return;this._exitTimer!==null&&(clearTimeout(this._exitTimer),this._exitTimer=null),this._overlay?.classList.add(`mint-off-canvas-hidden`),this._offCanvas?.classList.add(`mint-off-canvas-hidden`),this._dialogWasOpen=!1;let e=this._previousFocus;this._previousFocus=null,e?.isConnected&&e.focus()}};customElements.get(`mint-off-canvas`)||e.t(`mint-off-canvas`,t),module.exports=t;
|