@telia-ace/widget-core 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib-esm → dist}/action-resolver.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/actions-controller.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-configuration-api.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-controller.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-node-collection.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-node.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-platform.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-query.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/create-component-model.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/custom-component-handler.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/descriptor.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/extend-component.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/index.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/queries.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/state-processor.d.ts +0 -0
- package/{lib-esm → dist}/component-resolver.d.ts +0 -0
- package/{lib-esm → dist}/event-subscriber.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +1047 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/types/configuration.d.ts +0 -0
- package/{lib-esm → dist}/types/index.d.ts +0 -0
- package/{lib-esm → dist}/types/ui.d.ts +0 -0
- package/package.json +9 -9
- package/lib/action-resolver.d.ts +0 -8
- package/lib/action-resolver.js +0 -19
- package/lib/component-platform/actions-controller.d.ts +0 -40
- 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.d.ts +0 -18
- package/lib/component-platform/component-node-collection.js +0 -51
- package/lib/component-platform/component-node.d.ts +0 -63
- 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.d.ts +0 -16
- package/lib/component-platform/component-query.js +0 -35
- package/lib/component-platform/create-component-model.d.ts +0 -36
- 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.d.ts +0 -18
- 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.d.ts +0 -12
- 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.d.ts +0 -8
- 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.d.ts +0 -2
- 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.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.js +0 -48
- 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.js +0 -32
- 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.js +0 -10
- package/lib-esm/component-platform/queries.js +0 -46
- 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.js +0 -5
- package/lib-esm/types/configuration.js +0 -13
- 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 __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,18 +0,0 @@
|
|
|
1
|
-
import { EventManager } from '@webprovisions/platform';
|
|
2
|
-
import { ComponentNode } from './component-node';
|
|
3
|
-
import { SwitchMap } from './component-platform';
|
|
4
|
-
export declare type QueryDescriptor = {
|
|
5
|
-
id?: string;
|
|
6
|
-
type?: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare class ComponentNodeCollection {
|
|
10
|
-
root: ComponentNode;
|
|
11
|
-
private switches;
|
|
12
|
-
all: ComponentNode[];
|
|
13
|
-
visible: ComponentNode[];
|
|
14
|
-
detached: ComponentNode[];
|
|
15
|
-
constructor(root: ComponentNode, switches: SwitchMap, events: EventManager);
|
|
16
|
-
query(query?: QueryDescriptor): ComponentNode[];
|
|
17
|
-
get(id: string): ComponentNode | undefined;
|
|
18
|
-
}
|
|
@@ -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,63 +0,0 @@
|
|
|
1
|
-
import { Container, EventManager } from '@webprovisions/platform';
|
|
2
|
-
import { Breakpoints } from '../types';
|
|
3
|
-
export declare type ComponentNodeEventData = {
|
|
4
|
-
node: ComponentNode;
|
|
5
|
-
};
|
|
6
|
-
export declare type RemoveChangeset = () => void;
|
|
7
|
-
export declare type ComponentNodeAttributes = {
|
|
8
|
-
tags: string[];
|
|
9
|
-
properties: ComponentNodeProperties;
|
|
10
|
-
context: ComponentNodeContext;
|
|
11
|
-
layout: ComponentNodeLayout;
|
|
12
|
-
};
|
|
13
|
-
export declare type ResolveComponentNodeProperties = (properties: ComponentNodeProperties) => Partial<ComponentNodeProperties> | void;
|
|
14
|
-
export declare type ResolveComponentNodeContext = (context: ComponentNodeContext) => Partial<ComponentNodeContext>;
|
|
15
|
-
export declare type ResolveComponentNodeLayout = (layout: ComponentNodeLayout) => Partial<ComponentNodeLayout>;
|
|
16
|
-
export declare type ComponentNodeSettings = {
|
|
17
|
-
tags?: string[];
|
|
18
|
-
properties?: ComponentNodeProperties | ResolveComponentNodeProperties;
|
|
19
|
-
context?: ComponentNodeContext | ResolveComponentNodeContext;
|
|
20
|
-
layout?: ComponentNodeLayout | ResolveComponentNodeLayout;
|
|
21
|
-
};
|
|
22
|
-
export declare type ComponentNodeProperties = {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
};
|
|
25
|
-
export declare type ComponentNodeContext = {
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
};
|
|
28
|
-
export declare type ComponentNodeLayout = {
|
|
29
|
-
size?: Size;
|
|
30
|
-
indent?: number;
|
|
31
|
-
order?: number;
|
|
32
|
-
};
|
|
33
|
-
export declare type Size = number | 'full' | 'none';
|
|
34
|
-
export declare type UnmountComponentNode = () => void;
|
|
35
|
-
export declare type ChangesetOptions = {
|
|
36
|
-
breakpoints?: Breakpoints;
|
|
37
|
-
};
|
|
38
|
-
export declare type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];
|
|
39
|
-
export declare class ComponentNode {
|
|
40
|
-
private events;
|
|
41
|
-
id: string;
|
|
42
|
-
type: string;
|
|
43
|
-
name?: string;
|
|
44
|
-
parent?: ComponentNode;
|
|
45
|
-
tags: string[];
|
|
46
|
-
children: {
|
|
47
|
-
[key: string]: ComponentNode[];
|
|
48
|
-
};
|
|
49
|
-
changesets: Changeset[];
|
|
50
|
-
attributes: ComponentNodeAttributes;
|
|
51
|
-
private mountCount;
|
|
52
|
-
constructor(events: EventManager, type: string);
|
|
53
|
-
mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode;
|
|
54
|
-
appendChild(node: ComponentNode, branch?: string): void;
|
|
55
|
-
prependChild(node: ComponentNode, branch?: string): void;
|
|
56
|
-
touchProperties(properties: ResolveComponentNodeProperties, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
57
|
-
writeProperties(properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
58
|
-
writeLayout(layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
59
|
-
writeContext(context: Partial<ComponentNodeContext> | ResolveComponentNodeContext, options?: ChangesetOptions, removable?: boolean): RemoveChangeset;
|
|
60
|
-
getChildren(branch?: string): ComponentNode[];
|
|
61
|
-
remove(): void;
|
|
62
|
-
removeChild(node: ComponentNode): void;
|
|
63
|
-
}
|
|
@@ -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
|
-
}
|