@tft/interact 12.5.3 → 13.0.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 (116) hide show
  1. package/esm2020/index.mjs +6 -0
  2. package/esm2020/lib/directives/account-for-scale.directive.mjs +26 -0
  3. package/esm2020/lib/directives/apply-scale.directive.mjs +28 -0
  4. package/esm2020/lib/directives/auto-scroll.directive.mjs +56 -0
  5. package/esm2020/lib/directives/drag-preview.directive.mjs +20 -0
  6. package/esm2020/lib/directives/drag-root.directive.mjs +32 -0
  7. package/esm2020/lib/directives/draggable.directive.mjs +320 -0
  8. package/esm2020/lib/directives/dropzone.directive.mjs +114 -0
  9. package/esm2020/lib/directives/gesturable.directive.mjs +82 -0
  10. package/esm2020/lib/directives/index.mjs +10 -0
  11. package/esm2020/lib/directives/resizable.directive.mjs +228 -0
  12. package/esm2020/lib/interact.module.mjs +66 -0
  13. package/esm2020/lib/models/index.mjs +2 -0
  14. package/esm2020/lib/models/interact.mjs +28 -0
  15. package/esm2020/lib/pipes/array-of-n.pipe.mjs +22 -0
  16. package/esm2020/lib/pipes/index.mjs +2 -0
  17. package/esm2020/lib/services/interact.service.mjs +197 -0
  18. package/esm2020/lib/utils/helpers.mjs +35 -0
  19. package/esm2020/lib/utils/index.mjs +2 -0
  20. package/esm2020/tft-interact.mjs +5 -0
  21. package/fesm2015/{tft-interact.js → tft-interact.mjs} +355 -257
  22. package/fesm2015/tft-interact.mjs.map +1 -0
  23. package/fesm2020/tft-interact.mjs +1192 -0
  24. package/fesm2020/tft-interact.mjs.map +1 -0
  25. package/lib/directives/account-for-scale.directive.d.ts +3 -0
  26. package/lib/directives/apply-scale.directive.d.ts +3 -0
  27. package/lib/directives/auto-scroll.directive.d.ts +3 -0
  28. package/lib/directives/drag-preview.directive.d.ts +3 -0
  29. package/lib/directives/drag-root.directive.d.ts +3 -0
  30. package/lib/directives/draggable.directive.d.ts +3 -0
  31. package/lib/directives/dropzone.directive.d.ts +3 -0
  32. package/lib/directives/gesturable.directive.d.ts +3 -0
  33. package/lib/directives/resizable.directive.d.ts +3 -0
  34. package/lib/interact.module.d.ts +15 -0
  35. package/lib/pipes/array-of-n.pipe.d.ts +3 -0
  36. package/lib/services/interact.service.d.ts +3 -0
  37. package/package.json +23 -10
  38. package/tft-interact-13.0.0.tgz +0 -0
  39. package/tft-interact.d.ts +1 -2
  40. package/bundles/tft-interact.umd.js +0 -1526
  41. package/bundles/tft-interact.umd.js.map +0 -1
  42. package/esm2015/index.js +0 -6
  43. package/esm2015/index.js.map +0 -1
  44. package/esm2015/index.metadata.json +0 -1
  45. package/esm2015/lib/directives/account-for-scale.directive.js +0 -26
  46. package/esm2015/lib/directives/account-for-scale.directive.js.map +0 -1
  47. package/esm2015/lib/directives/account-for-scale.directive.metadata.json +0 -1
  48. package/esm2015/lib/directives/account-for-scale.directive.ngfactory.js.map +0 -1
  49. package/esm2015/lib/directives/apply-scale.directive.js +0 -26
  50. package/esm2015/lib/directives/apply-scale.directive.js.map +0 -1
  51. package/esm2015/lib/directives/apply-scale.directive.metadata.json +0 -1
  52. package/esm2015/lib/directives/apply-scale.directive.ngfactory.js.map +0 -1
  53. package/esm2015/lib/directives/auto-scroll.directive.js +0 -54
  54. package/esm2015/lib/directives/auto-scroll.directive.js.map +0 -1
  55. package/esm2015/lib/directives/auto-scroll.directive.metadata.json +0 -1
  56. package/esm2015/lib/directives/auto-scroll.directive.ngfactory.js.map +0 -1
  57. package/esm2015/lib/directives/drag-preview.directive.js +0 -20
  58. package/esm2015/lib/directives/drag-preview.directive.js.map +0 -1
  59. package/esm2015/lib/directives/drag-preview.directive.metadata.json +0 -1
  60. package/esm2015/lib/directives/drag-preview.directive.ngfactory.js.map +0 -1
  61. package/esm2015/lib/directives/drag-root.directive.js +0 -27
  62. package/esm2015/lib/directives/drag-root.directive.js.map +0 -1
  63. package/esm2015/lib/directives/drag-root.directive.metadata.json +0 -1
  64. package/esm2015/lib/directives/drag-root.directive.ngfactory.js.map +0 -1
  65. package/esm2015/lib/directives/draggable.directive.js +0 -286
  66. package/esm2015/lib/directives/draggable.directive.js.map +0 -1
  67. package/esm2015/lib/directives/draggable.directive.metadata.json +0 -1
  68. package/esm2015/lib/directives/draggable.directive.ngfactory.js.map +0 -1
  69. package/esm2015/lib/directives/dropzone.directive.js +0 -105
  70. package/esm2015/lib/directives/dropzone.directive.js.map +0 -1
  71. package/esm2015/lib/directives/dropzone.directive.metadata.json +0 -1
  72. package/esm2015/lib/directives/dropzone.directive.ngfactory.js.map +0 -1
  73. package/esm2015/lib/directives/gesturable.directive.js +0 -77
  74. package/esm2015/lib/directives/gesturable.directive.js.map +0 -1
  75. package/esm2015/lib/directives/gesturable.directive.metadata.json +0 -1
  76. package/esm2015/lib/directives/gesturable.directive.ngfactory.js.map +0 -1
  77. package/esm2015/lib/directives/index.js +0 -10
  78. package/esm2015/lib/directives/index.js.map +0 -1
  79. package/esm2015/lib/directives/index.metadata.json +0 -1
  80. package/esm2015/lib/directives/resizable.directive.js +0 -201
  81. package/esm2015/lib/directives/resizable.directive.js.map +0 -1
  82. package/esm2015/lib/directives/resizable.directive.metadata.json +0 -1
  83. package/esm2015/lib/directives/resizable.directive.ngfactory.js.map +0 -1
  84. package/esm2015/lib/interact.module.js +0 -43
  85. package/esm2015/lib/interact.module.js.map +0 -1
  86. package/esm2015/lib/interact.module.metadata.json +0 -1
  87. package/esm2015/lib/interact.module.ngfactory.js.map +0 -1
  88. package/esm2015/lib/models/index.js +0 -2
  89. package/esm2015/lib/models/index.js.map +0 -1
  90. package/esm2015/lib/models/index.metadata.json +0 -1
  91. package/esm2015/lib/models/interact.js +0 -28
  92. package/esm2015/lib/models/interact.js.map +0 -1
  93. package/esm2015/lib/models/interact.metadata.json +0 -1
  94. package/esm2015/lib/pipes/array-of-n.pipe.js +0 -18
  95. package/esm2015/lib/pipes/array-of-n.pipe.js.map +0 -1
  96. package/esm2015/lib/pipes/array-of-n.pipe.metadata.json +0 -1
  97. package/esm2015/lib/pipes/array-of-n.pipe.ngfactory.js.map +0 -1
  98. package/esm2015/lib/pipes/index.js +0 -2
  99. package/esm2015/lib/pipes/index.js.map +0 -1
  100. package/esm2015/lib/pipes/index.metadata.json +0 -1
  101. package/esm2015/lib/services/interact.service.js +0 -196
  102. package/esm2015/lib/services/interact.service.js.map +0 -1
  103. package/esm2015/lib/services/interact.service.metadata.json +0 -1
  104. package/esm2015/lib/services/interact.service.ngfactory.js.map +0 -1
  105. package/esm2015/lib/utils/helpers.js +0 -35
  106. package/esm2015/lib/utils/helpers.js.map +0 -1
  107. package/esm2015/lib/utils/helpers.metadata.json +0 -1
  108. package/esm2015/lib/utils/index.js +0 -2
  109. package/esm2015/lib/utils/index.js.map +0 -1
  110. package/esm2015/lib/utils/index.metadata.json +0 -1
  111. package/esm2015/tft-interact.js +0 -7
  112. package/esm2015/tft-interact.js.map +0 -1
  113. package/esm2015/tft-interact.metadata.json +0 -1
  114. package/fesm2015/tft-interact.js.map +0 -1
  115. package/tft-interact-12.5.3.tgz +0 -0
  116. package/tft-interact.metadata.json +0 -1
@@ -1,1526 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('interactjs'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@tft/interact', ['exports', '@angular/core', '@angular/common', 'interactjs', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.tft = global.tft || {}, global.tft.interact = {}), global.ng.core, global.ng.common, global.interact, global.rxjs, global.rxjs.operators));
5
- }(this, (function (exports, i0, common, interact, rxjs, operators) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () {
19
- return e[k];
20
- }
21
- });
22
- }
23
- });
24
- }
25
- n['default'] = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
30
- var interact__default = /*#__PURE__*/_interopDefaultLegacy(interact);
31
-
32
- /*! *****************************************************************************
33
- Copyright (c) Microsoft Corporation.
34
-
35
- Permission to use, copy, modify, and/or distribute this software for any
36
- purpose with or without fee is hereby granted.
37
-
38
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
39
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
41
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
42
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
43
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
44
- PERFORMANCE OF THIS SOFTWARE.
45
- ***************************************************************************** */
46
- /* global Reflect, Promise */
47
- var extendStatics = function (d, b) {
48
- extendStatics = Object.setPrototypeOf ||
49
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
50
- function (d, b) { for (var p in b)
51
- if (Object.prototype.hasOwnProperty.call(b, p))
52
- d[p] = b[p]; };
53
- return extendStatics(d, b);
54
- };
55
- function __extends(d, b) {
56
- if (typeof b !== "function" && b !== null)
57
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
58
- extendStatics(d, b);
59
- function __() { this.constructor = d; }
60
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
61
- }
62
- var __assign = function () {
63
- __assign = Object.assign || function __assign(t) {
64
- for (var s, i = 1, n = arguments.length; i < n; i++) {
65
- s = arguments[i];
66
- for (var p in s)
67
- if (Object.prototype.hasOwnProperty.call(s, p))
68
- t[p] = s[p];
69
- }
70
- return t;
71
- };
72
- return __assign.apply(this, arguments);
73
- };
74
- function __rest(s, e) {
75
- var t = {};
76
- for (var p in s)
77
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
78
- t[p] = s[p];
79
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
80
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
81
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
82
- t[p[i]] = s[p[i]];
83
- }
84
- return t;
85
- }
86
- function __decorate(decorators, target, key, desc) {
87
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
88
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
89
- r = Reflect.decorate(decorators, target, key, desc);
90
- else
91
- for (var i = decorators.length - 1; i >= 0; i--)
92
- if (d = decorators[i])
93
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
94
- return c > 3 && r && Object.defineProperty(target, key, r), r;
95
- }
96
- function __param(paramIndex, decorator) {
97
- return function (target, key) { decorator(target, key, paramIndex); };
98
- }
99
- function __metadata(metadataKey, metadataValue) {
100
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
101
- return Reflect.metadata(metadataKey, metadataValue);
102
- }
103
- function __awaiter(thisArg, _arguments, P, generator) {
104
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
105
- return new (P || (P = Promise))(function (resolve, reject) {
106
- function fulfilled(value) { try {
107
- step(generator.next(value));
108
- }
109
- catch (e) {
110
- reject(e);
111
- } }
112
- function rejected(value) { try {
113
- step(generator["throw"](value));
114
- }
115
- catch (e) {
116
- reject(e);
117
- } }
118
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
119
- step((generator = generator.apply(thisArg, _arguments || [])).next());
120
- });
121
- }
122
- function __generator(thisArg, body) {
123
- var _ = { label: 0, sent: function () { if (t[0] & 1)
124
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
125
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
126
- function verb(n) { return function (v) { return step([n, v]); }; }
127
- function step(op) {
128
- if (f)
129
- throw new TypeError("Generator is already executing.");
130
- while (_)
131
- try {
132
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
133
- return t;
134
- if (y = 0, t)
135
- op = [op[0] & 2, t.value];
136
- switch (op[0]) {
137
- case 0:
138
- case 1:
139
- t = op;
140
- break;
141
- case 4:
142
- _.label++;
143
- return { value: op[1], done: false };
144
- case 5:
145
- _.label++;
146
- y = op[1];
147
- op = [0];
148
- continue;
149
- case 7:
150
- op = _.ops.pop();
151
- _.trys.pop();
152
- continue;
153
- default:
154
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
155
- _ = 0;
156
- continue;
157
- }
158
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
159
- _.label = op[1];
160
- break;
161
- }
162
- if (op[0] === 6 && _.label < t[1]) {
163
- _.label = t[1];
164
- t = op;
165
- break;
166
- }
167
- if (t && _.label < t[2]) {
168
- _.label = t[2];
169
- _.ops.push(op);
170
- break;
171
- }
172
- if (t[2])
173
- _.ops.pop();
174
- _.trys.pop();
175
- continue;
176
- }
177
- op = body.call(thisArg, _);
178
- }
179
- catch (e) {
180
- op = [6, e];
181
- y = 0;
182
- }
183
- finally {
184
- f = t = 0;
185
- }
186
- if (op[0] & 5)
187
- throw op[1];
188
- return { value: op[0] ? op[1] : void 0, done: true };
189
- }
190
- }
191
- var __createBinding = Object.create ? (function (o, m, k, k2) {
192
- if (k2 === undefined)
193
- k2 = k;
194
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
195
- }) : (function (o, m, k, k2) {
196
- if (k2 === undefined)
197
- k2 = k;
198
- o[k2] = m[k];
199
- });
200
- function __exportStar(m, o) {
201
- for (var p in m)
202
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
203
- __createBinding(o, m, p);
204
- }
205
- function __values(o) {
206
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
207
- if (m)
208
- return m.call(o);
209
- if (o && typeof o.length === "number")
210
- return {
211
- next: function () {
212
- if (o && i >= o.length)
213
- o = void 0;
214
- return { value: o && o[i++], done: !o };
215
- }
216
- };
217
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
218
- }
219
- function __read(o, n) {
220
- var m = typeof Symbol === "function" && o[Symbol.iterator];
221
- if (!m)
222
- return o;
223
- var i = m.call(o), r, ar = [], e;
224
- try {
225
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
226
- ar.push(r.value);
227
- }
228
- catch (error) {
229
- e = { error: error };
230
- }
231
- finally {
232
- try {
233
- if (r && !r.done && (m = i["return"]))
234
- m.call(i);
235
- }
236
- finally {
237
- if (e)
238
- throw e.error;
239
- }
240
- }
241
- return ar;
242
- }
243
- /** @deprecated */
244
- function __spread() {
245
- for (var ar = [], i = 0; i < arguments.length; i++)
246
- ar = ar.concat(__read(arguments[i]));
247
- return ar;
248
- }
249
- /** @deprecated */
250
- function __spreadArrays() {
251
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
252
- s += arguments[i].length;
253
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
254
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
255
- r[k] = a[j];
256
- return r;
257
- }
258
- function __spreadArray(to, from) {
259
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
260
- to[j] = from[i];
261
- return to;
262
- }
263
- function __await(v) {
264
- return this instanceof __await ? (this.v = v, this) : new __await(v);
265
- }
266
- function __asyncGenerator(thisArg, _arguments, generator) {
267
- if (!Symbol.asyncIterator)
268
- throw new TypeError("Symbol.asyncIterator is not defined.");
269
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
270
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
271
- function verb(n) { if (g[n])
272
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
273
- function resume(n, v) { try {
274
- step(g[n](v));
275
- }
276
- catch (e) {
277
- settle(q[0][3], e);
278
- } }
279
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
280
- function fulfill(value) { resume("next", value); }
281
- function reject(value) { resume("throw", value); }
282
- function settle(f, v) { if (f(v), q.shift(), q.length)
283
- resume(q[0][0], q[0][1]); }
284
- }
285
- function __asyncDelegator(o) {
286
- var i, p;
287
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
288
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
289
- }
290
- function __asyncValues(o) {
291
- if (!Symbol.asyncIterator)
292
- throw new TypeError("Symbol.asyncIterator is not defined.");
293
- var m = o[Symbol.asyncIterator], i;
294
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
295
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
296
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
297
- }
298
- function __makeTemplateObject(cooked, raw) {
299
- if (Object.defineProperty) {
300
- Object.defineProperty(cooked, "raw", { value: raw });
301
- }
302
- else {
303
- cooked.raw = raw;
304
- }
305
- return cooked;
306
- }
307
- ;
308
- var __setModuleDefault = Object.create ? (function (o, v) {
309
- Object.defineProperty(o, "default", { enumerable: true, value: v });
310
- }) : function (o, v) {
311
- o["default"] = v;
312
- };
313
- function __importStar(mod) {
314
- if (mod && mod.__esModule)
315
- return mod;
316
- var result = {};
317
- if (mod != null)
318
- for (var k in mod)
319
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
320
- __createBinding(result, mod, k);
321
- __setModuleDefault(result, mod);
322
- return result;
323
- }
324
- function __importDefault(mod) {
325
- return (mod && mod.__esModule) ? mod : { default: mod };
326
- }
327
- function __classPrivateFieldGet(receiver, state, kind, f) {
328
- if (kind === "a" && !f)
329
- throw new TypeError("Private accessor was defined without a getter");
330
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
331
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
332
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
333
- }
334
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
335
- if (kind === "m")
336
- throw new TypeError("Private method is not writable");
337
- if (kind === "a" && !f)
338
- throw new TypeError("Private accessor was defined without a setter");
339
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
340
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
341
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
342
- }
343
-
344
- var ArrayOfNPipe = /** @class */ (function () {
345
- function ArrayOfNPipe() {
346
- }
347
- /**
348
- *
349
- * @param n the number to make an array of
350
- * @param max the max length of the array (useful for limiting rendering in ngFor loop)
351
- */
352
- ArrayOfNPipe.prototype.transform = function (n, max) {
353
- var length = ((max && max < n) || n === Infinity) ? max : n;
354
- return new Array(length).fill(length).map(function (x, i) { return i; });
355
- };
356
- return ArrayOfNPipe;
357
- }());
358
- ArrayOfNPipe.decorators = [
359
- { type: i0.Pipe, args: [{
360
- name: 'arrayOfN'
361
- },] }
362
- ];
363
-
364
- var INTERACT_ROOT_CONFIG = new i0.InjectionToken('INTERACT_ROOT_CONFIG_PARAMS');
365
- var DEFAULT_REGISTRY_ID = 'DEFAULT';
366
- /**
367
- * Default initial value for Delta BehaviorSubject
368
- */
369
- var defaultDelta = {
370
- deltaX: 0,
371
- deltaY: 0,
372
- targetElement: null
373
- };
374
- /**
375
- * Default initial value for Size BehaviorSubject
376
- */
377
- var defaultSize = {
378
- width: null,
379
- height: null,
380
- targetElement: null
381
- };
382
- /**
383
- * Default initial value for Position BehaviorSubject
384
- */
385
- var defaultPosition = {
386
- x: 0,
387
- y: 0,
388
- targetElement: null
389
- };
390
-
391
- var InteractService = /** @class */ (function () {
392
- function InteractService(rendererFactory, ngZone, rootConfig) {
393
- this.rendererFactory = rendererFactory;
394
- this.ngZone = ngZone;
395
- this.rootConfig = rootConfig;
396
- this._interactableIndex = 0;
397
- this._dropzoneIndex = 0;
398
- // TODO: consider using Map here
399
- this.dragRegistrySystem = {};
400
- this.cssUnit = 'px';
401
- this.renderer = this.rendererFactory.createRenderer(null, null);
402
- this.cssUnit = (rootConfig === null || rootConfig === void 0 ? void 0 : rootConfig.cssDimensionUnit) || 'px';
403
- }
404
- InteractService.prototype.addDeltaToPosition = function (delta, position) {
405
- return {
406
- x: delta.deltaX + position.x,
407
- y: delta.deltaY + position.y,
408
- targetElement: position.targetElement || delta.targetElement
409
- };
410
- };
411
- InteractService.prototype.addRegistryToSystem = function (customRegistryId) {
412
- if (customRegistryId === void 0) { customRegistryId = null; }
413
- var registryId = customRegistryId || this.createDropzoneId(this._dropzoneIndex++);
414
- this.dragRegistrySystem[registryId] = {};
415
- return registryId;
416
- };
417
- InteractService.prototype.addDraggableToRegistry = function (customRegistryId, interactableId) {
418
- if (customRegistryId === void 0) { customRegistryId = null; }
419
- if (interactableId === void 0) { interactableId = null; }
420
- var registryId = customRegistryId || DEFAULT_REGISTRY_ID;
421
- // if we pass an id to createInteractableId then it is used when creating the interactable
422
- // and returned, otherwise a new id is created for the draggable.
423
- var key = this.createInteractableId(interactableId);
424
- if (!Object.prototype.hasOwnProperty.call(this.dragRegistrySystem, registryId)) {
425
- this.dragRegistrySystem[registryId] = {};
426
- }
427
- this.dragRegistrySystem[registryId][key] = this.createInteractableState(defaultPosition, defaultSize, defaultDelta);
428
- return key;
429
- };
430
- InteractService.prototype.destroyInteractable = function (interactableId, registryId) {
431
- if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
432
- var interactableSystem = this.dragRegistrySystem[registryId][interactableId];
433
- if (interactableSystem) {
434
- // unsubscribe from all the subscriptions if they're subscriptions
435
- for (var propName in interactableSystem) {
436
- var prop = interactableSystem[propName];
437
- if (prop.unsubscribe && typeof prop.unsubscribe === 'function') {
438
- prop.unsubscribe();
439
- }
440
- ;
441
- }
442
- delete this.dragRegistrySystem[registryId][interactableId];
443
- }
444
- };
445
- InteractService.prototype.subscribeToInteractable = function (interactableId, registryId) {
446
- if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
447
- return this.dragRegistrySystem[registryId][interactableId];
448
- };
449
- InteractService.prototype.createInteractableState = function (initialPosition, initialSize, initialDelta) {
450
- var _this = this;
451
- var deltas$ = new rxjs.BehaviorSubject(initialDelta);
452
- // tracks the size of the element
453
- var size$ = new rxjs.BehaviorSubject(Object.assign(Object.assign({}, initialSize), initialDelta));
454
- // Stream of positions as they change
455
- var position$ = new rxjs.BehaviorSubject(initialPosition);
456
- // All draggable data mapped together
457
- var interactable$ = rxjs.combineLatest([
458
- size$.pipe(
459
- // startWith({...initialSize, ...initialDelta}),
460
- operators.shareReplay(1),
461
- // filter(resizeEvent => !!resizeEvent.targetElement),
462
- operators.tap(function (_a) {
463
- var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height, targetElement = _a.targetElement;
464
- _this.ngZone.runOutsideAngular(function () {
465
- _this.setElementSize(width, height, targetElement);
466
- });
467
- // only reposition if necessary i.e when resizing left or up
468
- if (deltaX || deltaY) {
469
- deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
470
- }
471
- })),
472
- deltas$.pipe(operators.shareReplay(1), operators.tap(function (delta) {
473
- var position = position$.value;
474
- var newPosition = _this.addDeltaToPosition(delta, position);
475
- position$.next(newPosition);
476
- })),
477
- position$.pipe(operators.shareReplay(1), operators.tap(function (position) {
478
- _this.ngZone.runOutsideAngular(function () {
479
- _this.setElementTransform(position.x, position.y, position);
480
- });
481
- }))
482
- ]).pipe(operators.shareReplay(1), operators.map(function (_a) {
483
- var _b = __read(_a, 3), size = _b[0], deltas = _b[1], position = _b[2];
484
- return {
485
- x: position.x,
486
- y: position.y,
487
- deltaX: deltas.deltaX,
488
- deltaY: deltas.deltaY,
489
- width: size.width,
490
- height: size.height,
491
- targetElement: size.targetElement || position.targetElement || deltas.targetElement
492
- };
493
- }));
494
- // TODO: update system to handle only returning interactable$
495
- return {
496
- deltas$: deltas$,
497
- position$: position$,
498
- size$: size$,
499
- interactable$: interactable$
500
- };
501
- };
502
- InteractService.prototype.createInteractableId = function (customInteractableId) {
503
- if (customInteractableId === void 0) { customInteractableId = null; }
504
- return customInteractableId || "interactable" + this._interactableIndex++;
505
- };
506
- InteractService.prototype.createDropzoneId = function (index) {
507
- return "dropzone" + index;
508
- };
509
- InteractService.prototype.getInteractableState = function (interactableId, registryId) {
510
- if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
511
- return this.dragRegistrySystem[registryId][interactableId].interactable$;
512
- };
513
- InteractService.prototype.updateDeltas = function (interactId, registryId, _a, targetElement) {
514
- var deltaX = _a.deltaX, deltaY = _a.deltaY;
515
- if (!this.interactableExistOnRegistry(interactId, registryId))
516
- return;
517
- this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
518
- };
519
- InteractService.prototype.updatePosition = function (interactId, registryId, _a, targetElement) {
520
- var x = _a.x, y = _a.y;
521
- if (!this.interactableExistOnRegistry(interactId, registryId))
522
- return;
523
- this.dragRegistrySystem[registryId][interactId].position$.next({ x: x, y: y, targetElement: targetElement });
524
- };
525
- InteractService.prototype.updateSize = function (interactId, registryId, _a, targetElement) {
526
- var deltaX = _a.deltaX, deltaY = _a.deltaY, width = _a.width, height = _a.height;
527
- if (!this.interactableExistOnRegistry(interactId, registryId))
528
- return;
529
- this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX: deltaX, deltaY: deltaY, width: width, height: height, targetElement: targetElement });
530
- };
531
- InteractService.prototype.interactableExistOnRegistry = function (interactId, registryId) {
532
- if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
533
- // eslint-disable-next-line no-prototype-builtins
534
- return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
535
- };
536
- /**
537
- * Uses renderer to set width and height of angular component
538
- * @param width the desired width of component
539
- * @param height the desired height of component
540
- * @param target the element to transform
541
- */
542
- InteractService.prototype.setElementSize = function (width, height, target) {
543
- if (!target)
544
- return;
545
- this.renderer.setStyle(target, 'width', "" + width + this.cssUnit);
546
- this.renderer.setStyle(target, 'height', "" + height + this.cssUnit);
547
- };
548
- /**
549
- * Uses renderer to set position of angular component
550
- * @param x position on x axis
551
- * @param y position on y axis
552
- * @param target the element to transform
553
- */
554
- InteractService.prototype.setElementTransform = function (x, y, position) {
555
- if (!(position === null || position === void 0 ? void 0 : position.targetElement))
556
- return;
557
- this.renderer.setStyle(position.targetElement, 'left', "" + x + this.cssUnit);
558
- this.renderer.setStyle(position.targetElement, 'top', "" + y + this.cssUnit);
559
- };
560
- /**
561
- * Generates a translate string for the x and y arguments passed to
562
- * be passed to css transform
563
- * @param x the position along the x axis
564
- * @param y the position along the y axis
565
- */
566
- InteractService.prototype.createTransformString = function (x, y) {
567
- return "translate3d(" + x + this.cssUnit + ", " + y + this.cssUnit + ", 0)";
568
- };
569
- InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement, scale) {
570
- // TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
571
- var zoneRect = zoneElement.getBoundingClientRect();
572
- var dragRect = dragElement.getBoundingClientRect();
573
- var position = scale
574
- ? {
575
- x: (dragRect.left - zoneRect.left) / scale || 1,
576
- y: (dragRect.top - zoneRect.top) / scale || 1
577
- } : {
578
- x: dragRect.left - zoneRect.left,
579
- y: dragRect.top - zoneRect.top
580
- };
581
- // console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
582
- return position;
583
- };
584
- return InteractService;
585
- }());
586
- InteractService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function InteractService_Factory() { return new InteractService(i0__namespace.ɵɵinject(i0__namespace.RendererFactory2), i0__namespace.ɵɵinject(i0__namespace.NgZone), i0__namespace.ɵɵinject(INTERACT_ROOT_CONFIG, 8)); }, token: InteractService, providedIn: "root" });
587
- InteractService.decorators = [
588
- { type: i0.Injectable, args: [{ providedIn: 'root' },] }
589
- ];
590
- InteractService.ctorParameters = function () { return [
591
- { type: i0.RendererFactory2 },
592
- { type: i0.NgZone },
593
- { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [INTERACT_ROOT_CONFIG,] }] }
594
- ]; };
595
-
596
- /**
597
- * Use to apply scale to the element and tell the drag and resize directives to account for the scale when
598
- * @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
599
- * @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
600
- * element accounts for scale
601
- */
602
- var AccountForScaleDirective = /** @class */ (function () {
603
- function AccountForScaleDirective(el) {
604
- this.el = el;
605
- // this setup allows consumers to set x, y scale independently or just set them both with scale
606
- this.scale = 1;
607
- }
608
- return AccountForScaleDirective;
609
- }());
610
- AccountForScaleDirective.decorators = [
611
- { type: i0.Directive, args: [{
612
- selector: '[tftAccountForScale]'
613
- },] }
614
- ];
615
- AccountForScaleDirective.ctorParameters = function () { return [
616
- { type: i0.ElementRef }
617
- ]; };
618
- AccountForScaleDirective.propDecorators = {
619
- scale: [{ type: i0.Input }]
620
- };
621
-
622
- var DropzoneDirective = /** @class */ (function () {
623
- function DropzoneDirective(el, renderer, interactService, account_for_scale_dir) {
624
- this.el = el;
625
- this.renderer = renderer;
626
- this.interactService = interactService;
627
- this.account_for_scale_dir = account_for_scale_dir;
628
- this.dropzoneConfig = {};
629
- this.position = 'relative';
630
- // proxies to pass interact events through to consumer of directive
631
- this.dropActivate = new i0.EventEmitter();
632
- this.dragEnter = new i0.EventEmitter();
633
- this.dragLeave = new i0.EventEmitter();
634
- this.dragDrop = new i0.EventEmitter();
635
- }
636
- Object.defineProperty(DropzoneDirective.prototype, "scale", {
637
- get: function () {
638
- var _a;
639
- return (_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale;
640
- },
641
- enumerable: false,
642
- configurable: true
643
- });
644
- DropzoneDirective.prototype.ngOnInit = function () {
645
- // connects
646
- this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
647
- this.dropzoneId = this.interactService.addRegistryToSystem(this.dropzoneId);
648
- };
649
- DropzoneDirective.prototype.ngOnChanges = function (changes) {
650
- if (!changes.dropzoneConfig || !this.dropzone)
651
- return;
652
- // this.dropzone.unset();
653
- // this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig)
654
- this.dropzone.dropzone(this.dropzoneConfig);
655
- };
656
- /**
657
- * Connects element to interacts dropzone events and returns a reference to the interactable
658
- * @param nativeElement the element to tie drop events to
659
- * @param dropzoneConfig the interact configuration to use when connecting
660
- */
661
- DropzoneDirective.prototype.connectDropzoneEvents = function (nativeElement, dropzoneConfig) {
662
- var _this = this;
663
- return interact__default['default'](nativeElement).dropzone(dropzoneConfig)
664
- // TODO: investigate when this fires in different scenarios
665
- .on('dropactivate', function (event) {
666
- _this.dropActivate.emit(_this.mapDropzoneEvent(event));
667
- })
668
- .on('dragenter', function (event) {
669
- _this.renderer.setProperty(event.relatedTarget, 'dropTarget', _this);
670
- _this.dragEnter.emit(_this.mapDropzoneEvent(event));
671
- })
672
- .on('dragleave', function (event) {
673
- if (event.relatedTarget.dropTarget === _this) {
674
- _this.renderer.setProperty(event.relatedTarget, 'dropTarget', null);
675
- }
676
- _this.dragLeave.emit(_this.mapDropzoneEvent(event));
677
- })
678
- .on('drop', function (event) {
679
- _this.dragDrop.emit(_this.mapDropzoneEvent(event));
680
- });
681
- };
682
- /**
683
- * Maps the drop event emitted by interact to something a little easier to use
684
- * @param event the drop event emitted by interact, extended with extra fields we added to
685
- */
686
- DropzoneDirective.prototype.mapDropzoneEvent = function (event) {
687
- var _a, _b;
688
- var zoneElement = event.target;
689
- var dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
690
- var scale = this.scale;
691
- var positionInDropTarget = zoneElement && dragElement
692
- ? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
693
- : null;
694
- return {
695
- interactEvent: event,
696
- dragRef: dragElement.dragRef,
697
- dragOrigin: dragElement.dragOrigin,
698
- dropTarget: event.relatedTarget.dropTarget,
699
- positionInDropTarget: positionInDropTarget
700
- };
701
- };
702
- return DropzoneDirective;
703
- }());
704
- DropzoneDirective.decorators = [
705
- { type: i0.Directive, args: [{
706
- selector: '[tftDropzone]',
707
- host: {
708
- '[id]': 'dropzoneId'
709
- }
710
- },] }
711
- ];
712
- DropzoneDirective.ctorParameters = function () { return [
713
- { type: i0.ElementRef },
714
- { type: i0.Renderer2 },
715
- { type: InteractService },
716
- { type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] }
717
- ]; };
718
- DropzoneDirective.propDecorators = {
719
- dropzoneId: [{ type: i0.Input }],
720
- dropzoneConfig: [{ type: i0.Input }],
721
- dropzoneData: [{ type: i0.Input }],
722
- position: [{ type: i0.Input }, { type: i0.HostBinding, args: ['style.position',] }],
723
- dropActivate: [{ type: i0.Output }],
724
- dragEnter: [{ type: i0.Output }],
725
- dragLeave: [{ type: i0.Output }],
726
- dragDrop: [{ type: i0.Output }]
727
- };
728
-
729
- var TFT_DRAG_PREVIEW = new i0.InjectionToken('DragPreviewDirective');
730
- var DragPreviewDirective = /** @class */ (function () {
731
- function DragPreviewDirective(templateRef) {
732
- this.templateRef = templateRef;
733
- }
734
- return DragPreviewDirective;
735
- }());
736
- DragPreviewDirective.decorators = [
737
- { type: i0.Directive, args: [{
738
- // eslint-disable-next-line @angular-eslint/directive-selector
739
- selector: 'ng-template[tftDragPreview]',
740
- },] }
741
- ];
742
- DragPreviewDirective.ctorParameters = function () { return [
743
- { type: i0.TemplateRef }
744
- ]; };
745
- DragPreviewDirective.propDecorators = {
746
- dragData: [{ type: i0.Input }]
747
- };
748
-
749
- /** Gets the closest ancestor of an element that matches a selector. */
750
- function getClosestMatchingAncestor(element, selector) {
751
- var currentElement = element.parentElement;
752
- while (currentElement) {
753
- // IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
754
- if (currentElement.matches ? currentElement.matches(selector) :
755
- currentElement.msMatchesSelector(selector)) {
756
- return currentElement;
757
- }
758
- currentElement = currentElement.parentElement;
759
- }
760
- return null;
761
- }
762
- /**
763
- * Create a copy of the HTML Element
764
- */
765
- function cloneElement$1(element) {
766
- var clone = element.cloneNode(true);
767
- clone.removeAttribute('id');
768
- return clone;
769
- }
770
- /**
771
- * Gets the root HTML element of an embedded view.
772
- * If the root is not an HTML element it gets wrapped in one.
773
- */
774
- function getRootNode(viewRef, _document) {
775
- var rootNodes = viewRef.rootNodes;
776
- if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
777
- return rootNodes[0];
778
- }
779
- var wrapper = _document.createElement('div');
780
- rootNodes.forEach(function (node) { return wrapper.appendChild(node); });
781
- return wrapper;
782
- }
783
-
784
- /**
785
- * Use this directive to select which element to attach the element to while dragging
786
- * @example <div tftDragRoot><div tftDraggable> </div> </div>
787
- * @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
788
- */
789
- var DragRootDirective = /** @class */ (function () {
790
- function DragRootDirective(el,
791
- // This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
792
- // It allows the the interact service to check if the drag root has some scaling applied to it and account for it when the component is dragged
793
- account_for_scale_dir) {
794
- this.el = el;
795
- this.account_for_scale_dir = account_for_scale_dir;
796
- }
797
- return DragRootDirective;
798
- }());
799
- DragRootDirective.decorators = [
800
- { type: i0.Directive, args: [{
801
- selector: '[tftDragRoot]',
802
- exportAs: 'tftDragRoot'
803
- },] }
804
- ];
805
- DragRootDirective.ctorParameters = function () { return [
806
- { type: i0.ElementRef },
807
- { type: AccountForScaleDirective, decorators: [{ type: i0.Optional }, { type: i0.Self }] }
808
- ]; };
809
-
810
- ;
811
- /**
812
- * Use to apply scale to the element and tell the drag and resize directives to account for the scale when
813
- * @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
814
- * @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
815
- * element accounts for scale
816
- */
817
- var AutoScrollDirective = /** @class */ (function () {
818
- function AutoScrollDirective(el) {
819
- var _this = this;
820
- this.el = el;
821
- /**
822
- * Limit minimum time between scroll events in milliseconds
823
- */
824
- this.autoScrollConfig = {
825
- margin: 50,
826
- distance: 3,
827
- interval: 50,
828
- speed: 300,
829
- enabled: true
830
- };
831
- this.scrollDeltaObserver = new rxjs.Subject();
832
- var _a = el.nativeElement, scrollTop = _a.scrollTop, scrollLeft = _a.scrollLeft;
833
- this.scrollSubject = new rxjs.BehaviorSubject({ scrollTop: scrollTop, scrollLeft: scrollLeft });
834
- this.scrollObserver = this.scrollSubject.pipe(operators.scan(function (previous, current) {
835
- var scrollTop = current.scrollTop - previous.scrollTop;
836
- var scrollLeft = current.scrollLeft - previous.scrollLeft;
837
- _this.scrollDeltaObserver.next({ scrollTop: scrollTop, scrollLeft: scrollLeft });
838
- return current;
839
- }), operators.shareReplay(1));
840
- this.scrollObserver.subscribe();
841
- }
842
- // this setup allows consumers to set x, y scale independently or just set them both with scale
843
- AutoScrollDirective.prototype.scroll = function (scrollEvent) {
844
- var target = scrollEvent.target;
845
- var scrollTop = target.scrollTop, scrollLeft = target.scrollLeft;
846
- this.scrollSubject.next({ scrollTop: scrollTop, scrollLeft: scrollLeft });
847
- };
848
- return AutoScrollDirective;
849
- }());
850
- AutoScrollDirective.decorators = [
851
- { type: i0.Directive, args: [{
852
- selector: '[tftAutoScroll]'
853
- },] }
854
- ];
855
- AutoScrollDirective.ctorParameters = function () { return [
856
- { type: i0.ElementRef }
857
- ]; };
858
- AutoScrollDirective.propDecorators = {
859
- autoScrollConfig: [{ type: i0.Input }],
860
- scroll: [{ type: i0.HostListener, args: ['scroll', ['$event'],] }]
861
- };
862
-
863
- /** @dynamic */
864
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
865
- var DraggableDirective = /** @class */ (function () {
866
- function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir, auto_scroll_dir) {
867
- this.el = el;
868
- this.interactService = interactService;
869
- this.renderer = renderer;
870
- this._viewContainerRef = _viewContainerRef;
871
- this._document = _document;
872
- this.account_for_scale_dir = account_for_scale_dir;
873
- this.dropzone_dir = dropzone_dir;
874
- this.drag_root_dir = drag_root_dir;
875
- this.auto_scroll_dir = auto_scroll_dir;
876
- /* zIndex while dragging*/
877
- this.dragZIndex = 10000;
878
- this.enableDragDefault = true;
879
- /**
880
- * @deprecated replaced by 'dragDisabled' property, please migrate before v13
881
- */
882
- this.disabled = false;
883
- this.dragDisabled = false;
884
- this.showPlaceholder = false;
885
- // pipes all interact events to event emitters
886
- this.dragStart = new i0.EventEmitter();
887
- this.dragMove = new i0.EventEmitter();
888
- this.dragInertiaStart = new i0.EventEmitter();
889
- this.dragEnd = new i0.EventEmitter();
890
- }
891
- Object.defineProperty(DraggableDirective.prototype, "scale", {
892
- // check all the different places for scale
893
- get: function () {
894
- var _a, _b, _c, _d;
895
- return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir.scale) || ((_d = (_c = this.dragRoot) === null || _c === void 0 ? void 0 : _c.account_for_scale_dir) === null || _d === void 0 ? void 0 : _d.scale);
896
- },
897
- enumerable: false,
898
- configurable: true
899
- });
900
- DraggableDirective.prototype.ngOnInit = function () {
901
- var _this = this;
902
- var _a, _b, _c, _d, _e;
903
- this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
904
- this.dragRootEl = (((_b = (_a = this.dragRoot) === null || _a === void 0 ? void 0 : _a.el) === null || _b === void 0 ? void 0 : _b.nativeElement) || ((_d = (_c = this.drag_root_dir) === null || _c === void 0 ? void 0 : _c.el) === null || _d === void 0 ? void 0 : _d.nativeElement)) || this._document.body;
905
- // register with parent dropzone if it exists, otherwise use default
906
- // this gives us a place on the registry to store our drag items that don't have a dropzone
907
- this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
908
- // add draggable to directory and store its id
909
- this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
910
- this.alignPositionWithInputs(this.x, this.y);
911
- // cache subscription to interactable state so we can unsubscribe onDestroy
912
- this.interactableState = this.interactService
913
- .getInteractableState(this.interactableId, this.registryId);
914
- // keep our cached position values in line with our drag state
915
- this.interactableSubscription = this.interactableState.subscribe(function (state) {
916
- _this.y = state.y;
917
- _this.x = state.x;
918
- });
919
- this.setDragConfig();
920
- };
921
- // TODO: watch config here as well and update interactable
922
- DraggableDirective.prototype.ngOnChanges = function (changes) {
923
- // we do this here instead of using a setter on the input so that it
924
- // will only run once when there is a change to x and y
925
- if (changes.y || changes.x) {
926
- this.alignPositionWithInputs(this.x, this.y);
927
- }
928
- if (changes.dragConfig || changes.disabled || changes.dragDisabled) {
929
- if (!this.interactable)
930
- return;
931
- this.setDragConfig();
932
- }
933
- /**
934
- * @deprecated remove this in v13
935
- */
936
- if (changes.disabled) {
937
- console.warn("It looks like your using the 'disabled' input on a tftDraggable directive, it has been deprecated and is replaced with 'dragDisabled', please migrate by v13");
938
- }
939
- };
940
- DraggableDirective.prototype.setDragConfig = function () {
941
- var enabled = !(this.disabled || this.dragDisabled);
942
- var dragConfig = Object.assign(Object.assign({}, this.dragConfig), { enabled: enabled });
943
- this.interactable.draggable(dragConfig);
944
- };
945
- DraggableDirective.prototype.ngAfterViewInit = function () {
946
- this.addDragPropertiesToElement(this.el.nativeElement);
947
- if (!this.dropzone_dir) {
948
- this.previewRef = this.el.nativeElement;
949
- }
950
- };
951
- DraggableDirective.prototype.ngOnDestroy = function () {
952
- // clean up state and subscriptions related to destroyed component
953
- this.interactableSubscription.unsubscribe();
954
- this.interactService.destroyInteractable(this.interactableId, this.registryId);
955
- };
956
- DraggableDirective.prototype.dragMoveListener = function (event, element) {
957
- var dx = event.dx, dy = event.dy;
958
- var scale = this.scale;
959
- var deltaX = scale ? dx / scale : dx;
960
- var deltaY = scale ? dy / scale : dy;
961
- this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY }, element);
962
- };
963
- DraggableDirective.prototype.setDragStyles = function (dragElement) {
964
- this.renderer.setStyle(dragElement, 'touchAction', 'none');
965
- this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
966
- this.renderer.setStyle(dragElement, 'position', 'absolute');
967
- };
968
- DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
969
- this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
970
- this.renderer.setProperty(nativeElement, 'dragOrigin', this.dropzone_dir || null);
971
- this.renderer.setProperty(nativeElement, 'dragRef', this);
972
- };
973
- DraggableDirective.prototype.mapDragEvent = function (event) {
974
- var _a;
975
- var target = event.target, dropzone = event.dropzone;
976
- var dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
977
- var scale = this.scale;
978
- var positionInDropTarget = target && dropzoneElement
979
- ? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef, scale)
980
- : null;
981
- return {
982
- interactEvent: event,
983
- dragRef: this,
984
- dragOrigin: target.dragOrigin,
985
- dropTarget: target.dropTarget,
986
- positionInDropTarget: positionInDropTarget
987
- };
988
- };
989
- DraggableDirective.prototype.setPosition = function (x, y) {
990
- this.interactService.updatePosition(this.interactableId, this.registryId, { x: x, y: y }, this.el.nativeElement);
991
- };
992
- DraggableDirective.prototype.alignPositionWithInputs = function (x, y) {
993
- // short circuit if positions aren't numbers or if they haven't changed
994
- if (!this.isValidPosition(x, y))
995
- return;
996
- this.interactService.updatePosition(this.interactableId, this.registryId, { x: x, y: y }, this.el.nativeElement);
997
- };
998
- DraggableDirective.prototype.isValidPosition = function (x, y) {
999
- return this.isNumeric(x) && this.isNumeric(y);
1000
- };
1001
- // We use use this instead of isNaN here to try and help performance
1002
- // We should be able to reliably restrict to numbers or falsey values
1003
- DraggableDirective.prototype.isNumeric = function (num) {
1004
- return typeof num === 'number' && !isNaN(num);
1005
- };
1006
- DraggableDirective.prototype.initiateDragEvents = function (dragConfig, nativeElement) {
1007
- var _this = this;
1008
- var defaultDragConfig = Object.assign(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }), (this.auto_scroll_dir && {
1009
- autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
1010
- }));
1011
- return interact__default['default'](nativeElement).draggable(defaultDragConfig)
1012
- .on('dragstart', function (event) {
1013
- var _a, _b, _c;
1014
- var interaction = event.interaction;
1015
- // check if we should append drag element to body
1016
- if (_this.enableDragDefault
1017
- && interaction.pointerIsDown
1018
- // TODO: probably don't need following condition checks anymore remove by 2022
1019
- // && !!this.dropzone_dir
1020
- // && !interaction.interacting()
1021
- ) {
1022
- if (_this._previewTemplate) {
1023
- var viewRef = _this._viewContainerRef.createEmbeddedView(_this._previewTemplate.templateRef);
1024
- _this.previewRef = getRootNode(viewRef, _this._document);
1025
- }
1026
- else {
1027
- _this.previewRef = cloneElement(_this.el.nativeElement);
1028
- }
1029
- _this.addDragPropertiesToElement(_this.previewRef);
1030
- _this.setDragStyles(_this.previewRef);
1031
- _this.dragRootEl.prepend(_this.previewRef);
1032
- var scale = ((_a = _this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = _this.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || 1;
1033
- var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement, scale), x = _f.x, y = _f.y;
1034
- _this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
1035
- if (!_this.showPlaceholder) {
1036
- _this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
1037
- }
1038
- }
1039
- // subscribe to scroll events if they are there, by only subscribing on dragstart we avoid wasting subscriptions on interactables that aren't be dragged
1040
- if (_this.auto_scroll_dir) {
1041
- _this.subscribeToScrollEvents();
1042
- }
1043
- _this.dragStart.emit(_this.mapDragEvent(event));
1044
- })
1045
- .on('dragmove', function (event) {
1046
- if (_this.enableDragDefault) {
1047
- var dragElement = _this.dropzone_dir && _this.previewRef || nativeElement;
1048
- _this.dragMoveListener(event, dragElement);
1049
- }
1050
- var mappedEvent = _this.mapDragEvent(event);
1051
- _this.dragMove.emit(mappedEvent);
1052
- })
1053
- .on('draginertiastart', function (event) {
1054
- _this.dragInertiaStart.emit(_this.mapDragEvent(event));
1055
- })
1056
- .on('dragend', function (event) {
1057
- var mappedEvent = _this.mapDragEvent(event);
1058
- if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
1059
- var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
1060
- _this.setPosition(x, y);
1061
- }
1062
- _this.renderer.setStyle(_this.el.nativeElement, 'display', '');
1063
- _this.dragEnd.emit(mappedEvent);
1064
- // unsubscribe from scroll events if subscribed
1065
- if (_this.auto_scroll_dir) {
1066
- _this.scrollEventsSubscription.unsubscribe();
1067
- }
1068
- if (_this.el.nativeElement !== _this.previewRef) {
1069
- // we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
1070
- setTimeout(function () {
1071
- _this.dragRootEl.removeChild(_this.previewRef);
1072
- });
1073
- }
1074
- });
1075
- };
1076
- DraggableDirective.prototype.subscribeToScrollEvents = function () {
1077
- var _this = this;
1078
- this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(function (_f) {
1079
- var scrollLeft = _f.scrollLeft, scrollTop = _f.scrollTop;
1080
- var deltaX = _this.scale ? scrollLeft / _this.scale : scrollLeft;
1081
- var deltaY = _this.scale ? scrollTop / _this.scale : scrollTop;
1082
- _this.interactService.updateDeltas(_this.interactableId, _this.registryId, { deltaX: deltaX, deltaY: deltaY }, _this.previewRef);
1083
- });
1084
- };
1085
- return DraggableDirective;
1086
- }());
1087
- DraggableDirective.decorators = [
1088
- { type: i0.Directive, args: [{
1089
- selector: '[tftDraggable]',
1090
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
1091
- host: {
1092
- '[style.touchAction]': 'this.dragDisabled ? "auto" : "none"',
1093
- '[style.position]': '"absolute"',
1094
- '[id]': 'interactableId',
1095
- }
1096
- },] }
1097
- ];
1098
- DraggableDirective.ctorParameters = function () { return [
1099
- { type: i0.ElementRef },
1100
- { type: InteractService },
1101
- { type: i0.Renderer2 },
1102
- { type: i0.ViewContainerRef },
1103
- { type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
1104
- { type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
1105
- { type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
1106
- { type: DragRootDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
1107
- { type: AutoScrollDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
1108
- ]; };
1109
- DraggableDirective.propDecorators = {
1110
- x: [{ type: i0.Input }],
1111
- y: [{ type: i0.Input }],
1112
- dragZIndex: [{ type: i0.Input }],
1113
- zIndex: [{ type: i0.Input }],
1114
- interactableId: [{ type: i0.Input }],
1115
- dragData: [{ type: i0.Input }],
1116
- enableDragDefault: [{ type: i0.Input }],
1117
- disabled: [{ type: i0.Input }],
1118
- dragDisabled: [{ type: i0.Input }],
1119
- dragConfig: [{ type: i0.Input }],
1120
- showPlaceholder: [{ type: i0.Input }],
1121
- dragRoot: [{ type: i0.Input }],
1122
- dragStart: [{ type: i0.Output }],
1123
- dragMove: [{ type: i0.Output }],
1124
- dragInertiaStart: [{ type: i0.Output }],
1125
- dragEnd: [{ type: i0.Output }],
1126
- _previewTemplate: [{ type: i0.ContentChild, args: [DragPreviewDirective,] }]
1127
- };
1128
- /**
1129
- * Component utils
1130
- */
1131
- // create a clone of the component passed in and add it to the root component
1132
- function cloneElement(element) {
1133
- var clone = element.cloneNode(true);
1134
- clone.removeAttribute('id');
1135
- return clone;
1136
- }
1137
- function getPreviewInsertionPoint(documentRef) {
1138
- // We can't use the body if the user is in fullscreen mode,
1139
- // because the preview will render under the fullscreen element.
1140
- return documentRef.fullscreenElement ||
1141
- documentRef.webkitFullscreenElement ||
1142
- documentRef.mozFullScreenElement ||
1143
- documentRef.msFullscreenElement ||
1144
- documentRef.body;
1145
- }
1146
-
1147
- /** @dynamic */
1148
- var ResizableDirective = /** @class */ (function () {
1149
- function ResizableDirective(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir, auto_scroll_dir) {
1150
- var _a;
1151
- this.el = el;
1152
- this._document = _document;
1153
- this.interactService = interactService;
1154
- this.renderer = renderer;
1155
- this.drag_root_dir = drag_root_dir;
1156
- this.account_for_scale_dir = account_for_scale_dir;
1157
- this.draggable_dir = draggable_dir;
1158
- this.dropzone_dir = dropzone_dir;
1159
- this.auto_scroll_dir = auto_scroll_dir;
1160
- this.enableResizeDefault = true;
1161
- // TODO: should this be an input with default or should consuming user set display in styles each time
1162
- this.position = 'absolute';
1163
- this.resizeDisabled = false;
1164
- this.resizeStart = new i0.EventEmitter();
1165
- this.resizeMove = new i0.EventEmitter();
1166
- this.resizeInertiaStart = new i0.EventEmitter();
1167
- this.resizeEnd = new i0.EventEmitter();
1168
- this.defaultConfig = {
1169
- edges: { left: true, right: true, bottom: true, top: true }
1170
- };
1171
- this.activeEdges = { left: false, right: false, top: false, bottom: false };
1172
- this.dragRootEl = ((_a = drag_root_dir === null || drag_root_dir === void 0 ? void 0 : drag_root_dir.el) === null || _a === void 0 ? void 0 : _a.nativeElement) || this._document.body;
1173
- }
1174
- Object.defineProperty(ResizableDirective.prototype, "scale", {
1175
- get: function () {
1176
- var _a, _b, _c;
1177
- return ((_a = this.account_for_scale_dir) === null || _a === void 0 ? void 0 : _a.scale) || ((_c = (_b = this.drag_root_dir) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale);
1178
- },
1179
- enumerable: false,
1180
- configurable: true
1181
- });
1182
- ResizableDirective.prototype.ngOnInit = function () {
1183
- var _a, _b;
1184
- this.addResizePropertiesToElement(this.el.nativeElement);
1185
- // we check for a dropzone, we use its id as the registry id if there is on
1186
- // otherwise, we use DEFAULT_REGISTRY_ID as a registry id. This allows us to keep our interactable
1187
- // drag state organized by dropzones.
1188
- this.registryId = ((_a = this.dropzone_dir) === null || _a === void 0 ? void 0 : _a.dropzoneId) || DEFAULT_REGISTRY_ID;
1189
- this.interactableId = ((_b = this.draggable_dir) === null || _b === void 0 ? void 0 : _b.interactableId) || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
1190
- this.interactable = this.initiateResizeEvents(Object.assign(Object.assign({}, this.defaultConfig), this.resizeConfig), this.el.nativeElement);
1191
- this.alignDimensionsWithInputs(this.width, this.height);
1192
- this.interactableSubscription = this.interactService
1193
- .getInteractableState(this.interactableId, this.registryId)
1194
- .subscribe();
1195
- };
1196
- ResizableDirective.prototype.ngOnChanges = function (changes) {
1197
- if ((changes.resizeConfig || changes.resizeDisabled) && this.interactable) {
1198
- this.interactable.resizable(Object.assign(Object.assign({}, this.resizeConfig), { enabled: !this.resizeDisabled }));
1199
- }
1200
- if (changes.width || changes.height) {
1201
- this.alignDimensionsWithInputs(this.width, this.height);
1202
- }
1203
- };
1204
- ResizableDirective.prototype.ngOnDestroy = function () {
1205
- this.interactableSubscription.unsubscribe();
1206
- this.interactService.destroyInteractable(this.interactableId, this.registryId);
1207
- };
1208
- ResizableDirective.prototype.resizeListener = function (event) {
1209
- var element = this.el.nativeElement;
1210
- var scale = this.scale;
1211
- var deltaRect = event.deltaRect;
1212
- var deltaX = deltaRect.left / scale;
1213
- var deltaY = deltaRect.top / scale;
1214
- // We get the width and height directly from the native element because
1215
- // the event dimension can get out of sync when resizing with autoScroll
1216
- var rect = element.getBoundingClientRect();
1217
- var width = (rect.width + deltaRect.width) / scale;
1218
- var height = (rect.height + deltaRect.height) / scale;
1219
- this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, this.el.nativeElement);
1220
- };
1221
- /**
1222
- * hook elements into interacts resize event listeners
1223
- * we spread the configs so that the consuming component only overwrites the
1224
- * pieces that it explicitly indicates
1225
- * @param resizeConfig
1226
- * @param nativeElement
1227
- */
1228
- ResizableDirective.prototype.initiateResizeEvents = function (resizeConfig, nativeElement) {
1229
- var _this = this;
1230
- var _a;
1231
- // TODO: This should try and get interactable from tft_draggable if it exists
1232
- var defaultResizeConfig = Object.assign(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }), (this.auto_scroll_dir && {
1233
- autoScroll: Object.assign(Object.assign({}, this.auto_scroll_dir.autoScrollConfig), { container: this.auto_scroll_dir.el.nativeElement })
1234
- }));
1235
- var interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact__default['default'](nativeElement);
1236
- return interactable.resizable(defaultResizeConfig)
1237
- .on('resizestart', function (event) {
1238
- _this.activeEdges = event.edges;
1239
- if (_this.auto_scroll_dir) {
1240
- _this.subscribeToScrollEvents();
1241
- }
1242
- _this.resizeStart.emit(_this.mapResizeEvent(event));
1243
- })
1244
- .on('resizemove', function (event) {
1245
- if (_this.enableResizeDefault) {
1246
- _this.resizeListener(event);
1247
- }
1248
- var mappedEvent = _this.mapResizeEvent(event);
1249
- _this.resizeMove.emit(mappedEvent);
1250
- })
1251
- .on('resizeinertiastart', function (event) { return _this.resizeInertiaStart.emit(_this.mapResizeEvent(event)); })
1252
- .on('resizeend', function (event) {
1253
- if (_this.auto_scroll_dir) {
1254
- _this.scrollEventsSubscription.unsubscribe();
1255
- }
1256
- _this.activeEdges = { left: false, right: false, top: false, bottom: false };
1257
- _this.resizeEnd.emit(_this.mapResizeEvent(event));
1258
- });
1259
- };
1260
- ResizableDirective.prototype.mapResizeEvent = function (event) {
1261
- var _a, _b;
1262
- var target = this.el.nativeElement;
1263
- var relatedTarget = (_b = (_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.dropzone_dir) === null || _b === void 0 ? void 0 : _b.el.nativeElement;
1264
- var scale = this.scale;
1265
- var positionInDropTarget = target && relatedTarget
1266
- ? this.interactService.calculatePositionInElement(relatedTarget, target, scale)
1267
- : null;
1268
- return {
1269
- interactEvent: event,
1270
- resizeRef: this,
1271
- dragRef: this.draggable_dir,
1272
- dragOrigin: this.dropzone_dir,
1273
- dropTarget: this.el.nativeElement.dropTarget,
1274
- positionInDropTarget: positionInDropTarget,
1275
- size: {
1276
- width: target.clientWidth / scale,
1277
- height: target.clientHeight / scale
1278
- }
1279
- };
1280
- };
1281
- ResizableDirective.prototype.alignDimensionsWithInputs = function (width, height) {
1282
- this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: 0, deltaY: 0, width: width, height: height }, this.el.nativeElement);
1283
- };
1284
- ResizableDirective.prototype.addResizePropertiesToElement = function (nativeElement) {
1285
- this.renderer.setProperty(nativeElement, 'resizeRef', this);
1286
- };
1287
- ResizableDirective.prototype.subscribeToScrollEvents = function () {
1288
- var _this = this;
1289
- this.scrollEventsSubscription = this.auto_scroll_dir.scrollDeltaObserver.subscribe(function (_d) {
1290
- var scrollLeft = _d.scrollLeft, scrollTop = _d.scrollTop;
1291
- var scale = _this.scale;
1292
- var target = _this.el.nativeElement;
1293
- var _e = target.getBoundingClientRect(), prevWidth = _e.width, prevHeight = _e.height;
1294
- var deltaHeight = scrollTop * (_this.activeEdges.top ? -1 : _this.activeEdges.bottom ? 1 : 0);
1295
- var deltaWidth = scrollLeft * (_this.activeEdges.left ? -1 : _this.activeEdges.right ? 1 : 0);
1296
- var height = (prevHeight + deltaHeight) / scale;
1297
- var width = (prevWidth + deltaWidth) / scale;
1298
- var deltaX = _this.activeEdges.left ? (scrollLeft / scale) : 0;
1299
- var deltaY = _this.activeEdges.top ? (scrollTop / scale) : 0;
1300
- _this.interactService.updateSize(_this.interactableId, _this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, _this.el.nativeElement);
1301
- });
1302
- };
1303
- return ResizableDirective;
1304
- }());
1305
- ResizableDirective.decorators = [
1306
- { type: i0.Directive, args: [{
1307
- selector: '[tftResizable]',
1308
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
1309
- host: {
1310
- // prevents touch events from colliding with with mouse events
1311
- // on touch screen
1312
- '[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
1313
- // default to absolute here to accommodate likely use cases
1314
- // consuming component can easily over ride with position input
1315
- '[style.position]': 'position',
1316
- // follows interactjs suggested practices
1317
- '[style.boxSizing]': '"border-box"',
1318
- }
1319
- },] }
1320
- ];
1321
- ResizableDirective.ctorParameters = function () { return [
1322
- { type: i0.ElementRef },
1323
- { type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
1324
- { type: InteractService },
1325
- { type: i0.Renderer2 },
1326
- { type: DragRootDirective, decorators: [{ type: i0.Optional }] },
1327
- { type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
1328
- { type: DraggableDirective, decorators: [{ type: i0.Optional }] },
1329
- { type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
1330
- { type: AutoScrollDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
1331
- ]; };
1332
- ResizableDirective.propDecorators = {
1333
- enableResizeDefault: [{ type: i0.Input }],
1334
- position: [{ type: i0.Input }],
1335
- resizeConfig: [{ type: i0.Input }],
1336
- interactableId: [{ type: i0.Input }],
1337
- width: [{ type: i0.Input }],
1338
- height: [{ type: i0.Input }],
1339
- resizeDisabled: [{ type: i0.Input }],
1340
- resizeStart: [{ type: i0.Output }],
1341
- resizeMove: [{ type: i0.Output }],
1342
- resizeInertiaStart: [{ type: i0.Output }],
1343
- resizeEnd: [{ type: i0.Output }]
1344
- };
1345
-
1346
- /** @dynamic */
1347
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1348
- var GesturableDirective = /** @class */ (function () {
1349
- function GesturableDirective(el, draggable_dir) {
1350
- this.el = el;
1351
- this.draggable_dir = draggable_dir;
1352
- this.gestureDisabled = false;
1353
- // pipes all interact events to event emitters
1354
- this.gestureStart = new i0.EventEmitter();
1355
- this.gestureMove = new i0.EventEmitter();
1356
- this.gestureEnd = new i0.EventEmitter();
1357
- }
1358
- GesturableDirective.prototype.ngOnInit = function () {
1359
- var _a;
1360
- this.gesturableId = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactableId) || 'id';
1361
- this.interactable = this.initiateGestureEvents(this.gestureConfig, this.el.nativeElement);
1362
- this.setGestureConfig();
1363
- };
1364
- // TODO: watch config here as well and update interactable
1365
- GesturableDirective.prototype.ngOnChanges = function (changes) {
1366
- // we do this here instead of using a setter on the input so that it
1367
- // will only run once when there is a change to x and y
1368
- if (changes.gestureConfig || changes.gestureDisabled) {
1369
- if (!this.interactable)
1370
- return;
1371
- this.setGestureConfig();
1372
- }
1373
- };
1374
- GesturableDirective.prototype.setGestureConfig = function () {
1375
- var enabled = !this.gestureDisabled;
1376
- var gestureConfig = Object.assign(Object.assign({}, this.gestureConfig), { enabled: enabled });
1377
- this.interactable.gesturable(gestureConfig);
1378
- };
1379
- GesturableDirective.prototype.initiateGestureEvents = function (gestureConfig, nativeElement) {
1380
- var _this = this;
1381
- var _a;
1382
- var defaultConfig = {
1383
- enabled: !this.gestureDisabled,
1384
- };
1385
- var interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact__default['default'](nativeElement);
1386
- return interactable.gesturable(Object.assign(Object.assign({}, defaultConfig), gestureConfig))
1387
- .on('gesturestart', function (event) {
1388
- _this.gestureStart.emit({ gestureRef: _this, interactEvent: event });
1389
- })
1390
- .on('gesturemove', function (event) {
1391
- _this.gestureMove.emit({ gestureRef: _this, interactEvent: event });
1392
- })
1393
- .on('gestureend', function (event) {
1394
- _this.gestureEnd.emit({ gestureRef: _this, interactEvent: event });
1395
- });
1396
- };
1397
- return GesturableDirective;
1398
- }());
1399
- GesturableDirective.decorators = [
1400
- { type: i0.Directive, args: [{
1401
- selector: '[tftGesturable]',
1402
- // eslint-disable-next-line @angular-eslint/no-host-metadata-property
1403
- host: {
1404
- // '[style.touchAction]': 'this.gestureDisabled ? "auto" : "none"',
1405
- '[id]': 'gesturableId',
1406
- }
1407
- },] }
1408
- ];
1409
- GesturableDirective.ctorParameters = function () { return [
1410
- { type: i0.ElementRef },
1411
- { type: DraggableDirective, decorators: [{ type: i0.Optional }] }
1412
- ]; };
1413
- GesturableDirective.propDecorators = {
1414
- gesturableId: [{ type: i0.Input }],
1415
- gestureDisabled: [{ type: i0.Input }],
1416
- gestureConfig: [{ type: i0.Input }],
1417
- gestureStart: [{ type: i0.Output }],
1418
- gestureMove: [{ type: i0.Output }],
1419
- gestureEnd: [{ type: i0.Output }]
1420
- };
1421
-
1422
- var ApplyScaleDirective = /** @class */ (function () {
1423
- function ApplyScaleDirective(el) {
1424
- this.el = el;
1425
- this._scale = 1;
1426
- }
1427
- Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
1428
- // this setup allows consumers to set x, y scale independently or just set them both with scale
1429
- set: function (val) {
1430
- this._scale;
1431
- this.fontSize = val + "px";
1432
- },
1433
- enumerable: false,
1434
- configurable: true
1435
- });
1436
- ;
1437
- return ApplyScaleDirective;
1438
- }());
1439
- ApplyScaleDirective.decorators = [
1440
- { type: i0.Directive, args: [{
1441
- selector: '[tftApplyScale]'
1442
- },] }
1443
- ];
1444
- ApplyScaleDirective.ctorParameters = function () { return [
1445
- { type: i0.ElementRef }
1446
- ]; };
1447
- ApplyScaleDirective.propDecorators = {
1448
- scale: [{ type: i0.Input }],
1449
- fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
1450
- };
1451
-
1452
- var EXPORTS = [
1453
- DraggableDirective,
1454
- ResizableDirective,
1455
- DropzoneDirective,
1456
- GesturableDirective,
1457
- DragRootDirective,
1458
- AutoScrollDirective,
1459
- AccountForScaleDirective,
1460
- ApplyScaleDirective,
1461
- DragPreviewDirective,
1462
- ArrayOfNPipe,
1463
- ];
1464
- var InteractModule = /** @class */ (function () {
1465
- function InteractModule() {
1466
- }
1467
- InteractModule.forRoot = function (config) {
1468
- var defaultConfig = { cssDimensionUnit: 'px' };
1469
- return {
1470
- ngModule: InteractModule,
1471
- providers: [
1472
- { provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
1473
- InteractService
1474
- ]
1475
- };
1476
- };
1477
- return InteractModule;
1478
- }());
1479
- InteractModule.decorators = [
1480
- { type: i0.NgModule, args: [{
1481
- imports: [common.CommonModule],
1482
- // providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
1483
- declarations: __spreadArray([], __read(EXPORTS)),
1484
- exports: __spreadArray([], __read(EXPORTS))
1485
- },] }
1486
- ];
1487
-
1488
- /**
1489
- * Generated bundle index. Do not edit.
1490
- */
1491
-
1492
- exports.AccountForScaleDirective = AccountForScaleDirective;
1493
- exports.ApplyScaleDirective = ApplyScaleDirective;
1494
- exports.ArrayOfNPipe = ArrayOfNPipe;
1495
- exports.AutoScrollDirective = AutoScrollDirective;
1496
- exports.DEFAULT_REGISTRY_ID = DEFAULT_REGISTRY_ID;
1497
- exports.DragPreviewDirective = DragPreviewDirective;
1498
- exports.DragRootDirective = DragRootDirective;
1499
- exports.DraggableDirective = DraggableDirective;
1500
- exports.DropzoneDirective = DropzoneDirective;
1501
- exports.GesturableDirective = GesturableDirective;
1502
- exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
1503
- exports.InteractModule = InteractModule;
1504
- exports.ResizableDirective = ResizableDirective;
1505
- exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;
1506
- exports.cloneElement = cloneElement$1;
1507
- exports.defaultDelta = defaultDelta;
1508
- exports.defaultPosition = defaultPosition;
1509
- exports.defaultSize = defaultSize;
1510
- exports.getClosestMatchingAncestor = getClosestMatchingAncestor;
1511
- exports.getRootNode = getRootNode;
1512
- exports.ɵa = DraggableDirective;
1513
- exports.ɵb = ResizableDirective;
1514
- exports.ɵc = DropzoneDirective;
1515
- exports.ɵd = GesturableDirective;
1516
- exports.ɵe = DragRootDirective;
1517
- exports.ɵf = AutoScrollDirective;
1518
- exports.ɵg = AccountForScaleDirective;
1519
- exports.ɵh = ApplyScaleDirective;
1520
- exports.ɵi = DragPreviewDirective;
1521
- exports.ɵj = ArrayOfNPipe;
1522
-
1523
- Object.defineProperty(exports, '__esModule', { value: true });
1524
-
1525
- })));
1526
- //# sourceMappingURL=tft-interact.umd.js.map