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