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