@telia-ace/widget-core 1.0.1 → 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.
Files changed (89) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +3 -3
  3. package/{lib-esm → dist}/action-resolver.d.ts +0 -0
  4. package/{lib-esm → dist}/component-platform/actions-controller.d.ts +0 -0
  5. package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +0 -0
  6. package/dist/component-platform/component-configuration-api.d.ts +2 -0
  7. package/{lib-esm → dist}/component-platform/component-controller.d.ts +0 -0
  8. package/{lib-esm → dist}/component-platform/component-node-collection.d.ts +0 -0
  9. package/{lib-esm → dist}/component-platform/component-node.d.ts +0 -0
  10. package/{lib → dist}/component-platform/component-platform.d.ts +4 -0
  11. package/{lib-esm → dist}/component-platform/component-query.d.ts +0 -0
  12. package/dist/component-platform/create-component-model.d.ts +36 -0
  13. package/dist/component-platform/custom-component-handler.d.ts +21 -0
  14. package/{lib-esm → dist}/component-platform/descriptor.d.ts +0 -0
  15. package/{lib-esm → dist}/component-platform/extend-component.d.ts +0 -0
  16. package/{lib → dist}/component-platform/index.d.ts +3 -1
  17. package/{lib-esm → dist}/component-platform/queries.d.ts +0 -0
  18. package/{lib-esm → dist}/component-platform/state-processor.d.ts +0 -0
  19. package/{lib-esm → dist}/component-resolver.d.ts +0 -0
  20. package/{lib-esm → dist}/event-subscriber.d.ts +0 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.js +1047 -0
  23. package/dist/index.js.map +1 -0
  24. package/{lib-esm → dist}/types/configuration.d.ts +0 -0
  25. package/{lib-esm → dist}/types/index.d.ts +0 -0
  26. package/{lib-esm → dist}/types/ui.d.ts +0 -1
  27. package/package.json +9 -9
  28. package/lib/action-resolver.d.ts +0 -8
  29. package/lib/action-resolver.js +0 -19
  30. package/lib/component-platform/actions-controller.d.ts +0 -40
  31. package/lib/component-platform/actions-controller.js +0 -119
  32. package/lib/component-platform/changeset-provider.d.ts +0 -8
  33. package/lib/component-platform/changeset-provider.js +0 -2
  34. package/lib/component-platform/component-controller.d.ts +0 -38
  35. package/lib/component-platform/component-controller.js +0 -119
  36. package/lib/component-platform/component-node-collection.d.ts +0 -18
  37. package/lib/component-platform/component-node-collection.js +0 -51
  38. package/lib/component-platform/component-node.d.ts +0 -63
  39. package/lib/component-platform/component-node.js +0 -190
  40. package/lib/component-platform/component-platform.js +0 -209
  41. package/lib/component-platform/component-query.d.ts +0 -16
  42. package/lib/component-platform/component-query.js +0 -35
  43. package/lib/component-platform/create-component-model.d.ts +0 -19
  44. package/lib/component-platform/create-component-model.js +0 -126
  45. package/lib/component-platform/descriptor.d.ts +0 -8
  46. package/lib/component-platform/descriptor.js +0 -12
  47. package/lib/component-platform/extend-component.d.ts +0 -8
  48. package/lib/component-platform/extend-component.js +0 -57
  49. package/lib/component-platform/index.js +0 -24
  50. package/lib/component-platform/queries.d.ts +0 -6
  51. package/lib/component-platform/queries.js +0 -53
  52. package/lib/component-platform/state-processor.d.ts +0 -12
  53. package/lib/component-platform/state-processor.js +0 -209
  54. package/lib/component-resolver.d.ts +0 -14
  55. package/lib/component-resolver.js +0 -49
  56. package/lib/event-subscriber.d.ts +0 -7
  57. package/lib/event-subscriber.js +0 -22
  58. package/lib/index.d.ts +0 -8
  59. package/lib/index.js +0 -39
  60. package/lib/types/configuration.d.ts +0 -86
  61. package/lib/types/configuration.js +0 -16
  62. package/lib/types/index.d.ts +0 -2
  63. package/lib/types/index.js +0 -18
  64. package/lib/types/ui.d.ts +0 -55
  65. package/lib/types/ui.js +0 -2
  66. package/lib-esm/action-resolver.js +0 -17
  67. package/lib-esm/component-platform/actions-controller.js +0 -116
  68. package/lib-esm/component-platform/changeset-provider.js +0 -1
  69. package/lib-esm/component-platform/component-controller.js +0 -116
  70. package/lib-esm/component-platform/component-node-collection.js +0 -48
  71. package/lib-esm/component-platform/component-node.js +0 -187
  72. package/lib-esm/component-platform/component-platform.d.ts +0 -50
  73. package/lib-esm/component-platform/component-platform.js +0 -206
  74. package/lib-esm/component-platform/component-query.js +0 -32
  75. package/lib-esm/component-platform/create-component-model.d.ts +0 -19
  76. package/lib-esm/component-platform/create-component-model.js +0 -121
  77. package/lib-esm/component-platform/descriptor.js +0 -8
  78. package/lib-esm/component-platform/extend-component.js +0 -53
  79. package/lib-esm/component-platform/index.d.ts +0 -16
  80. package/lib-esm/component-platform/index.js +0 -9
  81. package/lib-esm/component-platform/queries.js +0 -46
  82. package/lib-esm/component-platform/state-processor.js +0 -205
  83. package/lib-esm/component-resolver.js +0 -47
  84. package/lib-esm/event-subscriber.js +0 -18
  85. package/lib-esm/index.d.ts +0 -8
  86. package/lib-esm/index.js +0 -5
  87. package/lib-esm/types/configuration.js +0 -13
  88. package/lib-esm/types/index.js +0 -2
  89. package/lib-esm/types/ui.js +0 -1
package/lib/index.js DELETED
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.createEventSubscriber = exports.ComponentResolver = exports.traverseComponents = exports.findVisibleComponents = exports.findComponent = exports.extendComponent = exports.createComponentModel = exports.ComponentQuery = exports.ComponentPlatform = exports.ComponentNodeController = exports.ComponentNode = exports.asDescriptor = exports.ActionsController = exports.ActionResolver = void 0;
21
- var action_resolver_1 = require("./action-resolver");
22
- Object.defineProperty(exports, "ActionResolver", { enumerable: true, get: function () { return __importDefault(action_resolver_1).default; } });
23
- var component_platform_1 = require("./component-platform");
24
- Object.defineProperty(exports, "ActionsController", { enumerable: true, get: function () { return component_platform_1.ActionsController; } });
25
- Object.defineProperty(exports, "asDescriptor", { enumerable: true, get: function () { return component_platform_1.asDescriptor; } });
26
- Object.defineProperty(exports, "ComponentNode", { enumerable: true, get: function () { return component_platform_1.ComponentNode; } });
27
- Object.defineProperty(exports, "ComponentNodeController", { enumerable: true, get: function () { return component_platform_1.ComponentNodeController; } });
28
- Object.defineProperty(exports, "ComponentPlatform", { enumerable: true, get: function () { return component_platform_1.ComponentPlatform; } });
29
- Object.defineProperty(exports, "ComponentQuery", { enumerable: true, get: function () { return component_platform_1.ComponentQuery; } });
30
- Object.defineProperty(exports, "createComponentModel", { enumerable: true, get: function () { return component_platform_1.createComponentModel; } });
31
- Object.defineProperty(exports, "extendComponent", { enumerable: true, get: function () { return component_platform_1.extendComponent; } });
32
- Object.defineProperty(exports, "findComponent", { enumerable: true, get: function () { return component_platform_1.findComponent; } });
33
- Object.defineProperty(exports, "findVisibleComponents", { enumerable: true, get: function () { return component_platform_1.findVisibleComponents; } });
34
- Object.defineProperty(exports, "traverseComponents", { enumerable: true, get: function () { return component_platform_1.traverseComponents; } });
35
- var component_resolver_1 = require("./component-resolver");
36
- Object.defineProperty(exports, "ComponentResolver", { enumerable: true, get: function () { return __importDefault(component_resolver_1).default; } });
37
- var event_subscriber_1 = require("./event-subscriber");
38
- Object.defineProperty(exports, "createEventSubscriber", { enumerable: true, get: function () { return event_subscriber_1.createEventSubscriber; } });
39
- __exportStar(require("./types"), exports);
@@ -1,86 +0,0 @@
1
- import { ComponentNodeLayout } from '../component-platform';
2
- export declare type ComponentSettings = {
3
- type: string;
4
- context?: Context;
5
- properties?: Properties;
6
- layout?: ComponentNodeLayout;
7
- tags?: string[];
8
- children?: ComponentReference[];
9
- };
10
- declare enum HistoryMode {
11
- scopedHash = "scopedHash",
12
- hash = "hash",
13
- browser = "browser",
14
- memory = "memory"
15
- }
16
- export declare type RoutingSettings = {
17
- initialPath: string;
18
- mode: HistoryMode;
19
- basePath?: string;
20
- };
21
- export declare type ComponentReference = string | [string, ...ComponentReferenceOverride[]];
22
- export declare type Properties = {
23
- [key: string]: any;
24
- };
25
- export declare type Context = {
26
- [key: string]: any;
27
- };
28
- export declare type ViewDefinition = {
29
- path: string | string[];
30
- entry: ComponentReference;
31
- };
32
- export declare type Breakpoints = 'all' | string[];
33
- export declare type ComponentReferenceOverride = {
34
- breakpoints?: Breakpoints;
35
- size?: number | 'full' | 'none';
36
- indent?: number;
37
- tags?: string[];
38
- context?: Context;
39
- properties?: Properties;
40
- };
41
- export declare type ComponentDefinitionMap = {
42
- [name: string]: ComponentSettings;
43
- };
44
- export declare type WidgetSettings = {
45
- data: {
46
- projection: string;
47
- site?: 'current' | 'referrer';
48
- forceHttps?: boolean;
49
- };
50
- components: ComponentDefinitionMap;
51
- entry: ComponentReference;
52
- breakpoints: {
53
- [name: string]: string;
54
- };
55
- routing: RoutingSettings;
56
- views: {
57
- [name: string]: ViewDefinition;
58
- };
59
- integrationResources: {
60
- path: string;
61
- mediaQueriesSupported: boolean;
62
- }[];
63
- trigger?: {
64
- symbol?: Symbol;
65
- label?: string;
66
- action?: string;
67
- };
68
- activate?: boolean | null;
69
- plugins?: {
70
- [key: string]: any;
71
- };
72
- };
73
- export declare type MinMax = {
74
- min: string;
75
- max: string;
76
- };
77
- declare type Symbol = {
78
- type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;
79
- content: string;
80
- };
81
- export declare enum WidgetRenderState {
82
- open = "open",
83
- closed = "closed",
84
- hidden = "hidden"
85
- }
86
- export {};
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WidgetRenderState = void 0;
4
- var HistoryMode;
5
- (function (HistoryMode) {
6
- HistoryMode["scopedHash"] = "scopedHash";
7
- HistoryMode["hash"] = "hash";
8
- HistoryMode["browser"] = "browser";
9
- HistoryMode["memory"] = "memory";
10
- })(HistoryMode || (HistoryMode = {}));
11
- var WidgetRenderState;
12
- (function (WidgetRenderState) {
13
- WidgetRenderState["open"] = "open";
14
- WidgetRenderState["closed"] = "closed";
15
- WidgetRenderState["hidden"] = "hidden";
16
- })(WidgetRenderState = exports.WidgetRenderState || (exports.WidgetRenderState = {}));
@@ -1,2 +0,0 @@
1
- export * from './configuration';
2
- export * from './ui';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./configuration"), exports);
18
- __exportStar(require("./ui"), exports);
package/lib/types/ui.d.ts DELETED
@@ -1,55 +0,0 @@
1
- /// <reference types="react" />
2
- export declare type Theme = {
3
- gap: string;
4
- accessibility: {
5
- isTabbing: boolean;
6
- border: string;
7
- colors: {
8
- inactiveText: string;
9
- activeText: string;
10
- };
11
- };
12
- border: string;
13
- borderRadius: string;
14
- boxShadow: string;
15
- inputBorder: string;
16
- colors: {
17
- warning: string;
18
- accent: string;
19
- link: string;
20
- primary: string;
21
- text: string;
22
- textLight: string;
23
- };
24
- fonts: {
25
- type: string;
26
- base: string;
27
- small: string;
28
- normal: string;
29
- medium: string;
30
- large: string;
31
- huge: string;
32
- };
33
- sizes: {
34
- cardinal: number;
35
- small: string;
36
- normal: string;
37
- medium: string;
38
- large: string;
39
- };
40
- typographyVariantMapping?: {
41
- h1: 'h1';
42
- h2: 'h2';
43
- h3: 'h3';
44
- h4: 'h4';
45
- h5: 'h5';
46
- h6: 'h6';
47
- p: 'p';
48
- span: 'span';
49
- };
50
- };
51
- export declare type ModeWrapper = React.FC<{
52
- className: string;
53
- route: string;
54
- isTabbing: boolean;
55
- }>;
package/lib/types/ui.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- var ActionResolver = /** @class */ (function () {
2
- function ActionResolver(container) {
3
- var events = container.get('$widget').events;
4
- this.events = events.createChild(this);
5
- }
6
- ActionResolver.prototype.action = function (target, action, value) {
7
- this.events.dispatch('data:action', { action: action, value: value, target: target }, { bubbles: true });
8
- };
9
- ActionResolver.prototype.subscribe = function (origin, fn) {
10
- return this.events.subscribe('data:action', function (e, _a) {
11
- var action = _a.action, value = _a.value, target = _a.target;
12
- return origin === target && fn(origin, action, value);
13
- });
14
- };
15
- return ActionResolver;
16
- }());
17
- export default ActionResolver;
@@ -1,116 +0,0 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- import { ComponentNodeController } from './component-controller';
13
- var executeActionListeners = function (listeners, data, controller) {
14
- var stack = listeners.concat();
15
- var dispatch = function (data, globalOptions, controller) {
16
- var cancelled = true;
17
- if (stack.length) {
18
- var handler = stack.shift();
19
- var next = function (data, options) {
20
- cancelled = false;
21
- return dispatch(data, Object.assign({}, globalOptions, options), controller);
22
- };
23
- return Promise.resolve(handler(data, next, controller)).then(function (result) { return (__assign(__assign({}, result), { cancelled: cancelled })); });
24
- }
25
- return Promise.resolve({ data: data, cancelled: false, options: globalOptions });
26
- };
27
- return dispatch(data, {}, controller);
28
- };
29
- var ActionsController = /** @class */ (function () {
30
- function ActionsController(platform, target, ns) {
31
- this.platform = platform;
32
- this.target = target;
33
- this.ns = ns;
34
- this.subscriptions = [];
35
- this.create = this.create.bind(this);
36
- }
37
- ActionsController.prototype.create = function (key, fn) {
38
- var _this = this;
39
- if (fn === void 0) { fn = function () { }; }
40
- var handler = {
41
- key: key,
42
- fn: fn,
43
- target: this.target,
44
- ns: this.ns,
45
- };
46
- this.platform.actionsState.handlers.push(handler);
47
- var subscription = function () {
48
- var index = _this.platform.actionsState.handlers.indexOf(handler);
49
- if (index > -1) {
50
- _this.platform.actionsState.handlers.splice(index, 1);
51
- }
52
- };
53
- this.subscriptions.push(subscription);
54
- return subscription;
55
- };
56
- ActionsController.prototype.dispatch = function (key, data) {
57
- var _this = this;
58
- var instances = this.platform.nodes.all.concat(this.platform.nodes.detached);
59
- var output = {};
60
- // handlers matching the specified pattern.
61
- var handlers = this.platform.actionsState.handlers.filter(function (handler) { return handler.key === key && (!handler.ns || !_this.ns || handler.ns === _this.ns); });
62
- return Promise.all(handlers.map(function (handler) {
63
- // select all matching instances for this particular
64
- // handler (a handler can be mapped to many instances)
65
- var matchedInstances = instances.filter(function (instance) { return handler.target.match(instance) && _this.target.match(instance); });
66
- // execute watchers for each matched instance
67
- var watchers = _this.platform.actionsState.watchers
68
- .filter(function (watcher) {
69
- return (watcher.key === key &&
70
- (!watcher.ns || !_this.ns || watcher.ns === _this.ns) &&
71
- matchedInstances.some(function (instance) { return watcher.target.match(instance); }));
72
- })
73
- .map(function (watcher) { return watcher.fn; });
74
- // execute watchers and handler for each instance
75
- return Promise.all(matchedInstances.map(function (node) {
76
- var controller = new ComponentNodeController(_this.platform, node, _this.ns);
77
- return executeActionListeners(watchers, data, controller).then(function (input) {
78
- var _a = input.data, data = _a === void 0 ? {} : _a, options = input.options, cancelled = input.cancelled;
79
- return Promise.resolve(cancelled ? {} : handler.fn(data, options, controller)).then(function (handlerResponse) {
80
- output[node.id] = handlerResponse;
81
- });
82
- });
83
- }));
84
- })).then(function () { return output; });
85
- };
86
- ActionsController.prototype.watch = function (key, fn) {
87
- var _this = this;
88
- var parsedKey = key;
89
- var parsedNs = this.ns;
90
- var sections = key.split('.');
91
- if (sections.length > 1) {
92
- parsedNs = sections[0];
93
- parsedKey = sections.splice(1).join('.');
94
- }
95
- var watcher = {
96
- fn: fn,
97
- target: this.target,
98
- key: parsedKey,
99
- ns: parsedNs,
100
- };
101
- this.platform.actionsState.watchers.push(watcher);
102
- var subscription = function () {
103
- var index = _this.platform.actionsState.watchers.indexOf(watcher);
104
- if (index > -1) {
105
- _this.platform.actionsState.watchers.splice(index, 1);
106
- }
107
- };
108
- this.subscriptions.push(subscription);
109
- return subscription;
110
- };
111
- ActionsController.prototype.dispose = function () {
112
- this.subscriptions.forEach(function (unsubscribe) { return unsubscribe(); });
113
- };
114
- return ActionsController;
115
- }());
116
- export { ActionsController };
@@ -1 +0,0 @@
1
- export {};
@@ -1,116 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- import { createEventSubscriber } from '../event-subscriber';
18
- import { ActionsController } from './actions-controller';
19
- import { ComponentQuery } from './component-query';
20
- var ComponentNodeController = /** @class */ (function () {
21
- function ComponentNodeController(platform, node, ns) {
22
- this.platform = platform;
23
- this.node = node;
24
- this.actions = new ActionsController(platform, new ComponentQuery(platform).withId(node.id), ns);
25
- var _a = __read(createEventSubscriber(this.platform.events), 2), subscribe = _a[0], unsubscribe = _a[1];
26
- this.subscribe = subscribe;
27
- this.unsubscribe = unsubscribe;
28
- }
29
- ComponentNodeController.prototype.properties = function (updated) {
30
- if (updated) {
31
- this.node.touchProperties(function (properties) { return updated(properties); });
32
- }
33
- return this.node.attributes.properties;
34
- };
35
- ComponentNodeController.prototype.context = function (updated) {
36
- var _this = this;
37
- if (updated) {
38
- this.subscribe('components:context-changed', function (event, _a) {
39
- var node = _a.node;
40
- if (node === _this.node) {
41
- updated(_this.node.attributes.context);
42
- }
43
- });
44
- }
45
- return this.node.attributes.context;
46
- };
47
- ComponentNodeController.prototype.layout = function (updated) {
48
- var _this = this;
49
- if (updated) {
50
- this.subscribe('components:layout-changed', function (event, _a) {
51
- var node = _a.node;
52
- if (node === _this.node) {
53
- updated(_this.node.attributes.layout);
54
- }
55
- });
56
- }
57
- return this.node.attributes.layout;
58
- };
59
- ComponentNodeController.prototype.writeProperties = function (properties, options) {
60
- this.node.writeProperties(properties, options);
61
- };
62
- ComponentNodeController.prototype.writeContext = function (context, options) {
63
- this.node.writeProperties(context, options);
64
- };
65
- ComponentNodeController.prototype.writeLayout = function (layout, options) {
66
- this.node.writeLayout(layout, options);
67
- };
68
- ComponentNodeController.prototype.dispose = function () {
69
- this.unsubscribe();
70
- this.actions.dispose();
71
- };
72
- return ComponentNodeController;
73
- }());
74
- export { ComponentNodeController };
75
- var AbstractComponentController = /** @class */ (function () {
76
- function AbstractComponentController(platform, target, clearOnDispose) {
77
- if (clearOnDispose === void 0) { clearOnDispose = true; }
78
- this.platform = platform;
79
- this.target = target;
80
- this.clearOnDispose = clearOnDispose;
81
- this.removes = [];
82
- this.actions = new ActionsController(this.platform, this.target);
83
- }
84
- AbstractComponentController.prototype.writeProperties = function (properties, options) {
85
- this.removes.push(this.platform.write({
86
- options: options,
87
- attributes: { properties: properties },
88
- target: this.target,
89
- removable: this.clearOnDispose,
90
- }));
91
- };
92
- AbstractComponentController.prototype.writeContext = function (context, options) {
93
- this.removes.push(this.platform.write({
94
- options: options,
95
- attributes: { context: context },
96
- target: this.target,
97
- removable: this.clearOnDispose,
98
- }));
99
- };
100
- AbstractComponentController.prototype.writeLayout = function (layout, options) {
101
- this.removes.push(this.platform.write({
102
- options: options,
103
- attributes: { layout: layout },
104
- target: this.target,
105
- removable: this.clearOnDispose,
106
- }));
107
- };
108
- AbstractComponentController.prototype.dispose = function () {
109
- this.removes.forEach(function (remove) {
110
- remove();
111
- });
112
- this.actions.dispose();
113
- };
114
- return AbstractComponentController;
115
- }());
116
- export { AbstractComponentController };
@@ -1,48 +0,0 @@
1
- import { findComponent, findVisibleComponents, traverseComponents } from './queries';
2
- var ComponentNodeCollection = /** @class */ (function () {
3
- function ComponentNodeCollection(root, switches, events) {
4
- var _this = this;
5
- this.root = root;
6
- this.switches = switches;
7
- this.all = [];
8
- this.visible = [];
9
- this.detached = [];
10
- events.subscribe('components:node-appended', function (event, data) {
11
- _this.all.push(data.node);
12
- _this.visible = findVisibleComponents(root, switches);
13
- });
14
- events.subscribe('components:node-removed', function (event, data) {
15
- var indexToRemove = _this.all.indexOf(data.node);
16
- if (indexToRemove > -1) {
17
- _this.all.splice(indexToRemove, 1);
18
- }
19
- indexToRemove = _this.visible.indexOf(data.node);
20
- if (indexToRemove > -1) {
21
- _this.visible.splice(indexToRemove, 1);
22
- }
23
- _this.visible = findVisibleComponents(root, switches);
24
- });
25
- events.subscribe('components:node-switched', function (event, data) {
26
- _this.visible = findVisibleComponents(root, switches);
27
- });
28
- }
29
- ComponentNodeCollection.prototype.query = function (query) {
30
- if (query === void 0) { query = {}; }
31
- var nodes = [];
32
- traverseComponents(this.root, this.switches, function (node) {
33
- var match = Object.keys(query).every(function (member) {
34
- return query[member] === node[member];
35
- });
36
- if (match) {
37
- nodes.push(node);
38
- }
39
- });
40
- return nodes;
41
- };
42
- ComponentNodeCollection.prototype.get = function (id) {
43
- return (findComponent(this.root, this.switches, function (node) { return node.id === id; }) ||
44
- this.detached.find(function (node) { return node.id === id; }));
45
- };
46
- return ComponentNodeCollection;
47
- }());
48
- export { ComponentNodeCollection };