@sitecore-jss/sitecore-jss-angular 19.0.5-canary.0 → 19.0.5
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/dist/bundles/sitecore-jss-sitecore-jss-angular.umd.js +1363 -1363
- package/dist/components/date.directive.d.ts +17 -17
- package/dist/components/file.directive.d.ts +14 -14
- package/dist/components/generic-link.directive.d.ts +18 -18
- package/dist/components/image.directive.d.ts +32 -32
- package/dist/components/link.directive.d.ts +22 -22
- package/dist/components/missing-component.component.d.ts +4 -4
- package/dist/components/placeholder-loading.directive.d.ts +5 -5
- package/dist/components/placeholder.component.d.ts +45 -45
- package/dist/components/placeholder.token.d.ts +30 -30
- package/dist/components/raw.component.d.ts +9 -9
- package/dist/components/render-component.component.d.ts +31 -31
- package/dist/components/render-each.directive.d.ts +5 -5
- package/dist/components/render-empty.directive.d.ts +5 -5
- package/dist/components/rendering-field.d.ts +40 -40
- package/dist/components/rendering.d.ts +5 -5
- package/dist/components/rich-text.directive.d.ts +12 -12
- package/dist/components/router-link.directive.d.ts +16 -16
- package/dist/components/text.directive.d.ts +13 -13
- package/dist/esm2015/components/date.directive.js +52 -52
- package/dist/esm2015/components/file.directive.js +44 -44
- package/dist/esm2015/components/generic-link.directive.js +57 -57
- package/dist/esm2015/components/image.directive.js +122 -122
- package/dist/esm2015/components/link.directive.js +101 -101
- package/dist/esm2015/components/missing-component.component.js +12 -12
- package/dist/esm2015/components/placeholder-loading.directive.js +14 -14
- package/dist/esm2015/components/placeholder.component.js +191 -191
- package/dist/esm2015/components/placeholder.token.js +20 -20
- package/dist/esm2015/components/raw.component.js +36 -36
- package/dist/esm2015/components/render-component.component.js +88 -88
- package/dist/esm2015/components/render-each.directive.js +14 -14
- package/dist/esm2015/components/render-empty.directive.js +14 -14
- package/dist/esm2015/components/rendering-field.js +1 -1
- package/dist/esm2015/components/rendering.js +7 -7
- package/dist/esm2015/components/rich-text.directive.js +40 -40
- package/dist/esm2015/components/router-link.directive.js +43 -43
- package/dist/esm2015/components/text.directive.js +53 -53
- package/dist/esm2015/jss-component-factory.service.js +87 -87
- package/dist/esm2015/lib.module.js +110 -110
- package/dist/esm2015/public_api.js +13 -13
- package/dist/esm2015/sitecore-jss-sitecore-jss-angular.js +12 -12
- package/dist/fesm2015/sitecore-jss-sitecore-jss-angular.js +1027 -1027
- package/dist/jss-component-factory.service.d.ts +21 -21
- package/dist/lib.module.d.ts +24 -24
- package/dist/package.json +2 -2
- package/dist/public_api.d.ts +14 -14
- package/dist/sitecore-jss-sitecore-jss-angular.d.ts +12 -12
- package/package.json +3 -3
|
@@ -4,1409 +4,1409 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['sitecore-jss'] = global['sitecore-jss'] || {}, global['sitecore-jss']['sitecore-jss-angular'] = {}), global.ng.core, global['@sitecore-jss/sitecore-jss'], global.ng.router, global.rxjs, global.rxjs.operators, global.ng.common));
|
|
5
5
|
}(this, (function (exports, core, sitecoreJss, router, rxjs, operators, common) { 'use strict';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* File fields cannot be managed via the EE. We never output "editable."
|
|
9
|
-
*/
|
|
10
|
-
var FileDirective = /** @class */ (function () {
|
|
11
|
-
function FileDirective(viewContainer, templateRef) {
|
|
12
|
-
this.viewContainer = viewContainer;
|
|
13
|
-
this.templateRef = templateRef;
|
|
14
|
-
}
|
|
15
|
-
FileDirective.prototype.ngOnChanges = function (changes) {
|
|
16
|
-
if (changes.field) {
|
|
17
|
-
if (!this.viewRef) {
|
|
18
|
-
this.viewContainer.clear();
|
|
19
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
20
|
-
}
|
|
21
|
-
this.updateView();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
FileDirective.prototype.updateView = function () {
|
|
25
|
-
var field = this.field;
|
|
26
|
-
if (!field || (!field.value && !field.src)) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
var file = field.src ? field : field.value;
|
|
30
|
-
this.viewRef.rootNodes.forEach(function (node) {
|
|
31
|
-
if (!file)
|
|
32
|
-
return;
|
|
33
|
-
node.href = file.src;
|
|
34
|
-
if (node.innerHTML === '') {
|
|
35
|
-
node.innerHTML = file.title || file.displayName;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
return FileDirective;
|
|
40
|
-
}());
|
|
41
|
-
FileDirective.decorators = [
|
|
42
|
-
{ type: core.Directive, args: [{ selector: '[scFile]' },] }
|
|
43
|
-
];
|
|
44
|
-
FileDirective.ctorParameters = function () { return [
|
|
45
|
-
{ type: core.ViewContainerRef },
|
|
46
|
-
{ type: core.TemplateRef }
|
|
47
|
-
]; };
|
|
48
|
-
FileDirective.propDecorators = {
|
|
49
|
-
field: [{ type: core.Input, args: ['scFile',] }]
|
|
7
|
+
/**
|
|
8
|
+
* File fields cannot be managed via the EE. We never output "editable."
|
|
9
|
+
*/
|
|
10
|
+
var FileDirective = /** @class */ (function () {
|
|
11
|
+
function FileDirective(viewContainer, templateRef) {
|
|
12
|
+
this.viewContainer = viewContainer;
|
|
13
|
+
this.templateRef = templateRef;
|
|
14
|
+
}
|
|
15
|
+
FileDirective.prototype.ngOnChanges = function (changes) {
|
|
16
|
+
if (changes.field) {
|
|
17
|
+
if (!this.viewRef) {
|
|
18
|
+
this.viewContainer.clear();
|
|
19
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
20
|
+
}
|
|
21
|
+
this.updateView();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
FileDirective.prototype.updateView = function () {
|
|
25
|
+
var field = this.field;
|
|
26
|
+
if (!field || (!field.value && !field.src)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
var file = field.src ? field : field.value;
|
|
30
|
+
this.viewRef.rootNodes.forEach(function (node) {
|
|
31
|
+
if (!file)
|
|
32
|
+
return;
|
|
33
|
+
node.href = file.src;
|
|
34
|
+
if (node.innerHTML === '') {
|
|
35
|
+
node.innerHTML = file.title || file.displayName;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
return FileDirective;
|
|
40
|
+
}());
|
|
41
|
+
FileDirective.decorators = [
|
|
42
|
+
{ type: core.Directive, args: [{ selector: '[scFile]' },] }
|
|
43
|
+
];
|
|
44
|
+
FileDirective.ctorParameters = function () { return [
|
|
45
|
+
{ type: core.ViewContainerRef },
|
|
46
|
+
{ type: core.TemplateRef }
|
|
47
|
+
]; };
|
|
48
|
+
FileDirective.propDecorators = {
|
|
49
|
+
field: [{ type: core.Input, args: ['scFile',] }]
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
/*! *****************************************************************************
|
|
53
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
54
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
55
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
56
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
57
|
-
|
|
58
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
59
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
60
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
61
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
62
|
-
|
|
63
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
64
|
-
and limitations under the License.
|
|
65
|
-
***************************************************************************** */
|
|
66
|
-
/* global Reflect, Promise */
|
|
67
|
-
var extendStatics = function (d, b) {
|
|
68
|
-
extendStatics = Object.setPrototypeOf ||
|
|
69
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
70
|
-
function (d, b) { for (var p in b)
|
|
71
|
-
if (b.hasOwnProperty(p))
|
|
72
|
-
d[p] = b[p]; };
|
|
73
|
-
return extendStatics(d, b);
|
|
74
|
-
};
|
|
75
|
-
function __extends(d, b) {
|
|
76
|
-
extendStatics(d, b);
|
|
77
|
-
function __() { this.constructor = d; }
|
|
78
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
79
|
-
}
|
|
80
|
-
var __assign = function () {
|
|
81
|
-
__assign = Object.assign || function __assign(t) {
|
|
82
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
83
|
-
s = arguments[i];
|
|
84
|
-
for (var p in s)
|
|
85
|
-
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
86
|
-
t[p] = s[p];
|
|
87
|
-
}
|
|
88
|
-
return t;
|
|
89
|
-
};
|
|
90
|
-
return __assign.apply(this, arguments);
|
|
91
|
-
};
|
|
92
|
-
function __rest(s, e) {
|
|
93
|
-
var t = {};
|
|
94
|
-
for (var p in s)
|
|
95
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
96
|
-
t[p] = s[p];
|
|
97
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
98
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
99
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
100
|
-
t[p[i]] = s[p[i]];
|
|
101
|
-
}
|
|
102
|
-
return t;
|
|
103
|
-
}
|
|
104
|
-
function __decorate(decorators, target, key, desc) {
|
|
105
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
106
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
107
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
108
|
-
else
|
|
109
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
110
|
-
if (d = decorators[i])
|
|
111
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
112
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
113
|
-
}
|
|
114
|
-
function __param(paramIndex, decorator) {
|
|
115
|
-
return function (target, key) { decorator(target, key, paramIndex); };
|
|
116
|
-
}
|
|
117
|
-
function __metadata(metadataKey, metadataValue) {
|
|
118
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
119
|
-
return Reflect.metadata(metadataKey, metadataValue);
|
|
120
|
-
}
|
|
121
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
122
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
123
|
-
function fulfilled(value) { try {
|
|
124
|
-
step(generator.next(value));
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
reject(e);
|
|
128
|
-
} }
|
|
129
|
-
function rejected(value) { try {
|
|
130
|
-
step(generator["throw"](value));
|
|
131
|
-
}
|
|
132
|
-
catch (e) {
|
|
133
|
-
reject(e);
|
|
134
|
-
} }
|
|
135
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
136
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
function __generator(thisArg, body) {
|
|
140
|
-
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
141
|
-
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
142
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
143
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
144
|
-
function step(op) {
|
|
145
|
-
if (f)
|
|
146
|
-
throw new TypeError("Generator is already executing.");
|
|
147
|
-
while (_)
|
|
148
|
-
try {
|
|
149
|
-
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)
|
|
150
|
-
return t;
|
|
151
|
-
if (y = 0, t)
|
|
152
|
-
op = [op[0] & 2, t.value];
|
|
153
|
-
switch (op[0]) {
|
|
154
|
-
case 0:
|
|
155
|
-
case 1:
|
|
156
|
-
t = op;
|
|
157
|
-
break;
|
|
158
|
-
case 4:
|
|
159
|
-
_.label++;
|
|
160
|
-
return { value: op[1], done: false };
|
|
161
|
-
case 5:
|
|
162
|
-
_.label++;
|
|
163
|
-
y = op[1];
|
|
164
|
-
op = [0];
|
|
165
|
-
continue;
|
|
166
|
-
case 7:
|
|
167
|
-
op = _.ops.pop();
|
|
168
|
-
_.trys.pop();
|
|
169
|
-
continue;
|
|
170
|
-
default:
|
|
171
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
172
|
-
_ = 0;
|
|
173
|
-
continue;
|
|
174
|
-
}
|
|
175
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
176
|
-
_.label = op[1];
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
180
|
-
_.label = t[1];
|
|
181
|
-
t = op;
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
if (t && _.label < t[2]) {
|
|
185
|
-
_.label = t[2];
|
|
186
|
-
_.ops.push(op);
|
|
187
|
-
break;
|
|
188
|
-
}
|
|
189
|
-
if (t[2])
|
|
190
|
-
_.ops.pop();
|
|
191
|
-
_.trys.pop();
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
op = body.call(thisArg, _);
|
|
195
|
-
}
|
|
196
|
-
catch (e) {
|
|
197
|
-
op = [6, e];
|
|
198
|
-
y = 0;
|
|
199
|
-
}
|
|
200
|
-
finally {
|
|
201
|
-
f = t = 0;
|
|
202
|
-
}
|
|
203
|
-
if (op[0] & 5)
|
|
204
|
-
throw op[1];
|
|
205
|
-
return { value: op[0] ? op[1] : void 0, done: true };
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function __exportStar(m, exports) {
|
|
209
|
-
for (var p in m)
|
|
210
|
-
if (!exports.hasOwnProperty(p))
|
|
211
|
-
exports[p] = m[p];
|
|
212
|
-
}
|
|
213
|
-
function __values(o) {
|
|
214
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
215
|
-
if (m)
|
|
216
|
-
return m.call(o);
|
|
217
|
-
return {
|
|
218
|
-
next: function () {
|
|
219
|
-
if (o && i >= o.length)
|
|
220
|
-
o = void 0;
|
|
221
|
-
return { value: o && o[i++], done: !o };
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
function __read(o, n) {
|
|
226
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
227
|
-
if (!m)
|
|
228
|
-
return o;
|
|
229
|
-
var i = m.call(o), r, ar = [], e;
|
|
230
|
-
try {
|
|
231
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
232
|
-
ar.push(r.value);
|
|
233
|
-
}
|
|
234
|
-
catch (error) {
|
|
235
|
-
e = { error: error };
|
|
236
|
-
}
|
|
237
|
-
finally {
|
|
238
|
-
try {
|
|
239
|
-
if (r && !r.done && (m = i["return"]))
|
|
240
|
-
m.call(i);
|
|
241
|
-
}
|
|
242
|
-
finally {
|
|
243
|
-
if (e)
|
|
244
|
-
throw e.error;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
return ar;
|
|
248
|
-
}
|
|
249
|
-
function __spread() {
|
|
250
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
251
|
-
ar = ar.concat(__read(arguments[i]));
|
|
252
|
-
return ar;
|
|
253
|
-
}
|
|
254
|
-
function __spreadArrays() {
|
|
255
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
256
|
-
s += arguments[i].length;
|
|
257
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
258
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
259
|
-
r[k] = a[j];
|
|
260
|
-
return r;
|
|
261
|
-
}
|
|
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
|
-
function __importStar(mod) {
|
|
309
|
-
if (mod && mod.__esModule)
|
|
310
|
-
return mod;
|
|
311
|
-
var result = {};
|
|
312
|
-
if (mod != null)
|
|
313
|
-
for (var k in mod)
|
|
314
|
-
if (Object.hasOwnProperty.call(mod, k))
|
|
315
|
-
result[k] = mod[k];
|
|
316
|
-
result.default = mod;
|
|
317
|
-
return result;
|
|
318
|
-
}
|
|
319
|
-
function __importDefault(mod) {
|
|
320
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
52
|
+
/*! *****************************************************************************
|
|
53
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
54
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
55
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
56
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
57
|
+
|
|
58
|
+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
59
|
+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
60
|
+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
61
|
+
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
62
|
+
|
|
63
|
+
See the Apache Version 2.0 License for specific language governing permissions
|
|
64
|
+
and limitations under the License.
|
|
65
|
+
***************************************************************************** */
|
|
66
|
+
/* global Reflect, Promise */
|
|
67
|
+
var extendStatics = function (d, b) {
|
|
68
|
+
extendStatics = Object.setPrototypeOf ||
|
|
69
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
70
|
+
function (d, b) { for (var p in b)
|
|
71
|
+
if (b.hasOwnProperty(p))
|
|
72
|
+
d[p] = b[p]; };
|
|
73
|
+
return extendStatics(d, b);
|
|
74
|
+
};
|
|
75
|
+
function __extends(d, b) {
|
|
76
|
+
extendStatics(d, b);
|
|
77
|
+
function __() { this.constructor = d; }
|
|
78
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
79
|
+
}
|
|
80
|
+
var __assign = function () {
|
|
81
|
+
__assign = Object.assign || function __assign(t) {
|
|
82
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
83
|
+
s = arguments[i];
|
|
84
|
+
for (var p in s)
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(s, p))
|
|
86
|
+
t[p] = s[p];
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
};
|
|
90
|
+
return __assign.apply(this, arguments);
|
|
91
|
+
};
|
|
92
|
+
function __rest(s, e) {
|
|
93
|
+
var t = {};
|
|
94
|
+
for (var p in s)
|
|
95
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
96
|
+
t[p] = s[p];
|
|
97
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
98
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
99
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
100
|
+
t[p[i]] = s[p[i]];
|
|
101
|
+
}
|
|
102
|
+
return t;
|
|
103
|
+
}
|
|
104
|
+
function __decorate(decorators, target, key, desc) {
|
|
105
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
106
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
107
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
108
|
+
else
|
|
109
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
110
|
+
if (d = decorators[i])
|
|
111
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
112
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
113
|
+
}
|
|
114
|
+
function __param(paramIndex, decorator) {
|
|
115
|
+
return function (target, key) { decorator(target, key, paramIndex); };
|
|
116
|
+
}
|
|
117
|
+
function __metadata(metadataKey, metadataValue) {
|
|
118
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
119
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
120
|
+
}
|
|
121
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
122
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
123
|
+
function fulfilled(value) { try {
|
|
124
|
+
step(generator.next(value));
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
reject(e);
|
|
128
|
+
} }
|
|
129
|
+
function rejected(value) { try {
|
|
130
|
+
step(generator["throw"](value));
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
reject(e);
|
|
134
|
+
} }
|
|
135
|
+
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
136
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function __generator(thisArg, body) {
|
|
140
|
+
var _ = { label: 0, sent: function () { if (t[0] & 1)
|
|
141
|
+
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
142
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
|
143
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
144
|
+
function step(op) {
|
|
145
|
+
if (f)
|
|
146
|
+
throw new TypeError("Generator is already executing.");
|
|
147
|
+
while (_)
|
|
148
|
+
try {
|
|
149
|
+
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)
|
|
150
|
+
return t;
|
|
151
|
+
if (y = 0, t)
|
|
152
|
+
op = [op[0] & 2, t.value];
|
|
153
|
+
switch (op[0]) {
|
|
154
|
+
case 0:
|
|
155
|
+
case 1:
|
|
156
|
+
t = op;
|
|
157
|
+
break;
|
|
158
|
+
case 4:
|
|
159
|
+
_.label++;
|
|
160
|
+
return { value: op[1], done: false };
|
|
161
|
+
case 5:
|
|
162
|
+
_.label++;
|
|
163
|
+
y = op[1];
|
|
164
|
+
op = [0];
|
|
165
|
+
continue;
|
|
166
|
+
case 7:
|
|
167
|
+
op = _.ops.pop();
|
|
168
|
+
_.trys.pop();
|
|
169
|
+
continue;
|
|
170
|
+
default:
|
|
171
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
172
|
+
_ = 0;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
176
|
+
_.label = op[1];
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
180
|
+
_.label = t[1];
|
|
181
|
+
t = op;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
if (t && _.label < t[2]) {
|
|
185
|
+
_.label = t[2];
|
|
186
|
+
_.ops.push(op);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
if (t[2])
|
|
190
|
+
_.ops.pop();
|
|
191
|
+
_.trys.pop();
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
op = body.call(thisArg, _);
|
|
195
|
+
}
|
|
196
|
+
catch (e) {
|
|
197
|
+
op = [6, e];
|
|
198
|
+
y = 0;
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
f = t = 0;
|
|
202
|
+
}
|
|
203
|
+
if (op[0] & 5)
|
|
204
|
+
throw op[1];
|
|
205
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function __exportStar(m, exports) {
|
|
209
|
+
for (var p in m)
|
|
210
|
+
if (!exports.hasOwnProperty(p))
|
|
211
|
+
exports[p] = m[p];
|
|
212
|
+
}
|
|
213
|
+
function __values(o) {
|
|
214
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
215
|
+
if (m)
|
|
216
|
+
return m.call(o);
|
|
217
|
+
return {
|
|
218
|
+
next: function () {
|
|
219
|
+
if (o && i >= o.length)
|
|
220
|
+
o = void 0;
|
|
221
|
+
return { value: o && o[i++], done: !o };
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
function __read(o, n) {
|
|
226
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
227
|
+
if (!m)
|
|
228
|
+
return o;
|
|
229
|
+
var i = m.call(o), r, ar = [], e;
|
|
230
|
+
try {
|
|
231
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
232
|
+
ar.push(r.value);
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
e = { error: error };
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
try {
|
|
239
|
+
if (r && !r.done && (m = i["return"]))
|
|
240
|
+
m.call(i);
|
|
241
|
+
}
|
|
242
|
+
finally {
|
|
243
|
+
if (e)
|
|
244
|
+
throw e.error;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return ar;
|
|
248
|
+
}
|
|
249
|
+
function __spread() {
|
|
250
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
251
|
+
ar = ar.concat(__read(arguments[i]));
|
|
252
|
+
return ar;
|
|
253
|
+
}
|
|
254
|
+
function __spreadArrays() {
|
|
255
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
|
256
|
+
s += arguments[i].length;
|
|
257
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
258
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
259
|
+
r[k] = a[j];
|
|
260
|
+
return r;
|
|
261
|
+
}
|
|
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
|
+
function __importStar(mod) {
|
|
309
|
+
if (mod && mod.__esModule)
|
|
310
|
+
return mod;
|
|
311
|
+
var result = {};
|
|
312
|
+
if (mod != null)
|
|
313
|
+
for (var k in mod)
|
|
314
|
+
if (Object.hasOwnProperty.call(mod, k))
|
|
315
|
+
result[k] = mod[k];
|
|
316
|
+
result.default = mod;
|
|
317
|
+
return result;
|
|
318
|
+
}
|
|
319
|
+
function __importDefault(mod) {
|
|
320
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
var ImageDirective = /** @class */ (function () {
|
|
324
|
-
function ImageDirective(viewContainer, templateRef, renderer, elementRef) {
|
|
325
|
-
this.viewContainer = viewContainer;
|
|
326
|
-
this.templateRef = templateRef;
|
|
327
|
-
this.renderer = renderer;
|
|
328
|
-
this.elementRef = elementRef;
|
|
329
|
-
this.inlineRef = null;
|
|
330
|
-
this.editable = true;
|
|
331
|
-
this.urlParams = {};
|
|
332
|
-
this.attrs = {};
|
|
333
|
-
}
|
|
334
|
-
ImageDirective.prototype.ngOnChanges = function (changes) {
|
|
335
|
-
if (changes.field || changes.editable || changes.urlParams || changes.attrs) {
|
|
336
|
-
this.viewContainer.clear();
|
|
337
|
-
if (this.inlineRef) {
|
|
338
|
-
this.inlineRef.remove();
|
|
339
|
-
this.inlineRef = null;
|
|
340
|
-
}
|
|
341
|
-
this.updateView();
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
ImageDirective.prototype.updateView = function () {
|
|
345
|
-
var overrideAttrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
346
|
-
var media = this.field;
|
|
347
|
-
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
var attrs = {};
|
|
351
|
-
// we likely have an experience editor value, should be a string
|
|
352
|
-
if (this.editable && media.editable) {
|
|
353
|
-
var foundImg = sitecoreJss.mediaApi.findEditorImageTag(media.editable);
|
|
354
|
-
if (!foundImg) {
|
|
355
|
-
return this.renderInlineWrapper(media.editable);
|
|
356
|
-
}
|
|
357
|
-
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
358
|
-
if (!attrs) {
|
|
359
|
-
return this.renderInlineWrapper(media.editable);
|
|
360
|
-
}
|
|
361
|
-
var tempImg_1 = this.renderer.createElement('img');
|
|
362
|
-
Object.entries(attrs).forEach(function (_a) {
|
|
363
|
-
var _b = __read(_a, 2), key = _b[0], attrValue = _b[1];
|
|
364
|
-
return tempImg_1.setAttribute(key, attrValue);
|
|
365
|
-
});
|
|
366
|
-
var editableMarkup = media.editable.replace(foundImg.imgTag, tempImg_1.outerHTML);
|
|
367
|
-
return this.renderInlineWrapper(editableMarkup);
|
|
368
|
-
}
|
|
369
|
-
// some wise-guy/gal is passing in a 'raw' image object value
|
|
370
|
-
var img = media.src ? media : media.value;
|
|
371
|
-
if (!img) {
|
|
372
|
-
return null;
|
|
373
|
-
}
|
|
374
|
-
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
375
|
-
if (attrs) {
|
|
376
|
-
this.renderTemplate(attrs);
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
ImageDirective.prototype.getImageAttrs = function (fieldAttrs, parsedAttrs, imageParams) {
|
|
380
|
-
var combinedAttrs = Object.assign(Object.assign({}, fieldAttrs), parsedAttrs);
|
|
381
|
-
// eslint-disable-next-line prefer-const
|
|
382
|
-
var src = combinedAttrs.src, srcSet = combinedAttrs.srcSet, otherAttrs = __rest(combinedAttrs, ["src", "srcSet"]);
|
|
383
|
-
if (!src) {
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
var newAttrs = Object.assign({}, otherAttrs);
|
|
387
|
-
// update image URL for jss handler and image rendering params
|
|
388
|
-
src = sitecoreJss.mediaApi.updateImageUrl(src, imageParams, this.mediaUrlPrefix);
|
|
389
|
-
if (srcSet) {
|
|
390
|
-
// replace with HTML-formatted srcset, including updated image URLs
|
|
391
|
-
newAttrs.srcSet = sitecoreJss.mediaApi.getSrcSet(src, srcSet, imageParams, this.mediaUrlPrefix);
|
|
392
|
-
}
|
|
393
|
-
else {
|
|
394
|
-
newAttrs.src = src;
|
|
395
|
-
}
|
|
396
|
-
return newAttrs;
|
|
397
|
-
};
|
|
398
|
-
ImageDirective.prototype.renderTemplate = function (imageProps) {
|
|
399
|
-
var _this = this;
|
|
400
|
-
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
401
|
-
viewRef.rootNodes.forEach(function (node) {
|
|
402
|
-
Object.entries(imageProps).forEach(function (_a) {
|
|
403
|
-
var _b = __read(_a, 2), key = _b[0], imgPropVal = _b[1];
|
|
404
|
-
return _this.renderer.setAttribute(node, key, imgPropVal);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
};
|
|
408
|
-
ImageDirective.prototype.getElementAttrs = function () {
|
|
409
|
-
var view = this.templateRef.createEmbeddedView(null);
|
|
410
|
-
var element = view.rootNodes[0];
|
|
411
|
-
if (!element) {
|
|
412
|
-
return {};
|
|
413
|
-
}
|
|
414
|
-
var attrs = {};
|
|
415
|
-
for (var i = 0; i < element.attributes.length; i++) {
|
|
416
|
-
var attr = element.attributes.item(i);
|
|
417
|
-
if (attr) {
|
|
418
|
-
attrs[attr.name] = attr.value;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return attrs;
|
|
422
|
-
};
|
|
423
|
-
ImageDirective.prototype.renderInlineWrapper = function (editable) {
|
|
424
|
-
var span = this.renderer.createElement('span');
|
|
425
|
-
span.className = 'sc-image-wrapper';
|
|
426
|
-
span.innerHTML = editable;
|
|
427
|
-
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
428
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
429
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
430
|
-
this.inlineRef = span;
|
|
431
|
-
};
|
|
432
|
-
return ImageDirective;
|
|
433
|
-
}());
|
|
434
|
-
ImageDirective.decorators = [
|
|
435
|
-
{ type: core.Directive, args: [{ selector: '[scImage]' },] }
|
|
436
|
-
];
|
|
437
|
-
ImageDirective.ctorParameters = function () { return [
|
|
438
|
-
{ type: core.ViewContainerRef },
|
|
439
|
-
{ type: core.TemplateRef },
|
|
440
|
-
{ type: core.Renderer2 },
|
|
441
|
-
{ type: core.ElementRef }
|
|
442
|
-
]; };
|
|
443
|
-
ImageDirective.propDecorators = {
|
|
444
|
-
field: [{ type: core.Input, args: ['scImage',] }],
|
|
445
|
-
editable: [{ type: core.Input, args: ['scImageEditable',] }],
|
|
446
|
-
mediaUrlPrefix: [{ type: core.Input, args: ['scImageMediaUrlPrefix',] }],
|
|
447
|
-
urlParams: [{ type: core.Input, args: ['scImageUrlParams',] }],
|
|
448
|
-
attrs: [{ type: core.Input, args: ['scImageAttrs',] }]
|
|
323
|
+
var ImageDirective = /** @class */ (function () {
|
|
324
|
+
function ImageDirective(viewContainer, templateRef, renderer, elementRef) {
|
|
325
|
+
this.viewContainer = viewContainer;
|
|
326
|
+
this.templateRef = templateRef;
|
|
327
|
+
this.renderer = renderer;
|
|
328
|
+
this.elementRef = elementRef;
|
|
329
|
+
this.inlineRef = null;
|
|
330
|
+
this.editable = true;
|
|
331
|
+
this.urlParams = {};
|
|
332
|
+
this.attrs = {};
|
|
333
|
+
}
|
|
334
|
+
ImageDirective.prototype.ngOnChanges = function (changes) {
|
|
335
|
+
if (changes.field || changes.editable || changes.urlParams || changes.attrs) {
|
|
336
|
+
this.viewContainer.clear();
|
|
337
|
+
if (this.inlineRef) {
|
|
338
|
+
this.inlineRef.remove();
|
|
339
|
+
this.inlineRef = null;
|
|
340
|
+
}
|
|
341
|
+
this.updateView();
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
ImageDirective.prototype.updateView = function () {
|
|
345
|
+
var overrideAttrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
346
|
+
var media = this.field;
|
|
347
|
+
if (!media || (!media.editable && !media.value && !media.src)) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
var attrs = {};
|
|
351
|
+
// we likely have an experience editor value, should be a string
|
|
352
|
+
if (this.editable && media.editable) {
|
|
353
|
+
var foundImg = sitecoreJss.mediaApi.findEditorImageTag(media.editable);
|
|
354
|
+
if (!foundImg) {
|
|
355
|
+
return this.renderInlineWrapper(media.editable);
|
|
356
|
+
}
|
|
357
|
+
attrs = this.getImageAttrs(foundImg.attrs, overrideAttrs, this.urlParams);
|
|
358
|
+
if (!attrs) {
|
|
359
|
+
return this.renderInlineWrapper(media.editable);
|
|
360
|
+
}
|
|
361
|
+
var tempImg_1 = this.renderer.createElement('img');
|
|
362
|
+
Object.entries(attrs).forEach(function (_a) {
|
|
363
|
+
var _b = __read(_a, 2), key = _b[0], attrValue = _b[1];
|
|
364
|
+
return tempImg_1.setAttribute(key, attrValue);
|
|
365
|
+
});
|
|
366
|
+
var editableMarkup = media.editable.replace(foundImg.imgTag, tempImg_1.outerHTML);
|
|
367
|
+
return this.renderInlineWrapper(editableMarkup);
|
|
368
|
+
}
|
|
369
|
+
// some wise-guy/gal is passing in a 'raw' image object value
|
|
370
|
+
var img = media.src ? media : media.value;
|
|
371
|
+
if (!img) {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
attrs = this.getImageAttrs(img, overrideAttrs, this.urlParams);
|
|
375
|
+
if (attrs) {
|
|
376
|
+
this.renderTemplate(attrs);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
ImageDirective.prototype.getImageAttrs = function (fieldAttrs, parsedAttrs, imageParams) {
|
|
380
|
+
var combinedAttrs = Object.assign(Object.assign({}, fieldAttrs), parsedAttrs);
|
|
381
|
+
// eslint-disable-next-line prefer-const
|
|
382
|
+
var src = combinedAttrs.src, srcSet = combinedAttrs.srcSet, otherAttrs = __rest(combinedAttrs, ["src", "srcSet"]);
|
|
383
|
+
if (!src) {
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
var newAttrs = Object.assign({}, otherAttrs);
|
|
387
|
+
// update image URL for jss handler and image rendering params
|
|
388
|
+
src = sitecoreJss.mediaApi.updateImageUrl(src, imageParams, this.mediaUrlPrefix);
|
|
389
|
+
if (srcSet) {
|
|
390
|
+
// replace with HTML-formatted srcset, including updated image URLs
|
|
391
|
+
newAttrs.srcSet = sitecoreJss.mediaApi.getSrcSet(src, srcSet, imageParams, this.mediaUrlPrefix);
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
newAttrs.src = src;
|
|
395
|
+
}
|
|
396
|
+
return newAttrs;
|
|
397
|
+
};
|
|
398
|
+
ImageDirective.prototype.renderTemplate = function (imageProps) {
|
|
399
|
+
var _this = this;
|
|
400
|
+
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
401
|
+
viewRef.rootNodes.forEach(function (node) {
|
|
402
|
+
Object.entries(imageProps).forEach(function (_a) {
|
|
403
|
+
var _b = __read(_a, 2), key = _b[0], imgPropVal = _b[1];
|
|
404
|
+
return _this.renderer.setAttribute(node, key, imgPropVal);
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
ImageDirective.prototype.getElementAttrs = function () {
|
|
409
|
+
var view = this.templateRef.createEmbeddedView(null);
|
|
410
|
+
var element = view.rootNodes[0];
|
|
411
|
+
if (!element) {
|
|
412
|
+
return {};
|
|
413
|
+
}
|
|
414
|
+
var attrs = {};
|
|
415
|
+
for (var i = 0; i < element.attributes.length; i++) {
|
|
416
|
+
var attr = element.attributes.item(i);
|
|
417
|
+
if (attr) {
|
|
418
|
+
attrs[attr.name] = attr.value;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return attrs;
|
|
422
|
+
};
|
|
423
|
+
ImageDirective.prototype.renderInlineWrapper = function (editable) {
|
|
424
|
+
var span = this.renderer.createElement('span');
|
|
425
|
+
span.className = 'sc-image-wrapper';
|
|
426
|
+
span.innerHTML = editable;
|
|
427
|
+
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
428
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
429
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
430
|
+
this.inlineRef = span;
|
|
431
|
+
};
|
|
432
|
+
return ImageDirective;
|
|
433
|
+
}());
|
|
434
|
+
ImageDirective.decorators = [
|
|
435
|
+
{ type: core.Directive, args: [{ selector: '[scImage]' },] }
|
|
436
|
+
];
|
|
437
|
+
ImageDirective.ctorParameters = function () { return [
|
|
438
|
+
{ type: core.ViewContainerRef },
|
|
439
|
+
{ type: core.TemplateRef },
|
|
440
|
+
{ type: core.Renderer2 },
|
|
441
|
+
{ type: core.ElementRef }
|
|
442
|
+
]; };
|
|
443
|
+
ImageDirective.propDecorators = {
|
|
444
|
+
field: [{ type: core.Input, args: ['scImage',] }],
|
|
445
|
+
editable: [{ type: core.Input, args: ['scImageEditable',] }],
|
|
446
|
+
mediaUrlPrefix: [{ type: core.Input, args: ['scImageMediaUrlPrefix',] }],
|
|
447
|
+
urlParams: [{ type: core.Input, args: ['scImageUrlParams',] }],
|
|
448
|
+
attrs: [{ type: core.Input, args: ['scImageAttrs',] }]
|
|
449
449
|
};
|
|
450
450
|
|
|
451
|
-
var LinkDirective = /** @class */ (function () {
|
|
452
|
-
function LinkDirective(viewContainer, templateRef, renderer, elementRef) {
|
|
453
|
-
this.viewContainer = viewContainer;
|
|
454
|
-
this.templateRef = templateRef;
|
|
455
|
-
this.renderer = renderer;
|
|
456
|
-
this.elementRef = elementRef;
|
|
457
|
-
this.inlineRef = null;
|
|
458
|
-
this.editable = true;
|
|
459
|
-
this.attrs = {};
|
|
460
|
-
}
|
|
461
|
-
LinkDirective.prototype.ngOnChanges = function (changes) {
|
|
462
|
-
if (changes.field || changes.editable || changes.attrs) {
|
|
463
|
-
this.viewContainer.clear();
|
|
464
|
-
if (this.inlineRef) {
|
|
465
|
-
this.inlineRef.remove();
|
|
466
|
-
this.inlineRef = null;
|
|
467
|
-
}
|
|
468
|
-
this.updateView();
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
LinkDirective.prototype.updateView = function () {
|
|
472
|
-
var _a, _b;
|
|
473
|
-
var field = this.field;
|
|
474
|
-
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
475
|
-
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
476
|
-
}
|
|
477
|
-
else if (field && (field.href || field.value)) {
|
|
478
|
-
var props = field.href ? field : field.value;
|
|
479
|
-
var linkText = field.text || ((_a = field.value) === null || _a === void 0 ? void 0 : _a.text) || field.href || ((_b = field.value) === null || _b === void 0 ? void 0 : _b.href);
|
|
480
|
-
var mergedAttrs = Object.assign(Object.assign({}, props), this.attrs);
|
|
481
|
-
this.renderTemplate(mergedAttrs, linkText);
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
LinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
485
|
-
var _this = this;
|
|
486
|
-
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
487
|
-
viewRef.rootNodes.forEach(function (node) {
|
|
488
|
-
Object.entries(props).forEach(function (_c) {
|
|
489
|
-
var _d = __read(_c, 2), key = _d[0], propValue = _d[1];
|
|
490
|
-
if (typeof propValue !== 'string')
|
|
491
|
-
return;
|
|
492
|
-
if (key === 'href') {
|
|
493
|
-
var isInvalidLink = !propValue || /^https?:\/\/$/.test(propValue);
|
|
494
|
-
if (isInvalidLink) {
|
|
495
|
-
if (!node.href) {
|
|
496
|
-
return;
|
|
497
|
-
}
|
|
498
|
-
propValue = node.href;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
if (key === 'class' && node.className) {
|
|
502
|
-
propValue += " " + node.className;
|
|
503
|
-
}
|
|
504
|
-
_this.renderer.setAttribute(node, key, propValue);
|
|
505
|
-
});
|
|
506
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
507
|
-
node.textContent = linkText;
|
|
508
|
-
}
|
|
509
|
-
});
|
|
510
|
-
};
|
|
511
|
-
LinkDirective.prototype.renderInlineWrapper = function (editableFirstPart, editableLastPart) {
|
|
512
|
-
var _this = this;
|
|
513
|
-
var span = this.renderer.createElement('span');
|
|
514
|
-
span.className = 'sc-link-wrapper';
|
|
515
|
-
span.innerHTML = editableFirstPart + editableLastPart;
|
|
516
|
-
// assign attributes from template to inline wrapper
|
|
517
|
-
var attrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
518
|
-
Object.entries(attrs).forEach(function (_c) {
|
|
519
|
-
var _d = __read(_c, 2), key = _d[0], attrValue = _d[1];
|
|
520
|
-
return _this.renderer.setAttribute(span, key, attrValue);
|
|
521
|
-
});
|
|
522
|
-
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
523
|
-
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
524
|
-
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
525
|
-
this.inlineRef = span;
|
|
526
|
-
};
|
|
527
|
-
LinkDirective.prototype.getElementAttrs = function () {
|
|
528
|
-
var view = this.templateRef.createEmbeddedView(null);
|
|
529
|
-
var element = view.rootNodes[0];
|
|
530
|
-
if (!element) {
|
|
531
|
-
return {};
|
|
532
|
-
}
|
|
533
|
-
var attrs = {};
|
|
534
|
-
for (var i = 0; i < element.attributes.length; i++) {
|
|
535
|
-
var attr = element.attributes.item(i);
|
|
536
|
-
if (attr) {
|
|
537
|
-
attrs[attr.name] = attr.value;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
return attrs;
|
|
541
|
-
};
|
|
542
|
-
return LinkDirective;
|
|
543
|
-
}());
|
|
544
|
-
LinkDirective.decorators = [
|
|
545
|
-
{ type: core.Directive, args: [{ selector: '[scLink]' },] }
|
|
546
|
-
];
|
|
547
|
-
LinkDirective.ctorParameters = function () { return [
|
|
548
|
-
{ type: core.ViewContainerRef },
|
|
549
|
-
{ type: core.TemplateRef },
|
|
550
|
-
{ type: core.Renderer2 },
|
|
551
|
-
{ type: core.ElementRef }
|
|
552
|
-
]; };
|
|
553
|
-
LinkDirective.propDecorators = {
|
|
554
|
-
editable: [{ type: core.Input, args: ['scLinkEditable',] }],
|
|
555
|
-
attrs: [{ type: core.Input, args: ['scLinkAttrs',] }],
|
|
556
|
-
field: [{ type: core.Input, args: ['scLink',] }]
|
|
451
|
+
var LinkDirective = /** @class */ (function () {
|
|
452
|
+
function LinkDirective(viewContainer, templateRef, renderer, elementRef) {
|
|
453
|
+
this.viewContainer = viewContainer;
|
|
454
|
+
this.templateRef = templateRef;
|
|
455
|
+
this.renderer = renderer;
|
|
456
|
+
this.elementRef = elementRef;
|
|
457
|
+
this.inlineRef = null;
|
|
458
|
+
this.editable = true;
|
|
459
|
+
this.attrs = {};
|
|
460
|
+
}
|
|
461
|
+
LinkDirective.prototype.ngOnChanges = function (changes) {
|
|
462
|
+
if (changes.field || changes.editable || changes.attrs) {
|
|
463
|
+
this.viewContainer.clear();
|
|
464
|
+
if (this.inlineRef) {
|
|
465
|
+
this.inlineRef.remove();
|
|
466
|
+
this.inlineRef = null;
|
|
467
|
+
}
|
|
468
|
+
this.updateView();
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
LinkDirective.prototype.updateView = function () {
|
|
472
|
+
var _a, _b;
|
|
473
|
+
var field = this.field;
|
|
474
|
+
if (this.editable && field && field.editableFirstPart && field.editableLastPart) {
|
|
475
|
+
this.renderInlineWrapper(field.editableFirstPart, field.editableLastPart);
|
|
476
|
+
}
|
|
477
|
+
else if (field && (field.href || field.value)) {
|
|
478
|
+
var props = field.href ? field : field.value;
|
|
479
|
+
var linkText = field.text || ((_a = field.value) === null || _a === void 0 ? void 0 : _a.text) || field.href || ((_b = field.value) === null || _b === void 0 ? void 0 : _b.href);
|
|
480
|
+
var mergedAttrs = Object.assign(Object.assign({}, props), this.attrs);
|
|
481
|
+
this.renderTemplate(mergedAttrs, linkText);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
LinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
485
|
+
var _this = this;
|
|
486
|
+
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
487
|
+
viewRef.rootNodes.forEach(function (node) {
|
|
488
|
+
Object.entries(props).forEach(function (_c) {
|
|
489
|
+
var _d = __read(_c, 2), key = _d[0], propValue = _d[1];
|
|
490
|
+
if (typeof propValue !== 'string')
|
|
491
|
+
return;
|
|
492
|
+
if (key === 'href') {
|
|
493
|
+
var isInvalidLink = !propValue || /^https?:\/\/$/.test(propValue);
|
|
494
|
+
if (isInvalidLink) {
|
|
495
|
+
if (!node.href) {
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
propValue = node.href;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
if (key === 'class' && node.className) {
|
|
502
|
+
propValue += " " + node.className;
|
|
503
|
+
}
|
|
504
|
+
_this.renderer.setAttribute(node, key, propValue);
|
|
505
|
+
});
|
|
506
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
507
|
+
node.textContent = linkText;
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
LinkDirective.prototype.renderInlineWrapper = function (editableFirstPart, editableLastPart) {
|
|
512
|
+
var _this = this;
|
|
513
|
+
var span = this.renderer.createElement('span');
|
|
514
|
+
span.className = 'sc-link-wrapper';
|
|
515
|
+
span.innerHTML = editableFirstPart + editableLastPart;
|
|
516
|
+
// assign attributes from template to inline wrapper
|
|
517
|
+
var attrs = Object.assign(Object.assign({}, this.getElementAttrs()), this.attrs);
|
|
518
|
+
Object.entries(attrs).forEach(function (_c) {
|
|
519
|
+
var _d = __read(_c, 2), key = _d[0], attrValue = _d[1];
|
|
520
|
+
return _this.renderer.setAttribute(span, key, attrValue);
|
|
521
|
+
});
|
|
522
|
+
this.viewContainer.createEmbeddedView(this.templateRef);
|
|
523
|
+
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
524
|
+
this.renderer.insertBefore(parentNode, span, this.elementRef.nativeElement);
|
|
525
|
+
this.inlineRef = span;
|
|
526
|
+
};
|
|
527
|
+
LinkDirective.prototype.getElementAttrs = function () {
|
|
528
|
+
var view = this.templateRef.createEmbeddedView(null);
|
|
529
|
+
var element = view.rootNodes[0];
|
|
530
|
+
if (!element) {
|
|
531
|
+
return {};
|
|
532
|
+
}
|
|
533
|
+
var attrs = {};
|
|
534
|
+
for (var i = 0; i < element.attributes.length; i++) {
|
|
535
|
+
var attr = element.attributes.item(i);
|
|
536
|
+
if (attr) {
|
|
537
|
+
attrs[attr.name] = attr.value;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return attrs;
|
|
541
|
+
};
|
|
542
|
+
return LinkDirective;
|
|
543
|
+
}());
|
|
544
|
+
LinkDirective.decorators = [
|
|
545
|
+
{ type: core.Directive, args: [{ selector: '[scLink]' },] }
|
|
546
|
+
];
|
|
547
|
+
LinkDirective.ctorParameters = function () { return [
|
|
548
|
+
{ type: core.ViewContainerRef },
|
|
549
|
+
{ type: core.TemplateRef },
|
|
550
|
+
{ type: core.Renderer2 },
|
|
551
|
+
{ type: core.ElementRef }
|
|
552
|
+
]; };
|
|
553
|
+
LinkDirective.propDecorators = {
|
|
554
|
+
editable: [{ type: core.Input, args: ['scLinkEditable',] }],
|
|
555
|
+
attrs: [{ type: core.Input, args: ['scLinkAttrs',] }],
|
|
556
|
+
field: [{ type: core.Input, args: ['scLink',] }]
|
|
557
557
|
};
|
|
558
558
|
|
|
559
|
-
var RouterLinkDirective = /** @class */ (function (_super) {
|
|
560
|
-
__extends(RouterLinkDirective, _super);
|
|
561
|
-
function RouterLinkDirective(viewContainer, templateRef, renderer, elementRef, router) {
|
|
562
|
-
var _this = _super.call(this, viewContainer, templateRef, renderer, elementRef) || this;
|
|
563
|
-
_this.router = router;
|
|
564
|
-
_this.editable = true;
|
|
565
|
-
_this.attrs = {};
|
|
566
|
-
return _this;
|
|
567
|
-
}
|
|
568
|
-
RouterLinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
569
|
-
var _this = this;
|
|
570
|
-
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
571
|
-
viewRef.rootNodes.forEach(function (node) {
|
|
572
|
-
Object.entries(props).forEach(function (_a) {
|
|
573
|
-
var _b = __read(_a, 2), key = _b[0], propValue = _b[1];
|
|
574
|
-
_this.renderer.setAttribute(node, key, propValue);
|
|
575
|
-
if (key === 'href') {
|
|
576
|
-
_this.renderer.listen(node, 'click', function (event) {
|
|
577
|
-
_this.router.navigate([propValue]);
|
|
578
|
-
event.preventDefault();
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
583
|
-
node.textContent = linkText;
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
};
|
|
587
|
-
return RouterLinkDirective;
|
|
588
|
-
}(LinkDirective));
|
|
589
|
-
RouterLinkDirective.decorators = [
|
|
590
|
-
{ type: core.Directive, args: [{ selector: '[scRouterLink]' },] }
|
|
591
|
-
];
|
|
592
|
-
RouterLinkDirective.ctorParameters = function () { return [
|
|
593
|
-
{ type: core.ViewContainerRef },
|
|
594
|
-
{ type: core.TemplateRef },
|
|
595
|
-
{ type: core.Renderer2 },
|
|
596
|
-
{ type: core.ElementRef },
|
|
597
|
-
{ type: router.Router }
|
|
598
|
-
]; };
|
|
599
|
-
RouterLinkDirective.propDecorators = {
|
|
600
|
-
editable: [{ type: core.Input, args: ['scRouterLinkEditable',] }],
|
|
601
|
-
attrs: [{ type: core.Input, args: ['scRouterLinkAttrs',] }],
|
|
602
|
-
field: [{ type: core.Input, args: ['scRouterLink',] }]
|
|
559
|
+
var RouterLinkDirective = /** @class */ (function (_super) {
|
|
560
|
+
__extends(RouterLinkDirective, _super);
|
|
561
|
+
function RouterLinkDirective(viewContainer, templateRef, renderer, elementRef, router) {
|
|
562
|
+
var _this = _super.call(this, viewContainer, templateRef, renderer, elementRef) || this;
|
|
563
|
+
_this.router = router;
|
|
564
|
+
_this.editable = true;
|
|
565
|
+
_this.attrs = {};
|
|
566
|
+
return _this;
|
|
567
|
+
}
|
|
568
|
+
RouterLinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
569
|
+
var _this = this;
|
|
570
|
+
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
571
|
+
viewRef.rootNodes.forEach(function (node) {
|
|
572
|
+
Object.entries(props).forEach(function (_a) {
|
|
573
|
+
var _b = __read(_a, 2), key = _b[0], propValue = _b[1];
|
|
574
|
+
_this.renderer.setAttribute(node, key, propValue);
|
|
575
|
+
if (key === 'href') {
|
|
576
|
+
_this.renderer.listen(node, 'click', function (event) {
|
|
577
|
+
_this.router.navigate([propValue]);
|
|
578
|
+
event.preventDefault();
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
583
|
+
node.textContent = linkText;
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
};
|
|
587
|
+
return RouterLinkDirective;
|
|
588
|
+
}(LinkDirective));
|
|
589
|
+
RouterLinkDirective.decorators = [
|
|
590
|
+
{ type: core.Directive, args: [{ selector: '[scRouterLink]' },] }
|
|
591
|
+
];
|
|
592
|
+
RouterLinkDirective.ctorParameters = function () { return [
|
|
593
|
+
{ type: core.ViewContainerRef },
|
|
594
|
+
{ type: core.TemplateRef },
|
|
595
|
+
{ type: core.Renderer2 },
|
|
596
|
+
{ type: core.ElementRef },
|
|
597
|
+
{ type: router.Router }
|
|
598
|
+
]; };
|
|
599
|
+
RouterLinkDirective.propDecorators = {
|
|
600
|
+
editable: [{ type: core.Input, args: ['scRouterLinkEditable',] }],
|
|
601
|
+
attrs: [{ type: core.Input, args: ['scRouterLinkAttrs',] }],
|
|
602
|
+
field: [{ type: core.Input, args: ['scRouterLink',] }]
|
|
603
603
|
};
|
|
604
604
|
|
|
605
|
-
var GenericLinkDirective = /** @class */ (function (_super) {
|
|
606
|
-
__extends(GenericLinkDirective, _super);
|
|
607
|
-
function GenericLinkDirective(viewContainer, templateRef, renderer, elementRef, router) {
|
|
608
|
-
var _this = _super.call(this, viewContainer, templateRef, renderer, elementRef) || this;
|
|
609
|
-
_this.router = router;
|
|
610
|
-
_this.editable = true;
|
|
611
|
-
_this.attrs = {};
|
|
612
|
-
return _this;
|
|
613
|
-
}
|
|
614
|
-
GenericLinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
615
|
-
var _this = this;
|
|
616
|
-
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
617
|
-
viewRef.rootNodes.forEach(function (node) {
|
|
618
|
-
Object.entries(props).forEach(function (_a) {
|
|
619
|
-
var _b = __read(_a, 2), key = _b[0], propValue = _b[1];
|
|
620
|
-
if (key === 'href' && !_this.isAbsoluteUrl(propValue)) {
|
|
621
|
-
var urlTree = _this.router.createUrlTree([propValue], _this.extras);
|
|
622
|
-
_this.renderer.setAttribute(node, key, _this.router.serializeUrl(urlTree));
|
|
623
|
-
_this.renderer.listen(node, 'click', function (event) {
|
|
624
|
-
_this.router.navigate([propValue], _this.extras);
|
|
625
|
-
event.preventDefault();
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
else {
|
|
629
|
-
_this.renderer.setAttribute(node, key, propValue);
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
633
|
-
node.textContent = linkText;
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
};
|
|
637
|
-
GenericLinkDirective.prototype.isAbsoluteUrl = function (url) {
|
|
638
|
-
if (url === null) {
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
if (typeof url !== 'string') {
|
|
642
|
-
throw new TypeError('Expected a string');
|
|
643
|
-
}
|
|
644
|
-
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
645
|
-
};
|
|
646
|
-
return GenericLinkDirective;
|
|
647
|
-
}(LinkDirective));
|
|
648
|
-
GenericLinkDirective.decorators = [
|
|
649
|
-
{ type: core.Directive, args: [{ selector: '[scGenericLink]' },] }
|
|
650
|
-
];
|
|
651
|
-
GenericLinkDirective.ctorParameters = function () { return [
|
|
652
|
-
{ type: core.ViewContainerRef },
|
|
653
|
-
{ type: core.TemplateRef },
|
|
654
|
-
{ type: core.Renderer2 },
|
|
655
|
-
{ type: core.ElementRef },
|
|
656
|
-
{ type: router.Router }
|
|
657
|
-
]; };
|
|
658
|
-
GenericLinkDirective.propDecorators = {
|
|
659
|
-
editable: [{ type: core.Input, args: ['scGenericLinkEditable',] }],
|
|
660
|
-
attrs: [{ type: core.Input, args: ['scGenericLinkAttrs',] }],
|
|
661
|
-
field: [{ type: core.Input, args: ['scGenericLink',] }],
|
|
662
|
-
extras: [{ type: core.Input, args: ['scGenericLinkExtras',] }]
|
|
605
|
+
var GenericLinkDirective = /** @class */ (function (_super) {
|
|
606
|
+
__extends(GenericLinkDirective, _super);
|
|
607
|
+
function GenericLinkDirective(viewContainer, templateRef, renderer, elementRef, router) {
|
|
608
|
+
var _this = _super.call(this, viewContainer, templateRef, renderer, elementRef) || this;
|
|
609
|
+
_this.router = router;
|
|
610
|
+
_this.editable = true;
|
|
611
|
+
_this.attrs = {};
|
|
612
|
+
return _this;
|
|
613
|
+
}
|
|
614
|
+
GenericLinkDirective.prototype.renderTemplate = function (props, linkText) {
|
|
615
|
+
var _this = this;
|
|
616
|
+
var viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
617
|
+
viewRef.rootNodes.forEach(function (node) {
|
|
618
|
+
Object.entries(props).forEach(function (_a) {
|
|
619
|
+
var _b = __read(_a, 2), key = _b[0], propValue = _b[1];
|
|
620
|
+
if (key === 'href' && !_this.isAbsoluteUrl(propValue)) {
|
|
621
|
+
var urlTree = _this.router.createUrlTree([propValue], _this.extras);
|
|
622
|
+
_this.renderer.setAttribute(node, key, _this.router.serializeUrl(urlTree));
|
|
623
|
+
_this.renderer.listen(node, 'click', function (event) {
|
|
624
|
+
_this.router.navigate([propValue], _this.extras);
|
|
625
|
+
event.preventDefault();
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
_this.renderer.setAttribute(node, key, propValue);
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
if (node.childNodes && node.childNodes.length === 0 && linkText) {
|
|
633
|
+
node.textContent = linkText;
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
};
|
|
637
|
+
GenericLinkDirective.prototype.isAbsoluteUrl = function (url) {
|
|
638
|
+
if (url === null) {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
if (typeof url !== 'string') {
|
|
642
|
+
throw new TypeError('Expected a string');
|
|
643
|
+
}
|
|
644
|
+
return /^[a-z][a-z0-9+.-]*:/.test(url);
|
|
645
|
+
};
|
|
646
|
+
return GenericLinkDirective;
|
|
647
|
+
}(LinkDirective));
|
|
648
|
+
GenericLinkDirective.decorators = [
|
|
649
|
+
{ type: core.Directive, args: [{ selector: '[scGenericLink]' },] }
|
|
650
|
+
];
|
|
651
|
+
GenericLinkDirective.ctorParameters = function () { return [
|
|
652
|
+
{ type: core.ViewContainerRef },
|
|
653
|
+
{ type: core.TemplateRef },
|
|
654
|
+
{ type: core.Renderer2 },
|
|
655
|
+
{ type: core.ElementRef },
|
|
656
|
+
{ type: router.Router }
|
|
657
|
+
]; };
|
|
658
|
+
GenericLinkDirective.propDecorators = {
|
|
659
|
+
editable: [{ type: core.Input, args: ['scGenericLinkEditable',] }],
|
|
660
|
+
attrs: [{ type: core.Input, args: ['scGenericLinkAttrs',] }],
|
|
661
|
+
field: [{ type: core.Input, args: ['scGenericLink',] }],
|
|
662
|
+
extras: [{ type: core.Input, args: ['scGenericLinkExtras',] }]
|
|
663
663
|
};
|
|
664
664
|
|
|
665
|
-
/** Registers a statically loaded component */
|
|
666
|
-
var ComponentNameAndType = /** @class */ (function () {
|
|
667
|
-
function ComponentNameAndType() {
|
|
668
|
-
}
|
|
669
|
-
return ComponentNameAndType;
|
|
670
|
-
}());
|
|
671
|
-
/**
|
|
672
|
-
* @param {unknown} object
|
|
673
|
-
*/
|
|
674
|
-
function instanceOfComponentNameAndType(object) {
|
|
675
|
-
return typeof object === 'object' && object !== null && 'type' in object;
|
|
676
|
-
}
|
|
677
|
-
/**
|
|
678
|
-
* @param {unknown} object
|
|
679
|
-
*/
|
|
680
|
-
function instanceOfComponentNameAndModule(object) {
|
|
681
|
-
return typeof object === 'object' && object !== null && 'module' in object;
|
|
682
|
-
}
|
|
683
|
-
var PLACEHOLDER_COMPONENTS = new core.InjectionToken('Sc.placeholder.components');
|
|
684
|
-
var PLACEHOLDER_LAZY_COMPONENTS = new core.InjectionToken('Sc.placeholder.lazyComponents');
|
|
685
|
-
var PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new core.InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
665
|
+
/** Registers a statically loaded component */
|
|
666
|
+
var ComponentNameAndType = /** @class */ (function () {
|
|
667
|
+
function ComponentNameAndType() {
|
|
668
|
+
}
|
|
669
|
+
return ComponentNameAndType;
|
|
670
|
+
}());
|
|
671
|
+
/**
|
|
672
|
+
* @param {unknown} object
|
|
673
|
+
*/
|
|
674
|
+
function instanceOfComponentNameAndType(object) {
|
|
675
|
+
return typeof object === 'object' && object !== null && 'type' in object;
|
|
676
|
+
}
|
|
677
|
+
/**
|
|
678
|
+
* @param {unknown} object
|
|
679
|
+
*/
|
|
680
|
+
function instanceOfComponentNameAndModule(object) {
|
|
681
|
+
return typeof object === 'object' && object !== null && 'module' in object;
|
|
682
|
+
}
|
|
683
|
+
var PLACEHOLDER_COMPONENTS = new core.InjectionToken('Sc.placeholder.components');
|
|
684
|
+
var PLACEHOLDER_LAZY_COMPONENTS = new core.InjectionToken('Sc.placeholder.lazyComponents');
|
|
685
|
+
var PLACEHOLDER_MISSING_COMPONENT_COMPONENT = new core.InjectionToken('Sc.placeholder.missingComponentComponent');
|
|
686
686
|
var DYNAMIC_COMPONENT = new core.InjectionToken('Sc.placeholder.dynamicComponent');
|
|
687
687
|
|
|
688
|
-
var RawComponent = /** @class */ (function () {
|
|
689
|
-
function RawComponent(renderer, elementRef) {
|
|
690
|
-
this.renderer = renderer;
|
|
691
|
-
this.elementRef = elementRef;
|
|
692
|
-
}
|
|
693
|
-
RawComponent.prototype.ngOnInit = function () {
|
|
694
|
-
var el = this.renderer.createElement(this.rendering.name);
|
|
695
|
-
var contents = this.renderer.createText(this.rendering.contents || '');
|
|
696
|
-
var attributes = this.rendering.attributes;
|
|
697
|
-
for (var attr in attributes) {
|
|
698
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
699
|
-
if (attributes.hasOwnProperty(attr)) {
|
|
700
|
-
var value = attributes[attr];
|
|
701
|
-
this.renderer.setAttribute(el, attr, value || '');
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
this.renderer.appendChild(el, contents);
|
|
705
|
-
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
706
|
-
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
707
|
-
parentNode.removeChild(this.elementRef.nativeElement);
|
|
708
|
-
};
|
|
709
|
-
return RawComponent;
|
|
710
|
-
}());
|
|
711
|
-
RawComponent.decorators = [
|
|
712
|
-
{ type: core.Component, args: [{
|
|
713
|
-
selector: 'sc-raw',
|
|
714
|
-
template: ''
|
|
715
|
-
},] }
|
|
716
|
-
];
|
|
717
|
-
RawComponent.ctorParameters = function () { return [
|
|
718
|
-
{ type: core.Renderer2 },
|
|
719
|
-
{ type: core.ElementRef }
|
|
720
|
-
]; };
|
|
721
|
-
RawComponent.propDecorators = {
|
|
722
|
-
rendering: [{ type: core.Input }]
|
|
688
|
+
var RawComponent = /** @class */ (function () {
|
|
689
|
+
function RawComponent(renderer, elementRef) {
|
|
690
|
+
this.renderer = renderer;
|
|
691
|
+
this.elementRef = elementRef;
|
|
692
|
+
}
|
|
693
|
+
RawComponent.prototype.ngOnInit = function () {
|
|
694
|
+
var el = this.renderer.createElement(this.rendering.name);
|
|
695
|
+
var contents = this.renderer.createText(this.rendering.contents || '');
|
|
696
|
+
var attributes = this.rendering.attributes;
|
|
697
|
+
for (var attr in attributes) {
|
|
698
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
699
|
+
if (attributes.hasOwnProperty(attr)) {
|
|
700
|
+
var value = attributes[attr];
|
|
701
|
+
this.renderer.setAttribute(el, attr, value || '');
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
this.renderer.appendChild(el, contents);
|
|
705
|
+
var parentNode = this.renderer.parentNode(this.elementRef.nativeElement);
|
|
706
|
+
this.renderer.insertBefore(parentNode, el, this.elementRef.nativeElement);
|
|
707
|
+
parentNode.removeChild(this.elementRef.nativeElement);
|
|
708
|
+
};
|
|
709
|
+
return RawComponent;
|
|
710
|
+
}());
|
|
711
|
+
RawComponent.decorators = [
|
|
712
|
+
{ type: core.Component, args: [{
|
|
713
|
+
selector: 'sc-raw',
|
|
714
|
+
template: ''
|
|
715
|
+
},] }
|
|
716
|
+
];
|
|
717
|
+
RawComponent.ctorParameters = function () { return [
|
|
718
|
+
{ type: core.Renderer2 },
|
|
719
|
+
{ type: core.ElementRef }
|
|
720
|
+
]; };
|
|
721
|
+
RawComponent.propDecorators = {
|
|
722
|
+
rendering: [{ type: core.Input }]
|
|
723
723
|
};
|
|
724
724
|
|
|
725
|
-
/**
|
|
726
|
-
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
727
|
-
*/
|
|
728
|
-
function isRawRendering(rendering) {
|
|
729
|
-
return (!rendering.componentName &&
|
|
730
|
-
rendering.name !== undefined);
|
|
725
|
+
/**
|
|
726
|
+
* @param {HtmlElementRendering | ComponentRendering} rendering
|
|
727
|
+
*/
|
|
728
|
+
function isRawRendering(rendering) {
|
|
729
|
+
return (!rendering.componentName &&
|
|
730
|
+
rendering.name !== undefined);
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
var JssComponentFactoryService = /** @class */ (function () {
|
|
734
|
-
function JssComponentFactoryService(injector, compiler, components, lazyComponents) {
|
|
735
|
-
var _this = this;
|
|
736
|
-
this.injector = injector;
|
|
737
|
-
this.compiler = compiler;
|
|
738
|
-
this.components = components;
|
|
739
|
-
this.lazyComponents = lazyComponents;
|
|
740
|
-
this.componentMap = new Map();
|
|
741
|
-
this.lazyComponentMap = new Map();
|
|
742
|
-
this.components.forEach(function (c) { return _this.componentMap.set(c.name, c.type); });
|
|
743
|
-
if (this.lazyComponents) {
|
|
744
|
-
this.lazyComponents.forEach(function (c) { return _this.lazyComponentMap.set(c.path, c); });
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
JssComponentFactoryService.prototype.loadModuleFactory = function (lazyComponent) {
|
|
748
|
-
var _this = this;
|
|
749
|
-
return lazyComponent.loadChildren().then(function (loaded) {
|
|
750
|
-
if (loaded instanceof core.NgModuleFactory) {
|
|
751
|
-
return loaded;
|
|
752
|
-
}
|
|
753
|
-
else {
|
|
754
|
-
return _this.compiler.compileModuleAsync(loaded);
|
|
755
|
-
}
|
|
756
|
-
});
|
|
757
|
-
};
|
|
758
|
-
JssComponentFactoryService.prototype.getComponent = function (component) {
|
|
759
|
-
var _this = this;
|
|
760
|
-
var loadedComponent = this.componentMap.get(component.componentName);
|
|
761
|
-
if (loadedComponent) {
|
|
762
|
-
return Promise.resolve({
|
|
763
|
-
componentDefinition: component,
|
|
764
|
-
componentImplementation: this.componentMap.get(component.componentName),
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
var lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
768
|
-
if (lazyComponent) {
|
|
769
|
-
return this.loadModuleFactory(lazyComponent).then(function (ngModuleFactory) {
|
|
770
|
-
var componentType = null;
|
|
771
|
-
var moduleRef = ngModuleFactory.create(_this.injector);
|
|
772
|
-
var dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
773
|
-
if (!dynamicComponentType) {
|
|
774
|
-
throw new Error("JssComponentFactoryService: Lazy load module for component \"" + lazyComponent.path + "\" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?");
|
|
775
|
-
}
|
|
776
|
-
if (component.componentName in dynamicComponentType) {
|
|
777
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
|
-
componentType = dynamicComponentType[component.componentName];
|
|
779
|
-
}
|
|
780
|
-
else {
|
|
781
|
-
if (typeof dynamicComponentType === 'function') {
|
|
782
|
-
componentType = dynamicComponentType;
|
|
783
|
-
}
|
|
784
|
-
else {
|
|
785
|
-
throw new Error("JssComponentFactoryService: Lazy load module for component \"" + lazyComponent.path + "\" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?");
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
return {
|
|
789
|
-
componentDefinition: component,
|
|
790
|
-
componentImplementation: componentType,
|
|
791
|
-
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
792
|
-
};
|
|
793
|
-
});
|
|
794
|
-
}
|
|
795
|
-
return Promise.resolve({
|
|
796
|
-
componentDefinition: component,
|
|
797
|
-
});
|
|
798
|
-
};
|
|
799
|
-
JssComponentFactoryService.prototype.getComponents = function (components) {
|
|
800
|
-
var _this = this;
|
|
801
|
-
// acquire all components and keep them in order while handling their potential async-ness
|
|
802
|
-
return Promise.all(components.map(function (component) { return isRawRendering(component) ? _this.getRawComponent(component) : _this.getComponent(component); }));
|
|
803
|
-
};
|
|
804
|
-
JssComponentFactoryService.prototype.getRawComponent = function (component) {
|
|
805
|
-
return Promise.resolve({
|
|
806
|
-
componentImplementation: RawComponent,
|
|
807
|
-
componentDefinition: component,
|
|
808
|
-
});
|
|
809
|
-
};
|
|
810
|
-
return JssComponentFactoryService;
|
|
811
|
-
}());
|
|
812
|
-
JssComponentFactoryService.decorators = [
|
|
813
|
-
{ type: core.Injectable }
|
|
814
|
-
];
|
|
815
|
-
JssComponentFactoryService.ctorParameters = function () { return [
|
|
816
|
-
{ type: core.Injector },
|
|
817
|
-
{ type: core.Compiler },
|
|
818
|
-
{ type: Array, decorators: [{ type: core.Inject, args: [PLACEHOLDER_COMPONENTS,] }] },
|
|
819
|
-
{ type: Array, decorators: [{ type: core.Inject, args: [PLACEHOLDER_LAZY_COMPONENTS,] }] }
|
|
733
|
+
var JssComponentFactoryService = /** @class */ (function () {
|
|
734
|
+
function JssComponentFactoryService(injector, compiler, components, lazyComponents) {
|
|
735
|
+
var _this = this;
|
|
736
|
+
this.injector = injector;
|
|
737
|
+
this.compiler = compiler;
|
|
738
|
+
this.components = components;
|
|
739
|
+
this.lazyComponents = lazyComponents;
|
|
740
|
+
this.componentMap = new Map();
|
|
741
|
+
this.lazyComponentMap = new Map();
|
|
742
|
+
this.components.forEach(function (c) { return _this.componentMap.set(c.name, c.type); });
|
|
743
|
+
if (this.lazyComponents) {
|
|
744
|
+
this.lazyComponents.forEach(function (c) { return _this.lazyComponentMap.set(c.path, c); });
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
JssComponentFactoryService.prototype.loadModuleFactory = function (lazyComponent) {
|
|
748
|
+
var _this = this;
|
|
749
|
+
return lazyComponent.loadChildren().then(function (loaded) {
|
|
750
|
+
if (loaded instanceof core.NgModuleFactory) {
|
|
751
|
+
return loaded;
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
return _this.compiler.compileModuleAsync(loaded);
|
|
755
|
+
}
|
|
756
|
+
});
|
|
757
|
+
};
|
|
758
|
+
JssComponentFactoryService.prototype.getComponent = function (component) {
|
|
759
|
+
var _this = this;
|
|
760
|
+
var loadedComponent = this.componentMap.get(component.componentName);
|
|
761
|
+
if (loadedComponent) {
|
|
762
|
+
return Promise.resolve({
|
|
763
|
+
componentDefinition: component,
|
|
764
|
+
componentImplementation: this.componentMap.get(component.componentName),
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
var lazyComponent = this.lazyComponentMap.get(component.componentName);
|
|
768
|
+
if (lazyComponent) {
|
|
769
|
+
return this.loadModuleFactory(lazyComponent).then(function (ngModuleFactory) {
|
|
770
|
+
var componentType = null;
|
|
771
|
+
var moduleRef = ngModuleFactory.create(_this.injector);
|
|
772
|
+
var dynamicComponentType = moduleRef.injector.get(DYNAMIC_COMPONENT);
|
|
773
|
+
if (!dynamicComponentType) {
|
|
774
|
+
throw new Error("JssComponentFactoryService: Lazy load module for component \"" + lazyComponent.path + "\" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?");
|
|
775
|
+
}
|
|
776
|
+
if (component.componentName in dynamicComponentType) {
|
|
777
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
778
|
+
componentType = dynamicComponentType[component.componentName];
|
|
779
|
+
}
|
|
780
|
+
else {
|
|
781
|
+
if (typeof dynamicComponentType === 'function') {
|
|
782
|
+
componentType = dynamicComponentType;
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
throw new Error("JssComponentFactoryService: Lazy load module for component \"" + lazyComponent.path + "\" missing DYNAMIC_COMPONENT provider. Missing JssModule.forChild()?");
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return {
|
|
789
|
+
componentDefinition: component,
|
|
790
|
+
componentImplementation: componentType,
|
|
791
|
+
componentFactory: moduleRef.componentFactoryResolver.resolveComponentFactory(componentType),
|
|
792
|
+
};
|
|
793
|
+
});
|
|
794
|
+
}
|
|
795
|
+
return Promise.resolve({
|
|
796
|
+
componentDefinition: component,
|
|
797
|
+
});
|
|
798
|
+
};
|
|
799
|
+
JssComponentFactoryService.prototype.getComponents = function (components) {
|
|
800
|
+
var _this = this;
|
|
801
|
+
// acquire all components and keep them in order while handling their potential async-ness
|
|
802
|
+
return Promise.all(components.map(function (component) { return isRawRendering(component) ? _this.getRawComponent(component) : _this.getComponent(component); }));
|
|
803
|
+
};
|
|
804
|
+
JssComponentFactoryService.prototype.getRawComponent = function (component) {
|
|
805
|
+
return Promise.resolve({
|
|
806
|
+
componentImplementation: RawComponent,
|
|
807
|
+
componentDefinition: component,
|
|
808
|
+
});
|
|
809
|
+
};
|
|
810
|
+
return JssComponentFactoryService;
|
|
811
|
+
}());
|
|
812
|
+
JssComponentFactoryService.decorators = [
|
|
813
|
+
{ type: core.Injectable }
|
|
814
|
+
];
|
|
815
|
+
JssComponentFactoryService.ctorParameters = function () { return [
|
|
816
|
+
{ type: core.Injector },
|
|
817
|
+
{ type: core.Compiler },
|
|
818
|
+
{ type: Array, decorators: [{ type: core.Inject, args: [PLACEHOLDER_COMPONENTS,] }] },
|
|
819
|
+
{ type: Array, decorators: [{ type: core.Inject, args: [PLACEHOLDER_LAZY_COMPONENTS,] }] }
|
|
820
820
|
]; };
|
|
821
821
|
|
|
822
|
-
var PlaceholderLoadingDirective = /** @class */ (function () {
|
|
823
|
-
function PlaceholderLoadingDirective(templateRef) {
|
|
824
|
-
this.templateRef = templateRef;
|
|
825
|
-
}
|
|
826
|
-
return PlaceholderLoadingDirective;
|
|
827
|
-
}());
|
|
828
|
-
PlaceholderLoadingDirective.decorators = [
|
|
829
|
-
{ type: core.Directive, args: [{
|
|
830
|
-
selector: '[scPlaceholderLoading]',
|
|
831
|
-
},] }
|
|
832
|
-
];
|
|
833
|
-
PlaceholderLoadingDirective.ctorParameters = function () { return [
|
|
834
|
-
{ type: core.TemplateRef }
|
|
822
|
+
var PlaceholderLoadingDirective = /** @class */ (function () {
|
|
823
|
+
function PlaceholderLoadingDirective(templateRef) {
|
|
824
|
+
this.templateRef = templateRef;
|
|
825
|
+
}
|
|
826
|
+
return PlaceholderLoadingDirective;
|
|
827
|
+
}());
|
|
828
|
+
PlaceholderLoadingDirective.decorators = [
|
|
829
|
+
{ type: core.Directive, args: [{
|
|
830
|
+
selector: '[scPlaceholderLoading]',
|
|
831
|
+
},] }
|
|
832
|
+
];
|
|
833
|
+
PlaceholderLoadingDirective.ctorParameters = function () { return [
|
|
834
|
+
{ type: core.TemplateRef }
|
|
835
835
|
]; };
|
|
836
836
|
|
|
837
|
-
var RenderEachDirective = /** @class */ (function () {
|
|
838
|
-
function RenderEachDirective(templateRef) {
|
|
839
|
-
this.templateRef = templateRef;
|
|
840
|
-
}
|
|
841
|
-
return RenderEachDirective;
|
|
842
|
-
}());
|
|
843
|
-
RenderEachDirective.decorators = [
|
|
844
|
-
{ type: core.Directive, args: [{
|
|
845
|
-
selector: '[renderEach]',
|
|
846
|
-
},] }
|
|
847
|
-
];
|
|
848
|
-
RenderEachDirective.ctorParameters = function () { return [
|
|
849
|
-
{ type: core.TemplateRef }
|
|
837
|
+
var RenderEachDirective = /** @class */ (function () {
|
|
838
|
+
function RenderEachDirective(templateRef) {
|
|
839
|
+
this.templateRef = templateRef;
|
|
840
|
+
}
|
|
841
|
+
return RenderEachDirective;
|
|
842
|
+
}());
|
|
843
|
+
RenderEachDirective.decorators = [
|
|
844
|
+
{ type: core.Directive, args: [{
|
|
845
|
+
selector: '[renderEach]',
|
|
846
|
+
},] }
|
|
847
|
+
];
|
|
848
|
+
RenderEachDirective.ctorParameters = function () { return [
|
|
849
|
+
{ type: core.TemplateRef }
|
|
850
850
|
]; };
|
|
851
851
|
|
|
852
|
-
var RenderEmptyDirective = /** @class */ (function () {
|
|
853
|
-
function RenderEmptyDirective(templateRef) {
|
|
854
|
-
this.templateRef = templateRef;
|
|
855
|
-
}
|
|
856
|
-
return RenderEmptyDirective;
|
|
857
|
-
}());
|
|
858
|
-
RenderEmptyDirective.decorators = [
|
|
859
|
-
{ type: core.Directive, args: [{
|
|
860
|
-
selector: '[renderEmpty]',
|
|
861
|
-
},] }
|
|
862
|
-
];
|
|
863
|
-
RenderEmptyDirective.ctorParameters = function () { return [
|
|
864
|
-
{ type: core.TemplateRef }
|
|
852
|
+
var RenderEmptyDirective = /** @class */ (function () {
|
|
853
|
+
function RenderEmptyDirective(templateRef) {
|
|
854
|
+
this.templateRef = templateRef;
|
|
855
|
+
}
|
|
856
|
+
return RenderEmptyDirective;
|
|
857
|
+
}());
|
|
858
|
+
RenderEmptyDirective.decorators = [
|
|
859
|
+
{ type: core.Directive, args: [{
|
|
860
|
+
selector: '[renderEmpty]',
|
|
861
|
+
},] }
|
|
862
|
+
];
|
|
863
|
+
RenderEmptyDirective.ctorParameters = function () { return [
|
|
864
|
+
{ type: core.TemplateRef }
|
|
865
865
|
]; };
|
|
866
866
|
|
|
867
|
-
/**
|
|
868
|
-
* @param {ComponentRendering} rendering
|
|
869
|
-
* @param {string} name
|
|
870
|
-
*/
|
|
871
|
-
function getPlaceholder(rendering, name) {
|
|
872
|
-
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
873
|
-
return rendering.placeholders[name];
|
|
874
|
-
}
|
|
875
|
-
return null;
|
|
876
|
-
}
|
|
877
|
-
var PlaceholderComponent = /** @class */ (function () {
|
|
878
|
-
function PlaceholderComponent(componentFactoryResolver, differs, componentFactory, changeDetectorRef, elementRef, renderer, missingComponentComponent) {
|
|
879
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
880
|
-
this.differs = differs;
|
|
881
|
-
this.componentFactory = componentFactory;
|
|
882
|
-
this.changeDetectorRef = changeDetectorRef;
|
|
883
|
-
this.elementRef = elementRef;
|
|
884
|
-
this.renderer = renderer;
|
|
885
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
886
|
-
this._componentInstances = [];
|
|
887
|
-
this.destroyed = false;
|
|
888
|
-
this.parentStyleAttribute = '';
|
|
889
|
-
this.isLoading = true;
|
|
890
|
-
this.loaded = new core.EventEmitter();
|
|
891
|
-
}
|
|
892
|
-
Object.defineProperty(PlaceholderComponent.prototype, "inputs", {
|
|
893
|
-
set: function (value) {
|
|
894
|
-
this._inputs = value;
|
|
895
|
-
if (!this._differ && value) {
|
|
896
|
-
this._differ = this.differs.find(value).create();
|
|
897
|
-
}
|
|
898
|
-
},
|
|
899
|
-
enumerable: false,
|
|
900
|
-
configurable: true
|
|
901
|
-
});
|
|
902
|
-
PlaceholderComponent.prototype.ngOnInit = function () {
|
|
903
|
-
// just to ensure the element exists
|
|
904
|
-
var elem = this.elementRef.nativeElement;
|
|
905
|
-
if (elem) {
|
|
906
|
-
var attributes = elem.attributes;
|
|
907
|
-
for (var i = 0; i < attributes.length; i++) {
|
|
908
|
-
var attr = attributes.item(i);
|
|
909
|
-
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
910
|
-
this.parentStyleAttribute = attr.name;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
PlaceholderComponent.prototype.ngOnDestroy = function () {
|
|
916
|
-
this.destroyed = true;
|
|
917
|
-
this._componentInstances = [];
|
|
918
|
-
};
|
|
919
|
-
PlaceholderComponent.prototype.ngOnChanges = function (changes) {
|
|
920
|
-
if (changes.rendering || changes.renderings) {
|
|
921
|
-
this._render();
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
PlaceholderComponent.prototype.ngDoCheck = function () {
|
|
925
|
-
var _this = this;
|
|
926
|
-
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
927
|
-
return;
|
|
928
|
-
}
|
|
929
|
-
var changes = this._differ.diff(this._inputs);
|
|
930
|
-
if (!changes) {
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
var updates = {};
|
|
934
|
-
changes.forEachRemovedItem(function (change) { return (updates[change.key] = null); });
|
|
935
|
-
changes.forEachAddedItem(function (change) { return (updates[change.key] = change.currentValue); });
|
|
936
|
-
changes.forEachChangedItem(function (change) { return (updates[change.key] = change.currentValue); });
|
|
937
|
-
this._componentInstances.forEach(function (componentInstance) { return _this._setComponentInputs(componentInstance, updates); });
|
|
938
|
-
};
|
|
939
|
-
PlaceholderComponent.prototype._setComponentInputs = function (componentInstance, inputs) {
|
|
940
|
-
Object.entries(inputs).forEach(function (_a) {
|
|
941
|
-
var _b = __read(_a, 2), input = _b[0], inputValue = _b[1];
|
|
942
|
-
return (componentInstance[input] = inputValue);
|
|
943
|
-
});
|
|
944
|
-
};
|
|
945
|
-
PlaceholderComponent.prototype._subscribeComponentOutputs = function (componentInstance, outputs) {
|
|
946
|
-
var _this = this;
|
|
947
|
-
Object.keys(outputs)
|
|
948
|
-
.filter(function (output) { return componentInstance[output] && componentInstance[output] instanceof rxjs.Observable; })
|
|
949
|
-
.forEach(function (output) { return componentInstance[output]
|
|
950
|
-
.pipe(operators.takeWhile(function () { return !_this.destroyed; }))
|
|
951
|
-
.subscribe(outputs[output]); });
|
|
952
|
-
};
|
|
953
|
-
PlaceholderComponent.prototype._render = function () {
|
|
954
|
-
var _this = this;
|
|
955
|
-
this._componentInstances = [];
|
|
956
|
-
this.view.clear();
|
|
957
|
-
if (!this.rendering && !this.renderings) {
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
if (!this.name && !this.renderings) {
|
|
961
|
-
console.warn('Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.');
|
|
962
|
-
this.isLoading = false;
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
var placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
966
|
-
if (!placeholder) {
|
|
967
|
-
console.warn("Placeholder '" + this.name + "' was not found in the current rendering data", JSON.stringify(this.rendering, null, 2));
|
|
968
|
-
this.isLoading = false;
|
|
969
|
-
return;
|
|
970
|
-
}
|
|
971
|
-
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
972
|
-
var placeholderIsEmpty = placeholder.every(function (rendering) { return isRawRendering(rendering); });
|
|
973
|
-
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
974
|
-
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
975
|
-
renderings: placeholder,
|
|
976
|
-
});
|
|
977
|
-
this.isLoading = false;
|
|
978
|
-
}
|
|
979
|
-
else {
|
|
980
|
-
this.componentFactory
|
|
981
|
-
.getComponents(placeholder)
|
|
982
|
-
.then(function (components) { return components.forEach(function (rendering, index) {
|
|
983
|
-
if (_this.renderEachTemplate && !isRawRendering(rendering.componentDefinition)) {
|
|
984
|
-
_this._renderTemplatedComponent(rendering.componentDefinition, index);
|
|
985
|
-
}
|
|
986
|
-
else {
|
|
987
|
-
_this._renderEmbeddedComponent(rendering, index);
|
|
988
|
-
}
|
|
989
|
-
_this.isLoading = false;
|
|
990
|
-
}); })
|
|
991
|
-
.then(function () {
|
|
992
|
-
_this.changeDetectorRef.markForCheck();
|
|
993
|
-
_this.loaded.emit(_this.name);
|
|
994
|
-
});
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
PlaceholderComponent.prototype._renderTemplatedComponent = function (rendering, index) {
|
|
998
|
-
// the render-each template takes care of all component mapping etc
|
|
999
|
-
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
1000
|
-
// as a separate component
|
|
1001
|
-
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
1002
|
-
rendering: rendering,
|
|
1003
|
-
index: index,
|
|
1004
|
-
});
|
|
1005
|
-
};
|
|
1006
|
-
PlaceholderComponent.prototype._renderEmbeddedComponent = function (rendering, index) {
|
|
1007
|
-
if (!rendering.componentImplementation) {
|
|
1008
|
-
var componentName = rendering.componentDefinition.componentName;
|
|
1009
|
-
console.error("Placeholder " + this.name + " contains unknown component " + componentName + ".", "Ensure component is mapped, like:\n JssModule.withComponents([\n { name: '" + componentName + "', type: " + componentName + "Component }\n ])");
|
|
1010
|
-
rendering.componentImplementation = this.missingComponentComponent;
|
|
1011
|
-
}
|
|
1012
|
-
var componentFactory = rendering.componentFactory ||
|
|
1013
|
-
this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1014
|
-
// apply the parent style attribute _ngcontent
|
|
1015
|
-
// work-around for https://github.com/angular/angular/issues/12215
|
|
1016
|
-
var createdComponentRef = this.view.createComponent(componentFactory, index);
|
|
1017
|
-
if (this.parentStyleAttribute) {
|
|
1018
|
-
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
1019
|
-
}
|
|
1020
|
-
var componentInstance = createdComponentRef.instance;
|
|
1021
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
1022
|
-
if (this._inputs) {
|
|
1023
|
-
this._setComponentInputs(componentInstance, this._inputs);
|
|
1024
|
-
}
|
|
1025
|
-
if (this.outputs) {
|
|
1026
|
-
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
1027
|
-
}
|
|
1028
|
-
this._componentInstances.push(componentInstance);
|
|
1029
|
-
};
|
|
1030
|
-
return PlaceholderComponent;
|
|
1031
|
-
}());
|
|
1032
|
-
PlaceholderComponent.decorators = [
|
|
1033
|
-
{ type: core.Component, args: [{
|
|
1034
|
-
selector: 'sc-placeholder,[sc-placeholder]',
|
|
1035
|
-
template: "\n <ng-template\n *ngIf=\"isLoading\"\n [ngTemplateOutlet]=\"placeholderLoading?.templateRef\"\n ></ng-template>\n <ng-template #view></ng-template>\n "
|
|
1036
|
-
},] }
|
|
1037
|
-
];
|
|
1038
|
-
PlaceholderComponent.ctorParameters = function () { return [
|
|
1039
|
-
{ type: core.ComponentFactoryResolver },
|
|
1040
|
-
{ type: core.KeyValueDiffers },
|
|
1041
|
-
{ type: JssComponentFactoryService },
|
|
1042
|
-
{ type: core.ChangeDetectorRef },
|
|
1043
|
-
{ type: core.ElementRef },
|
|
1044
|
-
{ type: core.Renderer2 },
|
|
1045
|
-
{ type: core.Type, decorators: [{ type: core.Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1046
|
-
]; };
|
|
1047
|
-
PlaceholderComponent.propDecorators = {
|
|
1048
|
-
name: [{ type: core.Input }],
|
|
1049
|
-
rendering: [{ type: core.Input }],
|
|
1050
|
-
renderings: [{ type: core.Input }],
|
|
1051
|
-
outputs: [{ type: core.Input }],
|
|
1052
|
-
loaded: [{ type: core.Output }],
|
|
1053
|
-
view: [{ type: core.ViewChild, args: ['view', { read: core.ViewContainerRef, static: true },] }],
|
|
1054
|
-
renderEachTemplate: [{ type: core.ContentChild, args: [RenderEachDirective, { static: true },] }],
|
|
1055
|
-
renderEmptyTemplate: [{ type: core.ContentChild, args: [RenderEmptyDirective, { static: true },] }],
|
|
1056
|
-
placeholderLoading: [{ type: core.ContentChild, args: [PlaceholderLoadingDirective, { static: true },] }],
|
|
1057
|
-
inputs: [{ type: core.Input }]
|
|
867
|
+
/**
|
|
868
|
+
* @param {ComponentRendering} rendering
|
|
869
|
+
* @param {string} name
|
|
870
|
+
*/
|
|
871
|
+
function getPlaceholder(rendering, name) {
|
|
872
|
+
if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {
|
|
873
|
+
return rendering.placeholders[name];
|
|
874
|
+
}
|
|
875
|
+
return null;
|
|
876
|
+
}
|
|
877
|
+
var PlaceholderComponent = /** @class */ (function () {
|
|
878
|
+
function PlaceholderComponent(componentFactoryResolver, differs, componentFactory, changeDetectorRef, elementRef, renderer, missingComponentComponent) {
|
|
879
|
+
this.componentFactoryResolver = componentFactoryResolver;
|
|
880
|
+
this.differs = differs;
|
|
881
|
+
this.componentFactory = componentFactory;
|
|
882
|
+
this.changeDetectorRef = changeDetectorRef;
|
|
883
|
+
this.elementRef = elementRef;
|
|
884
|
+
this.renderer = renderer;
|
|
885
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
886
|
+
this._componentInstances = [];
|
|
887
|
+
this.destroyed = false;
|
|
888
|
+
this.parentStyleAttribute = '';
|
|
889
|
+
this.isLoading = true;
|
|
890
|
+
this.loaded = new core.EventEmitter();
|
|
891
|
+
}
|
|
892
|
+
Object.defineProperty(PlaceholderComponent.prototype, "inputs", {
|
|
893
|
+
set: function (value) {
|
|
894
|
+
this._inputs = value;
|
|
895
|
+
if (!this._differ && value) {
|
|
896
|
+
this._differ = this.differs.find(value).create();
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
enumerable: false,
|
|
900
|
+
configurable: true
|
|
901
|
+
});
|
|
902
|
+
PlaceholderComponent.prototype.ngOnInit = function () {
|
|
903
|
+
// just to ensure the element exists
|
|
904
|
+
var elem = this.elementRef.nativeElement;
|
|
905
|
+
if (elem) {
|
|
906
|
+
var attributes = elem.attributes;
|
|
907
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
908
|
+
var attr = attributes.item(i);
|
|
909
|
+
if (attr && attr.name.indexOf('_ngcontent') !== -1) {
|
|
910
|
+
this.parentStyleAttribute = attr.name;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
PlaceholderComponent.prototype.ngOnDestroy = function () {
|
|
916
|
+
this.destroyed = true;
|
|
917
|
+
this._componentInstances = [];
|
|
918
|
+
};
|
|
919
|
+
PlaceholderComponent.prototype.ngOnChanges = function (changes) {
|
|
920
|
+
if (changes.rendering || changes.renderings) {
|
|
921
|
+
this._render();
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
PlaceholderComponent.prototype.ngDoCheck = function () {
|
|
925
|
+
var _this = this;
|
|
926
|
+
if (!this._differ || !this._inputs || this._componentInstances.length === 0) {
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
var changes = this._differ.diff(this._inputs);
|
|
930
|
+
if (!changes) {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
var updates = {};
|
|
934
|
+
changes.forEachRemovedItem(function (change) { return (updates[change.key] = null); });
|
|
935
|
+
changes.forEachAddedItem(function (change) { return (updates[change.key] = change.currentValue); });
|
|
936
|
+
changes.forEachChangedItem(function (change) { return (updates[change.key] = change.currentValue); });
|
|
937
|
+
this._componentInstances.forEach(function (componentInstance) { return _this._setComponentInputs(componentInstance, updates); });
|
|
938
|
+
};
|
|
939
|
+
PlaceholderComponent.prototype._setComponentInputs = function (componentInstance, inputs) {
|
|
940
|
+
Object.entries(inputs).forEach(function (_a) {
|
|
941
|
+
var _b = __read(_a, 2), input = _b[0], inputValue = _b[1];
|
|
942
|
+
return (componentInstance[input] = inputValue);
|
|
943
|
+
});
|
|
944
|
+
};
|
|
945
|
+
PlaceholderComponent.prototype._subscribeComponentOutputs = function (componentInstance, outputs) {
|
|
946
|
+
var _this = this;
|
|
947
|
+
Object.keys(outputs)
|
|
948
|
+
.filter(function (output) { return componentInstance[output] && componentInstance[output] instanceof rxjs.Observable; })
|
|
949
|
+
.forEach(function (output) { return componentInstance[output]
|
|
950
|
+
.pipe(operators.takeWhile(function () { return !_this.destroyed; }))
|
|
951
|
+
.subscribe(outputs[output]); });
|
|
952
|
+
};
|
|
953
|
+
PlaceholderComponent.prototype._render = function () {
|
|
954
|
+
var _this = this;
|
|
955
|
+
this._componentInstances = [];
|
|
956
|
+
this.view.clear();
|
|
957
|
+
if (!this.rendering && !this.renderings) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (!this.name && !this.renderings) {
|
|
961
|
+
console.warn('Placeholder name was not specified, and explicit renderings array was not passed. Placeholder requires either name and rendering, or renderings.');
|
|
962
|
+
this.isLoading = false;
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
var placeholder = this.renderings || getPlaceholder(this.rendering, this.name || '');
|
|
966
|
+
if (!placeholder) {
|
|
967
|
+
console.warn("Placeholder '" + this.name + "' was not found in the current rendering data", JSON.stringify(this.rendering, null, 2));
|
|
968
|
+
this.isLoading = false;
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
// if the placeholder is empty (contains only raw renderings), then we may need to use the empty template if it's defined
|
|
972
|
+
var placeholderIsEmpty = placeholder.every(function (rendering) { return isRawRendering(rendering); });
|
|
973
|
+
if (this.renderEmptyTemplate && placeholderIsEmpty) {
|
|
974
|
+
this.view.createEmbeddedView(this.renderEmptyTemplate.templateRef, {
|
|
975
|
+
renderings: placeholder,
|
|
976
|
+
});
|
|
977
|
+
this.isLoading = false;
|
|
978
|
+
}
|
|
979
|
+
else {
|
|
980
|
+
this.componentFactory
|
|
981
|
+
.getComponents(placeholder)
|
|
982
|
+
.then(function (components) { return components.forEach(function (rendering, index) {
|
|
983
|
+
if (_this.renderEachTemplate && !isRawRendering(rendering.componentDefinition)) {
|
|
984
|
+
_this._renderTemplatedComponent(rendering.componentDefinition, index);
|
|
985
|
+
}
|
|
986
|
+
else {
|
|
987
|
+
_this._renderEmbeddedComponent(rendering, index);
|
|
988
|
+
}
|
|
989
|
+
_this.isLoading = false;
|
|
990
|
+
}); })
|
|
991
|
+
.then(function () {
|
|
992
|
+
_this.changeDetectorRef.markForCheck();
|
|
993
|
+
_this.loaded.emit(_this.name);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
PlaceholderComponent.prototype._renderTemplatedComponent = function (rendering, index) {
|
|
998
|
+
// the render-each template takes care of all component mapping etc
|
|
999
|
+
// generally using <sc-render-component> which is about like _renderEmbeddedComponent()
|
|
1000
|
+
// as a separate component
|
|
1001
|
+
this.view.createEmbeddedView(this.renderEachTemplate.templateRef, {
|
|
1002
|
+
rendering: rendering,
|
|
1003
|
+
index: index,
|
|
1004
|
+
});
|
|
1005
|
+
};
|
|
1006
|
+
PlaceholderComponent.prototype._renderEmbeddedComponent = function (rendering, index) {
|
|
1007
|
+
if (!rendering.componentImplementation) {
|
|
1008
|
+
var componentName = rendering.componentDefinition.componentName;
|
|
1009
|
+
console.error("Placeholder " + this.name + " contains unknown component " + componentName + ".", "Ensure component is mapped, like:\n JssModule.withComponents([\n { name: '" + componentName + "', type: " + componentName + "Component }\n ])");
|
|
1010
|
+
rendering.componentImplementation = this.missingComponentComponent;
|
|
1011
|
+
}
|
|
1012
|
+
var componentFactory = rendering.componentFactory ||
|
|
1013
|
+
this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1014
|
+
// apply the parent style attribute _ngcontent
|
|
1015
|
+
// work-around for https://github.com/angular/angular/issues/12215
|
|
1016
|
+
var createdComponentRef = this.view.createComponent(componentFactory, index);
|
|
1017
|
+
if (this.parentStyleAttribute) {
|
|
1018
|
+
this.renderer.setAttribute(createdComponentRef.location.nativeElement, this.parentStyleAttribute, '');
|
|
1019
|
+
}
|
|
1020
|
+
var componentInstance = createdComponentRef.instance;
|
|
1021
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
1022
|
+
if (this._inputs) {
|
|
1023
|
+
this._setComponentInputs(componentInstance, this._inputs);
|
|
1024
|
+
}
|
|
1025
|
+
if (this.outputs) {
|
|
1026
|
+
this._subscribeComponentOutputs(componentInstance, this.outputs);
|
|
1027
|
+
}
|
|
1028
|
+
this._componentInstances.push(componentInstance);
|
|
1029
|
+
};
|
|
1030
|
+
return PlaceholderComponent;
|
|
1031
|
+
}());
|
|
1032
|
+
PlaceholderComponent.decorators = [
|
|
1033
|
+
{ type: core.Component, args: [{
|
|
1034
|
+
selector: 'sc-placeholder,[sc-placeholder]',
|
|
1035
|
+
template: "\n <ng-template\n *ngIf=\"isLoading\"\n [ngTemplateOutlet]=\"placeholderLoading?.templateRef\"\n ></ng-template>\n <ng-template #view></ng-template>\n "
|
|
1036
|
+
},] }
|
|
1037
|
+
];
|
|
1038
|
+
PlaceholderComponent.ctorParameters = function () { return [
|
|
1039
|
+
{ type: core.ComponentFactoryResolver },
|
|
1040
|
+
{ type: core.KeyValueDiffers },
|
|
1041
|
+
{ type: JssComponentFactoryService },
|
|
1042
|
+
{ type: core.ChangeDetectorRef },
|
|
1043
|
+
{ type: core.ElementRef },
|
|
1044
|
+
{ type: core.Renderer2 },
|
|
1045
|
+
{ type: core.Type, decorators: [{ type: core.Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1046
|
+
]; };
|
|
1047
|
+
PlaceholderComponent.propDecorators = {
|
|
1048
|
+
name: [{ type: core.Input }],
|
|
1049
|
+
rendering: [{ type: core.Input }],
|
|
1050
|
+
renderings: [{ type: core.Input }],
|
|
1051
|
+
outputs: [{ type: core.Input }],
|
|
1052
|
+
loaded: [{ type: core.Output }],
|
|
1053
|
+
view: [{ type: core.ViewChild, args: ['view', { read: core.ViewContainerRef, static: true },] }],
|
|
1054
|
+
renderEachTemplate: [{ type: core.ContentChild, args: [RenderEachDirective, { static: true },] }],
|
|
1055
|
+
renderEmptyTemplate: [{ type: core.ContentChild, args: [RenderEmptyDirective, { static: true },] }],
|
|
1056
|
+
placeholderLoading: [{ type: core.ContentChild, args: [PlaceholderLoadingDirective, { static: true },] }],
|
|
1057
|
+
inputs: [{ type: core.Input }]
|
|
1058
1058
|
};
|
|
1059
1059
|
|
|
1060
|
-
var RichTextDirective = /** @class */ (function () {
|
|
1061
|
-
function RichTextDirective(viewContainer, templateRef) {
|
|
1062
|
-
this.viewContainer = viewContainer;
|
|
1063
|
-
this.templateRef = templateRef;
|
|
1064
|
-
this.editable = true;
|
|
1065
|
-
}
|
|
1066
|
-
RichTextDirective.prototype.ngOnChanges = function (changes) {
|
|
1067
|
-
if (changes.field || changes.editable) {
|
|
1068
|
-
if (!this.viewRef) {
|
|
1069
|
-
this.viewContainer.clear();
|
|
1070
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1071
|
-
}
|
|
1072
|
-
this.updateView();
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
RichTextDirective.prototype.updateView = function () {
|
|
1076
|
-
var field = this.field;
|
|
1077
|
-
if (!field || (!field.editable && !field.value)) {
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
var html = field.editable && this.editable ? field.editable : field.value;
|
|
1081
|
-
this.viewRef.rootNodes.forEach(function (node) {
|
|
1082
|
-
node.innerHTML = html;
|
|
1083
|
-
});
|
|
1084
|
-
};
|
|
1085
|
-
return RichTextDirective;
|
|
1086
|
-
}());
|
|
1087
|
-
RichTextDirective.decorators = [
|
|
1088
|
-
{ type: core.Directive, args: [{
|
|
1089
|
-
selector: '[scRichText]',
|
|
1090
|
-
},] }
|
|
1091
|
-
];
|
|
1092
|
-
RichTextDirective.ctorParameters = function () { return [
|
|
1093
|
-
{ type: core.ViewContainerRef },
|
|
1094
|
-
{ type: core.TemplateRef }
|
|
1095
|
-
]; };
|
|
1096
|
-
RichTextDirective.propDecorators = {
|
|
1097
|
-
editable: [{ type: core.Input, args: ['scRichTextEditable',] }],
|
|
1098
|
-
field: [{ type: core.Input, args: ['scRichText',] }]
|
|
1060
|
+
var RichTextDirective = /** @class */ (function () {
|
|
1061
|
+
function RichTextDirective(viewContainer, templateRef) {
|
|
1062
|
+
this.viewContainer = viewContainer;
|
|
1063
|
+
this.templateRef = templateRef;
|
|
1064
|
+
this.editable = true;
|
|
1065
|
+
}
|
|
1066
|
+
RichTextDirective.prototype.ngOnChanges = function (changes) {
|
|
1067
|
+
if (changes.field || changes.editable) {
|
|
1068
|
+
if (!this.viewRef) {
|
|
1069
|
+
this.viewContainer.clear();
|
|
1070
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1071
|
+
}
|
|
1072
|
+
this.updateView();
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
RichTextDirective.prototype.updateView = function () {
|
|
1076
|
+
var field = this.field;
|
|
1077
|
+
if (!field || (!field.editable && !field.value)) {
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
var html = field.editable && this.editable ? field.editable : field.value;
|
|
1081
|
+
this.viewRef.rootNodes.forEach(function (node) {
|
|
1082
|
+
node.innerHTML = html;
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1085
|
+
return RichTextDirective;
|
|
1086
|
+
}());
|
|
1087
|
+
RichTextDirective.decorators = [
|
|
1088
|
+
{ type: core.Directive, args: [{
|
|
1089
|
+
selector: '[scRichText]',
|
|
1090
|
+
},] }
|
|
1091
|
+
];
|
|
1092
|
+
RichTextDirective.ctorParameters = function () { return [
|
|
1093
|
+
{ type: core.ViewContainerRef },
|
|
1094
|
+
{ type: core.TemplateRef }
|
|
1095
|
+
]; };
|
|
1096
|
+
RichTextDirective.propDecorators = {
|
|
1097
|
+
editable: [{ type: core.Input, args: ['scRichTextEditable',] }],
|
|
1098
|
+
field: [{ type: core.Input, args: ['scRichText',] }]
|
|
1099
1099
|
};
|
|
1100
1100
|
|
|
1101
|
-
var TextDirective = /** @class */ (function () {
|
|
1102
|
-
function TextDirective(viewContainer, templateRef) {
|
|
1103
|
-
this.viewContainer = viewContainer;
|
|
1104
|
-
this.templateRef = templateRef;
|
|
1105
|
-
this.editable = true;
|
|
1106
|
-
this.encode = true;
|
|
1107
|
-
}
|
|
1108
|
-
TextDirective.prototype.ngOnChanges = function (changes) {
|
|
1109
|
-
if (changes.field || changes.editable || changes.encode) {
|
|
1110
|
-
if (!this.viewRef) {
|
|
1111
|
-
this.viewContainer.clear();
|
|
1112
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1113
|
-
}
|
|
1114
|
-
this.updateView();
|
|
1115
|
-
}
|
|
1116
|
-
};
|
|
1117
|
-
TextDirective.prototype.updateView = function () {
|
|
1118
|
-
var field = this.field;
|
|
1119
|
-
var editable = this.editable;
|
|
1120
|
-
if (!field || (!field.editable && (field.value === undefined || field.value === ''))) {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
// can't use editable value if we want to output unencoded
|
|
1124
|
-
if (!this.encode) {
|
|
1125
|
-
editable = false;
|
|
1126
|
-
}
|
|
1127
|
-
var html = field.editable && editable ? field.editable : field.value;
|
|
1128
|
-
var setDangerously = (field.editable && editable) || !this.encode;
|
|
1129
|
-
this.viewRef.rootNodes.forEach(function (node) {
|
|
1130
|
-
if (setDangerously) {
|
|
1131
|
-
node.innerHTML = html;
|
|
1132
|
-
}
|
|
1133
|
-
else {
|
|
1134
|
-
node.textContent = html;
|
|
1135
|
-
}
|
|
1136
|
-
});
|
|
1137
|
-
};
|
|
1138
|
-
return TextDirective;
|
|
1139
|
-
}());
|
|
1140
|
-
TextDirective.decorators = [
|
|
1141
|
-
{ type: core.Directive, args: [{
|
|
1142
|
-
selector: '[scText]',
|
|
1143
|
-
},] }
|
|
1144
|
-
];
|
|
1145
|
-
TextDirective.ctorParameters = function () { return [
|
|
1146
|
-
{ type: core.ViewContainerRef },
|
|
1147
|
-
{ type: core.TemplateRef }
|
|
1148
|
-
]; };
|
|
1149
|
-
TextDirective.propDecorators = {
|
|
1150
|
-
editable: [{ type: core.Input, args: ['scTextEditable',] }],
|
|
1151
|
-
encode: [{ type: core.Input, args: ['scTextEncode',] }],
|
|
1152
|
-
field: [{ type: core.Input, args: ['scText',] }]
|
|
1101
|
+
var TextDirective = /** @class */ (function () {
|
|
1102
|
+
function TextDirective(viewContainer, templateRef) {
|
|
1103
|
+
this.viewContainer = viewContainer;
|
|
1104
|
+
this.templateRef = templateRef;
|
|
1105
|
+
this.editable = true;
|
|
1106
|
+
this.encode = true;
|
|
1107
|
+
}
|
|
1108
|
+
TextDirective.prototype.ngOnChanges = function (changes) {
|
|
1109
|
+
if (changes.field || changes.editable || changes.encode) {
|
|
1110
|
+
if (!this.viewRef) {
|
|
1111
|
+
this.viewContainer.clear();
|
|
1112
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1113
|
+
}
|
|
1114
|
+
this.updateView();
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
TextDirective.prototype.updateView = function () {
|
|
1118
|
+
var field = this.field;
|
|
1119
|
+
var editable = this.editable;
|
|
1120
|
+
if (!field || (!field.editable && (field.value === undefined || field.value === ''))) {
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
// can't use editable value if we want to output unencoded
|
|
1124
|
+
if (!this.encode) {
|
|
1125
|
+
editable = false;
|
|
1126
|
+
}
|
|
1127
|
+
var html = field.editable && editable ? field.editable : field.value;
|
|
1128
|
+
var setDangerously = (field.editable && editable) || !this.encode;
|
|
1129
|
+
this.viewRef.rootNodes.forEach(function (node) {
|
|
1130
|
+
if (setDangerously) {
|
|
1131
|
+
node.innerHTML = html;
|
|
1132
|
+
}
|
|
1133
|
+
else {
|
|
1134
|
+
node.textContent = html;
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
};
|
|
1138
|
+
return TextDirective;
|
|
1139
|
+
}());
|
|
1140
|
+
TextDirective.decorators = [
|
|
1141
|
+
{ type: core.Directive, args: [{
|
|
1142
|
+
selector: '[scText]',
|
|
1143
|
+
},] }
|
|
1144
|
+
];
|
|
1145
|
+
TextDirective.ctorParameters = function () { return [
|
|
1146
|
+
{ type: core.ViewContainerRef },
|
|
1147
|
+
{ type: core.TemplateRef }
|
|
1148
|
+
]; };
|
|
1149
|
+
TextDirective.propDecorators = {
|
|
1150
|
+
editable: [{ type: core.Input, args: ['scTextEditable',] }],
|
|
1151
|
+
encode: [{ type: core.Input, args: ['scTextEncode',] }],
|
|
1152
|
+
field: [{ type: core.Input, args: ['scText',] }]
|
|
1153
1153
|
};
|
|
1154
1154
|
|
|
1155
|
-
var DateDirective = /** @class */ (function () {
|
|
1156
|
-
function DateDirective(viewContainer, templateRef, datePipe) {
|
|
1157
|
-
this.viewContainer = viewContainer;
|
|
1158
|
-
this.templateRef = templateRef;
|
|
1159
|
-
this.datePipe = datePipe;
|
|
1160
|
-
this.editable = true;
|
|
1161
|
-
}
|
|
1162
|
-
DateDirective.prototype.ngOnChanges = function (changes) {
|
|
1163
|
-
if (changes.field || changes.format) {
|
|
1164
|
-
if (!this.viewRef) {
|
|
1165
|
-
this.viewContainer.clear();
|
|
1166
|
-
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1167
|
-
}
|
|
1168
|
-
this.updateView();
|
|
1169
|
-
}
|
|
1170
|
-
};
|
|
1171
|
-
DateDirective.prototype.updateView = function () {
|
|
1172
|
-
var _this = this;
|
|
1173
|
-
var field = this.field;
|
|
1174
|
-
if (!field || (!field.editable && !field.value)) {
|
|
1175
|
-
return;
|
|
1176
|
-
}
|
|
1177
|
-
var html = field.editable && this.editable ? field.editable : field.value;
|
|
1178
|
-
var setDangerously = field.editable && this.editable;
|
|
1179
|
-
this.viewRef.rootNodes.forEach(function (node) {
|
|
1180
|
-
if (setDangerously) {
|
|
1181
|
-
node.innerHTML = html;
|
|
1182
|
-
}
|
|
1183
|
-
else {
|
|
1184
|
-
node.textContent = _this.datePipe.transform(html, _this.format, _this.timezone, _this.locale);
|
|
1185
|
-
}
|
|
1186
|
-
});
|
|
1187
|
-
};
|
|
1188
|
-
return DateDirective;
|
|
1189
|
-
}());
|
|
1190
|
-
DateDirective.decorators = [
|
|
1191
|
-
{ type: core.Directive, args: [{
|
|
1192
|
-
selector: '[scDate]',
|
|
1193
|
-
},] }
|
|
1194
|
-
];
|
|
1195
|
-
DateDirective.ctorParameters = function () { return [
|
|
1196
|
-
{ type: core.ViewContainerRef },
|
|
1197
|
-
{ type: core.TemplateRef },
|
|
1198
|
-
{ type: common.DatePipe }
|
|
1199
|
-
]; };
|
|
1200
|
-
DateDirective.propDecorators = {
|
|
1201
|
-
format: [{ type: core.Input, args: ['scDateFormat',] }],
|
|
1202
|
-
timezone: [{ type: core.Input, args: ['scDateTimezone',] }],
|
|
1203
|
-
locale: [{ type: core.Input, args: ['scDateLocale',] }],
|
|
1204
|
-
editable: [{ type: core.Input, args: ['scDateEditable',] }],
|
|
1205
|
-
field: [{ type: core.Input, args: ['scDate',] }]
|
|
1155
|
+
var DateDirective = /** @class */ (function () {
|
|
1156
|
+
function DateDirective(viewContainer, templateRef, datePipe) {
|
|
1157
|
+
this.viewContainer = viewContainer;
|
|
1158
|
+
this.templateRef = templateRef;
|
|
1159
|
+
this.datePipe = datePipe;
|
|
1160
|
+
this.editable = true;
|
|
1161
|
+
}
|
|
1162
|
+
DateDirective.prototype.ngOnChanges = function (changes) {
|
|
1163
|
+
if (changes.field || changes.format) {
|
|
1164
|
+
if (!this.viewRef) {
|
|
1165
|
+
this.viewContainer.clear();
|
|
1166
|
+
this.viewRef = this.viewContainer.createEmbeddedView(this.templateRef);
|
|
1167
|
+
}
|
|
1168
|
+
this.updateView();
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
DateDirective.prototype.updateView = function () {
|
|
1172
|
+
var _this = this;
|
|
1173
|
+
var field = this.field;
|
|
1174
|
+
if (!field || (!field.editable && !field.value)) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
var html = field.editable && this.editable ? field.editable : field.value;
|
|
1178
|
+
var setDangerously = field.editable && this.editable;
|
|
1179
|
+
this.viewRef.rootNodes.forEach(function (node) {
|
|
1180
|
+
if (setDangerously) {
|
|
1181
|
+
node.innerHTML = html;
|
|
1182
|
+
}
|
|
1183
|
+
else {
|
|
1184
|
+
node.textContent = _this.datePipe.transform(html, _this.format, _this.timezone, _this.locale);
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
};
|
|
1188
|
+
return DateDirective;
|
|
1189
|
+
}());
|
|
1190
|
+
DateDirective.decorators = [
|
|
1191
|
+
{ type: core.Directive, args: [{
|
|
1192
|
+
selector: '[scDate]',
|
|
1193
|
+
},] }
|
|
1194
|
+
];
|
|
1195
|
+
DateDirective.ctorParameters = function () { return [
|
|
1196
|
+
{ type: core.ViewContainerRef },
|
|
1197
|
+
{ type: core.TemplateRef },
|
|
1198
|
+
{ type: common.DatePipe }
|
|
1199
|
+
]; };
|
|
1200
|
+
DateDirective.propDecorators = {
|
|
1201
|
+
format: [{ type: core.Input, args: ['scDateFormat',] }],
|
|
1202
|
+
timezone: [{ type: core.Input, args: ['scDateTimezone',] }],
|
|
1203
|
+
locale: [{ type: core.Input, args: ['scDateLocale',] }],
|
|
1204
|
+
editable: [{ type: core.Input, args: ['scDateEditable',] }],
|
|
1205
|
+
field: [{ type: core.Input, args: ['scDate',] }]
|
|
1206
1206
|
};
|
|
1207
1207
|
|
|
1208
|
-
var MissingComponentComponent = /** @class */ (function () {
|
|
1209
|
-
function MissingComponentComponent() {
|
|
1210
|
-
}
|
|
1211
|
-
return MissingComponentComponent;
|
|
1212
|
-
}());
|
|
1213
|
-
MissingComponentComponent.decorators = [
|
|
1214
|
-
{ type: core.Component, args: [{
|
|
1215
|
-
selector: 'sc-missing-component',
|
|
1216
|
-
template: "\n <div\n style=\"background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;\"\n >\n <h2>{{ rendering.componentName }}</h2>\n <p>JSS component is missing Angular component implementation.</p>\n </div>\n "
|
|
1217
|
-
},] }
|
|
1218
|
-
];
|
|
1219
|
-
MissingComponentComponent.propDecorators = {
|
|
1220
|
-
rendering: [{ type: core.Input }]
|
|
1208
|
+
var MissingComponentComponent = /** @class */ (function () {
|
|
1209
|
+
function MissingComponentComponent() {
|
|
1210
|
+
}
|
|
1211
|
+
return MissingComponentComponent;
|
|
1212
|
+
}());
|
|
1213
|
+
MissingComponentComponent.decorators = [
|
|
1214
|
+
{ type: core.Component, args: [{
|
|
1215
|
+
selector: 'sc-missing-component',
|
|
1216
|
+
template: "\n <div\n style=\"background: darkorange; outline: 5px solid orange; padding: 10px; color: white; max-width: 500px;\"\n >\n <h2>{{ rendering.componentName }}</h2>\n <p>JSS component is missing Angular component implementation.</p>\n </div>\n "
|
|
1217
|
+
},] }
|
|
1218
|
+
];
|
|
1219
|
+
MissingComponentComponent.propDecorators = {
|
|
1220
|
+
rendering: [{ type: core.Input }]
|
|
1221
1221
|
};
|
|
1222
1222
|
|
|
1223
|
-
/**
|
|
1224
|
-
* Renders a single JSS component given a rendering definition.
|
|
1225
|
-
* Useful inside templated placeholders.
|
|
1226
|
-
*/
|
|
1227
|
-
var RenderComponentComponent = /** @class */ (function () {
|
|
1228
|
-
function RenderComponentComponent(componentFactoryResolver, differs, componentFactory, missingComponentComponent) {
|
|
1229
|
-
this.componentFactoryResolver = componentFactoryResolver;
|
|
1230
|
-
this.differs = differs;
|
|
1231
|
-
this.componentFactory = componentFactory;
|
|
1232
|
-
this.missingComponentComponent = missingComponentComponent;
|
|
1233
|
-
this.destroyed = false;
|
|
1234
|
-
}
|
|
1235
|
-
Object.defineProperty(RenderComponentComponent.prototype, "inputs", {
|
|
1236
|
-
set: function (value) {
|
|
1237
|
-
this._inputs = value;
|
|
1238
|
-
if (!this._differ && value) {
|
|
1239
|
-
this._differ = this.differs.find(value).create();
|
|
1240
|
-
}
|
|
1241
|
-
},
|
|
1242
|
-
enumerable: false,
|
|
1243
|
-
configurable: true
|
|
1244
|
-
});
|
|
1245
|
-
RenderComponentComponent.prototype.ngOnChanges = function (changes) {
|
|
1246
|
-
if (changes.rendering) {
|
|
1247
|
-
this._render();
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
RenderComponentComponent.prototype._setComponentInputs = function (componentInstance, inputs) {
|
|
1251
|
-
Object.entries(inputs).forEach(function (_a) {
|
|
1252
|
-
var _b = __read(_a, 2), input = _b[0], inputValue = _b[1];
|
|
1253
|
-
return (componentInstance[input] = inputValue);
|
|
1254
|
-
});
|
|
1255
|
-
};
|
|
1256
|
-
RenderComponentComponent.prototype._subscribeComponentOutputs = function (componentInstance, outputs) {
|
|
1257
|
-
var _this = this;
|
|
1258
|
-
Object.keys(outputs)
|
|
1259
|
-
.filter(function (output) { return componentInstance[output] && componentInstance[output] instanceof rxjs.Observable; })
|
|
1260
|
-
.forEach(function (output) { return componentInstance[output]
|
|
1261
|
-
.pipe(operators.takeWhile(function () { return !_this.destroyed; }))
|
|
1262
|
-
.subscribe(outputs[output]); });
|
|
1263
|
-
};
|
|
1264
|
-
RenderComponentComponent.prototype._render = function () {
|
|
1265
|
-
var _this = this;
|
|
1266
|
-
this.view.clear();
|
|
1267
|
-
if (!this.rendering) {
|
|
1268
|
-
return;
|
|
1269
|
-
}
|
|
1270
|
-
var resolveComponent = isRawRendering(this.rendering)
|
|
1271
|
-
? Promise.resolve({
|
|
1272
|
-
componentImplementation: RawComponent,
|
|
1273
|
-
componentDefinition: this.rendering,
|
|
1274
|
-
})
|
|
1275
|
-
: this.componentFactory.getComponent(this.rendering);
|
|
1276
|
-
resolveComponent.then(function (rendering) {
|
|
1277
|
-
if (!rendering.componentImplementation) {
|
|
1278
|
-
var componentName = rendering.componentDefinition.componentName;
|
|
1279
|
-
console.error("Attempted to render unknown component " + componentName + ".", "Ensure component is mapped, like:\n JssModule.withComponents([\n { name: '" + componentName + "', type: " + componentName + "Component }\n ])");
|
|
1280
|
-
rendering.componentImplementation = _this.missingComponentComponent;
|
|
1281
|
-
}
|
|
1282
|
-
var componentFactory = rendering.componentFactory ||
|
|
1283
|
-
_this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1284
|
-
var componentInstance = _this.view.createComponent(componentFactory, 0).instance;
|
|
1285
|
-
componentInstance.rendering = rendering.componentDefinition;
|
|
1286
|
-
if (_this._inputs) {
|
|
1287
|
-
_this._setComponentInputs(componentInstance, _this._inputs);
|
|
1288
|
-
}
|
|
1289
|
-
if (_this.outputs) {
|
|
1290
|
-
_this._subscribeComponentOutputs(componentInstance, _this.outputs);
|
|
1291
|
-
}
|
|
1292
|
-
});
|
|
1293
|
-
};
|
|
1294
|
-
return RenderComponentComponent;
|
|
1295
|
-
}());
|
|
1296
|
-
RenderComponentComponent.decorators = [
|
|
1297
|
-
{ type: core.Component, args: [{
|
|
1298
|
-
selector: 'sc-render-component',
|
|
1299
|
-
template: "\n <ng-template #view></ng-template>\n "
|
|
1300
|
-
},] }
|
|
1301
|
-
];
|
|
1302
|
-
RenderComponentComponent.ctorParameters = function () { return [
|
|
1303
|
-
{ type: core.ComponentFactoryResolver },
|
|
1304
|
-
{ type: core.KeyValueDiffers },
|
|
1305
|
-
{ type: JssComponentFactoryService },
|
|
1306
|
-
{ type: core.Type, decorators: [{ type: core.Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1307
|
-
]; };
|
|
1308
|
-
RenderComponentComponent.propDecorators = {
|
|
1309
|
-
rendering: [{ type: core.Input }],
|
|
1310
|
-
outputs: [{ type: core.Input }],
|
|
1311
|
-
view: [{ type: core.ViewChild, args: ['view', { read: core.ViewContainerRef, static: true },] }],
|
|
1312
|
-
inputs: [{ type: core.Input }]
|
|
1223
|
+
/**
|
|
1224
|
+
* Renders a single JSS component given a rendering definition.
|
|
1225
|
+
* Useful inside templated placeholders.
|
|
1226
|
+
*/
|
|
1227
|
+
var RenderComponentComponent = /** @class */ (function () {
|
|
1228
|
+
function RenderComponentComponent(componentFactoryResolver, differs, componentFactory, missingComponentComponent) {
|
|
1229
|
+
this.componentFactoryResolver = componentFactoryResolver;
|
|
1230
|
+
this.differs = differs;
|
|
1231
|
+
this.componentFactory = componentFactory;
|
|
1232
|
+
this.missingComponentComponent = missingComponentComponent;
|
|
1233
|
+
this.destroyed = false;
|
|
1234
|
+
}
|
|
1235
|
+
Object.defineProperty(RenderComponentComponent.prototype, "inputs", {
|
|
1236
|
+
set: function (value) {
|
|
1237
|
+
this._inputs = value;
|
|
1238
|
+
if (!this._differ && value) {
|
|
1239
|
+
this._differ = this.differs.find(value).create();
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1242
|
+
enumerable: false,
|
|
1243
|
+
configurable: true
|
|
1244
|
+
});
|
|
1245
|
+
RenderComponentComponent.prototype.ngOnChanges = function (changes) {
|
|
1246
|
+
if (changes.rendering) {
|
|
1247
|
+
this._render();
|
|
1248
|
+
}
|
|
1249
|
+
};
|
|
1250
|
+
RenderComponentComponent.prototype._setComponentInputs = function (componentInstance, inputs) {
|
|
1251
|
+
Object.entries(inputs).forEach(function (_a) {
|
|
1252
|
+
var _b = __read(_a, 2), input = _b[0], inputValue = _b[1];
|
|
1253
|
+
return (componentInstance[input] = inputValue);
|
|
1254
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
RenderComponentComponent.prototype._subscribeComponentOutputs = function (componentInstance, outputs) {
|
|
1257
|
+
var _this = this;
|
|
1258
|
+
Object.keys(outputs)
|
|
1259
|
+
.filter(function (output) { return componentInstance[output] && componentInstance[output] instanceof rxjs.Observable; })
|
|
1260
|
+
.forEach(function (output) { return componentInstance[output]
|
|
1261
|
+
.pipe(operators.takeWhile(function () { return !_this.destroyed; }))
|
|
1262
|
+
.subscribe(outputs[output]); });
|
|
1263
|
+
};
|
|
1264
|
+
RenderComponentComponent.prototype._render = function () {
|
|
1265
|
+
var _this = this;
|
|
1266
|
+
this.view.clear();
|
|
1267
|
+
if (!this.rendering) {
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
var resolveComponent = isRawRendering(this.rendering)
|
|
1271
|
+
? Promise.resolve({
|
|
1272
|
+
componentImplementation: RawComponent,
|
|
1273
|
+
componentDefinition: this.rendering,
|
|
1274
|
+
})
|
|
1275
|
+
: this.componentFactory.getComponent(this.rendering);
|
|
1276
|
+
resolveComponent.then(function (rendering) {
|
|
1277
|
+
if (!rendering.componentImplementation) {
|
|
1278
|
+
var componentName = rendering.componentDefinition.componentName;
|
|
1279
|
+
console.error("Attempted to render unknown component " + componentName + ".", "Ensure component is mapped, like:\n JssModule.withComponents([\n { name: '" + componentName + "', type: " + componentName + "Component }\n ])");
|
|
1280
|
+
rendering.componentImplementation = _this.missingComponentComponent;
|
|
1281
|
+
}
|
|
1282
|
+
var componentFactory = rendering.componentFactory ||
|
|
1283
|
+
_this.componentFactoryResolver.resolveComponentFactory(rendering.componentImplementation);
|
|
1284
|
+
var componentInstance = _this.view.createComponent(componentFactory, 0).instance;
|
|
1285
|
+
componentInstance.rendering = rendering.componentDefinition;
|
|
1286
|
+
if (_this._inputs) {
|
|
1287
|
+
_this._setComponentInputs(componentInstance, _this._inputs);
|
|
1288
|
+
}
|
|
1289
|
+
if (_this.outputs) {
|
|
1290
|
+
_this._subscribeComponentOutputs(componentInstance, _this.outputs);
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
};
|
|
1294
|
+
return RenderComponentComponent;
|
|
1295
|
+
}());
|
|
1296
|
+
RenderComponentComponent.decorators = [
|
|
1297
|
+
{ type: core.Component, args: [{
|
|
1298
|
+
selector: 'sc-render-component',
|
|
1299
|
+
template: "\n <ng-template #view></ng-template>\n "
|
|
1300
|
+
},] }
|
|
1301
|
+
];
|
|
1302
|
+
RenderComponentComponent.ctorParameters = function () { return [
|
|
1303
|
+
{ type: core.ComponentFactoryResolver },
|
|
1304
|
+
{ type: core.KeyValueDiffers },
|
|
1305
|
+
{ type: JssComponentFactoryService },
|
|
1306
|
+
{ type: core.Type, decorators: [{ type: core.Inject, args: [PLACEHOLDER_MISSING_COMPONENT_COMPONENT,] }] }
|
|
1307
|
+
]; };
|
|
1308
|
+
RenderComponentComponent.propDecorators = {
|
|
1309
|
+
rendering: [{ type: core.Input }],
|
|
1310
|
+
outputs: [{ type: core.Input }],
|
|
1311
|
+
view: [{ type: core.ViewChild, args: ['view', { read: core.ViewContainerRef, static: true },] }],
|
|
1312
|
+
inputs: [{ type: core.Input }]
|
|
1313
1313
|
};
|
|
1314
1314
|
|
|
1315
|
-
var JssModule = /** @class */ (function () {
|
|
1316
|
-
function JssModule() {
|
|
1317
|
-
}
|
|
1318
|
-
/**
|
|
1319
|
-
* Instantiates the JSS module with no component factory.
|
|
1320
|
-
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1321
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1322
|
-
*/
|
|
1323
|
-
JssModule.forRoot = function () {
|
|
1324
|
-
return {
|
|
1325
|
-
ngModule: JssModule,
|
|
1326
|
-
providers: [common.DatePipe, JssComponentFactoryService],
|
|
1327
|
-
};
|
|
1328
|
-
};
|
|
1329
|
-
/**
|
|
1330
|
-
* Instantiates a module for a lazy-loaded JSS component
|
|
1331
|
-
* @param {Type<unknown>} component
|
|
1332
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1333
|
-
*/
|
|
1334
|
-
JssModule.forChild = function (component) {
|
|
1335
|
-
return {
|
|
1336
|
-
ngModule: JssModule,
|
|
1337
|
-
providers: [
|
|
1338
|
-
{ provide: core.ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1339
|
-
{ provide: router.ROUTES, useValue: [], multi: true },
|
|
1340
|
-
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1341
|
-
],
|
|
1342
|
-
};
|
|
1343
|
-
};
|
|
1344
|
-
/**
|
|
1345
|
-
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1346
|
-
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1347
|
-
* @param {ComponentNameAndType[]} components
|
|
1348
|
-
* @param {ComponentNameAndModule[]} [lazyComponents]
|
|
1349
|
-
* @returns {ModuleWithProviders<JssModule>} module
|
|
1350
|
-
*/
|
|
1351
|
-
JssModule.withComponents = function (components, lazyComponents) {
|
|
1352
|
-
return {
|
|
1353
|
-
ngModule: JssModule,
|
|
1354
|
-
providers: __spread([
|
|
1355
|
-
{
|
|
1356
|
-
provide: core.ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1357
|
-
useValue: components,
|
|
1358
|
-
multi: true,
|
|
1359
|
-
},
|
|
1360
|
-
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1361
|
-
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1362
|
-
{ provide: router.ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1363
|
-
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent }
|
|
1364
|
-
], JssModule.forRoot().providers),
|
|
1365
|
-
};
|
|
1366
|
-
};
|
|
1367
|
-
return JssModule;
|
|
1368
|
-
}());
|
|
1369
|
-
JssModule.decorators = [
|
|
1370
|
-
{ type: core.NgModule, args: [{
|
|
1371
|
-
imports: [common.CommonModule],
|
|
1372
|
-
declarations: [
|
|
1373
|
-
FileDirective,
|
|
1374
|
-
ImageDirective,
|
|
1375
|
-
LinkDirective,
|
|
1376
|
-
RouterLinkDirective,
|
|
1377
|
-
GenericLinkDirective,
|
|
1378
|
-
DateDirective,
|
|
1379
|
-
RenderEachDirective,
|
|
1380
|
-
RenderEmptyDirective,
|
|
1381
|
-
PlaceholderLoadingDirective,
|
|
1382
|
-
RenderComponentComponent,
|
|
1383
|
-
PlaceholderComponent,
|
|
1384
|
-
RawComponent,
|
|
1385
|
-
RichTextDirective,
|
|
1386
|
-
TextDirective,
|
|
1387
|
-
MissingComponentComponent,
|
|
1388
|
-
],
|
|
1389
|
-
exports: [
|
|
1390
|
-
FileDirective,
|
|
1391
|
-
ImageDirective,
|
|
1392
|
-
DateDirective,
|
|
1393
|
-
LinkDirective,
|
|
1394
|
-
RouterLinkDirective,
|
|
1395
|
-
GenericLinkDirective,
|
|
1396
|
-
RenderEachDirective,
|
|
1397
|
-
RenderEmptyDirective,
|
|
1398
|
-
RenderComponentComponent,
|
|
1399
|
-
PlaceholderComponent,
|
|
1400
|
-
PlaceholderLoadingDirective,
|
|
1401
|
-
RichTextDirective,
|
|
1402
|
-
TextDirective,
|
|
1403
|
-
],
|
|
1404
|
-
entryComponents: [RawComponent, MissingComponentComponent],
|
|
1405
|
-
},] }
|
|
1315
|
+
var JssModule = /** @class */ (function () {
|
|
1316
|
+
function JssModule() {
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Instantiates the JSS module with no component factory.
|
|
1320
|
+
* Useful for using it from libraries. Most of the time you'd want withComponents()
|
|
1321
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1322
|
+
*/
|
|
1323
|
+
JssModule.forRoot = function () {
|
|
1324
|
+
return {
|
|
1325
|
+
ngModule: JssModule,
|
|
1326
|
+
providers: [common.DatePipe, JssComponentFactoryService],
|
|
1327
|
+
};
|
|
1328
|
+
};
|
|
1329
|
+
/**
|
|
1330
|
+
* Instantiates a module for a lazy-loaded JSS component
|
|
1331
|
+
* @param {Type<unknown>} component
|
|
1332
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1333
|
+
*/
|
|
1334
|
+
JssModule.forChild = function (component) {
|
|
1335
|
+
return {
|
|
1336
|
+
ngModule: JssModule,
|
|
1337
|
+
providers: [
|
|
1338
|
+
{ provide: core.ANALYZE_FOR_ENTRY_COMPONENTS, useValue: component, multi: true },
|
|
1339
|
+
{ provide: router.ROUTES, useValue: [], multi: true },
|
|
1340
|
+
{ provide: DYNAMIC_COMPONENT, useValue: component },
|
|
1341
|
+
],
|
|
1342
|
+
};
|
|
1343
|
+
};
|
|
1344
|
+
/**
|
|
1345
|
+
* Instantiates the JSS module and specifies the mapping from component name to component implementation.
|
|
1346
|
+
* Appropriate when defining the set of JSS components that your app is aware of.
|
|
1347
|
+
* @param {ComponentNameAndType[]} components
|
|
1348
|
+
* @param {ComponentNameAndModule[]} [lazyComponents]
|
|
1349
|
+
* @returns {ModuleWithProviders<JssModule>} module
|
|
1350
|
+
*/
|
|
1351
|
+
JssModule.withComponents = function (components, lazyComponents) {
|
|
1352
|
+
return {
|
|
1353
|
+
ngModule: JssModule,
|
|
1354
|
+
providers: __spread([
|
|
1355
|
+
{
|
|
1356
|
+
provide: core.ANALYZE_FOR_ENTRY_COMPONENTS,
|
|
1357
|
+
useValue: components,
|
|
1358
|
+
multi: true,
|
|
1359
|
+
},
|
|
1360
|
+
{ provide: PLACEHOLDER_COMPONENTS, useValue: components },
|
|
1361
|
+
{ provide: PLACEHOLDER_LAZY_COMPONENTS, useValue: lazyComponents || [] },
|
|
1362
|
+
{ provide: router.ROUTES, useValue: lazyComponents || [], multi: true },
|
|
1363
|
+
{ provide: PLACEHOLDER_MISSING_COMPONENT_COMPONENT, useValue: MissingComponentComponent }
|
|
1364
|
+
], JssModule.forRoot().providers),
|
|
1365
|
+
};
|
|
1366
|
+
};
|
|
1367
|
+
return JssModule;
|
|
1368
|
+
}());
|
|
1369
|
+
JssModule.decorators = [
|
|
1370
|
+
{ type: core.NgModule, args: [{
|
|
1371
|
+
imports: [common.CommonModule],
|
|
1372
|
+
declarations: [
|
|
1373
|
+
FileDirective,
|
|
1374
|
+
ImageDirective,
|
|
1375
|
+
LinkDirective,
|
|
1376
|
+
RouterLinkDirective,
|
|
1377
|
+
GenericLinkDirective,
|
|
1378
|
+
DateDirective,
|
|
1379
|
+
RenderEachDirective,
|
|
1380
|
+
RenderEmptyDirective,
|
|
1381
|
+
PlaceholderLoadingDirective,
|
|
1382
|
+
RenderComponentComponent,
|
|
1383
|
+
PlaceholderComponent,
|
|
1384
|
+
RawComponent,
|
|
1385
|
+
RichTextDirective,
|
|
1386
|
+
TextDirective,
|
|
1387
|
+
MissingComponentComponent,
|
|
1388
|
+
],
|
|
1389
|
+
exports: [
|
|
1390
|
+
FileDirective,
|
|
1391
|
+
ImageDirective,
|
|
1392
|
+
DateDirective,
|
|
1393
|
+
LinkDirective,
|
|
1394
|
+
RouterLinkDirective,
|
|
1395
|
+
GenericLinkDirective,
|
|
1396
|
+
RenderEachDirective,
|
|
1397
|
+
RenderEmptyDirective,
|
|
1398
|
+
RenderComponentComponent,
|
|
1399
|
+
PlaceholderComponent,
|
|
1400
|
+
PlaceholderLoadingDirective,
|
|
1401
|
+
RichTextDirective,
|
|
1402
|
+
TextDirective,
|
|
1403
|
+
],
|
|
1404
|
+
entryComponents: [RawComponent, MissingComponentComponent],
|
|
1405
|
+
},] }
|
|
1406
1406
|
];
|
|
1407
1407
|
|
|
1408
|
-
/**
|
|
1409
|
-
* Generated bundle index. Do not edit.
|
|
1408
|
+
/**
|
|
1409
|
+
* Generated bundle index. Do not edit.
|
|
1410
1410
|
*/
|
|
1411
1411
|
|
|
1412
1412
|
Object.defineProperty(exports, 'GraphQLDictionaryService', {
|