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