@spectrum-web-components/dropzone 1.12.0-snapshot.20260422090428 → 1.12.0
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/custom-elements.json +17 -8
- package/package.json +2 -2
- package/src/Dropzone.dev.js +42 -27
- package/src/Dropzone.dev.js.map +2 -2
- package/src/Dropzone.js +2 -2
- package/src/Dropzone.js.map +3 -3
package/custom-elements.json
CHANGED
|
@@ -150,20 +150,29 @@
|
|
|
150
150
|
],
|
|
151
151
|
"events": [
|
|
152
152
|
{
|
|
153
|
-
"
|
|
154
|
-
"
|
|
153
|
+
"name": "sp-dropzone-dragover",
|
|
154
|
+
"type": {
|
|
155
|
+
"text": "CustomEvent"
|
|
156
|
+
},
|
|
157
|
+
"description": "Announces when files have been dragged over the UI, but not yet dropped."
|
|
155
158
|
},
|
|
156
159
|
{
|
|
157
|
-
"
|
|
158
|
-
"
|
|
160
|
+
"name": "sp-dropzone-dragleave",
|
|
161
|
+
"type": {
|
|
162
|
+
"text": "CustomEvent"
|
|
163
|
+
},
|
|
164
|
+
"description": "Announces when dragged files have been moved out of the UI without having been dropped."
|
|
159
165
|
},
|
|
160
166
|
{
|
|
161
|
-
"
|
|
162
|
-
"
|
|
167
|
+
"name": "sp-dropzone-drop",
|
|
168
|
+
"type": {
|
|
169
|
+
"text": "CustomEvent"
|
|
170
|
+
},
|
|
171
|
+
"description": "Announces when dragged files have been dropped on the UI."
|
|
163
172
|
},
|
|
164
173
|
{
|
|
165
|
-
"description": "
|
|
166
|
-
"name": "sp-dropzone-
|
|
174
|
+
"description": "A cancellable event that confirms whether or not a file dropped on the UI should be accepted.",
|
|
175
|
+
"name": "sp-dropzone-should-accept"
|
|
167
176
|
}
|
|
168
177
|
],
|
|
169
178
|
"attributes": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/dropzone",
|
|
3
|
-
"version": "1.12.0
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Adobe",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
],
|
|
55
55
|
"types": "./src/index.d.ts",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@spectrum-web-components/base": "1.12.0
|
|
57
|
+
"@spectrum-web-components/base": "1.12.0"
|
|
58
58
|
},
|
|
59
59
|
"keywords": [
|
|
60
60
|
"design-system",
|
package/src/Dropzone.dev.js
CHANGED
|
@@ -51,14 +51,19 @@ export class Dropzone extends SpectrumElement {
|
|
|
51
51
|
this.removeEventListener("drop", this.onDrop);
|
|
52
52
|
this.removeEventListener("dragover", this.onDragOver);
|
|
53
53
|
this.removeEventListener("dragleave", this.onDragLeave);
|
|
54
|
+
this.clearDebouncedDragLeave();
|
|
54
55
|
}
|
|
55
56
|
onDragOver(event) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
const shouldAcceptEvent = new CustomEvent(
|
|
59
|
+
"sp-dropzone-should-accept",
|
|
60
|
+
{
|
|
61
|
+
bubbles: true,
|
|
62
|
+
cancelable: true,
|
|
63
|
+
composed: true,
|
|
64
|
+
detail: event
|
|
65
|
+
}
|
|
66
|
+
);
|
|
62
67
|
const shouldAccept = this.dispatchEvent(shouldAcceptEvent);
|
|
63
68
|
if (!event.dataTransfer) {
|
|
64
69
|
return;
|
|
@@ -67,39 +72,49 @@ export class Dropzone extends SpectrumElement {
|
|
|
67
72
|
event.dataTransfer.dropEffect = "none";
|
|
68
73
|
return;
|
|
69
74
|
}
|
|
70
|
-
event.preventDefault();
|
|
71
75
|
this.clearDebouncedDragLeave();
|
|
72
|
-
this.isDragged
|
|
76
|
+
if (!this.isDragged) {
|
|
77
|
+
this.isDragged = true;
|
|
78
|
+
}
|
|
73
79
|
event.dataTransfer.dropEffect = this.dropEffect;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
this.dispatchEvent(
|
|
81
|
+
new CustomEvent("sp-dropzone-dragover", {
|
|
82
|
+
bubbles: true,
|
|
83
|
+
composed: true,
|
|
84
|
+
detail: event
|
|
85
|
+
})
|
|
86
|
+
);
|
|
80
87
|
}
|
|
81
88
|
onDragLeave(event) {
|
|
89
|
+
if (event.relatedTarget && this.contains(event.relatedTarget)) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
82
92
|
this.clearDebouncedDragLeave();
|
|
83
93
|
this.debouncedDragLeave = window.setTimeout(() => {
|
|
84
94
|
this.isDragged = false;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
this.dispatchEvent(
|
|
96
|
+
new CustomEvent("sp-dropzone-dragleave", {
|
|
97
|
+
bubbles: true,
|
|
98
|
+
composed: true,
|
|
99
|
+
detail: event
|
|
100
|
+
})
|
|
101
|
+
);
|
|
91
102
|
}, 100);
|
|
92
103
|
}
|
|
93
104
|
onDrop(event) {
|
|
94
105
|
event.preventDefault();
|
|
106
|
+
if (!this.isDragged) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
95
109
|
this.clearDebouncedDragLeave();
|
|
96
110
|
this.isDragged = false;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
this.dispatchEvent(
|
|
112
|
+
new CustomEvent("sp-dropzone-drop", {
|
|
113
|
+
bubbles: true,
|
|
114
|
+
composed: true,
|
|
115
|
+
detail: event
|
|
116
|
+
})
|
|
117
|
+
);
|
|
103
118
|
}
|
|
104
119
|
render() {
|
|
105
120
|
return html`
|
|
@@ -107,7 +122,7 @@ export class Dropzone extends SpectrumElement {
|
|
|
107
122
|
`;
|
|
108
123
|
}
|
|
109
124
|
clearDebouncedDragLeave() {
|
|
110
|
-
if (this.debouncedDragLeave) {
|
|
125
|
+
if (this.debouncedDragLeave !== null) {
|
|
111
126
|
clearTimeout(this.debouncedDragLeave);
|
|
112
127
|
this.debouncedDragLeave = null;
|
|
113
128
|
}
|
package/src/Dropzone.dev.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Dropzone.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport dropzoneStyles from './dropzone.css.js';\n\nexport type DropzoneEventDetail = DragEvent;\n\nexport type DropEffects = 'copy' | 'move' | 'link' | 'none';\n\n/**\n * @element sp-dropzone\n *\n * @slot - The default slot on an `sp-dropzone` is a great place to place upload instructions\n * built with an `sp-illustrated-message` or other information, possibly even built from data\n * provided by the upload, to support users successfully interacting with the drag and drop\n * based features of your application\n *\n * @fires sp-dropzone-should-accept - A cancellable event that confirms whether or not\n * a file dropped on the UI should be accepted.\n * @fires sp-dropzone-dragover - Announces when files have been dragged over the UI, but not yet dropped.\n * @fires sp-dropzone-dragleave - Announces when dragged files have been moved out of the UI without having been dropped.\n * @fires sp-dropzone-drop - Announces when dragged files have been dropped on the UI.\n */\nexport class Dropzone extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [dropzoneStyles];\n }\n\n /**\n * Controls the feedback (typically visual) the user is given during a drag and drop operation\n *\n * @attr\n * @type {'copy' | 'move' | 'link' | 'none'}\n */\n public get dropEffect(): DropEffects {\n return this._dropEffect;\n }\n public set dropEffect(value: DropEffects) {\n if (['copy', 'move', 'link', 'none'].includes(value)) {\n this._dropEffect = value;\n }\n }\n private _dropEffect: DropEffects = 'copy';\n\n /**\n * Indicates that files are currently being dragged over the dropzone.\n */\n @property({ type: Boolean, reflect: true, attribute: 'dragged' })\n public isDragged = false;\n\n /**\n * Set this property to indicate that the component is in a filled state.\n */\n @property({ type: Boolean, attribute: 'filled' })\n public isFilled = false;\n\n private debouncedDragLeave: number | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('drop', this.onDrop);\n this.addEventListener('dragover', this.onDragOver);\n this.addEventListener('dragleave', this.onDragLeave);\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.removeEventListener('drop', this.onDrop);\n this.removeEventListener('dragover', this.onDragOver);\n this.removeEventListener('dragleave', this.onDragLeave);\n }\n\n public onDragOver(event: DragEvent): void {\n const shouldAcceptEvent = new CustomEvent('sp-dropzone-should-accept'
|
|
5
|
-
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAEzB,OAAO,oBAAoB;AAoBpB,aAAM,iBAAiB,gBAAgB;AAAA,EAAvC;AAAA;
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport dropzoneStyles from './dropzone.css.js';\n\nexport type DropzoneEventDetail = DragEvent;\n\nexport type DropEffects = 'copy' | 'move' | 'link' | 'none';\n\n/**\n * @element sp-dropzone\n *\n * @slot - The default slot on an `sp-dropzone` is a great place to place upload instructions\n * built with an `sp-illustrated-message` or other information, possibly even built from data\n * provided by the upload, to support users successfully interacting with the drag and drop\n * based features of your application\n *\n * @fires sp-dropzone-should-accept - A cancellable event that confirms whether or not\n * a file dropped on the UI should be accepted.\n * @fires sp-dropzone-dragover - Announces when files have been dragged over the UI, but not yet dropped.\n * @fires sp-dropzone-dragleave - Announces when dragged files have been moved out of the UI without having been dropped.\n * @fires sp-dropzone-drop - Announces when dragged files have been dropped on the UI.\n */\nexport class Dropzone extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [dropzoneStyles];\n }\n\n /**\n * Controls the feedback (typically visual) the user is given during a drag and drop operation\n *\n * @attr\n * @type {'copy' | 'move' | 'link' | 'none'}\n */\n public get dropEffect(): DropEffects {\n return this._dropEffect;\n }\n\n public set dropEffect(value: DropEffects) {\n if (['copy', 'move', 'link', 'none'].includes(value)) {\n this._dropEffect = value;\n }\n }\n\n private _dropEffect: DropEffects = 'copy';\n\n /**\n * Indicates that files are currently being dragged over the dropzone.\n */\n @property({ type: Boolean, reflect: true, attribute: 'dragged' })\n public isDragged = false;\n\n /**\n * Set this property to indicate that the component is in a filled state.\n */\n @property({ type: Boolean, attribute: 'filled' })\n public isFilled = false;\n\n private debouncedDragLeave: number | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('drop', this.onDrop);\n this.addEventListener('dragover', this.onDragOver);\n this.addEventListener('dragleave', this.onDragLeave);\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.removeEventListener('drop', this.onDrop);\n this.removeEventListener('dragover', this.onDragOver);\n this.removeEventListener('dragleave', this.onDragLeave);\n\n this.clearDebouncedDragLeave();\n }\n\n public onDragOver(event: DragEvent): void {\n /**\n * Required for Chrome/Windows to consistently allow dropping.\n * Without preventDefault(), Chrome may suppress the drop event.\n */\n event.preventDefault();\n\n const shouldAcceptEvent = new CustomEvent<DragEvent>(\n 'sp-dropzone-should-accept',\n {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: event,\n }\n );\n\n const shouldAccept = this.dispatchEvent(shouldAcceptEvent);\n\n if (!event.dataTransfer) {\n return;\n }\n\n if (!shouldAccept) {\n event.dataTransfer.dropEffect = 'none';\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n if (!this.isDragged) {\n this.isDragged = true;\n }\n\n event.dataTransfer.dropEffect = this.dropEffect;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-dragover', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }\n\n public onDragLeave(event: DragEvent): void {\n /**\n * Ignore internal dragleave events triggered while moving\n * between children inside the dropzone.\n */\n if (event.relatedTarget && this.contains(event.relatedTarget as Node)) {\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n this.debouncedDragLeave = window.setTimeout(() => {\n this.isDragged = false;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-dragleave', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }, 100);\n }\n\n public onDrop(event: DragEvent): void {\n /**\n * Prevent browser default behavior (opening files in browser).\n */\n event.preventDefault();\n\n if (!this.isDragged) {\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n this.isDragged = false;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-drop', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected clearDebouncedDragLeave(): void {\n if (this.debouncedDragLeave !== null) {\n clearTimeout(this.debouncedDragLeave);\n this.debouncedDragLeave = null;\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-dropzone:should-accept': CustomEvent<DragEvent>;\n 'sp-dropzone:dragover': CustomEvent<DragEvent>;\n 'sp-dropzone:dragleave': CustomEvent<DragEvent>;\n 'sp-dropzone:drop': CustomEvent<DragEvent>;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAYA;AAAA,EAEE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AAEzB,OAAO,oBAAoB;AAoBpB,aAAM,iBAAiB,gBAAgB;AAAA,EAAvC;AAAA;AAqBL,SAAQ,cAA2B;AAMnC,SAAO,YAAY;AAMnB,SAAO,WAAW;AAElB,SAAQ,qBAAoC;AAAA;AAAA,EAlC5C,WAA2B,SAAyB;AAClD,WAAO,CAAC,cAAc;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAW,aAA0B;AACnC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,WAAW,OAAoB;AACxC,QAAI,CAAC,QAAQ,QAAQ,QAAQ,MAAM,EAAE,SAAS,KAAK,GAAG;AACpD,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EAkBgB,oBAA0B;AACxC,UAAM,kBAAkB;AAExB,SAAK,iBAAiB,QAAQ,KAAK,MAAM;AACzC,SAAK,iBAAiB,YAAY,KAAK,UAAU;AACjD,SAAK,iBAAiB,aAAa,KAAK,WAAW;AAAA,EACrD;AAAA,EAEgB,uBAA6B;AAC3C,UAAM,qBAAqB;AAE3B,SAAK,oBAAoB,QAAQ,KAAK,MAAM;AAC5C,SAAK,oBAAoB,YAAY,KAAK,UAAU;AACpD,SAAK,oBAAoB,aAAa,KAAK,WAAW;AAEtD,SAAK,wBAAwB;AAAA,EAC/B;AAAA,EAEO,WAAW,OAAwB;AAKxC,UAAM,eAAe;AAErB,UAAM,oBAAoB,IAAI;AAAA,MAC5B;AAAA,MACA;AAAA,QACE,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,UAAU;AA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;AApIS;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,SAAS,MAAM,WAAW,UAAU,CAAC;AAAA,GA1BrD,SA2BJ;AAMA;AAAA,EADN,SAAS,EAAE,MAAM,SAAS,WAAW,SAAS,CAAC;AAAA,GAhCrC,SAiCJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/src/Dropzone.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=(a,o,e,r)=>{for(var t=r>1?void 0:r?p(o,e):o,s=a.length-1,n;s>=0;s--)(n=a[s])&&(t=(r?n(o,e,t):n(t))||t);return r&&t&&l(o,e,t),t};import{html as c,SpectrumElement as u}from"@spectrum-web-components/base";import{property as i}from"@spectrum-web-components/base/src/decorators.js";import v from"./dropzone.css.js";export class Dropzone extends u{constructor(){super(...arguments);this._dropEffect="copy";this.isDragged=!1;this.isFilled=!1;this.debouncedDragLeave=null}static get styles(){return[v]}get dropEffect(){return this._dropEffect}set dropEffect(e){["copy","move","link","none"].includes(e)&&(this._dropEffect=e)}connectedCallback(){super.connectedCallback(),this.addEventListener("drop",this.onDrop),this.addEventListener("dragover",this.onDragOver),this.addEventListener("dragleave",this.onDragLeave)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("drop",this.onDrop),this.removeEventListener("dragover",this.onDragOver),this.removeEventListener("dragleave",this.onDragLeave),this.clearDebouncedDragLeave()}onDragOver(e){e.preventDefault();const r=new CustomEvent("sp-dropzone-should-accept",{bubbles:!0,cancelable:!0,composed:!0,detail:e}),t=this.dispatchEvent(r);if(e.dataTransfer){if(!t){e.dataTransfer.dropEffect="none";return}this.clearDebouncedDragLeave(),this.isDragged||(this.isDragged=!0),e.dataTransfer.dropEffect=this.dropEffect,this.dispatchEvent(new CustomEvent("sp-dropzone-dragover",{bubbles:!0,composed:!0,detail:e}))}}onDragLeave(e){e.relatedTarget&&this.contains(e.relatedTarget)||(this.clearDebouncedDragLeave(),this.debouncedDragLeave=window.setTimeout(()=>{this.isDragged=!1,this.dispatchEvent(new CustomEvent("sp-dropzone-dragleave",{bubbles:!0,composed:!0,detail:e}))},100))}onDrop(e){e.preventDefault(),this.isDragged&&(this.clearDebouncedDragLeave(),this.isDragged=!1,this.dispatchEvent(new CustomEvent("sp-dropzone-drop",{bubbles:!0,composed:!0,detail:e})))}render(){return c`
|
|
2
2
|
<slot></slot>
|
|
3
|
-
`}clearDebouncedDragLeave(){this.debouncedDragLeave&&(clearTimeout(this.debouncedDragLeave),this.debouncedDragLeave=null)}}d([i({type:Boolean,reflect:!0,attribute:"dragged"})],Dropzone.prototype,"isDragged",2),d([i({type:Boolean,attribute:"filled"})],Dropzone.prototype,"isFilled",2);
|
|
3
|
+
`}clearDebouncedDragLeave(){this.debouncedDragLeave!==null&&(clearTimeout(this.debouncedDragLeave),this.debouncedDragLeave=null)}}d([i({type:Boolean,reflect:!0,attribute:"dragged"})],Dropzone.prototype,"isDragged",2),d([i({type:Boolean,attribute:"filled"})],Dropzone.prototype,"isFilled",2);
|
|
4
4
|
//# sourceMappingURL=Dropzone.js.map
|
package/src/Dropzone.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["Dropzone.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport dropzoneStyles from './dropzone.css.js';\n\nexport type DropzoneEventDetail = DragEvent;\n\nexport type DropEffects = 'copy' | 'move' | 'link' | 'none';\n\n/**\n * @element sp-dropzone\n *\n * @slot - The default slot on an `sp-dropzone` is a great place to place upload instructions\n * built with an `sp-illustrated-message` or other information, possibly even built from data\n * provided by the upload, to support users successfully interacting with the drag and drop\n * based features of your application\n *\n * @fires sp-dropzone-should-accept - A cancellable event that confirms whether or not\n * a file dropped on the UI should be accepted.\n * @fires sp-dropzone-dragover - Announces when files have been dragged over the UI, but not yet dropped.\n * @fires sp-dropzone-dragleave - Announces when dragged files have been moved out of the UI without having been dropped.\n * @fires sp-dropzone-drop - Announces when dragged files have been dropped on the UI.\n */\nexport class Dropzone extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [dropzoneStyles];\n }\n\n /**\n * Controls the feedback (typically visual) the user is given during a drag and drop operation\n *\n * @attr\n * @type {'copy' | 'move' | 'link' | 'none'}\n */\n public get dropEffect(): DropEffects {\n return this._dropEffect;\n }\n public set dropEffect(value: DropEffects) {\n if (['copy', 'move', 'link', 'none'].includes(value)) {\n this._dropEffect = value;\n }\n }\n private _dropEffect: DropEffects = 'copy';\n\n /**\n * Indicates that files are currently being dragged over the dropzone.\n */\n @property({ type: Boolean, reflect: true, attribute: 'dragged' })\n public isDragged = false;\n\n /**\n * Set this property to indicate that the component is in a filled state.\n */\n @property({ type: Boolean, attribute: 'filled' })\n public isFilled = false;\n\n private debouncedDragLeave: number | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('drop', this.onDrop);\n this.addEventListener('dragover', this.onDragOver);\n this.addEventListener('dragleave', this.onDragLeave);\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.removeEventListener('drop', this.onDrop);\n this.removeEventListener('dragover', this.onDragOver);\n this.removeEventListener('dragleave', this.onDragLeave);\n }\n\n public onDragOver(event: DragEvent): void {\n const shouldAcceptEvent = new CustomEvent('sp-dropzone-should-accept'
|
|
5
|
-
"mappings": "qNAYA,OAEE,QAAAA,EACA,mBAAAC,MAEK,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,OAAOC,MAAoB,oBAoBpB,aAAM,iBAAiBF,CAAgB,CAAvC,
|
|
6
|
-
"names": ["html", "SpectrumElement", "property", "dropzoneStyles", "value", "event", "shouldAcceptEvent", "shouldAccept", "
|
|
4
|
+
"sourcesContent": ["/**\n * Copyright 2026 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n CSSResultArray,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nimport dropzoneStyles from './dropzone.css.js';\n\nexport type DropzoneEventDetail = DragEvent;\n\nexport type DropEffects = 'copy' | 'move' | 'link' | 'none';\n\n/**\n * @element sp-dropzone\n *\n * @slot - The default slot on an `sp-dropzone` is a great place to place upload instructions\n * built with an `sp-illustrated-message` or other information, possibly even built from data\n * provided by the upload, to support users successfully interacting with the drag and drop\n * based features of your application\n *\n * @fires sp-dropzone-should-accept - A cancellable event that confirms whether or not\n * a file dropped on the UI should be accepted.\n * @fires sp-dropzone-dragover - Announces when files have been dragged over the UI, but not yet dropped.\n * @fires sp-dropzone-dragleave - Announces when dragged files have been moved out of the UI without having been dropped.\n * @fires sp-dropzone-drop - Announces when dragged files have been dropped on the UI.\n */\nexport class Dropzone extends SpectrumElement {\n public static override get styles(): CSSResultArray {\n return [dropzoneStyles];\n }\n\n /**\n * Controls the feedback (typically visual) the user is given during a drag and drop operation\n *\n * @attr\n * @type {'copy' | 'move' | 'link' | 'none'}\n */\n public get dropEffect(): DropEffects {\n return this._dropEffect;\n }\n\n public set dropEffect(value: DropEffects) {\n if (['copy', 'move', 'link', 'none'].includes(value)) {\n this._dropEffect = value;\n }\n }\n\n private _dropEffect: DropEffects = 'copy';\n\n /**\n * Indicates that files are currently being dragged over the dropzone.\n */\n @property({ type: Boolean, reflect: true, attribute: 'dragged' })\n public isDragged = false;\n\n /**\n * Set this property to indicate that the component is in a filled state.\n */\n @property({ type: Boolean, attribute: 'filled' })\n public isFilled = false;\n\n private debouncedDragLeave: number | null = null;\n\n public override connectedCallback(): void {\n super.connectedCallback();\n\n this.addEventListener('drop', this.onDrop);\n this.addEventListener('dragover', this.onDragOver);\n this.addEventListener('dragleave', this.onDragLeave);\n }\n\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n\n this.removeEventListener('drop', this.onDrop);\n this.removeEventListener('dragover', this.onDragOver);\n this.removeEventListener('dragleave', this.onDragLeave);\n\n this.clearDebouncedDragLeave();\n }\n\n public onDragOver(event: DragEvent): void {\n /**\n * Required for Chrome/Windows to consistently allow dropping.\n * Without preventDefault(), Chrome may suppress the drop event.\n */\n event.preventDefault();\n\n const shouldAcceptEvent = new CustomEvent<DragEvent>(\n 'sp-dropzone-should-accept',\n {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail: event,\n }\n );\n\n const shouldAccept = this.dispatchEvent(shouldAcceptEvent);\n\n if (!event.dataTransfer) {\n return;\n }\n\n if (!shouldAccept) {\n event.dataTransfer.dropEffect = 'none';\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n if (!this.isDragged) {\n this.isDragged = true;\n }\n\n event.dataTransfer.dropEffect = this.dropEffect;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-dragover', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }\n\n public onDragLeave(event: DragEvent): void {\n /**\n * Ignore internal dragleave events triggered while moving\n * between children inside the dropzone.\n */\n if (event.relatedTarget && this.contains(event.relatedTarget as Node)) {\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n this.debouncedDragLeave = window.setTimeout(() => {\n this.isDragged = false;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-dragleave', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }, 100);\n }\n\n public onDrop(event: DragEvent): void {\n /**\n * Prevent browser default behavior (opening files in browser).\n */\n event.preventDefault();\n\n if (!this.isDragged) {\n return;\n }\n\n this.clearDebouncedDragLeave();\n\n this.isDragged = false;\n\n this.dispatchEvent(\n new CustomEvent<DragEvent>('sp-dropzone-drop', {\n bubbles: true,\n composed: true,\n detail: event,\n })\n );\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot></slot>\n `;\n }\n\n protected clearDebouncedDragLeave(): void {\n if (this.debouncedDragLeave !== null) {\n clearTimeout(this.debouncedDragLeave);\n this.debouncedDragLeave = null;\n }\n }\n}\n\ndeclare global {\n interface GlobalEventHandlersEventMap {\n 'sp-dropzone:should-accept': CustomEvent<DragEvent>;\n 'sp-dropzone:dragover': CustomEvent<DragEvent>;\n 'sp-dropzone:dragleave': CustomEvent<DragEvent>;\n 'sp-dropzone:drop': CustomEvent<DragEvent>;\n }\n}\n"],
|
|
5
|
+
"mappings": "qNAYA,OAEE,QAAAA,EACA,mBAAAC,MAEK,gCACP,OAAS,YAAAC,MAAgB,kDAEzB,OAAOC,MAAoB,oBAoBpB,aAAM,iBAAiBF,CAAgB,CAAvC,kCAqBL,KAAQ,YAA2B,OAMnC,KAAO,UAAY,GAMnB,KAAO,SAAW,GAElB,KAAQ,mBAAoC,KAlC5C,WAA2B,QAAyB,CAClD,MAAO,CAACE,CAAc,CACxB,CAQA,IAAW,YAA0B,CACnC,OAAO,KAAK,WACd,CAEA,IAAW,WAAWC,EAAoB,CACpC,CAAC,OAAQ,OAAQ,OAAQ,MAAM,EAAE,SAASA,CAAK,IACjD,KAAK,YAAcA,EAEvB,CAkBgB,mB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AOL;AAAA;AAAA,KAGT,CAEU,yBAAgC,CACpC,KAAK,qBAAuB,OAC9B,aAAa,KAAK,kBAAkB,EACpC,KAAK,mBAAqB,KAE9B,CACF,CApISQ,EAAA,CADNN,EAAS,CAAE,KAAM,QAAS,QAAS,GAAM,UAAW,SAAU,CAAC,GA1BrD,SA2BJ,yBAMAM,EAAA,CADNN,EAAS,CAAE,KAAM,QAAS,UAAW,QAAS,CAAC,GAhCrC,SAiCJ",
|
|
6
|
+
"names": ["html", "SpectrumElement", "property", "dropzoneStyles", "value", "event", "shouldAcceptEvent", "shouldAccept", "__decorateClass"]
|
|
7
7
|
}
|