monobill-mintui 0.6.722 → 0.6.723
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/off-canvas/OffCanvas.d.ts +1 -8
- package/dist/components/off-canvas/OffCanvas.d.ts.map +1 -1
- package/dist/components/off-canvas/browser.js +7 -63
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +7 -63
- package/dist/index.cjs +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +7 -63
- package/dist/off-canvas.css +1 -1
- package/dist/side-navigation.css +1 -1
- package/package.json +1 -1
|
@@ -15,10 +15,6 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
15
15
|
private _closeButton;
|
|
16
16
|
private _contentObserver;
|
|
17
17
|
private _renderFrame;
|
|
18
|
-
private _enterFrame;
|
|
19
|
-
private _exitTimer;
|
|
20
|
-
private _previousFocus;
|
|
21
|
-
private _dialogWasOpen;
|
|
22
18
|
private _dialogKeydownHandler;
|
|
23
19
|
constructor();
|
|
24
20
|
connectedCallback(): void;
|
|
@@ -37,10 +33,7 @@ declare class MintOffCanvas extends HTMLElement {
|
|
|
37
33
|
close(): void;
|
|
38
34
|
render(): void;
|
|
39
35
|
private _observeContentMutations;
|
|
40
|
-
private
|
|
41
|
-
private _animateEnter;
|
|
42
|
-
private _animateExit;
|
|
43
|
-
private _finishExit;
|
|
36
|
+
private _syncOpenClasses;
|
|
44
37
|
}
|
|
45
38
|
export default MintOffCanvas;
|
|
46
39
|
//# 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"],"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,qBAAqB,CAAgD;;IAO7E,iBAAiB,IAAI,IAAI;IAkBzB,oBAAoB,IAAI,IAAI;IAiB5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM9F,OAAO,CAAC,eAAe;IAQvB,KAAK,IAAI,MAAM;IAIf,UAAU,IAAI,MAAM;IAIpB,WAAW,IAAI,iBAAiB;IAQhC,UAAU,IAAI,OAAO;IAKrB,QAAQ,IAAI,MAAM;IAMlB,SAAS,IAAI,MAAM;IAMnB,OAAO,CAAC,kBAAkB;IAS1B,MAAM,IAAI,OAAO;IAKjB,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAyMd,OAAO,CAAC,wBAAwB;IAehC,OAAO,CAAC,gBAAgB;CAQzB;AAOD,eAAe,aAAa,CAAA"}
|
|
@@ -36,29 +36,15 @@ 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._dialogKeydownHandler = null;
|
|
40
40
|
}
|
|
41
41
|
connectedCallback() {
|
|
42
42
|
this.classList.add("mint-off-canvas-host"), this.style.display = "none", this.render(), this._observeContentMutations(), this._dialogKeydownHandler = (e) => {
|
|
43
|
-
|
|
44
|
-
if (e.key === "Escape") {
|
|
45
|
-
e.preventDefault(), e.stopPropagation(), this.close();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (e.key !== "Tab") return;
|
|
49
|
-
let t = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
50
|
-
if (!t) return;
|
|
51
|
-
let n = this._getDialogFocusableElements(t);
|
|
52
|
-
if (!n.length) {
|
|
53
|
-
e.preventDefault(), t.focus();
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
let r = n[0], i = n[n.length - 1], a = document.activeElement;
|
|
57
|
-
e.shiftKey && (a === r || !t.contains(a)) ? (e.preventDefault(), i.focus()) : !e.shiftKey && (a === i || !t.contains(a)) && (e.preventDefault(), r.focus());
|
|
43
|
+
this.isOpen() && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.close());
|
|
58
44
|
}, document.addEventListener("keydown", this._dialogKeydownHandler, !0);
|
|
59
45
|
}
|
|
60
46
|
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.
|
|
47
|
+
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._overlay?.remove(), this._offCanvas?.remove();
|
|
62
48
|
}
|
|
63
49
|
attributeChangedCallback(e, t, n) {
|
|
64
50
|
t !== n && this.isConnected && this.render();
|
|
@@ -101,7 +87,7 @@ var t = class extends HTMLElement {
|
|
|
101
87
|
}
|
|
102
88
|
render() {
|
|
103
89
|
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 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
|
|
90
|
+
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");
|
|
105
91
|
let o = document.body ?? document.documentElement;
|
|
106
92
|
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
93
|
let s = this._offCanvas.querySelector(".mint-off-canvas-panel");
|
|
@@ -123,7 +109,7 @@ var t = class extends HTMLElement {
|
|
|
123
109
|
}), e.parentElement && e.remove();
|
|
124
110
|
}), Array.from(this.children).forEach((e) => {
|
|
125
111
|
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);
|
|
126
|
-
}),
|
|
112
|
+
}), this._syncOpenClasses(n);
|
|
127
113
|
}
|
|
128
114
|
_observeContentMutations() {
|
|
129
115
|
this._contentObserver ||= new MutationObserver(() => {
|
|
@@ -134,50 +120,8 @@ var t = class extends HTMLElement {
|
|
|
134
120
|
attributeFilter: ["slot"]
|
|
135
121
|
});
|
|
136
122
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
if (e.closest("[hidden], [aria-hidden=\"true\"]")) return !1;
|
|
140
|
-
let t = window.getComputedStyle(e);
|
|
141
|
-
return t.display !== "none" && t.visibility !== "hidden";
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
_animateEnter() {
|
|
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) {
|
|
150
|
-
this._dialogWasOpen = !0;
|
|
151
|
-
let e = document.activeElement;
|
|
152
|
-
this._previousFocus = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
153
|
-
}
|
|
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());
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
_animateExit() {
|
|
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));
|
|
174
|
-
}
|
|
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();
|
|
123
|
+
_syncOpenClasses(e) {
|
|
124
|
+
!this._offCanvas || !this._overlay || (this._offCanvas.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-hidden", !e));
|
|
181
125
|
}
|
|
182
126
|
};
|
|
183
127
|
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._dialogKeydownHandler=null}connectedCallback(){this.classList.add(`mint-off-canvas-host`),this.style.display=`none`,this.render(),this._observeContentMutations(),this._dialogKeydownHandler=e=>{this.isOpen()&&e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())},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._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`);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)}),this._syncOpenClasses(n)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_syncOpenClasses(e){!this._offCanvas||!this._overlay||(this._offCanvas.classList.toggle(`mint-off-canvas-open`,e),this._overlay.classList.toggle(`mint-off-canvas-open`,e),this._overlay.classList.toggle(`mint-off-canvas-hidden`,!e))}};customElements.get(`mint-off-canvas`)||e.t(`mint-off-canvas`,t),module.exports=t;
|
|
@@ -24,29 +24,15 @@ var t = class extends HTMLElement {
|
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
26
|
constructor() {
|
|
27
|
-
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.
|
|
27
|
+
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._dialogKeydownHandler = null;
|
|
28
28
|
}
|
|
29
29
|
connectedCallback() {
|
|
30
30
|
this.classList.add("mint-off-canvas-host"), this.style.display = "none", this.render(), this._observeContentMutations(), this._dialogKeydownHandler = (e) => {
|
|
31
|
-
|
|
32
|
-
if (e.key === "Escape") {
|
|
33
|
-
e.preventDefault(), e.stopPropagation(), this.close();
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (e.key !== "Tab") return;
|
|
37
|
-
let t = this._offCanvas?.querySelector(".mint-off-canvas-panel");
|
|
38
|
-
if (!t) return;
|
|
39
|
-
let n = this._getDialogFocusableElements(t);
|
|
40
|
-
if (!n.length) {
|
|
41
|
-
e.preventDefault(), t.focus();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let r = n[0], i = n[n.length - 1], a = document.activeElement;
|
|
45
|
-
e.shiftKey && (a === r || !t.contains(a)) ? (e.preventDefault(), i.focus()) : !e.shiftKey && (a === i || !t.contains(a)) && (e.preventDefault(), r.focus());
|
|
31
|
+
this.isOpen() && e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), this.close());
|
|
46
32
|
}, document.addEventListener("keydown", this._dialogKeydownHandler, !0);
|
|
47
33
|
}
|
|
48
34
|
disconnectedCallback() {
|
|
49
|
-
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.
|
|
35
|
+
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._overlay?.remove(), this._offCanvas?.remove();
|
|
50
36
|
}
|
|
51
37
|
attributeChangedCallback(e, t, n) {
|
|
52
38
|
t !== n && this.isConnected && this.render();
|
|
@@ -89,7 +75,7 @@ var t = class extends HTMLElement {
|
|
|
89
75
|
}
|
|
90
76
|
render() {
|
|
91
77
|
let e = this.getId(), t = this.getHeading(), n = this.isOpen(), r = this.getPosition(), i = this.isFullPage(), a = this.getHeight();
|
|
92
|
-
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
|
|
78
|
+
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");
|
|
93
79
|
let o = document.body ?? document.documentElement;
|
|
94
80
|
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);
|
|
95
81
|
let s = this._offCanvas.querySelector(".mint-off-canvas-panel");
|
|
@@ -111,7 +97,7 @@ var t = class extends HTMLElement {
|
|
|
111
97
|
}), e.parentElement && e.remove();
|
|
112
98
|
}), Array.from(this.children).forEach((e) => {
|
|
113
99
|
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);
|
|
114
|
-
}),
|
|
100
|
+
}), this._syncOpenClasses(n);
|
|
115
101
|
}
|
|
116
102
|
_observeContentMutations() {
|
|
117
103
|
this._contentObserver ||= new MutationObserver(() => {
|
|
@@ -122,50 +108,8 @@ var t = class extends HTMLElement {
|
|
|
122
108
|
attributeFilter: ["slot"]
|
|
123
109
|
});
|
|
124
110
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (e.closest("[hidden], [aria-hidden=\"true\"]")) return !1;
|
|
128
|
-
let t = window.getComputedStyle(e);
|
|
129
|
-
return t.display !== "none" && t.visibility !== "hidden";
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
_animateEnter() {
|
|
133
|
-
let e = this._offCanvas?.querySelector(".mint-off-canvas-panel"), t = this._offCanvas, n = this._overlay;
|
|
134
|
-
if (!e || !t || !n || this._enterFrame !== null || t.classList.contains("mint-off-canvas-open")) return;
|
|
135
|
-
this._exitTimer !== null && (clearTimeout(this._exitTimer), this._exitTimer = null);
|
|
136
|
-
let r = !this._dialogWasOpen;
|
|
137
|
-
if (r) {
|
|
138
|
-
this._dialogWasOpen = !0;
|
|
139
|
-
let e = document.activeElement;
|
|
140
|
-
this._previousFocus = e instanceof HTMLElement && e !== document.body ? e : null;
|
|
141
|
-
}
|
|
142
|
-
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(() => {
|
|
143
|
-
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());
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
_animateExit() {
|
|
147
|
-
let e = this._offCanvas, t = this._overlay;
|
|
148
|
-
if (!(!e || !t || e.classList.contains("mint-off-canvas-hidden"))) {
|
|
149
|
-
if (!this._offCanvas?.querySelector(".mint-off-canvas-panel")) {
|
|
150
|
-
t.classList.add("mint-off-canvas-hidden"), e.classList.add("mint-off-canvas-hidden"), this._dialogWasOpen = !1;
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
if (this._enterFrame !== null) {
|
|
154
|
-
cancelAnimationFrame(this._enterFrame), this._enterFrame = null, t.classList.add("mint-off-canvas-hidden"), e.classList.add("mint-off-canvas-hidden"), this._dialogWasOpen = !1;
|
|
155
|
-
let n = this._previousFocus;
|
|
156
|
-
this._previousFocus = null, n?.isConnected && n.focus();
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
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(() => {
|
|
160
|
-
this._finishExit();
|
|
161
|
-
}, 220));
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
_finishExit() {
|
|
165
|
-
if (this.isOpen()) return;
|
|
166
|
-
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;
|
|
167
|
-
let e = this._previousFocus;
|
|
168
|
-
this._previousFocus = null, e?.isConnected && e.focus();
|
|
111
|
+
_syncOpenClasses(e) {
|
|
112
|
+
!this._offCanvas || !this._overlay || (this._offCanvas.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-open", e), this._overlay.classList.toggle("mint-off-canvas-hidden", !e));
|
|
169
113
|
}
|
|
170
114
|
};
|
|
171
115
|
customElements.get("mint-off-canvas") || e("mint-off-canvas", t);
|