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