@tft/interact 12.5.0 → 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.
- package/esm2020/index.mjs +6 -0
- package/esm2020/lib/directives/account-for-scale.directive.mjs +26 -0
- package/esm2020/lib/directives/apply-scale.directive.mjs +28 -0
- package/esm2020/lib/directives/auto-scroll.directive.mjs +56 -0
- package/esm2020/lib/directives/drag-preview.directive.mjs +20 -0
- package/esm2020/lib/directives/drag-root.directive.mjs +32 -0
- package/esm2020/lib/directives/draggable.directive.mjs +320 -0
- package/esm2020/lib/directives/dropzone.directive.mjs +114 -0
- package/esm2020/lib/directives/gesturable.directive.mjs +82 -0
- package/esm2020/lib/directives/index.mjs +10 -0
- package/esm2020/lib/directives/resizable.directive.mjs +228 -0
- package/esm2020/lib/interact.module.mjs +66 -0
- package/esm2020/lib/models/index.mjs +2 -0
- package/esm2020/lib/models/interact.mjs +28 -0
- package/esm2020/lib/pipes/array-of-n.pipe.mjs +22 -0
- package/esm2020/lib/pipes/index.mjs +2 -0
- package/esm2020/lib/services/interact.service.mjs +197 -0
- package/esm2020/lib/utils/helpers.mjs +35 -0
- package/esm2020/lib/utils/index.mjs +2 -0
- package/esm2020/tft-interact.mjs +5 -0
- package/fesm2015/{tft-interact.js → tft-interact.mjs} +511 -289
- package/fesm2015/tft-interact.mjs.map +1 -0
- package/fesm2020/tft-interact.mjs +1192 -0
- package/fesm2020/tft-interact.mjs.map +1 -0
- package/lib/directives/account-for-scale.directive.d.ts +3 -0
- package/lib/directives/apply-scale.directive.d.ts +3 -0
- package/lib/directives/auto-scroll.directive.d.ts +34 -0
- package/lib/directives/drag-preview.directive.d.ts +3 -0
- package/lib/directives/drag-root.directive.d.ts +3 -0
- package/lib/directives/draggable.directive.d.ts +9 -1
- package/lib/directives/dropzone.directive.d.ts +6 -0
- package/lib/directives/gesturable.directive.d.ts +3 -0
- package/lib/directives/index.d.ts +1 -0
- package/lib/directives/resizable.directive.d.ts +13 -3
- package/lib/interact.module.d.ts +15 -0
- package/lib/models/interact.d.ts +4 -0
- package/lib/pipes/array-of-n.pipe.d.ts +3 -0
- package/lib/services/interact.service.d.ts +5 -2
- package/package.json +23 -10
- package/tft-interact-13.0.0.tgz +0 -0
- package/tft-interact.d.ts +1 -2
- package/bundles/tft-interact.umd.js +0 -1382
- package/bundles/tft-interact.umd.js.map +0 -1
- package/esm2015/index.js +0 -6
- package/esm2015/index.js.map +0 -1
- package/esm2015/index.metadata.json +0 -1
- package/esm2015/lib/directives/account-for-scale.directive.js +0 -26
- package/esm2015/lib/directives/account-for-scale.directive.js.map +0 -1
- package/esm2015/lib/directives/account-for-scale.directive.metadata.json +0 -1
- package/esm2015/lib/directives/apply-scale.directive.js +0 -26
- package/esm2015/lib/directives/apply-scale.directive.js.map +0 -1
- package/esm2015/lib/directives/apply-scale.directive.metadata.json +0 -1
- package/esm2015/lib/directives/drag-preview.directive.js +0 -20
- package/esm2015/lib/directives/drag-preview.directive.js.map +0 -1
- package/esm2015/lib/directives/drag-preview.directive.metadata.json +0 -1
- package/esm2015/lib/directives/drag-root.directive.js +0 -27
- package/esm2015/lib/directives/drag-root.directive.js.map +0 -1
- package/esm2015/lib/directives/drag-root.directive.metadata.json +0 -1
- package/esm2015/lib/directives/draggable.directive.js +0 -255
- package/esm2015/lib/directives/draggable.directive.js.map +0 -1
- package/esm2015/lib/directives/draggable.directive.metadata.json +0 -1
- package/esm2015/lib/directives/dropzone.directive.js +0 -99
- package/esm2015/lib/directives/dropzone.directive.js.map +0 -1
- package/esm2015/lib/directives/dropzone.directive.metadata.json +0 -1
- package/esm2015/lib/directives/gesturable.directive.js +0 -77
- package/esm2015/lib/directives/gesturable.directive.js.map +0 -1
- package/esm2015/lib/directives/gesturable.directive.metadata.json +0 -1
- package/esm2015/lib/directives/index.js +0 -9
- package/esm2015/lib/directives/index.js.map +0 -1
- package/esm2015/lib/directives/index.metadata.json +0 -1
- package/esm2015/lib/directives/resizable.directive.js +0 -152
- package/esm2015/lib/directives/resizable.directive.js.map +0 -1
- package/esm2015/lib/directives/resizable.directive.metadata.json +0 -1
- package/esm2015/lib/interact.module.js +0 -42
- package/esm2015/lib/interact.module.js.map +0 -1
- package/esm2015/lib/interact.module.metadata.json +0 -1
- package/esm2015/lib/models/index.js +0 -2
- package/esm2015/lib/models/index.js.map +0 -1
- package/esm2015/lib/models/index.metadata.json +0 -1
- package/esm2015/lib/models/interact.js +0 -28
- package/esm2015/lib/models/interact.js.map +0 -1
- package/esm2015/lib/models/interact.metadata.json +0 -1
- package/esm2015/lib/pipes/array-of-n.pipe.js +0 -18
- package/esm2015/lib/pipes/array-of-n.pipe.js.map +0 -1
- package/esm2015/lib/pipes/array-of-n.pipe.metadata.json +0 -1
- package/esm2015/lib/pipes/index.js +0 -2
- package/esm2015/lib/pipes/index.js.map +0 -1
- package/esm2015/lib/pipes/index.metadata.json +0 -1
- package/esm2015/lib/services/interact.service.js +0 -208
- package/esm2015/lib/services/interact.service.js.map +0 -1
- package/esm2015/lib/services/interact.service.metadata.json +0 -1
- package/esm2015/lib/utils/helpers.js +0 -35
- package/esm2015/lib/utils/helpers.js.map +0 -1
- package/esm2015/lib/utils/helpers.metadata.json +0 -1
- package/esm2015/lib/utils/index.js +0 -2
- package/esm2015/lib/utils/index.js.map +0 -1
- package/esm2015/lib/utils/index.metadata.json +0 -1
- package/esm2015/tft-interact.js +0 -7
- package/esm2015/tft-interact.js.map +0 -1
- package/esm2015/tft-interact.metadata.json +0 -1
- package/fesm2015/tft-interact.js.map +0 -1
- package/tft-interact-12.5.0.tgz +0 -0
- package/tft-interact.metadata.json +0 -1
|
@@ -1,1382 +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 an 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
|
-
if (this.dragRegistrySystem[registryId][interactableId]) {
|
|
433
|
-
delete this.dragRegistrySystem[registryId][interactableId];
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
InteractService.prototype.subscribeToInteractable = function (interactableId, registryId) {
|
|
437
|
-
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
438
|
-
return this.dragRegistrySystem[registryId][interactableId];
|
|
439
|
-
};
|
|
440
|
-
InteractService.prototype.createInteractableState = function (initialPosition, initialSize, initialDelta) {
|
|
441
|
-
var _this = this;
|
|
442
|
-
var deltas$ = new rxjs.BehaviorSubject(initialDelta);
|
|
443
|
-
// tracks the size of the element
|
|
444
|
-
var size$ = new rxjs.BehaviorSubject(Object.assign(Object.assign({}, initialSize), initialDelta));
|
|
445
|
-
// Stream of positions as they change
|
|
446
|
-
var position$ = new rxjs.BehaviorSubject(initialPosition);
|
|
447
|
-
// All draggable data mapped together
|
|
448
|
-
var interactable$ = rxjs.combineLatest([
|
|
449
|
-
size$.pipe(
|
|
450
|
-
// startWith({...initialSize, ...initialDelta}),
|
|
451
|
-
operators.shareReplay(1),
|
|
452
|
-
// filter(resizeEvent => !!resizeEvent.targetElement),
|
|
453
|
-
operators.tap(function (_c) {
|
|
454
|
-
var deltaX = _c.deltaX, deltaY = _c.deltaY, width = _c.width, height = _c.height, targetElement = _c.targetElement;
|
|
455
|
-
_this.ngZone.runOutsideAngular(function () {
|
|
456
|
-
_this.setElementSize(width, height, targetElement);
|
|
457
|
-
});
|
|
458
|
-
// only reposition if necessary i.e when resizing left or up
|
|
459
|
-
if (deltaX || deltaY) {
|
|
460
|
-
deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
|
|
461
|
-
}
|
|
462
|
-
})),
|
|
463
|
-
deltas$.pipe(operators.shareReplay(1), operators.tap(function (delta) {
|
|
464
|
-
var position = position$.value;
|
|
465
|
-
var newPosition = _this.addDeltaToPosition(delta, position);
|
|
466
|
-
position$.next(newPosition);
|
|
467
|
-
})),
|
|
468
|
-
position$.pipe(operators.shareReplay(1), operators.tap(function (position) {
|
|
469
|
-
_this.ngZone.runOutsideAngular(function () {
|
|
470
|
-
_this.setElementTransform(position.x, position.y, position);
|
|
471
|
-
});
|
|
472
|
-
}))
|
|
473
|
-
]).pipe(operators.shareReplay(1), operators.map(function (_c) {
|
|
474
|
-
var _d = __read(_c, 3), size = _d[0], deltas = _d[1], position = _d[2];
|
|
475
|
-
return {
|
|
476
|
-
x: position.x,
|
|
477
|
-
y: position.y,
|
|
478
|
-
deltaX: deltas.deltaX,
|
|
479
|
-
deltaY: deltas.deltaY,
|
|
480
|
-
width: size.width,
|
|
481
|
-
height: size.height,
|
|
482
|
-
targetElement: size.targetElement || position.targetElement || deltas.targetElement
|
|
483
|
-
};
|
|
484
|
-
}));
|
|
485
|
-
// TODO: update system to handle only returning interactable$
|
|
486
|
-
return {
|
|
487
|
-
deltas$: deltas$,
|
|
488
|
-
position$: position$,
|
|
489
|
-
size$: size$,
|
|
490
|
-
interactable$: interactable$
|
|
491
|
-
};
|
|
492
|
-
};
|
|
493
|
-
InteractService.prototype.createInteractableId = function (customInteractableId) {
|
|
494
|
-
if (customInteractableId === void 0) { customInteractableId = null; }
|
|
495
|
-
return customInteractableId || "interactable" + this._interactableIndex++;
|
|
496
|
-
};
|
|
497
|
-
InteractService.prototype.createDropzoneId = function (index) {
|
|
498
|
-
return "dropzone" + index;
|
|
499
|
-
};
|
|
500
|
-
InteractService.prototype.getInteractableState = function (interactableId, registryId) {
|
|
501
|
-
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
502
|
-
return this.dragRegistrySystem[registryId][interactableId].interactable$;
|
|
503
|
-
};
|
|
504
|
-
InteractService.prototype.updateDeltas = function (interactId, registryId, _c, targetElement) {
|
|
505
|
-
var deltaX = _c.deltaX, deltaY = _c.deltaY;
|
|
506
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
507
|
-
return;
|
|
508
|
-
this.dragRegistrySystem[registryId][interactId].deltas$.next({ deltaX: deltaX, deltaY: deltaY, targetElement: targetElement });
|
|
509
|
-
};
|
|
510
|
-
InteractService.prototype.updatePosition = function (interactId, registryId, _c, targetElement) {
|
|
511
|
-
var x = _c.x, y = _c.y;
|
|
512
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
513
|
-
return;
|
|
514
|
-
this.dragRegistrySystem[registryId][interactId].position$.next({ x: x, y: y, targetElement: targetElement });
|
|
515
|
-
};
|
|
516
|
-
InteractService.prototype.updateSize = function (interactId, registryId, _c, targetElement) {
|
|
517
|
-
var deltaX = _c.deltaX, deltaY = _c.deltaY, width = _c.width, height = _c.height;
|
|
518
|
-
if (!this.interactableExistOnRegistry(interactId, registryId))
|
|
519
|
-
return;
|
|
520
|
-
this.dragRegistrySystem[registryId][interactId].size$.next({ deltaX: deltaX, deltaY: deltaY, width: width, height: height, targetElement: targetElement });
|
|
521
|
-
};
|
|
522
|
-
InteractService.prototype.interactableExistOnRegistry = function (interactId, registryId) {
|
|
523
|
-
if (registryId === void 0) { registryId = DEFAULT_REGISTRY_ID; }
|
|
524
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
525
|
-
return this.dragRegistrySystem.hasOwnProperty(registryId) && this.dragRegistrySystem[registryId].hasOwnProperty(interactId);
|
|
526
|
-
};
|
|
527
|
-
/**
|
|
528
|
-
* Uses renderer to set width and height of angular component
|
|
529
|
-
* @param width the desired width of component
|
|
530
|
-
* @param height the desired height of component
|
|
531
|
-
* @param target the element to transform
|
|
532
|
-
*/
|
|
533
|
-
InteractService.prototype.setElementSize = function (width, height, target) {
|
|
534
|
-
var _a;
|
|
535
|
-
if (!target)
|
|
536
|
-
return;
|
|
537
|
-
var accountForScaleDirective = (_a = target.resizeRef) === null || _a === void 0 ? void 0 : _a.account_for_scale_dir;
|
|
538
|
-
if (accountForScaleDirective) {
|
|
539
|
-
var scale = accountForScaleDirective.scale;
|
|
540
|
-
var scaledWidth = width / scale;
|
|
541
|
-
var scaledHeight = height / scale;
|
|
542
|
-
this.renderer.setStyle(target, 'width', "" + scaledWidth + this.cssUnit);
|
|
543
|
-
this.renderer.setStyle(target, 'height', "" + scaledHeight + this.cssUnit);
|
|
544
|
-
}
|
|
545
|
-
else {
|
|
546
|
-
this.renderer.setStyle(target, 'width', "" + width + this.cssUnit);
|
|
547
|
-
this.renderer.setStyle(target, 'height', "" + height + this.cssUnit);
|
|
548
|
-
}
|
|
549
|
-
};
|
|
550
|
-
/**
|
|
551
|
-
* Uses renderer to set position of angular component
|
|
552
|
-
* @param x position on x axis
|
|
553
|
-
* @param y position on y axis
|
|
554
|
-
* @param target the element to transform
|
|
555
|
-
*/
|
|
556
|
-
InteractService.prototype.setElementTransform = function (x, y, position) {
|
|
557
|
-
var _a, _b;
|
|
558
|
-
if (!(position === null || position === void 0 ? void 0 : position.targetElement))
|
|
559
|
-
return;
|
|
560
|
-
var dragRef = (_a = position.targetElement) === null || _a === void 0 ? void 0 : _a.dragRef;
|
|
561
|
-
var accountForScaleDirective = (dragRef === null || dragRef === void 0 ? void 0 : dragRef.account_for_scale_dir) || ((_b = dragRef === null || dragRef === void 0 ? void 0 : dragRef.dragRoot) === null || _b === void 0 ? void 0 : _b.account_for_scale_dir);
|
|
562
|
-
if (accountForScaleDirective) {
|
|
563
|
-
var scale = accountForScaleDirective.scale;
|
|
564
|
-
this.renderer.setStyle(position.targetElement, 'left', "" + x / scale + this.cssUnit);
|
|
565
|
-
this.renderer.setStyle(position.targetElement, 'top', "" + y / scale + this.cssUnit);
|
|
566
|
-
}
|
|
567
|
-
else {
|
|
568
|
-
this.renderer.setStyle(position.targetElement, 'left', "" + x + this.cssUnit);
|
|
569
|
-
this.renderer.setStyle(position.targetElement, 'top', "" + y + this.cssUnit);
|
|
570
|
-
}
|
|
571
|
-
};
|
|
572
|
-
/**
|
|
573
|
-
* Generates a translate string for the x and y arguments passed to
|
|
574
|
-
* be passed to css transform
|
|
575
|
-
* @param x the position along the x axis
|
|
576
|
-
* @param y the position along the y axis
|
|
577
|
-
*/
|
|
578
|
-
InteractService.prototype.createTransformString = function (x, y) {
|
|
579
|
-
return "translate3d(" + x + this.cssUnit + ", " + y + this.cssUnit + ", 0)";
|
|
580
|
-
};
|
|
581
|
-
InteractService.prototype.calculatePositionInElement = function (zoneElement, dragElement, scale) {
|
|
582
|
-
// TODO: this calculation may not cover a lot of scenarios, keep an eye out for possible improvements
|
|
583
|
-
var zoneRect = zoneElement.getBoundingClientRect();
|
|
584
|
-
var dragRect = dragElement.getBoundingClientRect();
|
|
585
|
-
var position = scale
|
|
586
|
-
? {
|
|
587
|
-
x: (dragRect.left - zoneRect.left) / scale || 1,
|
|
588
|
-
y: (dragRect.top - zoneRect.top) / scale || 1
|
|
589
|
-
} : {
|
|
590
|
-
x: dragRect.left - zoneRect.left,
|
|
591
|
-
y: dragRect.top - zoneRect.top
|
|
592
|
-
};
|
|
593
|
-
// console.log({ y:position.y, drt:dragRect.top, zrt: zoneRect.top})
|
|
594
|
-
return position;
|
|
595
|
-
};
|
|
596
|
-
return InteractService;
|
|
597
|
-
}());
|
|
598
|
-
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" });
|
|
599
|
-
InteractService.decorators = [
|
|
600
|
-
{ type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
|
601
|
-
];
|
|
602
|
-
InteractService.ctorParameters = function () { return [
|
|
603
|
-
{ type: i0.RendererFactory2 },
|
|
604
|
-
{ type: i0.NgZone },
|
|
605
|
-
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [INTERACT_ROOT_CONFIG,] }] }
|
|
606
|
-
]; };
|
|
607
|
-
|
|
608
|
-
/**
|
|
609
|
-
* Use to apply scale to the element and tell the drag and resize directives to account for the scale when
|
|
610
|
-
* @example <div tftAccountForScale [scale]="2.5"> <div tftDraggable> </div> </div>
|
|
611
|
-
* @note if `dragRoot` is used this directive should be used on the same element to ensure that the drag
|
|
612
|
-
* element accounts for scale
|
|
613
|
-
*/
|
|
614
|
-
var AccountForScaleDirective = /** @class */ (function () {
|
|
615
|
-
function AccountForScaleDirective(el) {
|
|
616
|
-
this.el = el;
|
|
617
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
618
|
-
this.scale = 1;
|
|
619
|
-
}
|
|
620
|
-
return AccountForScaleDirective;
|
|
621
|
-
}());
|
|
622
|
-
AccountForScaleDirective.decorators = [
|
|
623
|
-
{ type: i0.Directive, args: [{
|
|
624
|
-
selector: '[tftAccountForScale]'
|
|
625
|
-
},] }
|
|
626
|
-
];
|
|
627
|
-
AccountForScaleDirective.ctorParameters = function () { return [
|
|
628
|
-
{ type: i0.ElementRef }
|
|
629
|
-
]; };
|
|
630
|
-
AccountForScaleDirective.propDecorators = {
|
|
631
|
-
scale: [{ type: i0.Input }]
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
var DropzoneDirective = /** @class */ (function () {
|
|
635
|
-
function DropzoneDirective(el, renderer, interactService, account_for_scale_dir) {
|
|
636
|
-
this.el = el;
|
|
637
|
-
this.renderer = renderer;
|
|
638
|
-
this.interactService = interactService;
|
|
639
|
-
this.account_for_scale_dir = account_for_scale_dir;
|
|
640
|
-
this.dropzoneConfig = {};
|
|
641
|
-
// proxies to pass interact events through to consumer of directive
|
|
642
|
-
this.dropActivate = new i0.EventEmitter();
|
|
643
|
-
this.dragEnter = new i0.EventEmitter();
|
|
644
|
-
this.dragLeave = new i0.EventEmitter();
|
|
645
|
-
this.dragDrop = new i0.EventEmitter();
|
|
646
|
-
}
|
|
647
|
-
DropzoneDirective.prototype.ngOnInit = function () {
|
|
648
|
-
// connects
|
|
649
|
-
this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig);
|
|
650
|
-
this.dropzoneId = this.interactService.addRegistryToSystem(this.dropzoneId);
|
|
651
|
-
};
|
|
652
|
-
DropzoneDirective.prototype.ngOnChanges = function (changes) {
|
|
653
|
-
if (!changes.dropzoneConfig || !this.dropzone)
|
|
654
|
-
return;
|
|
655
|
-
// this.dropzone.unset();
|
|
656
|
-
// this.dropzone = this.connectDropzoneEvents(this.el.nativeElement, this.dropzoneConfig)
|
|
657
|
-
this.dropzone.dropzone(this.dropzoneConfig);
|
|
658
|
-
};
|
|
659
|
-
/**
|
|
660
|
-
* Connects element to interacts dropzone events and returns a reference to the interactable
|
|
661
|
-
* @param nativeElement the element to tie drop events to
|
|
662
|
-
* @param dropzoneConfig the interact configuration to use when connecting
|
|
663
|
-
*/
|
|
664
|
-
DropzoneDirective.prototype.connectDropzoneEvents = function (nativeElement, dropzoneConfig) {
|
|
665
|
-
var _this = this;
|
|
666
|
-
return interact__default['default'](nativeElement).dropzone(dropzoneConfig)
|
|
667
|
-
// TODO: investigate when this fires in different scenarios
|
|
668
|
-
.on('dropactivate', function (event) {
|
|
669
|
-
_this.dropActivate.emit(_this.mapDropzoneEvent(event));
|
|
670
|
-
})
|
|
671
|
-
.on('dragenter', function (event) {
|
|
672
|
-
_this.renderer.setProperty(event.relatedTarget, 'dropTarget', _this);
|
|
673
|
-
_this.dragEnter.emit(_this.mapDropzoneEvent(event));
|
|
674
|
-
})
|
|
675
|
-
.on('dragleave', function (event) {
|
|
676
|
-
if (event.relatedTarget.dropTarget === _this) {
|
|
677
|
-
_this.renderer.setProperty(event.relatedTarget, 'dropTarget', null);
|
|
678
|
-
}
|
|
679
|
-
_this.dragLeave.emit(_this.mapDropzoneEvent(event));
|
|
680
|
-
})
|
|
681
|
-
.on('drop', function (event) {
|
|
682
|
-
_this.dragDrop.emit(_this.mapDropzoneEvent(event));
|
|
683
|
-
});
|
|
684
|
-
};
|
|
685
|
-
/**
|
|
686
|
-
* Maps the drop event emitted by interact to something a little easier to use
|
|
687
|
-
* @param event the drop event emitted by interact, extended with extra fields we added to
|
|
688
|
-
*/
|
|
689
|
-
DropzoneDirective.prototype.mapDropzoneEvent = function (event) {
|
|
690
|
-
var _a, _b, _c;
|
|
691
|
-
var zoneElement = event.target;
|
|
692
|
-
var dragElement = (_b = (_a = event.relatedTarget) === null || _a === void 0 ? void 0 : _a.dragRef) === null || _b === void 0 ? void 0 : _b.previewRef;
|
|
693
|
-
var scale = ((_c = this.account_for_scale_dir) === null || _c === void 0 ? void 0 : _c.scale) || null;
|
|
694
|
-
var positionInDropTarget = zoneElement && dragElement
|
|
695
|
-
? this.interactService.calculatePositionInElement(zoneElement, dragElement, scale)
|
|
696
|
-
: null;
|
|
697
|
-
return {
|
|
698
|
-
interactEvent: event,
|
|
699
|
-
dragRef: dragElement.dragRef,
|
|
700
|
-
dragOrigin: dragElement.dragOrigin,
|
|
701
|
-
dropTarget: event.relatedTarget.dropTarget,
|
|
702
|
-
positionInDropTarget: positionInDropTarget
|
|
703
|
-
};
|
|
704
|
-
};
|
|
705
|
-
return DropzoneDirective;
|
|
706
|
-
}());
|
|
707
|
-
DropzoneDirective.decorators = [
|
|
708
|
-
{ type: i0.Directive, args: [{
|
|
709
|
-
selector: '[tftDropzone]',
|
|
710
|
-
host: {
|
|
711
|
-
'[id]': 'dropzoneId',
|
|
712
|
-
}
|
|
713
|
-
},] }
|
|
714
|
-
];
|
|
715
|
-
DropzoneDirective.ctorParameters = function () { return [
|
|
716
|
-
{ type: i0.ElementRef },
|
|
717
|
-
{ type: i0.Renderer2 },
|
|
718
|
-
{ type: InteractService },
|
|
719
|
-
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] }
|
|
720
|
-
]; };
|
|
721
|
-
DropzoneDirective.propDecorators = {
|
|
722
|
-
dropzoneId: [{ type: i0.Input }],
|
|
723
|
-
dropzoneConfig: [{ type: i0.Input }],
|
|
724
|
-
dropzoneData: [{ type: i0.Input }],
|
|
725
|
-
dropActivate: [{ type: i0.Output }],
|
|
726
|
-
dragEnter: [{ type: i0.Output }],
|
|
727
|
-
dragLeave: [{ type: i0.Output }],
|
|
728
|
-
dragDrop: [{ type: i0.Output }]
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
var TFT_DRAG_PREVIEW = new i0.InjectionToken('DragPreviewDirective');
|
|
732
|
-
var DragPreviewDirective = /** @class */ (function () {
|
|
733
|
-
function DragPreviewDirective(templateRef) {
|
|
734
|
-
this.templateRef = templateRef;
|
|
735
|
-
}
|
|
736
|
-
return DragPreviewDirective;
|
|
737
|
-
}());
|
|
738
|
-
DragPreviewDirective.decorators = [
|
|
739
|
-
{ type: i0.Directive, args: [{
|
|
740
|
-
// eslint-disable-next-line @angular-eslint/directive-selector
|
|
741
|
-
selector: 'ng-template[tftDragPreview]',
|
|
742
|
-
},] }
|
|
743
|
-
];
|
|
744
|
-
DragPreviewDirective.ctorParameters = function () { return [
|
|
745
|
-
{ type: i0.TemplateRef }
|
|
746
|
-
]; };
|
|
747
|
-
DragPreviewDirective.propDecorators = {
|
|
748
|
-
dragData: [{ type: i0.Input }]
|
|
749
|
-
};
|
|
750
|
-
|
|
751
|
-
/** Gets the closest ancestor of an element that matches a selector. */
|
|
752
|
-
function getClosestMatchingAncestor(element, selector) {
|
|
753
|
-
var currentElement = element.parentElement;
|
|
754
|
-
while (currentElement) {
|
|
755
|
-
// IE doesn't support `matches` so we have to fall back to `msMatchesSelector`.
|
|
756
|
-
if (currentElement.matches ? currentElement.matches(selector) :
|
|
757
|
-
currentElement.msMatchesSelector(selector)) {
|
|
758
|
-
return currentElement;
|
|
759
|
-
}
|
|
760
|
-
currentElement = currentElement.parentElement;
|
|
761
|
-
}
|
|
762
|
-
return null;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Create a copy of the HTML Element
|
|
766
|
-
*/
|
|
767
|
-
function cloneElement$1(element) {
|
|
768
|
-
var clone = element.cloneNode(true);
|
|
769
|
-
clone.removeAttribute('id');
|
|
770
|
-
return clone;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Gets the root HTML element of an embedded view.
|
|
774
|
-
* If the root is not an HTML element it gets wrapped in one.
|
|
775
|
-
*/
|
|
776
|
-
function getRootNode(viewRef, _document) {
|
|
777
|
-
var rootNodes = viewRef.rootNodes;
|
|
778
|
-
if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
|
|
779
|
-
return rootNodes[0];
|
|
780
|
-
}
|
|
781
|
-
var wrapper = _document.createElement('div');
|
|
782
|
-
rootNodes.forEach(function (node) { return wrapper.appendChild(node); });
|
|
783
|
-
return wrapper;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/**
|
|
787
|
-
* Use this directive to select which element to attach the element to while dragging
|
|
788
|
-
* @example <div tftDragRoot><div tftDraggable> </div> </div>
|
|
789
|
-
* @note this directive will overwrite any style transformations (e.g. transform: scale(2); )
|
|
790
|
-
*/
|
|
791
|
-
var DragRootDirective = /** @class */ (function () {
|
|
792
|
-
function DragRootDirective(el,
|
|
793
|
-
// This is used when passing a dragRoot as in input to a draggable element that not a child of that dragRoot
|
|
794
|
-
// 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
|
|
795
|
-
account_for_scale_dir) {
|
|
796
|
-
this.el = el;
|
|
797
|
-
this.account_for_scale_dir = account_for_scale_dir;
|
|
798
|
-
}
|
|
799
|
-
return DragRootDirective;
|
|
800
|
-
}());
|
|
801
|
-
DragRootDirective.decorators = [
|
|
802
|
-
{ type: i0.Directive, args: [{
|
|
803
|
-
selector: '[tftDragRoot]',
|
|
804
|
-
exportAs: 'tftDragRoot'
|
|
805
|
-
},] }
|
|
806
|
-
];
|
|
807
|
-
DragRootDirective.ctorParameters = function () { return [
|
|
808
|
-
{ type: i0.ElementRef },
|
|
809
|
-
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }, { type: i0.Self }] }
|
|
810
|
-
]; };
|
|
811
|
-
|
|
812
|
-
/** @dynamic */
|
|
813
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
814
|
-
var DraggableDirective = /** @class */ (function () {
|
|
815
|
-
// cache holding element to use as placeholder while dragging
|
|
816
|
-
function DraggableDirective(el, interactService, renderer, _viewContainerRef, _document, account_for_scale_dir, dropzone_dir, drag_root_dir) {
|
|
817
|
-
this.el = el;
|
|
818
|
-
this.interactService = interactService;
|
|
819
|
-
this.renderer = renderer;
|
|
820
|
-
this._viewContainerRef = _viewContainerRef;
|
|
821
|
-
this._document = _document;
|
|
822
|
-
this.account_for_scale_dir = account_for_scale_dir;
|
|
823
|
-
this.dropzone_dir = dropzone_dir;
|
|
824
|
-
this.drag_root_dir = drag_root_dir;
|
|
825
|
-
/* zIndex while dragging*/
|
|
826
|
-
this.dragZIndex = 10000;
|
|
827
|
-
this.enableDragDefault = true;
|
|
828
|
-
/**
|
|
829
|
-
* @deprecated replaced by 'dragDisabled' property, please migrate before v13
|
|
830
|
-
*/
|
|
831
|
-
this.disabled = false;
|
|
832
|
-
this.dragDisabled = false;
|
|
833
|
-
this.showPlaceholder = false;
|
|
834
|
-
// pipes all interact events to event emitters
|
|
835
|
-
this.dragStart = new i0.EventEmitter();
|
|
836
|
-
this.dragMove = new i0.EventEmitter();
|
|
837
|
-
this.dragInertiaStart = new i0.EventEmitter();
|
|
838
|
-
this.dragEnd = new i0.EventEmitter();
|
|
839
|
-
}
|
|
840
|
-
DraggableDirective.prototype.ngOnInit = function () {
|
|
841
|
-
var _this = this;
|
|
842
|
-
var _a, _b, _c, _d, _e;
|
|
843
|
-
this.interactable = this.initiateDragEvents(this.dragConfig, this.el.nativeElement);
|
|
844
|
-
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;
|
|
845
|
-
// register with parent dropzone if it exists, otherwise use default
|
|
846
|
-
// this gives us a place on the registry to store our drag items that don't have a dropzone
|
|
847
|
-
this.registryId = ((_e = this.dropzone_dir) === null || _e === void 0 ? void 0 : _e.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
848
|
-
// add draggable to directory and store its id
|
|
849
|
-
this.interactableId = this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
850
|
-
this.alignPositionWithInputs(this.x, this.y);
|
|
851
|
-
// cache subscription to interactable state so we can unsubscribe onDestroy
|
|
852
|
-
this.interactableState = this.interactService
|
|
853
|
-
.getInteractableState(this.interactableId, this.registryId);
|
|
854
|
-
// keep our cached position values in line with our drag state
|
|
855
|
-
this.interactableSubscription = this.interactableState.subscribe(function (state) {
|
|
856
|
-
_this.y = state.y;
|
|
857
|
-
_this.x = state.x;
|
|
858
|
-
});
|
|
859
|
-
this.setDragConfig();
|
|
860
|
-
};
|
|
861
|
-
// TODO: watch config here as well and update interactable
|
|
862
|
-
DraggableDirective.prototype.ngOnChanges = function (changes) {
|
|
863
|
-
// we do this here instead of using a setter on the input so that it
|
|
864
|
-
// will only run once when there is a change to x and y
|
|
865
|
-
if (changes.y || changes.x) {
|
|
866
|
-
this.alignPositionWithInputs(this.x, this.y);
|
|
867
|
-
}
|
|
868
|
-
if (changes.dragConfig || changes.disabled || changes.dragDisabled) {
|
|
869
|
-
if (!this.interactable)
|
|
870
|
-
return;
|
|
871
|
-
this.setDragConfig();
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* @deprecated remove this in v13
|
|
875
|
-
*/
|
|
876
|
-
if (changes.disabled) {
|
|
877
|
-
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");
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
DraggableDirective.prototype.setDragConfig = function () {
|
|
881
|
-
var enabled = !(this.disabled || this.dragDisabled);
|
|
882
|
-
var dragConfig = Object.assign(Object.assign({}, this.dragConfig), { enabled: enabled });
|
|
883
|
-
this.interactable.draggable(dragConfig);
|
|
884
|
-
};
|
|
885
|
-
DraggableDirective.prototype.ngAfterViewInit = function () {
|
|
886
|
-
this.addDragPropertiesToElement(this.el.nativeElement);
|
|
887
|
-
if (!this.dropzone_dir) {
|
|
888
|
-
this.previewRef = this.el.nativeElement;
|
|
889
|
-
}
|
|
890
|
-
};
|
|
891
|
-
DraggableDirective.prototype.ngOnDestroy = function () {
|
|
892
|
-
// clean up state and subscriptions related to destroyed component
|
|
893
|
-
this.interactableSubscription.unsubscribe();
|
|
894
|
-
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
895
|
-
};
|
|
896
|
-
DraggableDirective.prototype.dragMoveListener = function (event, element) {
|
|
897
|
-
var dx = event.dx, dy = event.dy;
|
|
898
|
-
this.interactService.updateDeltas(this.interactableId, this.registryId, { deltaX: dx, deltaY: dy }, element);
|
|
899
|
-
};
|
|
900
|
-
DraggableDirective.prototype.setDragStyles = function (dragElement) {
|
|
901
|
-
this.renderer.setStyle(dragElement, 'touchAction', 'none');
|
|
902
|
-
this.renderer.setStyle(dragElement, 'zIndex', this.dragZIndex);
|
|
903
|
-
this.renderer.setStyle(dragElement, 'position', 'absolute');
|
|
904
|
-
};
|
|
905
|
-
DraggableDirective.prototype.addDragPropertiesToElement = function (nativeElement) {
|
|
906
|
-
this.renderer.setProperty(nativeElement, 'dropTarget', this.dropzone_dir || null);
|
|
907
|
-
this.renderer.setProperty(nativeElement, 'dragOrigin', this.dropzone_dir || null);
|
|
908
|
-
this.renderer.setProperty(nativeElement, 'dragRef', this);
|
|
909
|
-
};
|
|
910
|
-
DraggableDirective.prototype.mapDragEvent = function (event) {
|
|
911
|
-
var _a;
|
|
912
|
-
var target = event.target, dropzone = event.dropzone;
|
|
913
|
-
var dropzoneElement = (dropzone === null || dropzone === void 0 ? void 0 : dropzone.target) || ((_a = target.dropTarget) === null || _a === void 0 ? void 0 : _a.el.nativeElement);
|
|
914
|
-
var positionInDropTarget = target && dropzoneElement
|
|
915
|
-
? this.interactService.calculatePositionInElement(dropzoneElement, this.previewRef)
|
|
916
|
-
: null;
|
|
917
|
-
return {
|
|
918
|
-
interactEvent: event,
|
|
919
|
-
dragRef: this,
|
|
920
|
-
dragOrigin: target.dragOrigin,
|
|
921
|
-
dropTarget: target.dropTarget,
|
|
922
|
-
positionInDropTarget: positionInDropTarget
|
|
923
|
-
};
|
|
924
|
-
};
|
|
925
|
-
DraggableDirective.prototype.setPosition = function (x, y) {
|
|
926
|
-
this.interactService.updatePosition(this.interactableId, this.registryId, { x: x, y: y }, this.el.nativeElement);
|
|
927
|
-
};
|
|
928
|
-
DraggableDirective.prototype.alignPositionWithInputs = function (x, y) {
|
|
929
|
-
// short circuit if positions aren't numbers or if they haven't changed
|
|
930
|
-
if (!this.isValidPosition(x, y))
|
|
931
|
-
return;
|
|
932
|
-
this.interactService.updatePosition(this.interactableId, this.registryId, { x: x, y: y }, this.el.nativeElement);
|
|
933
|
-
};
|
|
934
|
-
DraggableDirective.prototype.isValidPosition = function (x, y) {
|
|
935
|
-
return this.isNumeric(x) && this.isNumeric(y);
|
|
936
|
-
};
|
|
937
|
-
// We use use this instead of isNaN here to try and help performance
|
|
938
|
-
// We should be able to reliably restrict to numbers or falsey values
|
|
939
|
-
DraggableDirective.prototype.isNumeric = function (num) {
|
|
940
|
-
return typeof num === 'number' && !isNaN(num);
|
|
941
|
-
};
|
|
942
|
-
DraggableDirective.prototype.initiateDragEvents = function (dragConfig, nativeElement) {
|
|
943
|
-
var _this = this;
|
|
944
|
-
return interact__default['default'](nativeElement).draggable(Object.assign(Object.assign({}, dragConfig), { enabled: !(this.disabled || this.dragDisabled) }))
|
|
945
|
-
.on('dragstart', function (event) {
|
|
946
|
-
var interaction = event.interaction;
|
|
947
|
-
// check if we should append drag element to body
|
|
948
|
-
if (_this.enableDragDefault
|
|
949
|
-
&& interaction.pointerIsDown
|
|
950
|
-
// TODO: probably don't need following condition checks anymore remove by 2022
|
|
951
|
-
// && !!this.dropzone_dir
|
|
952
|
-
// && !interaction.interacting()
|
|
953
|
-
) {
|
|
954
|
-
if (_this._previewTemplate) {
|
|
955
|
-
var viewRef = _this._viewContainerRef.createEmbeddedView(_this._previewTemplate.templateRef);
|
|
956
|
-
_this.previewRef = getRootNode(viewRef, _this._document);
|
|
957
|
-
}
|
|
958
|
-
else {
|
|
959
|
-
_this.previewRef = cloneElement(_this.el.nativeElement);
|
|
960
|
-
}
|
|
961
|
-
_this.addDragPropertiesToElement(_this.previewRef);
|
|
962
|
-
_this.setDragStyles(_this.previewRef);
|
|
963
|
-
_this.dragRootEl.prepend(_this.previewRef);
|
|
964
|
-
var _f = _this.interactService.calculatePositionInElement(_this.dragRootEl, nativeElement), x = _f.x, y = _f.y;
|
|
965
|
-
_this.interactService.updatePosition(_this.interactableId, _this.registryId, { x: x, y: y }, _this.previewRef);
|
|
966
|
-
if (!_this.showPlaceholder) {
|
|
967
|
-
_this.renderer.setStyle(_this.el.nativeElement, 'display', 'none');
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
_this.dragStart.emit(_this.mapDragEvent(event));
|
|
971
|
-
})
|
|
972
|
-
.on('dragmove', function (event) {
|
|
973
|
-
if (_this.enableDragDefault) {
|
|
974
|
-
var dragElement = _this.dropzone_dir && _this.previewRef || nativeElement;
|
|
975
|
-
_this.dragMoveListener(event, dragElement);
|
|
976
|
-
}
|
|
977
|
-
var mappedEvent = _this.mapDragEvent(event);
|
|
978
|
-
_this.dragMove.emit(mappedEvent);
|
|
979
|
-
})
|
|
980
|
-
.on('draginertiastart', function (event) {
|
|
981
|
-
_this.dragInertiaStart.emit(_this.mapDragEvent(event));
|
|
982
|
-
})
|
|
983
|
-
.on('dragend', function (event) {
|
|
984
|
-
var mappedEvent = _this.mapDragEvent(event);
|
|
985
|
-
if (!!_this.dropzone_dir && _this.dropzone_dir === event.target.dropTarget) {
|
|
986
|
-
var _f = mappedEvent.positionInDropTarget, x = _f.x, y = _f.y;
|
|
987
|
-
_this.setPosition(x, y);
|
|
988
|
-
}
|
|
989
|
-
_this.renderer.setStyle(_this.el.nativeElement, 'display', '');
|
|
990
|
-
_this.dragEnd.emit(mappedEvent);
|
|
991
|
-
if (_this.el.nativeElement !== _this.previewRef) {
|
|
992
|
-
// we do this in a timeout, so that we don't remove before the dropzone can get the boundingElementRect
|
|
993
|
-
setTimeout(function () {
|
|
994
|
-
_this.dragRootEl.removeChild(_this.previewRef);
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
});
|
|
998
|
-
};
|
|
999
|
-
return DraggableDirective;
|
|
1000
|
-
}());
|
|
1001
|
-
DraggableDirective.decorators = [
|
|
1002
|
-
{ type: i0.Directive, args: [{
|
|
1003
|
-
selector: '[tftDraggable]',
|
|
1004
|
-
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
1005
|
-
host: {
|
|
1006
|
-
'[style.touchAction]': 'this.dragDisabled ? "auto" : "none"',
|
|
1007
|
-
'[style.position]': '"absolute"',
|
|
1008
|
-
'[id]': 'interactableId',
|
|
1009
|
-
}
|
|
1010
|
-
},] }
|
|
1011
|
-
];
|
|
1012
|
-
DraggableDirective.ctorParameters = function () { return [
|
|
1013
|
-
{ type: i0.ElementRef },
|
|
1014
|
-
{ type: InteractService },
|
|
1015
|
-
{ type: i0.Renderer2 },
|
|
1016
|
-
{ type: i0.ViewContainerRef },
|
|
1017
|
-
{ type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
|
|
1018
|
-
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
|
|
1019
|
-
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] },
|
|
1020
|
-
{ type: DragRootDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1021
|
-
]; };
|
|
1022
|
-
DraggableDirective.propDecorators = {
|
|
1023
|
-
x: [{ type: i0.Input }],
|
|
1024
|
-
y: [{ type: i0.Input }],
|
|
1025
|
-
dragZIndex: [{ type: i0.Input }],
|
|
1026
|
-
zIndex: [{ type: i0.Input }],
|
|
1027
|
-
interactableId: [{ type: i0.Input }],
|
|
1028
|
-
dragData: [{ type: i0.Input }],
|
|
1029
|
-
enableDragDefault: [{ type: i0.Input }],
|
|
1030
|
-
disabled: [{ type: i0.Input }],
|
|
1031
|
-
dragDisabled: [{ type: i0.Input }],
|
|
1032
|
-
dragConfig: [{ type: i0.Input }],
|
|
1033
|
-
showPlaceholder: [{ type: i0.Input }],
|
|
1034
|
-
dragRoot: [{ type: i0.Input }],
|
|
1035
|
-
dragStart: [{ type: i0.Output }],
|
|
1036
|
-
dragMove: [{ type: i0.Output }],
|
|
1037
|
-
dragInertiaStart: [{ type: i0.Output }],
|
|
1038
|
-
dragEnd: [{ type: i0.Output }],
|
|
1039
|
-
_previewTemplate: [{ type: i0.ContentChild, args: [DragPreviewDirective,] }]
|
|
1040
|
-
};
|
|
1041
|
-
/**
|
|
1042
|
-
* Component utils
|
|
1043
|
-
*/
|
|
1044
|
-
// create a clone of the component passed in and add it to the root component
|
|
1045
|
-
function cloneElement(element) {
|
|
1046
|
-
var clone = element.cloneNode(true);
|
|
1047
|
-
clone.removeAttribute('id');
|
|
1048
|
-
return clone;
|
|
1049
|
-
}
|
|
1050
|
-
function getPreviewInsertionPoint(documentRef) {
|
|
1051
|
-
// We can't use the body if the user is in fullscreen mode,
|
|
1052
|
-
// because the preview will render under the fullscreen element.
|
|
1053
|
-
return documentRef.fullscreenElement ||
|
|
1054
|
-
documentRef.webkitFullscreenElement ||
|
|
1055
|
-
documentRef.mozFullScreenElement ||
|
|
1056
|
-
documentRef.msFullscreenElement ||
|
|
1057
|
-
documentRef.body;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
/** @dynamic */
|
|
1061
|
-
var ResizableDirective = /** @class */ (function () {
|
|
1062
|
-
function ResizableDirective(el, _document, interactService, renderer, drag_root_dir, account_for_scale_dir, draggable_dir, dropzone_dir) {
|
|
1063
|
-
var _a;
|
|
1064
|
-
this.el = el;
|
|
1065
|
-
this._document = _document;
|
|
1066
|
-
this.interactService = interactService;
|
|
1067
|
-
this.renderer = renderer;
|
|
1068
|
-
this.account_for_scale_dir = account_for_scale_dir;
|
|
1069
|
-
this.draggable_dir = draggable_dir;
|
|
1070
|
-
this.dropzone_dir = dropzone_dir;
|
|
1071
|
-
this.enableResizeDefault = true;
|
|
1072
|
-
// TODO: should this be an input with default or should consuming user set display in styles each time
|
|
1073
|
-
this.position = 'absolute';
|
|
1074
|
-
this.resizeDisabled = false;
|
|
1075
|
-
this.resizeStart = new i0.EventEmitter();
|
|
1076
|
-
this.resizeMove = new i0.EventEmitter();
|
|
1077
|
-
this.resizeInertiaStart = new i0.EventEmitter();
|
|
1078
|
-
this.resizeEnd = new i0.EventEmitter();
|
|
1079
|
-
this.defaultConfig = {
|
|
1080
|
-
edges: { left: true, right: true, bottom: true, top: true }
|
|
1081
|
-
};
|
|
1082
|
-
this.dragRoot = ((_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;
|
|
1083
|
-
}
|
|
1084
|
-
ResizableDirective.prototype.ngOnInit = function () {
|
|
1085
|
-
var _a, _b;
|
|
1086
|
-
this.addResizePropertiesToElement(this.el.nativeElement);
|
|
1087
|
-
// we check for a dropzone, we use its id as the registry id if there is on
|
|
1088
|
-
// otherwise, we use DEFAULT_REGISTRY_ID as a registry id. This allows us to keep our interactable
|
|
1089
|
-
// drag state organized by dropzones.
|
|
1090
|
-
this.registryId = ((_a = this.dropzone_dir) === null || _a === void 0 ? void 0 : _a.dropzoneId) || DEFAULT_REGISTRY_ID;
|
|
1091
|
-
this.interactableId = ((_b = this.draggable_dir) === null || _b === void 0 ? void 0 : _b.interactableId) || this.interactService.addDraggableToRegistry(this.registryId, this.interactableId);
|
|
1092
|
-
this.interactable = this.initiateResizeEvents(Object.assign(Object.assign({}, this.defaultConfig), this.resizeConfig), this.el.nativeElement);
|
|
1093
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
1094
|
-
this.interactableSubscription = this.interactService
|
|
1095
|
-
.getInteractableState(this.interactableId, this.registryId)
|
|
1096
|
-
.subscribe();
|
|
1097
|
-
};
|
|
1098
|
-
ResizableDirective.prototype.ngOnChanges = function (changes) {
|
|
1099
|
-
if ((changes.resizeConfig || changes.resizeDisabled) && this.interactable) {
|
|
1100
|
-
this.interactable.resizable(Object.assign(Object.assign({}, this.resizeConfig), { enabled: !this.resizeDisabled }));
|
|
1101
|
-
}
|
|
1102
|
-
if (changes.width || changes.height) {
|
|
1103
|
-
this.alignDimensionsWithInputs(this.width, this.height);
|
|
1104
|
-
}
|
|
1105
|
-
};
|
|
1106
|
-
ResizableDirective.prototype.ngOnDestroy = function () {
|
|
1107
|
-
this.interactableSubscription.unsubscribe();
|
|
1108
|
-
this.interactService.destroyInteractable(this.interactableId, this.registryId);
|
|
1109
|
-
};
|
|
1110
|
-
ResizableDirective.prototype.resizeListener = function (event) {
|
|
1111
|
-
var deltaX = event.deltaRect.left;
|
|
1112
|
-
var deltaY = event.deltaRect.top;
|
|
1113
|
-
var _c = event.rect, width = _c.width, height = _c.height;
|
|
1114
|
-
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: deltaX, deltaY: deltaY, width: width, height: height }, this.el.nativeElement);
|
|
1115
|
-
};
|
|
1116
|
-
/**
|
|
1117
|
-
* hook elements into interacts resize event listeners
|
|
1118
|
-
* we spread the configs so that the consuming component only overwrites the
|
|
1119
|
-
* pieces that it explicitly indicates
|
|
1120
|
-
* @param resizeConfig
|
|
1121
|
-
* @param nativeElement
|
|
1122
|
-
*/
|
|
1123
|
-
ResizableDirective.prototype.initiateResizeEvents = function (resizeConfig, nativeElement) {
|
|
1124
|
-
var _this = this;
|
|
1125
|
-
var _a;
|
|
1126
|
-
// TODO: This should try and get interactable from tft_draggable if it exists
|
|
1127
|
-
var interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact__default['default'](nativeElement);
|
|
1128
|
-
return interactable.resizable(Object.assign(Object.assign({}, resizeConfig), { enabled: !this.resizeDisabled }))
|
|
1129
|
-
.on('resizestart', function (event) { _this.resizeStart.emit(_this.mapResizeEvent(event)); })
|
|
1130
|
-
.on('resizemove', function (event) {
|
|
1131
|
-
if (_this.enableResizeDefault) {
|
|
1132
|
-
_this.resizeListener(event);
|
|
1133
|
-
}
|
|
1134
|
-
var mappedEvent = _this.mapResizeEvent(event);
|
|
1135
|
-
_this.resizeMove.emit(mappedEvent);
|
|
1136
|
-
})
|
|
1137
|
-
.on('resizeinertiastart', function (event) { return _this.resizeInertiaStart.emit(_this.mapResizeEvent(event)); })
|
|
1138
|
-
.on('resizeend', function (event) { return _this.resizeEnd.emit(_this.mapResizeEvent(event)); });
|
|
1139
|
-
};
|
|
1140
|
-
ResizableDirective.prototype.mapResizeEvent = function (event) {
|
|
1141
|
-
var _a, _b;
|
|
1142
|
-
var target = event.target;
|
|
1143
|
-
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;
|
|
1144
|
-
var positionInDropTarget = target && relatedTarget
|
|
1145
|
-
? this.interactService.calculatePositionInElement(relatedTarget, target)
|
|
1146
|
-
: null;
|
|
1147
|
-
return {
|
|
1148
|
-
interactEvent: event,
|
|
1149
|
-
resizeRef: this,
|
|
1150
|
-
// should I remove this?
|
|
1151
|
-
dragRef: this.draggable_dir,
|
|
1152
|
-
dragOrigin: this.dropzone_dir,
|
|
1153
|
-
dropTarget: this.el.nativeElement.dropTarget,
|
|
1154
|
-
positionInDropTarget: positionInDropTarget
|
|
1155
|
-
};
|
|
1156
|
-
};
|
|
1157
|
-
ResizableDirective.prototype.alignDimensionsWithInputs = function (width, height) {
|
|
1158
|
-
this.interactService.updateSize(this.interactableId, this.registryId, { deltaX: 0, deltaY: 0, width: width, height: height }, this.el.nativeElement);
|
|
1159
|
-
};
|
|
1160
|
-
ResizableDirective.prototype.addResizePropertiesToElement = function (nativeElement) {
|
|
1161
|
-
this.renderer.setProperty(nativeElement, 'resizeRef', this);
|
|
1162
|
-
};
|
|
1163
|
-
return ResizableDirective;
|
|
1164
|
-
}());
|
|
1165
|
-
ResizableDirective.decorators = [
|
|
1166
|
-
{ type: i0.Directive, args: [{
|
|
1167
|
-
selector: '[tftResizable]',
|
|
1168
|
-
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
1169
|
-
host: {
|
|
1170
|
-
// prevents touch events from colliding with with mouse events
|
|
1171
|
-
// on touch screen
|
|
1172
|
-
'[style.touchAction]': 'this.resizeDisabled ? "auto" : "none"',
|
|
1173
|
-
// default to absolute here to accommodate likely use cases
|
|
1174
|
-
// consuming component can easily over ride with position input
|
|
1175
|
-
'[style.position]': 'position',
|
|
1176
|
-
// follows interactjs suggested practices
|
|
1177
|
-
'[style.boxSizing]': '"border-box"',
|
|
1178
|
-
}
|
|
1179
|
-
},] }
|
|
1180
|
-
];
|
|
1181
|
-
ResizableDirective.ctorParameters = function () { return [
|
|
1182
|
-
{ type: i0.ElementRef },
|
|
1183
|
-
{ type: Document, decorators: [{ type: i0.Inject, args: [common.DOCUMENT,] }] },
|
|
1184
|
-
{ type: InteractService },
|
|
1185
|
-
{ type: i0.Renderer2 },
|
|
1186
|
-
{ type: DragRootDirective, decorators: [{ type: i0.Optional }] },
|
|
1187
|
-
{ type: AccountForScaleDirective, decorators: [{ type: i0.Optional }] },
|
|
1188
|
-
{ type: DraggableDirective, decorators: [{ type: i0.Optional }] },
|
|
1189
|
-
{ type: DropzoneDirective, decorators: [{ type: i0.Optional }, { type: i0.SkipSelf }] }
|
|
1190
|
-
]; };
|
|
1191
|
-
ResizableDirective.propDecorators = {
|
|
1192
|
-
enableResizeDefault: [{ type: i0.Input }],
|
|
1193
|
-
position: [{ type: i0.Input }],
|
|
1194
|
-
resizeConfig: [{ type: i0.Input }],
|
|
1195
|
-
interactableId: [{ type: i0.Input }],
|
|
1196
|
-
width: [{ type: i0.Input }],
|
|
1197
|
-
height: [{ type: i0.Input }],
|
|
1198
|
-
resizeDisabled: [{ type: i0.Input }],
|
|
1199
|
-
resizeStart: [{ type: i0.Output }],
|
|
1200
|
-
resizeMove: [{ type: i0.Output }],
|
|
1201
|
-
resizeInertiaStart: [{ type: i0.Output }],
|
|
1202
|
-
resizeEnd: [{ type: i0.Output }]
|
|
1203
|
-
};
|
|
1204
|
-
|
|
1205
|
-
/** @dynamic */
|
|
1206
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1207
|
-
var GesturableDirective = /** @class */ (function () {
|
|
1208
|
-
function GesturableDirective(el, draggable_dir) {
|
|
1209
|
-
this.el = el;
|
|
1210
|
-
this.draggable_dir = draggable_dir;
|
|
1211
|
-
this.gestureDisabled = false;
|
|
1212
|
-
// pipes all interact events to event emitters
|
|
1213
|
-
this.gestureStart = new i0.EventEmitter();
|
|
1214
|
-
this.gestureMove = new i0.EventEmitter();
|
|
1215
|
-
this.gestureEnd = new i0.EventEmitter();
|
|
1216
|
-
}
|
|
1217
|
-
GesturableDirective.prototype.ngOnInit = function () {
|
|
1218
|
-
var _a;
|
|
1219
|
-
this.gesturableId = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactableId) || 'id';
|
|
1220
|
-
this.interactable = this.initiateGestureEvents(this.gestureConfig, this.el.nativeElement);
|
|
1221
|
-
this.setGestureConfig();
|
|
1222
|
-
};
|
|
1223
|
-
// TODO: watch config here as well and update interactable
|
|
1224
|
-
GesturableDirective.prototype.ngOnChanges = function (changes) {
|
|
1225
|
-
// we do this here instead of using a setter on the input so that it
|
|
1226
|
-
// will only run once when there is a change to x and y
|
|
1227
|
-
if (changes.gestureConfig || changes.gestureDisabled) {
|
|
1228
|
-
if (!this.interactable)
|
|
1229
|
-
return;
|
|
1230
|
-
this.setGestureConfig();
|
|
1231
|
-
}
|
|
1232
|
-
};
|
|
1233
|
-
GesturableDirective.prototype.setGestureConfig = function () {
|
|
1234
|
-
var enabled = !this.gestureDisabled;
|
|
1235
|
-
var gestureConfig = Object.assign(Object.assign({}, this.gestureConfig), { enabled: enabled });
|
|
1236
|
-
this.interactable.gesturable(gestureConfig);
|
|
1237
|
-
};
|
|
1238
|
-
GesturableDirective.prototype.initiateGestureEvents = function (gestureConfig, nativeElement) {
|
|
1239
|
-
var _this = this;
|
|
1240
|
-
var _a;
|
|
1241
|
-
var defaultConfig = {
|
|
1242
|
-
enabled: !this.gestureDisabled,
|
|
1243
|
-
};
|
|
1244
|
-
var interactable = ((_a = this.draggable_dir) === null || _a === void 0 ? void 0 : _a.interactable) || interact__default['default'](nativeElement);
|
|
1245
|
-
return interactable.gesturable(Object.assign(Object.assign({}, defaultConfig), gestureConfig))
|
|
1246
|
-
.on('gesturestart', function (event) {
|
|
1247
|
-
_this.gestureStart.emit({ gestureRef: _this, interactEvent: event });
|
|
1248
|
-
})
|
|
1249
|
-
.on('gesturemove', function (event) {
|
|
1250
|
-
_this.gestureMove.emit({ gestureRef: _this, interactEvent: event });
|
|
1251
|
-
})
|
|
1252
|
-
.on('gestureend', function (event) {
|
|
1253
|
-
_this.gestureEnd.emit({ gestureRef: _this, interactEvent: event });
|
|
1254
|
-
});
|
|
1255
|
-
};
|
|
1256
|
-
return GesturableDirective;
|
|
1257
|
-
}());
|
|
1258
|
-
GesturableDirective.decorators = [
|
|
1259
|
-
{ type: i0.Directive, args: [{
|
|
1260
|
-
selector: '[tftGesturable]',
|
|
1261
|
-
// eslint-disable-next-line @angular-eslint/no-host-metadata-property
|
|
1262
|
-
host: {
|
|
1263
|
-
// '[style.touchAction]': 'this.gestureDisabled ? "auto" : "none"',
|
|
1264
|
-
'[id]': 'gesturableId',
|
|
1265
|
-
}
|
|
1266
|
-
},] }
|
|
1267
|
-
];
|
|
1268
|
-
GesturableDirective.ctorParameters = function () { return [
|
|
1269
|
-
{ type: i0.ElementRef },
|
|
1270
|
-
{ type: DraggableDirective, decorators: [{ type: i0.Optional }] }
|
|
1271
|
-
]; };
|
|
1272
|
-
GesturableDirective.propDecorators = {
|
|
1273
|
-
gesturableId: [{ type: i0.Input }],
|
|
1274
|
-
gestureDisabled: [{ type: i0.Input }],
|
|
1275
|
-
gestureConfig: [{ type: i0.Input }],
|
|
1276
|
-
gestureStart: [{ type: i0.Output }],
|
|
1277
|
-
gestureMove: [{ type: i0.Output }],
|
|
1278
|
-
gestureEnd: [{ type: i0.Output }]
|
|
1279
|
-
};
|
|
1280
|
-
|
|
1281
|
-
var ApplyScaleDirective = /** @class */ (function () {
|
|
1282
|
-
function ApplyScaleDirective(el) {
|
|
1283
|
-
this.el = el;
|
|
1284
|
-
this._scale = 1;
|
|
1285
|
-
}
|
|
1286
|
-
Object.defineProperty(ApplyScaleDirective.prototype, "scale", {
|
|
1287
|
-
// this setup allows consumers to set x, y scale independently or just set them both with scale
|
|
1288
|
-
set: function (val) {
|
|
1289
|
-
this._scale;
|
|
1290
|
-
this.fontSize = val + "px";
|
|
1291
|
-
},
|
|
1292
|
-
enumerable: false,
|
|
1293
|
-
configurable: true
|
|
1294
|
-
});
|
|
1295
|
-
;
|
|
1296
|
-
return ApplyScaleDirective;
|
|
1297
|
-
}());
|
|
1298
|
-
ApplyScaleDirective.decorators = [
|
|
1299
|
-
{ type: i0.Directive, args: [{
|
|
1300
|
-
selector: '[tftApplyScale]'
|
|
1301
|
-
},] }
|
|
1302
|
-
];
|
|
1303
|
-
ApplyScaleDirective.ctorParameters = function () { return [
|
|
1304
|
-
{ type: i0.ElementRef }
|
|
1305
|
-
]; };
|
|
1306
|
-
ApplyScaleDirective.propDecorators = {
|
|
1307
|
-
scale: [{ type: i0.Input }],
|
|
1308
|
-
fontSize: [{ type: i0.HostBinding, args: ['style.fontSize',] }]
|
|
1309
|
-
};
|
|
1310
|
-
|
|
1311
|
-
var EXPORTS = [
|
|
1312
|
-
DraggableDirective,
|
|
1313
|
-
ResizableDirective,
|
|
1314
|
-
DropzoneDirective,
|
|
1315
|
-
GesturableDirective,
|
|
1316
|
-
DragRootDirective,
|
|
1317
|
-
AccountForScaleDirective,
|
|
1318
|
-
ApplyScaleDirective,
|
|
1319
|
-
DragPreviewDirective,
|
|
1320
|
-
ArrayOfNPipe,
|
|
1321
|
-
];
|
|
1322
|
-
var InteractModule = /** @class */ (function () {
|
|
1323
|
-
function InteractModule() {
|
|
1324
|
-
}
|
|
1325
|
-
InteractModule.forRoot = function (config) {
|
|
1326
|
-
var defaultConfig = { cssDimensionUnit: 'px' };
|
|
1327
|
-
return {
|
|
1328
|
-
ngModule: InteractModule,
|
|
1329
|
-
providers: [
|
|
1330
|
-
{ provide: INTERACT_ROOT_CONFIG, useValue: Object.assign(Object.assign({}, defaultConfig), config) },
|
|
1331
|
-
InteractService
|
|
1332
|
-
]
|
|
1333
|
-
};
|
|
1334
|
-
};
|
|
1335
|
-
return InteractModule;
|
|
1336
|
-
}());
|
|
1337
|
-
InteractModule.decorators = [
|
|
1338
|
-
{ type: i0.NgModule, args: [{
|
|
1339
|
-
imports: [common.CommonModule],
|
|
1340
|
-
// providers: [{ provide: INTERACT_ROOT_CONFIG, useValue: 'px' }],
|
|
1341
|
-
declarations: __spreadArray([], __read(EXPORTS)),
|
|
1342
|
-
exports: __spreadArray([], __read(EXPORTS))
|
|
1343
|
-
},] }
|
|
1344
|
-
];
|
|
1345
|
-
|
|
1346
|
-
/**
|
|
1347
|
-
* Generated bundle index. Do not edit.
|
|
1348
|
-
*/
|
|
1349
|
-
|
|
1350
|
-
exports.AccountForScaleDirective = AccountForScaleDirective;
|
|
1351
|
-
exports.ApplyScaleDirective = ApplyScaleDirective;
|
|
1352
|
-
exports.ArrayOfNPipe = ArrayOfNPipe;
|
|
1353
|
-
exports.DEFAULT_REGISTRY_ID = DEFAULT_REGISTRY_ID;
|
|
1354
|
-
exports.DragPreviewDirective = DragPreviewDirective;
|
|
1355
|
-
exports.DragRootDirective = DragRootDirective;
|
|
1356
|
-
exports.DraggableDirective = DraggableDirective;
|
|
1357
|
-
exports.DropzoneDirective = DropzoneDirective;
|
|
1358
|
-
exports.GesturableDirective = GesturableDirective;
|
|
1359
|
-
exports.INTERACT_ROOT_CONFIG = INTERACT_ROOT_CONFIG;
|
|
1360
|
-
exports.InteractModule = InteractModule;
|
|
1361
|
-
exports.ResizableDirective = ResizableDirective;
|
|
1362
|
-
exports.TFT_DRAG_PREVIEW = TFT_DRAG_PREVIEW;
|
|
1363
|
-
exports.cloneElement = cloneElement$1;
|
|
1364
|
-
exports.defaultDelta = defaultDelta;
|
|
1365
|
-
exports.defaultPosition = defaultPosition;
|
|
1366
|
-
exports.defaultSize = defaultSize;
|
|
1367
|
-
exports.getClosestMatchingAncestor = getClosestMatchingAncestor;
|
|
1368
|
-
exports.getRootNode = getRootNode;
|
|
1369
|
-
exports.ɵa = DraggableDirective;
|
|
1370
|
-
exports.ɵb = ResizableDirective;
|
|
1371
|
-
exports.ɵc = DropzoneDirective;
|
|
1372
|
-
exports.ɵd = GesturableDirective;
|
|
1373
|
-
exports.ɵe = DragRootDirective;
|
|
1374
|
-
exports.ɵf = AccountForScaleDirective;
|
|
1375
|
-
exports.ɵg = ApplyScaleDirective;
|
|
1376
|
-
exports.ɵh = DragPreviewDirective;
|
|
1377
|
-
exports.ɵi = ArrayOfNPipe;
|
|
1378
|
-
|
|
1379
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1380
|
-
|
|
1381
|
-
})));
|
|
1382
|
-
//# sourceMappingURL=tft-interact.umd.js.map
|