@vonage/vivid 3.51.0 → 3.53.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.
Files changed (340) hide show
  1. package/README.md +1 -1
  2. package/accordion/index.cjs +1 -1
  3. package/accordion/index.js +1 -1
  4. package/accordion-item/index.cjs +1 -1
  5. package/accordion-item/index.js +1 -1
  6. package/alert/index.cjs +3 -3
  7. package/alert/index.js +3 -3
  8. package/appearance-ui/index.cjs +19 -11
  9. package/appearance-ui/index.js +19 -11
  10. package/audio-player/index.cjs +4 -3
  11. package/audio-player/index.js +4 -3
  12. package/avatar/index.cjs +1 -1
  13. package/avatar/index.js +1 -1
  14. package/badge/index.cjs +1 -1
  15. package/badge/index.js +1 -1
  16. package/banner/index.cjs +2 -2
  17. package/banner/index.js +2 -2
  18. package/breadcrumb-item/index.cjs +1 -1
  19. package/breadcrumb-item/index.js +1 -1
  20. package/button/index.cjs +2 -2
  21. package/button/index.js +2 -2
  22. package/card/index.cjs +2 -2
  23. package/card/index.js +2 -2
  24. package/checkbox/index.cjs +3 -2
  25. package/checkbox/index.js +3 -2
  26. package/combobox/index.cjs +5 -8
  27. package/combobox/index.js +5 -8
  28. package/custom-elements.json +2310 -769
  29. package/data-grid/index.cjs +1 -1
  30. package/data-grid/index.js +1 -1
  31. package/date-picker/index.cjs +7 -9
  32. package/date-picker/index.js +7 -9
  33. package/date-range-picker/index.cjs +7 -9
  34. package/date-range-picker/index.js +7 -9
  35. package/dial-pad/index.cjs +33 -0
  36. package/dial-pad/index.js +31 -0
  37. package/dialog/index.cjs +4 -4
  38. package/dialog/index.js +4 -4
  39. package/divider/index.cjs +1 -1
  40. package/divider/index.js +1 -1
  41. package/elevation/index.cjs +1 -1
  42. package/elevation/index.js +1 -1
  43. package/empty-state/index.cjs +2 -2
  44. package/empty-state/index.js +2 -2
  45. package/fab/index.cjs +2 -2
  46. package/fab/index.js +2 -2
  47. package/file-picker/index.cjs +4 -5
  48. package/file-picker/index.js +4 -5
  49. package/header/index.cjs +2 -2
  50. package/header/index.js +2 -2
  51. package/icon/index.cjs +1 -1
  52. package/icon/index.js +1 -1
  53. package/index.cjs +135 -123
  54. package/index.js +48 -46
  55. package/layout/index.cjs +1 -1
  56. package/layout/index.js +1 -1
  57. package/lib/avatar/definition.d.ts +1 -1
  58. package/lib/button/button.d.ts +1 -0
  59. package/lib/button/definition.d.ts +1 -1
  60. package/lib/calendar-event/definition.d.ts +1 -1
  61. package/lib/components.d.ts +3 -0
  62. package/lib/dial-pad/definition.d.ts +3 -0
  63. package/lib/dial-pad/dial-pad.d.ts +14 -0
  64. package/lib/dial-pad/dial-pad.template.d.ts +4 -0
  65. package/lib/dial-pad/locale.d.ts +18 -0
  66. package/lib/enums.d.ts +6 -0
  67. package/lib/layout/definition.d.ts +1 -1
  68. package/lib/menu-item/menu-item.d.ts +3 -0
  69. package/lib/range-slider/definition.d.ts +3 -0
  70. package/lib/range-slider/locale.d.ts +4 -0
  71. package/lib/range-slider/range-slider.d.ts +32 -0
  72. package/lib/range-slider/range-slider.form-associated.d.ts +10 -0
  73. package/lib/range-slider/range-slider.template.d.ts +4 -0
  74. package/lib/range-slider/utils/lerp.d.ts +2 -0
  75. package/lib/range-slider/utils/roundToStepValue.d.ts +1 -0
  76. package/lib/slider/slider.template.d.ts +1 -0
  77. package/lib/split-button/definition.d.ts +1 -1
  78. package/lib/text-anchor/definition.d.ts +1 -0
  79. package/lib/text-anchor/text-anchor.d.ts +5 -0
  80. package/lib/video-player/definition.d.ts +3 -0
  81. package/lib/video-player/locale.d.ts +1 -0
  82. package/lib/video-player/video-player.d.ts +17 -0
  83. package/lib/video-player/video-player.template.d.ts +4 -0
  84. package/listbox/index.cjs +25 -24
  85. package/listbox/index.js +25 -24
  86. package/locales/en-GB.cjs +34 -0
  87. package/locales/en-GB.js +34 -0
  88. package/locales/en-US.cjs +202 -0
  89. package/locales/en-US.js +202 -0
  90. package/locales/ja-JP.cjs +202 -1
  91. package/locales/ja-JP.js +202 -1
  92. package/locales/zh-CN.cjs +203 -0
  93. package/locales/zh-CN.js +203 -0
  94. package/menu/index.cjs +7 -7
  95. package/menu/index.js +7 -7
  96. package/menu-item/index.cjs +4 -4
  97. package/menu-item/index.js +4 -4
  98. package/nav/index.cjs +1 -1
  99. package/nav/index.js +1 -1
  100. package/nav-disclosure/index.cjs +2 -2
  101. package/nav-disclosure/index.js +2 -2
  102. package/nav-item/index.cjs +2 -2
  103. package/nav-item/index.js +2 -2
  104. package/note/index.cjs +2 -2
  105. package/note/index.js +2 -2
  106. package/number-field/index.cjs +5 -6
  107. package/number-field/index.js +5 -6
  108. package/option/index.cjs +2 -2
  109. package/option/index.js +2 -2
  110. package/package.json +34 -34
  111. package/pagination/index.cjs +3 -3
  112. package/pagination/index.js +3 -3
  113. package/popup/index.cjs +4 -4
  114. package/popup/index.js +4 -4
  115. package/progress/index.cjs +1 -1
  116. package/progress/index.js +1 -1
  117. package/progress-ring/index.cjs +1 -1
  118. package/progress-ring/index.js +1 -1
  119. package/radio/index.cjs +1 -1
  120. package/radio/index.js +1 -1
  121. package/radio-group/index.cjs +1 -1
  122. package/radio-group/index.js +1 -1
  123. package/range-slider/index.cjs +22 -0
  124. package/range-slider/index.js +20 -0
  125. package/select/index.cjs +7 -6
  126. package/select/index.js +7 -6
  127. package/selectable-box/index.cjs +5 -4
  128. package/selectable-box/index.js +5 -4
  129. package/shared/Reflector.cjs +5 -1
  130. package/shared/Reflector.js +5 -1
  131. package/shared/affix.cjs +11 -4
  132. package/shared/affix.js +12 -4
  133. package/shared/anchored.cjs +8 -2
  134. package/shared/anchored.js +8 -2
  135. package/shared/applyMixinsWithObservables.cjs +15 -0
  136. package/shared/applyMixinsWithObservables.js +13 -0
  137. package/shared/definition.cjs +9 -4
  138. package/shared/definition.js +9 -4
  139. package/shared/definition10.cjs +5 -5
  140. package/shared/definition10.js +5 -5
  141. package/shared/definition11.cjs +77 -49
  142. package/shared/definition11.js +78 -50
  143. package/shared/definition12.cjs +12 -14
  144. package/shared/definition12.js +12 -14
  145. package/shared/definition13.cjs +118 -75
  146. package/shared/definition13.js +118 -75
  147. package/shared/definition14.cjs +34 -33
  148. package/shared/definition14.js +34 -33
  149. package/shared/definition15.cjs +24 -12
  150. package/shared/definition15.js +24 -12
  151. package/shared/definition16.cjs +38 -43
  152. package/shared/definition16.js +38 -43
  153. package/shared/definition17.cjs +126 -66
  154. package/shared/definition17.js +127 -67
  155. package/shared/definition18.cjs +31 -15
  156. package/shared/definition18.js +31 -15
  157. package/shared/definition19.cjs +117 -81
  158. package/shared/definition19.js +117 -81
  159. package/shared/definition2.cjs +10 -5
  160. package/shared/definition2.js +10 -5
  161. package/shared/definition20.cjs +187 -227
  162. package/shared/definition20.js +183 -223
  163. package/shared/definition21.cjs +262 -69
  164. package/shared/definition21.js +261 -67
  165. package/shared/definition22.cjs +66 -61
  166. package/shared/definition22.js +64 -60
  167. package/shared/definition23.cjs +42 -77
  168. package/shared/definition23.js +41 -76
  169. package/shared/definition24.cjs +65 -2350
  170. package/shared/definition24.js +64 -2349
  171. package/shared/definition25.cjs +2402 -48
  172. package/shared/definition25.js +2401 -47
  173. package/shared/definition26.cjs +62 -28
  174. package/shared/definition26.js +61 -27
  175. package/shared/definition27.cjs +28 -54
  176. package/shared/definition27.js +27 -53
  177. package/shared/definition28.cjs +39 -819
  178. package/shared/definition28.js +38 -817
  179. package/shared/definition29.cjs +893 -54
  180. package/shared/definition29.js +893 -55
  181. package/shared/definition3.cjs +7 -10
  182. package/shared/definition3.js +7 -10
  183. package/shared/definition30.cjs +69 -85
  184. package/shared/definition30.js +68 -84
  185. package/shared/definition31.cjs +86 -23
  186. package/shared/definition31.js +86 -23
  187. package/shared/definition32.cjs +24 -14
  188. package/shared/definition32.js +23 -13
  189. package/shared/definition33.cjs +11 -53
  190. package/shared/definition33.js +10 -52
  191. package/shared/definition34.cjs +28 -500
  192. package/shared/definition34.js +28 -500
  193. package/shared/definition35.cjs +447 -194
  194. package/shared/definition35.js +447 -192
  195. package/shared/definition36.cjs +258 -188
  196. package/shared/definition36.js +255 -187
  197. package/shared/definition37.cjs +204 -78
  198. package/shared/definition37.js +203 -76
  199. package/shared/definition38.cjs +55 -51
  200. package/shared/definition38.js +52 -49
  201. package/shared/definition39.cjs +65 -423
  202. package/shared/definition39.js +64 -422
  203. package/shared/definition4.cjs +24 -12
  204. package/shared/definition4.js +24 -12
  205. package/shared/definition40.cjs +447 -35
  206. package/shared/definition40.js +444 -32
  207. package/shared/definition41.cjs +35 -678
  208. package/shared/definition41.js +34 -677
  209. package/shared/definition42.cjs +544 -99
  210. package/shared/definition42.js +543 -98
  211. package/shared/definition43.cjs +696 -77
  212. package/shared/definition43.js +695 -76
  213. package/shared/definition44.cjs +113 -563
  214. package/shared/definition44.js +112 -561
  215. package/shared/definition45.cjs +77 -117
  216. package/shared/definition45.js +75 -115
  217. package/shared/definition46.cjs +474 -86
  218. package/shared/definition46.js +474 -87
  219. package/shared/definition47.cjs +140 -23
  220. package/shared/definition47.js +139 -22
  221. package/shared/definition48.cjs +132 -57
  222. package/shared/definition48.js +131 -56
  223. package/shared/definition49.cjs +18 -524
  224. package/shared/definition49.js +17 -523
  225. package/shared/definition5.cjs +20 -17
  226. package/shared/definition5.js +20 -17
  227. package/shared/definition50.cjs +73 -25
  228. package/shared/definition50.js +72 -24
  229. package/shared/definition51.cjs +506 -99
  230. package/shared/definition51.js +505 -99
  231. package/shared/definition52.cjs +29 -277
  232. package/shared/definition52.js +28 -276
  233. package/shared/definition53.cjs +97 -256
  234. package/shared/definition53.js +97 -255
  235. package/shared/definition54.cjs +287 -769
  236. package/shared/definition54.js +287 -769
  237. package/shared/definition55.cjs +305 -105
  238. package/shared/definition55.js +304 -104
  239. package/shared/definition56.cjs +841 -81
  240. package/shared/definition56.js +840 -80
  241. package/shared/definition57.cjs +153 -69
  242. package/shared/definition57.js +152 -68
  243. package/shared/definition58.cjs +138 -299
  244. package/shared/definition58.js +137 -298
  245. package/shared/definition59.cjs +72 -27
  246. package/shared/definition59.js +71 -26
  247. package/shared/definition6.cjs +4 -5
  248. package/shared/definition6.js +4 -5
  249. package/shared/definition60.cjs +279 -1780
  250. package/shared/definition60.js +278 -1779
  251. package/shared/definition61.cjs +65870 -11
  252. package/shared/definition61.js +65869 -11
  253. package/shared/definition62.cjs +50 -0
  254. package/shared/definition62.js +46 -0
  255. package/shared/definition63.cjs +1828 -0
  256. package/shared/definition63.js +1824 -0
  257. package/shared/definition7.cjs +8 -6
  258. package/shared/definition7.js +8 -6
  259. package/shared/definition8.cjs +27 -20
  260. package/shared/definition8.js +27 -20
  261. package/shared/definition9.cjs +7 -10
  262. package/shared/definition9.js +7 -10
  263. package/shared/enums.cjs +8 -0
  264. package/shared/enums.js +8 -1
  265. package/shared/icon.cjs +7 -2
  266. package/shared/icon.js +7 -2
  267. package/shared/index2.cjs +67 -38
  268. package/shared/index2.js +67 -38
  269. package/shared/key-codes2.cjs +8 -0
  270. package/shared/key-codes2.js +5 -1
  271. package/shared/listbox.cjs +1 -1
  272. package/shared/listbox.js +1 -1
  273. package/shared/localization/Locale.d.ts +6 -0
  274. package/shared/patterns/form-elements/form-elements.d.ts +2 -3
  275. package/shared/patterns/index.d.ts +0 -1
  276. package/shared/presentationDate.cjs +140 -81
  277. package/shared/presentationDate.js +140 -81
  278. package/shared/slider.template.cjs +71 -0
  279. package/shared/slider.template.js +67 -0
  280. package/shared/text-anchor.cjs +6 -0
  281. package/shared/text-anchor.js +6 -0
  282. package/shared/text-anchor.template.cjs +33 -33
  283. package/shared/text-anchor.template.js +33 -33
  284. package/shared/text-field.cjs +1 -1
  285. package/shared/text-field.js +1 -1
  286. package/shared/utils/applyMixinsWithObservables.d.ts +1 -0
  287. package/side-drawer/index.cjs +1 -1
  288. package/side-drawer/index.js +1 -1
  289. package/slider/index.cjs +2 -1
  290. package/slider/index.js +2 -1
  291. package/split-button/index.cjs +2 -2
  292. package/split-button/index.js +2 -2
  293. package/style.css +1 -0
  294. package/styles/core/all.css +1 -1
  295. package/styles/core/theme.css +1 -1
  296. package/styles/core/typography.css +1 -1
  297. package/styles/fonts/spezia-variable.css +39 -13
  298. package/styles/tokens/theme-dark.css +4 -4
  299. package/styles/tokens/theme-light.css +4 -4
  300. package/styles/tokens/vivid-2-compat.css +4 -2
  301. package/switch/index.cjs +2 -2
  302. package/switch/index.js +2 -2
  303. package/tab/index.cjs +2 -2
  304. package/tab/index.js +2 -2
  305. package/tab-panel/index.cjs +1 -1
  306. package/tab-panel/index.js +1 -1
  307. package/tabs/index.cjs +4 -4
  308. package/tabs/index.js +4 -4
  309. package/tag/index.cjs +2 -2
  310. package/tag/index.js +2 -2
  311. package/tag-group/index.cjs +1 -1
  312. package/tag-group/index.js +1 -1
  313. package/text-area/index.cjs +4 -3
  314. package/text-area/index.js +4 -3
  315. package/text-field/index.cjs +4 -6
  316. package/text-field/index.js +4 -6
  317. package/time-picker/index.cjs +8 -10
  318. package/time-picker/index.js +8 -10
  319. package/toggletip/index.cjs +5 -5
  320. package/toggletip/index.js +5 -5
  321. package/tooltip/index.cjs +5 -5
  322. package/tooltip/index.js +5 -5
  323. package/tree-item/index.cjs +2 -2
  324. package/tree-item/index.js +2 -2
  325. package/tree-view/index.cjs +1 -1
  326. package/tree-view/index.js +1 -1
  327. package/video-player/index.cjs +17 -0
  328. package/video-player/index.js +15 -0
  329. package/vivid.api.json +428 -1
  330. package/focus/index.cjs +0 -7
  331. package/focus/index.js +0 -5
  332. package/lib/focus/definition.d.ts +0 -3
  333. package/lib/focus/focus.d.ts +0 -3
  334. package/lib/focus/focus.template.d.ts +0 -4
  335. package/lib/popup/popup.d.ts +0 -21
  336. package/shared/focus.cjs +0 -8
  337. package/shared/focus.js +0 -6
  338. package/shared/focus2.cjs +0 -11
  339. package/shared/focus2.js +0 -9
  340. package/shared/patterns/focus.d.ts +0 -3
@@ -1,2155 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  const index = require('./index.cjs');
4
- const definition$1 = require('./definition26.cjs');
5
- const definition$2 = require('./definition61.cjs');
6
- const definition = require('./definition11.cjs');
7
- const enums = require('./enums.cjs');
8
- require('./affix.cjs');
9
- const index$1 = require('./index2.cjs');
10
- const localized = require('./localized.cjs');
11
- const formAssociated = require('./form-associated.cjs');
4
+ const definition = require('./definition27.cjs');
5
+ const affix = require('./affix.cjs');
12
6
  const applyMixins = require('./apply-mixins.cjs');
13
- const when = require('./when.cjs');
7
+ const button = require('./button.cjs');
14
8
  const ref = require('./ref.cjs');
15
9
  const classNames = require('./class-names.cjs');
16
10
 
17
- const styles = ":host{display:block;max-inline-size:400px}.base{display:flex;flex-direction:column}.control{display:flex;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:center;padding:16px;border:1px dashed var(--vvd-color-neutral-400);background-color:var(--vvd-color-cta-50);border-radius:8px;color:var(--vvd-color-neutral-600);cursor:pointer;font:var(--vvd-typography-base);gap:8px;inline-size:100%;min-block-size:52px;outline:none}.control:not(.size-expanded){min-block-size:52px}.control.size-expanded{min-block-size:120px}.control:focus-visible{--focus-stroke-gap-color: transparent;--focus-inset: 1px;box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}.main{pointer-events:none}.dz-preview{display:grid;box-sizing:border-box;padding:6px 12px;border-radius:8px;grid-template-columns:1fr auto;grid-template-rows:auto auto;inline-size:100%}.dz-preview .dz-details{display:flex;min-width:0;flex-direction:column;max-inline-size:100%}.dz-preview .dz-details .dz-filename{overflow:hidden;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);text-overflow:ellipsis;white-space:nowrap}.dz-preview .dz-details .dz-size{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.dz-preview .dz-error-message{color:var(--vvd-color-alert-500);font:var(--vvd-typography-base-condensed);margin-block-start:4px}.dz-preview:not(.dz-error) .dz-error-message{display:none}.dz-preview.dz-error{border:1px solid var(--vvd-color-alert-500)}.dz-preview.dz-error .dz-details .dz-size,.dz-preview.dz-error .dz-progress{display:none}.dz-preview .remove-btn{display:inline;align-self:center;grid-column:2/-1;grid-row:1/-1}.message{margin-block-start:4px;--_low-ink-color: var(--vvd-color-neutral-600)}.preview-list{display:flex;flex-direction:column;gap:12px;margin-block-start:12px;overflow-y:auto}.preview-list:empty{display:none}\n";
18
-
19
- var objectExtend = extend;
20
-
21
- /*
22
- var obj = {a: 3, b: 5};
23
- extend(obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
24
- obj; // {a: 4, b: 5, c: 8}
25
-
26
- var obj = {a: 3, b: 5};
27
- extend({}, obj, {a: 4, c: 8}); // {a: 4, b: 5, c: 8}
28
- obj; // {a: 3, b: 5}
29
-
30
- var arr = [1, 2, 3];
31
- var obj = {a: 3, b: 5};
32
- extend(obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
33
- arr.push(4);
34
- obj; // {a: 3, b: 5, c: [1, 2, 3, 4]}
35
-
36
- var arr = [1, 2, 3];
37
- var obj = {a: 3, b: 5};
38
- extend(true, obj, {c: arr}); // {a: 3, b: 5, c: [1, 2, 3]}
39
- arr.push(4);
40
- obj; // {a: 3, b: 5, c: [1, 2, 3]}
41
-
42
- extend({a: 4, b: 5}); // {a: 4, b: 5}
43
- extend({a: 4, b: 5}, 3); {a: 4, b: 5}
44
- extend({a: 4, b: 5}, true); {a: 4, b: 5}
45
- extend('hello', {a: 4, b: 5}); // throws
46
- extend(3, {a: 4, b: 5}); // throws
47
- */
48
-
49
- function extend(/* [deep], obj1, obj2, [objn] */) {
50
- var args = [].slice.call(arguments);
51
- var deep = false;
52
- if (typeof args[0] == 'boolean') {
53
- deep = args.shift();
54
- }
55
- var result = args[0];
56
- if (isUnextendable(result)) {
57
- throw new Error('extendee must be an object');
58
- }
59
- var extenders = args.slice(1);
60
- var len = extenders.length;
61
- for (var i = 0; i < len; i++) {
62
- var extender = extenders[i];
63
- for (var key in extender) {
64
- if (Object.prototype.hasOwnProperty.call(extender, key)) {
65
- var value = extender[key];
66
- if (deep && isCloneable(value)) {
67
- var base = Array.isArray(value) ? [] : {};
68
- result[key] = extend(
69
- true,
70
- Object.prototype.hasOwnProperty.call(result, key) && !isUnextendable(result[key])
71
- ? result[key]
72
- : base,
73
- value
74
- );
75
- } else {
76
- result[key] = value;
77
- }
78
- }
79
- }
80
- }
81
- return result;
82
- }
83
-
84
- function isCloneable(obj) {
85
- return Array.isArray(obj) || {}.toString.call(obj) == '[object Object]';
86
- }
87
-
88
- function isUnextendable(val) {
89
- return !val || (typeof val != 'object' && typeof val != 'function');
90
- }
91
-
92
- function $parcel$interopDefault(a) {
93
- return a && a.__esModule ? a.default : a;
94
- }
95
-
96
- class $4040acfd8584338d$export$2e2bcd8739ae039 {
97
- // Add an event listener for given event
98
- on(event, fn) {
99
- this._callbacks = this._callbacks || {
100
- };
101
- // Create namespace for this event
102
- if (!this._callbacks[event]) this._callbacks[event] = [];
103
- this._callbacks[event].push(fn);
104
- return this;
105
- }
106
- emit(event, ...args) {
107
- this._callbacks = this._callbacks || {
108
- };
109
- let callbacks = this._callbacks[event];
110
- if (callbacks) for (let callback of callbacks)callback.apply(this, args);
111
- // trigger a corresponding DOM event
112
- if (this.element) this.element.dispatchEvent(this.makeEvent("dropzone:" + event, {
113
- args: args
114
- }));
115
- return this;
116
- }
117
- makeEvent(eventName, detail) {
118
- let params = {
119
- bubbles: true,
120
- cancelable: true,
121
- detail: detail
122
- };
123
- if (typeof window.CustomEvent === "function") return new CustomEvent(eventName, params);
124
- else {
125
- // IE 11 support
126
- // https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent
127
- var evt = document.createEvent("CustomEvent");
128
- evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
129
- return evt;
130
- }
131
- }
132
- // Remove event listener for given event. If fn is not provided, all event
133
- // listeners for that event will be removed. If neither is provided, all
134
- // event listeners will be removed.
135
- off(event, fn) {
136
- if (!this._callbacks || arguments.length === 0) {
137
- this._callbacks = {
138
- };
139
- return this;
140
- }
141
- // specific event
142
- let callbacks = this._callbacks[event];
143
- if (!callbacks) return this;
144
- // remove all handlers
145
- if (arguments.length === 1) {
146
- delete this._callbacks[event];
147
- return this;
148
- }
149
- // remove specific handler
150
- for(let i = 0; i < callbacks.length; i++){
151
- let callback = callbacks[i];
152
- if (callback === fn) {
153
- callbacks.splice(i, 1);
154
- break;
155
- }
156
- }
157
- return this;
158
- }
159
- }
160
-
161
-
162
-
163
- var $fd6031f88dce2e32$exports = {};
164
- $fd6031f88dce2e32$exports = "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-image\"><img data-dz-thumbnail=\"\"></div>\n <div class=\"dz-details\">\n <div class=\"dz-size\"><span data-dz-size=\"\"></span></div>\n <div class=\"dz-filename\"><span data-dz-name=\"\"></span></div>\n </div>\n <div class=\"dz-progress\">\n <span class=\"dz-upload\" data-dz-uploadprogress=\"\"></span>\n </div>\n <div class=\"dz-error-message\"><span data-dz-errormessage=\"\"></span></div>\n <div class=\"dz-success-mark\">\n <svg width=\"54\" height=\"54\" viewBox=\"0 0 54 54\" fill=\"white\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M10.2071 29.7929L14.2929 25.7071C14.6834 25.3166 15.3166 25.3166 15.7071 25.7071L21.2929 31.2929C21.6834 31.6834 22.3166 31.6834 22.7071 31.2929L38.2929 15.7071C38.6834 15.3166 39.3166 15.3166 39.7071 15.7071L43.7929 19.7929C44.1834 20.1834 44.1834 20.8166 43.7929 21.2071L22.7071 42.2929C22.3166 42.6834 21.6834 42.6834 21.2929 42.2929L10.2071 31.2071C9.81658 30.8166 9.81658 30.1834 10.2071 29.7929Z\"></path>\n </svg>\n </div>\n <div class=\"dz-error-mark\">\n <svg width=\"54\" height=\"54\" viewBox=\"0 0 54 54\" fill=\"white\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M26.2929 20.2929L19.2071 13.2071C18.8166 12.8166 18.1834 12.8166 17.7929 13.2071L13.2071 17.7929C12.8166 18.1834 12.8166 18.8166 13.2071 19.2071L20.2929 26.2929C20.6834 26.6834 20.6834 27.3166 20.2929 27.7071L13.2071 34.7929C12.8166 35.1834 12.8166 35.8166 13.2071 36.2071L17.7929 40.7929C18.1834 41.1834 18.8166 41.1834 19.2071 40.7929L26.2929 33.7071C26.6834 33.3166 27.3166 33.3166 27.7071 33.7071L34.7929 40.7929C35.1834 41.1834 35.8166 41.1834 36.2071 40.7929L40.7929 36.2071C41.1834 35.8166 41.1834 35.1834 40.7929 34.7929L33.7071 27.7071C33.3166 27.3166 33.3166 26.6834 33.7071 26.2929L40.7929 19.2071C41.1834 18.8166 41.1834 18.1834 40.7929 17.7929L36.2071 13.2071C35.8166 12.8166 35.1834 12.8166 34.7929 13.2071L27.7071 20.2929C27.3166 20.6834 26.6834 20.6834 26.2929 20.2929Z\"></path>\n </svg>\n </div>\n</div>\n";
165
-
166
-
167
- let $4ca367182776f80b$var$defaultOptions = {
168
- /**
169
- * Has to be specified on elements other than form (or when the form doesn't
170
- * have an `action` attribute).
171
- *
172
- * You can also provide a function that will be called with `files` and
173
- * `dataBlocks` and must return the url as string.
174
- */ url: null,
175
- /**
176
- * Can be changed to `"put"` if necessary. You can also provide a function
177
- * that will be called with `files` and must return the method (since `v3.12.0`).
178
- */ method: "post",
179
- /**
180
- * Will be set on the XHRequest.
181
- */ withCredentials: false,
182
- /**
183
- * The timeout for the XHR requests in milliseconds (since `v4.4.0`).
184
- * If set to null or 0, no timeout is going to be set.
185
- */ timeout: null,
186
- /**
187
- * How many file uploads to process in parallel (See the
188
- * Enqueuing file uploads documentation section for more info)
189
- */ parallelUploads: 2,
190
- /**
191
- * Whether to send multiple files in one request. If
192
- * this it set to true, then the fallback file input element will
193
- * have the `multiple` attribute as well. This option will
194
- * also trigger additional events (like `processingmultiple`). See the events
195
- * documentation section for more information.
196
- */ uploadMultiple: false,
197
- /**
198
- * Whether you want files to be uploaded in chunks to your server. This can't be
199
- * used in combination with `uploadMultiple`.
200
- *
201
- * See [chunksUploaded](#config-chunksUploaded) for the callback to finalise an upload.
202
- */ chunking: false,
203
- /**
204
- * If `chunking` is enabled, this defines whether **every** file should be chunked,
205
- * even if the file size is below chunkSize. This means, that the additional chunk
206
- * form data will be submitted and the `chunksUploaded` callback will be invoked.
207
- */ forceChunking: false,
208
- /**
209
- * If `chunking` is `true`, then this defines the chunk size in bytes.
210
- */ chunkSize: 2097152,
211
- /**
212
- * If `true`, the individual chunks of a file are being uploaded simultaneously.
213
- */ parallelChunkUploads: false,
214
- /**
215
- * Whether a chunk should be retried if it fails.
216
- */ retryChunks: false,
217
- /**
218
- * If `retryChunks` is true, how many times should it be retried.
219
- */ retryChunksLimit: 3,
220
- /**
221
- * The maximum filesize (in MiB) that is allowed to be uploaded.
222
- */ maxFilesize: 256,
223
- /**
224
- * The name of the file param that gets transferred.
225
- * **NOTE**: If you have the option `uploadMultiple` set to `true`, then
226
- * Dropzone will append `[]` to the name.
227
- */ paramName: "file",
228
- /**
229
- * Whether thumbnails for images should be generated
230
- */ createImageThumbnails: true,
231
- /**
232
- * In MB. When the filename exceeds this limit, the thumbnail will not be generated.
233
- */ maxThumbnailFilesize: 10,
234
- /**
235
- * If `null`, the ratio of the image will be used to calculate it.
236
- */ thumbnailWidth: 120,
237
- /**
238
- * The same as `thumbnailWidth`. If both are null, images will not be resized.
239
- */ thumbnailHeight: 120,
240
- /**
241
- * How the images should be scaled down in case both, `thumbnailWidth` and `thumbnailHeight` are provided.
242
- * Can be either `contain` or `crop`.
243
- */ thumbnailMethod: "crop",
244
- /**
245
- * If set, images will be resized to these dimensions before being **uploaded**.
246
- * If only one, `resizeWidth` **or** `resizeHeight` is provided, the original aspect
247
- * ratio of the file will be preserved.
248
- *
249
- * The `options.transformFile` function uses these options, so if the `transformFile` function
250
- * is overridden, these options don't do anything.
251
- */ resizeWidth: null,
252
- /**
253
- * See `resizeWidth`.
254
- */ resizeHeight: null,
255
- /**
256
- * The mime type of the resized image (before it gets uploaded to the server).
257
- * If `null` the original mime type will be used. To force jpeg, for example, use `image/jpeg`.
258
- * See `resizeWidth` for more information.
259
- */ resizeMimeType: null,
260
- /**
261
- * The quality of the resized images. See `resizeWidth`.
262
- */ resizeQuality: 0.8,
263
- /**
264
- * How the images should be scaled down in case both, `resizeWidth` and `resizeHeight` are provided.
265
- * Can be either `contain` or `crop`.
266
- */ resizeMethod: "contain",
267
- /**
268
- * The base that is used to calculate the **displayed** filesize. You can
269
- * change this to 1024 if you would rather display kibibytes, mebibytes,
270
- * etc... 1024 is technically incorrect, because `1024 bytes` are `1 kibibyte`
271
- * not `1 kilobyte`. You can change this to `1024` if you don't care about
272
- * validity.
273
- */ filesizeBase: 1000,
274
- /**
275
- * If not `null` defines how many files this Dropzone handles. If it exceeds,
276
- * the event `maxfilesexceeded` will be called. The dropzone element gets the
277
- * class `dz-max-files-reached` accordingly so you can provide visual
278
- * feedback.
279
- */ maxFiles: null,
280
- /**
281
- * An optional object to send additional headers to the server. Eg:
282
- * `{ "My-Awesome-Header": "header value" }`
283
- */ headers: null,
284
- /**
285
- * Should the default headers be set or not?
286
- * Accept: application/json <- for requesting json response
287
- * Cache-Control: no-cache <- Request shouldnt be cached
288
- * X-Requested-With: XMLHttpRequest <- We sent the request via XMLHttpRequest
289
- */ defaultHeaders: true,
290
- /**
291
- * If `true`, the dropzone element itself will be clickable, if `false`
292
- * nothing will be clickable.
293
- *
294
- * You can also pass an HTML element, a CSS selector (for multiple elements)
295
- * or an array of those. In that case, all of those elements will trigger an
296
- * upload when clicked.
297
- */ clickable: true,
298
- /**
299
- * Whether hidden files in directories should be ignored.
300
- */ ignoreHiddenFiles: true,
301
- /**
302
- * The default implementation of `accept` checks the file's mime type or
303
- * extension against this list. This is a comma separated list of mime
304
- * types or file extensions.
305
- *
306
- * Eg.: `image/*,application/pdf,.psd`
307
- *
308
- * If the Dropzone is `clickable` this option will also be used as
309
- * [`accept`](https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept)
310
- * parameter on the hidden file input as well.
311
- */ acceptedFiles: null,
312
- /**
313
- * **Deprecated!**
314
- * Use acceptedFiles instead.
315
- */ acceptedMimeTypes: null,
316
- /**
317
- * If false, files will be added to the queue but the queue will not be
318
- * processed automatically.
319
- * This can be useful if you need some additional user input before sending
320
- * files (or if you want want all files sent at once).
321
- * If you're ready to send the file simply call `myDropzone.processQueue()`.
322
- *
323
- * See the [enqueuing file uploads](#enqueuing-file-uploads) documentation
324
- * section for more information.
325
- */ autoProcessQueue: true,
326
- /**
327
- * If false, files added to the dropzone will not be queued by default.
328
- * You'll have to call `enqueueFile(file)` manually.
329
- */ autoQueue: true,
330
- /**
331
- * If `true`, this will add a link to every file preview to remove or cancel (if
332
- * already uploading) the file. The `dictCancelUpload`, `dictCancelUploadConfirmation`
333
- * and `dictRemoveFile` options are used for the wording.
334
- */ addRemoveLinks: false,
335
- /**
336
- * Defines where to display the file previews – if `null` the
337
- * Dropzone element itself is used. Can be a plain `HTMLElement` or a CSS
338
- * selector. The element should have the `dropzone-previews` class so
339
- * the previews are displayed properly.
340
- */ previewsContainer: null,
341
- /**
342
- * Set this to `true` if you don't want previews to be shown.
343
- */ disablePreviews: false,
344
- /**
345
- * This is the element the hidden input field (which is used when clicking on the
346
- * dropzone to trigger file selection) will be appended to. This might
347
- * be important in case you use frameworks to switch the content of your page.
348
- *
349
- * Can be a selector string, or an element directly.
350
- */ hiddenInputContainer: "body",
351
- /**
352
- * If null, no capture type will be specified
353
- * If camera, mobile devices will skip the file selection and choose camera
354
- * If microphone, mobile devices will skip the file selection and choose the microphone
355
- * If camcorder, mobile devices will skip the file selection and choose the camera in video mode
356
- * On apple devices multiple must be set to false. AcceptedFiles may need to
357
- * be set to an appropriate mime type (e.g. "image/*", "audio/*", or "video/*").
358
- */ capture: null,
359
- /**
360
- * **Deprecated**. Use `renameFile` instead.
361
- */ renameFilename: null,
362
- /**
363
- * A function that is invoked before the file is uploaded to the server and renames the file.
364
- * This function gets the `File` as argument and can use the `file.name`. The actual name of the
365
- * file that gets used during the upload can be accessed through `file.upload.filename`.
366
- */ renameFile: null,
367
- /**
368
- * If `true` the fallback will be forced. This is very useful to test your server
369
- * implementations first and make sure that everything works as
370
- * expected without dropzone if you experience problems, and to test
371
- * how your fallbacks will look.
372
- */ forceFallback: false,
373
- /**
374
- * The text used before any files are dropped.
375
- */ dictDefaultMessage: "Drop files here to upload",
376
- /**
377
- * The text that replaces the default message text it the browser is not supported.
378
- */ dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.",
379
- /**
380
- * The text that will be added before the fallback form.
381
- * If you provide a fallback element yourself, or if this option is `null` this will
382
- * be ignored.
383
- */ dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.",
384
- /**
385
- * If the filesize is too big.
386
- * `{{filesize}}` and `{{maxFilesize}}` will be replaced with the respective configuration values.
387
- */ dictFileTooBig: "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.",
388
- /**
389
- * If the file doesn't match the file type.
390
- */ dictInvalidFileType: "You can't upload files of this type.",
391
- /**
392
- * If the server response was invalid.
393
- * `{{statusCode}}` will be replaced with the servers status code.
394
- */ dictResponseError: "Server responded with {{statusCode}} code.",
395
- /**
396
- * If `addRemoveLinks` is true, the text to be used for the cancel upload link.
397
- */ dictCancelUpload: "Cancel upload",
398
- /**
399
- * The text that is displayed if an upload was manually canceled
400
- */ dictUploadCanceled: "Upload canceled.",
401
- /**
402
- * If `addRemoveLinks` is true, the text to be used for confirmation when cancelling upload.
403
- */ dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?",
404
- /**
405
- * If `addRemoveLinks` is true, the text to be used to remove a file.
406
- */ dictRemoveFile: "Remove file",
407
- /**
408
- * If this is not null, then the user will be prompted before removing a file.
409
- */ dictRemoveFileConfirmation: null,
410
- /**
411
- * Displayed if `maxFiles` is st and exceeded.
412
- * The string `{{maxFiles}}` will be replaced by the configuration value.
413
- */ dictMaxFilesExceeded: "You can not upload any more files.",
414
- /**
415
- * Allows you to translate the different units. Starting with `tb` for terabytes and going down to
416
- * `b` for bytes.
417
- */ dictFileSizeUnits: {
418
- tb: "TB",
419
- gb: "GB",
420
- mb: "MB",
421
- kb: "KB",
422
- b: "b"
423
- },
424
- /**
425
- * Called when dropzone initialized
426
- * You can add event listeners here
427
- */ init () {
428
- },
429
- /**
430
- * Can be an **object** of additional parameters to transfer to the server, **or** a `Function`
431
- * that gets invoked with the `files`, `xhr` and, if it's a chunked upload, `chunk` arguments. In case
432
- * of a function, this needs to return a map.
433
- *
434
- * The default implementation does nothing for normal uploads, but adds relevant information for
435
- * chunked uploads.
436
- *
437
- * This is the same as adding hidden input fields in the form element.
438
- */ params (files, xhr, chunk) {
439
- if (chunk) return {
440
- dzuuid: chunk.file.upload.uuid,
441
- dzchunkindex: chunk.index,
442
- dztotalfilesize: chunk.file.size,
443
- dzchunksize: this.options.chunkSize,
444
- dztotalchunkcount: chunk.file.upload.totalChunkCount,
445
- dzchunkbyteoffset: chunk.index * this.options.chunkSize
446
- };
447
- },
448
- /**
449
- * A function that gets a [file](https://developer.mozilla.org/en-US/docs/DOM/File)
450
- * and a `done` function as parameters.
451
- *
452
- * If the done function is invoked without arguments, the file is "accepted" and will
453
- * be processed. If you pass an error message, the file is rejected, and the error
454
- * message will be displayed.
455
- * This function will not be called if the file is too big or doesn't match the mime types.
456
- */ accept (file, done) {
457
- return done();
458
- },
459
- /**
460
- * The callback that will be invoked when all chunks have been uploaded for a file.
461
- * It gets the file for which the chunks have been uploaded as the first parameter,
462
- * and the `done` function as second. `done()` needs to be invoked when everything
463
- * needed to finish the upload process is done.
464
- */ chunksUploaded: function(file, done) {
465
- done();
466
- },
467
- /**
468
- * Sends the file as binary blob in body instead of form data.
469
- * If this is set, the `params` option will be ignored.
470
- * It's an error to set this to `true` along with `uploadMultiple` since
471
- * multiple files cannot be in a single binary body.
472
- */ binaryBody: false,
473
- /**
474
- * Gets called when the browser is not supported.
475
- * The default implementation shows the fallback input field and adds
476
- * a text.
477
- */ fallback () {
478
- // This code should pass in IE7... :(
479
- let messageElement;
480
- this.element.className = `${this.element.className} dz-browser-not-supported`;
481
- for (let child of this.element.getElementsByTagName("div"))if (/(^| )dz-message($| )/.test(child.className)) {
482
- messageElement = child;
483
- child.className = "dz-message"; // Removes the 'dz-default' class
484
- break;
485
- }
486
- if (!messageElement) {
487
- messageElement = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement('<div class="dz-message"><span></span></div>');
488
- this.element.appendChild(messageElement);
489
- }
490
- let span = messageElement.getElementsByTagName("span")[0];
491
- if (span) {
492
- if (span.textContent != null) span.textContent = this.options.dictFallbackMessage;
493
- else if (span.innerText != null) span.innerText = this.options.dictFallbackMessage;
494
- }
495
- return this.element.appendChild(this.getFallbackForm());
496
- },
497
- /**
498
- * Gets called to calculate the thumbnail dimensions.
499
- *
500
- * It gets `file`, `width` and `height` (both may be `null`) as parameters and must return an object containing:
501
- *
502
- * - `srcWidth` & `srcHeight` (required)
503
- * - `trgWidth` & `trgHeight` (required)
504
- * - `srcX` & `srcY` (optional, default `0`)
505
- * - `trgX` & `trgY` (optional, default `0`)
506
- *
507
- * Those values are going to be used by `ctx.drawImage()`.
508
- */ resize (file, width, height, resizeMethod) {
509
- let info = {
510
- srcX: 0,
511
- srcY: 0,
512
- srcWidth: file.width,
513
- srcHeight: file.height
514
- };
515
- let srcRatio = file.width / file.height;
516
- // Automatically calculate dimensions if not specified
517
- if (width == null && height == null) {
518
- width = info.srcWidth;
519
- height = info.srcHeight;
520
- } else if (width == null) width = height * srcRatio;
521
- else if (height == null) height = width / srcRatio;
522
- // Make sure images aren't upscaled
523
- width = Math.min(width, info.srcWidth);
524
- height = Math.min(height, info.srcHeight);
525
- let trgRatio = width / height;
526
- if (info.srcWidth > width || info.srcHeight > height) {
527
- // Image is bigger and needs rescaling
528
- if (resizeMethod === "crop") {
529
- if (srcRatio > trgRatio) {
530
- info.srcHeight = file.height;
531
- info.srcWidth = info.srcHeight * trgRatio;
532
- } else {
533
- info.srcWidth = file.width;
534
- info.srcHeight = info.srcWidth / trgRatio;
535
- }
536
- } else if (resizeMethod === "contain") {
537
- // Method 'contain'
538
- if (srcRatio > trgRatio) height = width / srcRatio;
539
- else width = height * srcRatio;
540
- } else throw new Error(`Unknown resizeMethod '${resizeMethod}'`);
541
- }
542
- info.srcX = (file.width - info.srcWidth) / 2;
543
- info.srcY = (file.height - info.srcHeight) / 2;
544
- info.trgWidth = width;
545
- info.trgHeight = height;
546
- return info;
547
- },
548
- /**
549
- * Can be used to transform the file (for example, resize an image if necessary).
550
- *
551
- * The default implementation uses `resizeWidth` and `resizeHeight` (if provided) and resizes
552
- * images according to those dimensions.
553
- *
554
- * Gets the `file` as the first parameter, and a `done()` function as the second, that needs
555
- * to be invoked with the file when the transformation is done.
556
- */ transformFile (file, done) {
557
- if ((this.options.resizeWidth || this.options.resizeHeight) && file.type.match(/image.*/)) return this.resizeImage(file, this.options.resizeWidth, this.options.resizeHeight, this.options.resizeMethod, done);
558
- else return done(file);
559
- },
560
- /**
561
- * A string that contains the template used for each dropped
562
- * file. Change it to fulfill your needs but make sure to properly
563
- * provide all elements.
564
- *
565
- * If you want to use an actual HTML element instead of providing a String
566
- * as a config option, you could create a div with the id `tpl`,
567
- * put the template inside it and provide the element like this:
568
- *
569
- * document
570
- * .querySelector('#tpl')
571
- * .innerHTML
572
- *
573
- */ previewTemplate: (/*@__PURE__*/$parcel$interopDefault($fd6031f88dce2e32$exports)),
574
- /*
575
- Those functions register themselves to the events on init and handle all
576
- the user interface specific stuff. Overwriting them won't break the upload
577
- but can break the way it's displayed.
578
- You can overwrite them if you don't like the default behavior. If you just
579
- want to add an additional event handler, register it on the dropzone object
580
- and don't overwrite those options.
581
- */ // Those are self explanatory and simply concern the DragnDrop.
582
- drop (e) {
583
- return this.element.classList.remove("dz-drag-hover");
584
- },
585
- dragstart (e) {
586
- },
587
- dragend (e) {
588
- return this.element.classList.remove("dz-drag-hover");
589
- },
590
- dragenter (e) {
591
- return this.element.classList.add("dz-drag-hover");
592
- },
593
- dragover (e) {
594
- return this.element.classList.add("dz-drag-hover");
595
- },
596
- dragleave (e) {
597
- return this.element.classList.remove("dz-drag-hover");
598
- },
599
- paste (e) {
600
- },
601
- // Called whenever there are no files left in the dropzone anymore, and the
602
- // dropzone should be displayed as if in the initial state.
603
- reset () {
604
- return this.element.classList.remove("dz-started");
605
- },
606
- // Called when a file is added to the queue
607
- // Receives `file`
608
- addedfile (file) {
609
- if (this.element === this.previewsContainer) this.element.classList.add("dz-started");
610
- if (this.previewsContainer && !this.options.disablePreviews) {
611
- file.previewElement = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(this.options.previewTemplate.trim());
612
- file.previewTemplate = file.previewElement; // Backwards compatibility
613
- this.previewsContainer.appendChild(file.previewElement);
614
- for (var node of file.previewElement.querySelectorAll("[data-dz-name]"))node.textContent = file.name;
615
- for (node of file.previewElement.querySelectorAll("[data-dz-size]"))node.innerHTML = this.filesize(file.size);
616
- if (this.options.addRemoveLinks) {
617
- file._removeLink = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<a class="dz-remove" href="javascript:undefined;" data-dz-remove>${this.options.dictRemoveFile}</a>`);
618
- file.previewElement.appendChild(file._removeLink);
619
- }
620
- let removeFileEvent = (e)=>{
621
- e.preventDefault();
622
- e.stopPropagation();
623
- if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm(this.options.dictCancelUploadConfirmation, ()=>this.removeFile(file)
624
- );
625
- else {
626
- if (this.options.dictRemoveFileConfirmation) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm(this.options.dictRemoveFileConfirmation, ()=>this.removeFile(file)
627
- );
628
- else return this.removeFile(file);
629
- }
630
- };
631
- for (let removeLink of file.previewElement.querySelectorAll("[data-dz-remove]"))removeLink.addEventListener("click", removeFileEvent);
632
- }
633
- },
634
- // Called whenever a file is removed.
635
- removedfile (file) {
636
- if (file.previewElement != null && file.previewElement.parentNode != null) file.previewElement.parentNode.removeChild(file.previewElement);
637
- return this._updateMaxFilesReachedClass();
638
- },
639
- // Called when a thumbnail has been generated
640
- // Receives `file` and `dataUrl`
641
- thumbnail (file, dataUrl) {
642
- if (file.previewElement) {
643
- file.previewElement.classList.remove("dz-file-preview");
644
- for (let thumbnailElement of file.previewElement.querySelectorAll("[data-dz-thumbnail]")){
645
- thumbnailElement.alt = file.name;
646
- thumbnailElement.src = dataUrl;
647
- }
648
- return setTimeout(()=>file.previewElement.classList.add("dz-image-preview")
649
- , 1);
650
- }
651
- },
652
- // Called whenever an error occurs
653
- // Receives `file` and `message`
654
- error (file, message) {
655
- if (file.previewElement) {
656
- file.previewElement.classList.add("dz-error");
657
- if (typeof message !== "string" && message.error) message = message.error;
658
- for (let node of file.previewElement.querySelectorAll("[data-dz-errormessage]"))node.textContent = message;
659
- }
660
- },
661
- errormultiple () {
662
- },
663
- // Called when a file gets processed. Since there is a cue, not all added
664
- // files are processed immediately.
665
- // Receives `file`
666
- processing (file) {
667
- if (file.previewElement) {
668
- file.previewElement.classList.add("dz-processing");
669
- if (file._removeLink) return file._removeLink.innerHTML = this.options.dictCancelUpload;
670
- }
671
- },
672
- processingmultiple () {
673
- },
674
- // Called whenever the upload progress gets updated.
675
- // Receives `file`, `progress` (percentage 0-100) and `bytesSent`.
676
- // To get the total number of bytes of the file, use `file.size`
677
- uploadprogress (file, progress, bytesSent) {
678
- if (file.previewElement) for (let node of file.previewElement.querySelectorAll("[data-dz-uploadprogress]"))node.nodeName === "PROGRESS" ? node.value = progress : node.style.width = `${progress}%`;
679
- },
680
- // Called whenever the total upload progress gets updated.
681
- // Called with totalUploadProgress (0-100), totalBytes and totalBytesSent
682
- totaluploadprogress () {
683
- },
684
- // Called just before the file is sent. Gets the `xhr` object as second
685
- // parameter, so you can modify it (for example to add a CSRF token) and a
686
- // `formData` object to add additional information.
687
- sending () {
688
- },
689
- sendingmultiple () {
690
- },
691
- // When the complete upload is finished and successful
692
- // Receives `file`
693
- success (file) {
694
- if (file.previewElement) return file.previewElement.classList.add("dz-success");
695
- },
696
- successmultiple () {
697
- },
698
- // When the upload is canceled.
699
- canceled (file) {
700
- return this.emit("error", file, this.options.dictUploadCanceled);
701
- },
702
- canceledmultiple () {
703
- },
704
- // When the upload is finished, either with success or an error.
705
- // Receives `file`
706
- complete (file) {
707
- if (file._removeLink) file._removeLink.innerHTML = this.options.dictRemoveFile;
708
- if (file.previewElement) return file.previewElement.classList.add("dz-complete");
709
- },
710
- completemultiple () {
711
- },
712
- maxfilesexceeded () {
713
- },
714
- maxfilesreached () {
715
- },
716
- queuecomplete () {
717
- },
718
- addedfiles () {
719
- }
720
- };
721
- var $4ca367182776f80b$export$2e2bcd8739ae039 = $4ca367182776f80b$var$defaultOptions;
722
-
723
-
724
- class $3ed269f2f0fb224b$export$2e2bcd8739ae039 extends $4040acfd8584338d$export$2e2bcd8739ae039 {
725
- static initClass() {
726
- // Exposing the emitter class, mainly for tests
727
- this.prototype.Emitter = $4040acfd8584338d$export$2e2bcd8739ae039;
728
- /*
729
- This is a list of all available events you can register on a dropzone object.
730
-
731
- You can register an event handler like this:
732
-
733
- dropzone.on("dragEnter", function() { });
734
-
735
- */ this.prototype.events = [
736
- "drop",
737
- "dragstart",
738
- "dragend",
739
- "dragenter",
740
- "dragover",
741
- "dragleave",
742
- "addedfile",
743
- "addedfiles",
744
- "removedfile",
745
- "thumbnail",
746
- "error",
747
- "errormultiple",
748
- "processing",
749
- "processingmultiple",
750
- "uploadprogress",
751
- "totaluploadprogress",
752
- "sending",
753
- "sendingmultiple",
754
- "success",
755
- "successmultiple",
756
- "canceled",
757
- "canceledmultiple",
758
- "complete",
759
- "completemultiple",
760
- "reset",
761
- "maxfilesexceeded",
762
- "maxfilesreached",
763
- "queuecomplete",
764
- ];
765
- this.prototype._thumbnailQueue = [];
766
- this.prototype._processingThumbnail = false;
767
- }
768
- // Returns all files that have been accepted
769
- getAcceptedFiles() {
770
- return this.files.filter((file)=>file.accepted
771
- ).map((file)=>file
772
- );
773
- }
774
- // Returns all files that have been rejected
775
- // Not sure when that's going to be useful, but added for completeness.
776
- getRejectedFiles() {
777
- return this.files.filter((file)=>!file.accepted
778
- ).map((file)=>file
779
- );
780
- }
781
- getFilesWithStatus(status) {
782
- return this.files.filter((file)=>file.status === status
783
- ).map((file)=>file
784
- );
785
- }
786
- // Returns all files that are in the queue
787
- getQueuedFiles() {
788
- return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED);
789
- }
790
- getUploadingFiles() {
791
- return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING);
792
- }
793
- getAddedFiles() {
794
- return this.getFilesWithStatus($3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED);
795
- }
796
- // Files that are either queued or uploading
797
- getActiveFiles() {
798
- return this.files.filter((file)=>file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING || file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED
799
- ).map((file)=>file
800
- );
801
- }
802
- // The function that gets called when Dropzone is initialized. You
803
- // can (and should) setup event listeners inside this function.
804
- init() {
805
- // In case it isn't set already
806
- if (this.element.tagName === "form") this.element.setAttribute("enctype", "multipart/form-data");
807
- if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) this.element.appendChild($3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<div class="dz-default dz-message"><button class="dz-button" type="button">${this.options.dictDefaultMessage}</button></div>`));
808
- if (this.clickableElements.length) {
809
- let setupHiddenFileInput = ()=>{
810
- if (this.hiddenFileInput) this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
811
- this.hiddenFileInput = document.createElement("input");
812
- this.hiddenFileInput.setAttribute("type", "file");
813
- if (this.options.maxFiles === null || this.options.maxFiles > 1) this.hiddenFileInput.setAttribute("multiple", "multiple");
814
- this.hiddenFileInput.className = "dz-hidden-input";
815
- if (this.options.acceptedFiles !== null) this.hiddenFileInput.setAttribute("accept", this.options.acceptedFiles);
816
- if (this.options.capture !== null) this.hiddenFileInput.setAttribute("capture", this.options.capture);
817
- // Making sure that no one can "tab" into this field.
818
- this.hiddenFileInput.setAttribute("tabindex", "-1");
819
- // Not setting `display="none"` because some browsers don't accept clicks
820
- // on elements that aren't displayed.
821
- this.hiddenFileInput.style.visibility = "hidden";
822
- this.hiddenFileInput.style.position = "absolute";
823
- this.hiddenFileInput.style.top = "0";
824
- this.hiddenFileInput.style.left = "0";
825
- this.hiddenFileInput.style.height = "0";
826
- this.hiddenFileInput.style.width = "0";
827
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement(this.options.hiddenInputContainer, "hiddenInputContainer").appendChild(this.hiddenFileInput);
828
- this.hiddenFileInput.addEventListener("change", ()=>{
829
- let { files: files } = this.hiddenFileInput;
830
- if (files.length) for (let file of files)this.addFile(file);
831
- this.emit("addedfiles", files);
832
- setupHiddenFileInput();
833
- });
834
- };
835
- setupHiddenFileInput();
836
- }
837
- this.URL = window.URL !== null ? window.URL : window.webkitURL;
838
- // Setup all event listeners on the Dropzone object itself.
839
- // They're not in @setupEventListeners() because they shouldn't be removed
840
- // again when the dropzone gets disabled.
841
- for (let eventName of this.events)this.on(eventName, this.options[eventName]);
842
- this.on("uploadprogress", ()=>this.updateTotalUploadProgress()
843
- );
844
- this.on("removedfile", ()=>this.updateTotalUploadProgress()
845
- );
846
- this.on("canceled", (file)=>this.emit("complete", file)
847
- );
848
- // Emit a `queuecomplete` event if all files finished uploading.
849
- this.on("complete", (file)=>{
850
- if (this.getAddedFiles().length === 0 && this.getUploadingFiles().length === 0 && this.getQueuedFiles().length === 0) // This needs to be deferred so that `queuecomplete` really triggers after `complete`
851
- return setTimeout(()=>this.emit("queuecomplete")
852
- , 0);
853
- });
854
- const containsFiles = function(e) {
855
- if (e.dataTransfer.types) // Because e.dataTransfer.types is an Object in
856
- // IE, we need to iterate like this instead of
857
- // using e.dataTransfer.types.some()
858
- for(var i = 0; i < e.dataTransfer.types.length; i++){
859
- if (e.dataTransfer.types[i] === "Files") return true;
860
- }
861
- return false;
862
- };
863
- let noPropagation = function(e) {
864
- // If there are no files, we don't want to stop
865
- // propagation so we don't interfere with other
866
- // drag and drop behaviour.
867
- if (!containsFiles(e)) return;
868
- e.stopPropagation();
869
- if (e.preventDefault) return e.preventDefault();
870
- else return e.returnValue = false;
871
- };
872
- // Create the listeners
873
- this.listeners = [
874
- {
875
- element: this.element,
876
- events: {
877
- dragstart: (e)=>{
878
- return this.emit("dragstart", e);
879
- },
880
- dragenter: (e)=>{
881
- noPropagation(e);
882
- return this.emit("dragenter", e);
883
- },
884
- dragover: (e)=>{
885
- // Makes it possible to drag files from chrome's download bar
886
- // http://stackoverflow.com/questions/19526430/drag-and-drop-file-uploads-from-chrome-downloads-bar
887
- // Try is required to prevent bug in Internet Explorer 11 (SCRIPT65535 exception)
888
- let efct;
889
- try {
890
- efct = e.dataTransfer.effectAllowed;
891
- } catch (error) {
892
- }
893
- e.dataTransfer.dropEffect = "move" === efct || "linkMove" === efct ? "move" : "copy";
894
- noPropagation(e);
895
- return this.emit("dragover", e);
896
- },
897
- dragleave: (e)=>{
898
- return this.emit("dragleave", e);
899
- },
900
- drop: (e)=>{
901
- noPropagation(e);
902
- return this.drop(e);
903
- },
904
- dragend: (e)=>{
905
- return this.emit("dragend", e);
906
- }
907
- }
908
- },
909
- ];
910
- this.clickableElements.forEach((clickableElement)=>{
911
- return this.listeners.push({
912
- element: clickableElement,
913
- events: {
914
- click: (evt)=>{
915
- // Only the actual dropzone or the message element should trigger file selection
916
- if (clickableElement !== this.element || evt.target === this.element || $3ed269f2f0fb224b$export$2e2bcd8739ae039.elementInside(evt.target, this.element.querySelector(".dz-message"))) this.hiddenFileInput.click(); // Forward the click
917
- return true;
918
- }
919
- }
920
- });
921
- });
922
- this.enable();
923
- return this.options.init.call(this);
924
- }
925
- // Not fully tested yet
926
- destroy() {
927
- this.disable();
928
- this.removeAllFiles(true);
929
- if (this.hiddenFileInput != null ? this.hiddenFileInput.parentNode : undefined) {
930
- this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput);
931
- this.hiddenFileInput = null;
932
- }
933
- delete this.element.dropzone;
934
- return $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.splice($3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.indexOf(this), 1);
935
- }
936
- updateTotalUploadProgress() {
937
- let totalUploadProgress;
938
- let totalBytesSent = 0;
939
- let totalBytes = 0;
940
- let activeFiles = this.getActiveFiles();
941
- if (activeFiles.length) {
942
- for (let file of this.getActiveFiles()){
943
- totalBytesSent += file.upload.bytesSent;
944
- totalBytes += file.upload.total;
945
- }
946
- totalUploadProgress = 100 * totalBytesSent / totalBytes;
947
- } else totalUploadProgress = 100;
948
- return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent);
949
- }
950
- // @options.paramName can be a function taking one parameter rather than a string.
951
- // A parameter name for a file is obtained simply by calling this with an index number.
952
- _getParamName(n) {
953
- if (typeof this.options.paramName === "function") return this.options.paramName(n);
954
- else return `${this.options.paramName}${this.options.uploadMultiple ? `[${n}]` : ""}`;
955
- }
956
- // If @options.renameFile is a function,
957
- // the function will be used to rename the file.name before appending it to the formData
958
- _renameFile(file) {
959
- if (typeof this.options.renameFile !== "function") return file.name;
960
- return this.options.renameFile(file);
961
- }
962
- // Returns a form that can be used as fallback if the browser does not support DragnDrop
963
- //
964
- // If the dropzone is already a form, only the input field and button are returned. Otherwise a complete form element is provided.
965
- // This code has to pass in IE7 :(
966
- getFallbackForm() {
967
- let existingFallback, form;
968
- if (existingFallback = this.getExistingFallback()) return existingFallback;
969
- let fieldsString = '<div class="dz-fallback">';
970
- if (this.options.dictFallbackText) fieldsString += `<p>${this.options.dictFallbackText}</p>`;
971
- fieldsString += `<input type="file" name="${this._getParamName(0)}" ${this.options.uploadMultiple ? 'multiple="multiple"' : undefined} /><input type="submit" value="Upload!"></div>`;
972
- let fields = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(fieldsString);
973
- if (this.element.tagName !== "FORM") {
974
- form = $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement(`<form action="${this.options.url}" enctype="multipart/form-data" method="${this.options.method}"></form>`);
975
- form.appendChild(fields);
976
- } else {
977
- // Make sure that the enctype and method attributes are set properly
978
- this.element.setAttribute("enctype", "multipart/form-data");
979
- this.element.setAttribute("method", this.options.method);
980
- }
981
- return form != null ? form : fields;
982
- }
983
- // Returns the fallback elements if they exist already
984
- //
985
- // This code has to pass in IE7 :(
986
- getExistingFallback() {
987
- let getFallback = function(elements) {
988
- for (let el of elements){
989
- if (/(^| )fallback($| )/.test(el.className)) return el;
990
- }
991
- };
992
- for (let tagName of [
993
- "div",
994
- "form"
995
- ]){
996
- var fallback;
997
- if (fallback = getFallback(this.element.getElementsByTagName(tagName))) return fallback;
998
- }
999
- }
1000
- // Activates all listeners stored in @listeners
1001
- setupEventListeners() {
1002
- return this.listeners.map((elementListeners)=>(()=>{
1003
- let result = [];
1004
- for(let event in elementListeners.events){
1005
- let listener = elementListeners.events[event];
1006
- result.push(elementListeners.element.addEventListener(event, listener, false));
1007
- }
1008
- return result;
1009
- })()
1010
- );
1011
- }
1012
- // Deactivates all listeners stored in @listeners
1013
- removeEventListeners() {
1014
- return this.listeners.map((elementListeners)=>(()=>{
1015
- let result = [];
1016
- for(let event in elementListeners.events){
1017
- let listener = elementListeners.events[event];
1018
- result.push(elementListeners.element.removeEventListener(event, listener, false));
1019
- }
1020
- return result;
1021
- })()
1022
- );
1023
- }
1024
- // Removes all event listeners and cancels all files in the queue or being processed.
1025
- disable() {
1026
- this.clickableElements.forEach((element)=>element.classList.remove("dz-clickable")
1027
- );
1028
- this.removeEventListeners();
1029
- this.disabled = true;
1030
- return this.files.map((file)=>this.cancelUpload(file)
1031
- );
1032
- }
1033
- enable() {
1034
- delete this.disabled;
1035
- this.clickableElements.forEach((element)=>element.classList.add("dz-clickable")
1036
- );
1037
- return this.setupEventListeners();
1038
- }
1039
- // Returns a nicely formatted filesize
1040
- filesize(size) {
1041
- let selectedSize = 0;
1042
- let selectedUnit = "b";
1043
- if (size > 0) {
1044
- let units = [
1045
- "tb",
1046
- "gb",
1047
- "mb",
1048
- "kb",
1049
- "b"
1050
- ];
1051
- for(let i = 0; i < units.length; i++){
1052
- let unit = units[i];
1053
- let cutoff = Math.pow(this.options.filesizeBase, 4 - i) / 10;
1054
- if (size >= cutoff) {
1055
- selectedSize = size / Math.pow(this.options.filesizeBase, 4 - i);
1056
- selectedUnit = unit;
1057
- break;
1058
- }
1059
- }
1060
- selectedSize = Math.round(10 * selectedSize) / 10; // Cutting of digits
1061
- }
1062
- return `<strong>${selectedSize}</strong> ${this.options.dictFileSizeUnits[selectedUnit]}`;
1063
- }
1064
- // Adds or removes the `dz-max-files-reached` class from the form.
1065
- _updateMaxFilesReachedClass() {
1066
- if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
1067
- if (this.getAcceptedFiles().length === this.options.maxFiles) this.emit("maxfilesreached", this.files);
1068
- return this.element.classList.add("dz-max-files-reached");
1069
- } else return this.element.classList.remove("dz-max-files-reached");
1070
- }
1071
- drop(e) {
1072
- if (!e.dataTransfer) return;
1073
- this.emit("drop", e);
1074
- // Convert the FileList to an Array
1075
- // This is necessary for IE11
1076
- let files = [];
1077
- for(let i = 0; i < e.dataTransfer.files.length; i++)files[i] = e.dataTransfer.files[i];
1078
- // Even if it's a folder, files.length will contain the folders.
1079
- if (files.length) {
1080
- let { items: items } = e.dataTransfer;
1081
- if (items && items.length && items[0].webkitGetAsEntry != null) // The browser supports dropping of folders, so handle items instead of files
1082
- this._addFilesFromItems(items);
1083
- else this.handleFiles(files);
1084
- }
1085
- this.emit("addedfiles", files);
1086
- }
1087
- paste(e) {
1088
- if ($3ed269f2f0fb224b$var$__guard__(e != null ? e.clipboardData : undefined, (x)=>x.items
1089
- ) == null) return;
1090
- this.emit("paste", e);
1091
- let { items: items } = e.clipboardData;
1092
- if (items.length) return this._addFilesFromItems(items);
1093
- }
1094
- handleFiles(files) {
1095
- for (let file of files)this.addFile(file);
1096
- }
1097
- // When a folder is dropped (or files are pasted), items must be handled
1098
- // instead of files.
1099
- _addFilesFromItems(items) {
1100
- return (()=>{
1101
- let result = [];
1102
- for (let item of items){
1103
- var entry;
1104
- if (item.webkitGetAsEntry != null && (entry = item.webkitGetAsEntry())) {
1105
- if (entry.isFile) result.push(this.addFile(item.getAsFile()));
1106
- else if (entry.isDirectory) // Append all files from that directory to files
1107
- result.push(this._addFilesFromDirectory(entry, entry.name));
1108
- else result.push(undefined);
1109
- } else if (item.getAsFile != null) {
1110
- if (item.kind == null || item.kind === "file") result.push(this.addFile(item.getAsFile()));
1111
- else result.push(undefined);
1112
- } else result.push(undefined);
1113
- }
1114
- return result;
1115
- })();
1116
- }
1117
- // Goes through the directory, and adds each file it finds recursively
1118
- _addFilesFromDirectory(directory, path) {
1119
- let dirReader = directory.createReader();
1120
- let errorHandler = (error)=>$3ed269f2f0fb224b$var$__guardMethod__(console, "log", (o)=>o.log(error)
1121
- )
1122
- ;
1123
- var readEntries = ()=>{
1124
- return dirReader.readEntries((entries)=>{
1125
- if (entries.length > 0) {
1126
- for (let entry of entries){
1127
- if (entry.isFile) entry.file((file)=>{
1128
- if (this.options.ignoreHiddenFiles && file.name.substring(0, 1) === ".") return;
1129
- file.fullPath = `${path}/${file.name}`;
1130
- return this.addFile(file);
1131
- });
1132
- else if (entry.isDirectory) this._addFilesFromDirectory(entry, `${path}/${entry.name}`);
1133
- }
1134
- // Recursively call readEntries() again, since browser only handle
1135
- // the first 100 entries.
1136
- // See: https://developer.mozilla.org/en-US/docs/Web/API/DirectoryReader#readEntries
1137
- readEntries();
1138
- }
1139
- return null;
1140
- }, errorHandler);
1141
- };
1142
- return readEntries();
1143
- }
1144
- // If `done()` is called without argument the file is accepted
1145
- // If you call it with an error message, the file is rejected
1146
- // (This allows for asynchronous validation)
1147
- //
1148
- // This function checks the filesize, and if the file.type passes the
1149
- // `acceptedFiles` check.
1150
- accept(file, done) {
1151
- if (this.options.maxFilesize && file.size > this.options.maxFilesize * 1048576) done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize));
1152
- else if (!$3ed269f2f0fb224b$export$2e2bcd8739ae039.isValidFile(file, this.options.acceptedFiles)) done(this.options.dictInvalidFileType);
1153
- else if (this.options.maxFiles != null && this.getAcceptedFiles().length >= this.options.maxFiles) {
1154
- done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles));
1155
- this.emit("maxfilesexceeded", file);
1156
- } else this.options.accept.call(this, file, done);
1157
- }
1158
- addFile(file) {
1159
- file.upload = {
1160
- uuid: $3ed269f2f0fb224b$export$2e2bcd8739ae039.uuidv4(),
1161
- progress: 0,
1162
- // Setting the total upload size to file.size for the beginning
1163
- // It's actual different than the size to be transmitted.
1164
- total: file.size,
1165
- bytesSent: 0,
1166
- filename: this._renameFile(file)
1167
- };
1168
- this.files.push(file);
1169
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED;
1170
- this.emit("addedfile", file);
1171
- this._enqueueThumbnail(file);
1172
- this.accept(file, (error)=>{
1173
- if (error) {
1174
- file.accepted = false;
1175
- this._errorProcessing([
1176
- file
1177
- ], error); // Will set the file.status
1178
- } else {
1179
- file.accepted = true;
1180
- if (this.options.autoQueue) this.enqueueFile(file);
1181
- // Will set .accepted = true
1182
- }
1183
- this._updateMaxFilesReachedClass();
1184
- });
1185
- }
1186
- // Wrapper for enqueueFile
1187
- enqueueFiles(files) {
1188
- for (let file of files)this.enqueueFile(file);
1189
- return null;
1190
- }
1191
- enqueueFile(file) {
1192
- if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED && file.accepted === true) {
1193
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED;
1194
- if (this.options.autoProcessQueue) return setTimeout(()=>this.processQueue()
1195
- , 0); // Deferring the call
1196
- } else throw new Error("This file can't be queued because it has already been processed or was rejected.");
1197
- }
1198
- _enqueueThumbnail(file) {
1199
- if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1048576) {
1200
- this._thumbnailQueue.push(file);
1201
- return setTimeout(()=>this._processThumbnailQueue()
1202
- , 0); // Deferring the call
1203
- }
1204
- }
1205
- _processThumbnailQueue() {
1206
- if (this._processingThumbnail || this._thumbnailQueue.length === 0) return;
1207
- this._processingThumbnail = true;
1208
- let file = this._thumbnailQueue.shift();
1209
- return this.createThumbnail(file, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, true, (dataUrl)=>{
1210
- this.emit("thumbnail", file, dataUrl);
1211
- this._processingThumbnail = false;
1212
- return this._processThumbnailQueue();
1213
- });
1214
- }
1215
- // Can be called by the user to remove a file
1216
- removeFile(file) {
1217
- if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) this.cancelUpload(file);
1218
- this.files = $3ed269f2f0fb224b$var$without(this.files, file);
1219
- this.emit("removedfile", file);
1220
- if (this.files.length === 0) return this.emit("reset");
1221
- }
1222
- // Removes all files that aren't currently processed from the list
1223
- removeAllFiles(cancelIfNecessary) {
1224
- // Create a copy of files since removeFile() changes the @files array.
1225
- if (cancelIfNecessary == null) cancelIfNecessary = false;
1226
- for (let file of this.files.slice())if (file.status !== $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING || cancelIfNecessary) this.removeFile(file);
1227
- return null;
1228
- }
1229
- // Resizes an image before it gets sent to the server. This function is the default behavior of
1230
- // `options.transformFile` if `resizeWidth` or `resizeHeight` are set. The callback is invoked with
1231
- // the resized blob.
1232
- resizeImage(file, width, height, resizeMethod, callback) {
1233
- return this.createThumbnail(file, width, height, resizeMethod, true, (dataUrl, canvas)=>{
1234
- if (canvas == null) // The image has not been resized
1235
- return callback(file);
1236
- else {
1237
- let { resizeMimeType: resizeMimeType } = this.options;
1238
- if (resizeMimeType == null) resizeMimeType = file.type;
1239
- let resizedDataURL = canvas.toDataURL(resizeMimeType, this.options.resizeQuality);
1240
- if (resizeMimeType === "image/jpeg" || resizeMimeType === "image/jpg") // Now add the original EXIF information
1241
- resizedDataURL = $3ed269f2f0fb224b$var$ExifRestore.restore(file.dataURL, resizedDataURL);
1242
- return callback($3ed269f2f0fb224b$export$2e2bcd8739ae039.dataURItoBlob(resizedDataURL));
1243
- }
1244
- });
1245
- }
1246
- createThumbnail(file, width, height, resizeMethod, fixOrientation, callback) {
1247
- let fileReader = new FileReader();
1248
- fileReader.onload = ()=>{
1249
- file.dataURL = fileReader.result;
1250
- // Don't bother creating a thumbnail for SVG images since they're vector
1251
- if (file.type === "image/svg+xml") {
1252
- if (callback != null) callback(fileReader.result);
1253
- return;
1254
- }
1255
- this.createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback);
1256
- };
1257
- fileReader.readAsDataURL(file);
1258
- }
1259
- // `mockFile` needs to have these attributes:
1260
- //
1261
- // { name: 'name', size: 12345, imageUrl: '' }
1262
- //
1263
- // `callback` will be invoked when the image has been downloaded and displayed.
1264
- // `crossOrigin` will be added to the `img` tag when accessing the file.
1265
- displayExistingFile(mockFile, imageUrl, callback, crossOrigin, resizeThumbnail = true) {
1266
- this.emit("addedfile", mockFile);
1267
- this.emit("complete", mockFile);
1268
- if (!resizeThumbnail) {
1269
- this.emit("thumbnail", mockFile, imageUrl);
1270
- if (callback) callback();
1271
- } else {
1272
- let onDone = (thumbnail)=>{
1273
- this.emit("thumbnail", mockFile, thumbnail);
1274
- if (callback) callback();
1275
- };
1276
- mockFile.dataURL = imageUrl;
1277
- this.createThumbnailFromUrl(mockFile, this.options.thumbnailWidth, this.options.thumbnailHeight, this.options.thumbnailMethod, this.options.fixOrientation, onDone, crossOrigin);
1278
- }
1279
- }
1280
- createThumbnailFromUrl(file, width, height, resizeMethod, fixOrientation, callback, crossOrigin) {
1281
- // Not using `new Image` here because of a bug in latest Chrome versions.
1282
- // See https://github.com/enyo/dropzone/pull/226
1283
- let img = document.createElement("img");
1284
- if (crossOrigin) img.crossOrigin = crossOrigin;
1285
- // fixOrientation is not needed anymore with browsers handling imageOrientation
1286
- fixOrientation = getComputedStyle(document.body)["imageOrientation"] == "from-image" ? false : fixOrientation;
1287
- img.onload = ()=>{
1288
- let loadExif = (callback)=>callback(1)
1289
- ;
1290
- if (typeof EXIF !== "undefined" && EXIF !== null && fixOrientation) loadExif = (callback)=>EXIF.getData(img, function() {
1291
- return callback(EXIF.getTag(this, "Orientation"));
1292
- })
1293
- ;
1294
- return loadExif((orientation)=>{
1295
- file.width = img.width;
1296
- file.height = img.height;
1297
- let resizeInfo = this.options.resize.call(this, file, width, height, resizeMethod);
1298
- let canvas = document.createElement("canvas");
1299
- let ctx = canvas.getContext("2d");
1300
- canvas.width = resizeInfo.trgWidth;
1301
- canvas.height = resizeInfo.trgHeight;
1302
- if (orientation > 4) {
1303
- canvas.width = resizeInfo.trgHeight;
1304
- canvas.height = resizeInfo.trgWidth;
1305
- }
1306
- switch(orientation){
1307
- case 2:
1308
- // horizontal flip
1309
- ctx.translate(canvas.width, 0);
1310
- ctx.scale(-1, 1);
1311
- break;
1312
- case 3:
1313
- // 180° rotate left
1314
- ctx.translate(canvas.width, canvas.height);
1315
- ctx.rotate(Math.PI);
1316
- break;
1317
- case 4:
1318
- // vertical flip
1319
- ctx.translate(0, canvas.height);
1320
- ctx.scale(1, -1);
1321
- break;
1322
- case 5:
1323
- // vertical flip + 90 rotate right
1324
- ctx.rotate(0.5 * Math.PI);
1325
- ctx.scale(1, -1);
1326
- break;
1327
- case 6:
1328
- // 90° rotate right
1329
- ctx.rotate(0.5 * Math.PI);
1330
- ctx.translate(0, -canvas.width);
1331
- break;
1332
- case 7:
1333
- // horizontal flip + 90 rotate right
1334
- ctx.rotate(0.5 * Math.PI);
1335
- ctx.translate(canvas.height, -canvas.width);
1336
- ctx.scale(-1, 1);
1337
- break;
1338
- case 8:
1339
- // 90° rotate left
1340
- ctx.rotate(-0.5 * Math.PI);
1341
- ctx.translate(-canvas.height, 0);
1342
- break;
1343
- }
1344
- // This is a bugfix for iOS' scaling bug.
1345
- $3ed269f2f0fb224b$var$drawImageIOSFix(ctx, img, resizeInfo.srcX != null ? resizeInfo.srcX : 0, resizeInfo.srcY != null ? resizeInfo.srcY : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, resizeInfo.trgX != null ? resizeInfo.trgX : 0, resizeInfo.trgY != null ? resizeInfo.trgY : 0, resizeInfo.trgWidth, resizeInfo.trgHeight);
1346
- let thumbnail = canvas.toDataURL("image/png");
1347
- if (callback != null) return callback(thumbnail, canvas);
1348
- });
1349
- };
1350
- if (callback != null) img.onerror = callback;
1351
- return img.src = file.dataURL;
1352
- }
1353
- // Goes through the queue and processes files if there aren't too many already.
1354
- processQueue() {
1355
- let { parallelUploads: parallelUploads } = this.options;
1356
- let processingLength = this.getUploadingFiles().length;
1357
- let i = processingLength;
1358
- // There are already at least as many files uploading than should be
1359
- if (processingLength >= parallelUploads) return;
1360
- let queuedFiles = this.getQueuedFiles();
1361
- if (!(queuedFiles.length > 0)) return;
1362
- if (this.options.uploadMultiple) // The files should be uploaded in one request
1363
- return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength));
1364
- else while(i < parallelUploads){
1365
- if (!queuedFiles.length) return;
1366
- // Nothing left to process
1367
- this.processFile(queuedFiles.shift());
1368
- i++;
1369
- }
1370
- }
1371
- // Wrapper for `processFiles`
1372
- processFile(file) {
1373
- return this.processFiles([
1374
- file
1375
- ]);
1376
- }
1377
- // Loads the file, then calls finishedLoading()
1378
- processFiles(files) {
1379
- for (let file of files){
1380
- file.processing = true; // Backwards compatibility
1381
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING;
1382
- this.emit("processing", file);
1383
- }
1384
- if (this.options.uploadMultiple) this.emit("processingmultiple", files);
1385
- return this.uploadFiles(files);
1386
- }
1387
- _getFilesWithXhr(xhr) {
1388
- return this.files.filter((file)=>file.xhr === xhr
1389
- ).map((file)=>file
1390
- );
1391
- }
1392
- // Cancels the file upload and sets the status to CANCELED
1393
- // **if** the file is actually being uploaded.
1394
- // If it's still in the queue, the file is being removed from it and the status
1395
- // set to CANCELED.
1396
- cancelUpload(file) {
1397
- if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING) {
1398
- let groupedFiles = this._getFilesWithXhr(file.xhr);
1399
- for (let groupedFile of groupedFiles)groupedFile.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED;
1400
- if (typeof file.xhr !== "undefined") file.xhr.abort();
1401
- for (let groupedFile1 of groupedFiles)this.emit("canceled", groupedFile1);
1402
- if (this.options.uploadMultiple) this.emit("canceledmultiple", groupedFiles);
1403
- } else if (file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED || file.status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED) {
1404
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED;
1405
- this.emit("canceled", file);
1406
- if (this.options.uploadMultiple) this.emit("canceledmultiple", [
1407
- file
1408
- ]);
1409
- }
1410
- if (this.options.autoProcessQueue) return this.processQueue();
1411
- }
1412
- resolveOption(option, ...args) {
1413
- if (typeof option === "function") return option.apply(this, args);
1414
- return option;
1415
- }
1416
- uploadFile(file) {
1417
- return this.uploadFiles([
1418
- file
1419
- ]);
1420
- }
1421
- uploadFiles(files) {
1422
- this._transformFiles(files, (transformedFiles)=>{
1423
- if (this.options.chunking) {
1424
- // Chunking is not allowed to be used with `uploadMultiple` so we know
1425
- // that there is only __one__file.
1426
- let transformedFile = transformedFiles[0];
1427
- files[0].upload.chunked = this.options.chunking && (this.options.forceChunking || transformedFile.size > this.options.chunkSize);
1428
- files[0].upload.totalChunkCount = Math.ceil(transformedFile.size / this.options.chunkSize);
1429
- }
1430
- if (files[0].upload.chunked) {
1431
- // This file should be sent in chunks!
1432
- // If the chunking option is set, we **know** that there can only be **one** file, since
1433
- // uploadMultiple is not allowed with this option.
1434
- let file = files[0];
1435
- let transformedFile = transformedFiles[0];
1436
- file.upload.chunks = [];
1437
- let handleNextChunk = ()=>{
1438
- let chunkIndex = 0;
1439
- // Find the next item in file.upload.chunks that is not defined yet.
1440
- while(file.upload.chunks[chunkIndex] !== undefined)chunkIndex++;
1441
- // This means, that all chunks have already been started.
1442
- if (chunkIndex >= file.upload.totalChunkCount) return;
1443
- let start = chunkIndex * this.options.chunkSize;
1444
- let end = Math.min(start + this.options.chunkSize, transformedFile.size);
1445
- let dataBlock = {
1446
- name: this._getParamName(0),
1447
- data: transformedFile.webkitSlice ? transformedFile.webkitSlice(start, end) : transformedFile.slice(start, end),
1448
- filename: file.upload.filename,
1449
- chunkIndex: chunkIndex
1450
- };
1451
- file.upload.chunks[chunkIndex] = {
1452
- file: file,
1453
- index: chunkIndex,
1454
- dataBlock: dataBlock,
1455
- status: $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING,
1456
- progress: 0,
1457
- retries: 0
1458
- };
1459
- this._uploadData(files, [
1460
- dataBlock
1461
- ]);
1462
- };
1463
- file.upload.finishedChunkUpload = (chunk, response)=>{
1464
- let allFinished = true;
1465
- chunk.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS;
1466
- // Clear the data from the chunk
1467
- chunk.dataBlock = null;
1468
- chunk.response = chunk.xhr.responseText;
1469
- chunk.responseHeaders = chunk.xhr.getAllResponseHeaders();
1470
- // Leaving this reference to xhr will cause memory leaks.
1471
- chunk.xhr = null;
1472
- for(let i = 0; i < file.upload.totalChunkCount; i++){
1473
- if (file.upload.chunks[i] === undefined) return handleNextChunk();
1474
- if (file.upload.chunks[i].status !== $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS) allFinished = false;
1475
- }
1476
- if (allFinished) this.options.chunksUploaded(file, ()=>{
1477
- this._finished(files, response, null);
1478
- });
1479
- };
1480
- if (this.options.parallelChunkUploads) for(let i = 0; i < file.upload.totalChunkCount; i++)handleNextChunk();
1481
- else handleNextChunk();
1482
- } else {
1483
- let dataBlocks = [];
1484
- for(let i = 0; i < files.length; i++)dataBlocks[i] = {
1485
- name: this._getParamName(i),
1486
- data: transformedFiles[i],
1487
- filename: files[i].upload.filename
1488
- };
1489
- this._uploadData(files, dataBlocks);
1490
- }
1491
- });
1492
- }
1493
- /// Returns the right chunk for given file and xhr
1494
- _getChunk(file, xhr) {
1495
- for(let i = 0; i < file.upload.totalChunkCount; i++){
1496
- if (file.upload.chunks[i] !== undefined && file.upload.chunks[i].xhr === xhr) return file.upload.chunks[i];
1497
- }
1498
- }
1499
- // This function actually uploads the file(s) to the server.
1500
- //
1501
- // If dataBlocks contains the actual data to upload (meaning, that this could
1502
- // either be transformed files, or individual chunks for chunked upload) then
1503
- // they will be used for the actual data to upload.
1504
- _uploadData(files, dataBlocks) {
1505
- let xhr = new XMLHttpRequest();
1506
- // Put the xhr object in the file objects to be able to reference it later.
1507
- for (let file of files)file.xhr = xhr;
1508
- if (files[0].upload.chunked) // Put the xhr object in the right chunk object, so it can be associated
1509
- // later, and found with _getChunk.
1510
- files[0].upload.chunks[dataBlocks[0].chunkIndex].xhr = xhr;
1511
- let method = this.resolveOption(this.options.method, files, dataBlocks);
1512
- let url = this.resolveOption(this.options.url, files, dataBlocks);
1513
- xhr.open(method, url, true);
1514
- // Setting the timeout after open because of IE11 issue: https://gitlab.com/meno/dropzone/issues/8
1515
- let timeout = this.resolveOption(this.options.timeout, files);
1516
- if (timeout) xhr.timeout = this.resolveOption(this.options.timeout, files);
1517
- // Has to be after `.open()`. See https://github.com/enyo/dropzone/issues/179
1518
- xhr.withCredentials = !!this.options.withCredentials;
1519
- xhr.onload = (e)=>{
1520
- this._finishedUploading(files, xhr, e);
1521
- };
1522
- xhr.ontimeout = ()=>{
1523
- this._handleUploadError(files, xhr, `Request timedout after ${this.options.timeout / 1000} seconds`);
1524
- };
1525
- xhr.onerror = ()=>{
1526
- this._handleUploadError(files, xhr);
1527
- };
1528
- // Some browsers do not have the .upload property
1529
- let progressObj = xhr.upload != null ? xhr.upload : xhr;
1530
- progressObj.onprogress = (e)=>this._updateFilesUploadProgress(files, xhr, e)
1531
- ;
1532
- let headers = this.options.defaultHeaders ? {
1533
- Accept: "application/json",
1534
- "Cache-Control": "no-cache",
1535
- "X-Requested-With": "XMLHttpRequest"
1536
- } : {
1537
- };
1538
- if (this.options.binaryBody) headers["Content-Type"] = files[0].type;
1539
- if (this.options.headers) objectExtend(headers, this.options.headers);
1540
- for(let headerName in headers){
1541
- let headerValue = headers[headerName];
1542
- if (headerValue) xhr.setRequestHeader(headerName, headerValue);
1543
- }
1544
- if (this.options.binaryBody) {
1545
- // Since the file is going to be sent as binary body, it doesn't make
1546
- // any sense to generate `FormData` for it.
1547
- for (let file of files)this.emit("sending", file, xhr);
1548
- if (this.options.uploadMultiple) this.emit("sendingmultiple", files, xhr);
1549
- this.submitRequest(xhr, null, files);
1550
- } else {
1551
- let formData = new FormData();
1552
- // Adding all @options parameters
1553
- if (this.options.params) {
1554
- let additionalParams = this.options.params;
1555
- if (typeof additionalParams === "function") additionalParams = additionalParams.call(this, files, xhr, files[0].upload.chunked ? this._getChunk(files[0], xhr) : null);
1556
- for(let key in additionalParams){
1557
- let value = additionalParams[key];
1558
- if (Array.isArray(value)) // The additional parameter contains an array,
1559
- // so lets iterate over it to attach each value
1560
- // individually.
1561
- for(let i = 0; i < value.length; i++)formData.append(key, value[i]);
1562
- else formData.append(key, value);
1563
- }
1564
- }
1565
- // Let the user add additional data if necessary
1566
- for (let file of files)this.emit("sending", file, xhr, formData);
1567
- if (this.options.uploadMultiple) this.emit("sendingmultiple", files, xhr, formData);
1568
- this._addFormElementData(formData);
1569
- // Finally add the files
1570
- // Has to be last because some servers (eg: S3) expect the file to be the last parameter
1571
- for(let i = 0; i < dataBlocks.length; i++){
1572
- let dataBlock = dataBlocks[i];
1573
- formData.append(dataBlock.name, dataBlock.data, dataBlock.filename);
1574
- }
1575
- this.submitRequest(xhr, formData, files);
1576
- }
1577
- }
1578
- // Transforms all files with this.options.transformFile and invokes done with the transformed files when done.
1579
- _transformFiles(files, done) {
1580
- let transformedFiles = [];
1581
- // Clumsy way of handling asynchronous calls, until I get to add a proper Future library.
1582
- let doneCounter = 0;
1583
- for(let i = 0; i < files.length; i++)this.options.transformFile.call(this, files[i], (transformedFile)=>{
1584
- transformedFiles[i] = transformedFile;
1585
- if (++doneCounter === files.length) done(transformedFiles);
1586
- });
1587
- }
1588
- // Takes care of adding other input elements of the form to the AJAX request
1589
- _addFormElementData(formData) {
1590
- // Take care of other input elements
1591
- if (this.element.tagName === "FORM") for (let input of this.element.querySelectorAll("input, textarea, select, button")){
1592
- let inputName = input.getAttribute("name");
1593
- let inputType = input.getAttribute("type");
1594
- if (inputType) inputType = inputType.toLowerCase();
1595
- // If the input doesn't have a name, we can't use it.
1596
- if (typeof inputName === "undefined" || inputName === null) continue;
1597
- if (input.tagName === "SELECT" && input.hasAttribute("multiple")) {
1598
- // Possibly multiple values
1599
- for (let option of input.options)if (option.selected) formData.append(inputName, option.value);
1600
- } else if (!inputType || inputType !== "checkbox" && inputType !== "radio" || input.checked) formData.append(inputName, input.value);
1601
- }
1602
- }
1603
- // Invoked when there is new progress information about given files.
1604
- // If e is not provided, it is assumed that the upload is finished.
1605
- _updateFilesUploadProgress(files, xhr, e) {
1606
- if (!files[0].upload.chunked) // Handle file uploads without chunking
1607
- for (let file of files){
1608
- if (file.upload.total && file.upload.bytesSent && file.upload.bytesSent == file.upload.total) continue;
1609
- if (e) {
1610
- file.upload.progress = 100 * e.loaded / e.total;
1611
- file.upload.total = e.total;
1612
- file.upload.bytesSent = e.loaded;
1613
- } else {
1614
- // No event, so we're at 100%
1615
- file.upload.progress = 100;
1616
- file.upload.bytesSent = file.upload.total;
1617
- }
1618
- this.emit("uploadprogress", file, file.upload.progress, file.upload.bytesSent);
1619
- }
1620
- else {
1621
- // Handle chunked file uploads
1622
- // Chunked upload is not compatible with uploading multiple files in one
1623
- // request, so we know there's only one file.
1624
- let file = files[0];
1625
- // Since this is a chunked upload, we need to update the appropriate chunk
1626
- // progress.
1627
- let chunk = this._getChunk(file, xhr);
1628
- if (e) {
1629
- chunk.progress = 100 * e.loaded / e.total;
1630
- chunk.total = e.total;
1631
- chunk.bytesSent = e.loaded;
1632
- } else {
1633
- // No event, so we're at 100%
1634
- chunk.progress = 100;
1635
- chunk.bytesSent = chunk.total;
1636
- }
1637
- // Now tally the *file* upload progress from its individual chunks
1638
- file.upload.progress = 0;
1639
- file.upload.total = 0;
1640
- file.upload.bytesSent = 0;
1641
- for(let i = 0; i < file.upload.totalChunkCount; i++)if (file.upload.chunks[i] && typeof file.upload.chunks[i].progress !== "undefined") {
1642
- file.upload.progress += file.upload.chunks[i].progress;
1643
- file.upload.total += file.upload.chunks[i].total;
1644
- file.upload.bytesSent += file.upload.chunks[i].bytesSent;
1645
- }
1646
- // Since the process is a percentage, we need to divide by the amount of
1647
- // chunks we've used.
1648
- file.upload.progress = file.upload.progress / file.upload.totalChunkCount;
1649
- this.emit("uploadprogress", file, file.upload.progress, file.upload.bytesSent);
1650
- }
1651
- }
1652
- _finishedUploading(files, xhr, e) {
1653
- let response;
1654
- if (files[0].status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED) return;
1655
- if (xhr.readyState !== 4) return;
1656
- if (xhr.responseType !== "arraybuffer" && xhr.responseType !== "blob") {
1657
- response = xhr.responseText;
1658
- if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) try {
1659
- response = JSON.parse(response);
1660
- } catch (error) {
1661
- e = error;
1662
- response = "Invalid JSON response from server.";
1663
- }
1664
- }
1665
- this._updateFilesUploadProgress(files, xhr);
1666
- if (!(200 <= xhr.status && xhr.status < 300)) this._handleUploadError(files, xhr, response);
1667
- else if (files[0].upload.chunked) files[0].upload.finishedChunkUpload(this._getChunk(files[0], xhr), response);
1668
- else this._finished(files, response, e);
1669
- }
1670
- _handleUploadError(files, xhr, response) {
1671
- if (files[0].status === $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED) return;
1672
- if (files[0].upload.chunked && this.options.retryChunks) {
1673
- let chunk = this._getChunk(files[0], xhr);
1674
- if ((chunk.retries++) < this.options.retryChunksLimit) {
1675
- this._uploadData(files, [
1676
- chunk.dataBlock
1677
- ]);
1678
- return;
1679
- } else console.warn("Retried this chunk too often. Giving up.");
1680
- }
1681
- this._errorProcessing(files, response || this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr);
1682
- }
1683
- submitRequest(xhr, formData, files) {
1684
- if (xhr.readyState != 1) {
1685
- console.warn("Cannot send this request because the XMLHttpRequest.readyState is not OPENED.");
1686
- return;
1687
- }
1688
- if (this.options.binaryBody) {
1689
- if (files[0].upload.chunked) {
1690
- const chunk = this._getChunk(files[0], xhr);
1691
- xhr.send(chunk.dataBlock.data);
1692
- } else xhr.send(files[0]);
1693
- } else xhr.send(formData);
1694
- }
1695
- // Called internally when processing is finished.
1696
- // Individual callbacks have to be called in the appropriate sections.
1697
- _finished(files, responseText, e) {
1698
- for (let file of files){
1699
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS;
1700
- this.emit("success", file, responseText, e);
1701
- this.emit("complete", file);
1702
- }
1703
- if (this.options.uploadMultiple) {
1704
- this.emit("successmultiple", files, responseText, e);
1705
- this.emit("completemultiple", files);
1706
- }
1707
- if (this.options.autoProcessQueue) return this.processQueue();
1708
- }
1709
- // Called internally when processing is finished.
1710
- // Individual callbacks have to be called in the appropriate sections.
1711
- _errorProcessing(files, message, xhr) {
1712
- for (let file of files){
1713
- file.status = $3ed269f2f0fb224b$export$2e2bcd8739ae039.ERROR;
1714
- this.emit("error", file, message, xhr);
1715
- this.emit("complete", file);
1716
- }
1717
- if (this.options.uploadMultiple) {
1718
- this.emit("errormultiple", files, message, xhr);
1719
- this.emit("completemultiple", files);
1720
- }
1721
- if (this.options.autoProcessQueue) return this.processQueue();
1722
- }
1723
- static uuidv4() {
1724
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1725
- let r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
1726
- return v.toString(16);
1727
- });
1728
- }
1729
- constructor(el, options){
1730
- super();
1731
- let fallback, left;
1732
- this.element = el;
1733
- this.clickableElements = [];
1734
- this.listeners = [];
1735
- this.files = []; // All files
1736
- if (typeof this.element === "string") this.element = document.querySelector(this.element);
1737
- // Not checking if instance of HTMLElement or Element since IE9 is extremely weird.
1738
- if (!this.element || this.element.nodeType == null) throw new Error("Invalid dropzone element.");
1739
- if (this.element.dropzone) throw new Error("Dropzone already attached.");
1740
- // Now add this dropzone to the instances.
1741
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances.push(this);
1742
- // Put the dropzone inside the element itself.
1743
- this.element.dropzone = this;
1744
- let elementOptions = (left = $3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement(this.element)) != null ? left : {
1745
- };
1746
- this.options = objectExtend(true, {
1747
- }, $4ca367182776f80b$export$2e2bcd8739ae039, elementOptions, options != null ? options : {
1748
- });
1749
- this.options.previewTemplate = this.options.previewTemplate.replace(/\n*/g, "");
1750
- // If the browser failed, just call the fallback and leave
1751
- if (this.options.forceFallback || !$3ed269f2f0fb224b$export$2e2bcd8739ae039.isBrowserSupported()) return this.options.fallback.call(this);
1752
- // @options.url = @element.getAttribute "action" unless @options.url?
1753
- if (this.options.url == null) this.options.url = this.element.getAttribute("action");
1754
- if (!this.options.url) throw new Error("No URL provided.");
1755
- if (this.options.acceptedFiles && this.options.acceptedMimeTypes) throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");
1756
- if (this.options.uploadMultiple && this.options.chunking) throw new Error("You cannot set both: uploadMultiple and chunking.");
1757
- if (this.options.binaryBody && this.options.uploadMultiple) throw new Error("You cannot set both: binaryBody and uploadMultiple.");
1758
- // Backwards compatibility
1759
- if (this.options.acceptedMimeTypes) {
1760
- this.options.acceptedFiles = this.options.acceptedMimeTypes;
1761
- delete this.options.acceptedMimeTypes;
1762
- }
1763
- // Backwards compatibility
1764
- if (this.options.renameFilename != null) this.options.renameFile = (file)=>this.options.renameFilename.call(this, file.name, file)
1765
- ;
1766
- if (typeof this.options.method === "string") this.options.method = this.options.method.toUpperCase();
1767
- if ((fallback = this.getExistingFallback()) && fallback.parentNode) // Remove the fallback
1768
- fallback.parentNode.removeChild(fallback);
1769
- // Display previews in the previewsContainer element or the Dropzone element unless explicitly set to false
1770
- if (this.options.previewsContainer !== false) {
1771
- if (this.options.previewsContainer) this.previewsContainer = $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement(this.options.previewsContainer, "previewsContainer");
1772
- else this.previewsContainer = this.element;
1773
- }
1774
- if (this.options.clickable) {
1775
- if (this.options.clickable === true) this.clickableElements = [
1776
- this.element
1777
- ];
1778
- else this.clickableElements = $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElements(this.options.clickable, "clickable");
1779
- }
1780
- this.init();
1781
- }
1782
- }
1783
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.initClass();
1784
- // This is a map of options for your different dropzones. Add configurations
1785
- // to this object for your different dropzone elemens.
1786
- //
1787
- // Example:
1788
- //
1789
- // Dropzone.options.myDropzoneElementId = { maxFilesize: 1 };
1790
- //
1791
- // And in html:
1792
- //
1793
- // <form action="/upload" id="my-dropzone-element-id" class="dropzone"></form>
1794
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.options = {
1795
- };
1796
- // Returns the options for an element or undefined if none available.
1797
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement = function(element) {
1798
- // Get the `Dropzone.options.elementId` for this element if it exists
1799
- if (element.getAttribute("id")) return $3ed269f2f0fb224b$export$2e2bcd8739ae039.options[$3ed269f2f0fb224b$var$camelize(element.getAttribute("id"))];
1800
- else return undefined;
1801
- };
1802
- // Holds a list of all dropzone instances
1803
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.instances = [];
1804
- // Returns the dropzone for given element if any
1805
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.forElement = function(element) {
1806
- if (typeof element === "string") element = document.querySelector(element);
1807
- if ((element != null ? element.dropzone : undefined) == null) throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");
1808
- return element.dropzone;
1809
- };
1810
- // Looks for all .dropzone elements and creates a dropzone for them
1811
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.discover = function() {
1812
- let dropzones;
1813
- if (document.querySelectorAll) dropzones = document.querySelectorAll(".dropzone");
1814
- else {
1815
- dropzones = [];
1816
- // IE :(
1817
- let checkElements = (elements)=>(()=>{
1818
- let result = [];
1819
- for (let el of elements)if (/(^| )dropzone($| )/.test(el.className)) result.push(dropzones.push(el));
1820
- else result.push(undefined);
1821
- return result;
1822
- })()
1823
- ;
1824
- checkElements(document.getElementsByTagName("div"));
1825
- checkElements(document.getElementsByTagName("form"));
1826
- }
1827
- return (()=>{
1828
- let result = [];
1829
- for (let dropzone of dropzones)// Create a dropzone unless auto discover has been disabled for specific element
1830
- if ($3ed269f2f0fb224b$export$2e2bcd8739ae039.optionsForElement(dropzone) !== false) result.push(new $3ed269f2f0fb224b$export$2e2bcd8739ae039(dropzone));
1831
- else result.push(undefined);
1832
- return result;
1833
- })();
1834
- };
1835
- // Some browsers support drag and drog functionality, but not correctly.
1836
- //
1837
- // So I created a blocklist of userAgents. Yes, yes. Browser sniffing, I know.
1838
- // But what to do when browsers *theoretically* support an API, but crash
1839
- // when using it.
1840
- //
1841
- // This is a list of regular expressions tested against navigator.userAgent
1842
- //
1843
- // ** It should only be used on browser that *do* support the API, but
1844
- // incorrectly **
1845
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers = [
1846
- // The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
1847
- /opera.*(Macintosh|Windows Phone).*version\/12/i,
1848
- ];
1849
- // Checks if the browser is supported
1850
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.isBrowserSupported = function() {
1851
- let capableBrowser = true;
1852
- if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) {
1853
- if (!("classList" in document.createElement("a"))) capableBrowser = false;
1854
- else {
1855
- if ($3ed269f2f0fb224b$export$2e2bcd8739ae039.blacklistedBrowsers !== undefined) // Since this has been renamed, this makes sure we don't break older
1856
- // configuration.
1857
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers = $3ed269f2f0fb224b$export$2e2bcd8739ae039.blacklistedBrowsers;
1858
- // The browser supports the API, but may be blocked.
1859
- for (let regex of $3ed269f2f0fb224b$export$2e2bcd8739ae039.blockedBrowsers)if (regex.test(navigator.userAgent)) {
1860
- capableBrowser = false;
1861
- continue;
1862
- }
1863
- }
1864
- } else capableBrowser = false;
1865
- return capableBrowser;
1866
- };
1867
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.dataURItoBlob = function(dataURI) {
1868
- // convert base64 to raw binary data held in a string
1869
- // doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
1870
- let byteString = atob(dataURI.split(",")[1]);
1871
- // separate out the mime component
1872
- let mimeString = dataURI.split(",")[0].split(":")[1].split(";")[0];
1873
- // write the bytes of the string to an ArrayBuffer
1874
- let ab = new ArrayBuffer(byteString.length);
1875
- let ia = new Uint8Array(ab);
1876
- for(let i = 0, end = byteString.length, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--)ia[i] = byteString.charCodeAt(i);
1877
- // write the ArrayBuffer to a blob
1878
- return new Blob([
1879
- ab
1880
- ], {
1881
- type: mimeString
1882
- });
1883
- };
1884
- // Returns an array without the rejected item
1885
- const $3ed269f2f0fb224b$var$without = (list, rejectedItem)=>list.filter((item)=>item !== rejectedItem
1886
- ).map((item)=>item
1887
- )
1888
- ;
1889
- // abc-def_ghi -> abcDefGhi
1890
- const $3ed269f2f0fb224b$var$camelize = (str)=>str.replace(/[\-_](\w)/g, (match)=>match.charAt(1).toUpperCase()
1891
- )
1892
- ;
1893
- // Creates an element from string
1894
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.createElement = function(string) {
1895
- let div = document.createElement("div");
1896
- div.innerHTML = string;
1897
- return div.childNodes[0];
1898
- };
1899
- // Tests if given element is inside (or simply is) the container
1900
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.elementInside = function(element, container) {
1901
- if (element === container) return true;
1902
- // Coffeescript doesn't support do/while loops
1903
- while(element = element.parentNode){
1904
- if (element === container) return true;
1905
- }
1906
- return false;
1907
- };
1908
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElement = function(el, name) {
1909
- let element;
1910
- if (typeof el === "string") element = document.querySelector(el);
1911
- else if (el.nodeType != null) element = el;
1912
- if (element == null) throw new Error(`Invalid \`${name}\` option provided. Please provide a CSS selector or a plain HTML element.`);
1913
- return element;
1914
- };
1915
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.getElements = function(els, name) {
1916
- let el, elements;
1917
- if (els instanceof Array) {
1918
- elements = [];
1919
- try {
1920
- for (el of els)elements.push(this.getElement(el, name));
1921
- } catch (e) {
1922
- elements = null;
1923
- }
1924
- } else if (typeof els === "string") {
1925
- elements = [];
1926
- for (el of document.querySelectorAll(els))elements.push(el);
1927
- } else if (els.nodeType != null) elements = [
1928
- els
1929
- ];
1930
- if (elements == null || !elements.length) throw new Error(`Invalid \`${name}\` option provided. Please provide a CSS selector, a plain HTML element or a list of those.`);
1931
- return elements;
1932
- };
1933
- // Asks the user the question and calls accepted or rejected accordingly
1934
- //
1935
- // The default implementation just uses `window.confirm` and then calls the
1936
- // appropriate callback.
1937
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.confirm = function(question, accepted, rejected) {
1938
- if (window.confirm(question)) return accepted();
1939
- else if (rejected != null) return rejected();
1940
- };
1941
- // Validates the mime type like this:
1942
- //
1943
- // https://developer.mozilla.org/en-US/docs/HTML/Element/input#attr-accept
1944
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.isValidFile = function(file, acceptedFiles) {
1945
- if (!acceptedFiles) return true;
1946
- // If there are no accepted mime types, it's OK
1947
- acceptedFiles = acceptedFiles.split(",");
1948
- let mimeType = file.type;
1949
- let baseMimeType = mimeType.replace(/\/.*$/, "");
1950
- for (let validType of acceptedFiles){
1951
- validType = validType.trim();
1952
- if (validType.charAt(0) === ".") {
1953
- if (file.name.toLowerCase().indexOf(validType.toLowerCase(), file.name.length - validType.length) !== -1) return true;
1954
- } else if (/\/\*$/.test(validType)) {
1955
- // This is something like a image/* mime type
1956
- if (baseMimeType === validType.replace(/\/.*$/, "")) return true;
1957
- } else {
1958
- if (mimeType === validType) return true;
1959
- }
1960
- }
1961
- return false;
1962
- };
1963
- // Augment jQuery
1964
- if (typeof jQuery !== "undefined" && jQuery !== null) jQuery.fn.dropzone = function(options) {
1965
- return this.each(function() {
1966
- return new $3ed269f2f0fb224b$export$2e2bcd8739ae039(this, options);
1967
- });
1968
- };
1969
- // Dropzone file status codes
1970
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.ADDED = "added";
1971
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED = "queued";
1972
- // For backwards compatibility. Now, if a file is accepted, it's either queued
1973
- // or uploading.
1974
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.ACCEPTED = $3ed269f2f0fb224b$export$2e2bcd8739ae039.QUEUED;
1975
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING = "uploading";
1976
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.PROCESSING = $3ed269f2f0fb224b$export$2e2bcd8739ae039.UPLOADING; // alias
1977
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.CANCELED = "canceled";
1978
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.ERROR = "error";
1979
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.SUCCESS = "success";
1980
- /*
1981
-
1982
- Bugfix for iOS 6 and 7
1983
- Source: http://stackoverflow.com/questions/11929099/html5-canvas-drawimage-ratio-bug-ios
1984
- based on the work of https://github.com/stomita/ios-imagefile-megapixel
1985
-
1986
- */ // Detecting vertical squash in loaded image.
1987
- // Fixes a bug which squash image vertically while drawing into canvas for some images.
1988
- // This is a bug in iOS6 devices. This function from https://github.com/stomita/ios-imagefile-megapixel
1989
- let $3ed269f2f0fb224b$var$detectVerticalSquash = function(img) {
1990
- img.naturalWidth;
1991
- let ih = img.naturalHeight;
1992
- let canvas = document.createElement("canvas");
1993
- canvas.width = 1;
1994
- canvas.height = ih;
1995
- let ctx = canvas.getContext("2d");
1996
- ctx.drawImage(img, 0, 0);
1997
- let { data: data } = ctx.getImageData(1, 0, 1, ih);
1998
- // search image edge pixel position in case it is squashed vertically.
1999
- let sy = 0;
2000
- let ey = ih;
2001
- let py = ih;
2002
- while(py > sy){
2003
- let alpha = data[(py - 1) * 4 + 3];
2004
- if (alpha === 0) ey = py;
2005
- else sy = py;
2006
- py = ey + sy >> 1;
2007
- }
2008
- let ratio = py / ih;
2009
- if (ratio === 0) return 1;
2010
- else return ratio;
2011
- };
2012
- // A replacement for context.drawImage
2013
- // (args are for source and destination).
2014
- var $3ed269f2f0fb224b$var$drawImageIOSFix = function(ctx, img, sx, sy, sw, sh, dx, dy, dw, dh) {
2015
- let vertSquashRatio = $3ed269f2f0fb224b$var$detectVerticalSquash(img);
2016
- return ctx.drawImage(img, sx, sy, sw, sh, dx, dy, dw, dh / vertSquashRatio);
2017
- };
2018
- // Based on MinifyJpeg
2019
- // Source: http://www.perry.cz/files/ExifRestorer.js
2020
- // http://elicon.blog57.fc2.com/blog-entry-206.html
2021
- class $3ed269f2f0fb224b$var$ExifRestore {
2022
- static initClass() {
2023
- this.KEY_STR = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
2024
- }
2025
- static encode64(input) {
2026
- let output = "";
2027
- let chr1 = undefined;
2028
- let chr2 = undefined;
2029
- let chr3 = "";
2030
- let enc1 = undefined;
2031
- let enc2 = undefined;
2032
- let enc3 = undefined;
2033
- let enc4 = "";
2034
- let i = 0;
2035
- while(true){
2036
- chr1 = input[i++];
2037
- chr2 = input[i++];
2038
- chr3 = input[i++];
2039
- enc1 = chr1 >> 2;
2040
- enc2 = (chr1 & 3) << 4 | chr2 >> 4;
2041
- enc3 = (chr2 & 15) << 2 | chr3 >> 6;
2042
- enc4 = chr3 & 63;
2043
- if (isNaN(chr2)) enc3 = enc4 = 64;
2044
- else if (isNaN(chr3)) enc4 = 64;
2045
- output = output + this.KEY_STR.charAt(enc1) + this.KEY_STR.charAt(enc2) + this.KEY_STR.charAt(enc3) + this.KEY_STR.charAt(enc4);
2046
- chr1 = chr2 = chr3 = "";
2047
- enc1 = enc2 = enc3 = enc4 = "";
2048
- if (!(i < input.length)) break;
2049
- }
2050
- return output;
2051
- }
2052
- static restore(origFileBase64, resizedFileBase64) {
2053
- if (!origFileBase64.match("data:image/jpeg;base64,")) return resizedFileBase64;
2054
- let rawImage = this.decode64(origFileBase64.replace("data:image/jpeg;base64,", ""));
2055
- let segments = this.slice2Segments(rawImage);
2056
- let image = this.exifManipulation(resizedFileBase64, segments);
2057
- return `data:image/jpeg;base64,${this.encode64(image)}`;
2058
- }
2059
- static exifManipulation(resizedFileBase64, segments) {
2060
- let exifArray = this.getExifArray(segments);
2061
- let newImageArray = this.insertExif(resizedFileBase64, exifArray);
2062
- let aBuffer = new Uint8Array(newImageArray);
2063
- return aBuffer;
2064
- }
2065
- static getExifArray(segments) {
2066
- let seg = undefined;
2067
- let x = 0;
2068
- while(x < segments.length){
2069
- seg = segments[x];
2070
- if (seg[0] === 255 & seg[1] === 225) return seg;
2071
- x++;
2072
- }
2073
- return [];
2074
- }
2075
- static insertExif(resizedFileBase64, exifArray) {
2076
- let imageData = resizedFileBase64.replace("data:image/jpeg;base64,", "");
2077
- let buf = this.decode64(imageData);
2078
- let separatePoint = buf.indexOf(255, 3);
2079
- let mae = buf.slice(0, separatePoint);
2080
- let ato = buf.slice(separatePoint);
2081
- let array = mae;
2082
- array = array.concat(exifArray);
2083
- array = array.concat(ato);
2084
- return array;
2085
- }
2086
- static slice2Segments(rawImageArray) {
2087
- let head = 0;
2088
- let segments = [];
2089
- while(true){
2090
- var length;
2091
- if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 218) break;
2092
- if (rawImageArray[head] === 255 & rawImageArray[head + 1] === 216) head += 2;
2093
- else {
2094
- length = rawImageArray[head + 2] * 256 + rawImageArray[head + 3];
2095
- let endPoint = head + length + 2;
2096
- let seg = rawImageArray.slice(head, endPoint);
2097
- segments.push(seg);
2098
- head = endPoint;
2099
- }
2100
- if (head > rawImageArray.length) break;
2101
- }
2102
- return segments;
2103
- }
2104
- static decode64(input) {
2105
- let chr1 = undefined;
2106
- let chr2 = undefined;
2107
- let chr3 = "";
2108
- let enc1 = undefined;
2109
- let enc2 = undefined;
2110
- let enc3 = undefined;
2111
- let enc4 = "";
2112
- let i = 0;
2113
- let buf = [];
2114
- // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
2115
- let base64test = /[^A-Za-z0-9\+\/\=]/g;
2116
- if (base64test.exec(input)) console.warn("There were invalid base64 characters in the input text.\nValid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\nExpect errors in decoding.");
2117
- input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
2118
- while(true){
2119
- enc1 = this.KEY_STR.indexOf(input.charAt(i++));
2120
- enc2 = this.KEY_STR.indexOf(input.charAt(i++));
2121
- enc3 = this.KEY_STR.indexOf(input.charAt(i++));
2122
- enc4 = this.KEY_STR.indexOf(input.charAt(i++));
2123
- chr1 = enc1 << 2 | enc2 >> 4;
2124
- chr2 = (enc2 & 15) << 4 | enc3 >> 2;
2125
- chr3 = (enc3 & 3) << 6 | enc4;
2126
- buf.push(chr1);
2127
- if (enc3 !== 64) buf.push(chr2);
2128
- if (enc4 !== 64) buf.push(chr3);
2129
- chr1 = chr2 = chr3 = "";
2130
- enc1 = enc2 = enc3 = enc4 = "";
2131
- if (!(i < input.length)) break;
2132
- }
2133
- return buf;
2134
- }
2135
- }
2136
- $3ed269f2f0fb224b$var$ExifRestore.initClass();
2137
- function $3ed269f2f0fb224b$var$__guard__(value, transform) {
2138
- return typeof value !== "undefined" && value !== null ? transform(value) : undefined;
2139
- }
2140
- function $3ed269f2f0fb224b$var$__guardMethod__(obj, methodName, transform) {
2141
- if (typeof obj !== "undefined" && obj !== null && typeof obj[methodName] === "function") return transform(obj, methodName);
2142
- else return undefined;
2143
- }
2144
-
2145
- class _FilePicker extends index.FoundationElement {
2146
- }
2147
- class FormAssociatedFilePicker extends formAssociated.FormAssociated(_FilePicker) {
2148
- constructor() {
2149
- super(...arguments);
2150
- this.proxy = document.createElement("input");
2151
- }
2152
- }
11
+ const styles = ".control{--_fab-inline-padding: 12px;display:inline-flex;box-sizing:border-box;align-items:center;border:0 none;border-radius:var(--_fab-border-radius);background:var(--_appearance-color-fill, var(--_elevation-fill));block-size:var(--_fab-block-size);color:var(--_appearance-color-text, var(--vvd-color-canvas-text));column-gap:var(--fab-icon-gap);filter:var(--_elevation-shadow);font:var(--vvd-typography-base-bold);padding-inline:var(--_fab-inline-padding);transition:background-color .15s linear,filter .15s linear;vertical-align:middle}.control.connotation-accent{--_connotation-color-primary: var(--vvd-fab-accent-primary, var(--vvd-color-canvas-text));--_connotation-color-primary-text: var(--vvd-fab-accent-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-fab-accent-primary-increment, var(--vvd-color-neutral-800));--_connotation-color-contrast: var(--vvd-fab-accent-contrast, var(--vvd-color-neutral-800));--_connotation-color-fierce: var(--vvd-fab-accent-fierce, var(--vvd-color-neutral-700));--_connotation-color-firm: var(--vvd-fab-accent-firm, var(--vvd-color-canvas-text))}.control.connotation-cta{--_connotation-color-primary: var(--vvd-fab-cta-primary, var(--vvd-color-cta-500));--_connotation-color-primary-text: var(--vvd-fab-cta-primary-text, var(--vvd-color-canvas));--_connotation-color-primary-increment: var(--vvd-fab-cta-primary-increment, var(--vvd-color-cta-600));--_connotation-color-contrast: var(--vvd-fab-cta-contrast, var(--vvd-color-cta-800));--_connotation-color-fierce: var(--vvd-fab-cta-fierce, var(--vvd-color-cta-700));--_connotation-color-firm: var(--vvd-fab-cta-firm, var(--vvd-color-cta-600))}.control{--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary);--_appearance-color-outline: transparent}.control:where(.hover,:hover):where(:not(.disabled,:disabled,.readonly)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-primary-increment);--_appearance-color-outline: transparent}.control:where(.disabled,:disabled){--_appearance-color-text: var(--vvd-color-neutral-300);--_appearance-color-fill: var(--vvd-color-neutral-100);--_appearance-color-outline: transparent}.control:where(.active,:active):where(:not(.disabled,:disabled)){--_appearance-color-text: var(--_connotation-color-primary-text);--_appearance-color-fill: var(--_connotation-color-fierce);--_appearance-color-outline: transparent}.control:not(.connotation-accent,.connotation-cta){--focus-stroke-gap-color: transparent}.control:focus-visible{box-shadow:inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:2px solid var(--focus-stroke-color, var(--vvd-color-canvas-text));outline-offset:calc(-2px - var(--focus-inset, 0px))}@supports (user-select: none){.control{user-select:none}}.control.size-expanded{--_fab-border-radius: 40px;--_fab-block-size:calc(1px*(56 + 4*clamp(-1, var(--vvd-size-density, 0), 2)));--_fab-inline-padding: 20px}.control:not(.size-expanded){--_fab-border-radius: 24px;--_fab-block-size:calc(1px*(40 + 4*clamp(-1, var(--vvd-size-density, 0), 2)))}.control.icon-only{--_fab-inline-padding: 0;border-radius:50%;place-content:center}@supports (aspect-ratio: 1){.control.icon-only{aspect-ratio:1}}@supports not (aspect-ratio: 1){.control.icon-only{inline-size:var(--_fab-block-size)}}.control:not(.icon-only){--fab-icon-gap: 10px}.control:disabled{--_elevation-fill: var(--vvd-color-surface-0dp);--_elevation-shadow: var(--vvd-shadow-surface-0dp);cursor:not-allowed}.control:not(:disabled){--_elevation-fill: var(--vvd-color-surface-4dp);--_elevation-shadow: var(--vvd-shadow-surface-4dp);cursor:pointer}.control:not(:disabled):hover{--_elevation-fill: var(--vvd-color-surface-12dp);--_elevation-shadow: var(--vvd-shadow-surface-12dp)}.control:not(:disabled):active{--_elevation-fill: var(--vvd-color-surface-24dp);--_elevation-shadow: var(--vvd-shadow-surface-24dp)}slot[name=icon]{line-height:1}.icon-trailing slot[name=icon]{display:inline-block;order:1}.control.size-extended slot[name=icon]{font-size:calc(calc(1px*(56 + 4*clamp(-1,var(--vvd-size-density, 0),2))) / 2.3333)}.control:not(.size-extended) slot[name=icon]{font-size:calc(1px*(40 + 4*clamp(-1,var(--vvd-size-density, 0),2))/2)}\n";
2153
12
 
2154
13
  var __defProp = Object.defineProperty;
2155
14
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2162,228 +21,84 @@ var __decorateClass = (decorators, target, key, kind) => {
2162
21
  __defProp(target, key, result);
2163
22
  return result;
2164
23
  };
2165
- const isFormAssociatedTryingToSetFormValueToFakePath = (value) => typeof value === "string";
2166
- let FilePicker = class extends FormAssociatedFilePicker {
2167
- constructor() {
2168
- super();
2169
- this.maxFileSize = 256;
2170
- /**
2171
- * Used internally to hold the tag that button is registered at.
2172
- */
2173
- this.buttonTag = "vwc-button";
2174
- this.setFormValue = (value, state) => {
2175
- if (isFormAssociatedTryingToSetFormValueToFakePath(value)) {
2176
- return;
2177
- }
2178
- super.setFormValue(value, state);
2179
- };
2180
- $3ed269f2f0fb224b$export$2e2bcd8739ae039.autoDiscover = false;
2181
- }
2182
- #dropzone;
2183
- /**
2184
- * Files that have been added to the file picker and passed validation.
2185
- *
2186
- * @public
2187
- */
2188
- get files() {
2189
- return this.#dropzone?.getAcceptedFiles() ?? [];
2190
- }
2191
- maxFilesChanged(_oldValue, newValue) {
2192
- if (!this.#dropzone) {
2193
- return;
2194
- }
2195
- this.#dropzone.options.maxFiles = newValue;
2196
- this.#updateHiddenFileInput();
2197
- }
2198
- maxFileSizeChanged(_oldValue, newValue) {
2199
- if (!this.#dropzone) {
2200
- return;
2201
- }
2202
- this.#dropzone.options.maxFilesize = newValue;
2203
- }
2204
- acceptChanged(_oldValue, newValue) {
2205
- if (!this.#dropzone) {
2206
- return;
2207
- }
2208
- this.#dropzone.options.acceptedFiles = newValue;
2209
- }
2210
- nameChanged(previous, next) {
2211
- super.nameChanged(previous, next);
2212
- this.#updateFormValue();
2213
- }
2214
- connectedCallback() {
2215
- super.connectedCallback();
2216
- const control = this.shadowRoot.querySelector(
2217
- ".control"
2218
- );
2219
- const previewList = this.shadowRoot.querySelector(
2220
- ".preview-list"
2221
- );
2222
- this.#dropzone = new $3ed269f2f0fb224b$export$2e2bcd8739ae039(control, {
2223
- url: "/",
2224
- // dummy url, we do not use dropzone's upload functionality
2225
- maxFiles: this.maxFiles ?? null,
2226
- maxFilesize: this.maxFileSize,
2227
- acceptedFiles: this.accept,
2228
- autoProcessQueue: false,
2229
- addRemoveLinks: false,
2230
- previewsContainer: previewList,
2231
- createImageThumbnails: false,
2232
- // Updated version of default template (https://github.com/dropzone/dropzone/blob/f50d1828ab5df79a76be00d1306cc320e39a27f4/src/preview-template.html)
2233
- previewTemplate: `<div class="dz-preview dz-file-preview">
2234
- <div class="dz-details">
2235
- <div class="dz-filename"><span data-dz-name></span></div>
2236
- <div class="dz-size"><span data-dz-size></span></div>
2237
- </div>
2238
- <div class="dz-error-message"><span data-dz-errormessage></span></div>
2239
- <${this.buttonTag} class="remove-btn" icon="delete-line" appearance="ghost" size="condensed" aria-label="${this.locale.filePicker.removeFileLabel}"></${this.buttonTag}>
2240
- </div>`,
2241
- dictInvalidFileType: this.locale.filePicker.invalidFileTypeError,
2242
- dictMaxFilesExceeded: this.locale.filePicker.maxFilesExceededError,
2243
- dictFileTooBig: this.locale.filePicker.fileTooBigError
2244
- });
2245
- this.#dropzone.on("addedfiles", (files) => {
2246
- for (const file of files) {
2247
- if (file.previewElement) {
2248
- const removeButton = file.previewElement.querySelector(
2249
- ".remove-btn"
2250
- );
2251
- removeButton.addEventListener("click", (e) => {
2252
- e.preventDefault();
2253
- e.stopPropagation();
2254
- this.#dropzone.removeFile(file);
2255
- });
2256
- }
2257
- }
2258
- this.#handleFilesChanged();
2259
- });
2260
- this.#dropzone.on("removedfile", () => {
2261
- this.#handleFilesChanged();
2262
- });
2263
- this.#dropzone.on("error", (file) => {
2264
- if (file.previewElement) {
2265
- const removeButton = file.previewElement.querySelector(
2266
- ".remove-btn"
2267
- );
2268
- removeButton.connotation = enums.Connotation.Alert;
2269
- }
2270
- });
2271
- }
2272
- disconnectedCallback() {
2273
- super.disconnectedCallback();
2274
- this.#dropzone.destroy();
2275
- }
2276
- /**
2277
- * Used internally to set the button tag.
2278
- * @internal
2279
- */
2280
- setButtonTag(tag) {
2281
- this.buttonTag = tag;
2282
- }
2283
- /**
2284
- * @internal
2285
- */
2286
- handleKeydown(e) {
2287
- if (e.key === "Enter" || e.key === " ") {
2288
- this.#chooseFile();
2289
- }
2290
- return true;
2291
- }
2292
- #chooseFile() {
2293
- if (this.#dropzone.hiddenFileInput) {
2294
- this.#dropzone.hiddenFileInput.click();
2295
- }
2296
- }
2297
- #updateHiddenFileInput() {
2298
- if (this.#dropzone.hiddenFileInput) {
2299
- this.#dropzone.hiddenFileInput.dispatchEvent(
2300
- new Event("change", { bubbles: false })
2301
- );
2302
- }
2303
- }
2304
- #handleFilesChanged() {
2305
- this.$emit("change");
2306
- this.#updateFormValue();
2307
- }
2308
- #updateFormValue() {
2309
- const files = this.files;
2310
- if (!this.name) {
2311
- this.setFormValue(null);
2312
- } else {
2313
- const formData = new FormData();
2314
- for (const file of files) {
2315
- formData.append(this.name, file);
2316
- }
2317
- this.setFormValue(formData);
2318
- }
2319
- this.#setValueToAFakePathLikeNativeInput();
2320
- }
2321
- #setValueToAFakePathLikeNativeInput() {
2322
- this.value = this.files.length > 0 ? `C:\\fakepath\\${this.files[0].name}` : "";
2323
- }
2324
- validate() {
2325
- super.validate(this.control);
2326
- }
2327
- formResetCallback() {
2328
- super.formResetCallback();
2329
- this.#dropzone.removeAllFiles();
2330
- }
2331
- };
2332
- __decorateClass([
2333
- index.attr({ attribute: "max-files" })
2334
- ], FilePicker.prototype, "maxFiles", 2);
24
+ class Fab extends button.Button {
25
+ }
2335
26
  __decorateClass([
2336
- index.attr({ mode: "fromView", attribute: "max-file-size" })
2337
- ], FilePicker.prototype, "maxFileSize", 2);
27
+ index.attr
28
+ ], Fab.prototype, "connotation", 2);
2338
29
  __decorateClass([
2339
30
  index.attr
2340
- ], FilePicker.prototype, "accept", 2);
31
+ ], Fab.prototype, "size", 2);
2341
32
  __decorateClass([
2342
33
  index.attr
2343
- ], FilePicker.prototype, "size", 2);
2344
- FilePicker = __decorateClass([
2345
- index$1.errorText,
2346
- index$1.formElements
2347
- ], FilePicker);
2348
- applyMixins.applyMixins(FilePicker, index$1.FormElementHelperText, localized.Localized);
34
+ ], Fab.prototype, "label", 2);
35
+ applyMixins.applyMixins(Fab, affix.AffixIconWithTrailing);
2349
36
 
2350
37
  const getClasses = ({
2351
- size
38
+ connotation,
39
+ size,
40
+ icon,
41
+ label,
42
+ iconTrailing,
43
+ disabled,
44
+ iconSlottedContent
2352
45
  }) => classNames.classNames(
2353
46
  "control",
2354
- "dz-default",
2355
- "dz-message",
2356
- [`size-${size}`, Boolean(size)]
47
+ [`connotation-${connotation}`, Boolean(connotation)],
48
+ [`size-${size}`, Boolean(size)],
49
+ ["icon-only", !label && !!(icon || iconSlottedContent?.length)],
50
+ ["icon-trailing", iconTrailing],
51
+ ["disabled", disabled]
2357
52
  );
2358
- const FilePickerTemplate = (context) => {
53
+ const FabTemplate = (context) => {
54
+ const affixIconTemplate = affix.affixIconTemplateFactory(context);
2359
55
  return index.html`
2360
- ${(x) => {
2361
- x.setButtonTag(context.tagFor(definition.Button));
2362
- }}
2363
- <div class="base" aria-label="${(x) => x.label}">
2364
- ${when.when((x) => x.label, index.html`<label>${(x) => x.label}</label>`)}
2365
- <div ${ref.ref("control")} class="${getClasses}" tabindex="0" role="button"
2366
- @keydown="${(x, c) => x.handleKeydown(c.event)}">
2367
- <slot class="main"></slot>
2368
- </div>
2369
- ${when.when((x) => !x.errorValidationMessage && x.helperText?.length, index$1.getFeedbackTemplate("helper", context))}
2370
- ${when.when((x) => x.errorValidationMessage, index$1.getFeedbackTemplate("error", context))}
2371
- <div class="preview-list"></div>
2372
- </div>
56
+ <button
57
+ class="${getClasses} "
58
+ ?autofocus="${(x) => x.autofocus}"
59
+ ?disabled="${(x) => x.disabled}"
60
+ form="${(x) => x.formId}"
61
+ formaction="${(x) => x.formaction}"
62
+ formenctype="${(x) => x.formenctype}"
63
+ formmethod="${(x) => x.formmethod}"
64
+ formnovalidate="${(x) => x.formnovalidate}"
65
+ formtarget="${(x) => x.formtarget}"
66
+ name="${(x) => x.name}"
67
+ type="${(x) => x.type}"
68
+ value="${(x) => x.value}"
69
+ aria-atomic="${(x) => x.ariaAtomic}"
70
+ aria-busy="${(x) => x.ariaBusy}"
71
+ aria-current="${(x) => x.ariaCurrent}"
72
+ aria-details="${(x) => x.ariaDetails}"
73
+ aria-disabled="${(x) => x.ariaDisabled}"
74
+ aria-expanded="${(x) => x.ariaExpanded}"
75
+ aria-haspopup="${(x) => x.ariaHaspopup}"
76
+ aria-hidden="${(x) => x.ariaHidden}"
77
+ aria-invalid="${(x) => x.ariaInvalid}"
78
+ aria-keyshortcuts="${(x) => x.ariaKeyshortcuts}"
79
+ aria-label="${(x) => x.ariaLabel}"
80
+ aria-live="${(x) => x.ariaLive}"
81
+ aria-pressed="${(x) => x.ariaPressed}"
82
+ aria-relevant="${(x) => x.ariaRelevant}"
83
+ aria-roledescription="${(x) => x.ariaRoledescription}"
84
+ ${ref.ref("control")}
85
+ >
86
+ ${(x) => affixIconTemplate(x.icon, affix.IconWrapper.Slot)} ${(x) => x.label}
87
+ </button>
2373
88
  `;
2374
89
  };
2375
90
 
2376
- const filePickerDefinition = FilePicker.compose({
2377
- baseName: "file-picker",
2378
- template: FilePickerTemplate,
91
+ const fabDefinition = Fab.compose({
92
+ baseName: "fab",
93
+ template: FabTemplate,
2379
94
  styles,
2380
95
  shadowOptions: {
2381
96
  delegatesFocus: true
2382
97
  }
2383
98
  });
2384
- const filePickerRegistries = [filePickerDefinition(), ...definition$1.iconRegistries, ...definition$2.focusRegistries, ...definition.buttonRegistries];
2385
- const registerFilePicker = index.registerFactory(filePickerRegistries);
99
+ const fabRegistries = [fabDefinition(), ...definition.iconRegistries];
100
+ const registerFab = index.registerFactory(fabRegistries);
2386
101
 
2387
- exports.filePickerDefinition = filePickerDefinition;
2388
- exports.filePickerRegistries = filePickerRegistries;
2389
- exports.registerFilePicker = registerFilePicker;
102
+ exports.fabDefinition = fabDefinition;
103
+ exports.fabRegistries = fabRegistries;
104
+ exports.registerFab = registerFab;