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