1 |
|
2 | "use strict";
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.showJsComp = function (compDetails, context, eParent, ref) {
|
5 | var doNothing = !compDetails || compDetails.componentFromFramework;
|
6 | if (doNothing) {
|
7 | return;
|
8 | }
|
9 | var comp = exports.createJsComp(compDetails);
|
10 | if (!comp) {
|
11 | return;
|
12 | }
|
13 | var compGui = comp.getGui();
|
14 | eParent.appendChild(compGui);
|
15 | setRef(ref, comp);
|
16 | return function () {
|
17 | var compGui = comp.getGui();
|
18 | if (compGui && compGui.parentElement) {
|
19 | compGui.parentElement.removeChild(compGui);
|
20 | }
|
21 | context.destroyBean(comp);
|
22 | if (ref) {
|
23 | setRef(ref, undefined);
|
24 | }
|
25 | };
|
26 | };
|
27 | var setRef = function (ref, value) {
|
28 | if (!ref) {
|
29 | return;
|
30 | }
|
31 | if (ref instanceof Function) {
|
32 | var refCallback = ref;
|
33 | refCallback(value);
|
34 | }
|
35 | else {
|
36 | var refObj = ref;
|
37 | refObj.current = value;
|
38 | }
|
39 | };
|
40 | exports.createJsComp = function (compDetails) {
|
41 | var promise = compDetails.newAgStackInstance();
|
42 | if (!promise) {
|
43 | return;
|
44 | }
|
45 | return promise.resolveNow(null, function (x) { return x; });
|
46 | };
|