@spectrum-web-components/dropzone 0.9.4 → 0.9.7
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 +2 -2
- package/package.json +4 -4
- package/src/dropzone.css.js +2 -2
- package/src/dropzone.css.js.map +1 -1
- package/src/spectrum-dropzone.css.js +2 -2
- package/src/spectrum-dropzone.css.js.map +1 -1
- package/stories/dropzone.stories.js +84 -0
- package/stories/dropzone.stories.js.map +1 -0
- package/test/benchmark/test-basic.js +40 -0
- package/test/benchmark/test-basic.js.map +1 -0
- package/test/dropzone.test-vrt.js +15 -0
- package/test/dropzone.test-vrt.js.map +1 -0
- package/test/dropzone.test.js +153 -0
- package/test/dropzone.test.js.map +1 -0
package/custom-elements.json
CHANGED
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
{
|
|
199
199
|
"kind": "variable",
|
|
200
200
|
"name": "styles",
|
|
201
|
-
"default": "css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500
|
|
201
|
+
"default": "css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))\n)}:host(:focus.focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus:focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus[dragged].focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus[dragged]:focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host{--spectrum-dropzone-illustration-color:var(\n--spectrum-global-color-static-blue-400\n);display:block}::slotted(*){font-family:var(\n--spectrum-body-m-text-font-family,var(--spectrum-alias-body-text-font-family)\n);font-size:var(\n--spectrum-body-s-text-size,var(--spectrum-alias-font-size-default)\n);font-style:var(\n--spectrum-body-s-text-font-style,var(--spectrum-global-font-style-regular)\n);font-weight:var(\n--spectrum-body-s-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);letter-spacing:var(\n--spectrum-body-s-text-letter-spacing,var(--spectrum-global-font-letter-spacing-none)\n);line-height:var(\n--spectrum-body-s-text-line-height,var(--spectrum-alias-body-text-line-height)\n);margin-bottom:0;margin-top:0;text-transform:var(--spectrum-body-s-text-transform,none)}:host([dragged]) ::slotted(*){--spectrum-global-color-gray-500:var(\n--spectrum-dropzone-illustration-color\n)}\n`"
|
|
202
202
|
}
|
|
203
203
|
],
|
|
204
204
|
"exports": [
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
{
|
|
235
235
|
"kind": "variable",
|
|
236
236
|
"name": "styles",
|
|
237
|
-
"default": "css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500
|
|
237
|
+
"default": "css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))\n)}:host(:focus.focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus:focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus[dragged].focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus[dragged]:focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}\n`"
|
|
238
238
|
}
|
|
239
239
|
],
|
|
240
240
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/dropzone",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"lit-html"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@spectrum-web-components/base": "^0.5.
|
|
47
|
+
"@spectrum-web-components/base": "^0.5.6",
|
|
48
48
|
"tslib": "^2.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@spectrum-css/dropzone": "^3.0.
|
|
51
|
+
"@spectrum-css/dropzone": "^3.0.23"
|
|
52
52
|
},
|
|
53
53
|
"types": "./src/index.d.ts",
|
|
54
54
|
"customElements": "custom-elements.json",
|
|
55
55
|
"sideEffects": [
|
|
56
56
|
"./sp-*.js"
|
|
57
57
|
],
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "32e049a0da090ffc1a54cfe3234be4d5efc73339"
|
|
59
59
|
}
|
package/src/dropzone.css.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -28,7 +28,7 @@ const styles = css `
|
|
|
28
28
|
)}:host(:focus){border-color:var(
|
|
29
29
|
--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)
|
|
30
30
|
)}:host(:focus) ::slotted(*){color:var(
|
|
31
|
-
--spectrum-global-color-static-gray-500
|
|
31
|
+
--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))
|
|
32
32
|
)}:host(:focus.focus-visible){border-color:var(
|
|
33
33
|
--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)
|
|
34
34
|
)}:host(:focus:focus-visible){border-color:var(
|
package/src/dropzone.css.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.css.js","sourceRoot":"","sources":["dropzone.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright
|
|
1
|
+
{"version":3,"file":"dropzone.css.js","sourceRoot":"","sources":["dropzone.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))\n)}:host(:focus.focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus:focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus[dragged].focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus[dragged]:focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host{--spectrum-dropzone-illustration-color:var(\n--spectrum-global-color-static-blue-400\n);display:block}::slotted(*){font-family:var(\n--spectrum-body-m-text-font-family,var(--spectrum-alias-body-text-font-family)\n);font-size:var(\n--spectrum-body-s-text-size,var(--spectrum-alias-font-size-default)\n);font-style:var(\n--spectrum-body-s-text-font-style,var(--spectrum-global-font-style-regular)\n);font-weight:var(\n--spectrum-body-s-text-font-weight,var(--spectrum-alias-body-text-font-weight)\n);letter-spacing:var(\n--spectrum-body-s-text-letter-spacing,var(--spectrum-global-font-letter-spacing-none)\n);line-height:var(\n--spectrum-body-s-text-line-height,var(--spectrum-alias-body-text-line-height)\n);margin-bottom:0;margin-top:0;text-transform:var(--spectrum-body-s-text-transform,none)}:host([dragged]) ::slotted(*){--spectrum-global-color-gray-500:var(\n--spectrum-dropzone-illustration-color\n)}\n`;\nexport default styles;"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
3
|
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
5
|
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
@@ -28,7 +28,7 @@ const styles = css `
|
|
|
28
28
|
)}:host(:focus){border-color:var(
|
|
29
29
|
--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)
|
|
30
30
|
)}:host(:focus) ::slotted(*){color:var(
|
|
31
|
-
--spectrum-global-color-static-gray-500
|
|
31
|
+
--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))
|
|
32
32
|
)}:host(:focus.focus-visible){border-color:var(
|
|
33
33
|
--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)
|
|
34
34
|
)}:host(:focus:focus-visible){border-color:var(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spectrum-dropzone.css.js","sourceRoot":"","sources":["spectrum-dropzone.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright
|
|
1
|
+
{"version":3,"file":"spectrum-dropzone.css.js","sourceRoot":"","sources":["spectrum-dropzone.css.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AACpD,MAAM,MAAM,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BjB,CAAC;AACF,eAAe,MAAM,CAAC","sourcesContent":["/*\nCopyright 2022 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { css } from '@spectrum-web-components/base';\nconst styles = css`\n:host{border-radius:var(\n--spectrum-dropzone-border-radius,var(--spectrum-alias-border-radius-regular)\n);border-style:dashed;border-width:var(\n--spectrum-dropzone-border-width,var(--spectrum-alias-border-size-thick)\n);padding:var(\n--spectrum-dropzone-padding,var(--spectrum-global-dimension-size-900)\n);text-align:center}:host([dragged]){border-style:solid}:host(:focus){border-style:dashed;outline:0}:host(:focus.focus-visible){border-style:solid}:host(:focus:focus-visible){border-style:solid}:host{border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host([dragged]){background-color:var(\n--spectrum-dropzone-background-color-selected-hover,var(--spectrum-alias-highlight-selected)\n);border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host([dragged]) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus){border-color:var(\n--spectrum-dropzone-border-color,var(--spectrum-global-color-gray-300)\n)}:host(:focus) ::slotted(*){color:var(\n--spectrum-global-color-static-gray-500,rgb(var(--spectrum-global-color-static-gray-500-rgb))\n)}:host(:focus.focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus:focus-visible){border-color:var(\n--spectrum-dropzone-border-color-selected-hover,var(--spectrum-global-color-blue-400)\n)}:host(:focus[dragged].focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}:host(:focus[dragged]:focus-visible) ::slotted(*){color:var(\n--spectrum-global-color-blue-400\n)}\n`;\nexport default styles;"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import { html } from '@spectrum-web-components/base';
|
|
13
|
+
import '../sp-dropzone.js';
|
|
14
|
+
import { illustration } from '../test/test-svg';
|
|
15
|
+
import '@spectrum-web-components/illustrated-message/sp-illustrated-message.js';
|
|
16
|
+
import '@spectrum-web-components/link/sp-link.js';
|
|
17
|
+
export default {
|
|
18
|
+
component: 'sp-dropzone',
|
|
19
|
+
title: 'Dropzone',
|
|
20
|
+
args: {
|
|
21
|
+
isDragged: false,
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
isDragged: {
|
|
25
|
+
name: 'isDragged',
|
|
26
|
+
type: { name: 'boolean', required: false },
|
|
27
|
+
table: {
|
|
28
|
+
type: { summary: 'boolean' },
|
|
29
|
+
defaultValue: { summary: false },
|
|
30
|
+
},
|
|
31
|
+
control: {
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export const Default = (args) => {
|
|
38
|
+
return html `
|
|
39
|
+
<sp-dropzone id="dropzone" tabindex="0" ?dragged=${args.isDragged}>
|
|
40
|
+
<sp-illustrated-message heading="Drag and Drop Your File" cta>
|
|
41
|
+
${illustration}
|
|
42
|
+
<div slot="description">
|
|
43
|
+
<label for="file-input">
|
|
44
|
+
<sp-link>Select a File</sp-link>
|
|
45
|
+
from your computer
|
|
46
|
+
</label>
|
|
47
|
+
<input type="file" id="file-input" style="display: none" />
|
|
48
|
+
</div>
|
|
49
|
+
<div slot="description">
|
|
50
|
+
or
|
|
51
|
+
<sp-link href="http://stock.adobe.com" target="blank">
|
|
52
|
+
Search Adobe Stock
|
|
53
|
+
</sp-link>
|
|
54
|
+
</div>
|
|
55
|
+
</sp-illustrated-message>
|
|
56
|
+
</sp-dropzone>
|
|
57
|
+
`;
|
|
58
|
+
};
|
|
59
|
+
export const Dragged = (args) => {
|
|
60
|
+
return html `
|
|
61
|
+
<sp-dropzone id="dropzone" tabindex="0" ?dragged=${args.isDragged}>
|
|
62
|
+
<sp-illustrated-message heading="Drag and Drop Your File" cta>
|
|
63
|
+
${illustration}
|
|
64
|
+
<div slot="description">
|
|
65
|
+
<label for="file-input">
|
|
66
|
+
<sp-link>Select a File</sp-link>
|
|
67
|
+
from your computer
|
|
68
|
+
</label>
|
|
69
|
+
<input type="file" id="file-input" style="display: none" />
|
|
70
|
+
</div>
|
|
71
|
+
<div slot="description">
|
|
72
|
+
or
|
|
73
|
+
<sp-link href="http://stock.adobe.com" target="blank">
|
|
74
|
+
Search Adobe Stock
|
|
75
|
+
</sp-link>
|
|
76
|
+
</div>
|
|
77
|
+
</sp-illustrated-message>
|
|
78
|
+
</sp-dropzone>
|
|
79
|
+
`;
|
|
80
|
+
};
|
|
81
|
+
Dragged.args = {
|
|
82
|
+
isDragged: true,
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=dropzone.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropzone.stories.js","sourceRoot":"","sources":["dropzone.stories.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,EAAE,IAAI,EAAkB,MAAM,+BAA+B,CAAC;AAErE,OAAO,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,wEAAwE,CAAC;AAChF,OAAO,0CAA0C,CAAC;AAElD,eAAe;IACX,SAAS,EAAE,aAAa;IACxB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE;QACF,SAAS,EAAE,KAAK;KACnB;IACD,QAAQ,EAAE;QACN,SAAS,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE;YAC1C,KAAK,EAAE;gBACH,IAAI,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;gBAC5B,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE;aACnC;YACD,OAAO,EAAE;gBACL,IAAI,EAAE,SAAS;aAClB;SACJ;KACJ;CACJ,CAAC;AAMF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAe,EAAkB,EAAE;IACvD,OAAO,IAAI,CAAA;2DAC4C,IAAI,CAAC,SAAS;;kBAEvD,YAAY;;;;;;;;;;;;;;;;KAgBzB,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAe,EAAkB,EAAE;IACvD,OAAO,IAAI,CAAA;2DAC4C,IAAI,CAAC,SAAS;;kBAEvD,YAAY;;;;;;;;;;;;;;;;KAgBzB,CAAC;AACN,CAAC,CAAC;AACF,OAAO,CAAC,IAAI,GAAG;IACX,SAAS,EAAE,IAAI;CAClB,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { html, TemplateResult } from '@spectrum-web-components/base';\n\nimport '../sp-dropzone.js';\nimport { illustration } from '../test/test-svg';\nimport '@spectrum-web-components/illustrated-message/sp-illustrated-message.js';\nimport '@spectrum-web-components/link/sp-link.js';\n\nexport default {\n component: 'sp-dropzone',\n title: 'Dropzone',\n args: {\n isDragged: false,\n },\n argTypes: {\n isDragged: {\n name: 'isDragged',\n type: { name: 'boolean', required: false },\n table: {\n type: { summary: 'boolean' },\n defaultValue: { summary: false },\n },\n control: {\n type: 'boolean',\n },\n },\n },\n};\n\ntype StoryArgs = {\n isDragged?: boolean;\n};\n\nexport const Default = (args: StoryArgs): TemplateResult => {\n return html`\n <sp-dropzone id=\"dropzone\" tabindex=\"0\" ?dragged=${args.isDragged}>\n <sp-illustrated-message heading=\"Drag and Drop Your File\" cta>\n ${illustration}\n <div slot=\"description\">\n <label for=\"file-input\">\n <sp-link>Select a File</sp-link>\n from your computer\n </label>\n <input type=\"file\" id=\"file-input\" style=\"display: none\" />\n </div>\n <div slot=\"description\">\n or\n <sp-link href=\"http://stock.adobe.com\" target=\"blank\">\n Search Adobe Stock\n </sp-link>\n </div>\n </sp-illustrated-message>\n </sp-dropzone>\n `;\n};\n\nexport const Dragged = (args: StoryArgs): TemplateResult => {\n return html`\n <sp-dropzone id=\"dropzone\" tabindex=\"0\" ?dragged=${args.isDragged}>\n <sp-illustrated-message heading=\"Drag and Drop Your File\" cta>\n ${illustration}\n <div slot=\"description\">\n <label for=\"file-input\">\n <sp-link>Select a File</sp-link>\n from your computer\n </label>\n <input type=\"file\" id=\"file-input\" style=\"display: none\" />\n </div>\n <div slot=\"description\">\n or\n <sp-link href=\"http://stock.adobe.com\" target=\"blank\">\n Search Adobe Stock\n </sp-link>\n </div>\n </sp-illustrated-message>\n </sp-dropzone>\n `;\n};\nDragged.args = {\n isDragged: true,\n};\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import '@spectrum-web-components/dropzone/sp-dropzone.js';
|
|
13
|
+
import { html } from 'lit';
|
|
14
|
+
import { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';
|
|
15
|
+
measureFixtureCreation(html `
|
|
16
|
+
<sp-dropzone id="dropzone">
|
|
17
|
+
<sp-illustrated-message heading="Drag and Drop Your File">
|
|
18
|
+
<svg>
|
|
19
|
+
<use xlink:href="geometry.svg#upload_geometry" />
|
|
20
|
+
</svg>
|
|
21
|
+
</sp-illustrated-message>
|
|
22
|
+
|
|
23
|
+
<div style="color: grey">
|
|
24
|
+
<div>
|
|
25
|
+
<label for="file-input">
|
|
26
|
+
<sp-link>Select a File</sp-link>
|
|
27
|
+
from your computer
|
|
28
|
+
</label>
|
|
29
|
+
<input type="file" id="file-input" style="display: none" />
|
|
30
|
+
</div>
|
|
31
|
+
<div>
|
|
32
|
+
or
|
|
33
|
+
<sp-link href="http://stock.adobe.com" target="blank">
|
|
34
|
+
Search Adobe Stock
|
|
35
|
+
</sp-link>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</sp-dropzone>
|
|
39
|
+
`);
|
|
40
|
+
//# sourceMappingURL=test-basic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-basic.js","sourceRoot":"","sources":["test-basic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,kDAAkD,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,sBAAsB,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;CAwB1B,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport '@spectrum-web-components/dropzone/sp-dropzone.js';\nimport { html } from 'lit';\nimport { measureFixtureCreation } from '../../../../test/benchmark/helpers.js';\n\nmeasureFixtureCreation(html`\n <sp-dropzone id=\"dropzone\">\n <sp-illustrated-message heading=\"Drag and Drop Your File\">\n <svg>\n <use xlink:href=\"geometry.svg#upload_geometry\" />\n </svg>\n </sp-illustrated-message>\n\n <div style=\"color: grey\">\n <div>\n <label for=\"file-input\">\n <sp-link>Select a File</sp-link>\n from your computer\n </label>\n <input type=\"file\" id=\"file-input\" style=\"display: none\" />\n </div>\n <div>\n or\n <sp-link href=\"http://stock.adobe.com\" target=\"blank\">\n Search Adobe Stock\n </sp-link>\n </div>\n </div>\n </sp-dropzone>\n`);\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import * as stories from '../stories/dropzone.stories.js';
|
|
13
|
+
import { regressVisuals } from '../../../test/visual/test.js';
|
|
14
|
+
regressVisuals('DropzoneStories', stories);
|
|
15
|
+
//# sourceMappingURL=dropzone.test-vrt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropzone.test-vrt.js","sourceRoot":"","sources":["dropzone.test-vrt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,KAAK,OAAO,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,cAAc,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport * as stories from '../stories/dropzone.stories.js';\nimport { regressVisuals } from '../../../test/visual/test.js';\n\nregressVisuals('DropzoneStories', stories);\n"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
import '../sp-dropzone.js';
|
|
13
|
+
import { illustration } from './test-svg.js';
|
|
14
|
+
import { waitForPredicate } from '../../../test/testing-helpers.js';
|
|
15
|
+
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
|
16
|
+
describe('Dropzone', () => {
|
|
17
|
+
it('loads', async () => {
|
|
18
|
+
const el = await fixture(html `
|
|
19
|
+
<sp-dropzone id="dropzone">
|
|
20
|
+
<sp-illustrated-message heading="Drag and Drop Your File">
|
|
21
|
+
${illustration}
|
|
22
|
+
</sp-illustrated-message>
|
|
23
|
+
|
|
24
|
+
<div style="color: grey">
|
|
25
|
+
<div>
|
|
26
|
+
<label for="file-input">
|
|
27
|
+
<sp-link>Select a File</sp-link>
|
|
28
|
+
from your computer
|
|
29
|
+
</label>
|
|
30
|
+
<input
|
|
31
|
+
type="file"
|
|
32
|
+
id="file-input"
|
|
33
|
+
style="display: none"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
<div>
|
|
37
|
+
or
|
|
38
|
+
<sp-link
|
|
39
|
+
href="http://stock.adobe.com"
|
|
40
|
+
target="blank"
|
|
41
|
+
>
|
|
42
|
+
Search Adobe Stock
|
|
43
|
+
</sp-link>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
</sp-dropzone>
|
|
47
|
+
`);
|
|
48
|
+
expect(el).to.not.equal(undefined);
|
|
49
|
+
if (!el.shadowRoot)
|
|
50
|
+
throw new Error('No shadowRoot');
|
|
51
|
+
const slot = el.shadowRoot.querySelector('slot');
|
|
52
|
+
expect(slot).to.not.equal(undefined);
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
it('manages `dropEffects`', async () => {
|
|
56
|
+
const el = await fixture(html `
|
|
57
|
+
<sp-dropzone id="dropzone"></sp-dropzone>
|
|
58
|
+
`);
|
|
59
|
+
await elementUpdated(el);
|
|
60
|
+
expect(el.dropEffect).to.equal('copy');
|
|
61
|
+
el.dropEffect = 'move';
|
|
62
|
+
await elementUpdated(el);
|
|
63
|
+
expect(el.dropEffect).to.equal('move');
|
|
64
|
+
});
|
|
65
|
+
it('manages `dragover` events', async () => {
|
|
66
|
+
const el = await fixture(html `
|
|
67
|
+
<sp-dropzone id="dropzone"></sp-dropzone>
|
|
68
|
+
`);
|
|
69
|
+
await elementUpdated(el);
|
|
70
|
+
expect(el.isDragged).to.be.false;
|
|
71
|
+
el.dispatchEvent(new DragEvent('dragover'));
|
|
72
|
+
expect(el.isDragged).to.be.false;
|
|
73
|
+
let dataTransfer = false;
|
|
74
|
+
try {
|
|
75
|
+
// Safari doesn't like this...
|
|
76
|
+
dataTransfer = new DataTransfer();
|
|
77
|
+
}
|
|
78
|
+
catch (error) { }
|
|
79
|
+
if (dataTransfer) {
|
|
80
|
+
const dragOverEvent = new DragEvent('dragover', {
|
|
81
|
+
dataTransfer,
|
|
82
|
+
});
|
|
83
|
+
el.dispatchEvent(dragOverEvent);
|
|
84
|
+
expect(el.isDragged).to.be.true;
|
|
85
|
+
// We should be able to make the following test here:
|
|
86
|
+
// expect(dataTransfer.dropEffect).to.equal(el.dropEffect);
|
|
87
|
+
// However, Chrome doesn't like it in the context of a test...
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
it('allows `dragover` events to be canceled', async () => {
|
|
91
|
+
const canceledDrag = (event) => {
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
};
|
|
94
|
+
const el = await fixture(html `
|
|
95
|
+
<sp-dropzone
|
|
96
|
+
id="dropzone"
|
|
97
|
+
@sp-dropzone-should-accept=${canceledDrag}
|
|
98
|
+
></sp-dropzone>
|
|
99
|
+
`);
|
|
100
|
+
await elementUpdated(el);
|
|
101
|
+
expect(el.isDragged).to.be.false;
|
|
102
|
+
let dataTransfer = false;
|
|
103
|
+
try {
|
|
104
|
+
// Safari doesn't like this...
|
|
105
|
+
dataTransfer = new DataTransfer();
|
|
106
|
+
}
|
|
107
|
+
catch (error) { }
|
|
108
|
+
if (dataTransfer) {
|
|
109
|
+
const dragOverEvent = new DragEvent('dragover', {
|
|
110
|
+
dataTransfer,
|
|
111
|
+
});
|
|
112
|
+
el.dispatchEvent(dragOverEvent);
|
|
113
|
+
expect(el.isDragged).to.be.false;
|
|
114
|
+
expect(dataTransfer.dropEffect).to.not.equal(el.dropEffect);
|
|
115
|
+
expect(dataTransfer.dropEffect).to.equal('none');
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
it('manages `dragleave` events via debounce', async () => {
|
|
119
|
+
let dragLeftCount = 0;
|
|
120
|
+
const onDragLeave = () => {
|
|
121
|
+
dragLeftCount += 1;
|
|
122
|
+
};
|
|
123
|
+
const el = await fixture(html `
|
|
124
|
+
<sp-dropzone
|
|
125
|
+
id="dropzone"
|
|
126
|
+
@sp-dropzone-dragleave=${onDragLeave}
|
|
127
|
+
></sp-dropzone>
|
|
128
|
+
`);
|
|
129
|
+
await elementUpdated(el);
|
|
130
|
+
expect(dragLeftCount).to.equal(0);
|
|
131
|
+
el.dispatchEvent(new DragEvent('dragleave'));
|
|
132
|
+
el.dispatchEvent(new DragEvent('dragleave'));
|
|
133
|
+
await waitForPredicate(() => dragLeftCount === 1);
|
|
134
|
+
expect(dragLeftCount).to.equal(1);
|
|
135
|
+
});
|
|
136
|
+
it('manages `dragleave` events', async () => {
|
|
137
|
+
let dropped = false;
|
|
138
|
+
const onDrop = () => {
|
|
139
|
+
dropped = true;
|
|
140
|
+
};
|
|
141
|
+
const el = await fixture(html `
|
|
142
|
+
<sp-dropzone
|
|
143
|
+
id="dropzone"
|
|
144
|
+
@sp-dropzone-drop=${onDrop}
|
|
145
|
+
></sp-dropzone>
|
|
146
|
+
`);
|
|
147
|
+
await elementUpdated(el);
|
|
148
|
+
expect(dropped).to.be.false;
|
|
149
|
+
el.dispatchEvent(new DragEvent('drop'));
|
|
150
|
+
expect(dropped).to.be.true;
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
//# sourceMappingURL=dropzone.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dropzone.test.js","sourceRoot":"","sources":["dropzone.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AACF,OAAO,mBAAmB,CAAC;AAE3B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzE,QAAQ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AK,CAAC;QACpB,MAAM,MAAM,GAAG,GAAS,EAAE;YACtB,OAAO,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;QACF,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;;wCAGwB,MAAM;;aAEjC,CACJ,CAAC;QAEF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAE5B,EAAE,CAAC,aAAa,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAExC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC/B,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport '../sp-dropzone.js';\nimport { Dropzone } from '../';\nimport { illustration } from './test-svg.js';\nimport { waitForPredicate } from '../../../test/testing-helpers.js';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\ndescribe('Dropzone', () => {\n it('loads', async () => {\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone id=\"dropzone\">\n <sp-illustrated-message heading=\"Drag and Drop Your File\">\n ${illustration}\n </sp-illustrated-message>\n\n <div style=\"color: grey\">\n <div>\n <label for=\"file-input\">\n <sp-link>Select a File</sp-link>\n from your computer\n </label>\n <input\n type=\"file\"\n id=\"file-input\"\n style=\"display: none\"\n />\n </div>\n <div>\n or\n <sp-link\n href=\"http://stock.adobe.com\"\n target=\"blank\"\n >\n Search Adobe Stock\n </sp-link>\n </div>\n </div>\n </sp-dropzone>\n `\n );\n expect(el).to.not.equal(undefined);\n if (!el.shadowRoot) throw new Error('No shadowRoot');\n const slot = el.shadowRoot.querySelector('slot') as HTMLSlotElement;\n expect(slot).to.not.equal(undefined);\n return true;\n });\n it('manages `dropEffects`', async () => {\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone id=\"dropzone\"></sp-dropzone>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.dropEffect).to.equal('copy');\n\n el.dropEffect = 'move';\n\n await elementUpdated(el);\n\n expect(el.dropEffect).to.equal('move');\n });\n it('manages `dragover` events', async () => {\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone id=\"dropzone\"></sp-dropzone>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.isDragged).to.be.false;\n\n el.dispatchEvent(new DragEvent('dragover'));\n\n expect(el.isDragged).to.be.false;\n\n let dataTransfer: DataTransfer | boolean = false;\n try {\n // Safari doesn't like this...\n dataTransfer = new DataTransfer();\n } catch (error) {}\n if (dataTransfer) {\n const dragOverEvent = new DragEvent('dragover', {\n dataTransfer,\n });\n\n el.dispatchEvent(dragOverEvent);\n\n expect(el.isDragged).to.be.true;\n // We should be able to make the following test here:\n // expect(dataTransfer.dropEffect).to.equal(el.dropEffect);\n // However, Chrome doesn't like it in the context of a test...\n }\n });\n it('allows `dragover` events to be canceled', async () => {\n const canceledDrag = (event: DragEvent): void => {\n event.preventDefault();\n };\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone\n id=\"dropzone\"\n @sp-dropzone-should-accept=${canceledDrag}\n ></sp-dropzone>\n `\n );\n\n await elementUpdated(el);\n\n expect(el.isDragged).to.be.false;\n\n let dataTransfer: DataTransfer | boolean = false;\n try {\n // Safari doesn't like this...\n dataTransfer = new DataTransfer();\n } catch (error) {}\n if (dataTransfer) {\n const dragOverEvent = new DragEvent('dragover', {\n dataTransfer,\n });\n\n el.dispatchEvent(dragOverEvent);\n\n expect(el.isDragged).to.be.false;\n expect(dataTransfer.dropEffect).to.not.equal(el.dropEffect);\n expect(dataTransfer.dropEffect).to.equal('none');\n }\n });\n it('manages `dragleave` events via debounce', async () => {\n let dragLeftCount = 0;\n const onDragLeave = (): void => {\n dragLeftCount += 1;\n };\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone\n id=\"dropzone\"\n @sp-dropzone-dragleave=${onDragLeave}\n ></sp-dropzone>\n `\n );\n\n await elementUpdated(el);\n\n expect(dragLeftCount).to.equal(0);\n\n el.dispatchEvent(new DragEvent('dragleave'));\n el.dispatchEvent(new DragEvent('dragleave'));\n\n await waitForPredicate(() => dragLeftCount === 1);\n\n expect(dragLeftCount).to.equal(1);\n });\n\n it('manages `dragleave` events', async () => {\n let dropped = false;\n const onDrop = (): void => {\n dropped = true;\n };\n const el = await fixture<Dropzone>(\n html`\n <sp-dropzone\n id=\"dropzone\"\n @sp-dropzone-drop=${onDrop}\n ></sp-dropzone>\n `\n );\n\n await elementUpdated(el);\n\n expect(dropped).to.be.false;\n\n el.dispatchEvent(new DragEvent('drop'));\n\n expect(dropped).to.be.true;\n });\n});\n"]}
|