UNPKG

1.78 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.Controller = void 0;
4var util_1 = require("@antv/util");
5/**
6 * Component Controller 规范需要定义的基类
7 * 1. 规范的 option 输入
8 * 2. 统一的信息获取 API
9 * 3. 明确定义的组件事件(名称、数据)
10 */
11var Controller = /** @class */ (function () {
12 function Controller(view) {
13 /** 是否可见 */
14 this.visible = true;
15 /** 所有的 component */
16 this.components = [];
17 this.view = view;
18 }
19 /**
20 * clear
21 * @param includeOption 是否清空 option 配置项(used in annotation)
22 */
23 Controller.prototype.clear = function (includeOption) {
24 // destroy all components
25 (0, util_1.each)(this.components, function (co) {
26 co.component.destroy();
27 });
28 // clear all component instance
29 this.components = [];
30 };
31 /**
32 * destroy the component
33 */
34 Controller.prototype.destroy = function () {
35 this.clear();
36 };
37 /**
38 * get all components
39 * @returns components array
40 */
41 Controller.prototype.getComponents = function () {
42 return this.components;
43 };
44 /**
45 * change visibility of component
46 * @param visible
47 */
48 Controller.prototype.changeVisible = function (visible) {
49 if (this.visible === visible) {
50 return;
51 }
52 this.components.forEach(function (co) {
53 if (visible) {
54 co.component.show();
55 }
56 else {
57 co.component.hide();
58 }
59 });
60 this.visible = visible;
61 };
62 return Controller;
63}());
64exports.Controller = Controller;
65//# sourceMappingURL=base.js.map
\No newline at end of file