UNPKG

4.68 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __extends = (this && this.__extends) || (function () {
9 var extendStatics = Object.setPrototypeOf ||
10 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12 return function (d, b) {
13 extendStatics(d, b);
14 function __() { this.constructor = d; }
15 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16 };
17})();
18var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22 return c > 3 && r && Object.defineProperty(target, key, r), r;
23};
24var __metadata = (this && this.__metadata) || function (k, v) {
25 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
26};
27Object.defineProperty(exports, "__esModule", { value: true });
28var component_1 = require("../../widgets/component");
29var context_1 = require("../../context/context");
30var gridOptionsWrapper_1 = require("../../gridOptionsWrapper");
31var PopupEditorWrapper = (function (_super) {
32 __extends(PopupEditorWrapper, _super);
33 function PopupEditorWrapper(cellEditor) {
34 var _this = _super.call(this, "<div class=\"ag-popup-editor\" tabindex=\"-1\"/>") || this;
35 _this.getGuiCalledOnChild = false;
36 _this.cellEditor = cellEditor;
37 return _this;
38 }
39 PopupEditorWrapper.prototype.onKeyDown = function (event) {
40 this.params.onKeyDown(event);
41 };
42 PopupEditorWrapper.prototype.getGui = function () {
43 // we call getGui() on child here (rather than in the constructor)
44 // as we should wait for 'init' to be called on child first.
45 if (!this.getGuiCalledOnChild) {
46 this.appendChild(this.cellEditor.getGui());
47 this.getGuiCalledOnChild = true;
48 }
49 return _super.prototype.getGui.call(this);
50 };
51 PopupEditorWrapper.prototype.init = function (params) {
52 var _this = this;
53 this.params = params;
54 this.gridOptionsWrapper.setDomData(this.getGui(), PopupEditorWrapper.DOM_KEY_POPUP_EDITOR_WRAPPER, true);
55 this.addDestroyFunc(function () {
56 if (_this.cellEditor.destroy) {
57 _this.cellEditor.destroy();
58 }
59 });
60 this.addDestroyableEventListener(
61 // this needs to be 'super' and not 'this' as if we call 'this',
62 // it ends up called 'getGui()' on the child before 'init' was called,
63 // which is not good
64 _super.prototype.getGui.call(this), 'keydown', this.onKeyDown.bind(this));
65 };
66 PopupEditorWrapper.prototype.afterGuiAttached = function () {
67 if (this.cellEditor.afterGuiAttached) {
68 this.cellEditor.afterGuiAttached();
69 }
70 };
71 PopupEditorWrapper.prototype.getValue = function () {
72 return this.cellEditor.getValue();
73 };
74 PopupEditorWrapper.prototype.isPopup = function () {
75 return true;
76 };
77 PopupEditorWrapper.prototype.isCancelBeforeStart = function () {
78 if (this.cellEditor.isCancelBeforeStart) {
79 return this.cellEditor.isCancelBeforeStart();
80 }
81 };
82 PopupEditorWrapper.prototype.isCancelAfterEnd = function () {
83 if (this.cellEditor.isCancelAfterEnd) {
84 return this.cellEditor.isCancelAfterEnd();
85 }
86 };
87 PopupEditorWrapper.prototype.focusIn = function () {
88 if (this.cellEditor.focusIn) {
89 this.cellEditor.focusIn();
90 }
91 };
92 PopupEditorWrapper.prototype.focusOut = function () {
93 if (this.cellEditor.focusOut) {
94 this.cellEditor.focusOut();
95 }
96 };
97 PopupEditorWrapper.DOM_KEY_POPUP_EDITOR_WRAPPER = 'popupEditorWrapper';
98 __decorate([
99 context_1.Autowired('gridOptionsWrapper'),
100 __metadata("design:type", gridOptionsWrapper_1.GridOptionsWrapper)
101 ], PopupEditorWrapper.prototype, "gridOptionsWrapper", void 0);
102 return PopupEditorWrapper;
103}(component_1.Component));
104exports.PopupEditorWrapper = PopupEditorWrapper;