Skip to content

Commit 517afcb

Browse files
SteffenDEgithub-actions[bot]
authored andcommitted
Update assets
1 parent 2c741ed commit 517afcb

File tree

6 files changed

+142
-25
lines changed

6 files changed

+142
-25
lines changed

priv/static/phoenix_live_view.cjs.js

Lines changed: 44 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix_live_view.cjs.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix_live_view.esm.js

Lines changed: 44 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix_live_view.esm.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

priv/static/phoenix_live_view.js

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var LiveView = (() => {
5959
"phx-focus-loading",
6060
"phx-hook-loading"
6161
];
62+
var PHX_DROP_TARGET_ACTIVE_CLASS = "phx-drop-target-active";
6263
var PHX_COMPONENT = "data-phx-component";
6364
var PHX_VIEW_REF = "data-phx-view";
6465
var PHX_LIVE_LINK = "data-phx-link";
@@ -297,6 +298,16 @@ var LiveView = (() => {
297298
entryUploader.upload();
298299
});
299300
};
301+
var eventContainsFiles = (e) => {
302+
if (e.dataTransfer.types) {
303+
for (let i = 0; i < e.dataTransfer.types.length; i++) {
304+
if (e.dataTransfer.types[i] === "Files") {
305+
return true;
306+
}
307+
}
308+
}
309+
return false;
310+
};
300311

301312
// js/phoenix_live_view/browser.js
302313
var Browser = {
@@ -6296,14 +6307,42 @@ removing illegal node: "${(childNode.outerHTML || childNode.nodeValue).trim()}"
62966307
}
62976308
);
62986309
this.on("dragover", (e) => e.preventDefault());
6310+
this.on("dragenter", (e) => {
6311+
const dropzone = closestPhxBinding(
6312+
e.target,
6313+
this.binding(PHX_DROP_TARGET)
6314+
);
6315+
if (!dropzone || !(dropzone instanceof HTMLElement)) {
6316+
return;
6317+
}
6318+
if (eventContainsFiles(e)) {
6319+
this.js().addClass(dropzone, PHX_DROP_TARGET_ACTIVE_CLASS);
6320+
}
6321+
});
6322+
this.on("dragleave", (e) => {
6323+
const dropzone = closestPhxBinding(
6324+
e.target,
6325+
this.binding(PHX_DROP_TARGET)
6326+
);
6327+
if (!dropzone || !(dropzone instanceof HTMLElement)) {
6328+
return;
6329+
}
6330+
const rect = dropzone.getBoundingClientRect();
6331+
if (e.clientX <= rect.left || e.clientX >= rect.right || e.clientY <= rect.top || e.clientY >= rect.bottom) {
6332+
this.js().removeClass(dropzone, PHX_DROP_TARGET_ACTIVE_CLASS);
6333+
}
6334+
});
62996335
this.on("drop", (e) => {
63006336
e.preventDefault();
6301-
const dropTargetId = maybe(
6302-
closestPhxBinding(e.target, this.binding(PHX_DROP_TARGET)),
6303-
(trueTarget) => {
6304-
return trueTarget.getAttribute(this.binding(PHX_DROP_TARGET));
6305-
}
6337+
const dropzone = closestPhxBinding(
6338+
e.target,
6339+
this.binding(PHX_DROP_TARGET)
63066340
);
6341+
if (!dropzone || !(dropzone instanceof HTMLElement)) {
6342+
return;
6343+
}
6344+
this.js().removeClass(dropzone, PHX_DROP_TARGET_ACTIVE_CLASS);
6345+
const dropTargetId = dropzone.getAttribute(this.binding(PHX_DROP_TARGET));
63076346
const dropTarget = dropTargetId && document.getElementById(dropTargetId);
63086347
const files = Array.from(e.dataTransfer.files || []);
63096348
if (!dropTarget || !(dropTarget instanceof HTMLInputElement) || dropTarget.disabled || files.length === 0 || !(dropTarget.files instanceof FileList)) {

priv/static/phoenix_live_view.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)