@telia-ace/widget-core 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +5 -5
- package/README.md +3 -3
- package/{lib-esm → dist}/action-resolver.d.ts +8 -8
- package/{lib → dist}/component-platform/actions-controller.d.ts +40 -40
- package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +8 -8
- package/{lib-esm → dist}/component-platform/component-configuration-api.d.ts +2 -2
- package/{lib-esm → dist}/component-platform/component-controller.d.ts +38 -38
- package/{lib → dist}/component-platform/component-node-collection.d.ts +18 -18
- package/{lib → dist}/component-platform/component-node.d.ts +63 -63
- package/{lib-esm → dist}/component-platform/component-platform.d.ts +54 -54
- package/{lib → dist}/component-platform/component-query.d.ts +16 -16
- package/{lib → dist}/component-platform/create-component-model.d.ts +36 -36
- package/{lib-esm → dist}/component-platform/custom-component-handler.d.ts +21 -21
- package/{lib-esm → dist}/component-platform/descriptor.d.ts +8 -8
- package/{lib-esm → dist}/component-platform/extend-component.d.ts +8 -8
- package/{lib → dist}/component-platform/index.d.ts +18 -18
- package/{lib-esm → dist}/component-platform/queries.d.ts +6 -6
- package/{lib → dist}/component-platform/state-processor.d.ts +12 -12
- package/{lib-esm → dist}/component-resolver.d.ts +14 -14
- package/{lib-esm → dist}/event-subscriber.d.ts +7 -7
- package/{lib → dist}/index.d.ts +8 -8
- package/dist/index.js +1047 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/types/configuration.d.ts +86 -86
- package/{lib → dist}/types/index.d.ts +2 -2
- package/{lib-esm → dist}/types/ui.d.ts +54 -54
- package/package.json +10 -10
- package/lib/action-resolver.d.ts +0 -8
- package/lib/action-resolver.js +0 -19
- package/lib/component-platform/actions-controller.js +0 -119
- package/lib/component-platform/changeset-provider.d.ts +0 -8
- package/lib/component-platform/changeset-provider.js +0 -2
- package/lib/component-platform/component-configuration-api.d.ts +0 -2
- package/lib/component-platform/component-configuration-api.js +0 -32
- package/lib/component-platform/component-controller.d.ts +0 -38
- package/lib/component-platform/component-controller.js +0 -119
- package/lib/component-platform/component-node-collection.js +0 -51
- package/lib/component-platform/component-node.js +0 -190
- package/lib/component-platform/component-platform.d.ts +0 -54
- package/lib/component-platform/component-platform.js +0 -220
- package/lib/component-platform/component-query.js +0 -35
- package/lib/component-platform/create-component-model.js +0 -141
- package/lib/component-platform/custom-component-handler.d.ts +0 -21
- package/lib/component-platform/custom-component-handler.js +0 -16
- package/lib/component-platform/descriptor.d.ts +0 -8
- package/lib/component-platform/descriptor.js +0 -12
- package/lib/component-platform/extend-component.d.ts +0 -8
- package/lib/component-platform/extend-component.js +0 -57
- package/lib/component-platform/index.js +0 -30
- package/lib/component-platform/queries.d.ts +0 -6
- package/lib/component-platform/queries.js +0 -53
- package/lib/component-platform/state-processor.js +0 -209
- package/lib/component-resolver.d.ts +0 -14
- package/lib/component-resolver.js +0 -49
- package/lib/event-subscriber.d.ts +0 -7
- package/lib/event-subscriber.js +0 -22
- package/lib/index.js +0 -41
- package/lib/types/configuration.d.ts +0 -86
- package/lib/types/configuration.js +0 -16
- package/lib/types/index.js +0 -18
- package/lib/types/ui.d.ts +0 -54
- package/lib/types/ui.js +0 -2
- package/lib-esm/action-resolver.js +0 -17
- package/lib-esm/component-platform/actions-controller.d.ts +0 -40
- package/lib-esm/component-platform/actions-controller.js +0 -116
- package/lib-esm/component-platform/changeset-provider.js +0 -1
- package/lib-esm/component-platform/component-configuration-api.js +0 -30
- package/lib-esm/component-platform/component-controller.js +0 -116
- package/lib-esm/component-platform/component-node-collection.d.ts +0 -18
- package/lib-esm/component-platform/component-node-collection.js +0 -48
- package/lib-esm/component-platform/component-node.d.ts +0 -63
- package/lib-esm/component-platform/component-node.js +0 -187
- package/lib-esm/component-platform/component-platform.js +0 -217
- package/lib-esm/component-platform/component-query.d.ts +0 -16
- package/lib-esm/component-platform/component-query.js +0 -32
- package/lib-esm/component-platform/create-component-model.d.ts +0 -36
- package/lib-esm/component-platform/create-component-model.js +0 -135
- package/lib-esm/component-platform/custom-component-handler.js +0 -13
- package/lib-esm/component-platform/descriptor.js +0 -8
- package/lib-esm/component-platform/extend-component.js +0 -53
- package/lib-esm/component-platform/index.d.ts +0 -18
- package/lib-esm/component-platform/index.js +0 -10
- package/lib-esm/component-platform/queries.js +0 -46
- package/lib-esm/component-platform/state-processor.d.ts +0 -12
- package/lib-esm/component-platform/state-processor.js +0 -205
- package/lib-esm/component-resolver.js +0 -47
- package/lib-esm/event-subscriber.js +0 -18
- package/lib-esm/index.d.ts +0 -8
- package/lib-esm/index.js +0 -5
- package/lib-esm/types/configuration.js +0 -13
- package/lib-esm/types/index.d.ts +0 -2
- package/lib-esm/types/index.js +0 -2
- package/lib-esm/types/ui.js +0 -1
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.ActionsController = void 0;
|
|
15
|
-
var component_controller_1 = require("./component-controller");
|
|
16
|
-
var executeActionListeners = function (listeners, data, controller) {
|
|
17
|
-
var stack = listeners.concat();
|
|
18
|
-
var dispatch = function (data, globalOptions, controller) {
|
|
19
|
-
var cancelled = true;
|
|
20
|
-
if (stack.length) {
|
|
21
|
-
var handler = stack.shift();
|
|
22
|
-
var next = function (data, options) {
|
|
23
|
-
cancelled = false;
|
|
24
|
-
return dispatch(data, Object.assign({}, globalOptions, options), controller);
|
|
25
|
-
};
|
|
26
|
-
return Promise.resolve(handler(data, next, controller)).then(function (result) { return (__assign(__assign({}, result), { cancelled: cancelled })); });
|
|
27
|
-
}
|
|
28
|
-
return Promise.resolve({ data: data, cancelled: false, options: globalOptions });
|
|
29
|
-
};
|
|
30
|
-
return dispatch(data, {}, controller);
|
|
31
|
-
};
|
|
32
|
-
var ActionsController = /** @class */ (function () {
|
|
33
|
-
function ActionsController(platform, target, ns) {
|
|
34
|
-
this.platform = platform;
|
|
35
|
-
this.target = target;
|
|
36
|
-
this.ns = ns;
|
|
37
|
-
this.subscriptions = [];
|
|
38
|
-
this.create = this.create.bind(this);
|
|
39
|
-
}
|
|
40
|
-
ActionsController.prototype.create = function (key, fn) {
|
|
41
|
-
var _this = this;
|
|
42
|
-
if (fn === void 0) { fn = function () { }; }
|
|
43
|
-
var handler = {
|
|
44
|
-
key: key,
|
|
45
|
-
fn: fn,
|
|
46
|
-
target: this.target,
|
|
47
|
-
ns: this.ns,
|
|
48
|
-
};
|
|
49
|
-
this.platform.actionsState.handlers.push(handler);
|
|
50
|
-
var subscription = function () {
|
|
51
|
-
var index = _this.platform.actionsState.handlers.indexOf(handler);
|
|
52
|
-
if (index > -1) {
|
|
53
|
-
_this.platform.actionsState.handlers.splice(index, 1);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.subscriptions.push(subscription);
|
|
57
|
-
return subscription;
|
|
58
|
-
};
|
|
59
|
-
ActionsController.prototype.dispatch = function (key, data) {
|
|
60
|
-
var _this = this;
|
|
61
|
-
var instances = this.platform.nodes.all.concat(this.platform.nodes.detached);
|
|
62
|
-
var output = {};
|
|
63
|
-
// handlers matching the specified pattern.
|
|
64
|
-
var handlers = this.platform.actionsState.handlers.filter(function (handler) { return handler.key === key && (!handler.ns || !_this.ns || handler.ns === _this.ns); });
|
|
65
|
-
return Promise.all(handlers.map(function (handler) {
|
|
66
|
-
// select all matching instances for this particular
|
|
67
|
-
// handler (a handler can be mapped to many instances)
|
|
68
|
-
var matchedInstances = instances.filter(function (instance) { return handler.target.match(instance) && _this.target.match(instance); });
|
|
69
|
-
// execute watchers for each matched instance
|
|
70
|
-
var watchers = _this.platform.actionsState.watchers
|
|
71
|
-
.filter(function (watcher) {
|
|
72
|
-
return (watcher.key === key &&
|
|
73
|
-
(!watcher.ns || !_this.ns || watcher.ns === _this.ns) &&
|
|
74
|
-
matchedInstances.some(function (instance) { return watcher.target.match(instance); }));
|
|
75
|
-
})
|
|
76
|
-
.map(function (watcher) { return watcher.fn; });
|
|
77
|
-
// execute watchers and handler for each instance
|
|
78
|
-
return Promise.all(matchedInstances.map(function (node) {
|
|
79
|
-
var controller = new component_controller_1.ComponentNodeController(_this.platform, node, _this.ns);
|
|
80
|
-
return executeActionListeners(watchers, data, controller).then(function (input) {
|
|
81
|
-
var _a = input.data, data = _a === void 0 ? {} : _a, options = input.options, cancelled = input.cancelled;
|
|
82
|
-
return Promise.resolve(cancelled ? {} : handler.fn(data, options, controller)).then(function (handlerResponse) {
|
|
83
|
-
output[node.id] = handlerResponse;
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}));
|
|
87
|
-
})).then(function () { return output; });
|
|
88
|
-
};
|
|
89
|
-
ActionsController.prototype.watch = function (key, fn) {
|
|
90
|
-
var _this = this;
|
|
91
|
-
var parsedKey = key;
|
|
92
|
-
var parsedNs = this.ns;
|
|
93
|
-
var sections = key.split('.');
|
|
94
|
-
if (sections.length > 1) {
|
|
95
|
-
parsedNs = sections[0];
|
|
96
|
-
parsedKey = sections.splice(1).join('.');
|
|
97
|
-
}
|
|
98
|
-
var watcher = {
|
|
99
|
-
fn: fn,
|
|
100
|
-
target: this.target,
|
|
101
|
-
key: parsedKey,
|
|
102
|
-
ns: parsedNs,
|
|
103
|
-
};
|
|
104
|
-
this.platform.actionsState.watchers.push(watcher);
|
|
105
|
-
var subscription = function () {
|
|
106
|
-
var index = _this.platform.actionsState.watchers.indexOf(watcher);
|
|
107
|
-
if (index > -1) {
|
|
108
|
-
_this.platform.actionsState.watchers.splice(index, 1);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
this.subscriptions.push(subscription);
|
|
112
|
-
return subscription;
|
|
113
|
-
};
|
|
114
|
-
ActionsController.prototype.dispose = function () {
|
|
115
|
-
this.subscriptions.forEach(function (unsubscribe) { return unsubscribe(); });
|
|
116
|
-
};
|
|
117
|
-
return ActionsController;
|
|
118
|
-
}());
|
|
119
|
-
exports.ActionsController = ActionsController;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ChangesetOptions, ComponentNodeSettings } from './component-node';
|
|
2
|
-
import { ComponentPlatform } from './component-platform';
|
|
3
|
-
import { ComponentQuery } from './component-query';
|
|
4
|
-
export interface ChangesetProvider {
|
|
5
|
-
write: (key: string, target: ComponentQuery, attributes: Partial<ComponentNodeSettings>, options: ChangesetOptions) => void;
|
|
6
|
-
remove: (key: string) => void;
|
|
7
|
-
load: (platform: ComponentPlatform) => Promise<any>;
|
|
8
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var platform_1 = require("@webprovisions/platform");
|
|
20
|
-
exports.default = (0, platform_1.createConfigurationApi)(function (builder) {
|
|
21
|
-
builder.createCommand('components', function (context) { return function (config) {
|
|
22
|
-
context.events.subscribeOnce('components:platform-created', function (event, _a) {
|
|
23
|
-
var platform = _a.platform;
|
|
24
|
-
if (config.handlers) {
|
|
25
|
-
config.handlers.forEach(function (_a) {
|
|
26
|
-
var _b = __read(_a, 2), key = _b[0], handler = _b[1];
|
|
27
|
-
platform.addComponentHandler(key, handler);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}; });
|
|
32
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ActionsController } from './actions-controller';
|
|
2
|
-
import { ChangesetOptions, ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
|
|
3
|
-
import { ComponentPlatform } from './component-platform';
|
|
4
|
-
import { ComponentQuery } from './component-query';
|
|
5
|
-
export interface ComponentController {
|
|
6
|
-
actions: ActionsController;
|
|
7
|
-
writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;
|
|
8
|
-
writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;
|
|
9
|
-
writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;
|
|
10
|
-
dispose(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare class ComponentNodeController implements ComponentController {
|
|
13
|
-
private platform;
|
|
14
|
-
node: ComponentNode;
|
|
15
|
-
actions: ActionsController;
|
|
16
|
-
private subscribe;
|
|
17
|
-
private unsubscribe;
|
|
18
|
-
constructor(platform: ComponentPlatform, node: ComponentNode, ns?: string);
|
|
19
|
-
properties<T extends ComponentNodeProperties>(updated?: (properties: T) => void | Partial<ComponentNodeProperties>): T;
|
|
20
|
-
context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext;
|
|
21
|
-
layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout;
|
|
22
|
-
writeProperties(properties: Partial<ComponentNodeProperties> | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>), options?: ChangesetOptions): void;
|
|
23
|
-
writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
|
|
24
|
-
writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
|
|
25
|
-
dispose(): void;
|
|
26
|
-
}
|
|
27
|
-
export declare class AbstractComponentController implements ComponentController {
|
|
28
|
-
private platform;
|
|
29
|
-
private target;
|
|
30
|
-
private clearOnDispose;
|
|
31
|
-
actions: ActionsController;
|
|
32
|
-
private removes;
|
|
33
|
-
constructor(platform: ComponentPlatform, target: ComponentQuery, clearOnDispose?: boolean);
|
|
34
|
-
writeProperties(properties: Partial<ComponentNodeProperties>, options?: ChangesetOptions): void;
|
|
35
|
-
writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
|
|
36
|
-
writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
|
|
37
|
-
dispose(): void;
|
|
38
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
-
if (!m) return o;
|
|
5
|
-
var i = m.call(o), r, ar = [], e;
|
|
6
|
-
try {
|
|
7
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
-
}
|
|
9
|
-
catch (error) { e = { error: error }; }
|
|
10
|
-
finally {
|
|
11
|
-
try {
|
|
12
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
-
}
|
|
14
|
-
finally { if (e) throw e.error; }
|
|
15
|
-
}
|
|
16
|
-
return ar;
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.AbstractComponentController = exports.ComponentNodeController = void 0;
|
|
20
|
-
var event_subscriber_1 = require("../event-subscriber");
|
|
21
|
-
var actions_controller_1 = require("./actions-controller");
|
|
22
|
-
var component_query_1 = require("./component-query");
|
|
23
|
-
var ComponentNodeController = /** @class */ (function () {
|
|
24
|
-
function ComponentNodeController(platform, node, ns) {
|
|
25
|
-
this.platform = platform;
|
|
26
|
-
this.node = node;
|
|
27
|
-
this.actions = new actions_controller_1.ActionsController(platform, new component_query_1.ComponentQuery(platform).withId(node.id), ns);
|
|
28
|
-
var _a = __read((0, event_subscriber_1.createEventSubscriber)(this.platform.events), 2), subscribe = _a[0], unsubscribe = _a[1];
|
|
29
|
-
this.subscribe = subscribe;
|
|
30
|
-
this.unsubscribe = unsubscribe;
|
|
31
|
-
}
|
|
32
|
-
ComponentNodeController.prototype.properties = function (updated) {
|
|
33
|
-
if (updated) {
|
|
34
|
-
this.node.touchProperties(function (properties) { return updated(properties); });
|
|
35
|
-
}
|
|
36
|
-
return this.node.attributes.properties;
|
|
37
|
-
};
|
|
38
|
-
ComponentNodeController.prototype.context = function (updated) {
|
|
39
|
-
var _this = this;
|
|
40
|
-
if (updated) {
|
|
41
|
-
this.subscribe('components:context-changed', function (event, _a) {
|
|
42
|
-
var node = _a.node;
|
|
43
|
-
if (node === _this.node) {
|
|
44
|
-
updated(_this.node.attributes.context);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return this.node.attributes.context;
|
|
49
|
-
};
|
|
50
|
-
ComponentNodeController.prototype.layout = function (updated) {
|
|
51
|
-
var _this = this;
|
|
52
|
-
if (updated) {
|
|
53
|
-
this.subscribe('components:layout-changed', function (event, _a) {
|
|
54
|
-
var node = _a.node;
|
|
55
|
-
if (node === _this.node) {
|
|
56
|
-
updated(_this.node.attributes.layout);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return this.node.attributes.layout;
|
|
61
|
-
};
|
|
62
|
-
ComponentNodeController.prototype.writeProperties = function (properties, options) {
|
|
63
|
-
this.node.writeProperties(properties, options);
|
|
64
|
-
};
|
|
65
|
-
ComponentNodeController.prototype.writeContext = function (context, options) {
|
|
66
|
-
this.node.writeProperties(context, options);
|
|
67
|
-
};
|
|
68
|
-
ComponentNodeController.prototype.writeLayout = function (layout, options) {
|
|
69
|
-
this.node.writeLayout(layout, options);
|
|
70
|
-
};
|
|
71
|
-
ComponentNodeController.prototype.dispose = function () {
|
|
72
|
-
this.unsubscribe();
|
|
73
|
-
this.actions.dispose();
|
|
74
|
-
};
|
|
75
|
-
return ComponentNodeController;
|
|
76
|
-
}());
|
|
77
|
-
exports.ComponentNodeController = ComponentNodeController;
|
|
78
|
-
var AbstractComponentController = /** @class */ (function () {
|
|
79
|
-
function AbstractComponentController(platform, target, clearOnDispose) {
|
|
80
|
-
if (clearOnDispose === void 0) { clearOnDispose = true; }
|
|
81
|
-
this.platform = platform;
|
|
82
|
-
this.target = target;
|
|
83
|
-
this.clearOnDispose = clearOnDispose;
|
|
84
|
-
this.removes = [];
|
|
85
|
-
this.actions = new actions_controller_1.ActionsController(this.platform, this.target);
|
|
86
|
-
}
|
|
87
|
-
AbstractComponentController.prototype.writeProperties = function (properties, options) {
|
|
88
|
-
this.removes.push(this.platform.write({
|
|
89
|
-
options: options,
|
|
90
|
-
attributes: { properties: properties },
|
|
91
|
-
target: this.target,
|
|
92
|
-
removable: this.clearOnDispose,
|
|
93
|
-
}));
|
|
94
|
-
};
|
|
95
|
-
AbstractComponentController.prototype.writeContext = function (context, options) {
|
|
96
|
-
this.removes.push(this.platform.write({
|
|
97
|
-
options: options,
|
|
98
|
-
attributes: { context: context },
|
|
99
|
-
target: this.target,
|
|
100
|
-
removable: this.clearOnDispose,
|
|
101
|
-
}));
|
|
102
|
-
};
|
|
103
|
-
AbstractComponentController.prototype.writeLayout = function (layout, options) {
|
|
104
|
-
this.removes.push(this.platform.write({
|
|
105
|
-
options: options,
|
|
106
|
-
attributes: { layout: layout },
|
|
107
|
-
target: this.target,
|
|
108
|
-
removable: this.clearOnDispose,
|
|
109
|
-
}));
|
|
110
|
-
};
|
|
111
|
-
AbstractComponentController.prototype.dispose = function () {
|
|
112
|
-
this.removes.forEach(function (remove) {
|
|
113
|
-
remove();
|
|
114
|
-
});
|
|
115
|
-
this.actions.dispose();
|
|
116
|
-
};
|
|
117
|
-
return AbstractComponentController;
|
|
118
|
-
}());
|
|
119
|
-
exports.AbstractComponentController = AbstractComponentController;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComponentNodeCollection = void 0;
|
|
4
|
-
var queries_1 = require("./queries");
|
|
5
|
-
var ComponentNodeCollection = /** @class */ (function () {
|
|
6
|
-
function ComponentNodeCollection(root, switches, events) {
|
|
7
|
-
var _this = this;
|
|
8
|
-
this.root = root;
|
|
9
|
-
this.switches = switches;
|
|
10
|
-
this.all = [];
|
|
11
|
-
this.visible = [];
|
|
12
|
-
this.detached = [];
|
|
13
|
-
events.subscribe('components:node-appended', function (event, data) {
|
|
14
|
-
_this.all.push(data.node);
|
|
15
|
-
_this.visible = (0, queries_1.findVisibleComponents)(root, switches);
|
|
16
|
-
});
|
|
17
|
-
events.subscribe('components:node-removed', function (event, data) {
|
|
18
|
-
var indexToRemove = _this.all.indexOf(data.node);
|
|
19
|
-
if (indexToRemove > -1) {
|
|
20
|
-
_this.all.splice(indexToRemove, 1);
|
|
21
|
-
}
|
|
22
|
-
indexToRemove = _this.visible.indexOf(data.node);
|
|
23
|
-
if (indexToRemove > -1) {
|
|
24
|
-
_this.visible.splice(indexToRemove, 1);
|
|
25
|
-
}
|
|
26
|
-
_this.visible = (0, queries_1.findVisibleComponents)(root, switches);
|
|
27
|
-
});
|
|
28
|
-
events.subscribe('components:node-switched', function (event, data) {
|
|
29
|
-
_this.visible = (0, queries_1.findVisibleComponents)(root, switches);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
ComponentNodeCollection.prototype.query = function (query) {
|
|
33
|
-
if (query === void 0) { query = {}; }
|
|
34
|
-
var nodes = [];
|
|
35
|
-
(0, queries_1.traverseComponents)(this.root, this.switches, function (node) {
|
|
36
|
-
var match = Object.keys(query).every(function (member) {
|
|
37
|
-
return query[member] === node[member];
|
|
38
|
-
});
|
|
39
|
-
if (match) {
|
|
40
|
-
nodes.push(node);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return nodes;
|
|
44
|
-
};
|
|
45
|
-
ComponentNodeCollection.prototype.get = function (id) {
|
|
46
|
-
return ((0, queries_1.findComponent)(this.root, this.switches, function (node) { return node.id === id; }) ||
|
|
47
|
-
this.detached.find(function (node) { return node.id === id; }));
|
|
48
|
-
};
|
|
49
|
-
return ComponentNodeCollection;
|
|
50
|
-
}());
|
|
51
|
-
exports.ComponentNodeCollection = ComponentNodeCollection;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComponentNode = void 0;
|
|
4
|
-
var widget_utilities_1 = require("@telia-ace/widget-utilities");
|
|
5
|
-
var ComponentNode = /** @class */ (function () {
|
|
6
|
-
function ComponentNode(events, type) {
|
|
7
|
-
this.events = events;
|
|
8
|
-
this.tags = [];
|
|
9
|
-
this.children = {};
|
|
10
|
-
this.changesets = [];
|
|
11
|
-
this.mountCount = 0;
|
|
12
|
-
this.id = (0, widget_utilities_1.uuid)();
|
|
13
|
-
this.type = type;
|
|
14
|
-
this.attributes = {
|
|
15
|
-
context: {},
|
|
16
|
-
properties: {},
|
|
17
|
-
layout: {},
|
|
18
|
-
tags: [],
|
|
19
|
-
};
|
|
20
|
-
// write default attributes
|
|
21
|
-
this.writeLayout({ size: 'full', indent: 0 });
|
|
22
|
-
}
|
|
23
|
-
ComponentNode.prototype.mount = function (viewOutletContainer, element) {
|
|
24
|
-
var _this = this;
|
|
25
|
-
var mountedNodes = viewOutletContainer.get('mounted-nodes');
|
|
26
|
-
if (!mountedNodes) {
|
|
27
|
-
mountedNodes = new Map();
|
|
28
|
-
viewOutletContainer.register('mounted-nodes', mountedNodes);
|
|
29
|
-
}
|
|
30
|
-
if (mountedNodes.has(this)) {
|
|
31
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
32
|
-
widget_utilities_1.Logger.error('Trying to mount an already mounted component node.', this);
|
|
33
|
-
}
|
|
34
|
-
return function () { };
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Dispatched when a node is mounted in a component.
|
|
38
|
-
* This happens once for every `ViewOutlet`.
|
|
39
|
-
*/
|
|
40
|
-
this.events.dispatch('components:node-mounted', { node: this });
|
|
41
|
-
if (this.mountCount === 0) {
|
|
42
|
-
this.mountCount = this.mountCount + 1;
|
|
43
|
-
/**
|
|
44
|
-
* Dispatched when a node is mounted in a component the first time.
|
|
45
|
-
*/
|
|
46
|
-
this.events.dispatch('components:node-enter', { node: this });
|
|
47
|
-
}
|
|
48
|
-
return function () {
|
|
49
|
-
mountedNodes.delete(_this);
|
|
50
|
-
_this.events.dispatch('components:node-unmounted', { node: _this });
|
|
51
|
-
_this.mountCount = _this.mountCount - 1;
|
|
52
|
-
if (_this.mountCount === 0) {
|
|
53
|
-
_this.events.dispatch('components:node-exit', { node: _this });
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
ComponentNode.prototype.appendChild = function (node, branch) {
|
|
58
|
-
if (branch === void 0) { branch = 'default'; }
|
|
59
|
-
if (node.parent) {
|
|
60
|
-
if (node.parent === this) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
node.parent.removeChild(node);
|
|
64
|
-
}
|
|
65
|
-
node.parent = this;
|
|
66
|
-
if (!this.children[branch]) {
|
|
67
|
-
this.children[branch] = [];
|
|
68
|
-
}
|
|
69
|
-
this.children[branch].push(node);
|
|
70
|
-
this.events.dispatch('components:node-appended', { node: node });
|
|
71
|
-
};
|
|
72
|
-
ComponentNode.prototype.prependChild = function (node, branch) {
|
|
73
|
-
if (branch === void 0) { branch = 'default'; }
|
|
74
|
-
if (node.parent) {
|
|
75
|
-
if (node.parent === this) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
node.parent.removeChild(node);
|
|
79
|
-
}
|
|
80
|
-
node.parent = this;
|
|
81
|
-
if (!this.children[branch]) {
|
|
82
|
-
this.children[branch] = [];
|
|
83
|
-
}
|
|
84
|
-
this.children[branch].unshift(node);
|
|
85
|
-
this.events.dispatch('components:node-appended', { node: node });
|
|
86
|
-
};
|
|
87
|
-
ComponentNode.prototype.touchProperties = function (properties, options, removable) {
|
|
88
|
-
var _this = this;
|
|
89
|
-
if (options === void 0) { options = {}; }
|
|
90
|
-
var attributes = { properties: properties };
|
|
91
|
-
var changeset = [attributes, options];
|
|
92
|
-
this.changesets.push(changeset);
|
|
93
|
-
this.events.dispatch('components:set-properties', { node: this });
|
|
94
|
-
return function () {
|
|
95
|
-
if (removable) {
|
|
96
|
-
var indexToRemove = _this.changesets.indexOf(changeset);
|
|
97
|
-
if (indexToRemove > -1) {
|
|
98
|
-
_this.changesets.splice(indexToRemove, 1);
|
|
99
|
-
_this.events.dispatch('components:set-properties', { node: _this });
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
ComponentNode.prototype.writeProperties = function (properties, options, removable) {
|
|
105
|
-
var _this = this;
|
|
106
|
-
if (options === void 0) { options = {}; }
|
|
107
|
-
var attributes = { properties: properties };
|
|
108
|
-
var changeset = [attributes, options];
|
|
109
|
-
this.changesets.push(changeset);
|
|
110
|
-
this.events.dispatch('components:set-properties', { node: this });
|
|
111
|
-
return function () {
|
|
112
|
-
if (removable) {
|
|
113
|
-
var indexToRemove = _this.changesets.indexOf(changeset);
|
|
114
|
-
if (indexToRemove > -1) {
|
|
115
|
-
_this.changesets.splice(indexToRemove, 1);
|
|
116
|
-
_this.events.dispatch('components:set-properties', { node: _this });
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
ComponentNode.prototype.writeLayout = function (layout, options, removable) {
|
|
122
|
-
var _this = this;
|
|
123
|
-
if (options === void 0) { options = {}; }
|
|
124
|
-
var attributes = { layout: layout };
|
|
125
|
-
var changeset = [attributes, options];
|
|
126
|
-
this.changesets.push(changeset);
|
|
127
|
-
this.events.dispatch('components:set-layout', { node: this });
|
|
128
|
-
return function () {
|
|
129
|
-
if (!removable) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
var indexToRemove = _this.changesets.indexOf(changeset);
|
|
133
|
-
if (indexToRemove > -1) {
|
|
134
|
-
_this.changesets.splice(indexToRemove, 1);
|
|
135
|
-
_this.events.dispatch('components:set-layout', { node: _this });
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
};
|
|
139
|
-
ComponentNode.prototype.writeContext = function (context, options, removable) {
|
|
140
|
-
var _this = this;
|
|
141
|
-
if (options === void 0) { options = {}; }
|
|
142
|
-
var attributes = { context: context };
|
|
143
|
-
var changeset = [attributes, options];
|
|
144
|
-
this.changesets.push(changeset);
|
|
145
|
-
this.events.dispatch('components:set-context', { node: this });
|
|
146
|
-
return function () {
|
|
147
|
-
if (!removable) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
var indexToRemove = _this.changesets.indexOf(changeset);
|
|
151
|
-
if (indexToRemove > -1) {
|
|
152
|
-
_this.changesets.splice(indexToRemove, 1);
|
|
153
|
-
_this.events.dispatch('components:set-context', { node: _this });
|
|
154
|
-
}
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
ComponentNode.prototype.getChildren = function (branch) {
|
|
158
|
-
if (branch === void 0) { branch = 'default'; }
|
|
159
|
-
var children = this.children[branch] || [];
|
|
160
|
-
return children.reduce(function (acc, node, i) {
|
|
161
|
-
var _a = node.attributes.layout.order, index = _a === void 0 ? i : _a;
|
|
162
|
-
if (!acc[index]) {
|
|
163
|
-
acc[index] = node;
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
acc.splice(index, 0, node);
|
|
167
|
-
}
|
|
168
|
-
return acc;
|
|
169
|
-
}, Array(children.length));
|
|
170
|
-
};
|
|
171
|
-
ComponentNode.prototype.remove = function () {
|
|
172
|
-
if (this.parent) {
|
|
173
|
-
this.parent.removeChild(this);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
ComponentNode.prototype.removeChild = function (node) {
|
|
177
|
-
var _this = this;
|
|
178
|
-
Object.keys(this.children).forEach(function (branch) {
|
|
179
|
-
var children = _this.children[branch];
|
|
180
|
-
var indexToRemove = children.indexOf(node);
|
|
181
|
-
if (indexToRemove > -1) {
|
|
182
|
-
children.splice(indexToRemove, 1);
|
|
183
|
-
_this.events.dispatch('components:node-removed', { node: node, parentNode: _this });
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
delete node.parent;
|
|
187
|
-
};
|
|
188
|
-
return ComponentNode;
|
|
189
|
-
}());
|
|
190
|
-
exports.ComponentNode = ComponentNode;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Container, EventManager, Widget } from '@webprovisions/platform';
|
|
2
|
-
import { ActionsController, ActionsState } from './actions-controller';
|
|
3
|
-
import { ChangesetProvider } from './changeset-provider';
|
|
4
|
-
import { ChangesetOptions, ComponentNode, ComponentNodeSettings, RemoveChangeset } from './component-node';
|
|
5
|
-
import { ComponentNodeCollection } from './component-node-collection';
|
|
6
|
-
import { ComponentQuery } from './component-query';
|
|
7
|
-
import { CustomHandlerCallback } from './custom-component-handler';
|
|
8
|
-
export declare type MergeOptions = {
|
|
9
|
-
breakpoints?: string[];
|
|
10
|
-
};
|
|
11
|
-
export declare type SwitchMap = {
|
|
12
|
-
[id: string]: string;
|
|
13
|
-
};
|
|
14
|
-
export declare type ChangesetData = {
|
|
15
|
-
key?: string;
|
|
16
|
-
target: ComponentQuery;
|
|
17
|
-
attributes: Partial<ComponentNodeSettings>;
|
|
18
|
-
options?: ChangesetOptions;
|
|
19
|
-
removable?: boolean;
|
|
20
|
-
provider?: string;
|
|
21
|
-
};
|
|
22
|
-
export declare class ComponentPlatform {
|
|
23
|
-
private providers;
|
|
24
|
-
events: EventManager;
|
|
25
|
-
breakpoints: string[];
|
|
26
|
-
nodes: ComponentNodeCollection;
|
|
27
|
-
actionsState: ActionsState;
|
|
28
|
-
private switches;
|
|
29
|
-
private changesets;
|
|
30
|
-
private subscriptions;
|
|
31
|
-
private processNode;
|
|
32
|
-
private customComponentHandler;
|
|
33
|
-
constructor(widget: Widget, providers?: {
|
|
34
|
-
[key: string]: ChangesetProvider;
|
|
35
|
-
});
|
|
36
|
-
static getInstance(container: Container): Promise<ComponentPlatform>;
|
|
37
|
-
addBreakpoint(name: string): void;
|
|
38
|
-
removeBreakpoint(name: string): void;
|
|
39
|
-
setSwitch(node: ComponentNode, branch: string): void;
|
|
40
|
-
getBranch(node: ComponentNode): string | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a `ComponentNode` of the specified type.
|
|
43
|
-
* @param type Type of node.
|
|
44
|
-
*/
|
|
45
|
-
createNode(type: string, options?: {
|
|
46
|
-
detached?: boolean;
|
|
47
|
-
}): ComponentNode;
|
|
48
|
-
components(): ComponentQuery;
|
|
49
|
-
actions(target: ComponentQuery, ns: string): ActionsController;
|
|
50
|
-
write(data: ChangesetData): RemoveChangeset;
|
|
51
|
-
addComponentHandler(definitionType: string, fn: CustomHandlerCallback): void;
|
|
52
|
-
getComponentHandler(definitionType: string): CustomHandlerCallback | undefined;
|
|
53
|
-
dispose(): void;
|
|
54
|
-
}
|