@ssv/ngx.ux 2.0.0-dev175 → 2.0.2-dev.7

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 (63) hide show
  1. package/README.md +7 -2
  2. package/esm2020/config.mjs +7 -0
  3. package/esm2020/index.mjs +5 -0
  4. package/esm2020/internal/internal.model.mjs +2 -0
  5. package/esm2020/module.mjs +65 -0
  6. package/esm2020/platform/window.mjs +30 -0
  7. package/esm2020/ssv-ngx.ux.mjs +5 -0
  8. package/esm2020/version.mjs +2 -0
  9. package/esm2020/viewport/index.mjs +9 -0
  10. package/esm2020/viewport/viewport-data/index.mjs +4 -0
  11. package/esm2020/viewport/viewport-data/viewport-data-matcher.mjs +108 -0
  12. package/esm2020/viewport/viewport-data/viewport-data.pipe.mjs +43 -0
  13. package/esm2020/viewport/viewport-data/viewport-data.service.mjs +37 -0
  14. package/esm2020/viewport/viewport-data/viewport-data.utils.mjs +100 -0
  15. package/esm2020/viewport/viewport-matcher-var.directive.mjs +63 -0
  16. package/esm2020/viewport/viewport-matcher.directive.mjs +131 -0
  17. package/esm2020/viewport/viewport-server-size.service.mjs +43 -0
  18. package/esm2020/viewport/viewport.const.mjs +18 -0
  19. package/esm2020/viewport/viewport.model.mjs +31 -0
  20. package/esm2020/viewport/viewport.service.mjs +66 -0
  21. package/esm2020/viewport/viewport.util.mjs +117 -0
  22. package/fesm2015/{ssv-ngx.ux.js → ssv-ngx.ux.mjs} +266 -240
  23. package/fesm2015/ssv-ngx.ux.mjs.map +1 -0
  24. package/fesm2020/ssv-ngx.ux.mjs +822 -0
  25. package/fesm2020/ssv-ngx.ux.mjs.map +1 -0
  26. package/module.d.ts +7 -0
  27. package/package.json +21 -9
  28. package/platform/window.d.ts +3 -0
  29. package/version.d.ts +1 -1
  30. package/viewport/viewport-data/viewport-data.pipe.d.ts +3 -0
  31. package/viewport/viewport-data/viewport-data.service.d.ts +4 -1
  32. package/viewport/viewport-matcher-var.directive.d.ts +3 -0
  33. package/viewport/viewport-matcher.directive.d.ts +3 -0
  34. package/viewport/viewport-server-size.service.d.ts +3 -0
  35. package/viewport/viewport.service.d.ts +11 -2
  36. package/CHANGELOG.md +0 -142
  37. package/bundles/ssv-ngx.ux.umd.js +0 -1213
  38. package/bundles/ssv-ngx.ux.umd.js.map +0 -1
  39. package/bundles/ssv-ngx.ux.umd.min.js +0 -16
  40. package/bundles/ssv-ngx.ux.umd.min.js.map +0 -1
  41. package/esm2015/config.js +0 -7
  42. package/esm2015/index.js +0 -5
  43. package/esm2015/internal/internal.model.js +0 -2
  44. package/esm2015/module.js +0 -50
  45. package/esm2015/platform/window.js +0 -28
  46. package/esm2015/ssv-ngx.ux.js +0 -7
  47. package/esm2015/version.js +0 -2
  48. package/esm2015/viewport/index.js +0 -9
  49. package/esm2015/viewport/viewport-data/index.js +0 -4
  50. package/esm2015/viewport/viewport-data/viewport-data-matcher.js +0 -108
  51. package/esm2015/viewport/viewport-data/viewport-data.pipe.js +0 -43
  52. package/esm2015/viewport/viewport-data/viewport-data.service.js +0 -38
  53. package/esm2015/viewport/viewport-data/viewport-data.utils.js +0 -100
  54. package/esm2015/viewport/viewport-matcher-var.directive.js +0 -64
  55. package/esm2015/viewport/viewport-matcher.directive.js +0 -134
  56. package/esm2015/viewport/viewport-server-size.service.js +0 -38
  57. package/esm2015/viewport/viewport.const.js +0 -18
  58. package/esm2015/viewport/viewport.model.js +0 -31
  59. package/esm2015/viewport/viewport.service.js +0 -64
  60. package/esm2015/viewport/viewport.util.js +0 -117
  61. package/fesm2015/ssv-ngx.ux.js.map +0 -1
  62. package/ssv-ngx.ux.d.ts +0 -6
  63. package/ssv-ngx.ux.metadata.json +0 -1
@@ -1,1213 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/operators'), require('rxjs')) :
3
- typeof define === 'function' && define.amd ? define('@ssv/ngx.ux', ['exports', '@angular/core', 'rxjs/operators', 'rxjs'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ssv = global.ssv || {}, global.ssv.ngx = global.ssv.ngx || {}, global.ssv.ngx.ux = {}), global.ng.core, global.rxjs.operators, global.rxjs));
5
- }(this, (function (exports, i0, operators, rxjs) { 'use strict';
6
-
7
- /*! *****************************************************************************
8
- Copyright (c) Microsoft Corporation.
9
-
10
- Permission to use, copy, modify, and/or distribute this software for any
11
- purpose with or without fee is hereby granted.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
14
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
16
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
17
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
18
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19
- PERFORMANCE OF THIS SOFTWARE.
20
- ***************************************************************************** */
21
- /* global Reflect, Promise */
22
- var extendStatics = function (d, b) {
23
- extendStatics = Object.setPrototypeOf ||
24
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
25
- function (d, b) { for (var p in b)
26
- if (Object.prototype.hasOwnProperty.call(b, p))
27
- d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
- function __extends(d, b) {
31
- extendStatics(d, b);
32
- function __() { this.constructor = d; }
33
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
34
- }
35
- var __assign = function () {
36
- __assign = Object.assign || function __assign(t) {
37
- for (var s, i = 1, n = arguments.length; i < n; i++) {
38
- s = arguments[i];
39
- for (var p in s)
40
- if (Object.prototype.hasOwnProperty.call(s, p))
41
- t[p] = s[p];
42
- }
43
- return t;
44
- };
45
- return __assign.apply(this, arguments);
46
- };
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s)
50
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
- t[p] = s[p];
52
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
- t[p[i]] = s[p[i]];
56
- }
57
- return t;
58
- }
59
- function __decorate(decorators, target, key, desc) {
60
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
61
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
62
- r = Reflect.decorate(decorators, target, key, desc);
63
- else
64
- for (var i = decorators.length - 1; i >= 0; i--)
65
- if (d = decorators[i])
66
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
67
- return c > 3 && r && Object.defineProperty(target, key, r), r;
68
- }
69
- function __param(paramIndex, decorator) {
70
- return function (target, key) { decorator(target, key, paramIndex); };
71
- }
72
- function __metadata(metadataKey, metadataValue) {
73
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
74
- return Reflect.metadata(metadataKey, metadataValue);
75
- }
76
- function __awaiter(thisArg, _arguments, P, generator) {
77
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
78
- return new (P || (P = Promise))(function (resolve, reject) {
79
- function fulfilled(value) { try {
80
- step(generator.next(value));
81
- }
82
- catch (e) {
83
- reject(e);
84
- } }
85
- function rejected(value) { try {
86
- step(generator["throw"](value));
87
- }
88
- catch (e) {
89
- reject(e);
90
- } }
91
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
92
- step((generator = generator.apply(thisArg, _arguments || [])).next());
93
- });
94
- }
95
- function __generator(thisArg, body) {
96
- var _ = { label: 0, sent: function () { if (t[0] & 1)
97
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
98
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
99
- function verb(n) { return function (v) { return step([n, v]); }; }
100
- function step(op) {
101
- if (f)
102
- throw new TypeError("Generator is already executing.");
103
- while (_)
104
- try {
105
- 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)
106
- return t;
107
- if (y = 0, t)
108
- op = [op[0] & 2, t.value];
109
- switch (op[0]) {
110
- case 0:
111
- case 1:
112
- t = op;
113
- break;
114
- case 4:
115
- _.label++;
116
- return { value: op[1], done: false };
117
- case 5:
118
- _.label++;
119
- y = op[1];
120
- op = [0];
121
- continue;
122
- case 7:
123
- op = _.ops.pop();
124
- _.trys.pop();
125
- continue;
126
- default:
127
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
128
- _ = 0;
129
- continue;
130
- }
131
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
132
- _.label = op[1];
133
- break;
134
- }
135
- if (op[0] === 6 && _.label < t[1]) {
136
- _.label = t[1];
137
- t = op;
138
- break;
139
- }
140
- if (t && _.label < t[2]) {
141
- _.label = t[2];
142
- _.ops.push(op);
143
- break;
144
- }
145
- if (t[2])
146
- _.ops.pop();
147
- _.trys.pop();
148
- continue;
149
- }
150
- op = body.call(thisArg, _);
151
- }
152
- catch (e) {
153
- op = [6, e];
154
- y = 0;
155
- }
156
- finally {
157
- f = t = 0;
158
- }
159
- if (op[0] & 5)
160
- throw op[1];
161
- return { value: op[0] ? op[1] : void 0, done: true };
162
- }
163
- }
164
- var __createBinding = Object.create ? (function (o, m, k, k2) {
165
- if (k2 === undefined)
166
- k2 = k;
167
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
168
- }) : (function (o, m, k, k2) {
169
- if (k2 === undefined)
170
- k2 = k;
171
- o[k2] = m[k];
172
- });
173
- function __exportStar(m, o) {
174
- for (var p in m)
175
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
176
- __createBinding(o, m, p);
177
- }
178
- function __values(o) {
179
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
180
- if (m)
181
- return m.call(o);
182
- if (o && typeof o.length === "number")
183
- return {
184
- next: function () {
185
- if (o && i >= o.length)
186
- o = void 0;
187
- return { value: o && o[i++], done: !o };
188
- }
189
- };
190
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
191
- }
192
- function __read(o, n) {
193
- var m = typeof Symbol === "function" && o[Symbol.iterator];
194
- if (!m)
195
- return o;
196
- var i = m.call(o), r, ar = [], e;
197
- try {
198
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
199
- ar.push(r.value);
200
- }
201
- catch (error) {
202
- e = { error: error };
203
- }
204
- finally {
205
- try {
206
- if (r && !r.done && (m = i["return"]))
207
- m.call(i);
208
- }
209
- finally {
210
- if (e)
211
- throw e.error;
212
- }
213
- }
214
- return ar;
215
- }
216
- function __spread() {
217
- for (var ar = [], i = 0; i < arguments.length; i++)
218
- ar = ar.concat(__read(arguments[i]));
219
- return ar;
220
- }
221
- function __spreadArrays() {
222
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
223
- s += arguments[i].length;
224
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
225
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
226
- r[k] = a[j];
227
- return r;
228
- }
229
- ;
230
- function __await(v) {
231
- return this instanceof __await ? (this.v = v, this) : new __await(v);
232
- }
233
- function __asyncGenerator(thisArg, _arguments, generator) {
234
- if (!Symbol.asyncIterator)
235
- throw new TypeError("Symbol.asyncIterator is not defined.");
236
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
237
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
238
- function verb(n) { if (g[n])
239
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
240
- function resume(n, v) { try {
241
- step(g[n](v));
242
- }
243
- catch (e) {
244
- settle(q[0][3], e);
245
- } }
246
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
247
- function fulfill(value) { resume("next", value); }
248
- function reject(value) { resume("throw", value); }
249
- function settle(f, v) { if (f(v), q.shift(), q.length)
250
- resume(q[0][0], q[0][1]); }
251
- }
252
- function __asyncDelegator(o) {
253
- var i, p;
254
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
255
- 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; }
256
- }
257
- function __asyncValues(o) {
258
- if (!Symbol.asyncIterator)
259
- throw new TypeError("Symbol.asyncIterator is not defined.");
260
- var m = o[Symbol.asyncIterator], i;
261
- 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);
262
- 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); }); }; }
263
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
264
- }
265
- function __makeTemplateObject(cooked, raw) {
266
- if (Object.defineProperty) {
267
- Object.defineProperty(cooked, "raw", { value: raw });
268
- }
269
- else {
270
- cooked.raw = raw;
271
- }
272
- return cooked;
273
- }
274
- ;
275
- var __setModuleDefault = Object.create ? (function (o, v) {
276
- Object.defineProperty(o, "default", { enumerable: true, value: v });
277
- }) : function (o, v) {
278
- o["default"] = v;
279
- };
280
- function __importStar(mod) {
281
- if (mod && mod.__esModule)
282
- return mod;
283
- var result = {};
284
- if (mod != null)
285
- for (var k in mod)
286
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
287
- __createBinding(result, mod, k);
288
- __setModuleDefault(result, mod);
289
- return result;
290
- }
291
- function __importDefault(mod) {
292
- return (mod && mod.__esModule) ? mod : { default: mod };
293
- }
294
- function __classPrivateFieldGet(receiver, privateMap) {
295
- if (!privateMap.has(receiver)) {
296
- throw new TypeError("attempted to get private field on non-instance");
297
- }
298
- return privateMap.get(receiver);
299
- }
300
- function __classPrivateFieldSet(receiver, privateMap, value) {
301
- if (!privateMap.has(receiver)) {
302
- throw new TypeError("attempted to set private field on non-instance");
303
- }
304
- privateMap.set(receiver, value);
305
- return value;
306
- }
307
-
308
- var _a;
309
- (function (ViewportDataMatchStrategy) {
310
- /** Indicates that size should match exact or default. */
311
- ViewportDataMatchStrategy[ViewportDataMatchStrategy["exact"] = 0] = "exact";
312
- /** Indicates that size matches when exact match, first match smaller (down) or default. */
313
- ViewportDataMatchStrategy[ViewportDataMatchStrategy["smaller"] = 1] = "smaller";
314
- /** Indicates that size matches when exact match, first match larger (up) or default. */
315
- ViewportDataMatchStrategy[ViewportDataMatchStrategy["larger"] = 2] = "larger";
316
- /** Indicates that size matches when exact match, or it tries both smaller/larger (smaller is preferred) until match or default. */
317
- ViewportDataMatchStrategy[ViewportDataMatchStrategy["closestSmallerFirst"] = 3] = "closestSmallerFirst";
318
- /** Indicates that size matches when exact match, or it tries both larger/smaller (larger is preferred) until match or default. */
319
- ViewportDataMatchStrategy[ViewportDataMatchStrategy["closestLargerFirst"] = 4] = "closestLargerFirst";
320
- })(exports.ViewportDataMatchStrategy || (exports.ViewportDataMatchStrategy = {}));
321
- /**
322
- * Utility function to match data based on strategy and size.
323
- *
324
- * @param dataConfig Data config to generate rules based on.
325
- * @param sizeType Size type to get data for.
326
- * @param strategy Strategy to use when building rules.
327
- * @param sizeTypes Available size types ordered by index type. (Can be obtained from `ViewportService`)
328
- * @param sizeTypeMap Available size type map. (Can be obtained from `ViewportService`)
329
- * @returns Returns the matched data value.
330
- */
331
- function matchViewportData(dataConfig, sizeType, strategy, sizeTypes, sizeTypeMap) {
332
- var matchFn = matchStrategyHandlerMap[strategy];
333
- if (!matchFn) {
334
- throw Error("matchViewportData: Viewport Data strategy not implemented. Strategy: '" + strategy + "'");
335
- }
336
- var data = matchFn(dataConfig, sizeType, sizeTypes, sizeTypeMap);
337
- if (data !== undefined) {
338
- return data;
339
- }
340
- return dataConfig.default;
341
- }
342
- var matchStrategyHandlerMap = (_a = {},
343
- _a[exports.ViewportDataMatchStrategy.exact] = matchWithExact,
344
- _a[exports.ViewportDataMatchStrategy.larger] = matchWithLargerMatch,
345
- _a[exports.ViewportDataMatchStrategy.smaller] = matchWithSmallerMatch,
346
- _a[exports.ViewportDataMatchStrategy.closestSmallerFirst] = matchWithClosestSmallerFirstMatch,
347
- _a[exports.ViewportDataMatchStrategy.closestLargerFirst] = matchWithClosestLargerFirstMatch,
348
- _a);
349
- function matchWithExact(dataConfig, currentSizeType) {
350
- return dataConfig[currentSizeType.name];
351
- }
352
- function matchWithLargerMatch(dataConfig, currentSizeType, sizeTypes) {
353
- var data = dataConfig[currentSizeType.name];
354
- if (data !== undefined) {
355
- return data;
356
- }
357
- var largestTypeIdx = sizeTypes[sizeTypes.length - 1].type;
358
- if (currentSizeType.type >= largestTypeIdx) {
359
- return undefined;
360
- }
361
- for (var index = currentSizeType.type; index < sizeTypes.length; index++) {
362
- var sizeType = sizeTypes[index];
363
- data = dataConfig[sizeType.name];
364
- if (data !== undefined) {
365
- return data;
366
- }
367
- }
368
- return undefined;
369
- }
370
- function matchWithSmallerMatch(dataConfig, currentSizeType, sizeTypes) {
371
- var data = dataConfig[currentSizeType.name];
372
- if (data !== undefined) {
373
- return data;
374
- }
375
- if (currentSizeType.type <= 0) {
376
- return undefined;
377
- }
378
- // eslint-disable-next-line for-direction
379
- for (var index = currentSizeType.type; index < sizeTypes.length; index--) {
380
- var sizeType = sizeTypes[index];
381
- data = dataConfig[sizeType.name];
382
- if (data !== undefined) {
383
- return data;
384
- }
385
- }
386
- return undefined;
387
- }
388
- function matchWithClosestSmallerFirstMatch(dataConfig, currentSizeType, sizeTypes) {
389
- return closestMatch(dataConfig, currentSizeType, sizeTypes, true);
390
- }
391
- function matchWithClosestLargerFirstMatch(dataConfig, currentSizeType, sizeTypes) {
392
- return closestMatch(dataConfig, currentSizeType, sizeTypes, false);
393
- }
394
- function closestMatch(dataConfig, currentSizeType, sizeTypes, isSmallerFirst) {
395
- var e_1, _a;
396
- var data = dataConfig[currentSizeType.name];
397
- if (data !== undefined) {
398
- return data;
399
- }
400
- var downIndex = currentSizeType.type;
401
- var upIndex = currentSizeType.type;
402
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
403
- for (var index = 0; index < sizeTypes.length; index++) {
404
- try {
405
- for (var _b = (e_1 = void 0, __values(isSmallerFirst ? [--downIndex, ++upIndex] : [++upIndex, --downIndex])), _c = _b.next(); !_c.done; _c = _b.next()) {
406
- var idx = _c.value;
407
- var sizeType = sizeTypes[idx];
408
- if (sizeType) {
409
- data = dataConfig[sizeType.name];
410
- if (data !== undefined) {
411
- return data;
412
- }
413
- }
414
- }
415
- }
416
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
417
- finally {
418
- try {
419
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
420
- }
421
- finally { if (e_1) throw e_1.error; }
422
- }
423
- }
424
- return undefined;
425
- }
426
-
427
- /** Default viewport breakpoints. */
428
- var UX_VIEWPORT_DEFAULT_BREAKPOINTS = {
429
- xsmall: 450,
430
- small: 767,
431
- medium: 992,
432
- large: 1280,
433
- fhd: 1920,
434
- qhd: 2560,
435
- uhd4k: 3840,
436
- uhd8k: 7680,
437
- };
438
- var UX_VIEWPORT_DEFAULT_CONFIG = {
439
- resizePollingSpeed: 33,
440
- breakpoints: UX_VIEWPORT_DEFAULT_BREAKPOINTS,
441
- defaultDataMatchStrategy: exports.ViewportDataMatchStrategy.smaller,
442
- };
443
-
444
- var UX_DEFAULT_CONFIG = {
445
- viewport: UX_VIEWPORT_DEFAULT_CONFIG,
446
- };
447
- var UX_CONFIG = new i0.InjectionToken("@ssv/ngx.ux-config");
448
-
449
- var WINDOW = new i0.InjectionToken("Window");
450
- var WindowRef = /** @class */ (function () {
451
- function WindowRef(
452
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
453
- window) {
454
- this.window = window;
455
- }
456
- Object.defineProperty(WindowRef.prototype, "native", {
457
- /** Window underlying native object. */
458
- get: function () {
459
- return this.window;
460
- },
461
- enumerable: false,
462
- configurable: true
463
- });
464
- Object.defineProperty(WindowRef.prototype, "hasNative", {
465
- /** Determines whether native element is supported or not. Generally `false` when executing in SSR. */
466
- get: function () {
467
- return !!this.native.window;
468
- },
469
- enumerable: false,
470
- configurable: true
471
- });
472
- return WindowRef;
473
- }());
474
- WindowRef.ɵprov = i0.ɵɵdefineInjectable({ factory: function WindowRef_Factory() { return new WindowRef(i0.ɵɵinject(WINDOW)); }, token: WindowRef, providedIn: "root" });
475
- WindowRef.decorators = [
476
- { type: i0.Injectable, args: [{
477
- providedIn: "root",
478
- },] }
479
- ];
480
- WindowRef.ctorParameters = function () { return [
481
- { type: undefined, decorators: [{ type: i0.Inject, args: [WINDOW,] }] }
482
- ]; };
483
-
484
- /**
485
- * The indices of each breakpoint provided based on the `UX_VIEWPORT_DEFAULT_BREAKPOINTS`.
486
- * @see UX_VIEWPORT_DEFAULT_BREAKPOINTS
487
- */
488
- (function (ViewportSizeType) {
489
- ViewportSizeType[ViewportSizeType["xsmall"] = 0] = "xsmall";
490
- ViewportSizeType[ViewportSizeType["small"] = 1] = "small";
491
- ViewportSizeType[ViewportSizeType["medium"] = 2] = "medium";
492
- ViewportSizeType[ViewportSizeType["large"] = 3] = "large";
493
- ViewportSizeType[ViewportSizeType["fhd"] = 4] = "fhd";
494
- ViewportSizeType[ViewportSizeType["qhd"] = 6] = "qhd";
495
- ViewportSizeType[ViewportSizeType["uhd4k"] = 7] = "uhd4k";
496
- ViewportSizeType[ViewportSizeType["uhd8k"] = 8] = "uhd8k";
497
- })(exports.ViewportSizeType || (exports.ViewportSizeType = {}));
498
- (function (ComparisonOperation) {
499
- ComparisonOperation["equals"] = "=";
500
- ComparisonOperation["notEquals"] = "<>";
501
- ComparisonOperation["lessThan"] = "<";
502
- ComparisonOperation["lessOrEqualThan"] = "<=";
503
- ComparisonOperation["greaterThan"] = ">";
504
- ComparisonOperation["greaterOrEqualThan"] = ">=";
505
- })(exports.ComparisonOperation || (exports.ComparisonOperation = {}));
506
- (function (DeviceType) {
507
- DeviceType["desktop"] = "desktop";
508
- DeviceType["mobile"] = "mobile";
509
- DeviceType["tablet"] = "tablet";
510
- })(exports.DeviceType || (exports.DeviceType = {}));
511
-
512
- var _a$1;
513
- // todo: make this configurable
514
- /** Viewport size for SSR. */
515
- var viewportSizeSSR = (_a$1 = {},
516
- _a$1[exports.DeviceType.desktop] = {
517
- width: 1366,
518
- height: 768,
519
- },
520
- _a$1[exports.DeviceType.tablet] = {
521
- width: 768,
522
- height: 1024,
523
- },
524
- _a$1[exports.DeviceType.mobile] = {
525
- width: 414,
526
- height: 736,
527
- },
528
- _a$1);
529
- var UX_VIEWPORT_SSR_DEVICE = new i0.InjectionToken("@ssv/ngx.ux-config/viewport/ssr-device");
530
- var ViewportServerSizeService = /** @class */ (function () {
531
- function ViewportServerSizeService(deviceType) {
532
- this.deviceType = deviceType;
533
- }
534
- ViewportServerSizeService.prototype.get = function () {
535
- return viewportSizeSSR[this.deviceType] || viewportSizeSSR[exports.DeviceType.desktop];
536
- };
537
- return ViewportServerSizeService;
538
- }());
539
- ViewportServerSizeService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ViewportServerSizeService_Factory() { return new ViewportServerSizeService(i0.ɵɵinject(UX_VIEWPORT_SSR_DEVICE, 8)); }, token: ViewportServerSizeService, providedIn: "root" });
540
- ViewportServerSizeService.decorators = [
541
- { type: i0.Injectable, args: [{
542
- providedIn: "root",
543
- },] }
544
- ];
545
- ViewportServerSizeService.ctorParameters = function () { return [
546
- { type: exports.DeviceType, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [UX_VIEWPORT_SSR_DEVICE,] }] }
547
- ]; };
548
-
549
- var _a$2;
550
- function isViewportSizeMatcherExpression(value) {
551
- if (typeof value !== "object" || !value) {
552
- return false;
553
- }
554
- var args = value;
555
- if (args.size && args.operation) {
556
- return true;
557
- }
558
- return false;
559
- }
560
- function isViewportSizeMatcherTupleExpression(arg) {
561
- if (!arg) {
562
- return false;
563
- }
564
- if (Array.isArray(arg)) {
565
- if (arg.length === 2) {
566
- var _a = __read(arg, 1), op = _a[0];
567
- return operations.includes(op);
568
- }
569
- }
570
- return false;
571
- }
572
- var operations = Object.values(exports.ComparisonOperation);
573
- var COMPARISON_OPERATION_FUNC_MAPPING = (_a$2 = {},
574
- _a$2[exports.ComparisonOperation.equals] = function (a, b) { return a === b; },
575
- _a$2[exports.ComparisonOperation.notEquals] = function (a, b) { return a !== b; },
576
- _a$2[exports.ComparisonOperation.lessThan] = function (a, b) { return a < b; },
577
- _a$2[exports.ComparisonOperation.lessOrEqualThan] = function (a, b) { return a <= b; },
578
- _a$2[exports.ComparisonOperation.greaterThan] = function (a, b) { return a > b; },
579
- _a$2[exports.ComparisonOperation.greaterOrEqualThan] = function (a, b) { return a >= b; },
580
- _a$2);
581
- function isViewportConditionMatch(evaluateSize, conditions, viewportSizeTypeInfoRefs) {
582
- var isExcluded = match(conditions.sizeTypeExclude, evaluateSize.name, false);
583
- var isIncluded;
584
- var isExpressionTruthy;
585
- if (!isExcluded && conditions.expression) {
586
- var ref = viewportSizeTypeInfoRefs[conditions.expression.size];
587
- if (!ref) {
588
- throw new Error("Viewport size type is invalid. Size type: '" + conditions.expression.size + "'");
589
- }
590
- var expMatcher = COMPARISON_OPERATION_FUNC_MAPPING[conditions.expression.operation];
591
- isExpressionTruthy = expMatcher(evaluateSize.type, ref.type);
592
- }
593
- else {
594
- isIncluded = match(conditions.sizeType, evaluateSize.name, true);
595
- }
596
- var shouldRender = (isExpressionTruthy || isIncluded) && !isExcluded;
597
- // console.warn(">>> shouldRender", { evaluateSize, conditions, shouldRender });
598
- return !!shouldRender;
599
- }
600
- function match(value, targetValue, defaultValue) {
601
- if (!value) {
602
- return defaultValue;
603
- }
604
- return Array.isArray(value)
605
- ? value.includes(targetValue)
606
- : value === targetValue;
607
- }
608
- function getSizeTypeInfo(width, sizeTypes) {
609
- var lastEntryIndex = sizeTypes.length - 1;
610
- for (var idx = 0; idx < lastEntryIndex; idx++) {
611
- var viewportSizeTypeInfo = sizeTypes[idx];
612
- if (width <= viewportSizeTypeInfo.widthThreshold) {
613
- return viewportSizeTypeInfo;
614
- }
615
- }
616
- return sizeTypes[lastEntryIndex];
617
- }
618
- /**
619
- * Converts the breakpoints into a 2 dimensional array containing the name and width, and sorted from
620
- * smallest to largest.
621
- * @param breakpoints the breakpoints obtained from the config
622
- * @internal
623
- */
624
- function getSortedBreakpoints(breakpoints) {
625
- return Object.entries(breakpoints)
626
- .sort(function (_a, _b) {
627
- var _c = __read(_a, 2), widthA = _c[1];
628
- var _d = __read(_b, 2), widthB = _d[1];
629
- return widthA - widthB;
630
- });
631
- }
632
- /**
633
- * A util function which generates the ViewportSizeTypeInfo.type for each breakpoint.
634
- * @param breakpoints the custom breakpoints
635
- */
636
- function generateViewportSizeType(breakpoints) {
637
- return Object.freeze(getSortedBreakpoints(breakpoints).reduce(function (dictionary, _a, index) {
638
- var _b = __read(_a, 1), name = _b[0];
639
- dictionary[name] = index;
640
- dictionary[index] = name;
641
- return dictionary;
642
- }, {}));
643
- }
644
- /**
645
- * Pre-processes the given breakpoints into an ordered list from smallest to largest while generating
646
- * all the necessary information on the viewport.
647
- * @param breakpoints the breakpoints obtained from the config
648
- * @internal
649
- */
650
- function generateViewportSizeTypeInfoList(breakpoints) {
651
- return getSortedBreakpoints(breakpoints)
652
- .map(function (_a, index) {
653
- var _b = __read(_a, 2), name = _b[0], width = _b[1];
654
- return (Object.freeze({
655
- name: name,
656
- type: index,
657
- widthThreshold: width
658
- }));
659
- });
660
- }
661
- /**
662
- * Converts the breakpoint list into a dictionary while using the name as key.
663
- * @param breakpointList the list of breakpoints
664
- * @internal
665
- */
666
- function generateViewportSizeTypeInfoRefs(breakpointList) {
667
- return Object.freeze(breakpointList.reduce(function (dictionary, breakpoint) {
668
- dictionary[breakpoint.name] = breakpoint;
669
- dictionary[breakpoint.type] = breakpoint;
670
- return dictionary;
671
- }, {}));
672
- }
673
-
674
- var ViewportService = /** @class */ (function () {
675
- function ViewportService(windowRef, viewportServerSize, config) {
676
- var _this = this;
677
- this.windowRef = windowRef;
678
- this.viewportServerSize = viewportServerSize;
679
- this._sizeTypes = generateViewportSizeTypeInfoList(config.viewport.breakpoints);
680
- this._sizeTypeMap = generateViewportSizeTypeInfoRefs(this._sizeTypes);
681
- if (windowRef.hasNative) {
682
- this.resize$ = rxjs.fromEvent(window, "resize").pipe(operators.map(function () { return _this.getViewportSize(); }), operators.auditTime(config.viewport.resizePollingSpeed), operators.share());
683
- }
684
- else {
685
- this.resize$ = rxjs.of(viewportServerSize.get());
686
- }
687
- var size = this.getViewportSize();
688
- this._sizeTypeSnapshot = getSizeTypeInfo(size.width, this.sizeTypes);
689
- this.size$ = this.resize$.pipe(operators.startWith(size), operators.distinctUntilChanged(function (a, b) { return a.width === b.width && a.height === b.height; }), operators.shareReplay(1));
690
- this.sizeType$ = this.size$.pipe(operators.distinctUntilChanged(function (a, b) { return a.width === b.width; }), operators.map(function (x) { return getSizeTypeInfo(x.width, _this.sizeTypes); }), operators.distinctUntilChanged(), operators.tap(function (x) { return _this._sizeTypeSnapshot = x; }), operators.shareReplay(1));
691
- }
692
- Object.defineProperty(ViewportService.prototype, "sizeTypeSnapshot", {
693
- /** Viewport size type snapshot of the last value. (Prefer use `sizeType$` observable when possible.) */
694
- get: function () { return this._sizeTypeSnapshot; },
695
- enumerable: false,
696
- configurable: true
697
- });
698
- Object.defineProperty(ViewportService.prototype, "sizeTypeMap", {
699
- /** Size types refs of the generated viewport size type info. */
700
- get: function () { return this._sizeTypeMap; },
701
- enumerable: false,
702
- configurable: true
703
- });
704
- Object.defineProperty(ViewportService.prototype, "sizeTypes", {
705
- /** Viewport size types list ordered by type, smallest to largest. */
706
- get: function () { return this._sizeTypes; },
707
- enumerable: false,
708
- configurable: true
709
- });
710
- /** Returns the current viewport size */
711
- ViewportService.prototype.getViewportSize = function () {
712
- if (!this.windowRef.hasNative) {
713
- return this.viewportServerSize.get();
714
- }
715
- var ua = navigator.userAgent.toLowerCase();
716
- if (ua.indexOf("safari") !== -1 && ua.indexOf("chrome") === -1) { // safari subtracts the scrollbar width
717
- return {
718
- width: this.windowRef.native.document.documentElement.clientWidth,
719
- height: this.windowRef.native.document.documentElement.clientHeight,
720
- };
721
- }
722
- return {
723
- width: this.windowRef.native.innerWidth,
724
- height: this.windowRef.native.innerHeight,
725
- };
726
- };
727
- return ViewportService;
728
- }());
729
- ViewportService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ViewportService_Factory() { return new ViewportService(i0.ɵɵinject(WindowRef), i0.ɵɵinject(ViewportServerSizeService), i0.ɵɵinject(UX_CONFIG)); }, token: ViewportService, providedIn: "root" });
730
- ViewportService.decorators = [
731
- { type: i0.Injectable, args: [{
732
- providedIn: "root",
733
- },] }
734
- ];
735
- ViewportService.ctorParameters = function () { return [
736
- { type: WindowRef },
737
- { type: ViewportServerSizeService },
738
- { type: undefined, decorators: [{ type: i0.Inject, args: [UX_CONFIG,] }] }
739
- ]; };
740
-
741
- var _a$3;
742
- /**
743
- * Utility function to generate rules based on strategies.
744
- *
745
- * @param dataConfig Data config to generate rules based on.
746
- * @param strategy Strategy to use when building rules.
747
- * @param sizeTypes Available size types ordered by index type. (Can be obtained from `ViewportService`)
748
- * @param sizeTypeMap Available size type map. (Can be obtained from `ViewportService`)
749
- * @returns Returns a collection of rules (ordered).
750
- */
751
- function generateViewportRulesRangeFromDataMatcher(dataConfig, strategy, sizeTypes, sizeTypeMap) {
752
- var ruleBuilderFn = matchStrategyHandlerMap$1[strategy];
753
- if (!ruleBuilderFn) {
754
- throw Error("generateViewportRulesRangeFromDataMatcher: Viewport Data strategy not implemented. Strategy: '" + strategy + "'");
755
- }
756
- var dataSizes = [];
757
- for (var key in dataConfig) {
758
- if (Object.prototype.hasOwnProperty.call(dataConfig, key)) {
759
- var data = dataConfig[key];
760
- if (data === undefined) {
761
- continue;
762
- }
763
- var size = sizeTypeMap[key];
764
- if (size) {
765
- dataSizes.push(size);
766
- }
767
- }
768
- }
769
- dataSizes = dataSizes.sort(function (_a, _b) {
770
- var typeA = _a.type;
771
- var typeB = _b.type;
772
- return typeA - typeB;
773
- });
774
- var rules = [];
775
- if (dataConfig.default) {
776
- rules.push({ value: dataConfig.default, min: undefined, max: undefined });
777
- }
778
- var prevRule;
779
- for (var index = 0; index < dataSizes.length; index++) {
780
- var prevDataSize = dataSizes[index - 1];
781
- var nextDataSize = dataSizes[index + 1];
782
- var dataSize = dataSizes[index];
783
- var prevSize = sizeTypes[dataSize.type - 1];
784
- // const nextSize = sizeTypes[dataSize.type + 1];
785
- var data = dataConfig[dataSize.name];
786
- var rule = {
787
- value: data,
788
- min: undefined,
789
- max: undefined,
790
- };
791
- ruleBuilderFn(rule, dataSize, nextDataSize, prevDataSize, prevSize, prevRule, sizeTypes);
792
- prevRule = rule;
793
- rules.push(rule);
794
- }
795
- return rules;
796
- }
797
- var matchStrategyHandlerMap$1 = (_a$3 = {},
798
- _a$3[exports.ViewportDataMatchStrategy.exact] = function (rule, dataSize, _nextDataSize, _prevDataSize, prevSize) {
799
- rule.max = dataSize.widthThreshold;
800
- if (prevSize) {
801
- rule.min = prevSize.widthThreshold + 1;
802
- }
803
- },
804
- _a$3[exports.ViewportDataMatchStrategy.smaller] = function (rule, dataSize, nextDataSize, _prevDataSize, prevSize) {
805
- if (nextDataSize) {
806
- rule.max = dataSize.widthThreshold;
807
- }
808
- if (prevSize) {
809
- rule.min = prevSize.widthThreshold + 1;
810
- }
811
- },
812
- _a$3[exports.ViewportDataMatchStrategy.larger] = function (rule, dataSize, _nextDataSize, prevDataSize) {
813
- if (dataSize) {
814
- rule.max = dataSize.widthThreshold;
815
- }
816
- if (prevDataSize) {
817
- rule.min = prevDataSize.widthThreshold + 1;
818
- }
819
- },
820
- _a$3[exports.ViewportDataMatchStrategy.closestSmallerFirst] = function (rule, dataSize, nextDataSize, _prevDataSize, _prevSize, prevRule, sizeTypes) {
821
- if (nextDataSize) {
822
- rule.max = calculateClosestWidthThreshold(nextDataSize, dataSize, sizeTypes, true);
823
- }
824
- if (prevRule === null || prevRule === void 0 ? void 0 : prevRule.max) {
825
- rule.min = prevRule.max + 1;
826
- }
827
- },
828
- _a$3[exports.ViewportDataMatchStrategy.closestLargerFirst] = function (rule, dataSize, nextDataSize, _prevDataSize, _prevSize, prevRule, sizeTypes) {
829
- if (nextDataSize) {
830
- rule.max = calculateClosestWidthThreshold(nextDataSize, dataSize, sizeTypes, false);
831
- }
832
- if (prevRule === null || prevRule === void 0 ? void 0 : prevRule.max) {
833
- rule.min = prevRule.max + 1;
834
- }
835
- },
836
- _a$3);
837
- function calculateClosestWidthThreshold(nextDataSize, dataSize, sizeTypes, isSmallerPreferred) {
838
- var fn = isSmallerPreferred ? Math.ceil : Math.floor;
839
- // get closest between curr and next
840
- var diffIndex = fn((nextDataSize.type - dataSize.type - 1) / 2);
841
- var diffNextSize = sizeTypes[dataSize.type + diffIndex];
842
- return (diffNextSize || dataSize).widthThreshold;
843
- }
844
-
845
- var ViewportDataService = /** @class */ (function () {
846
- function ViewportDataService(viewport, config) {
847
- this.viewport = viewport;
848
- this.config = config;
849
- }
850
- /** Get data for match. */
851
- ViewportDataService.prototype.get = function (dataConfig, strategy, sizeType) {
852
- if (strategy === void 0) { strategy = this.config.viewport.defaultDataMatchStrategy; }
853
- if (sizeType === void 0) { sizeType = this.viewport.sizeTypeSnapshot; }
854
- return matchViewportData(dataConfig, sizeType, strategy, this.viewport.sizeTypes, this.viewport.sizeTypeMap);
855
- };
856
- /** Get data for match as observable. */
857
- ViewportDataService.prototype.get$ = function (dataConfig, strategy) {
858
- var _this = this;
859
- return this.viewport.sizeType$.pipe(operators.map(function (sizeType) { return _this.get(dataConfig, strategy, sizeType); }), operators.distinctUntilChanged());
860
- };
861
- /** Generate rules based on strategies for data. */
862
- ViewportDataService.prototype.generateRules = function (dataConfig, strategy) {
863
- if (strategy === void 0) { strategy = this.config.viewport.defaultDataMatchStrategy; }
864
- return generateViewportRulesRangeFromDataMatcher(dataConfig, strategy, this.viewport.sizeTypes, this.viewport.sizeTypeMap);
865
- };
866
- return ViewportDataService;
867
- }());
868
- ViewportDataService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ViewportDataService_Factory() { return new ViewportDataService(i0.ɵɵinject(ViewportService), i0.ɵɵinject(UX_CONFIG)); }, token: ViewportDataService, providedIn: "root" });
869
- ViewportDataService.decorators = [
870
- { type: i0.Injectable, args: [{
871
- providedIn: "root",
872
- },] }
873
- ];
874
- ViewportDataService.ctorParameters = function () { return [
875
- { type: ViewportService },
876
- { type: undefined, decorators: [{ type: i0.Inject, args: [UX_CONFIG,] }] }
877
- ]; };
878
-
879
- /* eslint-disable @angular-eslint/no-pipe-impure */
880
- var ViewportDataPipe = /** @class */ (function () {
881
- function ViewportDataPipe(viewportData, cdr) {
882
- this.viewportData = viewportData;
883
- this.cdr = cdr;
884
- this.markForTransform = true;
885
- this.data$$ = rxjs.Subscription.EMPTY;
886
- }
887
- ViewportDataPipe.prototype.transform = function (data, strategy) {
888
- var _this = this;
889
- if (!this.markForTransform && data === this.data && strategy === this.strategy) {
890
- return this.value;
891
- }
892
- this.data = data;
893
- this.strategy = strategy;
894
- this.data$$.unsubscribe();
895
- this.data$$ = this.viewportData.get$(data, exports.ViewportDataMatchStrategy[strategy]).pipe(operators.tap(function (value) {
896
- _this.markForTransform = true;
897
- _this.value = value;
898
- _this.cdr.markForCheck();
899
- })).subscribe();
900
- this.markForTransform = false;
901
- return this.value;
902
- };
903
- ViewportDataPipe.prototype.ngOnDestroy = function () {
904
- this.data$$.unsubscribe();
905
- };
906
- return ViewportDataPipe;
907
- }());
908
- ViewportDataPipe.decorators = [
909
- { type: i0.Pipe, args: [{
910
- name: "ssvViewportData",
911
- pure: false
912
- },] }
913
- ];
914
- ViewportDataPipe.ctorParameters = function () { return [
915
- { type: ViewportDataService },
916
- { type: i0.ChangeDetectorRef }
917
- ]; };
918
-
919
- var NAME_CAMEL = "ssvViewportMatcherVar";
920
- var SsvViewportMatcherVarContext = /** @class */ (function () {
921
- function SsvViewportMatcherVarContext($implicit) {
922
- if ($implicit === void 0) { $implicit = false; }
923
- this.$implicit = $implicit;
924
- }
925
- return SsvViewportMatcherVarContext;
926
- }());
927
- var SsvViewportMatcherVarDirective = /** @class */ (function () {
928
- function SsvViewportMatcherVarDirective(viewport, viewContainer, templateRef) {
929
- this.viewport = viewport;
930
- this.viewContainer = viewContainer;
931
- this.templateRef = templateRef;
932
- this._matchConditions = {};
933
- this._context = new SsvViewportMatcherVarContext();
934
- this._destroy$ = new rxjs.Subject();
935
- this._update$ = new rxjs.ReplaySubject(1);
936
- }
937
- Object.defineProperty(SsvViewportMatcherVarDirective.prototype, "condition", {
938
- set: function (value) {
939
- if (isViewportSizeMatcherExpression(value)) {
940
- this._matchConditions.expression = value;
941
- }
942
- else if (isViewportSizeMatcherTupleExpression(value)) {
943
- var _a = __read(value, 2), op = _a[0], size = _a[1];
944
- this._matchConditions.expression = {
945
- operation: op,
946
- size: size
947
- };
948
- }
949
- else {
950
- this._matchConditions.sizeType = value;
951
- }
952
- this._update$.next();
953
- },
954
- enumerable: false,
955
- configurable: true
956
- });
957
- SsvViewportMatcherVarDirective.prototype.ngOnInit = function () {
958
- var _this = this;
959
- this.updateView();
960
- rxjs.combineLatest([this.viewport.sizeType$, this._update$]).pipe(operators.map(function (_a) {
961
- var _b = __read(_a, 1), sizeType = _b[0];
962
- return isViewportConditionMatch(sizeType, _this._matchConditions, _this.viewport.sizeTypeMap);
963
- }), operators.tap(function (x) { return _this._context.$implicit = x; }), operators.tap(function () { return _this._viewRef.markForCheck(); }), operators.takeUntil(this._destroy$)).subscribe();
964
- };
965
- SsvViewportMatcherVarDirective.prototype.ngOnDestroy = function () {
966
- this._destroy$.next();
967
- this._destroy$.complete();
968
- };
969
- SsvViewportMatcherVarDirective.prototype.updateView = function () {
970
- this.viewContainer.clear();
971
- this._viewRef = this.viewContainer.createEmbeddedView(this.templateRef, this._context);
972
- };
973
- return SsvViewportMatcherVarDirective;
974
- }());
975
- SsvViewportMatcherVarDirective.decorators = [
976
- { type: i0.Directive, args: [{
977
- selector: "[" + NAME_CAMEL + "]",
978
- },] }
979
- ];
980
- SsvViewportMatcherVarDirective.ctorParameters = function () { return [
981
- { type: ViewportService },
982
- { type: i0.ViewContainerRef },
983
- { type: i0.TemplateRef }
984
- ]; };
985
- SsvViewportMatcherVarDirective.propDecorators = {
986
- condition: [{ type: i0.Input, args: [NAME_CAMEL + "When",] }]
987
- };
988
-
989
- var SsvViewportMatcherContext = /** @class */ (function () {
990
- function SsvViewportMatcherContext() {
991
- this.sizeType = null;
992
- this.sizeTypeExclude = null;
993
- }
994
- return SsvViewportMatcherContext;
995
- }());
996
- var SsvViewportMatcherDirective = /** @class */ (function () {
997
- function SsvViewportMatcherDirective(viewport, renderer, viewContainer, cdr, templateRef) {
998
- this.viewport = viewport;
999
- this.renderer = renderer;
1000
- this.viewContainer = viewContainer;
1001
- this.cdr = cdr;
1002
- this._context = new SsvViewportMatcherContext();
1003
- this._thenTemplateRef = null;
1004
- this._elseTemplateRef = null;
1005
- this._thenViewRef = null;
1006
- this._elseViewRef = null;
1007
- this.sizeType$$ = rxjs.Subscription.EMPTY;
1008
- this.cssClass$$ = rxjs.Subscription.EMPTY;
1009
- this._update$ = new rxjs.Subject();
1010
- this._thenTemplateRef = templateRef;
1011
- }
1012
- Object.defineProperty(SsvViewportMatcherDirective.prototype, "ssvViewportMatcher", {
1013
- set: function (value) {
1014
- if (isViewportSizeMatcherExpression(value)) {
1015
- this._context.expression = value;
1016
- }
1017
- else if (isViewportSizeMatcherTupleExpression(value)) {
1018
- var _b = __read(value, 2), op = _b[0], size = _b[1];
1019
- this._context.expression = {
1020
- operation: op,
1021
- size: size
1022
- };
1023
- }
1024
- else {
1025
- this._context.sizeType = value;
1026
- }
1027
- if (this.sizeInfo) {
1028
- this._update$.next(this._context);
1029
- }
1030
- },
1031
- enumerable: false,
1032
- configurable: true
1033
- });
1034
- Object.defineProperty(SsvViewportMatcherDirective.prototype, "ssvViewportMatcherExclude", {
1035
- set: function (value) {
1036
- this._context.sizeTypeExclude = value;
1037
- if (this.sizeInfo) {
1038
- this._update$.next(this._context);
1039
- }
1040
- },
1041
- enumerable: false,
1042
- configurable: true
1043
- });
1044
- Object.defineProperty(SsvViewportMatcherDirective.prototype, "ssvViewportMatcherElse", {
1045
- set: function (templateRef) {
1046
- this._elseTemplateRef = templateRef;
1047
- this._elseViewRef = null; // clear previous view if any.
1048
- if (this.sizeInfo) {
1049
- this._update$.next(this._context);
1050
- }
1051
- },
1052
- enumerable: false,
1053
- configurable: true
1054
- });
1055
- SsvViewportMatcherDirective.prototype.ngOnInit = function () {
1056
- var _this = this;
1057
- // console.log("ssvViewportMatcher init");
1058
- this._update$
1059
- .pipe(
1060
- // tap(x => console.log(">>> ssvViewportMatcher - update triggered", x)),
1061
- operators.filter(function () { return !!_this.sizeInfo; }),
1062
- // tap(x => console.log(">>> ssvViewportMatcher - updating...", x)),
1063
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1064
- operators.tap(function () { return _this._updateView(_this.sizeInfo); }), operators.tap(function () { return _this.cdr.markForCheck(); }))
1065
- .subscribe();
1066
- this.sizeType$$ = this.viewport.sizeType$
1067
- .pipe(
1068
- // tap(x => console.log("ssvViewportMatcher - sizeType changed", x)),
1069
- operators.tap(function (x) { return _this.sizeInfo = x; }), operators.tap(function () { return _this._update$.next(_this._context); }))
1070
- .subscribe();
1071
- this.cssClass$$ = this.viewport.sizeType$
1072
- .pipe(operators.startWith(undefined), operators.filter(function () { return !!(_this._thenViewRef || _this._elseViewRef); }), operators.pairwise(), operators.tap(function (_b) {
1073
- var _c = __read(_b, 2), prev = _c[0], curr = _c[1];
1074
- var _a;
1075
- var el = _this._thenViewRef
1076
- ? _this._thenViewRef.rootNodes[0]
1077
- : (_a = _this._elseViewRef) === null || _a === void 0 ? void 0 : _a.rootNodes[0];
1078
- if (!el.classList) {
1079
- return;
1080
- }
1081
- if (prev) {
1082
- _this.renderer.removeClass(el, "ssv-vp-size--" + prev.name);
1083
- }
1084
- _this.renderer.addClass(el, "ssv-vp-size--" + (curr === null || curr === void 0 ? void 0 : curr.name));
1085
- }))
1086
- .subscribe();
1087
- };
1088
- SsvViewportMatcherDirective.prototype.ngOnDestroy = function () {
1089
- this.cssClass$$.unsubscribe();
1090
- this.sizeType$$.unsubscribe();
1091
- this._update$.complete();
1092
- };
1093
- SsvViewportMatcherDirective.prototype._updateView = function (sizeInfo) {
1094
- if (isViewportConditionMatch(sizeInfo, this._context, this.viewport.sizeTypeMap)) {
1095
- if (!this._thenViewRef) {
1096
- this.viewContainer.clear();
1097
- this._elseViewRef = null;
1098
- if (this._thenTemplateRef) {
1099
- this._thenViewRef = this.viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
1100
- }
1101
- }
1102
- }
1103
- else {
1104
- if (!this._elseViewRef) {
1105
- this.viewContainer.clear();
1106
- this._thenViewRef = null;
1107
- if (this._elseTemplateRef) {
1108
- this._elseViewRef = this.viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
1109
- }
1110
- }
1111
- }
1112
- };
1113
- return SsvViewportMatcherDirective;
1114
- }());
1115
- SsvViewportMatcherDirective.decorators = [
1116
- { type: i0.Directive, args: [{
1117
- selector: "[ssvViewportMatcher]",
1118
- exportAs: "ssvViewportMatcher",
1119
- },] }
1120
- ];
1121
- SsvViewportMatcherDirective.ctorParameters = function () { return [
1122
- { type: ViewportService },
1123
- { type: i0.Renderer2 },
1124
- { type: i0.ViewContainerRef },
1125
- { type: i0.ChangeDetectorRef },
1126
- { type: i0.TemplateRef }
1127
- ]; };
1128
- SsvViewportMatcherDirective.propDecorators = {
1129
- ssvViewportMatcher: [{ type: i0.Input }],
1130
- ssvViewportMatcherExclude: [{ type: i0.Input }],
1131
- ssvViewportMatcherElse: [{ type: i0.Input }]
1132
- };
1133
-
1134
- /** @internal */
1135
- var MODULE_CONFIG_DATA = new i0.InjectionToken("@ssv/ngx.ux/configData");
1136
- var components = [
1137
- SsvViewportMatcherDirective,
1138
- SsvViewportMatcherVarDirective,
1139
- ViewportDataPipe,
1140
- ];
1141
- // todo: create module for Viewport
1142
- var SsvUxModule = /** @class */ (function () {
1143
- function SsvUxModule() {
1144
- }
1145
- SsvUxModule.forRoot = function (config) {
1146
- return {
1147
- ngModule: SsvUxModule,
1148
- providers: [
1149
- { provide: MODULE_CONFIG_DATA, useValue: config },
1150
- ],
1151
- };
1152
- };
1153
- return SsvUxModule;
1154
- }());
1155
- SsvUxModule.decorators = [
1156
- { type: i0.NgModule, args: [{
1157
- declarations: [components],
1158
- providers: [
1159
- { provide: UX_CONFIG, useFactory: _moduleConfigFactory, deps: [[MODULE_CONFIG_DATA, new i0.Optional()]] },
1160
- { provide: WINDOW, useFactory: _window },
1161
- ],
1162
- exports: __spread(components),
1163
- },] }
1164
- ];
1165
- /** @internal */
1166
- function _moduleConfigFactory(config) {
1167
- if (!config) {
1168
- return UX_DEFAULT_CONFIG;
1169
- }
1170
- var uxOptions = typeof config === "function" ? config() : config;
1171
- var viewport = Object.assign(Object.assign({}, UX_DEFAULT_CONFIG.viewport), uxOptions.viewport); // breakpoints shouldn't be merged
1172
- return { viewport: viewport };
1173
- }
1174
- /** @internal */
1175
- function _window() {
1176
- if (typeof window !== "undefined") {
1177
- return window;
1178
- }
1179
- return {};
1180
- }
1181
-
1182
- var VERSION = "2.0.0-dev175";
1183
-
1184
- /**
1185
- * Generated bundle index. Do not edit.
1186
- */
1187
-
1188
- exports.MODULE_CONFIG_DATA = MODULE_CONFIG_DATA;
1189
- exports.SsvUxModule = SsvUxModule;
1190
- exports.SsvViewportMatcherContext = SsvViewportMatcherContext;
1191
- exports.SsvViewportMatcherDirective = SsvViewportMatcherDirective;
1192
- exports.SsvViewportMatcherVarContext = SsvViewportMatcherVarContext;
1193
- exports.SsvViewportMatcherVarDirective = SsvViewportMatcherVarDirective;
1194
- exports.UX_CONFIG = UX_CONFIG;
1195
- exports.UX_DEFAULT_CONFIG = UX_DEFAULT_CONFIG;
1196
- exports.UX_VIEWPORT_DEFAULT_BREAKPOINTS = UX_VIEWPORT_DEFAULT_BREAKPOINTS;
1197
- exports.UX_VIEWPORT_SSR_DEVICE = UX_VIEWPORT_SSR_DEVICE;
1198
- exports.VERSION = VERSION;
1199
- exports.ViewportDataPipe = ViewportDataPipe;
1200
- exports.ViewportDataService = ViewportDataService;
1201
- exports.ViewportServerSizeService = ViewportServerSizeService;
1202
- exports.ViewportService = ViewportService;
1203
- exports._moduleConfigFactory = _moduleConfigFactory;
1204
- exports._window = _window;
1205
- exports.generateViewportSizeType = generateViewportSizeType;
1206
- exports.ɵa = UX_VIEWPORT_DEFAULT_CONFIG;
1207
- exports.ɵb = WINDOW;
1208
- exports.ɵc = WindowRef;
1209
-
1210
- Object.defineProperty(exports, '__esModule', { value: true });
1211
-
1212
- })));
1213
- //# sourceMappingURL=ssv-ngx.ux.umd.js.map