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