monobill-mintui 0.6.681 → 0.6.682
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/alert/browser.js +3 -8
- package/dist/components/alert/index.cjs +1 -1
- package/dist/components/alert/index.js +3 -8
- package/dist/components/back-button/browser.js +1 -1
- package/dist/components/back-button/index.cjs +1 -1
- package/dist/components/back-button/index.js +1 -1
- package/dist/components/button/browser.js +1 -1
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/chip/browser.js +1 -1
- package/dist/components/chip/index.cjs +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chunks/{back-button-DM9ajnIB.js → back-button-cGUnOwR0.js} +1 -1
- package/dist/components/chunks/{back-button-E389glZH.js → back-button-olXJu_Sg.js} +1 -1
- package/dist/components/chunks/{button-D-NMERaG.js → button-B3VB87bu.js} +1 -1
- package/dist/components/chunks/{button-WCO2Tpah.js → button-kbb_mcUl.js} +1 -1
- package/dist/components/chunks/{chip-Ct2fr0ce.js → chip-DAtL5k_M.js} +1 -1
- package/dist/components/chunks/{chip-DovN-Bp2.js → chip-DUz4yd1g.js} +1 -1
- package/dist/components/chunks/{confirm-action-CgiQX3-2.js → confirm-action-CnPIYT3p.js} +3 -3
- package/dist/components/chunks/{confirm-action-BMb31P5R.js → confirm-action-DbbXuKLM.js} +1 -1
- package/dist/components/chunks/{date-picker-BSw2O7ZD.js → date-picker-Drb3TIOp.js} +1 -1
- package/dist/components/chunks/{date-picker-BVZKsafj.js → date-picker-Ip1NrxP9.js} +3 -3
- package/dist/components/chunks/{input-CNG7PaSY.js → input-Cbpk3dfA.js} +1 -1
- package/dist/components/chunks/{input-DzTy1_ke.js → input-Dqa8FmcB.js} +1 -1
- package/dist/components/chunks/{modal-7h_ECXDc.js → modal-CZARWHo8.js} +1 -1
- package/dist/components/chunks/{modal-lOXK_Bj-.js → modal-XaqMQTPn.js} +3 -3
- package/dist/components/chunks/{popover-eTECdkG7.js → popover-Bek5fgHz.js} +1 -1
- package/dist/components/chunks/{popover-BAXGWQgn.js → popover-co0gSvD-.js} +1 -1
- package/dist/components/chunks/{table-B9e-cnAC.js → table-B_g7lNzN.js} +1 -1
- package/dist/components/chunks/{table-vjF3q3J5.js → table-slcPmVWy.js} +1 -1
- package/dist/components/chunks/{time-picker-EefLx837.js → time-picker-C9TxayLS.js} +1 -1
- package/dist/components/chunks/{time-picker-CwHfWKcg.js → time-picker-uJ2DcTIE.js} +3 -3
- package/dist/components/chunks/warning-BmMe8nCm.js +9 -0
- package/dist/components/chunks/warning-DJFJUqRZ.js +1 -0
- 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/date-picker/browser.js +1 -1
- package/dist/components/date-picker/index.cjs +1 -1
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/datetime-picker/browser.js +3 -3
- package/dist/components/datetime-picker/index.cjs +1 -1
- package/dist/components/datetime-picker/index.js +3 -3
- package/dist/components/dropzone/Dropzone.d.ts +25 -0
- package/dist/components/dropzone/Dropzone.d.ts.map +1 -1
- package/dist/components/dropzone/browser.js +128 -30
- package/dist/components/dropzone/index.cjs +1 -1
- package/dist/components/dropzone/index.d.ts +1 -0
- package/dist/components/dropzone/index.d.ts.map +1 -1
- package/dist/components/dropzone/index.js +128 -30
- package/dist/components/input/browser.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +1 -1
- package/dist/components/link/browser.js +1 -1
- package/dist/components/link/index.cjs +1 -1
- package/dist/components/link/index.js +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/navigation/browser.js +3 -3
- package/dist/components/navigation/index.cjs +1 -1
- package/dist/components/navigation/index.js +3 -3
- package/dist/components/off-canvas/browser.js +3 -3
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +3 -3
- package/dist/components/page/browser.js +3 -3
- package/dist/components/page/index.cjs +1 -1
- package/dist/components/page/index.js +3 -3
- package/dist/components/popover/browser.js +1 -1
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/resource-table/browser.js +8 -8
- package/dist/components/resource-table/index.cjs +1 -1
- package/dist/components/resource-table/index.js +8 -8
- package/dist/components/scroll-fade/browser.js +1 -1
- package/dist/components/scroll-fade/index.cjs +1 -1
- package/dist/components/scroll-fade/index.js +1 -1
- package/dist/components/search/browser.js +5 -5
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.js +5 -5
- package/dist/components/select/browser.js +1 -1
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +1 -1
- package/dist/components/side-navigation/browser.js +5 -5
- package/dist/components/side-navigation/index.cjs +1 -1
- package/dist/components/side-navigation/index.js +5 -5
- 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/spinner/browser.js +1 -1
- package/dist/components/spinner/index.cjs +1 -1
- package/dist/components/spinner/index.js +1 -1
- package/dist/components/stack/browser.js +1 -1
- package/dist/components/stack/index.cjs +1 -1
- package/dist/components/stack/index.js +1 -1
- package/dist/components/table/browser.js +1 -1
- package/dist/components/table/index.cjs +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/tags/browser.js +3 -3
- package/dist/components/tags/index.cjs +1 -1
- package/dist/components/tags/index.js +3 -3
- package/dist/components/text/browser.js +1 -1
- package/dist/components/text/index.cjs +1 -1
- package/dist/components/text/index.js +1 -1
- package/dist/components/time-picker/browser.js +1 -1
- package/dist/components/time-picker/index.cjs +1 -1
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/tree/browser.js +5 -5
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +5 -5
- package/dist/dropzone.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +2 -2
- package/dist/index.js +126 -29
- package/dist/tree.css +1 -1
- package/package.json +1 -1
- /package/dist/components/chunks/{ScrollFade-DT2Br2g7.js → ScrollFade-BMs09zZN.js} +0 -0
- /package/dist/components/chunks/{ScrollFade-D1FPF6ZS.js → ScrollFade-DvzPIk2A.js} +0 -0
- /package/dist/components/chunks/{caret-down-BfBLwx6q.js → caret-down-BlWHVe6N.js} +0 -0
- /package/dist/components/chunks/{caret-down-BBhOg9_Z.js → caret-down-DpWztgFw.js} +0 -0
- /package/dist/components/chunks/{caret-right-C-bQyIjW.js → caret-right-CLV6cfS6.js} +0 -0
- /package/dist/components/chunks/{caret-right-CqNU7vAZ.js → caret-right-PMLTNWu6.js} +0 -0
- /package/dist/components/chunks/{close-BeiBTo1F.js → close-BiJXzxmk.js} +0 -0
- /package/dist/components/chunks/{close-a2blCqJN.js → close-Bkk4TtJM.js} +0 -0
- /package/dist/components/chunks/{link-CU-gTgir.js → link-ACOyvLkd.js} +0 -0
- /package/dist/components/chunks/{link-BjbBJpI6.js → link-DVKhDl3O.js} +0 -0
- /package/dist/components/chunks/{search-Ce29Aglb.js → search-BnA4_oWo.js} +0 -0
- /package/dist/components/chunks/{search-BiBJR6IK.js → search-oEuzdZDO.js} +0 -0
- /package/dist/components/chunks/{sortable-C46XSDeN.js → sortable-BAL3k9Se.js} +0 -0
- /package/dist/components/chunks/{sortable-BmObFEEn.js → sortable-Dgk6LvmB.js} +0 -0
- /package/dist/components/chunks/{spinner-BjC3nA-C.js → spinner-B2sml0AG.js} +0 -0
- /package/dist/components/chunks/{spinner-DfPbEa2d.js → spinner-CUcCgLKS.js} +0 -0
- /package/dist/components/chunks/{stack-nq3AmcMG.js → stack-CzcHNnl8.js} +0 -0
- /package/dist/components/chunks/{stack-Bdl46AdO.js → stack-DEIdHS0n.js} +0 -0
- /package/dist/components/chunks/{text-Bmfl6CxJ.js → text-C-6UCBp-.js} +0 -0
- /package/dist/components/chunks/{text-Cpl5ljSe.js → text-CfvRRKGZ.js} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./icon-Basse9AD.js";
|
|
2
2
|
import { t as e } from "./register-element-BFYmIynH.js";
|
|
3
|
-
import "./text-
|
|
4
|
-
import "./input-
|
|
5
|
-
import "./popover-
|
|
3
|
+
import "./text-C-6UCBp-.js";
|
|
4
|
+
import "./input-Dqa8FmcB.js";
|
|
5
|
+
import "./popover-co0gSvD-.js";
|
|
6
6
|
//#region src/components/time-picker/TimePicker.ts
|
|
7
7
|
var t = class extends HTMLElement {
|
|
8
8
|
constructor(...e) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { a as e } from "./icon-Basse9AD.js";
|
|
2
|
+
e({
|
|
3
|
+
name: "warning",
|
|
4
|
+
viewBox: "0 0 24 24",
|
|
5
|
+
path: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z",
|
|
6
|
+
strokeLinecap: "round",
|
|
7
|
+
strokeLinejoin: "round"
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./icon-CGXHKbMq.js`).a({name:`warning`,viewBox:`0 0 24 24`,path:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`,strokeLinecap:`round`,strokeLinejoin:`round`});
|
|
@@ -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-CnPIYT3p.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-DbbXuKLM.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-CnPIYT3p.js";
|
|
10
10
|
export { t as confirm, e as default };
|
|
@@ -16,5 +16,5 @@ __mintLoadStyle('icon', '../../icon.css')
|
|
|
16
16
|
__mintLoadStyle('popover', '../../popover.css')
|
|
17
17
|
__mintLoadStyle('stack', '../../stack.css')
|
|
18
18
|
__mintLoadStyle('date-picker', '../../date-picker.css')
|
|
19
|
-
import { t as e } from "../chunks/date-picker-
|
|
19
|
+
import { t as e } from "../chunks/date-picker-Ip1NrxP9.js";
|
|
20
20
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/date-picker-
|
|
1
|
+
const e=require(`../chunks/date-picker-Drb3TIOp.js`);module.exports=e.t;
|
|
@@ -21,9 +21,9 @@ __mintLoadStyle('text', '../../text.css')
|
|
|
21
21
|
__mintLoadStyle('datetime-picker', '../../datetime-picker.css')
|
|
22
22
|
import "../chunks/icon-Basse9AD.js";
|
|
23
23
|
import { t as e } from "../chunks/register-element-BFYmIynH.js";
|
|
24
|
-
import "../chunks/text-
|
|
25
|
-
import "../chunks/date-picker-
|
|
26
|
-
import "../chunks/time-picker-
|
|
24
|
+
import "../chunks/text-C-6UCBp-.js";
|
|
25
|
+
import "../chunks/date-picker-Ip1NrxP9.js";
|
|
26
|
+
import "../chunks/time-picker-uJ2DcTIE.js";
|
|
27
27
|
//#region src/components/datetime-picker/DateTimePicker.ts
|
|
28
28
|
var t = class extends HTMLElement {
|
|
29
29
|
constructor(...e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`../chunks/icon-CGXHKbMq.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-
|
|
1
|
+
require(`../chunks/icon-CGXHKbMq.js`);const e=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/text-CfvRRKGZ.js`),require(`../chunks/date-picker-Drb3TIOp.js`),require(`../chunks/time-picker-C9TxayLS.js`);var t=class extends HTMLElement{constructor(...e){super(...e),this._datePicker=null,this._timePicker=null,this._content=null,this._popoverContent=null,this._popoverObserver=null,this._hiddenInput=null,this._dateValue=``,this._timeValue=``,this._dateStageComplete=!1,this._ready=!1,this._writingValue=!1,this._displayControlBound=!1}static get observedAttributes(){return[`value`,`label`,`info`,`name`,`required`,`disabled`,`readonly`,`format`,`display-format`,`min`,`max`,`shortcuts`,`hours`,`minutes`,`seconds`,`error`,`error-message`]}connectedCallback(){this.classList.add(`mint-datetime-picker`),this._readValue(this.getAttribute(`value`)||``),this.render(),this._ready=!0}attributeChangedCallback(e,t,n){if(!(t===n||!this._ready||e===`value`&&this._writingValue)){if(e===`value`){this._readValue(n||``),this.render();return}if(e===`error`||e===`error-message`){this._syncState();return}this.render()}}get value(){return this.getAttribute(`value`)||``}set value(e){this.setValue(e||``)}getValue(){return this.getAttribute(`value`)||``}setValue(e){this._readValue(e),this._writingValue=!0,e?this.setAttribute(`value`,e):this.removeAttribute(`value`),this._writingValue=!1,this.render(),this._syncState()}_parseDate(e,t){let n=e.match(/^(\d{4})-(\d{2})-(\d{2})/);if(n)return new Date(Number(n[1]),Number(n[2])-1,Number(n[3]));let r={yyyy:`(\\d{4})`,yy:`(\\d{2})`,Y:`(\\d{4})`,y:`(\\d{2})`,mm:`(\\d{1,2})`,m:`(\\d{1,2})`,n:`(\\d{1,2})`,dd:`(\\d{1,2})`,d:`(\\d{1,2})`,j:`(\\d{1,2})`,M:`([A-Za-z]+)`,F:`([A-Za-z]+)`},i=Object.keys(r).sort((e,t)=>t.length-e.length),a=[],o=`^`;for(let e=0;e<t.length;){let n=i.find(n=>t.startsWith(n,e));n?(o+=r[n],a.push(n),e+=n.length):(o+=t[e].replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),e++)}let s=e.match(RegExp(`${o}$`,`i`));if(!s)return null;let c=2e3,l=1,u=1;a.forEach((e,t)=>{let n=s[t+1];if(e===`Y`||e===`yyyy`)c=Number(n);else if(e===`y`||e===`yy`)c=Number(n)+2e3;else if(e===`m`||e===`mm`||e===`n`)l=Number(n);else if(e===`d`||e===`dd`||e===`j`)u=Number(n);else if(e===`M`||e===`F`){let e=new Date(`${n} 1, 2000`).getMonth();Number.isNaN(e)||(l=e+1)}});let d=new Date(c,l-1,u);return d.getFullYear()===c&&d.getMonth()===l-1&&d.getDate()===u?d:null}_formatDate(e,t){let n=e=>String(e).padStart(2,`0`),r={Y:String(e.getFullYear()),yyyy:String(e.getFullYear()),yy:String(e.getFullYear()).slice(-2),y:String(e.getFullYear()).slice(-2),mm:n(e.getMonth()+1),m:n(e.getMonth()+1),n:String(e.getMonth()+1),dd:n(e.getDate()),d:n(e.getDate()),j:String(e.getDate()),M:e.toLocaleString(void 0,{month:`short`}),F:e.toLocaleString(void 0,{month:`long`})};return t.replace(/yyyy|yy|mm|dd|Y|y|m|n|d|j|M|F/g,e=>r[e])}_readValue(e){let[t=``,n=``]=e.split(/[T ]/),r=this._parseDate(t,this.getAttribute(`format`)||`mm/dd/yyyy`);this._dateValue=r?this._formatDate(r,this.getAttribute(`format`)||`mm/dd/yyyy`):``,this._timeValue=n||``,this._dateStageComplete=!!r}_toISODate(){let e=this._parseDate(this._dateValue,this.getAttribute(`format`)||`mm/dd/yyyy`);return e?`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`:``}_syncValue(e=!1){let t=this._toISODate(),n=this._timeValue,r=t&&n?`${t}T${n}`:``;this._writingValue=!0,r?this.setAttribute(`value`,r):this.removeAttribute(`value`),this._writingValue=!1,this._hiddenInput&&(this._hiddenInput.value=r),e&&r&&(this.dispatchEvent(new Event(`input`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:r},bubbles:!0,composed:!0})))}_syncState(){this._datePicker&&(this._datePicker.setAttribute(`value`,this._dateValue),this._datePicker.setAttribute(`error`,this.getAttribute(`error`)||`false`),this._datePicker.setAttribute(`error-message`,this.getAttribute(`error-message`)||``),this._timePicker?.setAttribute(`error`,this.getAttribute(`error`)||`false`),this._timePicker?.setAttribute(`error-message`,this.getAttribute(`error-message`)||``),this._hiddenInput&&(this._hiddenInput.value=this.getValue()),this._syncCombinedDisplay())}render(){let e=this.getAttribute(`label`)||``,t=this.getAttribute(`info`)||``,n=this.getAttribute(`format`)||`mm/dd/yyyy`,r=this.getAttribute(`disabled`)===`true`,i=this.getAttribute(`readonly`)===`true`;this._displayControlBound=!1;let a=document.createElement(`mint-date-picker`);a.setAttribute(`class`,`mint-datetime-picker-date`),a.setAttribute(`keep-open-on-select`,`true`),a.setAttribute(`format`,n),a.setAttribute(`value`,this._dateValue),a.setAttribute(`label`,e),a.setAttribute(`info`,t),a.setAttribute(`display-format`,this.getAttribute(`display-format`)||`F j, Y`);for(let e of[`min`,`max`,`shortcuts`])this.hasAttribute(e)&&a.setAttribute(e,this.getAttribute(e)||``);r&&a.setAttribute(`disabled`,`true`),i&&a.setAttribute(`readonly`,`true`),this.hasAttribute(`required`)&&a.setAttribute(`required`,this.getAttribute(`required`)||`true`),this.hasAttribute(`error`)&&a.setAttribute(`error`,this.getAttribute(`error`)||`false`),this.hasAttribute(`error-message`)&&a.setAttribute(`error-message`,this.getAttribute(`error-message`)||``),a.addEventListener(`change`,e=>{e.stopPropagation();let t=e.detail?.value||a.value||``;this._parseDate(t,n)&&(this._dateValue=t,this._dateStageComplete=!0,this._syncValue(!1),this._syncCombinedDisplay(),this._openTimeStage())}),this._datePicker=a,this._bindCombinedDisplayControl();let o=document.createElement(`div`);o.className=`mint-datetime-picker-content`,this._content=o,this.innerHTML=``,this.appendChild(o),o.appendChild(a),this._hiddenInput=document.createElement(`input`),this._hiddenInput.type=`hidden`,this._hiddenInput.name=this.getAttribute(`name`)||``,this._hiddenInput.value=this.getValue(),this.appendChild(this._hiddenInput),this._waitForPopover()}_getPopover(){let e=this._datePicker,t=e?.getPopoverElement?.()||e?._popover;if(t)return t;let n=e?.querySelector?.(`.mint-date-picker-icon-button`)?.id;return n?document.querySelector(`mint-popover[trigger-id="${CSS.escape(n)}"]`):null}_getPopoverContent(e){return e.querySelector(`.popover-content`)||e}_waitForPopover(e=0){let t=this._getPopover();if(!t){e<120&&requestAnimationFrame(()=>this._waitForPopover(e+1));return}if(this._popoverContent=this._datePicker?.getPopoverContentElement?.()||this._getPopoverContent(t),this._bindCombinedDisplayControl(),this._syncCombinedDisplay(),this._popoverObserver?.disconnect(),this._popoverObserver=new MutationObserver(()=>{if(t.getAttribute(`open`)===`true`){let e=this._datePicker;typeof e?.refreshCalendar==`function`?e.refreshCalendar():e?._buildCalendar?.()}}),this._popoverObserver.observe(t,{attributes:!0,attributeFilter:[`open`]}),t.getAttribute(`open`)===`true`){let e=this._datePicker;typeof e?.refreshCalendar==`function`?e.refreshCalendar():e?._buildCalendar?.()}}_bindCombinedDisplayControl(){if(this._displayControlBound||!this._datePicker)return;this._displayControlBound=!0;let e=e=>{if(!e.target?.closest(`.mint-date-picker-field`)||this.getAttribute(`disabled`)===`true`||this.getAttribute(`readonly`)===`true`||e instanceof KeyboardEvent&&e.key!==`Enter`&&e.key!==` `)return;e.preventDefault(),e.stopImmediatePropagation();let t=this._getPopover();t?.open?t.open():t?.setAttribute(`open`,`true`)};this._datePicker.addEventListener(`click`,e,!0),this._datePicker.addEventListener(`keydown`,e,!0)}_openTimeStage(){queueMicrotask(()=>{let e=this._getPopover();if(e?.getAttribute(`open`)!==`true`){typeof e?.open==`function`?e.open():e?.setAttribute(`open`,`true`),requestAnimationFrame(()=>this._renderTimeStage());return}this._renderTimeStage()})}_renderTimeStage(){if(!this._popoverContent||!this._dateStageComplete)return;let e=document.createElement(`div`);e.className=`mint-datetime-picker-panel`;let t=document.createElement(`button`);t.type=`button`,t.className=`mint-datetime-picker-time-heading`,t.setAttribute(`aria-label`,`Change date, ${this._dateValue}`),t.textContent=this._getFormattedDate(),t.addEventListener(`click`,()=>{let e=this._datePicker;typeof e?.refreshCalendar==`function`?e.refreshCalendar():e?._buildCalendar?.()});let n=document.createElement(`mint-time-picker`),r=this.getAttribute(`disabled`)===`true`,i=this.getAttribute(`readonly`)===`true`;n.setAttribute(`inline`,`true`),n.setAttribute(`value`,this._timeValue||`09:00`),n.setAttribute(`label`,``);for(let e of[`hours`,`minutes`,`seconds`])this.hasAttribute(e)&&n.setAttribute(e,this.getAttribute(e)||``);r&&n.setAttribute(`disabled`,`true`),i&&n.setAttribute(`readonly`,`true`),n.addEventListener(`change`,()=>{this._timeValue=n.getValue?.()||n.getAttribute(`value`)||``,this._syncValue(!0),this._syncCombinedDisplay()}),n.addEventListener(`change`,e=>e.stopPropagation()),n.addEventListener(`input`,e=>e.stopPropagation()),this._timePicker=n,e.appendChild(t),e.appendChild(n),this._popoverContent.replaceChildren(e)}_syncCombinedDisplay(){let e=this._datePicker?.getDisplayElement?.()||this._datePicker?.querySelector(`.mint-date-picker-display`);if(!e||!this._dateValue)return;let t=this._getFormattedDate();e.textContent=this._timeValue?`${t} · ${this._formatTime(this._timeValue)}`:t,e.setAttribute(`aria-label`,`${this.getAttribute(`label`)||`Date and time`}: ${e.textContent}`)}_getFormattedDate(){let e=this._parseDate(this._dateValue,this.getAttribute(`format`)||`mm/dd/yyyy`);return e?this._formatDate(e,this.getAttribute(`display-format`)||`F j, Y`):this._dateValue}_formatTime(e){let[t=`00`,n=`00`,r]=e.split(`:`),i=Number(t),a=this.getAttribute(`hours`)!==`false`,o=this.getAttribute(`minutes`)!==`false`,s=this.getAttribute(`seconds`)===`true`;if(!a)return[o?n:``,s?r||`00`:``].filter(Boolean).join(`:`);let c=i%12||12;return`${[String(c),o?n:``,s?r||`00`:``].filter(Boolean).join(`:`)} ${i>=12?`pm`:`am`}`}};customElements.get(`mint-datetime-picker`)||e.t(`mint-datetime-picker`,t),module.exports=t;
|
|
@@ -9,9 +9,9 @@ import '../../text.css'
|
|
|
9
9
|
import '../../datetime-picker.css'
|
|
10
10
|
import "../chunks/icon-Basse9AD.js";
|
|
11
11
|
import { t as e } from "../chunks/register-element-BFYmIynH.js";
|
|
12
|
-
import "../chunks/text-
|
|
13
|
-
import "../chunks/date-picker-
|
|
14
|
-
import "../chunks/time-picker-
|
|
12
|
+
import "../chunks/text-C-6UCBp-.js";
|
|
13
|
+
import "../chunks/date-picker-Ip1NrxP9.js";
|
|
14
|
+
import "../chunks/time-picker-uJ2DcTIE.js";
|
|
15
15
|
//#region src/components/datetime-picker/DateTimePicker.ts
|
|
16
16
|
var t = class extends HTMLElement {
|
|
17
17
|
constructor(...e) {
|
|
@@ -10,6 +10,13 @@ declare class MintDropzone extends HTMLElement {
|
|
|
10
10
|
private _listenersInitialized;
|
|
11
11
|
private _selectedFiles;
|
|
12
12
|
private _previewUrls;
|
|
13
|
+
private _fileStates;
|
|
14
|
+
private _emptyState;
|
|
15
|
+
private _iconContainer;
|
|
16
|
+
private _labelElement;
|
|
17
|
+
private _transitionTimer;
|
|
18
|
+
private _resizeObserver;
|
|
19
|
+
private _showFileList;
|
|
13
20
|
private _resetHandler;
|
|
14
21
|
private _onDropzoneClick?;
|
|
15
22
|
private _onDragOver?;
|
|
@@ -48,12 +55,30 @@ declare class MintDropzone extends HTMLElement {
|
|
|
48
55
|
private _dispatchSelectionEvents;
|
|
49
56
|
private _syncFileInputFromSelected;
|
|
50
57
|
get files(): FileList | null;
|
|
58
|
+
/** Returns a snapshot of the files currently in the dropzone. */
|
|
59
|
+
getFiles(): File[];
|
|
60
|
+
/** Returns files with their current upload progress and error state. */
|
|
61
|
+
getFileEntries(): Array<{
|
|
62
|
+
file: File;
|
|
63
|
+
progress: number | null;
|
|
64
|
+
error: string;
|
|
65
|
+
uploaded: boolean;
|
|
66
|
+
}>;
|
|
67
|
+
/** Removes a file by File object, list index, or exact file name. */
|
|
68
|
+
removeFile(fileOrIndexOrName: File | number | string): boolean;
|
|
69
|
+
/** Sets a per-file upload percentage (0–100), or null to hide progress. */
|
|
70
|
+
setFileProgress(file: File, progress: number | null): void;
|
|
71
|
+
/** Sets a per-file server error message and exposes it from the file warning affordance. */
|
|
72
|
+
setFileError(file: File, message: string): void;
|
|
73
|
+
/** Marks a file as uploaded and hides its progress indicator. */
|
|
74
|
+
setFileUploaded(file: File): void;
|
|
51
75
|
syncFiles(): void;
|
|
52
76
|
private _renderPreviews;
|
|
53
77
|
private _removeFileAt;
|
|
54
78
|
private _cleanupPreviewUrls;
|
|
55
79
|
private _attachFormResetListener;
|
|
56
80
|
private _applyValidFiles;
|
|
81
|
+
private _animateListIn;
|
|
57
82
|
private _isDuplicateFile;
|
|
58
83
|
}
|
|
59
84
|
export default MintDropzone;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropzone.d.ts","sourceRoot":"","sources":["../../../src/components/dropzone/Dropzone.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAA;AAEtB,cAAM,YAAa,SAAQ,WAAW;IACpC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,qBAAqB,CAAiB;IAC9C,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,gBAAgB,CAAC,CAAyB;IAClD,OAAO,CAAC,WAAW,CAAC,CAAwB;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAwB;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAwB;IACxC,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,UAAU,CAAC,CAA4B;IAC/C,OAAO,CAAC,QAAQ,CAAC,CAAyB;IAC1C,OAAO,CAAC,OAAO,CAAC,CAAyB;IACzC,OAAO,CAAC,OAAO,CAA6D;;IAM5E,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"Dropzone.d.ts","sourceRoot":"","sources":["../../../src/components/dropzone/Dropzone.ts"],"names":[],"mappings":"AAEA,OAAO,eAAe,CAAA;AAEtB,cAAM,YAAa,SAAQ,WAAW;IACpC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,SAAS,CAA2B;IAC5C,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,iBAAiB,CAA2B;IACpD,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,gBAAgB,CAAiB;IACzC,OAAO,CAAC,qBAAqB,CAAiB;IAC9C,OAAO,CAAC,cAAc,CAAa;IACnC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,WAAW,CAAiF;IACpG,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,cAAc,CAA2B;IACjD,OAAO,CAAC,aAAa,CAA2B;IAChD,OAAO,CAAC,gBAAgB,CAA6C;IACrE,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,gBAAgB,CAAC,CAAyB;IAClD,OAAO,CAAC,WAAW,CAAC,CAAwB;IAC5C,OAAO,CAAC,YAAY,CAAC,CAAwB;IAC7C,OAAO,CAAC,OAAO,CAAC,CAAwB;IACxC,OAAO,CAAC,kBAAkB,CAAC,CAAoB;IAC/C,OAAO,CAAC,iBAAiB,CAAC,CAAoB;IAC9C,OAAO,CAAC,UAAU,CAAC,CAA4B;IAC/C,OAAO,CAAC,QAAQ,CAAC,CAAyB;IAC1C,OAAO,CAAC,OAAO,CAAC,CAAyB;IACzC,OAAO,CAAC,OAAO,CAA6D;;IAM5E,iBAAiB,IAAI,IAAI;IAMzB,oBAAoB,IAAI,IAAI;IAY5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAkB9F,QAAQ,IAAI,MAAM;IAIlB,SAAS,IAAI,MAAM;IAInB,UAAU,IAAI,OAAO;IAKrB,QAAQ,IAAI,MAAM;IAIlB,SAAS,IAAI,MAAM;IAInB,OAAO,CAAC,eAAe;IAwCvB,OAAO,IAAI,MAAM;IAIjB,QAAQ,IAAI,OAAO;IAKnB,eAAe,IAAI,MAAM;IAIzB,UAAU,IAAI,OAAO;IAKrB,SAAS,IAAI,OAAO;IAKpB,MAAM,IAAI,IAAI;IA2Gd,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,iBAAiB;IA0BzB,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,mBAAmB;IAyM3B,OAAO,CAAC,oBAAoB;IAwB5B,OAAO,CAAC,YAAY;IAqCpB,OAAO,CAAC,eAAe;IAyBvB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,wBAAwB;IAOhC,OAAO,CAAC,0BAA0B;IAyBlC,IAAI,KAAK,IAAI,QAAQ,GAAG,IAAI,CAI3B;IAED,iEAAiE;IACjE,QAAQ,IAAI,IAAI,EAAE;IAIlB,wEAAwE;IACxE,cAAc,IAAI,KAAK,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IAIlG,qEAAqE;IACrE,UAAU,CAAC,iBAAiB,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;IAS9D,2EAA2E;IAC3E,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAU1D,4FAA4F;IAC5F,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAO/C,iEAAiE;IACjE,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAQjC,SAAS,IAAI,IAAI;IAIjB,OAAO,CAAC,eAAe;IAsJvB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,gBAAgB;IA2BxB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,gBAAgB;CAOzB;AAOD,eAAe,YAAY,CAAA"}
|
|
@@ -16,7 +16,8 @@ __mintLoadStyle('dropzone', '../../dropzone.css')
|
|
|
16
16
|
import { a as e } from "../chunks/icon-Basse9AD.js";
|
|
17
17
|
import { t } from "../chunks/register-element-BFYmIynH.js";
|
|
18
18
|
import "../chunks/icon-DcgcsymT.js";
|
|
19
|
-
import "../chunks/
|
|
19
|
+
import "../chunks/warning-BmMe8nCm.js";
|
|
20
|
+
import "../chunks/close-BiJXzxmk.js";
|
|
20
21
|
e({
|
|
21
22
|
name: "upload",
|
|
22
23
|
viewBox: "0 0 24 24",
|
|
@@ -50,13 +51,13 @@ var n = class extends HTMLElement {
|
|
|
50
51
|
];
|
|
51
52
|
}
|
|
52
53
|
constructor() {
|
|
53
|
-
super(), this._dropzone = null, this._fileInput = null, this._previewContainer = null, this._isDragging = !1, this._wasDragging = !1, this._isUpdatingFiles = !1, this._listenersInitialized = !1, this._selectedFiles = [], this._previewUrls = [], this._resetHandler = null, this._a11yId = `mint-dropzone-${Math.random().toString(36).slice(2, 10)}`;
|
|
54
|
+
super(), this._dropzone = null, this._fileInput = null, this._previewContainer = null, this._isDragging = !1, this._wasDragging = !1, this._isUpdatingFiles = !1, this._listenersInitialized = !1, this._selectedFiles = [], this._previewUrls = [], this._fileStates = /* @__PURE__ */ new Map(), this._emptyState = null, this._iconContainer = null, this._labelElement = null, this._transitionTimer = null, this._resizeObserver = null, this._showFileList = !1, this._resetHandler = null, this._a11yId = `mint-dropzone-${Math.random().toString(36).slice(2, 10)}`;
|
|
54
55
|
}
|
|
55
56
|
connectedCallback() {
|
|
56
57
|
this.classList.add("mint-dropzone"), this.render(), this._attachFormResetListener();
|
|
57
58
|
}
|
|
58
59
|
disconnectedCallback() {
|
|
59
|
-
if (this.removeEventListeners(), this._cleanupPreviewUrls(), this._resetHandler) {
|
|
60
|
+
if (this.removeEventListeners(), this._cleanupPreviewUrls(), this._resizeObserver?.disconnect(), this._transitionTimer && clearTimeout(this._transitionTimer), this._resetHandler) {
|
|
60
61
|
let e = this.closest("form");
|
|
61
62
|
e && e.removeEventListener("reset", this._resetHandler), this._resetHandler = null;
|
|
62
63
|
}
|
|
@@ -120,17 +121,15 @@ var n = class extends HTMLElement {
|
|
|
120
121
|
let e = (this.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean), n = this.querySelector(".mint-dropzone-error");
|
|
121
122
|
n && (n.id = `${this.id || this._a11yId}-error`, e.push(n.id)), e.length ? this._dropzone.setAttribute("aria-describedby", Array.from(new Set(e)).join(" ")) : this._dropzone.removeAttribute("aria-describedby");
|
|
122
123
|
}
|
|
123
|
-
this._dropzone.style.width = a, this._dropzone.style.height = o, this._dropzone.style.minWidth =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
f.className = "mint-dropzone-icon";
|
|
128
|
-
let p = document.createElement("mint-icon");
|
|
129
|
-
if (p.setAttribute("name", "upload"), p.className = "mint-dropzone-upload-icon", f.appendChild(p), this._dropzone.appendChild(f), t) {
|
|
130
|
-
let e = document.createElement("div");
|
|
131
|
-
e.className = "mint-dropzone-label", e.textContent = t, this._dropzone.appendChild(e);
|
|
124
|
+
if (this._dropzone.style.width = a, this._dropzone.style.height = o, this._dropzone.style.minWidth = "0", this._dropzone.style.minHeight = "0", this._dropzone.style.maxWidth = "100%", this._fileInput || (this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.className = "mint-dropzone-file-input", this._fileInput.setAttribute("tabindex", "-1"), this._fileInput.setAttribute("aria-hidden", "true"), this._dropzone.appendChild(this._fileInput)), this._fileInput.accept = n, this._fileInput.multiple = r, this._fileInput.disabled = i, s ? this._fileInput.name = s : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", c ? "true" : "false"), !this._emptyState) {
|
|
125
|
+
this._emptyState = document.createElement("div"), this._emptyState.className = "mint-dropzone-empty-state", this._iconContainer = document.createElement("div"), this._iconContainer.className = "mint-dropzone-icon";
|
|
126
|
+
let e = document.createElement("mint-icon");
|
|
127
|
+
e.setAttribute("name", "upload"), e.className = "mint-dropzone-upload-icon", this._iconContainer.appendChild(e), this._emptyState.appendChild(this._iconContainer), this._labelElement = document.createElement("div"), this._labelElement.className = "mint-dropzone-label", this._emptyState.appendChild(this._labelElement), this._dropzone.appendChild(this._emptyState);
|
|
132
128
|
}
|
|
133
|
-
this.
|
|
129
|
+
this._labelElement && (this._labelElement.textContent = t, this._labelElement.hidden = !t), this._dropzone.classList.toggle("has-files", this._selectedFiles.length > 0), this._emptyState.classList.toggle("is-hidden", this._selectedFiles.length > 0), this._emptyState.classList.remove("is-showing"), !this._resizeObserver && typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(([e]) => {
|
|
130
|
+
let { width: t, height: n } = e.contentRect;
|
|
131
|
+
this._dropzone?.classList.toggle("is-wide", t >= 520 && t >= n);
|
|
132
|
+
}), this._resizeObserver.observe(this._dropzone)), this.setupEventListeners(), this._renderErrorState(c, l), this._renderPreviews(), this._renderSkeleton(e);
|
|
134
133
|
}
|
|
135
134
|
_updateDragState() {
|
|
136
135
|
this._dropzone && this._updateDragStateClass();
|
|
@@ -283,6 +282,64 @@ var n = class extends HTMLElement {
|
|
|
283
282
|
get files() {
|
|
284
283
|
return this._syncFileInputFromSelected(), this._fileInput?.files || null;
|
|
285
284
|
}
|
|
285
|
+
getFiles() {
|
|
286
|
+
return [...this._selectedFiles];
|
|
287
|
+
}
|
|
288
|
+
getFileEntries() {
|
|
289
|
+
return this._selectedFiles.map((e) => ({
|
|
290
|
+
file: e,
|
|
291
|
+
...this._fileStates.get(e) || {
|
|
292
|
+
progress: null,
|
|
293
|
+
error: "",
|
|
294
|
+
uploaded: !1
|
|
295
|
+
}
|
|
296
|
+
}));
|
|
297
|
+
}
|
|
298
|
+
removeFile(e) {
|
|
299
|
+
let t = typeof e == "number" ? e : this._selectedFiles.findIndex((t) => typeof e == "string" ? t.name === e : t === e);
|
|
300
|
+
return t < 0 || t >= this._selectedFiles.length ? !1 : (this._removeFileAt(t), !0);
|
|
301
|
+
}
|
|
302
|
+
setFileProgress(e, t) {
|
|
303
|
+
if (!this._selectedFiles.includes(e)) return;
|
|
304
|
+
let n = this._fileStates.get(e) || {
|
|
305
|
+
progress: null,
|
|
306
|
+
error: "",
|
|
307
|
+
uploaded: !1
|
|
308
|
+
};
|
|
309
|
+
n.progress = t === null ? null : Math.max(0, Math.min(100, t)), n.uploaded = !1, this._fileStates.set(e, n), this._renderPreviews(), this.dispatchEvent(new CustomEvent("fileprogress", {
|
|
310
|
+
detail: {
|
|
311
|
+
file: e,
|
|
312
|
+
progress: n.progress
|
|
313
|
+
},
|
|
314
|
+
bubbles: !0,
|
|
315
|
+
composed: !0
|
|
316
|
+
}));
|
|
317
|
+
}
|
|
318
|
+
setFileError(e, t) {
|
|
319
|
+
this._selectedFiles.includes(e) && (this._fileStates.set(e, {
|
|
320
|
+
progress: null,
|
|
321
|
+
error: t,
|
|
322
|
+
uploaded: !1
|
|
323
|
+
}), this._renderPreviews(), this.dispatchEvent(new CustomEvent("fileerror", {
|
|
324
|
+
detail: {
|
|
325
|
+
file: e,
|
|
326
|
+
message: t
|
|
327
|
+
},
|
|
328
|
+
bubbles: !0,
|
|
329
|
+
composed: !0
|
|
330
|
+
})));
|
|
331
|
+
}
|
|
332
|
+
setFileUploaded(e) {
|
|
333
|
+
this._selectedFiles.includes(e) && (this._fileStates.set(e, {
|
|
334
|
+
progress: null,
|
|
335
|
+
error: "",
|
|
336
|
+
uploaded: !0
|
|
337
|
+
}), this._renderPreviews(), this.dispatchEvent(new CustomEvent("fileuploaded", {
|
|
338
|
+
detail: { file: e },
|
|
339
|
+
bubbles: !0,
|
|
340
|
+
composed: !0
|
|
341
|
+
})));
|
|
342
|
+
}
|
|
286
343
|
syncFiles() {
|
|
287
344
|
this._syncFileInputFromSelected();
|
|
288
345
|
}
|
|
@@ -296,24 +353,48 @@ var n = class extends HTMLElement {
|
|
|
296
353
|
e.className = "mint-dropzone-previews-wrapper", e.classList.toggle("has-error", this.hasError()), e.classList.toggle("is-dragging", this._isDragging);
|
|
297
354
|
let t = document.createElement("div");
|
|
298
355
|
t.className = "mint-dropzone-previews", this._selectedFiles.forEach((e, n) => {
|
|
299
|
-
let r =
|
|
300
|
-
|
|
356
|
+
let r = this._fileStates.get(e) || {
|
|
357
|
+
progress: null,
|
|
358
|
+
error: "",
|
|
359
|
+
uploaded: !1
|
|
360
|
+
}, i = document.createElement("div");
|
|
361
|
+
if (i.className = "mint-dropzone-file", i.classList.toggle("has-upload-error", !!r.error), e.type.startsWith("image/")) {
|
|
301
362
|
let t = document.createElement("img");
|
|
302
363
|
t.className = "mint-dropzone-file-image";
|
|
303
364
|
let n = URL.createObjectURL(e);
|
|
304
|
-
this._previewUrls.push(n), t.src = n,
|
|
365
|
+
this._previewUrls.push(n), t.src = n, i.appendChild(t);
|
|
305
366
|
} else {
|
|
306
367
|
let e = document.createElement("mint-icon");
|
|
307
|
-
e.setAttribute("name", "attach"), e.className = "mint-dropzone-file-icon",
|
|
368
|
+
e.setAttribute("name", "attach"), e.className = "mint-dropzone-file-icon", i.appendChild(e);
|
|
308
369
|
}
|
|
309
|
-
let
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
370
|
+
let a = document.createElement("div");
|
|
371
|
+
if (a.className = "mint-dropzone-file-name", a.textContent = e.name, i.appendChild(a), r.uploaded) {
|
|
372
|
+
let t = document.createElement("span");
|
|
373
|
+
t.className = "mint-dropzone-file-uploaded", t.setAttribute("role", "img"), t.setAttribute("aria-label", `${e.name} uploaded successfully`);
|
|
374
|
+
let n = document.createElement("mint-icon");
|
|
375
|
+
n.setAttribute("name", "check"), t.appendChild(n), i.appendChild(t);
|
|
376
|
+
} else if (r.progress !== null && !r.error) {
|
|
377
|
+
let t = document.createElement("progress");
|
|
378
|
+
t.className = "mint-dropzone-file-progress", t.max = 100, t.value = r.progress, t.setAttribute("aria-label", `Uploading ${e.name}: ${r.progress}%`), i.appendChild(t);
|
|
379
|
+
}
|
|
380
|
+
if (r.error) {
|
|
381
|
+
let t = document.createElement("button");
|
|
382
|
+
t.type = "button", t.className = "mint-dropzone-file-error", t.setAttribute("aria-label", `Upload failed for ${e.name}`), t.setAttribute("aria-expanded", "false");
|
|
383
|
+
let n = document.createElement("mint-icon");
|
|
384
|
+
n.setAttribute("name", "warning"), t.appendChild(n);
|
|
385
|
+
let a = document.createElement("span");
|
|
386
|
+
a.className = "mint-dropzone-file-error-message", a.setAttribute("role", "tooltip"), a.textContent = r.error, t.appendChild(a), t.addEventListener("click", (e) => {
|
|
387
|
+
e.preventDefault(), e.stopPropagation();
|
|
388
|
+
let n = t.classList.toggle("is-open");
|
|
389
|
+
t.setAttribute("aria-expanded", String(n));
|
|
390
|
+
}), i.appendChild(t);
|
|
391
|
+
}
|
|
392
|
+
let o = document.createElement("button");
|
|
393
|
+
o.type = "button", o.className = "mint-dropzone-file-remove";
|
|
394
|
+
let s = document.createElement("mint-icon");
|
|
395
|
+
s.setAttribute("name", "close"), s.className = "mint-dropzone-file-remove-icon", o.appendChild(s), o.addEventListener("click", (e) => {
|
|
315
396
|
e.preventDefault(), e.stopPropagation(), this._removeFileAt(n);
|
|
316
|
-
}),
|
|
397
|
+
}), i.appendChild(o), t.appendChild(i);
|
|
317
398
|
});
|
|
318
399
|
let n = document.createElement("div");
|
|
319
400
|
n.className = "mint-dropzone-preview-fade is-top", e.appendChild(n);
|
|
@@ -323,12 +404,12 @@ var n = class extends HTMLElement {
|
|
|
323
404
|
let e = t.scrollTop, i = t.scrollHeight, a = t.clientHeight;
|
|
324
405
|
e > 0 ? n.classList.add("is-visible") : n.classList.remove("is-visible"), e + a < i - 1 ? r.classList.add("is-visible") : r.classList.remove("is-visible");
|
|
325
406
|
};
|
|
326
|
-
i(), t.addEventListener("scroll", i), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
407
|
+
i(), t.addEventListener("scroll", i), e.appendChild(t), this._previewContainer = e, e.classList.toggle("is-visible", this._showFileList), this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
327
408
|
}
|
|
328
409
|
_removeFileAt(e) {
|
|
329
410
|
if (e < 0 || e >= this._selectedFiles.length) return;
|
|
330
411
|
let [t] = this._selectedFiles.splice(e, 1);
|
|
331
|
-
t && this._cleanupPreviewUrls(), this._syncFileInputFromSelected(), this._renderPreviews(), this._dispatchSelectionEvents();
|
|
412
|
+
t && (this._cleanupPreviewUrls(), this._fileStates.delete(t)), this._syncFileInputFromSelected(), this._selectedFiles.length === 0 ? this._animateListIn() : this._renderPreviews(), this._dispatchSelectionEvents();
|
|
332
413
|
}
|
|
333
414
|
_cleanupPreviewUrls() {
|
|
334
415
|
this._previewUrls.forEach((e) => URL.revokeObjectURL(e)), this._previewUrls = [];
|
|
@@ -336,15 +417,32 @@ var n = class extends HTMLElement {
|
|
|
336
417
|
_attachFormResetListener() {
|
|
337
418
|
let e = this.closest("form");
|
|
338
419
|
!e || this._resetHandler || (this._resetHandler = () => {
|
|
339
|
-
this._selectedFiles = [], this._syncFileInputFromSelected(), this.
|
|
420
|
+
this._selectedFiles = [], this._fileStates.clear(), this._syncFileInputFromSelected(), this._animateListIn(), this._cleanupPreviewUrls();
|
|
340
421
|
}, e.addEventListener("reset", this._resetHandler));
|
|
341
422
|
}
|
|
342
423
|
_applyValidFiles(e) {
|
|
343
424
|
if (this.isMultiple()) {
|
|
344
425
|
let t = e.filter((e) => !this._isDuplicateFile(e));
|
|
345
|
-
this._selectedFiles.push(...t)
|
|
346
|
-
|
|
347
|
-
|
|
426
|
+
this._selectedFiles.push(...t), t.forEach((e) => this._fileStates.set(e, {
|
|
427
|
+
progress: null,
|
|
428
|
+
error: "",
|
|
429
|
+
uploaded: !1
|
|
430
|
+
}));
|
|
431
|
+
} else this._selectedFiles = [e[0]], this._fileStates.clear(), this._fileStates.set(e[0], {
|
|
432
|
+
progress: null,
|
|
433
|
+
error: "",
|
|
434
|
+
uploaded: !1
|
|
435
|
+
});
|
|
436
|
+
this._syncFileInputFromSelected(), this._selectedFiles.length > 0 && (this.removeAttribute("error"), this.removeAttribute("error-message"), this._fileInput && this._fileInput.removeAttribute("aria-invalid")), this._renderPreviews(), this._animateListIn(), this._dispatchSelectionEvents();
|
|
437
|
+
}
|
|
438
|
+
_animateListIn() {
|
|
439
|
+
if (this._transitionTimer && clearTimeout(this._transitionTimer), !this._selectedFiles.length) {
|
|
440
|
+
this._showFileList = !1, this._dropzone?.classList.remove("has-files"), this._emptyState?.classList.remove("is-hidden", "is-hiding"), this._emptyState?.classList.add("is-showing"), this._transitionTimer = setTimeout(() => this._emptyState?.classList.remove("is-showing"), 220), this._renderPreviews();
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this._showFileList = !1, this._dropzone?.classList.add("has-files", "is-upload-transition"), this._emptyState?.classList.remove("is-hidden", "is-showing"), this._emptyState?.classList.add("is-hiding"), this._transitionTimer = setTimeout(() => {
|
|
444
|
+
this._showFileList = !0, this._emptyState?.classList.remove("is-hiding"), this._emptyState?.classList.add("is-hidden"), this._dropzone?.classList.remove("is-upload-transition"), this._renderPreviews();
|
|
445
|
+
}, 580);
|
|
348
446
|
}
|
|
349
447
|
_isDuplicateFile(e) {
|
|
350
448
|
return this._selectedFiles.some((t) => t.name === e.name && t.size === e.size && t.lastModified === e.lastModified);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/icon-CGXHKbMq.js`),t=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-Cfhjb8tV.js`),require(`../chunks/close-a2blCqJN.js`),e.a({name:`upload`,viewBox:`0 0 24 24`,path:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`,strokeLinecap:`round`,strokeLinejoin:`round`}),e.a({name:`attach`,viewBox:`0 0 24 24`,path:`M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13`,strokeLinecap:`round`,strokeLinejoin:`round`});var n=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`,`aria-label`,`aria-describedby`]}constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null,this._a11yId=`mint-dropzone-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-dropzone`),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e===`loading`){this.render();return}this.render()}}getLabel(){return this.getAttribute(`label`)||``}getAccept(){return this.getAttribute(`accept`)||``}isMultiple(){return this.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=this._dropzone;if(e){this.classList.add(`is-loading`),t||(t=document.createElement(`div`),t.className=`mint-dropzone-skeleton-container`,n?(n.classList.add(`is-positioned`),n.appendChild(t)):this.appendChild(t));let e=t.querySelector(`.mint-dropzone-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton`,t.appendChild(e)),t.classList.add(`is-visible`),n?.classList.add(`is-loading`)}else this.classList.remove(`is-loading`),t&&t.classList.remove(`is-visible`),n?.classList.remove(`is-loading`)}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();if(this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i)this._dropzone.setAttribute(`tabindex`,`-1`),this._dropzone.removeAttribute(`role`);else{this._dropzone.setAttribute(`tabindex`,`0`),this._dropzone.setAttribute(`role`,`button`),this._dropzone.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||t||`File upload dropzone`);let e=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),n=this.querySelector(`.mint-dropzone-error`);n&&(n.id=`${this.id||this._a11yId}-error`,e.push(n.id)),e.length?this._dropzone.setAttribute(`aria-describedby`,Array.from(new Set(e)).join(` `)):this._dropzone.removeAttribute(`aria-describedby`)}this._dropzone.style.width=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=a,this._dropzone.style.minHeight=o,this._fileInput||(this._fileInput=document.createElement(`input`),this._fileInput.type=`file`,this._fileInput.className=`mint-dropzone-file-input`,this._fileInput.setAttribute(`tabindex`,`-1`),this._fileInput.setAttribute(`aria-hidden`,`true`),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`);let u=this._dropzone.querySelector(`.mint-dropzone-icon`),d=this._dropzone.querySelector(`.mint-dropzone-label`);u&&u.remove(),d&&d.remove();let f=document.createElement(`div`);f.className=`mint-dropzone-icon`;let p=document.createElement(`mint-icon`);if(p.setAttribute(`name`,`upload`),p.className=`mint-dropzone-upload-icon`,f.appendChild(p),this._dropzone.appendChild(f),t){let e=document.createElement(`div`);e.className=`mint-dropzone-label`,e.textContent=t,this._dropzone.appendChild(e)}this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);if(e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error`,this.appendChild(n)),n.textContent=t):n&&n.remove(),this._dropzone){this._dropzone.setAttribute(`aria-invalid`,String(e)),n&&(n.id=`${this.id||this._a11yId}-error`);let t=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean);n&&t.push(n.id),t.length?this._dropzone.setAttribute(`aria-describedby`,Array.from(new Set(t)).join(` `)):this._dropzone.removeAttribute(`aria-describedby`)}}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError();this._dropzone.className=`mint-dropzone-target`,this._dropzone.classList.toggle(`has-files`,this._selectedFiles.length>0),this._dropzone.classList.toggle(`is-dragging`,this._isDragging),this._dropzone.classList.toggle(`has-error`,t),this._dropzone.classList.toggle(`is-disabled`,e)}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())},this._onDrop||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`is-focused`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.files||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper`,e.classList.toggle(`has-error`,this.hasError()),e.classList.toggle(`is-dragging`,this._isDragging);let t=document.createElement(`div`);t.className=`mint-dropzone-previews`,this._selectedFiles.forEach((e,n)=>{let r=document.createElement(`div`);if(r.className=`mint-dropzone-file`,e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`mint-dropzone-file-image`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,r.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`mint-dropzone-file-icon`,r.appendChild(e)}let i=document.createElement(`div`);i.className=`mint-dropzone-file-name`,i.textContent=e.name,r.appendChild(i);let a=document.createElement(`button`);a.type=`button`,a.className=`mint-dropzone-file-remove`;let o=document.createElement(`mint-icon`);o.setAttribute(`name`,`close`),o.className=`mint-dropzone-file-remove-icon`,a.appendChild(o),a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),r.appendChild(a),t.appendChild(r)});let n=document.createElement(`div`);n.className=`mint-dropzone-preview-fade is-top`,e.appendChild(n);let r=document.createElement(`div`);r.className=`mint-dropzone-preview-fade is-bottom is-visible`,e.appendChild(r);let i=()=>{let e=t.scrollTop,i=t.scrollHeight,a=t.clientHeight;e>0?n.classList.add(`is-visible`):n.classList.remove(`is-visible`),e+a<i-1?r.classList.add(`is-visible`):r.classList.remove(`is-visible`)};i(),t.addEventListener(`scroll`,i),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){let e=this.closest(`form`);!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener(`reset`,this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t)}else this._selectedFiles=[e[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute(`error`),this.removeAttribute(`error-message`),this._fileInput&&this._fileInput.removeAttribute(`aria-invalid`)),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}};customElements.get(`mint-dropzone`)||t.t(`mint-dropzone`,n),module.exports=n;
|
|
1
|
+
const e=require(`../chunks/icon-CGXHKbMq.js`),t=require(`../chunks/register-element-tCL_F1YI.js`);require(`../chunks/icon-Cfhjb8tV.js`),require(`../chunks/warning-DJFJUqRZ.js`),require(`../chunks/close-Bkk4TtJM.js`),e.a({name:`upload`,viewBox:`0 0 24 24`,path:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`,strokeLinecap:`round`,strokeLinejoin:`round`}),e.a({name:`attach`,viewBox:`0 0 24 24`,path:`M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13`,strokeLinecap:`round`,strokeLinejoin:`round`});var n=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`,`aria-label`,`aria-describedby`]}constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._fileStates=new Map,this._emptyState=null,this._iconContainer=null,this._labelElement=null,this._transitionTimer=null,this._resizeObserver=null,this._showFileList=!1,this._resetHandler=null,this._a11yId=`mint-dropzone-${Math.random().toString(36).slice(2,10)}`}connectedCallback(){this.classList.add(`mint-dropzone`),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resizeObserver?.disconnect(),this._transitionTimer&&clearTimeout(this._transitionTimer),this._resetHandler){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e===`loading`){this.render();return}this.render()}}getLabel(){return this.getAttribute(`label`)||``}getAccept(){return this.getAttribute(`accept`)||``}isMultiple(){return this.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=this._dropzone;if(e){this.classList.add(`is-loading`),t||(t=document.createElement(`div`),t.className=`mint-dropzone-skeleton-container`,n?(n.classList.add(`is-positioned`),n.appendChild(t)):this.appendChild(t));let e=t.querySelector(`.mint-dropzone-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton`,t.appendChild(e)),t.classList.add(`is-visible`),n?.classList.add(`is-loading`)}else this.classList.remove(`is-loading`),t&&t.classList.remove(`is-visible`),n?.classList.remove(`is-loading`)}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();if(this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i)this._dropzone.setAttribute(`tabindex`,`-1`),this._dropzone.removeAttribute(`role`);else{this._dropzone.setAttribute(`tabindex`,`0`),this._dropzone.setAttribute(`role`,`button`),this._dropzone.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||t||`File upload dropzone`);let e=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean),n=this.querySelector(`.mint-dropzone-error`);n&&(n.id=`${this.id||this._a11yId}-error`,e.push(n.id)),e.length?this._dropzone.setAttribute(`aria-describedby`,Array.from(new Set(e)).join(` `)):this._dropzone.removeAttribute(`aria-describedby`)}if(this._dropzone.style.width=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=`0`,this._dropzone.style.minHeight=`0`,this._dropzone.style.maxWidth=`100%`,this._fileInput||(this._fileInput=document.createElement(`input`),this._fileInput.type=`file`,this._fileInput.className=`mint-dropzone-file-input`,this._fileInput.setAttribute(`tabindex`,`-1`),this._fileInput.setAttribute(`aria-hidden`,`true`),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`),!this._emptyState){this._emptyState=document.createElement(`div`),this._emptyState.className=`mint-dropzone-empty-state`,this._iconContainer=document.createElement(`div`),this._iconContainer.className=`mint-dropzone-icon`;let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`upload`),e.className=`mint-dropzone-upload-icon`,this._iconContainer.appendChild(e),this._emptyState.appendChild(this._iconContainer),this._labelElement=document.createElement(`div`),this._labelElement.className=`mint-dropzone-label`,this._emptyState.appendChild(this._labelElement),this._dropzone.appendChild(this._emptyState)}this._labelElement&&(this._labelElement.textContent=t,this._labelElement.hidden=!t),this._dropzone.classList.toggle(`has-files`,this._selectedFiles.length>0),this._emptyState.classList.toggle(`is-hidden`,this._selectedFiles.length>0),this._emptyState.classList.remove(`is-showing`),!this._resizeObserver&&typeof ResizeObserver<`u`&&(this._resizeObserver=new ResizeObserver(([e])=>{let{width:t,height:n}=e.contentRect;this._dropzone?.classList.toggle(`is-wide`,t>=520&&t>=n)}),this._resizeObserver.observe(this._dropzone)),this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);if(e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error`,this.appendChild(n)),n.textContent=t):n&&n.remove(),this._dropzone){this._dropzone.setAttribute(`aria-invalid`,String(e)),n&&(n.id=`${this.id||this._a11yId}-error`);let t=(this.getAttribute(`aria-describedby`)||``).split(/\s+/).filter(Boolean);n&&t.push(n.id),t.length?this._dropzone.setAttribute(`aria-describedby`,Array.from(new Set(t)).join(` `)):this._dropzone.removeAttribute(`aria-describedby`)}}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError();this._dropzone.className=`mint-dropzone-target`,this._dropzone.classList.toggle(`has-files`,this._selectedFiles.length>0),this._dropzone.classList.toggle(`is-dragging`,this._isDragging),this._dropzone.classList.toggle(`has-error`,t),this._dropzone.classList.toggle(`is-disabled`,e)}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())},this._onDrop||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`is-focused`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.files||null}getFiles(){return[...this._selectedFiles]}getFileEntries(){return this._selectedFiles.map(e=>({file:e,...this._fileStates.get(e)||{progress:null,error:``,uploaded:!1}}))}removeFile(e){let t=typeof e==`number`?e:this._selectedFiles.findIndex(t=>typeof e==`string`?t.name===e:t===e);return t<0||t>=this._selectedFiles.length?!1:(this._removeFileAt(t),!0)}setFileProgress(e,t){if(!this._selectedFiles.includes(e))return;let n=this._fileStates.get(e)||{progress:null,error:``,uploaded:!1};n.progress=t===null?null:Math.max(0,Math.min(100,t)),n.uploaded=!1,this._fileStates.set(e,n),this._renderPreviews(),this.dispatchEvent(new CustomEvent(`fileprogress`,{detail:{file:e,progress:n.progress},bubbles:!0,composed:!0}))}setFileError(e,t){this._selectedFiles.includes(e)&&(this._fileStates.set(e,{progress:null,error:t,uploaded:!1}),this._renderPreviews(),this.dispatchEvent(new CustomEvent(`fileerror`,{detail:{file:e,message:t},bubbles:!0,composed:!0})))}setFileUploaded(e){this._selectedFiles.includes(e)&&(this._fileStates.set(e,{progress:null,error:``,uploaded:!0}),this._renderPreviews(),this.dispatchEvent(new CustomEvent(`fileuploaded`,{detail:{file:e},bubbles:!0,composed:!0})))}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper`,e.classList.toggle(`has-error`,this.hasError()),e.classList.toggle(`is-dragging`,this._isDragging);let t=document.createElement(`div`);t.className=`mint-dropzone-previews`,this._selectedFiles.forEach((e,n)=>{let r=this._fileStates.get(e)||{progress:null,error:``,uploaded:!1},i=document.createElement(`div`);if(i.className=`mint-dropzone-file`,i.classList.toggle(`has-upload-error`,!!r.error),e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`mint-dropzone-file-image`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,i.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`mint-dropzone-file-icon`,i.appendChild(e)}let a=document.createElement(`div`);if(a.className=`mint-dropzone-file-name`,a.textContent=e.name,i.appendChild(a),r.uploaded){let t=document.createElement(`span`);t.className=`mint-dropzone-file-uploaded`,t.setAttribute(`role`,`img`),t.setAttribute(`aria-label`,`${e.name} uploaded successfully`);let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`check`),t.appendChild(n),i.appendChild(t)}else if(r.progress!==null&&!r.error){let t=document.createElement(`progress`);t.className=`mint-dropzone-file-progress`,t.max=100,t.value=r.progress,t.setAttribute(`aria-label`,`Uploading ${e.name}: ${r.progress}%`),i.appendChild(t)}if(r.error){let t=document.createElement(`button`);t.type=`button`,t.className=`mint-dropzone-file-error`,t.setAttribute(`aria-label`,`Upload failed for ${e.name}`),t.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`warning`),t.appendChild(n);let a=document.createElement(`span`);a.className=`mint-dropzone-file-error-message`,a.setAttribute(`role`,`tooltip`),a.textContent=r.error,t.appendChild(a),t.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let n=t.classList.toggle(`is-open`);t.setAttribute(`aria-expanded`,String(n))}),i.appendChild(t)}let o=document.createElement(`button`);o.type=`button`,o.className=`mint-dropzone-file-remove`;let s=document.createElement(`mint-icon`);s.setAttribute(`name`,`close`),s.className=`mint-dropzone-file-remove-icon`,o.appendChild(s),o.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),i.appendChild(o),t.appendChild(i)});let n=document.createElement(`div`);n.className=`mint-dropzone-preview-fade is-top`,e.appendChild(n);let r=document.createElement(`div`);r.className=`mint-dropzone-preview-fade is-bottom is-visible`,e.appendChild(r);let i=()=>{let e=t.scrollTop,i=t.scrollHeight,a=t.clientHeight;e>0?n.classList.add(`is-visible`):n.classList.remove(`is-visible`),e+a<i-1?r.classList.add(`is-visible`):r.classList.remove(`is-visible`)};i(),t.addEventListener(`scroll`,i),e.appendChild(t),this._previewContainer=e,e.classList.toggle(`is-visible`,this._showFileList),this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[t]=this._selectedFiles.splice(e,1);t&&(this._cleanupPreviewUrls(),this._fileStates.delete(t)),this._syncFileInputFromSelected(),this._selectedFiles.length===0?this._animateListIn():this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){let e=this.closest(`form`);!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._fileStates.clear(),this._syncFileInputFromSelected(),this._animateListIn(),this._cleanupPreviewUrls()},e.addEventListener(`reset`,this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t),t.forEach(e=>this._fileStates.set(e,{progress:null,error:``,uploaded:!1}))}else this._selectedFiles=[e[0]],this._fileStates.clear(),this._fileStates.set(e[0],{progress:null,error:``,uploaded:!1});this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute(`error`),this.removeAttribute(`error-message`),this._fileInput&&this._fileInput.removeAttribute(`aria-invalid`)),this._renderPreviews(),this._animateListIn(),this._dispatchSelectionEvents()}_animateListIn(){if(this._transitionTimer&&clearTimeout(this._transitionTimer),!this._selectedFiles.length){this._showFileList=!1,this._dropzone?.classList.remove(`has-files`),this._emptyState?.classList.remove(`is-hidden`,`is-hiding`),this._emptyState?.classList.add(`is-showing`),this._transitionTimer=setTimeout(()=>this._emptyState?.classList.remove(`is-showing`),220),this._renderPreviews();return}this._showFileList=!1,this._dropzone?.classList.add(`has-files`,`is-upload-transition`),this._emptyState?.classList.remove(`is-hidden`,`is-showing`),this._emptyState?.classList.add(`is-hiding`),this._transitionTimer=setTimeout(()=>{this._showFileList=!0,this._emptyState?.classList.remove(`is-hiding`),this._emptyState?.classList.add(`is-hidden`),this._dropzone?.classList.remove(`is-upload-transition`),this._renderPreviews()},580)}_isDuplicateFile(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}};customElements.get(`mint-dropzone`)||t.t(`mint-dropzone`,n),module.exports=n;
|
|
@@ -3,6 +3,7 @@ import '../icon/index.ts';
|
|
|
3
3
|
import '../icon/icons/upload.ts';
|
|
4
4
|
import '../icon/icons/attach.ts';
|
|
5
5
|
import '../icon/icons/close.ts';
|
|
6
|
+
import '../icon/icons/warning.ts';
|
|
6
7
|
import './Dropzone';
|
|
7
8
|
export { default } from './Dropzone';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropzone/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AACrB,OAAO,kBAAkB,CAAA;AACzB,OAAO,yBAAyB,CAAA;AAChC,OAAO,yBAAyB,CAAA;AAChC,OAAO,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dropzone/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AACrB,OAAO,kBAAkB,CAAA;AACzB,OAAO,yBAAyB,CAAA;AAChC,OAAO,yBAAyB,CAAA;AAChC,OAAO,wBAAwB,CAAA;AAC/B,OAAO,0BAA0B,CAAA;AAEjC,OAAO,YAAY,CAAA;AAGnB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA"}
|