UNPKG

2.48 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";
8Object.defineProperty(exports, "__esModule", { value: true });
9function QuerySelector(selector) {
10 return querySelectorFunc.bind(this, selector);
11}
12exports.QuerySelector = QuerySelector;
13function RefSelector(ref) {
14 return querySelectorFunc.bind(this, "[ref=" + ref + "]");
15}
16exports.RefSelector = RefSelector;
17function querySelectorFunc(selector, classPrototype, methodOrAttributeName, index) {
18 if (selector === null) {
19 console.error("ag-Grid: QuerySelector selector should not be null");
20 return;
21 }
22 if (typeof index === "number") {
23 console.error("ag-Grid: QuerySelector should be on an attribute");
24 return;
25 }
26 addToObjectProps(classPrototype, 'querySelectors', {
27 attributeName: methodOrAttributeName,
28 querySelector: selector
29 });
30}
31// think we should take this out, put property bindings on the
32function Listener(eventName) {
33 return listenerFunc.bind(this, eventName);
34}
35exports.Listener = Listener;
36function listenerFunc(eventName, target, methodName) {
37 if (eventName === null) {
38 console.error("ag-Grid: EventListener eventName should not be null");
39 return;
40 }
41 addToObjectProps(target, 'listenerMethods', {
42 methodName: methodName,
43 eventName: eventName
44 });
45}
46// think we should take this out, put property bindings on the
47function Method(eventName) {
48 return methodFunc.bind(this, eventName);
49}
50exports.Method = Method;
51function methodFunc(alias, target, methodName) {
52 if (alias === null) {
53 console.error("ag-Grid: EventListener eventName should not be null");
54 return;
55 }
56 addToObjectProps(target, 'methods', {
57 methodName: methodName,
58 alias: alias
59 });
60}
61function addToObjectProps(target, key, value) {
62 // it's an attribute on the class
63 var props = getOrCreateProps(target, target.constructor.name);
64 if (!props[key]) {
65 props[key] = [];
66 }
67 props[key].push(value);
68}
69function getOrCreateProps(target, instanceName) {
70 if (!target.__agComponentMetaData) {
71 target.__agComponentMetaData = {};
72 }
73 if (!target.__agComponentMetaData[instanceName]) {
74 target.__agComponentMetaData[instanceName] = {};
75 }
76 return target.__agComponentMetaData[instanceName];
77}