monobill-mintui 0.6.663 → 0.6.665
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-Buw_dyiT.js → confirm-action-CYr8kA4R.js} +1 -1
- package/dist/components/chunks/{confirm-action-C8W8VFAY.js → confirm-action-tRfK5xQP.js} +1 -1
- package/dist/components/chunks/{modal-CmduVvfc.js → modal-DPJrUEb3.js} +16 -11
- package/dist/components/chunks/modal-VURZX7TM.js +1 -0
- package/dist/components/chunks/sortable-BmObFEEn.js +1 -0
- package/dist/components/chunks/{sortable-CNlF0_gv.js → sortable-C46XSDeN.js} +27 -7
- 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 +1 -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/sortable/Sortable.d.ts +4 -0
- package/dist/components/sortable/Sortable.d.ts.map +1 -1
- package/dist/components/sortable/browser.js +1 -1
- package/dist/components/sortable/index.cjs +1 -1
- package/dist/components/sortable/index.js +1 -1
- package/dist/components/tree/browser.js +2 -2
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.css +1 -1
- package/dist/index.js +43 -18
- package/dist/modal.css +1 -1
- package/package.json +1 -1
- package/dist/components/chunks/modal-qGRlOaQe.js +0 -1
- package/dist/components/chunks/sortable-CVK48xj1.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./register-element-BFYmIynH.js";
|
|
2
2
|
import "./text-Bmfl6CxJ.js";
|
|
3
3
|
import "./button-h2EuXJM5.js";
|
|
4
|
-
import "./modal-
|
|
4
|
+
import "./modal-DPJrUEb3.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-Cpl5ljSe.js`),require(`./button-D-yKHP5o.js`),require(`./modal-
|
|
1
|
+
const e=require(`./register-element-tCL_F1YI.js`);require(`./text-Cpl5ljSe.js`),require(`./button-D-yKHP5o.js`),require(`./modal-VURZX7TM.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}});
|
|
@@ -34,7 +34,8 @@ var a = class extends HTMLElement {
|
|
|
34
34
|
return [
|
|
35
35
|
"id",
|
|
36
36
|
"heading",
|
|
37
|
-
"open"
|
|
37
|
+
"open",
|
|
38
|
+
"size"
|
|
38
39
|
];
|
|
39
40
|
}
|
|
40
41
|
constructor() {
|
|
@@ -62,6 +63,10 @@ var a = class extends HTMLElement {
|
|
|
62
63
|
getHeading() {
|
|
63
64
|
return this.getAttribute("heading") || "";
|
|
64
65
|
}
|
|
66
|
+
getSize() {
|
|
67
|
+
let e = this.getAttribute("size");
|
|
68
|
+
return e === "small" || e === "large" ? e : "default";
|
|
69
|
+
}
|
|
65
70
|
isOpen() {
|
|
66
71
|
return this.hasAttribute("open");
|
|
67
72
|
}
|
|
@@ -72,24 +77,24 @@ var a = class extends HTMLElement {
|
|
|
72
77
|
this.removeAttribute("open");
|
|
73
78
|
}
|
|
74
79
|
render() {
|
|
75
|
-
let e = this.getId(), t = this.getHeading(), n = this.isOpen();
|
|
80
|
+
let e = this.getId(), t = this.getHeading(), n = this.isOpen(), i = this.getSize();
|
|
76
81
|
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) {
|
|
77
82
|
let e = this._modal.querySelector(".modal-content");
|
|
78
83
|
e || (e = document.createElement("div"), e.className = "modal-content", this._modal.appendChild(e)), this._renderedOpen || (this._renderedOpen = !0, r(this), this._animateEnter());
|
|
79
84
|
} else this._renderedOpen && (this._renderedOpen = !1, this._animateExit());
|
|
80
|
-
let
|
|
81
|
-
|
|
82
|
-
let
|
|
83
|
-
t ? (
|
|
85
|
+
let a = this._modal.querySelector(".modal-content");
|
|
86
|
+
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));
|
|
87
|
+
let o = this._headingSlot.querySelector("mint-text");
|
|
88
|
+
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) => {
|
|
84
89
|
e.parentElement !== this._headingSlot && this._headingSlot.appendChild(e);
|
|
85
|
-
}), 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"),
|
|
90
|
+
}), 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) => {
|
|
86
91
|
e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
87
92
|
});
|
|
88
|
-
let
|
|
89
|
-
if (
|
|
90
|
-
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"),
|
|
93
|
+
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;
|
|
94
|
+
if (s.length || l) {
|
|
95
|
+
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));
|
|
91
96
|
let e = this._actionsSlot.querySelector("mint-stack");
|
|
92
|
-
e || (e = document.createElement("mint-stack"), e.setAttribute("direction", "horizontal"), e.setAttribute("align-content", "right"), e.className = "mint-actions-stack", this._actionsSlot.appendChild(e)),
|
|
97
|
+
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) => {
|
|
93
98
|
Array.from(t.children).forEach((t) => e.appendChild(t)), t.remove();
|
|
94
99
|
});
|
|
95
100
|
} else this._actionsSlot &&= (this._actionsSlot.remove(), null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./icon-_eTWDyJr.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./text-Cpl5ljSe.js`),require(`./button-D-yKHP5o.js`),require(`./stack-Bdl46AdO.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(()=>{if(!this.isOpen())return;let t=window.getComputedStyle(e).borderRadius;this._setTransformOrigin(e),e.style.borderRadius=`50%`,e.style.transform=`scale(0.1, 0.2)`,e.style.opacity=`0.9`,e.getBoundingClientRect(),e.style.transition=`opacity 320ms ease-out, transform 360ms cubic-bezier(0.2, 0.8, 0.2, 1), border-radius 360ms cubic-bezier(0.2, 0.8, 0.2, 1)`,requestAnimationFrame(()=>{this.isOpen()&&(e.style.transform=`scale(1)`,e.style.opacity=`1`,e.style.borderRadius=t,window.setTimeout(()=>{this.isOpen()&&(e.style.transition=``,e.style.transform=`none`)},380))})}))}_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}_setTransformOrigin(e){let t=this._findTriggerElement(this._triggerElement);this._triggerElement=t;let n=this._findTriggerPoint(t);if(n){let t=e.getBoundingClientRect();e.style.transformOrigin=`${n.x-t.left}px ${n.y-t.top}px`,this._triggerPoint=n;return}this._triggerPoint={x:window.innerWidth/2,y:0};let r=e.getBoundingClientRect();e.style.transformOrigin=`${this._triggerPoint.x-r.left}px ${this._triggerPoint.y-r.top}px`}_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 220ms ease-in, transform 260ms cubic-bezier(0.4, 0, 1, 1), border-radius 260ms cubic-bezier(0.4, 0, 1, 1)`,e.style.borderRadius=`50%`,e.style.transform=`scale(0.1, 0.2)`,e.style.opacity=`0.9`,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.borderRadius=``,e.style.transition=``,i(this))},280)}};typeof customElements<`u`&&!customElements.get(`mint-modal`)&&e.t(`mint-modal`,a),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return a}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./register-element-tCL_F1YI.js`);var t=`mint-sortable-placeholder`,n=`mint-sortable-dragging`,r=class e extends HTMLElement{static get observedAttributes(){return[`direction`,`gap`,`text-align`,`align-content`,`scroll-max-height`,`disabled`,`handle-selector`,`scroll-sensitivity`,`scroll-speed`,`animation-duration`,`item-key-attribute`,`group`]}constructor(){super(),this._pointerId=null,this._dragEl=null,this._placeholder=null,this._listRoot=this,this._startIndex=0,this._pointerStartX=0,this._pointerStartY=0,this._scrollRaf=null,this._childObserver=null,this._pointerBoundRoot=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropAtEnd=!1,this._dropRejected=!1,this._sortStatus=null,this._flipCleanupTimers=new WeakMap,this._lastPreviewRoot=null,this._lastPreviewIndex=-1,this._keyboardKeydownHandler=e=>this._onKeyboardReorder(e),this._onListPointerDown=e=>{let t=e;if(this._isDisabled()||this._pointerId!==null||t.button!==0)return;let n=t.target;if(!n||!this.contains(n))return;let r=(n instanceof Element?n:n.parentElement)?.closest(`mint-sortable`);if(r&&r!==this)return;let i=this._closestSortableItem(n);if(!i||!this._listRoot.contains(i)||i.hasAttribute(`data-sortable-disabled`))return;let a=this._getHandleSelector();if(a){let e=t.target.closest(a);if(!e||!i.contains(e))return}t.preventDefault(),this._startDrag(t,i)},this._boundPointerMove=this._onPointerMove.bind(this),this._boundPointerUp=this._onPointerUp.bind(this),this._boundPointerCancel=this._onPointerCancel.bind(this)}connectedCallback(){this.classList.add(`mint-sortable`),this._syncInnerStackAttributes(),this._applyHostScrollAndLayout(),this.addEventListener(`keydown`,this._keyboardKeydownHandler),this._observeInnerStack()}disconnectedCallback(){this._unobserveInnerStack(),this.removeEventListener(`keydown`,this._keyboardKeydownHandler),this._teardownDrag(),this._pointerBoundRoot&&=(this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),null)}attributeChangedCallback(e,t,n){t!==n&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}_observeInnerStack(){this._childObserver||(this._childObserver=new MutationObserver(()=>{this._pointerId===null&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}),this._childObserver.observe(this,{childList:!0}))}_unobserveInnerStack(){this._childObserver&&=(this._childObserver.disconnect(),null)}_getInnerStack(){for(let e=0;e<this.children.length;e++){let t=this.children[e];if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===`MINT-STACK`)return t}return null}_resolveListRoot(){return this._getInnerStack()??this}_getItemKeyAttribute(){return this.getAttribute(`item-key-attribute`)?.trim()||`data-sortable-id`}_collectOrderedKeys(){let e=this._resolveListRoot(),n=this._getItemKeyAttribute(),r=[];for(let i=0;i<e.children.length;i++){let a=e.children[i];if(a.nodeType!==Node.ELEMENT_NODE)continue;let o=a;o.classList.contains(t)||o.hasAttribute(`data-mint-sortable-status`)||r.push(o.getAttribute(n)??``)}return r}_syncInnerStackAttributes(){let e=this._getInnerStack();if(!e)return;let t=this.getDirection(),n=this.getGap(),r=this.getTextAlign();e.setAttribute(`direction`,t),e.setAttribute(`gap`,String(n)),r?e.setAttribute(`text-align`,r):e.removeAttribute(`text-align`);let i=this.getAlignContent();i?e.setAttribute(`align-content`,i):e.removeAttribute(`align-content`)}_applyHostScrollAndLayout(){this._listRoot=this._resolveListRoot();let e=this.getAttribute(`scroll-max-height`);e?(this.style.maxHeight=e,this.style.overflowY=`auto`,this.style.overflowX=`hidden`,this.classList.add(`mint-sortable-scrollable`)):(this.style.maxHeight=``,this.style.overflowY=``,this.style.overflowX=``,this.classList.remove(`mint-sortable-scrollable`));let t=this._getInnerStack();this.classList.toggle(`mint-sortable-has-inner-stack`,!!t);let n=this.getDirection(),r=this.getAlignContent(),i=Math.min(12,Math.max(1,Math.round(this.getGap()))),a=this.getTextAlign();this.style.setProperty(`--mint-sortable-direction`,n===`horizontal`?`row`:`column`),this.style.setProperty(`--mint-sortable-gap`,`${i*.25}rem`),this.style.setProperty(`--mint-sortable-text-align`,a||`initial`),this.style.setProperty(`--mint-sortable-button-justify`,a===`left`?`flex-start`:a===`right`?`flex-end`:`center`);let o=r?r===`left`?`flex-start`:r===`right`?`flex-end`:`center`:``,s=n===`vertical`&&o||`stretch`,c=n===`horizontal`&&o||`flex-start`;this.style.setProperty(`--mint-sortable-cross-align`,s),this.style.setProperty(`--mint-sortable-main-align`,c),this._ensureListPointerBinding(),this._syncKeyboardAccessibility()}_syncKeyboardAccessibility(){let e=this._resolveListRoot();e.hasAttribute(`role`)||e.setAttribute(`role`,`list`),this._sortStatus||(this._sortStatus=document.createElement(`div`),this._sortStatus.className=`mint-sortable-status`,this._sortStatus.setAttribute(`role`,`status`),this._sortStatus.setAttribute(`aria-live`,`polite`),this._sortStatus.setAttribute(`aria-atomic`,`true`),this._sortStatus.setAttribute(`data-mint-sortable-status`,``),this.appendChild(this._sortStatus)),this._getLayoutChildren().forEach(e=>{e.classList.contains(t)||(e.hasAttribute(`role`)||e.setAttribute(`role`,`listitem`),e.hasAttribute(`tabindex`)||(e.tabIndex=0),e.setAttribute(`aria-keyshortcuts`,`Alt+ArrowUp Alt+ArrowDown`),e.hasAttribute(`aria-roledescription`)||e.setAttribute(`aria-roledescription`,`sortable item`))})}_onKeyboardReorder(e){if(this._isDisabled()||!e.altKey||![`ArrowUp`,`ArrowDown`].includes(e.key))return;let n=e.target instanceof Element?e.target:null,r=n?.closest(`mint-sortable`);if(r&&r!==this)return;let i=n?this._closestSortableItem(n):null;if(!i||i.hasAttribute(`data-sortable-disabled`))return;let a=this._getLayoutChildren().filter(e=>!e.classList.contains(t)),o=a.indexOf(i),s=o+(e.key===`ArrowUp`?-1:1);if(o<0||s<0||s>=a.length)return;e.preventDefault();let c=a[s];e.key===`ArrowUp`?this._listRoot.insertBefore(i,c):this._listRoot.insertBefore(c,i),i.focus({preventScroll:!0});let l=this._collectOrderedKeys(),u=this._indexOfItem(i),d=i.getAttribute(`aria-label`)||i.textContent?.trim().replace(/\s+/g,` `)||`Item`;this._sortStatus&&(this._sortStatus.textContent=`${d} moved to position ${u+1} of ${a.length}.`);let f=this.getAttribute(`data-tree-parent-id`)||null,p={oldIndex:o,newIndex:u,keys:l,itemId:i.getAttribute(this._getItemKeyAttribute())||``,oldParentId:f,newParentId:f,sourceContainerId:this.id||null,destinationContainerId:this.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-change`,{bubbles:!0,composed:!0,detail:p})),this.dispatchEvent(new CustomEvent(`mint-sortable-order`,{bubbles:!0,composed:!0,detail:{keys:l}}))}getDirection(){return(this.getAttribute(`direction`)||`vertical`)===`horizontal`?`horizontal`:`vertical`}getGap(){let e=this.getAttribute(`gap`)||`3`,t=parseFloat(e);return Number.isFinite(t)?t:3}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getAlignContent(){let e=(this.getAttribute(`align-content`)||``).trim().toLowerCase();return e===`left`||e===`right`||e===`center`?e:``}_isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}_getHandleSelector(){let e=this.getAttribute(`handle-selector`);return e&&e.trim()?e.trim():null}_getScrollSensitivity(){let e=parseFloat(this.getAttribute(`scroll-sensitivity`)||`48`);return Number.isFinite(e)?e:48}_getScrollSpeed(){let e=parseFloat(this.getAttribute(`scroll-speed`)||`12`);return Number.isFinite(e)?e:12}_getAnimationDurationMs(){let e=parseFloat(this.getAttribute(`animation-duration`)||`220`);return Number.isFinite(e)?Math.max(0,e):220}_ensureListPointerBinding(){let e=this._resolveListRoot();this._pointerBoundRoot!==e&&(this._pointerBoundRoot&&this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),e.addEventListener(`pointerdown`,this._onListPointerDown),this._pointerBoundRoot=e,this._listRoot=e)}_closestSortableItem(e){let r=e;for(;r&&r!==this._listRoot;){if(r.nodeType===Node.ELEMENT_NODE){let e=r;if(e.classList.contains(t)||e.classList.contains(n))return null;if(r.parentElement===this._listRoot)return e}r=r.parentElement}return null}_startDrag(e,r){this._listRoot=this._resolveListRoot(),this._restoreAfter=r.nextElementSibling,this._originListRoot=this._listRoot,this._originNextSibling=r.nextElementSibling,this._dropList=this,this._dropAtEnd=!1,this._dropRejected=!1,this._dragEl=r,this._pointerId=e.pointerId,this._startIndex=this._indexOfItem(r);let i=r.getBoundingClientRect();this._pointerStartX=e.clientX,this._pointerStartY=e.clientY;let a=document.createElement(`div`);a.className=t,a.style.minHeight=`${i.height}px`,a.style.minWidth=`${i.width}px`,a.setAttribute(`aria-hidden`,`true`),this._placeholder=a,this._listRoot.insertBefore(a,r),r.classList.add(n),r.style.position=`fixed`,r.style.left=`${i.left}px`,r.style.top=`${i.top}px`,r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,r.style.margin=`0`,r.style.zIndex=`10000`,r.style.boxSizing=`border-box`,r.style.pointerEvents=`none`,r.style.touchAction=`none`,r.style.transform=`translate3d(0, 0, 0) scale(1.015)`,r.style.transformOrigin=`center center`,r.style.willChange=`transform`,r.setPointerCapture(e.pointerId);let o=this._collectOrderedKeys(),s={index:this._startIndex,itemId:r.getAttribute(this._getItemKeyAttribute())||``,keys:o,sourceContainerId:this.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-start`,{bubbles:!0,composed:!0,detail:s})),this.dispatchEvent(new CustomEvent(`sort-start`,{bubbles:!0,composed:!0,detail:s})),window.addEventListener(`pointermove`,this._boundPointerMove,{passive:!1}),window.addEventListener(`pointerup`,this._boundPointerUp),window.addEventListener(`pointercancel`,this._boundPointerCancel)}_indexOfItem(e){let n=0;for(let r=0;r<this._listRoot.children.length;r++){let i=this._listRoot.children[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;let a=i;if(!a.classList.contains(t)){if(a===e)return n;n++}}return-1}_getLayoutChildren(){return Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&!e.hasAttribute(`data-mint-sortable-status`))}_onPointerMove(e){if(e.pointerId!==this._pointerId||!this._dragEl||!this._placeholder)return;e.preventDefault();let t=e.clientX-this._pointerStartX,n=e.clientY-this._pointerStartY;this._dragEl.style.transform=`translate3d(${t}px, ${n}px, 0) scale(1.015)`,this.dispatchEvent(new CustomEvent(`mint-sortable-drag`,{bubbles:!0,composed:!0,detail:{item:this._dragEl,source:this,clientX:e.clientX,clientY:e.clientY}})),this._autoScroll(e),this._maybeMovePlaceholder(e)}_resolveDropList(t){let n=document.elementFromPoint(t.clientX,t.clientY),r=n?.closest(`[data-mint-sortable-drop-container]`);this._dropAtEnd=!!r?.hasAttribute(`data-mint-sortable-drop-end`);let i=r?.getAttribute(`data-mint-sortable-drop-container`),a=i?document.getElementById(i):null,o=a?.matches(`mint-sortable`)?a:n?.closest(`mint-sortable`),s=o instanceof e?o:this,c=this.getAttribute(`group`)?.trim(),l=!!(c&&s.getAttribute(`group`)?.trim()===c),u=!!(this._dragEl&&(s===this._dragEl||this._dragEl.contains(s))),d=s===this||l&&s.isConnected&&!u,f=new CustomEvent(`mint-sortable-drag-over`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:this._dragEl,source:this,target:s,clientX:t.clientX,clientY:t.clientY}});return this.dispatchEvent(f),this._dropRejected=!d||f.defaultPrevented,this._dropRejected?this:s}_autoScroll(e){let t=this;for(;t&&t!==document.body;){let e=getComputedStyle(t);if(/(auto|scroll)/.test(`${e.overflowY} ${e.overflow}`)&&t.scrollHeight>t.clientHeight||t.style.maxHeight)break;t=t.parentElement}if(!t||t===document.body)return;let n=this._getScrollSensitivity(),r=this._getScrollSpeed(),i=t.getBoundingClientRect();this._scrollRaf!==null&&cancelAnimationFrame(this._scrollRaf),this._scrollRaf=requestAnimationFrame(()=>{this._scrollRaf=null;let a=0;e.clientY<i.top+n?a=-r:e.clientY>i.bottom-n&&(a=r),a!==0&&(t.scrollTop+=a,this._maybeMovePlaceholder(e))})}_maybeMovePlaceholder(e){let t=this._placeholder,n=this._dragEl;if(!t||!n)return;let r=this._resolveDropList(e),i=r._resolveListRoot();if(i===n||n.contains(i))return;t.parentElement!==i&&r._flipAnimate(()=>i.appendChild(t)),this._dropList=r;let a=r.getDirection()===`horizontal`,o=a?e.clientX:e.clientY,s=this.hasAttribute(`data-mint-sortable-full-crossing`);if(this._dropAtEnd&&r!==this){(t.parentElement!==i||i.lastElementChild!==t)&&r._flipAnimate(()=>i.appendChild(t)),this._dispatchPreview(r,i,t,n);return}let c=Array.from(i.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n&&e!==t),l=null;for(let e of c){let n=e.getBoundingClientRect(),r=a?n.left:n.top,c=a?n.left+n.width:n.top+n.height;if(s){if(o<r){l=e;break}if(o<=c&&Array.prototype.indexOf.call(i.children,t)<Array.prototype.indexOf.call(i.children,e)){l=e;break}}else if(o<(a?n.left+n.width/2:n.top+n.height/2)){l=e;break}}let u=Array.from(i.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n),d=u.length>0&&u[u.length-1]===t;(l?!(t.nextSibling===l&&t.parentNode===i):!d)&&(r._flipAnimate(()=>{l?i.insertBefore(t,l):i.appendChild(t)}),this._dispatchPreview(r,i,t,n))}_dispatchPreview(e,t,n,r){let i=Array.from(t.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==r&&!e.hasAttribute(`data-mint-sortable-status`)),a=i.indexOf(n);if(a<0||this._lastPreviewRoot===t&&this._lastPreviewIndex===a)return;this._lastPreviewRoot=t,this._lastPreviewIndex=a;let o=this._getItemKeyAttribute(),s=i.map(e=>e===n?r.getAttribute(o)||``:e.getAttribute(o)||``),c={itemId:r.getAttribute(o)||``,oldIndex:this._startIndex,newIndex:a,keys:s,sourceContainerId:this.id||null,destinationContainerId:e.id||null};this.dispatchEvent(new CustomEvent(`mint-sortable-preview`,{bubbles:!0,composed:!0,detail:c}))}_flipAnimate(e){let t=this._dragEl,n=this._getAnimationDurationMs(),r=this._getLayoutChildren().filter(e=>e!==t),i=new Map;if(r.forEach(e=>{let t=this._flipCleanupTimers.get(e);t!==void 0&&(window.clearTimeout(t),this._flipCleanupTimers.delete(e)),i.set(e,e.getBoundingClientRect()),e.style.transition=`none`,e.style.transform=``}),r.length&&r[0].offsetHeight,e(),n<=0||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches){r.forEach(e=>{e.style.transition=``,e.style.transform=``});return}r.forEach(e=>{let t=i.get(e);if(!t)return;let r=e.getBoundingClientRect(),a=t.left-r.left,o=t.top-r.top;Math.abs(a)<.5&&Math.abs(o)<.5||(e.style.transition=`none`,e.style.transform=`translate(${a}px, ${o}px)`,requestAnimationFrame(()=>{e.style.transition=`transform ${n}ms cubic-bezier(0.22, 1, 0.36, 1)`,e.style.transform=``;let t=()=>{e.removeEventListener(`transitionend`,t),e.style.transition=``,e.style.transform=``,this._flipCleanupTimers.delete(e)};e.addEventListener(`transitionend`,t,{once:!0}),this._flipCleanupTimers.set(e,window.setTimeout(t,n+40))}))})}_onPointerUp(e){e.pointerId===this._pointerId&&(this._maybeMovePlaceholder(e),this._finishDrag(!1))}_onPointerCancel(e){e.pointerId===this._pointerId&&this._finishDrag(!0)}_finishDrag(e){let t=this._dragEl,r=this._placeholder;if(!t||this._pointerId===null){this._teardownDrag();return}try{t.releasePointerCapture(this._pointerId)}catch{}window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel);let i=this._dropList??this,a=i._resolveListRoot();!e&&!this._dropRejected&&this._dropAtEnd&&i!==this&&r?.parentNode===a&&a.appendChild(r);let o=this.getAttribute(`data-tree-parent-id`)||null,s=i.getAttribute(`data-tree-parent-id`)||null,c=this._indexOfItem(t),l=r?.parentNode===a?Array.from(a.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==t&&!e.hasAttribute(`data-mint-sortable-status`)).indexOf(r):c,u=new CustomEvent(`mint-sortable-before-drop`,{bubbles:!0,composed:!0,cancelable:!0,detail:{item:t,source:this,target:i,oldIndex:c,newIndex:l,oldParentId:o,newParentId:s}});e||this.dispatchEvent(u);let d=e||this._dropRejected||u.defaultPrevented;if(d){let e=this._originListRoot??this._listRoot,n=this._originNextSibling??this._restoreAfter;n&&n.parentNode===e?e.insertBefore(t,n):e.appendChild(t)}else r?.parentNode&&r.parentNode.insertBefore(t,r);r?.remove(),this._placeholder=null,t.classList.remove(n),t.style.cssText=``;let f=d?c:i._indexOfItem(t);this._pointerId=null,this._dragEl=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropAtEnd=!1,this._dropRejected=!1,this._lastPreviewRoot=null,this._lastPreviewIndex=-1;let p=this._collectOrderedKeys(),m=i._collectOrderedKeys(),h=!d&&(!d&&o!==s||f!==c),g=t.getAttribute(this._getItemKeyAttribute())||``,_={oldIndex:c,newIndex:f,cancelled:d,keys:p,sourceKeys:p,destinationKeys:m,oldParentId:o,newParentId:s,sourceContainerId:this.id||null,destinationContainerId:i.id||null,itemId:g};this.dispatchEvent(new CustomEvent(`mint-sortable-end`,{bubbles:!0,composed:!0,detail:_})),this.dispatchEvent(new CustomEvent(`sort-stop`,{bubbles:!0,composed:!0,detail:_})),h&&(this.dispatchEvent(new CustomEvent(`mint-sortable-change`,{bubbles:!0,composed:!0,detail:_})),this.dispatchEvent(new CustomEvent(`mint-sortable-order`,{bubbles:!0,composed:!0,detail:{keys:p,sourceKeys:p,destinationKeys:m,oldParentId:o,newParentId:s,itemId:g}})))}_teardownDrag(){if(this._scrollRaf!==null&&(cancelAnimationFrame(this._scrollRaf),this._scrollRaf=null),window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel),this._dragEl){try{this._pointerId!==null&&this._dragEl.releasePointerCapture(this._pointerId)}catch{}this._dragEl.classList.remove(n),this._dragEl.style.cssText=``}this._placeholder?.remove(),this._placeholder=null,this._dragEl=null,this._pointerId=null,this._restoreAfter=null,this._originListRoot=null,this._originNextSibling=null,this._dropList=null,this._dropRejected=!1,this._lastPreviewRoot=null,this._lastPreviewIndex=-1}};customElements.get(`mint-sortable`)||e.t(`mint-sortable`,r),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
@@ -18,7 +18,7 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
18
18
|
];
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
|
-
super(), this._pointerId = null, this._dragEl = null, this._placeholder = null, this._listRoot = this, this._startIndex = 0, this._pointerStartX = 0, this._pointerStartY = 0, this._scrollRaf = null, this._childObserver = null, this._pointerBoundRoot = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropAtEnd = !1, this._dropRejected = !1, this._sortStatus = null, this._flipCleanupTimers = /* @__PURE__ */ new WeakMap(), this._keyboardKeydownHandler = (e) => this._onKeyboardReorder(e), this._onListPointerDown = (e) => {
|
|
21
|
+
super(), this._pointerId = null, this._dragEl = null, this._placeholder = null, this._listRoot = this, this._startIndex = 0, this._pointerStartX = 0, this._pointerStartY = 0, this._scrollRaf = null, this._childObserver = null, this._pointerBoundRoot = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropAtEnd = !1, this._dropRejected = !1, this._sortStatus = null, this._flipCleanupTimers = /* @__PURE__ */ new WeakMap(), this._lastPreviewRoot = null, this._lastPreviewIndex = -1, this._keyboardKeydownHandler = (e) => this._onKeyboardReorder(e), this._onListPointerDown = (e) => {
|
|
22
22
|
let t = e;
|
|
23
23
|
if (this._isDisabled() || this._pointerId !== null || t.button !== 0) return;
|
|
24
24
|
let n = t.target;
|
|
@@ -196,7 +196,9 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
196
196
|
a.className = t, a.style.minHeight = `${i.height}px`, a.style.minWidth = `${i.width}px`, a.setAttribute("aria-hidden", "true"), this._placeholder = a, this._listRoot.insertBefore(a, r), r.classList.add(n), r.style.position = "fixed", r.style.left = `${i.left}px`, r.style.top = `${i.top}px`, r.style.width = `${i.width}px`, r.style.height = `${i.height}px`, r.style.margin = "0", r.style.zIndex = "10000", r.style.boxSizing = "border-box", r.style.pointerEvents = "none", r.style.touchAction = "none", r.style.transform = "translate3d(0, 0, 0) scale(1.015)", r.style.transformOrigin = "center center", r.style.willChange = "transform", r.setPointerCapture(e.pointerId);
|
|
197
197
|
let o = this._collectOrderedKeys(), s = {
|
|
198
198
|
index: this._startIndex,
|
|
199
|
-
|
|
199
|
+
itemId: r.getAttribute(this._getItemKeyAttribute()) || "",
|
|
200
|
+
keys: o,
|
|
201
|
+
sourceContainerId: this.id || null
|
|
200
202
|
};
|
|
201
203
|
this.dispatchEvent(new CustomEvent("mint-sortable-start", {
|
|
202
204
|
bubbles: !0,
|
|
@@ -279,7 +281,7 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
279
281
|
t.parentElement !== i && r._flipAnimate(() => i.appendChild(t)), this._dropList = r;
|
|
280
282
|
let a = r.getDirection() === "horizontal", o = a ? e.clientX : e.clientY, s = this.hasAttribute("data-mint-sortable-full-crossing");
|
|
281
283
|
if (this._dropAtEnd && r !== this) {
|
|
282
|
-
(t.parentElement !== i || i.lastElementChild !== t) && r._flipAnimate(() => i.appendChild(t));
|
|
284
|
+
(t.parentElement !== i || i.lastElementChild !== t) && r._flipAnimate(() => i.appendChild(t)), this._dispatchPreview(r, i, t, n);
|
|
283
285
|
return;
|
|
284
286
|
}
|
|
285
287
|
let c = Array.from(i.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && e !== n && e !== t), l = null;
|
|
@@ -300,9 +302,27 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
304
|
let u = Array.from(i.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && e !== n), d = u.length > 0 && u[u.length - 1] === t;
|
|
303
|
-
(l ? !(t.nextSibling === l && t.parentNode === i) : !d) && r._flipAnimate(() => {
|
|
305
|
+
(l ? !(t.nextSibling === l && t.parentNode === i) : !d) && (r._flipAnimate(() => {
|
|
304
306
|
l ? i.insertBefore(t, l) : i.appendChild(t);
|
|
305
|
-
});
|
|
307
|
+
}), this._dispatchPreview(r, i, t, n));
|
|
308
|
+
}
|
|
309
|
+
_dispatchPreview(e, t, n, r) {
|
|
310
|
+
let i = Array.from(t.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && e !== r && !e.hasAttribute("data-mint-sortable-status")), a = i.indexOf(n);
|
|
311
|
+
if (a < 0 || this._lastPreviewRoot === t && this._lastPreviewIndex === a) return;
|
|
312
|
+
this._lastPreviewRoot = t, this._lastPreviewIndex = a;
|
|
313
|
+
let o = this._getItemKeyAttribute(), s = i.map((e) => e === n ? r.getAttribute(o) || "" : e.getAttribute(o) || ""), c = {
|
|
314
|
+
itemId: r.getAttribute(o) || "",
|
|
315
|
+
oldIndex: this._startIndex,
|
|
316
|
+
newIndex: a,
|
|
317
|
+
keys: s,
|
|
318
|
+
sourceContainerId: this.id || null,
|
|
319
|
+
destinationContainerId: e.id || null
|
|
320
|
+
};
|
|
321
|
+
this.dispatchEvent(new CustomEvent("mint-sortable-preview", {
|
|
322
|
+
bubbles: !0,
|
|
323
|
+
composed: !0,
|
|
324
|
+
detail: c
|
|
325
|
+
}));
|
|
306
326
|
}
|
|
307
327
|
_flipAnimate(e) {
|
|
308
328
|
let t = this._dragEl, n = this._getAnimationDurationMs(), r = this._getLayoutChildren().filter((e) => e !== t), i = /* @__PURE__ */ new Map();
|
|
@@ -368,7 +388,7 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
368
388
|
} else r?.parentNode && r.parentNode.insertBefore(t, r);
|
|
369
389
|
r?.remove(), this._placeholder = null, t.classList.remove(n), t.style.cssText = "";
|
|
370
390
|
let f = d ? c : i._indexOfItem(t);
|
|
371
|
-
this._pointerId = null, this._dragEl = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropAtEnd = !1, this._dropRejected = !1;
|
|
391
|
+
this._pointerId = null, this._dragEl = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropAtEnd = !1, this._dropRejected = !1, this._lastPreviewRoot = null, this._lastPreviewIndex = -1;
|
|
372
392
|
let p = this._collectOrderedKeys(), m = i._collectOrderedKeys(), h = !d && (!d && o !== s || f !== c), g = t.getAttribute(this._getItemKeyAttribute()) || "", _ = {
|
|
373
393
|
oldIndex: c,
|
|
374
394
|
newIndex: f,
|
|
@@ -414,7 +434,7 @@ var t = "mint-sortable-placeholder", n = "mint-sortable-dragging", r = class e e
|
|
|
414
434
|
} catch {}
|
|
415
435
|
this._dragEl.classList.remove(n), this._dragEl.style.cssText = "";
|
|
416
436
|
}
|
|
417
|
-
this._placeholder?.remove(), this._placeholder = null, this._dragEl = null, this._pointerId = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropRejected = !1;
|
|
437
|
+
this._placeholder?.remove(), this._placeholder = null, this._dragEl = null, this._pointerId = null, this._restoreAfter = null, this._originListRoot = null, this._originNextSibling = null, this._dropList = null, this._dropRejected = !1, this._lastPreviewRoot = null, this._lastPreviewIndex = -1;
|
|
418
438
|
}
|
|
419
439
|
};
|
|
420
440
|
customElements.get("mint-sortable") || e("mint-sortable", r);
|
|
@@ -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-CYr8kA4R.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-tRfK5xQP.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-CYr8kA4R.js";
|
|
10
10
|
export { t as confirm, e as default };
|
|
@@ -31,7 +31,7 @@ declare class MintModal extends HTMLElement {
|
|
|
31
31
|
private _scheduleRender;
|
|
32
32
|
getId(): string;
|
|
33
33
|
getHeading(): string;
|
|
34
|
-
getSize(): 'small' | 'default';
|
|
34
|
+
getSize(): 'small' | 'default' | 'large';
|
|
35
35
|
isOpen(): boolean;
|
|
36
36
|
open(trigger?: HTMLElement | string): void;
|
|
37
37
|
close(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,eAAe,CAAA;AACtB,OAAO,gBAAgB,CAAA;AA0CvB,cAAM,SAAU,SAAQ,WAAW;IACjC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,MAAM,CAA2B;IACzC,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,eAAe,CAA2B;IAClD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,iBAAiB,CAAkF;IAC3G,OAAO,CAAC,mBAAmB,CAA+C;IAC1E,OAAO,CAAC,iBAAiB,CAAgC;IACzD,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,qBAAqB,CAAgD;;IAO7E,iBAAiB,IAAI,IAAI;IA4CzB,oBAAoB,IAAI,IAAI;IAgC5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAU9F,OAAO,CAAC,eAAe;IAQvB,KAAK,IAAI,MAAM;IAIf,UAAU,IAAI,MAAM;IAIpB,OAAO,IAAI,OAAO,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,CAAA;AACxB,OAAO,eAAe,CAAA;AACtB,OAAO,qBAAqB,CAAA;AAC5B,OAAO,eAAe,CAAA;AACtB,OAAO,gBAAgB,CAAA;AA0CvB,cAAM,SAAU,SAAQ,WAAW;IACjC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,QAAQ,CAA2B;IAC3C,OAAO,CAAC,MAAM,CAA2B;IACzC,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,eAAe,CAA2B;IAClD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,iBAAiB,CAAkF;IAC3G,OAAO,CAAC,mBAAmB,CAA+C;IAC1E,OAAO,CAAC,iBAAiB,CAAgC;IACzD,OAAO,CAAC,gBAAgB,CAAgC;IACxD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,qBAAqB,CAAgD;;IAO7E,iBAAiB,IAAI,IAAI;IA4CzB,oBAAoB,IAAI,IAAI;IAgC5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAU9F,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;IA2Rd,OAAO,CAAC,sBAAsB;IAe9B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,2BAA2B;IASnC,OAAO,CAAC,aAAa;IAoDrB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,mBAAmB;IAiB3B,OAAO,CAAC,YAAY;CAuCrB;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-DPJrUEb3.js";
|
|
21
21
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/modal-
|
|
1
|
+
const e=require(`../chunks/modal-VURZX7TM.js`);module.exports=e.t;
|
|
@@ -24,6 +24,8 @@ declare class MintSortable extends HTMLElement {
|
|
|
24
24
|
private _dropRejected;
|
|
25
25
|
private _sortStatus;
|
|
26
26
|
private _flipCleanupTimers;
|
|
27
|
+
private _lastPreviewRoot;
|
|
28
|
+
private _lastPreviewIndex;
|
|
27
29
|
private _keyboardKeydownHandler;
|
|
28
30
|
constructor();
|
|
29
31
|
connectedCallback(): void;
|
|
@@ -60,6 +62,8 @@ declare class MintSortable extends HTMLElement {
|
|
|
60
62
|
private _resolveDropList;
|
|
61
63
|
private _autoScroll;
|
|
62
64
|
private _maybeMovePlaceholder;
|
|
65
|
+
/** Emit a serializable snapshot of the proposed order whenever the placeholder changes. */
|
|
66
|
+
private _dispatchPreview;
|
|
63
67
|
private _flipAnimate;
|
|
64
68
|
private _onPointerUp;
|
|
65
69
|
private _onPointerCancel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sortable.d.ts","sourceRoot":"","sources":["../../../src/components/sortable/Sortable.ts"],"names":[],"mappings":"AAIA,KAAK,cAAc,GAAG,YAAY,GAAG,UAAU,CAAA;AAC/C,KAAK,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AACxD,KAAK,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAKpD,cAAM,YAAa,SAAQ,WAAW;IACpC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAexC;IAED,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,kBAAkB,CAAqC;IAC/D,OAAO,CAAC,uBAAuB,CAAiE;;IAShG,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;IAU5B,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM/F,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,gBAAgB;IAIxB,wFAAwF;IACxF,OAAO,CAAC,oBAAoB;IAI5B,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,yBAAyB;IAejC,OAAO,CAAC,yBAAyB;IAwCjC,OAAO,CAAC,0BAA0B;IAqBlC,OAAO,CAAC,kBAAkB;IAqC1B,YAAY,IAAI,cAAc;IAK9B,MAAM,IAAI,MAAM;IAMhB,YAAY,IAAI,SAAS,GAAG,EAAE;IAM9B,eAAe,IAAI,iBAAiB,GAAG,EAAE;IAQzC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,kBAAkB,CAuBzB;IAED,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,UAAU;
|
|
1
|
+
{"version":3,"file":"Sortable.d.ts","sourceRoot":"","sources":["../../../src/components/sortable/Sortable.ts"],"names":[],"mappings":"AAIA,KAAK,cAAc,GAAG,YAAY,GAAG,UAAU,CAAA;AAC/C,KAAK,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;AACxD,KAAK,iBAAiB,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAA;AAKpD,cAAM,YAAa,SAAQ,WAAW;IACpC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAexC;IAED,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,mBAAmB,CAA2B;IACtD,OAAO,CAAC,cAAc,CAAgC;IACtD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,kBAAkB,CAAuB;IACjD,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,kBAAkB,CAAqC;IAC/D,OAAO,CAAC,gBAAgB,CAA2B;IACnD,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,uBAAuB,CAAiE;;IAShG,iBAAiB,IAAI,IAAI;IAQzB,oBAAoB,IAAI,IAAI;IAU5B,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM/F,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,oBAAoB;IAO5B,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,gBAAgB;IAIxB,wFAAwF;IACxF,OAAO,CAAC,oBAAoB;IAI5B,6EAA6E;IAC7E,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,yBAAyB;IAejC,OAAO,CAAC,yBAAyB;IAwCjC,OAAO,CAAC,0BAA0B;IAqBlC,OAAO,CAAC,kBAAkB;IAqC1B,YAAY,IAAI,cAAc;IAK9B,MAAM,IAAI,MAAM;IAMhB,YAAY,IAAI,SAAS,GAAG,EAAE;IAM9B,eAAe,IAAI,iBAAiB,GAAG,EAAE;IAQzC,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,qBAAqB;IAK7B,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,kBAAkB,CAuBzB;IAED,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,UAAU;IAmElB,OAAO,CAAC,YAAY;IAapB,OAAO,CAAC,kBAAkB;IAI1B,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,gBAAgB;IA0BxB,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,qBAAqB;IA+E7B,2FAA2F;IAC3F,OAAO,CAAC,gBAAgB;IAsBxB,OAAO,CAAC,YAAY;IAsDpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,WAAW;IA+HnB,OAAO,CAAC,aAAa;CA8BtB;AAMD,eAAe,YAAY,CAAA"}
|
|
@@ -12,5 +12,5 @@ const __mintLoadStyle = (key, url) => {
|
|
|
12
12
|
}
|
|
13
13
|
__mintLoadStyle('theme', '../../theme.css')
|
|
14
14
|
__mintLoadStyle('sortable', '../../sortable.css')
|
|
15
|
-
import { t as e } from "../chunks/sortable-
|
|
15
|
+
import { t as e } from "../chunks/sortable-C46XSDeN.js";
|
|
16
16
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/sortable-
|
|
1
|
+
const e=require(`../chunks/sortable-BmObFEEn.js`);module.exports=e.t;
|
|
@@ -25,9 +25,9 @@ import "../chunks/icon-D9XshOW2.js";
|
|
|
25
25
|
import { t as e } from "../chunks/register-element-BFYmIynH.js";
|
|
26
26
|
import "../chunks/spinner-BjC3nA-C.js";
|
|
27
27
|
import "../chunks/button-h2EuXJM5.js";
|
|
28
|
-
import "../chunks/confirm-action-
|
|
28
|
+
import "../chunks/confirm-action-CYr8kA4R.js";
|
|
29
29
|
import "../chunks/popover-FdMS4yAD.js";
|
|
30
|
-
import "../chunks/sortable-
|
|
30
|
+
import "../chunks/sortable-C46XSDeN.js";
|
|
31
31
|
//#region src/components/tree/tree-utils.js
|
|
32
32
|
function t(e = []) {
|
|
33
33
|
s(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-_eTWDyJr.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/spinner-DfPbEa2d.js`),require(`../chunks/button-D-yKHP5o.js`),require(`../chunks/confirm-action-C8W8VFAY.js`),require(`../chunks/popover-wGdggZ-a.js`),require(`../chunks/sortable-CVK48xj1.js`);function t(e=[]){s(e);let t=e=>e.map(e=>({...e,children:Array.isArray(e.children)?t(e.children):[]}));return t(e)}function n(e,t){let r=String(t);for(let t of e){if(String(t.id)===r)return t;let e=n(t.children||[],r);if(e)return e}return null}function r(e,t,n=null){let i=String(t);for(let t of e){if(String(t.id)===i)return{parentId:n,siblings:e,item:t};let a=r(t.children||[],i,String(t.id));if(a)return a}return null}function i(e,t,n=0){let r=String(t);for(let t of e){if(String(t.id)===r)return n;let e=i(t.children||[],r,n+1);if(e>=0)return e}return-1}function a(e){let t=Array.isArray(e?.children)?e.children:[];return t.length?1+Math.max(...t.map(a)):1}function o(e,t){return String(e.id)===String(t)?!0:(e.children||[]).some(e=>o(e,t))}function s(e){let t=new Set,n=e=>{for(let r of e){if(r.id===null||r.id===void 0||String(r.id)===``)throw Error(`Every tree item must have a non-empty identifier.`);let e=String(r.id);if(t.has(e))throw Error(`Tree item identifiers must be unique. Duplicate identifier: ${e}.`);t.add(e),n(r.children||[])}};n(e)}function c(e,s,c,l,u={}){let d=t(e),f=r(d,s);if(!f)throw Error(`Tree item ${s} was not found.`);if(f.item.disabled||f.item.draggable===!1)throw Error(`Disabled tree items cannot be moved.`);let p=c==null||c===``?null:n(d,c);if(c!=null&&c!==``&&!p)throw Error(`Target parent ${c} was not found.`);if(p&&o(f.item,p.id))throw Error(`A tree item cannot be moved inside itself or one of its descendants.`);if(p?.disabled)throw Error(`Disabled tree items cannot contain children.`);if(u.allowNesting===!1&&p)throw Error(`Nesting is disabled for this tree.`);if(p?.canHaveChildren===!1)throw Error(`The target item cannot contain children.`);if(p?.acceptsTypes?.length&&!p.acceptsTypes.includes(f.item.type))throw Error(`The target item does not accept this item type.`);let m=p?p.children:d,h=f.siblings.findIndex(e=>String(e.id)===String(s)),[g]=f.siblings.splice(h,1),_=Math.min(Math.max(0,Number.isFinite(l)?Math.trunc(l):m.length),m.length);m.splice(_,0,g);let v=Number.isFinite(u.maxDepth)?Math.max(1,Math.trunc(u.maxDepth)):1/0;if((p?i(d,p.id)+1:0)+a(g)>v)throw Error(`Moving this branch would exceed the maximum tree depth of ${v}.`);return{items:d,item:g,oldParentId:f.parentId,newParentId:p?String(p.id):null,oldIndex:h,newIndex:_}}var l=0;function u(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:n}))}function d(e,t){let n=e.getAttribute(t);return n===``||n===`true`}function f(e){return e==null||e===``?null:String(e)}var p=class extends HTMLElement{constructor(...e){super(...e),this._items=[],this._undoStack=[],this._redoStack=[],this._selectedId=null,this._expandedIds=new Set,this._root=null,this._confirm=null,this._treeId=`mint-tree-${++l}`,this._liveRegion=null,this._dragExpansion=null,this._autoExpandedIds=new Set,this._dragHoverExpandedId=null,this._keyboardFocusRestore=null,this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer=null,this._onClick=e=>{let t=e.target instanceof Element?e.target.closest(`[data-tree-command]`):null;if(!t||!this.contains(t))return;let r=t.getAttribute(`data-tree-command`),i=t.getAttribute(`data-tree-id`);if(r===`create-root`)u(this,`mint-tree-create`,{parentId:null,items:this.items});else if(r===`expand-all`)this._expandedIds=this._defaultExpandedIds(this._items),this._syncExpandedDOM(),u(this,`mint-tree-expand`,{all:!0,expandedIds:this.expandedIds});else if(r===`collapse-all`)this._expandedIds.clear(),this._syncExpandedDOM(),u(this,`mint-tree-collapse`,{all:!0,expandedIds:[]});else if(r===`undo`)this._undo();else if(r===`redo`)this._redo();else if(r===`toggle`&&i){let e=!this._expandedIds.has(i);this._setExpanded(i,e,!0)}else if(r===`select`&&i){if(this.classList.contains(`mint-tree-drag-active`)||this._suppressSelectionClick){e.preventDefault(),this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=null;return}this._select(i)}else if(r===`create-child`&&i)this._closeItemPopover(t),u(this,`mint-tree-create`,{parentId:i,items:this.items});else if(r===`edit`&&i){this._closeItemPopover(t);let e=n(this._items,i);e&&u(this,`mint-tree-edit`,{item:{...e},itemId:i,items:this.items})}else if(r===`delete`&&i)this._closeItemPopover(t),this._confirmDelete(i);else if([`move-up`,`move-down`,`nest-previous`,`outdent`].includes(r||``)&&i)this._closeItemPopover(t),this._moveByCommand(i,r||``);else if(r===`custom`&&i){this._closeItemPopover(t);let e=n(this._items,i),r=t.getAttribute(`data-tree-action`)||``,a=e?.actions?.find(e=>e.id===r);if(e&&a){let t={item:{...e},itemId:i,action:{...a,onSelect:void 0},items:this.items};u(this,`mint-tree-action`,t),a.onSelect?.({item:{...e},itemId:i,action:a,items:this.items})}}},this._onSortableDrag=e=>{let t=e.detail;if(!t||!Number.isFinite(t.clientX)||!Number.isFinite(t.clientY))return;let r=document.elementFromPoint(t.clientX,t.clientY),i=r?.closest(`[data-mint-tree-row]`),a=t.item?.getAttribute(`data-tree-id`)||``,o=null;if(i&&i.getAttribute(`data-tree-id`)!==a){let e=i.querySelector(`:scope > .mint-tree-row`)?.getBoundingClientRect()||i.getBoundingClientRect(),r=e.height?(t.clientY-e.top)/e.height:0;if(r>.22&&r<.78){let e=i.getAttribute(`data-tree-id`)||``;n(this._items,e)&&this._isValidDrop(a,e)&&(o=e)}}if(!o&&this._dragHoverExpandedId){let e=[...this._root?.querySelectorAll(`[data-tree-id]`)??[]].find(e=>e.getAttribute(`data-tree-id`)===this._dragHoverExpandedId)?.querySelector(`:scope > mint-sortable.mint-tree-children`);r&&e?.contains(r)&&(o=this._dragHoverExpandedId)}if(this._dragHoverExpandedId&&this._dragHoverExpandedId!==o){let e=this._dragHoverExpandedId;this._dragHoverExpandedId=null,this._autoExpandedIds.delete(e),this._expandedIds.delete(e),this._syncNodeExpanded(e);let t=n(this._items,e);t&&u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0})}if(o){let e=n(this._items,o);e&&!this._expandedIds.has(o)&&(this._expandedIds.add(o),this._autoExpandedIds.add(o),this._dragHoverExpandedId=o,this._syncNodeExpanded(o),u(this,`mint-tree-expand`,{itemId:o,item:{...e},expandedIds:this.expandedIds,automatic:!0}))}},this._onSortableStart=()=>{this.classList.add(`mint-tree-drag-active`),this._dragHoverExpandedId=null,this._dragExpansion?.timer!==null&&this._dragExpansion?.timer!==void 0&&window.clearTimeout(this._dragExpansion.timer),this._dragExpansion=null;let e=this._root?.querySelector(`.mint-sortable-dragging[data-tree-id]`),t=e?.getAttribute(`data-tree-id`)||``,n=e?.querySelector(`:scope > mint-sortable.mint-tree-children`);if(!e||!t||!n||n.hidden||!this._expandedIds.has(t))return;let r=e.querySelector(`:scope > .mint-tree-row`),i=this._root?.querySelector(`.mint-sortable-placeholder`),a=n.getBoundingClientRect().height;n.style.height=`${a}px`,n.style.overflow=`hidden`,e.style.height=`auto`,e.style.overflow=`hidden`,this._dragExpansion={itemId:t,item:e,childList:n,timer:null},this._setTransientExpanded(t,!1),n.offsetHeight,requestAnimationFrame(()=>{this._dragExpansion?.childList===n&&(n.classList.add(`mint-tree-drag-collapse`),n.style.height=`0px`,i&&r&&(i.style.minHeight=`${r.getBoundingClientRect().height}px`))})},this._onSortableEnd=e=>{this.classList.remove(`mint-tree-drag-active`),this._suppressSelectionClick=!0,this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=window.setTimeout(()=>{this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer=null},300);let t=e.detail,r=t&&!t.cancelled?f(t.newParentId):null;for(let e of this._autoExpandedIds){if(e===r)continue;this._expandedIds.delete(e),this._syncNodeExpanded(e);let t=n(this._items,e);t&&u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0})}this._autoExpandedIds.clear(),this._dragHoverExpandedId=null;let i=this._dragExpansion;if(!i)return;i.item=[...this._root?.querySelectorAll(`[data-tree-id]`)??[]].find(e=>e.getAttribute(`data-tree-id`)===i.itemId)||i.item,i.childList=i.item.querySelector(`:scope > mint-sortable.mint-tree-children`)||i.childList;let{item:a,childList:o,itemId:s}=i;o.style.height=`0px`,o.style.overflow=`hidden`,o.classList.remove(`mint-tree-drag-collapse`),this._setTransientExpanded(s,!0),o.offsetHeight;let c=o.scrollHeight;requestAnimationFrame(()=>{this._dragExpansion===i&&(o.style.height=`${c}px`)}),i.timer=window.setTimeout(()=>{o.style.height=``,o.style.overflow=``,o.style.opacity=``,this._dragExpansion=null},155)},this._onSortableDragOver=e=>{let t=e,{item:r,target:i}=t.detail||{};if(!r||!i)return;this._root?.querySelectorAll(`.mint-tree-drop-invalid`).forEach(e=>e.classList.remove(`mint-tree-drop-invalid`));let a=this._root?.querySelector(`.mint-sortable-placeholder`),o=r.getAttribute(`data-tree-id`)||``,s=f(i.getAttribute(`data-tree-parent-id`)),c=i===t.detail.source||this._isValidDrop(o,s),l=s?n(this._items,s):null;c&&i!==t.detail.source&&l?a?.setAttribute(`data-drop-label`,`Drop here to nest under ${l.label}`):c&&i===this._root?.querySelector(`:scope > mint-sortable`)?a?.setAttribute(`data-drop-label`,`Drop here to move to the top level`):a?.removeAttribute(`data-drop-label`);let u=(Number.isFinite(t.detail.clientX)&&Number.isFinite(t.detail.clientY)?document.elementFromPoint(t.detail.clientX,t.detail.clientY):null)?.closest(`[data-mint-tree-row]`);u&&u.getAttribute(`data-tree-id`)!==o&&!c&&u.classList.add(`mint-tree-drop-invalid`),c||t.preventDefault()},this._onSortableBeforeDrop=e=>{let t=e,n=t.detail;if(!n?.item||!n.target)return;let r=n.item.getAttribute(`data-tree-id`)||``,i=f(n.target.getAttribute(`data-tree-parent-id`));n.target!==n.source&&!this._isValidDrop(r,i)&&t.preventDefault()},this._onSortableChange=e=>{let t=e.detail;if(!t||t.cancelled)return;let r=t.itemId||``,i=f(t.oldParentId),a=f(t.newParentId),o=this._root?.querySelector(`:scope > mint-sortable`);if(!o)return;let s=n(this._items,r);this._recordHistory(),this._items=this._readItemsFromDOM(o),this._collapseEmptyExpandedNodes();let c=n(this._items,r);if(!c||!s)return;let l={itemId:r,item:{...c},items:this.items,oldParentId:i,newParentId:a,oldIndex:Number(t.oldIndex??-1),newIndex:Number(t.newIndex??-1)};this._clearDropState(),u(this,`mint-tree-change`,{items:l.items,itemId:r}),i===a?u(this,`mint-tree-reorder`,l):u(this,`mint-tree-reparent`,l);let d=`${c.label} moved${a?` into ${n(this._items,a)?.label||`a group`}`:` to the top level`}.`;this._dragExpansion?.itemId===r?window.setTimeout(()=>{this.isConnected&&(this._render(),this._focusRow(r),this._announce(d))},155):(this._render(),this._focusRow(r),this._announce(d))},this._onKeydown=e=>{let t=e.target instanceof Element?e.target.closest(`[data-mint-tree-row]`):null;if(!t)return;if(e.altKey&&[`ArrowUp`,`ArrowDown`].includes(e.key)){e.preventDefault();let n=t.getAttribute(`data-tree-id`)||``;if(n){this._keyboardFocusRestore&&window.clearTimeout(this._keyboardFocusRestore.timer);let e={id:n,x:window.scrollX,y:window.scrollY,timer:0};e.timer=window.setTimeout(()=>{this._keyboardFocusRestore===e&&(this._keyboardFocusRestore=null)},2e3),this._keyboardFocusRestore=e}return}let i=t.getAttribute(`data-tree-id`)||``;if(e.altKey&&e.key===`ArrowRight`){e.preventDefault(),this._keyboardIndent(i);return}if(e.altKey&&e.key===`ArrowLeft`){e.preventDefault(),this._keyboardOutdent(i);return}let a=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].filter(e=>!e.closest(`mint-sortable[hidden]`)),o=a.indexOf(t);if(e.key===`ArrowDown`)e.preventDefault(),a[o+1]?.focus({preventScroll:!0});else if(e.key===`ArrowUp`)e.preventDefault(),a[o-1]?.focus({preventScroll:!0});else if(e.key===`ArrowRight`)e.preventDefault(),this._expandedIds.has(i)?a[o+1]?.focus({preventScroll:!0}):this._setExpanded(i,!0,!0);else if(e.key===`ArrowLeft`)if(e.preventDefault(),this._expandedIds.has(i))this._setExpanded(i,!1,!0);else{let e=r(this._items,i)?.parentId;e&&[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e)?.focus({preventScroll:!0})}else if(e.key===`Enter`||e.key===` `||e.key===`Spacebar`){let r=e.target instanceof Element?e.target.closest(`[data-tree-command="select"]`):null;(t===e.target||r)&&(e.preventDefault(),n(this._items,i)?.children?.length?this._setExpanded(i,!this._expandedIds.has(i),!0):this._select(i))}}}static get observedAttributes(){return[`selected-id`,`max-depth`,`allow-nesting`,`disabled`,`loading`,`create-label`,`empty-label`,`delete-confirmation`,`expanded-ids`]}connectedCallback(){this._root||(this._selectedId=f(this.getAttribute(`selected-id`)),this._expandedIds=this.hasAttribute(`expanded-ids`)?this._readExpandedIds(this.getAttribute(`expanded-ids`)):this._defaultExpandedIds(this._items),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeydown,!0),this.addEventListener(`mint-sortable-start`,this._onSortableStart),this.addEventListener(`mint-sortable-end`,this._onSortableEnd),this.addEventListener(`mint-sortable-drag`,this._onSortableDrag),this.addEventListener(`mint-sortable-drag-over`,this._onSortableDragOver),this.addEventListener(`mint-sortable-before-drop`,this._onSortableBeforeDrop),this.addEventListener(`mint-sortable-change`,this._onSortableChange),this._render())}disconnectedCallback(){this._dragExpansion?.timer!==null&&this._dragExpansion?.timer!==void 0&&window.clearTimeout(this._dragExpansion.timer),this._keyboardFocusRestore&&window.clearTimeout(this._keyboardFocusRestore.timer),this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=null,this._suppressSelectionClick=!1,this._keyboardFocusRestore=null,this._dragExpansion=null,this._autoExpandedIds.clear(),this._dragHoverExpandedId=null,this.classList.remove(`mint-tree-drag-active`),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeydown,!0),this.removeEventListener(`mint-sortable-start`,this._onSortableStart),this.removeEventListener(`mint-sortable-end`,this._onSortableEnd),this.removeEventListener(`mint-sortable-drag`,this._onSortableDrag),this.removeEventListener(`mint-sortable-drag-over`,this._onSortableDragOver),this.removeEventListener(`mint-sortable-before-drop`,this._onSortableBeforeDrop),this.removeEventListener(`mint-sortable-change`,this._onSortableChange),this._root=null}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`selected-id`){this._selectedId=f(n),this._syncSelectionDOM();return}e===`expanded-ids`&&(this._expandedIds=this._readExpandedIds(n)),this._render()}}get items(){return t(this._items)}set items(e){this._items=t(Array.isArray(e)?e:[]),this._undoStack=[],this._redoStack=[],this.hasAttribute(`expanded-ids`)||(this._expandedIds=this._defaultExpandedIds(this._items)),this.isConnected&&this._render()}get selectedId(){return this._selectedId}set selectedId(e){this._selectedId=f(e),this._selectedId===null?this.removeAttribute(`selected-id`):this.setAttribute(`selected-id`,this._selectedId)}get expandedIds(){return[...this._expandedIds]}set expandedIds(e){this._expandedIds=new Set((Array.isArray(e)?e:[]).map(String)),this.isConnected&&this._render()}save(){u(this,`mint-tree-save`,{items:this.items})}select(e){this._select(String(e))}expand(e){this._setExpanded(String(e),!0,!0)}collapse(e){this._setExpanded(String(e),!1,!0)}_readExpandedIds(e){if(!e)return this._defaultExpandedIds(this._items);try{let t=JSON.parse(e);return new Set(Array.isArray(t)?t.map(String):[])}catch{return new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))}}_defaultExpandedIds(e){let t=new Set,n=e=>e.forEach(e=>{e.children?.length&&(t.add(String(e.id)),n(e.children))});return n(e),t}_maxDepth(){let e=Number.parseInt(this.getAttribute(`max-depth`)||``,10);return Number.isFinite(e)&&e>0?e:1/0}_allowNesting(){return!this.hasAttribute(`allow-nesting`)||d(this,`allow-nesting`)}_disabled(){return d(this,`disabled`)}_isLoading(){return d(this,`loading`)}_render(){let e=document.activeElement instanceof HTMLElement?document.activeElement.closest(`[data-mint-tree-row]`):null,t=e&&this.contains(e)?e.getAttribute(`data-tree-id`):null;t&&this._keyboardFocusRestore&&(this._keyboardFocusRestore.id=t);let n=document.createElement(`div`);n.className=`mint-tree-shell`,n.setAttribute(`role`,`tree`),n.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||`Hierarchical items`),n.setAttribute(`aria-busy`,String(this._isLoading()));let r=document.createElement(`div`);r.className=`mint-tree-toolbar`;let i=document.createElement(`span`);i.className=`mint-tree-count`,i.textContent=`${this._countItems()} ${this._countItems()===1?`item`:`items`}`,r.appendChild(i);let a=document.createElement(`div`);a.className=`mint-tree-toolbar-actions`;let o=this._createButton(``,`ghost`,`undo`);o.setAttribute(`icon`,`undo`),o.setAttribute(`aria-label`,`Undo last change`),o.setAttribute(`title`,`Undo`),(!this._undoStack.length||this._disabled())&&o.setAttribute(`disabled`,`true`);let s=this._createButton(``,`ghost`,`redo`);s.setAttribute(`icon`,`redo`),s.setAttribute(`aria-label`,`Redo last undone change`),s.setAttribute(`title`,`Redo`),(!this._redoStack.length||this._disabled())&&s.setAttribute(`disabled`,`true`);let c=this._createButton(``,`ghost`,`expand-all`);c.setAttribute(`icon`,`expand`),c.setAttribute(`aria-label`,`Expand all`),c.setAttribute(`title`,`Expand all`);let l=this._createButton(``,`ghost`,`collapse-all`);if(l.setAttribute(`icon`,`collapse`),l.setAttribute(`aria-label`,`Collapse all`),l.setAttribute(`title`,`Collapse all`),a.append(o,s,c,l),r.appendChild(a),n.appendChild(r),this._isLoading()){let e=document.createElement(`div`);e.className=`mint-tree-loading`,e.setAttribute(`aria-label`,`Loading items`);let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`small`),e.appendChild(t),n.appendChild(e)}else if(this._items.length)n.appendChild(this._createList(this._items,null,0));else{let e=document.createElement(`div`);e.className=`mint-tree-empty`,e.textContent=this.getAttribute(`empty-label`)||`No items yet.`,n.appendChild(e)}this._liveRegion=document.createElement(`div`),this._liveRegion.className=`mint-tree-live-region`,this._liveRegion.setAttribute(`role`,`status`),this._liveRegion.setAttribute(`aria-live`,`polite`),this._liveRegion.setAttribute(`aria-atomic`,`true`),n.appendChild(this._liveRegion);let u=document.createElement(`mint-confirm-action`);u.className=`mint-tree-confirm`,this._confirm=u,n.appendChild(u),this.replaceChildren(n),this._root=n,this.classList.add(`mint-tree`),this._disabled()?this.setAttribute(`aria-disabled`,`true`):this.removeAttribute(`aria-disabled`);let d=this._keyboardFocusRestore;d&&(this._focusRow(d.id),window.scrollTo({left:d.x,top:d.y,behavior:`instant`}),requestAnimationFrame(()=>{this._keyboardFocusRestore===d&&(this._focusRow(d.id),window.scrollTo({left:d.x,top:d.y,behavior:`instant`}))}))}_countItems(e=this._items){return e.reduce((e,t)=>e+1+this._countItems(t.children||[]),0)}_createButton(e,t,n){let r=document.createElement(`mint-button`);return r.textContent=e,r.setAttribute(`variant`,t),r.setAttribute(`data-tree-command`,n),r}_createList(e,t,n){let r=document.createElement(`mint-sortable`);r.id=`${this._treeId}-list-${t??`root`}`,r.setAttribute(`group`,this._treeId),r.setAttribute(`data-tree-parent-id`,t??``),r.setAttribute(`role`,`group`),r.setAttribute(`data-tree-depth`,String(n)),r.setAttribute(`direction`,`vertical`),r.setAttribute(`gap`,`1`),r.setAttribute(`handle-selector`,`[data-mint-sortable-handle]`),r.setAttribute(`animation-duration`,`320`),r.setAttribute(`item-key-attribute`,`data-tree-id`);let i=document.createElement(`mint-stack`);i.setAttribute(`direction`,`vertical`),i.setAttribute(`gap`,`1`);for(let t of e)i.appendChild(this._createNode(t,n));return r.appendChild(i),r}_createNode(e,t){let n=String(e.id),r=Array.isArray(e.children)?e.children:[],i=e.canHaveChildren!==!1&&this._allowNesting()&&t+a(e)<this._maxDepth(),o=document.createElement(`div`);o.className=`mint-tree-node`,o.setAttribute(`data-tree-id`,n),o.setAttribute(`role`,`treeitem`),o.setAttribute(`data-mint-tree-row`,``),o.setAttribute(`aria-level`,String(t+1)),o.setAttribute(`aria-selected`,String(this._selectedId===n)),o.setAttribute(`tabindex`,this._selectedId===n||this._selectedId===null&&t===0&&this._items[0]?.id===e.id?`0`:`-1`),o.setAttribute(`aria-label`,e.label),r.length&&o.setAttribute(`aria-expanded`,String(this._expandedIds.has(n))),(e.disabled||this._disabled())&&o.setAttribute(`aria-disabled`,`true`),(e.draggable===!1||this._disabled())&&o.setAttribute(`data-sortable-disabled`,``);let s=document.createElement(`div`);s.className=`mint-tree-row`,s.setAttribute(`data-tree-id`,n);let c=document.createElement(`span`);c.className=`mint-tree-drag-handle`,c.setAttribute(`data-mint-sortable-handle`,``),c.setAttribute(`role`,`button`),c.setAttribute(`tabindex`,`-1`),c.setAttribute(`aria-label`,`Drag ${e.label} to move`);let l=document.createElement(`mint-icon`);if(l.setAttribute(`name`,`grip-dots`),l.setAttribute(`aria-hidden`,`true`),c.appendChild(l),s.appendChild(c),r.length){let t=document.createElement(`mint-button`);t.className=`mint-tree-expand`,t.setAttribute(`variant`,`ghost`),t.setAttribute(`icon`,this._expandedIds.has(n)?`caret-up`:`caret-down`),t.setAttribute(`data-tree-command`,`toggle`),t.setAttribute(`data-tree-id`,n),t.setAttribute(`aria-label`,`${this._expandedIds.has(n)?`Collapse`:`Expand`} ${e.label}`),t.setAttribute(`aria-expanded`,String(this._expandedIds.has(n))),(this._disabled()||e.disabled===!0)&&t.setAttribute(`disabled`,`true`),s.appendChild(t)}else{let e=document.createElement(`span`);e.className=`mint-tree-expand-spacer`,e.setAttribute(`aria-hidden`,`true`),s.appendChild(e)}let u=document.createElement(`span`);if(u.className=`mint-tree-label`,u.setAttribute(`data-tree-command`,`select`),u.setAttribute(`data-tree-id`,n),i&&(u.setAttribute(`data-mint-sortable-drop-container`,`${this._treeId}-list-${n}`),u.setAttribute(`data-mint-sortable-drop-end`,``)),e.icon){let t=document.createElement(`mint-icon`);t.setAttribute(`name`,String(e.icon)),t.setAttribute(`aria-hidden`,`true`),u.appendChild(t)}let d=document.createElement(`span`);if(d.className=`mint-tree-label-text`,d.textContent=e.label,u.appendChild(d),s.appendChild(u),e.metadata){let t=document.createElement(`span`);t.className=`mint-tree-metadata`,t.textContent=String(e.metadata),s.appendChild(t)}let f=document.createElement(`span`);f.className=`mint-tree-nest-target`,f.setAttribute(`data-mint-sortable-drop-container`,`${this._treeId}-list-${n}`),f.setAttribute(`data-mint-sortable-drop-end`,``),f.setAttribute(`aria-hidden`,`true`);let p=document.createElement(`mint-icon`);p.setAttribute(`name`,`arrow-right`),p.setAttribute(`aria-hidden`,`true`),f.appendChild(p),i&&s.appendChild(f);let m=this._createActions(e,i);s.appendChild(m),o.appendChild(s);let h=this._createList(r,n,t+1);return h.classList.add(`mint-tree-children`),h.hidden=!this._expandedIds.has(n),o.appendChild(h),o}_createActions(e,t){let i=document.createElement(`div`);i.className=`mint-tree-actions`;let a=`${this._treeId}-actions-trigger-${encodeURIComponent(String(e.id))}`,o=`${a}-popover`,s=document.createElement(`mint-button`);s.id=a,s.setAttribute(`variant`,`ghost`),s.setAttribute(`icon`,`ellipsis`),s.setAttribute(`aria-label`,`Actions for ${e.label}`),s.setAttribute(`aria-haspopup`,`menu`),i.appendChild(s);let c=document.createElement(`mint-popover`);c.id=o,c.setAttribute(`trigger-id`,a),c.setAttribute(`direction`,`down`),c.setAttribute(`trigger-align`,`end`),c.setAttribute(`padding`,`0.3rem`);let l=document.createElement(`div`);l.className=`mint-tree-menu`,l.setAttribute(`role`,`menu`);let u=(t,n,r=!1)=>{let i=document.createElement(`mint-button`);i.textContent=n,i.setAttribute(`variant`,`ghost`),i.setAttribute(`full-width`,`true`),i.setAttribute(`align`,`left`),i.setAttribute(`role`,`menuitem`),i.setAttribute(`data-tree-command`,t),i.setAttribute(`data-tree-id`,String(e.id)),(r||e.disabled===!0||this._disabled())&&i.setAttribute(`disabled`,`true`),l.appendChild(i)},d=Array.isArray(e.actions)?e.actions:null;if(d)for(let t of d){let n=document.createElement(`mint-button`);n.textContent=t.label,n.setAttribute(`variant`,`ghost`),n.setAttribute(`full-width`,`true`),n.setAttribute(`align`,`left`),n.setAttribute(`role`,`menuitem`),n.setAttribute(`data-tree-command`,`custom`),n.setAttribute(`data-tree-id`,String(e.id)),n.setAttribute(`data-tree-action`,t.id),(t.disabled===!0||e.disabled===!0||this._disabled())&&n.setAttribute(`disabled`,`true`),t.icon&&n.setAttribute(`icon`,t.icon),t.tone&&n.setAttribute(`tone`,t.tone),l.appendChild(n)}else{let i=r(this._items,e.id),a=i?.siblings||[],o=a.findIndex(t=>String(t.id)===String(e.id)),s=o>0?a[o-1]:null,c=i?.parentId?n(this._items,i.parentId):null;u(`move-up`,`Move up`,o<=0),u(`move-down`,`Move down`,o<0||o>=a.length-1),u(`nest-previous`,`Nest under previous item`,!s||!this._isValidDrop(String(e.id),String(s.id))),u(`outdent`,`Move to parent level`,!c),u(`create-child`,`Add child`,!t),u(`edit`,`Edit`),u(`delete`,`Delete`)}return c.appendChild(l),i.appendChild(c),i}_closeItemPopover(e){(e.closest(`.mint-tree-menu`)?.closest(`mint-popover`))?.close?.()}async _confirmDelete(e){let t=n(this._items,e);!t||!this._confirm?.showConfirm||await this._confirm.showConfirm({question:this.getAttribute(`delete-confirmation`)||`Delete “${t.label}”?`,tone:`danger`,confirmLabel:`Delete`,cancelLabel:`Cancel`})&&u(this,`mint-tree-delete`,{item:{...t},itemId:e,items:this.items})}_moveByCommand(e,t){let n=r(this._items,e);if(!n)return;let i=n.siblings.findIndex(t=>String(t.id)===e),a=n.parentId,o=i;if(t===`move-up`)o=i-1;else if(t===`move-down`)o=i+1;else if(t===`nest-previous`){let e=n.siblings[i-1];if(!e)return;a=String(e.id),o=(e.children||[]).length}else if(t===`outdent`){if(n.parentId===null)return;let e=r(this._items,n.parentId);if(!e)return;a=e.parentId,o=e.siblings.findIndex(e=>String(e.id)===n.parentId)+1}else return;try{let t=c(this._items,e,a,o,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._applyMove(t)}catch{}}_applyMove(e){this._recordHistory(),this._items=e.items,this._collapseEmptyExpandedNodes(),e.newParentId&&this._expandedIds.add(e.newParentId),this._render(),this._focusRow(String(e.item.id));let t={itemId:String(e.item.id),item:{...e.item},items:this.items,oldParentId:e.oldParentId,newParentId:e.newParentId,oldIndex:e.oldIndex,newIndex:e.newIndex};u(this,`mint-tree-change`,{items:t.items,itemId:t.itemId}),u(this,t.oldParentId===t.newParentId?`mint-tree-reorder`:`mint-tree-reparent`,t),this._announce(`${t.item.label} moved${t.newParentId?` into ${n(this._items,t.newParentId)?.label||`a group`}`:` to the top level`}.`)}_select(e){if(this.classList.contains(`mint-tree-drag-active`))return;let t=n(this._items,e);!t||t.disabled||this._disabled()||(this._selectedId=e,this.setAttribute(`selected-id`,e),this._syncSelectionDOM(),u(this,`mint-tree-select`,{item:{...t},itemId:e,items:this.items}))}_syncSelectionDOM(){(this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]).forEach(e=>{let t=e.getAttribute(`data-tree-id`)===this._selectedId;e.setAttribute(`aria-selected`,String(t)),e.tabIndex=t?0:-1})}_setExpanded(e,t,r){let i=n(this._items,e);!i||i.disabled||this._disabled()||(t?this._expandedIds.add(e):this._expandedIds.delete(e),this._syncNodeExpanded(e),r&&u(this,t?`mint-tree-expand`:`mint-tree-collapse`,{itemId:e,item:{...i},expandedIds:this.expandedIds}))}_syncExpandedDOM(){this._root?.querySelectorAll(`[data-mint-tree-row]`).forEach(e=>this._syncNodeExpanded(e.getAttribute(`data-tree-id`)||``))}_syncNodeExpanded(e){let t=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e),r=t?.querySelector(`:scope > mint-sortable.mint-tree-children`);if(!t||!r)return;let i=this._expandedIds.has(e);t.setAttribute(`aria-expanded`,String(i));let a=t.querySelector(`[data-tree-command="toggle"]`);a?.setAttribute(`aria-expanded`,String(i)),a?.setAttribute(`aria-label`,`${i?`Collapse`:`Expand`} ${n(this._items,e)?.label||`item`}`),a?.setAttribute(`icon`,i?`caret-up`:`caret-down`),r.hidden=!i}_setTransientExpanded(e,t){let r=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e);if(!r)return;r.setAttribute(`aria-expanded`,String(t));let i=r.querySelector(`[data-tree-command="toggle"]`),a=n(this._items,e)?.label||`item`;i?.setAttribute(`aria-expanded`,String(t)),i?.setAttribute(`aria-label`,`${t?`Collapse`:`Expand`} ${a}`),i?.setAttribute(`icon`,t?`caret-up`:`caret-down`)}_isValidDrop(e,t){let r=n(this._items,e);if(!r)return!1;let i=t===null?null:n(this._items,t);return!(t!==null&&!i||i?.disabled||i&&(String(i.id)===e||this._isDescendant(r,i.id))||!this._allowNesting()&&i||i?.canHaveChildren===!1||i?.acceptsTypes?.length&&!i.acceptsTypes.includes(r.type||``)||(i?this._depthOf(String(i.id)):-1)+1+a(r)>this._maxDepth())}_isDescendant(e,t){return(e.children||[]).some(e=>String(e.id)===String(t)||this._isDescendant(e,t))}_depthOf(e){let t=r(this._items,e);return t?this._depthOfParent(t.parentId):-1}_depthOfParent(e){if(e===null)return 0;let t=r(this._items,e);return t?this._depthOfParent(t.parentId)+1:0}_readItemsFromDOM(e){let t=e.querySelector(`:scope > mint-stack`);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.classList.contains(`mint-tree-node`)).map(e=>{let t=e.getAttribute(`data-tree-id`)||``,r=n(this._items,t),i=e.querySelector(`:scope > mint-sortable.mint-tree-children`);return{...r||{id:t,label:t},children:i?this._readItemsFromDOM(i):[]}}):[]}_clearDropState(){this._root?.querySelectorAll(`.mint-tree-drop-invalid`).forEach(e=>e.classList.remove(`mint-tree-drop-invalid`))}_collapseEmptyExpandedNodes(){for(let e of[...this._expandedIds]){let t=n(this._items,e);!t||t.children?.length||(this._expandedIds.delete(e),this._syncNodeExpanded(e),u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0,empty:!0}))}}_announce(e){this._liveRegion&&(this._liveRegion.textContent=e)}_recordHistory(){this._undoStack.push(t(this._items)),this._undoStack.length>50&&this._undoStack.shift(),this._redoStack=[]}_undo(){let e=this._undoStack.pop();e&&(this._redoStack.push(t(this._items)),this._items=e,this._render(),u(this,`mint-tree-change`,{items:this.items,itemId:this._selectedId}),u(this,`mint-tree-undo`,{items:this.items}))}_redo(){let e=this._redoStack.pop();e&&(this._undoStack.push(t(this._items)),this._items=e,this._render(),u(this,`mint-tree-change`,{items:this.items,itemId:this._selectedId}),u(this,`mint-tree-redo`,{items:this.items}))}_keyboardIndent(e){let t=r(this._items,e);if(!t||t.siblings.indexOf(t.item)<=0)return;let n=t.siblings[t.siblings.indexOf(t.item)-1];try{let t=c(this._items,e,n.id,(n.children||[]).length,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._recordHistory(),this._items=t.items,this._expandedIds.add(String(n.id)),this._render(),this._focusRow(e),u(this,`mint-tree-reparent`,{itemId:e,item:{...t.item},items:this.items,oldParentId:t.oldParentId,newParentId:t.newParentId,oldIndex:t.oldIndex,newIndex:t.newIndex})}catch{}}_keyboardOutdent(e){let t=r(this._items,e);if(!t||t.parentId===null)return;let n=r(this._items,t.parentId);if(!n)return;let i=n.siblings.findIndex(e=>String(e.id)===t.parentId)+1;try{let t=c(this._items,e,n.parentId,i,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._recordHistory(),this._items=t.items,this._render(),this._focusRow(e),u(this,`mint-tree-reparent`,{itemId:e,item:{...t.item},items:this.items,oldParentId:t.oldParentId,newParentId:t.newParentId,oldIndex:t.oldIndex,newIndex:t.newIndex})}catch{}}_focusRow(e){[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e)?.focus({preventScroll:!0})}};customElements.get(`mint-tree`)||e.t(`mint-tree`,p),exports.MintTree=p,exports.default=p;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}}),require(`../chunks/icon-_eTWDyJr.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/spinner-DfPbEa2d.js`),require(`../chunks/button-D-yKHP5o.js`),require(`../chunks/confirm-action-tRfK5xQP.js`),require(`../chunks/popover-wGdggZ-a.js`),require(`../chunks/sortable-BmObFEEn.js`);function t(e=[]){s(e);let t=e=>e.map(e=>({...e,children:Array.isArray(e.children)?t(e.children):[]}));return t(e)}function n(e,t){let r=String(t);for(let t of e){if(String(t.id)===r)return t;let e=n(t.children||[],r);if(e)return e}return null}function r(e,t,n=null){let i=String(t);for(let t of e){if(String(t.id)===i)return{parentId:n,siblings:e,item:t};let a=r(t.children||[],i,String(t.id));if(a)return a}return null}function i(e,t,n=0){let r=String(t);for(let t of e){if(String(t.id)===r)return n;let e=i(t.children||[],r,n+1);if(e>=0)return e}return-1}function a(e){let t=Array.isArray(e?.children)?e.children:[];return t.length?1+Math.max(...t.map(a)):1}function o(e,t){return String(e.id)===String(t)?!0:(e.children||[]).some(e=>o(e,t))}function s(e){let t=new Set,n=e=>{for(let r of e){if(r.id===null||r.id===void 0||String(r.id)===``)throw Error(`Every tree item must have a non-empty identifier.`);let e=String(r.id);if(t.has(e))throw Error(`Tree item identifiers must be unique. Duplicate identifier: ${e}.`);t.add(e),n(r.children||[])}};n(e)}function c(e,s,c,l,u={}){let d=t(e),f=r(d,s);if(!f)throw Error(`Tree item ${s} was not found.`);if(f.item.disabled||f.item.draggable===!1)throw Error(`Disabled tree items cannot be moved.`);let p=c==null||c===``?null:n(d,c);if(c!=null&&c!==``&&!p)throw Error(`Target parent ${c} was not found.`);if(p&&o(f.item,p.id))throw Error(`A tree item cannot be moved inside itself or one of its descendants.`);if(p?.disabled)throw Error(`Disabled tree items cannot contain children.`);if(u.allowNesting===!1&&p)throw Error(`Nesting is disabled for this tree.`);if(p?.canHaveChildren===!1)throw Error(`The target item cannot contain children.`);if(p?.acceptsTypes?.length&&!p.acceptsTypes.includes(f.item.type))throw Error(`The target item does not accept this item type.`);let m=p?p.children:d,h=f.siblings.findIndex(e=>String(e.id)===String(s)),[g]=f.siblings.splice(h,1),_=Math.min(Math.max(0,Number.isFinite(l)?Math.trunc(l):m.length),m.length);m.splice(_,0,g);let v=Number.isFinite(u.maxDepth)?Math.max(1,Math.trunc(u.maxDepth)):1/0;if((p?i(d,p.id)+1:0)+a(g)>v)throw Error(`Moving this branch would exceed the maximum tree depth of ${v}.`);return{items:d,item:g,oldParentId:f.parentId,newParentId:p?String(p.id):null,oldIndex:h,newIndex:_}}var l=0;function u(e,t,n){e.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:n}))}function d(e,t){let n=e.getAttribute(t);return n===``||n===`true`}function f(e){return e==null||e===``?null:String(e)}var p=class extends HTMLElement{constructor(...e){super(...e),this._items=[],this._undoStack=[],this._redoStack=[],this._selectedId=null,this._expandedIds=new Set,this._root=null,this._confirm=null,this._treeId=`mint-tree-${++l}`,this._liveRegion=null,this._dragExpansion=null,this._autoExpandedIds=new Set,this._dragHoverExpandedId=null,this._keyboardFocusRestore=null,this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer=null,this._onClick=e=>{let t=e.target instanceof Element?e.target.closest(`[data-tree-command]`):null;if(!t||!this.contains(t))return;let r=t.getAttribute(`data-tree-command`),i=t.getAttribute(`data-tree-id`);if(r===`create-root`)u(this,`mint-tree-create`,{parentId:null,items:this.items});else if(r===`expand-all`)this._expandedIds=this._defaultExpandedIds(this._items),this._syncExpandedDOM(),u(this,`mint-tree-expand`,{all:!0,expandedIds:this.expandedIds});else if(r===`collapse-all`)this._expandedIds.clear(),this._syncExpandedDOM(),u(this,`mint-tree-collapse`,{all:!0,expandedIds:[]});else if(r===`undo`)this._undo();else if(r===`redo`)this._redo();else if(r===`toggle`&&i){let e=!this._expandedIds.has(i);this._setExpanded(i,e,!0)}else if(r===`select`&&i){if(this.classList.contains(`mint-tree-drag-active`)||this._suppressSelectionClick){e.preventDefault(),this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=null;return}this._select(i)}else if(r===`create-child`&&i)this._closeItemPopover(t),u(this,`mint-tree-create`,{parentId:i,items:this.items});else if(r===`edit`&&i){this._closeItemPopover(t);let e=n(this._items,i);e&&u(this,`mint-tree-edit`,{item:{...e},itemId:i,items:this.items})}else if(r===`delete`&&i)this._closeItemPopover(t),this._confirmDelete(i);else if([`move-up`,`move-down`,`nest-previous`,`outdent`].includes(r||``)&&i)this._closeItemPopover(t),this._moveByCommand(i,r||``);else if(r===`custom`&&i){this._closeItemPopover(t);let e=n(this._items,i),r=t.getAttribute(`data-tree-action`)||``,a=e?.actions?.find(e=>e.id===r);if(e&&a){let t={item:{...e},itemId:i,action:{...a,onSelect:void 0},items:this.items};u(this,`mint-tree-action`,t),a.onSelect?.({item:{...e},itemId:i,action:a,items:this.items})}}},this._onSortableDrag=e=>{let t=e.detail;if(!t||!Number.isFinite(t.clientX)||!Number.isFinite(t.clientY))return;let r=document.elementFromPoint(t.clientX,t.clientY),i=r?.closest(`[data-mint-tree-row]`),a=t.item?.getAttribute(`data-tree-id`)||``,o=null;if(i&&i.getAttribute(`data-tree-id`)!==a){let e=i.querySelector(`:scope > .mint-tree-row`)?.getBoundingClientRect()||i.getBoundingClientRect(),r=e.height?(t.clientY-e.top)/e.height:0;if(r>.22&&r<.78){let e=i.getAttribute(`data-tree-id`)||``;n(this._items,e)&&this._isValidDrop(a,e)&&(o=e)}}if(!o&&this._dragHoverExpandedId){let e=[...this._root?.querySelectorAll(`[data-tree-id]`)??[]].find(e=>e.getAttribute(`data-tree-id`)===this._dragHoverExpandedId)?.querySelector(`:scope > mint-sortable.mint-tree-children`);r&&e?.contains(r)&&(o=this._dragHoverExpandedId)}if(this._dragHoverExpandedId&&this._dragHoverExpandedId!==o){let e=this._dragHoverExpandedId;this._dragHoverExpandedId=null,this._autoExpandedIds.delete(e),this._expandedIds.delete(e),this._syncNodeExpanded(e);let t=n(this._items,e);t&&u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0})}if(o){let e=n(this._items,o);e&&!this._expandedIds.has(o)&&(this._expandedIds.add(o),this._autoExpandedIds.add(o),this._dragHoverExpandedId=o,this._syncNodeExpanded(o),u(this,`mint-tree-expand`,{itemId:o,item:{...e},expandedIds:this.expandedIds,automatic:!0}))}},this._onSortableStart=()=>{this.classList.add(`mint-tree-drag-active`),this._dragHoverExpandedId=null,this._dragExpansion?.timer!==null&&this._dragExpansion?.timer!==void 0&&window.clearTimeout(this._dragExpansion.timer),this._dragExpansion=null;let e=this._root?.querySelector(`.mint-sortable-dragging[data-tree-id]`),t=e?.getAttribute(`data-tree-id`)||``,n=e?.querySelector(`:scope > mint-sortable.mint-tree-children`);if(!e||!t||!n||n.hidden||!this._expandedIds.has(t))return;let r=e.querySelector(`:scope > .mint-tree-row`),i=this._root?.querySelector(`.mint-sortable-placeholder`),a=n.getBoundingClientRect().height;n.style.height=`${a}px`,n.style.overflow=`hidden`,e.style.height=`auto`,e.style.overflow=`hidden`,this._dragExpansion={itemId:t,item:e,childList:n,timer:null},this._setTransientExpanded(t,!1),n.offsetHeight,requestAnimationFrame(()=>{this._dragExpansion?.childList===n&&(n.classList.add(`mint-tree-drag-collapse`),n.style.height=`0px`,i&&r&&(i.style.minHeight=`${r.getBoundingClientRect().height}px`))})},this._onSortableEnd=e=>{this.classList.remove(`mint-tree-drag-active`),this._suppressSelectionClick=!0,this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=window.setTimeout(()=>{this._suppressSelectionClick=!1,this._selectionClickSuppressionTimer=null},300);let t=e.detail,r=t&&!t.cancelled?f(t.newParentId):null;for(let e of this._autoExpandedIds){if(e===r)continue;this._expandedIds.delete(e),this._syncNodeExpanded(e);let t=n(this._items,e);t&&u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0})}this._autoExpandedIds.clear(),this._dragHoverExpandedId=null;let i=this._dragExpansion;if(!i)return;i.item=[...this._root?.querySelectorAll(`[data-tree-id]`)??[]].find(e=>e.getAttribute(`data-tree-id`)===i.itemId)||i.item,i.childList=i.item.querySelector(`:scope > mint-sortable.mint-tree-children`)||i.childList;let{item:a,childList:o,itemId:s}=i;o.style.height=`0px`,o.style.overflow=`hidden`,o.classList.remove(`mint-tree-drag-collapse`),this._setTransientExpanded(s,!0),o.offsetHeight;let c=o.scrollHeight;requestAnimationFrame(()=>{this._dragExpansion===i&&(o.style.height=`${c}px`)}),i.timer=window.setTimeout(()=>{o.style.height=``,o.style.overflow=``,o.style.opacity=``,this._dragExpansion=null},155)},this._onSortableDragOver=e=>{let t=e,{item:r,target:i}=t.detail||{};if(!r||!i)return;this._root?.querySelectorAll(`.mint-tree-drop-invalid`).forEach(e=>e.classList.remove(`mint-tree-drop-invalid`));let a=this._root?.querySelector(`.mint-sortable-placeholder`),o=r.getAttribute(`data-tree-id`)||``,s=f(i.getAttribute(`data-tree-parent-id`)),c=i===t.detail.source||this._isValidDrop(o,s),l=s?n(this._items,s):null;c&&i!==t.detail.source&&l?a?.setAttribute(`data-drop-label`,`Drop here to nest under ${l.label}`):c&&i===this._root?.querySelector(`:scope > mint-sortable`)?a?.setAttribute(`data-drop-label`,`Drop here to move to the top level`):a?.removeAttribute(`data-drop-label`);let u=(Number.isFinite(t.detail.clientX)&&Number.isFinite(t.detail.clientY)?document.elementFromPoint(t.detail.clientX,t.detail.clientY):null)?.closest(`[data-mint-tree-row]`);u&&u.getAttribute(`data-tree-id`)!==o&&!c&&u.classList.add(`mint-tree-drop-invalid`),c||t.preventDefault()},this._onSortableBeforeDrop=e=>{let t=e,n=t.detail;if(!n?.item||!n.target)return;let r=n.item.getAttribute(`data-tree-id`)||``,i=f(n.target.getAttribute(`data-tree-parent-id`));n.target!==n.source&&!this._isValidDrop(r,i)&&t.preventDefault()},this._onSortableChange=e=>{let t=e.detail;if(!t||t.cancelled)return;let r=t.itemId||``,i=f(t.oldParentId),a=f(t.newParentId),o=this._root?.querySelector(`:scope > mint-sortable`);if(!o)return;let s=n(this._items,r);this._recordHistory(),this._items=this._readItemsFromDOM(o),this._collapseEmptyExpandedNodes();let c=n(this._items,r);if(!c||!s)return;let l={itemId:r,item:{...c},items:this.items,oldParentId:i,newParentId:a,oldIndex:Number(t.oldIndex??-1),newIndex:Number(t.newIndex??-1)};this._clearDropState(),u(this,`mint-tree-change`,{items:l.items,itemId:r}),i===a?u(this,`mint-tree-reorder`,l):u(this,`mint-tree-reparent`,l);let d=`${c.label} moved${a?` into ${n(this._items,a)?.label||`a group`}`:` to the top level`}.`;this._dragExpansion?.itemId===r?window.setTimeout(()=>{this.isConnected&&(this._render(),this._focusRow(r),this._announce(d))},155):(this._render(),this._focusRow(r),this._announce(d))},this._onKeydown=e=>{let t=e.target instanceof Element?e.target.closest(`[data-mint-tree-row]`):null;if(!t)return;if(e.altKey&&[`ArrowUp`,`ArrowDown`].includes(e.key)){e.preventDefault();let n=t.getAttribute(`data-tree-id`)||``;if(n){this._keyboardFocusRestore&&window.clearTimeout(this._keyboardFocusRestore.timer);let e={id:n,x:window.scrollX,y:window.scrollY,timer:0};e.timer=window.setTimeout(()=>{this._keyboardFocusRestore===e&&(this._keyboardFocusRestore=null)},2e3),this._keyboardFocusRestore=e}return}let i=t.getAttribute(`data-tree-id`)||``;if(e.altKey&&e.key===`ArrowRight`){e.preventDefault(),this._keyboardIndent(i);return}if(e.altKey&&e.key===`ArrowLeft`){e.preventDefault(),this._keyboardOutdent(i);return}let a=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].filter(e=>!e.closest(`mint-sortable[hidden]`)),o=a.indexOf(t);if(e.key===`ArrowDown`)e.preventDefault(),a[o+1]?.focus({preventScroll:!0});else if(e.key===`ArrowUp`)e.preventDefault(),a[o-1]?.focus({preventScroll:!0});else if(e.key===`ArrowRight`)e.preventDefault(),this._expandedIds.has(i)?a[o+1]?.focus({preventScroll:!0}):this._setExpanded(i,!0,!0);else if(e.key===`ArrowLeft`)if(e.preventDefault(),this._expandedIds.has(i))this._setExpanded(i,!1,!0);else{let e=r(this._items,i)?.parentId;e&&[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e)?.focus({preventScroll:!0})}else if(e.key===`Enter`||e.key===` `||e.key===`Spacebar`){let r=e.target instanceof Element?e.target.closest(`[data-tree-command="select"]`):null;(t===e.target||r)&&(e.preventDefault(),n(this._items,i)?.children?.length?this._setExpanded(i,!this._expandedIds.has(i),!0):this._select(i))}}}static get observedAttributes(){return[`selected-id`,`max-depth`,`allow-nesting`,`disabled`,`loading`,`create-label`,`empty-label`,`delete-confirmation`,`expanded-ids`]}connectedCallback(){this._root||(this._selectedId=f(this.getAttribute(`selected-id`)),this._expandedIds=this.hasAttribute(`expanded-ids`)?this._readExpandedIds(this.getAttribute(`expanded-ids`)):this._defaultExpandedIds(this._items),this.addEventListener(`click`,this._onClick),this.addEventListener(`keydown`,this._onKeydown,!0),this.addEventListener(`mint-sortable-start`,this._onSortableStart),this.addEventListener(`mint-sortable-end`,this._onSortableEnd),this.addEventListener(`mint-sortable-drag`,this._onSortableDrag),this.addEventListener(`mint-sortable-drag-over`,this._onSortableDragOver),this.addEventListener(`mint-sortable-before-drop`,this._onSortableBeforeDrop),this.addEventListener(`mint-sortable-change`,this._onSortableChange),this._render())}disconnectedCallback(){this._dragExpansion?.timer!==null&&this._dragExpansion?.timer!==void 0&&window.clearTimeout(this._dragExpansion.timer),this._keyboardFocusRestore&&window.clearTimeout(this._keyboardFocusRestore.timer),this._selectionClickSuppressionTimer!==null&&window.clearTimeout(this._selectionClickSuppressionTimer),this._selectionClickSuppressionTimer=null,this._suppressSelectionClick=!1,this._keyboardFocusRestore=null,this._dragExpansion=null,this._autoExpandedIds.clear(),this._dragHoverExpandedId=null,this.classList.remove(`mint-tree-drag-active`),this.removeEventListener(`click`,this._onClick),this.removeEventListener(`keydown`,this._onKeydown,!0),this.removeEventListener(`mint-sortable-start`,this._onSortableStart),this.removeEventListener(`mint-sortable-end`,this._onSortableEnd),this.removeEventListener(`mint-sortable-drag`,this._onSortableDrag),this.removeEventListener(`mint-sortable-drag-over`,this._onSortableDragOver),this.removeEventListener(`mint-sortable-before-drop`,this._onSortableBeforeDrop),this.removeEventListener(`mint-sortable-change`,this._onSortableChange),this._root=null}attributeChangedCallback(e,t,n){if(!(t===n||!this.isConnected)){if(e===`selected-id`){this._selectedId=f(n),this._syncSelectionDOM();return}e===`expanded-ids`&&(this._expandedIds=this._readExpandedIds(n)),this._render()}}get items(){return t(this._items)}set items(e){this._items=t(Array.isArray(e)?e:[]),this._undoStack=[],this._redoStack=[],this.hasAttribute(`expanded-ids`)||(this._expandedIds=this._defaultExpandedIds(this._items)),this.isConnected&&this._render()}get selectedId(){return this._selectedId}set selectedId(e){this._selectedId=f(e),this._selectedId===null?this.removeAttribute(`selected-id`):this.setAttribute(`selected-id`,this._selectedId)}get expandedIds(){return[...this._expandedIds]}set expandedIds(e){this._expandedIds=new Set((Array.isArray(e)?e:[]).map(String)),this.isConnected&&this._render()}save(){u(this,`mint-tree-save`,{items:this.items})}select(e){this._select(String(e))}expand(e){this._setExpanded(String(e),!0,!0)}collapse(e){this._setExpanded(String(e),!1,!0)}_readExpandedIds(e){if(!e)return this._defaultExpandedIds(this._items);try{let t=JSON.parse(e);return new Set(Array.isArray(t)?t.map(String):[])}catch{return new Set(e.split(`,`).map(e=>e.trim()).filter(Boolean))}}_defaultExpandedIds(e){let t=new Set,n=e=>e.forEach(e=>{e.children?.length&&(t.add(String(e.id)),n(e.children))});return n(e),t}_maxDepth(){let e=Number.parseInt(this.getAttribute(`max-depth`)||``,10);return Number.isFinite(e)&&e>0?e:1/0}_allowNesting(){return!this.hasAttribute(`allow-nesting`)||d(this,`allow-nesting`)}_disabled(){return d(this,`disabled`)}_isLoading(){return d(this,`loading`)}_render(){let e=document.activeElement instanceof HTMLElement?document.activeElement.closest(`[data-mint-tree-row]`):null,t=e&&this.contains(e)?e.getAttribute(`data-tree-id`):null;t&&this._keyboardFocusRestore&&(this._keyboardFocusRestore.id=t);let n=document.createElement(`div`);n.className=`mint-tree-shell`,n.setAttribute(`role`,`tree`),n.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||`Hierarchical items`),n.setAttribute(`aria-busy`,String(this._isLoading()));let r=document.createElement(`div`);r.className=`mint-tree-toolbar`;let i=document.createElement(`span`);i.className=`mint-tree-count`,i.textContent=`${this._countItems()} ${this._countItems()===1?`item`:`items`}`,r.appendChild(i);let a=document.createElement(`div`);a.className=`mint-tree-toolbar-actions`;let o=this._createButton(``,`ghost`,`undo`);o.setAttribute(`icon`,`undo`),o.setAttribute(`aria-label`,`Undo last change`),o.setAttribute(`title`,`Undo`),(!this._undoStack.length||this._disabled())&&o.setAttribute(`disabled`,`true`);let s=this._createButton(``,`ghost`,`redo`);s.setAttribute(`icon`,`redo`),s.setAttribute(`aria-label`,`Redo last undone change`),s.setAttribute(`title`,`Redo`),(!this._redoStack.length||this._disabled())&&s.setAttribute(`disabled`,`true`);let c=this._createButton(``,`ghost`,`expand-all`);c.setAttribute(`icon`,`expand`),c.setAttribute(`aria-label`,`Expand all`),c.setAttribute(`title`,`Expand all`);let l=this._createButton(``,`ghost`,`collapse-all`);if(l.setAttribute(`icon`,`collapse`),l.setAttribute(`aria-label`,`Collapse all`),l.setAttribute(`title`,`Collapse all`),a.append(o,s,c,l),r.appendChild(a),n.appendChild(r),this._isLoading()){let e=document.createElement(`div`);e.className=`mint-tree-loading`,e.setAttribute(`aria-label`,`Loading items`);let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`small`),e.appendChild(t),n.appendChild(e)}else if(this._items.length)n.appendChild(this._createList(this._items,null,0));else{let e=document.createElement(`div`);e.className=`mint-tree-empty`,e.textContent=this.getAttribute(`empty-label`)||`No items yet.`,n.appendChild(e)}this._liveRegion=document.createElement(`div`),this._liveRegion.className=`mint-tree-live-region`,this._liveRegion.setAttribute(`role`,`status`),this._liveRegion.setAttribute(`aria-live`,`polite`),this._liveRegion.setAttribute(`aria-atomic`,`true`),n.appendChild(this._liveRegion);let u=document.createElement(`mint-confirm-action`);u.className=`mint-tree-confirm`,this._confirm=u,n.appendChild(u),this.replaceChildren(n),this._root=n,this.classList.add(`mint-tree`),this._disabled()?this.setAttribute(`aria-disabled`,`true`):this.removeAttribute(`aria-disabled`);let d=this._keyboardFocusRestore;d&&(this._focusRow(d.id),window.scrollTo({left:d.x,top:d.y,behavior:`instant`}),requestAnimationFrame(()=>{this._keyboardFocusRestore===d&&(this._focusRow(d.id),window.scrollTo({left:d.x,top:d.y,behavior:`instant`}))}))}_countItems(e=this._items){return e.reduce((e,t)=>e+1+this._countItems(t.children||[]),0)}_createButton(e,t,n){let r=document.createElement(`mint-button`);return r.textContent=e,r.setAttribute(`variant`,t),r.setAttribute(`data-tree-command`,n),r}_createList(e,t,n){let r=document.createElement(`mint-sortable`);r.id=`${this._treeId}-list-${t??`root`}`,r.setAttribute(`group`,this._treeId),r.setAttribute(`data-tree-parent-id`,t??``),r.setAttribute(`role`,`group`),r.setAttribute(`data-tree-depth`,String(n)),r.setAttribute(`direction`,`vertical`),r.setAttribute(`gap`,`1`),r.setAttribute(`handle-selector`,`[data-mint-sortable-handle]`),r.setAttribute(`animation-duration`,`320`),r.setAttribute(`item-key-attribute`,`data-tree-id`);let i=document.createElement(`mint-stack`);i.setAttribute(`direction`,`vertical`),i.setAttribute(`gap`,`1`);for(let t of e)i.appendChild(this._createNode(t,n));return r.appendChild(i),r}_createNode(e,t){let n=String(e.id),r=Array.isArray(e.children)?e.children:[],i=e.canHaveChildren!==!1&&this._allowNesting()&&t+a(e)<this._maxDepth(),o=document.createElement(`div`);o.className=`mint-tree-node`,o.setAttribute(`data-tree-id`,n),o.setAttribute(`role`,`treeitem`),o.setAttribute(`data-mint-tree-row`,``),o.setAttribute(`aria-level`,String(t+1)),o.setAttribute(`aria-selected`,String(this._selectedId===n)),o.setAttribute(`tabindex`,this._selectedId===n||this._selectedId===null&&t===0&&this._items[0]?.id===e.id?`0`:`-1`),o.setAttribute(`aria-label`,e.label),r.length&&o.setAttribute(`aria-expanded`,String(this._expandedIds.has(n))),(e.disabled||this._disabled())&&o.setAttribute(`aria-disabled`,`true`),(e.draggable===!1||this._disabled())&&o.setAttribute(`data-sortable-disabled`,``);let s=document.createElement(`div`);s.className=`mint-tree-row`,s.setAttribute(`data-tree-id`,n);let c=document.createElement(`span`);c.className=`mint-tree-drag-handle`,c.setAttribute(`data-mint-sortable-handle`,``),c.setAttribute(`role`,`button`),c.setAttribute(`tabindex`,`-1`),c.setAttribute(`aria-label`,`Drag ${e.label} to move`);let l=document.createElement(`mint-icon`);if(l.setAttribute(`name`,`grip-dots`),l.setAttribute(`aria-hidden`,`true`),c.appendChild(l),s.appendChild(c),r.length){let t=document.createElement(`mint-button`);t.className=`mint-tree-expand`,t.setAttribute(`variant`,`ghost`),t.setAttribute(`icon`,this._expandedIds.has(n)?`caret-up`:`caret-down`),t.setAttribute(`data-tree-command`,`toggle`),t.setAttribute(`data-tree-id`,n),t.setAttribute(`aria-label`,`${this._expandedIds.has(n)?`Collapse`:`Expand`} ${e.label}`),t.setAttribute(`aria-expanded`,String(this._expandedIds.has(n))),(this._disabled()||e.disabled===!0)&&t.setAttribute(`disabled`,`true`),s.appendChild(t)}else{let e=document.createElement(`span`);e.className=`mint-tree-expand-spacer`,e.setAttribute(`aria-hidden`,`true`),s.appendChild(e)}let u=document.createElement(`span`);if(u.className=`mint-tree-label`,u.setAttribute(`data-tree-command`,`select`),u.setAttribute(`data-tree-id`,n),i&&(u.setAttribute(`data-mint-sortable-drop-container`,`${this._treeId}-list-${n}`),u.setAttribute(`data-mint-sortable-drop-end`,``)),e.icon){let t=document.createElement(`mint-icon`);t.setAttribute(`name`,String(e.icon)),t.setAttribute(`aria-hidden`,`true`),u.appendChild(t)}let d=document.createElement(`span`);if(d.className=`mint-tree-label-text`,d.textContent=e.label,u.appendChild(d),s.appendChild(u),e.metadata){let t=document.createElement(`span`);t.className=`mint-tree-metadata`,t.textContent=String(e.metadata),s.appendChild(t)}let f=document.createElement(`span`);f.className=`mint-tree-nest-target`,f.setAttribute(`data-mint-sortable-drop-container`,`${this._treeId}-list-${n}`),f.setAttribute(`data-mint-sortable-drop-end`,``),f.setAttribute(`aria-hidden`,`true`);let p=document.createElement(`mint-icon`);p.setAttribute(`name`,`arrow-right`),p.setAttribute(`aria-hidden`,`true`),f.appendChild(p),i&&s.appendChild(f);let m=this._createActions(e,i);s.appendChild(m),o.appendChild(s);let h=this._createList(r,n,t+1);return h.classList.add(`mint-tree-children`),h.hidden=!this._expandedIds.has(n),o.appendChild(h),o}_createActions(e,t){let i=document.createElement(`div`);i.className=`mint-tree-actions`;let a=`${this._treeId}-actions-trigger-${encodeURIComponent(String(e.id))}`,o=`${a}-popover`,s=document.createElement(`mint-button`);s.id=a,s.setAttribute(`variant`,`ghost`),s.setAttribute(`icon`,`ellipsis`),s.setAttribute(`aria-label`,`Actions for ${e.label}`),s.setAttribute(`aria-haspopup`,`menu`),i.appendChild(s);let c=document.createElement(`mint-popover`);c.id=o,c.setAttribute(`trigger-id`,a),c.setAttribute(`direction`,`down`),c.setAttribute(`trigger-align`,`end`),c.setAttribute(`padding`,`0.3rem`);let l=document.createElement(`div`);l.className=`mint-tree-menu`,l.setAttribute(`role`,`menu`);let u=(t,n,r=!1)=>{let i=document.createElement(`mint-button`);i.textContent=n,i.setAttribute(`variant`,`ghost`),i.setAttribute(`full-width`,`true`),i.setAttribute(`align`,`left`),i.setAttribute(`role`,`menuitem`),i.setAttribute(`data-tree-command`,t),i.setAttribute(`data-tree-id`,String(e.id)),(r||e.disabled===!0||this._disabled())&&i.setAttribute(`disabled`,`true`),l.appendChild(i)},d=Array.isArray(e.actions)?e.actions:null;if(d)for(let t of d){let n=document.createElement(`mint-button`);n.textContent=t.label,n.setAttribute(`variant`,`ghost`),n.setAttribute(`full-width`,`true`),n.setAttribute(`align`,`left`),n.setAttribute(`role`,`menuitem`),n.setAttribute(`data-tree-command`,`custom`),n.setAttribute(`data-tree-id`,String(e.id)),n.setAttribute(`data-tree-action`,t.id),(t.disabled===!0||e.disabled===!0||this._disabled())&&n.setAttribute(`disabled`,`true`),t.icon&&n.setAttribute(`icon`,t.icon),t.tone&&n.setAttribute(`tone`,t.tone),l.appendChild(n)}else{let i=r(this._items,e.id),a=i?.siblings||[],o=a.findIndex(t=>String(t.id)===String(e.id)),s=o>0?a[o-1]:null,c=i?.parentId?n(this._items,i.parentId):null;u(`move-up`,`Move up`,o<=0),u(`move-down`,`Move down`,o<0||o>=a.length-1),u(`nest-previous`,`Nest under previous item`,!s||!this._isValidDrop(String(e.id),String(s.id))),u(`outdent`,`Move to parent level`,!c),u(`create-child`,`Add child`,!t),u(`edit`,`Edit`),u(`delete`,`Delete`)}return c.appendChild(l),i.appendChild(c),i}_closeItemPopover(e){(e.closest(`.mint-tree-menu`)?.closest(`mint-popover`))?.close?.()}async _confirmDelete(e){let t=n(this._items,e);!t||!this._confirm?.showConfirm||await this._confirm.showConfirm({question:this.getAttribute(`delete-confirmation`)||`Delete “${t.label}”?`,tone:`danger`,confirmLabel:`Delete`,cancelLabel:`Cancel`})&&u(this,`mint-tree-delete`,{item:{...t},itemId:e,items:this.items})}_moveByCommand(e,t){let n=r(this._items,e);if(!n)return;let i=n.siblings.findIndex(t=>String(t.id)===e),a=n.parentId,o=i;if(t===`move-up`)o=i-1;else if(t===`move-down`)o=i+1;else if(t===`nest-previous`){let e=n.siblings[i-1];if(!e)return;a=String(e.id),o=(e.children||[]).length}else if(t===`outdent`){if(n.parentId===null)return;let e=r(this._items,n.parentId);if(!e)return;a=e.parentId,o=e.siblings.findIndex(e=>String(e.id)===n.parentId)+1}else return;try{let t=c(this._items,e,a,o,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._applyMove(t)}catch{}}_applyMove(e){this._recordHistory(),this._items=e.items,this._collapseEmptyExpandedNodes(),e.newParentId&&this._expandedIds.add(e.newParentId),this._render(),this._focusRow(String(e.item.id));let t={itemId:String(e.item.id),item:{...e.item},items:this.items,oldParentId:e.oldParentId,newParentId:e.newParentId,oldIndex:e.oldIndex,newIndex:e.newIndex};u(this,`mint-tree-change`,{items:t.items,itemId:t.itemId}),u(this,t.oldParentId===t.newParentId?`mint-tree-reorder`:`mint-tree-reparent`,t),this._announce(`${t.item.label} moved${t.newParentId?` into ${n(this._items,t.newParentId)?.label||`a group`}`:` to the top level`}.`)}_select(e){if(this.classList.contains(`mint-tree-drag-active`))return;let t=n(this._items,e);!t||t.disabled||this._disabled()||(this._selectedId=e,this.setAttribute(`selected-id`,e),this._syncSelectionDOM(),u(this,`mint-tree-select`,{item:{...t},itemId:e,items:this.items}))}_syncSelectionDOM(){(this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]).forEach(e=>{let t=e.getAttribute(`data-tree-id`)===this._selectedId;e.setAttribute(`aria-selected`,String(t)),e.tabIndex=t?0:-1})}_setExpanded(e,t,r){let i=n(this._items,e);!i||i.disabled||this._disabled()||(t?this._expandedIds.add(e):this._expandedIds.delete(e),this._syncNodeExpanded(e),r&&u(this,t?`mint-tree-expand`:`mint-tree-collapse`,{itemId:e,item:{...i},expandedIds:this.expandedIds}))}_syncExpandedDOM(){this._root?.querySelectorAll(`[data-mint-tree-row]`).forEach(e=>this._syncNodeExpanded(e.getAttribute(`data-tree-id`)||``))}_syncNodeExpanded(e){let t=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e),r=t?.querySelector(`:scope > mint-sortable.mint-tree-children`);if(!t||!r)return;let i=this._expandedIds.has(e);t.setAttribute(`aria-expanded`,String(i));let a=t.querySelector(`[data-tree-command="toggle"]`);a?.setAttribute(`aria-expanded`,String(i)),a?.setAttribute(`aria-label`,`${i?`Collapse`:`Expand`} ${n(this._items,e)?.label||`item`}`),a?.setAttribute(`icon`,i?`caret-up`:`caret-down`),r.hidden=!i}_setTransientExpanded(e,t){let r=[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e);if(!r)return;r.setAttribute(`aria-expanded`,String(t));let i=r.querySelector(`[data-tree-command="toggle"]`),a=n(this._items,e)?.label||`item`;i?.setAttribute(`aria-expanded`,String(t)),i?.setAttribute(`aria-label`,`${t?`Collapse`:`Expand`} ${a}`),i?.setAttribute(`icon`,t?`caret-up`:`caret-down`)}_isValidDrop(e,t){let r=n(this._items,e);if(!r)return!1;let i=t===null?null:n(this._items,t);return!(t!==null&&!i||i?.disabled||i&&(String(i.id)===e||this._isDescendant(r,i.id))||!this._allowNesting()&&i||i?.canHaveChildren===!1||i?.acceptsTypes?.length&&!i.acceptsTypes.includes(r.type||``)||(i?this._depthOf(String(i.id)):-1)+1+a(r)>this._maxDepth())}_isDescendant(e,t){return(e.children||[]).some(e=>String(e.id)===String(t)||this._isDescendant(e,t))}_depthOf(e){let t=r(this._items,e);return t?this._depthOfParent(t.parentId):-1}_depthOfParent(e){if(e===null)return 0;let t=r(this._items,e);return t?this._depthOfParent(t.parentId)+1:0}_readItemsFromDOM(e){let t=e.querySelector(`:scope > mint-stack`);return t?[...t.children].filter(e=>e instanceof HTMLElement&&e.classList.contains(`mint-tree-node`)).map(e=>{let t=e.getAttribute(`data-tree-id`)||``,r=n(this._items,t),i=e.querySelector(`:scope > mint-sortable.mint-tree-children`);return{...r||{id:t,label:t},children:i?this._readItemsFromDOM(i):[]}}):[]}_clearDropState(){this._root?.querySelectorAll(`.mint-tree-drop-invalid`).forEach(e=>e.classList.remove(`mint-tree-drop-invalid`))}_collapseEmptyExpandedNodes(){for(let e of[...this._expandedIds]){let t=n(this._items,e);!t||t.children?.length||(this._expandedIds.delete(e),this._syncNodeExpanded(e),u(this,`mint-tree-collapse`,{itemId:e,item:{...t},expandedIds:this.expandedIds,automatic:!0,empty:!0}))}}_announce(e){this._liveRegion&&(this._liveRegion.textContent=e)}_recordHistory(){this._undoStack.push(t(this._items)),this._undoStack.length>50&&this._undoStack.shift(),this._redoStack=[]}_undo(){let e=this._undoStack.pop();e&&(this._redoStack.push(t(this._items)),this._items=e,this._render(),u(this,`mint-tree-change`,{items:this.items,itemId:this._selectedId}),u(this,`mint-tree-undo`,{items:this.items}))}_redo(){let e=this._redoStack.pop();e&&(this._undoStack.push(t(this._items)),this._items=e,this._render(),u(this,`mint-tree-change`,{items:this.items,itemId:this._selectedId}),u(this,`mint-tree-redo`,{items:this.items}))}_keyboardIndent(e){let t=r(this._items,e);if(!t||t.siblings.indexOf(t.item)<=0)return;let n=t.siblings[t.siblings.indexOf(t.item)-1];try{let t=c(this._items,e,n.id,(n.children||[]).length,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._recordHistory(),this._items=t.items,this._expandedIds.add(String(n.id)),this._render(),this._focusRow(e),u(this,`mint-tree-reparent`,{itemId:e,item:{...t.item},items:this.items,oldParentId:t.oldParentId,newParentId:t.newParentId,oldIndex:t.oldIndex,newIndex:t.newIndex})}catch{}}_keyboardOutdent(e){let t=r(this._items,e);if(!t||t.parentId===null)return;let n=r(this._items,t.parentId);if(!n)return;let i=n.siblings.findIndex(e=>String(e.id)===t.parentId)+1;try{let t=c(this._items,e,n.parentId,i,{maxDepth:this._maxDepth(),allowNesting:this._allowNesting()});this._recordHistory(),this._items=t.items,this._render(),this._focusRow(e),u(this,`mint-tree-reparent`,{itemId:e,item:{...t.item},items:this.items,oldParentId:t.oldParentId,newParentId:t.newParentId,oldIndex:t.oldIndex,newIndex:t.newIndex})}catch{}}_focusRow(e){[...this._root?.querySelectorAll(`[data-mint-tree-row]`)??[]].find(t=>t.getAttribute(`data-tree-id`)===e)?.focus({preventScroll:!0})}};customElements.get(`mint-tree`)||e.t(`mint-tree`,p),exports.MintTree=p,exports.default=p;
|
|
@@ -13,9 +13,9 @@ import "../chunks/icon-D9XshOW2.js";
|
|
|
13
13
|
import { t as e } from "../chunks/register-element-BFYmIynH.js";
|
|
14
14
|
import "../chunks/spinner-BjC3nA-C.js";
|
|
15
15
|
import "../chunks/button-h2EuXJM5.js";
|
|
16
|
-
import "../chunks/confirm-action-
|
|
16
|
+
import "../chunks/confirm-action-CYr8kA4R.js";
|
|
17
17
|
import "../chunks/popover-FdMS4yAD.js";
|
|
18
|
-
import "../chunks/sortable-
|
|
18
|
+
import "../chunks/sortable-C46XSDeN.js";
|
|
19
19
|
//#region src/components/tree/tree-utils.js
|
|
20
20
|
function t(e = []) {
|
|
21
21
|
s(e);
|